import RecipeModule from "./recipe/recipeModule"; import NormalisedURLPath from "./normalisedURLPath"; import NormalisedURLDomain from "./normalisedURLDomain"; import { NormalisedRecipeConfig } from "./recipe/recipeModule/types"; import { CookieHandlerInput } from "./cookieHandler/types"; import { WindowHandlerInput } from "./windowHandler/types"; import { DateProviderInput } from "./dateProvider/types"; import type { UserInput as EmailPasswordConfig } from "./recipe/emailpassword/types"; import type { UserInput as EmailVerificationConfig } from "./recipe/emailverification/types"; import type { UserInput as MultitenancyConfig } from "./recipe/multitenancy/types"; import type { UserInput as MultiFactorAuthConfig } from "./recipe/multifactorauth/types"; import type { UserInput as OAuth2ProviderConfig } from "./recipe/oauth2provider/types"; import type { UserInput as PasswordlessConfig } from "./recipe/passwordless/types"; import type { UserInput as SessionConfig } from "./recipe/session/types"; import type { UserInput as ThirdPartyConfig } from "./recipe/thirdparty/types"; import type { UserInput as TotpConfig } from "./recipe/totp/types"; import type { UserInput as WebauthnConfig } from "./recipe/webauthn/types"; /** * The configuration object to be passed when calling SuperTokens.init */ export declare type SuperTokensConfig = { /** * The information specific to your application, this helps the SDK understand * how SuperTokens is setup in your system */ appInfo: AppInfoUserInput; /** * Identifier for the client, such as `web`, `ios`, etc. to be used with thirdparty, multitenancy recipes. */ clientType?: string; /** * List of recipes that you want to use. Refer to the documentation for the recipe * that you want to use to know how this property should be set. */ recipeList: CreateRecipeFunction[]; /** * Custom handlers that the SDK should use when trying to read or write to document.cookie * * In most cases you should not need to provide these. When provided, the SDK will rely on * these functions instead of using document.cookie directly * * When using this feature, take extra care to use the correct function version (async/async). * The interface by default uses async versions of the functions when possible but specific parts * of the SDK may rely on using the sync versions instead. */ cookieHandler?: CookieHandlerInput; /** * Custom handlers that the SDK should use when trying to access Window APIs * * In most cases you should not need to provide these. When provided, the SDK will rely on * these functions instead of using any Window APIs directly * * When using this feature, take extra care to use the correct function version (async/async). * The interface by default uses async versions of the functions when possible but specific parts * of the SDK may rely on using the sync versions instead. */ windowHandler?: WindowHandlerInput; /** * Custom provider for SDK timing calculations relative to server time. * * The default implementation automatically adjusts for client-server time deviation. * * Typically, you won't need to provide these. If provided, the SDK uses * your implementation instead of the default one. */ dateProvider?: DateProviderInput; /** * Enabled logging for the SuperTokens SDK. The SDK will log information in different stages. */ enableDebugLogs?: boolean; /** * * Our experimental features are not yet stable and are subject to change. In practical terms, this means that their interface is subject to change without a major version update. * They are also not tested as much as our "normal" features. * * If you want to use these features, or if you have any feedback please let us know at: * https://supertokens.com/discord * */ experimental?: { plugins?: SuperTokensPlugin[]; }; }; export declare type CreateRecipeFunction = ( appInfo: NormalisedAppInfo, clientType: string | undefined, enableDebugLogs: boolean, overrideMaps: NonNullable[] ) => RecipeModule>; export declare type AppInfoUserInput = { /** * The name of your application */ appName: string; /** * The domain at which you host your backend SDKs. This is used by the SDK when making * network requests. For example if your API server is running on http://localhost:8080 * then when calling SuperTokens.init the value for `apiDomain` should be set to * `http://localhost:8080` * * This value must match the one set in the backend SDKs for SuperTokens to work correctly */ apiDomain: string; /** * The path at which the SuperTokens APIs are exposed by your backend. Defaults to `/auth`. * * This value must match the one set in the backend SDKs for SuperTokens to work correctly */ apiBasePath?: string; /** * An API gateway may be used which prepends a path to the API route. * That path should be specified here. */ apiGatewayPath?: string; }; /** * Normalised version of the config passed to SuperTokens.init */ export declare type NormalisedAppInfo = { /** * The name of your application */ appName: string; /** * The domain at which you host your backend SDKs. This is used by the SDK when making * network requests. For example if your API server is running on http://localhost:8080 * then when calling SuperTokens.init the value for `apiDomain` should be set to * `http://localhost:8080` * * This value must match the one set in the backend SDKs for SuperTokens to work correctly */ apiDomain: NormalisedURLDomain; /** * The path at which the SuperTokens APIs are exposed by your backend. Defaults to `/auth`. * * This value must match the one set in the backend SDKs for SuperTokens to work correctly */ apiBasePath: NormalisedURLPath; }; export declare type User = { id: string; timeJoined: number; isPrimaryUser: boolean; tenantIds: string[]; emails: string[]; phoneNumbers: string[]; thirdParty: { id: string; userId: string; }[]; webauthn?: { credentialIds: string[]; }; loginMethods: { tenantIds: string[]; timeJoined: number; recipeId: "emailpassword" | "thirdparty" | "passwordless" | "webauthn"; recipeUserId: string; verified?: boolean; email?: string; phoneNumber?: string; thirdParty?: { id: string; userId: string; }; }[]; }; export declare type GeneralErrorResponse = { status: "GENERAL_ERROR"; message: string; fetchResponse: Response; }; export declare type AllRecipeConfigs = { emailpassword: EmailPasswordConfig; emailverification: EmailVerificationConfig; multifactorauth: MultiFactorAuthConfig; multitenancy: MultitenancyConfig; oauth2provider: OAuth2ProviderConfig; passwordless: PasswordlessConfig; session: SessionConfig; thirdparty: ThirdPartyConfig; totp: TotpConfig; webauthn: WebauthnConfig; }; export declare type RecipePluginOverride = { functions?: NonNullable["functions"]; config?: (config: AllRecipeConfigs[T]) => AllRecipeConfigs[T]; }; export declare type SuperTokensPlugin = { id: string; version?: string; compatibleWebJSSDKVersions?: string | string[]; dependencies?: ( config: SuperTokensPublicConfig, pluginsAbove: SuperTokensPublicPlugin[], sdkVersion: string ) => | { status: "OK"; pluginsToAdd?: SuperTokensPlugin[]; } | { status: "ERROR"; message: string; }; overrideMap?: { [recipeId in keyof AllRecipeConfigs]?: RecipePluginOverride & { recipeInitRequired?: boolean | ((sdkVersion: string) => boolean); }; }; init?: (config: SuperTokensPublicConfig, plugins: SuperTokensPublicPlugin[], sdkVersion: string) => void; exports?: Record; config?: (config: SuperTokensPublicConfig) => Omit | undefined; }; export declare const nonPublicConfigProperties: readonly ["experimental"]; export declare type NonPublicConfigPropertiesType = (typeof nonPublicConfigProperties)[number]; export declare type SuperTokensPublicPlugin = Pick< SuperTokensPlugin, "id" | "version" | "exports" | "compatibleWebJSSDKVersions" > & { initialized: boolean; }; export declare type SuperTokensConfigWithNormalisedAppInfo = Omit & { appInfo: NormalisedAppInfo; }; export declare type SuperTokensPublicConfig = Omit< Omit, "appInfo" > & { appInfo: NormalisedAppInfo; };