From f851846de9f7d5902204d5abe6d39d906aea8c92 Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Sun, 9 Jun 2024 23:00:29 +0200 Subject: [PATCH 1/9] feat: add boilerplate for OAuth2 recipe --- lib/.eslintrc.js | 5 +- .../oauth2/componentOverrideContext.d.ts | 9 ++ .../themes/resumePageSpinner/index.d.ts | 4 + .../oauth2/components/themes/themeBase.d.ts | 8 ++ .../components/themes/translations.d.ts | 23 ++++ lib/build/recipe/oauth2/index.d.ts | 18 +++ lib/build/recipe/oauth2/prebuiltui.d.ts | 60 ++++++++++ lib/build/recipe/oauth2/recipe.d.ts | 28 +++++ lib/build/recipe/oauth2/types.d.ts | 39 ++++++ lib/build/recipe/oauth2/utils.d.ts | 2 + lib/build/recipe/thirdparty/index.d.ts | 1 - .../oauth2/componentOverrideContext.tsx | 7 ++ .../themes/resumePageSpinner/index.tsx | 45 +++++++ .../oauth2/components/themes/styles.css | 1 + .../oauth2/components/themes/themeBase.tsx | 41 +++++++ .../oauth2/components/themes/translations.ts | 7 ++ lib/ts/recipe/oauth2/index.ts | 33 ++++++ lib/ts/recipe/oauth2/prebuiltui.tsx | 81 +++++++++++++ lib/ts/recipe/oauth2/recipe.ts | 111 ++++++++++++++++++ lib/ts/recipe/oauth2/types.ts | 47 ++++++++ lib/ts/recipe/oauth2/utils.ts | 13 ++ package-lock.json | 10 +- package.json | 2 +- recipe/oauth2/index.d.ts | 17 +++ recipe/oauth2/index.js | 20 ++++ 25 files changed, 623 insertions(+), 9 deletions(-) create mode 100644 lib/build/recipe/oauth2/componentOverrideContext.d.ts create mode 100644 lib/build/recipe/oauth2/components/themes/resumePageSpinner/index.d.ts create mode 100644 lib/build/recipe/oauth2/components/themes/themeBase.d.ts create mode 100644 lib/build/recipe/oauth2/components/themes/translations.d.ts create mode 100644 lib/build/recipe/oauth2/index.d.ts create mode 100644 lib/build/recipe/oauth2/prebuiltui.d.ts create mode 100644 lib/build/recipe/oauth2/recipe.d.ts create mode 100644 lib/build/recipe/oauth2/types.d.ts create mode 100644 lib/build/recipe/oauth2/utils.d.ts create mode 100644 lib/ts/recipe/oauth2/componentOverrideContext.tsx create mode 100644 lib/ts/recipe/oauth2/components/themes/resumePageSpinner/index.tsx create mode 100644 lib/ts/recipe/oauth2/components/themes/styles.css create mode 100644 lib/ts/recipe/oauth2/components/themes/themeBase.tsx create mode 100644 lib/ts/recipe/oauth2/components/themes/translations.ts create mode 100644 lib/ts/recipe/oauth2/index.ts create mode 100644 lib/ts/recipe/oauth2/prebuiltui.tsx create mode 100644 lib/ts/recipe/oauth2/recipe.ts create mode 100644 lib/ts/recipe/oauth2/types.ts create mode 100644 lib/ts/recipe/oauth2/utils.ts create mode 100644 recipe/oauth2/index.d.ts create mode 100644 recipe/oauth2/index.js diff --git a/lib/.eslintrc.js b/lib/.eslintrc.js index d7cb8d283..5f2f77fba 100644 --- a/lib/.eslintrc.js +++ b/lib/.eslintrc.js @@ -60,7 +60,10 @@ module.exports = { ], "@typescript-eslint/naming-convention": "off", "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-unused-vars": [2, { vars: "all", args: "all", varsIgnorePattern: "^React$|^jsx$" }], + "@typescript-eslint/no-unused-vars": [ + 2, + { vars: "all", args: "all", varsIgnorePattern: "^React$|^jsx$", argsIgnorePattern: "^_" }, + ], "@typescript-eslint/prefer-namespace-keyword": "error", "@typescript-eslint/quotes": ["error", "double"], "@typescript-eslint/semi": ["error", "always"], diff --git a/lib/build/recipe/oauth2/componentOverrideContext.d.ts b/lib/build/recipe/oauth2/componentOverrideContext.d.ts new file mode 100644 index 000000000..288fc18e7 --- /dev/null +++ b/lib/build/recipe/oauth2/componentOverrideContext.d.ts @@ -0,0 +1,9 @@ +/// +import type { ComponentOverrideMap } from "./types"; +declare const useContext: () => ComponentOverrideMap, + Provider: import("react").FC< + import("react").PropsWithChildren<{ + components: ComponentOverrideMap; + }> + >; +export { useContext as useRecipeComponentOverrideContext, Provider as RecipeComponentsOverrideContextProvider }; diff --git a/lib/build/recipe/oauth2/components/themes/resumePageSpinner/index.d.ts b/lib/build/recipe/oauth2/components/themes/resumePageSpinner/index.d.ts new file mode 100644 index 000000000..f619535eb --- /dev/null +++ b/lib/build/recipe/oauth2/components/themes/resumePageSpinner/index.d.ts @@ -0,0 +1,4 @@ +import type { NormalisedConfig } from "../../../types"; +export declare const ResumePageSpinner: (props: { + config: NormalisedConfig; +}) => import("react/jsx-runtime").JSX.Element; diff --git a/lib/build/recipe/oauth2/components/themes/themeBase.d.ts b/lib/build/recipe/oauth2/components/themes/themeBase.d.ts new file mode 100644 index 000000000..f95129fbf --- /dev/null +++ b/lib/build/recipe/oauth2/components/themes/themeBase.d.ts @@ -0,0 +1,8 @@ +import React from "react"; +import type { PropsWithChildren } from "react"; +export declare const ThemeBase: React.FC< + PropsWithChildren<{ + loadDefaultFont: boolean; + userStyles: Array; + }> +>; diff --git a/lib/build/recipe/oauth2/components/themes/translations.d.ts b/lib/build/recipe/oauth2/components/themes/translations.d.ts new file mode 100644 index 000000000..fdc937dc1 --- /dev/null +++ b/lib/build/recipe/oauth2/components/themes/translations.d.ts @@ -0,0 +1,23 @@ +export declare const defaultTranslationsOAuth2: { + en: { + AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; + AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; + AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; + AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; + AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_START: string; + AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_SIGN_IN_LINK: string; + AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_END: string; + AUTH_PAGE_FOOTER_START: string; + AUTH_PAGE_FOOTER_TOS: string; + AUTH_PAGE_FOOTER_AND: string; + AUTH_PAGE_FOOTER_PP: string; + AUTH_PAGE_FOOTER_END: string; + DIVIDER_OR: string; + BRANDING_POWERED_BY_START: string; + BRANDING_POWERED_BY_END: string; + SOMETHING_WENT_WRONG_ERROR: string; + SOMETHING_WENT_WRONG_ERROR_RELOAD: string; + }; +}; diff --git a/lib/build/recipe/oauth2/index.d.ts b/lib/build/recipe/oauth2/index.d.ts new file mode 100644 index 000000000..f0696f114 --- /dev/null +++ b/lib/build/recipe/oauth2/index.d.ts @@ -0,0 +1,18 @@ +/// +import { UserInput } from "./types"; +import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2"; +export default class Wrapper { + static init(config?: UserInput): import("../../types").RecipeInitResult; + static ComponentsOverrideProvider: import("react").FC< + import("react").PropsWithChildren<{ + components: import("./types").ComponentOverrideMap; + }> + >; +} +declare const init: typeof Wrapper.init; +declare const MultitenancyComponentsOverrideProvider: import("react").FC< + import("react").PropsWithChildren<{ + components: import("./types").ComponentOverrideMap; + }> +>; +export { init, UserInput, RecipeInterface, MultitenancyComponentsOverrideProvider }; diff --git a/lib/build/recipe/oauth2/prebuiltui.d.ts b/lib/build/recipe/oauth2/prebuiltui.d.ts new file mode 100644 index 000000000..53239a833 --- /dev/null +++ b/lib/build/recipe/oauth2/prebuiltui.d.ts @@ -0,0 +1,60 @@ +/// +import { RecipeRouter } from "../recipeRouter"; +import { ResumePageSpinner } from "./components/themes/resumePageSpinner"; +import OAuth2 from "./recipe"; +import type { GenericComponentOverrideMap } from "../../components/componentOverride/componentOverrideContext"; +import type { RecipeFeatureComponentMap, FeatureBaseProps, UserContext } from "../../types"; +import type { AuthComponent } from "../../types"; +export declare class OAuth2PreBuiltUI extends RecipeRouter { + readonly recipeInstance: OAuth2; + static instance?: OAuth2PreBuiltUI; + languageTranslations: { + en: { + AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; + AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; + AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; + AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; + AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_START: string; + AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_SIGN_IN_LINK: string; + AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_END: string; + AUTH_PAGE_FOOTER_START: string; + AUTH_PAGE_FOOTER_TOS: string; + AUTH_PAGE_FOOTER_AND: string; + AUTH_PAGE_FOOTER_PP: string; + AUTH_PAGE_FOOTER_END: string; + DIVIDER_OR: string; + BRANDING_POWERED_BY_START: string; + BRANDING_POWERED_BY_END: string; + SOMETHING_WENT_WRONG_ERROR: string; + SOMETHING_WENT_WRONG_ERROR_RELOAD: string; + }; + }; + constructor(recipeInstance: OAuth2); + static getInstanceOrInitAndGetInstance(): OAuth2PreBuiltUI; + static getFeatures(useComponentOverrides?: () => GenericComponentOverrideMap): RecipeFeatureComponentMap; + static getFeatureComponent( + componentName: never, + props: FeatureBaseProps<{ + redirectOnSessionExists?: boolean; + userContext?: UserContext; + }>, + useComponentOverrides?: () => GenericComponentOverrideMap + ): JSX.Element; + getFeatures: (_useComponentOverrides?: () => GenericComponentOverrideMap) => RecipeFeatureComponentMap; + getFeatureComponent: ( + _componentName: never, + _props: FeatureBaseProps<{ + redirectOnSessionExists?: boolean; + userContext?: UserContext; + }>, + _useComponentOverrides?: () => GenericComponentOverrideMap + ) => JSX.Element; + getAuthComponents(): AuthComponent[]; + static reset(): void; + static ResumePageSpinnerTheme: (props: { + config: import("./types").NormalisedConfig; + }) => import("react/jsx-runtime").JSX.Element; +} +export { ResumePageSpinner as ResumePageSpinnerTheme }; diff --git a/lib/build/recipe/oauth2/recipe.d.ts b/lib/build/recipe/oauth2/recipe.d.ts new file mode 100644 index 000000000..e8d1f1c8f --- /dev/null +++ b/lib/build/recipe/oauth2/recipe.d.ts @@ -0,0 +1,28 @@ +import OAuth2WebJS from "supertokens-web-js/recipe/oauth2"; +import RecipeModule from "../recipeModule"; +import type { + GetRedirectionURLContext, + NormalisedConfig, + OnHandleEventContext, + PreAndPostAPIHookAction, + UserInput, +} from "./types"; +import type { RecipeInitResult, NormalisedConfigWithAppInfoAndRecipeID, WebJSRecipeInterface } from "../../types"; +export default class OAuth2 extends RecipeModule< + GetRedirectionURLContext, + PreAndPostAPIHookAction, + OnHandleEventContext, + NormalisedConfig +> { + readonly webJSRecipe: WebJSRecipeInterface; + static instance?: OAuth2; + static readonly RECIPE_ID = "multitenancy"; + readonly recipeID = "multitenancy"; + constructor( + config: NormalisedConfigWithAppInfoAndRecipeID, + webJSRecipe?: WebJSRecipeInterface + ); + static init(config?: UserInput): RecipeInitResult; + static getInstanceOrThrow(): OAuth2; + static reset(): void; +} diff --git a/lib/build/recipe/oauth2/types.d.ts b/lib/build/recipe/oauth2/types.d.ts new file mode 100644 index 000000000..ca4b29abc --- /dev/null +++ b/lib/build/recipe/oauth2/types.d.ts @@ -0,0 +1,39 @@ +import type { ComponentOverride } from "../../components/componentOverride/componentOverride"; +import type { UserContext } from "../../types"; +import type { + UserInput as RecipeModuleUserInput, + NormalisedConfig as NormalisedRecipeModuleConfig, +} from "../recipeModule/types"; +import type OverrideableBuilder from "supertokens-js-override"; +import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2/types"; +export declare type PreAndPostAPIHookAction = never; +export declare type UserInput = { + override?: { + functions?: ( + originalImplementation: RecipeInterface, + builder: OverrideableBuilder + ) => RecipeInterface; + }; +} & RecipeModuleUserInput; +export declare type NormalisedConfig = NormalisedRecipeModuleConfig< + GetRedirectionURLContext, + PreAndPostAPIHookAction, + OnHandleEventContext +> & { + override: { + functions?: ( + originalImplementation: RecipeInterface, + builder: OverrideableBuilder + ) => RecipeInterface; + }; +}; +export declare type ComponentOverrideMap = { + ResumePageSpinner: ComponentOverride; +}; +export declare type GetRedirectionURLContext = { + action: "RESUME"; +}; +export declare type OnHandleEventContext = { + action: "RESUMER"; + userContext: UserContext; +}; diff --git a/lib/build/recipe/oauth2/utils.d.ts b/lib/build/recipe/oauth2/utils.d.ts new file mode 100644 index 000000000..1fbfafdf5 --- /dev/null +++ b/lib/build/recipe/oauth2/utils.d.ts @@ -0,0 +1,2 @@ +import type { UserInput, NormalisedConfig } from "./types"; +export declare function normaliseOAuth2Config(config?: UserInput): NormalisedConfig; diff --git a/lib/build/recipe/thirdparty/index.d.ts b/lib/build/recipe/thirdparty/index.d.ts index 4654d4ad8..6b8fb2194 100644 --- a/lib/build/recipe/thirdparty/index.d.ts +++ b/lib/build/recipe/thirdparty/index.d.ts @@ -22,7 +22,6 @@ export default class Wrapper { never, import("./types").PreAndPostAPIHookAction, { - rid: "thirdparty"; action: "SUCCESS"; isNewRecipeUser: boolean; createdNewSession: boolean; diff --git a/lib/ts/recipe/oauth2/componentOverrideContext.tsx b/lib/ts/recipe/oauth2/componentOverrideContext.tsx new file mode 100644 index 000000000..467bd5485 --- /dev/null +++ b/lib/ts/recipe/oauth2/componentOverrideContext.tsx @@ -0,0 +1,7 @@ +import { createGenericComponentsOverrideContext } from "../../components/componentOverride/genericComponentOverrideContext"; + +import type { ComponentOverrideMap } from "./types"; + +const [useContext, Provider] = createGenericComponentsOverrideContext(); + +export { useContext as useRecipeComponentOverrideContext, Provider as RecipeComponentsOverrideContextProvider }; diff --git a/lib/ts/recipe/oauth2/components/themes/resumePageSpinner/index.tsx b/lib/ts/recipe/oauth2/components/themes/resumePageSpinner/index.tsx new file mode 100644 index 000000000..8c51c8cab --- /dev/null +++ b/lib/ts/recipe/oauth2/components/themes/resumePageSpinner/index.tsx @@ -0,0 +1,45 @@ +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +import SpinnerIcon from "../../../../../components/assets/spinnerIcon"; +import { withOverride } from "../../../../../components/componentOverride/withOverride"; +import SuperTokens from "../../../../../superTokens"; +import { ThemeBase } from "../themeBase"; + +import type { NormalisedConfig } from "../../../types"; + +// TODO: This is just a placeholder to make the pre-commit script happy. I'm not sure we'll need this. +const OAuth2ResumePageSpinner: React.FC = () => { + return ( +
+
+
+ +
+
+
+ ); +}; + +const ResumePageSpinnerWithOverride = withOverride("OAuth2ResumePageSpinner", OAuth2ResumePageSpinner); + +export const ResumePageSpinner = (props: { config: NormalisedConfig }) => { + const rootStyle = SuperTokens.getInstanceOrThrow().rootStyle; + + return ( + + + + ); +}; diff --git a/lib/ts/recipe/oauth2/components/themes/styles.css b/lib/ts/recipe/oauth2/components/themes/styles.css new file mode 100644 index 000000000..48b21284b --- /dev/null +++ b/lib/ts/recipe/oauth2/components/themes/styles.css @@ -0,0 +1 @@ +@import "../../../../styles/styles.css"; diff --git a/lib/ts/recipe/oauth2/components/themes/themeBase.tsx b/lib/ts/recipe/oauth2/components/themes/themeBase.tsx new file mode 100644 index 000000000..4dc8cad23 --- /dev/null +++ b/lib/ts/recipe/oauth2/components/themes/themeBase.tsx @@ -0,0 +1,41 @@ +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +import React from "react"; +import { Fragment } from "react"; + +import styles from "./styles.css"; + +import type { PropsWithChildren } from "react"; + +export const ThemeBase: React.FC< + PropsWithChildren<{ loadDefaultFont: boolean; userStyles: Array }> +> = ({ children, userStyles, loadDefaultFont }) => { + return ( + + {children} + {loadDefaultFont && ( + + )} + + + ); +}; diff --git a/lib/ts/recipe/oauth2/components/themes/translations.ts b/lib/ts/recipe/oauth2/components/themes/translations.ts new file mode 100644 index 000000000..6f7b1f5d1 --- /dev/null +++ b/lib/ts/recipe/oauth2/components/themes/translations.ts @@ -0,0 +1,7 @@ +import { defaultTranslationsCommon } from "../../../../translation/translations"; + +export const defaultTranslationsOAuth2 = { + en: { + ...defaultTranslationsCommon.en, + }, +}; diff --git a/lib/ts/recipe/oauth2/index.ts b/lib/ts/recipe/oauth2/index.ts new file mode 100644 index 000000000..5b041af00 --- /dev/null +++ b/lib/ts/recipe/oauth2/index.ts @@ -0,0 +1,33 @@ +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +import { RecipeComponentsOverrideContextProvider } from "./componentOverrideContext"; +import OAuth2 from "./recipe"; +import { UserInput } from "./types"; + +import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2"; + +export default class Wrapper { + static init(config?: UserInput) { + return OAuth2.init(config); + } + + static ComponentsOverrideProvider = RecipeComponentsOverrideContextProvider; +} + +const init = Wrapper.init; +const MultitenancyComponentsOverrideProvider = Wrapper.ComponentsOverrideProvider; + +export { init, UserInput, RecipeInterface, MultitenancyComponentsOverrideProvider }; diff --git a/lib/ts/recipe/oauth2/prebuiltui.tsx b/lib/ts/recipe/oauth2/prebuiltui.tsx new file mode 100644 index 000000000..95d111c2e --- /dev/null +++ b/lib/ts/recipe/oauth2/prebuiltui.tsx @@ -0,0 +1,81 @@ +import { isTest } from "../../utils"; +import { RecipeRouter } from "../recipeRouter"; + +import { useRecipeComponentOverrideContext } from "./componentOverrideContext"; +import { ResumePageSpinner } from "./components/themes/resumePageSpinner"; +import { defaultTranslationsOAuth2 } from "./components/themes/translations"; +import OAuth2 from "./recipe"; + +import type { GenericComponentOverrideMap } from "../../components/componentOverride/componentOverrideContext"; +import type { RecipeFeatureComponentMap, FeatureBaseProps, UserContext } from "../../types"; +import type { AuthComponent } from "../../types"; + +export class OAuth2PreBuiltUI extends RecipeRouter { + static instance?: OAuth2PreBuiltUI; + + languageTranslations = defaultTranslationsOAuth2; + + constructor(public readonly recipeInstance: OAuth2) { + super(); + } + + // Static methods + static getInstanceOrInitAndGetInstance(): OAuth2PreBuiltUI { + if (OAuth2PreBuiltUI.instance === undefined) { + const recipeInstance = OAuth2.getInstanceOrThrow(); + OAuth2PreBuiltUI.instance = new OAuth2PreBuiltUI(recipeInstance); + } + + return OAuth2PreBuiltUI.instance; + } + static getFeatures( + useComponentOverrides: () => GenericComponentOverrideMap = useRecipeComponentOverrideContext + ): RecipeFeatureComponentMap { + return OAuth2PreBuiltUI.getInstanceOrInitAndGetInstance().getFeatures(useComponentOverrides); + } + static getFeatureComponent( + componentName: never, + props: FeatureBaseProps<{ redirectOnSessionExists?: boolean; userContext?: UserContext }>, + useComponentOverrides: () => GenericComponentOverrideMap = useRecipeComponentOverrideContext + ): JSX.Element { + return OAuth2PreBuiltUI.getInstanceOrInitAndGetInstance().getFeatureComponent( + componentName, + props, + useComponentOverrides + ); + } + + // Instance methods + getFeatures = ( + _useComponentOverrides: () => GenericComponentOverrideMap = useRecipeComponentOverrideContext + ): RecipeFeatureComponentMap => { + const features: RecipeFeatureComponentMap = {}; + + return features; + }; + getFeatureComponent = ( + _componentName: never, + _props: FeatureBaseProps<{ redirectOnSessionExists?: boolean; userContext?: UserContext }>, + _useComponentOverrides: () => GenericComponentOverrideMap = useRecipeComponentOverrideContext + ): JSX.Element => { + throw new Error("Not implemented."); + }; + + getAuthComponents(): AuthComponent[] { + return []; + } + + // For tests + static reset(): void { + if (!isTest()) { + return; + } + + OAuth2PreBuiltUI.instance = undefined; + return; + } + + static ResumePageSpinnerTheme = ResumePageSpinner; +} + +export { ResumePageSpinner as ResumePageSpinnerTheme }; diff --git a/lib/ts/recipe/oauth2/recipe.ts b/lib/ts/recipe/oauth2/recipe.ts new file mode 100644 index 000000000..0854dedfa --- /dev/null +++ b/lib/ts/recipe/oauth2/recipe.ts @@ -0,0 +1,111 @@ +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +/* + * Imports. + */ + +import OAuth2WebJS from "supertokens-web-js/recipe/oauth2"; + +import { SSR_ERROR } from "../../constants"; +import { isTest } from "../../utils"; +import RecipeModule from "../recipeModule"; + +import { normaliseOAuth2Config } from "./utils"; + +import type { + GetRedirectionURLContext, + NormalisedConfig, + OnHandleEventContext, + PreAndPostAPIHookAction, + UserInput, +} from "./types"; +import type { RecipeInitResult, NormalisedConfigWithAppInfoAndRecipeID, WebJSRecipeInterface } from "../../types"; +import type { NormalisedAppInfo } from "../../types"; + +/* + * Class. + */ +export default class OAuth2 extends RecipeModule< + GetRedirectionURLContext, + PreAndPostAPIHookAction, + OnHandleEventContext, + NormalisedConfig +> { + static instance?: OAuth2; + static readonly RECIPE_ID = "multitenancy"; + + public readonly recipeID = OAuth2.RECIPE_ID; + + constructor( + config: NormalisedConfigWithAppInfoAndRecipeID, + public readonly webJSRecipe: WebJSRecipeInterface = OAuth2WebJS + ) { + super(config); + } + + static init(config?: UserInput): RecipeInitResult { + const normalisedConfig = normaliseOAuth2Config(config); + return { + recipeID: OAuth2.RECIPE_ID, + authReact: ( + appInfo: NormalisedAppInfo + ): RecipeModule< + GetRedirectionURLContext, + PreAndPostAPIHookAction, + OnHandleEventContext, + NormalisedConfig + > => { + OAuth2.instance = new OAuth2({ + ...normalisedConfig, + appInfo, + recipeId: OAuth2.RECIPE_ID, + }); + return OAuth2.instance; + }, + webJS: OAuth2WebJS.init({ + ...normalisedConfig, + }), + }; + } + + static getInstanceOrThrow(): OAuth2 { + if (OAuth2.instance === undefined) { + let error = + "No instance of OAuth2 found. Make sure to call the OAuth2.init method." + + "See https://supertokens.io/docs/oauth2/quick-setup/frontend"; + + // eslint-disable-next-line supertokens-auth-react/no-direct-window-object + if (typeof window === "undefined") { + error = error + SSR_ERROR; + } + throw Error(error); + } + + return OAuth2.instance; + } + + /* + * Tests methods. + */ + static reset(): void { + if (!isTest()) { + return; + } + + OAuth2.instance = undefined; + return; + } +} diff --git a/lib/ts/recipe/oauth2/types.ts b/lib/ts/recipe/oauth2/types.ts new file mode 100644 index 000000000..dd10e8cd7 --- /dev/null +++ b/lib/ts/recipe/oauth2/types.ts @@ -0,0 +1,47 @@ +import type { ComponentOverride } from "../../components/componentOverride/componentOverride"; +import type { UserContext } from "../../types"; +import type { + UserInput as RecipeModuleUserInput, + NormalisedConfig as NormalisedRecipeModuleConfig, +} from "../recipeModule/types"; +import type OverrideableBuilder from "supertokens-js-override"; +import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2/types"; + +export type PreAndPostAPIHookAction = never; + +export type UserInput = { + override?: { + functions?: ( + originalImplementation: RecipeInterface, + builder: OverrideableBuilder + ) => RecipeInterface; + }; +} & RecipeModuleUserInput; + +export type NormalisedConfig = NormalisedRecipeModuleConfig< + GetRedirectionURLContext, + PreAndPostAPIHookAction, + OnHandleEventContext +> & { + override: { + functions?: ( + originalImplementation: RecipeInterface, + builder: OverrideableBuilder + ) => RecipeInterface; + }; +}; + +export type ComponentOverrideMap = { + ResumePageSpinner: ComponentOverride; // TODO: proper component list. this is a just placeholder to the typechecker happy +}; + +export type GetRedirectionURLContext = { + // TODO: proper list + action: "RESUME"; +}; + +export type OnHandleEventContext = { + // TODO: proper list + action: "RESUMER"; + userContext: UserContext; +}; diff --git a/lib/ts/recipe/oauth2/utils.ts b/lib/ts/recipe/oauth2/utils.ts new file mode 100644 index 000000000..5302c9c4b --- /dev/null +++ b/lib/ts/recipe/oauth2/utils.ts @@ -0,0 +1,13 @@ +import { normaliseRecipeModuleConfig } from "../recipeModule/utils"; + +import type { UserInput, NormalisedConfig } from "./types"; + +export function normaliseOAuth2Config(config?: UserInput): NormalisedConfig { + return { + ...normaliseRecipeModuleConfig(config), + override: { + functions: (originalImplementation) => originalImplementation, + ...config?.override, + }, + }; +} diff --git a/package-lock.json b/package-lock.json index 9b58dc987..b2f93887a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -103,7 +103,7 @@ "peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0", - "supertokens-web-js": "^0.12.0" + "supertokens-web-js": "github:supertokens/supertokens-web-js#feat/oauth2/base" } }, "eslint": { @@ -23890,8 +23890,7 @@ }, "node_modules/supertokens-web-js": { "version": "0.12.0", - "resolved": "https://registry.npmjs.org/supertokens-web-js/-/supertokens-web-js-0.12.0.tgz", - "integrity": "sha512-QQGp2TuikT29AuzAa+M0PvwNG8qZBUs3fuJzaD45G70HxD3Or5Yrz9gkhAH1BNQF9xIFIyLnTxxb+vU3HBGa0w==", + "resolved": "git+ssh://git@github.com/supertokens/supertokens-web-js.git#e39849ab165916ad948755d25d1347098019fbf5", "peer": true, "dependencies": { "supertokens-js-override": "0.0.4", @@ -43370,9 +43369,8 @@ "integrity": "sha512-r0JFBjkMIdep3Lbk3JA+MpnpuOtw4RSyrlRAbrzMcxwiYco3GFWl/daimQZ5b1forOiUODpOlXbSOljP/oyurg==" }, "supertokens-web-js": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/supertokens-web-js/-/supertokens-web-js-0.12.0.tgz", - "integrity": "sha512-QQGp2TuikT29AuzAa+M0PvwNG8qZBUs3fuJzaD45G70HxD3Or5Yrz9gkhAH1BNQF9xIFIyLnTxxb+vU3HBGa0w==", + "version": "git+ssh://git@github.com/supertokens/supertokens-web-js.git#e39849ab165916ad948755d25d1347098019fbf5", + "from": "supertokens-web-js@github:supertokens/supertokens-web-js#feat/oauth2/base", "peer": true, "requires": { "supertokens-js-override": "0.0.4", diff --git a/package.json b/package.json index 2520998f4..6fe6dd23c 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0", - "supertokens-web-js": "^0.12.0" + "supertokens-web-js": "github:supertokens/supertokens-web-js#feat/oauth2/base" }, "scripts": { "init": "bash ./init.sh", diff --git a/recipe/oauth2/index.d.ts b/recipe/oauth2/index.d.ts new file mode 100644 index 000000000..c2f68c17f --- /dev/null +++ b/recipe/oauth2/index.d.ts @@ -0,0 +1,17 @@ +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +export * from "../../lib/build/recipe/oauth2"; +import * as _default from "../../lib/build/recipe/oauth2"; +export default _default; diff --git a/recipe/oauth2/index.js b/recipe/oauth2/index.js new file mode 100644 index 000000000..143b09f75 --- /dev/null +++ b/recipe/oauth2/index.js @@ -0,0 +1,20 @@ +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +exports.__esModule = true; +__export(require("../../lib/build/oauth2")); From d19e638e84d7c42469ee11de536e45a92243b951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mih=C3=A1ly=20Lengyel?= Date: Sun, 7 Jul 2024 23:06:41 +0200 Subject: [PATCH 2/9] feat!: add initial impl for OAuth2 (#833) * feat: add initial impl of OAuth2 recipe * build: add missing bundle conf * fix: wrong recipe id * feat: clean up todos * feat: make use of getLoginChallengeInfo * fix: self-review fixes --- hooks/pre-commit.sh | 2 +- lib/build/arrowLeftIcon.js | 4 +- lib/build/authCompWrapper.js | 4 +- lib/build/authRecipe-shared.js | 6 +- lib/build/authRecipe-shared2.js | 20 +- lib/build/emailLargeIcon.js | 6 +- lib/build/emailpassword-shared.js | 4 +- lib/build/emailpassword-shared3.js | 136 +- lib/build/emailpassword-shared5.js | 94 +- lib/build/emailpassword.js | 55 +- lib/build/emailpasswordprebuiltui.js | 513 +++--- lib/build/emailverification-shared.js | 109 +- lib/build/emailverification-shared2.js | 41 +- lib/build/emailverification.js | 31 +- lib/build/emailverificationprebuiltui.js | 300 ++-- lib/build/genericComponentOverrideContext.js | 1449 +--------------- lib/build/index.js | 5 +- lib/build/index2.js | 564 ++++--- lib/build/multifactorauth-shared.js | 169 +- lib/build/multifactorauth-shared2.js | 266 ++- lib/build/multifactorauth.js | 9 +- lib/build/multifactorauthprebuiltui.js | 131 +- lib/build/multitenancy.js | 9 +- lib/build/oauth2-shared.js | 117 ++ lib/build/oauth2.js | 61 + lib/build/passwordless-shared.js | 118 +- lib/build/passwordless.js | 83 +- lib/build/passwordlessprebuiltui.js | 1097 ++++++------- .../theme/authPage/authPageHeader.d.ts | 1 + lib/build/recipe/authRecipe/types.d.ts | 16 +- .../components/features/signin/index.d.ts | 2 + .../components/features/signup/index.d.ts | 2 + .../components/themes/translations.d.ts | 1 + .../recipe/emailpassword/prebuiltui.d.ts | 1 + lib/build/recipe/emailpassword/recipe.d.ts | 4 +- .../components/themes/translations.d.ts | 1 + .../recipe/emailverification/prebuiltui.d.ts | 1 + .../components/themes/translations.d.ts | 1 + .../recipe/multifactorauth/prebuiltui.d.ts | 1 + .../oauth2/componentOverrideContext.d.ts | 9 - .../themes/resumePageSpinner/index.d.ts | 4 - .../oauth2/components/themes/themeBase.d.ts | 8 - .../components/themes/translations.d.ts | 23 - lib/build/recipe/oauth2/index.d.ts | 47 +- lib/build/recipe/oauth2/prebuiltui.d.ts | 60 - lib/build/recipe/oauth2/recipe.d.ts | 13 +- lib/build/recipe/oauth2/types.d.ts | 23 +- .../features/signInAndUp/index.d.ts | 2 + .../features/signInAndUpEPCombo/index.d.ts | 2 + .../features/userInputCode/index.d.ts | 2 + .../components/themes/translations.d.ts | 1 + lib/build/recipe/passwordless/prebuiltui.d.ts | 1 + .../components/themes/translations.d.ts | 1 + lib/build/recipe/session/prebuiltui.d.ts | 1 + lib/build/recipe/session/recipe.d.ts | 5 +- .../features/signInAndUp/index.d.ts | 2 + .../components/themes/translations.d.ts | 1 + lib/build/recipe/thirdparty/prebuiltui.d.ts | 1 + lib/build/recipe/thirdparty/types.d.ts | 1 + .../totp/components/themes/translations.d.ts | 1 + lib/build/recipe/totp/prebuiltui.d.ts | 1 + lib/build/recipeModule-shared.js | 35 +- lib/build/session.js | 93 +- lib/build/sessionprebuiltui.js | 61 +- lib/build/superTokens.js | 1450 +++++++++++++++++ lib/build/thirdparty-shared.js | 274 ++-- lib/build/thirdparty.js | 37 +- lib/build/thirdpartyprebuiltui.js | 204 ++- lib/build/totp-shared.js | 92 +- lib/build/totp.js | 25 +- lib/build/totpprebuiltui.js | 300 ++-- lib/build/translation/translations.d.ts | 1 + lib/build/translationContext.js | 12 +- lib/build/types.d.ts | 15 +- lib/build/ui-entry.js | 5 +- lib/build/ui/index.d.ts | 1 + .../components/feature/authPage/authPage.tsx | 81 +- .../theme/authPage/authPageHeader.tsx | 3 + .../components/theme/authPage/index.tsx | 1 + lib/ts/recipe/authRecipe/types.ts | 16 +- .../components/features/signin/index.tsx | 35 +- .../components/features/signup/index.tsx | 34 +- lib/ts/recipe/emailpassword/recipe.tsx | 3 +- .../oauth2/componentOverrideContext.tsx | 7 - .../themes/resumePageSpinner/index.tsx | 45 - .../oauth2/components/themes/styles.css | 1 - .../oauth2/components/themes/themeBase.tsx | 41 - .../oauth2/components/themes/translations.ts | 7 - lib/ts/recipe/oauth2/index.ts | 44 +- lib/ts/recipe/oauth2/prebuiltui.tsx | 81 - lib/ts/recipe/oauth2/recipe.ts | 26 +- lib/ts/recipe/oauth2/types.ts | 27 +- .../components/features/signInAndUp/index.tsx | 33 +- .../features/signInAndUpEPCombo/index.tsx | 33 +- .../features/userInputCode/index.tsx | 35 +- lib/ts/recipe/session/recipe.tsx | 23 +- .../components/features/signInAndUp/index.tsx | 4 + .../features/signInAndUpCallback/index.tsx | 35 +- lib/ts/recipe/thirdparty/functionOverrides.ts | 4 +- lib/ts/recipe/thirdparty/types.ts | 1 + lib/ts/translation/translations.ts | 1 + lib/ts/types.ts | 16 +- rollup.config.mjs | 1 + test/prepTestApp.sh | 11 +- 104 files changed, 4359 insertions(+), 4538 deletions(-) create mode 100644 lib/build/oauth2-shared.js create mode 100644 lib/build/oauth2.js delete mode 100644 lib/build/recipe/oauth2/componentOverrideContext.d.ts delete mode 100644 lib/build/recipe/oauth2/components/themes/resumePageSpinner/index.d.ts delete mode 100644 lib/build/recipe/oauth2/components/themes/themeBase.d.ts delete mode 100644 lib/build/recipe/oauth2/components/themes/translations.d.ts delete mode 100644 lib/build/recipe/oauth2/prebuiltui.d.ts create mode 100644 lib/build/superTokens.js delete mode 100644 lib/ts/recipe/oauth2/componentOverrideContext.tsx delete mode 100644 lib/ts/recipe/oauth2/components/themes/resumePageSpinner/index.tsx delete mode 100644 lib/ts/recipe/oauth2/components/themes/styles.css delete mode 100644 lib/ts/recipe/oauth2/components/themes/themeBase.tsx delete mode 100644 lib/ts/recipe/oauth2/components/themes/translations.ts delete mode 100644 lib/ts/recipe/oauth2/prebuiltui.tsx diff --git a/hooks/pre-commit.sh b/hooks/pre-commit.sh index 68e81428d..c78117c0a 100755 --- a/hooks/pre-commit.sh +++ b/hooks/pre-commit.sh @@ -34,7 +34,7 @@ else fi npm run check-circular-dependencies -circDep=$? +circDep=$? echo "$(tput setaf 3)* No circular dependencies?$(tput sgr 0)" diff --git a/lib/build/arrowLeftIcon.js b/lib/build/arrowLeftIcon.js index 0c1efe594..96e4ef41b 100644 --- a/lib/build/arrowLeftIcon.js +++ b/lib/build/arrowLeftIcon.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var jsxRuntime = require("react/jsx-runtime"); /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. @@ -27,7 +27,7 @@ function ArrowLeftIcon(_a) { var color = _a.color; return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "11.272", diff --git a/lib/build/authCompWrapper.js b/lib/build/authCompWrapper.js index ae3e8d5ec..7a112772e 100644 --- a/lib/build/authCompWrapper.js +++ b/lib/build/authCompWrapper.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var jsxRuntime = require("react/jsx-runtime"); var uiEntry = require("./index2.js"); @@ -9,7 +9,7 @@ function AuthComponentWrapper(_a) { recipeComponentOverrides = _a.recipeComponentOverrides; return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - genericComponentOverrideContext.__assign({ value: recipeComponentOverrides }, { children: children }) + superTokens.__assign({ value: recipeComponentOverrides }, { children: children }) ); } diff --git a/lib/build/authRecipe-shared.js b/lib/build/authRecipe-shared.js index a49f45a02..a1f7e7efb 100644 --- a/lib/build/authRecipe-shared.js +++ b/lib/build/authRecipe-shared.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. * @@ -17,7 +17,7 @@ var genericComponentOverrideContext = require("./genericComponentOverrideContext * under the License. */ function normaliseAuthRecipe(config) { - return genericComponentOverrideContext.normaliseRecipeModuleConfig(config); + return superTokens.normaliseRecipeModuleConfig(config); } function selectComponentsToCoverAllFirstFactors(comps, firstFactorIds) { if (firstFactorIds.length === 0) { @@ -45,7 +45,7 @@ function selectComponentsToCoverAllFirstFactors(comps, firstFactorIds) { if (componentsLeft.length !== 0) { var nextComps = selectComponentsToCoverAllFirstFactors(componentsLeft, factorIdsLeft); if (nextComps !== undefined) { - return { value: genericComponentOverrideContext.__spreadArray([c], nextComps, true) }; + return { value: superTokens.__spreadArray([c], nextComps, true) }; } } }; diff --git a/lib/build/authRecipe-shared2.js b/lib/build/authRecipe-shared2.js index 6ac9fc7cf..119ec2461 100644 --- a/lib/build/authRecipe-shared2.js +++ b/lib/build/authRecipe-shared2.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var index = require("./recipeModule-shared.js"); var types = require("./multifactorauth-shared.js"); @@ -19,26 +19,26 @@ var types = require("./multifactorauth-shared.js"); * under the License. */ var AuthRecipe = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(AuthRecipe, _super); + superTokens.__extends(AuthRecipe, _super); function AuthRecipe() { var _this = (_super !== null && _super.apply(this, arguments)) || this; // eslint-disable-next-line @typescript-eslint/no-unused-vars _this.getAuthRecipeDefaultRedirectionURL = function (_context) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { throw new Error("Should never come here"); }); }); }; _this.signOut = function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, types.Session.getInstanceOrThrow().signOut({ - userContext: genericComponentOverrideContext.getNormalisedUserContext( + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -50,14 +50,14 @@ var AuthRecipe = /** @class */ (function (_super) { }); }; _this.doesSessionExist = function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, types.Session.getInstanceOrThrow().doesSessionExist({ - userContext: genericComponentOverrideContext.getNormalisedUserContext( + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), diff --git a/lib/build/emailLargeIcon.js b/lib/build/emailLargeIcon.js index 3985ac948..54c0b4b70 100644 --- a/lib/build/emailLargeIcon.js +++ b/lib/build/emailLargeIcon.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var jsxRuntime = require("react/jsx-runtime"); /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. @@ -26,12 +26,12 @@ var jsxRuntime = require("react/jsx-runtime"); function EmailLargeIcon() { return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "59.867", height: "40.34", viewBox: "0 0 59.867 40.34" }, { children: jsxRuntime.jsxs( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "email", transform: "translate(0 -83.5)" }, { children: [ diff --git a/lib/build/emailpassword-shared.js b/lib/build/emailpassword-shared.js index 2cf2045e7..e0dae7dd3 100644 --- a/lib/build/emailpassword-shared.js +++ b/lib/build/emailpassword-shared.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var jsxRuntime = require("react/jsx-runtime"); require("./index2.js"); var translationContext = require("./translationContext.js"); @@ -20,7 +20,7 @@ function Button(_a) { } return jsxRuntime.jsxs( "button", - genericComponentOverrideContext.__assign( + superTokens.__assign( { type: type, disabled: disabled, onClick: onClick, "data-supertokens": "button" }, { children: [t(label), isLoading && "..."] } ) diff --git a/lib/build/emailpassword-shared3.js b/lib/build/emailpassword-shared3.js index 73b589369..57b17541e 100644 --- a/lib/build/emailpassword-shared3.js +++ b/lib/build/emailpassword-shared3.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var EmailPasswordWebJS = require("supertokens-web-js/recipe/emailpassword"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); var index = require("./authRecipe-shared2.js"); @@ -17,20 +17,19 @@ var NormalisedURLPath__default = /*#__PURE__*/ _interopDefault(NormalisedURLPath var getFunctionOverrides = function (onHandleEvent) { return function (originalImp) { - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImp), { + return superTokens.__assign(superTokens.__assign({}, originalImp), { submitNewPassword: function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var response; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, originalImp.submitNewPassword( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, input), - { formFields: [input.formFields[0]] } - ) + superTokens.__assign(superTokens.__assign({}, input), { + formFields: [input.formFields[0]], + }) ), ]; case 1: @@ -47,9 +46,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, sendPasswordResetEmail: function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var response; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.sendPasswordResetEmail(input)]; @@ -71,9 +70,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, signUp: function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var payloadBeforeCall, response, payloadAfterCall; - return genericComponentOverrideContext.__generator(this, function (_c) { + return superTokens.__generator(this, function (_c) { switch (_c.label) { case 0: _c.trys.push([0, 2, , 3]); @@ -133,9 +132,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, signIn: function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var payloadBeforeCall, response, payloadAfterCall; - return genericComponentOverrideContext.__generator(this, function (_c) { + return superTokens.__generator(this, function (_c) { switch (_c.label) { case 0: _c.trys.push([0, 2, , 3]); @@ -216,9 +215,9 @@ var getFunctionOverrides = function (onHandleEvent) { * defaultEmailValidator. */ function defaultEmailValidator(value) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var defaultEmailValidatorRegexp; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { if (typeof value !== "string") { return [2 /*return*/, "ERROR_EMAIL_NON_STRING"]; } @@ -242,8 +241,8 @@ function defaultEmailValidator(value) { * Contains lowercase, uppercase, and numbers. */ function defaultPasswordValidator(value) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { if (typeof value !== "string") { return [2 /*return*/, "ERROR_PASSWORD_NON_STRING"]; } @@ -271,8 +270,8 @@ function defaultPasswordValidator(value) { * type string */ function defaultLoginPasswordValidator(value) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { if (typeof value !== "string") { return [2 /*return*/, "ERROR_PASSWORD_NON_STRING"]; } @@ -285,8 +284,8 @@ function defaultLoginPasswordValidator(value) { */ // eslint-disable-next-line @typescript-eslint/no-unused-vars function defaultValidate(_) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [2 /*return*/, undefined]; }); }); @@ -322,7 +321,7 @@ function normaliseEmailPasswordConfig(config) { signUpEmailField, config.resetPasswordUsingTokenFeature ); - var override = genericComponentOverrideContext.__assign( + var override = superTokens.__assign( { functions: function (originalImplementation) { return originalImplementation; @@ -330,14 +329,11 @@ function normaliseEmailPasswordConfig(config) { }, config.override ); - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, utils.normaliseAuthRecipe(config)), - { - signInAndUpFeature: signInAndUpFeature, - resetPasswordUsingTokenFeature: resetPasswordUsingTokenFeature, - override: override, - } - ); + return superTokens.__assign(superTokens.__assign({}, utils.normaliseAuthRecipe(config)), { + signInAndUpFeature: signInAndUpFeature, + resetPasswordUsingTokenFeature: resetPasswordUsingTokenFeature, + override: override, + }); } function normaliseSignInAndUpFeature(config) { if (config === undefined) { @@ -352,17 +348,17 @@ function normaliseSignInAndUpFeature(config) { */ var defaultSignInFields = signUpForm.formFields.reduce(function (signInFieldsAccumulator, field) { if (field.id === "email") { - return genericComponentOverrideContext.__spreadArray( - genericComponentOverrideContext.__spreadArray([], signInFieldsAccumulator, true), + return superTokens.__spreadArray( + superTokens.__spreadArray([], signInFieldsAccumulator, true), [field], false ); } if (field.id === "password") { - return genericComponentOverrideContext.__spreadArray( - genericComponentOverrideContext.__spreadArray([], signInFieldsAccumulator, true), + return superTokens.__spreadArray( + superTokens.__spreadArray([], signInFieldsAccumulator, true), [ - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, field), { + superTokens.__assign(superTokens.__assign({}, field), { autoComplete: "current-password", validate: defaultLoginPasswordValidator, }), @@ -407,9 +403,7 @@ function normaliseSignInFormFeatureConfig(defaultFormFields, config) { }) // Sign In fields are never optional. .map(function (field) { - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, field), { - optional: false, - }); + return superTokens.__assign(superTokens.__assign({}, field), { optional: false }); }); } var formFields = mergeFormFields(defaultFormFields, userFormFields); @@ -479,10 +473,11 @@ function normaliseResetPasswordUsingTokenFeature(signUpPasswordFieldValidate, si var enterEmailForm = { style: enterEmailFormStyle, formFields: [ - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, getDefaultEmailFormField()), - { validate: signUpEmailField.validate, placeholder: "", autofocus: true } - ), + superTokens.__assign(superTokens.__assign({}, getDefaultEmailFormField()), { + validate: signUpEmailField.validate, + placeholder: "", + autofocus: true, + }), ], }; return { @@ -517,11 +512,8 @@ function mergeFormFields(defaultFormFields, userFormFields) { optional = false; } // Merge. - mergedFormFields[j] = genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, mergedFormFields[j]), - userField - ), + mergedFormFields[j] = superTokens.__assign( + superTokens.__assign(superTokens.__assign({}, mergedFormFields[j]), userField), { optional: optional } ); isNewField = false; @@ -531,7 +523,7 @@ function mergeFormFields(defaultFormFields, userFormFields) { // If new field, push to mergeFormFields. if (isNewField) { mergedFormFields.push( - genericComponentOverrideContext.__assign( + superTokens.__assign( { optional: false, placeholder: userField.label, validate: defaultValidate }, userField ) @@ -548,10 +540,10 @@ function getFormattedFormField(field) { if (field.optional === false && field.nonOptionalErrorMsg === "") { throw new Error("nonOptionalErrorMsg for field ".concat(field.id, " cannot be an empty string")); } - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, field), { + return superTokens.__assign(superTokens.__assign({}, field), { validate: function (value) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: // Absent or not optional empty field @@ -589,7 +581,7 @@ function getFormattedFormField(field) { * Class. */ var EmailPassword = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(EmailPassword, _super); + superTokens.__extends(EmailPassword, _super); function EmailPassword(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = EmailPasswordWebJS__default.default; @@ -599,9 +591,9 @@ var EmailPassword = /** @class */ (function (_super) { _this.recipeID = EmailPassword.RECIPE_ID; _this.firstFactorIds = [types.FactorIds.EMAILPASSWORD]; _this.getDefaultRedirectionURL = function (context) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var resetPasswordPath; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { if (context.action === "RESET_PASSWORD") { resetPasswordPath = new NormalisedURLPath__default.default( constants.DEFAULT_RESET_PASSWORD_PATH @@ -622,7 +614,6 @@ var EmailPassword = /** @class */ (function (_super) { }); }); }; - _this.recipeID = config.recipeId; return _this; } EmailPassword.prototype.getFirstFactorsForAuthPage = function () { @@ -634,27 +625,24 @@ var EmailPassword = /** @class */ (function (_super) { recipeID: EmailPassword.RECIPE_ID, authReact: function (appInfo) { EmailPassword.instance = new EmailPassword( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, normalisedConfig), - { appInfo: appInfo, recipeId: EmailPassword.RECIPE_ID } - ) + superTokens.__assign(superTokens.__assign({}, normalisedConfig), { + appInfo: appInfo, + recipeId: EmailPassword.RECIPE_ID, + }) ); return EmailPassword.instance; }, webJS: EmailPasswordWebJS__default.default.init( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, normalisedConfig), - { - override: { - functions: function (originalImpl, builder) { - var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); - builder.override(functions); - builder.override(normalisedConfig.override.functions); - return originalImpl; - }, + superTokens.__assign(superTokens.__assign({}, normalisedConfig), { + override: { + functions: function (originalImpl, builder) { + var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); + builder.override(functions); + builder.override(normalisedConfig.override.functions); + return originalImpl; }, - } - ) + }, + }) ), }; }; @@ -665,7 +653,7 @@ var EmailPassword = /** @class */ (function (_super) { "See https://supertokens.io/docs/emailpassword/quick-setup/frontend"; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { - error = error + genericComponentOverrideContext.SSR_ERROR; + error = error + superTokens.SSR_ERROR; } throw Error(error); } @@ -675,7 +663,7 @@ var EmailPassword = /** @class */ (function (_super) { * Tests methods. */ EmailPassword.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } EmailPassword.instance = undefined; diff --git a/lib/build/emailpassword-shared5.js b/lib/build/emailpassword-shared5.js index aa56ddb98..60d3b9840 100644 --- a/lib/build/emailpassword-shared5.js +++ b/lib/build/emailpassword-shared5.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var jsxRuntime = require("react/jsx-runtime"); var React = require("react"); var STGeneralError = require("supertokens-web-js/utils/error"); @@ -24,7 +24,7 @@ function FormRow(_a) { hasError = _a.hasError; return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": ["formRow", hasError ? "hasError" : ""].join(" ") }, { children: children } ) @@ -54,7 +54,7 @@ function FormRow(_a) { function CheckedIcon() { return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "14.862", @@ -96,7 +96,7 @@ function CheckedIcon() { function ErrorIcon() { return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "17", @@ -109,7 +109,7 @@ function ErrorIcon() { children: [ jsxRuntime.jsx( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { className: "Asdf", fill: "rgb(var(--palette-error))" }, { children: jsxRuntime.jsx("path", { @@ -121,7 +121,7 @@ function ErrorIcon() { ), jsxRuntime.jsx( "text", - genericComponentOverrideContext.__assign( + superTokens.__assign( { fill: "#fff", fontSize: "10px", @@ -131,7 +131,7 @@ function ErrorIcon() { { children: jsxRuntime.jsx( "tspan", - genericComponentOverrideContext.__assign({ x: "0", y: "0" }, { children: "!" }) + superTokens.__assign({ x: "0", y: "0" }, { children: "!" }) ), } ) @@ -169,7 +169,7 @@ function ShowPasswordIcon(_a) { return jsxRuntime.jsx("div", { children: jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "18.391", @@ -194,7 +194,7 @@ function ShowPasswordIcon(_a) { }), jsxRuntime.jsxs( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { fill: "rgb(var(--palette-textPrimary))", stroke: "rgb(var(--palette-inputBackground))", @@ -243,7 +243,7 @@ function ShowPasswordIcon(_a) { return jsxRuntime.jsx("div", { children: jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "18.281", @@ -268,7 +268,7 @@ function ShowPasswordIcon(_a) { }), jsxRuntime.jsxs( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { fill: "rgb(var(--palette-textPrimary))", stroke: "rgb(var(--palette-inputBackground))", @@ -343,12 +343,12 @@ var Input = function (_a) { } return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "inputContainer" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": ["inputWrapper", hasError ? "inputError" : ""].join(" ") }, { children: [ @@ -368,7 +368,7 @@ var Input = function (_a) { hasError === true && jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "inputAdornment inputAdornmentError" }, { children: jsxRuntime.jsx(ErrorIcon, {}) } ) @@ -377,7 +377,7 @@ var Input = function (_a) { hasError === false && jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "inputAdornment inputAdornmentSuccess" }, { children: jsxRuntime.jsx(CheckedIcon, {}) } ) @@ -386,7 +386,7 @@ var Input = function (_a) { value.length > 0 && jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { onClick: function () { return setShowPassword(showPassword === false); @@ -414,7 +414,7 @@ function InputError(_a) { var t = translationContext.useTranslation(); return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign({ "data-supertokens": "inputErrorMessage" }, { children: t(error) }) + superTokens.__assign({ "data-supertokens": "inputErrorMessage" }, { children: t(error) }) ); } @@ -424,7 +424,7 @@ function Label(_a) { var t = translationContext.useTranslation(); return jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "label" }, { children: [t(value), showIsRequired && value && value.trim() !== "" && " *"] } ) @@ -547,8 +547,8 @@ var FormBase = function (props) { }); // If there is a formfield missing from the states array, we fill with the default value if (fieldsWithoutState.length > 0) { - fs = genericComponentOverrideContext.__spreadArray( - genericComponentOverrideContext.__spreadArray([], fs, true), + fs = superTokens.__spreadArray( + superTokens.__spreadArray([], fs, true), fieldsWithoutState.map(function (f) { return { id: f.id, value: fetchDefaultValue(f) }; }), @@ -584,8 +584,8 @@ var FormBase = function (props) { return f.id === id; }); if (field === undefined) { - return genericComponentOverrideContext.__spreadArray( - genericComponentOverrideContext.__spreadArray([], os, true), + return superTokens.__spreadArray( + superTokens.__spreadArray([], os, true), [update({ id: id, value: "" })], false ); @@ -602,18 +602,16 @@ var FormBase = function (props) { var onInputFocus = React.useCallback( function (field) { updateFieldState(field.id, function (os) { - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, os), { - validated: false, - }); + return superTokens.__assign(superTokens.__assign({}, os), { validated: false }); }); }, [updateFieldState] ); var onInputBlur = React.useCallback( function (field) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var fieldConfig, error, _a; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: if (!validateOnBlur) { @@ -633,10 +631,10 @@ var FormBase = function (props) { case 3: error = _a; updateFieldState(field.id, function (os) { - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, os), - { error: error, validated: error === undefined && field.value.length !== 0 } - ); + return superTokens.__assign(superTokens.__assign({}, os), { + error: error, + validated: error === undefined && field.value.length !== 0, + }); }); return [2 /*return*/]; } @@ -651,10 +649,7 @@ var FormBase = function (props) { throw new Error("".concat(field.id, " value must be a string")); } updateFieldState(field.id, function (os) { - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, os), { - value: field.value, - error: undefined, - }); + return superTokens.__assign(superTokens.__assign({}, os), { value: field.value, error: undefined }); }); props.clearError(); }, @@ -662,7 +657,7 @@ var FormBase = function (props) { ); var onFormSubmit = React.useCallback( function (e) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var apiFields, fieldUpdates, result, @@ -675,7 +670,7 @@ var FormBase = function (props) { field, errorFields_1, getErrorMessage_1; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: // Prevent default event propagation. @@ -684,10 +679,7 @@ var FormBase = function (props) { setIsLoading(true); setFieldStates(function (os) { return os.map(function (fs) { - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, fs), - { error: undefined } - ); + return superTokens.__assign(superTokens.__assign({}, fs), { error: undefined }); }); }); apiFields = formFields.map(function (field) { @@ -740,10 +732,9 @@ var FormBase = function (props) { if (update || field.clearOnSubmit === true) { // We can do these one by one, it's almost never more than one field updateFieldState(field.id, function (os) { - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, os), - { value: update ? update.value : "" } - ); + return superTokens.__assign(superTokens.__assign({}, os), { + value: update ? update.value : "", + }); }); } }; @@ -802,10 +793,9 @@ var FormBase = function (props) { }; setFieldStates(function (os) { return os.map(function (fs) { - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, fs), - { error: getErrorMessage_1(fs) } - ); + return superTokens.__assign(superTokens.__assign({}, fs), { + error: getErrorMessage_1(fs), + }); }); }); } @@ -828,12 +818,12 @@ var FormBase = function (props) { ); return jsxRuntime.jsx( FormStateContext.Provider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { value: fieldStates }, { children: jsxRuntime.jsxs( "form", - genericComponentOverrideContext.__assign( + superTokens.__assign( { autoComplete: "on", noValidate: true, @@ -863,7 +853,7 @@ var FormBase = function (props) { }; return jsxRuntime.jsx( FormRow, - genericComponentOverrideContext.__assign( + superTokens.__assign( { hasError: fstate.error !== undefined }, { children: jsxRuntime.jsxs(React.Fragment, { diff --git a/lib/build/emailpassword.js b/lib/build/emailpassword.js index 34ec5282c..896fc08df 100644 --- a/lib/build/emailpassword.js +++ b/lib/build/emailpassword.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var componentOverrideContext = require("./emailpassword-shared2.js"); var recipe = require("./emailpassword-shared3.js"); require("supertokens-web-js"); @@ -14,12 +14,15 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); +require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); require("supertokens-web-js/recipe/emailpassword"); require("./authRecipe-shared2.js"); require("./recipeModule-shared.js"); require("./multifactorauth-shared.js"); require("supertokens-web-js/recipe/session"); +require("./oauth2-shared.js"); +require("supertokens-web-js/recipe/oauth2"); require("./emailpassword-shared4.js"); require("./authRecipe-shared.js"); @@ -43,12 +46,12 @@ var Wrapper = /** @class */ (function () { return recipe.EmailPassword.init(config); }; Wrapper.signOut = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailPassword.getInstanceOrThrow().signOut({ - userContext: genericComponentOverrideContext.getNormalisedUserContext( + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -57,13 +60,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.submitNewPassword = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailPassword.getInstanceOrThrow().webJSRecipe.submitNewPassword( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext(input.userContext), }) ), ]; @@ -71,13 +74,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.sendPasswordResetEmail = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailPassword.getInstanceOrThrow().webJSRecipe.sendPasswordResetEmail( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext(input.userContext), }) ), ]; @@ -85,13 +88,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.signUp = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailPassword.getInstanceOrThrow().webJSRecipe.signUp( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext(input.userContext), }) ), ]; @@ -99,13 +102,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.signIn = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailPassword.getInstanceOrThrow().webJSRecipe.signIn( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext(input.userContext), }) ), ]; @@ -113,13 +116,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.doesEmailExist = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailPassword.getInstanceOrThrow().webJSRecipe.doesEmailExist( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext(input.userContext), }) ), ]; @@ -128,8 +131,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.getResetPasswordTokenFromURL = function (input) { return recipe.EmailPassword.getInstanceOrThrow().webJSRecipe.getResetPasswordTokenFromURL( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) diff --git a/lib/build/emailpasswordprebuiltui.js b/lib/build/emailpasswordprebuiltui.js index 4cb40e083..dcfcdb5f1 100644 --- a/lib/build/emailpasswordprebuiltui.js +++ b/lib/build/emailpasswordprebuiltui.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var jsxRuntime = require("react/jsx-runtime"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); var uiEntry = require("./index2.js"); @@ -15,12 +15,12 @@ var STGeneralError = require("supertokens-web-js/utils/error"); var button = require("./emailpassword-shared.js"); var authCompWrapper = require("./authCompWrapper.js"); var emailverification = require("./emailverification.js"); -var recipe = require("./emailverification-shared.js"); +var recipe$1 = require("./emailverification-shared.js"); var session = require("./session.js"); var types = require("./multifactorauth-shared.js"); +var recipe = require("./emailpassword-shared3.js"); var STGeneralError$1 = require("supertokens-web-js/lib/build/error"); var constants = require("./emailpassword-shared4.js"); -var recipe$1 = require("./emailpassword-shared3.js"); require("supertokens-web-js"); require("supertokens-web-js/utils/cookieHandler"); require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); @@ -30,10 +30,13 @@ require("supertokens-web-js/utils"); require("supertokens-web-js/utils/normalisedURLDomain"); require("react-dom"); require("./multitenancy-shared.js"); +require("./genericComponentOverrideContext.js"); require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); +require("./oauth2-shared.js"); +require("supertokens-web-js/recipe/oauth2"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); require("./multifactorauth-shared3.js"); @@ -86,7 +89,7 @@ function BackToSignInButton(_a) { var t = translationContext.useTranslation(); return jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: onClick }, { children: [ @@ -123,25 +126,25 @@ var EmailPasswordResetPasswordEmail = function (props) { if (status === "SENT") { return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: [ jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "primaryText enterEmailSuccessMessage" }, { children: [ emailSuccessText, jsxRuntime.jsx( "span", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "link resendEmailLink", onClick: resend, @@ -165,18 +168,18 @@ var EmailPasswordResetPasswordEmail = function (props) { // Otherwise, return Form. return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container resetPasswordEmailForm" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: [ jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle withBackButton" }, { children: [ @@ -193,7 +196,7 @@ var EmailPasswordResetPasswordEmail = function (props) { ), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: t("EMAIL_PASSWORD_RESET_HEADER_SUBTITLE") } ) @@ -207,65 +210,58 @@ var EmailPasswordResetPasswordEmail = function (props) { buttonLabel: "EMAIL_PASSWORD_RESET_SEND_BTN", onSuccess: onSuccess, callAPI: function (formFields) { - return genericComponentOverrideContext.__awaiter( - void 0, - void 0, - void 0, - function () { - var validationErrors, emailField, resp; - return genericComponentOverrideContext.__generator(this, function (_a) { - switch (_a.label) { - case 0: + return superTokens.__awaiter(void 0, void 0, void 0, function () { + var validationErrors, emailField, resp; + return superTokens.__generator(this, function (_a) { + switch (_a.label) { + case 0: + return [ + 4 /*yield*/, + superTokens.validateForm( + formFields, + props.config.resetPasswordUsingTokenFeature + .enterEmailForm.formFields + ), + ]; + case 1: + validationErrors = _a.sent(); + if (validationErrors.length > 0) { return [ - 4 /*yield*/, - genericComponentOverrideContext.validateForm( - formFields, - props.config.resetPasswordUsingTokenFeature - .enterEmailForm.formFields - ), + 2 /*return*/, + { + status: "FIELD_ERROR", + formFields: validationErrors, + }, ]; - case 1: - validationErrors = _a.sent(); - if (validationErrors.length > 0) { - return [ - 2 /*return*/, - { - status: "FIELD_ERROR", - formFields: validationErrors, - }, - ]; - } - emailField = formFields.find(function (field) { - return field.id === "email"; - }); - if (emailField !== undefined) { - setEmailFieldValue(emailField.value); - } + } + emailField = formFields.find(function (field) { + return field.id === "email"; + }); + if (emailField !== undefined) { + setEmailFieldValue(emailField.value); + } + return [ + 4 /*yield*/, + props.recipeImplementation.sendPasswordResetEmail({ + formFields: formFields, + userContext: userContext, + }), + ]; + case 2: + resp = _a.sent(); + if (resp.status === "PASSWORD_RESET_NOT_ALLOWED") { return [ - 4 /*yield*/, - props.recipeImplementation.sendPasswordResetEmail({ - formFields: formFields, - userContext: userContext, - }), + 2 /*return*/, + { + status: "FIELD_ERROR", + formFields: [{ id: "email", error: resp.reason }], + }, ]; - case 2: - resp = _a.sent(); - if (resp.status === "PASSWORD_RESET_NOT_ALLOWED") { - return [ - 2 /*return*/, - { - status: "FIELD_ERROR", - formFields: [ - { id: "email", error: resp.reason }, - ], - }, - ]; - } - return [2 /*return*/, resp]; - } - }); - } - ); + } + return [2 /*return*/, resp]; + } + }); + }); }, showLabels: true, validateOnBlur: true, @@ -294,18 +290,18 @@ var EmailPasswordSubmitNewPassword = function (props) { if (status === "SUCCESS") { return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: [ jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle" }, { children: t("EMAIL_PASSWORD_RESET_SUBMIT_PW_SUCCESS_HEADER_TITLE") } ) @@ -317,7 +313,7 @@ var EmailPasswordSubmitNewPassword = function (props) { children: [ jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "primaryText submitNewPasswordSuccessMessage", @@ -351,25 +347,25 @@ var EmailPasswordSubmitNewPassword = function (props) { } return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container resetPasswordPasswordForm" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: [ jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle" }, { children: t("EMAIL_PASSWORD_RESET_SUBMIT_PW_HEADER_TITLE") } ) ), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: t("EMAIL_PASSWORD_RESET_SUBMIT_PW_HEADER_SUBTITLE") } ) @@ -384,77 +380,70 @@ var EmailPasswordSubmitNewPassword = function (props) { onSuccess: onSuccess, validateOnBlur: true, callAPI: function (fields) { - return genericComponentOverrideContext.__awaiter( - void 0, - void 0, - void 0, - function () { - var validationErrors, response; - return genericComponentOverrideContext.__generator(this, function (_a) { - switch (_a.label) { - case 0: + return superTokens.__awaiter(void 0, void 0, void 0, function () { + var validationErrors, response; + return superTokens.__generator(this, function (_a) { + switch (_a.label) { + case 0: + return [ + 4 /*yield*/, + superTokens.validateForm( + fields, + props.config.resetPasswordUsingTokenFeature + .submitNewPasswordForm.formFields + ), + ]; + case 1: + validationErrors = _a.sent(); + if (validationErrors.length > 0) { return [ - 4 /*yield*/, - genericComponentOverrideContext.validateForm( - fields, - props.config.resetPasswordUsingTokenFeature - .submitNewPasswordForm.formFields - ), - ]; - case 1: - validationErrors = _a.sent(); - if (validationErrors.length > 0) { - return [ - 2 /*return*/, - { - status: "FIELD_ERROR", - formFields: validationErrors, - }, - ]; - } - // Verify that both passwords match. - if (fields[0].value !== fields[1].value) { - return [ - 2 /*return*/, - { - status: "FIELD_ERROR", - formFields: [ - { - id: fields[1].id, - error: "ERROR_CONFIRM_PASSWORD_NO_MATCH", - }, - ], - }, - ]; - } - return [ - 4 /*yield*/, - props.recipeImplementation.submitNewPassword({ - formFields: fields, - userContext: userContext, - }), + 2 /*return*/, + { + status: "FIELD_ERROR", + formFields: validationErrors, + }, ]; - case 2: - response = _a.sent(); - if ( - response.status === "RESET_PASSWORD_INVALID_TOKEN_ERROR" - ) { - throw new STGeneralError__default.default( - "EMAIL_PASSWORD_RESET_PASSWORD_INVALID_TOKEN_ERROR" - ); - } + } + // Verify that both passwords match. + if (fields[0].value !== fields[1].value) { return [ 2 /*return*/, - response.status === "FIELD_ERROR" - ? response - : { - status: "OK", - }, + { + status: "FIELD_ERROR", + formFields: [ + { + id: fields[1].id, + error: "ERROR_CONFIRM_PASSWORD_NO_MATCH", + }, + ], + }, ]; - } - }); - } - ); + } + return [ + 4 /*yield*/, + props.recipeImplementation.submitNewPassword({ + formFields: fields, + userContext: userContext, + }), + ]; + case 2: + response = _a.sent(); + if (response.status === "RESET_PASSWORD_INVALID_TOKEN_ERROR") { + throw new STGeneralError__default.default( + "EMAIL_PASSWORD_RESET_PASSWORD_INVALID_TOKEN_ERROR" + ); + } + return [ + 2 /*return*/, + response.status === "FIELD_ERROR" + ? response + : { + status: "OK", + }, + ]; + } + }); + }); }, showLabels: true, }), @@ -477,38 +466,30 @@ function ResetPasswordUsingTokenTheme(props) { */ // If no token, return SubmitNewPassword. if (props.submitNewPasswordForm !== undefined) { - return jsxRuntime.jsx( - SubmitNewPassword, - genericComponentOverrideContext.__assign({}, props.submitNewPasswordForm) - ); + return jsxRuntime.jsx(SubmitNewPassword, superTokens.__assign({}, props.submitNewPasswordForm)); } // Otherwise, return EnterEmail. - return jsxRuntime.jsx(ResetPasswordEmail, genericComponentOverrideContext.__assign({}, props.enterEmailForm)); + return jsxRuntime.jsx(ResetPasswordEmail, superTokens.__assign({}, props.enterEmailForm)); } function ResetPasswordUsingTokenThemeWrapper(props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var userStyles = props.submitNewPasswordForm ? props.config.resetPasswordUsingTokenFeature.submitNewPasswordForm.style : props.config.resetPasswordUsingTokenFeature.enterEmailForm.style; return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( translations.ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, userStyles], }, - { - children: jsxRuntime.jsx( - ResetPasswordUsingTokenTheme, - genericComponentOverrideContext.__assign({}, props) - ), - } + { children: jsxRuntime.jsx(ResetPasswordUsingTokenTheme, superTokens.__assign({}, props)) } ) ), } @@ -517,9 +498,9 @@ function ResetPasswordUsingTokenThemeWrapper(props) { } var defaultTranslationsEmailPassword = { - en: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, uiEntry.defaultTranslationsCommon.en), + en: superTokens.__assign( + superTokens.__assign( + superTokens.__assign({}, uiEntry.defaultTranslationsCommon.en), translations.defaultTranslationsEmailVerification.en ), { @@ -591,7 +572,7 @@ var defaultTranslationsEmailPassword = { }; var ResetPasswordUsingToken$1 = function (props) { - var token = genericComponentOverrideContext.getQueryParams("token"); + var token = superTokens.getQueryParams("token"); var userContext = uiEntry.useUserContext(); if (props.userContext !== undefined) { userContext = props.userContext; @@ -617,7 +598,7 @@ var ResetPasswordUsingToken$1 = function (props) { recipeImplementation: props.recipe.webJSRecipe, config: props.recipe.config, onSignInClicked: function () { - void genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ + void superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ show: "signin", navigate: props.navigate, redirectBack: false, @@ -628,7 +609,7 @@ var ResetPasswordUsingToken$1 = function (props) { }; var enterEmailForm = { onBackButtonClicked: function () { - return genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ + return superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ show: "signin", navigate: props.navigate, redirectBack: false, @@ -655,14 +636,14 @@ var ResetPasswordUsingToken$1 = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { - useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, + useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, defaultStore: defaultTranslationsEmailPassword, }, { @@ -671,7 +652,7 @@ var ResetPasswordUsingToken$1 = function (props) { props.children === undefined && jsxRuntime.jsx( ResetPasswordUsingTokenThemeWrapper, - genericComponentOverrideContext.__assign({}, childProps) + superTokens.__assign({}, childProps) ), props.children && React__namespace.Children.map(props.children, function (child) { @@ -701,14 +682,14 @@ var SignInForm = uiEntry.withOverride("EmailPasswordSignInForm", function EmailP buttonLabel: "EMAIL_PASSWORD_SIGN_IN_SUBMIT_BTN", onSuccess: props.onSuccess, callAPI: function (formFields) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var validationErrors, response; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, - genericComponentOverrideContext.validateForm( + superTokens.validateForm( formFields, props.config.signInAndUpFeature.signInForm.formFields ), @@ -752,22 +733,22 @@ var SignInForm = uiEntry.withOverride("EmailPasswordSignInForm", function EmailP }); }); function SignInTheme(props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeStyle = props.config.signInAndUpFeature.signInForm.style; return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( translations.ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, activeStyle], }, - { children: jsxRuntime.jsx(SignInForm, genericComponentOverrideContext.__assign({}, props)) } + { children: jsxRuntime.jsx(SignInForm, superTokens.__assign({}, props)) } ) ), } @@ -775,22 +756,22 @@ function SignInTheme(props) { ); } -function useChildProps$1(recipe$1, error, onError, clearError, userContext, navigate) { +function useChildProps$1(recipe$2, onAuthSuccess, error, onError, clearError, userContext, navigate) { var _this = this; var session$1 = uiEntry.useSessionContext(); var recipeImplementation = React.useMemo( function () { - return getModifiedRecipeImplementation$1(recipe$1.webJSRecipe); + return getModifiedRecipeImplementation$1(recipe$2.webJSRecipe); }, - [recipe$1] + [recipe$2] ); - var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var rethrowInRender = superTokens.useRethrowInRender(); var t = translationContext.useTranslation(); var onSignInSuccess = React.useCallback( function () { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var payloadAfterCall; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, , 3]); @@ -810,47 +791,38 @@ function useChildProps$1(recipe$1, error, onError, clearError, userContext, navi case 3: return [ 2 /*return*/, - types.Session.getInstanceOrThrow() - .validateGlobalClaimsAndHandleSuccessRedirection( - { - action: "SUCCESS", - createdNewUser: false, - isNewRecipeUser: false, - newSessionCreated: - session$1.loading || - !session$1.doesSessionExist || - (payloadAfterCall !== undefined && - session$1.accessTokenPayload.sessionHandle !== - payloadAfterCall.sessionHandle), - recipeId: recipe$1.recipeID, - }, - recipe$1.recipeID, - genericComponentOverrideContext.getRedirectToPathFromURL(), - userContext, - navigate - ) - .catch(rethrowInRender), + onAuthSuccess({ + createdNewUser: false, + isNewRecipeUser: false, + newSessionCreated: + session$1.loading || + !session$1.doesSessionExist || + (payloadAfterCall !== undefined && + session$1.accessTokenPayload.sessionHandle !== + payloadAfterCall.sessionHandle), + recipeId: recipe.EmailPassword.RECIPE_ID, + }).catch(rethrowInRender), ]; } }); }); }, - [recipe$1, userContext, navigate] + [recipe$2, userContext, navigate] ); return React.useMemo( function () { var onForgotPasswordClick = function () { - return recipe$1.redirect({ action: "RESET_PASSWORD" }, navigate, undefined, userContext); + return recipe$2.redirect({ action: "RESET_PASSWORD" }, navigate, undefined, userContext); }; - var signInAndUpFeature = recipe$1.config.signInAndUpFeature; + var signInAndUpFeature = recipe$2.config.signInAndUpFeature; var signInFeature = signInAndUpFeature.signInForm; var formFields = signInFeature.formFields.map(function (f) { return f.id !== "password" ? f - : genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, f), { + : superTokens.__assign(superTokens.__assign({}, f), { labelComponent: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ @@ -860,7 +832,7 @@ function useChildProps$1(recipe$1, error, onError, clearError, userContext, navi }), jsxRuntime.jsx( "a", - genericComponentOverrideContext.__assign( + superTokens.__assign( { onClick: onForgotPasswordClick, "data-supertokens": @@ -877,16 +849,16 @@ function useChildProps$1(recipe$1, error, onError, clearError, userContext, navi }); return { recipeImplementation: recipeImplementation, - config: recipe$1.config, + config: recipe$2.config, styleFromInit: signInFeature.style, formFields: formFields, error: error, clearError: clearError, onError: onError, onFetchError: function (err) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var invalidClaims, evInstance; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -914,7 +886,7 @@ function useChildProps$1(recipe$1, error, onError, clearError, userContext, navi _b.label = 2; case 2: _b.trys.push([2, 4, , 5]); - evInstance = recipe.EmailVerification.getInstanceOrThrow(); + evInstance = recipe$1.EmailVerification.getInstanceOrThrow(); return [ 4 /*yield*/, evInstance.redirect( @@ -944,12 +916,13 @@ function useChildProps$1(recipe$1, error, onError, clearError, userContext, navi userContext: userContext, }; }, - [recipe$1] + [recipe$2] ); } var SignInFeature = function (props) { var childProps = useChildProps$1( props.recipe, + props.onAuthSuccess, props.error, props.onError, props.clearError, @@ -959,20 +932,17 @@ var SignInFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { recipeComponentOverrides: recipeComponentOverrides }, { children: jsxRuntime.jsxs(React.Fragment, { children: [ props.children === undefined && - jsxRuntime.jsx(SignInTheme, genericComponentOverrideContext.__assign({}, childProps)), + jsxRuntime.jsx(SignInTheme, superTokens.__assign({}, childProps)), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { - return React__namespace.cloneElement( - child, - genericComponentOverrideContext.__assign({}, childProps) - ); + return React__namespace.cloneElement(child, superTokens.__assign({}, childProps)); } return child; }), @@ -983,7 +953,7 @@ var SignInFeature = function (props) { ); }; var getModifiedRecipeImplementation$1 = function (origImpl) { - return genericComponentOverrideContext.__assign({}, origImpl); + return superTokens.__assign({}, origImpl); }; var SignUpForm = uiEntry.withOverride("EmailPasswordSignUpForm", function EmailPasswordSignUpForm(props) { @@ -997,14 +967,14 @@ var SignUpForm = uiEntry.withOverride("EmailPasswordSignUpForm", function EmailP buttonLabel: "EMAIL_PASSWORD_SIGN_UP_SUBMIT_BTN", onSuccess: props.onSuccess, callAPI: function (formFields) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var validationErrors, res; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, - genericComponentOverrideContext.validateForm( + superTokens.validateForm( formFields, props.config.signInAndUpFeature.signUpForm.formFields ), @@ -1043,22 +1013,22 @@ var SignUpForm = uiEntry.withOverride("EmailPasswordSignUpForm", function EmailP }); }); function SignUpTheme(props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeStyle = props.config.signInAndUpFeature.signUpForm.style; return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( translations.ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, activeStyle], }, - { children: jsxRuntime.jsx(SignUpForm, genericComponentOverrideContext.__assign({}, props)) } + { children: jsxRuntime.jsx(SignUpForm, superTokens.__assign({}, props)) } ) ), } @@ -1066,21 +1036,21 @@ function SignUpTheme(props) { ); } -function useChildProps(recipe$1, error, onError, clearError, userContext, navigate) { +function useChildProps(recipe, onAuthSuccess, error, onError, clearError, userContext, navigate) { var _this = this; var session$1 = uiEntry.useSessionContext(); var recipeImplementation = React.useMemo( function () { - return recipe$1 && getModifiedRecipeImplementation(recipe$1.webJSRecipe); + return recipe && getModifiedRecipeImplementation(recipe.webJSRecipe); }, - [recipe$1] + [recipe] ); - var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var rethrowInRender = superTokens.useRethrowInRender(); var onSignUpSuccess = React.useCallback( function (result) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var payloadAfterCall; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, , 3]); @@ -1100,46 +1070,37 @@ function useChildProps(recipe$1, error, onError, clearError, userContext, naviga case 3: return [ 2 /*return*/, - types.Session.getInstanceOrThrow() - .validateGlobalClaimsAndHandleSuccessRedirection( - { - action: "SUCCESS", - createdNewUser: result.user.loginMethods.length === 1, - isNewRecipeUser: true, - newSessionCreated: - session$1.loading || - !session$1.doesSessionExist || - (payloadAfterCall !== undefined && - session$1.accessTokenPayload.sessionHandle !== - payloadAfterCall.sessionHandle), - recipeId: recipe$1.recipeID, - }, - recipe$1.recipeID, - genericComponentOverrideContext.getRedirectToPathFromURL(), - userContext, - navigate - ) - .catch(rethrowInRender), + onAuthSuccess({ + createdNewUser: result.user.loginMethods.length === 1, + isNewRecipeUser: true, + newSessionCreated: + session$1.loading || + !session$1.doesSessionExist || + (payloadAfterCall !== undefined && + session$1.accessTokenPayload.sessionHandle !== + payloadAfterCall.sessionHandle), + recipeId: recipe.recipeID, + }).catch(rethrowInRender), ]; } }); }); }, - [recipe$1, userContext, navigate] + [recipe, userContext, navigate] ); return React.useMemo( function () { - var signInAndUpFeature = recipe$1.config.signInAndUpFeature; + var signInAndUpFeature = recipe.config.signInAndUpFeature; var signUpFeature = signInAndUpFeature.signUpForm; return { recipeImplementation: recipeImplementation, - config: recipe$1.config, + config: recipe.config, styleFromInit: signUpFeature.style, - formFields: getThemeSignUpFeatureFormFields(signUpFeature.formFields, recipe$1, userContext), + formFields: getThemeSignUpFeatureFormFields(signUpFeature.formFields, recipe, userContext), onFetchError: function (err) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var invalidClaims, evInstance; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -1167,7 +1128,7 @@ function useChildProps(recipe$1, error, onError, clearError, userContext, naviga _b.label = 2; case 2: _b.trys.push([2, 4, , 5]); - evInstance = recipe.EmailVerification.getInstanceOrThrow(); + evInstance = recipe$1.EmailVerification.getInstanceOrThrow(); return [ 4 /*yield*/, evInstance.redirect( @@ -1199,7 +1160,7 @@ function useChildProps(recipe$1, error, onError, clearError, userContext, naviga clearError: clearError, }; }, - [recipe$1] + [recipe] ); } var SignUpFeature = function (props) { @@ -1209,6 +1170,7 @@ var SignUpFeature = function (props) { } var childProps = useChildProps( props.recipe, + props.onAuthSuccess, props.error, props.onError, props.clearError, @@ -1218,20 +1180,17 @@ var SignUpFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { recipeComponentOverrides: recipeComponentOverrides }, { children: jsxRuntime.jsxs(React.Fragment, { children: [ props.children === undefined && - jsxRuntime.jsx(SignUpTheme, genericComponentOverrideContext.__assign({}, childProps)), + jsxRuntime.jsx(SignUpTheme, superTokens.__assign({}, childProps)), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { - return React__namespace.cloneElement( - child, - genericComponentOverrideContext.__assign({}, childProps) - ); + return React__namespace.cloneElement(child, superTokens.__assign({}, childProps)); } return child; }), @@ -1242,13 +1201,13 @@ var SignUpFeature = function (props) { ); }; var getModifiedRecipeImplementation = function (origImpl) { - return genericComponentOverrideContext.__assign({}, origImpl); + return superTokens.__assign({}, origImpl); }; function getThemeSignUpFeatureFormFields(formFields, recipe, userContext) { var _this = this; var emailPasswordOnly = formFields.length === 2; return formFields.map(function (field) { - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, field), { + return superTokens.__assign(superTokens.__assign({}, field), { showIsRequired: (function () { // If email and password only, do not show required indicator (*). if (emailPasswordOnly) { @@ -1264,9 +1223,9 @@ function getThemeSignUpFeatureFormFields(formFields, recipe, userContext) { } // Otherwise, if email, use syntax validate method and check if email exists. return function (value) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var error, emailExists, err_1; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, field.validate(value)]; @@ -1312,7 +1271,7 @@ function getThemeSignUpFeatureFormFields(formFields, recipe, userContext) { } var EmailPasswordPreBuiltUI = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(EmailPasswordPreBuiltUI, _super); + superTokens.__extends(EmailPasswordPreBuiltUI, _super); function EmailPasswordPreBuiltUI(recipeInstance) { var _this = _super.call(this) || this; _this.recipeInstance = recipeInstance; @@ -1328,13 +1287,11 @@ var EmailPasswordPreBuiltUI = /** @class */ (function (_super) { new NormalisedURLPath__default.default(constants.DEFAULT_RESET_PASSWORD_PATH) ); features[normalisedFullPath.getAsStringDangerous()] = { - matches: genericComponentOverrideContext.matchRecipeIdUsingQueryParams( - _this.recipeInstance.config.recipeId - ), + matches: superTokens.matchRecipeIdUsingQueryParams(_this.recipeInstance.config.recipeId), component: function (props) { return _this.getFeatureComponent("resetpassword", props, useComponentOverrides); }, - recipeID: recipe$1.EmailPassword.RECIPE_ID, + recipeID: recipe.EmailPassword.RECIPE_ID, }; } return features; @@ -1346,12 +1303,12 @@ var EmailPasswordPreBuiltUI = /** @class */ (function (_super) { if (componentName === "resetpassword") { return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ResetPasswordUsingToken$1, - genericComponentOverrideContext.__assign({ recipe: _this.recipeInstance }, props, { + superTokens.__assign({ recipe: _this.recipeInstance }, props, { useComponentOverrides: useComponentOverrides, }) ), @@ -1368,7 +1325,7 @@ var EmailPasswordPreBuiltUI = /** @class */ (function (_super) { // Static methods EmailPasswordPreBuiltUI.getInstanceOrInitAndGetInstance = function () { if (EmailPasswordPreBuiltUI.instance === undefined) { - var recipeInstance = recipe$1.EmailPassword.getInstanceOrThrow(); + var recipeInstance = recipe.EmailPassword.getInstanceOrThrow(); EmailPasswordPreBuiltUI.instance = new EmailPasswordPreBuiltUI(recipeInstance); } return EmailPasswordPreBuiltUI.instance; @@ -1399,7 +1356,7 @@ var EmailPasswordPreBuiltUI = /** @class */ (function (_super) { component: function (props) { return jsxRuntime.jsx( SignUpFeature, - genericComponentOverrideContext.__assign( + superTokens.__assign( { recipe: _this.recipeInstance, useComponentOverrides: componentOverrideContext.useContext, @@ -1417,7 +1374,7 @@ var EmailPasswordPreBuiltUI = /** @class */ (function (_super) { component: function (props) { return jsxRuntime.jsx( SignInFeature, - genericComponentOverrideContext.__assign( + superTokens.__assign( { recipe: _this.recipeInstance, useComponentOverrides: componentOverrideContext.useContext, @@ -1432,7 +1389,7 @@ var EmailPasswordPreBuiltUI = /** @class */ (function (_super) { }; // For tests EmailPasswordPreBuiltUI.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } EmailPasswordPreBuiltUI.instance = undefined; diff --git a/lib/build/emailverification-shared.js b/lib/build/emailverification-shared.js index e75d4a068..e63d777b0 100644 --- a/lib/build/emailverification-shared.js +++ b/lib/build/emailverification-shared.js @@ -1,6 +1,7 @@ "use strict"; var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var EmailVerificationWebJS = require("supertokens-web-js/recipe/emailverification"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); var postSuperTokensInitCallbacks = require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); @@ -35,10 +36,10 @@ var _a = genericComponentOverrideContext.createGenericComponentsOverrideContext( var DEFAULT_VERIFY_EMAIL_PATH = "/verify-email"; var EmailVerificationClaimClass = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(EmailVerificationClaimClass, _super); + superTokens.__extends(EmailVerificationClaimClass, _super); function EmailVerificationClaimClass(getRecipeImpl, onFailureRedirection) { var _this = _super.call(this, getRecipeImpl) || this; - var validatorsWithCallbacks = genericComponentOverrideContext.__assign({}, _this.validators); + var validatorsWithCallbacks = superTokens.__assign({}, _this.validators); var _loop_1 = function (key) { var validator = validatorsWithCallbacks[key]; validatorsWithCallbacks[key] = function () { @@ -46,22 +47,19 @@ var EmailVerificationClaimClass = /** @class */ (function (_super) { for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, validator.apply(void 0, args)), - { - onFailureRedirection: function (args) { - if (onFailureRedirection !== undefined) { - return onFailureRedirection(args); - } - var recipe = EmailVerification.getInstanceOrThrow(); - if (recipe.config.mode === "REQUIRED") { - return recipe.getRedirectUrl({ action: "VERIFY_EMAIL" }, args.userContext); - } - return undefined; - }, - showAccessDeniedOnFailure: false, - } - ); + return superTokens.__assign(superTokens.__assign({}, validator.apply(void 0, args)), { + onFailureRedirection: function (args) { + if (onFailureRedirection !== undefined) { + return onFailureRedirection(args); + } + var recipe = EmailVerification.getInstanceOrThrow(); + if (recipe.config.mode === "REQUIRED") { + return recipe.getRedirectUrl({ action: "VERIFY_EMAIL" }, args.userContext); + } + return undefined; + }, + showAccessDeniedOnFailure: false, + }); }; }; for (var key in validatorsWithCallbacks) { @@ -75,11 +73,11 @@ var EmailVerificationClaimClass = /** @class */ (function (_super) { var getFunctionOverrides = function (onHandleEvent) { return function (originalImp) { - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImp), { + return superTokens.__assign(superTokens.__assign({}, originalImp), { verifyEmail: function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var response; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.verifyEmail(input)]; @@ -97,9 +95,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, sendVerificationEmail: function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var response; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.sendVerificationEmail(input)]; @@ -154,7 +152,7 @@ function normaliseEmailVerificationFeature(config) { var verifyEmailLinkClickedScreen = { style: verifyEmailLinkClickedScreenStyle, }; - var override = genericComponentOverrideContext.__assign( + var override = superTokens.__assign( { functions: function (originalImplementation) { return originalImplementation; @@ -162,19 +160,13 @@ function normaliseEmailVerificationFeature(config) { }, config.override ); - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign( - {}, - genericComponentOverrideContext.normaliseRecipeModuleConfig(config) - ), - { - disableDefaultUI: disableDefaultUI, - mode: mode, - sendVerifyEmailScreen: sendVerifyEmailScreen, - verifyEmailLinkClickedScreen: verifyEmailLinkClickedScreen, - override: override, - } - ); + return superTokens.__assign(superTokens.__assign({}, superTokens.normaliseRecipeModuleConfig(config)), { + disableDefaultUI: disableDefaultUI, + mode: mode, + sendVerifyEmailScreen: sendVerifyEmailScreen, + verifyEmailLinkClickedScreen: verifyEmailLinkClickedScreen, + override: override, + }); } /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. @@ -192,7 +184,7 @@ function normaliseEmailVerificationFeature(config) { * under the License. */ var EmailVerification = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(EmailVerification, _super); + superTokens.__extends(EmailVerification, _super); function EmailVerification(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = EmailVerificationWebJS__default.default; @@ -201,9 +193,9 @@ var EmailVerification = /** @class */ (function (_super) { _this.webJSRecipe = webJSRecipe; _this.recipeID = EmailVerification.RECIPE_ID; _this.getDefaultRedirectionURL = function (context) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var verifyEmailPath; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { if (context.action === "VERIFY_EMAIL") { verifyEmailPath = new NormalisedURLPath__default.default(DEFAULT_VERIFY_EMAIL_PATH); return [ @@ -235,27 +227,24 @@ var EmailVerification = /** @class */ (function (_super) { recipeID: EmailVerification.RECIPE_ID, authReact: function (appInfo) { EmailVerification.instance = new EmailVerification( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, normalisedConfig), - { appInfo: appInfo, recipeId: EmailVerification.RECIPE_ID } - ) + superTokens.__assign(superTokens.__assign({}, normalisedConfig), { + appInfo: appInfo, + recipeId: EmailVerification.RECIPE_ID, + }) ); return EmailVerification.instance; }, webJS: EmailVerificationWebJS__default.default.init( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, normalisedConfig), - { - override: { - functions: function (originalImpl, builder) { - var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); - builder.override(functions); - builder.override(normalisedConfig.override.functions); - return originalImpl; - }, + superTokens.__assign(superTokens.__assign({}, normalisedConfig), { + override: { + functions: function (originalImpl, builder) { + var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); + builder.override(functions); + builder.override(normalisedConfig.override.functions); + return originalImpl; }, - } - ) + }, + }) ), }; }; @@ -264,15 +253,15 @@ var EmailVerification = /** @class */ (function (_super) { var error = "No instance of EmailVerification found. Make sure to call the EmailVerification.init method."; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { - error = error + genericComponentOverrideContext.SSR_ERROR; + error = error + superTokens.SSR_ERROR; } throw Error(error); } return EmailVerification.instance; }; EmailVerification.prototype.isEmailVerified = function (userContext) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -288,7 +277,7 @@ var EmailVerification = /** @class */ (function (_super) { }); }; EmailVerification.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } EmailVerification.instance = undefined; diff --git a/lib/build/emailverification-shared2.js b/lib/build/emailverification-shared2.js index 988181f8d..7fb4ce474 100644 --- a/lib/build/emailverification-shared2.js +++ b/lib/build/emailverification-shared2.js @@ -2,7 +2,7 @@ var jsxRuntime = require("react/jsx-runtime"); var React = require("react"); -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var uiEntry = require("./index2.js"); var styles = @@ -27,27 +27,24 @@ var ThemeBase = function (_a) { }; var defaultTranslationsEmailVerification = { - en: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, uiEntry.defaultTranslationsCommon.en), - { - EMAIL_VERIFICATION_RESEND_SUCCESS: "Email resent", - EMAIL_VERIFICATION_SEND_TITLE: "Verify your email address", - EMAIL_VERIFICATION_SEND_DESC_START: "", - EMAIL_VERIFICATION_SEND_DESC_STRONG: "Please click on the link", - EMAIL_VERIFICATION_SEND_DESC_END: " in the email we just sent you to confirm your email address.", - EMAIL_VERIFICATION_RESEND_BTN: "Resend Email", - EMAIL_VERIFICATION_LOGOUT: "Logout ", - EMAIL_VERIFICATION_SUCCESS: "Email verification successful!", - EMAIL_VERIFICATION_CONTINUE_BTN: "CONTINUE", - EMAIL_VERIFICATION_CONTINUE_LINK: "Continue", - EMAIL_VERIFICATION_EXPIRED: "The email verification link has expired", - EMAIL_VERIFICATION_ERROR_TITLE: "Something went wrong", - EMAIL_VERIFICATION_ERROR_DESC: "We encountered an unexpected error. Please contact support for assistance", - EMAIL_VERIFICATION_LINK_CLICKED_HEADER: "Verify your email address", - EMAIL_VERIFICATION_LINK_CLICKED_DESC: "Please click on the button below to verify your email address", - EMAIL_VERIFICATION_LINK_CLICKED_CONTINUE_BUTTON: "CONTINUE", - } - ), + en: superTokens.__assign(superTokens.__assign({}, uiEntry.defaultTranslationsCommon.en), { + EMAIL_VERIFICATION_RESEND_SUCCESS: "Email resent", + EMAIL_VERIFICATION_SEND_TITLE: "Verify your email address", + EMAIL_VERIFICATION_SEND_DESC_START: "", + EMAIL_VERIFICATION_SEND_DESC_STRONG: "Please click on the link", + EMAIL_VERIFICATION_SEND_DESC_END: " in the email we just sent you to confirm your email address.", + EMAIL_VERIFICATION_RESEND_BTN: "Resend Email", + EMAIL_VERIFICATION_LOGOUT: "Logout ", + EMAIL_VERIFICATION_SUCCESS: "Email verification successful!", + EMAIL_VERIFICATION_CONTINUE_BTN: "CONTINUE", + EMAIL_VERIFICATION_CONTINUE_LINK: "Continue", + EMAIL_VERIFICATION_EXPIRED: "The email verification link has expired", + EMAIL_VERIFICATION_ERROR_TITLE: "Something went wrong", + EMAIL_VERIFICATION_ERROR_DESC: "We encountered an unexpected error. Please contact support for assistance", + EMAIL_VERIFICATION_LINK_CLICKED_HEADER: "Verify your email address", + EMAIL_VERIFICATION_LINK_CLICKED_DESC: "Please click on the button below to verify your email address", + EMAIL_VERIFICATION_LINK_CLICKED_CONTINUE_BUTTON: "CONTINUE", + }), }; exports.ThemeBase = ThemeBase; diff --git a/lib/build/emailverification.js b/lib/build/emailverification.js index 57f8143f7..4c72c2735 100644 --- a/lib/build/emailverification.js +++ b/lib/build/emailverification.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var recipe = require("./emailverification-shared.js"); require("supertokens-web-js"); require("supertokens-web-js/utils/cookieHandler"); @@ -13,6 +13,7 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); +require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); require("supertokens-web-js/recipe/emailverification"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); @@ -38,13 +39,13 @@ var Wrapper = /** @class */ (function () { return recipe.EmailVerification.init(config); }; Wrapper.isEmailVerified = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailVerification.getInstanceOrThrow().webJSRecipe.isEmailVerified( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -54,13 +55,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.verifyEmail = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailVerification.getInstanceOrThrow().webJSRecipe.verifyEmail( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -70,13 +71,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.sendVerificationEmail = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailVerification.getInstanceOrThrow().webJSRecipe.sendVerificationEmail( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -87,8 +88,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.getEmailVerificationTokenFromURL = function (input) { return recipe.EmailVerification.getInstanceOrThrow().webJSRecipe.getEmailVerificationTokenFromURL( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) diff --git a/lib/build/emailverificationprebuiltui.js b/lib/build/emailverificationprebuiltui.js index fdbac2e2d..b2dab0fe6 100644 --- a/lib/build/emailverificationprebuiltui.js +++ b/lib/build/emailverificationprebuiltui.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var jsxRuntime = require("react/jsx-runtime"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); var uiEntry = require("./index2.js"); @@ -22,10 +22,13 @@ require("supertokens-web-js/utils"); require("supertokens-web-js/utils/normalisedURLDomain"); require("react-dom"); require("./multitenancy-shared.js"); +require("./genericComponentOverrideContext.js"); require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); +require("./oauth2-shared.js"); +require("supertokens-web-js/recipe/oauth2"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); require("supertokens-web-js/recipe/session"); @@ -90,7 +93,7 @@ function ArrowRightIcon(_a) { var color = _a.color; return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "11.272", @@ -121,9 +124,9 @@ var EmailVerificationSendVerifyEmail = function (props) { errorMessage = _b[0], setErrorMessage = _b[1]; var resendEmail = function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var response, e_1; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 5, , 6]); @@ -161,9 +164,9 @@ var EmailVerificationSendVerifyEmail = function (props) { }); }; var logout = function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var e_2; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); @@ -194,8 +197,8 @@ var EmailVerificationSendVerifyEmail = function (props) { ); var checkSendResponse = React.useCallback( function (response) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: if (!(response.status === "EMAIL_ALREADY_VERIFIED_ERROR")) return [3 /*break*/, 2]; @@ -212,8 +215,8 @@ var EmailVerificationSendVerifyEmail = function (props) { [props.config, props.recipeImplementation, props.onEmailAlreadyVerified] ); var handleSendError = React.useCallback(function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -232,15 +235,15 @@ var EmailVerificationSendVerifyEmail = function (props) { }); }); }, []); - genericComponentOverrideContext.useOnMountAPICall(sendVerificationEmail, checkSendResponse, handleSendError); + superTokens.useOnMountAPICall(sendVerificationEmail, checkSendResponse, handleSendError); return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: [ @@ -251,28 +254,28 @@ var EmailVerificationSendVerifyEmail = function (props) { status === "EMAIL_RESENT" && jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "generalSuccess" }, { children: t("EMAIL_VERIFICATION_RESEND_SUCCESS") } ) ), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "sendVerifyEmailIcon" }, { children: jsxRuntime.jsx(emailLargeIcon.EmailLargeIcon, {}) } ) ), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle headerTinyTitle" }, { children: t("EMAIL_VERIFICATION_SEND_TITLE") } ) ), jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "primaryText sendVerifyEmailText" }, { children: [ @@ -288,14 +291,14 @@ var EmailVerificationSendVerifyEmail = function (props) { status !== "EMAIL_RESENT" && jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "link sendVerifyEmailResend", onClick: resendEmail }, { children: t("EMAIL_VERIFICATION_RESEND_BTN") } ) ), jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "secondaryText secondaryLinkWithArrow", onClick: logout }, { children: [ @@ -340,7 +343,7 @@ var SendVerifyEmail = uiEntry.withOverride("EmailVerificationSendVerifyEmail", E function CheckedRoundIcon() { return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "33", @@ -351,7 +354,7 @@ function CheckedRoundIcon() { { children: jsxRuntime.jsxs( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { fill: "rgb(var(--palette-success))", stroke: "rgb(var(--palette-success))" }, { children: [ @@ -396,7 +399,7 @@ function CheckedRoundIcon() { function ErrorLargeIcon() { return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "33", @@ -409,7 +412,7 @@ function ErrorLargeIcon() { children: [ jsxRuntime.jsx( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { fill: "rgb(var(--palette-error))" }, { children: jsxRuntime.jsx("path", { @@ -421,7 +424,7 @@ function ErrorLargeIcon() { ), jsxRuntime.jsx( "text", - genericComponentOverrideContext.__assign( + superTokens.__assign( { fill: "#fff", "font-family": "Rubik-Bold, Rubik", @@ -432,7 +435,7 @@ function ErrorLargeIcon() { { children: jsxRuntime.jsx( "tspan", - genericComponentOverrideContext.__assign({ x: "0", y: "0" }, { children: "!" }) + superTokens.__assign({ x: "0", y: "0" }, { children: "!" }) ), } ) @@ -459,8 +462,8 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { setVerifyLoading = _c[1]; var verifyEmailOnMount = React.useCallback( function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { if (sessionContext.loading === true) { // This callback should only be called if the session is already loaded throw new Error("Should never come here"); @@ -484,8 +487,8 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { ); var handleVerifyResp = React.useCallback( function (response) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { if (response === "INTERACTION_REQUIRED") { setStatus("INTERACTION_REQUIRED"); } else if (response.status === "EMAIL_VERIFICATION_INVALID_TOKEN_ERROR") { @@ -508,28 +511,23 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { }, [setStatus, setErrorMessage] ); - genericComponentOverrideContext.useOnMountAPICall( - verifyEmailOnMount, - handleVerifyResp, - handleError, - sessionContext.loading === false - ); + superTokens.useOnMountAPICall(verifyEmailOnMount, handleVerifyResp, handleError, sessionContext.loading === false); var onTokenInvalidRedirect = props.onTokenInvalidRedirect, onSuccess = props.onSuccess; if (status === "LOADING") { return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "spinner" }, { children: jsxRuntime.jsx(uiEntry.SpinnerIcon, {}) } ) @@ -544,25 +542,25 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { if (status === "INTERACTION_REQUIRED") { return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row noFormRow" }, { children: [ jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle" }, { children: t("EMAIL_VERIFICATION_LINK_CLICKED_HEADER") } ) ), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: t("EMAIL_VERIFICATION_LINK_CLICKED_DESC") } ) @@ -570,44 +568,36 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { jsxRuntime.jsx(button.Button, { isLoading: verifyLoading, onClick: function () { - return genericComponentOverrideContext.__awaiter( - void 0, - void 0, - void 0, - function () { - var resp, err_1; - return genericComponentOverrideContext.__generator( - this, - function (_a) { - switch (_a.label) { - case 0: - setVerifyLoading(true); - _a.label = 1; - case 1: - _a.trys.push([1, 4, , 5]); - return [ - 4 /*yield*/, - props.recipeImplementation.verifyEmail({ - userContext: userContext, - }), - ]; - case 2: - resp = _a.sent(); - return [4 /*yield*/, handleVerifyResp(resp)]; - case 3: - _a.sent(); - return [3 /*break*/, 5]; - case 4: - err_1 = _a.sent(); - void handleError(err_1); - return [3 /*break*/, 5]; - case 5: - return [2 /*return*/]; - } - } - ); - } - ); + return superTokens.__awaiter(void 0, void 0, void 0, function () { + var resp, err_1; + return superTokens.__generator(this, function (_a) { + switch (_a.label) { + case 0: + setVerifyLoading(true); + _a.label = 1; + case 1: + _a.trys.push([1, 4, , 5]); + return [ + 4 /*yield*/, + props.recipeImplementation.verifyEmail({ + userContext: userContext, + }), + ]; + case 2: + resp = _a.sent(); + return [4 /*yield*/, handleVerifyResp(resp)]; + case 3: + _a.sent(); + return [3 /*break*/, 5]; + case 4: + err_1 = _a.sent(); + void handleError(err_1); + return [3 /*break*/, 5]; + case 5: + return [2 /*return*/]; + } + }); + }); }, type: "button", label: "EMAIL_VERIFICATION_LINK_CLICKED_CONTINUE_BUTTON", @@ -623,26 +613,26 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { if (status === "SUCCESSFUL") { return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row noFormRow" }, { children: [ jsxRuntime.jsx(CheckedRoundIcon, {}), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle headerTinyTitle" }, { children: t("EMAIL_VERIFICATION_SUCCESS") } ) ), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "emailVerificationButtonWrapper" }, { children: jsxRuntime.jsx(button.Button, { @@ -665,25 +655,25 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { if (status === "INVALID") { return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row noFormRow" }, { children: [ jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle headerTinyTitle" }, { children: t("EMAIL_VERIFICATION_EXPIRED") } ) ), jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { onClick: onTokenInvalidRedirect, "data-supertokens": "secondaryText secondaryLinkWithArrow", @@ -708,18 +698,18 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { } return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row noFormRow" }, { children: [ jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle error" }, { children: [ @@ -731,7 +721,7 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { ), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "primaryText" }, { children: t( @@ -759,32 +749,26 @@ function EmailVerificationTheme(props) { var sessionContext = session.useSessionContext(); // If we have a token, return VerifyEmailLinkClicked. if (props.verifyEmailLinkClickedScreen !== undefined) { - return jsxRuntime.jsx( - VerifyEmailLinkClicked, - genericComponentOverrideContext.__assign({}, props.verifyEmailLinkClickedScreen) - ); + return jsxRuntime.jsx(VerifyEmailLinkClicked, superTokens.__assign({}, props.verifyEmailLinkClickedScreen)); } // If we have an active session, we want to send the verification email if (sessionContext.loading === false && sessionContext.doesSessionExist === true) { - return jsxRuntime.jsx( - SendVerifyEmail, - genericComponentOverrideContext.__assign({}, props.sendVerifyEmailScreen) - ); + return jsxRuntime.jsx(SendVerifyEmail, superTokens.__assign({}, props.sendVerifyEmailScreen)); } // Otherwise, return an empty screen, waiting for the feature component to redirection to complete. return jsxRuntime.jsx(jsxRuntime.Fragment, {}); } function EmailVerificationThemeWrapper(props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( translations.ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [ @@ -795,12 +779,7 @@ function EmailVerificationThemeWrapper(props) { : props.config.verifyEmailLinkClickedScreen.style, ], }, - { - children: jsxRuntime.jsx( - EmailVerificationTheme, - genericComponentOverrideContext.__assign({}, props) - ), - } + { children: jsxRuntime.jsx(EmailVerificationTheme, superTokens.__assign({}, props)) } ) ), } @@ -814,7 +793,7 @@ var EmailVerification$1 = function (props) { var _b = React.useState("LOADING"), status = _b[0], setStatus = _b[1]; - var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var rethrowInRender = superTokens.useRethrowInRender(); var recipeComponentOverrides = props.useComponentOverrides(); var userContext = uiEntry.useUserContext(); if (props.userContext !== undefined) { @@ -822,8 +801,8 @@ var EmailVerification$1 = function (props) { } var redirectToAuthWithHistory = React.useCallback( function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -841,33 +820,30 @@ var EmailVerification$1 = function (props) { ); var modifiedRecipeImplementation = React.useMemo( function () { - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, props.recipe.webJSRecipe), - { - sendVerificationEmail: function (input) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - var response; - return genericComponentOverrideContext.__generator(this, function (_a) { - switch (_a.label) { - case 0: - return [4 /*yield*/, props.recipe.webJSRecipe.sendVerificationEmail(input)]; - case 1: - response = _a.sent(); - genericComponentOverrideContext.clearQueryParams(["token"]); - return [2 /*return*/, response]; - } - }); + return superTokens.__assign(superTokens.__assign({}, props.recipe.webJSRecipe), { + sendVerificationEmail: function (input) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + var response; + return superTokens.__generator(this, function (_a) { + switch (_a.label) { + case 0: + return [4 /*yield*/, props.recipe.webJSRecipe.sendVerificationEmail(input)]; + case 1: + response = _a.sent(); + superTokens.clearQueryParams(["token"]); + return [2 /*return*/, response]; + } }); - }, - } - ); + }); + }, + }); }, [props.recipe] ); var onSuccess = React.useCallback( function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, types.Session.getInstanceOrThrow() @@ -887,10 +863,10 @@ var EmailVerification$1 = function (props) { ); var fetchIsEmailVerified = React.useCallback( function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var token; var _a; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: if (sessionContext.loading === true) { @@ -898,9 +874,7 @@ var EmailVerification$1 = function (props) { throw new Error("Should never come here"); } token = - (_a = genericComponentOverrideContext.getQueryParams("token")) !== null && _a !== void 0 - ? _a - : undefined; + (_a = superTokens.getQueryParams("token")) !== null && _a !== void 0 ? _a : undefined; if (!(token === undefined)) return [3 /*break*/, 4]; if (!!sessionContext.doesSessionExist) return [3 /*break*/, 2]; return [4 /*yield*/, redirectToAuthWithHistory()]; @@ -925,8 +899,8 @@ var EmailVerification$1 = function (props) { ); var checkIsEmailVerified = React.useCallback( function (isVerified) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { if (isVerified) { return [2 /*return*/, onSuccess()]; } @@ -939,8 +913,8 @@ var EmailVerification$1 = function (props) { ); var handleError = React.useCallback( function (err) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -963,7 +937,7 @@ var EmailVerification$1 = function (props) { }, [redirectToAuthWithHistory] ); - genericComponentOverrideContext.useOnMountAPICall( + superTokens.useOnMountAPICall( fetchIsEmailVerified, checkIsEmailVerified, handleError, @@ -971,9 +945,9 @@ var EmailVerification$1 = function (props) { ); var signOut = React.useCallback( function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var session; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: session = types.Session.getInstanceOrThrow(); @@ -1000,8 +974,7 @@ var EmailVerification$1 = function (props) { redirectToAuth: redirectToAuthWithHistory, }; var verifyEmailLinkClickedScreenFeature = props.recipe.config.verifyEmailLinkClickedScreen; - var token = - (_a = genericComponentOverrideContext.getQueryParams("token")) !== null && _a !== void 0 ? _a : undefined; + var token = (_a = superTokens.getQueryParams("token")) !== null && _a !== void 0 ? _a : undefined; var verifyEmailLinkClickedScreen = token === undefined ? undefined @@ -1021,14 +994,14 @@ var EmailVerification$1 = function (props) { }; return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { - useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, + useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, defaultStore: translations.defaultTranslationsEmailVerification, }, { @@ -1037,7 +1010,7 @@ var EmailVerification$1 = function (props) { props.children === undefined && jsxRuntime.jsx( EmailVerificationThemeWrapper, - genericComponentOverrideContext.__assign({}, childProps) + superTokens.__assign({}, childProps) ), props.children && React__namespace.Children.map(props.children, function (child) { @@ -1057,7 +1030,7 @@ var EmailVerification$1 = function (props) { }; var EmailVerificationPreBuiltUI = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(EmailVerificationPreBuiltUI, _super); + superTokens.__extends(EmailVerificationPreBuiltUI, _super); function EmailVerificationPreBuiltUI(recipeInstance) { var _this = _super.call(this) || this; _this.recipeInstance = recipeInstance; @@ -1073,9 +1046,7 @@ var EmailVerificationPreBuiltUI = /** @class */ (function (_super) { new NormalisedURLPath__default.default(recipe.DEFAULT_VERIFY_EMAIL_PATH) ); features[normalisedFullPath.getAsStringDangerous()] = { - matches: genericComponentOverrideContext.matchRecipeIdUsingQueryParams( - _this.recipeInstance.config.recipeId - ), + matches: superTokens.matchRecipeIdUsingQueryParams(_this.recipeInstance.config.recipeId), component: function (props) { return _this.getFeatureComponent("emailverification", props, useComponentOverrides); }, @@ -1095,12 +1066,12 @@ var EmailVerificationPreBuiltUI = /** @class */ (function (_super) { } return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( session.SessionAuth, - genericComponentOverrideContext.__assign( + superTokens.__assign( { requireAuth: false, overrideGlobalClaimValidators: function () { @@ -1112,18 +1083,15 @@ var EmailVerificationPreBuiltUI = /** @class */ (function (_super) { children: function (value) { return jsxRuntime.jsx( EmailVerification$1, - genericComponentOverrideContext.__assign( + superTokens.__assign( { recipe: _this.recipeInstance, useComponentOverrides: useComponentOverrides, }, - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, props), - { - // We do this to make sure it does not add another provider - userContext: value, - } - ) + superTokens.__assign(superTokens.__assign({}, props), { + // We do this to make sure it does not add another provider + userContext: value, + }) ) ); }, @@ -1166,7 +1134,7 @@ var EmailVerificationPreBuiltUI = /** @class */ (function (_super) { }; // For tests EmailVerificationPreBuiltUI.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } EmailVerificationPreBuiltUI.instance = undefined; diff --git a/lib/build/genericComponentOverrideContext.js b/lib/build/genericComponentOverrideContext.js index 8cb5d736f..4d5d3f5d7 100644 --- a/lib/build/genericComponentOverrideContext.js +++ b/lib/build/genericComponentOverrideContext.js @@ -1,1421 +1,14 @@ "use strict"; -var SuperTokensWebJS = require("supertokens-web-js"); -var cookieHandler = require("supertokens-web-js/utils/cookieHandler"); -var postSuperTokensInitCallbacks = require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); -var windowHandler = require("supertokens-web-js/utils/windowHandler"); -var MultitenancyWebJS = require("supertokens-web-js/recipe/multitenancy"); -var utils = require("supertokens-web-js/utils"); -var React = require("react"); -var NormalisedURLDomain = require("supertokens-web-js/utils/normalisedURLDomain"); -var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); +var superTokens = require("./superTokens.js"); var jsxRuntime = require("react/jsx-runtime"); +var React = require("react"); function _interopDefault(e) { return e && e.__esModule ? e : { default: e }; } -var SuperTokensWebJS__default = /*#__PURE__*/ _interopDefault(SuperTokensWebJS); -var MultitenancyWebJS__default = /*#__PURE__*/ _interopDefault(MultitenancyWebJS); var React__default = /*#__PURE__*/ _interopDefault(React); -var NormalisedURLDomain__default = /*#__PURE__*/ _interopDefault(NormalisedURLDomain); -var NormalisedURLPath__default = /*#__PURE__*/ _interopDefault(NormalisedURLPath); - -/****************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -/* global Reflect, Promise, SuppressedError, Symbol */ - -var extendStatics = function (d, b) { - extendStatics = - Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && - function (d, b) { - d.__proto__ = b; - }) || - function (d, b) { - for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; - }; - return extendStatics(d, b); -}; - -function __extends(d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { - this.constructor = d; - } - d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); -} - -exports.__assign = function () { - exports.__assign = - Object.assign || - function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - return exports.__assign.apply(this, arguments); -}; - -function __rest(s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; - } - return t; -} - -function __awaiter(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function (resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} - -function __generator(thisArg, body) { - var _ = { - label: 0, - sent: function () { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [], - }, - f, - y, - t, - g; - return ( - (g = { next: verb(0), throw: verb(1), return: verb(2) }), - typeof Symbol === "function" && - (g[Symbol.iterator] = function () { - return this; - }), - g - ); - function verb(n) { - return function (v) { - return step([n, v]); - }; - } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while ((g && ((g = 0), op[0] && (_ = 0)), _)) - try { - if ( - ((f = 1), - y && - (t = - op[0] & 2 - ? y["return"] - : op[0] - ? y["throw"] || ((t = y["return"]) && t.call(y), 0) - : y.next) && - !(t = t.call(y, op[1])).done) - ) - return t; - if (((y = 0), t)) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if (!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && (op[0] === 6 || op[0] === 2)) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; - } -} - -function __spreadArray(to, from, pack) { - if (pack || arguments.length === 2) - for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -} - -typeof SuppressedError === "function" - ? SuppressedError - : function (error, suppressed, message) { - var e = new Error(message); - return (e.name = "SuppressedError"), (e.error = error), (e.suppressed = suppressed), e; - }; - -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. - * - * This software is licensed under the Apache License, Version 2.0 (the - * "License") as published by the Apache Software Foundation. - * - * You may not use this file except in compliance with the License. You may - * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -/* - * Consts. - */ -var RECIPE_ID_QUERY_PARAM = "rid"; -var DEFAULT_API_BASE_PATH = "/auth"; -var DEFAULT_WEBSITE_BASE_PATH = "/auth"; -var ST_ROOT_ID = "supertokens-root"; -var SSR_ERROR = - "\nIf you are trying to use this method doing server-side-rendering, please make sure you move this method inside a componentDidMount method or useEffect hook."; - -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. - * - * This software is licensed under the Apache License, Version 2.0 (the - * "License") as published by the Apache Software Foundation. - * - * You may not use this file except in compliance with the License. You may - * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -var package_version = "0.42.2"; - -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. - * - * This software is licensed under the Apache License, Version 2.0 (the - * "License") as published by the Apache Software Foundation. - * - * You may not use this file except in compliance with the License. You may - * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -var SUPERTOKENS_DEBUG_NAMESPACE = "com.supertokens.auth-react"; -var __debugLogsEnabled = false; -function enableLogging() { - __debugLogsEnabled = true; -} -function logDebugMessage(message) { - if (__debugLogsEnabled) { - // eslint-disable-next-line no-console - console.log( - "" - .concat(SUPERTOKENS_DEBUG_NAMESPACE, ' {t: "') - .concat(new Date().toISOString(), '", message: "') - .concat(message, '", supertokens-auth-react-ver: "') - .concat(package_version, '"}') - ); - } -} - -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. - * - * This software is licensed under the Apache License, Version 2.0 (the - * "License") as published by the Apache Software Foundation. - * - * You may not use this file except in compliance with the License. You may - * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -/* - * getRecipeIdFromPath - * Input: - * Output: The "rid" query param if present, null otherwise. - */ -function getRecipeIdFromSearch(search) { - var urlParams = new URLSearchParams(search); - return urlParams.get(RECIPE_ID_QUERY_PARAM); -} -function clearQueryParams(paramNames) { - var newURL = new URL(windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHref()); - for (var _i = 0, paramNames_1 = paramNames; _i < paramNames_1.length; _i++) { - var param = paramNames_1[_i]; - newURL.searchParams.delete(param); - } - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.replaceState( - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.getState(), - "", - newURL.toString() - ); -} -function updateQueryParam(name, value) { - var newURL = new URL(windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHref()); - newURL.searchParams.set(name, value); - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.replaceState( - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.getState(), - "", - newURL.toString() - ); -} -function clearErrorQueryParam() { - clearQueryParams(["error", "message"]); -} -function getQueryParams(param) { - var urlParams = new URLSearchParams( - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getSearch() - ); - return urlParams.get(param); -} -function getURLHash() { - // By default it is returined with the "#" at the beginning, we cut that off here. - return windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHash().substr(1); -} -function getRedirectToPathFromURL() { - var redirectToPath = getQueryParams("redirectToPath"); - if (redirectToPath === null) { - return undefined; - } else { - try { - var url = void 0; - try { - url = new URL(redirectToPath); - } catch (error) { - var fakeDomain = redirectToPath.startsWith("/") ? "http://localhost" : "http://localhost/"; - url = new URL("".concat(fakeDomain).concat(redirectToPath)); - } - // Prevent Open redirects by normalising path. - var normalisedURLPath = new NormalisedURLPath__default.default(redirectToPath).getAsStringDangerous(); - var pathQueryParams = url.search || ""; // url.search contains the leading ? - var pathHash = url.hash || ""; // url.hash contains the leading # - var pathWithQueryParamsAndHash = normalisedURLPath + pathQueryParams + pathHash; - // Ensure a leading "/" if `normalisedUrlPath` is empty but `pathWithQueryParamsAndHash` is not to ensure proper redirection. - // Example: "?test=1" will not redirect the user to `/?test=1` if we don't add a leading "/". - if ( - normalisedURLPath.length === 0 && - pathWithQueryParamsAndHash.length > 0 && - !pathWithQueryParamsAndHash.startsWith("/") - ) { - return "/" + pathWithQueryParamsAndHash; - } - return pathWithQueryParamsAndHash; - } catch (_a) { - return undefined; - } - } -} -/* - * isTest - */ -function isTest() { - try { - return process.env.TEST_MODE === "testing" || process.env.REACT_APP_TEST_MODE === "testing"; - } catch (err) { - // can get Uncaught ReferenceError: process is not defined error - return false; - } -} -function normaliseInputAppInfoOrThrowError(appInfo) { - if (appInfo === undefined) { - throw new Error("Please provide the appInfo object when calling supertokens.init"); - } - if (appInfo.apiDomain === undefined) { - throw new Error("Please provide your apiDomain inside the appInfo object when calling supertokens.init"); - } - if (appInfo.appName === undefined) { - throw new Error("Please provide your appName inside the appInfo object when calling supertokens.init"); - } - if (appInfo.websiteDomain === undefined) { - throw new Error("Please provide your websiteDomain inside the appInfo object when calling supertokens.init"); - } - var apiGatewayPath = new NormalisedURLPath__default.default(""); - if (appInfo.apiGatewayPath !== undefined) { - apiGatewayPath = new NormalisedURLPath__default.default(appInfo.apiGatewayPath); - } - return { - appName: appInfo.appName, - apiDomain: new NormalisedURLDomain__default.default(appInfo.apiDomain), - websiteDomain: new NormalisedURLDomain__default.default(appInfo.websiteDomain), - apiBasePath: apiGatewayPath.appendPath( - getNormalisedURLPathOrDefault(DEFAULT_API_BASE_PATH, appInfo.apiBasePath) - ), - websiteBasePath: getNormalisedURLPathOrDefault(DEFAULT_WEBSITE_BASE_PATH, appInfo.websiteBasePath), - }; -} -function getNormalisedURLPathOrDefault(defaultPath, path) { - if (path !== undefined) { - return new NormalisedURLPath__default.default(path); - } else { - return new NormalisedURLPath__default.default(defaultPath); - } -} -/* - * validateForm - */ -// We check that the number of fields in input and config form field is the same. -// We check that each item in the config form field is also present in the input form field -function validateForm(inputs, configFormFields) { - return __awaiter(this, void 0, void 0, function () { - var validationErrors, _loop_1, i; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - validationErrors = []; - if (configFormFields.length !== inputs.length) { - throw Error("Are you sending too many / too few formFields?"); - } - _loop_1 = function (i) { - var field, input, value, error; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - field = configFormFields[i]; - input = inputs.find(function (i) { - return i.id === field.id; - }); - value = input.value; - if (input.id === "email") { - value = value.trim(); - } - return [4 /*yield*/, field.validate(value)]; - case 1: - error = _b.sent(); - // If error, add it. - if (error !== undefined) { - validationErrors.push({ - error: error, - id: field.id, - }); - } - return [2 /*return*/]; - } - }); - }; - i = 0; - _a.label = 1; - case 1: - if (!(i < configFormFields.length)) return [3 /*break*/, 4]; - return [5 /*yield**/, _loop_1(i)]; - case 2: - _a.sent(); - _a.label = 3; - case 3: - i++; - return [3 /*break*/, 1]; - case 4: - return [2 /*return*/, validationErrors]; - } - }); - }); -} -/* - * getCurrentNormalisedUrlPath - */ -function getCurrentNormalisedUrlPath() { - return new NormalisedURLPath__default.default( - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getPathName() - ); -} -function getCurrentNormalisedUrlPathWithQueryParamsAndFragments() { - var normalisedUrlPath = getCurrentNormalisedUrlPath().getAsStringDangerous(); - return ( - normalisedUrlPath + - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getSearch() + - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHash() - ); -} -function appendQueryParamsToURL(stringUrl, queryParams) { - if (queryParams === undefined) { - return stringUrl; - } - try { - var url_1 = new URL(stringUrl); - Object.entries(queryParams).forEach(function (_a) { - var key = _a[0], - value = _a[1]; - url_1.searchParams.set(key, value); - }); - return url_1.href; - } catch (e) { - var fakeDomain = stringUrl.startsWith("/") ? "http://localhost" : "http://localhost/"; - var url_2 = new URL("".concat(fakeDomain).concat(stringUrl)); - Object.entries(queryParams).forEach(function (_a) { - var key = _a[0], - value = _a[1]; - url_2.searchParams.set(key, value); - }); - return "".concat(url_2.pathname).concat(url_2.search).concat(url_2.hash); - } -} -function appendTrailingSlashToURL(stringUrl) { - return stringUrl.endsWith("/") ? stringUrl : stringUrl + "/"; -} -/* - * Default method for matching recipe route based on query params. - */ -function matchRecipeIdUsingQueryParams(recipeId) { - return function () { - var recipeIdFromSearch = getRecipeIdFromSearch( - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getSearch() - ); - return recipeIdFromSearch === recipeId; - }; -} -function redirectWithFullPageReload(to) { - if (to.trim() === "") { - to = "/"; - } - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.setHref(to); -} -function redirectWithNavigate(to, navigate) { - if (to.trim() === "") { - to = "/"; - } - if ("push" in navigate) { - // we are using react-router-dom that is before v6 - navigate.push(to); - } else { - // in react-router-dom v6, it is just navigate(to) - navigate(to); - } -} -function getOriginOfPage() { - return new NormalisedURLDomain__default.default( - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getOrigin() - ); -} -function getLocalStorage(key) { - return __awaiter(this, void 0, void 0, function () { - var res; - return __generator(this, function (_a) { - res = windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.localStorage.getItem(key); - if (res === null || res === undefined) { - return [2 /*return*/, null]; - } - return [2 /*return*/, res]; - }); - }); -} -function setLocalStorage(key, value) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - return [ - 4 /*yield*/, - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.localStorage.setItem( - key, - value - ), - ]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); -} -function removeFromLocalStorage(key) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - return [ - 4 /*yield*/, - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.localStorage.removeItem( - key - ), - ]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); -} -function mergeObjects(obj1, obj2) { - var res = exports.__assign({}, obj1); - for (var key in obj2) { - if (typeof res[key] === "object" && typeof obj2[key] === "object") { - res[key] = mergeObjects(res[key], obj2[key]); - } else { - res[key] = obj2[key]; - } - } - return res; -} -function normaliseCookieScopeOrThrowError(cookieScope) { - function helper(cookieScope) { - cookieScope = cookieScope.trim().toLowerCase(); - // first we convert it to a URL so that we can use the URL class - if (cookieScope.startsWith(".")) { - cookieScope = cookieScope.substr(1); - } - if (!cookieScope.startsWith("http://") && !cookieScope.startsWith("https://")) { - cookieScope = "http://" + cookieScope; - } - try { - var urlObj = new URL(cookieScope); - cookieScope = urlObj.hostname; - // remove leading dot - if (cookieScope.startsWith(".")) { - cookieScope = cookieScope.substr(1); - } - return cookieScope; - } catch (err) { - throw new Error("Please provide a valid cookie scope"); - } - } - function isAnIpAddress(ipaddress) { - return /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test( - ipaddress - ); - } - var noDotNormalised = helper(cookieScope); - if (noDotNormalised === "localhost" || isAnIpAddress(noDotNormalised)) { - return noDotNormalised; - } - if (cookieScope.startsWith(".")) { - return "." + noDotNormalised; - } - return noDotNormalised; -} -function getDefaultCookieScope() { - try { - return normaliseCookieScopeOrThrowError( - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHostName() - ); - } catch (_a) { - return undefined; - } -} -function getCookieValue(name) { - return __awaiter(this, void 0, void 0, function () { - var value, _a, parts, last, temp; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - _a = "; "; - return [ - 4 /*yield*/, - cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.getCookie(), - ]; - case 1: - value = _a + _b.sent(); - parts = value.split("; " + name + "="); - if (parts.length >= 2) { - last = parts.pop(); - if (last !== undefined) { - temp = last.split(";").shift(); - if (temp === undefined) { - return [2 /*return*/, null]; - } - return [2 /*return*/, temp]; - } - } - return [2 /*return*/, null]; - } - }); - }); -} -// undefined value will remove the cookie -function setFrontendCookie(name, value, scope) { - return __awaiter(this, void 0, void 0, function () { - var expires, cookieVal; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - expires = "Thu, 01 Jan 1970 00:00:01 GMT"; - cookieVal = ""; - if (value !== undefined) { - cookieVal = value; - expires = undefined; // set cookie without expiry - } - if ( - !( - scope === "localhost" || - scope === - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHostName() || - scope === undefined - ) - ) - return [3 /*break*/, 5]; - if (!(expires !== undefined)) return [3 /*break*/, 2]; - return [ - 4 /*yield*/, - cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( - "".concat(name, "=").concat(cookieVal, ";expires=").concat(expires, ";path=/;samesite=lax") - ), - ]; - case 1: - _a.sent(); - return [3 /*break*/, 4]; - case 2: - return [ - 4 /*yield*/, - cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( - "" - .concat(name, "=") - .concat(cookieVal, ";expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/;samesite=lax") - ), - ]; - case 3: - _a.sent(); - _a.label = 4; - case 4: - return [3 /*break*/, 9]; - case 5: - if (!(expires !== undefined)) return [3 /*break*/, 7]; - return [ - 4 /*yield*/, - cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( - "" - .concat(name, "=") - .concat(cookieVal, ";expires=") - .concat(expires, ";domain=") - .concat(scope, ";path=/;samesite=lax") - ), - ]; - case 6: - _a.sent(); - return [3 /*break*/, 9]; - case 7: - return [ - 4 /*yield*/, - cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( - "" - .concat(name, "=") - .concat(cookieVal, ";domain=") - .concat(scope, ";expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/;samesite=lax") - ), - ]; - case 8: - _a.sent(); - _a.label = 9; - case 9: - return [2 /*return*/]; - } - }); - }); -} -function getNormalisedUserContext(userContext) { - return userContext === undefined ? {} : userContext; -} -/** - * This function handles calling APIs that should only be called once during mount (mostly on mount of a route/feature component). - * It's split into multiple callbacks (fetch + handleResponse/handleError) because we expect fetch to take longer and - * and the component may be unmounted during the first fetch, in which case we want to avoid updating state/redirecting. - * This is especially relevant for development in strict mode with React 18 (and in the future for concurrent rendering). - * - * @param fetch This is a callback that is only called once on mount. Mostly it's for consuming tokens/doing one time only API calls - * @param handleResponse This is called with the result of the first (fetch) call if it succeeds. - * @param handleError This is called with the error of the first (fetch) call if it rejects. - * @param startLoading Will start the whole process if this is set to true (or omitted). Mostly used to wait for session loading. - */ -var useOnMountAPICall = function (fetch, handleResponse, handleError, startLoading) { - if (startLoading === void 0) { - startLoading = true; - } - var consumeReq = React.useRef(); - var _a = React.useState(undefined), - error = _a[0], - setError = _a[1]; - React.useEffect( - function () { - var effect = function (signal) { - return __awaiter(void 0, void 0, void 0, function () { - var resp, err_1, err_2; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 9]); - if (consumeReq.current === undefined) { - consumeReq.current = fetch(); - } - return [4 /*yield*/, consumeReq.current]; - case 1: - resp = _a.sent(); - if (!signal.aborted) { - void handleResponse(resp); - } - return [3 /*break*/, 9]; - case 2: - err_1 = _a.sent(); - if (!!signal.aborted) return [3 /*break*/, 8]; - if (!(handleError !== undefined)) return [3 /*break*/, 7]; - _a.label = 3; - case 3: - _a.trys.push([3, 5, , 6]); - return [4 /*yield*/, handleError(err_1, resp)]; - case 4: - _a.sent(); - return [3 /*break*/, 6]; - case 5: - err_2 = _a.sent(); - setError(err_2); - return [3 /*break*/, 6]; - case 6: - return [3 /*break*/, 8]; - case 7: - setError(err_1); - _a.label = 8; - case 8: - return [3 /*break*/, 9]; - case 9: - return [2 /*return*/]; - } - }); - }); - }; - if (startLoading) { - var ctrl_1 = new AbortController(); - void effect(ctrl_1.signal); - return function () { - ctrl_1.abort(); - }; - } - return; - }, - [setError, consumeReq, fetch, handleResponse, handleError, startLoading] - ); - if (error) { - throw error; - } -}; -function useRethrowInRender() { - var _a = React.useState(undefined), - error = _a[0], - setError = _a[1]; - if (error) { - throw error; - } - return setError; -} - -var BaseRecipeModule = /** @class */ (function () { - /* - * Constructor. - */ - function BaseRecipeModule(config) { - this.config = config; - } - return BaseRecipeModule; -})(); - -function normaliseRecipeModuleConfig(config) { - var _this = this; - if (config === undefined) { - config = {}; - } - var onHandleEvent = config.onHandleEvent, - getRedirectionURL = config.getRedirectionURL, - preAPIHook = config.preAPIHook, - postAPIHook = config.postAPIHook; - if (onHandleEvent === undefined) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function - onHandleEvent = function (_) {}; - } - if (getRedirectionURL === undefined) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - getRedirectionURL = function (_) { - return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2 /*return*/, undefined]; - }); - }); - }; - } - if (preAPIHook === undefined) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - preAPIHook = function (context) { - return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2 /*return*/, context]; - }); - }); - }; - } - if (postAPIHook === undefined) { - // eslint-disable-next-line @typescript-eslint/no-empty-function - postAPIHook = function () { - return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2 /*return*/]; - }); - }); - }; - } - var rootStyle = config.style === undefined ? "" : config.style; - return exports.__assign(exports.__assign({}, config), { - getRedirectionURL: getRedirectionURL, - onHandleEvent: onHandleEvent, - preAPIHook: preAPIHook, - postAPIHook: postAPIHook, - recipeRootStyle: rootStyle, - }); -} - -function normaliseMultitenancyConfig(config) { - return exports.__assign(exports.__assign({}, normaliseRecipeModuleConfig(config)), { - override: exports.__assign( - { - functions: function (originalImplementation) { - return originalImplementation; - }, - }, - config === null || config === void 0 ? void 0 : config.override - ), - }); -} -function hasIntersectingRecipes(tenantMethods, recipeList) { - return tenantMethods.firstFactors.some(function (factorId) { - return recipeList.some(function (r) { - return r.firstFactorIds.includes(factorId); - }); - }); -} - -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. - * - * This software is licensed under the Apache License, Version 2.0 (the - * "License") as published by the Apache Software Foundation. - * - * You may not use this file except in compliance with the License. You may - * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -/* - * Class. - */ -var Multitenancy = /** @class */ (function (_super) { - __extends(Multitenancy, _super); - function Multitenancy(config, webJSRecipe) { - if (webJSRecipe === void 0) { - webJSRecipe = MultitenancyWebJS__default.default; - } - var _this = _super.call(this, config) || this; - _this.webJSRecipe = webJSRecipe; - _this.recipeID = Multitenancy.RECIPE_ID; - _this.dynamicLoginMethodsCache = {}; - return _this; - } - Multitenancy.prototype.getCurrentDynamicLoginMethods = function (input) { - var _a; - return __awaiter(this, void 0, void 0, function () { - var userContext, tenantId, tenantMethods; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - if (SuperTokens.usesDynamicLoginMethods === false) { - return [2 /*return*/, undefined]; - } - userContext = utils.getNormalisedUserContext(input.userContext); - return [4 /*yield*/, Multitenancy.getInstanceOrThrow().webJSRecipe.getTenantId()]; - case 1: - tenantId = (_a = _b.sent()) !== null && _a !== void 0 ? _a : "public"; - if (this.dynamicLoginMethodsCache[tenantId] === undefined) { - this.dynamicLoginMethodsCache[tenantId] = Multitenancy.getDynamicLoginMethods({ - tenantId: tenantId, - userContext: userContext, - }); - } - return [4 /*yield*/, this.dynamicLoginMethodsCache[tenantId]]; - case 2: - tenantMethods = _b.sent(); - if ( - !hasIntersectingRecipes( - tenantMethods, - SuperTokens.getInstanceOrThrow().recipeList.filter(function (recipe) { - return "firstFactorIds" in recipe; - }) - ) - ) { - throw new Error( - "Initialized recipes have no overlap with core recipes or could not load login methods" - ); - } - return [2 /*return*/, tenantMethods]; - } - }); - }); - }; - Multitenancy.getDynamicLoginMethods = function (input) { - return __awaiter(this, void 0, void 0, function () { - var _a, thirdParty, firstFactors; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - return [4 /*yield*/, MultitenancyWebJS__default.default.getLoginMethods(input)]; - case 1: - (_a = _b.sent()), (thirdParty = _a.thirdParty), (firstFactors = _a.firstFactors); - return [ - 2 /*return*/, - { - thirdparty: thirdParty, - firstFactors: firstFactors, - }, - ]; - } - }); - }); - }; - Multitenancy.init = function (config) { - var normalisedConfig = normaliseMultitenancyConfig(config); - return { - recipeID: Multitenancy.RECIPE_ID, - authReact: function (appInfo) { - Multitenancy.instance = new Multitenancy( - exports.__assign(exports.__assign({}, normalisedConfig), { - appInfo: appInfo, - recipeId: Multitenancy.RECIPE_ID, - }) - ); - return Multitenancy.instance; - }, - webJS: MultitenancyWebJS__default.default.init(exports.__assign({}, normalisedConfig)), - }; - }; - Multitenancy.getInstanceOrThrow = function () { - if (Multitenancy.instance === undefined) { - var error = - "No instance of Multitenancy found. Make sure to call the Multitenancy.init method." + - "See https://supertokens.io/docs/multitenancy/quick-setup/frontend"; - // eslint-disable-next-line supertokens-auth-react/no-direct-window-object - if (typeof window === "undefined") { - error = error + SSR_ERROR; - } - throw Error(error); - } - return Multitenancy.instance; - }; - /* - * Tests methods. - */ - Multitenancy.reset = function () { - if (!isTest()) { - return; - } - Multitenancy.instance = undefined; - return; - }; - Multitenancy.RECIPE_ID = "multitenancy"; - return Multitenancy; -})(BaseRecipeModule); - -var TranslationController = /** @class */ (function () { - function TranslationController() { - this.handlers = new Map(); - } - TranslationController.prototype.emit = function (event, detail) { - var handlerList = this.handlers.get(event) || []; - for (var _i = 0, handlerList_1 = handlerList; _i < handlerList_1.length; _i++) { - var h = handlerList_1[_i]; - h(event, detail); - } - }; - TranslationController.prototype.on = function (event, handler) { - var handlerList = this.handlers.get(event) || []; - this.handlers.set(event, handlerList.concat(handler)); - }; - TranslationController.prototype.off = function (event, handler) { - var handlerList = this.handlers.get(event) || []; - this.handlers.set( - event, - handlerList.filter(function (h) { - return h !== handler; - }) - ); - }; - return TranslationController; -})(); -var CURRENT_LANGUAGE_COOKIE_NAME = "sCurrLanguage"; -function saveCurrentLanguage(language, cookieDomain) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - _b.trys.push([0, 2, , 3]); - return [4 /*yield*/, setFrontendCookie(CURRENT_LANGUAGE_COOKIE_NAME, language, cookieDomain)]; - case 1: - _b.sent(); - return [3 /*break*/, 3]; - case 2: - _b.sent(); - return [3 /*break*/, 3]; - case 3: - return [2 /*return*/]; - } - }); - }); -} -function getCurrentLanguageFromCookie() { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - _b.trys.push([0, 2, , 3]); - return [4 /*yield*/, getCookieValue(CURRENT_LANGUAGE_COOKIE_NAME)]; - case 1: - return [2 /*return*/, _b.sent()]; - case 2: - _b.sent(); - // This can throw if we are not in a browser - // Since this is just loading a preference we can safely ignore the exception - return [2 /*return*/, null]; - case 3: - return [2 /*return*/]; - } - }); - }); -} - -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. - * - * This software is licensed under the Apache License, Version 2.0 (the - * "License") as published by the Apache Software Foundation. - * - * You may not use this file except in compliance with the License. You may - * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -/* - * Class. - */ -var SuperTokens = /** @class */ (function () { - /* - * Constructor. - */ - function SuperTokens(config) { - var _this = this; - var _a, _b, _c, _d; - this.recipeList = []; - this.changeLanguage = function (lang) { - return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - return [ - 4 /*yield*/, - saveCurrentLanguage(lang, this.languageTranslations.currentLanguageCookieScope), - ]; - case 1: - _a.sent(); - this.languageTranslations.translationEventSource.emit("LanguageChange", lang); - return [2 /*return*/]; - } - }); - }); - }; - this.redirectToAuth = function (options) { - return __awaiter(_this, void 0, void 0, function () { - var queryParams, redirectUrl; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - queryParams = options.queryParams === undefined ? {} : options.queryParams; - if (options.show !== undefined) { - queryParams.show = options.show; - } - if (options.redirectBack === true) { - queryParams.redirectToPath = getCurrentNormalisedUrlPathWithQueryParamsAndFragments(); - } - return [ - 4 /*yield*/, - this.getRedirectUrl( - { - action: "TO_AUTH", - showSignIn: options.show === "signin", - }, - options.userContext - ), - ]; - case 1: - redirectUrl = _a.sent(); - if (redirectUrl === null) { - logDebugMessage("Skipping redirection because the user override returned null"); - return [2 /*return*/]; - } - redirectUrl = appendQueryParamsToURL(redirectUrl, queryParams); - return [2 /*return*/, this.redirectToUrl(redirectUrl, options.navigate)]; - } - }); - }); - }; - this.redirectToUrl = function (redirectUrl, navigate) { - return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - doRedirection(this.appInfo, redirectUrl, navigate); - return [2 /*return*/]; - }); - }); - }; - this.redirect = function (context, navigate, queryParams, userContext) { - return __awaiter(_this, void 0, void 0, function () { - var redirectUrl; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - return [4 /*yield*/, this.getRedirectUrl(context, getNormalisedUserContext(userContext))]; - case 1: - redirectUrl = _a.sent(); - if (redirectUrl === null) { - logDebugMessage( - "Skipping redirection because the user override returned null for context ".concat( - JSON.stringify(context, null, 2) - ) - ); - return [2 /*return*/]; - } - redirectUrl = appendQueryParamsToURL(redirectUrl, queryParams); - return [ - 2 /*return*/, - SuperTokens.getInstanceOrThrow().redirectToUrl(redirectUrl, navigate), - ]; - } - }); - }); - }; - this.appInfo = normaliseInputAppInfoOrThrowError(config.appInfo); - if (config.recipeList === undefined || config.recipeList.length === 0) { - throw new Error( - "Please provide at least one recipe to the supertokens.init function call. See https://supertokens.io/docs/emailpassword/quick-setup/frontend" - ); - } - var translationConfig = config.languageTranslations === undefined ? {} : config.languageTranslations; - this.languageTranslations = { - defaultLanguage: translationConfig.defaultLanguage === undefined ? "en" : translationConfig.defaultLanguage, - currentLanguageCookieScope: - translationConfig.currentLanguageCookieScope !== undefined - ? normaliseCookieScopeOrThrowError(translationConfig.currentLanguageCookieScope) - : getDefaultCookieScope(), - userTranslationStore: translationConfig.translations !== undefined ? translationConfig.translations : {}, - translationEventSource: new TranslationController(), - userTranslationFunc: translationConfig.translationFunc, - }; - var enableDebugLogs = Boolean(config === null || config === void 0 ? void 0 : config.enableDebugLogs); - if (enableDebugLogs) { - enableLogging(); - } - this.userGetRedirectionURL = config.getRedirectionURL; - this.recipeList = config.recipeList.map(function (_a) { - var authReact = _a.authReact; - return authReact(_this.appInfo, enableDebugLogs); - }); - this.rootStyle = (_a = config.style) !== null && _a !== void 0 ? _a : ""; - this.privacyPolicyLink = config.privacyPolicyLink; - this.termsOfServiceLink = config.termsOfServiceLink; - this.useShadowDom = (_b = config.useShadowDom) !== null && _b !== void 0 ? _b : true; - this.defaultToSignUp = (_c = config.defaultToSignUp) !== null && _c !== void 0 ? _c : false; - this.disableAuthRoute = (_d = config.disableAuthRoute) !== null && _d !== void 0 ? _d : false; - } - /* - * Static Methods. - */ - SuperTokens.init = function (config) { - var _a; - cookieHandler.CookieHandlerReference.init(config.cookieHandler); - windowHandler.WindowHandlerReference.init(config.windowHandler); - if (SuperTokens.instance !== undefined) { - console.warn("SuperTokens was already initialized"); - return; - } - SuperTokens.usesDynamicLoginMethods = - (_a = config.usesDynamicLoginMethods) !== null && _a !== void 0 ? _a : false; - var recipes = - config.recipeList.find(function (recipe) { - return recipe.recipeID === Multitenancy.RECIPE_ID; - }) !== undefined - ? config.recipeList - : config.recipeList.concat(Multitenancy.init({})); - SuperTokensWebJS__default.default.init( - exports.__assign(exports.__assign({}, config), { - recipeList: recipes.map(function (_a) { - var webJS = _a.webJS; - return webJS; - }), - }) - ); - SuperTokens.instance = new SuperTokens(exports.__assign(exports.__assign({}, config), { recipeList: recipes })); - postSuperTokensInitCallbacks.PostSuperTokensInitCallbacks.runPostInitCallbacks(); - }; - SuperTokens.getInstanceOrThrow = function () { - if (SuperTokens.instance === undefined) { - var error = "SuperTokens must be initialized before calling this method."; - // eslint-disable-next-line supertokens-auth-react/no-direct-window-object - if (typeof window === "undefined") { - error = error + SSR_ERROR; - } - throw new Error(error); - } - return SuperTokens.instance; - }; - SuperTokens.prototype.getRecipeOrThrow = function (recipeId) { - var recipe = this.recipeList.find(function (recipe) { - return recipe.config.recipeId === recipeId; - }); - if (recipe === undefined) { - throw new Error("Missing recipe: ".concat(recipeId)); - } - return recipe; - }; - SuperTokens.prototype.loadTranslation = function (store) { - this.languageTranslations.translationEventSource.emit("TranslationLoaded", store); - }; - SuperTokens.prototype.getRedirectUrl = function (context, userContext) { - var _a; - return __awaiter(this, void 0, void 0, function () { - var userRes, redirectUrl; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - if (!this.userGetRedirectionURL) return [3 /*break*/, 2]; - return [4 /*yield*/, this.userGetRedirectionURL(context, userContext)]; - case 1: - userRes = _b.sent(); - if (userRes !== undefined) { - return [2 /*return*/, userRes]; - } - _b.label = 2; - case 2: - if (context.action === "TO_AUTH") { - redirectUrl = this.appInfo.websiteBasePath.getAsStringDangerous(); - return [2 /*return*/, appendTrailingSlashToURL(redirectUrl)]; - } else if (context.action === "SUCCESS") { - return [2 /*return*/, (_a = context.redirectToPath) !== null && _a !== void 0 ? _a : "/"]; - } - throw new Error("Should never come here: unexpected redirection context"); - } - }); - }); - }; - /* - * Tests methods. - */ - SuperTokens.reset = function () { - if (!isTest()) { - return; - } - SuperTokens.instance = undefined; - return; - }; - SuperTokens.usesDynamicLoginMethods = false; - return SuperTokens; -})(); -function doRedirection(appInfo, redirectUrl, navigate) { - try { - new URL(redirectUrl); // If full URL, no error thrown, skip in app redirection. - } catch (e) { - // For multi tenancy, If mismatch between websiteDomain and current location, prepend URL relative path with websiteDomain. - var origin_1 = getOriginOfPage().getAsStringDangerous(); - if (origin_1 !== appInfo.websiteDomain.getAsStringDangerous()) { - redirectUrl = "".concat(appInfo.websiteDomain.getAsStringDangerous()).concat(redirectUrl); - redirectWithFullPageReload(redirectUrl); - return; - } - // If navigate was provided, use to redirect without reloading. - if (navigate !== undefined) { - redirectWithNavigate(redirectUrl, navigate); - return; - } - } - // Otherwise, redirect in app. - redirectWithFullPageReload(redirectUrl); -} var createGenericComponentsOverrideContext = function (v) { if (v === void 0) { @@ -1428,42 +21,12 @@ var createGenericComponentsOverrideContext = function (v) { var Provider = function (_a) { var children = _a.children, components = _a.components; - return jsxRuntime.jsx(genericContext.Provider, exports.__assign({ value: components }, { children: children })); + return jsxRuntime.jsx( + genericContext.Provider, + superTokens.__assign({ value: components }, { children: children }) + ); }; return [useComponentsOverrideContext, Provider, genericContext.Consumer]; }; -exports.BaseRecipeModule = BaseRecipeModule; -exports.Multitenancy = Multitenancy; -exports.SSR_ERROR = SSR_ERROR; -exports.ST_ROOT_ID = ST_ROOT_ID; -exports.SuperTokens = SuperTokens; -exports.__awaiter = __awaiter; -exports.__extends = __extends; -exports.__generator = __generator; -exports.__rest = __rest; -exports.__spreadArray = __spreadArray; -exports.appendQueryParamsToURL = appendQueryParamsToURL; -exports.clearErrorQueryParam = clearErrorQueryParam; -exports.clearQueryParams = clearQueryParams; exports.createGenericComponentsOverrideContext = createGenericComponentsOverrideContext; -exports.getCurrentLanguageFromCookie = getCurrentLanguageFromCookie; -exports.getCurrentNormalisedUrlPath = getCurrentNormalisedUrlPath; -exports.getCurrentNormalisedUrlPathWithQueryParamsAndFragments = getCurrentNormalisedUrlPathWithQueryParamsAndFragments; -exports.getLocalStorage = getLocalStorage; -exports.getNormalisedUserContext = getNormalisedUserContext; -exports.getQueryParams = getQueryParams; -exports.getRedirectToPathFromURL = getRedirectToPathFromURL; -exports.getURLHash = getURLHash; -exports.isTest = isTest; -exports.logDebugMessage = logDebugMessage; -exports.matchRecipeIdUsingQueryParams = matchRecipeIdUsingQueryParams; -exports.mergeObjects = mergeObjects; -exports.normaliseRecipeModuleConfig = normaliseRecipeModuleConfig; -exports.redirectWithFullPageReload = redirectWithFullPageReload; -exports.removeFromLocalStorage = removeFromLocalStorage; -exports.setLocalStorage = setLocalStorage; -exports.updateQueryParam = updateQueryParam; -exports.useOnMountAPICall = useOnMountAPICall; -exports.useRethrowInRender = useRethrowInRender; -exports.validateForm = validateForm; diff --git a/lib/build/index.js b/lib/build/index.js index 3df5aed90..5c44bab66 100644 --- a/lib/build/index.js +++ b/lib/build/index.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -require("./genericComponentOverrideContext.js"); +require("./superTokens.js"); var uiEntry = require("./index2.js"); var translationContext = require("./translationContext.js"); require("supertokens-web-js"); @@ -17,12 +17,15 @@ require("supertokens-web-js/utils/normalisedURLPath"); require("react/jsx-runtime"); require("react-dom"); require("./multitenancy-shared.js"); +require("./genericComponentOverrideContext.js"); require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); require("./multifactorauth-shared.js"); require("supertokens-web-js/recipe/session"); +require("./oauth2-shared.js"); +require("supertokens-web-js/recipe/oauth2"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); diff --git a/lib/build/index2.js b/lib/build/index2.js index e5fb3ff39..89239b8b2 100644 --- a/lib/build/index2.js +++ b/lib/build/index2.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var jsxRuntime = require("react/jsx-runtime"); var React = require("react"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); @@ -8,8 +8,10 @@ var translationContext = require("./translationContext.js"); var windowHandler = require("supertokens-web-js/utils/windowHandler"); var reactDom = require("react-dom"); var componentOverrideContext = require("./multitenancy-shared.js"); -var recipe = require("./multifactorauth-shared2.js"); +var recipe$1 = require("./multifactorauth-shared2.js"); var types = require("./multifactorauth-shared.js"); +var recipe = require("./oauth2-shared.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var utils = require("./authRecipe-shared.js"); var NormalisedURLPath$1 = require("supertokens-web-js/lib/build/normalisedURLPath"); @@ -46,12 +48,12 @@ var ComponentOverrideContext = React__default.default.createContext("IS_DEFAULT" function SpinnerIcon() { return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { version: "1.1", viewBox: "25 25 50 50", "data-supertokens": "spinnerIcon" }, { children: jsxRuntime.jsxs( "circle", - genericComponentOverrideContext.__assign( + superTokens.__assign( { cx: "50", cy: "50", @@ -112,10 +114,10 @@ var withOverride = function (overrideKey, DefaultComponent) { if (OverrideComponent !== null) { return jsxRuntime.jsx( OverrideComponent, - genericComponentOverrideContext.__assign({ DefaultComponent: DefaultComponent }, props) + superTokens.__assign({ DefaultComponent: DefaultComponent }, props) ); } - return jsxRuntime.jsx(DefaultComponent, genericComponentOverrideContext.__assign({}, props)); + return jsxRuntime.jsx(DefaultComponent, superTokens.__assign({}, props)); }; }; @@ -143,17 +145,17 @@ var ThemeBase$1 = function (_a) { var MultitenancyDynamicLoginMethodsSpinnerTheme = function () { return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container delayedRender" }, { children: jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "spinner delayedRender" }, { children: jsxRuntime.jsx(SpinnerIcon, {}) } ) @@ -170,10 +172,10 @@ var DynamicLoginMethodsSpinnerThemeWithOverride = withOverride( MultitenancyDynamicLoginMethodsSpinnerTheme ); var DynamicLoginMethodsSpinnerTheme = function (props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; return jsxRuntime.jsx( ThemeBase$1, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: false, userStyles: [rootStyle, props.config.recipeRootStyle] }, { children: jsxRuntime.jsx(DynamicLoginMethodsSpinnerThemeWithOverride, {}) } ) @@ -185,17 +187,17 @@ var DynamicLoginMethodsSpinnerTheme = function (props) { // - it's used inside FeatureWrapper & RoutingComponent (meaning it can't use FeatureWrapper) // - it's not used in any specific route (multitenancy doesn't have a pre-built UI) var DynamicLoginMethodsSpinner = function () { - var recipe = genericComponentOverrideContext.Multitenancy.getInstanceOrThrow(); + var recipe = superTokens.Multitenancy.getInstanceOrThrow(); var recipeComponentOverrides = componentOverrideContext.useContext(); return jsxRuntime.jsx( ComponentOverrideContext.Provider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( WithOrWithoutShadowDom, - genericComponentOverrideContext.__assign( - { useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom }, + superTokens.__assign( + { useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom }, { children: jsxRuntime.jsx(DynamicLoginMethodsSpinnerTheme, { config: recipe.config }) } ) ), @@ -218,7 +220,7 @@ var DynamicLoginMethodsProvider = function (_a) { var contextValue = value === undefined ? { loaded: false } : { loaded: true, loginMethods: value }; return jsxRuntime.jsx( dynamicLoginMethodsContext.Provider, - genericComponentOverrideContext.__assign({ value: contextValue }, { children: children }) + superTokens.__assign({ value: contextValue }, { children: children }) ); }; @@ -229,10 +231,10 @@ var useUserContext = function () { var UserContextProvider = function (_a) { var children = _a.children, userContext = _a.userContext; - var currentUserContext = React.useState(genericComponentOverrideContext.getNormalisedUserContext(userContext))[0]; + var currentUserContext = React.useState(superTokens.getNormalisedUserContext(userContext))[0]; return jsxRuntime.jsx( UserContextContext.Provider, - genericComponentOverrideContext.__assign({ value: currentUserContext }, { children: children }) + superTokens.__assign({ value: currentUserContext }, { children: children }) ); }; @@ -241,17 +243,17 @@ function FeatureWrapper(_a) { useShadowDom = _a.useShadowDom, defaultStore = _a.defaultStore; var userContext = useUserContext(); - var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var rethrowInRender = superTokens.useRethrowInRender(); var _b = React.useState(undefined), loadedDynamicLoginMethods = _b[0], setLoadedDynamicLoginMethods = _b[1]; - var st = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow(); + var st = superTokens.SuperTokens.getInstanceOrThrow(); React.useEffect( function () { if (loadedDynamicLoginMethods) { return; } - genericComponentOverrideContext.Multitenancy.getInstanceOrThrow() + superTokens.Multitenancy.getInstanceOrThrow() .getCurrentDynamicLoginMethods({ userContext: userContext }) .then( function (loginMethods) { @@ -264,20 +266,20 @@ function FeatureWrapper(_a) { }, [loadedDynamicLoginMethods, setLoadedDynamicLoginMethods] ); - if (genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods && !loadedDynamicLoginMethods) { + if (superTokens.SuperTokens.usesDynamicLoginMethods && !loadedDynamicLoginMethods) { return jsxRuntime.jsx(DynamicLoginMethodsSpinner, {}); } return jsxRuntime.jsx( DynamicLoginMethodsProvider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { value: loadedDynamicLoginMethods }, { children: jsxRuntime.jsx( translationContext.TranslationContextProvider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { defaultLanguage: st.languageTranslations.defaultLanguage, - defaultStore: genericComponentOverrideContext.mergeObjects( + defaultStore: superTokens.mergeObjects( defaultStore, st.languageTranslations.userTranslationStore ), @@ -287,10 +289,7 @@ function FeatureWrapper(_a) { { children: jsxRuntime.jsx( WithOrWithoutShadowDom, - genericComponentOverrideContext.__assign( - { useShadowDom: useShadowDom }, - { children: children } - ) + superTokens.__assign({ useShadowDom: useShadowDom }, { children: children }) ), } ) @@ -323,8 +322,8 @@ function WithShadowDom(_a) { // Otherwise, use shadow dom. return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( - { id: genericComponentOverrideContext.ST_ROOT_ID, ref: rootDiv }, + superTokens.__assign( + { id: superTokens.ST_ROOT_ID, ref: rootDiv }, { children: shadowRoot && reactDom.createPortal(children, shadowRoot) } ) ); @@ -336,8 +335,8 @@ function WithOrWithoutShadowDom(_a) { if (useShadowDom === false) { return jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( - { id: genericComponentOverrideContext.ST_ROOT_ID }, + superTokens.__assign( + { id: superTokens.ST_ROOT_ID }, { children: [children, jsxRuntime.jsx(DisableAutoFillInput, {})] } ) ); @@ -348,7 +347,7 @@ function DisableAutoFillInput() { /* eslint-disable react/jsx-no-literals */ return jsxRuntime.jsx( "style", - genericComponentOverrideContext.__assign( + superTokens.__assign( { type: "text/css" }, { children: @@ -364,6 +363,7 @@ var defaultTranslationsCommon = { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: "Sign Up / Sign In", AUTH_PAGE_HEADER_TITLE_SIGN_IN: "Sign In", AUTH_PAGE_HEADER_TITLE_SIGN_UP: "Sign Up", + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: " to continue to ", AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: "Not registered yet?", AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: "Sign Up", AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: "", @@ -404,7 +404,7 @@ function SuperTokensBranding() { var t = translationContext.useTranslation(); return jsxRuntime.jsxs( "a", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "superTokensBranding", href: "https://supertokens.com?utm_campaign=poweredby", @@ -454,7 +454,7 @@ function UserContextWrapper(props) { if (props.userContext !== undefined) { return jsxRuntime.jsx( UserContextProvider, - genericComponentOverrideContext.__assign({ userContext: props.userContext }, { children: props.children }) + superTokens.__assign({ userContext: props.userContext }, { children: props.children }) ); } return jsxRuntime.jsx(UserContextContext.Consumer, { @@ -484,10 +484,7 @@ function UserContextWrapper(props) { function GeneralError(_a) { var error = _a.error; var t = translationContext.useTranslation(); - return jsxRuntime.jsx( - "div", - genericComponentOverrideContext.__assign({ "data-supertokens": "generalError" }, { children: t(error) }) - ); + return jsxRuntime.jsx("div", superTokens.__assign({ "data-supertokens": "generalError" }, { children: t(error) })); } var styles = @@ -518,14 +515,14 @@ var AuthPageComponentList = withOverride("AuthPageComponentList", function AuthP list.push(function () { return jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "dividerWithOr" }, { children: [ jsxRuntime.jsx("div", { "data-supertokens": "divider" }), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "dividerText" }, { children: t("DIVIDER_OR") } ) @@ -544,11 +541,11 @@ var AuthPageComponentList = withOverride("AuthPageComponentList", function AuthP } return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "authComponentList" }, { children: list.map(function (i) { - return i(genericComponentOverrideContext.__assign({}, props)); + return i(superTokens.__assign({}, props)); }), } ) @@ -569,7 +566,7 @@ var AuthPageFooter = withOverride("AuthPageFooter", function AuthPageFooter(_a) } return jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "secondaryText privacyPolicyAndTermsAndConditions" }, { children: [ @@ -577,7 +574,7 @@ var AuthPageFooter = withOverride("AuthPageFooter", function AuthPageFooter(_a) termsOfServiceLink !== undefined && jsxRuntime.jsx( "a", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "link", href: termsOfServiceLink, @@ -591,7 +588,7 @@ var AuthPageFooter = withOverride("AuthPageFooter", function AuthPageFooter(_a) privacyPolicyLink !== undefined && jsxRuntime.jsx( "a", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "link", href: privacyPolicyLink, @@ -632,7 +629,7 @@ function HeavyArrowLeftIcon(_a) { var color = _a.color; return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "16", @@ -658,7 +655,7 @@ function BackButton(_a) { var onClick = _a.onClick; return jsxRuntime.jsx( "button", - genericComponentOverrideContext.__assign( + superTokens.__assign( { onClick: onClick, "data-supertokens": "backButton backButtonCommon" }, { children: jsxRuntime.jsx(HeavyArrowLeftIcon, { color: "rgb(var(--palette-textTitle))" }) } ) @@ -670,13 +667,14 @@ var AuthPageHeader = withOverride("AuthPageHeader", function AuthPageHeader(_a) hasSeparateSignUpView = _a.hasSeparateSignUpView, isSignUp = _a.isSignUp, showBackButton = _a.showBackButton, - resetFactorList = _a.resetFactorList; + resetFactorList = _a.resetFactorList, + clientAppName = _a.clientAppName; var t = translationContext.useTranslation(); return jsxRuntime.jsxs(React.Fragment, { children: [ jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle withBackButton" }, { children: [ @@ -690,6 +688,8 @@ var AuthPageHeader = withOverride("AuthPageHeader", function AuthPageHeader(_a) : isSignUp ? t("AUTH_PAGE_HEADER_TITLE_SIGN_UP") : t("AUTH_PAGE_HEADER_TITLE_SIGN_IN"), + clientAppName && + "".concat(t("AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP")).concat(t(clientAppName)), jsxRuntime.jsx("span", { "data-supertokens": "backButtonPlaceholder backButtonCommon" }), ], } @@ -699,14 +699,14 @@ var AuthPageHeader = withOverride("AuthPageHeader", function AuthPageHeader(_a) (!isSignUp ? jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: [ t("AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START"), jsxRuntime.jsx( "span", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "link", onClick: onSignInUpSwitcherClick }, { children: t("AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK") } ) @@ -718,14 +718,14 @@ var AuthPageHeader = withOverride("AuthPageHeader", function AuthPageHeader(_a) ) : jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: [ t("AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_START"), jsxRuntime.jsx( "span", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "link", onClick: onSignInUpSwitcherClick }, { children: t("AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_SIGN_IN_LINK") } ) @@ -744,7 +744,7 @@ function AuthPageTheme(props) { if (props.fullPageCompWithPreloadedInfo) { return jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.fullPageCompWithPreloadedInfo.component( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, props), { + superTokens.__assign(superTokens.__assign({}, props), { preloadInfo: props.fullPageCompWithPreloadedInfo.preloadInfo, }) ), @@ -752,7 +752,7 @@ function AuthPageTheme(props) { } return jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container authPage ".concat( props.factorIds.length > 1 ? "multiFactor" : "singleFactor" @@ -762,7 +762,7 @@ function AuthPageTheme(props) { children: [ jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: [ @@ -773,12 +773,10 @@ function AuthPageTheme(props) { hasSeparateSignUpView: props.hasSeparateSignUpView, resetFactorList: props.resetFactorList, showBackButton: props.showBackButton, + clientAppName: props.clientAppName, }), props.error !== undefined && jsxRuntime.jsx(GeneralError, { error: props.error }), - jsxRuntime.jsx( - AuthPageComponentList, - genericComponentOverrideContext.__assign({}, props) - ), + jsxRuntime.jsx(AuthPageComponentList, superTokens.__assign({}, props)), jsxRuntime.jsx(AuthPageFooter, { factorIds: props.factorIds, isSignUp: props.isSignUp, @@ -797,18 +795,18 @@ function AuthPageTheme(props) { ); } function AuthPageThemeWrapper(props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = hasFontDefined(rootStyle); return jsxRuntime.jsx( UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle] }, - { children: jsxRuntime.jsx(AuthPageTheme, genericComponentOverrideContext.__assign({}, props)) } + { children: jsxRuntime.jsx(AuthPageTheme, superTokens.__assign({}, props)) } ) ), } @@ -825,24 +823,19 @@ var AuthPageWrapper = function (props) { var authRecipeComponentOverrides = useContext(); return jsxRuntime.jsx( UserContextProvider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( SessionAuthWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { requireAuth: false, doRedirection: false }, { children: jsxRuntime.jsx( ComponentOverrideContext.Provider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { value: authRecipeComponentOverrides }, - { - children: jsxRuntime.jsx( - AuthPageInner, - genericComponentOverrideContext.__assign({}, props) - ), - } + { children: jsxRuntime.jsx(AuthPageInner, superTokens.__assign({}, props)) } ) ), } @@ -879,33 +872,37 @@ var AuthPageInner = function (props) { : undefined; var showStringFromQSRef = React.useRef(showStringFromQS); var errorFromQSRef = React.useRef(errorFromQS); + var loginChallenge = search.get("loginChallenge"); var sessionContext = useSessionContext(); var userContext = useUserContext(); - var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var rethrowInRender = superTokens.useRethrowInRender(); var _f = React.useState(undefined), loadedDynamicLoginMethods = _f[0], setLoadedDynamicLoginMethods = _f[1]; - var _g = React.useState(errorFromQS), - error = _g[0], - setError = _g[1]; - var _h = React.useState(false), - sessionLoadedAndNotRedirecting = _h[0], - setSessionLoadedAndNotRedirecting = _h[1]; - var st = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow(); - var _j = React.useState(props.factors), - factorList = _j[0], - setFactorList = _j[1]; - var _k = React.useState( + var _g = React.useState(undefined), + oauth2ClientInfo = _g[0], + setOAuth2ClientInfo = _g[1]; + var _h = React.useState(errorFromQS), + error = _h[0], + setError = _h[1]; + var _j = React.useState(false), + sessionLoadedAndNotRedirecting = _j[0], + setSessionLoadedAndNotRedirecting = _j[1]; + var st = superTokens.SuperTokens.getInstanceOrThrow(); + var _k = React.useState(props.factors), + factorList = _k[0], + setFactorList = _k[1]; + var _l = React.useState( (_e = (_d = props.isSignUp) !== null && _d !== void 0 ? _d : isSignUpFromQS) !== null && _e !== void 0 ? _e : st.defaultToSignUp ), - isSignUp = _k[0], - setIsSignUp = _k[1]; + isSignUp = _l[0], + setIsSignUp = _l[1]; // We use this to signal that we need to update the components we show on screen - var _l = React.useState(0), - rebuildReqCount = _l[0], - setRebuildReqCount = _l[1]; + var _m = React.useState(0), + rebuildReqCount = _m[0], + setRebuildReqCount = _m[1]; var lastBuild = React.useRef({ buildReq: undefined }); React.useEffect(function () { if (props.useSignUpStateFromQueryString && showStringFromQSRef.current !== showStringFromQS) { @@ -933,7 +930,7 @@ var AuthPageInner = function (props) { var onSignInUpSwitcherClick = React.useCallback( function () { if (props.useSignUpStateFromQueryString === true) { - genericComponentOverrideContext.updateQueryParam("show", isSignUp ? "signin" : "signup"); + superTokens.updateQueryParam("show", isSignUp ? "signin" : "signup"); } setError(undefined); setIsSignUp(!isSignUp); @@ -948,7 +945,7 @@ var AuthPageInner = function (props) { if (loadedDynamicLoginMethods) { return; } - genericComponentOverrideContext.Multitenancy.getInstanceOrThrow() + superTokens.Multitenancy.getInstanceOrThrow() .getCurrentDynamicLoginMethods({ userContext: userContext }) .then( function (loginMethods) { @@ -961,6 +958,23 @@ var AuthPageInner = function (props) { }, [loadedDynamicLoginMethods, setLoadedDynamicLoginMethods] ); + React.useEffect( + function () { + if (oauth2ClientInfo) { + return; + } + var oauth2Recipe = recipe.OAuth2.getInstance(); + if (oauth2Recipe !== undefined && loginChallenge !== null) { + void recipe.OAuth2.getInstanceOrThrow() + .webJSRecipe.getLoginChallengeInfo({ loginChallenge: loginChallenge, userContext: userContext }) + .then(function (_a) { + var info = _a.info; + return setOAuth2ClientInfo(info); + }); + } + }, + [setOAuth2ClientInfo, loginChallenge, oauth2ClientInfo] + ); React.useEffect( function () { if (sessionLoadedAndNotRedirecting) { @@ -977,15 +991,34 @@ var AuthPageInner = function (props) { types.Session.getInstanceOrThrow().config.onHandleEvent({ action: "SESSION_ALREADY_EXISTS", }); - void types.Session.getInstanceOrThrow() - .validateGlobalClaimsAndHandleSuccessRedirection( - undefined, - types.Session.RECIPE_ID, // TODO - genericComponentOverrideContext.getRedirectToPathFromURL(), - userContext, - props.navigate - ) - .catch(rethrowInRender); + if (loginChallenge !== null) { + void types.Session.getInstanceOrThrow() + .validateGlobalClaimsAndHandleSuccessRedirection( + { + action: "SUCCESS_OAUTH2", + createdNewUser: false, + isNewRecipeUser: false, + loginChallenge: loginChallenge, + newSessionCreated: false, + recipeId: types.Session.RECIPE_ID, + }, + types.Session.RECIPE_ID, + superTokens.getRedirectToPathFromURL(), + userContext, + props.navigate + ) + .catch(rethrowInRender); + } else { + void types.Session.getInstanceOrThrow() + .validateGlobalClaimsAndHandleSuccessRedirection( + undefined, + types.Session.RECIPE_ID, + superTokens.getRedirectToPathFromURL(), + userContext, + props.navigate + ) + .catch(rethrowInRender); + } } else { setSessionLoadedAndNotRedirecting(true); } @@ -996,16 +1029,16 @@ var AuthPageInner = function (props) { }, [sessionContext.loading] ); - var _m = React.useState(), - authComponentListInfo = _m[0], - setAuthComponentListInfo = _m[1]; + var _o = React.useState(), + authComponentListInfo = _o[0], + setAuthComponentListInfo = _o[1]; var showUseAnotherLink = factorList !== undefined && (props.factors === undefined || props.factors.some(function (id) { return !factorList.includes(id); })); - var stInstance = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow(); + var stInstance = superTokens.SuperTokens.getInstanceOrThrow(); var privacyPolicyLink = stInstance.privacyPolicyLink; var termsOfServiceLink = stInstance.termsOfServiceLink; React.useEffect( @@ -1016,8 +1049,7 @@ var AuthPageInner = function (props) { } if ( sessionLoadedAndNotRedirecting && - (loadedDynamicLoginMethods !== undefined || - !genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods) + (loadedDynamicLoginMethods !== undefined || !superTokens.SuperTokens.usesDynamicLoginMethods) ) { void buildAndSetChildProps( props.preBuiltUIList, @@ -1048,43 +1080,62 @@ var AuthPageInner = function (props) { rethrowInRender, ] ); + var onAuthSuccess = React.useCallback( + function (ctx) { + return types.Session.getInstanceOrThrow().validateGlobalClaimsAndHandleSuccessRedirection( + loginChallenge !== null + ? superTokens.__assign(superTokens.__assign({}, ctx), { + action: "SUCCESS_OAUTH2", + loginChallenge: loginChallenge, + }) + : superTokens.__assign(superTokens.__assign({}, ctx), { + action: "SUCCESS", + redirectToPath: superTokens.getRedirectToPathFromURL(), + }), + ctx.recipeId, + superTokens.getRedirectToPathFromURL(), + userContext + ); + }, + [loginChallenge] + ); var childProps = - authComponentListInfo !== undefined - ? genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, authComponentListInfo), - { - error: error, - onError: function (err) { - setError(err); - }, - clearError: function () { - return setError(undefined); - }, - navigate: props.navigate, - onSignInUpSwitcherClick: onSignInUpSwitcherClick, - privacyPolicyLink: privacyPolicyLink, - rebuildAuthPage: function () { - return setRebuildReqCount(function (v) { - return v + 1; - }); - }, - setFactorList: function (factorIds) { - setFactorList(factorIds); - setRebuildReqCount(function (v) { - return v + 1; - }); - }, - resetFactorList: function () { - setFactorList(props.factors); - setRebuildReqCount(function (v) { - return v + 1; - }); - }, - showBackButton: showUseAnotherLink, - termsOfServiceLink: termsOfServiceLink, - userContext: userContext, - } - ) + authComponentListInfo !== undefined && (loginChallenge === null || oauth2ClientInfo !== undefined) + ? superTokens.__assign(superTokens.__assign({}, authComponentListInfo), { + clientAppName: + oauth2ClientInfo === null || oauth2ClientInfo === void 0 ? void 0 : oauth2ClientInfo.clientName, + onAuthSuccess: onAuthSuccess, + error: error, + onError: function (err) { + setError(err); + }, + clearError: function () { + return setError(undefined); + }, + navigate: props.navigate, + onSignInUpSwitcherClick: onSignInUpSwitcherClick, + privacyPolicyLink: privacyPolicyLink, + rebuildAuthPage: function () { + return setRebuildReqCount(function (v) { + return v + 1; + }); + }, + setFactorList: function (factorIds) { + setFactorList(factorIds); + setRebuildReqCount(function (v) { + return v + 1; + }); + }, + resetFactorList: function () { + setFactorList(props.factors); + setRebuildReqCount(function (v) { + return v + 1; + }); + }, + showBackButton: showUseAnotherLink, + termsOfServiceLink: termsOfServiceLink, + userContext: userContext, + }) : undefined; var mergedTranslations = React.useMemo( function () { @@ -1092,10 +1143,10 @@ var AuthPageInner = function (props) { if (authComponentListInfo !== undefined) { for (var _i = 0, _a = props.preBuiltUIList; _i < _a.length; _i++) { var ui = _a[_i]; - res = genericComponentOverrideContext.mergeObjects(res, ui.languageTranslations); + res = superTokens.mergeObjects(res, ui.languageTranslations); } } - res = genericComponentOverrideContext.mergeObjects(res, st.languageTranslations.userTranslationStore); + res = superTokens.mergeObjects(res, st.languageTranslations.userTranslationStore); return res; }, [st.languageTranslations.userTranslationStore, authComponentListInfo] @@ -1105,12 +1156,12 @@ var AuthPageInner = function (props) { } else { return jsxRuntime.jsx( DynamicLoginMethodsProvider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { value: loadedDynamicLoginMethods }, { children: jsxRuntime.jsx( translationContext.TranslationContextProvider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { defaultLanguage: st.languageTranslations.defaultLanguage, defaultStore: mergedTranslations, @@ -1120,7 +1171,7 @@ var AuthPageInner = function (props) { { children: jsxRuntime.jsx( WithOrWithoutShadowDom, - genericComponentOverrideContext.__assign( + superTokens.__assign( { useShadowDom: st.useShadowDom }, { children: jsxRuntime.jsxs(React.Fragment, { @@ -1128,7 +1179,7 @@ var AuthPageInner = function (props) { props.children === undefined && jsxRuntime.jsx( AuthPageThemeWrapper, - genericComponentOverrideContext.__assign({}, childProps) + superTokens.__assign({}, childProps) ), props.children && React__default.default.Children.map( @@ -1166,7 +1217,7 @@ function buildAndSetChildProps( abort ) { var _a, _b, _c, _d; - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var authRecipesInited, firstFactors, missingPreBuiltUIs, @@ -1183,15 +1234,14 @@ function buildAndSetChildProps( preloadRes, partialAuthComps, selectedComponents; - return genericComponentOverrideContext.__generator(this, function (_f) { + return superTokens.__generator(this, function (_f) { switch (_f.label) { case 0: - authRecipesInited = - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().recipeList.filter(function ( - recipe - ) { - return "firstFactorIds" in recipe; - }); + authRecipesInited = superTokens.SuperTokens.getInstanceOrThrow().recipeList.filter(function ( + recipe + ) { + return "firstFactorIds" in recipe; + }); firstFactors = (_c = (_a = @@ -1201,13 +1251,13 @@ function buildAndSetChildProps( ? void 0 : loadedDynamicLoginMethods.firstFactors) !== null && _a !== void 0 ? _a - : (_b = recipe.MultiFactorAuth.getInstance()) === null || _b === void 0 + : (_b = recipe$1.MultiFactorAuth.getInstance()) === null || _b === void 0 ? void 0 : _b.config.firstFactors) !== null && _c !== void 0 ? _c : authRecipesInited.reduce(function (acc, recipe) { - return genericComponentOverrideContext.__spreadArray( - genericComponentOverrideContext.__spreadArray([], acc, true), + return superTokens.__spreadArray( + superTokens.__spreadArray([], acc, true), recipe.getFirstFactorsForAuthPage(), true ); @@ -1217,7 +1267,7 @@ function buildAndSetChildProps( (loadedDynamicLoginMethods === null || loadedDynamicLoginMethods === void 0 ? void 0 : loadedDynamicLoginMethods.firstFactors) === undefined && - ((_d = recipe.MultiFactorAuth.getInstance()) === null || _d === void 0 + ((_d = recipe$1.MultiFactorAuth.getInstance()) === null || _d === void 0 ? void 0 : _d.config.firstFactors) === undefined ) { @@ -1248,7 +1298,7 @@ function buildAndSetChildProps( // We have no provider defined for the tenant either if ( thirdPartyPreBuiltUI.recipeInstance.config.signInAndUpFeature.providers.length === 0 && - (!genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods || + (!superTokens.SuperTokens.usesDynamicLoginMethods || loadedDynamicLoginMethods.thirdparty.providers.length === 0) ) { firstFactors = firstFactors.filter(function (f) { @@ -1397,7 +1447,7 @@ function chooseComponentBasedOnFirstFactors(firstFactors, routeComponents) { fallbackRid = rid; fallbackComponent = matchingComp; if (firstFactors.length === factorsProvided.length) { - genericComponentOverrideContext.logDebugMessage( + superTokens.logDebugMessage( "Rendering ".concat(rid, " because it matches factors: ").concat(firstFactors, " exactly") ); return { value: matchingComp }; @@ -1439,7 +1489,7 @@ function chooseComponentBasedOnFirstFactors(firstFactors, routeComponents) { if (typeof state_1 === "object") return state_1.value; } if (fallbackComponent !== undefined) { - genericComponentOverrideContext.logDebugMessage( + superTokens.logDebugMessage( "Rendering ".concat(fallbackRid, " to cover ").concat(firstFactors, " as a fallback") ); return fallbackComponent; @@ -1470,7 +1520,7 @@ function chooseComponentBasedOnFirstFactors(firstFactors, routeComponents) { ) { enabledLoginMethods.push("passwordless"); } - genericComponentOverrideContext.logDebugMessage( + superTokens.logDebugMessage( "Choosing component using fallback logic w/ ".concat(enabledLoginMethods.join(", "), " enabled") ); var enabledRecipeCount = enabledLoginMethods.length; @@ -1555,8 +1605,7 @@ var RecipeRouter = /** @class */ (function () { var path = normalisedUrl.getAsStringDangerous(); // We check if we are on the auth page to later see if we should take first factors into account. var isAuthPage = - path === - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous(); + path === superTokens.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous(); // We get all components that can handle the current path var routeComponents = preBuiltUIList.reduce(function (components, c) { var routes = c.getPathsToFeatureComponentWithRecipeIdMap(); @@ -1604,7 +1653,7 @@ var RecipeRouter = /** @class */ (function () { return ( !ridlist.includes(comp.comp.recipeID) || comp.route !== - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous() + superTokens.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous() ); }); if (matchingNonAuthComponent) { @@ -1615,8 +1664,8 @@ var RecipeRouter = /** @class */ (function () { if (defaultToStaticList) { return defaultComp; } - var mfaRecipe = recipe.MultiFactorAuth.getInstance(); - if (genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods === false) { + var mfaRecipe = recipe$1.MultiFactorAuth.getInstance(); + if (superTokens.SuperTokens.usesDynamicLoginMethods === false) { // If we are not using dynamic login methods, we can use the rid requested by the app if (componentMatchingRid) { return componentMatchingRid.comp; @@ -1678,7 +1727,7 @@ var RecipeRouter = /** @class */ (function () { function RoutingComponent(props) { var _a, _b; var userContext = useUserContext(); - var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var rethrowInRender = superTokens.useRethrowInRender(); var _c = React.useState(undefined), loadedDynamicLoginMethods = _c[0], setLoadedDynamicLoginMethods = _c[1]; @@ -1686,8 +1735,7 @@ function RoutingComponent(props) { (_a = props.getReactRouterDomWithCustomHistory()) === null || _a === void 0 ? void 0 : _a.useHistoryCustom(); var path = props.path; var isAuthPage = - path === - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous(); + path === superTokens.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous(); var location = (_b = props.getReactRouterDomWithCustomHistory()) === null || _b === void 0 ? void 0 : _b.useLocation(); var componentToRender = React__default.default.useMemo( @@ -1699,20 +1747,14 @@ function RoutingComponent(props) { // During development, this runs twice so as to warn devs of if there // are any side effects that happen here. So in tests, it will result in // the console log twice - if ( - loadedDynamicLoginMethods !== undefined || - genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods === false - ) { + if (loadedDynamicLoginMethods !== undefined || superTokens.SuperTokens.usesDynamicLoginMethods === false) { var result = RecipeRouter.getMatchingComponentForRouteAndRecipeIdFromPreBuiltUIList( normalizedPath, props.preBuiltUIList, false, loadedDynamicLoginMethods ); - if ( - result === undefined && - genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods === true - ) { + if (result === undefined && superTokens.SuperTokens.usesDynamicLoginMethods === true) { void redirectToAuth({ navigate: navigate, redirectBack: false }); } return result; @@ -1728,7 +1770,7 @@ function RoutingComponent(props) { if (loadedDynamicLoginMethods) { return; } - genericComponentOverrideContext.Multitenancy.getInstanceOrThrow() + superTokens.Multitenancy.getInstanceOrThrow() .getCurrentDynamicLoginMethods({ userContext: userContext }) .then( function (loginMethods) { @@ -1748,15 +1790,12 @@ function RoutingComponent(props) { useSignUpStateFromQueryString: true, }); } - if ( - genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods && - loadedDynamicLoginMethods === undefined - ) { + if (superTokens.SuperTokens.usesDynamicLoginMethods && loadedDynamicLoginMethods === undefined) { return jsxRuntime.jsx(DynamicLoginMethodsSpinner, {}); } if ( componentToRender === undefined || - (loadedDynamicLoginMethods === undefined && genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods) + (loadedDynamicLoginMethods === undefined && superTokens.SuperTokens.usesDynamicLoginMethods) ) { return null; } @@ -1784,7 +1823,7 @@ function getSuperTokensRoutesForReactRouterDom$1(_a) { if (!(path in routes)) { routes[path] = jsxRuntime.jsx( Route, - genericComponentOverrideContext.__assign( + superTokens.__assign( { exact: true, path: pathForRouter }, { children: jsxRuntime.jsx(RoutingComponent, { @@ -1802,18 +1841,18 @@ function getSuperTokensRoutesForReactRouterDom$1(_a) { }, {}) ); if ( - !genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().disableAuthRoute && + !superTokens.SuperTokens.getInstanceOrThrow().disableAuthRoute && recipeList.some(function (ui) { return ui.getAuthComponents().length !== 0; }) ) { - var path = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow() + var path = superTokens.SuperTokens.getInstanceOrThrow() .appInfo.websiteBasePath.appendPath(new NormalisedURLPath__default$1.default("/")) .getAsStringDangerous(); routes.push( jsxRuntime.jsx( Route, - genericComponentOverrideContext.__assign( + superTokens.__assign( { exact: true, path: getPathForRouter$1(basePath, path) }, { children: jsxRuntime.jsx(RoutingComponent, { @@ -1881,12 +1920,12 @@ function getSuperTokensRoutesForReactRouterDomV6(_a) { }, {}) ); if ( - !genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().disableAuthRoute && + !superTokens.SuperTokens.getInstanceOrThrow().disableAuthRoute && recipeList.some(function (ui) { return ui.getAuthComponents().length !== 0; }) ) { - var path = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow() + var path = superTokens.SuperTokens.getInstanceOrThrow() .appInfo.websiteBasePath.appendPath(new NormalisedURLPath__default$1.default("/")) .getAsStringDangerous(); routes.push( @@ -1991,16 +2030,15 @@ var UI = /** @class */ (function () { var recipeList = preBuiltUiClassList.map(function (r) { return r.getInstanceOrInitAndGetInstance(); }); - var path = genericComponentOverrideContext.getCurrentNormalisedUrlPath().getAsStringDangerous(); + var path = superTokens.getCurrentNormalisedUrlPath().getAsStringDangerous(); var isAuthPage = - path === - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous(); + path === superTokens.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous(); if (isAuthPage) { - return !genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().disableAuthRoute; + return !superTokens.SuperTokens.getInstanceOrThrow().disableAuthRoute; } return ( RecipeRouter.getMatchingComponentForRouteAndRecipeIdFromPreBuiltUIList( - genericComponentOverrideContext.getCurrentNormalisedUrlPath(), + superTokens.getCurrentNormalisedUrlPath(), recipeList, true ) !== undefined @@ -2012,7 +2050,7 @@ var UI = /** @class */ (function () { }); return jsxRuntime.jsx(RoutingComponent, { getReactRouterDomWithCustomHistory: UI.getReactRouterDomWithCustomHistory, - path: genericComponentOverrideContext.getCurrentNormalisedUrlPath().getAsStringDangerous(), + path: superTokens.getCurrentNormalisedUrlPath().getAsStringDangerous(), preBuiltUIList: recipeList, }); }; @@ -2022,7 +2060,7 @@ var UI = /** @class */ (function () { UI.AuthPage = function (props) { return jsxRuntime.jsx( AuthPageWrapper, - genericComponentOverrideContext.__assign({}, props, { + superTokens.__assign({}, props, { preBuiltUIList: props.preBuiltUIList.map(function (r) { return r.getInstanceOrInitAndGetInstance(); }), @@ -2044,7 +2082,7 @@ var AuthPage = UI.AuthPage; var SessionAuth = function (_a) { var _b; var children = _a.children, - props = genericComponentOverrideContext.__rest(_a, ["children"]); + props = superTokens.__rest(_a, ["children"]); var requireAuth = React.useRef(props.requireAuth); if (props.requireAuth !== requireAuth.current) { throw new Error( @@ -2072,19 +2110,19 @@ var SessionAuth = function (_a) { // the app is using react-router-dom but added a session auth outside of the router. } var userContext = useUserContext(); - var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var rethrowInRender = superTokens.useRethrowInRender(); var redirectToLogin = React.useCallback(function () { - void genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ + void superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: navigate, userContext: userContext, redirectBack: true, }); }, []); var buildContext = React.useCallback(function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var sessionExists, invalidClaims, err_1, err_2; var _a; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: if (session.current === undefined) { @@ -2204,9 +2242,9 @@ var SessionAuth = function (_a) { }, []); var setInitialContextAndMaybeRedirect = React.useCallback( function (toSetContext) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var failureRedirectInfo, err_3; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: if (context.loading === false) { @@ -2244,7 +2282,7 @@ var SessionAuth = function (_a) { case 3: return [ 4 /*yield*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToUrl( + superTokens.SuperTokens.getInstanceOrThrow().redirectToUrl( failureRedirectInfo.redirectPath, navigate ), @@ -2269,10 +2307,9 @@ var SessionAuth = function (_a) { return [ 2 /*return*/, setContext( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, toSetContext), - { accessDeniedValidatorError: failureRedirectInfo.failedClaim } - ) + superTokens.__assign(superTokens.__assign({}, toSetContext), { + accessDeniedValidatorError: failureRedirectInfo.failedClaim, + }) ), ]; } @@ -2295,14 +2332,14 @@ var SessionAuth = function (_a) { navigate, ] ); - genericComponentOverrideContext.useOnMountAPICall(buildContext, setInitialContextAndMaybeRedirect); + superTokens.useOnMountAPICall(buildContext, setInitialContextAndMaybeRedirect); // subscribe to events on mount React.useEffect( function () { function onHandleEvent(event) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var _a, invalidClaims, failureRedirectInfo, err_4; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: _a = event.action; @@ -2354,16 +2391,16 @@ var SessionAuth = function (_a) { ) return [3 /*break*/, 5]; setContext( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, event.sessionContext), - { loading: false, invalidClaims: invalidClaims } - ) + superTokens.__assign(superTokens.__assign({}, event.sessionContext), { + loading: false, + invalidClaims: invalidClaims, + }) ); return [3 /*break*/, 7]; case 5: return [ 4 /*yield*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToUrl( + superTokens.SuperTokens.getInstanceOrThrow().redirectToUrl( failureRedirectInfo.redirectPath, navigate ), @@ -2388,40 +2425,37 @@ var SessionAuth = function (_a) { return [ 2 /*return*/, setContext( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, event.sessionContext), - { - loading: false, - invalidClaims: invalidClaims, - accessDeniedValidatorError: failureRedirectInfo.failedClaim, - } - ) + superTokens.__assign(superTokens.__assign({}, event.sessionContext), { + loading: false, + invalidClaims: invalidClaims, + accessDeniedValidatorError: failureRedirectInfo.failedClaim, + }) ), ]; } _b.label = 10; case 10: setContext( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, event.sessionContext), - { loading: false, invalidClaims: invalidClaims } - ) + superTokens.__assign(superTokens.__assign({}, event.sessionContext), { + loading: false, + invalidClaims: invalidClaims, + }) ); return [2 /*return*/]; case 11: setContext( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, event.sessionContext), - { loading: false, invalidClaims: [] } - ) + superTokens.__assign(superTokens.__assign({}, event.sessionContext), { + loading: false, + invalidClaims: [], + }) ); return [2 /*return*/]; case 12: setContext( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, event.sessionContext), - { loading: false, invalidClaims: [] } - ) + superTokens.__assign(superTokens.__assign({}, event.sessionContext), { + loading: false, + invalidClaims: [], + }) ); if (props.onSessionExpired !== undefined) { props.onSessionExpired(); @@ -2458,17 +2492,14 @@ var SessionAuth = function (_a) { validationError: context.accessDeniedValidatorError, }); } - return jsxRuntime.jsx( - SessionContext.Provider, - genericComponentOverrideContext.__assign({ value: context }, { children: children }) - ); + return jsxRuntime.jsx(SessionContext.Provider, superTokens.__assign({ value: context }, { children: children })); }; var SessionAuthWrapper = function (props) { return jsxRuntime.jsx( UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, - { children: jsxRuntime.jsx(SessionAuth, genericComponentOverrideContext.__assign({}, props)) } + { children: jsxRuntime.jsx(SessionAuth, superTokens.__assign({}, props)) } ) ); }; @@ -2476,7 +2507,7 @@ var SessionAuthWrapper = function (props) { var SuperTokensWrapper = function (props) { return jsxRuntime.jsx( SessionAuthWrapper, - genericComponentOverrideContext.__assign({}, props, { requireAuth: false, doRedirection: false }) + superTokens.__assign({}, props, { requireAuth: false, doRedirection: false }) ); }; @@ -2500,37 +2531,34 @@ var SuperTokensWrapper = function (props) { var SuperTokensAPIWrapper = /** @class */ (function () { function SuperTokensAPIWrapper() {} SuperTokensAPIWrapper.init = function (config) { - genericComponentOverrideContext.SuperTokens.init(config); + superTokens.SuperTokens.init(config); }; SuperTokensAPIWrapper.changeLanguage = function (language) { - return genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().changeLanguage(language); + return superTokens.SuperTokens.getInstanceOrThrow().changeLanguage(language); }; SuperTokensAPIWrapper.loadTranslation = function (store) { - return genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().loadTranslation(store); + return superTokens.SuperTokens.getInstanceOrThrow().loadTranslation(store); }; var _a; _a = SuperTokensAPIWrapper; SuperTokensAPIWrapper.SuperTokensWrapper = SuperTokensWrapper; SuperTokensAPIWrapper.redirectToAuth = function (options) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var _b; - return genericComponentOverrideContext.__generator(_a, function (_c) { + return superTokens.__generator(_a, function (_c) { return [ 2 /*return*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, options), - { - redirectBack: - (_b = options === null || options === void 0 ? void 0 : options.redirectBack) !== - null && _b !== void 0 - ? _b - : true, - userContext: genericComponentOverrideContext.getNormalisedUserContext( - options === null || options === void 0 ? void 0 : options.userContext - ), - } - ) + superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth( + superTokens.__assign(superTokens.__assign({}, options), { + redirectBack: + (_b = options === null || options === void 0 ? void 0 : options.redirectBack) !== + null && _b !== void 0 + ? _b + : true, + userContext: superTokens.getNormalisedUserContext( + options === null || options === void 0 ? void 0 : options.userContext + ), + }) ), ]; }); diff --git a/lib/build/multifactorauth-shared.js b/lib/build/multifactorauth-shared.js index dcbacf133..1a551eaa3 100644 --- a/lib/build/multifactorauth-shared.js +++ b/lib/build/multifactorauth-shared.js @@ -1,7 +1,8 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var WebJSSessionRecipe = require("supertokens-web-js/recipe/session"); +var recipe = require("./oauth2-shared.js"); var index = require("./recipeModule-shared.js"); var utils = require("supertokens-web-js/utils"); var windowHandler = require("supertokens-web-js/utils/windowHandler"); @@ -38,7 +39,7 @@ function normaliseSessionConfig(config) { var accessDeniedScreen = { style: accessDeniedScreenStyle, }; - var override = genericComponentOverrideContext.__assign( + var override = superTokens.__assign( { functions: function (originalImplementation) { return originalImplementation; @@ -46,26 +47,20 @@ function normaliseSessionConfig(config) { }, config.override ); - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign( - {}, - genericComponentOverrideContext.normaliseRecipeModuleConfig(config) - ), - { - // TODO: ideally we'd get the default (or normalized) value from supertokens-website - invalidClaimStatusCode: (_c = config.invalidClaimStatusCode) !== null && _c !== void 0 ? _c : 403, - accessDeniedScreen: accessDeniedScreen, - override: override, - } - ); + return superTokens.__assign(superTokens.__assign({}, superTokens.normaliseRecipeModuleConfig(config)), { + // TODO: ideally we'd get the default (or normalized) value from supertokens-website + invalidClaimStatusCode: (_c = config.invalidClaimStatusCode) !== null && _c !== void 0 ? _c : 403, + accessDeniedScreen: accessDeniedScreen, + override: override, + }); } var getFailureRedirectionInfo = function (_a) { var invalidClaims = _a.invalidClaims, overrideGlobalClaimValidators = _a.overrideGlobalClaimValidators, userContext = _a.userContext; - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var globalValidators, failedClaim, _loop_1, _i, globalValidators_1, validator, state_1; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: globalValidators = utils.getGlobalClaimValidators({ @@ -75,7 +70,7 @@ var getFailureRedirectionInfo = function (_a) { failedClaim = undefined; _loop_1 = function (validator) { var claim, failureCallback, redirectPath; - return genericComponentOverrideContext.__generator(this, function (_c) { + return superTokens.__generator(this, function (_c) { switch (_c.label) { case 0: claim = invalidClaims.find(function (c) { @@ -148,7 +143,7 @@ function validateAndCompareOnFailureRedirectionURLToCurrent(redirectURL) { if (!redirectURL.startsWith("/")) { throw new Error("onFailureRedirectionURL returned a relative url: ".concat(redirectURL)); } - var appInfo = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().appInfo; + var appInfo = superTokens.SuperTokens.getInstanceOrThrow().appInfo; // otherwise we prepend the websiteDomain fullRedirectURL = "".concat(appInfo.websiteDomain.getAsStringDangerous()).concat(redirectURL); } @@ -170,7 +165,7 @@ function validateAndCompareOnFailureRedirectionURLToCurrent(redirectURL) { * under the License. */ var Session = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(Session, _super); + superTokens.__extends(Session, _super); function Session(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = WebJSSessionRecipe__default.default; @@ -189,8 +184,8 @@ var Session = /** @class */ (function (_super) { return _this.webJSRecipe.getClaimValue(input); }; _this.getAccessTokenPayloadSecurely = function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [2 /*return*/, this.webJSRecipe.getAccessTokenPayloadSecurely(input)]; }); }); @@ -202,8 +197,8 @@ var Session = /** @class */ (function (_super) { return _this.webJSRecipe.signOut(input); }; _this.attemptRefreshingSession = function () { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [2 /*return*/, this.webJSRecipe.attemptRefreshingSession()]; }); }); @@ -234,12 +229,12 @@ var Session = /** @class */ (function (_super) { userContext, navigate ) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var invalidClaims, jsonContext, failureRedirectInfo, successContextStr, storedContext; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: - userContext = genericComponentOverrideContext.getNormalisedUserContext(userContext); + userContext = superTokens.getNormalisedUserContext(userContext); return [4 /*yield*/, this.doesSessionExist({ userContext: userContext })]; case 1: // First we check if there is an active session @@ -248,7 +243,7 @@ var Session = /** @class */ (function (_super) { // This can happen e.g.: if the user clicked on the email verification link in a browser without an active session return [ 2 /*return*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ + superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: navigate, redirectBack: false, userContext: userContext, @@ -266,10 +261,7 @@ var Session = /** @class */ (function (_super) { }); return [ 4 /*yield*/, - genericComponentOverrideContext.setLocalStorage( - "supertokens-success-redirection-context", - jsonContext - ), + superTokens.setLocalStorage("supertokens-success-redirection-context", jsonContext), ]; case 3: _a.sent(); @@ -300,7 +292,7 @@ var Session = /** @class */ (function (_super) { } return [ 2 /*return*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToUrl( + superTokens.SuperTokens.getInstanceOrThrow().redirectToUrl( failureRedirectInfo.redirectPath, navigate ), @@ -311,9 +303,7 @@ var Session = /** @class */ (function (_super) { if (!(successRedirectContext === undefined)) return [3 /*break*/, 13]; return [ 4 /*yield*/, - genericComponentOverrideContext.getLocalStorage( - "supertokens-success-redirection-context" - ), + superTokens.getLocalStorage("supertokens-success-redirection-context"), ]; case 7: successContextStr = _a.sent(); @@ -331,9 +321,7 @@ var Session = /** @class */ (function (_super) { case 9: return [ 4 /*yield*/, - genericComponentOverrideContext.removeFromLocalStorage( - "supertokens-success-redirection-context" - ), + superTokens.removeFromLocalStorage("supertokens-success-redirection-context"), ]; case 10: _a.sent(); @@ -356,12 +344,23 @@ var Session = /** @class */ (function (_super) { if (successRedirectContext === undefined) { throw new Error("This should never happen: successRedirectContext undefined "); } - if (redirectToPath !== undefined) { + if (successRedirectContext.action === "SUCCESS_OAUTH2") { + return [ + 2 /*return*/, + recipe.OAuth2.getInstanceOrThrow().redirect( + successRedirectContext, + navigate, + {}, + userContext + ), + ]; + } + if (successRedirectContext.action === "SUCCESS" && redirectToPath !== undefined) { successRedirectContext.redirectToPath = redirectToPath; } return [ 2 /*return*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirect( + superTokens.SuperTokens.getInstanceOrThrow().redirect( successRedirectContext, navigate, {}, @@ -377,16 +376,16 @@ var Session = /** @class */ (function (_super) { * @returns "/" */ _this.getDefaultRedirectionURL = function () { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [2 /*return*/, "/"]; }); }); }; _this.notifyListeners = function (event) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var sessionContext; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.getSessionContext(event)]; @@ -395,9 +394,7 @@ var Session = /** @class */ (function (_super) { // We copy this.eventListeners into a new array to "freeze" it for the loop // We do this to avoid an infinite loop in case one of the listeners causes a new listener to be added (e.g.: through re-rendering) Array.from(this.eventListeners).forEach(function (listener) { - return listener( - genericComponentOverrideContext.__assign({ sessionContext: sessionContext }, event) - ); + return listener(superTokens.__assign({ sessionContext: sessionContext }, event)); }); return [2 /*return*/]; } @@ -409,9 +406,9 @@ var Session = /** @class */ (function (_super) { Session.prototype.getSessionContext = function (_a) { var action = _a.action, userContext = _a.userContext; - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var _b, userId, accessTokenPayload; - return genericComponentOverrideContext.__generator(this, function (_c) { + return superTokens.__generator(this, function (_c) { switch (_c.label) { case 0: if ( @@ -471,54 +468,42 @@ var Session = /** @class */ (function (_super) { recipeID: Session.RECIPE_ID, authReact: function (appInfo) { Session.instance = new Session( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, normalisedConfig), - { appInfo: appInfo, recipeId: Session.RECIPE_ID } - ) + superTokens.__assign(superTokens.__assign({}, normalisedConfig), { + appInfo: appInfo, + recipeId: Session.RECIPE_ID, + }) ); return Session.instance; }, webJS: WebJSSessionRecipe__default.default.init( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, normalisedConfig), - { - onHandleEvent: function (event) { - if (normalisedConfig.onHandleEvent !== undefined) { - normalisedConfig.onHandleEvent(event); - } - void Session.getInstanceOrThrow().notifyListeners(event); - }, - preAPIHook: function (context) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - var response; - return genericComponentOverrideContext.__generator(this, function (_a) { - response = genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, context), - { - requestInit: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, context.requestInit), - { - headers: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign( - {}, - context.requestInit.headers - ), - { rid: Session.RECIPE_ID } - ), - } - ), - } - ); - if (normalisedConfig.preAPIHook === undefined) { - return [2 /*return*/, response]; - } else { - return [2 /*return*/, normalisedConfig.preAPIHook(context)]; - } + superTokens.__assign(superTokens.__assign({}, normalisedConfig), { + onHandleEvent: function (event) { + if (normalisedConfig.onHandleEvent !== undefined) { + normalisedConfig.onHandleEvent(event); + } + void Session.getInstanceOrThrow().notifyListeners(event); + }, + preAPIHook: function (context) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + var response; + return superTokens.__generator(this, function (_a) { + response = superTokens.__assign(superTokens.__assign({}, context), { + requestInit: superTokens.__assign(superTokens.__assign({}, context.requestInit), { + headers: superTokens.__assign( + superTokens.__assign({}, context.requestInit.headers), + { rid: Session.RECIPE_ID } + ), + }), }); + if (normalisedConfig.preAPIHook === undefined) { + return [2 /*return*/, response]; + } else { + return [2 /*return*/, normalisedConfig.preAPIHook(context)]; + } }); - }, - } - ) + }); + }, + }) ), }; }; @@ -534,7 +519,7 @@ var Session = /** @class */ (function (_super) { return Session.instance; }; Session.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } Session.instance = undefined; diff --git a/lib/build/multifactorauth-shared2.js b/lib/build/multifactorauth-shared2.js index 4eb51565b..c42157764 100644 --- a/lib/build/multifactorauth-shared2.js +++ b/lib/build/multifactorauth-shared2.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var MultiFactorAuthWebJS = require("supertokens-web-js/recipe/multifactorauth"); var utils = require("supertokens-web-js/utils"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); @@ -42,11 +42,11 @@ var getFunctionOverrides = function ( _onHandleEvent ) { return function (originalImp) { - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImp), { + return superTokens.__assign(superTokens.__assign({}, originalImp), { resyncSessionAndFetchMFAInfo: function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var stWindow, stored, parsed, unlock, stored_1, parsed, val; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: stWindow = windowHandler.WindowHandlerReference.getReferenceOrThrow(); @@ -63,14 +63,11 @@ var getFunctionOverrides = function ( if (parsed.t > Date.now() - 1000) { return [ 2 /*return*/, - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, parsed.v), - { - // Adding a fake response is not great, but we do want to add something and this way it's detectable by the app - // so they could even add specific handling for it if they preferred. - fetchResponse: new Response(null, { status: 304 }), - } - ), + superTokens.__assign(superTokens.__assign({}, parsed.v), { + // Adding a fake response is not great, but we do want to add something and this way it's detectable by the app + // so they could even add specific handling for it if they preferred. + fetchResponse: new Response(null, { status: 304 }), + }), ]; } } @@ -96,14 +93,11 @@ var getFunctionOverrides = function ( if (parsed.t > Date.now() - 1000) { return [ 2 /*return*/, - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, parsed.v), - { - // Adding a fake response is not great, but we do want to add something and this way it's detectable by the app - // so they could even add specific handling for it if they preferred. - fetchResponse: new Response(null, { status: 304 }), - } - ), + superTokens.__assign(superTokens.__assign({}, parsed.v), { + // Adding a fake response is not great, but we do want to add something and this way it's detectable by the app + // so they could even add specific handling for it if they preferred. + fetchResponse: new Response(null, { status: 304 }), + }), ]; } } @@ -161,9 +155,9 @@ var MultiFactorAuthClaimClass = /** @class */ (function () { var defaultOnFailureRedirection = function (_a) { var reason = _a.reason, userContext = _a.userContext; - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var recipe, nextFactorOptions, availableFactors, mfaInfo_1, availableFactors; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: recipe = getRecipe(); @@ -172,7 +166,7 @@ var MultiFactorAuthClaimClass = /** @class */ (function () { reason.allOfInAnyOrder || (reason.factorId !== undefined ? [reason.factorId] : undefined); if (!(nextFactorOptions !== undefined)) return [3 /*break*/, 1]; - genericComponentOverrideContext.logDebugMessage( + superTokens.logDebugMessage( "Redirecting to MFA on next array from validation failure: " + nextFactorOptions.join(", ") ); @@ -217,7 +211,7 @@ var MultiFactorAuthClaimClass = /** @class */ (function () { .map(function (v) { return v.id; }); - genericComponentOverrideContext.logDebugMessage( + superTokens.logDebugMessage( "Redirecting to MFA on next array from backend: " + availableFactors.join(", ") ); if (availableFactors.length === 1) { @@ -239,67 +233,52 @@ var MultiFactorAuthClaimClass = /** @class */ (function () { }); }); }; - this.validators = genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, this.webJSClaim.validators), - { - hasCompletedMFARequirementsForAuth: function (doRedirection, showAccessDeniedOnFailure) { - if (doRedirection === void 0) { - doRedirection = true; - } - if (showAccessDeniedOnFailure === void 0) { - showAccessDeniedOnFailure = true; - } - var orig = _this.webJSClaim.validators.hasCompletedMFARequirementsForAuth(); - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, orig), - { - showAccessDeniedOnFailure: showAccessDeniedOnFailure, - onFailureRedirection: - onFailureRedirection !== null && onFailureRedirection !== void 0 - ? onFailureRedirection - : function (_a) { - var reason = _a.reason, - userContext = _a.userContext; - return doRedirection - ? defaultOnFailureRedirection({ - reason: reason, - userContext: userContext, - }) - : undefined; - }, - } - ); - }, - hasCompletedFactors: function (requirements, doRedirection, showAccessDeniedOnFailure) { - if (doRedirection === void 0) { - doRedirection = true; - } - if (showAccessDeniedOnFailure === void 0) { - showAccessDeniedOnFailure = true; - } - var orig = _this.webJSClaim.validators.hasCompletedFactors(requirements); - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, orig), - { - showAccessDeniedOnFailure: showAccessDeniedOnFailure, - onFailureRedirection: - onFailureRedirection !== null && onFailureRedirection !== void 0 - ? onFailureRedirection - : function (_a) { - var reason = _a.reason, - userContext = _a.userContext; - return doRedirection - ? defaultOnFailureRedirection({ - reason: reason, - userContext: userContext, - }) - : undefined; - }, - } - ); - }, - } - ); + this.validators = superTokens.__assign(superTokens.__assign({}, this.webJSClaim.validators), { + hasCompletedMFARequirementsForAuth: function (doRedirection, showAccessDeniedOnFailure) { + if (doRedirection === void 0) { + doRedirection = true; + } + if (showAccessDeniedOnFailure === void 0) { + showAccessDeniedOnFailure = true; + } + var orig = _this.webJSClaim.validators.hasCompletedMFARequirementsForAuth(); + return superTokens.__assign(superTokens.__assign({}, orig), { + showAccessDeniedOnFailure: showAccessDeniedOnFailure, + onFailureRedirection: + onFailureRedirection !== null && onFailureRedirection !== void 0 + ? onFailureRedirection + : function (_a) { + var reason = _a.reason, + userContext = _a.userContext; + return doRedirection + ? defaultOnFailureRedirection({ reason: reason, userContext: userContext }) + : undefined; + }, + }); + }, + hasCompletedFactors: function (requirements, doRedirection, showAccessDeniedOnFailure) { + if (doRedirection === void 0) { + doRedirection = true; + } + if (showAccessDeniedOnFailure === void 0) { + showAccessDeniedOnFailure = true; + } + var orig = _this.webJSClaim.validators.hasCompletedFactors(requirements); + return superTokens.__assign(superTokens.__assign({}, orig), { + showAccessDeniedOnFailure: showAccessDeniedOnFailure, + onFailureRedirection: + onFailureRedirection !== null && onFailureRedirection !== void 0 + ? onFailureRedirection + : function (_a) { + var reason = _a.reason, + userContext = _a.userContext; + return doRedirection + ? defaultOnFailureRedirection({ reason: reason, userContext: userContext }) + : undefined; + }, + }); + }, + }); } return MultiFactorAuthClaimClass; })(); @@ -324,7 +303,7 @@ function normaliseMultiFactorAuthFeature(config) { config = {}; } var disableDefaultUI = config.disableDefaultUI === true; - var override = genericComponentOverrideContext.__assign( + var override = superTokens.__assign( { functions: function (originalImplementation) { return originalImplementation; @@ -332,21 +311,15 @@ function normaliseMultiFactorAuthFeature(config) { }, config.override ); - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign( - {}, - genericComponentOverrideContext.normaliseRecipeModuleConfig(config) - ), - { - disableDefaultUI: disableDefaultUI, - firstFactors: config === null || config === void 0 ? void 0 : config.firstFactors, - getSecondaryFactorInfo: function (orig) { - return orig; - }, - factorChooserScreen: (_a = config.factorChooserScreen) !== null && _a !== void 0 ? _a : {}, - override: override, - } - ); + return superTokens.__assign(superTokens.__assign({}, superTokens.normaliseRecipeModuleConfig(config)), { + disableDefaultUI: disableDefaultUI, + firstFactors: config === null || config === void 0 ? void 0 : config.firstFactors, + getSecondaryFactorInfo: function (orig) { + return orig; + }, + factorChooserScreen: (_a = config.factorChooserScreen) !== null && _a !== void 0 ? _a : {}, + override: override, + }); } function getAvailableFactors(factors, nextArrayQueryParam, recipe, userContext) { // There are 3 cases here: @@ -378,7 +351,7 @@ function getAvailableFactors(factors, nextArrayQueryParam, recipe, userContext) * under the License. */ var MultiFactorAuth = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(MultiFactorAuth, _super); + superTokens.__extends(MultiFactorAuth, _super); function MultiFactorAuth(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = MultiFactorAuthWebJS__default.default; @@ -388,9 +361,9 @@ var MultiFactorAuth = /** @class */ (function (_super) { _this.recipeID = MultiFactorAuth.RECIPE_ID; _this.secondaryFactors = []; _this.getDefaultRedirectionURL = function (context, userContext) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var chooserPath, url, redirectInfo, url; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { if (context.action === "FACTOR_CHOOSER") { chooserPath = new NormalisedURLPath__default.default(DEFAULT_FACTOR_CHOOSER_PATH); url = this.config.appInfo.websiteBasePath.appendPath(chooserPath).getAsStringDangerous(); @@ -438,27 +411,24 @@ var MultiFactorAuth = /** @class */ (function (_super) { recipeID: MultiFactorAuth.RECIPE_ID, authReact: function (appInfo) { MultiFactorAuth.instance = new MultiFactorAuth( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, normalisedConfig), - { appInfo: appInfo, recipeId: MultiFactorAuth.RECIPE_ID } - ) + superTokens.__assign(superTokens.__assign({}, normalisedConfig), { + appInfo: appInfo, + recipeId: MultiFactorAuth.RECIPE_ID, + }) ); return MultiFactorAuth.instance; }, webJS: MultiFactorAuthWebJS__default.default.init( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, normalisedConfig), - { - override: { - functions: function (originalImpl, builder) { - var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); - builder.override(functions); - builder.override(normalisedConfig.override.functions); - return originalImpl; - }, + superTokens.__assign(superTokens.__assign({}, normalisedConfig), { + override: { + functions: function (originalImpl, builder) { + var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); + builder.override(functions); + builder.override(normalisedConfig.override.functions); + return originalImpl; }, - } - ) + }, + }) ), }; }; @@ -470,15 +440,15 @@ var MultiFactorAuth = /** @class */ (function (_super) { var error = "No instance of MultiFactorAuth found. Make sure to call the MultiFactorAuth.init method."; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { - error = error + genericComponentOverrideContext.SSR_ERROR; + error = error + superTokens.SSR_ERROR; } throw Error(error); } return MultiFactorAuth.instance; }; MultiFactorAuth.prototype.addMFAFactors = function (secondaryFactors) { - this.secondaryFactors = genericComponentOverrideContext.__spreadArray( - genericComponentOverrideContext.__spreadArray( + this.secondaryFactors = superTokens.__spreadArray( + superTokens.__spreadArray( [], this.secondaryFactors.filter(function (factor) { return secondaryFactors.every(function (newFactor) { @@ -504,9 +474,9 @@ var MultiFactorAuth = /** @class */ (function (_super) { if (redirectBack === void 0) { redirectBack = false; } - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var url, redirectUrl, redirectUrl; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: return [ @@ -533,25 +503,17 @@ var MultiFactorAuth = /** @class */ (function (_super) { // and is on a custom path that has a redirectToPath set to pathX when calling this function, // then we keep that in the query params if redirectBack is set to false. if (redirectBack) { - redirectUrl = - genericComponentOverrideContext.getCurrentNormalisedUrlPathWithQueryParamsAndFragments(); - url = genericComponentOverrideContext.appendQueryParamsToURL(url, { - redirectToPath: redirectUrl, - }); + redirectUrl = superTokens.getCurrentNormalisedUrlPathWithQueryParamsAndFragments(); + url = superTokens.appendQueryParamsToURL(url, { redirectToPath: redirectUrl }); } else { - redirectUrl = genericComponentOverrideContext.getRedirectToPathFromURL(); + redirectUrl = superTokens.getRedirectToPathFromURL(); if (redirectUrl) { - url = genericComponentOverrideContext.appendQueryParamsToURL(url, { - redirectToPath: redirectUrl, - }); + url = superTokens.appendQueryParamsToURL(url, { redirectToPath: redirectUrl }); } } return [ 2 /*return*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToUrl( - url, - navigate - ), + superTokens.SuperTokens.getInstanceOrThrow().redirectToUrl(url, navigate), ]; } }); @@ -569,9 +531,9 @@ var MultiFactorAuth = /** @class */ (function (_super) { if (nextFactorOptions === void 0) { nextFactorOptions = []; } - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var url, redirectUrl, redirectUrl; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: return [ @@ -587,25 +549,17 @@ var MultiFactorAuth = /** @class */ (function (_super) { return [2 /*return*/]; } if (redirectBack) { - redirectUrl = - genericComponentOverrideContext.getCurrentNormalisedUrlPathWithQueryParamsAndFragments(); - url = genericComponentOverrideContext.appendQueryParamsToURL(url, { - redirectToPath: redirectUrl, - }); + redirectUrl = superTokens.getCurrentNormalisedUrlPathWithQueryParamsAndFragments(); + url = superTokens.appendQueryParamsToURL(url, { redirectToPath: redirectUrl }); } else { - redirectUrl = genericComponentOverrideContext.getRedirectToPathFromURL(); + redirectUrl = superTokens.getRedirectToPathFromURL(); if (redirectUrl) { - url = genericComponentOverrideContext.appendQueryParamsToURL(url, { - redirectToPath: redirectUrl, - }); + url = superTokens.appendQueryParamsToURL(url, { redirectToPath: redirectUrl }); } } return [ 2 /*return*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToUrl( - url, - navigate - ), + superTokens.SuperTokens.getInstanceOrThrow().redirectToUrl(url, navigate), ]; } }); @@ -615,7 +569,7 @@ var MultiFactorAuth = /** @class */ (function (_super) { * Tests methods. */ MultiFactorAuth.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } MultiFactorAuth.instance = undefined; @@ -629,8 +583,8 @@ var MultiFactorAuth = /** @class */ (function (_super) { return MultiFactorAuth.getInstanceOrThrow(); }, function (context, userContext) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(_a, function (_b) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__generator(_a, function (_b) { switch (_b.label) { case 0: return [4 /*yield*/, this.getInstanceOrThrow().getRedirectUrl(context, userContext)]; diff --git a/lib/build/multifactorauth.js b/lib/build/multifactorauth.js index e852d1bcb..a8fff189f 100644 --- a/lib/build/multifactorauth.js +++ b/lib/build/multifactorauth.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var componentOverrideContext = require("./multifactorauth-shared3.js"); var recipe = require("./multifactorauth-shared2.js"); var types = require("./multifactorauth-shared.js"); @@ -15,11 +15,14 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); +require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); require("supertokens-web-js/recipe/session"); +require("./oauth2-shared.js"); +require("supertokens-web-js/recipe/oauth2"); /* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. * @@ -42,8 +45,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.resyncSessionAndFetchMFAInfo = function (input) { return recipe.MultiFactorAuth.getInstanceOrThrow().webJSRecipe.resyncSessionAndFetchMFAInfo( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) diff --git a/lib/build/multifactorauthprebuiltui.js b/lib/build/multifactorauthprebuiltui.js index b63a8f2e5..5a7a2d72e 100644 --- a/lib/build/multifactorauthprebuiltui.js +++ b/lib/build/multifactorauthprebuiltui.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var jsxRuntime = require("react/jsx-runtime"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); var uiEntry = require("./index2.js"); @@ -21,11 +21,14 @@ require("supertokens-web-js/utils"); require("supertokens-web-js/utils/normalisedURLDomain"); require("react-dom"); require("./multitenancy-shared.js"); +require("./genericComponentOverrideContext.js"); +require("./oauth2-shared.js"); +require("supertokens-web-js/recipe/oauth2"); +require("./recipeModule-shared.js"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); require("supertokens-web-js/recipe/session"); require("./session-shared.js"); -require("./recipeModule-shared.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); @@ -88,12 +91,12 @@ var FactorChooserFooter = uiEntry.withOverride("MFAFactorChooserFooter", functio var t = translationContext.useTranslation(); return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row factorChooserFooter" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: logout }, { children: [ @@ -114,12 +117,12 @@ var FactorChooserHeader = uiEntry.withOverride("MFAFactorChooserHeader", functio var t = translationContext.useTranslation(); return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row factorChooserHeader" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle withBackButton" }, { children: [ @@ -150,33 +153,30 @@ var FactorOption = uiEntry.withOverride("MFAFactorOption", function MFAFactorOpt var t = translationContext.useTranslation(); return jsxRuntime.jsxs( "a", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "factorChooserOption ".concat(id), onClick: onClick }, { children: [ jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( - { "data-supertokens": "factorLogo" }, - { children: [" ", logo({})] } - ) + superTokens.__assign({ "data-supertokens": "factorLogo" }, { children: [" ", logo({})] }) ), jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "factorOptionText" }, { children: [ jsxRuntime.jsx( "h6", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "factorName" }, { children: t(name) } ) ), jsxRuntime.jsx( "p", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "factorDescription" }, { children: t(description) } ) @@ -196,7 +196,7 @@ var FactorList = uiEntry.withOverride("MFAFactorList", function MFAFactorList(_a navigateToFactor = _a.navigateToFactor; return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row factorChooserList" }, { children: availableFactors.map(function (factor) { @@ -229,7 +229,7 @@ function FactorChooserTheme(props) { } return jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container mfa" }, { children: [ @@ -249,16 +249,16 @@ function FactorChooserTheme(props) { ); } function FactorChooserThemeWrapper(props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [ @@ -267,12 +267,7 @@ function FactorChooserThemeWrapper(props) { props.config.factorChooserScreen.style, ], }, - { - children: jsxRuntime.jsx( - FactorChooserTheme, - genericComponentOverrideContext.__assign({}, props) - ), - } + { children: jsxRuntime.jsx(FactorChooserTheme, superTokens.__assign({}, props)) } ) ), } @@ -281,23 +276,20 @@ function FactorChooserThemeWrapper(props) { } var defaultTranslationsMultiFactorAuth = { - en: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, uiEntry.defaultTranslationsCommon.en), - { - MULTI_FACTOR_CHOOSER_HEADER_TITLE: "Please select a factor", - MULTI_FACTOR_AUTH_LOGOUT: "Log out", - PWLESS_MFA_OTP_PHONE_NAME: "SMS based OTP", - PWLESS_MFA_OTP_PHONE_DESCRIPTION: "Get an OTP code on your phone to complete the authentication request", - PWLESS_MFA_OTP_EMAIL_NAME: "Email based OTP", - PWLESS_MFA_OTP_EMAIL_DESCRIPTION: - "Get an OTP code on your email address to complete the authentication request", - TOTP_MFA_NAME: "TOTP", - TOTP_MFA_DESCRIPTION: "Use an authenticator app to complete the authentication request", - MFA_NO_AVAILABLE_OPTIONS: "You have no available secondary factors.", - MFA_NO_AVAILABLE_OPTIONS_LOGIN: - "You have no available secondary factors and cannot complete the sign-in process. Please contact support.", - } - ), + en: superTokens.__assign(superTokens.__assign({}, uiEntry.defaultTranslationsCommon.en), { + MULTI_FACTOR_CHOOSER_HEADER_TITLE: "Please select a factor", + MULTI_FACTOR_AUTH_LOGOUT: "Log out", + PWLESS_MFA_OTP_PHONE_NAME: "SMS based OTP", + PWLESS_MFA_OTP_PHONE_DESCRIPTION: "Get an OTP code on your phone to complete the authentication request", + PWLESS_MFA_OTP_EMAIL_NAME: "Email based OTP", + PWLESS_MFA_OTP_EMAIL_DESCRIPTION: + "Get an OTP code on your email address to complete the authentication request", + TOTP_MFA_NAME: "TOTP", + TOTP_MFA_DESCRIPTION: "Use an authenticator app to complete the authentication request", + MFA_NO_AVAILABLE_OPTIONS: "You have no available secondary factors.", + MFA_NO_AVAILABLE_OPTIONS_LOGIN: + "You have no available secondary factors and cannot complete the sign-in process. Please contact support.", + }), }; var FactorChooser$1 = function (props) { @@ -311,12 +303,11 @@ var FactorChooser$1 = function (props) { userContext = props.userContext; } var recipeComponentOverrides = props.useComponentOverrides(); - var nextQueryParam = - (_a = genericComponentOverrideContext.getQueryParams("n")) !== null && _a !== void 0 ? _a : undefined; + var nextQueryParam = (_a = superTokens.getQueryParams("n")) !== null && _a !== void 0 ? _a : undefined; var redirectToAuthWithHistory = React.useCallback( function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -334,8 +325,8 @@ var FactorChooser$1 = function (props) { ); var fetchMFAInfo = React.useCallback( function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, props.recipe.webJSRecipe.resyncSessionAndFetchMFAInfo({ userContext: userContext }), @@ -347,8 +338,8 @@ var FactorChooser$1 = function (props) { ); var checkMFAInfo = React.useCallback( function (mfaInfo) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { setMFAInfo({ factors: mfaInfo.factors, phoneNumbers: mfaInfo.phoneNumbers, @@ -362,8 +353,8 @@ var FactorChooser$1 = function (props) { ); var handleError = React.useCallback( function (err) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -386,12 +377,7 @@ var FactorChooser$1 = function (props) { }, [redirectToAuthWithHistory] ); - genericComponentOverrideContext.useOnMountAPICall( - fetchMFAInfo, - checkMFAInfo, - handleError, - sessionContext.loading === false - ); + superTokens.useOnMountAPICall(fetchMFAInfo, checkMFAInfo, handleError, sessionContext.loading === false); var navigateToFactor = React.useCallback( function (factorId) { props.recipe.config.onHandleEvent({ @@ -404,9 +390,9 @@ var FactorChooser$1 = function (props) { ); var signOut = React.useCallback( function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var session; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: session = types.Session.getInstanceOrThrow(); @@ -455,24 +441,21 @@ var FactorChooser$1 = function (props) { }; return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { - useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, + useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, defaultStore: defaultTranslationsMultiFactorAuth, }, { children: jsxRuntime.jsxs(React.Fragment, { children: [ props.children === undefined && - jsxRuntime.jsx( - FactorChooserThemeWrapper, - genericComponentOverrideContext.__assign({}, childProps) - ), + jsxRuntime.jsx(FactorChooserThemeWrapper, superTokens.__assign({}, childProps)), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { @@ -491,7 +474,7 @@ var FactorChooser$1 = function (props) { }; var MultiFactorAuthPreBuiltUI = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(MultiFactorAuthPreBuiltUI, _super); + superTokens.__extends(MultiFactorAuthPreBuiltUI, _super); function MultiFactorAuthPreBuiltUI(recipeInstance) { var _this = _super.call(this) || this; _this.recipeInstance = recipeInstance; @@ -507,9 +490,7 @@ var MultiFactorAuthPreBuiltUI = /** @class */ (function (_super) { new NormalisedURLPath__default.default(recipe.DEFAULT_FACTOR_CHOOSER_PATH) ); features[normalisedFullPath.getAsStringDangerous()] = { - matches: genericComponentOverrideContext.matchRecipeIdUsingQueryParams( - _this.recipeInstance.config.recipeId - ), + matches: superTokens.matchRecipeIdUsingQueryParams(_this.recipeInstance.config.recipeId), component: function (props) { return _this.getFeatureComponent("factorchooser", props, useComponentOverrides); }, @@ -529,12 +510,12 @@ var MultiFactorAuthPreBuiltUI = /** @class */ (function (_super) { } return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( session.SessionAuth, - genericComponentOverrideContext.__assign( + superTokens.__assign( { overrideGlobalClaimValidators: function () { return []; @@ -543,7 +524,7 @@ var MultiFactorAuthPreBuiltUI = /** @class */ (function (_super) { { children: jsxRuntime.jsx( FactorChooser$1, - genericComponentOverrideContext.__assign( + superTokens.__assign( { recipe: _this.recipeInstance, useComponentOverrides: useComponentOverrides, @@ -589,7 +570,7 @@ var MultiFactorAuthPreBuiltUI = /** @class */ (function (_super) { }; // For tests MultiFactorAuthPreBuiltUI.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } MultiFactorAuthPreBuiltUI.instance = undefined; diff --git a/lib/build/multitenancy.js b/lib/build/multitenancy.js index 05284f52e..7c2f0e43d 100644 --- a/lib/build/multitenancy.js +++ b/lib/build/multitenancy.js @@ -4,16 +4,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); var MultitenancyWebJS = require("supertokens-web-js/recipe/multitenancy"); var componentOverrideContext = require("./multitenancy-shared.js"); -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); +require("./genericComponentOverrideContext.js"); +require("react/jsx-runtime"); +require("react"); require("supertokens-web-js"); require("supertokens-web-js/utils/cookieHandler"); require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); require("supertokens-web-js/utils/windowHandler"); require("supertokens-web-js/utils"); -require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); -require("react/jsx-runtime"); /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. * @@ -32,7 +33,7 @@ require("react/jsx-runtime"); var Wrapper = /** @class */ (function () { function Wrapper() {} Wrapper.init = function (config) { - return genericComponentOverrideContext.Multitenancy.init(config); + return superTokens.Multitenancy.init(config); }; Wrapper.AllowedDomainsClaim = MultitenancyWebJS.AllowedDomainsClaim; Wrapper.ComponentsOverrideProvider = componentOverrideContext.Provider; diff --git a/lib/build/oauth2-shared.js b/lib/build/oauth2-shared.js new file mode 100644 index 000000000..0b94367e6 --- /dev/null +++ b/lib/build/oauth2-shared.js @@ -0,0 +1,117 @@ +"use strict"; + +var superTokens = require("./superTokens.js"); +var OAuth2WebJS = require("supertokens-web-js/recipe/oauth2"); +var index = require("./recipeModule-shared.js"); + +function _interopDefault(e) { + return e && e.__esModule ? e : { default: e }; +} + +var OAuth2WebJS__default = /*#__PURE__*/ _interopDefault(OAuth2WebJS); + +function normaliseOAuth2Config(config) { + return superTokens.__assign(superTokens.__assign({}, superTokens.normaliseRecipeModuleConfig(config)), { + override: superTokens.__assign( + { + functions: function (originalImplementation) { + return originalImplementation; + }, + }, + config === null || config === void 0 ? void 0 : config.override + ), + }); +} + +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +/* + * Class. + */ +var OAuth2 = /** @class */ (function (_super) { + superTokens.__extends(OAuth2, _super); + function OAuth2(config, webJSRecipe) { + if (webJSRecipe === void 0) { + webJSRecipe = OAuth2WebJS__default.default; + } + var _this = _super.call(this, config) || this; + _this.webJSRecipe = webJSRecipe; + _this.recipeID = OAuth2.RECIPE_ID; + return _this; + } + OAuth2.init = function (config) { + var normalisedConfig = normaliseOAuth2Config(config); + return { + recipeID: OAuth2.RECIPE_ID, + authReact: function (appInfo) { + OAuth2.instance = new OAuth2( + superTokens.__assign(superTokens.__assign({}, normalisedConfig), { + appInfo: appInfo, + recipeId: OAuth2.RECIPE_ID, + }) + ); + return OAuth2.instance; + }, + webJS: OAuth2WebJS__default.default.init(superTokens.__assign({}, normalisedConfig)), + }; + }; + OAuth2.getInstanceOrThrow = function () { + if (OAuth2.instance === undefined) { + var error = + "No instance of OAuth2 found. Make sure to call the OAuth2.init method." + + "See https://supertokens.io/docs/oauth2/quick-setup/frontend"; + // eslint-disable-next-line supertokens-auth-react/no-direct-window-object + if (typeof window === "undefined") { + error = error + superTokens.SSR_ERROR; + } + throw Error(error); + } + return OAuth2.instance; + }; + OAuth2.getInstance = function () { + return OAuth2.instance; + }; + OAuth2.prototype.getDefaultRedirectionURL = function (ctx) { + return superTokens.__awaiter(this, void 0, void 0, function () { + var domain, basePath; + return superTokens.__generator(this, function (_a) { + if (ctx.action === "SUCCESS_OAUTH2") { + domain = this.config.appInfo.apiDomain.getAsStringDangerous(); + basePath = this.config.appInfo.apiBasePath.getAsStringDangerous(); + return [ + 2 /*return*/, + "".concat(domain).concat(basePath, "/oauth2/login?loginChallenge=").concat(ctx.loginChallenge), + ]; + } else { + throw new Error("Should never come here: unknown action in OAuth2.getDefaultRedirectionURL"); + } + }); + }); + }; + /* + * Tests methods. + */ + OAuth2.reset = function () { + if (!superTokens.isTest()) { + return; + } + OAuth2.instance = undefined; + return; + }; + OAuth2.RECIPE_ID = "oauth2"; + return OAuth2; +})(index.RecipeModule); + +exports.OAuth2 = OAuth2; diff --git a/lib/build/oauth2.js b/lib/build/oauth2.js new file mode 100644 index 000000000..18fd21099 --- /dev/null +++ b/lib/build/oauth2.js @@ -0,0 +1,61 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); + +var recipe = require("./oauth2-shared.js"); +require("./superTokens.js"); +require("supertokens-web-js"); +require("supertokens-web-js/utils/cookieHandler"); +require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); +require("supertokens-web-js/utils/windowHandler"); +require("supertokens-web-js/recipe/multitenancy"); +require("supertokens-web-js/utils"); +require("react"); +require("supertokens-web-js/utils/normalisedURLDomain"); +require("supertokens-web-js/utils/normalisedURLPath"); +require("supertokens-web-js/recipe/oauth2"); +require("./recipeModule-shared.js"); + +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +var Wrapper = /** @class */ (function () { + function Wrapper() {} + Wrapper.init = function (config) { + return recipe.OAuth2.init(config); + }; + /** + * Returns information about an OAuth login in progress + * + * @param loginChallenge The login challenge from the url + * + * @param userContext (OPTIONAL) Refer to {@link https://supertokens.com/docs/emailpassword/advanced-customizations/user-context the documentation} + * + * @param options (OPTIONAL) Use this to configure additional properties (for example pre api hooks) + * + * @returns `{status: "OK", info: LoginInfo}` + * + * @throws STGeneralError if the API exposed by the backend SDKs returns `status: "GENERAL_ERROR"` + */ + Wrapper.getLoginChallengeInfo = function (input) { + return recipe.OAuth2.getInstanceOrThrow().webJSRecipe.getLoginChallengeInfo(input); + }; + return Wrapper; +})(); +var init = Wrapper.init; +var getLoginChallengeInfo = Wrapper.getLoginChallengeInfo; + +exports.default = Wrapper; +exports.getLoginChallengeInfo = getLoginChallengeInfo; +exports.init = init; diff --git a/lib/build/passwordless-shared.js b/lib/build/passwordless-shared.js index 9a5e31150..79b224e8b 100644 --- a/lib/build/passwordless-shared.js +++ b/lib/build/passwordless-shared.js @@ -1,6 +1,7 @@ "use strict"; var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var PasswordlessWebJS = require("supertokens-web-js/recipe/passwordless"); var postSuperTokensInitCallbacks = require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); var jsxRuntime = require("react/jsx-runtime"); @@ -22,7 +23,7 @@ var _a = genericComponentOverrideContext.createGenericComponentsOverrideContext( var OTPEmailIcon = function () { return jsxRuntime.jsxs( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { width: "17", height: "15", viewBox: "0 0 17 15", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [ @@ -36,7 +37,7 @@ var OTPEmailIcon = function () { jsxRuntime.jsx("defs", { children: jsxRuntime.jsxs( "linearGradient", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "paint0_linear_4445_310", x1: "8.5", @@ -63,7 +64,7 @@ var OTPEmailIcon = function () { var OTPSMSIcon = function () { return jsxRuntime.jsxs( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { width: "17", height: "15", viewBox: "0 0 17 15", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [ @@ -77,7 +78,7 @@ var OTPSMSIcon = function () { jsxRuntime.jsx("defs", { children: jsxRuntime.jsxs( "linearGradient", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "paint0_linear_4445_316", x1: "8.5", @@ -103,11 +104,11 @@ var OTPSMSIcon = function () { var getFunctionOverrides = function (onHandleEvent) { return function (originalImp) { - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImp), { + return superTokens.__assign(superTokens.__assign({}, originalImp), { createCode: function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var response; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.createCode(input)]; @@ -125,9 +126,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, resendCode: function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var response; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.resendCode(input)]; @@ -149,9 +150,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, consumeCode: function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var payloadBeforeCall, response, payloadAfterCall; - return genericComponentOverrideContext.__generator(this, function (_c) { + return superTokens.__generator(this, function (_c) { switch (_c.label) { case 0: _c.trys.push([0, 2, , 3]); @@ -216,20 +217,17 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, setLoginAttemptInfo: function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, originalImp.setLoginAttemptInfo( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, input), - { - attemptInfo: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, input.attemptInfo), - input.userContext.additionalAttemptInfo - ), - } - ) + superTokens.__assign(superTokens.__assign({}, input), { + attemptInfo: superTokens.__assign( + superTokens.__assign({}, input.attemptInfo), + input.userContext.additionalAttemptInfo + ), + }) ), ]; }); @@ -270,8 +268,8 @@ function defaultEmailValidator(value) { return undefined; } function userInputCodeValidate(value) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { if (typeof value !== "string") { return [2 /*return*/, "GENERAL_ERROR_OTP_NON_STRING"]; } @@ -287,8 +285,8 @@ function userInputCodeValidate(value) { */ // eslint-disable-next-line @typescript-eslint/no-unused-vars function defaultValidate(_) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [2 /*return*/, undefined]; }); }); @@ -316,7 +314,7 @@ function normalisePasswordlessConfig(config) { throw new Error("Please pass one of 'PHONE', 'EMAIL' or 'EMAIL_OR_PHONE' as the contactMethod"); } var signInUpFeature = normalizeSignInUpFeatureConfig(config.signInUpFeature, config); - var override = genericComponentOverrideContext.__assign( + var override = superTokens.__assign( { functions: function (originalImplementation) { return originalImplementation; @@ -338,18 +336,15 @@ function normalisePasswordlessConfig(config) { ) { validatePhoneNumber = config.validatePhoneNumber; } - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, utils.normaliseAuthRecipe(config)), - { - validateEmailAddress: validateEmailAddress, - validatePhoneNumber: validatePhoneNumber, - signInUpFeature: signInUpFeature, - linkClickedScreenFeature: normalisePasswordlessBaseConfig(config.linkClickedScreenFeature), - mfaFeature: normalisePasswordlessBaseConfig(config.mfaFeature), - contactMethod: config.contactMethod, - override: override, - } - ); + return superTokens.__assign(superTokens.__assign({}, utils.normaliseAuthRecipe(config)), { + validateEmailAddress: validateEmailAddress, + validatePhoneNumber: validatePhoneNumber, + signInUpFeature: signInUpFeature, + linkClickedScreenFeature: normalisePasswordlessBaseConfig(config.linkClickedScreenFeature), + mfaFeature: normalisePasswordlessBaseConfig(config.mfaFeature), + contactMethod: config.contactMethod, + override: override, + }); } function normalizeSignInUpFeatureConfig(signInUpInput, config) { if ( @@ -359,7 +354,7 @@ function normalizeSignInUpFeatureConfig(signInUpInput, config) { ) { throw new Error("Please pass a positive number as resendEmailOrSMSGapInSeconds"); } - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, signInUpInput), { + return superTokens.__assign(superTokens.__assign({}, signInUpInput), { resendEmailOrSMSGapInSeconds: (signInUpInput === null || signInUpInput === void 0 ? void 0 @@ -397,9 +392,7 @@ function normalizeSignInUpFeatureConfig(signInUpInput, config) { } function normalisePasswordlessBaseConfig(config) { var style = config && config.style !== undefined ? config.style : ""; - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, config), { - style: style, - }); + return superTokens.__assign(superTokens.__assign({}, config), { style: style }); } /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. @@ -434,7 +427,7 @@ var otpEmailFactor = { * Class. */ var Passwordless = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(Passwordless, _super); + superTokens.__extends(Passwordless, _super); function Passwordless(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = PasswordlessWebJS__default.default; @@ -449,8 +442,8 @@ var Passwordless = /** @class */ (function (_super) { types.FactorIds.LINK_PHONE, ]; _this.getDefaultRedirectionURL = function (context) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [2 /*return*/, this.getAuthRecipeDefaultRedirectionURL(context)]; }); }); @@ -479,27 +472,24 @@ var Passwordless = /** @class */ (function (_super) { recipeID: Passwordless.RECIPE_ID, authReact: function (appInfo) { Passwordless.instance = new Passwordless( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, normalisedConfig), - { appInfo: appInfo, recipeId: Passwordless.RECIPE_ID } - ) + superTokens.__assign(superTokens.__assign({}, normalisedConfig), { + appInfo: appInfo, + recipeId: Passwordless.RECIPE_ID, + }) ); return Passwordless.instance; }, webJS: PasswordlessWebJS__default.default.init( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, normalisedConfig), - { - override: { - functions: function (originalImpl, builder) { - var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); - builder.override(functions); - builder.override(normalisedConfig.override.functions); - return originalImpl; - }, + superTokens.__assign(superTokens.__assign({}, normalisedConfig), { + override: { + functions: function (originalImpl, builder) { + var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); + builder.override(functions); + builder.override(normalisedConfig.override.functions); + return originalImpl; }, - } - ) + }, + }) ), }; }; @@ -510,7 +500,7 @@ var Passwordless = /** @class */ (function (_super) { "See https://supertokens.io/docs/passwordless/quick-setup/frontend"; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { - error = error + genericComponentOverrideContext.SSR_ERROR; + error = error + superTokens.SSR_ERROR; } throw Error(error); } @@ -520,7 +510,7 @@ var Passwordless = /** @class */ (function (_super) { * Tests methods. */ Passwordless.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } Passwordless.instance = undefined; diff --git a/lib/build/passwordless.js b/lib/build/passwordless.js index da90f1017..5a12b5cf9 100644 --- a/lib/build/passwordless.js +++ b/lib/build/passwordless.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var recipe = require("./passwordless-shared.js"); require("supertokens-web-js"); require("supertokens-web-js/utils/cookieHandler"); @@ -13,12 +13,15 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); +require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); require("supertokens-web-js/recipe/passwordless"); require("./authRecipe-shared2.js"); require("./recipeModule-shared.js"); require("./multifactorauth-shared.js"); require("supertokens-web-js/recipe/session"); +require("./oauth2-shared.js"); +require("supertokens-web-js/recipe/oauth2"); require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); @@ -44,12 +47,12 @@ var Wrapper = /** @class */ (function () { return recipe.Passwordless.init(config); }; Wrapper.signOut = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().signOut({ - userContext: genericComponentOverrideContext.getNormalisedUserContext( + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -58,13 +61,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.createCode = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.createCode( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -74,13 +77,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.resendCode = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.resendCode( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -90,13 +93,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.consumeCode = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.consumeCode( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -107,8 +110,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.getLinkCodeFromURL = function (input) { return recipe.Passwordless.getInstanceOrThrow().webJSRecipe.getLinkCodeFromURL( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -116,21 +119,21 @@ var Wrapper = /** @class */ (function () { }; Wrapper.getPreAuthSessionIdFromURL = function (input) { return recipe.Passwordless.getInstanceOrThrow().webJSRecipe.getPreAuthSessionIdFromURL( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) ); }; Wrapper.doesEmailExist = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.doesEmailExist( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext(input.userContext), }) ), ]; @@ -138,13 +141,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.doesPhoneNumberExist = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.doesPhoneNumberExist( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext(input.userContext), }) ), ]; @@ -152,13 +155,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.getLoginAttemptInfo = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.getLoginAttemptInfo( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -168,13 +171,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.setLoginAttemptInfo = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.setLoginAttemptInfo( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext(input.userContext), }) ), ]; @@ -182,13 +185,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.clearLoginAttemptInfo = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.clearLoginAttemptInfo( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) diff --git a/lib/build/passwordlessprebuiltui.js b/lib/build/passwordlessprebuiltui.js index 7704f1fac..b41426f43 100644 --- a/lib/build/passwordlessprebuiltui.js +++ b/lib/build/passwordlessprebuiltui.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var React = require("react"); var jsxRuntime = require("react/jsx-runtime"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); @@ -31,11 +31,14 @@ require("supertokens-web-js/utils"); require("supertokens-web-js/utils/normalisedURLDomain"); require("react-dom"); require("./multitenancy-shared.js"); +require("./genericComponentOverrideContext.js"); +require("./oauth2-shared.js"); +require("supertokens-web-js/recipe/oauth2"); +require("./recipeModule-shared.js"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); require("supertokens-web-js/recipe/emailpassword"); require("./authRecipe-shared2.js"); -require("./recipeModule-shared.js"); require("./emailpassword-shared4.js"); require("./multifactorauth-shared3.js"); require("supertokens-web-js/recipe/session"); @@ -104,7 +107,7 @@ var ThemeBase = function (_a) { var ContinueWithPasswordless = function (props) { return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "continueWithPasswordlessButtonWrapper" }, { children: jsxRuntime.jsx(button.Button, { @@ -124,18 +127,13 @@ var ContinueWithPasswordlessWithOverride = uiEntry.withOverride( ContinueWithPasswordless ); var ContinueWithPasswordlessTheme = function (props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); return jsxRuntime.jsx( ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle] }, - { - children: jsxRuntime.jsx( - ContinueWithPasswordlessWithOverride, - genericComponentOverrideContext.__assign({}, props) - ), - } + { children: jsxRuntime.jsx(ContinueWithPasswordlessWithOverride, superTokens.__assign({}, props)) } ) ); }; @@ -144,12 +142,12 @@ var ContinueWithPasswordlessFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { recipeComponentOverrides: recipeComponentOverrides }, { children: jsxRuntime.jsx( ContinueWithPasswordlessTheme, - genericComponentOverrideContext.__assign({}, props, { + superTokens.__assign({}, props, { continueWithPasswordlessClicked: function () { return props.setFactorList(props.factorIds); }, @@ -168,12 +166,12 @@ var PasswordlessLinkClickedScreen = function (props) { setLoading = _a[1]; return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: @@ -182,21 +180,21 @@ var PasswordlessLinkClickedScreen = function (props) { children: [ jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle" }, { children: t("PWLESS_LINK_CLICKED_CONTINUE_HEADER") } ) ), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: t("PWLESS_LINK_CLICKED_CONTINUE_DESC") } ) ), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "continueButtonWrapper" }, { children: jsxRuntime.jsx(button.Button, { @@ -215,7 +213,7 @@ var PasswordlessLinkClickedScreen = function (props) { }) : jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "spinner" }, { children: jsxRuntime.jsx(uiEntry.SpinnerIcon, {}) } ) @@ -232,97 +230,89 @@ var LinkClickedScreenWithOverride = uiEntry.withOverride( PasswordlessLinkClickedScreen ); var LinkClickedScreen$1 = function (props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); return jsxRuntime.jsx( ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, props.config.linkClickedScreenFeature.style], }, - { - children: jsxRuntime.jsx( - LinkClickedScreenWithOverride, - genericComponentOverrideContext.__assign({}, props) - ), - } + { children: jsxRuntime.jsx(LinkClickedScreenWithOverride, superTokens.__assign({}, props)) } ) ); }; var defaultTranslationsPasswordless = { - en: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, uiEntry.defaultTranslationsCommon.en), - { - GENERAL_ERROR_EMAIL_UNDEFINED: "Please set your email", - GENERAL_ERROR_EMAIL_NON_STRING: "Email must be of type string", - GENERAL_ERROR_EMAIL_INVALID: "Email is invalid", - GENERAL_ERROR_PHONE_UNDEFINED: "Please set your phone number", - GENERAL_ERROR_PHONE_NON_STRING: "Phone number must be of type string", - GENERAL_ERROR_PHONE_INVALID: "Phone number is invalid", - GENERAL_ERROR_OTP_UNDEFINED: "Please fill your OTP", - GENERAL_ERROR_OTP_INVALID: "Invalid OTP", - GENERAL_ERROR_OTP_EXPIRED: "Expired OTP.", - GENERAL_ERROR_OTP_NON_STRING: "OTP must be of type string", - GENERAL_ERROR_OTP_EMPTY: "OTP cannot be empty", - ERROR_SIGN_IN_UP_LINK: "Invalid magic link. Please try again.", - ERROR_SIGN_IN_UP_RESEND_RESTART_FLOW: "Login timed out. Please try again.", - ERROR_SIGN_IN_UP_CODE_CONSUME_RESTART_FLOW: "Login unsuccessful. Please try again.", - PWLESS_SIGN_IN_UP_EMAIL_LABEL: "Email", - PWLESS_SIGN_IN_UP_PHONE_LABEL: "Phone Number", - PWLESS_SIGN_IN_UP_SWITCH_TO_PHONE: "Use a Phone number", - PWLESS_SIGN_IN_UP_SWITCH_TO_EMAIL: "Use an Email", - PWLESS_SIGN_IN_UP_CONTINUE_BUTTON: "CONTINUE", - PWLESS_COMBO_CONTINUE_WITH_PASSWORDLESS_LINK: "Continue with passwordless", - PWLESS_COMBO_CONTINUE_WITH_PASSWORDLESS_BUTTON: "CONTINUE WITH PASSWORDLESS", - PWLESS_COMBO_PASSWORD_LABEL: "Password", - PWLESS_COMBO_FORGOT_PW_LINK: "Forgot password?", - PWLESS_LINK_SENT_RESEND_SUCCESS: "Link resent", - PWLESS_LINK_SENT_RESEND_TITLE: "Link sent!", - PWLESS_LINK_SENT_RESEND_DESC_START_EMAIL: "We sent a link to ", - PWLESS_LINK_SENT_RESEND_DESC_START_PHONE: "We sent a link to your phone number ", - PWLESS_LINK_SENT_RESEND_DESC_END_EMAIL: " Click the link to login or sign up", - PWLESS_LINK_SENT_RESEND_DESC_END_PHONE: "", - PWLESS_SIGN_IN_UP_CHANGE_CONTACT_INFO_EMAIL: "Change email", - PWLESS_SIGN_IN_UP_CHANGE_CONTACT_INFO_PHONE: "Change phone number", - PWLESS_LINK_CLICKED_CONTINUE_HEADER: "Sign Up or Log In", - PWLESS_LINK_CLICKED_CONTINUE_DESC: "Click the button below to log in on this device", - PWLESS_LINK_CLICKED_CONTINUE_BUTTON: "CONTINUE", - PWLESS_RESEND_SUCCESS_EMAIL: "Email resent", - PWLESS_RESEND_SUCCESS_PHONE: "SMS resent", - PWLESS_RESEND_BTN_DISABLED_START: "Resend in ", - PWLESS_RESEND_BTN_DISABLED_END: "", - PWLESS_RESEND_BTN_EMAIL: "Resend Email", - PWLESS_RESEND_BTN_PHONE: "Resend SMS", - PWLESS_USER_INPUT_CODE_HEADER_TITLE: "Enter OTP", - PWLESS_USER_INPUT_CODE_HEADER_SUBTITLE: "An OTP was sent to you at", - PWLESS_USER_INPUT_CODE_HEADER_SUBTITLE_LINK: "An OTP and a magic link was sent to you at", - PWLESS_USER_INPUT_CODE_INPUT_LABEL: "OTP", - PWLESS_MFA_HEADER_TITLE_PHONE: "SMS based OTP", - PWLESS_MFA_HEADER_TITLE_EMAIL: "Email based OTP", - PWLESS_MFA_FOOTER_LOGOUT: "Logout", - /* - * The following are error messages from our backend SDK. - * These are returned as full messages to preserver compatibilty, but they work just like the keys above. - * They are shown as is by default (setting the value to undefined will display the raw translation key) - */ - "Failed to generate a one time code. Please try again": undefined, - "Phone number is invalid": undefined, - "Email is invalid": undefined, - "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_002)": - undefined, - "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_003)": - undefined, - "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_017)": undefined, - "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_018)": undefined, - "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_019)": undefined, - } - ), + en: superTokens.__assign(superTokens.__assign({}, uiEntry.defaultTranslationsCommon.en), { + GENERAL_ERROR_EMAIL_UNDEFINED: "Please set your email", + GENERAL_ERROR_EMAIL_NON_STRING: "Email must be of type string", + GENERAL_ERROR_EMAIL_INVALID: "Email is invalid", + GENERAL_ERROR_PHONE_UNDEFINED: "Please set your phone number", + GENERAL_ERROR_PHONE_NON_STRING: "Phone number must be of type string", + GENERAL_ERROR_PHONE_INVALID: "Phone number is invalid", + GENERAL_ERROR_OTP_UNDEFINED: "Please fill your OTP", + GENERAL_ERROR_OTP_INVALID: "Invalid OTP", + GENERAL_ERROR_OTP_EXPIRED: "Expired OTP.", + GENERAL_ERROR_OTP_NON_STRING: "OTP must be of type string", + GENERAL_ERROR_OTP_EMPTY: "OTP cannot be empty", + ERROR_SIGN_IN_UP_LINK: "Invalid magic link. Please try again.", + ERROR_SIGN_IN_UP_RESEND_RESTART_FLOW: "Login timed out. Please try again.", + ERROR_SIGN_IN_UP_CODE_CONSUME_RESTART_FLOW: "Login unsuccessful. Please try again.", + PWLESS_SIGN_IN_UP_EMAIL_LABEL: "Email", + PWLESS_SIGN_IN_UP_PHONE_LABEL: "Phone Number", + PWLESS_SIGN_IN_UP_SWITCH_TO_PHONE: "Use a Phone number", + PWLESS_SIGN_IN_UP_SWITCH_TO_EMAIL: "Use an Email", + PWLESS_SIGN_IN_UP_CONTINUE_BUTTON: "CONTINUE", + PWLESS_COMBO_CONTINUE_WITH_PASSWORDLESS_LINK: "Continue with passwordless", + PWLESS_COMBO_CONTINUE_WITH_PASSWORDLESS_BUTTON: "CONTINUE WITH PASSWORDLESS", + PWLESS_COMBO_PASSWORD_LABEL: "Password", + PWLESS_COMBO_FORGOT_PW_LINK: "Forgot password?", + PWLESS_LINK_SENT_RESEND_SUCCESS: "Link resent", + PWLESS_LINK_SENT_RESEND_TITLE: "Link sent!", + PWLESS_LINK_SENT_RESEND_DESC_START_EMAIL: "We sent a link to ", + PWLESS_LINK_SENT_RESEND_DESC_START_PHONE: "We sent a link to your phone number ", + PWLESS_LINK_SENT_RESEND_DESC_END_EMAIL: " Click the link to login or sign up", + PWLESS_LINK_SENT_RESEND_DESC_END_PHONE: "", + PWLESS_SIGN_IN_UP_CHANGE_CONTACT_INFO_EMAIL: "Change email", + PWLESS_SIGN_IN_UP_CHANGE_CONTACT_INFO_PHONE: "Change phone number", + PWLESS_LINK_CLICKED_CONTINUE_HEADER: "Sign Up or Log In", + PWLESS_LINK_CLICKED_CONTINUE_DESC: "Click the button below to log in on this device", + PWLESS_LINK_CLICKED_CONTINUE_BUTTON: "CONTINUE", + PWLESS_RESEND_SUCCESS_EMAIL: "Email resent", + PWLESS_RESEND_SUCCESS_PHONE: "SMS resent", + PWLESS_RESEND_BTN_DISABLED_START: "Resend in ", + PWLESS_RESEND_BTN_DISABLED_END: "", + PWLESS_RESEND_BTN_EMAIL: "Resend Email", + PWLESS_RESEND_BTN_PHONE: "Resend SMS", + PWLESS_USER_INPUT_CODE_HEADER_TITLE: "Enter OTP", + PWLESS_USER_INPUT_CODE_HEADER_SUBTITLE: "An OTP was sent to you at", + PWLESS_USER_INPUT_CODE_HEADER_SUBTITLE_LINK: "An OTP and a magic link was sent to you at", + PWLESS_USER_INPUT_CODE_INPUT_LABEL: "OTP", + PWLESS_MFA_HEADER_TITLE_PHONE: "SMS based OTP", + PWLESS_MFA_HEADER_TITLE_EMAIL: "Email based OTP", + PWLESS_MFA_FOOTER_LOGOUT: "Logout", + /* + * The following are error messages from our backend SDK. + * These are returned as full messages to preserver compatibilty, but they work just like the keys above. + * They are shown as is by default (setting the value to undefined will display the raw translation key) + */ + "Failed to generate a one time code. Please try again": undefined, + "Phone number is invalid": undefined, + "Email is invalid": undefined, + "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_002)": + undefined, + "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_003)": + undefined, + "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_017)": undefined, + "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_018)": undefined, + "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_019)": undefined, + }), }; var LinkClickedScreen = function (props) { - var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var rethrowInRender = superTokens.useRethrowInRender(); var userContext = uiEntry.useUserContext(); if (props.userContext !== undefined) { userContext = props.userContext; @@ -332,19 +322,19 @@ var LinkClickedScreen = function (props) { setRequireUserInteraction = _a[1]; var consumeCodeAtMount = React.useCallback( function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var preAuthSessionId, linkCode, loginAttemptInfo, payloadBeforeCall; var _b; - return genericComponentOverrideContext.__generator(this, function (_c) { + return superTokens.__generator(this, function (_c) { switch (_c.label) { case 0: - preAuthSessionId = genericComponentOverrideContext.getQueryParams("preAuthSessionId"); - linkCode = genericComponentOverrideContext.getURLHash(); + preAuthSessionId = superTokens.getQueryParams("preAuthSessionId"); + linkCode = superTokens.getURLHash(); if (!(preAuthSessionId === null || preAuthSessionId.length === 0 || linkCode.length === 0)) return [3 /*break*/, 2]; return [ 4 /*yield*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ + superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: "signin", @@ -407,9 +397,9 @@ var LinkClickedScreen = function (props) { ); var handleConsumeResp = React.useCallback( function (consumeRes) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var response, payloadBeforeCall, payloadAfterCall, loginAttemptInfo; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: if (consumeRes === "REQUIRES_INTERACTION") { @@ -424,7 +414,7 @@ var LinkClickedScreen = function (props) { if (response.status === "RESTART_FLOW_ERROR") { return [ 2 /*return*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ + superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: "restart_link", @@ -437,7 +427,7 @@ var LinkClickedScreen = function (props) { if (response.status === "SIGN_IN_UP_NOT_ALLOWED") { return [ 2 /*return*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ + superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: response.reason, @@ -518,7 +508,7 @@ var LinkClickedScreen = function (props) { var handleConsumeError = React.useCallback( function (err) { if (STGeneralError__default.default.isThisError(err)) { - return genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ + return superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: "custom", @@ -528,7 +518,7 @@ var LinkClickedScreen = function (props) { userContext: userContext, }); } else { - return genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ + return superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: "signin", @@ -540,16 +530,16 @@ var LinkClickedScreen = function (props) { }, [props.navigate, userContext] ); - genericComponentOverrideContext.useOnMountAPICall(consumeCodeAtMount, handleConsumeResp, handleConsumeError); + superTokens.useOnMountAPICall(consumeCodeAtMount, handleConsumeResp, handleConsumeError); var recipeComponentOverrides = props.useComponentOverrides(); var childProps = { recipeImplementation: props.recipe.webJSRecipe, config: props.recipe.config, requireUserInteraction: requireUserInteraction, consumeCode: function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var payloadBeforeCall, consumeResp, err_1; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 7, , 8]); @@ -600,24 +590,21 @@ var LinkClickedScreen = function (props) { }; return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { - useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, + useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, defaultStore: defaultTranslationsPasswordless, }, { children: jsxRuntime.jsxs(React.Fragment, { children: [ props.children === undefined && - jsxRuntime.jsx( - LinkClickedScreen$1, - genericComponentOverrideContext.__assign({}, childProps) - ), + jsxRuntime.jsx(LinkClickedScreen$1, superTokens.__assign({}, childProps)), props.children && React__namespace.default.Children.map(props.children, function (child) { if (React__namespace.default.isValidElement(child)) { @@ -658,29 +645,29 @@ var LinkClickedScreen = function (props) { function SMSLargeIcon() { return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "52.013", height: "41.889", viewBox: "0 0 52.013 41.889" }, { children: jsxRuntime.jsx( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "Group_10400", "data-name": "Group 10400", transform: "translate(-724.625 -241.125)" }, { children: jsxRuntime.jsxs( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "Group_10399", "data-name": "Group 10399" }, { children: [ jsxRuntime.jsxs( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "Group_10398", "data-name": "Group 10398" }, { children: [ jsxRuntime.jsxs( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "_2639922_sms_icon", "data-name": "2639922_sms_icon", @@ -730,7 +717,7 @@ function SMSLargeIcon() { ), jsxRuntime.jsxs( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "_2639922_sms_icon-2", "data-name": "2639922_sms_icon", @@ -762,7 +749,7 @@ function SMSLargeIcon() { ), jsxRuntime.jsxs( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "Group_10397", "data-name": "Group 10397" }, { children: [ @@ -792,7 +779,7 @@ function SMSLargeIcon() { ), jsxRuntime.jsxs( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "Group_10396", "data-name": "Group 10396" }, { children: [ @@ -829,7 +816,7 @@ function SMSLargeIcon() { }), jsxRuntime.jsxs( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "Group_10395", "data-name": "Group 10395" }, { children: [ @@ -903,7 +890,7 @@ var ResendButton = uiEntry.withOverride("PasswordlessResendButton", function Pas ); return jsxRuntime.jsx( "button", - genericComponentOverrideContext.__assign( + superTokens.__assign( { type: "button", disabled: secsUntilResend !== undefined, @@ -954,9 +941,9 @@ var PasswordlessLinkSent = function (props) { }, []); var resendEmail = React.useCallback( function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var response, generalError, e_1; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 5, , 6]); @@ -1014,12 +1001,12 @@ var PasswordlessLinkSent = function (props) { var resendActive = status === "LINK_RESENT"; return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: [ @@ -1030,14 +1017,14 @@ var PasswordlessLinkSent = function (props) { resendActive && jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "generalSuccess" }, { children: t("PWLESS_LINK_SENT_RESEND_SUCCESS") } ) ), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "sendCodeIcon" }, { children: @@ -1049,14 +1036,14 @@ var PasswordlessLinkSent = function (props) { ), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle headerTinyTitle" }, { children: t("PWLESS_LINK_SENT_RESEND_TITLE") } ) ), jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "primaryText sendCodeText" }, { children: [ @@ -1081,7 +1068,7 @@ var PasswordlessLinkSent = function (props) { }), jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: function () { @@ -1112,22 +1099,22 @@ var PasswordlessLinkSent = function (props) { }; var LinkSent = uiEntry.withOverride("PasswordlessLinkSent", PasswordlessLinkSent); function LinkSentWrapper(props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeStyle = props.config.signInUpFeature.linkSentScreenStyle; return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, activeStyle], }, - { children: jsxRuntime.jsx(LinkSent, genericComponentOverrideContext.__assign({}, props)) } + { children: jsxRuntime.jsx(LinkSent, superTokens.__assign({}, props)) } ) ), } @@ -1153,15 +1140,15 @@ function useChildProps$4( }, [recipe$1, onError, rebuildAuthPage] ); - var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var rethrowInRender = superTokens.useRethrowInRender(); return React.useMemo( function () { return { userContext: userContext, onSuccess: function (result) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var payloadAfterCall; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, , 3]); @@ -1198,7 +1185,7 @@ function useChildProps$4( recipeId: recipe$1.recipeID, }, recipe$1.recipeID, - genericComponentOverrideContext.getRedirectToPathFromURL(), + superTokens.getRedirectToPathFromURL(), userContext, navigate ) @@ -1209,9 +1196,9 @@ function useChildProps$4( }); }, onFetchError: function (err) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var invalidClaims, evInstance; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -1291,15 +1278,12 @@ var LinkSentFeatureInner = function (props) { props.children === undefined && jsxRuntime.jsx( LinkSentWrapper, - genericComponentOverrideContext.__assign({}, childProps, { userContext: props.userContext }) + superTokens.__assign({}, childProps, { userContext: props.userContext }) ), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { - return React__namespace.cloneElement( - child, - genericComponentOverrideContext.__assign({}, childProps) - ); + return React__namespace.cloneElement(child, superTokens.__assign({}, childProps)); } return child; }), @@ -1310,19 +1294,19 @@ var LinkSentFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { recipeComponentOverrides: recipeComponentOverrides }, - { children: jsxRuntime.jsx(LinkSentFeatureInner, genericComponentOverrideContext.__assign({}, props)) } + { children: jsxRuntime.jsx(LinkSentFeatureInner, superTokens.__assign({}, props)) } ) ); }; function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPage) { var _this = this; - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImpl), { + return superTokens.__assign(superTokens.__assign({}, originalImpl), { resendCode: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var res, loginAttemptInfo, timestamp; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.resendCode(input)]; @@ -1343,10 +1327,9 @@ function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPa 4 /*yield*/, originalImpl.setLoginAttemptInfo({ userContext: input.userContext, - attemptInfo: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, loginAttemptInfo), - { lastResend: timestamp } - ), + attemptInfo: superTokens.__assign(superTokens.__assign({}, loginAttemptInfo), { + lastResend: timestamp, + }), }), ]; case 3: @@ -1374,9 +1357,9 @@ function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPa }); }, consumeCode: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var res; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.consumeCode(input)]; @@ -1425,8 +1408,8 @@ function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPa }); }, clearLoginAttemptInfo: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -1437,7 +1420,7 @@ function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPa ]; case 1: _a.sent(); - genericComponentOverrideContext.clearErrorQueryParam(); + superTokens.clearErrorQueryParam(); rebuildAuthPage(); return [2 /*return*/]; } @@ -1449,9 +1432,9 @@ function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPa var phoneNumberUtilsImport; function getPhoneNumberUtils() { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var global; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, preloadPhoneNumberUtils()]; @@ -1478,9 +1461,9 @@ function preloadPhoneNumberUtils() { // This was moved to a separate file to make tree-shaking more effective, since we do not want to include the phoneNumberUtils // in the base pwless recipe because it increases the bundle size by a lot function defaultPhoneNumberValidator(value) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var intlTelInputUtils; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: if (typeof value !== "string") { @@ -1521,10 +1504,10 @@ var EmailForm = uiEntry.withOverride("PasswordlessEmailForm", function Passwordl buttonLabel: "PWLESS_SIGN_IN_UP_CONTINUE_BUTTON", onSuccess: props.onSuccess, callAPI: function (formFields) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var email, validationRes, response; var _a; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: email = @@ -3553,7 +3536,7 @@ function PhoneNumberInput(_a) { // if it detects a mobile environment, but this doesn't work with our styling if we use shadow dom var anyIti = itiRef; if (anyIti.isMobile) { - var root = document.getElementById(genericComponentOverrideContext.ST_ROOT_ID); + var root = document.getElementById(superTokens.ST_ROOT_ID); // We only have to do this if we are using shadowDom and we need access to the dom element anyway // so passing the shadowroot element here would be both impractical and not too useful if (root === null || root === void 0 ? void 0 : root.shadowRoot) { @@ -3575,13 +3558,13 @@ function PhoneNumberInput(_a) { */ return jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "inputContainer" }, { children: [ jsxRuntime.jsxs( "style", - genericComponentOverrideContext.__assign( + superTokens.__assign( { type: "text/css" }, { children: [ @@ -3593,7 +3576,7 @@ function PhoneNumberInput(_a) { ), jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "phoneInputWrapper inputWrapper ".concat( hasError ? "inputError" : "" @@ -3625,7 +3608,7 @@ function PhoneNumberInput(_a) { hasError === true && jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "inputAdornment inputAdornmentError" }, { children: jsxRuntime.jsx(formBase.ErrorIcon, {}) } ) @@ -3643,7 +3626,7 @@ function PhoneNumberInput(_a) { // TODO: type props var phoneNumberInputWithInjectedProps = function (injectedProps) { return function (props) { - return jsxRuntime.jsx(PhoneNumberInput, genericComponentOverrideContext.__assign({}, injectedProps, props)); + return jsxRuntime.jsx(PhoneNumberInput, superTokens.__assign({}, injectedProps, props)); }; }; @@ -3681,10 +3664,10 @@ var PhoneForm = uiEntry.withOverride("PasswordlessPhoneForm", function Passwordl buttonLabel: "PWLESS_SIGN_IN_UP_CONTINUE_BUTTON", onSuccess: props.onSuccess, callAPI: function (formFields) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var phoneNumber, validationRes, response; var _a; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: phoneNumber = @@ -3735,7 +3718,7 @@ var UserInputCodeFormFooter = uiEntry.withOverride( return jsxRuntime.jsx(React.Fragment, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: function () { @@ -3767,14 +3750,14 @@ var UserInputCodeFormHeader = uiEntry.withOverride( children: [ jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle" }, { children: t("PWLESS_USER_INPUT_CODE_HEADER_TITLE") } ) ), jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: [ @@ -3796,26 +3779,20 @@ var UserInputCodeFormHeader = uiEntry.withOverride( var UserInputCodeFormScreen = function (props) { return jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container" }, { children: [ jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: [ - jsxRuntime.jsx( - UserInputCodeFormHeader, - genericComponentOverrideContext.__assign({}, props) - ), + jsxRuntime.jsx(UserInputCodeFormHeader, superTokens.__assign({}, props)), props.error !== undefined && jsxRuntime.jsx(uiEntry.GeneralError, { error: props.error }), - jsxRuntime.jsx( - UserInputCodeForm, - genericComponentOverrideContext.__assign({}, props) - ), + jsxRuntime.jsx(UserInputCodeForm, superTokens.__assign({}, props)), ], } ) @@ -3845,9 +3822,9 @@ var UserInputCodeForm = uiEntry.withOverride("PasswordlessUserInputCodeForm", fu ); var resend = React.useCallback( function resend() { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var response, generalError, e_1; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 5, , 6]); @@ -3906,7 +3883,7 @@ var UserInputCodeForm = uiEntry.withOverride("PasswordlessUserInputCodeForm", fu clearResendNotifTimeout !== undefined && jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "generalSuccess" }, { children: @@ -3926,7 +3903,7 @@ var UserInputCodeForm = uiEntry.withOverride("PasswordlessUserInputCodeForm", fu label: "", labelComponent: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ @@ -3955,10 +3932,10 @@ var UserInputCodeForm = uiEntry.withOverride("PasswordlessUserInputCodeForm", fu onSuccess: props.onSuccess, buttonLabel: "PWLESS_SIGN_IN_UP_CONTINUE_BUTTON", callAPI: function (formFields) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var userInputCode, response; var _a; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: userInputCode = @@ -4006,36 +3983,29 @@ var UserInputCodeForm = uiEntry.withOverride("PasswordlessUserInputCodeForm", fu ? _a : jsxRuntime.jsx( UserInputCodeFormFooter, - genericComponentOverrideContext.__assign({}, props, { - loginAttemptInfo: props.loginAttemptInfo, - }) + superTokens.__assign({}, props, { loginAttemptInfo: props.loginAttemptInfo }) ), }), ], }); }); function UserInputCodeFormScreenWrapper(props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeStyle = props.config.signInUpFeature.userInputCodeFormStyle; return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, activeStyle], }, - { - children: jsxRuntime.jsx( - UserInputCodeFormScreen, - genericComponentOverrideContext.__assign({}, props) - ), - } + { children: jsxRuntime.jsx(UserInputCodeFormScreen, superTokens.__assign({}, props)) } ) ), } @@ -4046,17 +4016,17 @@ function UserInputCodeFormScreenWrapper(props) { var OTPLoadingScreen = function () { return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container delayedRender pwless-mfa loadingScreen" }, { children: jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "spinner delayedRender" }, { children: jsxRuntime.jsx(uiEntry.SpinnerIcon, {}) } ) @@ -4074,12 +4044,12 @@ var MFAFooter = uiEntry.withOverride("PasswordlessMFAFooter", function Passwordl var t = translationContext.useTranslation(); return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "footerLinkGroupVert pwless-mfa footer" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: props.onSignOutClicked, @@ -4105,7 +4075,7 @@ var MFAHeader = uiEntry.withOverride("PasswordlessMFAHeader", function Passwordl children: [ jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle withBackButton pwless-mfa header" }, { children: [ @@ -4136,14 +4106,14 @@ var MFAOTPFooter = uiEntry.withOverride("PasswordlessMFAOTPFooter", function Pas var userContext = uiEntry.useUserContext(); return jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "footerLinkGroupVert pwless-mfa otpFooter" }, { children: [ canChangeEmail && jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "secondaryText", onClick: function () { @@ -4162,7 +4132,7 @@ var MFAOTPFooter = uiEntry.withOverride("PasswordlessMFAOTPFooter", function Pas ), jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: onSignOutClicked, @@ -4193,7 +4163,7 @@ var MFAOTPHeader = uiEntry.withOverride("PasswordlessMFAOTPHeader", function Pas children: [ jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle withBackButton pwless-mfa otpHeader" }, { children: [ @@ -4210,7 +4180,7 @@ var MFAOTPHeader = uiEntry.withOverride("PasswordlessMFAOTPHeader", function Pas ), jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: [ @@ -4240,7 +4210,7 @@ var MFATheme = function (_a) { var activeScreen = _a.activeScreen, featureState = _a.featureState, onBackButtonClicked = _a.onBackButtonClicked, - props = genericComponentOverrideContext.__rest(_a, ["activeScreen", "featureState", "onBackButtonClicked"]); + props = superTokens.__rest(_a, ["activeScreen", "featureState", "onBackButtonClicked"]); var t = translationContext.useTranslation(); var commonProps = { recipeImplementation: props.recipeImplementation, @@ -4265,13 +4235,13 @@ var MFATheme = function (_a) { }) : jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container pwless-mfa" }, { children: [ jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: jsxRuntime.jsxs(React__namespace.default.Fragment, { @@ -4279,7 +4249,7 @@ var MFATheme = function (_a) { activeScreen === MFAScreens.UserInputCodeForm ? jsxRuntime.jsx( MFAOTPHeader, - genericComponentOverrideContext.__assign({}, commonProps, { + superTokens.__assign({}, commonProps, { showBackButton: featureState.showBackButton, loginAttemptInfo: featureState.loginAttemptInfo, canChangeEmail: featureState.canChangeEmail, @@ -4288,7 +4258,7 @@ var MFATheme = function (_a) { ) : jsxRuntime.jsx( MFAHeader, - genericComponentOverrideContext.__assign({}, commonProps, { + superTokens.__assign({}, commonProps, { showBackButton: featureState.showBackButton, onBackButtonClicked: onBackButtonClicked, contactMethod: @@ -4302,54 +4272,42 @@ var MFATheme = function (_a) { activeScreen === MFAScreens.EmailForm ? jsxRuntime.jsx( EmailForm, - genericComponentOverrideContext.__assign({}, commonProps, { + superTokens.__assign({}, commonProps, { footer: jsxRuntime.jsx( MFAFooter, - genericComponentOverrideContext.__assign( - {}, - commonProps, - { - onSignOutClicked: props.onSignOutClicked, - canChangeEmail: featureState.canChangeEmail, - } - ) + superTokens.__assign({}, commonProps, { + onSignOutClicked: props.onSignOutClicked, + canChangeEmail: featureState.canChangeEmail, + }) ), }) ) : activeScreen === MFAScreens.PhoneForm ? jsxRuntime.jsx( PhoneForm, - genericComponentOverrideContext.__assign({}, commonProps, { + superTokens.__assign({}, commonProps, { footer: jsxRuntime.jsx( MFAFooter, - genericComponentOverrideContext.__assign( - {}, - commonProps, - { - onSignOutClicked: props.onSignOutClicked, - canChangeEmail: featureState.canChangeEmail, - } - ) + superTokens.__assign({}, commonProps, { + onSignOutClicked: props.onSignOutClicked, + canChangeEmail: featureState.canChangeEmail, + }) ), }) ) : activeScreen === MFAScreens.UserInputCodeForm ? jsxRuntime.jsx( UserInputCodeForm, - genericComponentOverrideContext.__assign({}, commonProps, { + superTokens.__assign({}, commonProps, { loginAttemptInfo: featureState.loginAttemptInfo, onSuccess: props.onSuccess, footer: jsxRuntime.jsx( MFAOTPFooter, - genericComponentOverrideContext.__assign( - {}, - commonProps, - { - onSignOutClicked: props.onSignOutClicked, - canChangeEmail: featureState.canChangeEmail, - loginAttemptInfo: featureState.loginAttemptInfo, - } - ) + superTokens.__assign({}, commonProps, { + onSignOutClicked: props.onSignOutClicked, + canChangeEmail: featureState.canChangeEmail, + loginAttemptInfo: featureState.loginAttemptInfo, + }) ), }) ) @@ -4366,7 +4324,7 @@ var MFATheme = function (_a) { ); }; function MFAThemeWrapper(props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeScreen = getActiveScreen$2(props); var activeStyle; @@ -4381,12 +4339,12 @@ function MFAThemeWrapper(props) { } return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [ @@ -4399,7 +4357,7 @@ function MFAThemeWrapper(props) { { children: jsxRuntime.jsx( MFATheme, - genericComponentOverrideContext.__assign({}, props, { activeScreen: activeScreen }) + superTokens.__assign({}, props, { activeScreen: activeScreen }) ), } ) @@ -4439,31 +4397,30 @@ var useFeatureReducer = function () { if (!oldState.loginAttemptInfo) { return oldState; } - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, oldState), - { - error: undefined, - loginAttemptInfo: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, oldState.loginAttemptInfo), - { lastResend: action.timestamp } - ), - } - ); + return superTokens.__assign(superTokens.__assign({}, oldState), { + error: undefined, + loginAttemptInfo: superTokens.__assign(superTokens.__assign({}, oldState.loginAttemptInfo), { + lastResend: action.timestamp, + }), + }); case "restartFlow": - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, oldState), - { error: action.error, loginAttemptInfo: undefined, showAccessDenied: !oldState.canChangeEmail } - ); + return superTokens.__assign(superTokens.__assign({}, oldState), { + error: action.error, + loginAttemptInfo: undefined, + showAccessDenied: !oldState.canChangeEmail, + }); case "setError": - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, oldState), - { loaded: true, error: action.error, showAccessDenied: action.showAccessDenied } - ); + return superTokens.__assign(superTokens.__assign({}, oldState), { + loaded: true, + error: action.error, + showAccessDenied: action.showAccessDenied, + }); case "startVerify": - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, oldState), - { loaded: true, loginAttemptInfo: action.loginAttemptInfo, error: undefined } - ); + return superTokens.__assign(superTokens.__assign({}, oldState), { + loaded: true, + loginAttemptInfo: action.loginAttemptInfo, + error: undefined, + }); default: return oldState; } @@ -4478,25 +4435,23 @@ var useFeatureReducer = function () { }, function (initArg) { var error = undefined; - var errorQueryParam = genericComponentOverrideContext.getQueryParams("error"); + var errorQueryParam = superTokens.getQueryParams("error"); if (errorQueryParam !== null) { error = "SOMETHING_WENT_WRONG_ERROR"; } - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, initArg), { - error: error, - }); + return superTokens.__assign(superTokens.__assign({}, initArg), { error: error }); } ); }; function useChildProps$3(recipe$1, recipeImplementation, state, contactMethod, dispatch, userContext, navigate) { var _this = this; - var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var rethrowInRender = superTokens.useRethrowInRender(); return React.useMemo( function () { var _a; return { onSuccess: function () { - var redirectToPath = genericComponentOverrideContext.getRedirectToPathFromURL(); + var redirectToPath = superTokens.getRedirectToPathFromURL(); return types.Session.getInstanceOrThrow() .validateGlobalClaimsAndHandleSuccessRedirection( undefined, @@ -4508,8 +4463,8 @@ function useChildProps$3(recipe$1, recipeImplementation, state, contactMethod, d .catch(rethrowInRender); }, onSignOutClicked: function () { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -4536,8 +4491,8 @@ function useChildProps$3(recipe$1, recipeImplementation, state, contactMethod, d }); }, onBackButtonClicked: function () { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: if (!state.loginAttemptInfo) return [3 /*break*/, 2]; @@ -4569,9 +4524,9 @@ function useChildProps$3(recipe$1, recipeImplementation, state, contactMethod, d }); }, onFetchError: function (err) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var invalidClaims, evInstance; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -4669,20 +4624,17 @@ var MFAFeatureInner = function (props) { props.children === undefined && jsxRuntime.jsx( MFAThemeWrapper, - genericComponentOverrideContext.__assign({}, childProps, { - featureState: state, - dispatch: dispatch, - }) + superTokens.__assign({}, childProps, { featureState: state, dispatch: dispatch }) ), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { return React__namespace.cloneElement( child, - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, childProps), - { featureState: state, dispatch: dispatch } - ) + superTokens.__assign(superTokens.__assign({}, childProps), { + featureState: state, + dispatch: dispatch, + }) ); } return child; @@ -4694,22 +4646,17 @@ var MFAFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { - useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, + useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, defaultStore: defaultTranslationsPasswordless, }, - { - children: jsxRuntime.jsx( - MFAFeatureInner, - genericComponentOverrideContext.__assign({}, props) - ), - } + { children: jsxRuntime.jsx(MFAFeatureInner, superTokens.__assign({}, props)) } ) ), } @@ -4720,8 +4667,8 @@ function useOnLoad(props, recipeImplementation, dispatch, userContext) { var _this = this; var fetchMFAInfo = React__namespace.useCallback( function () { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe$3.MultiFactorAuth.getInstanceOrThrow().webJSRecipe.resyncSessionAndFetchMFAInfo({ @@ -4741,7 +4688,7 @@ function useOnLoad(props, recipeImplementation, dispatch, userContext) { ); var onLoad = React__namespace.useCallback( function (mfaInfo) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var error, errorQueryParam, doSetup, @@ -4754,12 +4701,12 @@ function useOnLoad(props, recipeImplementation, dispatch, userContext) { err_1, invalidClaims, evInstance; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: error = undefined; - errorQueryParam = genericComponentOverrideContext.getQueryParams("error"); - doSetup = genericComponentOverrideContext.getQueryParams("setup"); + errorQueryParam = superTokens.getQueryParams("error"); + doSetup = superTokens.getQueryParams("setup"); if (errorQueryParam !== null) { error = "SOMETHING_WENT_WRONG_ERROR"; } @@ -4820,10 +4767,9 @@ function useOnLoad(props, recipeImplementation, dispatch, userContext) { return [ 4 /*yield*/, recipeImplementation.createCode( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, createCodeInfo), - { userContext: userContext } - ) + superTokens.__assign(superTokens.__assign({}, createCodeInfo), { + userContext: userContext, + }) ), ]; case 5: @@ -4926,15 +4872,15 @@ function useOnLoad(props, recipeImplementation, dispatch, userContext) { }, [dispatch, recipeImplementation, props.contactMethod, userContext] ); - genericComponentOverrideContext.useOnMountAPICall(fetchMFAInfo, onLoad, handleLoadError); + superTokens.useOnMountAPICall(fetchMFAInfo, onLoad, handleLoadError); } function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { var _this = this; - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImpl), { + return superTokens.__assign(superTokens.__assign({}, originalImpl), { createCode: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var contactInfo, phoneNumberUtils, contactMethod, additionalAttemptInfo, res, loginAttemptInfo; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, getPhoneNumberUtils()]; @@ -4954,20 +4900,16 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { lastResend: Date.now(), contactMethod: contactMethod, contactInfo: contactInfo, - redirectToPath: genericComponentOverrideContext.getRedirectToPathFromURL(), + redirectToPath: superTokens.getRedirectToPathFromURL(), }; return [ 4 /*yield*/, originalImpl.createCode( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, input), - { - userContext: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, input.userContext), - { additionalAttemptInfo: additionalAttemptInfo } - ), - } - ) + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.__assign(superTokens.__assign({}, input.userContext), { + additionalAttemptInfo: additionalAttemptInfo, + }), + }) ), ]; case 2: @@ -4990,9 +4932,9 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { }); }, resendCode: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var res, loginAttemptInfo, timestamp; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.resendCode(input)]; @@ -5013,10 +4955,9 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { 4 /*yield*/, originalImpl.setLoginAttemptInfo({ userContext: input.userContext, - attemptInfo: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, loginAttemptInfo), - { lastResend: timestamp } - ), + attemptInfo: superTokens.__assign(superTokens.__assign({}, loginAttemptInfo), { + lastResend: timestamp, + }), }), ]; case 3: @@ -5044,9 +4985,9 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { }); }, consumeCode: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var res; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.consumeCode(input)]; @@ -5097,8 +5038,8 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { }); }, clearLoginAttemptInfo: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -5109,7 +5050,7 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { ]; case 1: _a.sent(); - genericComponentOverrideContext.clearErrorQueryParam(); + superTokens.clearErrorQueryParam(); dispatch({ type: "restartFlow", error: undefined }); return [2 /*return*/]; } @@ -5151,14 +5092,14 @@ var EmailOrPhoneForm = uiEntry.withOverride( label: "", labelComponent: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ jsxRuntime.jsx(formBase.Label, { value: "PWLESS_SIGN_IN_UP_PHONE_LABEL" }), jsxRuntime.jsx( "a", - genericComponentOverrideContext.__assign( + superTokens.__assign( { onClick: function () { return setIsPhoneNumber(false); @@ -5187,7 +5128,7 @@ var EmailOrPhoneForm = uiEntry.withOverride( label: "", labelComponent: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ @@ -5197,7 +5138,7 @@ var EmailOrPhoneForm = uiEntry.withOverride( }), jsxRuntime.jsx( "a", - genericComponentOverrideContext.__assign( + superTokens.__assign( { onClick: function () { return setIsPhoneNumber(function (v) { @@ -5225,10 +5166,10 @@ var EmailOrPhoneForm = uiEntry.withOverride( buttonLabel: "PWLESS_SIGN_IN_UP_CONTINUE_BUTTON", onSuccess: props.onSuccess, callAPI: function (formFields) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var contactInfo, phoneNumber, validationRes, email, validationRes, response; var _a, _b; - return genericComponentOverrideContext.__generator(this, function (_c) { + return superTokens.__generator(this, function (_c) { switch (_c.label) { case 0: if (!isPhoneNumber) return [3 /*break*/, 2]; @@ -5271,10 +5212,9 @@ var EmailOrPhoneForm = uiEntry.withOverride( return [ 4 /*yield*/, props.recipeImplementation.createCode( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, contactInfo), - { userContext: userContext } - ) + superTokens.__assign(superTokens.__assign({}, contactInfo), { + userContext: userContext, + }) ), ]; case 5: @@ -5305,7 +5245,7 @@ var SignInUpScreens; */ var SignInUpTheme$1 = function (_a) { var activeScreen = _a.activeScreen, - props = genericComponentOverrideContext.__rest(_a, ["activeScreen"]); + props = superTokens.__rest(_a, ["activeScreen"]); var commonProps = { recipeImplementation: props.recipeImplementation, config: props.config, @@ -5316,15 +5256,15 @@ var SignInUpTheme$1 = function (_a) { validatePhoneNumber: props.validatePhoneNumber, }; return activeScreen === SignInUpScreens.EmailForm - ? jsxRuntime.jsx(EmailForm, genericComponentOverrideContext.__assign({}, commonProps)) + ? jsxRuntime.jsx(EmailForm, superTokens.__assign({}, commonProps)) : activeScreen === SignInUpScreens.PhoneForm - ? jsxRuntime.jsx(PhoneForm, genericComponentOverrideContext.__assign({}, commonProps)) + ? jsxRuntime.jsx(PhoneForm, superTokens.__assign({}, commonProps)) : activeScreen === SignInUpScreens.EmailOrPhoneForm - ? jsxRuntime.jsx(EmailOrPhoneForm, genericComponentOverrideContext.__assign({}, commonProps)) + ? jsxRuntime.jsx(EmailOrPhoneForm, superTokens.__assign({}, commonProps)) : null; }; function SignInUpThemeWrapper$1(props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeScreen = getActiveScreen$1(props.factorIds); var activeStyle; @@ -5337,12 +5277,12 @@ function SignInUpThemeWrapper$1(props) { } return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, activeStyle], @@ -5350,7 +5290,7 @@ function SignInUpThemeWrapper$1(props) { { children: jsxRuntime.jsx( SignInUpTheme$1, - genericComponentOverrideContext.__assign({}, props, { activeScreen: activeScreen }) + superTokens.__assign({}, props, { activeScreen: activeScreen }) ), } ) @@ -5371,7 +5311,17 @@ function getActiveScreen$1(factorIds) { } } -function useChildProps$2(recipe$1, factorIds, error, onError, clearError, rebuildAuthPage, userContext, navigate) { +function useChildProps$2( + recipe$1, + factorIds, + onAuthSuccess, + error, + onError, + clearError, + rebuildAuthPage, + userContext, + navigate +) { var _this = this; var session$1 = uiEntry.useSessionContext(); var recipeImplementation = React__namespace.useMemo( @@ -5382,16 +5332,16 @@ function useChildProps$2(recipe$1, factorIds, error, onError, clearError, rebuil }, [recipe$1] ); - var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var rethrowInRender = superTokens.useRethrowInRender(); return React.useMemo( function () { var _a; return { userContext: userContext, onSuccess: function (result) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var payloadAfterCall; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, , 3]); @@ -5411,28 +5361,18 @@ function useChildProps$2(recipe$1, factorIds, error, onError, clearError, rebuil case 3: return [ 2 /*return*/, - types.Session.getInstanceOrThrow() - .validateGlobalClaimsAndHandleSuccessRedirection( - { - action: "SUCCESS", - createdNewUser: - result.createdNewRecipeUser && - result.user.loginMethods.length === 1, - isNewRecipeUser: result.createdNewRecipeUser, - newSessionCreated: - session$1.loading || - !session$1.doesSessionExist || - (payloadAfterCall !== undefined && - session$1.accessTokenPayload.sessionHandle !== - payloadAfterCall.sessionHandle), - recipeId: recipe$1.recipeID, - }, - recipe$1.recipeID, - genericComponentOverrideContext.getRedirectToPathFromURL(), - userContext, - navigate - ) - .catch(rethrowInRender), + onAuthSuccess({ + createdNewUser: + result.createdNewRecipeUser && result.user.loginMethods.length === 1, + isNewRecipeUser: result.createdNewRecipeUser, + newSessionCreated: + session$1.loading || + !session$1.doesSessionExist || + (payloadAfterCall !== undefined && + session$1.accessTokenPayload.sessionHandle !== + payloadAfterCall.sessionHandle), + recipeId: "passwordless", + }).catch(rethrowInRender), ]; } }); @@ -5442,9 +5382,9 @@ function useChildProps$2(recipe$1, factorIds, error, onError, clearError, rebuil onError: onError, clearError: clearError, onFetchError: function (err) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var invalidClaims, evInstance; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -5517,6 +5457,7 @@ var SignInUpFeatureInner = function (props) { var childProps = useChildProps$2( props.recipe, props.factorIds, + props.onAuthSuccess, props.error, props.onError, props.clearError, @@ -5527,14 +5468,11 @@ var SignInUpFeatureInner = function (props) { return jsxRuntime.jsxs(React.Fragment, { children: [ props.children === undefined && - jsxRuntime.jsx(SignInUpThemeWrapper$1, genericComponentOverrideContext.__assign({}, childProps)), + jsxRuntime.jsx(SignInUpThemeWrapper$1, superTokens.__assign({}, childProps)), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { - return React__namespace.cloneElement( - child, - genericComponentOverrideContext.__assign({}, childProps) - ); + return React__namespace.cloneElement(child, superTokens.__assign({}, childProps)); } return child; }), @@ -5545,19 +5483,19 @@ var SignInUpFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { recipeComponentOverrides: recipeComponentOverrides }, - { children: jsxRuntime.jsx(SignInUpFeatureInner, genericComponentOverrideContext.__assign({}, props)) } + { children: jsxRuntime.jsx(SignInUpFeatureInner, superTokens.__assign({}, props)) } ) ); }; function getModifiedRecipeImplementation$2(originalImpl, config, rebuildAuthPage) { var _this = this; - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImpl), { + return superTokens.__assign(superTokens.__assign({}, originalImpl), { createCode: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var contactInfo, phoneNumberUtils, contactMethod, additionalAttemptInfo, res; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, getPhoneNumberUtils()]; @@ -5577,20 +5515,16 @@ function getModifiedRecipeImplementation$2(originalImpl, config, rebuildAuthPage lastResend: Date.now(), contactMethod: contactMethod, contactInfo: contactInfo, - redirectToPath: genericComponentOverrideContext.getRedirectToPathFromURL(), + redirectToPath: superTokens.getRedirectToPathFromURL(), }; return [ 4 /*yield*/, originalImpl.createCode( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, input), - { - userContext: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, input.userContext), - { additionalAttemptInfo: additionalAttemptInfo } - ), - } - ) + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.__assign(superTokens.__assign({}, input.userContext), { + additionalAttemptInfo: additionalAttemptInfo, + }), + }) ), ]; case 2: @@ -5621,14 +5555,14 @@ var ContinueWithPasswordlessFooter = function (_a) { } return jsxRuntime.jsx( "a", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "link linkButton continueWithPasswordlessLink", onClick: function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var phoneNumber, validationRes, email, validationRes; var _a, _b; - return genericComponentOverrideContext.__generator(this, function (_c) { + return superTokens.__generator(this, function (_c) { switch (_c.label) { case 0: if (!isPhoneNumber) return [3 /*break*/, 2]; @@ -5706,7 +5640,7 @@ var EPComboEmailForm = uiEntry.withOverride( validate: recipe$2.defaultValidate, labelComponent: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ @@ -5716,7 +5650,7 @@ var EPComboEmailForm = uiEntry.withOverride( }), jsxRuntime.jsx( "a", - genericComponentOverrideContext.__assign( + superTokens.__assign( { onClick: function () { return recipe$1.EmailPassword.getInstanceOrThrow().redirect({ @@ -5742,10 +5676,10 @@ var EPComboEmailForm = uiEntry.withOverride( buttonLabel: "PWLESS_SIGN_IN_UP_CONTINUE_BUTTON", onSuccess: props.onSuccess, callAPI: function (formFields) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var email, validationRes; var _a; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: email = @@ -5811,14 +5745,14 @@ var EPComboEmailOrPhoneForm = uiEntry.withOverride( label: "", labelComponent: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ jsxRuntime.jsx(formBase.Label, { value: "PWLESS_SIGN_IN_UP_PHONE_LABEL" }), jsxRuntime.jsx( "a", - genericComponentOverrideContext.__assign( + superTokens.__assign( { onClick: function () { return props.setIsPhoneNumber(false); @@ -5847,14 +5781,14 @@ var EPComboEmailOrPhoneForm = uiEntry.withOverride( label: "", labelComponent: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ jsxRuntime.jsx(formBase.Label, { value: "PWLESS_SIGN_IN_UP_EMAIL_LABEL" }), jsxRuntime.jsx( "a", - genericComponentOverrideContext.__assign( + superTokens.__assign( { onClick: function () { return props.setIsPhoneNumber(true); @@ -5887,7 +5821,7 @@ var EPComboEmailOrPhoneForm = uiEntry.withOverride( validate: recipe$2.defaultValidate, labelComponent: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ @@ -5897,7 +5831,7 @@ var EPComboEmailOrPhoneForm = uiEntry.withOverride( }), jsxRuntime.jsx( "a", - genericComponentOverrideContext.__assign( + superTokens.__assign( { onClick: function () { return recipe$1.EmailPassword.getInstanceOrThrow().redirect({ @@ -5922,10 +5856,10 @@ var EPComboEmailOrPhoneForm = uiEntry.withOverride( formFields: formFields, buttonLabel: "PWLESS_SIGN_IN_UP_CONTINUE_BUTTON", callAPI: function (formFields) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var phoneNumber, validationRes, email, validationRes; var _a, _b; - return genericComponentOverrideContext.__generator(this, function (_c) { + return superTokens.__generator(this, function (_c) { switch (_c.label) { case 0: if (!props.isPhoneNumber) return [3 /*break*/, 2]; @@ -5998,27 +5932,27 @@ var SignInUpEPComboScreens; */ var SignInUpTheme = function (_a) { var activeScreen = _a.activeScreen, - props = genericComponentOverrideContext.__rest(_a, ["activeScreen"]); - var commonProps = genericComponentOverrideContext.__assign({}, props); + props = superTokens.__rest(_a, ["activeScreen"]); + var commonProps = superTokens.__assign({}, props); return activeScreen === SignInUpEPComboScreens.EmailForm - ? jsxRuntime.jsx(EPComboEmailForm, genericComponentOverrideContext.__assign({}, commonProps)) + ? jsxRuntime.jsx(EPComboEmailForm, superTokens.__assign({}, commonProps)) : activeScreen === SignInUpEPComboScreens.EmailOrPhoneForm - ? jsxRuntime.jsx(EPComboEmailOrPhoneForm, genericComponentOverrideContext.__assign({}, commonProps)) + ? jsxRuntime.jsx(EPComboEmailOrPhoneForm, superTokens.__assign({}, commonProps)) : null; }; function SignInUpThemeWrapper(props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeScreen = getActiveScreen(props.factorIds); var activeStyle = props.config.signInUpFeature.emailOrPhoneFormStyle; return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, activeStyle], @@ -6026,7 +5960,7 @@ function SignInUpThemeWrapper(props) { { children: jsxRuntime.jsx( SignInUpTheme, - genericComponentOverrideContext.__assign({}, props, { activeScreen: activeScreen }) + superTokens.__assign({}, props, { activeScreen: activeScreen }) ), } ) @@ -6043,7 +5977,17 @@ function getActiveScreen(factorIds) { } } -function useChildProps$1(recipe$2, factorIds, error, onError, clearError, rebuildAuthPage, userContext, navigate) { +function useChildProps$1( + recipe$2, + factorIds, + onAuthSuccess, + error, + onError, + clearError, + rebuildAuthPage, + userContext, + navigate +) { var _this = this; var session$1 = uiEntry.useSessionContext(); var recipeImplementation = React__namespace.useMemo( @@ -6063,7 +6007,7 @@ function useChildProps$1(recipe$2, factorIds, error, onError, clearError, rebuil var _c = React__namespace.useState(false), showContinueWithPasswordlessLink = _c[0], setShowContinueWithPasswordlessLink = _c[1]; - var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var rethrowInRender = superTokens.useRethrowInRender(); return React.useMemo( function () { var _a; @@ -6080,9 +6024,9 @@ function useChildProps$1(recipe$2, factorIds, error, onError, clearError, rebuil showPasswordField: showPasswordField, showContinueWithPasswordlessLink: showContinueWithPasswordlessLink, onContactInfoSubmit: function (contactInfo) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var createRes, email, _a, epExists, pwlessExists, createRes; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: if (!isPhoneNumber) return [3 /*break*/, 2]; @@ -6155,14 +6099,14 @@ function useChildProps$1(recipe$2, factorIds, error, onError, clearError, rebuil }); }, onPasswordSubmit: function (formFields) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var validationErrors, response; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, - genericComponentOverrideContext.validateForm( + superTokens.validateForm( formFields, recipe$1.EmailPassword.getInstanceOrThrow().config.signInAndUpFeature .signInForm.formFields @@ -6197,10 +6141,9 @@ function useChildProps$1(recipe$2, factorIds, error, onError, clearError, rebuil } else { return [ 2 /*return*/, - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, response), - { isEmailPassword: true } - ), + superTokens.__assign(superTokens.__assign({}, response), { + isEmailPassword: true, + }), ]; } } @@ -6208,19 +6151,18 @@ function useChildProps$1(recipe$2, factorIds, error, onError, clearError, rebuil }); }, onContinueWithPasswordlessClick: function (contactInfo) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var createInfo, createRes; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: createInfo = isPhoneNumber ? { phoneNumber: contactInfo } : { email: contactInfo }; return [ 4 /*yield*/, recipeImplementation.createCode( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, createInfo), - { userContext: userContext } - ) + superTokens.__assign(superTokens.__assign({}, createInfo), { + userContext: userContext, + }) ), ]; case 1: @@ -6236,9 +6178,9 @@ function useChildProps$1(recipe$2, factorIds, error, onError, clearError, rebuil }); }, onSuccess: function (result) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var payloadAfterCall; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: if (!result.isEmailPassword) { @@ -6263,32 +6205,20 @@ function useChildProps$1(recipe$2, factorIds, error, onError, clearError, rebuil case 4: return [ 2 /*return*/, - types.Session.getInstanceOrThrow() - .validateGlobalClaimsAndHandleSuccessRedirection( - { - action: "SUCCESS", - createdNewUser: - result.createdNewRecipeUser && - result.user.loginMethods.length === 1, - isNewRecipeUser: result.createdNewRecipeUser, - newSessionCreated: - session$1.loading || - !session$1.doesSessionExist || - (payloadAfterCall !== undefined && - session$1.accessTokenPayload.sessionHandle !== - payloadAfterCall.sessionHandle), - recipeId: result.isEmailPassword - ? recipe$1.EmailPassword.RECIPE_ID - : recipe$2.recipeID, - }, - result.isEmailPassword - ? recipe$1.EmailPassword.RECIPE_ID - : recipe$2.recipeID, - genericComponentOverrideContext.getRedirectToPathFromURL(), - userContext, - navigate - ) - .catch(rethrowInRender), + onAuthSuccess({ + createdNewUser: + result.createdNewRecipeUser && result.user.loginMethods.length === 1, + isNewRecipeUser: result.createdNewRecipeUser, + newSessionCreated: + session$1.loading || + !session$1.doesSessionExist || + (payloadAfterCall !== undefined && + session$1.accessTokenPayload.sessionHandle !== + payloadAfterCall.sessionHandle), + recipeId: result.isEmailPassword + ? recipe$1.EmailPassword.RECIPE_ID + : recipe$2.recipeID, + }).catch(rethrowInRender), ]; } }); @@ -6298,9 +6228,9 @@ function useChildProps$1(recipe$2, factorIds, error, onError, clearError, rebuil onError: onError, clearError: clearError, onFetchError: function (err) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var invalidClaims, evInstance; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -6381,6 +6311,7 @@ var SignInUpEPComboFeatureInner = function (props) { var childProps = useChildProps$1( props.recipe, props.factorIds, + props.onAuthSuccess, props.error, props.onError, props.clearError, @@ -6390,15 +6321,11 @@ var SignInUpEPComboFeatureInner = function (props) { ); return jsxRuntime.jsxs(React.Fragment, { children: [ - props.children === undefined && - jsxRuntime.jsx(SignInUpThemeWrapper, genericComponentOverrideContext.__assign({}, childProps)), + props.children === undefined && jsxRuntime.jsx(SignInUpThemeWrapper, superTokens.__assign({}, childProps)), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { - return React__namespace.cloneElement( - child, - genericComponentOverrideContext.__assign({}, childProps) - ); + return React__namespace.cloneElement(child, superTokens.__assign({}, childProps)); } return child; }), @@ -6409,24 +6336,19 @@ var SignInUpEPComboFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { recipeComponentOverrides: recipeComponentOverrides }, - { - children: jsxRuntime.jsx( - SignInUpEPComboFeatureInner, - genericComponentOverrideContext.__assign({}, props) - ), - } + { children: jsxRuntime.jsx(SignInUpEPComboFeatureInner, superTokens.__assign({}, props)) } ) ); }; function getModifiedRecipeImplementation$1(originalImpl, config, rebuildAuthPage) { var _this = this; - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImpl), { + return superTokens.__assign(superTokens.__assign({}, originalImpl), { createCode: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var contactInfo, phoneNumberUtils, contactMethod, additionalAttemptInfo, res; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, getPhoneNumberUtils()]; @@ -6446,20 +6368,16 @@ function getModifiedRecipeImplementation$1(originalImpl, config, rebuildAuthPage lastResend: Date.now(), contactMethod: contactMethod, contactInfo: contactInfo, - redirectToPath: genericComponentOverrideContext.getRedirectToPathFromURL(), + redirectToPath: superTokens.getRedirectToPathFromURL(), }; return [ 4 /*yield*/, originalImpl.createCode( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, input), - { - userContext: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, input.userContext), - { additionalAttemptInfo: additionalAttemptInfo } - ), - } - ) + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.__assign(superTokens.__assign({}, input.userContext), { + additionalAttemptInfo: additionalAttemptInfo, + }), + }) ), ]; case 2: @@ -6475,7 +6393,17 @@ function getModifiedRecipeImplementation$1(originalImpl, config, rebuildAuthPage }); } -function useChildProps(recipe$1, loginAttemptInfo, error, onError, clearError, rebuildAuthPage, userContext, navigate) { +function useChildProps( + recipe$1, + loginAttemptInfo, + onAuthSuccess, + error, + onError, + clearError, + rebuildAuthPage, + userContext, + navigate +) { var _this = this; var session$1 = uiEntry.useSessionContext(); var recipeImplementation = React__namespace.useMemo( @@ -6484,15 +6412,15 @@ function useChildProps(recipe$1, loginAttemptInfo, error, onError, clearError, r }, [recipe$1, onError, rebuildAuthPage] ); - var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var rethrowInRender = superTokens.useRethrowInRender(); return React.useMemo( function () { return { userContext: userContext, onSuccess: function (result) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var payloadAfterCall; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, , 3]); @@ -6512,37 +6440,27 @@ function useChildProps(recipe$1, loginAttemptInfo, error, onError, clearError, r case 3: return [ 2 /*return*/, - types.Session.getInstanceOrThrow() - .validateGlobalClaimsAndHandleSuccessRedirection( - { - action: "SUCCESS", - createdNewUser: - result.createdNewRecipeUser && - result.user.loginMethods.length === 1, - isNewRecipeUser: result.createdNewRecipeUser, - newSessionCreated: - session$1.loading || - !session$1.doesSessionExist || - (payloadAfterCall !== undefined && - session$1.accessTokenPayload.sessionHandle !== - payloadAfterCall.sessionHandle), - recipeId: recipe$1.recipeID, - }, - recipe$1.recipeID, - genericComponentOverrideContext.getRedirectToPathFromURL(), - userContext, - navigate - ) - .catch(rethrowInRender), + onAuthSuccess({ + createdNewUser: + result.createdNewRecipeUser && result.user.loginMethods.length === 1, + isNewRecipeUser: result.createdNewRecipeUser, + newSessionCreated: + session$1.loading || + !session$1.doesSessionExist || + (payloadAfterCall !== undefined && + session$1.accessTokenPayload.sessionHandle !== + payloadAfterCall.sessionHandle), + recipeId: "passwordless", + }).catch(rethrowInRender), ]; } }); }); }, onFetchError: function (err) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var invalidClaims, evInstance; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -6610,6 +6528,7 @@ var UserInputCodeFeatureInner = function (props) { var childProps = useChildProps( props.recipe, props.loginAttemptInfo, + props.onAuthSuccess, props.error, props.onError, props.clearError, @@ -6622,15 +6541,12 @@ var UserInputCodeFeatureInner = function (props) { props.children === undefined && jsxRuntime.jsx( UserInputCodeFormScreenWrapper, - genericComponentOverrideContext.__assign({}, childProps, { userContext: props.userContext }) + superTokens.__assign({}, childProps, { userContext: props.userContext }) ), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { - return React__namespace.cloneElement( - child, - genericComponentOverrideContext.__assign({}, childProps) - ); + return React__namespace.cloneElement(child, superTokens.__assign({}, childProps)); } return child; }), @@ -6641,19 +6557,19 @@ var UserInputCodeFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { recipeComponentOverrides: recipeComponentOverrides }, - { children: jsxRuntime.jsx(UserInputCodeFeatureInner, genericComponentOverrideContext.__assign({}, props)) } + { children: jsxRuntime.jsx(UserInputCodeFeatureInner, superTokens.__assign({}, props)) } ) ); }; function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage) { var _this = this; - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImpl), { + return superTokens.__assign(superTokens.__assign({}, originalImpl), { resendCode: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var res, loginAttemptInfo, timestamp; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.resendCode(input)]; @@ -6674,10 +6590,9 @@ function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage 4 /*yield*/, originalImpl.setLoginAttemptInfo({ userContext: input.userContext, - attemptInfo: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, loginAttemptInfo), - { lastResend: timestamp } - ), + attemptInfo: superTokens.__assign(superTokens.__assign({}, loginAttemptInfo), { + lastResend: timestamp, + }), }), ]; case 3: @@ -6705,9 +6620,9 @@ function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage }); }, consumeCode: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var res; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.consumeCode(input)]; @@ -6756,8 +6671,8 @@ function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage }); }, clearLoginAttemptInfo: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -6768,7 +6683,7 @@ function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage ]; case 1: _a.sent(); - genericComponentOverrideContext.clearErrorQueryParam(); + superTokens.clearErrorQueryParam(); rebuildAuthPage(); return [2 /*return*/]; } @@ -6779,7 +6694,7 @@ function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage } var PasswordlessPreBuiltUI = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(PasswordlessPreBuiltUI, _super); + superTokens.__extends(PasswordlessPreBuiltUI, _super); function PasswordlessPreBuiltUI(recipeInstance) { var _this = _super.call(this) || this; _this.recipeInstance = recipeInstance; @@ -6795,9 +6710,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { new NormalisedURLPath__default.default("/verify") ); features[normalisedFullPath.getAsStringDangerous()] = { - matches: genericComponentOverrideContext.matchRecipeIdUsingQueryParams( - _this.recipeInstance.config.recipeId - ), + matches: superTokens.matchRecipeIdUsingQueryParams(_this.recipeInstance.config.recipeId), component: function (props) { return _this.getFeatureComponent("linkClickedScreen", props, useComponentOverrides); }, @@ -6809,9 +6722,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { new NormalisedURLPath__default.default("/mfa/otp-phone") ); features[normalisedFullPathPhone.getAsStringDangerous()] = { - matches: genericComponentOverrideContext.matchRecipeIdUsingQueryParams( - _this.recipeInstance.config.recipeId - ), + matches: superTokens.matchRecipeIdUsingQueryParams(_this.recipeInstance.config.recipeId), component: function (props) { return _this.getFeatureComponent("otp-phone", props, useComponentOverrides); }, @@ -6821,9 +6732,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { new NormalisedURLPath__default.default("/mfa/otp-email") ); features[normalisedFullPathEmail.getAsStringDangerous()] = { - matches: genericComponentOverrideContext.matchRecipeIdUsingQueryParams( - _this.recipeInstance.config.recipeId - ), + matches: superTokens.matchRecipeIdUsingQueryParams(_this.recipeInstance.config.recipeId), component: function (props) { return _this.getFeatureComponent("otp-email", props, useComponentOverrides); }, @@ -6839,21 +6748,19 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { if (componentName === "linkClickedScreen") { return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( session.SessionAuth, - genericComponentOverrideContext.__assign( + superTokens.__assign( { requireAuth: false, doRedirection: false }, { children: jsxRuntime.jsx( LinkClickedScreen, - genericComponentOverrideContext.__assign( - { recipe: _this.recipeInstance }, - props, - { useComponentOverrides: useComponentOverrides } - ) + superTokens.__assign({ recipe: _this.recipeInstance }, props, { + useComponentOverrides: useComponentOverrides, + }) ), } ) @@ -6865,12 +6772,12 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { if (componentName === "otp-email") { return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( session.SessionAuth, - genericComponentOverrideContext.__assign( + superTokens.__assign( { overrideGlobalClaimValidators: function () { return []; @@ -6879,7 +6786,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { { children: jsxRuntime.jsx( MFAFeature, - genericComponentOverrideContext.__assign( + superTokens.__assign( { recipe: _this.recipeInstance, useComponentOverrides: useComponentOverrides, @@ -6899,12 +6806,12 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { if (componentName === "otp-phone") { return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( session.SessionAuth, - genericComponentOverrideContext.__assign( + superTokens.__assign( { overrideGlobalClaimValidators: function () { return []; @@ -6913,7 +6820,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { { children: jsxRuntime.jsx( MFAFeature, - genericComponentOverrideContext.__assign( + superTokens.__assign( { recipe: _this.recipeInstance, useComponentOverrides: useComponentOverrides, @@ -6966,16 +6873,16 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { types.FactorIds.OTP_EMAIL, types.FactorIds.OTP_PHONE, ]); - var res = genericComponentOverrideContext.__spreadArray( - genericComponentOverrideContext.__spreadArray( + var res = superTokens.__spreadArray( + superTokens.__spreadArray( [ { type: "FULL_PAGE", preloadInfoAndRunChecks: function (firstFactors, userContext) { var _b, _c; - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var loginAttemptInfo; - return genericComponentOverrideContext.__generator(this, function (_d) { + return superTokens.__generator(this, function (_d) { switch (_d.label) { case 0: return [ @@ -7053,10 +6960,10 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { }, component: function (_b) { var preloadInfo = _b.preloadInfo, - props = genericComponentOverrideContext.__rest(_b, ["preloadInfo"]); + props = superTokens.__rest(_b, ["preloadInfo"]); return jsxRuntime.jsx( LinkSentFeature, - genericComponentOverrideContext.__assign({}, props, { + superTokens.__assign({}, props, { recipe: _this.recipeInstance, useComponentOverrides: recipe$2.useContext, loginAttemptInfo: preloadInfo, @@ -7069,9 +6976,9 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { type: "FULL_PAGE", preloadInfoAndRunChecks: function (firstFactors, userContext) { var _b, _c; - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var loginAttemptInfo; - return genericComponentOverrideContext.__generator(this, function (_d) { + return superTokens.__generator(this, function (_d) { switch (_d.label) { case 0: return [ @@ -7149,10 +7056,10 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { }, component: function (_b) { var preloadInfo = _b.preloadInfo, - props = genericComponentOverrideContext.__rest(_b, ["preloadInfo"]); + props = superTokens.__rest(_b, ["preloadInfo"]); return jsxRuntime.jsx( UserInputCodeFeature, - genericComponentOverrideContext.__assign({}, props, { + superTokens.__assign({}, props, { recipe: _this.recipeInstance, useComponentOverrides: recipe$2.useContext, loginAttemptInfo: preloadInfo, @@ -7170,7 +7077,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { component: function (props) { return React.createElement( SignInUpFeature, - genericComponentOverrideContext.__assign({}, props, { + superTokens.__assign({}, props, { key: factors.join("|"), recipe: _this.recipeInstance, useComponentOverrides: recipe$2.useContext, @@ -7190,7 +7097,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { component: function (props) { return jsxRuntime.jsx( ContinueWithPasswordlessFeature, - genericComponentOverrideContext.__assign({}, props, { + superTokens.__assign({}, props, { recipe: _this.recipeInstance, factorIds: factors, useComponentOverrides: recipe$2.useContext, @@ -7210,11 +7117,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { res, factorCombos .map(function (combo) { - return genericComponentOverrideContext.__spreadArray( - [types.FactorIds.EMAILPASSWORD], - combo, - true - ); + return superTokens.__spreadArray([types.FactorIds.EMAILPASSWORD], combo, true); }) .map(function (factors) { return { @@ -7224,7 +7127,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { component: function (props) { return React.createElement( SignInUpEPComboFeature, - genericComponentOverrideContext.__assign({}, props, { + superTokens.__assign({}, props, { key: factors.join("|"), recipe: _this.recipeInstance, useComponentOverrides: recipe$2.useContext, @@ -7242,7 +7145,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { }; // For tests PasswordlessPreBuiltUI.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } PasswordlessPreBuiltUI.instance = undefined; @@ -7270,10 +7173,10 @@ function getAllChoices(choices) { return [[]]; } var subChoices = getAllChoices(choices.slice(1)); - return genericComponentOverrideContext.__spreadArray( - genericComponentOverrideContext.__spreadArray([], subChoices, true), + return superTokens.__spreadArray( + superTokens.__spreadArray([], subChoices, true), subChoices.map(function (a) { - return genericComponentOverrideContext.__spreadArray([choices[0]], a, true); + return superTokens.__spreadArray([choices[0]], a, true); }), true ); diff --git a/lib/build/recipe/authRecipe/components/theme/authPage/authPageHeader.d.ts b/lib/build/recipe/authRecipe/components/theme/authPage/authPageHeader.d.ts index 60ed74fed..eff8b2713 100644 --- a/lib/build/recipe/authRecipe/components/theme/authPage/authPageHeader.d.ts +++ b/lib/build/recipe/authRecipe/components/theme/authPage/authPageHeader.d.ts @@ -6,4 +6,5 @@ export declare const AuthPageHeader: import("react").ComponentType<{ onSignInUpSwitcherClick: (() => void) | undefined; resetFactorList: () => void; showBackButton: boolean; + clientAppName?: string | undefined; }>; diff --git a/lib/build/recipe/authRecipe/types.d.ts b/lib/build/recipe/authRecipe/types.d.ts index 4dbbf3131..1f8562b45 100644 --- a/lib/build/recipe/authRecipe/types.d.ts +++ b/lib/build/recipe/authRecipe/types.d.ts @@ -3,7 +3,13 @@ import type { AuthPageComponentList } from "./components/theme/authPage/authPage import type { AuthPageFooter } from "./components/theme/authPage/authPageFooter"; import type { AuthPageHeader } from "./components/theme/authPage/authPageHeader"; import type { ComponentOverride } from "../../components/componentOverride/componentOverride"; -import type { AuthComponentProps, Navigate, PartialAuthComponentProps, UserContext } from "../../types"; +import type { + AuthComponentProps, + Navigate, + PartialAuthComponentProps, + SuccessRedirectContext, + UserContext, +} from "../../types"; import type { Config as RecipeModuleConfig, NormalisedConfig as NormalisedRecipeModuleConfig, @@ -26,7 +32,15 @@ declare type ComponentWithPreloadInfo = { >; preloadInfo: T; }; +export declare type AuthSuccessContext = Omit< + SuccessRedirectContext, + "redirectToPath" | "action" | "loginChallenge" | "recipeId" +> & { + recipeId: string; +}; export declare type AuthPageThemeProps = { + clientAppName: string | undefined; + onAuthSuccess: (successContext: AuthSuccessContext) => Promise; showBackButton: boolean; setFactorList: (factorIds: string[]) => void; resetFactorList: () => void; diff --git a/lib/build/recipe/emailpassword/components/features/signin/index.d.ts b/lib/build/recipe/emailpassword/components/features/signin/index.d.ts index cc8a4adfa..89d1808a1 100644 --- a/lib/build/recipe/emailpassword/components/features/signin/index.d.ts +++ b/lib/build/recipe/emailpassword/components/features/signin/index.d.ts @@ -1,10 +1,12 @@ import * as React from "react"; import type { Navigate, UserContext, PartialAuthComponentProps } from "../../../../../types"; +import type { AuthSuccessContext } from "../../../../authRecipe/types"; import type Recipe from "../../../recipe"; import type { SignInThemeProps } from "../../../types"; import type { ComponentOverrideMap } from "../../../types"; export declare function useChildProps( recipe: Recipe, + onAuthSuccess: (successContext: AuthSuccessContext) => Promise, error: string | undefined, onError: (err: string) => void, clearError: () => void, diff --git a/lib/build/recipe/emailpassword/components/features/signup/index.d.ts b/lib/build/recipe/emailpassword/components/features/signup/index.d.ts index a0b3bc16d..08715c7a5 100644 --- a/lib/build/recipe/emailpassword/components/features/signup/index.d.ts +++ b/lib/build/recipe/emailpassword/components/features/signup/index.d.ts @@ -1,10 +1,12 @@ import * as React from "react"; import type { Navigate, UserContext, PartialAuthComponentProps } from "../../../../../types"; +import type { AuthSuccessContext } from "../../../../authRecipe/types"; import type Recipe from "../../../recipe"; import type { SignUpThemeProps } from "../../../types"; import type { ComponentOverrideMap } from "../../../types"; export declare function useChildProps( recipe: Recipe, + onAuthSuccess: (successContext: AuthSuccessContext) => Promise, error: string | undefined, onError: (err: string) => void, clearError: () => void, diff --git a/lib/build/recipe/emailpassword/components/themes/translations.d.ts b/lib/build/recipe/emailpassword/components/themes/translations.d.ts index 144c2c176..ec431cb0f 100644 --- a/lib/build/recipe/emailpassword/components/themes/translations.d.ts +++ b/lib/build/recipe/emailpassword/components/themes/translations.d.ts @@ -74,6 +74,7 @@ export declare const defaultTranslationsEmailPassword: { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; diff --git a/lib/build/recipe/emailpassword/prebuiltui.d.ts b/lib/build/recipe/emailpassword/prebuiltui.d.ts index 1865fe165..dde794f58 100644 --- a/lib/build/recipe/emailpassword/prebuiltui.d.ts +++ b/lib/build/recipe/emailpassword/prebuiltui.d.ts @@ -84,6 +84,7 @@ export declare class EmailPasswordPreBuiltUI extends RecipeRouter { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; diff --git a/lib/build/recipe/emailpassword/recipe.d.ts b/lib/build/recipe/emailpassword/recipe.d.ts index a4c04ec3e..73be9e8f5 100644 --- a/lib/build/recipe/emailpassword/recipe.d.ts +++ b/lib/build/recipe/emailpassword/recipe.d.ts @@ -16,8 +16,8 @@ export default class EmailPassword extends AuthRecipe< > { readonly webJSRecipe: WebJSRecipeInterface; static instance?: EmailPassword; - static RECIPE_ID: string; - recipeID: string; + static RECIPE_ID: "emailpassword"; + recipeID: "emailpassword"; firstFactorIds: "emailpassword"[]; getFirstFactorsForAuthPage(): string[]; constructor( diff --git a/lib/build/recipe/emailverification/components/themes/translations.d.ts b/lib/build/recipe/emailverification/components/themes/translations.d.ts index a41cb0c89..357f1f004 100644 --- a/lib/build/recipe/emailverification/components/themes/translations.d.ts +++ b/lib/build/recipe/emailverification/components/themes/translations.d.ts @@ -19,6 +19,7 @@ export declare const defaultTranslationsEmailVerification: { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; diff --git a/lib/build/recipe/emailverification/prebuiltui.d.ts b/lib/build/recipe/emailverification/prebuiltui.d.ts index 5b548ded9..4ada857a7 100644 --- a/lib/build/recipe/emailverification/prebuiltui.d.ts +++ b/lib/build/recipe/emailverification/prebuiltui.d.ts @@ -29,6 +29,7 @@ export declare class EmailVerificationPreBuiltUI extends RecipeRouter { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; diff --git a/lib/build/recipe/multifactorauth/components/themes/translations.d.ts b/lib/build/recipe/multifactorauth/components/themes/translations.d.ts index d1a9adae9..b26ba3b86 100644 --- a/lib/build/recipe/multifactorauth/components/themes/translations.d.ts +++ b/lib/build/recipe/multifactorauth/components/themes/translations.d.ts @@ -13,6 +13,7 @@ export declare const defaultTranslationsMultiFactorAuth: { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; diff --git a/lib/build/recipe/multifactorauth/prebuiltui.d.ts b/lib/build/recipe/multifactorauth/prebuiltui.d.ts index fc22c808a..796cdfa3d 100644 --- a/lib/build/recipe/multifactorauth/prebuiltui.d.ts +++ b/lib/build/recipe/multifactorauth/prebuiltui.d.ts @@ -23,6 +23,7 @@ export declare class MultiFactorAuthPreBuiltUI extends RecipeRouter { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; diff --git a/lib/build/recipe/oauth2/componentOverrideContext.d.ts b/lib/build/recipe/oauth2/componentOverrideContext.d.ts deleted file mode 100644 index 288fc18e7..000000000 --- a/lib/build/recipe/oauth2/componentOverrideContext.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// -import type { ComponentOverrideMap } from "./types"; -declare const useContext: () => ComponentOverrideMap, - Provider: import("react").FC< - import("react").PropsWithChildren<{ - components: ComponentOverrideMap; - }> - >; -export { useContext as useRecipeComponentOverrideContext, Provider as RecipeComponentsOverrideContextProvider }; diff --git a/lib/build/recipe/oauth2/components/themes/resumePageSpinner/index.d.ts b/lib/build/recipe/oauth2/components/themes/resumePageSpinner/index.d.ts deleted file mode 100644 index f619535eb..000000000 --- a/lib/build/recipe/oauth2/components/themes/resumePageSpinner/index.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { NormalisedConfig } from "../../../types"; -export declare const ResumePageSpinner: (props: { - config: NormalisedConfig; -}) => import("react/jsx-runtime").JSX.Element; diff --git a/lib/build/recipe/oauth2/components/themes/themeBase.d.ts b/lib/build/recipe/oauth2/components/themes/themeBase.d.ts deleted file mode 100644 index f95129fbf..000000000 --- a/lib/build/recipe/oauth2/components/themes/themeBase.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import type { PropsWithChildren } from "react"; -export declare const ThemeBase: React.FC< - PropsWithChildren<{ - loadDefaultFont: boolean; - userStyles: Array; - }> ->; diff --git a/lib/build/recipe/oauth2/components/themes/translations.d.ts b/lib/build/recipe/oauth2/components/themes/translations.d.ts deleted file mode 100644 index fdc937dc1..000000000 --- a/lib/build/recipe/oauth2/components/themes/translations.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -export declare const defaultTranslationsOAuth2: { - en: { - AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; - AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; - AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; - AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; - AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; - AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; - AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_START: string; - AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_SIGN_IN_LINK: string; - AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_END: string; - AUTH_PAGE_FOOTER_START: string; - AUTH_PAGE_FOOTER_TOS: string; - AUTH_PAGE_FOOTER_AND: string; - AUTH_PAGE_FOOTER_PP: string; - AUTH_PAGE_FOOTER_END: string; - DIVIDER_OR: string; - BRANDING_POWERED_BY_START: string; - BRANDING_POWERED_BY_END: string; - SOMETHING_WENT_WRONG_ERROR: string; - SOMETHING_WENT_WRONG_ERROR_RELOAD: string; - }; -}; diff --git a/lib/build/recipe/oauth2/index.d.ts b/lib/build/recipe/oauth2/index.d.ts index f0696f114..6b398a579 100644 --- a/lib/build/recipe/oauth2/index.d.ts +++ b/lib/build/recipe/oauth2/index.d.ts @@ -1,18 +1,39 @@ -/// -import { UserInput } from "./types"; +import { UserInput, GetRedirectionURLContext, PreAPIHookContext, OnHandleEventContext } from "./types"; +import type { RecipeFunctionOptions, LoginInfo } from "supertokens-web-js/recipe/oauth2"; import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2"; export default class Wrapper { static init(config?: UserInput): import("../../types").RecipeInitResult; - static ComponentsOverrideProvider: import("react").FC< - import("react").PropsWithChildren<{ - components: import("./types").ComponentOverrideMap; - }> - >; + /** + * Returns information about an OAuth login in progress + * + * @param loginChallenge The login challenge from the url + * + * @param userContext (OPTIONAL) Refer to {@link https://supertokens.com/docs/emailpassword/advanced-customizations/user-context the documentation} + * + * @param options (OPTIONAL) Use this to configure additional properties (for example pre api hooks) + * + * @returns `{status: "OK", info: LoginInfo}` + * + * @throws STGeneralError if the API exposed by the backend SDKs returns `status: "GENERAL_ERROR"` + */ + static getLoginChallengeInfo(input: { + loginChallenge: string; + options?: RecipeFunctionOptions; + userContext?: any; + }): Promise<{ + status: "OK"; + info: LoginInfo; + fetchResponse: Response; + }>; } declare const init: typeof Wrapper.init; -declare const MultitenancyComponentsOverrideProvider: import("react").FC< - import("react").PropsWithChildren<{ - components: import("./types").ComponentOverrideMap; - }> ->; -export { init, UserInput, RecipeInterface, MultitenancyComponentsOverrideProvider }; +declare const getLoginChallengeInfo: typeof Wrapper.getLoginChallengeInfo; +export { + init, + getLoginChallengeInfo, + GetRedirectionURLContext, + PreAPIHookContext, + OnHandleEventContext, + UserInput, + RecipeInterface, +}; diff --git a/lib/build/recipe/oauth2/prebuiltui.d.ts b/lib/build/recipe/oauth2/prebuiltui.d.ts deleted file mode 100644 index 53239a833..000000000 --- a/lib/build/recipe/oauth2/prebuiltui.d.ts +++ /dev/null @@ -1,60 +0,0 @@ -/// -import { RecipeRouter } from "../recipeRouter"; -import { ResumePageSpinner } from "./components/themes/resumePageSpinner"; -import OAuth2 from "./recipe"; -import type { GenericComponentOverrideMap } from "../../components/componentOverride/componentOverrideContext"; -import type { RecipeFeatureComponentMap, FeatureBaseProps, UserContext } from "../../types"; -import type { AuthComponent } from "../../types"; -export declare class OAuth2PreBuiltUI extends RecipeRouter { - readonly recipeInstance: OAuth2; - static instance?: OAuth2PreBuiltUI; - languageTranslations: { - en: { - AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; - AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; - AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; - AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; - AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; - AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; - AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_START: string; - AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_SIGN_IN_LINK: string; - AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_END: string; - AUTH_PAGE_FOOTER_START: string; - AUTH_PAGE_FOOTER_TOS: string; - AUTH_PAGE_FOOTER_AND: string; - AUTH_PAGE_FOOTER_PP: string; - AUTH_PAGE_FOOTER_END: string; - DIVIDER_OR: string; - BRANDING_POWERED_BY_START: string; - BRANDING_POWERED_BY_END: string; - SOMETHING_WENT_WRONG_ERROR: string; - SOMETHING_WENT_WRONG_ERROR_RELOAD: string; - }; - }; - constructor(recipeInstance: OAuth2); - static getInstanceOrInitAndGetInstance(): OAuth2PreBuiltUI; - static getFeatures(useComponentOverrides?: () => GenericComponentOverrideMap): RecipeFeatureComponentMap; - static getFeatureComponent( - componentName: never, - props: FeatureBaseProps<{ - redirectOnSessionExists?: boolean; - userContext?: UserContext; - }>, - useComponentOverrides?: () => GenericComponentOverrideMap - ): JSX.Element; - getFeatures: (_useComponentOverrides?: () => GenericComponentOverrideMap) => RecipeFeatureComponentMap; - getFeatureComponent: ( - _componentName: never, - _props: FeatureBaseProps<{ - redirectOnSessionExists?: boolean; - userContext?: UserContext; - }>, - _useComponentOverrides?: () => GenericComponentOverrideMap - ) => JSX.Element; - getAuthComponents(): AuthComponent[]; - static reset(): void; - static ResumePageSpinnerTheme: (props: { - config: import("./types").NormalisedConfig; - }) => import("react/jsx-runtime").JSX.Element; -} -export { ResumePageSpinner as ResumePageSpinnerTheme }; diff --git a/lib/build/recipe/oauth2/recipe.d.ts b/lib/build/recipe/oauth2/recipe.d.ts index e8d1f1c8f..46a0a63e2 100644 --- a/lib/build/recipe/oauth2/recipe.d.ts +++ b/lib/build/recipe/oauth2/recipe.d.ts @@ -7,7 +7,12 @@ import type { PreAndPostAPIHookAction, UserInput, } from "./types"; -import type { RecipeInitResult, NormalisedConfigWithAppInfoAndRecipeID, WebJSRecipeInterface } from "../../types"; +import type { + RecipeInitResult, + NormalisedConfigWithAppInfoAndRecipeID, + WebJSRecipeInterface, + SuccessRedirectContextOAuth2, +} from "../../types"; export default class OAuth2 extends RecipeModule< GetRedirectionURLContext, PreAndPostAPIHookAction, @@ -16,13 +21,15 @@ export default class OAuth2 extends RecipeModule< > { readonly webJSRecipe: WebJSRecipeInterface; static instance?: OAuth2; - static readonly RECIPE_ID = "multitenancy"; - readonly recipeID = "multitenancy"; + static readonly RECIPE_ID = "oauth2"; + readonly recipeID = "oauth2"; constructor( config: NormalisedConfigWithAppInfoAndRecipeID, webJSRecipe?: WebJSRecipeInterface ); static init(config?: UserInput): RecipeInitResult; static getInstanceOrThrow(): OAuth2; + static getInstance(): OAuth2 | undefined; + getDefaultRedirectionURL(ctx: SuccessRedirectContextOAuth2): Promise; static reset(): void; } diff --git a/lib/build/recipe/oauth2/types.d.ts b/lib/build/recipe/oauth2/types.d.ts index ca4b29abc..abd42d1fa 100644 --- a/lib/build/recipe/oauth2/types.d.ts +++ b/lib/build/recipe/oauth2/types.d.ts @@ -1,12 +1,17 @@ -import type { ComponentOverride } from "../../components/componentOverride/componentOverride"; -import type { UserContext } from "../../types"; +import type { SuccessRedirectContextOAuth2, UserContext } from "../../types"; import type { UserInput as RecipeModuleUserInput, NormalisedConfig as NormalisedRecipeModuleConfig, } from "../recipeModule/types"; import type OverrideableBuilder from "supertokens-js-override"; import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2/types"; -export declare type PreAndPostAPIHookAction = never; +export declare type PreAndPostAPIHookAction = "GET_LOGIN_CHALLENGE_INFO"; +export declare type PreAPIHookContext = { + action: PreAndPostAPIHookAction; + requestInit: RequestInit; + url: string; + userContext: UserContext; +}; export declare type UserInput = { override?: { functions?: ( @@ -27,13 +32,5 @@ export declare type NormalisedConfig = NormalisedRecipeModuleConfig< ) => RecipeInterface; }; }; -export declare type ComponentOverrideMap = { - ResumePageSpinner: ComponentOverride; -}; -export declare type GetRedirectionURLContext = { - action: "RESUME"; -}; -export declare type OnHandleEventContext = { - action: "RESUMER"; - userContext: UserContext; -}; +export declare type GetRedirectionURLContext = SuccessRedirectContextOAuth2; +export declare type OnHandleEventContext = never; diff --git a/lib/build/recipe/passwordless/components/features/signInAndUp/index.d.ts b/lib/build/recipe/passwordless/components/features/signInAndUp/index.d.ts index ac9b8560b..c04406f69 100644 --- a/lib/build/recipe/passwordless/components/features/signInAndUp/index.d.ts +++ b/lib/build/recipe/passwordless/components/features/signInAndUp/index.d.ts @@ -1,11 +1,13 @@ import * as React from "react"; import type { Navigate, UserContext, PartialAuthComponentProps } from "../../../../../types"; +import type { AuthSuccessContext } from "../../../../authRecipe/types"; import type Recipe from "../../../recipe"; import type { ComponentOverrideMap } from "../../../types"; import type { SignInUpChildProps } from "../../../types"; export declare function useChildProps( recipe: Recipe, factorIds: string[], + onAuthSuccess: (successContext: AuthSuccessContext) => Promise, error: string | undefined, onError: (err: string) => void, clearError: () => void, diff --git a/lib/build/recipe/passwordless/components/features/signInAndUpEPCombo/index.d.ts b/lib/build/recipe/passwordless/components/features/signInAndUpEPCombo/index.d.ts index 4b6c409d5..ca36dd12e 100644 --- a/lib/build/recipe/passwordless/components/features/signInAndUpEPCombo/index.d.ts +++ b/lib/build/recipe/passwordless/components/features/signInAndUpEPCombo/index.d.ts @@ -1,11 +1,13 @@ import * as React from "react"; import type { Navigate, UserContext, PartialAuthComponentProps } from "../../../../../types"; +import type { AuthSuccessContext } from "../../../../authRecipe/types"; import type Recipe from "../../../recipe"; import type { ComponentOverrideMap } from "../../../types"; import type { SignInUpEPComboChildProps } from "../../../types"; export declare function useChildProps( recipe: Recipe, factorIds: string[], + onAuthSuccess: (successContext: AuthSuccessContext) => Promise, error: string | undefined, onError: (err: string) => void, clearError: () => void, diff --git a/lib/build/recipe/passwordless/components/features/userInputCode/index.d.ts b/lib/build/recipe/passwordless/components/features/userInputCode/index.d.ts index 969a82dd9..438527b9c 100644 --- a/lib/build/recipe/passwordless/components/features/userInputCode/index.d.ts +++ b/lib/build/recipe/passwordless/components/features/userInputCode/index.d.ts @@ -1,10 +1,12 @@ import * as React from "react"; import type { Navigate, UserContext, AuthComponentProps } from "../../../../../types"; +import type { AuthSuccessContext } from "../../../../authRecipe/types"; import type Recipe from "../../../recipe"; import type { ComponentOverrideMap, LoginAttemptInfo, SignInUpUserInputCodeFormProps } from "../../../types"; export declare function useChildProps( recipe: Recipe, loginAttemptInfo: LoginAttemptInfo, + onAuthSuccess: (successContext: AuthSuccessContext) => Promise, error: string | undefined, onError: (err: string) => void, clearError: () => void, diff --git a/lib/build/recipe/passwordless/components/themes/translations.d.ts b/lib/build/recipe/passwordless/components/themes/translations.d.ts index d60b40a2e..d1ddad9ec 100644 --- a/lib/build/recipe/passwordless/components/themes/translations.d.ts +++ b/lib/build/recipe/passwordless/components/themes/translations.d.ts @@ -58,6 +58,7 @@ export declare const defaultTranslationsPasswordless: { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; diff --git a/lib/build/recipe/passwordless/prebuiltui.d.ts b/lib/build/recipe/passwordless/prebuiltui.d.ts index 18238e194..10c96a0a5 100644 --- a/lib/build/recipe/passwordless/prebuiltui.d.ts +++ b/lib/build/recipe/passwordless/prebuiltui.d.ts @@ -69,6 +69,7 @@ export declare class PasswordlessPreBuiltUI extends RecipeRouter { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; diff --git a/lib/build/recipe/session/components/themes/translations.d.ts b/lib/build/recipe/session/components/themes/translations.d.ts index 40c73700a..ba13878f9 100644 --- a/lib/build/recipe/session/components/themes/translations.d.ts +++ b/lib/build/recipe/session/components/themes/translations.d.ts @@ -6,6 +6,7 @@ export declare const defaultTranslationsSession: { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; diff --git a/lib/build/recipe/session/prebuiltui.d.ts b/lib/build/recipe/session/prebuiltui.d.ts index fb829532d..85559c54b 100644 --- a/lib/build/recipe/session/prebuiltui.d.ts +++ b/lib/build/recipe/session/prebuiltui.d.ts @@ -16,6 +16,7 @@ export declare class SessionPreBuiltUI extends RecipeRouter { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; diff --git a/lib/build/recipe/session/recipe.d.ts b/lib/build/recipe/session/recipe.d.ts index 536d3cae5..1077959b6 100644 --- a/lib/build/recipe/session/recipe.d.ts +++ b/lib/build/recipe/session/recipe.d.ts @@ -7,7 +7,8 @@ import type { Navigate, NormalisedConfigWithAppInfoAndRecipeID, RecipeInitResult, - SuccessRedirectContext, + SuccessRedirectContextInApp, + SuccessRedirectContextOAuth2, UserContext, } from "../../types"; import type { ClaimValidationError, SessionClaimValidator } from "supertokens-web-js/recipe/session"; @@ -52,7 +53,7 @@ export default class Session extends RecipeModule void) => () => void; validateGlobalClaimsAndHandleSuccessRedirection: ( successRedirectContext: - | (Omit & { + | ((Omit | Omit) & { recipeId: string; }) | undefined, diff --git a/lib/build/recipe/thirdparty/components/features/signInAndUp/index.d.ts b/lib/build/recipe/thirdparty/components/features/signInAndUp/index.d.ts index 55967b373..554676d75 100644 --- a/lib/build/recipe/thirdparty/components/features/signInAndUp/index.d.ts +++ b/lib/build/recipe/thirdparty/components/features/signInAndUp/index.d.ts @@ -1,9 +1,11 @@ import * as React from "react"; import type { Navigate, PartialAuthComponentProps, UserContext } from "../../../../../types"; +import type { AuthSuccessContext } from "../../../../authRecipe/types"; import type Recipe from "../../../recipe"; import type { ComponentOverrideMap, SignInAndUpThemeProps } from "../../../types"; export declare function useChildProps( recipe: Recipe, + onAuthSuccess: (successContext: AuthSuccessContext) => Promise, error: string | undefined, onError: (err: string) => void, clearError: () => void, diff --git a/lib/build/recipe/thirdparty/components/themes/translations.d.ts b/lib/build/recipe/thirdparty/components/themes/translations.d.ts index f42500509..426312d4d 100644 --- a/lib/build/recipe/thirdparty/components/themes/translations.d.ts +++ b/lib/build/recipe/thirdparty/components/themes/translations.d.ts @@ -13,6 +13,7 @@ export declare const defaultTranslationsThirdParty: { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; diff --git a/lib/build/recipe/thirdparty/prebuiltui.d.ts b/lib/build/recipe/thirdparty/prebuiltui.d.ts index 0ae83b7e5..4c3899d89 100644 --- a/lib/build/recipe/thirdparty/prebuiltui.d.ts +++ b/lib/build/recipe/thirdparty/prebuiltui.d.ts @@ -23,6 +23,7 @@ export declare class ThirdPartyPreBuiltUI extends RecipeRouter { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; diff --git a/lib/build/recipe/thirdparty/types.d.ts b/lib/build/recipe/thirdparty/types.d.ts index 91531ef39..68867e1c1 100644 --- a/lib/build/recipe/thirdparty/types.d.ts +++ b/lib/build/recipe/thirdparty/types.d.ts @@ -81,4 +81,5 @@ export declare type StateObject = WebJsStateObject & { export declare type CustomStateProperties = { rid: string; redirectToPath: string; + oauth2LoginChallenge?: string; }; diff --git a/lib/build/recipe/totp/components/themes/translations.d.ts b/lib/build/recipe/totp/components/themes/translations.d.ts index 949499447..34fbb59e6 100644 --- a/lib/build/recipe/totp/components/themes/translations.d.ts +++ b/lib/build/recipe/totp/components/themes/translations.d.ts @@ -25,6 +25,7 @@ export declare const defaultTranslationsTOTP: { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; diff --git a/lib/build/recipe/totp/prebuiltui.d.ts b/lib/build/recipe/totp/prebuiltui.d.ts index 7799b5f0a..690aa7282 100644 --- a/lib/build/recipe/totp/prebuiltui.d.ts +++ b/lib/build/recipe/totp/prebuiltui.d.ts @@ -35,6 +35,7 @@ export declare class TOTPPreBuiltUI extends RecipeRouter { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; diff --git a/lib/build/recipeModule-shared.js b/lib/build/recipeModule-shared.js index 709d6a3fe..096e6ddb4 100644 --- a/lib/build/recipeModule-shared.js +++ b/lib/build/recipeModule-shared.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. * @@ -17,42 +17,33 @@ var genericComponentOverrideContext = require("./genericComponentOverrideContext * under the License. */ var RecipeModule = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(RecipeModule, _super); + superTokens.__extends(RecipeModule, _super); function RecipeModule() { var _this = (_super !== null && _super.apply(this, arguments)) || this; _this.redirect = function (context, navigate, queryParams, userContext) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var redirectUrl; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, - this.getRedirectUrl( - context, - genericComponentOverrideContext.getNormalisedUserContext(userContext) - ), + this.getRedirectUrl(context, superTokens.getNormalisedUserContext(userContext)), ]; case 1: redirectUrl = _a.sent(); if (redirectUrl === null) { - genericComponentOverrideContext.logDebugMessage( + superTokens.logDebugMessage( "Skipping redirection because the user override returned null for context ".concat( JSON.stringify(context, null, 2) ) ); return [2 /*return*/]; } - redirectUrl = genericComponentOverrideContext.appendQueryParamsToURL( - redirectUrl, - queryParams - ); + redirectUrl = superTokens.appendQueryParamsToURL(redirectUrl, queryParams); return [ 2 /*return*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToUrl( - redirectUrl, - navigate - ), + superTokens.SuperTokens.getInstanceOrThrow().redirectToUrl(redirectUrl, navigate), ]; } }); @@ -60,9 +51,9 @@ var RecipeModule = /** @class */ (function (_super) { }; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types _this.getRedirectUrl = function (context, userContext) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var redirectUrl; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.config.getRedirectionURL(context, userContext)]; @@ -83,13 +74,13 @@ var RecipeModule = /** @class */ (function (_super) { } // eslint-disable-next-line @typescript-eslint/no-unused-vars RecipeModule.prototype.getDefaultRedirectionURL = function (_, _userContext) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { throw new Error("getDefaultRedirectionURL is not implemented."); }); }); }; return RecipeModule; -})(genericComponentOverrideContext.BaseRecipeModule); +})(superTokens.BaseRecipeModule); exports.RecipeModule = RecipeModule; diff --git a/lib/build/session.js b/lib/build/session.js index ed2d033bb..8531109d0 100644 --- a/lib/build/session.js +++ b/lib/build/session.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var WebJSSessionRecipe = require("supertokens-web-js/recipe/session"); var componentOverrideContext = require("./session-shared.js"); var types = require("./multifactorauth-shared.js"); @@ -16,7 +16,10 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); +require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); +require("./oauth2-shared.js"); +require("supertokens-web-js/recipe/oauth2"); require("./recipeModule-shared.js"); require("./translationContext.js"); require("react-dom"); @@ -28,10 +31,10 @@ require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); var BooleanClaim = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(BooleanClaim, _super); + superTokens.__extends(BooleanClaim, _super); function BooleanClaim(config) { var _this = _super.call(this, config) || this; - var validatorsWithCallbacks = genericComponentOverrideContext.__assign({}, _this.validators); + var validatorsWithCallbacks = superTokens.__assign({}, _this.validators); var _loop_1 = function (key) { var validator = validatorsWithCallbacks[key]; validatorsWithCallbacks[key] = function () { @@ -39,13 +42,10 @@ var BooleanClaim = /** @class */ (function (_super) { for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, validator.apply(void 0, args)), - { - onFailureRedirection: config.onFailureRedirection, - showAccessDeniedOnFailure: config.showAccessDeniedOnFailure, - } - ); + return superTokens.__assign(superTokens.__assign({}, validator.apply(void 0, args)), { + onFailureRedirection: config.onFailureRedirection, + showAccessDeniedOnFailure: config.showAccessDeniedOnFailure, + }); }; }; for (var key in validatorsWithCallbacks) { @@ -58,10 +58,10 @@ var BooleanClaim = /** @class */ (function (_super) { })(WebJSSessionRecipe.BooleanClaim); var PrimitiveArrayClaim = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(PrimitiveArrayClaim, _super); + superTokens.__extends(PrimitiveArrayClaim, _super); function PrimitiveArrayClaim(config) { var _this = _super.call(this, config) || this; - var validatorsWithCallbacks = genericComponentOverrideContext.__assign({}, _this.validators); + var validatorsWithCallbacks = superTokens.__assign({}, _this.validators); var _loop_1 = function (key) { var validator = validatorsWithCallbacks[key]; validatorsWithCallbacks[key] = function () { @@ -69,13 +69,10 @@ var PrimitiveArrayClaim = /** @class */ (function (_super) { for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, validator.apply(void 0, args)), - { - onFailureRedirection: config.onFailureRedirection, - showAccessDeniedOnFailure: config.showAccessDeniedOnFailure, - } - ); + return superTokens.__assign(superTokens.__assign({}, validator.apply(void 0, args)), { + onFailureRedirection: config.onFailureRedirection, + showAccessDeniedOnFailure: config.showAccessDeniedOnFailure, + }); }; }; for (var key in validatorsWithCallbacks) { @@ -88,10 +85,10 @@ var PrimitiveArrayClaim = /** @class */ (function (_super) { })(WebJSSessionRecipe.PrimitiveArrayClaim); var PrimitiveClaim = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(PrimitiveClaim, _super); + superTokens.__extends(PrimitiveClaim, _super); function PrimitiveClaim(config) { var _this = _super.call(this, config) || this; - var validatorsWithCallbacks = genericComponentOverrideContext.__assign({}, _this.validators); + var validatorsWithCallbacks = superTokens.__assign({}, _this.validators); var _loop_1 = function (key) { var validator = validatorsWithCallbacks[key]; validatorsWithCallbacks[key] = function () { @@ -99,13 +96,10 @@ var PrimitiveClaim = /** @class */ (function (_super) { for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, validator.apply(void 0, args)), - { - onFailureRedirection: config.onFailureRedirection, - showAccessDeniedOnFailure: config.showAccessDeniedOnFailure, - } - ); + return superTokens.__assign(superTokens.__assign({}, validator.apply(void 0, args)), { + onFailureRedirection: config.onFailureRedirection, + showAccessDeniedOnFailure: config.showAccessDeniedOnFailure, + }); }; }; for (var key in validatorsWithCallbacks) { @@ -158,12 +152,12 @@ var SessionAPIWrapper = /** @class */ (function () { return types.Session.init(config); }; SessionAPIWrapper.getUserId = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, types.Session.getInstanceOrThrow().getUserId({ - userContext: genericComponentOverrideContext.getNormalisedUserContext( + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -172,12 +166,12 @@ var SessionAPIWrapper = /** @class */ (function () { }); }; SessionAPIWrapper.getAccessToken = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, types.Session.getInstanceOrThrow().getAccessToken({ - userContext: genericComponentOverrideContext.getNormalisedUserContext( + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -186,12 +180,12 @@ var SessionAPIWrapper = /** @class */ (function () { }); }; SessionAPIWrapper.getAccessTokenPayloadSecurely = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, types.Session.getInstanceOrThrow().getAccessTokenPayloadSecurely({ - userContext: genericComponentOverrideContext.getNormalisedUserContext( + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -200,19 +194,19 @@ var SessionAPIWrapper = /** @class */ (function () { }); }; SessionAPIWrapper.attemptRefreshingSession = function () { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [2 /*return*/, types.Session.getInstanceOrThrow().attemptRefreshingSession()]; }); }); }; SessionAPIWrapper.doesSessionExist = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, types.Session.getInstanceOrThrow().doesSessionExist({ - userContext: genericComponentOverrideContext.getNormalisedUserContext( + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -224,18 +218,15 @@ var SessionAPIWrapper = /** @class */ (function () { * @deprecated */ SessionAPIWrapper.addAxiosInterceptors = function (axiosInstance, userContext) { - return types.Session.addAxiosInterceptors( - axiosInstance, - genericComponentOverrideContext.getNormalisedUserContext(userContext) - ); + return types.Session.addAxiosInterceptors(axiosInstance, superTokens.getNormalisedUserContext(userContext)); }; SessionAPIWrapper.signOut = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, types.Session.getInstanceOrThrow().signOut({ - userContext: genericComponentOverrideContext.getNormalisedUserContext( + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -247,7 +238,7 @@ var SessionAPIWrapper = /** @class */ (function () { return types.Session.getInstanceOrThrow().validateClaims({ overrideGlobalClaimValidators: input === null || input === void 0 ? void 0 : input.overrideGlobalClaimValidators, - userContext: genericComponentOverrideContext.getNormalisedUserContext( + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }); @@ -258,7 +249,7 @@ var SessionAPIWrapper = /** @class */ (function () { SessionAPIWrapper.getClaimValue = function (input) { return types.Session.getInstanceOrThrow().getClaimValue({ claim: input.claim, - userContext: genericComponentOverrideContext.getNormalisedUserContext( + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }); diff --git a/lib/build/sessionprebuiltui.js b/lib/build/sessionprebuiltui.js index 2b8426957..d17922280 100644 --- a/lib/build/sessionprebuiltui.js +++ b/lib/build/sessionprebuiltui.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var jsxRuntime = require("react/jsx-runtime"); var uiEntry = require("./index2.js"); var componentOverrideContext = require("./session-shared.js"); @@ -18,10 +18,13 @@ require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); require("react-dom"); require("./multitenancy-shared.js"); +require("./genericComponentOverrideContext.js"); require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); +require("./oauth2-shared.js"); +require("supertokens-web-js/recipe/oauth2"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); require("supertokens-web-js/recipe/session"); @@ -29,7 +32,7 @@ require("supertokens-web-js/recipe/session"); function ErrorRoundIcon() { return jsxRuntime.jsxs( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { width: "32", height: "32", viewBox: "0 0 32 32", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [ @@ -55,7 +58,7 @@ function BackButton(_a) { var t = translationContext.useTranslation(); return jsxRuntime.jsx( "button", - genericComponentOverrideContext.__assign( + superTokens.__assign( { onClick: onClick, "data-supertokens": "buttonBase backButton" }, { children: t("GO_BACK") } ) @@ -70,7 +73,7 @@ function LogoutButton(_a) { var t = translationContext.useTranslation(); return jsxRuntime.jsxs( "button", - genericComponentOverrideContext.__assign( + superTokens.__assign( { onClick: onClick, "data-supertokens": "buttonBase logoutButton" }, { children: [ @@ -107,8 +110,8 @@ var AccessDeniedScreen$2 = function (props) { var userContext = uiEntry.useUserContext(); var t = translationContext.useTranslation(); var onLogout = function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, props.recipe.signOut({ userContext: userContext })]; @@ -116,7 +119,7 @@ var AccessDeniedScreen$2 = function (props) { _a.sent(); return [ 4 /*yield*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ + superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ show: "signin", redirectBack: false, userContext: userContext, @@ -145,24 +148,24 @@ var AccessDeniedScreen$2 = function (props) { }; return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "center accessDenied" }, { children: jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: [ jsxRuntime.jsx(ErrorRoundIcon, {}), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle" }, { children: t("ACCESS_DENIED") } ) @@ -171,14 +174,14 @@ var AccessDeniedScreen$2 = function (props) { props.error && jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "primaryText accessDeniedError" }, { children: [" ", props.error] } ) ), jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "buttonsGroup" }, { children: [ @@ -203,30 +206,26 @@ var AccessDeniedScreen$2 = function (props) { }; var AccessDeniedThemeWithOverride = uiEntry.withOverride("SessionAccessDenied", AccessDeniedScreen$2); var AccessDeniedScreenTheme = function (props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); return jsxRuntime.jsx( ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, props.config.accessDeniedScreen.style], }, - { - children: jsxRuntime.jsx( - AccessDeniedThemeWithOverride, - genericComponentOverrideContext.__assign({}, props) - ), - } + { children: jsxRuntime.jsx(AccessDeniedThemeWithOverride, superTokens.__assign({}, props)) } ) ); }; var defaultTranslationsSession = { - en: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, uiEntry.defaultTranslationsCommon.en), - { ACCESS_DENIED: "Access denied", GO_BACK: "Go back", LOGOUT: "Log out" } - ), + en: superTokens.__assign(superTokens.__assign({}, uiEntry.defaultTranslationsCommon.en), { + ACCESS_DENIED: "Access denied", + GO_BACK: "Go back", + LOGOUT: "Log out", + }), }; var AccessDeniedScreen$1 = function (props) { @@ -240,18 +239,18 @@ var AccessDeniedScreen$1 = function (props) { : _b.useHistoryCustom(); return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { defaultStore: defaultTranslationsSession, useShadowDom: (_c = props.useShadowDom) !== null && _c !== void 0 ? _c - : genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, + : superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, }, { children: jsxRuntime.jsx(AccessDeniedScreenTheme, { @@ -269,7 +268,7 @@ var AccessDeniedScreen$1 = function (props) { }; var SessionPreBuiltUI = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(SessionPreBuiltUI, _super); + superTokens.__extends(SessionPreBuiltUI, _super); function SessionPreBuiltUI(recipeInstance) { var _this = _super.call(this) || this; _this.recipeInstance = recipeInstance; @@ -288,7 +287,7 @@ var SessionPreBuiltUI = /** @class */ (function (_super) { if (componentName === "accessDenied") { return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx(AccessDeniedScreen$1, { @@ -334,7 +333,7 @@ var SessionPreBuiltUI = /** @class */ (function (_super) { }; // For tests SessionPreBuiltUI.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } SessionPreBuiltUI.instance = undefined; diff --git a/lib/build/superTokens.js b/lib/build/superTokens.js new file mode 100644 index 000000000..6f3e33976 --- /dev/null +++ b/lib/build/superTokens.js @@ -0,0 +1,1450 @@ +"use strict"; + +var SuperTokensWebJS = require("supertokens-web-js"); +var cookieHandler = require("supertokens-web-js/utils/cookieHandler"); +var postSuperTokensInitCallbacks = require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); +var windowHandler = require("supertokens-web-js/utils/windowHandler"); +var MultitenancyWebJS = require("supertokens-web-js/recipe/multitenancy"); +var utils = require("supertokens-web-js/utils"); +var React = require("react"); +var NormalisedURLDomain = require("supertokens-web-js/utils/normalisedURLDomain"); +var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); + +function _interopDefault(e) { + return e && e.__esModule ? e : { default: e }; +} + +var SuperTokensWebJS__default = /*#__PURE__*/ _interopDefault(SuperTokensWebJS); +var MultitenancyWebJS__default = /*#__PURE__*/ _interopDefault(MultitenancyWebJS); +var NormalisedURLDomain__default = /*#__PURE__*/ _interopDefault(NormalisedURLDomain); +var NormalisedURLPath__default = /*#__PURE__*/ _interopDefault(NormalisedURLPath); + +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise, SuppressedError, Symbol */ + +var extendStatics = function (d, b) { + extendStatics = + Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && + function (d, b) { + d.__proto__ = b; + }) || + function (d, b) { + for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; + }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); +} + +exports.__assign = function () { + exports.__assign = + Object.assign || + function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return exports.__assign.apply(this, arguments); +}; + +function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; + } + return t; +} + +function __awaiter(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function (resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +function __generator(thisArg, body) { + var _ = { + label: 0, + sent: function () { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === "function" && + (g[Symbol.iterator] = function () { + return this; + }), + g + ); + function verb(n) { + return function (v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while ((g && ((g = 0), op[0] && (_ = 0)), _)) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y["return"] + : op[0] + ? y["throw"] || ((t = y["return"]) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if (!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && (op[0] === 6 || op[0] === 2)) { + _ = 0; + continue; + } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) + for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +} + +typeof SuppressedError === "function" + ? SuppressedError + : function (error, suppressed, message) { + var e = new Error(message); + return (e.name = "SuppressedError"), (e.error = error), (e.suppressed = suppressed), e; + }; + +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +/* + * Consts. + */ +var RECIPE_ID_QUERY_PARAM = "rid"; +var DEFAULT_API_BASE_PATH = "/auth"; +var DEFAULT_WEBSITE_BASE_PATH = "/auth"; +var ST_ROOT_ID = "supertokens-root"; +var SSR_ERROR = + "\nIf you are trying to use this method doing server-side-rendering, please make sure you move this method inside a componentDidMount method or useEffect hook."; + +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +var package_version = "0.42.2"; + +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +var SUPERTOKENS_DEBUG_NAMESPACE = "com.supertokens.auth-react"; +var __debugLogsEnabled = false; +function enableLogging() { + __debugLogsEnabled = true; +} +function logDebugMessage(message) { + if (__debugLogsEnabled) { + // eslint-disable-next-line no-console + console.log( + "" + .concat(SUPERTOKENS_DEBUG_NAMESPACE, ' {t: "') + .concat(new Date().toISOString(), '", message: "') + .concat(message, '", supertokens-auth-react-ver: "') + .concat(package_version, '"}') + ); + } +} + +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +/* + * getRecipeIdFromPath + * Input: + * Output: The "rid" query param if present, null otherwise. + */ +function getRecipeIdFromSearch(search) { + var urlParams = new URLSearchParams(search); + return urlParams.get(RECIPE_ID_QUERY_PARAM); +} +function clearQueryParams(paramNames) { + var newURL = new URL(windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHref()); + for (var _i = 0, paramNames_1 = paramNames; _i < paramNames_1.length; _i++) { + var param = paramNames_1[_i]; + newURL.searchParams.delete(param); + } + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.replaceState( + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.getState(), + "", + newURL.toString() + ); +} +function updateQueryParam(name, value) { + var newURL = new URL(windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHref()); + newURL.searchParams.set(name, value); + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.replaceState( + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.getState(), + "", + newURL.toString() + ); +} +function clearErrorQueryParam() { + clearQueryParams(["error", "message"]); +} +function getQueryParams(param) { + var urlParams = new URLSearchParams( + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getSearch() + ); + return urlParams.get(param); +} +function getURLHash() { + // By default it is returined with the "#" at the beginning, we cut that off here. + return windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHash().substr(1); +} +function getRedirectToPathFromURL() { + var redirectToPath = getQueryParams("redirectToPath"); + if (redirectToPath === null) { + return undefined; + } else { + try { + var url = void 0; + try { + url = new URL(redirectToPath); + } catch (error) { + var fakeDomain = redirectToPath.startsWith("/") ? "http://localhost" : "http://localhost/"; + url = new URL("".concat(fakeDomain).concat(redirectToPath)); + } + // Prevent Open redirects by normalising path. + var normalisedURLPath = new NormalisedURLPath__default.default(redirectToPath).getAsStringDangerous(); + var pathQueryParams = url.search || ""; // url.search contains the leading ? + var pathHash = url.hash || ""; // url.hash contains the leading # + var pathWithQueryParamsAndHash = normalisedURLPath + pathQueryParams + pathHash; + // Ensure a leading "/" if `normalisedUrlPath` is empty but `pathWithQueryParamsAndHash` is not to ensure proper redirection. + // Example: "?test=1" will not redirect the user to `/?test=1` if we don't add a leading "/". + if ( + normalisedURLPath.length === 0 && + pathWithQueryParamsAndHash.length > 0 && + !pathWithQueryParamsAndHash.startsWith("/") + ) { + return "/" + pathWithQueryParamsAndHash; + } + return pathWithQueryParamsAndHash; + } catch (_a) { + return undefined; + } + } +} +/* + * isTest + */ +function isTest() { + try { + return process.env.TEST_MODE === "testing" || process.env.REACT_APP_TEST_MODE === "testing"; + } catch (err) { + // can get Uncaught ReferenceError: process is not defined error + return false; + } +} +function normaliseInputAppInfoOrThrowError(appInfo) { + if (appInfo === undefined) { + throw new Error("Please provide the appInfo object when calling supertokens.init"); + } + if (appInfo.apiDomain === undefined) { + throw new Error("Please provide your apiDomain inside the appInfo object when calling supertokens.init"); + } + if (appInfo.appName === undefined) { + throw new Error("Please provide your appName inside the appInfo object when calling supertokens.init"); + } + if (appInfo.websiteDomain === undefined) { + throw new Error("Please provide your websiteDomain inside the appInfo object when calling supertokens.init"); + } + var apiGatewayPath = new NormalisedURLPath__default.default(""); + if (appInfo.apiGatewayPath !== undefined) { + apiGatewayPath = new NormalisedURLPath__default.default(appInfo.apiGatewayPath); + } + return { + appName: appInfo.appName, + apiDomain: new NormalisedURLDomain__default.default(appInfo.apiDomain), + websiteDomain: new NormalisedURLDomain__default.default(appInfo.websiteDomain), + apiBasePath: apiGatewayPath.appendPath( + getNormalisedURLPathOrDefault(DEFAULT_API_BASE_PATH, appInfo.apiBasePath) + ), + websiteBasePath: getNormalisedURLPathOrDefault(DEFAULT_WEBSITE_BASE_PATH, appInfo.websiteBasePath), + }; +} +function getNormalisedURLPathOrDefault(defaultPath, path) { + if (path !== undefined) { + return new NormalisedURLPath__default.default(path); + } else { + return new NormalisedURLPath__default.default(defaultPath); + } +} +/* + * validateForm + */ +// We check that the number of fields in input and config form field is the same. +// We check that each item in the config form field is also present in the input form field +function validateForm(inputs, configFormFields) { + return __awaiter(this, void 0, void 0, function () { + var validationErrors, _loop_1, i; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + validationErrors = []; + if (configFormFields.length !== inputs.length) { + throw Error("Are you sending too many / too few formFields?"); + } + _loop_1 = function (i) { + var field, input, value, error; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + field = configFormFields[i]; + input = inputs.find(function (i) { + return i.id === field.id; + }); + value = input.value; + if (input.id === "email") { + value = value.trim(); + } + return [4 /*yield*/, field.validate(value)]; + case 1: + error = _b.sent(); + // If error, add it. + if (error !== undefined) { + validationErrors.push({ + error: error, + id: field.id, + }); + } + return [2 /*return*/]; + } + }); + }; + i = 0; + _a.label = 1; + case 1: + if (!(i < configFormFields.length)) return [3 /*break*/, 4]; + return [5 /*yield**/, _loop_1(i)]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + i++; + return [3 /*break*/, 1]; + case 4: + return [2 /*return*/, validationErrors]; + } + }); + }); +} +/* + * getCurrentNormalisedUrlPath + */ +function getCurrentNormalisedUrlPath() { + return new NormalisedURLPath__default.default( + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getPathName() + ); +} +function getCurrentNormalisedUrlPathWithQueryParamsAndFragments() { + var normalisedUrlPath = getCurrentNormalisedUrlPath().getAsStringDangerous(); + return ( + normalisedUrlPath + + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getSearch() + + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHash() + ); +} +function appendQueryParamsToURL(stringUrl, queryParams) { + if (queryParams === undefined) { + return stringUrl; + } + try { + var url_1 = new URL(stringUrl); + Object.entries(queryParams).forEach(function (_a) { + var key = _a[0], + value = _a[1]; + url_1.searchParams.set(key, value); + }); + return url_1.href; + } catch (e) { + var fakeDomain = stringUrl.startsWith("/") ? "http://localhost" : "http://localhost/"; + var url_2 = new URL("".concat(fakeDomain).concat(stringUrl)); + Object.entries(queryParams).forEach(function (_a) { + var key = _a[0], + value = _a[1]; + url_2.searchParams.set(key, value); + }); + return "".concat(url_2.pathname).concat(url_2.search).concat(url_2.hash); + } +} +function appendTrailingSlashToURL(stringUrl) { + return stringUrl.endsWith("/") ? stringUrl : stringUrl + "/"; +} +/* + * Default method for matching recipe route based on query params. + */ +function matchRecipeIdUsingQueryParams(recipeId) { + return function () { + var recipeIdFromSearch = getRecipeIdFromSearch( + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getSearch() + ); + return recipeIdFromSearch === recipeId; + }; +} +function redirectWithFullPageReload(to) { + if (to.trim() === "") { + to = "/"; + } + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.setHref(to); +} +function redirectWithNavigate(to, navigate) { + if (to.trim() === "") { + to = "/"; + } + if ("push" in navigate) { + // we are using react-router-dom that is before v6 + navigate.push(to); + } else { + // in react-router-dom v6, it is just navigate(to) + navigate(to); + } +} +function getOriginOfPage() { + return new NormalisedURLDomain__default.default( + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getOrigin() + ); +} +function getLocalStorage(key) { + return __awaiter(this, void 0, void 0, function () { + var res; + return __generator(this, function (_a) { + res = windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.localStorage.getItem(key); + if (res === null || res === undefined) { + return [2 /*return*/, null]; + } + return [2 /*return*/, res]; + }); + }); +} +function setLocalStorage(key, value) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + return [ + 4 /*yield*/, + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.localStorage.setItem( + key, + value + ), + ]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); +} +function removeFromLocalStorage(key) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + return [ + 4 /*yield*/, + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.localStorage.removeItem( + key + ), + ]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); +} +function mergeObjects(obj1, obj2) { + var res = exports.__assign({}, obj1); + for (var key in obj2) { + if (typeof res[key] === "object" && typeof obj2[key] === "object") { + res[key] = mergeObjects(res[key], obj2[key]); + } else { + res[key] = obj2[key]; + } + } + return res; +} +function normaliseCookieScopeOrThrowError(cookieScope) { + function helper(cookieScope) { + cookieScope = cookieScope.trim().toLowerCase(); + // first we convert it to a URL so that we can use the URL class + if (cookieScope.startsWith(".")) { + cookieScope = cookieScope.substr(1); + } + if (!cookieScope.startsWith("http://") && !cookieScope.startsWith("https://")) { + cookieScope = "http://" + cookieScope; + } + try { + var urlObj = new URL(cookieScope); + cookieScope = urlObj.hostname; + // remove leading dot + if (cookieScope.startsWith(".")) { + cookieScope = cookieScope.substr(1); + } + return cookieScope; + } catch (err) { + throw new Error("Please provide a valid cookie scope"); + } + } + function isAnIpAddress(ipaddress) { + return /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test( + ipaddress + ); + } + var noDotNormalised = helper(cookieScope); + if (noDotNormalised === "localhost" || isAnIpAddress(noDotNormalised)) { + return noDotNormalised; + } + if (cookieScope.startsWith(".")) { + return "." + noDotNormalised; + } + return noDotNormalised; +} +function getDefaultCookieScope() { + try { + return normaliseCookieScopeOrThrowError( + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHostName() + ); + } catch (_a) { + return undefined; + } +} +function getCookieValue(name) { + return __awaiter(this, void 0, void 0, function () { + var value, _a, parts, last, temp; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _a = "; "; + return [ + 4 /*yield*/, + cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.getCookie(), + ]; + case 1: + value = _a + _b.sent(); + parts = value.split("; " + name + "="); + if (parts.length >= 2) { + last = parts.pop(); + if (last !== undefined) { + temp = last.split(";").shift(); + if (temp === undefined) { + return [2 /*return*/, null]; + } + return [2 /*return*/, temp]; + } + } + return [2 /*return*/, null]; + } + }); + }); +} +// undefined value will remove the cookie +function setFrontendCookie(name, value, scope) { + return __awaiter(this, void 0, void 0, function () { + var expires, cookieVal; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + expires = "Thu, 01 Jan 1970 00:00:01 GMT"; + cookieVal = ""; + if (value !== undefined) { + cookieVal = value; + expires = undefined; // set cookie without expiry + } + if ( + !( + scope === "localhost" || + scope === + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHostName() || + scope === undefined + ) + ) + return [3 /*break*/, 5]; + if (!(expires !== undefined)) return [3 /*break*/, 2]; + return [ + 4 /*yield*/, + cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( + "".concat(name, "=").concat(cookieVal, ";expires=").concat(expires, ";path=/;samesite=lax") + ), + ]; + case 1: + _a.sent(); + return [3 /*break*/, 4]; + case 2: + return [ + 4 /*yield*/, + cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( + "" + .concat(name, "=") + .concat(cookieVal, ";expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/;samesite=lax") + ), + ]; + case 3: + _a.sent(); + _a.label = 4; + case 4: + return [3 /*break*/, 9]; + case 5: + if (!(expires !== undefined)) return [3 /*break*/, 7]; + return [ + 4 /*yield*/, + cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( + "" + .concat(name, "=") + .concat(cookieVal, ";expires=") + .concat(expires, ";domain=") + .concat(scope, ";path=/;samesite=lax") + ), + ]; + case 6: + _a.sent(); + return [3 /*break*/, 9]; + case 7: + return [ + 4 /*yield*/, + cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( + "" + .concat(name, "=") + .concat(cookieVal, ";domain=") + .concat(scope, ";expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/;samesite=lax") + ), + ]; + case 8: + _a.sent(); + _a.label = 9; + case 9: + return [2 /*return*/]; + } + }); + }); +} +function getNormalisedUserContext(userContext) { + return userContext === undefined ? {} : userContext; +} +/** + * This function handles calling APIs that should only be called once during mount (mostly on mount of a route/feature component). + * It's split into multiple callbacks (fetch + handleResponse/handleError) because we expect fetch to take longer and + * and the component may be unmounted during the first fetch, in which case we want to avoid updating state/redirecting. + * This is especially relevant for development in strict mode with React 18 (and in the future for concurrent rendering). + * + * @param fetch This is a callback that is only called once on mount. Mostly it's for consuming tokens/doing one time only API calls + * @param handleResponse This is called with the result of the first (fetch) call if it succeeds. + * @param handleError This is called with the error of the first (fetch) call if it rejects. + * @param startLoading Will start the whole process if this is set to true (or omitted). Mostly used to wait for session loading. + */ +var useOnMountAPICall = function (fetch, handleResponse, handleError, startLoading) { + if (startLoading === void 0) { + startLoading = true; + } + var consumeReq = React.useRef(); + var _a = React.useState(undefined), + error = _a[0], + setError = _a[1]; + React.useEffect( + function () { + var effect = function (signal) { + return __awaiter(void 0, void 0, void 0, function () { + var resp, err_1, err_2; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + _a.trys.push([0, 2, , 9]); + if (consumeReq.current === undefined) { + consumeReq.current = fetch(); + } + return [4 /*yield*/, consumeReq.current]; + case 1: + resp = _a.sent(); + if (!signal.aborted) { + void handleResponse(resp); + } + return [3 /*break*/, 9]; + case 2: + err_1 = _a.sent(); + if (!!signal.aborted) return [3 /*break*/, 8]; + if (!(handleError !== undefined)) return [3 /*break*/, 7]; + _a.label = 3; + case 3: + _a.trys.push([3, 5, , 6]); + return [4 /*yield*/, handleError(err_1, resp)]; + case 4: + _a.sent(); + return [3 /*break*/, 6]; + case 5: + err_2 = _a.sent(); + setError(err_2); + return [3 /*break*/, 6]; + case 6: + return [3 /*break*/, 8]; + case 7: + setError(err_1); + _a.label = 8; + case 8: + return [3 /*break*/, 9]; + case 9: + return [2 /*return*/]; + } + }); + }); + }; + if (startLoading) { + var ctrl_1 = new AbortController(); + void effect(ctrl_1.signal); + return function () { + ctrl_1.abort(); + }; + } + return; + }, + [setError, consumeReq, fetch, handleResponse, handleError, startLoading] + ); + if (error) { + throw error; + } +}; +function useRethrowInRender() { + var _a = React.useState(undefined), + error = _a[0], + setError = _a[1]; + if (error) { + throw error; + } + return setError; +} + +var BaseRecipeModule = /** @class */ (function () { + /* + * Constructor. + */ + function BaseRecipeModule(config) { + this.config = config; + } + return BaseRecipeModule; +})(); + +function normaliseRecipeModuleConfig(config) { + var _this = this; + if (config === undefined) { + config = {}; + } + var onHandleEvent = config.onHandleEvent, + getRedirectionURL = config.getRedirectionURL, + preAPIHook = config.preAPIHook, + postAPIHook = config.postAPIHook; + if (onHandleEvent === undefined) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function + onHandleEvent = function (_) {}; + } + if (getRedirectionURL === undefined) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getRedirectionURL = function (_) { + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/, undefined]; + }); + }); + }; + } + if (preAPIHook === undefined) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + preAPIHook = function (context) { + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/, context]; + }); + }); + }; + } + if (postAPIHook === undefined) { + // eslint-disable-next-line @typescript-eslint/no-empty-function + postAPIHook = function () { + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/]; + }); + }); + }; + } + var rootStyle = config.style === undefined ? "" : config.style; + return exports.__assign(exports.__assign({}, config), { + getRedirectionURL: getRedirectionURL, + onHandleEvent: onHandleEvent, + preAPIHook: preAPIHook, + postAPIHook: postAPIHook, + recipeRootStyle: rootStyle, + }); +} + +function normaliseMultitenancyConfig(config) { + return exports.__assign(exports.__assign({}, normaliseRecipeModuleConfig(config)), { + override: exports.__assign( + { + functions: function (originalImplementation) { + return originalImplementation; + }, + }, + config === null || config === void 0 ? void 0 : config.override + ), + }); +} +function hasIntersectingRecipes(tenantMethods, recipeList) { + return tenantMethods.firstFactors.some(function (factorId) { + return recipeList.some(function (r) { + return r.firstFactorIds.includes(factorId); + }); + }); +} + +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +/* + * Class. + */ +var Multitenancy = /** @class */ (function (_super) { + __extends(Multitenancy, _super); + function Multitenancy(config, webJSRecipe) { + if (webJSRecipe === void 0) { + webJSRecipe = MultitenancyWebJS__default.default; + } + var _this = _super.call(this, config) || this; + _this.webJSRecipe = webJSRecipe; + _this.recipeID = Multitenancy.RECIPE_ID; + _this.dynamicLoginMethodsCache = {}; + return _this; + } + Multitenancy.prototype.getCurrentDynamicLoginMethods = function (input) { + var _a; + return __awaiter(this, void 0, void 0, function () { + var userContext, tenantId, tenantMethods; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (SuperTokens.usesDynamicLoginMethods === false) { + return [2 /*return*/, undefined]; + } + userContext = utils.getNormalisedUserContext(input.userContext); + return [4 /*yield*/, Multitenancy.getInstanceOrThrow().webJSRecipe.getTenantId()]; + case 1: + tenantId = (_a = _b.sent()) !== null && _a !== void 0 ? _a : "public"; + if (this.dynamicLoginMethodsCache[tenantId] === undefined) { + this.dynamicLoginMethodsCache[tenantId] = Multitenancy.getDynamicLoginMethods({ + tenantId: tenantId, + userContext: userContext, + }); + } + return [4 /*yield*/, this.dynamicLoginMethodsCache[tenantId]]; + case 2: + tenantMethods = _b.sent(); + if ( + !hasIntersectingRecipes( + tenantMethods, + SuperTokens.getInstanceOrThrow().recipeList.filter(function (recipe) { + return "firstFactorIds" in recipe; + }) + ) + ) { + throw new Error( + "Initialized recipes have no overlap with core recipes or could not load login methods" + ); + } + return [2 /*return*/, tenantMethods]; + } + }); + }); + }; + Multitenancy.getDynamicLoginMethods = function (input) { + return __awaiter(this, void 0, void 0, function () { + var _a, thirdParty, firstFactors; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + return [4 /*yield*/, MultitenancyWebJS__default.default.getLoginMethods(input)]; + case 1: + (_a = _b.sent()), (thirdParty = _a.thirdParty), (firstFactors = _a.firstFactors); + return [ + 2 /*return*/, + { + thirdparty: thirdParty, + firstFactors: firstFactors, + }, + ]; + } + }); + }); + }; + Multitenancy.init = function (config) { + var normalisedConfig = normaliseMultitenancyConfig(config); + return { + recipeID: Multitenancy.RECIPE_ID, + authReact: function (appInfo) { + Multitenancy.instance = new Multitenancy( + exports.__assign(exports.__assign({}, normalisedConfig), { + appInfo: appInfo, + recipeId: Multitenancy.RECIPE_ID, + }) + ); + return Multitenancy.instance; + }, + webJS: MultitenancyWebJS__default.default.init(exports.__assign({}, normalisedConfig)), + }; + }; + Multitenancy.getInstanceOrThrow = function () { + if (Multitenancy.instance === undefined) { + var error = + "No instance of Multitenancy found. Make sure to call the Multitenancy.init method." + + "See https://supertokens.io/docs/multitenancy/quick-setup/frontend"; + // eslint-disable-next-line supertokens-auth-react/no-direct-window-object + if (typeof window === "undefined") { + error = error + SSR_ERROR; + } + throw Error(error); + } + return Multitenancy.instance; + }; + /* + * Tests methods. + */ + Multitenancy.reset = function () { + if (!isTest()) { + return; + } + Multitenancy.instance = undefined; + return; + }; + Multitenancy.RECIPE_ID = "multitenancy"; + return Multitenancy; +})(BaseRecipeModule); + +var TranslationController = /** @class */ (function () { + function TranslationController() { + this.handlers = new Map(); + } + TranslationController.prototype.emit = function (event, detail) { + var handlerList = this.handlers.get(event) || []; + for (var _i = 0, handlerList_1 = handlerList; _i < handlerList_1.length; _i++) { + var h = handlerList_1[_i]; + h(event, detail); + } + }; + TranslationController.prototype.on = function (event, handler) { + var handlerList = this.handlers.get(event) || []; + this.handlers.set(event, handlerList.concat(handler)); + }; + TranslationController.prototype.off = function (event, handler) { + var handlerList = this.handlers.get(event) || []; + this.handlers.set( + event, + handlerList.filter(function (h) { + return h !== handler; + }) + ); + }; + return TranslationController; +})(); +var CURRENT_LANGUAGE_COOKIE_NAME = "sCurrLanguage"; +function saveCurrentLanguage(language, cookieDomain) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _b.trys.push([0, 2, , 3]); + return [4 /*yield*/, setFrontendCookie(CURRENT_LANGUAGE_COOKIE_NAME, language, cookieDomain)]; + case 1: + _b.sent(); + return [3 /*break*/, 3]; + case 2: + _b.sent(); + return [3 /*break*/, 3]; + case 3: + return [2 /*return*/]; + } + }); + }); +} +function getCurrentLanguageFromCookie() { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _b.trys.push([0, 2, , 3]); + return [4 /*yield*/, getCookieValue(CURRENT_LANGUAGE_COOKIE_NAME)]; + case 1: + return [2 /*return*/, _b.sent()]; + case 2: + _b.sent(); + // This can throw if we are not in a browser + // Since this is just loading a preference we can safely ignore the exception + return [2 /*return*/, null]; + case 3: + return [2 /*return*/]; + } + }); + }); +} + +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +/* + * Class. + */ +var SuperTokens = /** @class */ (function () { + /* + * Constructor. + */ + function SuperTokens(config) { + var _this = this; + var _a, _b, _c, _d; + this.recipeList = []; + this.changeLanguage = function (lang) { + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + return [ + 4 /*yield*/, + saveCurrentLanguage(lang, this.languageTranslations.currentLanguageCookieScope), + ]; + case 1: + _a.sent(); + this.languageTranslations.translationEventSource.emit("LanguageChange", lang); + return [2 /*return*/]; + } + }); + }); + }; + this.redirectToAuth = function (options) { + return __awaiter(_this, void 0, void 0, function () { + var queryParams, redirectUrl; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + queryParams = options.queryParams === undefined ? {} : options.queryParams; + if (options.show !== undefined) { + queryParams.show = options.show; + } + if (options.redirectBack === true) { + queryParams.redirectToPath = getCurrentNormalisedUrlPathWithQueryParamsAndFragments(); + } + return [ + 4 /*yield*/, + this.getRedirectUrl( + { + action: "TO_AUTH", + showSignIn: options.show === "signin", + }, + options.userContext + ), + ]; + case 1: + redirectUrl = _a.sent(); + if (redirectUrl === null) { + logDebugMessage("Skipping redirection because the user override returned null"); + return [2 /*return*/]; + } + redirectUrl = appendQueryParamsToURL(redirectUrl, queryParams); + return [2 /*return*/, this.redirectToUrl(redirectUrl, options.navigate)]; + } + }); + }); + }; + this.redirectToUrl = function (redirectUrl, navigate) { + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + doRedirection(this.appInfo, redirectUrl, navigate); + return [2 /*return*/]; + }); + }); + }; + this.redirect = function (context, navigate, queryParams, userContext) { + return __awaiter(_this, void 0, void 0, function () { + var redirectUrl; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + return [4 /*yield*/, this.getRedirectUrl(context, getNormalisedUserContext(userContext))]; + case 1: + redirectUrl = _a.sent(); + if (redirectUrl === null) { + logDebugMessage( + "Skipping redirection because the user override returned null for context ".concat( + JSON.stringify(context, null, 2) + ) + ); + return [2 /*return*/]; + } + redirectUrl = appendQueryParamsToURL(redirectUrl, queryParams); + return [ + 2 /*return*/, + SuperTokens.getInstanceOrThrow().redirectToUrl(redirectUrl, navigate), + ]; + } + }); + }); + }; + this.appInfo = normaliseInputAppInfoOrThrowError(config.appInfo); + if (config.recipeList === undefined || config.recipeList.length === 0) { + throw new Error( + "Please provide at least one recipe to the supertokens.init function call. See https://supertokens.io/docs/emailpassword/quick-setup/frontend" + ); + } + var translationConfig = config.languageTranslations === undefined ? {} : config.languageTranslations; + this.languageTranslations = { + defaultLanguage: translationConfig.defaultLanguage === undefined ? "en" : translationConfig.defaultLanguage, + currentLanguageCookieScope: + translationConfig.currentLanguageCookieScope !== undefined + ? normaliseCookieScopeOrThrowError(translationConfig.currentLanguageCookieScope) + : getDefaultCookieScope(), + userTranslationStore: translationConfig.translations !== undefined ? translationConfig.translations : {}, + translationEventSource: new TranslationController(), + userTranslationFunc: translationConfig.translationFunc, + }; + var enableDebugLogs = Boolean(config === null || config === void 0 ? void 0 : config.enableDebugLogs); + if (enableDebugLogs) { + enableLogging(); + } + this.userGetRedirectionURL = config.getRedirectionURL; + this.recipeList = config.recipeList.map(function (_a) { + var authReact = _a.authReact; + return authReact(_this.appInfo, enableDebugLogs); + }); + this.rootStyle = (_a = config.style) !== null && _a !== void 0 ? _a : ""; + this.privacyPolicyLink = config.privacyPolicyLink; + this.termsOfServiceLink = config.termsOfServiceLink; + this.useShadowDom = (_b = config.useShadowDom) !== null && _b !== void 0 ? _b : true; + this.defaultToSignUp = (_c = config.defaultToSignUp) !== null && _c !== void 0 ? _c : false; + this.disableAuthRoute = (_d = config.disableAuthRoute) !== null && _d !== void 0 ? _d : false; + } + /* + * Static Methods. + */ + SuperTokens.init = function (config) { + var _a; + cookieHandler.CookieHandlerReference.init(config.cookieHandler); + windowHandler.WindowHandlerReference.init(config.windowHandler); + if (SuperTokens.instance !== undefined) { + console.warn("SuperTokens was already initialized"); + return; + } + SuperTokens.usesDynamicLoginMethods = + (_a = config.usesDynamicLoginMethods) !== null && _a !== void 0 ? _a : false; + var recipes = + config.recipeList.find(function (recipe) { + return recipe.recipeID === Multitenancy.RECIPE_ID; + }) !== undefined + ? config.recipeList + : config.recipeList.concat(Multitenancy.init({})); + SuperTokensWebJS__default.default.init( + exports.__assign(exports.__assign({}, config), { + recipeList: recipes.map(function (_a) { + var webJS = _a.webJS; + return webJS; + }), + }) + ); + SuperTokens.instance = new SuperTokens(exports.__assign(exports.__assign({}, config), { recipeList: recipes })); + postSuperTokensInitCallbacks.PostSuperTokensInitCallbacks.runPostInitCallbacks(); + }; + SuperTokens.getInstanceOrThrow = function () { + if (SuperTokens.instance === undefined) { + var error = "SuperTokens must be initialized before calling this method."; + // eslint-disable-next-line supertokens-auth-react/no-direct-window-object + if (typeof window === "undefined") { + error = error + SSR_ERROR; + } + throw new Error(error); + } + return SuperTokens.instance; + }; + SuperTokens.prototype.getRecipeOrThrow = function (recipeId) { + var recipe = this.recipeList.find(function (recipe) { + return recipe.config.recipeId === recipeId; + }); + if (recipe === undefined) { + throw new Error("Missing recipe: ".concat(recipeId)); + } + return recipe; + }; + SuperTokens.prototype.loadTranslation = function (store) { + this.languageTranslations.translationEventSource.emit("TranslationLoaded", store); + }; + SuperTokens.prototype.getRedirectUrl = function (context, userContext) { + var _a; + return __awaiter(this, void 0, void 0, function () { + var userRes, redirectUrl; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!this.userGetRedirectionURL) return [3 /*break*/, 2]; + return [4 /*yield*/, this.userGetRedirectionURL(context, userContext)]; + case 1: + userRes = _b.sent(); + if (userRes !== undefined) { + return [2 /*return*/, userRes]; + } + _b.label = 2; + case 2: + if (context.action === "TO_AUTH") { + redirectUrl = this.appInfo.websiteBasePath.getAsStringDangerous(); + return [2 /*return*/, appendTrailingSlashToURL(redirectUrl)]; + } else if (context.action === "SUCCESS") { + return [2 /*return*/, (_a = context.redirectToPath) !== null && _a !== void 0 ? _a : "/"]; + } + throw new Error("Should never come here: unexpected redirection context"); + } + }); + }); + }; + /* + * Tests methods. + */ + SuperTokens.reset = function () { + if (!isTest()) { + return; + } + SuperTokens.instance = undefined; + return; + }; + SuperTokens.usesDynamicLoginMethods = false; + return SuperTokens; +})(); +function doRedirection(appInfo, redirectUrl, navigate) { + try { + new URL(redirectUrl); // If full URL, no error thrown, skip in app redirection. + } catch (e) { + // For multi tenancy, If mismatch between websiteDomain and current location, prepend URL relative path with websiteDomain. + var origin_1 = getOriginOfPage().getAsStringDangerous(); + if (origin_1 !== appInfo.websiteDomain.getAsStringDangerous()) { + redirectUrl = "".concat(appInfo.websiteDomain.getAsStringDangerous()).concat(redirectUrl); + redirectWithFullPageReload(redirectUrl); + return; + } + // If navigate was provided, use to redirect without reloading. + if (navigate !== undefined) { + redirectWithNavigate(redirectUrl, navigate); + return; + } + } + // Otherwise, redirect in app. + redirectWithFullPageReload(redirectUrl); +} + +exports.BaseRecipeModule = BaseRecipeModule; +exports.Multitenancy = Multitenancy; +exports.SSR_ERROR = SSR_ERROR; +exports.ST_ROOT_ID = ST_ROOT_ID; +exports.SuperTokens = SuperTokens; +exports.__awaiter = __awaiter; +exports.__extends = __extends; +exports.__generator = __generator; +exports.__rest = __rest; +exports.__spreadArray = __spreadArray; +exports.appendQueryParamsToURL = appendQueryParamsToURL; +exports.clearErrorQueryParam = clearErrorQueryParam; +exports.clearQueryParams = clearQueryParams; +exports.getCurrentLanguageFromCookie = getCurrentLanguageFromCookie; +exports.getCurrentNormalisedUrlPath = getCurrentNormalisedUrlPath; +exports.getCurrentNormalisedUrlPathWithQueryParamsAndFragments = getCurrentNormalisedUrlPathWithQueryParamsAndFragments; +exports.getLocalStorage = getLocalStorage; +exports.getNormalisedUserContext = getNormalisedUserContext; +exports.getQueryParams = getQueryParams; +exports.getRedirectToPathFromURL = getRedirectToPathFromURL; +exports.getURLHash = getURLHash; +exports.isTest = isTest; +exports.logDebugMessage = logDebugMessage; +exports.matchRecipeIdUsingQueryParams = matchRecipeIdUsingQueryParams; +exports.mergeObjects = mergeObjects; +exports.normaliseRecipeModuleConfig = normaliseRecipeModuleConfig; +exports.redirectWithFullPageReload = redirectWithFullPageReload; +exports.removeFromLocalStorage = removeFromLocalStorage; +exports.setLocalStorage = setLocalStorage; +exports.updateQueryParam = updateQueryParam; +exports.useOnMountAPICall = useOnMountAPICall; +exports.useRethrowInRender = useRethrowInRender; +exports.validateForm = validateForm; diff --git a/lib/build/thirdparty-shared.js b/lib/build/thirdparty-shared.js index c5ee98daa..6be7a734c 100644 --- a/lib/build/thirdparty-shared.js +++ b/lib/build/thirdparty-shared.js @@ -1,6 +1,7 @@ "use strict"; var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var ThirdpartyWebJS = require("supertokens-web-js/recipe/thirdparty"); var index = require("./authRecipe-shared2.js"); var types = require("./multifactorauth-shared.js"); @@ -30,24 +31,24 @@ function ProviderButton(_a) { var providerStyleName = "provider".concat(providerName); return jsxRuntime.jsxs( "button", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "button providerButton ".concat(providerStyleName) }, { children: [ logo !== undefined && jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "providerButtonLeft" }, { children: jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "providerButtonLogo" }, { children: jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "providerButtonLogoCenter" }, { children: logo } ) @@ -60,7 +61,7 @@ function ProviderButton(_a) { ), jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "providerButtonText" }, { children: [ @@ -119,10 +120,9 @@ var Provider = /** @class */ (function () { if (this.config.getRedirectURL) { return this.config.getRedirectURL(this.config.id); } - var domain = - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().appInfo.websiteDomain.getAsStringDangerous(); + var domain = superTokens.SuperTokens.getInstanceOrThrow().appInfo.websiteDomain.getAsStringDangerous(); var callbackPath = new NormalisedURLPath__default.default("/callback/".concat(this.config.id)); - var path = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow() + var path = superTokens.SuperTokens.getInstanceOrThrow() .appInfo.websiteBasePath.appendPath(callbackPath) .getAsStringDangerous(); return "".concat(domain).concat(path); @@ -137,20 +137,18 @@ var Provider = /** @class */ (function () { * Class. */ var ActiveDirectory = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(ActiveDirectory, _super); + superTokens.__extends(ActiveDirectory, _super); /* * Constructor. */ function ActiveDirectory(config) { var _this = - _super.call( - this, - genericComponentOverrideContext.__assign({ id: "active-directory", name: "Active Directory" }, config) - ) || this; + _super.call(this, superTokens.__assign({ id: "active-directory", name: "Active Directory" }, config)) || + this; _this.getLogo = function () { return jsxRuntime.jsxs( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { width: "18", height: "16", @@ -162,7 +160,7 @@ var ActiveDirectory = /** @class */ (function (_super) { children: [ jsxRuntime.jsxs( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { clipPath: "url(#clip0_402_84)" }, { children: [ @@ -189,7 +187,7 @@ var ActiveDirectory = /** @class */ (function (_super) { jsxRuntime.jsx("defs", { children: jsxRuntime.jsx( "clipPath", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "clip0_402_84" }, { children: jsxRuntime.jsx("rect", { @@ -223,7 +221,7 @@ var ActiveDirectory = /** @class */ (function (_super) { * Tests methods. */ ActiveDirectory.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } ActiveDirectory.instance = undefined; @@ -236,17 +234,16 @@ var ActiveDirectory = /** @class */ (function (_super) { * Class. */ var Apple = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(Apple, _super); + superTokens.__extends(Apple, _super); /* * Constructor. */ function Apple(config) { - var _this = - _super.call(this, genericComponentOverrideContext.__assign({ id: "apple", name: "Apple" }, config)) || this; + var _this = _super.call(this, superTokens.__assign({ id: "apple", name: "Apple" }, config)) || this; _this.getLogo = function () { return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "15.614", @@ -256,7 +253,7 @@ var Apple = /** @class */ (function (_super) { { children: jsxRuntime.jsxs( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "iconfinder_logo_brand_brands_logos_apple_ios_2993701", transform: "translate(-2)", @@ -315,10 +312,9 @@ var Apple = /** @class */ (function (_super) { return _this; } Apple.prototype.getRedirectURIOnProviderDashboard = function () { - var domain = - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().appInfo.apiDomain.getAsStringDangerous(); + var domain = superTokens.SuperTokens.getInstanceOrThrow().appInfo.apiDomain.getAsStringDangerous(); var callbackPath = new NormalisedURLPath__default$1.default("/callback/".concat(this.id)); - var path = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow() + var path = superTokens.SuperTokens.getInstanceOrThrow() .appInfo.apiBasePath.appendPath(callbackPath) .getAsStringDangerous(); return "".concat(domain).concat(path); @@ -338,7 +334,7 @@ var Apple = /** @class */ (function (_super) { * Tests methods. */ Apple.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } Apple.instance = undefined; @@ -351,20 +347,16 @@ var Apple = /** @class */ (function (_super) { * Class. */ var Bitbucket = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(Bitbucket, _super); + superTokens.__extends(Bitbucket, _super); /* * Constructor. */ function Bitbucket(config) { - var _this = - _super.call( - this, - genericComponentOverrideContext.__assign({ id: "bitbucket", name: "Bitbucket" }, config) - ) || this; + var _this = _super.call(this, superTokens.__assign({ id: "bitbucket", name: "Bitbucket" }, config)) || this; _this.getLogo = function () { return jsxRuntime.jsxs( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { width: "19", height: "17", @@ -385,7 +377,7 @@ var Bitbucket = /** @class */ (function (_super) { jsxRuntime.jsx("defs", { children: jsxRuntime.jsxs( "linearGradient", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "paint0_linear_4108_67124", x1: "19.2748", @@ -425,7 +417,7 @@ var Bitbucket = /** @class */ (function (_super) { * Tests methods. */ Bitbucket.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } Bitbucket.instance = undefined; @@ -438,20 +430,16 @@ var Bitbucket = /** @class */ (function (_super) { * Class. */ var BoxySAML = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(BoxySAML, _super); + superTokens.__extends(BoxySAML, _super); /* * Constructor. */ function BoxySAML(config) { - var _this = - _super.call( - this, - genericComponentOverrideContext.__assign({ id: "boxy-saml", name: "BoxySAML" }, config) - ) || this; + var _this = _super.call(this, superTokens.__assign({ id: "boxy-saml", name: "BoxySAML" }, config)) || this; _this.getLogo = function () { return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { width: "18", height: "18", @@ -487,7 +475,7 @@ var BoxySAML = /** @class */ (function (_super) { * Tests methods. */ BoxySAML.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } BoxySAML.instance = undefined; @@ -500,18 +488,16 @@ var BoxySAML = /** @class */ (function (_super) { * Class. */ var Discord = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(Discord, _super); + superTokens.__extends(Discord, _super); /* * Constructor. */ function Discord(config) { - var _this = - _super.call(this, genericComponentOverrideContext.__assign({ id: "discord", name: "Discord" }, config)) || - this; + var _this = _super.call(this, superTokens.__assign({ id: "discord", name: "Discord" }, config)) || this; _this.getLogo = function () { return jsxRuntime.jsxs( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { width: "18", height: "14", @@ -523,7 +509,7 @@ var Discord = /** @class */ (function (_super) { children: [ jsxRuntime.jsx( "g", - genericComponentOverrideContext.__assign( + superTokens.__assign( { clipPath: "url(#clip0_4108_67056)" }, { children: jsxRuntime.jsx("path", { @@ -536,7 +522,7 @@ var Discord = /** @class */ (function (_super) { jsxRuntime.jsx("defs", { children: jsxRuntime.jsx( "clipPath", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "clip0_4108_67056" }, { children: jsxRuntime.jsx("rect", { @@ -570,7 +556,7 @@ var Discord = /** @class */ (function (_super) { * Tests methods. */ Discord.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } Discord.instance = undefined; @@ -583,18 +569,16 @@ var Discord = /** @class */ (function (_super) { * Class. */ var Facebook = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(Facebook, _super); + superTokens.__extends(Facebook, _super); /* * Constructor. */ function Facebook(config) { - var _this = - _super.call(this, genericComponentOverrideContext.__assign({ id: "facebook", name: "Facebook" }, config)) || - this; + var _this = _super.call(this, superTokens.__assign({ id: "facebook", name: "Facebook" }, config)) || this; _this.getLogo = function () { return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { fill: "#1777F2", xmlns: "http://www.w3.org/2000/svg", @@ -627,7 +611,7 @@ var Facebook = /** @class */ (function (_super) { * Tests methods. */ Facebook.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } Facebook.instance = undefined; @@ -640,18 +624,16 @@ var Facebook = /** @class */ (function (_super) { * Class. */ var Github = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(Github, _super); + superTokens.__extends(Github, _super); /* * Constructor. */ function Github(config) { - var _this = - _super.call(this, genericComponentOverrideContext.__assign({ id: "github", name: "GitHub" }, config)) || - this; + var _this = _super.call(this, superTokens.__assign({ id: "github", name: "GitHub" }, config)) || this; _this.getLogo = function () { return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "17.556", viewBox: "0 0 18 17.556" }, { children: jsxRuntime.jsx("path", { @@ -681,7 +663,7 @@ var Github = /** @class */ (function (_super) { * Tests methods. */ Github.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } Github.instance = undefined; @@ -694,18 +676,16 @@ var Github = /** @class */ (function (_super) { * Class. */ var Gitlab = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(Gitlab, _super); + superTokens.__extends(Gitlab, _super); /* * Constructor. */ function Gitlab(config) { - var _this = - _super.call(this, genericComponentOverrideContext.__assign({ id: "gitlab", name: "Gitlab" }, config)) || - this; + var _this = _super.call(this, superTokens.__assign({ id: "gitlab", name: "Gitlab" }, config)) || this; _this.getLogo = function () { return jsxRuntime.jsxs( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { width: "18", height: "18", @@ -753,7 +733,7 @@ var Gitlab = /** @class */ (function (_super) { * Tests methods. */ Gitlab.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } Gitlab.instance = undefined; @@ -766,18 +746,16 @@ var Gitlab = /** @class */ (function (_super) { * Class. */ var Google = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(Google, _super); + superTokens.__extends(Google, _super); /* * Constructor. */ function Google(config) { - var _this = - _super.call(this, genericComponentOverrideContext.__assign({ id: "google", name: "Google" }, config)) || - this; + var _this = _super.call(this, superTokens.__assign({ id: "google", name: "Google" }, config)) || this; _this.getLogo = function () { return jsxRuntime.jsxs( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48", width: "18px", height: "18px" }, { children: [ @@ -819,7 +797,7 @@ var Google = /** @class */ (function (_super) { * Tests methods. */ Google.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } Google.instance = undefined; @@ -829,17 +807,15 @@ var Google = /** @class */ (function (_super) { })(Provider); var GoogleWorkspaces = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(GoogleWorkspaces, _super); + superTokens.__extends(GoogleWorkspaces, _super); function GoogleWorkspaces(config) { var _this = - _super.call( - this, - genericComponentOverrideContext.__assign({ id: "google-workspaces", name: "Google Workspaces" }, config) - ) || this; + _super.call(this, superTokens.__assign({ id: "google-workspaces", name: "Google Workspaces" }, config)) || + this; _this.getLogo = function () { return jsxRuntime.jsxs( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48", width: "18px", height: "18px" }, { children: [ @@ -881,7 +857,7 @@ var GoogleWorkspaces = /** @class */ (function (_super) { * Tests methods. */ GoogleWorkspaces.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } GoogleWorkspaces.instance = undefined; @@ -894,18 +870,16 @@ var GoogleWorkspaces = /** @class */ (function (_super) { * Class. */ var LinkedIn = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(LinkedIn, _super); + superTokens.__extends(LinkedIn, _super); /* * Constructor. */ function LinkedIn(config) { - var _this = - _super.call(this, genericComponentOverrideContext.__assign({ id: "linkedin", name: "LinkedIn" }, config)) || - this; + var _this = _super.call(this, superTokens.__assign({ id: "linkedin", name: "LinkedIn" }, config)) || this; _this.getLogo = function () { return jsxRuntime.jsxs( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48", width: "20", height: "20" }, { children: [ @@ -939,7 +913,7 @@ var LinkedIn = /** @class */ (function (_super) { * Tests methods. */ LinkedIn.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } LinkedIn.instance = undefined; @@ -952,17 +926,16 @@ var LinkedIn = /** @class */ (function (_super) { * Class. */ var Okta = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(Okta, _super); + superTokens.__extends(Okta, _super); /* * Constructor. */ function Okta(config) { - var _this = - _super.call(this, genericComponentOverrideContext.__assign({ id: "okta", name: "Okta" }, config)) || this; + var _this = _super.call(this, superTokens.__assign({ id: "okta", name: "Okta" }, config)) || this; _this.getLogo = function () { return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { width: "18", height: "18", @@ -998,7 +971,7 @@ var Okta = /** @class */ (function (_super) { * Tests methods. */ Okta.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } Okta.instance = undefined; @@ -1011,7 +984,7 @@ var Okta = /** @class */ (function (_super) { * Class. */ var Twitter = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(Twitter, _super); + superTokens.__extends(Twitter, _super); /* * Constructor. */ @@ -1023,14 +996,13 @@ var Twitter = /** @class */ (function (_super) { if (normalisedUseLegacyTwitterLogo) { name = "Twitter"; } - _this = - _super.call(this, genericComponentOverrideContext.__assign({ id: "twitter", name: name }, config)) || this; + _this = _super.call(this, superTokens.__assign({ id: "twitter", name: name }, config)) || this; _this.useLegacyTwitterLogo = false; _this.getLogo = function () { if (_this.useLegacyTwitterLogo === true) { return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "20.129", @@ -1054,7 +1026,7 @@ var Twitter = /** @class */ (function (_super) { } return jsxRuntime.jsx( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 1200 1227" }, { children: jsxRuntime.jsx("path", { @@ -1083,7 +1055,7 @@ var Twitter = /** @class */ (function (_super) { * Tests methods. */ Twitter.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } Twitter.instance = undefined; @@ -1094,11 +1066,11 @@ var Twitter = /** @class */ (function (_super) { var getFunctionOverrides = function (recipeId, onHandleEvent) { return function (originalImp) { - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImp), { + return superTokens.__assign(superTokens.__assign({}, originalImp), { signInAndUp: function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var payloadBeforeCall, response, payloadAfterCall; - return genericComponentOverrideContext.__generator(this, function (_c) { + return superTokens.__generator(this, function (_c) { switch (_c.label) { case 0: _c.trys.push([0, 2, , 3]); @@ -1158,11 +1130,15 @@ var getFunctionOverrides = function (recipeId, onHandleEvent) { }); }, setStateAndOtherInfoToStorage: function (input) { + var _a; + var loginChallenge = + (_a = superTokens.getQueryParams("loginChallenge")) !== null && _a !== void 0 ? _a : undefined; return originalImp.setStateAndOtherInfoToStorage({ - state: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, input.state), - { rid: recipeId, redirectToPath: genericComponentOverrideContext.getRedirectToPathFromURL() } - ), + state: superTokens.__assign(superTokens.__assign({}, input.state), { + rid: recipeId, + oauth2LoginChallenge: loginChallenge, + redirectToPath: superTokens.getRedirectToPathFromURL(), + }), userContext: input.userContext, }); }, @@ -1174,7 +1150,7 @@ var getFunctionOverrides = function (recipeId, onHandleEvent) { * Class. */ var Custom = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(Custom, _super); + superTokens.__extends(Custom, _super); /* * Constructor. */ @@ -1222,7 +1198,7 @@ function normaliseThirdPartyConfig(config) { var signInAndUpFeature = normaliseSignInAndUpFeature(config.signInAndUpFeature); var oAuthCallbackScreen = config.oAuthCallbackScreen === undefined ? {} : { style: config.oAuthCallbackScreen.style }; - var override = genericComponentOverrideContext.__assign( + var override = superTokens.__assign( { functions: function (originalImplementation) { return originalImplementation; @@ -1230,10 +1206,11 @@ function normaliseThirdPartyConfig(config) { }, config.override ); - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, utils.normaliseAuthRecipe(config)), - { signInAndUpFeature: signInAndUpFeature, oAuthCallbackScreen: oAuthCallbackScreen, override: override } - ); + return superTokens.__assign(superTokens.__assign({}, utils.normaliseAuthRecipe(config)), { + signInAndUpFeature: signInAndUpFeature, + oAuthCallbackScreen: oAuthCallbackScreen, + override: override, + }); } function normaliseSignInAndUpFeature(config) { if (config === undefined) { @@ -1286,18 +1263,16 @@ function matchRecipeIdUsingState(recipe, userContext) { return false; } function redirectToThirdPartyLogin(input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var loginMethods, tenantProviders, providers, provider, response; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, - genericComponentOverrideContext.Multitenancy.getInstanceOrThrow().getCurrentDynamicLoginMethods( - { - userContext: input.userContext, - } - ), + superTokens.Multitenancy.getInstanceOrThrow().getCurrentDynamicLoginMethods({ + userContext: input.userContext, + }), ]; case 1: loginMethods = _a.sent(); @@ -1329,7 +1304,7 @@ function redirectToThirdPartyLogin(input) { ]; case 2: response = _a.sent(); - genericComponentOverrideContext.redirectWithFullPageReload(response); + superTokens.redirectWithFullPageReload(response); return [2 /*return*/, { status: "OK" }]; } }); @@ -1355,7 +1330,7 @@ var mergeProviders = function (_a) { twitter: Twitter, facebook: Facebook, }; - var usesDynamicLoginMethods = genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods === true; + var usesDynamicLoginMethods = superTokens.SuperTokens.usesDynamicLoginMethods === true; if ( usesDynamicLoginMethods === false && (clientProviders === null || clientProviders === void 0 ? void 0 : clientProviders.length) === 0 @@ -1385,14 +1360,11 @@ var mergeProviders = function (_a) { if (provider !== undefined) { providers.push( Custom.init( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, provider.config), - { - id: tenantProvider.id, - name: tenantProvider.name, - buttonComponent: provider.getButton(tenantProvider.name), - } - ) + superTokens.__assign(superTokens.__assign({}, provider.config), { + id: tenantProvider.id, + name: tenantProvider.name, + buttonComponent: provider.getButton(tenantProvider.name), + }) ) ); } else { @@ -1436,14 +1408,14 @@ var mergeProviders = function (_a) { * Class. */ var ThirdParty = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(ThirdParty, _super); + superTokens.__extends(ThirdParty, _super); function ThirdParty(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = ThirdpartyWebJS__default.default; } var _this = this; if ( - genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods === false && + superTokens.SuperTokens.usesDynamicLoginMethods === false && config.signInAndUpFeature.providers.length === 0 ) { throw new Error("ThirdParty signInAndUpFeature providers array cannot be empty."); @@ -1456,8 +1428,8 @@ var ThirdParty = /** @class */ (function (_super) { * Instance methods. */ _this.getDefaultRedirectionURL = function (context) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [2 /*return*/, this.getAuthRecipeDefaultRedirectionURL(context)]; }); }); @@ -1474,30 +1446,24 @@ var ThirdParty = /** @class */ (function (_super) { recipeID: ThirdParty.RECIPE_ID, authReact: function (appInfo) { ThirdParty.instance = new ThirdParty( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, normalisedConfig), - { appInfo: appInfo, recipeId: ThirdParty.RECIPE_ID } - ) + superTokens.__assign(superTokens.__assign({}, normalisedConfig), { + appInfo: appInfo, + recipeId: ThirdParty.RECIPE_ID, + }) ); return ThirdParty.instance; }, webJS: ThirdpartyWebJS__default.default.init( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, normalisedConfig), - { - override: { - functions: function (originalImpl, builder) { - var functions = getFunctionOverrides( - ThirdParty.RECIPE_ID, - normalisedConfig.onHandleEvent - ); - builder.override(functions); - builder.override(normalisedConfig.override.functions); - return originalImpl; - }, + superTokens.__assign(superTokens.__assign({}, normalisedConfig), { + override: { + functions: function (originalImpl, builder) { + var functions = getFunctionOverrides(ThirdParty.RECIPE_ID, normalisedConfig.onHandleEvent); + builder.override(functions); + builder.override(normalisedConfig.override.functions); + return originalImpl; }, - } - ) + }, + }) ), }; }; @@ -1508,7 +1474,7 @@ var ThirdParty = /** @class */ (function (_super) { "See https://supertokens.io/docs/thirdparty/quick-setup/frontend"; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { - error = error + genericComponentOverrideContext.SSR_ERROR; + error = error + superTokens.SSR_ERROR; } throw Error(error); } @@ -1518,7 +1484,7 @@ var ThirdParty = /** @class */ (function (_super) { * Tests methods. */ ThirdParty.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } ThirdParty.instance = undefined; diff --git a/lib/build/thirdparty.js b/lib/build/thirdparty.js index 287ebc3ca..478ac7b00 100644 --- a/lib/build/thirdparty.js +++ b/lib/build/thirdparty.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var recipe = require("./thirdparty-shared.js"); require("supertokens-web-js"); require("supertokens-web-js/utils/cookieHandler"); @@ -13,12 +13,15 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); +require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); require("supertokens-web-js/recipe/thirdparty"); require("./authRecipe-shared2.js"); require("./recipeModule-shared.js"); require("./multifactorauth-shared.js"); require("supertokens-web-js/recipe/session"); +require("./oauth2-shared.js"); +require("supertokens-web-js/recipe/oauth2"); require("./authRecipe-shared.js"); require("./translationContext.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); @@ -46,12 +49,12 @@ var Wrapper = /** @class */ (function () { return recipe.ThirdParty.init(config); }; Wrapper.signOut = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.ThirdParty.getInstanceOrThrow().signOut({ - userContext: genericComponentOverrideContext.getNormalisedUserContext( + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -60,16 +63,16 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.redirectToThirdPartyLogin = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var recipeInstance; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { recipeInstance = recipe.ThirdParty.getInstanceOrThrow(); return [ 2 /*return*/, recipe.redirectToThirdPartyLogin({ thirdPartyId: input.thirdPartyId, config: recipeInstance.config, - userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), + userContext: superTokens.getNormalisedUserContext(input.userContext), recipeImplementation: recipeInstance.webJSRecipe, }), ]; @@ -78,21 +81,21 @@ var Wrapper = /** @class */ (function () { }; Wrapper.getStateAndOtherInfoFromStorage = function (input) { return recipe.ThirdParty.getInstanceOrThrow().webJSRecipe.getStateAndOtherInfoFromStorage( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) ); }; Wrapper.getAuthorisationURLWithQueryParamsAndSetState = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.ThirdParty.getInstanceOrThrow().webJSRecipe.getAuthorisationURLWithQueryParamsAndSetState( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext(input.userContext), }) ), ]; @@ -100,13 +103,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.signInAndUp = function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe.ThirdParty.getInstanceOrThrow().webJSRecipe.signInAndUp( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) diff --git a/lib/build/thirdpartyprebuiltui.js b/lib/build/thirdpartyprebuiltui.js index 7c8a6cc8a..064b775cd 100644 --- a/lib/build/thirdpartyprebuiltui.js +++ b/lib/build/thirdpartyprebuiltui.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var jsxRuntime = require("react/jsx-runtime"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); var uiEntry = require("./index2.js"); @@ -23,10 +23,13 @@ require("supertokens-web-js/utils/normalisedURLDomain"); require("./translationContext.js"); require("react-dom"); require("./multitenancy-shared.js"); +require("./genericComponentOverrideContext.js"); require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); +require("./oauth2-shared.js"); +require("supertokens-web-js/recipe/oauth2"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); require("./multifactorauth-shared3.js"); @@ -94,9 +97,9 @@ var ThemeBase = function (_a) { var ThirdPartySignInAndUpProvidersForm = function (props) { var userContext = uiEntry.useUserContext(); var signInClick = function (providerId) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var response, generalError, e_1; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 5, , 6]); @@ -151,12 +154,12 @@ var ThirdPartySignInAndUpProvidersForm = function (props) { children: props.providers.map(function (provider) { return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "providerContainer" }, { children: jsxRuntime.jsx( "span", - genericComponentOverrideContext.__assign( + superTokens.__assign( { onClick: function () { return signInClick(provider.id); @@ -175,16 +178,16 @@ var ThirdPartySignInAndUpProvidersForm = function (props) { var ProvidersForm = uiEntry.withOverride("ThirdPartySignInAndUpProvidersForm", ThirdPartySignInAndUpProvidersForm); var SignInAndUpThemeWrapper = function (props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [ @@ -193,7 +196,7 @@ var SignInAndUpThemeWrapper = function (props) { props.config.signInAndUpFeature.style, ], }, - { children: jsxRuntime.jsx(ProvidersForm, genericComponentOverrideContext.__assign({}, props)) } + { children: jsxRuntime.jsx(ProvidersForm, superTokens.__assign({}, props)) } ) ), } @@ -201,7 +204,17 @@ var SignInAndUpThemeWrapper = function (props) { ); }; -function useChildProps(recipe$1, error, onError, clearError, rebuildAuthPage, setFactorList, navigate, userContext) { +function useChildProps( + recipe$1, + onAuthSuccess, + error, + onError, + clearError, + rebuildAuthPage, + setFactorList, + navigate, + userContext +) { var recipeImplementation = React.useMemo( function () { return recipe$1 && getModifiedRecipeImplementation(recipe$1.webJSRecipe); @@ -212,7 +225,7 @@ function useChildProps(recipe$1, error, onError, clearError, rebuildAuthPage, se return React.useMemo( function () { var tenantProviders; - if (genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods) { + if (superTokens.SuperTokens.usesDynamicLoginMethods) { if (dynamicLoginMethods.loaded === false) { throw new Error("Component requiring dynamicLoginMethods rendered without FeatureWrapper."); } else { @@ -222,6 +235,7 @@ function useChildProps(recipe$1, error, onError, clearError, rebuildAuthPage, se } } return { + onAuthSuccess: onAuthSuccess, error: error, onError: onError, clearError: clearError, @@ -244,6 +258,7 @@ function useChildProps(recipe$1, error, onError, clearError, rebuildAuthPage, se var SignInAndUpFeature = function (props) { var childProps = useChildProps( props.recipe, + props.onAuthSuccess, props.error, props.onError, props.clearError, @@ -252,21 +267,15 @@ var SignInAndUpFeature = function (props) { props.navigate, props.userContext ); - var themeProps = genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, childProps), - { providers: childProps.providers } - ); + var themeProps = superTokens.__assign(superTokens.__assign({}, childProps), { providers: childProps.providers }); return jsxRuntime.jsxs(React.Fragment, { children: [ props.children === undefined && - jsxRuntime.jsx(SignInAndUpThemeWrapper, genericComponentOverrideContext.__assign({}, themeProps)), + jsxRuntime.jsx(SignInAndUpThemeWrapper, superTokens.__assign({}, themeProps)), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { - return React__namespace.cloneElement( - child, - genericComponentOverrideContext.__assign({}, childProps) - ); + return React__namespace.cloneElement(child, superTokens.__assign({}, childProps)); } return child; }), @@ -277,21 +286,21 @@ var SignInAndUpFeatureWrapper = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { recipeComponentOverrides: recipeComponentOverrides }, - { children: jsxRuntime.jsx(SignInAndUpFeature, genericComponentOverrideContext.__assign({}, props)) } + { children: jsxRuntime.jsx(SignInAndUpFeature, superTokens.__assign({}, props)) } ) ); }; var getModifiedRecipeImplementation = function (origImpl) { - return genericComponentOverrideContext.__assign({}, origImpl); + return superTokens.__assign({}, origImpl); }; /* * Component. */ var ThirdPartySignInAndUpCallbackTheme = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(ThirdPartySignInAndUpCallbackTheme, _super); + superTokens.__extends(ThirdPartySignInAndUpCallbackTheme, _super); function ThirdPartySignInAndUpCallbackTheme() { /* * Methods. @@ -300,17 +309,17 @@ var ThirdPartySignInAndUpCallbackTheme = /** @class */ (function (_super) { _this.render = function () { return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "spinner" }, { children: jsxRuntime.jsx(uiEntry.SpinnerIcon, {}) } ) @@ -331,11 +340,11 @@ var SignInAndUpCallbackThemeWithOverride = uiEntry.withOverride( ThirdPartySignInAndUpCallbackTheme ); var SignInAndUpCallbackTheme = function (props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); return jsxRuntime.jsx( ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, props.config.signInAndUpFeature.style], @@ -346,29 +355,26 @@ var SignInAndUpCallbackTheme = function (props) { }; var defaultTranslationsThirdParty = { - en: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, uiEntry.defaultTranslationsCommon.en), - { - THIRD_PARTY_PROVIDER_DEFAULT_BTN_START: "Continue with ", - THIRD_PARTY_PROVIDER_DEFAULT_BTN_END: "", - THIRD_PARTY_ERROR_NO_EMAIL: "Could not retrieve email. Please try a different method.", - /* - * The following are error messages from our backend SDK. - * These are returned as full messages to preserver compatibilty, but they work just like the keys above. - * They are shown as is by default (setting the value to undefined will display the raw translation key) - */ - "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_004)": - undefined, - "Cannot sign in / up because new email cannot be applied to existing account. Please contact support. (ERR_CODE_005)": - undefined, - "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_006)": - undefined, - "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_020)": undefined, - "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_021)": undefined, - "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_022)": undefined, - "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_023)": undefined, - } - ), + en: superTokens.__assign(superTokens.__assign({}, uiEntry.defaultTranslationsCommon.en), { + THIRD_PARTY_PROVIDER_DEFAULT_BTN_START: "Continue with ", + THIRD_PARTY_PROVIDER_DEFAULT_BTN_END: "", + THIRD_PARTY_ERROR_NO_EMAIL: "Could not retrieve email. Please try a different method.", + /* + * The following are error messages from our backend SDK. + * These are returned as full messages to preserver compatibilty, but they work just like the keys above. + * They are shown as is by default (setting the value to undefined will display the raw translation key) + */ + "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_004)": + undefined, + "Cannot sign in / up because new email cannot be applied to existing account. Please contact support. (ERR_CODE_005)": + undefined, + "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_006)": + undefined, + "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_020)": undefined, + "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_021)": undefined, + "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_022)": undefined, + "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_023)": undefined, + }), }; var SignInAndUpCallback$1 = function (props) { @@ -376,13 +382,13 @@ var SignInAndUpCallback$1 = function (props) { if (props.userContext !== undefined) { userContext = props.userContext; } - var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var rethrowInRender = superTokens.useRethrowInRender(); var verifyCode = React.useCallback( function () { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var payloadBeforeCall; var _b; - return genericComponentOverrideContext.__generator(this, function (_c) { + return superTokens.__generator(this, function (_c) { switch (_c.label) { case 0: _c.trys.push([0, 2, , 3]); @@ -422,15 +428,15 @@ var SignInAndUpCallback$1 = function (props) { function (_a) { var response = _a.response, payloadBeforeCall = _a.payloadBeforeCall; - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { - var payloadAfterCall, stateResponse, redirectToPath; - return genericComponentOverrideContext.__generator(this, function (_c) { + return superTokens.__awaiter(void 0, void 0, void 0, function () { + var payloadAfterCall, stateResponse, redirectToPath, loginChallenge; + return superTokens.__generator(this, function (_c) { switch (_c.label) { case 0: if (response.status === "NO_EMAIL_GIVEN_BY_PROVIDER") { return [ 2 /*return*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ + superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: "no_email_present", @@ -443,7 +449,7 @@ var SignInAndUpCallback$1 = function (props) { if (response.status === "SIGN_IN_UP_NOT_ALLOWED") { return [ 2 /*return*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ + superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: response.status, @@ -477,22 +483,42 @@ var SignInAndUpCallback$1 = function (props) { userContext: userContext, }); redirectToPath = stateResponse === undefined ? undefined : stateResponse.redirectToPath; + loginChallenge = + stateResponse === null || stateResponse === void 0 + ? void 0 + : stateResponse.oauth2LoginChallenge; return [ 2 /*return*/, types.Session.getInstanceOrThrow() .validateGlobalClaimsAndHandleSuccessRedirection( - { - action: "SUCCESS", - createdNewUser: - response.createdNewRecipeUser && - response.user.loginMethods.length === 1, - isNewRecipeUser: response.createdNewRecipeUser, - newSessionCreated: - payloadAfterCall !== undefined && - (payloadBeforeCall === undefined || - payloadBeforeCall.sessionHandle !== payloadAfterCall.sessionHandle), - recipeId: props.recipe.recipeID, - }, + loginChallenge !== undefined + ? { + action: "SUCCESS_OAUTH2", + loginChallenge: loginChallenge, + createdNewUser: + response.createdNewRecipeUser && + response.user.loginMethods.length === 1, + isNewRecipeUser: response.createdNewRecipeUser, + newSessionCreated: + payloadAfterCall !== undefined && + (payloadBeforeCall === undefined || + payloadBeforeCall.sessionHandle !== + payloadAfterCall.sessionHandle), + recipeId: props.recipe.recipeID, + } + : { + action: "SUCCESS", + createdNewUser: + response.createdNewRecipeUser && + response.user.loginMethods.length === 1, + isNewRecipeUser: response.createdNewRecipeUser, + newSessionCreated: + payloadAfterCall !== undefined && + (payloadBeforeCall === undefined || + payloadBeforeCall.sessionHandle !== + payloadAfterCall.sessionHandle), + recipeId: props.recipe.recipeID, + }, props.recipe.recipeID, redirectToPath, userContext, @@ -510,9 +536,9 @@ var SignInAndUpCallback$1 = function (props) { ); var handleError = React.useCallback( function (err) { - return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return superTokens.__awaiter(void 0, void 0, void 0, function () { var invalidClaims, evInstance; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -559,7 +585,7 @@ var SignInAndUpCallback$1 = function (props) { if (STGeneralError__default.default.isThisError(err)) { return [ 2 /*return*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ + superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: "custom", @@ -572,7 +598,7 @@ var SignInAndUpCallback$1 = function (props) { } return [ 2 /*return*/, - genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ + superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: "signin", @@ -587,18 +613,18 @@ var SignInAndUpCallback$1 = function (props) { }, [props.navigate, userContext] ); - genericComponentOverrideContext.useOnMountAPICall(verifyCode, handleVerifyResponse, handleError); + superTokens.useOnMountAPICall(verifyCode, handleVerifyResponse, handleError); var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { - useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, + useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, defaultStore: defaultTranslationsThirdParty, }, { @@ -618,7 +644,7 @@ var SignInAndUpCallback$1 = function (props) { }; var ThirdPartyPreBuiltUI = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(ThirdPartyPreBuiltUI, _super); + superTokens.__extends(ThirdPartyPreBuiltUI, _super); function ThirdPartyPreBuiltUI(recipeInstance) { var _this = _super.call(this) || this; _this.recipeInstance = recipeInstance; @@ -651,21 +677,19 @@ var ThirdPartyPreBuiltUI = /** @class */ (function (_super) { if (componentName === "signinupcallback") { return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( session.SessionAuth, - genericComponentOverrideContext.__assign( + superTokens.__assign( { requireAuth: false, doRedirection: false }, { children: jsxRuntime.jsx( SignInAndUpCallback$1, - genericComponentOverrideContext.__assign( - { recipe: _this.recipeInstance }, - props, - { useComponentOverrides: useComponentOverrides } - ) + superTokens.__assign({ recipe: _this.recipeInstance }, props, { + useComponentOverrides: useComponentOverrides, + }) ), } ) @@ -710,7 +734,7 @@ var ThirdPartyPreBuiltUI = /** @class */ (function (_super) { component: function (props) { return jsxRuntime.jsx( SignInAndUpFeatureWrapper, - genericComponentOverrideContext.__assign({}, props, { + superTokens.__assign({}, props, { recipe: _this.recipeInstance, useComponentOverrides: recipe.useContext, }), @@ -725,7 +749,7 @@ var ThirdPartyPreBuiltUI = /** @class */ (function (_super) { }; // For tests ThirdPartyPreBuiltUI.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } ThirdPartyPreBuiltUI.instance = undefined; diff --git a/lib/build/totp-shared.js b/lib/build/totp-shared.js index ce1ea7bc5..19bcbbaf7 100644 --- a/lib/build/totp-shared.js +++ b/lib/build/totp-shared.js @@ -1,6 +1,7 @@ "use strict"; var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var TOTPWebJS = require("supertokens-web-js/recipe/totp"); var postSuperTokensInitCallbacks = require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); var jsxRuntime = require("react/jsx-runtime"); @@ -21,7 +22,7 @@ var _a = genericComponentOverrideContext.createGenericComponentsOverrideContext( var TOTPIcon = function () { return jsxRuntime.jsxs( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { width: "20", height: "19", viewBox: "0 0 20 19", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [ @@ -34,7 +35,7 @@ var TOTPIcon = function () { jsxRuntime.jsx("defs", { children: jsxRuntime.jsxs( "linearGradient", - genericComponentOverrideContext.__assign( + superTokens.__assign( { id: "paint0_linear_4901_3396", x1: "10", @@ -60,11 +61,11 @@ var TOTPIcon = function () { var getFunctionOverrides = function (onHandleEvent) { return function (originalImp) { - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImp), { + return superTokens.__assign(superTokens.__assign({}, originalImp), { createDevice: function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var response; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.createDevice(input)]; @@ -83,9 +84,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, verifyDevice: function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var response; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.verifyDevice(input)]; @@ -105,9 +106,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, verifyCode: function (input) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var response; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.verifyCode(input)]; @@ -146,7 +147,7 @@ function normaliseMultiFactorAuthFeature(config) { if (config === undefined) { config = {}; } - var override = genericComponentOverrideContext.__assign( + var override = superTokens.__assign( { functions: function (originalImplementation) { return originalImplementation; @@ -154,29 +155,23 @@ function normaliseMultiFactorAuthFeature(config) { }, config.override ); - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign( - {}, - genericComponentOverrideContext.normaliseRecipeModuleConfig(config) + return superTokens.__assign(superTokens.__assign({}, superTokens.normaliseRecipeModuleConfig(config)), { + totpMFAScreen: superTokens.__assign( + { + disableDefaultUI: false, + blockedScreenStyle: "", + setupScreenStyle: "", + verificationScreenStyle: "", + loadingScreenStyle: "", + }, + config.totpMFAScreen ), - { - totpMFAScreen: genericComponentOverrideContext.__assign( - { - disableDefaultUI: false, - blockedScreenStyle: "", - setupScreenStyle: "", - verificationScreenStyle: "", - loadingScreenStyle: "", - }, - config.totpMFAScreen - ), - override: override, - } - ); + override: override, + }); } function totpCodeValidate(value) { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { if (typeof value !== "string") { return [2 /*return*/, "GENERAL_ERROR_TOTP_NON_STRING"]; } @@ -210,7 +205,7 @@ var totpFactor = { logo: TOTPIcon, }; var TOTP = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(TOTP, _super); + superTokens.__extends(TOTP, _super); function TOTP(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = TOTPWebJS__default.default; @@ -220,8 +215,8 @@ var TOTP = /** @class */ (function (_super) { _this.recipeID = TOTP.RECIPE_ID; // eslint-disable-next-line @typescript-eslint/no-unused-vars _this.getDefaultRedirectionURL = function (_context) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { throw new Error("Should never come here"); }); }); @@ -240,27 +235,24 @@ var TOTP = /** @class */ (function (_super) { recipeID: TOTP.RECIPE_ID, authReact: function (appInfo) { TOTP.instance = new TOTP( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, normalisedConfig), - { appInfo: appInfo, recipeId: TOTP.RECIPE_ID } - ) + superTokens.__assign(superTokens.__assign({}, normalisedConfig), { + appInfo: appInfo, + recipeId: TOTP.RECIPE_ID, + }) ); return TOTP.instance; }, webJS: TOTPWebJS__default.default.init( - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, normalisedConfig), - { - override: { - functions: function (originalImpl, builder) { - var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); - builder.override(functions); - builder.override(normalisedConfig.override.functions); - return originalImpl; - }, + superTokens.__assign(superTokens.__assign({}, normalisedConfig), { + override: { + functions: function (originalImpl, builder) { + var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); + builder.override(functions); + builder.override(normalisedConfig.override.functions); + return originalImpl; }, - } - ) + }, + }) ), }; }; @@ -272,7 +264,7 @@ var TOTP = /** @class */ (function (_super) { var error = "No instance of TOTP found. Make sure to call the TOTP.init method."; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { - error = error + genericComponentOverrideContext.SSR_ERROR; + error = error + superTokens.SSR_ERROR; } throw Error(error); } diff --git a/lib/build/totp.js b/lib/build/totp.js index 12f9d30d9..4b185faaf 100644 --- a/lib/build/totp.js +++ b/lib/build/totp.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var recipe = require("./totp-shared.js"); require("supertokens-web-js"); require("supertokens-web-js/utils/cookieHandler"); @@ -13,6 +13,7 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); +require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); require("supertokens-web-js/recipe/totp"); require("./multifactorauth-shared2.js"); @@ -21,6 +22,8 @@ require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); require("./multifactorauth-shared.js"); require("supertokens-web-js/recipe/session"); +require("./oauth2-shared.js"); +require("supertokens-web-js/recipe/oauth2"); /* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. * @@ -43,8 +46,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.createDevice = function (input) { return recipe.TOTP.getInstanceOrThrow().webJSRecipe.createDevice( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -52,8 +55,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.verifyCode = function (input) { return recipe.TOTP.getInstanceOrThrow().webJSRecipe.verifyCode( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -61,8 +64,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.verifyDevice = function (input) { return recipe.TOTP.getInstanceOrThrow().webJSRecipe.verifyDevice( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -70,8 +73,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.removeDevice = function (input) { return recipe.TOTP.getInstanceOrThrow().webJSRecipe.removeDevice( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -79,8 +82,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.listDevices = function (input) { return recipe.TOTP.getInstanceOrThrow().webJSRecipe.listDevices( - genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { - userContext: genericComponentOverrideContext.getNormalisedUserContext( + superTokens.__assign(superTokens.__assign({}, input), { + userContext: superTokens.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) diff --git a/lib/build/totpprebuiltui.js b/lib/build/totpprebuiltui.js index ce57ced04..dad1d8520 100644 --- a/lib/build/totpprebuiltui.js +++ b/lib/build/totpprebuiltui.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var jsxRuntime = require("react/jsx-runtime"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); var uiEntry = require("./index2.js"); @@ -23,12 +23,15 @@ require("supertokens-web-js/utils"); require("supertokens-web-js/utils/normalisedURLDomain"); require("react-dom"); require("./multitenancy-shared.js"); +require("./genericComponentOverrideContext.js"); +require("./oauth2-shared.js"); +require("supertokens-web-js/recipe/oauth2"); +require("./recipeModule-shared.js"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); require("supertokens-web-js/recipe/session"); require("./session-shared.js"); require("supertokens-web-js/recipe/totp"); -require("./recipeModule-shared.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./emailpassword-shared4.js"); @@ -92,7 +95,7 @@ var ThemeBase = function (_a) { var BlockedIcon = function () { return jsxRuntime.jsxs( "svg", - genericComponentOverrideContext.__assign( + superTokens.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "65", height: "65", viewBox: "0 0 65 65", fill: "none" }, { children: [ @@ -144,7 +147,7 @@ var RetryButton = function (_a) { ); return jsxRuntime.jsx( "button", - genericComponentOverrideContext.__assign( + superTokens.__assign( { type: "button", disabled: secsUntilRetry !== undefined, @@ -179,26 +182,26 @@ var TOTPBlockedScreen = function (props) { var t = translationContext.useTranslation(); return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container totp-mfa blockedScreen" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row noFormRow" }, { children: [ jsxRuntime.jsx(BlockedIcon, {}), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle" }, { children: t("TOTP_BLOCKED_TITLE") } ) ), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: t("TOTP_BLOCKED_SUBTITLE") } ) @@ -216,7 +219,7 @@ var TOTPBlockedScreen = function (props) { ), jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: props.onSignOutClicked, @@ -244,17 +247,17 @@ var BlockedScreen = uiEntry.withOverride("TOTPBlockedScreen", TOTPBlockedScreen) var TOTPLoadingScreen = function () { return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container delayedRender totp-mfa loadingScreen" }, { children: jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "spinner delayedRender" }, { children: jsxRuntime.jsx(uiEntry.SpinnerIcon, {}) } ) @@ -291,10 +294,10 @@ var CodeForm = uiEntry.withOverride("TOTPCodeForm", function TOTPCodeForm(props) onSuccess: props.onSuccess, buttonLabel: "TOTP_CODE_CONTINUE_BUTTON", callAPI: function (formFields) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var totp, response; var _a; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: totp = @@ -359,12 +362,12 @@ var CodeVerificationFooter = uiEntry.withOverride( var t = translationContext.useTranslation(); return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "footerLinkGroupVert totp-mfa codeVerificationFooter" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: onSignOutClicked, @@ -393,7 +396,7 @@ var CodeVerificationHeader = uiEntry.withOverride( children: [ jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle withBackButton totp-mfa codeVerificationHeader" }, { children: [ @@ -412,7 +415,7 @@ var CodeVerificationHeader = uiEntry.withOverride( ), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: t("TOTP_CODE_VERIFICATION_HEADER_SUBTITLE") } ) @@ -3353,7 +3356,7 @@ var DeviceInfoSection = uiEntry.withOverride("TOTPDeviceInfoSection", function T children: [ jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "totpDeviceInfoWithQR totp-mfa deviceInfoSection" }, { children: [ @@ -3364,14 +3367,14 @@ var DeviceInfoSection = uiEntry.withOverride("TOTPDeviceInfoSection", function T }), jsxRuntime.jsxs( "span", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "showTOTPSecret" }, { children: [ t("TOTP_SHOW_SECRET_START"), jsxRuntime.jsx( "button", - genericComponentOverrideContext.__assign( + superTokens.__assign( { type: "button", onClick: props.onShowSecretClicked, @@ -3388,7 +3391,7 @@ var DeviceInfoSection = uiEntry.withOverride("TOTPDeviceInfoSection", function T props.showSecret && jsxRuntime.jsx( "span", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "totpSecret" }, { children: props.deviceInfo.secret } ) @@ -3407,12 +3410,12 @@ var DeviceSetupFooter = uiEntry.withOverride("TOTPDeviceSetupFooter", function T var t = translationContext.useTranslation(); return jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "footerLinkGroupVert totp-mfa deviceSetupFooter" }, { children: jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: onSignOutClicked }, { children: [ @@ -3435,7 +3438,7 @@ var DeviceSetupHeader = uiEntry.withOverride("TOTPDeviceSetupHeader", function T children: [ jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerTitle withBackButton totp-mfa deviceSetupHeader" }, { children: [ @@ -3452,7 +3455,7 @@ var DeviceSetupHeader = uiEntry.withOverride("TOTPDeviceSetupHeader", function T ), jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: t("TOTP_DEVICE_SETUP_HEADER_SUBTITLE") } ) @@ -3473,7 +3476,7 @@ var TOTPMFAScreens; var TOTPMFATheme = function (_a) { var activeScreen = _a.activeScreen, featureState = _a.featureState, - props = genericComponentOverrideContext.__rest(_a, ["activeScreen", "featureState"]); + props = superTokens.__rest(_a, ["activeScreen", "featureState"]); var t = translationContext.useTranslation(); var commonProps = { featureState: featureState, @@ -3501,13 +3504,13 @@ var TOTPMFATheme = function (_a) { ? jsxRuntime.jsx(LoadingScreen, {}) : jsxRuntime.jsxs( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "container totp-mfa" }, { children: [ jsxRuntime.jsx( "div", - genericComponentOverrideContext.__assign( + superTokens.__assign( { "data-supertokens": "row" }, { children: @@ -3517,14 +3520,14 @@ var TOTPMFATheme = function (_a) { activeScreen === TOTPMFAScreens.DeviceSetup ? jsxRuntime.jsx( DeviceSetupHeader, - genericComponentOverrideContext.__assign({}, commonProps, { + superTokens.__assign({}, commonProps, { showBackButton: featureState.showBackButton, onBackButtonClicked: props.onBackButtonClicked, }) ) : jsxRuntime.jsx( CodeVerificationHeader, - genericComponentOverrideContext.__assign({}, commonProps, { + superTokens.__assign({}, commonProps, { showBackButton: featureState.showBackButton, onBackButtonClicked: props.onBackButtonClicked, }) @@ -3532,7 +3535,7 @@ var TOTPMFATheme = function (_a) { activeScreen === TOTPMFAScreens.DeviceSetup && jsxRuntime.jsx( DeviceInfoSection, - genericComponentOverrideContext.__assign({}, commonProps, { + superTokens.__assign({}, commonProps, { deviceInfo: featureState.deviceInfo, showSecret: featureState.showSecret, onShowSecretClicked: props.onShowSecretClicked, @@ -3544,25 +3547,21 @@ var TOTPMFATheme = function (_a) { }), jsxRuntime.jsx( CodeForm, - genericComponentOverrideContext.__assign({}, commonProps, { + superTokens.__assign({}, commonProps, { onSuccess: props.onSuccess, footer: activeScreen === TOTPMFAScreens.DeviceSetup ? jsxRuntime.jsx( DeviceSetupFooter, - genericComponentOverrideContext.__assign( - {}, - commonProps, - { onSignOutClicked: props.onSignOutClicked } - ) + superTokens.__assign({}, commonProps, { + onSignOutClicked: props.onSignOutClicked, + }) ) : jsxRuntime.jsx( CodeVerificationFooter, - genericComponentOverrideContext.__assign( - {}, - commonProps, - { onSignOutClicked: props.onSignOutClicked } - ) + superTokens.__assign({}, commonProps, { + onSignOutClicked: props.onSignOutClicked, + }) ), }) ), @@ -3578,7 +3577,7 @@ var TOTPMFATheme = function (_a) { ); }; function TOTPMFAThemeWrapper(props) { - var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeScreen = getActiveScreen(props); var activeStyle; @@ -3593,12 +3592,12 @@ function TOTPMFAThemeWrapper(props) { } return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - genericComponentOverrideContext.__assign( + superTokens.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, activeStyle], @@ -3606,7 +3605,7 @@ function TOTPMFAThemeWrapper(props) { { children: jsxRuntime.jsx( TOTPMFATheme, - genericComponentOverrideContext.__assign({}, props, { activeScreen: activeScreen }) + superTokens.__assign({}, props, { activeScreen: activeScreen }) ), } ) @@ -3642,38 +3641,33 @@ function getErrorString(error, state, t) { } var defaultTranslationsTOTP = { - en: genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, uiEntry.defaultTranslationsCommon.en), - { - TOTP_SHOW_SECRET_START: "Unable to scan? Use a", - TOTP_SHOW_SECRET_LINK: "secret key", - TOTP_SHOW_SECRET_END: "", - TOTP_CODE_VERIFICATION_HEADER_TITLE: "Enter TOTP", - TOTP_CODE_VERIFICATION_HEADER_SUBTITLE: - "Open the two-factor authenticator (TOTP) app on your mobile device to view your authentication code", - TOTP_DEVICE_SETUP_HEADER_TITLE: "Add a TOTP device", - TOTP_DEVICE_SETUP_HEADER_SUBTITLE: - "Please scan the given QR code from a phone app like Google Authenticator.", - TOTP_CODE_INPUT_LABEL: "Please enter TOTP", - TOTP_CODE_CONTINUE_BUTTON: "Continue", - TOTP_BLOCKED_TITLE: "Account locked", - TOTP_BLOCKED_SUBTITLE: "Account locked due to multiple failed login attempts.", - TOTP_MFA_BLOCKED_TIMER_START: "", - TOTP_MFA_BLOCKED_TIMER_END: "", - TOTP_MFA_BLOCKED_RETRY: "Try again", - TOTP_MFA_LOGOUT: "Logout", - ERROR_TOTP_INVALID_CODE: "Invalid TOTP. Please try again.", - ERROR_TOTP_INVALID_CODE_RETRY_START: "", - // \xA0 is non breaking space. - // We add it to make sure there is no line break between the number and the rest of the sentence - ERROR_TOTP_INVALID_CODE_RETRY_END: "\xA0attempt(s) remaining before account is temporarily locked.", - ERROR_TOTP_UNKNOWN_DEVICE: - "The device was deleted before verification. Please refresh the page to try again.", - GENERAL_ERROR_TOTP_NON_STRING: "TOTP code must be of type string", - GENERAL_ERROR_TOTP_EMPTY: "TOTP code cannot be empty", - GENERAL_ERROR_TOTP_UNDEFINED: "Please fill your TOTP code", - } - ), + en: superTokens.__assign(superTokens.__assign({}, uiEntry.defaultTranslationsCommon.en), { + TOTP_SHOW_SECRET_START: "Unable to scan? Use a", + TOTP_SHOW_SECRET_LINK: "secret key", + TOTP_SHOW_SECRET_END: "", + TOTP_CODE_VERIFICATION_HEADER_TITLE: "Enter TOTP", + TOTP_CODE_VERIFICATION_HEADER_SUBTITLE: + "Open the two-factor authenticator (TOTP) app on your mobile device to view your authentication code", + TOTP_DEVICE_SETUP_HEADER_TITLE: "Add a TOTP device", + TOTP_DEVICE_SETUP_HEADER_SUBTITLE: "Please scan the given QR code from a phone app like Google Authenticator.", + TOTP_CODE_INPUT_LABEL: "Please enter TOTP", + TOTP_CODE_CONTINUE_BUTTON: "Continue", + TOTP_BLOCKED_TITLE: "Account locked", + TOTP_BLOCKED_SUBTITLE: "Account locked due to multiple failed login attempts.", + TOTP_MFA_BLOCKED_TIMER_START: "", + TOTP_MFA_BLOCKED_TIMER_END: "", + TOTP_MFA_BLOCKED_RETRY: "Try again", + TOTP_MFA_LOGOUT: "Logout", + ERROR_TOTP_INVALID_CODE: "Invalid TOTP. Please try again.", + ERROR_TOTP_INVALID_CODE_RETRY_START: "", + // \xA0 is non breaking space. + // We add it to make sure there is no line break between the number and the rest of the sentence + ERROR_TOTP_INVALID_CODE_RETRY_END: "\xA0attempt(s) remaining before account is temporarily locked.", + ERROR_TOTP_UNKNOWN_DEVICE: "The device was deleted before verification. Please refresh the page to try again.", + GENERAL_ERROR_TOTP_NON_STRING: "TOTP code must be of type string", + GENERAL_ERROR_TOTP_EMPTY: "TOTP code cannot be empty", + GENERAL_ERROR_TOTP_UNDEFINED: "Please fill your TOTP code", + }), }; var useFeatureReducer = function () { @@ -3693,46 +3687,38 @@ var useFeatureReducer = function () { showSecret: false, }; case "setBlocked": - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, oldState), - { isBlocked: true, nextRetryAt: action.nextRetryAt, error: action.error } - ); + return superTokens.__assign(superTokens.__assign({}, oldState), { + isBlocked: true, + nextRetryAt: action.nextRetryAt, + error: action.error, + }); case "setError": - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, oldState), - { - loaded: true, - maxAttemptCount: - (_a = action.maxAttemptCount) !== null && _a !== void 0 ? _a : oldState.maxAttemptCount, - currAttemptCount: - (_b = action.currAttemptCount) !== null && _b !== void 0 - ? _b - : oldState.currAttemptCount, - showAccessDenied: action.showAccessDenied, - error: action.error, - } - ); + return superTokens.__assign(superTokens.__assign({}, oldState), { + loaded: true, + maxAttemptCount: + (_a = action.maxAttemptCount) !== null && _a !== void 0 ? _a : oldState.maxAttemptCount, + currAttemptCount: + (_b = action.currAttemptCount) !== null && _b !== void 0 ? _b : oldState.currAttemptCount, + showAccessDenied: action.showAccessDenied, + error: action.error, + }); case "createDevice": - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, oldState), - { - deviceInfo: action.deviceInfo, - isBlocked: false, - showSecret: false, - nextRetryAt: undefined, - error: undefined, - } - ); + return superTokens.__assign(superTokens.__assign({}, oldState), { + deviceInfo: action.deviceInfo, + isBlocked: false, + showSecret: false, + nextRetryAt: undefined, + error: undefined, + }); case "showSecret": - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, oldState), - { showSecret: true } - ); + return superTokens.__assign(superTokens.__assign({}, oldState), { showSecret: true }); case "restartFlow": - return genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, oldState), - { isBlocked: false, showSecret: false, nextRetryAt: undefined, error: action.error } - ); + return superTokens.__assign(superTokens.__assign({}, oldState), { + isBlocked: false, + showSecret: false, + nextRetryAt: undefined, + error: action.error, + }); default: return oldState; } @@ -3748,13 +3734,11 @@ var useFeatureReducer = function () { }, function (initArg) { var error = undefined; - var errorQueryParam = genericComponentOverrideContext.getQueryParams("error"); + var errorQueryParam = superTokens.getQueryParams("error"); if (errorQueryParam !== null) { error = "SOMETHING_WENT_WRONG_ERROR"; } - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, initArg), { - error: error, - }); + return superTokens.__assign(superTokens.__assign({}, initArg), { error: error }); } ); }; @@ -3762,8 +3746,8 @@ function useOnLoad(recipeImpl, dispatch, userContext) { var _this = this; var fetchMFAInfo = React__namespace.useCallback( function () { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { return [ 2 /*return*/, recipe$1.MultiFactorAuth.getInstanceOrThrow().webJSRecipe.resyncSessionAndFetchMFAInfo({ @@ -3783,14 +3767,14 @@ function useOnLoad(recipeImpl, dispatch, userContext) { ); var onLoad = React__namespace.useCallback( function (mfaInfo) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var error, errorQueryParam, doSetup, alreadySetup, showBackButton, deviceInfo, createResp; - return genericComponentOverrideContext.__generator(this, function (_b) { + return superTokens.__generator(this, function (_b) { switch (_b.label) { case 0: error = undefined; - errorQueryParam = genericComponentOverrideContext.getQueryParams("error"); - doSetup = genericComponentOverrideContext.getQueryParams("setup"); + errorQueryParam = superTokens.getQueryParams("error"); + doSetup = superTokens.getQueryParams("setup"); if (errorQueryParam !== null) { error = "SOMETHING_WENT_WRONG_ERROR"; } @@ -3837,7 +3821,7 @@ function useOnLoad(recipeImpl, dispatch, userContext) { }); return [2 /*return*/]; } - deviceInfo = genericComponentOverrideContext.__assign({}, createResp); + deviceInfo = superTokens.__assign({}, createResp); delete deviceInfo.status; _b.label = 5; case 5: @@ -3857,11 +3841,11 @@ function useOnLoad(recipeImpl, dispatch, userContext) { }, [dispatch, recipeImpl, userContext] ); - genericComponentOverrideContext.useOnMountAPICall(fetchMFAInfo, onLoad, handleLoadError); + superTokens.useOnMountAPICall(fetchMFAInfo, onLoad, handleLoadError); } function useChildProps(recipe, recipeImplementation, state, dispatch, userContext, navigate) { var _this = this; - var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var rethrowInRender = superTokens.useRethrowInRender(); return React.useMemo( function () { return { @@ -3869,8 +3853,8 @@ function useChildProps(recipe, recipeImplementation, state, dispatch, userContex dispatch({ type: "showSecret" }); }, onBackButtonClicked: function () { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: if (!state.deviceInfo) return [3 /*break*/, 2]; @@ -3908,8 +3892,8 @@ function useChildProps(recipe, recipeImplementation, state, dispatch, userContex dispatch({ type: "restartFlow", error: undefined }); }, onSignOutClicked: function () { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__awaiter(_this, void 0, void 0, function () { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: if (!state.deviceInfo) return [3 /*break*/, 2]; @@ -3942,7 +3926,7 @@ function useChildProps(recipe, recipeImplementation, state, dispatch, userContex }); }, onSuccess: function () { - var redirectToPath = genericComponentOverrideContext.getRedirectToPathFromURL(); + var redirectToPath = superTokens.getRedirectToPathFromURL(); return types.Session.getInstanceOrThrow() .validateGlobalClaimsAndHandleSuccessRedirection( undefined, @@ -3976,14 +3960,14 @@ var SignInUpFeature = function (props) { useOnLoad(recipeImplementation, dispatch, userContext); return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - genericComponentOverrideContext.__assign( + superTokens.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { - useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, + useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, defaultStore: defaultTranslationsTOTP, }, { @@ -3992,7 +3976,7 @@ var SignInUpFeature = function (props) { props.children === undefined && jsxRuntime.jsx( TOTPMFAThemeWrapper, - genericComponentOverrideContext.__assign({}, childProps, { + superTokens.__assign({}, childProps, { featureState: state, dispatch: dispatch, }) @@ -4002,10 +3986,10 @@ var SignInUpFeature = function (props) { if (React__namespace.isValidElement(child)) { return React__namespace.cloneElement( child, - genericComponentOverrideContext.__assign( - genericComponentOverrideContext.__assign({}, childProps), - { featureState: state, dispatch: dispatch } - ) + superTokens.__assign(superTokens.__assign({}, childProps), { + featureState: state, + dispatch: dispatch, + }) ); } return child; @@ -4021,18 +4005,18 @@ var SignInUpFeature = function (props) { }; function getModifiedRecipeImplementation(originalImpl, dispatch) { var _this = this; - return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImpl), { + return superTokens.__assign(superTokens.__assign({}, originalImpl), { createDevice: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var res, deviceInfo; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.createDevice(input)]; case 1: res = _a.sent(); if (res.status === "OK") { - deviceInfo = genericComponentOverrideContext.__assign({}, res); + deviceInfo = superTokens.__assign({}, res); delete deviceInfo.status; dispatch({ type: "createDevice", deviceInfo: deviceInfo }); } @@ -4042,9 +4026,9 @@ function getModifiedRecipeImplementation(originalImpl, dispatch) { }); }, verifyCode: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var res; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.verifyCode(input)]; @@ -4071,9 +4055,9 @@ function getModifiedRecipeImplementation(originalImpl, dispatch) { }); }, verifyDevice: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var res; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.verifyDevice(input)]; @@ -4106,9 +4090,9 @@ function getModifiedRecipeImplementation(originalImpl, dispatch) { }); }, removeDevice: function (input) { - return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return superTokens.__awaiter(_this, void 0, void 0, function () { var res; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.removeDevice(input)]; @@ -4140,7 +4124,7 @@ function getModifiedRecipeImplementation(originalImpl, dispatch) { var DEFAULT_TOTP_PATH = "/mfa/totp"; var TOTPPreBuiltUI = /** @class */ (function (_super) { - genericComponentOverrideContext.__extends(TOTPPreBuiltUI, _super); + superTokens.__extends(TOTPPreBuiltUI, _super); function TOTPPreBuiltUI(recipeInstance) { var _this = _super.call(this) || this; _this.recipeInstance = recipeInstance; @@ -4156,9 +4140,7 @@ var TOTPPreBuiltUI = /** @class */ (function (_super) { new NormalisedURLPath__default.default(DEFAULT_TOTP_PATH) ); features[normalisedFullPath.getAsStringDangerous()] = { - matches: genericComponentOverrideContext.matchRecipeIdUsingQueryParams( - _this.recipeInstance.config.recipeId - ), + matches: superTokens.matchRecipeIdUsingQueryParams(_this.recipeInstance.config.recipeId), component: function (props) { return _this.getFeatureComponent("mfaTOTP", props, useComponentOverrides); }, @@ -4178,12 +4160,12 @@ var TOTPPreBuiltUI = /** @class */ (function (_super) { } return jsxRuntime.jsx( uiEntry.UserContextWrapper, - genericComponentOverrideContext.__assign( + superTokens.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( session.SessionAuth, - genericComponentOverrideContext.__assign( + superTokens.__assign( { overrideGlobalClaimValidators: function () { return []; @@ -4192,7 +4174,7 @@ var TOTPPreBuiltUI = /** @class */ (function (_super) { { children: jsxRuntime.jsx( SignInUpFeature, - genericComponentOverrideContext.__assign( + superTokens.__assign( { recipe: _this.recipeInstance, useComponentOverrides: useComponentOverrides, @@ -4238,7 +4220,7 @@ var TOTPPreBuiltUI = /** @class */ (function (_super) { }; // For tests TOTPPreBuiltUI.reset = function () { - if (!genericComponentOverrideContext.isTest()) { + if (!superTokens.isTest()) { return; } TOTPPreBuiltUI.instance = undefined; diff --git a/lib/build/translation/translations.d.ts b/lib/build/translation/translations.d.ts index ea5e1261c..24274f854 100644 --- a/lib/build/translation/translations.d.ts +++ b/lib/build/translation/translations.d.ts @@ -3,6 +3,7 @@ export declare const defaultTranslationsCommon: { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: string; AUTH_PAGE_HEADER_TITLE_SIGN_IN: string; AUTH_PAGE_HEADER_TITLE_SIGN_UP: string; + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: string; AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_END: string; diff --git a/lib/build/translationContext.js b/lib/build/translationContext.js index f74c9f995..01ccda532 100644 --- a/lib/build/translationContext.js +++ b/lib/build/translationContext.js @@ -1,6 +1,6 @@ "use strict"; -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var superTokens = require("./superTokens.js"); var jsxRuntime = require("react/jsx-runtime"); var React = require("react"); @@ -34,12 +34,12 @@ var TranslationContextProvider = function (_a) { React.useEffect( function () { function loadLanguageFromCookies() { - return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return superTokens.__awaiter(this, void 0, void 0, function () { var cookieLang, cookieLangTemp; - return genericComponentOverrideContext.__generator(this, function (_a) { + return superTokens.__generator(this, function (_a) { switch (_a.label) { case 0: - return [4 /*yield*/, genericComponentOverrideContext.getCurrentLanguageFromCookie()]; + return [4 /*yield*/, superTokens.getCurrentLanguageFromCookie()]; case 1: cookieLang = _a.sent(); cookieLangTemp = cookieLang === null ? defaultLanguage : cookieLang; @@ -70,7 +70,7 @@ var TranslationContextProvider = function (_a) { // eslint-disable-next-line @typescript-eslint/no-unused-vars var loadHandler = function (_eventName, detail) { setTranslationStore(function (os) { - return genericComponentOverrideContext.mergeObjects(os, detail); + return superTokens.mergeObjects(os, detail); }); }; translationControlEventSource.on("LanguageChange", changeHandler); @@ -105,7 +105,7 @@ var TranslationContextProvider = function (_a) { } return jsxRuntime.jsx( TranslationContext.Provider, - genericComponentOverrideContext.__assign({ value: { translate: translateFunc } }, { children: children }) + superTokens.__assign({ value: { translate: translateFunc } }, { children: children }) ); }; diff --git a/lib/build/types.d.ts b/lib/build/types.d.ts index 07706a714..d4a235220 100644 --- a/lib/build/types.d.ts +++ b/lib/build/types.d.ts @@ -1,4 +1,5 @@ import type { DateProviderInput } from "./dateProvider/types"; +import type { AuthSuccessContext } from "./recipe/authRecipe/types"; import type { BaseRecipeModule } from "./recipe/recipeModule/baseRecipeModule"; import type { NormalisedConfig as NormalisedRecipeModuleConfig } from "./recipe/recipeModule/types"; import type { TranslationFunc, TranslationStore } from "./translation/translationHelpers"; @@ -9,7 +10,7 @@ import type { CookieHandlerInput } from "supertokens-web-js/utils/cookieHandler/ import type NormalisedURLDomain from "supertokens-web-js/utils/normalisedURLDomain"; import type NormalisedURLPath from "supertokens-web-js/utils/normalisedURLPath"; import type { WindowHandlerInput } from "supertokens-web-js/utils/windowHandler/types"; -export declare type SuccessRedirectContext = { +declare type SuccessRedirectContextCommon = { recipeId: | "emailpassword" | "thirdparty" @@ -18,18 +19,25 @@ export declare type SuccessRedirectContext = { | "thirdpartyemailpassword" | "emailverification" | "totp"; - action: "SUCCESS"; isNewRecipeUser: boolean; createdNewUser: boolean; newSessionCreated: boolean; +}; +export declare type SuccessRedirectContextInApp = SuccessRedirectContextCommon & { + action: "SUCCESS"; redirectToPath?: string; }; +export declare type SuccessRedirectContextOAuth2 = SuccessRedirectContextCommon & { + action: "SUCCESS_OAUTH2"; + loginChallenge: string; +}; +export declare type SuccessRedirectContext = SuccessRedirectContextInApp | SuccessRedirectContextOAuth2; export declare type GetRedirectionURLContext = | { action: "TO_AUTH"; showSignIn?: boolean; } - | SuccessRedirectContext; + | SuccessRedirectContextInApp; export declare type ValidationFailureCallback = | (({ userContext, @@ -184,6 +192,7 @@ export declare type UserContext = Record; export declare type AuthComponentProps = { setFactorList: (factorIds: string[]) => void; rebuildAuthPage: () => void; + onAuthSuccess: (successContext: AuthSuccessContext) => Promise; navigate: Navigate | undefined; userContext: UserContext; error: string | undefined; diff --git a/lib/build/ui-entry.js b/lib/build/ui-entry.js index 52083a79c..e25d17705 100644 --- a/lib/build/ui-entry.js +++ b/lib/build/ui-entry.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -require("./genericComponentOverrideContext.js"); +require("./superTokens.js"); require("react/jsx-runtime"); require("react"); var uiEntry = require("./index2.js"); @@ -17,12 +17,15 @@ require("supertokens-web-js/utils/normalisedURLPath"); require("./translationContext.js"); require("react-dom"); require("./multitenancy-shared.js"); +require("./genericComponentOverrideContext.js"); require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); require("./multifactorauth-shared.js"); require("supertokens-web-js/recipe/session"); +require("./oauth2-shared.js"); +require("supertokens-web-js/recipe/oauth2"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); diff --git a/lib/build/ui/index.d.ts b/lib/build/ui/index.d.ts index 3f69b71fd..bcd8d6aec 100644 --- a/lib/build/ui/index.d.ts +++ b/lib/build/ui/index.d.ts @@ -41,6 +41,7 @@ declare class UI { onSignInUpSwitcherClick: (() => void) | undefined; resetFactorList: () => void; showBackButton: boolean; + clientAppName?: string | undefined; }>; static AuthPageComponentList: React.ComponentType; static AuthRecipeComponentsOverrideContextProvider: React.FC< diff --git a/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx b/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx index 31c403458..182c84b1f 100644 --- a/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx +++ b/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx @@ -31,6 +31,7 @@ import { FactorIds } from "../../../../multifactorauth/types"; import DynamicLoginMethodsSpinner from "../../../../multitenancy/components/features/dynamicLoginMethodsSpinner"; import { DynamicLoginMethodsProvider } from "../../../../multitenancy/dynamicLoginMethodsContext"; import Multitenancy from "../../../../multitenancy/recipe"; +import OAuth2 from "../../../../oauth2/recipe"; import Session from "../../../../session/recipe"; import SessionAuthWrapper from "../../../../session/sessionAuth"; import useSessionContext from "../../../../session/useSessionContext"; @@ -43,8 +44,9 @@ import type { TranslationStore } from "../../../../../translation/translationHel import type { AuthComponent, Navigate, PartialAuthComponent, UserContext } from "../../../../../types"; import type { GetLoginMethodsResponseNormalized } from "../../../../multitenancy/types"; import type { RecipeRouter } from "../../../../recipeRouter"; -import type { AuthPageThemeProps } from "../../../types"; +import type { AuthPageThemeProps, AuthSuccessContext } from "../../../types"; import type { PropsWithChildren } from "react"; +import type { LoginInfo } from "supertokens-web-js/recipe/oauth2/types"; const errorQSMap: Record = { signin: "SOMETHING_WENT_WRONG_ERROR", @@ -102,6 +104,7 @@ const AuthPageInner: React.FC = (props) => { const showStringFromQSRef = useRef(showStringFromQS); const errorFromQSRef = useRef(errorFromQS); + const loginChallenge = search.get("loginChallenge"); const sessionContext = useSessionContext(); const userContext = useUserContext(); @@ -110,6 +113,7 @@ const AuthPageInner: React.FC = (props) => { const [loadedDynamicLoginMethods, setLoadedDynamicLoginMethods] = useState< GetLoginMethodsResponseNormalized | undefined >(undefined); + const [oauth2ClientInfo, setOAuth2ClientInfo] = useState(undefined); const [error, setError] = useState(errorFromQS); const [sessionLoadedAndNotRedirecting, setSessionLoadedAndNotRedirecting] = useState(false); const st = SuperTokens.getInstanceOrThrow(); @@ -163,6 +167,18 @@ const AuthPageInner: React.FC = (props) => { ); }, [loadedDynamicLoginMethods, setLoadedDynamicLoginMethods]); + useEffect(() => { + if (oauth2ClientInfo) { + return; + } + const oauth2Recipe = OAuth2.getInstance(); + if (oauth2Recipe !== undefined && loginChallenge !== null) { + void OAuth2.getInstanceOrThrow() + .webJSRecipe.getLoginChallengeInfo({ loginChallenge, userContext }) + .then(({ info }) => setOAuth2ClientInfo(info)); + } + }, [setOAuth2ClientInfo, loginChallenge, oauth2ClientInfo]); + useEffect(() => { if (sessionLoadedAndNotRedirecting) { return; @@ -179,15 +195,34 @@ const AuthPageInner: React.FC = (props) => { Session.getInstanceOrThrow().config.onHandleEvent({ action: "SESSION_ALREADY_EXISTS", }); - void Session.getInstanceOrThrow() - .validateGlobalClaimsAndHandleSuccessRedirection( - undefined, - Session.RECIPE_ID, // TODO - getRedirectToPathFromURL(), - userContext, - props.navigate - ) - .catch(rethrowInRender); + if (loginChallenge !== null) { + void Session.getInstanceOrThrow() + .validateGlobalClaimsAndHandleSuccessRedirection( + { + action: "SUCCESS_OAUTH2", + createdNewUser: false, + isNewRecipeUser: false, + loginChallenge, + newSessionCreated: false, + recipeId: Session.RECIPE_ID, + }, + Session.RECIPE_ID, + getRedirectToPathFromURL(), + userContext, + props.navigate + ) + .catch(rethrowInRender); + } else { + void Session.getInstanceOrThrow() + .validateGlobalClaimsAndHandleSuccessRedirection( + undefined, + Session.RECIPE_ID, + getRedirectToPathFromURL(), + userContext, + props.navigate + ) + .catch(rethrowInRender); + } } else { setSessionLoadedAndNotRedirecting(true); } @@ -247,10 +282,34 @@ const AuthPageInner: React.FC = (props) => { rethrowInRender, ]); + const onAuthSuccess = useCallback( + (ctx: AuthSuccessContext) => { + return Session.getInstanceOrThrow().validateGlobalClaimsAndHandleSuccessRedirection( + loginChallenge !== null + ? { + ...ctx, + action: "SUCCESS_OAUTH2", + loginChallenge, + } + : { + ...ctx, + action: "SUCCESS", + redirectToPath: getRedirectToPathFromURL(), + }, + ctx.recipeId, + getRedirectToPathFromURL(), + userContext + ); + }, + [loginChallenge] + ); + const childProps: AuthPageThemeProps | undefined = - authComponentListInfo !== undefined + authComponentListInfo !== undefined && (loginChallenge === null || oauth2ClientInfo !== undefined) ? { ...authComponentListInfo, + clientAppName: oauth2ClientInfo?.clientName, + onAuthSuccess, error, onError: (err) => { setError(err); diff --git a/lib/ts/recipe/authRecipe/components/theme/authPage/authPageHeader.tsx b/lib/ts/recipe/authRecipe/components/theme/authPage/authPageHeader.tsx index 40c4cb375..724defeef 100644 --- a/lib/ts/recipe/authRecipe/components/theme/authPage/authPageHeader.tsx +++ b/lib/ts/recipe/authRecipe/components/theme/authPage/authPageHeader.tsx @@ -26,6 +26,7 @@ export const AuthPageHeader = withOverride( isSignUp, showBackButton, resetFactorList, + clientAppName, }: { factorIds: string[]; isSignUp: boolean; @@ -33,6 +34,7 @@ export const AuthPageHeader = withOverride( onSignInUpSwitcherClick: (() => void) | undefined; resetFactorList: () => void; showBackButton: boolean; + clientAppName?: string; }): JSX.Element { const t = useTranslation(); @@ -51,6 +53,7 @@ export const AuthPageHeader = withOverride( : isSignUp ? t("AUTH_PAGE_HEADER_TITLE_SIGN_UP") : t("AUTH_PAGE_HEADER_TITLE_SIGN_IN")} + {clientAppName && `${t("AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP")}${t(clientAppName)}`} {/* empty span for spacing the back button */} diff --git a/lib/ts/recipe/authRecipe/components/theme/authPage/index.tsx b/lib/ts/recipe/authRecipe/components/theme/authPage/index.tsx index 7d38b3641..b5d3fa9b4 100644 --- a/lib/ts/recipe/authRecipe/components/theme/authPage/index.tsx +++ b/lib/ts/recipe/authRecipe/components/theme/authPage/index.tsx @@ -51,6 +51,7 @@ export function AuthPageTheme(props: AuthPageThemeProps): JSX.Element { hasSeparateSignUpView={props.hasSeparateSignUpView} resetFactorList={props.resetFactorList} showBackButton={props.showBackButton} + clientAppName={props.clientAppName} /> {props.error !== undefined && } diff --git a/lib/ts/recipe/authRecipe/types.ts b/lib/ts/recipe/authRecipe/types.ts index 92c47fcc5..19847895a 100644 --- a/lib/ts/recipe/authRecipe/types.ts +++ b/lib/ts/recipe/authRecipe/types.ts @@ -17,7 +17,13 @@ import type { AuthPageComponentList } from "./components/theme/authPage/authPage import type { AuthPageFooter } from "./components/theme/authPage/authPageFooter"; import type { AuthPageHeader } from "./components/theme/authPage/authPageHeader"; import type { ComponentOverride } from "../../components/componentOverride/componentOverride"; -import type { AuthComponentProps, Navigate, PartialAuthComponentProps, UserContext } from "../../types"; +import type { + AuthComponentProps, + Navigate, + PartialAuthComponentProps, + SuccessRedirectContext, + UserContext, +} from "../../types"; import type { Config as RecipeModuleConfig, NormalisedConfig as NormalisedRecipeModuleConfig, @@ -47,7 +53,15 @@ type ComponentWithPreloadInfo = { preloadInfo: T; }; +export type AuthSuccessContext = Omit< + SuccessRedirectContext, + "redirectToPath" | "action" | "loginChallenge" | "recipeId" +> & { recipeId: string }; + export type AuthPageThemeProps = { + clientAppName: string | undefined; + onAuthSuccess: (successContext: AuthSuccessContext) => Promise; + showBackButton: boolean; setFactorList: (factorIds: string[]) => void; resetFactorList: () => void; diff --git a/lib/ts/recipe/emailpassword/components/features/signin/index.tsx b/lib/ts/recipe/emailpassword/components/features/signin/index.tsx index 7aa06621b..0ffe5ab2d 100644 --- a/lib/ts/recipe/emailpassword/components/features/signin/index.tsx +++ b/lib/ts/recipe/emailpassword/components/features/signin/index.tsx @@ -23,16 +23,18 @@ import { useCallback } from "react"; import AuthComponentWrapper from "../../../../../components/authCompWrapper"; import { useTranslation } from "../../../../../translation/translationContext"; -import { getRedirectToPathFromURL, useRethrowInRender } from "../../../../../utils"; +import { useRethrowInRender } from "../../../../../utils"; import { EmailVerificationClaim } from "../../../../emailverification"; import EmailVerification from "../../../../emailverification/recipe"; import { getInvalidClaimsFromResponse } from "../../../../session"; import Session from "../../../../session/recipe"; import useSessionContext from "../../../../session/useSessionContext"; +import EmailPassword from "../../../recipe"; import { Label } from "../../library"; import SignInTheme from "../../themes/signIn"; import type { Navigate, UserContext, PartialAuthComponentProps } from "../../../../../types"; +import type { AuthSuccessContext } from "../../../../authRecipe/types"; import type Recipe from "../../../recipe"; import type { SignInThemeProps } from "../../../types"; import type { ComponentOverrideMap } from "../../../types"; @@ -40,6 +42,7 @@ import type { RecipeInterface } from "supertokens-web-js/recipe/emailpassword"; export function useChildProps( recipe: Recipe, + onAuthSuccess: (successContext: AuthSuccessContext) => Promise, error: string | undefined, onError: (err: string) => void, clearError: () => void, @@ -61,25 +64,16 @@ export function useChildProps( payloadAfterCall = undefined; } - return Session.getInstanceOrThrow() - .validateGlobalClaimsAndHandleSuccessRedirection( - { - action: "SUCCESS", - createdNewUser: false, - isNewRecipeUser: false, - newSessionCreated: - session.loading || - !session.doesSessionExist || - (payloadAfterCall !== undefined && - session.accessTokenPayload.sessionHandle !== payloadAfterCall.sessionHandle), - recipeId: recipe!.recipeID, - }, - recipe!.recipeID, - getRedirectToPathFromURL(), - userContext, - navigate - ) - .catch(rethrowInRender); + return onAuthSuccess({ + createdNewUser: false, + isNewRecipeUser: false, + newSessionCreated: + session.loading || + !session.doesSessionExist || + (payloadAfterCall !== undefined && + session.accessTokenPayload.sessionHandle !== payloadAfterCall.sessionHandle), + recipeId: EmailPassword.RECIPE_ID, + }).catch(rethrowInRender); }, [recipe, userContext, navigate]); return useMemo(() => { @@ -153,6 +147,7 @@ export const SignInFeature: React.FC< > = (props) => { const childProps = useChildProps( props.recipe, + props.onAuthSuccess, props.error, props.onError, props.clearError, diff --git a/lib/ts/recipe/emailpassword/components/features/signup/index.tsx b/lib/ts/recipe/emailpassword/components/features/signup/index.tsx index 1bb3f7653..24b2e5152 100644 --- a/lib/ts/recipe/emailpassword/components/features/signup/index.tsx +++ b/lib/ts/recipe/emailpassword/components/features/signup/index.tsx @@ -24,7 +24,7 @@ import STGeneralError from "supertokens-web-js/utils/error"; import AuthComponentWrapper from "../../../../../components/authCompWrapper"; import { useUserContext } from "../../../../../usercontext"; -import { getRedirectToPathFromURL, useRethrowInRender } from "../../../../../utils"; +import { useRethrowInRender } from "../../../../../utils"; import { EmailVerificationClaim } from "../../../../emailverification"; import EmailVerification from "../../../../emailverification/recipe"; import { getInvalidClaimsFromResponse } from "../../../../session"; @@ -33,6 +33,7 @@ import useSessionContext from "../../../../session/useSessionContext"; import SignUpTheme from "../../themes/signUp"; import type { Navigate, NormalisedFormField, UserContext, PartialAuthComponentProps } from "../../../../../types"; +import type { AuthSuccessContext } from "../../../../authRecipe/types"; import type Recipe from "../../../recipe"; import type { SignUpThemeProps } from "../../../types"; import type { ComponentOverrideMap, FormFieldThemeProps } from "../../../types"; @@ -41,6 +42,7 @@ import type { User } from "supertokens-web-js/types"; export function useChildProps( recipe: Recipe, + onAuthSuccess: (successContext: AuthSuccessContext) => Promise, error: string | undefined, onError: (err: string) => void, clearError: () => void, @@ -61,25 +63,16 @@ export function useChildProps( } catch { payloadAfterCall = undefined; } - return Session.getInstanceOrThrow() - .validateGlobalClaimsAndHandleSuccessRedirection( - { - action: "SUCCESS", - createdNewUser: result.user.loginMethods.length === 1, - isNewRecipeUser: true, - newSessionCreated: - session.loading || - !session.doesSessionExist || - (payloadAfterCall !== undefined && - session.accessTokenPayload.sessionHandle !== payloadAfterCall.sessionHandle), - recipeId: recipe!.recipeID, - }, - recipe!.recipeID, - getRedirectToPathFromURL(), - userContext, - navigate - ) - .catch(rethrowInRender); + return onAuthSuccess({ + createdNewUser: result.user.loginMethods.length === 1, + isNewRecipeUser: true, + newSessionCreated: + session.loading || + !session.doesSessionExist || + (payloadAfterCall !== undefined && + session.accessTokenPayload.sessionHandle !== payloadAfterCall.sessionHandle), + recipeId: recipe!.recipeID, + }).catch(rethrowInRender); }, [recipe, userContext, navigate] ); @@ -138,6 +131,7 @@ export const SignUpFeature: React.FC< } const childProps = useChildProps( props.recipe, + props.onAuthSuccess, props.error, props.onError, props.clearError, diff --git a/lib/ts/recipe/emailpassword/recipe.tsx b/lib/ts/recipe/emailpassword/recipe.tsx index e0f05a2ad..da00eb696 100644 --- a/lib/ts/recipe/emailpassword/recipe.tsx +++ b/lib/ts/recipe/emailpassword/recipe.tsx @@ -50,7 +50,7 @@ export default class EmailPassword extends AuthRecipe< NormalisedConfig > { static instance?: EmailPassword; - static RECIPE_ID = "emailpassword"; + static RECIPE_ID = "emailpassword" as const; recipeID = EmailPassword.RECIPE_ID; firstFactorIds = [FactorIds.EMAILPASSWORD]; @@ -63,7 +63,6 @@ export default class EmailPassword extends AuthRecipe< public readonly webJSRecipe: WebJSRecipeInterface = EmailPasswordWebJS ) { super(config); - this.recipeID = config.recipeId; } getDefaultRedirectionURL = async (context: GetRedirectionURLContext): Promise => { diff --git a/lib/ts/recipe/oauth2/componentOverrideContext.tsx b/lib/ts/recipe/oauth2/componentOverrideContext.tsx deleted file mode 100644 index 467bd5485..000000000 --- a/lib/ts/recipe/oauth2/componentOverrideContext.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { createGenericComponentsOverrideContext } from "../../components/componentOverride/genericComponentOverrideContext"; - -import type { ComponentOverrideMap } from "./types"; - -const [useContext, Provider] = createGenericComponentsOverrideContext(); - -export { useContext as useRecipeComponentOverrideContext, Provider as RecipeComponentsOverrideContextProvider }; diff --git a/lib/ts/recipe/oauth2/components/themes/resumePageSpinner/index.tsx b/lib/ts/recipe/oauth2/components/themes/resumePageSpinner/index.tsx deleted file mode 100644 index 8c51c8cab..000000000 --- a/lib/ts/recipe/oauth2/components/themes/resumePageSpinner/index.tsx +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. - * - * This software is licensed under the Apache License, Version 2.0 (the - * "License") as published by the Apache Software Foundation. - * - * You may not use this file except in compliance with the License. You may - * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -import SpinnerIcon from "../../../../../components/assets/spinnerIcon"; -import { withOverride } from "../../../../../components/componentOverride/withOverride"; -import SuperTokens from "../../../../../superTokens"; -import { ThemeBase } from "../themeBase"; - -import type { NormalisedConfig } from "../../../types"; - -// TODO: This is just a placeholder to make the pre-commit script happy. I'm not sure we'll need this. -const OAuth2ResumePageSpinner: React.FC = () => { - return ( -
-
-
- -
-
-
- ); -}; - -const ResumePageSpinnerWithOverride = withOverride("OAuth2ResumePageSpinner", OAuth2ResumePageSpinner); - -export const ResumePageSpinner = (props: { config: NormalisedConfig }) => { - const rootStyle = SuperTokens.getInstanceOrThrow().rootStyle; - - return ( - - - - ); -}; diff --git a/lib/ts/recipe/oauth2/components/themes/styles.css b/lib/ts/recipe/oauth2/components/themes/styles.css deleted file mode 100644 index 48b21284b..000000000 --- a/lib/ts/recipe/oauth2/components/themes/styles.css +++ /dev/null @@ -1 +0,0 @@ -@import "../../../../styles/styles.css"; diff --git a/lib/ts/recipe/oauth2/components/themes/themeBase.tsx b/lib/ts/recipe/oauth2/components/themes/themeBase.tsx deleted file mode 100644 index 4dc8cad23..000000000 --- a/lib/ts/recipe/oauth2/components/themes/themeBase.tsx +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. - * - * This software is licensed under the Apache License, Version 2.0 (the - * "License") as published by the Apache Software Foundation. - * - * You may not use this file except in compliance with the License. You may - * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -import React from "react"; -import { Fragment } from "react"; - -import styles from "./styles.css"; - -import type { PropsWithChildren } from "react"; - -export const ThemeBase: React.FC< - PropsWithChildren<{ loadDefaultFont: boolean; userStyles: Array }> -> = ({ children, userStyles, loadDefaultFont }) => { - return ( - - {children} - {loadDefaultFont && ( - - )} - - - ); -}; diff --git a/lib/ts/recipe/oauth2/components/themes/translations.ts b/lib/ts/recipe/oauth2/components/themes/translations.ts deleted file mode 100644 index 6f7b1f5d1..000000000 --- a/lib/ts/recipe/oauth2/components/themes/translations.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { defaultTranslationsCommon } from "../../../../translation/translations"; - -export const defaultTranslationsOAuth2 = { - en: { - ...defaultTranslationsCommon.en, - }, -}; diff --git a/lib/ts/recipe/oauth2/index.ts b/lib/ts/recipe/oauth2/index.ts index 5b041af00..728dba6b8 100644 --- a/lib/ts/recipe/oauth2/index.ts +++ b/lib/ts/recipe/oauth2/index.ts @@ -1,4 +1,4 @@ -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. * * This software is licensed under the Apache License, Version 2.0 (the * "License") as published by the Apache Software Foundation. @@ -13,21 +13,51 @@ * under the License. */ -import { RecipeComponentsOverrideContextProvider } from "./componentOverrideContext"; import OAuth2 from "./recipe"; -import { UserInput } from "./types"; +import { UserInput, GetRedirectionURLContext, PreAPIHookContext, OnHandleEventContext } from "./types"; +import type { RecipeFunctionOptions, LoginInfo } from "supertokens-web-js/recipe/oauth2"; import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2"; export default class Wrapper { static init(config?: UserInput) { return OAuth2.init(config); } - - static ComponentsOverrideProvider = RecipeComponentsOverrideContextProvider; + /** + * Returns information about an OAuth login in progress + * + * @param loginChallenge The login challenge from the url + * + * @param userContext (OPTIONAL) Refer to {@link https://supertokens.com/docs/emailpassword/advanced-customizations/user-context the documentation} + * + * @param options (OPTIONAL) Use this to configure additional properties (for example pre api hooks) + * + * @returns `{status: "OK", info: LoginInfo}` + * + * @throws STGeneralError if the API exposed by the backend SDKs returns `status: "GENERAL_ERROR"` + */ + static getLoginChallengeInfo(input: { + loginChallenge: string; + options?: RecipeFunctionOptions; + userContext?: any; + }): Promise<{ + status: "OK"; + info: LoginInfo; + fetchResponse: Response; + }> { + return OAuth2.getInstanceOrThrow().webJSRecipe.getLoginChallengeInfo(input); + } } const init = Wrapper.init; -const MultitenancyComponentsOverrideProvider = Wrapper.ComponentsOverrideProvider; +const getLoginChallengeInfo = Wrapper.getLoginChallengeInfo; -export { init, UserInput, RecipeInterface, MultitenancyComponentsOverrideProvider }; +export { + init, + getLoginChallengeInfo, + GetRedirectionURLContext, + PreAPIHookContext, + OnHandleEventContext, + UserInput, + RecipeInterface, +}; diff --git a/lib/ts/recipe/oauth2/prebuiltui.tsx b/lib/ts/recipe/oauth2/prebuiltui.tsx deleted file mode 100644 index 95d111c2e..000000000 --- a/lib/ts/recipe/oauth2/prebuiltui.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import { isTest } from "../../utils"; -import { RecipeRouter } from "../recipeRouter"; - -import { useRecipeComponentOverrideContext } from "./componentOverrideContext"; -import { ResumePageSpinner } from "./components/themes/resumePageSpinner"; -import { defaultTranslationsOAuth2 } from "./components/themes/translations"; -import OAuth2 from "./recipe"; - -import type { GenericComponentOverrideMap } from "../../components/componentOverride/componentOverrideContext"; -import type { RecipeFeatureComponentMap, FeatureBaseProps, UserContext } from "../../types"; -import type { AuthComponent } from "../../types"; - -export class OAuth2PreBuiltUI extends RecipeRouter { - static instance?: OAuth2PreBuiltUI; - - languageTranslations = defaultTranslationsOAuth2; - - constructor(public readonly recipeInstance: OAuth2) { - super(); - } - - // Static methods - static getInstanceOrInitAndGetInstance(): OAuth2PreBuiltUI { - if (OAuth2PreBuiltUI.instance === undefined) { - const recipeInstance = OAuth2.getInstanceOrThrow(); - OAuth2PreBuiltUI.instance = new OAuth2PreBuiltUI(recipeInstance); - } - - return OAuth2PreBuiltUI.instance; - } - static getFeatures( - useComponentOverrides: () => GenericComponentOverrideMap = useRecipeComponentOverrideContext - ): RecipeFeatureComponentMap { - return OAuth2PreBuiltUI.getInstanceOrInitAndGetInstance().getFeatures(useComponentOverrides); - } - static getFeatureComponent( - componentName: never, - props: FeatureBaseProps<{ redirectOnSessionExists?: boolean; userContext?: UserContext }>, - useComponentOverrides: () => GenericComponentOverrideMap = useRecipeComponentOverrideContext - ): JSX.Element { - return OAuth2PreBuiltUI.getInstanceOrInitAndGetInstance().getFeatureComponent( - componentName, - props, - useComponentOverrides - ); - } - - // Instance methods - getFeatures = ( - _useComponentOverrides: () => GenericComponentOverrideMap = useRecipeComponentOverrideContext - ): RecipeFeatureComponentMap => { - const features: RecipeFeatureComponentMap = {}; - - return features; - }; - getFeatureComponent = ( - _componentName: never, - _props: FeatureBaseProps<{ redirectOnSessionExists?: boolean; userContext?: UserContext }>, - _useComponentOverrides: () => GenericComponentOverrideMap = useRecipeComponentOverrideContext - ): JSX.Element => { - throw new Error("Not implemented."); - }; - - getAuthComponents(): AuthComponent[] { - return []; - } - - // For tests - static reset(): void { - if (!isTest()) { - return; - } - - OAuth2PreBuiltUI.instance = undefined; - return; - } - - static ResumePageSpinnerTheme = ResumePageSpinner; -} - -export { ResumePageSpinner as ResumePageSpinnerTheme }; diff --git a/lib/ts/recipe/oauth2/recipe.ts b/lib/ts/recipe/oauth2/recipe.ts index 0854dedfa..4638fc315 100644 --- a/lib/ts/recipe/oauth2/recipe.ts +++ b/lib/ts/recipe/oauth2/recipe.ts @@ -1,4 +1,4 @@ -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. * * This software is licensed under the Apache License, Version 2.0 (the * "License") as published by the Apache Software Foundation. @@ -32,7 +32,12 @@ import type { PreAndPostAPIHookAction, UserInput, } from "./types"; -import type { RecipeInitResult, NormalisedConfigWithAppInfoAndRecipeID, WebJSRecipeInterface } from "../../types"; +import type { + RecipeInitResult, + NormalisedConfigWithAppInfoAndRecipeID, + WebJSRecipeInterface, + SuccessRedirectContextOAuth2, +} from "../../types"; import type { NormalisedAppInfo } from "../../types"; /* @@ -45,7 +50,7 @@ export default class OAuth2 extends RecipeModule< NormalisedConfig > { static instance?: OAuth2; - static readonly RECIPE_ID = "multitenancy"; + static readonly RECIPE_ID = "oauth2"; public readonly recipeID = OAuth2.RECIPE_ID; @@ -97,6 +102,21 @@ export default class OAuth2 extends RecipeModule< return OAuth2.instance; } + static getInstance(): OAuth2 | undefined { + return OAuth2.instance; + } + + async getDefaultRedirectionURL(ctx: SuccessRedirectContextOAuth2): Promise { + if (ctx.action === "SUCCESS_OAUTH2") { + const domain = this.config.appInfo.apiDomain.getAsStringDangerous(); + const basePath = this.config.appInfo.apiBasePath.getAsStringDangerous(); + + return `${domain}${basePath}/oauth2/login?loginChallenge=${ctx.loginChallenge}`; + } else { + throw new Error("Should never come here: unknown action in OAuth2.getDefaultRedirectionURL"); + } + } + /* * Tests methods. */ diff --git a/lib/ts/recipe/oauth2/types.ts b/lib/ts/recipe/oauth2/types.ts index dd10e8cd7..ce076d31a 100644 --- a/lib/ts/recipe/oauth2/types.ts +++ b/lib/ts/recipe/oauth2/types.ts @@ -1,5 +1,4 @@ -import type { ComponentOverride } from "../../components/componentOverride/componentOverride"; -import type { UserContext } from "../../types"; +import type { SuccessRedirectContextOAuth2, UserContext } from "../../types"; import type { UserInput as RecipeModuleUserInput, NormalisedConfig as NormalisedRecipeModuleConfig, @@ -7,7 +6,14 @@ import type { import type OverrideableBuilder from "supertokens-js-override"; import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2/types"; -export type PreAndPostAPIHookAction = never; +export type PreAndPostAPIHookAction = "GET_LOGIN_CHALLENGE_INFO"; + +export type PreAPIHookContext = { + action: PreAndPostAPIHookAction; + requestInit: RequestInit; + url: string; + userContext: UserContext; +}; export type UserInput = { override?: { @@ -31,17 +37,6 @@ export type NormalisedConfig = NormalisedRecipeModuleConfig< }; }; -export type ComponentOverrideMap = { - ResumePageSpinner: ComponentOverride; // TODO: proper component list. this is a just placeholder to the typechecker happy -}; - -export type GetRedirectionURLContext = { - // TODO: proper list - action: "RESUME"; -}; +export type GetRedirectionURLContext = SuccessRedirectContextOAuth2; -export type OnHandleEventContext = { - // TODO: proper list - action: "RESUMER"; - userContext: UserContext; -}; +export type OnHandleEventContext = never; diff --git a/lib/ts/recipe/passwordless/components/features/signInAndUp/index.tsx b/lib/ts/recipe/passwordless/components/features/signInAndUp/index.tsx index 20ade54f8..a825d2d32 100644 --- a/lib/ts/recipe/passwordless/components/features/signInAndUp/index.tsx +++ b/lib/ts/recipe/passwordless/components/features/signInAndUp/index.tsx @@ -25,7 +25,6 @@ import { getRedirectToPathFromURL, useRethrowInRender } from "../../../../../uti import { EmailVerificationClaim } from "../../../../emailverification"; import EmailVerification from "../../../../emailverification/recipe"; import { getInvalidClaimsFromResponse } from "../../../../session"; -import SessionRecipe from "../../../../session/recipe"; import Session from "../../../../session/recipe"; import useSessionContext from "../../../../session/useSessionContext"; import { defaultPhoneNumberValidator } from "../../../defaultPhoneNumberValidator"; @@ -33,6 +32,7 @@ import { getPhoneNumberUtils } from "../../../phoneNumberUtils"; import SignInUpThemeWrapper from "../../themes/signInUp"; import type { Navigate, UserContext, PartialAuthComponentProps } from "../../../../../types"; +import type { AuthSuccessContext } from "../../../../authRecipe/types"; import type Recipe from "../../../recipe"; import type { ComponentOverrideMap } from "../../../types"; import type { SignInUpChildProps, NormalisedConfig } from "../../../types"; @@ -42,6 +42,7 @@ import type { User } from "supertokens-web-js/types"; export function useChildProps( recipe: Recipe, factorIds: string[], + onAuthSuccess: (successContext: AuthSuccessContext) => Promise, error: string | undefined, onError: (err: string) => void, clearError: () => void, @@ -68,25 +69,16 @@ export function useChildProps( } catch { payloadAfterCall = undefined; } - return SessionRecipe.getInstanceOrThrow() - .validateGlobalClaimsAndHandleSuccessRedirection( - { - action: "SUCCESS", - createdNewUser: result.createdNewRecipeUser && result.user.loginMethods.length === 1, - isNewRecipeUser: result.createdNewRecipeUser, - newSessionCreated: - session.loading || - !session.doesSessionExist || - (payloadAfterCall !== undefined && - session.accessTokenPayload.sessionHandle !== payloadAfterCall.sessionHandle), - recipeId: recipe.recipeID, - }, - recipe.recipeID, - getRedirectToPathFromURL(), - userContext, - navigate - ) - .catch(rethrowInRender); + return onAuthSuccess({ + createdNewUser: result.createdNewRecipeUser && result.user.loginMethods.length === 1, + isNewRecipeUser: result.createdNewRecipeUser, + newSessionCreated: + session.loading || + !session.doesSessionExist || + (payloadAfterCall !== undefined && + session.accessTokenPayload.sessionHandle !== payloadAfterCall.sessionHandle), + recipeId: "passwordless", + }).catch(rethrowInRender); }, error, onError, @@ -137,6 +129,7 @@ const SignInUpFeatureInner: React.FC< const childProps = useChildProps( props.recipe, props.factorIds, + props.onAuthSuccess, props.error, props.onError, props.clearError, diff --git a/lib/ts/recipe/passwordless/components/features/signInAndUpEPCombo/index.tsx b/lib/ts/recipe/passwordless/components/features/signInAndUpEPCombo/index.tsx index b07e502f0..96a6a3852 100644 --- a/lib/ts/recipe/passwordless/components/features/signInAndUpEPCombo/index.tsx +++ b/lib/ts/recipe/passwordless/components/features/signInAndUpEPCombo/index.tsx @@ -27,7 +27,6 @@ import EmailPassword from "../../../../emailpassword/recipe"; import { EmailVerificationClaim } from "../../../../emailverification"; import EmailVerification from "../../../../emailverification/recipe"; import { getInvalidClaimsFromResponse } from "../../../../session"; -import SessionRecipe from "../../../../session/recipe"; import Session from "../../../../session/recipe"; import useSessionContext from "../../../../session/useSessionContext"; import { defaultPhoneNumberValidator } from "../../../defaultPhoneNumberValidator"; @@ -35,6 +34,7 @@ import { getPhoneNumberUtils } from "../../../phoneNumberUtils"; import SignInUpEPComboThemeWrapper from "../../themes/signInUpEPCombo"; import type { Navigate, UserContext, PartialAuthComponentProps } from "../../../../../types"; +import type { AuthSuccessContext } from "../../../../authRecipe/types"; import type Recipe from "../../../recipe"; import type { ComponentOverrideMap } from "../../../types"; import type { SignInUpEPComboChildProps, NormalisedConfig } from "../../../types"; @@ -43,6 +43,7 @@ import type { RecipeInterface } from "supertokens-web-js/recipe/passwordless"; export function useChildProps( recipe: Recipe, factorIds: string[], + onAuthSuccess: (successContext: AuthSuccessContext) => Promise, error: string | undefined, onError: (err: string) => void, clearError: () => void, @@ -165,25 +166,16 @@ export function useChildProps( } catch { payloadAfterCall = undefined; } - return SessionRecipe.getInstanceOrThrow() - .validateGlobalClaimsAndHandleSuccessRedirection( - { - action: "SUCCESS", - createdNewUser: result.createdNewRecipeUser && result.user.loginMethods.length === 1, - isNewRecipeUser: result.createdNewRecipeUser, - newSessionCreated: - session.loading || - !session.doesSessionExist || - (payloadAfterCall !== undefined && - session.accessTokenPayload.sessionHandle !== payloadAfterCall.sessionHandle), - recipeId: result.isEmailPassword ? EmailPassword.RECIPE_ID : recipe.recipeID, - }, - result.isEmailPassword ? EmailPassword.RECIPE_ID : recipe.recipeID, - getRedirectToPathFromURL(), - userContext, - navigate - ) - .catch(rethrowInRender); + return onAuthSuccess({ + createdNewUser: result.createdNewRecipeUser && result.user.loginMethods.length === 1, + isNewRecipeUser: result.createdNewRecipeUser, + newSessionCreated: + session.loading || + !session.doesSessionExist || + (payloadAfterCall !== undefined && + session.accessTokenPayload.sessionHandle !== payloadAfterCall.sessionHandle), + recipeId: result.isEmailPassword ? EmailPassword.RECIPE_ID : recipe.recipeID, + }).catch(rethrowInRender); }, error, onError, @@ -242,6 +234,7 @@ const SignInUpEPComboFeatureInner: React.FC< const childProps = useChildProps( props.recipe, props.factorIds, + props.onAuthSuccess, props.error, props.onError, props.clearError, diff --git a/lib/ts/recipe/passwordless/components/features/userInputCode/index.tsx b/lib/ts/recipe/passwordless/components/features/userInputCode/index.tsx index 6baa25972..7141d7d13 100644 --- a/lib/ts/recipe/passwordless/components/features/userInputCode/index.tsx +++ b/lib/ts/recipe/passwordless/components/features/userInputCode/index.tsx @@ -20,16 +20,16 @@ import { Fragment } from "react"; import { useMemo } from "react"; import AuthComponentWrapper from "../../../../../components/authCompWrapper"; -import { clearErrorQueryParam, getRedirectToPathFromURL, useRethrowInRender } from "../../../../../utils"; +import { clearErrorQueryParam, useRethrowInRender } from "../../../../../utils"; import { EmailVerificationClaim } from "../../../../emailverification"; import EmailVerification from "../../../../emailverification/recipe"; import { getInvalidClaimsFromResponse } from "../../../../session"; -import SessionRecipe from "../../../../session/recipe"; import Session from "../../../../session/recipe"; import useSessionContext from "../../../../session/useSessionContext"; import UserInputCodeFormScreenWrapper from "../../themes/userInputCodeForm/userInputCodeFormScreen"; import type { Navigate, UserContext, AuthComponentProps } from "../../../../../types"; +import type { AuthSuccessContext } from "../../../../authRecipe/types"; import type Recipe from "../../../recipe"; import type { AdditionalLoginAttemptInfoProperties, @@ -43,6 +43,7 @@ import type { User } from "supertokens-web-js/types"; export function useChildProps( recipe: Recipe, loginAttemptInfo: LoginAttemptInfo, + onAuthSuccess: (successContext: AuthSuccessContext) => Promise, error: string | undefined, onError: (err: string) => void, clearError: () => void, @@ -69,25 +70,16 @@ export function useChildProps( } catch { payloadAfterCall = undefined; } - return SessionRecipe.getInstanceOrThrow() - .validateGlobalClaimsAndHandleSuccessRedirection( - { - action: "SUCCESS", - createdNewUser: result.createdNewRecipeUser && result.user.loginMethods.length === 1, - isNewRecipeUser: result.createdNewRecipeUser, - newSessionCreated: - session.loading || - !session.doesSessionExist || - (payloadAfterCall !== undefined && - session.accessTokenPayload.sessionHandle !== payloadAfterCall.sessionHandle), - recipeId: recipe.recipeID, - }, - recipe.recipeID, - getRedirectToPathFromURL(), - userContext, - navigate - ) - .catch(rethrowInRender); + return onAuthSuccess({ + createdNewUser: result.createdNewRecipeUser && result.user.loginMethods.length === 1, + isNewRecipeUser: result.createdNewRecipeUser, + newSessionCreated: + session.loading || + !session.doesSessionExist || + (payloadAfterCall !== undefined && + session.accessTokenPayload.sessionHandle !== payloadAfterCall.sessionHandle), + recipeId: "passwordless", + }).catch(rethrowInRender); }, onFetchError: async (err: Response) => { if (err.status === Session.getInstanceOrThrow().config.invalidClaimStatusCode) { @@ -132,6 +124,7 @@ const UserInputCodeFeatureInner: React.FC< const childProps = useChildProps( props.recipe, props.loginAttemptInfo, + props.onAuthSuccess, props.error, props.onError, props.clearError, diff --git a/lib/ts/recipe/session/recipe.tsx b/lib/ts/recipe/session/recipe.tsx index 5c628333b..31a7982cd 100644 --- a/lib/ts/recipe/session/recipe.tsx +++ b/lib/ts/recipe/session/recipe.tsx @@ -27,6 +27,7 @@ import { removeFromLocalStorage, setLocalStorage, } from "../../utils"; +import OAuth2 from "../oauth2/recipe"; import RecipeModule from "../recipeModule"; import { @@ -42,7 +43,8 @@ import type { NormalisedAppInfo, NormalisedConfigWithAppInfoAndRecipeID, RecipeInitResult, - SuccessRedirectContext, + SuccessRedirectContextInApp, + SuccessRedirectContextOAuth2, UserContext, } from "../../types"; import type { ClaimValidationError, SessionClaimValidator } from "supertokens-web-js/recipe/session"; @@ -126,7 +128,11 @@ export default class Session extends RecipeModule & { recipeId: string }) | undefined, + successRedirectContext: + | ((Omit | Omit) & { + recipeId: string; + }) + | undefined, fallbackRecipeId: string, redirectToPath?: string, userContext?: UserContext, @@ -210,12 +216,21 @@ export default class Session extends RecipeModule Promise, error: string | undefined, onError: (err: string) => void, clearError: () => void, @@ -57,6 +59,7 @@ export function useChildProps( } return { + onAuthSuccess, error, onError, clearError, @@ -84,6 +87,7 @@ type PropType = PartialAuthComponentProps & { export const SignInAndUpFeature: React.FC = (props) => { const childProps = useChildProps( props.recipe, + props.onAuthSuccess, props.error, props.onError, props.clearError, diff --git a/lib/ts/recipe/thirdparty/components/features/signInAndUpCallback/index.tsx b/lib/ts/recipe/thirdparty/components/features/signInAndUpCallback/index.tsx index 4d9fe7a5f..abc3ea8d9 100644 --- a/lib/ts/recipe/thirdparty/components/features/signInAndUpCallback/index.tsx +++ b/lib/ts/recipe/thirdparty/components/features/signInAndUpCallback/index.tsx @@ -104,19 +104,34 @@ const SignInAndUpCallback: React.FC = (props) => { userContext, }); const redirectToPath = stateResponse === undefined ? undefined : stateResponse.redirectToPath; + const loginChallenge = stateResponse?.oauth2LoginChallenge; return Session.getInstanceOrThrow() .validateGlobalClaimsAndHandleSuccessRedirection( - { - action: "SUCCESS", - createdNewUser: response.createdNewRecipeUser && response.user.loginMethods.length === 1, - isNewRecipeUser: response.createdNewRecipeUser, - newSessionCreated: - payloadAfterCall !== undefined && - (payloadBeforeCall === undefined || - payloadBeforeCall.sessionHandle !== payloadAfterCall.sessionHandle), - recipeId: props.recipe.recipeID, - }, + loginChallenge !== undefined + ? { + action: "SUCCESS_OAUTH2", + loginChallenge, + createdNewUser: + response.createdNewRecipeUser && response.user.loginMethods.length === 1, + isNewRecipeUser: response.createdNewRecipeUser, + newSessionCreated: + payloadAfterCall !== undefined && + (payloadBeforeCall === undefined || + payloadBeforeCall.sessionHandle !== payloadAfterCall.sessionHandle), + recipeId: props.recipe.recipeID, + } + : { + action: "SUCCESS", + createdNewUser: + response.createdNewRecipeUser && response.user.loginMethods.length === 1, + isNewRecipeUser: response.createdNewRecipeUser, + newSessionCreated: + payloadAfterCall !== undefined && + (payloadBeforeCall === undefined || + payloadBeforeCall.sessionHandle !== payloadAfterCall.sessionHandle), + recipeId: props.recipe.recipeID, + }, props.recipe.recipeID, redirectToPath, userContext, diff --git a/lib/ts/recipe/thirdparty/functionOverrides.ts b/lib/ts/recipe/thirdparty/functionOverrides.ts index 299ce2236..c95f8f51f 100644 --- a/lib/ts/recipe/thirdparty/functionOverrides.ts +++ b/lib/ts/recipe/thirdparty/functionOverrides.ts @@ -1,4 +1,4 @@ -import { getRedirectToPathFromURL } from "../../utils"; +import { getQueryParams, getRedirectToPathFromURL } from "../../utils"; import Session from "../session/recipe"; import type { OnHandleEventContext } from "./types"; @@ -49,6 +49,7 @@ export const getFunctionOverrides = }, setStateAndOtherInfoToStorage: function (input) { + const loginChallenge = getQueryParams("loginChallenge") ?? undefined; return originalImp.setStateAndOtherInfoToStorage<{ rid?: string; redirectToPath?: string; @@ -56,6 +57,7 @@ export const getFunctionOverrides = state: { ...input.state, rid: recipeId, + oauth2LoginChallenge: loginChallenge, redirectToPath: getRedirectToPathFromURL(), }, userContext: input.userContext, diff --git a/lib/ts/recipe/thirdparty/types.ts b/lib/ts/recipe/thirdparty/types.ts index dd6658ace..89d177d90 100644 --- a/lib/ts/recipe/thirdparty/types.ts +++ b/lib/ts/recipe/thirdparty/types.ts @@ -116,4 +116,5 @@ export type StateObject = WebJsStateObject & { export type CustomStateProperties = { rid: string; redirectToPath: string; + oauth2LoginChallenge?: string; }; diff --git a/lib/ts/translation/translations.ts b/lib/ts/translation/translations.ts index b78c4098b..424897019 100644 --- a/lib/ts/translation/translations.ts +++ b/lib/ts/translation/translations.ts @@ -3,6 +3,7 @@ export const defaultTranslationsCommon = { AUTH_PAGE_HEADER_TITLE_SIGN_IN_AND_UP: "Sign Up / Sign In", AUTH_PAGE_HEADER_TITLE_SIGN_IN: "Sign In", AUTH_PAGE_HEADER_TITLE_SIGN_UP: "Sign Up", + AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP: " to continue to ", AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START: "Not registered yet?", AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK: "Sign Up", diff --git a/lib/ts/types.ts b/lib/ts/types.ts index ad4b2fff0..b6518b4b9 100644 --- a/lib/ts/types.ts +++ b/lib/ts/types.ts @@ -14,6 +14,7 @@ */ import type { DateProviderInput } from "./dateProvider/types"; +import type { AuthSuccessContext } from "./recipe/authRecipe/types"; import type { BaseRecipeModule } from "./recipe/recipeModule/baseRecipeModule"; import type { NormalisedConfig as NormalisedRecipeModuleConfig } from "./recipe/recipeModule/types"; import type { TranslationFunc, TranslationStore } from "./translation/translationHelpers"; @@ -25,7 +26,7 @@ import type NormalisedURLDomain from "supertokens-web-js/utils/normalisedURLDoma import type NormalisedURLPath from "supertokens-web-js/utils/normalisedURLPath"; import type { WindowHandlerInput } from "supertokens-web-js/utils/windowHandler/types"; -export type SuccessRedirectContext = { +type SuccessRedirectContextCommon = { recipeId: | "emailpassword" | "thirdparty" @@ -34,19 +35,25 @@ export type SuccessRedirectContext = { | "thirdpartyemailpassword" | "emailverification" | "totp"; - action: "SUCCESS"; isNewRecipeUser: boolean; createdNewUser: boolean; newSessionCreated: boolean; - redirectToPath?: string; }; +export type SuccessRedirectContextInApp = SuccessRedirectContextCommon & { action: "SUCCESS"; redirectToPath?: string }; +export type SuccessRedirectContextOAuth2 = SuccessRedirectContextCommon & { + action: "SUCCESS_OAUTH2"; + loginChallenge: string; +}; + +export type SuccessRedirectContext = SuccessRedirectContextInApp | SuccessRedirectContextOAuth2; + export type GetRedirectionURLContext = | { action: "TO_AUTH"; showSignIn?: boolean; } - | SuccessRedirectContext; + | SuccessRedirectContextInApp; export type ValidationFailureCallback = | (({ @@ -415,6 +422,7 @@ export type UserContext = Record; export type AuthComponentProps = { setFactorList: (factorIds: string[]) => void; rebuildAuthPage: () => void; + onAuthSuccess: (successContext: AuthSuccessContext) => Promise; navigate: Navigate | undefined; userContext: UserContext; error: string | undefined; diff --git a/rollup.config.mjs b/rollup.config.mjs index e59a7aa1d..930ba2d5d 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -25,6 +25,7 @@ export default [ emailpasswordprebuiltui: "lib/ts/recipe/emailpassword/prebuiltui.tsx", passwordless: "lib/ts/recipe/passwordless/index.ts", passwordlessprebuiltui: "lib/ts/recipe/passwordless/prebuiltui.tsx", + oauth2: "lib/ts/recipe/oauth2/index.ts", thirdparty: "lib/ts/recipe/thirdparty/index.ts", thirdpartyprebuiltui: "lib/ts/recipe/thirdparty/prebuiltui.tsx", multitenancy: "lib/ts/recipe/multitenancy/index.ts", diff --git a/test/prepTestApp.sh b/test/prepTestApp.sh index d42f26602..a628f362a 100755 --- a/test/prepTestApp.sh +++ b/test/prepTestApp.sh @@ -2,14 +2,17 @@ # pack-unpack repo to simulate an install npm pack + +REPO=$(pwd) + cd $1 rm -rf node_modules/.cache rm -rf node_modules/supertokens-auth-react/lib || true rm -rf node_modules/supertokens-auth-react/recipe || true mkdir -p node_modules/supertokens-auth-react -tar -xf ../../supertokens-auth-react-*.tgz --strip-components=1 -C node_modules/supertokens-auth-react -rm ../../supertokens-auth-react-*.tgz +tar -xf $REPO/supertokens-auth-react-*.tgz --strip-components=1 -C node_modules/supertokens-auth-react +rm $REPO/supertokens-auth-react-*.tgz cd node_modules/supertokens-auth-react @@ -22,9 +25,9 @@ rm -rf node_modules/supertokens-web-js || true rm -rf node_modules/supertokens-website || true # We symlink the supertokens-web-js dep to ensure it's the same version (maybe linked locally) -ln -s ../../../../../node_modules/supertokens-web-js node_modules/supertokens-web-js +ln -s $REPO/node_modules/supertokens-web-js node_modules/supertokens-web-js # We symlink the supertokens-website dep to ensure it's the same version (maybe linked locally) -ln -s ../../../../../node_modules/supertokens-website node_modules/supertokens-website +ln -s $REPO/node_modules/supertokens-website node_modules/supertokens-website echo "$1 prepped." From b7de9d2b9feef899a331200fbe07f6d62fbe513c Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Sun, 28 Jul 2024 02:11:01 +0200 Subject: [PATCH 3/9] refactor: rename OAuth2 to OAuth2Provider --- lib/build/emailpassword.js | 4 +- lib/build/emailpasswordprebuiltui.js | 4 +- lib/build/emailverificationprebuiltui.js | 4 +- lib/build/index.js | 4 +- lib/build/index2.js | 6 +-- lib/build/multifactorauth-shared.js | 4 +- lib/build/multifactorauth.js | 4 +- lib/build/multifactorauthprebuiltui.js | 4 +- ...th2-shared.js => oauth2provider-shared.js} | 48 ++++++++++--------- lib/build/{oauth2.js => oauth2provider.js} | 8 ++-- lib/build/passwordless.js | 4 +- lib/build/passwordlessprebuiltui.js | 4 +- .../{oauth2 => oauth2provider}/index.d.ts | 4 +- .../{oauth2 => oauth2provider}/recipe.d.ts | 14 +++--- .../{oauth2 => oauth2provider}/types.d.ts | 2 +- .../{oauth2 => oauth2provider}/utils.d.ts | 0 lib/build/session.js | 4 +- lib/build/sessionprebuiltui.js | 4 +- lib/build/thirdparty.js | 4 +- lib/build/thirdpartyprebuiltui.js | 4 +- lib/build/totp.js | 4 +- lib/build/totpprebuiltui.js | 4 +- lib/build/ui-entry.js | 4 +- .../components/feature/authPage/authPage.tsx | 8 ++-- .../{oauth2 => oauth2provider}/index.ts | 10 ++-- .../{oauth2 => oauth2provider}/recipe.ts | 34 ++++++------- .../{oauth2 => oauth2provider}/types.ts | 2 +- .../{oauth2 => oauth2provider}/utils.ts | 0 lib/ts/recipe/session/recipe.tsx | 4 +- recipe/{oauth2 => oauth2provider}/index.d.ts | 4 +- recipe/{oauth2 => oauth2provider}/index.js | 2 +- rollup.config.mjs | 2 +- 32 files changed, 107 insertions(+), 105 deletions(-) rename lib/build/{oauth2-shared.js => oauth2provider-shared.js} (71%) rename lib/build/{oauth2.js => oauth2provider.js} (89%) rename lib/build/recipe/{oauth2 => oauth2provider}/index.d.ts (96%) rename lib/build/recipe/{oauth2 => oauth2provider}/recipe.d.ts (71%) rename lib/build/recipe/{oauth2 => oauth2provider}/types.d.ts (98%) rename lib/build/recipe/{oauth2 => oauth2provider}/utils.d.ts (100%) rename lib/ts/recipe/{oauth2 => oauth2provider}/index.ts (90%) rename lib/ts/recipe/{oauth2 => oauth2provider}/recipe.ts (77%) rename lib/ts/recipe/{oauth2 => oauth2provider}/types.ts (98%) rename lib/ts/recipe/{oauth2 => oauth2provider}/utils.ts (100%) rename recipe/{oauth2 => oauth2provider}/index.d.ts (85%) rename recipe/{oauth2 => oauth2provider}/index.js (94%) diff --git a/lib/build/emailpassword.js b/lib/build/emailpassword.js index 896fc08df..a16aef3ed 100644 --- a/lib/build/emailpassword.js +++ b/lib/build/emailpassword.js @@ -21,8 +21,8 @@ require("./authRecipe-shared2.js"); require("./recipeModule-shared.js"); require("./multifactorauth-shared.js"); require("supertokens-web-js/recipe/session"); -require("./oauth2-shared.js"); -require("supertokens-web-js/recipe/oauth2"); +require("./oauth2provider-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); require("./emailpassword-shared4.js"); require("./authRecipe-shared.js"); diff --git a/lib/build/emailpasswordprebuiltui.js b/lib/build/emailpasswordprebuiltui.js index dcfcdb5f1..28263d209 100644 --- a/lib/build/emailpasswordprebuiltui.js +++ b/lib/build/emailpasswordprebuiltui.js @@ -35,8 +35,8 @@ require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); -require("./oauth2-shared.js"); -require("supertokens-web-js/recipe/oauth2"); +require("./oauth2provider-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); require("./multifactorauth-shared3.js"); diff --git a/lib/build/emailverificationprebuiltui.js b/lib/build/emailverificationprebuiltui.js index b2dab0fe6..1262bec05 100644 --- a/lib/build/emailverificationprebuiltui.js +++ b/lib/build/emailverificationprebuiltui.js @@ -27,8 +27,8 @@ require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); -require("./oauth2-shared.js"); -require("supertokens-web-js/recipe/oauth2"); +require("./oauth2provider-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); require("supertokens-web-js/recipe/session"); diff --git a/lib/build/index.js b/lib/build/index.js index 5c44bab66..11217f2b2 100644 --- a/lib/build/index.js +++ b/lib/build/index.js @@ -24,8 +24,8 @@ require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); require("./multifactorauth-shared.js"); require("supertokens-web-js/recipe/session"); -require("./oauth2-shared.js"); -require("supertokens-web-js/recipe/oauth2"); +require("./oauth2provider-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); diff --git a/lib/build/index2.js b/lib/build/index2.js index 89239b8b2..92bd7b221 100644 --- a/lib/build/index2.js +++ b/lib/build/index2.js @@ -10,7 +10,7 @@ var reactDom = require("react-dom"); var componentOverrideContext = require("./multitenancy-shared.js"); var recipe$1 = require("./multifactorauth-shared2.js"); var types = require("./multifactorauth-shared.js"); -var recipe = require("./oauth2-shared.js"); +var recipe = require("./oauth2provider-shared.js"); var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var utils = require("./authRecipe-shared.js"); var NormalisedURLPath$1 = require("supertokens-web-js/lib/build/normalisedURLPath"); @@ -963,9 +963,9 @@ var AuthPageInner = function (props) { if (oauth2ClientInfo) { return; } - var oauth2Recipe = recipe.OAuth2.getInstance(); + var oauth2Recipe = recipe.OAuth2Provider.getInstance(); if (oauth2Recipe !== undefined && loginChallenge !== null) { - void recipe.OAuth2.getInstanceOrThrow() + void recipe.OAuth2Provider.getInstanceOrThrow() .webJSRecipe.getLoginChallengeInfo({ loginChallenge: loginChallenge, userContext: userContext }) .then(function (_a) { var info = _a.info; diff --git a/lib/build/multifactorauth-shared.js b/lib/build/multifactorauth-shared.js index 1a551eaa3..a2ee8cc66 100644 --- a/lib/build/multifactorauth-shared.js +++ b/lib/build/multifactorauth-shared.js @@ -2,7 +2,7 @@ var superTokens = require("./superTokens.js"); var WebJSSessionRecipe = require("supertokens-web-js/recipe/session"); -var recipe = require("./oauth2-shared.js"); +var recipe = require("./oauth2provider-shared.js"); var index = require("./recipeModule-shared.js"); var utils = require("supertokens-web-js/utils"); var windowHandler = require("supertokens-web-js/utils/windowHandler"); @@ -347,7 +347,7 @@ var Session = /** @class */ (function (_super) { if (successRedirectContext.action === "SUCCESS_OAUTH2") { return [ 2 /*return*/, - recipe.OAuth2.getInstanceOrThrow().redirect( + recipe.OAuth2Provider.getInstanceOrThrow().redirect( successRedirectContext, navigate, {}, diff --git a/lib/build/multifactorauth.js b/lib/build/multifactorauth.js index a8fff189f..d797015e1 100644 --- a/lib/build/multifactorauth.js +++ b/lib/build/multifactorauth.js @@ -21,8 +21,8 @@ require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); require("supertokens-web-js/recipe/session"); -require("./oauth2-shared.js"); -require("supertokens-web-js/recipe/oauth2"); +require("./oauth2provider-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); /* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. * diff --git a/lib/build/multifactorauthprebuiltui.js b/lib/build/multifactorauthprebuiltui.js index 5a7a2d72e..125f54dc9 100644 --- a/lib/build/multifactorauthprebuiltui.js +++ b/lib/build/multifactorauthprebuiltui.js @@ -22,8 +22,8 @@ require("supertokens-web-js/utils/normalisedURLDomain"); require("react-dom"); require("./multitenancy-shared.js"); require("./genericComponentOverrideContext.js"); -require("./oauth2-shared.js"); -require("supertokens-web-js/recipe/oauth2"); +require("./oauth2provider-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); require("./recipeModule-shared.js"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); diff --git a/lib/build/oauth2-shared.js b/lib/build/oauth2provider-shared.js similarity index 71% rename from lib/build/oauth2-shared.js rename to lib/build/oauth2provider-shared.js index 0b94367e6..4d65805f4 100644 --- a/lib/build/oauth2-shared.js +++ b/lib/build/oauth2provider-shared.js @@ -1,7 +1,7 @@ "use strict"; var superTokens = require("./superTokens.js"); -var OAuth2WebJS = require("supertokens-web-js/recipe/oauth2"); +var OAuth2WebJS = require("supertokens-web-js/recipe/oauth2provider"); var index = require("./recipeModule-shared.js"); function _interopDefault(e) { @@ -40,37 +40,37 @@ function normaliseOAuth2Config(config) { /* * Class. */ -var OAuth2 = /** @class */ (function (_super) { - superTokens.__extends(OAuth2, _super); - function OAuth2(config, webJSRecipe) { +var OAuth2Provider = /** @class */ (function (_super) { + superTokens.__extends(OAuth2Provider, _super); + function OAuth2Provider(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = OAuth2WebJS__default.default; } var _this = _super.call(this, config) || this; _this.webJSRecipe = webJSRecipe; - _this.recipeID = OAuth2.RECIPE_ID; + _this.recipeID = OAuth2Provider.RECIPE_ID; return _this; } - OAuth2.init = function (config) { + OAuth2Provider.init = function (config) { var normalisedConfig = normaliseOAuth2Config(config); return { - recipeID: OAuth2.RECIPE_ID, + recipeID: OAuth2Provider.RECIPE_ID, authReact: function (appInfo) { - OAuth2.instance = new OAuth2( + OAuth2Provider.instance = new OAuth2Provider( superTokens.__assign(superTokens.__assign({}, normalisedConfig), { appInfo: appInfo, - recipeId: OAuth2.RECIPE_ID, + recipeId: OAuth2Provider.RECIPE_ID, }) ); - return OAuth2.instance; + return OAuth2Provider.instance; }, webJS: OAuth2WebJS__default.default.init(superTokens.__assign({}, normalisedConfig)), }; }; - OAuth2.getInstanceOrThrow = function () { - if (OAuth2.instance === undefined) { + OAuth2Provider.getInstanceOrThrow = function () { + if (OAuth2Provider.instance === undefined) { var error = - "No instance of OAuth2 found. Make sure to call the OAuth2.init method." + + "No instance of OAuth2Provider found. Make sure to call the OAuth2Provider.init method." + "See https://supertokens.io/docs/oauth2/quick-setup/frontend"; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { @@ -78,12 +78,12 @@ var OAuth2 = /** @class */ (function (_super) { } throw Error(error); } - return OAuth2.instance; + return OAuth2Provider.instance; }; - OAuth2.getInstance = function () { - return OAuth2.instance; + OAuth2Provider.getInstance = function () { + return OAuth2Provider.instance; }; - OAuth2.prototype.getDefaultRedirectionURL = function (ctx) { + OAuth2Provider.prototype.getDefaultRedirectionURL = function (ctx) { return superTokens.__awaiter(this, void 0, void 0, function () { var domain, basePath; return superTokens.__generator(this, function (_a) { @@ -95,7 +95,9 @@ var OAuth2 = /** @class */ (function (_super) { "".concat(domain).concat(basePath, "/oauth2/login?loginChallenge=").concat(ctx.loginChallenge), ]; } else { - throw new Error("Should never come here: unknown action in OAuth2.getDefaultRedirectionURL"); + throw new Error( + "Should never come here: unknown action in OAuth2Provider.getDefaultRedirectionURL" + ); } }); }); @@ -103,15 +105,15 @@ var OAuth2 = /** @class */ (function (_super) { /* * Tests methods. */ - OAuth2.reset = function () { + OAuth2Provider.reset = function () { if (!superTokens.isTest()) { return; } - OAuth2.instance = undefined; + OAuth2Provider.instance = undefined; return; }; - OAuth2.RECIPE_ID = "oauth2"; - return OAuth2; + OAuth2Provider.RECIPE_ID = "oauth2provider"; + return OAuth2Provider; })(index.RecipeModule); -exports.OAuth2 = OAuth2; +exports.OAuth2Provider = OAuth2Provider; diff --git a/lib/build/oauth2.js b/lib/build/oauth2provider.js similarity index 89% rename from lib/build/oauth2.js rename to lib/build/oauth2provider.js index 18fd21099..7887de699 100644 --- a/lib/build/oauth2.js +++ b/lib/build/oauth2provider.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var recipe = require("./oauth2-shared.js"); +var recipe = require("./oauth2provider-shared.js"); require("./superTokens.js"); require("supertokens-web-js"); require("supertokens-web-js/utils/cookieHandler"); @@ -13,7 +13,7 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); -require("supertokens-web-js/recipe/oauth2"); +require("supertokens-web-js/recipe/oauth2provider"); require("./recipeModule-shared.js"); /* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. @@ -33,7 +33,7 @@ require("./recipeModule-shared.js"); var Wrapper = /** @class */ (function () { function Wrapper() {} Wrapper.init = function (config) { - return recipe.OAuth2.init(config); + return recipe.OAuth2Provider.init(config); }; /** * Returns information about an OAuth login in progress @@ -49,7 +49,7 @@ var Wrapper = /** @class */ (function () { * @throws STGeneralError if the API exposed by the backend SDKs returns `status: "GENERAL_ERROR"` */ Wrapper.getLoginChallengeInfo = function (input) { - return recipe.OAuth2.getInstanceOrThrow().webJSRecipe.getLoginChallengeInfo(input); + return recipe.OAuth2Provider.getInstanceOrThrow().webJSRecipe.getLoginChallengeInfo(input); }; return Wrapper; })(); diff --git a/lib/build/passwordless.js b/lib/build/passwordless.js index 5a12b5cf9..0892e826d 100644 --- a/lib/build/passwordless.js +++ b/lib/build/passwordless.js @@ -20,8 +20,8 @@ require("./authRecipe-shared2.js"); require("./recipeModule-shared.js"); require("./multifactorauth-shared.js"); require("supertokens-web-js/recipe/session"); -require("./oauth2-shared.js"); -require("supertokens-web-js/recipe/oauth2"); +require("./oauth2provider-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); diff --git a/lib/build/passwordlessprebuiltui.js b/lib/build/passwordlessprebuiltui.js index b41426f43..2a64a89af 100644 --- a/lib/build/passwordlessprebuiltui.js +++ b/lib/build/passwordlessprebuiltui.js @@ -32,8 +32,8 @@ require("supertokens-web-js/utils/normalisedURLDomain"); require("react-dom"); require("./multitenancy-shared.js"); require("./genericComponentOverrideContext.js"); -require("./oauth2-shared.js"); -require("supertokens-web-js/recipe/oauth2"); +require("./oauth2provider-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); require("./recipeModule-shared.js"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); diff --git a/lib/build/recipe/oauth2/index.d.ts b/lib/build/recipe/oauth2provider/index.d.ts similarity index 96% rename from lib/build/recipe/oauth2/index.d.ts rename to lib/build/recipe/oauth2provider/index.d.ts index 6b398a579..77cd9b408 100644 --- a/lib/build/recipe/oauth2/index.d.ts +++ b/lib/build/recipe/oauth2provider/index.d.ts @@ -1,6 +1,6 @@ import { UserInput, GetRedirectionURLContext, PreAPIHookContext, OnHandleEventContext } from "./types"; -import type { RecipeFunctionOptions, LoginInfo } from "supertokens-web-js/recipe/oauth2"; -import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2"; +import type { RecipeFunctionOptions, LoginInfo } from "supertokens-web-js/recipe/oauth2provider"; +import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2provider"; export default class Wrapper { static init(config?: UserInput): import("../../types").RecipeInitResult; /** diff --git a/lib/build/recipe/oauth2/recipe.d.ts b/lib/build/recipe/oauth2provider/recipe.d.ts similarity index 71% rename from lib/build/recipe/oauth2/recipe.d.ts rename to lib/build/recipe/oauth2provider/recipe.d.ts index 46a0a63e2..3911833f7 100644 --- a/lib/build/recipe/oauth2/recipe.d.ts +++ b/lib/build/recipe/oauth2provider/recipe.d.ts @@ -1,4 +1,4 @@ -import OAuth2WebJS from "supertokens-web-js/recipe/oauth2"; +import OAuth2WebJS from "supertokens-web-js/recipe/oauth2provider"; import RecipeModule from "../recipeModule"; import type { GetRedirectionURLContext, @@ -13,23 +13,23 @@ import type { WebJSRecipeInterface, SuccessRedirectContextOAuth2, } from "../../types"; -export default class OAuth2 extends RecipeModule< +export default class OAuth2Provider extends RecipeModule< GetRedirectionURLContext, PreAndPostAPIHookAction, OnHandleEventContext, NormalisedConfig > { readonly webJSRecipe: WebJSRecipeInterface; - static instance?: OAuth2; - static readonly RECIPE_ID = "oauth2"; - readonly recipeID = "oauth2"; + static instance?: OAuth2Provider; + static readonly RECIPE_ID = "oauth2provider"; + readonly recipeID = "oauth2provider"; constructor( config: NormalisedConfigWithAppInfoAndRecipeID, webJSRecipe?: WebJSRecipeInterface ); static init(config?: UserInput): RecipeInitResult; - static getInstanceOrThrow(): OAuth2; - static getInstance(): OAuth2 | undefined; + static getInstanceOrThrow(): OAuth2Provider; + static getInstance(): OAuth2Provider | undefined; getDefaultRedirectionURL(ctx: SuccessRedirectContextOAuth2): Promise; static reset(): void; } diff --git a/lib/build/recipe/oauth2/types.d.ts b/lib/build/recipe/oauth2provider/types.d.ts similarity index 98% rename from lib/build/recipe/oauth2/types.d.ts rename to lib/build/recipe/oauth2provider/types.d.ts index abd42d1fa..16b4ca38e 100644 --- a/lib/build/recipe/oauth2/types.d.ts +++ b/lib/build/recipe/oauth2provider/types.d.ts @@ -4,7 +4,7 @@ import type { NormalisedConfig as NormalisedRecipeModuleConfig, } from "../recipeModule/types"; import type OverrideableBuilder from "supertokens-js-override"; -import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2/types"; +import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2provider/types"; export declare type PreAndPostAPIHookAction = "GET_LOGIN_CHALLENGE_INFO"; export declare type PreAPIHookContext = { action: PreAndPostAPIHookAction; diff --git a/lib/build/recipe/oauth2/utils.d.ts b/lib/build/recipe/oauth2provider/utils.d.ts similarity index 100% rename from lib/build/recipe/oauth2/utils.d.ts rename to lib/build/recipe/oauth2provider/utils.d.ts diff --git a/lib/build/session.js b/lib/build/session.js index 8531109d0..b805d24cc 100644 --- a/lib/build/session.js +++ b/lib/build/session.js @@ -18,8 +18,8 @@ require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); -require("./oauth2-shared.js"); -require("supertokens-web-js/recipe/oauth2"); +require("./oauth2provider-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); require("./recipeModule-shared.js"); require("./translationContext.js"); require("react-dom"); diff --git a/lib/build/sessionprebuiltui.js b/lib/build/sessionprebuiltui.js index d17922280..cd2879394 100644 --- a/lib/build/sessionprebuiltui.js +++ b/lib/build/sessionprebuiltui.js @@ -23,8 +23,8 @@ require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); -require("./oauth2-shared.js"); -require("supertokens-web-js/recipe/oauth2"); +require("./oauth2provider-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); require("supertokens-web-js/recipe/session"); diff --git a/lib/build/thirdparty.js b/lib/build/thirdparty.js index 478ac7b00..679cc22d8 100644 --- a/lib/build/thirdparty.js +++ b/lib/build/thirdparty.js @@ -20,8 +20,8 @@ require("./authRecipe-shared2.js"); require("./recipeModule-shared.js"); require("./multifactorauth-shared.js"); require("supertokens-web-js/recipe/session"); -require("./oauth2-shared.js"); -require("supertokens-web-js/recipe/oauth2"); +require("./oauth2provider-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); require("./authRecipe-shared.js"); require("./translationContext.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); diff --git a/lib/build/thirdpartyprebuiltui.js b/lib/build/thirdpartyprebuiltui.js index 064b775cd..3d27fc978 100644 --- a/lib/build/thirdpartyprebuiltui.js +++ b/lib/build/thirdpartyprebuiltui.js @@ -28,8 +28,8 @@ require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); -require("./oauth2-shared.js"); -require("supertokens-web-js/recipe/oauth2"); +require("./oauth2provider-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); require("./multifactorauth-shared3.js"); diff --git a/lib/build/totp.js b/lib/build/totp.js index 4b185faaf..61a7a7d57 100644 --- a/lib/build/totp.js +++ b/lib/build/totp.js @@ -22,8 +22,8 @@ require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); require("./multifactorauth-shared.js"); require("supertokens-web-js/recipe/session"); -require("./oauth2-shared.js"); -require("supertokens-web-js/recipe/oauth2"); +require("./oauth2provider-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); /* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. * diff --git a/lib/build/totpprebuiltui.js b/lib/build/totpprebuiltui.js index dad1d8520..9256ff84c 100644 --- a/lib/build/totpprebuiltui.js +++ b/lib/build/totpprebuiltui.js @@ -24,8 +24,8 @@ require("supertokens-web-js/utils/normalisedURLDomain"); require("react-dom"); require("./multitenancy-shared.js"); require("./genericComponentOverrideContext.js"); -require("./oauth2-shared.js"); -require("supertokens-web-js/recipe/oauth2"); +require("./oauth2provider-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); require("./recipeModule-shared.js"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); diff --git a/lib/build/ui-entry.js b/lib/build/ui-entry.js index e25d17705..941fd497d 100644 --- a/lib/build/ui-entry.js +++ b/lib/build/ui-entry.js @@ -24,8 +24,8 @@ require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./recipeModule-shared.js"); require("./multifactorauth-shared.js"); require("supertokens-web-js/recipe/session"); -require("./oauth2-shared.js"); -require("supertokens-web-js/recipe/oauth2"); +require("./oauth2provider-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); diff --git a/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx b/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx index 182c84b1f..358b5f1e3 100644 --- a/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx +++ b/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx @@ -31,7 +31,7 @@ import { FactorIds } from "../../../../multifactorauth/types"; import DynamicLoginMethodsSpinner from "../../../../multitenancy/components/features/dynamicLoginMethodsSpinner"; import { DynamicLoginMethodsProvider } from "../../../../multitenancy/dynamicLoginMethodsContext"; import Multitenancy from "../../../../multitenancy/recipe"; -import OAuth2 from "../../../../oauth2/recipe"; +import OAuth2Provider from "../../../../oauth2provider/recipe"; import Session from "../../../../session/recipe"; import SessionAuthWrapper from "../../../../session/sessionAuth"; import useSessionContext from "../../../../session/useSessionContext"; @@ -46,7 +46,7 @@ import type { GetLoginMethodsResponseNormalized } from "../../../../multitenancy import type { RecipeRouter } from "../../../../recipeRouter"; import type { AuthPageThemeProps, AuthSuccessContext } from "../../../types"; import type { PropsWithChildren } from "react"; -import type { LoginInfo } from "supertokens-web-js/recipe/oauth2/types"; +import type { LoginInfo } from "supertokens-web-js/recipe/oauth2provider/types"; const errorQSMap: Record = { signin: "SOMETHING_WENT_WRONG_ERROR", @@ -171,9 +171,9 @@ const AuthPageInner: React.FC = (props) => { if (oauth2ClientInfo) { return; } - const oauth2Recipe = OAuth2.getInstance(); + const oauth2Recipe = OAuth2Provider.getInstance(); if (oauth2Recipe !== undefined && loginChallenge !== null) { - void OAuth2.getInstanceOrThrow() + void OAuth2Provider.getInstanceOrThrow() .webJSRecipe.getLoginChallengeInfo({ loginChallenge, userContext }) .then(({ info }) => setOAuth2ClientInfo(info)); } diff --git a/lib/ts/recipe/oauth2/index.ts b/lib/ts/recipe/oauth2provider/index.ts similarity index 90% rename from lib/ts/recipe/oauth2/index.ts rename to lib/ts/recipe/oauth2provider/index.ts index 728dba6b8..980b8efe8 100644 --- a/lib/ts/recipe/oauth2/index.ts +++ b/lib/ts/recipe/oauth2provider/index.ts @@ -13,15 +13,15 @@ * under the License. */ -import OAuth2 from "./recipe"; +import OAuth2Provider from "./recipe"; import { UserInput, GetRedirectionURLContext, PreAPIHookContext, OnHandleEventContext } from "./types"; -import type { RecipeFunctionOptions, LoginInfo } from "supertokens-web-js/recipe/oauth2"; -import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2"; +import type { RecipeFunctionOptions, LoginInfo } from "supertokens-web-js/recipe/oauth2provider"; +import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2provider"; export default class Wrapper { static init(config?: UserInput) { - return OAuth2.init(config); + return OAuth2Provider.init(config); } /** * Returns information about an OAuth login in progress @@ -45,7 +45,7 @@ export default class Wrapper { info: LoginInfo; fetchResponse: Response; }> { - return OAuth2.getInstanceOrThrow().webJSRecipe.getLoginChallengeInfo(input); + return OAuth2Provider.getInstanceOrThrow().webJSRecipe.getLoginChallengeInfo(input); } } diff --git a/lib/ts/recipe/oauth2/recipe.ts b/lib/ts/recipe/oauth2provider/recipe.ts similarity index 77% rename from lib/ts/recipe/oauth2/recipe.ts rename to lib/ts/recipe/oauth2provider/recipe.ts index 4638fc315..57a5b121b 100644 --- a/lib/ts/recipe/oauth2/recipe.ts +++ b/lib/ts/recipe/oauth2provider/recipe.ts @@ -17,7 +17,7 @@ * Imports. */ -import OAuth2WebJS from "supertokens-web-js/recipe/oauth2"; +import OAuth2WebJS from "supertokens-web-js/recipe/oauth2provider"; import { SSR_ERROR } from "../../constants"; import { isTest } from "../../utils"; @@ -43,16 +43,16 @@ import type { NormalisedAppInfo } from "../../types"; /* * Class. */ -export default class OAuth2 extends RecipeModule< +export default class OAuth2Provider extends RecipeModule< GetRedirectionURLContext, PreAndPostAPIHookAction, OnHandleEventContext, NormalisedConfig > { - static instance?: OAuth2; - static readonly RECIPE_ID = "oauth2"; + static instance?: OAuth2Provider; + static readonly RECIPE_ID = "oauth2provider"; - public readonly recipeID = OAuth2.RECIPE_ID; + public readonly recipeID = OAuth2Provider.RECIPE_ID; constructor( config: NormalisedConfigWithAppInfoAndRecipeID, @@ -64,7 +64,7 @@ export default class OAuth2 extends RecipeModule< static init(config?: UserInput): RecipeInitResult { const normalisedConfig = normaliseOAuth2Config(config); return { - recipeID: OAuth2.RECIPE_ID, + recipeID: OAuth2Provider.RECIPE_ID, authReact: ( appInfo: NormalisedAppInfo ): RecipeModule< @@ -73,12 +73,12 @@ export default class OAuth2 extends RecipeModule< OnHandleEventContext, NormalisedConfig > => { - OAuth2.instance = new OAuth2({ + OAuth2Provider.instance = new OAuth2Provider({ ...normalisedConfig, appInfo, - recipeId: OAuth2.RECIPE_ID, + recipeId: OAuth2Provider.RECIPE_ID, }); - return OAuth2.instance; + return OAuth2Provider.instance; }, webJS: OAuth2WebJS.init({ ...normalisedConfig, @@ -86,10 +86,10 @@ export default class OAuth2 extends RecipeModule< }; } - static getInstanceOrThrow(): OAuth2 { - if (OAuth2.instance === undefined) { + static getInstanceOrThrow(): OAuth2Provider { + if (OAuth2Provider.instance === undefined) { let error = - "No instance of OAuth2 found. Make sure to call the OAuth2.init method." + + "No instance of OAuth2Provider found. Make sure to call the OAuth2Provider.init method." + "See https://supertokens.io/docs/oauth2/quick-setup/frontend"; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object @@ -99,11 +99,11 @@ export default class OAuth2 extends RecipeModule< throw Error(error); } - return OAuth2.instance; + return OAuth2Provider.instance; } - static getInstance(): OAuth2 | undefined { - return OAuth2.instance; + static getInstance(): OAuth2Provider | undefined { + return OAuth2Provider.instance; } async getDefaultRedirectionURL(ctx: SuccessRedirectContextOAuth2): Promise { @@ -113,7 +113,7 @@ export default class OAuth2 extends RecipeModule< return `${domain}${basePath}/oauth2/login?loginChallenge=${ctx.loginChallenge}`; } else { - throw new Error("Should never come here: unknown action in OAuth2.getDefaultRedirectionURL"); + throw new Error("Should never come here: unknown action in OAuth2Provider.getDefaultRedirectionURL"); } } @@ -125,7 +125,7 @@ export default class OAuth2 extends RecipeModule< return; } - OAuth2.instance = undefined; + OAuth2Provider.instance = undefined; return; } } diff --git a/lib/ts/recipe/oauth2/types.ts b/lib/ts/recipe/oauth2provider/types.ts similarity index 98% rename from lib/ts/recipe/oauth2/types.ts rename to lib/ts/recipe/oauth2provider/types.ts index ce076d31a..bcb7323f4 100644 --- a/lib/ts/recipe/oauth2/types.ts +++ b/lib/ts/recipe/oauth2provider/types.ts @@ -4,7 +4,7 @@ import type { NormalisedConfig as NormalisedRecipeModuleConfig, } from "../recipeModule/types"; import type OverrideableBuilder from "supertokens-js-override"; -import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2/types"; +import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2provider/types"; export type PreAndPostAPIHookAction = "GET_LOGIN_CHALLENGE_INFO"; diff --git a/lib/ts/recipe/oauth2/utils.ts b/lib/ts/recipe/oauth2provider/utils.ts similarity index 100% rename from lib/ts/recipe/oauth2/utils.ts rename to lib/ts/recipe/oauth2provider/utils.ts diff --git a/lib/ts/recipe/session/recipe.tsx b/lib/ts/recipe/session/recipe.tsx index 31a7982cd..e6dca7ac9 100644 --- a/lib/ts/recipe/session/recipe.tsx +++ b/lib/ts/recipe/session/recipe.tsx @@ -27,7 +27,7 @@ import { removeFromLocalStorage, setLocalStorage, } from "../../utils"; -import OAuth2 from "../oauth2/recipe"; +import OAuth2Provider from "../oauth2provider/recipe"; import RecipeModule from "../recipeModule"; import { @@ -217,7 +217,7 @@ export default class Session extends RecipeModule Date: Tue, 30 Jul 2024 01:53:26 +0200 Subject: [PATCH 4/9] feat: show logo for oauth clients --- lib/build/emailverification-shared2.js | 2 +- lib/build/index2.js | 49 ++++++++++++++++--- lib/build/multifactorauthprebuiltui.js | 2 +- lib/build/passwordlessprebuiltui.js | 2 +- .../theme/authPage/authPageHeader.d.ts | 8 ++- lib/build/recipe/authRecipe/types.d.ts | 6 ++- lib/build/recipe/oauth2provider/types.d.ts | 2 +- lib/build/sessionprebuiltui.js | 2 +- lib/build/thirdpartyprebuiltui.js | 2 +- lib/build/totpprebuiltui.js | 2 +- lib/build/ui/index.d.ts | 8 ++- .../components/feature/authPage/authPage.tsx | 2 +- .../theme/authPage/authPageHeader.tsx | 28 +++++++++-- .../components/theme/authPage/index.tsx | 2 +- lib/ts/recipe/authRecipe/types.ts | 6 ++- lib/ts/recipe/oauth2provider/types.ts | 2 +- lib/ts/styles/styles.css | 21 ++++++++ stories/allrecipes.stories.tsx | 11 +++++ stories/authPage.stories.tsx | 40 +++++++++++++++ stories/utils.ts | 30 ++++++++++++ 20 files changed, 202 insertions(+), 25 deletions(-) diff --git a/lib/build/emailverification-shared2.js b/lib/build/emailverification-shared2.js index 7fb4ce474..fd3e1549a 100644 --- a/lib/build/emailverification-shared2.js +++ b/lib/build/emailverification-shared2.js @@ -6,7 +6,7 @@ var superTokens = require("./superTokens.js"); var uiEntry = require("./index2.js"); var styles = - '/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n\n/*\n * Default styles.\n */\n\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n\n/* TODO: split the link style into separate things*/\n\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="inputContainer"] {\n margin-top: 6px;\n}\n\n[data-supertokens~="inputWrapper"] {\n box-sizing: border-box;\n width: 100%;\n display: flex;\n align-items: center;\n background-color: rgb(var(--palette-inputBackground));\n height: 34px;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n}\n\n[data-supertokens~="inputWrapper"][focus-within] {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputWrapper"]:focus-within {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"][focus-within] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"]:focus-within {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="input"] {\n box-sizing: border-box;\n padding-left: 15px;\n filter: none;\n color: rgb(var(--palette-textInput));\n background-color: transparent;\n border-radius: 6px;\n font-size: var(--font-size-1);\n border: none;\n padding-right: 25px;\n letter-spacing: 1.2px;\n flex: 9 1 75%;\n width: 75%;\n height: 32px;\n}\n\n[data-supertokens~="input"]:focus {\n border: none;\n outline: none;\n}\n\n[data-supertokens~="input"]:-webkit-autofill,\n[data-supertokens~="input"]:-webkit-autofill:hover,\n[data-supertokens~="input"]:-webkit-autofill:focus,\n[data-supertokens~="input"]:-webkit-autofill:active {\n -webkit-text-fill-color: rgb(var(--palette-textInput));\n box-shadow: 0 0 0 30px rgb(var(--palette-inputBackground)) inset;\n}\n\n[data-supertokens~="inputAdornment"] {\n justify-content: center;\n margin-right: 5px;\n}\n\n[data-supertokens~="showPassword"] {\n cursor: pointer;\n}\n\n[data-supertokens~="enterEmailSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n word-break: break-word;\n}\n\n[data-supertokens~="submitNewPasswordSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n}\n\n[data-supertokens~="inputErrorMessage"] {\n padding-top: 5px;\n padding-bottom: 5px;\n color: rgb(var(--palette-error));\n line-height: 24px;\n font-weight: 400;\n font-size: var(--font-size-1);\n text-align: left;\n animation: slideTop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;\n max-width: 330px;\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="inputErrorMessage"] {\n max-width: 250px;\n }\n}\n\n[data-supertokens~="inputErrorSymbol"] {\n margin-right: 5px;\n top: 1px;\n position: relative;\n left: 2px;\n}\n\n[data-supertokens~="label"] {\n text-align: left;\n font-weight: 500;\n font-size: var(--font-size-1);\n line-height: 24px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="formRow"] {\n display: flex;\n flex-direction: column;\n padding-top: 0px;\n padding-bottom: 20px;\n}\n\n[data-supertokens~="formRow"][data-supertokens~="hasError"] {\n padding-bottom: 0;\n}\n\n[data-supertokens~="formRow"]:last-child {\n padding-bottom: 0;\n}\n\n[data-supertokens~="sendVerifyEmailIcon"] {\n margin-top: 11px;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="sendVerifyEmailText"] {\n line-height: 21px;\n font-size: var(--font-size-1);\n text-align: center;\n font-weight: 300;\n letter-spacing: 0.8px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="sendVerifyEmailResend"] {\n margin-top: 13px;\n font-weight: 300;\n}\n\n[data-supertokens~="sendVerifyEmailResend"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="noFormRow"] {\n padding-bottom: 25px;\n}\n\n[data-supertokens~="emailVerificationButtonWrapper"] {\n padding-top: 25px;\n max-width: 96px;\n margin: 0 auto;\n}\n\n[data-supertokens~="resendEmailLink"] {\n display: inline-block;\n}\n\n[data-supertokens~="resetPasswordEmailForm"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="resetPasswordPasswordForm"] {\n padding-bottom: 20px;\n}\n'; + '/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n\n/*\n * Default styles.\n */\n\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n\n/* TODO: split the link style into separate things*/\n\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}\n\n[data-supertokens~="inputContainer"] {\n margin-top: 6px;\n}\n\n[data-supertokens~="inputWrapper"] {\n box-sizing: border-box;\n width: 100%;\n display: flex;\n align-items: center;\n background-color: rgb(var(--palette-inputBackground));\n height: 34px;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n}\n\n[data-supertokens~="inputWrapper"][focus-within] {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputWrapper"]:focus-within {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"][focus-within] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"]:focus-within {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="input"] {\n box-sizing: border-box;\n padding-left: 15px;\n filter: none;\n color: rgb(var(--palette-textInput));\n background-color: transparent;\n border-radius: 6px;\n font-size: var(--font-size-1);\n border: none;\n padding-right: 25px;\n letter-spacing: 1.2px;\n flex: 9 1 75%;\n width: 75%;\n height: 32px;\n}\n\n[data-supertokens~="input"]:focus {\n border: none;\n outline: none;\n}\n\n[data-supertokens~="input"]:-webkit-autofill,\n[data-supertokens~="input"]:-webkit-autofill:hover,\n[data-supertokens~="input"]:-webkit-autofill:focus,\n[data-supertokens~="input"]:-webkit-autofill:active {\n -webkit-text-fill-color: rgb(var(--palette-textInput));\n box-shadow: 0 0 0 30px rgb(var(--palette-inputBackground)) inset;\n}\n\n[data-supertokens~="inputAdornment"] {\n justify-content: center;\n margin-right: 5px;\n}\n\n[data-supertokens~="showPassword"] {\n cursor: pointer;\n}\n\n[data-supertokens~="enterEmailSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n word-break: break-word;\n}\n\n[data-supertokens~="submitNewPasswordSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n}\n\n[data-supertokens~="inputErrorMessage"] {\n padding-top: 5px;\n padding-bottom: 5px;\n color: rgb(var(--palette-error));\n line-height: 24px;\n font-weight: 400;\n font-size: var(--font-size-1);\n text-align: left;\n animation: slideTop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;\n max-width: 330px;\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="inputErrorMessage"] {\n max-width: 250px;\n }\n}\n\n[data-supertokens~="inputErrorSymbol"] {\n margin-right: 5px;\n top: 1px;\n position: relative;\n left: 2px;\n}\n\n[data-supertokens~="label"] {\n text-align: left;\n font-weight: 500;\n font-size: var(--font-size-1);\n line-height: 24px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="formRow"] {\n display: flex;\n flex-direction: column;\n padding-top: 0px;\n padding-bottom: 20px;\n}\n\n[data-supertokens~="formRow"][data-supertokens~="hasError"] {\n padding-bottom: 0;\n}\n\n[data-supertokens~="formRow"]:last-child {\n padding-bottom: 0;\n}\n\n[data-supertokens~="sendVerifyEmailIcon"] {\n margin-top: 11px;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="sendVerifyEmailText"] {\n line-height: 21px;\n font-size: var(--font-size-1);\n text-align: center;\n font-weight: 300;\n letter-spacing: 0.8px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="sendVerifyEmailResend"] {\n margin-top: 13px;\n font-weight: 300;\n}\n\n[data-supertokens~="sendVerifyEmailResend"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="noFormRow"] {\n padding-bottom: 25px;\n}\n\n[data-supertokens~="emailVerificationButtonWrapper"] {\n padding-top: 25px;\n max-width: 96px;\n margin: 0 auto;\n}\n\n[data-supertokens~="resendEmailLink"] {\n display: inline-block;\n}\n\n[data-supertokens~="resetPasswordEmailForm"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="resetPasswordPasswordForm"] {\n padding-bottom: 20px;\n}\n'; var ThemeBase = function (_a) { var children = _a.children, diff --git a/lib/build/index2.js b/lib/build/index2.js index 92bd7b221..61f093552 100644 --- a/lib/build/index2.js +++ b/lib/build/index2.js @@ -122,7 +122,7 @@ var withOverride = function (overrideKey, DefaultComponent) { }; var styles$1 = - '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n'; + '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}\n'; var ThemeBase$1 = function (_a) { var children = _a.children, @@ -488,7 +488,7 @@ function GeneralError(_a) { } var styles = - '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n'; + '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}'; var ThemeBase = function (_a) { var children = _a.children, @@ -668,10 +668,16 @@ var AuthPageHeader = withOverride("AuthPageHeader", function AuthPageHeader(_a) isSignUp = _a.isSignUp, showBackButton = _a.showBackButton, resetFactorList = _a.resetFactorList, - clientAppName = _a.clientAppName; + oauth2ClientInfo = _a.oauth2ClientInfo; var t = translationContext.useTranslation(); return jsxRuntime.jsxs(React.Fragment, { children: [ + (oauth2ClientInfo === null || oauth2ClientInfo === void 0 ? void 0 : oauth2ClientInfo.clientLogoUri) && + jsxRuntime.jsx("img", { + src: oauth2ClientInfo.clientLogoUri, + alt: oauth2ClientInfo.clientName, + "data-supertokens": "authPageTitleOAuthClientLogo", + }), jsxRuntime.jsxs( "div", superTokens.__assign( @@ -688,13 +694,41 @@ var AuthPageHeader = withOverride("AuthPageHeader", function AuthPageHeader(_a) : isSignUp ? t("AUTH_PAGE_HEADER_TITLE_SIGN_UP") : t("AUTH_PAGE_HEADER_TITLE_SIGN_IN"), - clientAppName && - "".concat(t("AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP")).concat(t(clientAppName)), jsxRuntime.jsx("span", { "data-supertokens": "backButtonPlaceholder backButtonCommon" }), ], } ) ), + oauth2ClientInfo && + jsxRuntime.jsxs( + "div", + superTokens.__assign( + { "data-supertokens": "authPageTitleOAuthClient" }, + { + children: [ + t("AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP"), + oauth2ClientInfo.clientUri !== undefined + ? jsxRuntime.jsx( + "a", + superTokens.__assign( + { + "data-supertokens": "authPageTitleOAuthClientUrl link", + href: oauth2ClientInfo.clientUri, + }, + { children: oauth2ClientInfo.clientName } + ) + ) + : jsxRuntime.jsx( + "span", + superTokens.__assign( + { "data-supertokens": "authPageTitleOAuthClientName" }, + { children: oauth2ClientInfo.clientName } + ) + ), + ], + } + ) + ), hasSeparateSignUpView && (!isSignUp ? jsxRuntime.jsxs( @@ -773,7 +807,7 @@ function AuthPageTheme(props) { hasSeparateSignUpView: props.hasSeparateSignUpView, resetFactorList: props.resetFactorList, showBackButton: props.showBackButton, - clientAppName: props.clientAppName, + oauth2ClientInfo: props.oauth2ClientInfo, }), props.error !== undefined && jsxRuntime.jsx(GeneralError, { error: props.error }), jsxRuntime.jsx(AuthPageComponentList, superTokens.__assign({}, props)), @@ -1102,8 +1136,7 @@ var AuthPageInner = function (props) { var childProps = authComponentListInfo !== undefined && (loginChallenge === null || oauth2ClientInfo !== undefined) ? superTokens.__assign(superTokens.__assign({}, authComponentListInfo), { - clientAppName: - oauth2ClientInfo === null || oauth2ClientInfo === void 0 ? void 0 : oauth2ClientInfo.clientName, + oauth2ClientInfo: oauth2ClientInfo, onAuthSuccess: onAuthSuccess, error: error, onError: function (err) { diff --git a/lib/build/multifactorauthprebuiltui.js b/lib/build/multifactorauthprebuiltui.js index 125f54dc9..b8170b7c1 100644 --- a/lib/build/multifactorauthprebuiltui.js +++ b/lib/build/multifactorauthprebuiltui.js @@ -66,7 +66,7 @@ var NormalisedURLPath__default = /*#__PURE__*/ _interopDefault(NormalisedURLPath var React__namespace = /*#__PURE__*/ _interopNamespace(React); var styles = - '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="mfa"][data-supertokens~="container"] {\n padding-top: 34px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="row"] {\n padding-top: 6px;\n padding-bottom: 6px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="headerTitle"] {\n font-size: var(--font-size-3);\n font-weight: 500;\n line-height: 30px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="factorChooserList"] {\n margin-bottom: 12px;\n}\n[data-supertokens~="factorChooserOption"] {\n display: flex;\n flex-direction: row;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n padding: 20px 16px;\n cursor: pointer;\n margin-top: 12px;\n}\n[data-supertokens~="factorChooserOption"]:hover {\n border: 1px solid rgb(var(--palette-textLink));\n}\n[data-supertokens~="factorOptionText"] {\n flex-grow: 1;\n display: flex;\n flex-direction: column;\n align-items: start;\n text-align: left;\n}\n[data-supertokens~="factorLogo"] {\n flex-grow: 0;\n min-width: 30px;\n text-align: left;\n margin-top: 6px;\n}\n[data-supertokens~="totp"] [data-supertokens~="factorLogo"] {\n margin-top: 3px;\n margin-left: -1px;\n}\n[data-supertokens~="factorName"] {\n color: rgb(var(--palette-textPrimary));\n font-size: var(--font-size-1);\n font-weight: 500;\n margin: 4px;\n}\n[data-supertokens~="factorChooserOption"]:hover [data-supertokens~="factorName"] {\n color: rgb(var(--palette-textLink));\n}\n[data-supertokens~="factorDescription"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-0);\n margin: 4px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n margin-bottom: 26px;\n text-align: right;\n}\n'; + '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}\n[data-supertokens~="mfa"][data-supertokens~="container"] {\n padding-top: 34px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="row"] {\n padding-top: 6px;\n padding-bottom: 6px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="headerTitle"] {\n font-size: var(--font-size-3);\n font-weight: 500;\n line-height: 30px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="factorChooserList"] {\n margin-bottom: 12px;\n}\n[data-supertokens~="factorChooserOption"] {\n display: flex;\n flex-direction: row;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n padding: 20px 16px;\n cursor: pointer;\n margin-top: 12px;\n}\n[data-supertokens~="factorChooserOption"]:hover {\n border: 1px solid rgb(var(--palette-textLink));\n}\n[data-supertokens~="factorOptionText"] {\n flex-grow: 1;\n display: flex;\n flex-direction: column;\n align-items: start;\n text-align: left;\n}\n[data-supertokens~="factorLogo"] {\n flex-grow: 0;\n min-width: 30px;\n text-align: left;\n margin-top: 6px;\n}\n[data-supertokens~="totp"] [data-supertokens~="factorLogo"] {\n margin-top: 3px;\n margin-left: -1px;\n}\n[data-supertokens~="factorName"] {\n color: rgb(var(--palette-textPrimary));\n font-size: var(--font-size-1);\n font-weight: 500;\n margin: 4px;\n}\n[data-supertokens~="factorChooserOption"]:hover [data-supertokens~="factorName"] {\n color: rgb(var(--palette-textLink));\n}\n[data-supertokens~="factorDescription"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-0);\n margin: 4px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n margin-bottom: 26px;\n text-align: right;\n}\n'; var ThemeBase = function (_a) { var children = _a.children, diff --git a/lib/build/passwordlessprebuiltui.js b/lib/build/passwordlessprebuiltui.js index 2a64a89af..514f798c4 100644 --- a/lib/build/passwordlessprebuiltui.js +++ b/lib/build/passwordlessprebuiltui.js @@ -84,7 +84,7 @@ var STGeneralError__default = /*#__PURE__*/ _interopDefault(STGeneralError); var STGeneralError__default$1 = /*#__PURE__*/ _interopDefault(STGeneralError$1); var styles = - '/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n\n/*\n * Default styles.\n */\n\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n\n/* TODO: split the link style into separate things*/\n\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n\n/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="inputContainer"] {\n margin-top: 6px;\n}\n\n[data-supertokens~="inputWrapper"] {\n box-sizing: border-box;\n width: 100%;\n display: flex;\n align-items: center;\n background-color: rgb(var(--palette-inputBackground));\n height: 34px;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n}\n\n[data-supertokens~="inputWrapper"][focus-within] {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputWrapper"]:focus-within {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"][focus-within] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"]:focus-within {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="input"] {\n box-sizing: border-box;\n padding-left: 15px;\n filter: none;\n color: rgb(var(--palette-textInput));\n background-color: transparent;\n border-radius: 6px;\n font-size: var(--font-size-1);\n border: none;\n padding-right: 25px;\n letter-spacing: 1.2px;\n flex: 9 1 75%;\n width: 75%;\n height: 32px;\n}\n\n[data-supertokens~="input"]:focus {\n border: none;\n outline: none;\n}\n\n[data-supertokens~="input"]:-webkit-autofill,\n[data-supertokens~="input"]:-webkit-autofill:hover,\n[data-supertokens~="input"]:-webkit-autofill:focus,\n[data-supertokens~="input"]:-webkit-autofill:active {\n -webkit-text-fill-color: rgb(var(--palette-textInput));\n box-shadow: 0 0 0 30px rgb(var(--palette-inputBackground)) inset;\n}\n\n[data-supertokens~="inputAdornment"] {\n justify-content: center;\n margin-right: 5px;\n}\n\n[data-supertokens~="showPassword"] {\n cursor: pointer;\n}\n\n[data-supertokens~="enterEmailSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n word-break: break-word;\n}\n\n[data-supertokens~="submitNewPasswordSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n}\n\n[data-supertokens~="inputErrorMessage"] {\n padding-top: 5px;\n padding-bottom: 5px;\n color: rgb(var(--palette-error));\n line-height: 24px;\n font-weight: 400;\n font-size: var(--font-size-1);\n text-align: left;\n animation: slideTop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;\n max-width: 330px;\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="inputErrorMessage"] {\n max-width: 250px;\n }\n}\n\n[data-supertokens~="inputErrorSymbol"] {\n margin-right: 5px;\n top: 1px;\n position: relative;\n left: 2px;\n}\n\n[data-supertokens~="label"] {\n text-align: left;\n font-weight: 500;\n font-size: var(--font-size-1);\n line-height: 24px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="formRow"] {\n display: flex;\n flex-direction: column;\n padding-top: 0px;\n padding-bottom: 20px;\n}\n\n[data-supertokens~="formRow"][data-supertokens~="hasError"] {\n padding-bottom: 0;\n}\n\n[data-supertokens~="formRow"]:last-child {\n padding-bottom: 0;\n}\n\n[data-supertokens~="sendVerifyEmailIcon"] {\n margin-top: 11px;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="sendVerifyEmailText"] {\n line-height: 21px;\n font-size: var(--font-size-1);\n text-align: center;\n font-weight: 300;\n letter-spacing: 0.8px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="sendVerifyEmailResend"] {\n margin-top: 13px;\n font-weight: 300;\n}\n\n[data-supertokens~="sendVerifyEmailResend"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="noFormRow"] {\n padding-bottom: 25px;\n}\n\n[data-supertokens~="emailVerificationButtonWrapper"] {\n padding-top: 25px;\n max-width: 96px;\n margin: 0 auto;\n}\n\n[data-supertokens~="resendEmailLink"] {\n display: inline-block;\n}\n\n[data-supertokens~="resetPasswordEmailForm"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="resetPasswordPasswordForm"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="generalSuccess"] {\n margin-bottom: 20px;\n animation: swingIn 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) alternate 2 both;\n}\n\n[data-supertokens~="headerSubtitle"] strong {\n max-width: 100%;\n display: inline-block;\n vertical-align: bottom;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n[data-supertokens~="sendCodeText"] {\n margin-top: 15px;\n margin-bottom: 20px;\n}\n\n[data-supertokens~="sendCodeText"] strong {\n max-width: 100%;\n display: inline-block;\n vertical-align: bottom;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n[data-supertokens~="phoneInputLibRoot"] {\n display: flex;\n align-items: center;\n}\n\n[data-supertokens~="phoneInputWrapper"] {\n display: flex;\n align-items: center;\n}\n\ninput[type="tel"][data-supertokens~="input-phoneNumber"] {\n padding-left: 15px;\n}\n\n[data-supertokens~="phoneInputWrapper"] .iti {\n flex: 1 1;\n min-width: 0;\n width: 100%;\n background: transparent;\n border: none;\n color: inherit;\n outline: none;\n}\n\n[data-supertokens~="continueButtonWrapper"] {\n margin-top: 10px;\n margin-bottom: 30px;\n}\n\n.iti__country-list {\n border: 0;\n top: 40px;\n width: min(72.2vw, 320px);\n border-radius: 6;\n box-shadow: 0px 0px 3px 0px rgba(0, 0, 0, 0.16);\n}\n\n.iti__country {\n display: flex;\n align-items: center;\n height: 34px;\n cursor: pointer;\n\n padding: 0 8px;\n}\n\n.iti__country-name {\n color: var(--palette-textLabel);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n margin: "0 16px";\n}\n\n[data-supertokens~="continueWithPasswordlessButtonWrapper"] {\n margin: 9px 0;\n}\n\n[data-supertokens~="continueWithPasswordlessLink"] {\n margin-top: 9px;\n}\n'; + '/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n\n/*\n * Default styles.\n */\n\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n\n/* TODO: split the link style into separate things*/\n\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}\n\n/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="inputContainer"] {\n margin-top: 6px;\n}\n\n[data-supertokens~="inputWrapper"] {\n box-sizing: border-box;\n width: 100%;\n display: flex;\n align-items: center;\n background-color: rgb(var(--palette-inputBackground));\n height: 34px;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n}\n\n[data-supertokens~="inputWrapper"][focus-within] {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputWrapper"]:focus-within {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"][focus-within] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"]:focus-within {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="input"] {\n box-sizing: border-box;\n padding-left: 15px;\n filter: none;\n color: rgb(var(--palette-textInput));\n background-color: transparent;\n border-radius: 6px;\n font-size: var(--font-size-1);\n border: none;\n padding-right: 25px;\n letter-spacing: 1.2px;\n flex: 9 1 75%;\n width: 75%;\n height: 32px;\n}\n\n[data-supertokens~="input"]:focus {\n border: none;\n outline: none;\n}\n\n[data-supertokens~="input"]:-webkit-autofill,\n[data-supertokens~="input"]:-webkit-autofill:hover,\n[data-supertokens~="input"]:-webkit-autofill:focus,\n[data-supertokens~="input"]:-webkit-autofill:active {\n -webkit-text-fill-color: rgb(var(--palette-textInput));\n box-shadow: 0 0 0 30px rgb(var(--palette-inputBackground)) inset;\n}\n\n[data-supertokens~="inputAdornment"] {\n justify-content: center;\n margin-right: 5px;\n}\n\n[data-supertokens~="showPassword"] {\n cursor: pointer;\n}\n\n[data-supertokens~="enterEmailSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n word-break: break-word;\n}\n\n[data-supertokens~="submitNewPasswordSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n}\n\n[data-supertokens~="inputErrorMessage"] {\n padding-top: 5px;\n padding-bottom: 5px;\n color: rgb(var(--palette-error));\n line-height: 24px;\n font-weight: 400;\n font-size: var(--font-size-1);\n text-align: left;\n animation: slideTop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;\n max-width: 330px;\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="inputErrorMessage"] {\n max-width: 250px;\n }\n}\n\n[data-supertokens~="inputErrorSymbol"] {\n margin-right: 5px;\n top: 1px;\n position: relative;\n left: 2px;\n}\n\n[data-supertokens~="label"] {\n text-align: left;\n font-weight: 500;\n font-size: var(--font-size-1);\n line-height: 24px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="formRow"] {\n display: flex;\n flex-direction: column;\n padding-top: 0px;\n padding-bottom: 20px;\n}\n\n[data-supertokens~="formRow"][data-supertokens~="hasError"] {\n padding-bottom: 0;\n}\n\n[data-supertokens~="formRow"]:last-child {\n padding-bottom: 0;\n}\n\n[data-supertokens~="sendVerifyEmailIcon"] {\n margin-top: 11px;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="sendVerifyEmailText"] {\n line-height: 21px;\n font-size: var(--font-size-1);\n text-align: center;\n font-weight: 300;\n letter-spacing: 0.8px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="sendVerifyEmailResend"] {\n margin-top: 13px;\n font-weight: 300;\n}\n\n[data-supertokens~="sendVerifyEmailResend"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="noFormRow"] {\n padding-bottom: 25px;\n}\n\n[data-supertokens~="emailVerificationButtonWrapper"] {\n padding-top: 25px;\n max-width: 96px;\n margin: 0 auto;\n}\n\n[data-supertokens~="resendEmailLink"] {\n display: inline-block;\n}\n\n[data-supertokens~="resetPasswordEmailForm"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="resetPasswordPasswordForm"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="generalSuccess"] {\n margin-bottom: 20px;\n animation: swingIn 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) alternate 2 both;\n}\n\n[data-supertokens~="headerSubtitle"] strong {\n max-width: 100%;\n display: inline-block;\n vertical-align: bottom;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n[data-supertokens~="sendCodeText"] {\n margin-top: 15px;\n margin-bottom: 20px;\n}\n\n[data-supertokens~="sendCodeText"] strong {\n max-width: 100%;\n display: inline-block;\n vertical-align: bottom;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n[data-supertokens~="phoneInputLibRoot"] {\n display: flex;\n align-items: center;\n}\n\n[data-supertokens~="phoneInputWrapper"] {\n display: flex;\n align-items: center;\n}\n\ninput[type="tel"][data-supertokens~="input-phoneNumber"] {\n padding-left: 15px;\n}\n\n[data-supertokens~="phoneInputWrapper"] .iti {\n flex: 1 1;\n min-width: 0;\n width: 100%;\n background: transparent;\n border: none;\n color: inherit;\n outline: none;\n}\n\n[data-supertokens~="continueButtonWrapper"] {\n margin-top: 10px;\n margin-bottom: 30px;\n}\n\n.iti__country-list {\n border: 0;\n top: 40px;\n width: min(72.2vw, 320px);\n border-radius: 6;\n box-shadow: 0px 0px 3px 0px rgba(0, 0, 0, 0.16);\n}\n\n.iti__country {\n display: flex;\n align-items: center;\n height: 34px;\n cursor: pointer;\n\n padding: 0 8px;\n}\n\n.iti__country-name {\n color: var(--palette-textLabel);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n margin: "0 16px";\n}\n\n[data-supertokens~="continueWithPasswordlessButtonWrapper"] {\n margin: 9px 0;\n}\n\n[data-supertokens~="continueWithPasswordlessLink"] {\n margin-top: 9px;\n}\n'; var ThemeBase = function (_a) { var children = _a.children, diff --git a/lib/build/recipe/authRecipe/components/theme/authPage/authPageHeader.d.ts b/lib/build/recipe/authRecipe/components/theme/authPage/authPageHeader.d.ts index eff8b2713..bd8b9fd2a 100644 --- a/lib/build/recipe/authRecipe/components/theme/authPage/authPageHeader.d.ts +++ b/lib/build/recipe/authRecipe/components/theme/authPage/authPageHeader.d.ts @@ -6,5 +6,11 @@ export declare const AuthPageHeader: import("react").ComponentType<{ onSignInUpSwitcherClick: (() => void) | undefined; resetFactorList: () => void; showBackButton: boolean; - clientAppName?: string | undefined; + oauth2ClientInfo?: + | { + clientLogoUri?: string | undefined; + clientUri?: string | undefined; + clientName: string; + } + | undefined; }>; diff --git a/lib/build/recipe/authRecipe/types.d.ts b/lib/build/recipe/authRecipe/types.d.ts index 1f8562b45..2111f5f31 100644 --- a/lib/build/recipe/authRecipe/types.d.ts +++ b/lib/build/recipe/authRecipe/types.d.ts @@ -39,7 +39,11 @@ export declare type AuthSuccessContext = Omit< recipeId: string; }; export declare type AuthPageThemeProps = { - clientAppName: string | undefined; + oauth2ClientInfo?: { + clientLogo?: string; + clientUri?: string; + clientName: string; + }; onAuthSuccess: (successContext: AuthSuccessContext) => Promise; showBackButton: boolean; setFactorList: (factorIds: string[]) => void; diff --git a/lib/build/recipe/oauth2provider/types.d.ts b/lib/build/recipe/oauth2provider/types.d.ts index 16b4ca38e..0221c29c1 100644 --- a/lib/build/recipe/oauth2provider/types.d.ts +++ b/lib/build/recipe/oauth2provider/types.d.ts @@ -33,4 +33,4 @@ export declare type NormalisedConfig = NormalisedRecipeModuleConfig< }; }; export declare type GetRedirectionURLContext = SuccessRedirectContextOAuth2; -export declare type OnHandleEventContext = never; +export declare type OnHandleEventContext = any; diff --git a/lib/build/sessionprebuiltui.js b/lib/build/sessionprebuiltui.js index cd2879394..4641f1636 100644 --- a/lib/build/sessionprebuiltui.js +++ b/lib/build/sessionprebuiltui.js @@ -86,7 +86,7 @@ function LogoutButton(_a) { } var styles = - '/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n\n/*\n * Default styles.\n */\n\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n\n/* TODO: split the link style into separate things*/\n\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n\n/* Override */\n\n[data-supertokens~="accessDenied"] [data-supertokens~="row"] {\n padding-bottom: 24px;\n}\n\n[data-supertokens~="accessDenied"] [data-supertokens~="divider"] {\n padding: 0;\n margin: 34px 0 18px 0;\n}\n\n[data-supertokens~="accessDenied"] [data-supertokens~="headerTitle"] {\n margin: 10px 0 0 0;\n font-style: normal;\n font-weight: 700;\n font-size: 20px;\n line-height: 30px;\n}\n\n/* Override end */\n\n[data-supertokens~="center"] {\n height: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n flex: 1 1 auto;\n}\n\n[data-supertokens~="buttonsGroup"] {\n margin-top: 34px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n[data-supertokens~="buttonBase"] {\n font-family: "Rubik", sans-serif;\n font-size: var(--font-size-1);\n line-height: 21px;\n font-weight: 500;\n background: transparent;\n outline: none;\n border: none;\n cursor: pointer;\n}\n\n[data-supertokens~="backButton"] {\n color: rgb(var(--palette-textLink));\n}\n\n[data-supertokens~="logoutButton"] {\n display: flex;\n align-items: center;\n gap: 6px;\n color: rgb(var(--palette-textGray));\n}\n\n[data-supertokens~="primaryText"][data-supertokens~="accessDeniedError"] {\n font-weight: 400;\n}\n'; + '/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n\n/*\n * Default styles.\n */\n\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n\n/* TODO: split the link style into separate things*/\n\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}\n\n/* Override */\n\n[data-supertokens~="accessDenied"] [data-supertokens~="row"] {\n padding-bottom: 24px;\n}\n\n[data-supertokens~="accessDenied"] [data-supertokens~="divider"] {\n padding: 0;\n margin: 34px 0 18px 0;\n}\n\n[data-supertokens~="accessDenied"] [data-supertokens~="headerTitle"] {\n margin: 10px 0 0 0;\n font-style: normal;\n font-weight: 700;\n font-size: 20px;\n line-height: 30px;\n}\n\n/* Override end */\n\n[data-supertokens~="center"] {\n height: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n flex: 1 1 auto;\n}\n\n[data-supertokens~="buttonsGroup"] {\n margin-top: 34px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n[data-supertokens~="buttonBase"] {\n font-family: "Rubik", sans-serif;\n font-size: var(--font-size-1);\n line-height: 21px;\n font-weight: 500;\n background: transparent;\n outline: none;\n border: none;\n cursor: pointer;\n}\n\n[data-supertokens~="backButton"] {\n color: rgb(var(--palette-textLink));\n}\n\n[data-supertokens~="logoutButton"] {\n display: flex;\n align-items: center;\n gap: 6px;\n color: rgb(var(--palette-textGray));\n}\n\n[data-supertokens~="primaryText"][data-supertokens~="accessDeniedError"] {\n font-weight: 400;\n}\n'; var ThemeBase = function (_a) { var children = _a.children, diff --git a/lib/build/thirdpartyprebuiltui.js b/lib/build/thirdpartyprebuiltui.js index 3d27fc978..816c895a1 100644 --- a/lib/build/thirdpartyprebuiltui.js +++ b/lib/build/thirdpartyprebuiltui.js @@ -74,7 +74,7 @@ var React__namespace = /*#__PURE__*/ _interopNamespace(React); var STGeneralError__default = /*#__PURE__*/ _interopDefault(STGeneralError); var styles = - '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="providerContainer"] {\n padding-top: 9px;\n padding-bottom: 9px;\n}\n[data-supertokens~="button"][data-supertokens~="providerButton"] {\n min-height: 32px;\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 2px 8px;\n\n background-color: white;\n border-color: rgb(221, 221, 221);\n color: black;\n}\n[data-supertokens~="multiFactor"] [data-supertokens~="button"][data-supertokens~="providerButton"] {\n margin: auto;\n max-width: 240px;\n}\n[data-supertokens~="button"][data-supertokens~="providerButton"]:hover {\n filter: none;\n background-color: #fafafa;\n}\n[data-supertokens~="providerButtonLeft"] {\n min-width: 34px;\n margin-left: 66px;\n}\n[data-supertokens~="multiFactor"] [data-supertokens~="providerButtonLeft"] {\n margin-left: 30px;\n}\n[data-supertokens~="providerButtonLogo"] {\n height: 30px;\n display: flex;\n}\n[data-supertokens~="providerButtonLogoCenter"] {\n display: flex;\n margin: auto;\n}\n[data-supertokens~="providerButtonText"] {\n font-weight: 400;\n text-align: center;\n justify-content: center;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n display: inline-block;\n}\n[data-supertokens~="providerButtonText"]:only-child {\n margin: 0 auto;\n}\n'; + '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}\n[data-supertokens~="providerContainer"] {\n padding-top: 9px;\n padding-bottom: 9px;\n}\n[data-supertokens~="button"][data-supertokens~="providerButton"] {\n min-height: 32px;\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 2px 8px;\n\n background-color: white;\n border-color: rgb(221, 221, 221);\n color: black;\n}\n[data-supertokens~="multiFactor"] [data-supertokens~="button"][data-supertokens~="providerButton"] {\n margin: auto;\n max-width: 240px;\n}\n[data-supertokens~="button"][data-supertokens~="providerButton"]:hover {\n filter: none;\n background-color: #fafafa;\n}\n[data-supertokens~="providerButtonLeft"] {\n min-width: 34px;\n margin-left: 66px;\n}\n[data-supertokens~="multiFactor"] [data-supertokens~="providerButtonLeft"] {\n margin-left: 30px;\n}\n[data-supertokens~="providerButtonLogo"] {\n height: 30px;\n display: flex;\n}\n[data-supertokens~="providerButtonLogoCenter"] {\n display: flex;\n margin: auto;\n}\n[data-supertokens~="providerButtonText"] {\n font-weight: 400;\n text-align: center;\n justify-content: center;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n display: inline-block;\n}\n[data-supertokens~="providerButtonText"]:only-child {\n margin: 0 auto;\n}\n'; var ThemeBase = function (_a) { var children = _a.children, diff --git a/lib/build/totpprebuiltui.js b/lib/build/totpprebuiltui.js index 9256ff84c..769b48910 100644 --- a/lib/build/totpprebuiltui.js +++ b/lib/build/totpprebuiltui.js @@ -72,7 +72,7 @@ var React__namespace = /*#__PURE__*/ _interopNamespace(React); var STGeneralError__default = /*#__PURE__*/ _interopDefault(STGeneralError); var styles = - '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n[data-supertokens~="inputContainer"] {\n margin-top: 6px;\n}\n[data-supertokens~="inputWrapper"] {\n box-sizing: border-box;\n width: 100%;\n display: flex;\n align-items: center;\n background-color: rgb(var(--palette-inputBackground));\n height: 34px;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n}\n[data-supertokens~="inputWrapper"][focus-within] {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n[data-supertokens~="inputWrapper"]:focus-within {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n[data-supertokens~="inputError"] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n[data-supertokens~="inputError"][focus-within] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n[data-supertokens~="inputError"]:focus-within {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n[data-supertokens~="input"] {\n box-sizing: border-box;\n padding-left: 15px;\n filter: none;\n color: rgb(var(--palette-textInput));\n background-color: transparent;\n border-radius: 6px;\n font-size: var(--font-size-1);\n border: none;\n padding-right: 25px;\n letter-spacing: 1.2px;\n flex: 9 1 75%;\n width: 75%;\n height: 32px;\n}\n[data-supertokens~="input"]:focus {\n border: none;\n outline: none;\n}\n[data-supertokens~="input"]:-webkit-autofill,\n[data-supertokens~="input"]:-webkit-autofill:hover,\n[data-supertokens~="input"]:-webkit-autofill:focus,\n[data-supertokens~="input"]:-webkit-autofill:active {\n -webkit-text-fill-color: rgb(var(--palette-textInput));\n box-shadow: 0 0 0 30px rgb(var(--palette-inputBackground)) inset;\n}\n[data-supertokens~="inputAdornment"] {\n justify-content: center;\n margin-right: 5px;\n}\n[data-supertokens~="showPassword"] {\n cursor: pointer;\n}\n[data-supertokens~="enterEmailSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n word-break: break-word;\n}\n[data-supertokens~="submitNewPasswordSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n}\n[data-supertokens~="inputErrorMessage"] {\n padding-top: 5px;\n padding-bottom: 5px;\n color: rgb(var(--palette-error));\n line-height: 24px;\n font-weight: 400;\n font-size: var(--font-size-1);\n text-align: left;\n animation: slideTop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;\n max-width: 330px;\n}\n@media (max-width: 440px) {\n [data-supertokens~="inputErrorMessage"] {\n max-width: 250px;\n }\n}\n[data-supertokens~="inputErrorSymbol"] {\n margin-right: 5px;\n top: 1px;\n position: relative;\n left: 2px;\n}\n[data-supertokens~="label"] {\n text-align: left;\n font-weight: 500;\n font-size: var(--font-size-1);\n line-height: 24px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="formRow"] {\n display: flex;\n flex-direction: column;\n padding-top: 0px;\n padding-bottom: 20px;\n}\n[data-supertokens~="formRow"][data-supertokens~="hasError"] {\n padding-bottom: 0;\n}\n[data-supertokens~="formRow"]:last-child {\n padding-bottom: 0;\n}\n[data-supertokens~="sendVerifyEmailIcon"] {\n margin-top: 11px;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="sendVerifyEmailText"] {\n line-height: 21px;\n font-size: var(--font-size-1);\n text-align: center;\n font-weight: 300;\n letter-spacing: 0.8px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="sendVerifyEmailResend"] {\n margin-top: 13px;\n font-weight: 300;\n}\n[data-supertokens~="sendVerifyEmailResend"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="noFormRow"] {\n padding-bottom: 25px;\n}\n[data-supertokens~="emailVerificationButtonWrapper"] {\n padding-top: 25px;\n max-width: 96px;\n margin: 0 auto;\n}\n[data-supertokens~="resendEmailLink"] {\n display: inline-block;\n}\n[data-supertokens~="resetPasswordEmailForm"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="resetPasswordPasswordForm"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="totp"] [data-supertokens~="container"] {\n padding-top: 24px;\n}\n[data-supertokens~="totp"] [data-supertokens~="divider"] {\n margin-top: 20px;\n margin-bottom: 20px;\n}\n[data-supertokens~="totp"] [data-supertokens~="row"] {\n padding-top: 16px;\n padding-bottom: 8px;\n width: auto;\n margin: 0 50px;\n}\n[data-supertokens~="totpDeviceQR"] {\n border-radius: 12px;\n border: 1px solid rgb(var(--palette-inputBorder));\n padding: 16px;\n max-width: 172px;\n max-height: 172px;\n}\n[data-supertokens~="showTOTPSecret"] {\n display: block;\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-0);\n margin: 16px 0 12px;\n}\n[data-supertokens~="totpSecret"] {\n display: block;\n border-radius: 6px;\n padding: 7px 15px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n font-weight: 600;\n letter-spacing: 3.36px;\n background: rgba(var(--palette-textLink), 0.08);\n word-wrap: break-word;\n overflow-y: hidden;\n}\nbutton[data-supertokens~="showTOTPSecretBtn"] {\n font-size: 12px;\n}\n[data-supertokens~="showTOTPSecretBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="retryCodeBtn"]:disabled {\n border: 0;\n border-radius: 6px;\n color: rgb(var(--palette-error));\n background: rgb(var(--palette-errorBackground));\n}\n'; + '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}\n/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n[data-supertokens~="inputContainer"] {\n margin-top: 6px;\n}\n[data-supertokens~="inputWrapper"] {\n box-sizing: border-box;\n width: 100%;\n display: flex;\n align-items: center;\n background-color: rgb(var(--palette-inputBackground));\n height: 34px;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n}\n[data-supertokens~="inputWrapper"][focus-within] {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n[data-supertokens~="inputWrapper"]:focus-within {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n[data-supertokens~="inputError"] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n[data-supertokens~="inputError"][focus-within] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n[data-supertokens~="inputError"]:focus-within {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n[data-supertokens~="input"] {\n box-sizing: border-box;\n padding-left: 15px;\n filter: none;\n color: rgb(var(--palette-textInput));\n background-color: transparent;\n border-radius: 6px;\n font-size: var(--font-size-1);\n border: none;\n padding-right: 25px;\n letter-spacing: 1.2px;\n flex: 9 1 75%;\n width: 75%;\n height: 32px;\n}\n[data-supertokens~="input"]:focus {\n border: none;\n outline: none;\n}\n[data-supertokens~="input"]:-webkit-autofill,\n[data-supertokens~="input"]:-webkit-autofill:hover,\n[data-supertokens~="input"]:-webkit-autofill:focus,\n[data-supertokens~="input"]:-webkit-autofill:active {\n -webkit-text-fill-color: rgb(var(--palette-textInput));\n box-shadow: 0 0 0 30px rgb(var(--palette-inputBackground)) inset;\n}\n[data-supertokens~="inputAdornment"] {\n justify-content: center;\n margin-right: 5px;\n}\n[data-supertokens~="showPassword"] {\n cursor: pointer;\n}\n[data-supertokens~="enterEmailSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n word-break: break-word;\n}\n[data-supertokens~="submitNewPasswordSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n}\n[data-supertokens~="inputErrorMessage"] {\n padding-top: 5px;\n padding-bottom: 5px;\n color: rgb(var(--palette-error));\n line-height: 24px;\n font-weight: 400;\n font-size: var(--font-size-1);\n text-align: left;\n animation: slideTop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;\n max-width: 330px;\n}\n@media (max-width: 440px) {\n [data-supertokens~="inputErrorMessage"] {\n max-width: 250px;\n }\n}\n[data-supertokens~="inputErrorSymbol"] {\n margin-right: 5px;\n top: 1px;\n position: relative;\n left: 2px;\n}\n[data-supertokens~="label"] {\n text-align: left;\n font-weight: 500;\n font-size: var(--font-size-1);\n line-height: 24px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="formRow"] {\n display: flex;\n flex-direction: column;\n padding-top: 0px;\n padding-bottom: 20px;\n}\n[data-supertokens~="formRow"][data-supertokens~="hasError"] {\n padding-bottom: 0;\n}\n[data-supertokens~="formRow"]:last-child {\n padding-bottom: 0;\n}\n[data-supertokens~="sendVerifyEmailIcon"] {\n margin-top: 11px;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="sendVerifyEmailText"] {\n line-height: 21px;\n font-size: var(--font-size-1);\n text-align: center;\n font-weight: 300;\n letter-spacing: 0.8px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="sendVerifyEmailResend"] {\n margin-top: 13px;\n font-weight: 300;\n}\n[data-supertokens~="sendVerifyEmailResend"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="noFormRow"] {\n padding-bottom: 25px;\n}\n[data-supertokens~="emailVerificationButtonWrapper"] {\n padding-top: 25px;\n max-width: 96px;\n margin: 0 auto;\n}\n[data-supertokens~="resendEmailLink"] {\n display: inline-block;\n}\n[data-supertokens~="resetPasswordEmailForm"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="resetPasswordPasswordForm"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="totp"] [data-supertokens~="container"] {\n padding-top: 24px;\n}\n[data-supertokens~="totp"] [data-supertokens~="divider"] {\n margin-top: 20px;\n margin-bottom: 20px;\n}\n[data-supertokens~="totp"] [data-supertokens~="row"] {\n padding-top: 16px;\n padding-bottom: 8px;\n width: auto;\n margin: 0 50px;\n}\n[data-supertokens~="totpDeviceQR"] {\n border-radius: 12px;\n border: 1px solid rgb(var(--palette-inputBorder));\n padding: 16px;\n max-width: 172px;\n max-height: 172px;\n}\n[data-supertokens~="showTOTPSecret"] {\n display: block;\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-0);\n margin: 16px 0 12px;\n}\n[data-supertokens~="totpSecret"] {\n display: block;\n border-radius: 6px;\n padding: 7px 15px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n font-weight: 600;\n letter-spacing: 3.36px;\n background: rgba(var(--palette-textLink), 0.08);\n word-wrap: break-word;\n overflow-y: hidden;\n}\nbutton[data-supertokens~="showTOTPSecretBtn"] {\n font-size: 12px;\n}\n[data-supertokens~="showTOTPSecretBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="retryCodeBtn"]:disabled {\n border: 0;\n border-radius: 6px;\n color: rgb(var(--palette-error));\n background: rgb(var(--palette-errorBackground));\n}\n'; var ThemeBase = function (_a) { var children = _a.children, diff --git a/lib/build/ui/index.d.ts b/lib/build/ui/index.d.ts index bcd8d6aec..fc3c5e56a 100644 --- a/lib/build/ui/index.d.ts +++ b/lib/build/ui/index.d.ts @@ -41,7 +41,13 @@ declare class UI { onSignInUpSwitcherClick: (() => void) | undefined; resetFactorList: () => void; showBackButton: boolean; - clientAppName?: string | undefined; + oauthClientInfo?: + | { + clientLogo?: string | undefined; + clientUri?: string | undefined; + clientAppName?: string | undefined; + } + | undefined; }>; static AuthPageComponentList: React.ComponentType; static AuthRecipeComponentsOverrideContextProvider: React.FC< diff --git a/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx b/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx index 358b5f1e3..de23b96b3 100644 --- a/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx +++ b/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx @@ -308,7 +308,7 @@ const AuthPageInner: React.FC = (props) => { authComponentListInfo !== undefined && (loginChallenge === null || oauth2ClientInfo !== undefined) ? { ...authComponentListInfo, - clientAppName: oauth2ClientInfo?.clientName, + oauth2ClientInfo, onAuthSuccess, error, onError: (err) => { diff --git a/lib/ts/recipe/authRecipe/components/theme/authPage/authPageHeader.tsx b/lib/ts/recipe/authRecipe/components/theme/authPage/authPageHeader.tsx index 724defeef..993300172 100644 --- a/lib/ts/recipe/authRecipe/components/theme/authPage/authPageHeader.tsx +++ b/lib/ts/recipe/authRecipe/components/theme/authPage/authPageHeader.tsx @@ -26,7 +26,7 @@ export const AuthPageHeader = withOverride( isSignUp, showBackButton, resetFactorList, - clientAppName, + oauth2ClientInfo, }: { factorIds: string[]; isSignUp: boolean; @@ -34,12 +34,23 @@ export const AuthPageHeader = withOverride( onSignInUpSwitcherClick: (() => void) | undefined; resetFactorList: () => void; showBackButton: boolean; - clientAppName?: string; + oauth2ClientInfo?: { + clientLogoUri?: string; + clientUri?: string; + clientName: string; + }; }): JSX.Element { const t = useTranslation(); return ( + {oauth2ClientInfo?.clientLogoUri && ( + {oauth2ClientInfo.clientName} + )}
{showBackButton ? ( @@ -53,11 +64,22 @@ export const AuthPageHeader = withOverride( : isSignUp ? t("AUTH_PAGE_HEADER_TITLE_SIGN_UP") : t("AUTH_PAGE_HEADER_TITLE_SIGN_IN")} - {clientAppName && `${t("AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP")}${t(clientAppName)}`} {/* empty span for spacing the back button */}
+ {oauth2ClientInfo && ( +
+ {t("AUTH_PAGE_HEADER_TITLE_SIGN_IN_UP_TO_APP")} + {oauth2ClientInfo.clientUri !== undefined ? ( + + {oauth2ClientInfo.clientName} + + ) : ( + {oauth2ClientInfo.clientName} + )} +
+ )} {hasSeparateSignUpView && (!isSignUp ? (
diff --git a/lib/ts/recipe/authRecipe/components/theme/authPage/index.tsx b/lib/ts/recipe/authRecipe/components/theme/authPage/index.tsx index b5d3fa9b4..c0c3070ca 100644 --- a/lib/ts/recipe/authRecipe/components/theme/authPage/index.tsx +++ b/lib/ts/recipe/authRecipe/components/theme/authPage/index.tsx @@ -51,7 +51,7 @@ export function AuthPageTheme(props: AuthPageThemeProps): JSX.Element { hasSeparateSignUpView={props.hasSeparateSignUpView} resetFactorList={props.resetFactorList} showBackButton={props.showBackButton} - clientAppName={props.clientAppName} + oauth2ClientInfo={props.oauth2ClientInfo} /> {props.error !== undefined && } diff --git a/lib/ts/recipe/authRecipe/types.ts b/lib/ts/recipe/authRecipe/types.ts index 19847895a..e41837acd 100644 --- a/lib/ts/recipe/authRecipe/types.ts +++ b/lib/ts/recipe/authRecipe/types.ts @@ -59,7 +59,11 @@ export type AuthSuccessContext = Omit< > & { recipeId: string }; export type AuthPageThemeProps = { - clientAppName: string | undefined; + oauth2ClientInfo?: { + clientLogo?: string; + clientUri?: string; + clientName: string; + }; onAuthSuccess: (successContext: AuthSuccessContext) => Promise; showBackButton: boolean; diff --git a/lib/ts/recipe/oauth2provider/types.ts b/lib/ts/recipe/oauth2provider/types.ts index bcb7323f4..0a43695f2 100644 --- a/lib/ts/recipe/oauth2provider/types.ts +++ b/lib/ts/recipe/oauth2provider/types.ts @@ -39,4 +39,4 @@ export type NormalisedConfig = NormalisedRecipeModuleConfig< export type GetRedirectionURLContext = SuccessRedirectContextOAuth2; -export type OnHandleEventContext = never; +export type OnHandleEventContext = any; diff --git a/lib/ts/styles/styles.css b/lib/ts/styles/styles.css index 766df0a41..d05bf1c75 100644 --- a/lib/ts/styles/styles.css +++ b/lib/ts/styles/styles.css @@ -383,3 +383,24 @@ [data-supertokens~="authComponentList"] { padding-bottom: 20px; } + +[data-supertokens~="authPageTitleOAuthClient"] { + color: rgb(var(--palette-textGray)); + font-size: var(--font-size-1); + font-weight: 400; + margin: 10px 0 25px; +} + +[data-supertokens~="authPageTitleOAuthClientUrl"] { + text-decoration: none; +} + +[data-supertokens~="authPageTitleOAuthClientLogo"] { + width: 44px; + height: 44px; + margin-bottom: 10px; +} + +[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] { + color: rgb(var(--palette-textTitle)); +} diff --git a/stories/allrecipes.stories.tsx b/stories/allrecipes.stories.tsx index 6b13ea26f..6322a8f5f 100644 --- a/stories/allrecipes.stories.tsx +++ b/stories/allrecipes.stories.tsx @@ -141,6 +141,17 @@ export const ResetPasswordLinkClicked: Story = { }, }; +export const OAuth2Login: Story = { + args: { + path: "/auth", + query: "loginChallenge=asdf", + "oauth2.initialized": true, + "oauth2.clientName": "Google", + "oauth2.clientLogoUri": "https://upload.wikimedia.org/wikipedia/commons/c/c1/Google_%22G%22_logo.svg", + "oauth2.clientUri": "https://google.com", + }, +}; + export const ContactFormCombined: Story = { args: { "multifactorauth.firstFactors": ["thirdparty", "emailpassword", "otp-email", "otp-phone"], diff --git a/stories/authPage.stories.tsx b/stories/authPage.stories.tsx index 63618e908..8d04122e9 100644 --- a/stories/authPage.stories.tsx +++ b/stories/authPage.stories.tsx @@ -20,6 +20,10 @@ export type Args = { "passwordless.initialized": boolean; "passwordless.contactMethod": "PHONE" | "EMAIL" | "EMAIL_OR_PHONE"; "passwordless.defaultToEmail": boolean; + "oauth2.initialized": boolean; + "oauth2.clientName": string; + "oauth2.clientLogoUri": string; + "oauth2.clientUri": string; path?: string; query?: string; hash?: string; @@ -104,6 +108,10 @@ const meta: Meta = { "passwordless.contactMethod": "EMAIL_OR_PHONE", "passwordless.defaultToEmail": true, rootStyle: "", + "oauth2.initialized": true, + "oauth2.clientName": "My App", + "oauth2.clientLogoUri": "https://example.com/logo.png", + "oauth2.clientUri": "https://example.com", }, argTypes: { "multifactorauth.initialized": { @@ -211,6 +219,38 @@ const meta: Meta = { truthy: true, }, }, + "oauth2.initialized": { + table: { + category: "oauth2", + }, + }, + "oauth2.clientName": { + table: { + category: "oauth2", + }, + if: { + arg: "oauth2.initialized", + truthy: true, + }, + }, + "oauth2.clientLogoUri": { + table: { + category: "oauth2", + }, + if: { + arg: "oauth2.initialized", + truthy: true, + }, + }, + "oauth2.clientUri": { + table: { + category: "oauth2", + }, + if: { + arg: "oauth2.initialized", + truthy: true, + }, + }, }, }; diff --git a/stories/utils.ts b/stories/utils.ts index 16dcdee89..06183a5ac 100644 --- a/stories/utils.ts +++ b/stories/utils.ts @@ -29,6 +29,7 @@ import SuperTokensWebJS from "supertokens-web-js/lib/build/supertokens"; import { AdditionalLoginAttemptInfoProperties, LoginAttemptInfo } from "../lib/ts/recipe/passwordless/types"; import { WindowHandlerReference } from "supertokens-web-js/utils/windowHandler"; import { PostSuperTokensInitCallbacks } from "supertokens-web-js/utils/postSuperTokensInitCallbacks"; +import OAuth2Provider from "../lib/ts/recipe/oauth2provider/recipe"; export function withFetchResponse(resp: T): T & { fetchResponse: Response } { return resp as any; @@ -125,6 +126,12 @@ export type AuthPageConf = { firstFactors: FirstFactor[]; providers: ProviderId[]; }; + oauth2: { + initialized: boolean; + clientName: string; + clientLogoUri: string; + clientUri: string; + }; }; export function buildInit(args: AuthPageConf, funcOverrides: any) { @@ -213,6 +220,29 @@ export function buildInit(args: AuthPageConf, funcOverrides: any) { ); } + if (args.oauth2.initialized) { + recipeList.push( + OAuth2Provider.init({ + override: { + functions: (oI) => ({ + ...oI, + getLoginChallengeInfo: async () => { + return { + status: "OK", + info: { + clientName: args.oauth2.clientName, + clientLogoUri: args.oauth2.clientLogoUri || undefined, + clientUri: args.oauth2.clientUri || undefined, + }, + fetchResponse: undefined as any, + }; + }, + }), + }, + }) as any + ); + } + return { useShadowDom: false, defaultToSignUp: args.defaultToSignUp, From a297391334074d4fe0bc73e31ddaad35184a4d46 Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Wed, 31 Jul 2024 12:07:59 +0530 Subject: [PATCH 5/9] fix: Rename oauth2 to oauth2provider --- lib/build/emailverification-shared2.js | 2 +- lib/build/index2.js | 4 ++-- lib/build/multifactorauthprebuiltui.js | 2 +- lib/build/oauth2provider-shared.js | 5 ++++- lib/build/passwordlessprebuiltui.js | 2 +- lib/build/sessionprebuiltui.js | 2 +- lib/build/thirdpartyprebuiltui.js | 2 +- lib/build/totpprebuiltui.js | 2 +- lib/build/ui/index.d.ts | 6 +++--- lib/ts/recipe/oauth2provider/recipe.ts | 2 +- package-lock.json | 5 +++-- 11 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/build/emailverification-shared2.js b/lib/build/emailverification-shared2.js index fd3e1549a..054d62c03 100644 --- a/lib/build/emailverification-shared2.js +++ b/lib/build/emailverification-shared2.js @@ -6,7 +6,7 @@ var superTokens = require("./superTokens.js"); var uiEntry = require("./index2.js"); var styles = - '/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n\n/*\n * Default styles.\n */\n\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n\n/* TODO: split the link style into separate things*/\n\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}\n\n[data-supertokens~="inputContainer"] {\n margin-top: 6px;\n}\n\n[data-supertokens~="inputWrapper"] {\n box-sizing: border-box;\n width: 100%;\n display: flex;\n align-items: center;\n background-color: rgb(var(--palette-inputBackground));\n height: 34px;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n}\n\n[data-supertokens~="inputWrapper"][focus-within] {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputWrapper"]:focus-within {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"][focus-within] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"]:focus-within {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="input"] {\n box-sizing: border-box;\n padding-left: 15px;\n filter: none;\n color: rgb(var(--palette-textInput));\n background-color: transparent;\n border-radius: 6px;\n font-size: var(--font-size-1);\n border: none;\n padding-right: 25px;\n letter-spacing: 1.2px;\n flex: 9 1 75%;\n width: 75%;\n height: 32px;\n}\n\n[data-supertokens~="input"]:focus {\n border: none;\n outline: none;\n}\n\n[data-supertokens~="input"]:-webkit-autofill,\n[data-supertokens~="input"]:-webkit-autofill:hover,\n[data-supertokens~="input"]:-webkit-autofill:focus,\n[data-supertokens~="input"]:-webkit-autofill:active {\n -webkit-text-fill-color: rgb(var(--palette-textInput));\n box-shadow: 0 0 0 30px rgb(var(--palette-inputBackground)) inset;\n}\n\n[data-supertokens~="inputAdornment"] {\n justify-content: center;\n margin-right: 5px;\n}\n\n[data-supertokens~="showPassword"] {\n cursor: pointer;\n}\n\n[data-supertokens~="enterEmailSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n word-break: break-word;\n}\n\n[data-supertokens~="submitNewPasswordSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n}\n\n[data-supertokens~="inputErrorMessage"] {\n padding-top: 5px;\n padding-bottom: 5px;\n color: rgb(var(--palette-error));\n line-height: 24px;\n font-weight: 400;\n font-size: var(--font-size-1);\n text-align: left;\n animation: slideTop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;\n max-width: 330px;\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="inputErrorMessage"] {\n max-width: 250px;\n }\n}\n\n[data-supertokens~="inputErrorSymbol"] {\n margin-right: 5px;\n top: 1px;\n position: relative;\n left: 2px;\n}\n\n[data-supertokens~="label"] {\n text-align: left;\n font-weight: 500;\n font-size: var(--font-size-1);\n line-height: 24px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="formRow"] {\n display: flex;\n flex-direction: column;\n padding-top: 0px;\n padding-bottom: 20px;\n}\n\n[data-supertokens~="formRow"][data-supertokens~="hasError"] {\n padding-bottom: 0;\n}\n\n[data-supertokens~="formRow"]:last-child {\n padding-bottom: 0;\n}\n\n[data-supertokens~="sendVerifyEmailIcon"] {\n margin-top: 11px;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="sendVerifyEmailText"] {\n line-height: 21px;\n font-size: var(--font-size-1);\n text-align: center;\n font-weight: 300;\n letter-spacing: 0.8px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="sendVerifyEmailResend"] {\n margin-top: 13px;\n font-weight: 300;\n}\n\n[data-supertokens~="sendVerifyEmailResend"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="noFormRow"] {\n padding-bottom: 25px;\n}\n\n[data-supertokens~="emailVerificationButtonWrapper"] {\n padding-top: 25px;\n max-width: 96px;\n margin: 0 auto;\n}\n\n[data-supertokens~="resendEmailLink"] {\n display: inline-block;\n}\n\n[data-supertokens~="resetPasswordEmailForm"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="resetPasswordPasswordForm"] {\n padding-bottom: 20px;\n}\n'; + '/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n\n/*\n * Default styles.\n */\n\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n\n/* TODO: split the link style into separate things*/\n\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px;\n}\n\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle));\n}\n\n[data-supertokens~="inputContainer"] {\n margin-top: 6px;\n}\n\n[data-supertokens~="inputWrapper"] {\n box-sizing: border-box;\n width: 100%;\n display: flex;\n align-items: center;\n background-color: rgb(var(--palette-inputBackground));\n height: 34px;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n}\n\n[data-supertokens~="inputWrapper"][focus-within] {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputWrapper"]:focus-within {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"][focus-within] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"]:focus-within {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="input"] {\n box-sizing: border-box;\n padding-left: 15px;\n filter: none;\n color: rgb(var(--palette-textInput));\n background-color: transparent;\n border-radius: 6px;\n font-size: var(--font-size-1);\n border: none;\n padding-right: 25px;\n letter-spacing: 1.2px;\n flex: 9 1 75%;\n width: 75%;\n height: 32px;\n}\n\n[data-supertokens~="input"]:focus {\n border: none;\n outline: none;\n}\n\n[data-supertokens~="input"]:-webkit-autofill,\n[data-supertokens~="input"]:-webkit-autofill:hover,\n[data-supertokens~="input"]:-webkit-autofill:focus,\n[data-supertokens~="input"]:-webkit-autofill:active {\n -webkit-text-fill-color: rgb(var(--palette-textInput));\n box-shadow: 0 0 0 30px rgb(var(--palette-inputBackground)) inset;\n}\n\n[data-supertokens~="inputAdornment"] {\n justify-content: center;\n margin-right: 5px;\n}\n\n[data-supertokens~="showPassword"] {\n cursor: pointer;\n}\n\n[data-supertokens~="enterEmailSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n word-break: break-word;\n}\n\n[data-supertokens~="submitNewPasswordSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n}\n\n[data-supertokens~="inputErrorMessage"] {\n padding-top: 5px;\n padding-bottom: 5px;\n color: rgb(var(--palette-error));\n line-height: 24px;\n font-weight: 400;\n font-size: var(--font-size-1);\n text-align: left;\n animation: slideTop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;\n max-width: 330px;\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="inputErrorMessage"] {\n max-width: 250px;\n }\n}\n\n[data-supertokens~="inputErrorSymbol"] {\n margin-right: 5px;\n top: 1px;\n position: relative;\n left: 2px;\n}\n\n[data-supertokens~="label"] {\n text-align: left;\n font-weight: 500;\n font-size: var(--font-size-1);\n line-height: 24px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="formRow"] {\n display: flex;\n flex-direction: column;\n padding-top: 0px;\n padding-bottom: 20px;\n}\n\n[data-supertokens~="formRow"][data-supertokens~="hasError"] {\n padding-bottom: 0;\n}\n\n[data-supertokens~="formRow"]:last-child {\n padding-bottom: 0;\n}\n\n[data-supertokens~="sendVerifyEmailIcon"] {\n margin-top: 11px;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="sendVerifyEmailText"] {\n line-height: 21px;\n font-size: var(--font-size-1);\n text-align: center;\n font-weight: 300;\n letter-spacing: 0.8px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="sendVerifyEmailResend"] {\n margin-top: 13px;\n font-weight: 300;\n}\n\n[data-supertokens~="sendVerifyEmailResend"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="noFormRow"] {\n padding-bottom: 25px;\n}\n\n[data-supertokens~="emailVerificationButtonWrapper"] {\n padding-top: 25px;\n max-width: 96px;\n margin: 0 auto;\n}\n\n[data-supertokens~="resendEmailLink"] {\n display: inline-block;\n}\n\n[data-supertokens~="resetPasswordEmailForm"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="resetPasswordPasswordForm"] {\n padding-bottom: 20px;\n}\n'; var ThemeBase = function (_a) { var children = _a.children, diff --git a/lib/build/index2.js b/lib/build/index2.js index 61f093552..658a76f2d 100644 --- a/lib/build/index2.js +++ b/lib/build/index2.js @@ -122,7 +122,7 @@ var withOverride = function (overrideKey, DefaultComponent) { }; var styles$1 = - '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}\n'; + '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px;\n}\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle));\n}\n'; var ThemeBase$1 = function (_a) { var children = _a.children, @@ -488,7 +488,7 @@ function GeneralError(_a) { } var styles = - '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}'; + '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px;\n}\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle));\n}\n'; var ThemeBase = function (_a) { var children = _a.children, diff --git a/lib/build/multifactorauthprebuiltui.js b/lib/build/multifactorauthprebuiltui.js index b8170b7c1..3aa6244e1 100644 --- a/lib/build/multifactorauthprebuiltui.js +++ b/lib/build/multifactorauthprebuiltui.js @@ -66,7 +66,7 @@ var NormalisedURLPath__default = /*#__PURE__*/ _interopDefault(NormalisedURLPath var React__namespace = /*#__PURE__*/ _interopNamespace(React); var styles = - '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}\n[data-supertokens~="mfa"][data-supertokens~="container"] {\n padding-top: 34px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="row"] {\n padding-top: 6px;\n padding-bottom: 6px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="headerTitle"] {\n font-size: var(--font-size-3);\n font-weight: 500;\n line-height: 30px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="factorChooserList"] {\n margin-bottom: 12px;\n}\n[data-supertokens~="factorChooserOption"] {\n display: flex;\n flex-direction: row;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n padding: 20px 16px;\n cursor: pointer;\n margin-top: 12px;\n}\n[data-supertokens~="factorChooserOption"]:hover {\n border: 1px solid rgb(var(--palette-textLink));\n}\n[data-supertokens~="factorOptionText"] {\n flex-grow: 1;\n display: flex;\n flex-direction: column;\n align-items: start;\n text-align: left;\n}\n[data-supertokens~="factorLogo"] {\n flex-grow: 0;\n min-width: 30px;\n text-align: left;\n margin-top: 6px;\n}\n[data-supertokens~="totp"] [data-supertokens~="factorLogo"] {\n margin-top: 3px;\n margin-left: -1px;\n}\n[data-supertokens~="factorName"] {\n color: rgb(var(--palette-textPrimary));\n font-size: var(--font-size-1);\n font-weight: 500;\n margin: 4px;\n}\n[data-supertokens~="factorChooserOption"]:hover [data-supertokens~="factorName"] {\n color: rgb(var(--palette-textLink));\n}\n[data-supertokens~="factorDescription"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-0);\n margin: 4px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n margin-bottom: 26px;\n text-align: right;\n}\n'; + '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px;\n}\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="mfa"][data-supertokens~="container"] {\n padding-top: 34px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="row"] {\n padding-top: 6px;\n padding-bottom: 6px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="headerTitle"] {\n font-size: var(--font-size-3);\n font-weight: 500;\n line-height: 30px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="factorChooserList"] {\n margin-bottom: 12px;\n}\n[data-supertokens~="factorChooserOption"] {\n display: flex;\n flex-direction: row;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n padding: 20px 16px;\n cursor: pointer;\n margin-top: 12px;\n}\n[data-supertokens~="factorChooserOption"]:hover {\n border: 1px solid rgb(var(--palette-textLink));\n}\n[data-supertokens~="factorOptionText"] {\n flex-grow: 1;\n display: flex;\n flex-direction: column;\n align-items: start;\n text-align: left;\n}\n[data-supertokens~="factorLogo"] {\n flex-grow: 0;\n min-width: 30px;\n text-align: left;\n margin-top: 6px;\n}\n[data-supertokens~="totp"] [data-supertokens~="factorLogo"] {\n margin-top: 3px;\n margin-left: -1px;\n}\n[data-supertokens~="factorName"] {\n color: rgb(var(--palette-textPrimary));\n font-size: var(--font-size-1);\n font-weight: 500;\n margin: 4px;\n}\n[data-supertokens~="factorChooserOption"]:hover [data-supertokens~="factorName"] {\n color: rgb(var(--palette-textLink));\n}\n[data-supertokens~="factorDescription"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-0);\n margin: 4px;\n}\n[data-supertokens~="mfa"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n margin-bottom: 26px;\n text-align: right;\n}\n'; var ThemeBase = function (_a) { var children = _a.children, diff --git a/lib/build/oauth2provider-shared.js b/lib/build/oauth2provider-shared.js index 4d65805f4..e0c40e5e5 100644 --- a/lib/build/oauth2provider-shared.js +++ b/lib/build/oauth2provider-shared.js @@ -92,7 +92,10 @@ var OAuth2Provider = /** @class */ (function (_super) { basePath = this.config.appInfo.apiBasePath.getAsStringDangerous(); return [ 2 /*return*/, - "".concat(domain).concat(basePath, "/oauth2/login?loginChallenge=").concat(ctx.loginChallenge), + "" + .concat(domain) + .concat(basePath, "/oauth2provider/login?loginChallenge=") + .concat(ctx.loginChallenge), ]; } else { throw new Error( diff --git a/lib/build/passwordlessprebuiltui.js b/lib/build/passwordlessprebuiltui.js index 514f798c4..e788b3bbd 100644 --- a/lib/build/passwordlessprebuiltui.js +++ b/lib/build/passwordlessprebuiltui.js @@ -84,7 +84,7 @@ var STGeneralError__default = /*#__PURE__*/ _interopDefault(STGeneralError); var STGeneralError__default$1 = /*#__PURE__*/ _interopDefault(STGeneralError$1); var styles = - '/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n\n/*\n * Default styles.\n */\n\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n\n/* TODO: split the link style into separate things*/\n\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}\n\n/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="inputContainer"] {\n margin-top: 6px;\n}\n\n[data-supertokens~="inputWrapper"] {\n box-sizing: border-box;\n width: 100%;\n display: flex;\n align-items: center;\n background-color: rgb(var(--palette-inputBackground));\n height: 34px;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n}\n\n[data-supertokens~="inputWrapper"][focus-within] {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputWrapper"]:focus-within {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"][focus-within] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"]:focus-within {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="input"] {\n box-sizing: border-box;\n padding-left: 15px;\n filter: none;\n color: rgb(var(--palette-textInput));\n background-color: transparent;\n border-radius: 6px;\n font-size: var(--font-size-1);\n border: none;\n padding-right: 25px;\n letter-spacing: 1.2px;\n flex: 9 1 75%;\n width: 75%;\n height: 32px;\n}\n\n[data-supertokens~="input"]:focus {\n border: none;\n outline: none;\n}\n\n[data-supertokens~="input"]:-webkit-autofill,\n[data-supertokens~="input"]:-webkit-autofill:hover,\n[data-supertokens~="input"]:-webkit-autofill:focus,\n[data-supertokens~="input"]:-webkit-autofill:active {\n -webkit-text-fill-color: rgb(var(--palette-textInput));\n box-shadow: 0 0 0 30px rgb(var(--palette-inputBackground)) inset;\n}\n\n[data-supertokens~="inputAdornment"] {\n justify-content: center;\n margin-right: 5px;\n}\n\n[data-supertokens~="showPassword"] {\n cursor: pointer;\n}\n\n[data-supertokens~="enterEmailSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n word-break: break-word;\n}\n\n[data-supertokens~="submitNewPasswordSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n}\n\n[data-supertokens~="inputErrorMessage"] {\n padding-top: 5px;\n padding-bottom: 5px;\n color: rgb(var(--palette-error));\n line-height: 24px;\n font-weight: 400;\n font-size: var(--font-size-1);\n text-align: left;\n animation: slideTop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;\n max-width: 330px;\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="inputErrorMessage"] {\n max-width: 250px;\n }\n}\n\n[data-supertokens~="inputErrorSymbol"] {\n margin-right: 5px;\n top: 1px;\n position: relative;\n left: 2px;\n}\n\n[data-supertokens~="label"] {\n text-align: left;\n font-weight: 500;\n font-size: var(--font-size-1);\n line-height: 24px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="formRow"] {\n display: flex;\n flex-direction: column;\n padding-top: 0px;\n padding-bottom: 20px;\n}\n\n[data-supertokens~="formRow"][data-supertokens~="hasError"] {\n padding-bottom: 0;\n}\n\n[data-supertokens~="formRow"]:last-child {\n padding-bottom: 0;\n}\n\n[data-supertokens~="sendVerifyEmailIcon"] {\n margin-top: 11px;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="sendVerifyEmailText"] {\n line-height: 21px;\n font-size: var(--font-size-1);\n text-align: center;\n font-weight: 300;\n letter-spacing: 0.8px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="sendVerifyEmailResend"] {\n margin-top: 13px;\n font-weight: 300;\n}\n\n[data-supertokens~="sendVerifyEmailResend"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="noFormRow"] {\n padding-bottom: 25px;\n}\n\n[data-supertokens~="emailVerificationButtonWrapper"] {\n padding-top: 25px;\n max-width: 96px;\n margin: 0 auto;\n}\n\n[data-supertokens~="resendEmailLink"] {\n display: inline-block;\n}\n\n[data-supertokens~="resetPasswordEmailForm"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="resetPasswordPasswordForm"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="generalSuccess"] {\n margin-bottom: 20px;\n animation: swingIn 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) alternate 2 both;\n}\n\n[data-supertokens~="headerSubtitle"] strong {\n max-width: 100%;\n display: inline-block;\n vertical-align: bottom;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n[data-supertokens~="sendCodeText"] {\n margin-top: 15px;\n margin-bottom: 20px;\n}\n\n[data-supertokens~="sendCodeText"] strong {\n max-width: 100%;\n display: inline-block;\n vertical-align: bottom;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n[data-supertokens~="phoneInputLibRoot"] {\n display: flex;\n align-items: center;\n}\n\n[data-supertokens~="phoneInputWrapper"] {\n display: flex;\n align-items: center;\n}\n\ninput[type="tel"][data-supertokens~="input-phoneNumber"] {\n padding-left: 15px;\n}\n\n[data-supertokens~="phoneInputWrapper"] .iti {\n flex: 1 1;\n min-width: 0;\n width: 100%;\n background: transparent;\n border: none;\n color: inherit;\n outline: none;\n}\n\n[data-supertokens~="continueButtonWrapper"] {\n margin-top: 10px;\n margin-bottom: 30px;\n}\n\n.iti__country-list {\n border: 0;\n top: 40px;\n width: min(72.2vw, 320px);\n border-radius: 6;\n box-shadow: 0px 0px 3px 0px rgba(0, 0, 0, 0.16);\n}\n\n.iti__country {\n display: flex;\n align-items: center;\n height: 34px;\n cursor: pointer;\n\n padding: 0 8px;\n}\n\n.iti__country-name {\n color: var(--palette-textLabel);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n margin: "0 16px";\n}\n\n[data-supertokens~="continueWithPasswordlessButtonWrapper"] {\n margin: 9px 0;\n}\n\n[data-supertokens~="continueWithPasswordlessLink"] {\n margin-top: 9px;\n}\n'; + '/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n\n/*\n * Default styles.\n */\n\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n\n/* TODO: split the link style into separate things*/\n\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px;\n}\n\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle));\n}\n\n/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="inputContainer"] {\n margin-top: 6px;\n}\n\n[data-supertokens~="inputWrapper"] {\n box-sizing: border-box;\n width: 100%;\n display: flex;\n align-items: center;\n background-color: rgb(var(--palette-inputBackground));\n height: 34px;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n}\n\n[data-supertokens~="inputWrapper"][focus-within] {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputWrapper"]:focus-within {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"][focus-within] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="inputError"]:focus-within {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n\n[data-supertokens~="input"] {\n box-sizing: border-box;\n padding-left: 15px;\n filter: none;\n color: rgb(var(--palette-textInput));\n background-color: transparent;\n border-radius: 6px;\n font-size: var(--font-size-1);\n border: none;\n padding-right: 25px;\n letter-spacing: 1.2px;\n flex: 9 1 75%;\n width: 75%;\n height: 32px;\n}\n\n[data-supertokens~="input"]:focus {\n border: none;\n outline: none;\n}\n\n[data-supertokens~="input"]:-webkit-autofill,\n[data-supertokens~="input"]:-webkit-autofill:hover,\n[data-supertokens~="input"]:-webkit-autofill:focus,\n[data-supertokens~="input"]:-webkit-autofill:active {\n -webkit-text-fill-color: rgb(var(--palette-textInput));\n box-shadow: 0 0 0 30px rgb(var(--palette-inputBackground)) inset;\n}\n\n[data-supertokens~="inputAdornment"] {\n justify-content: center;\n margin-right: 5px;\n}\n\n[data-supertokens~="showPassword"] {\n cursor: pointer;\n}\n\n[data-supertokens~="enterEmailSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n word-break: break-word;\n}\n\n[data-supertokens~="submitNewPasswordSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n}\n\n[data-supertokens~="inputErrorMessage"] {\n padding-top: 5px;\n padding-bottom: 5px;\n color: rgb(var(--palette-error));\n line-height: 24px;\n font-weight: 400;\n font-size: var(--font-size-1);\n text-align: left;\n animation: slideTop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;\n max-width: 330px;\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="inputErrorMessage"] {\n max-width: 250px;\n }\n}\n\n[data-supertokens~="inputErrorSymbol"] {\n margin-right: 5px;\n top: 1px;\n position: relative;\n left: 2px;\n}\n\n[data-supertokens~="label"] {\n text-align: left;\n font-weight: 500;\n font-size: var(--font-size-1);\n line-height: 24px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="formRow"] {\n display: flex;\n flex-direction: column;\n padding-top: 0px;\n padding-bottom: 20px;\n}\n\n[data-supertokens~="formRow"][data-supertokens~="hasError"] {\n padding-bottom: 0;\n}\n\n[data-supertokens~="formRow"]:last-child {\n padding-bottom: 0;\n}\n\n[data-supertokens~="sendVerifyEmailIcon"] {\n margin-top: 11px;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="sendVerifyEmailText"] {\n line-height: 21px;\n font-size: var(--font-size-1);\n text-align: center;\n font-weight: 300;\n letter-spacing: 0.8px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="sendVerifyEmailResend"] {\n margin-top: 13px;\n font-weight: 300;\n}\n\n[data-supertokens~="sendVerifyEmailResend"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="noFormRow"] {\n padding-bottom: 25px;\n}\n\n[data-supertokens~="emailVerificationButtonWrapper"] {\n padding-top: 25px;\n max-width: 96px;\n margin: 0 auto;\n}\n\n[data-supertokens~="resendEmailLink"] {\n display: inline-block;\n}\n\n[data-supertokens~="resetPasswordEmailForm"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="resetPasswordPasswordForm"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="generalSuccess"] {\n margin-bottom: 20px;\n animation: swingIn 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) alternate 2 both;\n}\n\n[data-supertokens~="headerSubtitle"] strong {\n max-width: 100%;\n display: inline-block;\n vertical-align: bottom;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n[data-supertokens~="sendCodeText"] {\n margin-top: 15px;\n margin-bottom: 20px;\n}\n\n[data-supertokens~="sendCodeText"] strong {\n max-width: 100%;\n display: inline-block;\n vertical-align: bottom;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n[data-supertokens~="phoneInputLibRoot"] {\n display: flex;\n align-items: center;\n}\n\n[data-supertokens~="phoneInputWrapper"] {\n display: flex;\n align-items: center;\n}\n\ninput[type="tel"][data-supertokens~="input-phoneNumber"] {\n padding-left: 15px;\n}\n\n[data-supertokens~="phoneInputWrapper"] .iti {\n flex: 1 1;\n min-width: 0;\n width: 100%;\n background: transparent;\n border: none;\n color: inherit;\n outline: none;\n}\n\n[data-supertokens~="continueButtonWrapper"] {\n margin-top: 10px;\n margin-bottom: 30px;\n}\n\n.iti__country-list {\n border: 0;\n top: 40px;\n width: min(72.2vw, 320px);\n border-radius: 6;\n box-shadow: 0px 0px 3px 0px rgba(0, 0, 0, 0.16);\n}\n\n.iti__country {\n display: flex;\n align-items: center;\n height: 34px;\n cursor: pointer;\n\n padding: 0 8px;\n}\n\n.iti__country-name {\n color: var(--palette-textLabel);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n margin: "0 16px";\n}\n\n[data-supertokens~="continueWithPasswordlessButtonWrapper"] {\n margin: 9px 0;\n}\n\n[data-supertokens~="continueWithPasswordlessLink"] {\n margin-top: 9px;\n}\n'; var ThemeBase = function (_a) { var children = _a.children, diff --git a/lib/build/sessionprebuiltui.js b/lib/build/sessionprebuiltui.js index 4641f1636..965c551fb 100644 --- a/lib/build/sessionprebuiltui.js +++ b/lib/build/sessionprebuiltui.js @@ -86,7 +86,7 @@ function LogoutButton(_a) { } var styles = - '/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n\n/*\n * Default styles.\n */\n\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n\n/* TODO: split the link style into separate things*/\n\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}\n\n/* Override */\n\n[data-supertokens~="accessDenied"] [data-supertokens~="row"] {\n padding-bottom: 24px;\n}\n\n[data-supertokens~="accessDenied"] [data-supertokens~="divider"] {\n padding: 0;\n margin: 34px 0 18px 0;\n}\n\n[data-supertokens~="accessDenied"] [data-supertokens~="headerTitle"] {\n margin: 10px 0 0 0;\n font-style: normal;\n font-weight: 700;\n font-size: 20px;\n line-height: 30px;\n}\n\n/* Override end */\n\n[data-supertokens~="center"] {\n height: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n flex: 1 1 auto;\n}\n\n[data-supertokens~="buttonsGroup"] {\n margin-top: 34px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n[data-supertokens~="buttonBase"] {\n font-family: "Rubik", sans-serif;\n font-size: var(--font-size-1);\n line-height: 21px;\n font-weight: 500;\n background: transparent;\n outline: none;\n border: none;\n cursor: pointer;\n}\n\n[data-supertokens~="backButton"] {\n color: rgb(var(--palette-textLink));\n}\n\n[data-supertokens~="logoutButton"] {\n display: flex;\n align-items: center;\n gap: 6px;\n color: rgb(var(--palette-textGray));\n}\n\n[data-supertokens~="primaryText"][data-supertokens~="accessDeniedError"] {\n font-weight: 400;\n}\n'; + '/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\n[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n\n/*\n * Default styles.\n */\n\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n\n/* TODO: split the link style into separate things*/\n\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px;\n}\n\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle));\n}\n\n/* Override */\n\n[data-supertokens~="accessDenied"] [data-supertokens~="row"] {\n padding-bottom: 24px;\n}\n\n[data-supertokens~="accessDenied"] [data-supertokens~="divider"] {\n padding: 0;\n margin: 34px 0 18px 0;\n}\n\n[data-supertokens~="accessDenied"] [data-supertokens~="headerTitle"] {\n margin: 10px 0 0 0;\n font-style: normal;\n font-weight: 700;\n font-size: 20px;\n line-height: 30px;\n}\n\n/* Override end */\n\n[data-supertokens~="center"] {\n height: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n flex: 1 1 auto;\n}\n\n[data-supertokens~="buttonsGroup"] {\n margin-top: 34px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n[data-supertokens~="buttonBase"] {\n font-family: "Rubik", sans-serif;\n font-size: var(--font-size-1);\n line-height: 21px;\n font-weight: 500;\n background: transparent;\n outline: none;\n border: none;\n cursor: pointer;\n}\n\n[data-supertokens~="backButton"] {\n color: rgb(var(--palette-textLink));\n}\n\n[data-supertokens~="logoutButton"] {\n display: flex;\n align-items: center;\n gap: 6px;\n color: rgb(var(--palette-textGray));\n}\n\n[data-supertokens~="primaryText"][data-supertokens~="accessDeniedError"] {\n font-weight: 400;\n}\n'; var ThemeBase = function (_a) { var children = _a.children, diff --git a/lib/build/thirdpartyprebuiltui.js b/lib/build/thirdpartyprebuiltui.js index 816c895a1..d2c6f67b9 100644 --- a/lib/build/thirdpartyprebuiltui.js +++ b/lib/build/thirdpartyprebuiltui.js @@ -74,7 +74,7 @@ var React__namespace = /*#__PURE__*/ _interopNamespace(React); var STGeneralError__default = /*#__PURE__*/ _interopDefault(STGeneralError); var styles = - '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}\n[data-supertokens~="providerContainer"] {\n padding-top: 9px;\n padding-bottom: 9px;\n}\n[data-supertokens~="button"][data-supertokens~="providerButton"] {\n min-height: 32px;\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 2px 8px;\n\n background-color: white;\n border-color: rgb(221, 221, 221);\n color: black;\n}\n[data-supertokens~="multiFactor"] [data-supertokens~="button"][data-supertokens~="providerButton"] {\n margin: auto;\n max-width: 240px;\n}\n[data-supertokens~="button"][data-supertokens~="providerButton"]:hover {\n filter: none;\n background-color: #fafafa;\n}\n[data-supertokens~="providerButtonLeft"] {\n min-width: 34px;\n margin-left: 66px;\n}\n[data-supertokens~="multiFactor"] [data-supertokens~="providerButtonLeft"] {\n margin-left: 30px;\n}\n[data-supertokens~="providerButtonLogo"] {\n height: 30px;\n display: flex;\n}\n[data-supertokens~="providerButtonLogoCenter"] {\n display: flex;\n margin: auto;\n}\n[data-supertokens~="providerButtonText"] {\n font-weight: 400;\n text-align: center;\n justify-content: center;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n display: inline-block;\n}\n[data-supertokens~="providerButtonText"]:only-child {\n margin: 0 auto;\n}\n'; + '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px;\n}\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="providerContainer"] {\n padding-top: 9px;\n padding-bottom: 9px;\n}\n[data-supertokens~="button"][data-supertokens~="providerButton"] {\n min-height: 32px;\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 2px 8px;\n\n background-color: white;\n border-color: rgb(221, 221, 221);\n color: black;\n}\n[data-supertokens~="multiFactor"] [data-supertokens~="button"][data-supertokens~="providerButton"] {\n margin: auto;\n max-width: 240px;\n}\n[data-supertokens~="button"][data-supertokens~="providerButton"]:hover {\n filter: none;\n background-color: #fafafa;\n}\n[data-supertokens~="providerButtonLeft"] {\n min-width: 34px;\n margin-left: 66px;\n}\n[data-supertokens~="multiFactor"] [data-supertokens~="providerButtonLeft"] {\n margin-left: 30px;\n}\n[data-supertokens~="providerButtonLogo"] {\n height: 30px;\n display: flex;\n}\n[data-supertokens~="providerButtonLogoCenter"] {\n display: flex;\n margin: auto;\n}\n[data-supertokens~="providerButtonText"] {\n font-weight: 400;\n text-align: center;\n justify-content: center;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n display: inline-block;\n}\n[data-supertokens~="providerButtonText"]:only-child {\n margin: 0 auto;\n}\n'; var ThemeBase = function (_a) { var children = _a.children, diff --git a/lib/build/totpprebuiltui.js b/lib/build/totpprebuiltui.js index 769b48910..72c1c7604 100644 --- a/lib/build/totpprebuiltui.js +++ b/lib/build/totpprebuiltui.js @@ -72,7 +72,7 @@ var React__namespace = /*#__PURE__*/ _interopNamespace(React); var STGeneralError__default = /*#__PURE__*/ _interopDefault(STGeneralError); var styles = - '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px\n}\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle))\n}\n/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n[data-supertokens~="inputContainer"] {\n margin-top: 6px;\n}\n[data-supertokens~="inputWrapper"] {\n box-sizing: border-box;\n width: 100%;\n display: flex;\n align-items: center;\n background-color: rgb(var(--palette-inputBackground));\n height: 34px;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n}\n[data-supertokens~="inputWrapper"][focus-within] {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n[data-supertokens~="inputWrapper"]:focus-within {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n[data-supertokens~="inputError"] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n[data-supertokens~="inputError"][focus-within] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n[data-supertokens~="inputError"]:focus-within {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n[data-supertokens~="input"] {\n box-sizing: border-box;\n padding-left: 15px;\n filter: none;\n color: rgb(var(--palette-textInput));\n background-color: transparent;\n border-radius: 6px;\n font-size: var(--font-size-1);\n border: none;\n padding-right: 25px;\n letter-spacing: 1.2px;\n flex: 9 1 75%;\n width: 75%;\n height: 32px;\n}\n[data-supertokens~="input"]:focus {\n border: none;\n outline: none;\n}\n[data-supertokens~="input"]:-webkit-autofill,\n[data-supertokens~="input"]:-webkit-autofill:hover,\n[data-supertokens~="input"]:-webkit-autofill:focus,\n[data-supertokens~="input"]:-webkit-autofill:active {\n -webkit-text-fill-color: rgb(var(--palette-textInput));\n box-shadow: 0 0 0 30px rgb(var(--palette-inputBackground)) inset;\n}\n[data-supertokens~="inputAdornment"] {\n justify-content: center;\n margin-right: 5px;\n}\n[data-supertokens~="showPassword"] {\n cursor: pointer;\n}\n[data-supertokens~="enterEmailSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n word-break: break-word;\n}\n[data-supertokens~="submitNewPasswordSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n}\n[data-supertokens~="inputErrorMessage"] {\n padding-top: 5px;\n padding-bottom: 5px;\n color: rgb(var(--palette-error));\n line-height: 24px;\n font-weight: 400;\n font-size: var(--font-size-1);\n text-align: left;\n animation: slideTop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;\n max-width: 330px;\n}\n@media (max-width: 440px) {\n [data-supertokens~="inputErrorMessage"] {\n max-width: 250px;\n }\n}\n[data-supertokens~="inputErrorSymbol"] {\n margin-right: 5px;\n top: 1px;\n position: relative;\n left: 2px;\n}\n[data-supertokens~="label"] {\n text-align: left;\n font-weight: 500;\n font-size: var(--font-size-1);\n line-height: 24px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="formRow"] {\n display: flex;\n flex-direction: column;\n padding-top: 0px;\n padding-bottom: 20px;\n}\n[data-supertokens~="formRow"][data-supertokens~="hasError"] {\n padding-bottom: 0;\n}\n[data-supertokens~="formRow"]:last-child {\n padding-bottom: 0;\n}\n[data-supertokens~="sendVerifyEmailIcon"] {\n margin-top: 11px;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="sendVerifyEmailText"] {\n line-height: 21px;\n font-size: var(--font-size-1);\n text-align: center;\n font-weight: 300;\n letter-spacing: 0.8px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="sendVerifyEmailResend"] {\n margin-top: 13px;\n font-weight: 300;\n}\n[data-supertokens~="sendVerifyEmailResend"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="noFormRow"] {\n padding-bottom: 25px;\n}\n[data-supertokens~="emailVerificationButtonWrapper"] {\n padding-top: 25px;\n max-width: 96px;\n margin: 0 auto;\n}\n[data-supertokens~="resendEmailLink"] {\n display: inline-block;\n}\n[data-supertokens~="resetPasswordEmailForm"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="resetPasswordPasswordForm"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="totp"] [data-supertokens~="container"] {\n padding-top: 24px;\n}\n[data-supertokens~="totp"] [data-supertokens~="divider"] {\n margin-top: 20px;\n margin-bottom: 20px;\n}\n[data-supertokens~="totp"] [data-supertokens~="row"] {\n padding-top: 16px;\n padding-bottom: 8px;\n width: auto;\n margin: 0 50px;\n}\n[data-supertokens~="totpDeviceQR"] {\n border-radius: 12px;\n border: 1px solid rgb(var(--palette-inputBorder));\n padding: 16px;\n max-width: 172px;\n max-height: 172px;\n}\n[data-supertokens~="showTOTPSecret"] {\n display: block;\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-0);\n margin: 16px 0 12px;\n}\n[data-supertokens~="totpSecret"] {\n display: block;\n border-radius: 6px;\n padding: 7px 15px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n font-weight: 600;\n letter-spacing: 3.36px;\n background: rgba(var(--palette-textLink), 0.08);\n word-wrap: break-word;\n overflow-y: hidden;\n}\nbutton[data-supertokens~="showTOTPSecretBtn"] {\n font-size: 12px;\n}\n[data-supertokens~="showTOTPSecretBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="retryCodeBtn"]:disabled {\n border: 0;\n border-radius: 6px;\n color: rgb(var(--palette-error));\n background: rgb(var(--palette-errorBackground));\n}\n'; + '[data-supertokens~="container"] {\n --palette-background: 255, 255, 255;\n --palette-inputBackground: 250, 250, 250;\n --palette-inputBorder: 224, 224, 224;\n --palette-primary: 255, 155, 51;\n --palette-primaryBorder: 238, 141, 35;\n --palette-success: 65, 167, 0;\n --palette-successBackground: 217, 255, 191;\n --palette-error: 255, 23, 23;\n --palette-errorBackground: 255, 241, 235;\n --palette-textTitle: 34, 34, 34;\n --palette-textLabel: 34, 34, 34;\n --palette-textInput: 34, 34, 34;\n --palette-textPrimary: 101, 101, 101;\n --palette-textLink: 0, 118, 255;\n --palette-buttonText: 255, 255, 255;\n --palette-textGray: 128, 128, 128;\n --palette-superTokensBrandingBackground: 242, 245, 246;\n --palette-superTokensBrandingText: 173, 189, 196;\n\n --font-size-0: 12px;\n --font-size-1: 14px;\n --font-size-2: 16px;\n --font-size-3: 19px;\n --font-size-4: 24px;\n}\n/*\n * Default styles.\n */\n@keyframes slideTop {\n 0% {\n transform: translateY(-5px);\n }\n 100% {\n transform: translateY(0px);\n }\n}\n@keyframes swing-in-top-fwd {\n 0% {\n transform: rotateX(-100deg);\n transform-origin: top;\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n transform-origin: top;\n opacity: 1;\n }\n}\n[data-supertokens~="container"] {\n font-family: "Rubik", sans-serif;\n margin: 12px auto;\n margin-top: 26px;\n margin-bottom: 26px;\n width: 420px;\n text-align: center;\n border-radius: 8px;\n box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);\n background-color: rgb(var(--palette-background));\n}\n@media (max-width: 440px) {\n [data-supertokens~="container"] {\n width: 95vw;\n }\n}\n[data-supertokens~="row"] {\n margin: 0 auto;\n width: 76%;\n padding-top: 30px;\n padding-bottom: 10px;\n}\n[data-supertokens~="superTokensBranding"] {\n display: block;\n margin: 10px auto 0;\n background: rgb(var(--palette-superTokensBrandingBackground));\n color: rgb(var(--palette-superTokensBrandingText));\n text-decoration: none;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n border-radius: 6px 6px 0 0;\n padding: 4px 9px;\n font-weight: 400;\n font-size: var(--font-size-0);\n letter-spacing: 0.4px;\n}\n[data-supertokens~="generalError"] {\n background: rgb(var(--palette-errorBackground));\n padding-top: 10px;\n padding-bottom: 10px;\n margin-bottom: 10px;\n margin-top: 24px;\n padding-left: 18px;\n padding-right: 18px;\n letter-spacing: 0.2px;\n font-size: var(--font-size-1);\n border-radius: 8px;\n color: rgb(var(--palette-error));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n word-wrap: break-word;\n}\n[data-supertokens~="headerTitle"] {\n font-size: var(--font-size-4);\n line-height: 40px;\n letter-spacing: 0.58px;\n font-weight: 500;\n margin-bottom: 2px;\n color: rgb(var(--palette-textTitle));\n}\n[data-supertokens~="headerSubtitle"] {\n font-weight: 400;\n color: rgb(var(--palette-textGray));\n margin-bottom: 21px;\n}\n[data-supertokens~="headerSubtitle"][data-supertokens~="secondaryText"] {\n color: rgb(var(--palette-textGray));\n font-weight: 400;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] {\n max-width: 300px;\n margin-top: 10px;\n}\n[data-supertokens~="privacyPolicyAndTermsAndConditions"] a {\n line-height: 21px;\n}\n/* TODO: split the link style into separate things*/\n/* We add this before primary and secondary text, because if they are applied to the same element the other ones take priority */\n[data-supertokens~="link"] {\n padding-left: 3px;\n padding-right: 3px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n cursor: pointer;\n letter-spacing: 0.16px;\n line-height: 26px;\n}\n[data-supertokens~="primaryText"] {\n font-size: var(--font-size-1);\n font-weight: 500;\n letter-spacing: 0.4px;\n line-height: 21px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="secondaryText"] {\n font-size: var(--font-size-1);\n font-weight: 300;\n letter-spacing: 0.4px;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="secondaryText"] strong {\n font-weight: 500;\n}\n[data-supertokens~="divider"] {\n margin-top: 1.5em;\n margin-bottom: 1.5em;\n border-bottom: 0.3px solid #dddddd;\n align-items: center;\n padding-bottom: 5px;\n flex: 3 3;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="generalSuccess"] {\n color: rgb(var(--palette-success));\n font-size: var(--font-size-1);\n background: rgb(var(--palette-successBackground));\n animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;\n padding: 9px 15px 9px 15px;\n border-radius: 6px;\n display: inline-block;\n}\n[data-supertokens~="spinner"] {\n width: 80px;\n height: auto;\n padding-top: 20px;\n padding-bottom: 40px;\n margin: 0 auto;\n}\n[data-supertokens~="error"] {\n color: rgb(var(--palette-error));\n}\n[data-supertokens~="linkButton"] {\n font-family: "Rubik", sans-serif;\n background-color: transparent;\n border: 0;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] {\n color: rgb(var(--palette-textGray));\n font-weight: 500;\n margin-top: 10px;\n margin-bottom: 40px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"] svg {\n margin-right: 0.3em;\n}\n[data-supertokens~="secondaryLinkWithLeftArrow"]:hover svg {\n position: relative;\n left: -4px;\n}\n[data-supertokens~="button"] {\n font-family: "Rubik", sans-serif;\n background-color: rgb(var(--palette-primary));\n color: rgb(var(--palette-buttonText));\n width: 100%;\n height: 34px;\n font-weight: 700;\n border-width: 1px;\n border-style: solid;\n border-radius: 6px;\n border-color: rgb(var(--palette-primaryBorder));\n background-position: center;\n transition: all 0.4s;\n background-size: 12000%;\n cursor: pointer;\n}\n[data-supertokens~="button"]:disabled {\n border: none;\n cursor: no-drop;\n}\n[data-supertokens~="button"]:active {\n outline: none;\n transition: all 0s;\n background-size: 100%;\n filter: brightness(0.85);\n}\n[data-supertokens~="button"]:focus {\n outline: none;\n}\n[data-supertokens~="backButtonCommon"] {\n width: 16px;\n height: 13px;\n}\n[data-supertokens~="backButton"] {\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0px;\n}\n[data-supertokens~="backButtonPlaceholder"] {\n display: block;\n}\n[data-supertokens~="delayedRender"] {\n animation-duration: 0.1s;\n animation-name: animate-fade;\n animation-delay: 0.2s;\n animation-fill-mode: backwards;\n}\n@keyframes animate-fade {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] {\n display: flex;\n flex-direction: column;\n margin-top: 10px;\n gap: 24px;\n}\n[data-supertokens~="footerLinkGroupVert"] > div {\n cursor: pointer;\n margin: 0;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryText"] {\n font-weight: 400;\n}\n[data-supertokens~="footerLinkGroupVert"] [data-supertokens~="secondaryLinkWithLeftArrow"] {\n font-weight: 500;\n position: relative;\n left: -6px; /* half the width of the left arrow */\n}\n@media (max-width: 360px) {\n [data-supertokens~="footerLinkGroupVert"] {\n flex-direction: column;\n }\n [data-supertokens~="footerLinkGroupVert"] > div {\n margin: 0 auto;\n }\n}\n[data-supertokens~="footerLinkGroupVert"] div:only-child {\n margin-left: auto;\n margin-right: auto;\n margin-top: 14px;\n}\n[data-supertokens~="withBackButton"] {\n position: relative;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="dividerWithOr"] {\n padding-top: 5px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: rgb(var(--palette-textPrimary));\n}\n[data-supertokens~="dividerText"] {\n flex: 1 1;\n}\n[data-supertokens~="formLabelWithLinkWrapper"] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n[data-supertokens~="formLabelLinkBtn"] {\n width: auto;\n margin-top: 0;\n line-height: 24px;\n}\n[data-supertokens~="formLabelLinkBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="formLabelLinkBtn"]:disabled {\n color: rgb(var(--palette-textPrimary));\n cursor: default;\n text-decoration: none;\n}\n[data-supertokens~="authComponentList"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] {\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-1);\n font-weight: 400;\n margin: 10px 0 25px;\n}\n[data-supertokens~="authPageTitleOAuthClientUrl"] {\n text-decoration: none;\n}\n[data-supertokens~="authPageTitleOAuthClientLogo"] {\n width: 44px;\n height: 44px;\n margin-bottom: 10px;\n}\n[data-supertokens~="authPageTitleOAuthClient"] [data-supertokens~="authPageTitleOAuthClientName"] {\n color: rgb(var(--palette-textTitle));\n}\n/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.\n *\n * This software is licensed under the Apache License, Version 2.0 (the\n * "License") as published by the Apache Software Foundation.\n *\n * You may not use this file except in compliance with the License. You may\n * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n[data-supertokens~="inputContainer"] {\n margin-top: 6px;\n}\n[data-supertokens~="inputWrapper"] {\n box-sizing: border-box;\n width: 100%;\n display: flex;\n align-items: center;\n background-color: rgb(var(--palette-inputBackground));\n height: 34px;\n border-radius: 6px;\n border: 1px solid rgb(var(--palette-inputBorder));\n}\n[data-supertokens~="inputWrapper"][focus-within] {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n[data-supertokens~="inputWrapper"]:focus-within {\n background-color: rgba(var(--palette-inputBackground), 0.25);\n border: 1px solid rgb(var(--palette-primary));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-primary), 0.25);\n outline: none;\n}\n[data-supertokens~="inputError"] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n[data-supertokens~="inputError"][focus-within] {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n[data-supertokens~="inputError"]:focus-within {\n border: 1px solid rgb(var(--palette-error));\n box-shadow: 0 0 0 0.2rem rgba(var(--palette-error), 0.25);\n outline: none;\n}\n[data-supertokens~="input"] {\n box-sizing: border-box;\n padding-left: 15px;\n filter: none;\n color: rgb(var(--palette-textInput));\n background-color: transparent;\n border-radius: 6px;\n font-size: var(--font-size-1);\n border: none;\n padding-right: 25px;\n letter-spacing: 1.2px;\n flex: 9 1 75%;\n width: 75%;\n height: 32px;\n}\n[data-supertokens~="input"]:focus {\n border: none;\n outline: none;\n}\n[data-supertokens~="input"]:-webkit-autofill,\n[data-supertokens~="input"]:-webkit-autofill:hover,\n[data-supertokens~="input"]:-webkit-autofill:focus,\n[data-supertokens~="input"]:-webkit-autofill:active {\n -webkit-text-fill-color: rgb(var(--palette-textInput));\n box-shadow: 0 0 0 30px rgb(var(--palette-inputBackground)) inset;\n}\n[data-supertokens~="inputAdornment"] {\n justify-content: center;\n margin-right: 5px;\n}\n[data-supertokens~="showPassword"] {\n cursor: pointer;\n}\n[data-supertokens~="enterEmailSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n word-break: break-word;\n}\n[data-supertokens~="submitNewPasswordSuccessMessage"] {\n margin-top: 15px;\n margin-bottom: 15px;\n}\n[data-supertokens~="inputErrorMessage"] {\n padding-top: 5px;\n padding-bottom: 5px;\n color: rgb(var(--palette-error));\n line-height: 24px;\n font-weight: 400;\n font-size: var(--font-size-1);\n text-align: left;\n animation: slideTop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;\n max-width: 330px;\n}\n@media (max-width: 440px) {\n [data-supertokens~="inputErrorMessage"] {\n max-width: 250px;\n }\n}\n[data-supertokens~="inputErrorSymbol"] {\n margin-right: 5px;\n top: 1px;\n position: relative;\n left: 2px;\n}\n[data-supertokens~="label"] {\n text-align: left;\n font-weight: 500;\n font-size: var(--font-size-1);\n line-height: 24px;\n color: rgb(var(--palette-textLabel));\n}\n[data-supertokens~="formRow"] {\n display: flex;\n flex-direction: column;\n padding-top: 0px;\n padding-bottom: 20px;\n}\n[data-supertokens~="formRow"][data-supertokens~="hasError"] {\n padding-bottom: 0;\n}\n[data-supertokens~="formRow"]:last-child {\n padding-bottom: 0;\n}\n[data-supertokens~="sendVerifyEmailIcon"] {\n margin-top: 11px;\n}\n[data-supertokens~="headerTinyTitle"] {\n margin-top: 13px;\n font-size: var(--font-size-3);\n letter-spacing: 1.1px;\n font-weight: 500;\n line-height: 28px;\n}\n[data-supertokens~="sendVerifyEmailText"] {\n line-height: 21px;\n font-size: var(--font-size-1);\n text-align: center;\n font-weight: 300;\n letter-spacing: 0.8px;\n}\n[data-supertokens~="secondaryLinkWithArrow"] {\n margin-top: 10px;\n margin-bottom: 30px;\n cursor: pointer;\n}\n[data-supertokens~="secondaryLinkWithArrow"]:hover {\n position: relative;\n left: 2px;\n word-spacing: 4px;\n}\n[data-supertokens~="sendVerifyEmailResend"] {\n margin-top: 13px;\n font-weight: 300;\n}\n[data-supertokens~="sendVerifyEmailResend"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="noFormRow"] {\n padding-bottom: 25px;\n}\n[data-supertokens~="emailVerificationButtonWrapper"] {\n padding-top: 25px;\n max-width: 96px;\n margin: 0 auto;\n}\n[data-supertokens~="resendEmailLink"] {\n display: inline-block;\n}\n[data-supertokens~="resetPasswordEmailForm"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="resetPasswordPasswordForm"] {\n padding-bottom: 20px;\n}\n[data-supertokens~="totp"] [data-supertokens~="container"] {\n padding-top: 24px;\n}\n[data-supertokens~="totp"] [data-supertokens~="divider"] {\n margin-top: 20px;\n margin-bottom: 20px;\n}\n[data-supertokens~="totp"] [data-supertokens~="row"] {\n padding-top: 16px;\n padding-bottom: 8px;\n width: auto;\n margin: 0 50px;\n}\n[data-supertokens~="totpDeviceQR"] {\n border-radius: 12px;\n border: 1px solid rgb(var(--palette-inputBorder));\n padding: 16px;\n max-width: 172px;\n max-height: 172px;\n}\n[data-supertokens~="showTOTPSecret"] {\n display: block;\n color: rgb(var(--palette-textGray));\n font-size: var(--font-size-0);\n margin: 16px 0 12px;\n}\n[data-supertokens~="totpSecret"] {\n display: block;\n border-radius: 6px;\n padding: 7px 15px;\n color: rgb(var(--palette-textLink));\n font-size: var(--font-size-1);\n font-weight: 600;\n letter-spacing: 3.36px;\n background: rgba(var(--palette-textLink), 0.08);\n word-wrap: break-word;\n overflow-y: hidden;\n}\nbutton[data-supertokens~="showTOTPSecretBtn"] {\n font-size: 12px;\n}\n[data-supertokens~="showTOTPSecretBtn"]:hover {\n text-decoration: underline;\n}\n[data-supertokens~="retryCodeBtn"]:disabled {\n border: 0;\n border-radius: 6px;\n color: rgb(var(--palette-error));\n background: rgb(var(--palette-errorBackground));\n}\n'; var ThemeBase = function (_a) { var children = _a.children, diff --git a/lib/build/ui/index.d.ts b/lib/build/ui/index.d.ts index fc3c5e56a..c345f2b0c 100644 --- a/lib/build/ui/index.d.ts +++ b/lib/build/ui/index.d.ts @@ -41,11 +41,11 @@ declare class UI { onSignInUpSwitcherClick: (() => void) | undefined; resetFactorList: () => void; showBackButton: boolean; - oauthClientInfo?: + oauth2ClientInfo?: | { - clientLogo?: string | undefined; + clientLogoUri?: string | undefined; clientUri?: string | undefined; - clientAppName?: string | undefined; + clientName: string; } | undefined; }>; diff --git a/lib/ts/recipe/oauth2provider/recipe.ts b/lib/ts/recipe/oauth2provider/recipe.ts index 57a5b121b..f59a09d1e 100644 --- a/lib/ts/recipe/oauth2provider/recipe.ts +++ b/lib/ts/recipe/oauth2provider/recipe.ts @@ -111,7 +111,7 @@ export default class OAuth2Provider extends RecipeModule< const domain = this.config.appInfo.apiDomain.getAsStringDangerous(); const basePath = this.config.appInfo.apiBasePath.getAsStringDangerous(); - return `${domain}${basePath}/oauth2/login?loginChallenge=${ctx.loginChallenge}`; + return `${domain}${basePath}/oauth2provider/login?loginChallenge=${ctx.loginChallenge}`; } else { throw new Error("Should never come here: unknown action in OAuth2Provider.getDefaultRedirectionURL"); } diff --git a/package-lock.json b/package-lock.json index b2f93887a..f34f9a2ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23890,7 +23890,8 @@ }, "node_modules/supertokens-web-js": { "version": "0.12.0", - "resolved": "git+ssh://git@github.com/supertokens/supertokens-web-js.git#e39849ab165916ad948755d25d1347098019fbf5", + "resolved": "git+ssh://git@github.com/supertokens/supertokens-web-js.git#d7cc0fe8b4736f083216546ac66a0a23b2eff964", + "license": "Apache-2.0", "peer": true, "dependencies": { "supertokens-js-override": "0.0.4", @@ -43369,7 +43370,7 @@ "integrity": "sha512-r0JFBjkMIdep3Lbk3JA+MpnpuOtw4RSyrlRAbrzMcxwiYco3GFWl/daimQZ5b1forOiUODpOlXbSOljP/oyurg==" }, "supertokens-web-js": { - "version": "git+ssh://git@github.com/supertokens/supertokens-web-js.git#e39849ab165916ad948755d25d1347098019fbf5", + "version": "git+ssh://git@github.com/supertokens/supertokens-web-js.git#d7cc0fe8b4736f083216546ac66a0a23b2eff964", "from": "supertokens-web-js@github:supertokens/supertokens-web-js#feat/oauth2/base", "peer": true, "requires": { From 55ace9cd3eb5796652ae4869187a112f8257b9be Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Mon, 5 Aug 2024 01:44:33 +0530 Subject: [PATCH 6/9] test: Add e2e test for OAuth2 (#843) * test: Add e2e test for OAuth2 * fix: PR changes * feat: add tryLinkingWithSessionUser, forceFreshAuth and small test fixes * test: add explanation comment to oauth2 tests --------- Co-authored-by: Mihaly Lengyel --- examples/for-tests/package.json | 2 + examples/for-tests/src/App.js | 16 +- .../for-tests/src/AppWithReactDomRouter.js | 4 + examples/for-tests/src/OAuth2Page.js | 52 +++++ examples/for-tests/src/config.js | 13 ++ lib/build/emailpasswordprebuiltui.js | 92 +++++++- lib/build/index2.js | 6 +- lib/build/oauth2provider-shared.js | 5 +- lib/build/passwordlessprebuiltui.js | 79 ++++--- lib/build/recipe/emailpassword/index.d.ts | 2 + lib/build/recipe/passwordless/index.d.ts | 2 + lib/build/recipe/session/recipe.d.ts | 6 +- lib/build/recipe/thirdparty/index.d.ts | 1 + lib/build/thirdparty-shared.js | 1 + .../components/feature/authPage/authPage.tsx | 6 +- .../components/features/signin/index.tsx | 8 + .../components/features/signup/index.tsx | 8 + .../components/themes/signIn/index.tsx | 1 + .../components/themes/signUp/index.tsx | 1 + lib/ts/recipe/emailpassword/index.ts | 2 + lib/ts/recipe/oauth2provider/recipe.ts | 2 +- .../components/features/linkSent/index.tsx | 1 + .../components/features/mfa/index.tsx | 3 + .../components/features/signInAndUp/index.tsx | 1 + .../features/signInAndUpEPCombo/index.tsx | 20 +- .../features/userInputCode/index.tsx | 1 + .../components/themes/signInUp/emailForm.tsx | 1 + .../themes/signInUp/emailOrPhoneForm.tsx | 1 + .../components/themes/signInUp/phoneForm.tsx | 1 + lib/ts/recipe/passwordless/index.ts | 14 +- lib/ts/recipe/session/recipe.tsx | 6 +- lib/ts/recipe/thirdparty/index.ts | 1 + lib/ts/recipe/thirdparty/utils.ts | 1 + test/end-to-end/emailverification.test.js | 1 + test/end-to-end/generalerror.test.js | 2 +- test/end-to-end/oauth2provider.test.js | 197 ++++++++++++++++++ test/end-to-end/signin-rrdv6.test.js | 6 +- test/end-to-end/signin.test.js | 6 +- .../thirdpartyemailpassword.test.js | 2 +- test/helpers.js | 39 +++- test/server/index.js | 30 ++- test/server/utils.js | 4 +- 42 files changed, 569 insertions(+), 78 deletions(-) create mode 100644 examples/for-tests/src/OAuth2Page.js create mode 100644 examples/for-tests/src/config.js create mode 100644 test/end-to-end/oauth2provider.test.js diff --git a/examples/for-tests/package.json b/examples/for-tests/package.json index 9f67560d0..04323793d 100644 --- a/examples/for-tests/package.json +++ b/examples/for-tests/package.json @@ -4,8 +4,10 @@ "private": true, "dependencies": { "axios": "^0.21.0", + "oidc-client-ts": "^3.0.1", "react": "^18.0.0", "react-dom": "^18.0.0", + "react-oidc-context": "^3.1.0", "react-router-dom": "6.11.2", "react-scripts": "^5.0.1" }, diff --git a/examples/for-tests/src/App.js b/examples/for-tests/src/App.js index 048337ec8..7bdb1092c 100644 --- a/examples/for-tests/src/App.js +++ b/examples/for-tests/src/App.js @@ -14,6 +14,7 @@ import Multitenancy from "supertokens-auth-react/recipe/multitenancy"; import UserRoles from "supertokens-auth-react/recipe/userroles"; import MultiFactorAuth from "supertokens-auth-react/recipe/multifactorauth"; import TOTP from "supertokens-auth-react/recipe/totp"; +import OAuth2Provider from "supertokens-auth-react/recipe/oauth2provider"; import axios from "axios"; import { useSessionContext } from "supertokens-auth-react/recipe/session"; @@ -27,6 +28,7 @@ import { logWithPrefix } from "./logWithPrefix"; import { ErrorBoundary } from "./ErrorBoundary"; import { useNavigate } from "react-router-dom"; import { getTestContext, getEnabledRecipes, getQueryParams } from "./testContext"; +import { getApiDomain, getWebsiteDomain } from "./config"; const loadv5RRD = window.localStorage.getItem("react-router-dom-is-v5") === "true"; if (loadv5RRD) { @@ -43,18 +45,6 @@ const withRouter = function (Child) { Session.addAxiosInterceptors(axios); -export function getApiDomain() { - const apiPort = process.env.REACT_APP_API_PORT || 8082; - const apiUrl = process.env.REACT_APP_API_URL || `http://localhost:${apiPort}`; - return apiUrl; -} - -export function getWebsiteDomain() { - const websitePort = process.env.REACT_APP_WEBSITE_PORT || 3031; - const websiteUrl = process.env.REACT_APP_WEBSITE_URL || `http://localhost:${websitePort}`; - return getQueryParams("websiteDomain") ?? websiteUrl; -} - /* * Use localStorage for tests configurations. */ @@ -419,6 +409,7 @@ let recipeList = [ console.log(`ST_LOGS SESSION ON_HANDLE_EVENT ${ctx.action}`); }, }), + OAuth2Provider.init(), ]; let enabledRecipes = getEnabledRecipes(); @@ -801,7 +792,6 @@ function getSignInFormFields(formType) { id: "test", }, ]; - return; } } diff --git a/examples/for-tests/src/AppWithReactDomRouter.js b/examples/for-tests/src/AppWithReactDomRouter.js index a545bb447..f53ee0f30 100644 --- a/examples/for-tests/src/AppWithReactDomRouter.js +++ b/examples/for-tests/src/AppWithReactDomRouter.js @@ -12,6 +12,7 @@ import { MultiFactorAuthPreBuiltUI } from "supertokens-auth-react/recipe/multifa import { TOTPPreBuiltUI } from "supertokens-auth-react/recipe/totp/prebuiltui"; import { BaseComponent, Home, Contact, Dashboard, DashboardNoAuthRequired } from "./App"; import { getEnabledRecipes, getTestContext } from "./testContext"; +import OAuth2Page from "./OAuth2Page"; function AppWithReactDomRouter(props) { /** @@ -172,6 +173,9 @@ function AppWithReactDomRouter(props) { } /> )} + + } /> + } /> diff --git a/examples/for-tests/src/OAuth2Page.js b/examples/for-tests/src/OAuth2Page.js new file mode 100644 index 000000000..76ab8b130 --- /dev/null +++ b/examples/for-tests/src/OAuth2Page.js @@ -0,0 +1,52 @@ +import { AuthProvider, useAuth } from "react-oidc-context"; +import { getApiDomain, getWebsiteDomain } from "./config"; + +// NOTE: For convenience, the same page/component handles both login initiation and callback. +// Separate pages for login and callback are not required. + +const oidcConfig = { + client_id: window.localStorage.getItem("oauth2-client-id"), + authority: `${getApiDomain()}/auth`, + response_type: "code", + redirect_uri: `${getWebsiteDomain()}/oauth2/callback`, + scope: "profile openid offline_access email", + onSigninCallback: async (user) => { + // Clears the response code and other params from the callback url + window.history.replaceState({}, document.title, window.location.pathname); + }, +}; + +function AuthPage() { + const { signinRedirect, signoutSilent, user, error } = useAuth(); + + return ( +
+

OAuth2 Login Test

+
+ {user ? ( +
+
{JSON.stringify(user.profile, null, 2)}
+ +
+ ) : ( +
+ {error &&

Error: {error.message}

} + +
+ )} +
+
+ ); +} + +export default function OAuth2Page() { + return ( + + + + ); +} diff --git a/examples/for-tests/src/config.js b/examples/for-tests/src/config.js new file mode 100644 index 000000000..ae591c224 --- /dev/null +++ b/examples/for-tests/src/config.js @@ -0,0 +1,13 @@ +import { getQueryParams } from "./testContext"; + +export function getApiDomain() { + const apiPort = process.env.REACT_APP_API_PORT || 8082; + const apiUrl = process.env.REACT_APP_API_URL || `http://localhost:${apiPort}`; + return apiUrl; +} + +export function getWebsiteDomain() { + const websitePort = process.env.REACT_APP_WEBSITE_PORT || 3031; + const websiteUrl = process.env.REACT_APP_WEBSITE_URL || `http://localhost:${websitePort}`; + return getQueryParams("websiteDomain") ?? websiteUrl; +} diff --git a/lib/build/emailpasswordprebuiltui.js b/lib/build/emailpasswordprebuiltui.js index 28263d209..6dd2da964 100644 --- a/lib/build/emailpasswordprebuiltui.js +++ b/lib/build/emailpasswordprebuiltui.js @@ -709,6 +709,7 @@ var SignInForm = uiEntry.withOverride("EmailPasswordSignInForm", function EmailP 4 /*yield*/, props.recipeImplementation.signIn({ formFields: formFields, + tryLinkingWithSessionUser: false, userContext: userContext, }), ]; @@ -953,7 +954,50 @@ var SignInFeature = function (props) { ); }; var getModifiedRecipeImplementation$1 = function (origImpl) { - return superTokens.__assign({}, origImpl); + return superTokens.__assign(superTokens.__assign({}, origImpl), { + signIn: function (input) { + return superTokens.__awaiter(this, void 0, void 0, function () { + var response; + return superTokens.__generator(this, function (_a) { + switch (_a.label) { + case 0: + return [ + 4 /*yield*/, + origImpl.signIn( + superTokens.__assign(superTokens.__assign({}, input), { + tryLinkingWithSessionUser: false, + }) + ), + ]; + case 1: + response = _a.sent(); + return [2 /*return*/, response]; + } + }); + }); + }, + signUp: function (input) { + return superTokens.__awaiter(this, void 0, void 0, function () { + var response; + return superTokens.__generator(this, function (_a) { + switch (_a.label) { + case 0: + return [ + 4 /*yield*/, + origImpl.signUp( + superTokens.__assign(superTokens.__assign({}, input), { + tryLinkingWithSessionUser: false, + }) + ), + ]; + case 1: + response = _a.sent(); + return [2 /*return*/, response]; + } + }); + }); + }, + }); }; var SignUpForm = uiEntry.withOverride("EmailPasswordSignUpForm", function EmailPasswordSignUpForm(props) { @@ -994,6 +1038,7 @@ var SignUpForm = uiEntry.withOverride("EmailPasswordSignUpForm", function EmailP 4 /*yield*/, props.recipeImplementation.signUp({ formFields: formFields, + tryLinkingWithSessionUser: false, userContext: userContext, }), ]; @@ -1201,7 +1246,50 @@ var SignUpFeature = function (props) { ); }; var getModifiedRecipeImplementation = function (origImpl) { - return superTokens.__assign({}, origImpl); + return superTokens.__assign(superTokens.__assign({}, origImpl), { + signIn: function (input) { + return superTokens.__awaiter(this, void 0, void 0, function () { + var response; + return superTokens.__generator(this, function (_a) { + switch (_a.label) { + case 0: + return [ + 4 /*yield*/, + origImpl.signIn( + superTokens.__assign(superTokens.__assign({}, input), { + tryLinkingWithSessionUser: false, + }) + ), + ]; + case 1: + response = _a.sent(); + return [2 /*return*/, response]; + } + }); + }); + }, + signUp: function (input) { + return superTokens.__awaiter(this, void 0, void 0, function () { + var response; + return superTokens.__generator(this, function (_a) { + switch (_a.label) { + case 0: + return [ + 4 /*yield*/, + origImpl.signUp( + superTokens.__assign(superTokens.__assign({}, input), { + tryLinkingWithSessionUser: false, + }) + ), + ]; + case 1: + response = _a.sent(); + return [2 /*return*/, response]; + } + }); + }); + }, + }); }; function getThemeSignUpFeatureFormFields(formFields, recipe, userContext) { var _this = this; diff --git a/lib/build/index2.js b/lib/build/index2.js index 658a76f2d..77de0cac3 100644 --- a/lib/build/index2.js +++ b/lib/build/index2.js @@ -907,6 +907,7 @@ var AuthPageInner = function (props) { var showStringFromQSRef = React.useRef(showStringFromQS); var errorFromQSRef = React.useRef(errorFromQS); var loginChallenge = search.get("loginChallenge"); + var forceFreshAuth = search.get("forceFreshAuth") === "true"; var sessionContext = useSessionContext(); var userContext = useUserContext(); var rethrowInRender = superTokens.useRethrowInRender(); @@ -1021,7 +1022,7 @@ var AuthPageInner = function (props) { if (sessionContext.doesSessionExist) { if (props.onSessionAlreadyExists !== undefined) { props.onSessionAlreadyExists(); - } else if (props.redirectOnSessionExists !== false) { + } else if (props.redirectOnSessionExists !== false && !forceFreshAuth) { types.Session.getInstanceOrThrow().config.onHandleEvent({ action: "SESSION_ALREADY_EXISTS", }); @@ -1128,7 +1129,8 @@ var AuthPageInner = function (props) { }), ctx.recipeId, superTokens.getRedirectToPathFromURL(), - userContext + userContext, + props.navigate ); }, [loginChallenge] diff --git a/lib/build/oauth2provider-shared.js b/lib/build/oauth2provider-shared.js index e0c40e5e5..03b573a62 100644 --- a/lib/build/oauth2provider-shared.js +++ b/lib/build/oauth2provider-shared.js @@ -92,10 +92,7 @@ var OAuth2Provider = /** @class */ (function (_super) { basePath = this.config.appInfo.apiBasePath.getAsStringDangerous(); return [ 2 /*return*/, - "" - .concat(domain) - .concat(basePath, "/oauth2provider/login?loginChallenge=") - .concat(ctx.loginChallenge), + "".concat(domain).concat(basePath, "/oauth/login?loginChallenge=").concat(ctx.loginChallenge), ]; } else { throw new Error( diff --git a/lib/build/passwordlessprebuiltui.js b/lib/build/passwordlessprebuiltui.js index e788b3bbd..b58501178 100644 --- a/lib/build/passwordlessprebuiltui.js +++ b/lib/build/passwordlessprebuiltui.js @@ -1306,12 +1306,13 @@ function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPa resendCode: function (input) { return superTokens.__awaiter(_this, void 0, void 0, function () { var res, loginAttemptInfo, timestamp; - return superTokens.__generator(this, function (_a) { - switch (_a.label) { + var _a; + return superTokens.__generator(this, function (_b) { + switch (_b.label) { case 0: return [4 /*yield*/, originalImpl.resendCode(input)]; case 1: - res = _a.sent(); + res = _b.sent(); if (!(res.status === "OK")) return [3 /*break*/, 5]; return [ 4 /*yield*/, @@ -1320,7 +1321,7 @@ function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPa }), ]; case 2: - loginAttemptInfo = _a.sent(); + loginAttemptInfo = _b.sent(); if (!(loginAttemptInfo !== undefined)) return [3 /*break*/, 4]; timestamp = Date.now(); return [ @@ -1328,13 +1329,17 @@ function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPa originalImpl.setLoginAttemptInfo({ userContext: input.userContext, attemptInfo: superTokens.__assign(superTokens.__assign({}, loginAttemptInfo), { + tryLinkingWithSessionUser: + (_a = loginAttemptInfo.tryLinkingWithSessionUser) !== null && _a !== void 0 + ? _a + : false, lastResend: timestamp, }), }), ]; case 3: - _a.sent(); - _a.label = 4; + _b.sent(); + _b.label = 4; case 4: return [3 /*break*/, 7]; case 5: @@ -1346,10 +1351,10 @@ function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPa }), ]; case 6: - _a.sent(); + _b.sent(); setError("ERROR_SIGN_IN_UP_RESEND_RESTART_FLOW"); rebuildAuthPage(); - _a.label = 7; + _b.label = 7; case 7: return [2 /*return*/, res]; } @@ -1529,6 +1534,7 @@ var EmailForm = uiEntry.withOverride("PasswordlessEmailForm", function Passwordl 4 /*yield*/, props.recipeImplementation.createCode({ email: email, + // tryLinkingWithSessionUser is set by the fn override userContext: userContext, }), ]; @@ -3689,6 +3695,7 @@ var PhoneForm = uiEntry.withOverride("PasswordlessPhoneForm", function Passwordl 4 /*yield*/, props.recipeImplementation.createCode({ phoneNumber: phoneNumber, + // tryLinkingWithSessionUser is set by the fn override userContext: userContext, }), ]; @@ -4768,6 +4775,7 @@ function useOnLoad(props, recipeImplementation, dispatch, userContext) { 4 /*yield*/, recipeImplementation.createCode( superTokens.__assign(superTokens.__assign({}, createCodeInfo), { + tryLinkingWithSessionUser: true, userContext: userContext, }) ), @@ -4906,6 +4914,7 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { 4 /*yield*/, originalImpl.createCode( superTokens.__assign(superTokens.__assign({}, input), { + tryLinkingWithSessionUser: true, userContext: superTokens.__assign(superTokens.__assign({}, input.userContext), { additionalAttemptInfo: additionalAttemptInfo, }), @@ -4934,12 +4943,13 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { resendCode: function (input) { return superTokens.__awaiter(_this, void 0, void 0, function () { var res, loginAttemptInfo, timestamp; - return superTokens.__generator(this, function (_a) { - switch (_a.label) { + var _a; + return superTokens.__generator(this, function (_b) { + switch (_b.label) { case 0: return [4 /*yield*/, originalImpl.resendCode(input)]; case 1: - res = _a.sent(); + res = _b.sent(); if (!(res.status === "OK")) return [3 /*break*/, 5]; return [ 4 /*yield*/, @@ -4948,7 +4958,7 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { }), ]; case 2: - loginAttemptInfo = _a.sent(); + loginAttemptInfo = _b.sent(); if (!(loginAttemptInfo !== undefined)) return [3 /*break*/, 4]; timestamp = Date.now(); return [ @@ -4956,14 +4966,18 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { originalImpl.setLoginAttemptInfo({ userContext: input.userContext, attemptInfo: superTokens.__assign(superTokens.__assign({}, loginAttemptInfo), { + tryLinkingWithSessionUser: + (_a = loginAttemptInfo.tryLinkingWithSessionUser) !== null && _a !== void 0 + ? _a + : true, lastResend: timestamp, }), }), ]; case 3: - _a.sent(); + _b.sent(); dispatch({ type: "resendCode", timestamp: timestamp }); - _a.label = 4; + _b.label = 4; case 4: return [3 /*break*/, 7]; case 5: @@ -4975,9 +4989,9 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { }), ]; case 6: - _a.sent(); + _b.sent(); dispatch({ type: "restartFlow", error: "ERROR_SIGN_IN_UP_RESEND_RESTART_FLOW" }); - _a.label = 7; + _b.label = 7; case 7: return [2 /*return*/, res]; } @@ -5213,6 +5227,7 @@ var EmailOrPhoneForm = uiEntry.withOverride( 4 /*yield*/, props.recipeImplementation.createCode( superTokens.__assign(superTokens.__assign({}, contactInfo), { + // tryLinkingWithSessionUser is set by the fn override userContext: userContext, }) ), @@ -5521,6 +5536,7 @@ function getModifiedRecipeImplementation$2(originalImpl, config, rebuildAuthPage 4 /*yield*/, originalImpl.createCode( superTokens.__assign(superTokens.__assign({}, input), { + tryLinkingWithSessionUser: false, userContext: superTokens.__assign(superTokens.__assign({}, input.userContext), { additionalAttemptInfo: additionalAttemptInfo, }), @@ -6034,6 +6050,7 @@ function useChildProps$1( 4 /*yield*/, recipeImplementation.createCode({ phoneNumber: contactInfo, + tryLinkingWithSessionUser: false, userContext: userContext, }), ]; @@ -6078,7 +6095,11 @@ function useChildProps$1( if (!pwlessExists.doesExist) return [3 /*break*/, 6]; return [ 4 /*yield*/, - recipeImplementation.createCode({ email: email, userContext: userContext }), + recipeImplementation.createCode({ + email: email, + tryLinkingWithSessionUser: false, + userContext: userContext, + }), ]; case 5: createRes = _b.sent(); @@ -6127,6 +6148,7 @@ function useChildProps$1( 4 /*yield*/, recipe$1.EmailPassword.getInstanceOrThrow().webJSRecipe.signIn({ formFields: formFields, + tryLinkingWithSessionUser: false, userContext: userContext, }), ]; @@ -6161,6 +6183,7 @@ function useChildProps$1( 4 /*yield*/, recipeImplementation.createCode( superTokens.__assign(superTokens.__assign({}, createInfo), { + tryLinkingWithSessionUser: false, userContext: userContext, }) ), @@ -6374,6 +6397,7 @@ function getModifiedRecipeImplementation$1(originalImpl, config, rebuildAuthPage 4 /*yield*/, originalImpl.createCode( superTokens.__assign(superTokens.__assign({}, input), { + tryLinkingWithSessionUser: false, userContext: superTokens.__assign(superTokens.__assign({}, input.userContext), { additionalAttemptInfo: additionalAttemptInfo, }), @@ -6569,12 +6593,13 @@ function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage resendCode: function (input) { return superTokens.__awaiter(_this, void 0, void 0, function () { var res, loginAttemptInfo, timestamp; - return superTokens.__generator(this, function (_a) { - switch (_a.label) { + var _a; + return superTokens.__generator(this, function (_b) { + switch (_b.label) { case 0: return [4 /*yield*/, originalImpl.resendCode(input)]; case 1: - res = _a.sent(); + res = _b.sent(); if (!(res.status === "OK")) return [3 /*break*/, 5]; return [ 4 /*yield*/, @@ -6583,7 +6608,7 @@ function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage }), ]; case 2: - loginAttemptInfo = _a.sent(); + loginAttemptInfo = _b.sent(); if (!(loginAttemptInfo !== undefined)) return [3 /*break*/, 4]; timestamp = Date.now(); return [ @@ -6591,13 +6616,17 @@ function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage originalImpl.setLoginAttemptInfo({ userContext: input.userContext, attemptInfo: superTokens.__assign(superTokens.__assign({}, loginAttemptInfo), { + tryLinkingWithSessionUser: + (_a = loginAttemptInfo.tryLinkingWithSessionUser) !== null && _a !== void 0 + ? _a + : false, lastResend: timestamp, }), }), ]; case 3: - _a.sent(); - _a.label = 4; + _b.sent(); + _b.label = 4; case 4: return [3 /*break*/, 7]; case 5: @@ -6609,10 +6638,10 @@ function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage }), ]; case 6: - _a.sent(); + _b.sent(); setError("ERROR_SIGN_IN_UP_RESEND_RESTART_FLOW"); rebuildAuthPage(); - _a.label = 7; + _b.label = 7; case 7: return [2 /*return*/, res]; } diff --git a/lib/build/recipe/emailpassword/index.d.ts b/lib/build/recipe/emailpassword/index.d.ts index f5dbca606..089a44d92 100644 --- a/lib/build/recipe/emailpassword/index.d.ts +++ b/lib/build/recipe/emailpassword/index.d.ts @@ -66,6 +66,7 @@ export default class Wrapper { id: string; value: string; }[]; + tryLinkingWithSessionUser?: boolean; options?: RecipeFunctionOptions; userContext?: UserContext; }): Promise< @@ -93,6 +94,7 @@ export default class Wrapper { id: string; value: string; }[]; + tryLinkingWithSessionUser?: boolean; options?: RecipeFunctionOptions; userContext?: UserContext; }): Promise< diff --git a/lib/build/recipe/passwordless/index.d.ts b/lib/build/recipe/passwordless/index.d.ts index 0bf17133d..5f851efbe 100644 --- a/lib/build/recipe/passwordless/index.d.ts +++ b/lib/build/recipe/passwordless/index.d.ts @@ -20,11 +20,13 @@ export default class Wrapper { input: | { email: string; + tryLinkingWithSessionUser?: boolean; userContext?: UserContext; options?: RecipeFunctionOptions; } | { phoneNumber: string; + tryLinkingWithSessionUser?: boolean; userContext?: UserContext; options?: RecipeFunctionOptions; } diff --git a/lib/build/recipe/session/recipe.d.ts b/lib/build/recipe/session/recipe.d.ts index 1077959b6..4925a3630 100644 --- a/lib/build/recipe/session/recipe.d.ts +++ b/lib/build/recipe/session/recipe.d.ts @@ -58,9 +58,9 @@ export default class Session extends RecipeModule Promise; /** * This should only get called if validateGlobalClaimsAndHandleSuccessRedirection couldn't get a redirectInfo diff --git a/lib/build/recipe/thirdparty/index.d.ts b/lib/build/recipe/thirdparty/index.d.ts index 6b8fb2194..9978aeb1f 100644 --- a/lib/build/recipe/thirdparty/index.d.ts +++ b/lib/build/recipe/thirdparty/index.d.ts @@ -41,6 +41,7 @@ export default class Wrapper { thirdPartyId: string; frontendRedirectURI: string; redirectURIOnProviderDashboard?: string; + tryLinkingWithSessionUser?: boolean; userContext?: UserContext; options?: RecipeFunctionOptions; }): Promise; diff --git a/lib/build/thirdparty-shared.js b/lib/build/thirdparty-shared.js index 6be7a734c..626dfd0fe 100644 --- a/lib/build/thirdparty-shared.js +++ b/lib/build/thirdparty-shared.js @@ -1299,6 +1299,7 @@ function redirectToThirdPartyLogin(input) { thirdPartyId: input.thirdPartyId, frontendRedirectURI: provider.getRedirectURL(), redirectURIOnProviderDashboard: provider.getRedirectURIOnProviderDashboard(), + tryLinkingWithSessionUser: false, userContext: input.userContext, }), ]; diff --git a/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx b/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx index de23b96b3..66fa995f1 100644 --- a/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx +++ b/lib/ts/recipe/authRecipe/components/feature/authPage/authPage.tsx @@ -105,6 +105,7 @@ const AuthPageInner: React.FC = (props) => { const showStringFromQSRef = useRef(showStringFromQS); const errorFromQSRef = useRef(errorFromQS); const loginChallenge = search.get("loginChallenge"); + const forceFreshAuth = search.get("forceFreshAuth") === "true"; const sessionContext = useSessionContext(); const userContext = useUserContext(); @@ -191,7 +192,7 @@ const AuthPageInner: React.FC = (props) => { if (sessionContext.doesSessionExist) { if (props.onSessionAlreadyExists !== undefined) { props.onSessionAlreadyExists(); - } else if (props.redirectOnSessionExists !== false) { + } else if (props.redirectOnSessionExists !== false && !forceFreshAuth) { Session.getInstanceOrThrow().config.onHandleEvent({ action: "SESSION_ALREADY_EXISTS", }); @@ -298,7 +299,8 @@ const AuthPageInner: React.FC = (props) => { }, ctx.recipeId, getRedirectToPathFromURL(), - userContext + userContext, + props.navigate ); }, [loginChallenge] diff --git a/lib/ts/recipe/emailpassword/components/features/signin/index.tsx b/lib/ts/recipe/emailpassword/components/features/signin/index.tsx index 0ffe5ab2d..dd580735f 100644 --- a/lib/ts/recipe/emailpassword/components/features/signin/index.tsx +++ b/lib/ts/recipe/emailpassword/components/features/signin/index.tsx @@ -182,5 +182,13 @@ export default SignInFeature; const getModifiedRecipeImplementation = (origImpl: RecipeInterface): RecipeInterface => { return { ...origImpl, + signIn: async function (input) { + const response = await origImpl.signIn({ ...input, tryLinkingWithSessionUser: false }); + return response; + }, + signUp: async function (input) { + const response = await origImpl.signUp({ ...input, tryLinkingWithSessionUser: false }); + return response; + }, }; }; diff --git a/lib/ts/recipe/emailpassword/components/features/signup/index.tsx b/lib/ts/recipe/emailpassword/components/features/signup/index.tsx index 24b2e5152..46728ee42 100644 --- a/lib/ts/recipe/emailpassword/components/features/signup/index.tsx +++ b/lib/ts/recipe/emailpassword/components/features/signup/index.tsx @@ -166,6 +166,14 @@ export default SignUpFeature; const getModifiedRecipeImplementation = (origImpl: RecipeInterface): RecipeInterface => { return { ...origImpl, + signIn: async function (input) { + const response = await origImpl.signIn({ ...input, tryLinkingWithSessionUser: false }); + return response; + }, + signUp: async function (input) { + const response = await origImpl.signUp({ ...input, tryLinkingWithSessionUser: false }); + return response; + }, }; }; diff --git a/lib/ts/recipe/emailpassword/components/themes/signIn/index.tsx b/lib/ts/recipe/emailpassword/components/themes/signIn/index.tsx index 0c7817f71..7e57d8aef 100644 --- a/lib/ts/recipe/emailpassword/components/themes/signIn/index.tsx +++ b/lib/ts/recipe/emailpassword/components/themes/signIn/index.tsx @@ -58,6 +58,7 @@ export const SignInForm = withOverride( const response = await props.recipeImplementation.signIn({ formFields, + tryLinkingWithSessionUser: false, userContext, }); if (response.status === "WRONG_CREDENTIALS_ERROR") { diff --git a/lib/ts/recipe/emailpassword/components/themes/signUp/index.tsx b/lib/ts/recipe/emailpassword/components/themes/signUp/index.tsx index f0388629b..b0c76e350 100644 --- a/lib/ts/recipe/emailpassword/components/themes/signUp/index.tsx +++ b/lib/ts/recipe/emailpassword/components/themes/signUp/index.tsx @@ -58,6 +58,7 @@ export const SignUpForm = withOverride( const res = await props.recipeImplementation.signUp({ formFields, + tryLinkingWithSessionUser: false, userContext, }); diff --git a/lib/ts/recipe/emailpassword/index.ts b/lib/ts/recipe/emailpassword/index.ts index e601cf2ba..98d170cf5 100644 --- a/lib/ts/recipe/emailpassword/index.ts +++ b/lib/ts/recipe/emailpassword/index.ts @@ -100,6 +100,7 @@ export default class Wrapper { id: string; value: string; }[]; + tryLinkingWithSessionUser?: boolean; options?: RecipeFunctionOptions; userContext?: UserContext; }): Promise< @@ -133,6 +134,7 @@ export default class Wrapper { id: string; value: string; }[]; + tryLinkingWithSessionUser?: boolean; options?: RecipeFunctionOptions; userContext?: UserContext; }): Promise< diff --git a/lib/ts/recipe/oauth2provider/recipe.ts b/lib/ts/recipe/oauth2provider/recipe.ts index f59a09d1e..d88503db1 100644 --- a/lib/ts/recipe/oauth2provider/recipe.ts +++ b/lib/ts/recipe/oauth2provider/recipe.ts @@ -111,7 +111,7 @@ export default class OAuth2Provider extends RecipeModule< const domain = this.config.appInfo.apiDomain.getAsStringDangerous(); const basePath = this.config.appInfo.apiBasePath.getAsStringDangerous(); - return `${domain}${basePath}/oauth2provider/login?loginChallenge=${ctx.loginChallenge}`; + return `${domain}${basePath}/oauth/login?loginChallenge=${ctx.loginChallenge}`; } else { throw new Error("Should never come here: unknown action in OAuth2Provider.getDefaultRedirectionURL"); } diff --git a/lib/ts/recipe/passwordless/components/features/linkSent/index.tsx b/lib/ts/recipe/passwordless/components/features/linkSent/index.tsx index a6ec99e49..d31beed4a 100644 --- a/lib/ts/recipe/passwordless/components/features/linkSent/index.tsx +++ b/lib/ts/recipe/passwordless/components/features/linkSent/index.tsx @@ -204,6 +204,7 @@ function getModifiedRecipeImplementation( userContext: input.userContext, attemptInfo: { ...loginAttemptInfo, + tryLinkingWithSessionUser: loginAttemptInfo.tryLinkingWithSessionUser ?? false, lastResend: timestamp, }, }); diff --git a/lib/ts/recipe/passwordless/components/features/mfa/index.tsx b/lib/ts/recipe/passwordless/components/features/mfa/index.tsx index 7fd0332cf..c80e9d4c5 100644 --- a/lib/ts/recipe/passwordless/components/features/mfa/index.tsx +++ b/lib/ts/recipe/passwordless/components/features/mfa/index.tsx @@ -357,6 +357,7 @@ function useOnLoad( // createCode also dispatches the event that marks this page fully loaded createResp = await recipeImplementation!.createCode({ ...createCodeInfo, + tryLinkingWithSessionUser: true, userContext, }); } catch (err: any) { @@ -463,6 +464,7 @@ function getModifiedRecipeImplementation( const res = await originalImpl.createCode({ ...input, + tryLinkingWithSessionUser: true, userContext: { ...input.userContext, additionalAttemptInfo }, }); @@ -493,6 +495,7 @@ function getModifiedRecipeImplementation( userContext: input.userContext, attemptInfo: { ...loginAttemptInfo, + tryLinkingWithSessionUser: loginAttemptInfo.tryLinkingWithSessionUser ?? true, lastResend: timestamp, }, }); diff --git a/lib/ts/recipe/passwordless/components/features/signInAndUp/index.tsx b/lib/ts/recipe/passwordless/components/features/signInAndUp/index.tsx index a825d2d32..34c440ff6 100644 --- a/lib/ts/recipe/passwordless/components/features/signInAndUp/index.tsx +++ b/lib/ts/recipe/passwordless/components/features/signInAndUp/index.tsx @@ -208,6 +208,7 @@ function getModifiedRecipeImplementation( const res = await originalImpl.createCode({ ...input, + tryLinkingWithSessionUser: false, userContext: { ...input.userContext, additionalAttemptInfo }, }); if (res.status === "OK") { diff --git a/lib/ts/recipe/passwordless/components/features/signInAndUpEPCombo/index.tsx b/lib/ts/recipe/passwordless/components/features/signInAndUpEPCombo/index.tsx index 96a6a3852..adc9e243c 100644 --- a/lib/ts/recipe/passwordless/components/features/signInAndUpEPCombo/index.tsx +++ b/lib/ts/recipe/passwordless/components/features/signInAndUpEPCombo/index.tsx @@ -76,7 +76,11 @@ export function useChildProps( showContinueWithPasswordlessLink, onContactInfoSubmit: async (contactInfo: string) => { if (isPhoneNumber) { - const createRes = await recipeImplementation.createCode({ phoneNumber: contactInfo, userContext }); + const createRes = await recipeImplementation.createCode({ + phoneNumber: contactInfo, + tryLinkingWithSessionUser: false, + userContext, + }); if (createRes.status === "SIGN_IN_UP_NOT_ALLOWED") { throw new STGeneralError(createRes.reason); @@ -105,7 +109,11 @@ export function useChildProps( return { status: "OK" }; } else if (pwlessExists.doesExist) { // only pwless exists - const createRes = await recipeImplementation.createCode({ email, userContext }); + const createRes = await recipeImplementation.createCode({ + email, + tryLinkingWithSessionUser: false, + userContext, + }); if (createRes.status === "SIGN_IN_UP_NOT_ALLOWED") { throw new STGeneralError(createRes.reason); @@ -134,6 +142,7 @@ export function useChildProps( const response = await EmailPassword.getInstanceOrThrow().webJSRecipe.signIn({ formFields, + tryLinkingWithSessionUser: false, userContext, }); if (response.status === "WRONG_CREDENTIALS_ERROR") { @@ -147,7 +156,11 @@ export function useChildProps( onContinueWithPasswordlessClick: async (contactInfo) => { // When this function is called, the contactInfo has already been validated const createInfo = isPhoneNumber ? { phoneNumber: contactInfo } : { email: contactInfo }; - const createRes = await recipeImplementation.createCode({ ...createInfo, userContext }); + const createRes = await recipeImplementation.createCode({ + ...createInfo, + tryLinkingWithSessionUser: false, + userContext, + }); if (createRes.status !== "OK") { onError(createRes.reason); } else { @@ -313,6 +326,7 @@ function getModifiedRecipeImplementation( const res = await originalImpl.createCode({ ...input, + tryLinkingWithSessionUser: false, userContext: { ...input.userContext, additionalAttemptInfo }, }); if (res.status === "OK") { diff --git a/lib/ts/recipe/passwordless/components/features/userInputCode/index.tsx b/lib/ts/recipe/passwordless/components/features/userInputCode/index.tsx index 7141d7d13..bcdeff3b2 100644 --- a/lib/ts/recipe/passwordless/components/features/userInputCode/index.tsx +++ b/lib/ts/recipe/passwordless/components/features/userInputCode/index.tsx @@ -199,6 +199,7 @@ function getModifiedRecipeImplementation( userContext: input.userContext, attemptInfo: { ...loginAttemptInfo, + tryLinkingWithSessionUser: loginAttemptInfo.tryLinkingWithSessionUser ?? false, lastResend: timestamp, }, }); diff --git a/lib/ts/recipe/passwordless/components/themes/signInUp/emailForm.tsx b/lib/ts/recipe/passwordless/components/themes/signInUp/emailForm.tsx index 902924b0c..8eb3b1911 100644 --- a/lib/ts/recipe/passwordless/components/themes/signInUp/emailForm.tsx +++ b/lib/ts/recipe/passwordless/components/themes/signInUp/emailForm.tsx @@ -62,6 +62,7 @@ export const EmailForm = withOverride( const response = await props.recipeImplementation.createCode({ email, + // tryLinkingWithSessionUser is set by the fn override userContext, }); diff --git a/lib/ts/recipe/passwordless/components/themes/signInUp/emailOrPhoneForm.tsx b/lib/ts/recipe/passwordless/components/themes/signInUp/emailOrPhoneForm.tsx index 795bf7faa..2b4b609fb 100644 --- a/lib/ts/recipe/passwordless/components/themes/signInUp/emailOrPhoneForm.tsx +++ b/lib/ts/recipe/passwordless/components/themes/signInUp/emailOrPhoneForm.tsx @@ -137,6 +137,7 @@ export const EmailOrPhoneForm = withOverride( const response = await props.recipeImplementation.createCode({ ...contactInfo, + // tryLinkingWithSessionUser is set by the fn override userContext, }); diff --git a/lib/ts/recipe/passwordless/components/themes/signInUp/phoneForm.tsx b/lib/ts/recipe/passwordless/components/themes/signInUp/phoneForm.tsx index 0fe9efe43..58d84f969 100644 --- a/lib/ts/recipe/passwordless/components/themes/signInUp/phoneForm.tsx +++ b/lib/ts/recipe/passwordless/components/themes/signInUp/phoneForm.tsx @@ -79,6 +79,7 @@ export const PhoneForm = withOverride( const response = await props.recipeImplementation.createCode({ phoneNumber, + // tryLinkingWithSessionUser is set by the fn override userContext, }); diff --git a/lib/ts/recipe/passwordless/index.ts b/lib/ts/recipe/passwordless/index.ts index b3276b8e0..0ce48c588 100644 --- a/lib/ts/recipe/passwordless/index.ts +++ b/lib/ts/recipe/passwordless/index.ts @@ -40,8 +40,18 @@ export default class Wrapper { static async createCode( input: - | { email: string; userContext?: UserContext; options?: RecipeFunctionOptions } - | { phoneNumber: string; userContext?: UserContext; options?: RecipeFunctionOptions } + | { + email: string; + tryLinkingWithSessionUser?: boolean; + userContext?: UserContext; + options?: RecipeFunctionOptions; + } + | { + phoneNumber: string; + tryLinkingWithSessionUser?: boolean; + userContext?: UserContext; + options?: RecipeFunctionOptions; + } ): Promise< | { status: "OK"; diff --git a/lib/ts/recipe/session/recipe.tsx b/lib/ts/recipe/session/recipe.tsx index e6dca7ac9..98ac0fb94 100644 --- a/lib/ts/recipe/session/recipe.tsx +++ b/lib/ts/recipe/session/recipe.tsx @@ -134,9 +134,9 @@ export default class Session extends RecipeModule => { userContext = getNormalisedUserContext(userContext); // First we check if there is an active session diff --git a/lib/ts/recipe/thirdparty/index.ts b/lib/ts/recipe/thirdparty/index.ts index 126364905..7f35750e9 100644 --- a/lib/ts/recipe/thirdparty/index.ts +++ b/lib/ts/recipe/thirdparty/index.ts @@ -86,6 +86,7 @@ export default class Wrapper { thirdPartyId: string; frontendRedirectURI: string; redirectURIOnProviderDashboard?: string; + tryLinkingWithSessionUser?: boolean; userContext?: UserContext; options?: RecipeFunctionOptions; }): Promise { diff --git a/lib/ts/recipe/thirdparty/utils.ts b/lib/ts/recipe/thirdparty/utils.ts index eceb9dd45..3b48b8883 100644 --- a/lib/ts/recipe/thirdparty/utils.ts +++ b/lib/ts/recipe/thirdparty/utils.ts @@ -152,6 +152,7 @@ export async function redirectToThirdPartyLogin(input: { thirdPartyId: input.thirdPartyId, frontendRedirectURI: provider.getRedirectURL(), redirectURIOnProviderDashboard: provider.getRedirectURIOnProviderDashboard(), + tryLinkingWithSessionUser: false, userContext: input.userContext, }); diff --git a/test/end-to-end/emailverification.test.js b/test/end-to-end/emailverification.test.js index 585d9d08e..435f29f27 100644 --- a/test/end-to-end/emailverification.test.js +++ b/test/end-to-end/emailverification.test.js @@ -104,6 +104,7 @@ describe("SuperTokens Email Verification", function () { consoleLogs = []; page.on("console", (consoleObj) => { const log = consoleObj.text(); + // console.log(log); if (log.startsWith("ST_LOGS")) { consoleLogs.push(log); } diff --git a/test/end-to-end/generalerror.test.js b/test/end-to-end/generalerror.test.js index 10160aebd..b29d76fa3 100644 --- a/test/end-to-end/generalerror.test.js +++ b/test/end-to-end/generalerror.test.js @@ -175,7 +175,7 @@ describe("General error rendering", function () { { name: "name", value: "John Doe" }, { name: "age", value: "20" }, ], - '{"formFields":[{"id":"email","value":"john.doe2@supertokens.io"},{"id":"password","value":"Str0ngP@ssw0rd"},{"id":"name","value":"John Doe"},{"id":"age","value":"20"},{"id":"country","value":""}]}', + '{"formFields":[{"id":"email","value":"john.doe2@supertokens.io"},{"id":"password","value":"Str0ngP@ssw0rd"},{"id":"name","value":"John Doe"},{"id":"age","value":"20"},{"id":"country","value":""}],"tryLinkingWithSessionUser":false}', rid ); diff --git a/test/end-to-end/oauth2provider.test.js b/test/end-to-end/oauth2provider.test.js new file mode 100644 index 000000000..0165ce80b --- /dev/null +++ b/test/end-to-end/oauth2provider.test.js @@ -0,0 +1,197 @@ +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +/* + * Imports + */ + +import assert from "assert"; +import puppeteer from "puppeteer"; +import { + clearBrowserCookiesWithoutAffectingConsole, + toggleSignInSignUp, + screenshotOnFailure, + backendBeforeEach, + waitForUrl, + createOAuth2Client, + setOAuth2ClientIdInStorage, + removeOAuth2ClientIdFromStorage, + getOAuth2LoginButton, + getOAuth2LogoutButton, + getOAuth2TokenData, + isReact16, + waitFor, + signUp, + getDefaultSignUpFieldValues, + getTestEmail, +} from "../helpers"; +import fetch from "isomorphic-fetch"; + +import { TEST_CLIENT_BASE_URL, TEST_SERVER_BASE_URL, SIGN_OUT_API } from "../constants"; + +// We do no thave to use a separate domain for the oauth2 client, since the way we are testing +// the lib doesn't interact with the supertokens session handling. +// Using a redirection uri that has the same domain as the auth portal shouldn't affect the test. + +/* + * Tests. + */ +describe("SuperTokens OAuth2Provider", function () { + let browser; + let page; + let consoleLogs = []; + let skipped = false; + + before(async function () { + // Skip these tests if running in React 16 + if (isReact16()) { + skipped = true; + this.skip(); + } + + await backendBeforeEach(); + + await fetch(`${TEST_SERVER_BASE_URL}/startst`, { + method: "POST", + }).catch(console.error); + + browser = await puppeteer.launch({ + args: ["--no-sandbox", "--disable-setuid-sandbox"], + headless: true, + }); + }); + + after(async function () { + if (skipped) { + return; + } + await browser.close(); + + await fetch(`${TEST_SERVER_BASE_URL}/after`, { + method: "POST", + }).catch(console.error); + + await fetch(`${TEST_SERVER_BASE_URL}/stopst`, { + method: "POST", + }).catch(console.error); + }); + + afterEach(function () { + return screenshotOnFailure(this, browser); + }); + + beforeEach(async function () { + page = await browser.newPage(); + page.on("console", (consoleObj) => { + const log = consoleObj.text(); + if (log.startsWith("ST_LOGS")) { + consoleLogs.push(log); + } + }); + consoleLogs = await clearBrowserCookiesWithoutAffectingConsole(page, []); + }); + + describe("Generic OAuth2 Client Library", function () { + afterEach(async function () { + await removeOAuth2ClientIdFromStorage(page); + }); + + it("should successfully complete the OAuth2 flow", async function () { + const { client } = await createOAuth2Client({ + scope: "offline_access profile openid email", + redirectUris: [`${TEST_CLIENT_BASE_URL}/oauth2/callback`], + accessTokenStrategy: "jwt", + tokenEndpointAuthMethod: "none", + grantTypes: ["authorization_code", "refresh_token"], + responseTypes: ["code", "id_token"], + skipConsent: true, + }); + + await setOAuth2ClientIdInStorage(page, client.clientId); + + await page.goto(`${TEST_CLIENT_BASE_URL}/oauth2/login`); + + let loginButton = await getOAuth2LoginButton(page); + await loginButton.click(); + + await waitForUrl(page, "/auth"); + + await toggleSignInSignUp(page); + const { fieldValues, postValues } = getDefaultSignUpFieldValues({ email: getTestEmail() }); + await signUp(page, fieldValues, postValues, "emailpassword"); + + await waitForUrl(page, "/oauth2/callback"); + + // Validate token data + const tokenData = await getOAuth2TokenData(page); + assert.deepStrictEqual(tokenData.aud, [client.clientId]); + + // Logout + const logoutButton = await getOAuth2LogoutButton(page); + await logoutButton.click(); + + // Ensure the Login Button is visible after logout is clicked + loginButton = await getOAuth2LoginButton(page); + assert.ok(loginButton !== null); + }); + + it("should successfully refresh the tokens after expiry", async function () { + const { client } = await createOAuth2Client({ + scope: "offline_access profile openid email", + redirectUris: [`${TEST_CLIENT_BASE_URL}/oauth2/callback`], + accessTokenStrategy: "jwt", + tokenEndpointAuthMethod: "none", + grantTypes: ["authorization_code", "refresh_token"], + responseTypes: ["code", "id_token"], + skipConsent: true, + // The library refreshes the token 60 seconds before it expires. + // We set the token lifespan to 63 seconds to force a refresh in 3 seconds. + authorizationCodeGrantAccessTokenLifespan: "63s", + }); + + await setOAuth2ClientIdInStorage(page, client.clientId); + + await page.goto(`${TEST_CLIENT_BASE_URL}/oauth2/login`); + + let loginButton = await getOAuth2LoginButton(page); + await loginButton.click(); + + await waitForUrl(page, "/auth"); + + await toggleSignInSignUp(page); + const { fieldValues, postValues } = getDefaultSignUpFieldValues({ email: getTestEmail() }); + await signUp(page, fieldValues, postValues, "emailpassword"); + + await waitForUrl(page, "/oauth2/callback"); + + // Validate token data + const tokenDataAfterLogin = await getOAuth2TokenData(page); + assert.deepStrictEqual(tokenDataAfterLogin.aud, [client.clientId]); + + // Although the react-oidc-context library automatically refreshes the + // token, we wait for 4 seconds and reload the page to ensure a refresh. + await waitFor(4000); + await page.reload(); + await page.waitForNavigation({ waitUntil: "networkidle0" }); + + const tokenDataAfterRefresh = await getOAuth2TokenData(page); + assert.deepStrictEqual(tokenDataAfterRefresh.aud, [client.clientId]); + + // Validate the token was refreshed + assert(tokenDataAfterLogin.iat !== tokenDataAfterRefresh.iat); + assert(tokenDataAfterLogin.exp < tokenDataAfterRefresh.exp); + }); + }); +}); diff --git a/test/end-to-end/signin-rrdv6.test.js b/test/end-to-end/signin-rrdv6.test.js index ab595eba7..53dbcdc84 100644 --- a/test/end-to-end/signin-rrdv6.test.js +++ b/test/end-to-end/signin-rrdv6.test.js @@ -186,7 +186,7 @@ describe("SuperTokens SignIn with react router dom v6", function () { assert.strictEqual(request.headers().rid, "emailpassword"); assert.strictEqual( request.postData(), - '{"formFields":[{"id":"email","value":"john@gmail.com"},{"id":"password","value":"********"}]}' + '{"formFields":[{"id":"email","value":"john@gmail.com"},{"id":"password","value":"********"}],"tryLinkingWithSessionUser":false}' ); assert.strictEqual(response.status, "WRONG_CREDENTIALS_ERROR"); @@ -258,7 +258,7 @@ describe("SuperTokens SignIn with react router dom v6", function () { assert.strictEqual(request.headers().rid, "emailpassword"); assert.strictEqual( request.postData(), - '{"formFields":[{"id":"email","value":"john.doe@supertokens.io"},{"id":"password","value":"Str0ngP@ssw0rd"}]}' + '{"formFields":[{"id":"email","value":"john.doe@supertokens.io"},{"id":"password","value":"Str0ngP@ssw0rd"}],"tryLinkingWithSessionUser":false}' ); assert.strictEqual(response.status, "OK"); @@ -403,7 +403,7 @@ describe("SuperTokens SignIn with react router dom v6", function () { assert.strictEqual(request.headers().rid, "emailpassword"); assert.strictEqual( request.postData(), - '{"formFields":[{"id":"email","value":"john.doe@supertokens.io"},{"id":"password","value":"Str0ngP@ssw0rd"}]}' + '{"formFields":[{"id":"email","value":"john.doe@supertokens.io"},{"id":"password","value":"Str0ngP@ssw0rd"}],"tryLinkingWithSessionUser":false}' ); assert.strictEqual(response.status, "OK"); diff --git a/test/end-to-end/signin.test.js b/test/end-to-end/signin.test.js index 877cfe70b..876fd83bd 100644 --- a/test/end-to-end/signin.test.js +++ b/test/end-to-end/signin.test.js @@ -183,7 +183,7 @@ describe("SuperTokens SignIn", function () { assert.strictEqual(request.headers().rid, "emailpassword"); assert.strictEqual( request.postData(), - '{"formFields":[{"id":"email","value":"john@gmail.com"},{"id":"password","value":"********"}]}' + '{"formFields":[{"id":"email","value":"john@gmail.com"},{"id":"password","value":"********"}],"tryLinkingWithSessionUser":false}' ); assert.strictEqual(response.status, "WRONG_CREDENTIALS_ERROR"); @@ -270,7 +270,7 @@ describe("SuperTokens SignIn", function () { assert.strictEqual(request.headers().rid, "emailpassword"); assert.strictEqual( request.postData(), - '{"formFields":[{"id":"email","value":"john.doe@supertokens.io"},{"id":"password","value":"Str0ngP@ssw0rd"}]}' + '{"formFields":[{"id":"email","value":"john.doe@supertokens.io"},{"id":"password","value":"Str0ngP@ssw0rd"}],"tryLinkingWithSessionUser":false}' ); assert.strictEqual(response.status, "OK"); @@ -415,7 +415,7 @@ describe("SuperTokens SignIn", function () { assert.strictEqual(request.headers().rid, "emailpassword"); assert.strictEqual( request.postData(), - '{"formFields":[{"id":"email","value":"john.doe@supertokens.io"},{"id":"password","value":"Str0ngP@ssw0rd"}]}' + '{"formFields":[{"id":"email","value":"john.doe@supertokens.io"},{"id":"password","value":"Str0ngP@ssw0rd"}],"tryLinkingWithSessionUser":false}' ); assert.strictEqual(response.status, "OK"); diff --git a/test/end-to-end/thirdpartyemailpassword.test.js b/test/end-to-end/thirdpartyemailpassword.test.js index ae102d88d..d1b7f56fa 100644 --- a/test/end-to-end/thirdpartyemailpassword.test.js +++ b/test/end-to-end/thirdpartyemailpassword.test.js @@ -332,7 +332,7 @@ describe("SuperTokens Third Party Email Password", function () { { name: "name", value: "John Doe" }, { name: "age", value: "20" }, ], - '{"formFields":[{"id":"email","value":"bradparishdoh@gmail.com"},{"id":"password","value":"Str0ngP@ssw0rd"},{"id":"name","value":"John Doe"},{"id":"age","value":"20"},{"id":"country","value":""}]}', + '{"formFields":[{"id":"email","value":"bradparishdoh@gmail.com"},{"id":"password","value":"Str0ngP@ssw0rd"},{"id":"name","value":"John Doe"},{"id":"age","value":"20"},{"id":"country","value":""}],"tryLinkingWithSessionUser":false}', "thirdpartyemailpassword" ); await waitForUrl(page, "/dashboard"); diff --git a/test/helpers.js b/test/helpers.js index bb8b123e3..efe97ed4d 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -649,7 +649,7 @@ export async function defaultSignUp(page, rid = "emailpassword") { { name: "name", value: "John Doe" }, { name: "age", value: "20" }, ], - '{"formFields":[{"id":"email","value":"john.doe@supertokens.io"},{"id":"password","value":"Str0ngP@ssw0rd"},{"id":"name","value":"John Doe"},{"id":"age","value":"20"},{"id":"country","value":""}]}', + '{"formFields":[{"id":"email","value":"john.doe@supertokens.io"},{"id":"password","value":"Str0ngP@ssw0rd"},{"id":"name","value":"John Doe"},{"id":"age","value":"20"},{"id":"country","value":""}],"tryLinkingWithSessionUser":false}', rid ); } @@ -666,7 +666,7 @@ export function getDefaultSignUpFieldValues({ { name: "name", value: name }, { name: "age", value: age }, ]; - const postValues = `{"formFields":[{"id":"email","value":"${email}"},{"id":"password","value":"${password}"},{"id":"name","value":"${name}"},{"id":"age","value":"${age}"},{"id":"country","value":""}]}`; + const postValues = `{"formFields":[{"id":"email","value":"${email}"},{"id":"password","value":"${password}"},{"id":"name","value":"${name}"},{"id":"age","value":"${age}"},{"id":"country","value":""}],"tryLinkingWithSessionUser":false}`; return { fieldValues, postValues }; } @@ -958,7 +958,7 @@ export async function setGeneralErrorToLocalStorage(recipeName, action, page) { }); } -export async function getTestEmail(post) { +export function getTestEmail(post) { return `john.doe+${Date.now()}-${post ?? "0"}@supertokens.io`; } @@ -1105,3 +1105,36 @@ export async function expectErrorThrown(page, cb) { await Promise.all([hitErrorBoundary, cb()]); assert(hitErrorBoundary); } + +export async function createOAuth2Client(input) { + const resp = await fetch(`${TEST_APPLICATION_SERVER_BASE_URL}/test/create-oauth2-client`, { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify(input), + }); + return await resp.json(); +} + +// For the OAuth2 end-to-end test, we need to provide the created clientId to both the OAuth2 login and callback pages. +// We use localStorage to store the clientId instead of query params, as it must be available on the callback page as well. +export async function setOAuth2ClientIdInStorage(page, clientId) { + return page.evaluate((clientId) => localStorage.setItem("oauth2-client-id", clientId), clientId); +} + +export async function removeOAuth2ClientIdFromStorage(page) { + return page.evaluate(() => localStorage.removeItem("oauth2-client-id")); +} + +export async function getOAuth2LoginButton(page) { + return page.waitForSelector("#oauth2-login-button"); +} + +export async function getOAuth2LogoutButton(page) { + return page.waitForSelector("#oauth2-logout-button"); +} + +export async function getOAuth2TokenData(page) { + const element = await page.waitForSelector("#oauth2-token-data"); + const tokenData = await element.evaluate((el) => el.textContent); + return JSON.parse(tokenData); +} diff --git a/test/server/index.js b/test/server/index.js index a59381352..f76e6c3a1 100644 --- a/test/server/index.js +++ b/test/server/index.js @@ -52,7 +52,7 @@ const UserRolesRaw = require("supertokens-node/lib/build/recipe/userroles/recipe const UserRoles = require("supertokens-node/recipe/userroles"); const MultitenancyRaw = require("supertokens-node/lib/build/recipe/multitenancy/recipe").default; -const Multitenancy = require("supertokens-node/lib/build/recipe/multitenancy"); +const Multitenancy = require("supertokens-node/recipe/multitenancy"); const AccountLinkingRaw = require("supertokens-node/lib/build/recipe/accountlinking/recipe").default; const AccountLinking = require("supertokens-node/recipe/accountlinking"); @@ -66,6 +66,9 @@ const MultiFactorAuth = require("supertokens-node/recipe/multifactorauth"); const TOTPRaw = require("supertokens-node/lib/build/recipe/totp/recipe").default; const TOTP = require("supertokens-node/recipe/totp"); +const OAuth2ProviderRaw = require("supertokens-node/lib/build/recipe/oauth2provider/recipe").default; +const OAuth2Provider = require("supertokens-node/recipe/oauth2provider"); + const OTPAuth = require("otpauth"); let generalErrorSupported; @@ -386,10 +389,22 @@ app.get("/token", async (_, res) => { app.post("/setupTenant", async (req, res) => { const { tenantId, loginMethods, coreConfig } = req.body; + const firstFactors = []; + + if (loginMethods.emailPassword?.enabled === true) { + firstFactors.push("emailpassword"); + } + if (loginMethods.thirdParty?.enabled === true) { + firstFactors.push("thirdparty"); + } + if (loginMethods.passwordless?.enabled === true) { + firstFactors.push("otp-phone"); + firstFactors.push("otp-email"); + firstFactors.push("link-phone"); + firstFactors.push("link-email"); + } let coreResp = await Multitenancy.createOrUpdateTenant(tenantId, { - emailPasswordEnabled: loginMethods.emailPassword?.enabled === true, - thirdPartyEnabled: loginMethods.thirdParty?.enabled === true, - passwordlessEnabled: loginMethods.passwordless?.enabled === true, + firstFactors, coreConfig, }); @@ -489,6 +504,11 @@ app.get("/test/featureFlags", (req, res) => { }); }); +app.post("/test/create-oauth2-client", async (req, res) => { + const { client } = await OAuth2Provider.createOAuth2Client(req.body); + res.send({ client }); +}); + app.use(errorHandler()); app.use(async (err, req, res, next) => { @@ -532,6 +552,7 @@ function initST() { UserMetadataRaw.reset(); MultiFactorAuthRaw.reset(); TOTPRaw.reset(); + OAuth2ProviderRaw.reset(); EmailVerificationRaw.reset(); EmailPasswordRaw.reset(); @@ -730,6 +751,7 @@ function initST() { }, }), ], + ["oauth2provider", OAuth2Provider.init()], ]; passwordlessConfig = { diff --git a/test/server/utils.js b/test/server/utils.js index 5e7bb8c8a..b568ff9ca 100644 --- a/test/server/utils.js +++ b/test/server/utils.js @@ -180,9 +180,7 @@ module.exports.startST = async function (config = {}) { }, body: JSON.stringify({ appId, - emailPasswordEnabled: true, - thirdPartyEnabled: true, - passwordlessEnabled: true, + firstFactors: ["emailpassword", "thirdparty", "passwordless"], coreConfig: config.coreConfig, }), }); From b63bd81a20b1b2265fdd6f804c7379b671745aa5 Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Mon, 19 Aug 2024 00:29:24 +0200 Subject: [PATCH 7/9] feat: add a route we can use to force refreshes --- .../for-tests/src/AppWithReactDomRouter.js | 7 +- examples/for-tests/src/OAuth2Page.js | 66 +- lib/build/arrowLeftIcon.js | 4 +- lib/build/authCompWrapper.js | 4 +- lib/build/authRecipe-shared.js | 6 +- lib/build/authRecipe-shared2.js | 20 +- lib/build/emailLargeIcon.js | 6 +- lib/build/emailpassword-shared.js | 4 +- lib/build/emailpassword-shared3.js | 135 +- lib/build/emailpassword-shared5.js | 94 +- lib/build/emailpassword.js | 53 +- lib/build/emailpasswordprebuiltui.js | 447 ++--- lib/build/emailverification-shared.js | 109 +- lib/build/emailverification-shared2.js | 41 +- lib/build/emailverification.js | 31 +- lib/build/emailverificationprebuiltui.js | 298 ++-- lib/build/genericComponentOverrideContext.js | 1449 +++++++++++++++- lib/build/index.js | 3 +- lib/build/index2.js | 453 ++--- lib/build/multifactorauth-shared.js | 155 +- lib/build/multifactorauth-shared2.js | 266 +-- lib/build/multifactorauth.js | 7 +- lib/build/multifactorauthprebuiltui.js | 127 +- lib/build/multitenancy.js | 9 +- lib/build/oauth2provider-shared.js | 94 +- lib/build/oauth2provider-shared2.js | 10 + lib/build/oauth2provider.js | 6 +- lib/build/oauth2providerprebuiltui.js | 261 +++ lib/build/passwordless-shared.js | 118 +- lib/build/passwordless.js | 81 +- lib/build/passwordlessprebuiltui.js | 991 ++++++----- .../componentOverrideContext.d.ts | 9 + .../features/tryRefreshPage/index.d.ts | 11 + .../components/themes/translations.d.ts | 3 + .../recipe/oauth2provider/constants.d.ts | 1 + .../oauth2provider/functionOverrides.d.ts | 6 + lib/build/recipe/oauth2provider/index.d.ts | 8 + .../recipe/oauth2provider/prebuiltui.d.ts | 42 + lib/build/recipe/oauth2provider/recipe.d.ts | 9 +- lib/build/recipe/oauth2provider/types.d.ts | 21 +- lib/build/recipeModule-shared.js | 35 +- lib/build/session.js | 91 +- lib/build/sessionprebuiltui.js | 59 +- lib/build/superTokens.js | 1450 ----------------- lib/build/thirdparty-shared.js | 279 ++-- lib/build/thirdparty.js | 35 +- lib/build/thirdpartyprebuiltui.js | 142 +- lib/build/totp-shared.js | 92 +- lib/build/totp.js | 23 +- lib/build/totpprebuiltui.js | 296 ++-- lib/build/translationContext.js | 12 +- lib/build/ui-entry.js | 3 +- .../componentOverrideContext.tsx | 7 + .../features/tryRefreshPage/index.tsx | 90 + .../components/themes/translations.ts | 3 + lib/ts/recipe/oauth2provider/constants.ts | 15 + .../oauth2provider/functionOverrides.ts | 19 + lib/ts/recipe/oauth2provider/index.ts | 4 + lib/ts/recipe/oauth2provider/prebuiltui.tsx | 108 ++ lib/ts/recipe/oauth2provider/recipe.ts | 20 +- lib/ts/recipe/oauth2provider/types.ts | 27 +- lib/ts/recipe/oauth2provider/utils.ts | 1 + package-lock.json | 16 +- recipe/oauth2provider/prebuiltui.d.ts | 17 + recipe/oauth2provider/prebuiltui.js | 20 + rollup.config.mjs | 1 + 66 files changed, 4764 insertions(+), 3566 deletions(-) create mode 100644 lib/build/oauth2provider-shared2.js create mode 100644 lib/build/oauth2providerprebuiltui.js create mode 100644 lib/build/recipe/oauth2provider/componentOverrideContext.d.ts create mode 100644 lib/build/recipe/oauth2provider/components/features/tryRefreshPage/index.d.ts create mode 100644 lib/build/recipe/oauth2provider/components/themes/translations.d.ts create mode 100644 lib/build/recipe/oauth2provider/constants.d.ts create mode 100644 lib/build/recipe/oauth2provider/functionOverrides.d.ts create mode 100644 lib/build/recipe/oauth2provider/prebuiltui.d.ts delete mode 100644 lib/build/superTokens.js create mode 100644 lib/ts/recipe/oauth2provider/componentOverrideContext.tsx create mode 100644 lib/ts/recipe/oauth2provider/components/features/tryRefreshPage/index.tsx create mode 100644 lib/ts/recipe/oauth2provider/components/themes/translations.ts create mode 100644 lib/ts/recipe/oauth2provider/constants.ts create mode 100644 lib/ts/recipe/oauth2provider/functionOverrides.ts create mode 100644 lib/ts/recipe/oauth2provider/prebuiltui.tsx create mode 100644 recipe/oauth2provider/prebuiltui.d.ts create mode 100644 recipe/oauth2provider/prebuiltui.js diff --git a/examples/for-tests/src/AppWithReactDomRouter.js b/examples/for-tests/src/AppWithReactDomRouter.js index f53ee0f30..9e1a664ec 100644 --- a/examples/for-tests/src/AppWithReactDomRouter.js +++ b/examples/for-tests/src/AppWithReactDomRouter.js @@ -7,6 +7,7 @@ import { EmailPasswordPreBuiltUI } from "supertokens-auth-react/recipe/emailpass import { PasswordlessPreBuiltUI } from "supertokens-auth-react/recipe/passwordless/prebuiltui"; import { EmailVerificationPreBuiltUI } from "supertokens-auth-react/recipe/emailverification/prebuiltui"; import { ThirdPartyPreBuiltUI, SignInAndUpCallback } from "supertokens-auth-react/recipe/thirdparty/prebuiltui"; +import { OAuth2ProviderPreBuiltUI } from "supertokens-auth-react/recipe/oauth2provider/prebuiltui"; import { AccessDeniedScreen } from "supertokens-auth-react/recipe/session/prebuiltui"; import { MultiFactorAuthPreBuiltUI } from "supertokens-auth-react/recipe/multifactorauth/prebuiltui"; import { TOTPPreBuiltUI } from "supertokens-auth-react/recipe/totp/prebuiltui"; @@ -31,7 +32,7 @@ function AppWithReactDomRouter(props) { const emailVerificationMode = window.localStorage.getItem("mode") || "OFF"; const websiteBasePath = window.localStorage.getItem("websiteBasePath") || undefined; - let recipePreBuiltUIList = [TOTPPreBuiltUI]; + let recipePreBuiltUIList = [TOTPPreBuiltUI, OAuth2ProviderPreBuiltUI]; if (enabledRecipes.some((r) => r.startsWith("thirdparty"))) { recipePreBuiltUIList.push(ThirdPartyPreBuiltUI); } @@ -174,8 +175,8 @@ function AppWithReactDomRouter(props) { /> )} - } /> - } /> + } /> + } /> diff --git a/examples/for-tests/src/OAuth2Page.js b/examples/for-tests/src/OAuth2Page.js index 76ab8b130..aa5b03839 100644 --- a/examples/for-tests/src/OAuth2Page.js +++ b/examples/for-tests/src/OAuth2Page.js @@ -4,12 +4,18 @@ import { getApiDomain, getWebsiteDomain } from "./config"; // NOTE: For convenience, the same page/component handles both login initiation and callback. // Separate pages for login and callback are not required. +const scopes = window.localStorage.getItem("oauth2-scopes") ?? "profile openid offline_access email"; +const extraConfig = JSON.parse(window.localStorage.getItem("oauth2-extra-config") ?? "{}"); +const extraSignInParams = JSON.parse(window.localStorage.getItem("oauth2-extra-sign-in-params") ?? "{}"); +const extraSignOutParams = JSON.parse(window.localStorage.getItem("oauth2-extra-sign-out-params") ?? "{}"); + const oidcConfig = { client_id: window.localStorage.getItem("oauth2-client-id"), authority: `${getApiDomain()}/auth`, response_type: "code", - redirect_uri: `${getWebsiteDomain()}/oauth2/callback`, - scope: "profile openid offline_access email", + redirect_uri: `${getWebsiteDomain()}/oauth/callback`, + scope: scopes ? scopes : "profile openid offline_access email", + ...extraConfig, onSigninCallback: async (user) => { // Clears the response code and other params from the callback url window.history.replaceState({}, document.title, window.location.pathname); @@ -17,27 +23,57 @@ const oidcConfig = { }; function AuthPage() { - const { signinRedirect, signoutSilent, user, error } = useAuth(); + const { signinRedirect, signinSilent, signoutSilent, user, error } = useAuth(); return (

OAuth2 Login Test

-
- {user ? ( -
+
+ {error &&

Error: {error.message}

} + {user && ( + <>
{JSON.stringify(user.profile, null, 2)}
- -
- ) : ( -
- {error &&

Error: {error.message}

} - -
+ )} + + + + +
); diff --git a/lib/build/arrowLeftIcon.js b/lib/build/arrowLeftIcon.js index 96e4ef41b..0c1efe594 100644 --- a/lib/build/arrowLeftIcon.js +++ b/lib/build/arrowLeftIcon.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var jsxRuntime = require("react/jsx-runtime"); /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. @@ -27,7 +27,7 @@ function ArrowLeftIcon(_a) { var color = _a.color; return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "11.272", diff --git a/lib/build/authCompWrapper.js b/lib/build/authCompWrapper.js index 7a112772e..ae3e8d5ec 100644 --- a/lib/build/authCompWrapper.js +++ b/lib/build/authCompWrapper.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var jsxRuntime = require("react/jsx-runtime"); var uiEntry = require("./index2.js"); @@ -9,7 +9,7 @@ function AuthComponentWrapper(_a) { recipeComponentOverrides = _a.recipeComponentOverrides; return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - superTokens.__assign({ value: recipeComponentOverrides }, { children: children }) + genericComponentOverrideContext.__assign({ value: recipeComponentOverrides }, { children: children }) ); } diff --git a/lib/build/authRecipe-shared.js b/lib/build/authRecipe-shared.js index a1f7e7efb..a49f45a02 100644 --- a/lib/build/authRecipe-shared.js +++ b/lib/build/authRecipe-shared.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. * @@ -17,7 +17,7 @@ var superTokens = require("./superTokens.js"); * under the License. */ function normaliseAuthRecipe(config) { - return superTokens.normaliseRecipeModuleConfig(config); + return genericComponentOverrideContext.normaliseRecipeModuleConfig(config); } function selectComponentsToCoverAllFirstFactors(comps, firstFactorIds) { if (firstFactorIds.length === 0) { @@ -45,7 +45,7 @@ function selectComponentsToCoverAllFirstFactors(comps, firstFactorIds) { if (componentsLeft.length !== 0) { var nextComps = selectComponentsToCoverAllFirstFactors(componentsLeft, factorIdsLeft); if (nextComps !== undefined) { - return { value: superTokens.__spreadArray([c], nextComps, true) }; + return { value: genericComponentOverrideContext.__spreadArray([c], nextComps, true) }; } } }; diff --git a/lib/build/authRecipe-shared2.js b/lib/build/authRecipe-shared2.js index 119ec2461..6ac9fc7cf 100644 --- a/lib/build/authRecipe-shared2.js +++ b/lib/build/authRecipe-shared2.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var index = require("./recipeModule-shared.js"); var types = require("./multifactorauth-shared.js"); @@ -19,26 +19,26 @@ var types = require("./multifactorauth-shared.js"); * under the License. */ var AuthRecipe = /** @class */ (function (_super) { - superTokens.__extends(AuthRecipe, _super); + genericComponentOverrideContext.__extends(AuthRecipe, _super); function AuthRecipe() { var _this = (_super !== null && _super.apply(this, arguments)) || this; // eslint-disable-next-line @typescript-eslint/no-unused-vars _this.getAuthRecipeDefaultRedirectionURL = function (_context) { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { throw new Error("Should never come here"); }); }); }; _this.signOut = function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, types.Session.getInstanceOrThrow().signOut({ - userContext: superTokens.getNormalisedUserContext( + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -50,14 +50,14 @@ var AuthRecipe = /** @class */ (function (_super) { }); }; _this.doesSessionExist = function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, types.Session.getInstanceOrThrow().doesSessionExist({ - userContext: superTokens.getNormalisedUserContext( + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), diff --git a/lib/build/emailLargeIcon.js b/lib/build/emailLargeIcon.js index 54c0b4b70..3985ac948 100644 --- a/lib/build/emailLargeIcon.js +++ b/lib/build/emailLargeIcon.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var jsxRuntime = require("react/jsx-runtime"); /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. @@ -26,12 +26,12 @@ var jsxRuntime = require("react/jsx-runtime"); function EmailLargeIcon() { return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "59.867", height: "40.34", viewBox: "0 0 59.867 40.34" }, { children: jsxRuntime.jsxs( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "email", transform: "translate(0 -83.5)" }, { children: [ diff --git a/lib/build/emailpassword-shared.js b/lib/build/emailpassword-shared.js index e0dae7dd3..2cf2045e7 100644 --- a/lib/build/emailpassword-shared.js +++ b/lib/build/emailpassword-shared.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var jsxRuntime = require("react/jsx-runtime"); require("./index2.js"); var translationContext = require("./translationContext.js"); @@ -20,7 +20,7 @@ function Button(_a) { } return jsxRuntime.jsxs( "button", - superTokens.__assign( + genericComponentOverrideContext.__assign( { type: type, disabled: disabled, onClick: onClick, "data-supertokens": "button" }, { children: [t(label), isLoading && "..."] } ) diff --git a/lib/build/emailpassword-shared3.js b/lib/build/emailpassword-shared3.js index 57b17541e..7382236e5 100644 --- a/lib/build/emailpassword-shared3.js +++ b/lib/build/emailpassword-shared3.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var EmailPasswordWebJS = require("supertokens-web-js/recipe/emailpassword"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); var index = require("./authRecipe-shared2.js"); @@ -17,19 +17,20 @@ var NormalisedURLPath__default = /*#__PURE__*/ _interopDefault(NormalisedURLPath var getFunctionOverrides = function (onHandleEvent) { return function (originalImp) { - return superTokens.__assign(superTokens.__assign({}, originalImp), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImp), { submitNewPassword: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, originalImp.submitNewPassword( - superTokens.__assign(superTokens.__assign({}, input), { - formFields: [input.formFields[0]], - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, input), + { formFields: [input.formFields[0]] } + ) ), ]; case 1: @@ -46,9 +47,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, sendPasswordResetEmail: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.sendPasswordResetEmail(input)]; @@ -70,9 +71,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, signUp: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var payloadBeforeCall, response, payloadAfterCall; - return superTokens.__generator(this, function (_c) { + return genericComponentOverrideContext.__generator(this, function (_c) { switch (_c.label) { case 0: _c.trys.push([0, 2, , 3]); @@ -132,9 +133,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, signIn: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var payloadBeforeCall, response, payloadAfterCall; - return superTokens.__generator(this, function (_c) { + return genericComponentOverrideContext.__generator(this, function (_c) { switch (_c.label) { case 0: _c.trys.push([0, 2, , 3]); @@ -215,9 +216,9 @@ var getFunctionOverrides = function (onHandleEvent) { * defaultEmailValidator. */ function defaultEmailValidator(value) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var defaultEmailValidatorRegexp; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { if (typeof value !== "string") { return [2 /*return*/, "ERROR_EMAIL_NON_STRING"]; } @@ -241,8 +242,8 @@ function defaultEmailValidator(value) { * Contains lowercase, uppercase, and numbers. */ function defaultPasswordValidator(value) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { if (typeof value !== "string") { return [2 /*return*/, "ERROR_PASSWORD_NON_STRING"]; } @@ -270,8 +271,8 @@ function defaultPasswordValidator(value) { * type string */ function defaultLoginPasswordValidator(value) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { if (typeof value !== "string") { return [2 /*return*/, "ERROR_PASSWORD_NON_STRING"]; } @@ -284,8 +285,8 @@ function defaultLoginPasswordValidator(value) { */ // eslint-disable-next-line @typescript-eslint/no-unused-vars function defaultValidate(_) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [2 /*return*/, undefined]; }); }); @@ -321,7 +322,7 @@ function normaliseEmailPasswordConfig(config) { signUpEmailField, config.resetPasswordUsingTokenFeature ); - var override = superTokens.__assign( + var override = genericComponentOverrideContext.__assign( { functions: function (originalImplementation) { return originalImplementation; @@ -329,11 +330,14 @@ function normaliseEmailPasswordConfig(config) { }, config.override ); - return superTokens.__assign(superTokens.__assign({}, utils.normaliseAuthRecipe(config)), { - signInAndUpFeature: signInAndUpFeature, - resetPasswordUsingTokenFeature: resetPasswordUsingTokenFeature, - override: override, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, utils.normaliseAuthRecipe(config)), + { + signInAndUpFeature: signInAndUpFeature, + resetPasswordUsingTokenFeature: resetPasswordUsingTokenFeature, + override: override, + } + ); } function normaliseSignInAndUpFeature(config) { if (config === undefined) { @@ -348,17 +352,17 @@ function normaliseSignInAndUpFeature(config) { */ var defaultSignInFields = signUpForm.formFields.reduce(function (signInFieldsAccumulator, field) { if (field.id === "email") { - return superTokens.__spreadArray( - superTokens.__spreadArray([], signInFieldsAccumulator, true), + return genericComponentOverrideContext.__spreadArray( + genericComponentOverrideContext.__spreadArray([], signInFieldsAccumulator, true), [field], false ); } if (field.id === "password") { - return superTokens.__spreadArray( - superTokens.__spreadArray([], signInFieldsAccumulator, true), + return genericComponentOverrideContext.__spreadArray( + genericComponentOverrideContext.__spreadArray([], signInFieldsAccumulator, true), [ - superTokens.__assign(superTokens.__assign({}, field), { + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, field), { autoComplete: "current-password", validate: defaultLoginPasswordValidator, }), @@ -403,7 +407,9 @@ function normaliseSignInFormFeatureConfig(defaultFormFields, config) { }) // Sign In fields are never optional. .map(function (field) { - return superTokens.__assign(superTokens.__assign({}, field), { optional: false }); + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, field), { + optional: false, + }); }); } var formFields = mergeFormFields(defaultFormFields, userFormFields); @@ -473,11 +479,10 @@ function normaliseResetPasswordUsingTokenFeature(signUpPasswordFieldValidate, si var enterEmailForm = { style: enterEmailFormStyle, formFields: [ - superTokens.__assign(superTokens.__assign({}, getDefaultEmailFormField()), { - validate: signUpEmailField.validate, - placeholder: "", - autofocus: true, - }), + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, getDefaultEmailFormField()), + { validate: signUpEmailField.validate, placeholder: "", autofocus: true } + ), ], }; return { @@ -512,8 +517,11 @@ function mergeFormFields(defaultFormFields, userFormFields) { optional = false; } // Merge. - mergedFormFields[j] = superTokens.__assign( - superTokens.__assign(superTokens.__assign({}, mergedFormFields[j]), userField), + mergedFormFields[j] = genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, mergedFormFields[j]), + userField + ), { optional: optional } ); isNewField = false; @@ -523,7 +531,7 @@ function mergeFormFields(defaultFormFields, userFormFields) { // If new field, push to mergeFormFields. if (isNewField) { mergedFormFields.push( - superTokens.__assign( + genericComponentOverrideContext.__assign( { optional: false, placeholder: userField.label, validate: defaultValidate }, userField ) @@ -540,10 +548,10 @@ function getFormattedFormField(field) { if (field.optional === false && field.nonOptionalErrorMsg === "") { throw new Error("nonOptionalErrorMsg for field ".concat(field.id, " cannot be an empty string")); } - return superTokens.__assign(superTokens.__assign({}, field), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, field), { validate: function (value) { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: // Absent or not optional empty field @@ -581,7 +589,7 @@ function getFormattedFormField(field) { * Class. */ var EmailPassword = /** @class */ (function (_super) { - superTokens.__extends(EmailPassword, _super); + genericComponentOverrideContext.__extends(EmailPassword, _super); function EmailPassword(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = EmailPasswordWebJS__default.default; @@ -591,9 +599,9 @@ var EmailPassword = /** @class */ (function (_super) { _this.recipeID = EmailPassword.RECIPE_ID; _this.firstFactorIds = [types.FactorIds.EMAILPASSWORD]; _this.getDefaultRedirectionURL = function (context) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var resetPasswordPath; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { if (context.action === "RESET_PASSWORD") { resetPasswordPath = new NormalisedURLPath__default.default( constants.DEFAULT_RESET_PASSWORD_PATH @@ -625,24 +633,27 @@ var EmailPassword = /** @class */ (function (_super) { recipeID: EmailPassword.RECIPE_ID, authReact: function (appInfo) { EmailPassword.instance = new EmailPassword( - superTokens.__assign(superTokens.__assign({}, normalisedConfig), { - appInfo: appInfo, - recipeId: EmailPassword.RECIPE_ID, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { appInfo: appInfo, recipeId: EmailPassword.RECIPE_ID } + ) ); return EmailPassword.instance; }, webJS: EmailPasswordWebJS__default.default.init( - superTokens.__assign(superTokens.__assign({}, normalisedConfig), { - override: { - functions: function (originalImpl, builder) { - var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); - builder.override(functions); - builder.override(normalisedConfig.override.functions); - return originalImpl; + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { + override: { + functions: function (originalImpl, builder) { + var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); + builder.override(functions); + builder.override(normalisedConfig.override.functions); + return originalImpl; + }, }, - }, - }) + } + ) ), }; }; @@ -653,7 +664,7 @@ var EmailPassword = /** @class */ (function (_super) { "See https://supertokens.io/docs/emailpassword/quick-setup/frontend"; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { - error = error + superTokens.SSR_ERROR; + error = error + genericComponentOverrideContext.SSR_ERROR; } throw Error(error); } @@ -663,7 +674,7 @@ var EmailPassword = /** @class */ (function (_super) { * Tests methods. */ EmailPassword.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } EmailPassword.instance = undefined; diff --git a/lib/build/emailpassword-shared5.js b/lib/build/emailpassword-shared5.js index 60d3b9840..aa56ddb98 100644 --- a/lib/build/emailpassword-shared5.js +++ b/lib/build/emailpassword-shared5.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var jsxRuntime = require("react/jsx-runtime"); var React = require("react"); var STGeneralError = require("supertokens-web-js/utils/error"); @@ -24,7 +24,7 @@ function FormRow(_a) { hasError = _a.hasError; return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": ["formRow", hasError ? "hasError" : ""].join(" ") }, { children: children } ) @@ -54,7 +54,7 @@ function FormRow(_a) { function CheckedIcon() { return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "14.862", @@ -96,7 +96,7 @@ function CheckedIcon() { function ErrorIcon() { return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "17", @@ -109,7 +109,7 @@ function ErrorIcon() { children: [ jsxRuntime.jsx( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { className: "Asdf", fill: "rgb(var(--palette-error))" }, { children: jsxRuntime.jsx("path", { @@ -121,7 +121,7 @@ function ErrorIcon() { ), jsxRuntime.jsx( "text", - superTokens.__assign( + genericComponentOverrideContext.__assign( { fill: "#fff", fontSize: "10px", @@ -131,7 +131,7 @@ function ErrorIcon() { { children: jsxRuntime.jsx( "tspan", - superTokens.__assign({ x: "0", y: "0" }, { children: "!" }) + genericComponentOverrideContext.__assign({ x: "0", y: "0" }, { children: "!" }) ), } ) @@ -169,7 +169,7 @@ function ShowPasswordIcon(_a) { return jsxRuntime.jsx("div", { children: jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "18.391", @@ -194,7 +194,7 @@ function ShowPasswordIcon(_a) { }), jsxRuntime.jsxs( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { fill: "rgb(var(--palette-textPrimary))", stroke: "rgb(var(--palette-inputBackground))", @@ -243,7 +243,7 @@ function ShowPasswordIcon(_a) { return jsxRuntime.jsx("div", { children: jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "18.281", @@ -268,7 +268,7 @@ function ShowPasswordIcon(_a) { }), jsxRuntime.jsxs( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { fill: "rgb(var(--palette-textPrimary))", stroke: "rgb(var(--palette-inputBackground))", @@ -343,12 +343,12 @@ var Input = function (_a) { } return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "inputContainer" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": ["inputWrapper", hasError ? "inputError" : ""].join(" ") }, { children: [ @@ -368,7 +368,7 @@ var Input = function (_a) { hasError === true && jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "inputAdornment inputAdornmentError" }, { children: jsxRuntime.jsx(ErrorIcon, {}) } ) @@ -377,7 +377,7 @@ var Input = function (_a) { hasError === false && jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "inputAdornment inputAdornmentSuccess" }, { children: jsxRuntime.jsx(CheckedIcon, {}) } ) @@ -386,7 +386,7 @@ var Input = function (_a) { value.length > 0 && jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { onClick: function () { return setShowPassword(showPassword === false); @@ -414,7 +414,7 @@ function InputError(_a) { var t = translationContext.useTranslation(); return jsxRuntime.jsx( "div", - superTokens.__assign({ "data-supertokens": "inputErrorMessage" }, { children: t(error) }) + genericComponentOverrideContext.__assign({ "data-supertokens": "inputErrorMessage" }, { children: t(error) }) ); } @@ -424,7 +424,7 @@ function Label(_a) { var t = translationContext.useTranslation(); return jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "label" }, { children: [t(value), showIsRequired && value && value.trim() !== "" && " *"] } ) @@ -547,8 +547,8 @@ var FormBase = function (props) { }); // If there is a formfield missing from the states array, we fill with the default value if (fieldsWithoutState.length > 0) { - fs = superTokens.__spreadArray( - superTokens.__spreadArray([], fs, true), + fs = genericComponentOverrideContext.__spreadArray( + genericComponentOverrideContext.__spreadArray([], fs, true), fieldsWithoutState.map(function (f) { return { id: f.id, value: fetchDefaultValue(f) }; }), @@ -584,8 +584,8 @@ var FormBase = function (props) { return f.id === id; }); if (field === undefined) { - return superTokens.__spreadArray( - superTokens.__spreadArray([], os, true), + return genericComponentOverrideContext.__spreadArray( + genericComponentOverrideContext.__spreadArray([], os, true), [update({ id: id, value: "" })], false ); @@ -602,16 +602,18 @@ var FormBase = function (props) { var onInputFocus = React.useCallback( function (field) { updateFieldState(field.id, function (os) { - return superTokens.__assign(superTokens.__assign({}, os), { validated: false }); + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, os), { + validated: false, + }); }); }, [updateFieldState] ); var onInputBlur = React.useCallback( function (field) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var fieldConfig, error, _a; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: if (!validateOnBlur) { @@ -631,10 +633,10 @@ var FormBase = function (props) { case 3: error = _a; updateFieldState(field.id, function (os) { - return superTokens.__assign(superTokens.__assign({}, os), { - error: error, - validated: error === undefined && field.value.length !== 0, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, os), + { error: error, validated: error === undefined && field.value.length !== 0 } + ); }); return [2 /*return*/]; } @@ -649,7 +651,10 @@ var FormBase = function (props) { throw new Error("".concat(field.id, " value must be a string")); } updateFieldState(field.id, function (os) { - return superTokens.__assign(superTokens.__assign({}, os), { value: field.value, error: undefined }); + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, os), { + value: field.value, + error: undefined, + }); }); props.clearError(); }, @@ -657,7 +662,7 @@ var FormBase = function (props) { ); var onFormSubmit = React.useCallback( function (e) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var apiFields, fieldUpdates, result, @@ -670,7 +675,7 @@ var FormBase = function (props) { field, errorFields_1, getErrorMessage_1; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: // Prevent default event propagation. @@ -679,7 +684,10 @@ var FormBase = function (props) { setIsLoading(true); setFieldStates(function (os) { return os.map(function (fs) { - return superTokens.__assign(superTokens.__assign({}, fs), { error: undefined }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, fs), + { error: undefined } + ); }); }); apiFields = formFields.map(function (field) { @@ -732,9 +740,10 @@ var FormBase = function (props) { if (update || field.clearOnSubmit === true) { // We can do these one by one, it's almost never more than one field updateFieldState(field.id, function (os) { - return superTokens.__assign(superTokens.__assign({}, os), { - value: update ? update.value : "", - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, os), + { value: update ? update.value : "" } + ); }); } }; @@ -793,9 +802,10 @@ var FormBase = function (props) { }; setFieldStates(function (os) { return os.map(function (fs) { - return superTokens.__assign(superTokens.__assign({}, fs), { - error: getErrorMessage_1(fs), - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, fs), + { error: getErrorMessage_1(fs) } + ); }); }); } @@ -818,12 +828,12 @@ var FormBase = function (props) { ); return jsxRuntime.jsx( FormStateContext.Provider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { value: fieldStates }, { children: jsxRuntime.jsxs( "form", - superTokens.__assign( + genericComponentOverrideContext.__assign( { autoComplete: "on", noValidate: true, @@ -853,7 +863,7 @@ var FormBase = function (props) { }; return jsxRuntime.jsx( FormRow, - superTokens.__assign( + genericComponentOverrideContext.__assign( { hasError: fstate.error !== undefined }, { children: jsxRuntime.jsxs(React.Fragment, { diff --git a/lib/build/emailpassword.js b/lib/build/emailpassword.js index a16aef3ed..d297074f3 100644 --- a/lib/build/emailpassword.js +++ b/lib/build/emailpassword.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var componentOverrideContext = require("./emailpassword-shared2.js"); var recipe = require("./emailpassword-shared3.js"); require("supertokens-web-js"); @@ -14,7 +14,6 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); -require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); require("supertokens-web-js/recipe/emailpassword"); require("./authRecipe-shared2.js"); @@ -46,12 +45,12 @@ var Wrapper = /** @class */ (function () { return recipe.EmailPassword.init(config); }; Wrapper.signOut = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailPassword.getInstanceOrThrow().signOut({ - userContext: superTokens.getNormalisedUserContext( + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -60,13 +59,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.submitNewPassword = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailPassword.getInstanceOrThrow().webJSRecipe.submitNewPassword( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext(input.userContext), + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), }) ), ]; @@ -74,13 +73,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.sendPasswordResetEmail = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailPassword.getInstanceOrThrow().webJSRecipe.sendPasswordResetEmail( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext(input.userContext), + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), }) ), ]; @@ -88,13 +87,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.signUp = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailPassword.getInstanceOrThrow().webJSRecipe.signUp( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext(input.userContext), + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), }) ), ]; @@ -102,13 +101,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.signIn = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailPassword.getInstanceOrThrow().webJSRecipe.signIn( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext(input.userContext), + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), }) ), ]; @@ -116,13 +115,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.doesEmailExist = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailPassword.getInstanceOrThrow().webJSRecipe.doesEmailExist( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext(input.userContext), + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), }) ), ]; @@ -131,8 +130,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.getResetPasswordTokenFromURL = function (input) { return recipe.EmailPassword.getInstanceOrThrow().webJSRecipe.getResetPasswordTokenFromURL( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) diff --git a/lib/build/emailpasswordprebuiltui.js b/lib/build/emailpasswordprebuiltui.js index 6dd2da964..50ad9e111 100644 --- a/lib/build/emailpasswordprebuiltui.js +++ b/lib/build/emailpasswordprebuiltui.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var jsxRuntime = require("react/jsx-runtime"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); var uiEntry = require("./index2.js"); @@ -30,7 +30,6 @@ require("supertokens-web-js/utils"); require("supertokens-web-js/utils/normalisedURLDomain"); require("react-dom"); require("./multitenancy-shared.js"); -require("./genericComponentOverrideContext.js"); require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); @@ -89,7 +88,7 @@ function BackToSignInButton(_a) { var t = translationContext.useTranslation(); return jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: onClick }, { children: [ @@ -126,25 +125,25 @@ var EmailPasswordResetPasswordEmail = function (props) { if (status === "SENT") { return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: [ jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "primaryText enterEmailSuccessMessage" }, { children: [ emailSuccessText, jsxRuntime.jsx( "span", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "link resendEmailLink", onClick: resend, @@ -168,18 +167,18 @@ var EmailPasswordResetPasswordEmail = function (props) { // Otherwise, return Form. return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container resetPasswordEmailForm" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: [ jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle withBackButton" }, { children: [ @@ -196,7 +195,7 @@ var EmailPasswordResetPasswordEmail = function (props) { ), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: t("EMAIL_PASSWORD_RESET_HEADER_SUBTITLE") } ) @@ -210,58 +209,65 @@ var EmailPasswordResetPasswordEmail = function (props) { buttonLabel: "EMAIL_PASSWORD_RESET_SEND_BTN", onSuccess: onSuccess, callAPI: function (formFields) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - var validationErrors, emailField, resp; - return superTokens.__generator(this, function (_a) { - switch (_a.label) { - case 0: - return [ - 4 /*yield*/, - superTokens.validateForm( - formFields, - props.config.resetPasswordUsingTokenFeature - .enterEmailForm.formFields - ), - ]; - case 1: - validationErrors = _a.sent(); - if (validationErrors.length > 0) { + return genericComponentOverrideContext.__awaiter( + void 0, + void 0, + void 0, + function () { + var validationErrors, emailField, resp; + return genericComponentOverrideContext.__generator(this, function (_a) { + switch (_a.label) { + case 0: return [ - 2 /*return*/, - { - status: "FIELD_ERROR", - formFields: validationErrors, - }, + 4 /*yield*/, + genericComponentOverrideContext.validateForm( + formFields, + props.config.resetPasswordUsingTokenFeature + .enterEmailForm.formFields + ), ]; - } - emailField = formFields.find(function (field) { - return field.id === "email"; - }); - if (emailField !== undefined) { - setEmailFieldValue(emailField.value); - } - return [ - 4 /*yield*/, - props.recipeImplementation.sendPasswordResetEmail({ - formFields: formFields, - userContext: userContext, - }), - ]; - case 2: - resp = _a.sent(); - if (resp.status === "PASSWORD_RESET_NOT_ALLOWED") { + case 1: + validationErrors = _a.sent(); + if (validationErrors.length > 0) { + return [ + 2 /*return*/, + { + status: "FIELD_ERROR", + formFields: validationErrors, + }, + ]; + } + emailField = formFields.find(function (field) { + return field.id === "email"; + }); + if (emailField !== undefined) { + setEmailFieldValue(emailField.value); + } return [ - 2 /*return*/, - { - status: "FIELD_ERROR", - formFields: [{ id: "email", error: resp.reason }], - }, + 4 /*yield*/, + props.recipeImplementation.sendPasswordResetEmail({ + formFields: formFields, + userContext: userContext, + }), ]; - } - return [2 /*return*/, resp]; - } - }); - }); + case 2: + resp = _a.sent(); + if (resp.status === "PASSWORD_RESET_NOT_ALLOWED") { + return [ + 2 /*return*/, + { + status: "FIELD_ERROR", + formFields: [ + { id: "email", error: resp.reason }, + ], + }, + ]; + } + return [2 /*return*/, resp]; + } + }); + } + ); }, showLabels: true, validateOnBlur: true, @@ -290,18 +296,18 @@ var EmailPasswordSubmitNewPassword = function (props) { if (status === "SUCCESS") { return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: [ jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle" }, { children: t("EMAIL_PASSWORD_RESET_SUBMIT_PW_SUCCESS_HEADER_TITLE") } ) @@ -313,7 +319,7 @@ var EmailPasswordSubmitNewPassword = function (props) { children: [ jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "primaryText submitNewPasswordSuccessMessage", @@ -347,25 +353,25 @@ var EmailPasswordSubmitNewPassword = function (props) { } return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container resetPasswordPasswordForm" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: [ jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle" }, { children: t("EMAIL_PASSWORD_RESET_SUBMIT_PW_HEADER_TITLE") } ) ), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: t("EMAIL_PASSWORD_RESET_SUBMIT_PW_HEADER_SUBTITLE") } ) @@ -380,70 +386,77 @@ var EmailPasswordSubmitNewPassword = function (props) { onSuccess: onSuccess, validateOnBlur: true, callAPI: function (fields) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - var validationErrors, response; - return superTokens.__generator(this, function (_a) { - switch (_a.label) { - case 0: - return [ - 4 /*yield*/, - superTokens.validateForm( - fields, - props.config.resetPasswordUsingTokenFeature - .submitNewPasswordForm.formFields - ), - ]; - case 1: - validationErrors = _a.sent(); - if (validationErrors.length > 0) { + return genericComponentOverrideContext.__awaiter( + void 0, + void 0, + void 0, + function () { + var validationErrors, response; + return genericComponentOverrideContext.__generator(this, function (_a) { + switch (_a.label) { + case 0: return [ - 2 /*return*/, - { - status: "FIELD_ERROR", - formFields: validationErrors, - }, + 4 /*yield*/, + genericComponentOverrideContext.validateForm( + fields, + props.config.resetPasswordUsingTokenFeature + .submitNewPasswordForm.formFields + ), + ]; + case 1: + validationErrors = _a.sent(); + if (validationErrors.length > 0) { + return [ + 2 /*return*/, + { + status: "FIELD_ERROR", + formFields: validationErrors, + }, + ]; + } + // Verify that both passwords match. + if (fields[0].value !== fields[1].value) { + return [ + 2 /*return*/, + { + status: "FIELD_ERROR", + formFields: [ + { + id: fields[1].id, + error: "ERROR_CONFIRM_PASSWORD_NO_MATCH", + }, + ], + }, + ]; + } + return [ + 4 /*yield*/, + props.recipeImplementation.submitNewPassword({ + formFields: fields, + userContext: userContext, + }), ]; - } - // Verify that both passwords match. - if (fields[0].value !== fields[1].value) { + case 2: + response = _a.sent(); + if ( + response.status === "RESET_PASSWORD_INVALID_TOKEN_ERROR" + ) { + throw new STGeneralError__default.default( + "EMAIL_PASSWORD_RESET_PASSWORD_INVALID_TOKEN_ERROR" + ); + } return [ 2 /*return*/, - { - status: "FIELD_ERROR", - formFields: [ - { - id: fields[1].id, - error: "ERROR_CONFIRM_PASSWORD_NO_MATCH", - }, - ], - }, + response.status === "FIELD_ERROR" + ? response + : { + status: "OK", + }, ]; - } - return [ - 4 /*yield*/, - props.recipeImplementation.submitNewPassword({ - formFields: fields, - userContext: userContext, - }), - ]; - case 2: - response = _a.sent(); - if (response.status === "RESET_PASSWORD_INVALID_TOKEN_ERROR") { - throw new STGeneralError__default.default( - "EMAIL_PASSWORD_RESET_PASSWORD_INVALID_TOKEN_ERROR" - ); - } - return [ - 2 /*return*/, - response.status === "FIELD_ERROR" - ? response - : { - status: "OK", - }, - ]; - } - }); - }); + } + }); + } + ); }, showLabels: true, }), @@ -466,30 +479,38 @@ function ResetPasswordUsingTokenTheme(props) { */ // If no token, return SubmitNewPassword. if (props.submitNewPasswordForm !== undefined) { - return jsxRuntime.jsx(SubmitNewPassword, superTokens.__assign({}, props.submitNewPasswordForm)); + return jsxRuntime.jsx( + SubmitNewPassword, + genericComponentOverrideContext.__assign({}, props.submitNewPasswordForm) + ); } // Otherwise, return EnterEmail. - return jsxRuntime.jsx(ResetPasswordEmail, superTokens.__assign({}, props.enterEmailForm)); + return jsxRuntime.jsx(ResetPasswordEmail, genericComponentOverrideContext.__assign({}, props.enterEmailForm)); } function ResetPasswordUsingTokenThemeWrapper(props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var userStyles = props.submitNewPasswordForm ? props.config.resetPasswordUsingTokenFeature.submitNewPasswordForm.style : props.config.resetPasswordUsingTokenFeature.enterEmailForm.style; return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( translations.ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, userStyles], }, - { children: jsxRuntime.jsx(ResetPasswordUsingTokenTheme, superTokens.__assign({}, props)) } + { + children: jsxRuntime.jsx( + ResetPasswordUsingTokenTheme, + genericComponentOverrideContext.__assign({}, props) + ), + } ) ), } @@ -498,9 +519,9 @@ function ResetPasswordUsingTokenThemeWrapper(props) { } var defaultTranslationsEmailPassword = { - en: superTokens.__assign( - superTokens.__assign( - superTokens.__assign({}, uiEntry.defaultTranslationsCommon.en), + en: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, uiEntry.defaultTranslationsCommon.en), translations.defaultTranslationsEmailVerification.en ), { @@ -572,7 +593,7 @@ var defaultTranslationsEmailPassword = { }; var ResetPasswordUsingToken$1 = function (props) { - var token = superTokens.getQueryParams("token"); + var token = genericComponentOverrideContext.getQueryParams("token"); var userContext = uiEntry.useUserContext(); if (props.userContext !== undefined) { userContext = props.userContext; @@ -598,7 +619,7 @@ var ResetPasswordUsingToken$1 = function (props) { recipeImplementation: props.recipe.webJSRecipe, config: props.recipe.config, onSignInClicked: function () { - void superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ + void genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ show: "signin", navigate: props.navigate, redirectBack: false, @@ -609,7 +630,7 @@ var ResetPasswordUsingToken$1 = function (props) { }; var enterEmailForm = { onBackButtonClicked: function () { - return superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ + return genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ show: "signin", navigate: props.navigate, redirectBack: false, @@ -636,14 +657,14 @@ var ResetPasswordUsingToken$1 = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { - useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, + useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, defaultStore: defaultTranslationsEmailPassword, }, { @@ -652,7 +673,7 @@ var ResetPasswordUsingToken$1 = function (props) { props.children === undefined && jsxRuntime.jsx( ResetPasswordUsingTokenThemeWrapper, - superTokens.__assign({}, childProps) + genericComponentOverrideContext.__assign({}, childProps) ), props.children && React__namespace.Children.map(props.children, function (child) { @@ -682,14 +703,14 @@ var SignInForm = uiEntry.withOverride("EmailPasswordSignInForm", function EmailP buttonLabel: "EMAIL_PASSWORD_SIGN_IN_SUBMIT_BTN", onSuccess: props.onSuccess, callAPI: function (formFields) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var validationErrors, response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, - superTokens.validateForm( + genericComponentOverrideContext.validateForm( formFields, props.config.signInAndUpFeature.signInForm.formFields ), @@ -734,22 +755,22 @@ var SignInForm = uiEntry.withOverride("EmailPasswordSignInForm", function EmailP }); }); function SignInTheme(props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeStyle = props.config.signInAndUpFeature.signInForm.style; return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( translations.ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, activeStyle], }, - { children: jsxRuntime.jsx(SignInForm, superTokens.__assign({}, props)) } + { children: jsxRuntime.jsx(SignInForm, genericComponentOverrideContext.__assign({}, props)) } ) ), } @@ -766,13 +787,13 @@ function useChildProps$1(recipe$2, onAuthSuccess, error, onError, clearError, us }, [recipe$2] ); - var rethrowInRender = superTokens.useRethrowInRender(); + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); var t = translationContext.useTranslation(); var onSignInSuccess = React.useCallback( function () { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var payloadAfterCall; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, , 3]); @@ -820,10 +841,10 @@ function useChildProps$1(recipe$2, onAuthSuccess, error, onError, clearError, us var formFields = signInFeature.formFields.map(function (f) { return f.id !== "password" ? f - : superTokens.__assign(superTokens.__assign({}, f), { + : genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, f), { labelComponent: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ @@ -833,7 +854,7 @@ function useChildProps$1(recipe$2, onAuthSuccess, error, onError, clearError, us }), jsxRuntime.jsx( "a", - superTokens.__assign( + genericComponentOverrideContext.__assign( { onClick: onForgotPasswordClick, "data-supertokens": @@ -857,9 +878,9 @@ function useChildProps$1(recipe$2, onAuthSuccess, error, onError, clearError, us clearError: clearError, onError: onError, onFetchError: function (err) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var invalidClaims, evInstance; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -933,17 +954,20 @@ var SignInFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { recipeComponentOverrides: recipeComponentOverrides }, { children: jsxRuntime.jsxs(React.Fragment, { children: [ props.children === undefined && - jsxRuntime.jsx(SignInTheme, superTokens.__assign({}, childProps)), + jsxRuntime.jsx(SignInTheme, genericComponentOverrideContext.__assign({}, childProps)), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { - return React__namespace.cloneElement(child, superTokens.__assign({}, childProps)); + return React__namespace.cloneElement( + child, + genericComponentOverrideContext.__assign({}, childProps) + ); } return child; }), @@ -954,19 +978,20 @@ var SignInFeature = function (props) { ); }; var getModifiedRecipeImplementation$1 = function (origImpl) { - return superTokens.__assign(superTokens.__assign({}, origImpl), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, origImpl), { signIn: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, origImpl.signIn( - superTokens.__assign(superTokens.__assign({}, input), { - tryLinkingWithSessionUser: false, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, input), + { tryLinkingWithSessionUser: false } + ) ), ]; case 1: @@ -977,17 +1002,18 @@ var getModifiedRecipeImplementation$1 = function (origImpl) { }); }, signUp: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, origImpl.signUp( - superTokens.__assign(superTokens.__assign({}, input), { - tryLinkingWithSessionUser: false, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, input), + { tryLinkingWithSessionUser: false } + ) ), ]; case 1: @@ -1011,14 +1037,14 @@ var SignUpForm = uiEntry.withOverride("EmailPasswordSignUpForm", function EmailP buttonLabel: "EMAIL_PASSWORD_SIGN_UP_SUBMIT_BTN", onSuccess: props.onSuccess, callAPI: function (formFields) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var validationErrors, res; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, - superTokens.validateForm( + genericComponentOverrideContext.validateForm( formFields, props.config.signInAndUpFeature.signUpForm.formFields ), @@ -1058,22 +1084,22 @@ var SignUpForm = uiEntry.withOverride("EmailPasswordSignUpForm", function EmailP }); }); function SignUpTheme(props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeStyle = props.config.signInAndUpFeature.signUpForm.style; return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( translations.ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, activeStyle], }, - { children: jsxRuntime.jsx(SignUpForm, superTokens.__assign({}, props)) } + { children: jsxRuntime.jsx(SignUpForm, genericComponentOverrideContext.__assign({}, props)) } ) ), } @@ -1090,12 +1116,12 @@ function useChildProps(recipe, onAuthSuccess, error, onError, clearError, userCo }, [recipe] ); - var rethrowInRender = superTokens.useRethrowInRender(); + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); var onSignUpSuccess = React.useCallback( function (result) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var payloadAfterCall; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, , 3]); @@ -1143,9 +1169,9 @@ function useChildProps(recipe, onAuthSuccess, error, onError, clearError, userCo styleFromInit: signUpFeature.style, formFields: getThemeSignUpFeatureFormFields(signUpFeature.formFields, recipe, userContext), onFetchError: function (err) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var invalidClaims, evInstance; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -1225,17 +1251,20 @@ var SignUpFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { recipeComponentOverrides: recipeComponentOverrides }, { children: jsxRuntime.jsxs(React.Fragment, { children: [ props.children === undefined && - jsxRuntime.jsx(SignUpTheme, superTokens.__assign({}, childProps)), + jsxRuntime.jsx(SignUpTheme, genericComponentOverrideContext.__assign({}, childProps)), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { - return React__namespace.cloneElement(child, superTokens.__assign({}, childProps)); + return React__namespace.cloneElement( + child, + genericComponentOverrideContext.__assign({}, childProps) + ); } return child; }), @@ -1246,19 +1275,20 @@ var SignUpFeature = function (props) { ); }; var getModifiedRecipeImplementation = function (origImpl) { - return superTokens.__assign(superTokens.__assign({}, origImpl), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, origImpl), { signIn: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, origImpl.signIn( - superTokens.__assign(superTokens.__assign({}, input), { - tryLinkingWithSessionUser: false, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, input), + { tryLinkingWithSessionUser: false } + ) ), ]; case 1: @@ -1269,17 +1299,18 @@ var getModifiedRecipeImplementation = function (origImpl) { }); }, signUp: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, origImpl.signUp( - superTokens.__assign(superTokens.__assign({}, input), { - tryLinkingWithSessionUser: false, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, input), + { tryLinkingWithSessionUser: false } + ) ), ]; case 1: @@ -1295,7 +1326,7 @@ function getThemeSignUpFeatureFormFields(formFields, recipe, userContext) { var _this = this; var emailPasswordOnly = formFields.length === 2; return formFields.map(function (field) { - return superTokens.__assign(superTokens.__assign({}, field), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, field), { showIsRequired: (function () { // If email and password only, do not show required indicator (*). if (emailPasswordOnly) { @@ -1311,9 +1342,9 @@ function getThemeSignUpFeatureFormFields(formFields, recipe, userContext) { } // Otherwise, if email, use syntax validate method and check if email exists. return function (value) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var error, emailExists, err_1; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, field.validate(value)]; @@ -1359,7 +1390,7 @@ function getThemeSignUpFeatureFormFields(formFields, recipe, userContext) { } var EmailPasswordPreBuiltUI = /** @class */ (function (_super) { - superTokens.__extends(EmailPasswordPreBuiltUI, _super); + genericComponentOverrideContext.__extends(EmailPasswordPreBuiltUI, _super); function EmailPasswordPreBuiltUI(recipeInstance) { var _this = _super.call(this) || this; _this.recipeInstance = recipeInstance; @@ -1375,7 +1406,9 @@ var EmailPasswordPreBuiltUI = /** @class */ (function (_super) { new NormalisedURLPath__default.default(constants.DEFAULT_RESET_PASSWORD_PATH) ); features[normalisedFullPath.getAsStringDangerous()] = { - matches: superTokens.matchRecipeIdUsingQueryParams(_this.recipeInstance.config.recipeId), + matches: genericComponentOverrideContext.matchRecipeIdUsingQueryParams( + _this.recipeInstance.config.recipeId + ), component: function (props) { return _this.getFeatureComponent("resetpassword", props, useComponentOverrides); }, @@ -1391,12 +1424,12 @@ var EmailPasswordPreBuiltUI = /** @class */ (function (_super) { if (componentName === "resetpassword") { return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ResetPasswordUsingToken$1, - superTokens.__assign({ recipe: _this.recipeInstance }, props, { + genericComponentOverrideContext.__assign({ recipe: _this.recipeInstance }, props, { useComponentOverrides: useComponentOverrides, }) ), @@ -1444,7 +1477,7 @@ var EmailPasswordPreBuiltUI = /** @class */ (function (_super) { component: function (props) { return jsxRuntime.jsx( SignUpFeature, - superTokens.__assign( + genericComponentOverrideContext.__assign( { recipe: _this.recipeInstance, useComponentOverrides: componentOverrideContext.useContext, @@ -1462,7 +1495,7 @@ var EmailPasswordPreBuiltUI = /** @class */ (function (_super) { component: function (props) { return jsxRuntime.jsx( SignInFeature, - superTokens.__assign( + genericComponentOverrideContext.__assign( { recipe: _this.recipeInstance, useComponentOverrides: componentOverrideContext.useContext, @@ -1477,7 +1510,7 @@ var EmailPasswordPreBuiltUI = /** @class */ (function (_super) { }; // For tests EmailPasswordPreBuiltUI.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } EmailPasswordPreBuiltUI.instance = undefined; diff --git a/lib/build/emailverification-shared.js b/lib/build/emailverification-shared.js index e63d777b0..e75d4a068 100644 --- a/lib/build/emailverification-shared.js +++ b/lib/build/emailverification-shared.js @@ -1,7 +1,6 @@ "use strict"; var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); -var superTokens = require("./superTokens.js"); var EmailVerificationWebJS = require("supertokens-web-js/recipe/emailverification"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); var postSuperTokensInitCallbacks = require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); @@ -36,10 +35,10 @@ var _a = genericComponentOverrideContext.createGenericComponentsOverrideContext( var DEFAULT_VERIFY_EMAIL_PATH = "/verify-email"; var EmailVerificationClaimClass = /** @class */ (function (_super) { - superTokens.__extends(EmailVerificationClaimClass, _super); + genericComponentOverrideContext.__extends(EmailVerificationClaimClass, _super); function EmailVerificationClaimClass(getRecipeImpl, onFailureRedirection) { var _this = _super.call(this, getRecipeImpl) || this; - var validatorsWithCallbacks = superTokens.__assign({}, _this.validators); + var validatorsWithCallbacks = genericComponentOverrideContext.__assign({}, _this.validators); var _loop_1 = function (key) { var validator = validatorsWithCallbacks[key]; validatorsWithCallbacks[key] = function () { @@ -47,19 +46,22 @@ var EmailVerificationClaimClass = /** @class */ (function (_super) { for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return superTokens.__assign(superTokens.__assign({}, validator.apply(void 0, args)), { - onFailureRedirection: function (args) { - if (onFailureRedirection !== undefined) { - return onFailureRedirection(args); - } - var recipe = EmailVerification.getInstanceOrThrow(); - if (recipe.config.mode === "REQUIRED") { - return recipe.getRedirectUrl({ action: "VERIFY_EMAIL" }, args.userContext); - } - return undefined; - }, - showAccessDeniedOnFailure: false, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, validator.apply(void 0, args)), + { + onFailureRedirection: function (args) { + if (onFailureRedirection !== undefined) { + return onFailureRedirection(args); + } + var recipe = EmailVerification.getInstanceOrThrow(); + if (recipe.config.mode === "REQUIRED") { + return recipe.getRedirectUrl({ action: "VERIFY_EMAIL" }, args.userContext); + } + return undefined; + }, + showAccessDeniedOnFailure: false, + } + ); }; }; for (var key in validatorsWithCallbacks) { @@ -73,11 +75,11 @@ var EmailVerificationClaimClass = /** @class */ (function (_super) { var getFunctionOverrides = function (onHandleEvent) { return function (originalImp) { - return superTokens.__assign(superTokens.__assign({}, originalImp), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImp), { verifyEmail: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.verifyEmail(input)]; @@ -95,9 +97,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, sendVerificationEmail: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.sendVerificationEmail(input)]; @@ -152,7 +154,7 @@ function normaliseEmailVerificationFeature(config) { var verifyEmailLinkClickedScreen = { style: verifyEmailLinkClickedScreenStyle, }; - var override = superTokens.__assign( + var override = genericComponentOverrideContext.__assign( { functions: function (originalImplementation) { return originalImplementation; @@ -160,13 +162,19 @@ function normaliseEmailVerificationFeature(config) { }, config.override ); - return superTokens.__assign(superTokens.__assign({}, superTokens.normaliseRecipeModuleConfig(config)), { - disableDefaultUI: disableDefaultUI, - mode: mode, - sendVerifyEmailScreen: sendVerifyEmailScreen, - verifyEmailLinkClickedScreen: verifyEmailLinkClickedScreen, - override: override, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign( + {}, + genericComponentOverrideContext.normaliseRecipeModuleConfig(config) + ), + { + disableDefaultUI: disableDefaultUI, + mode: mode, + sendVerifyEmailScreen: sendVerifyEmailScreen, + verifyEmailLinkClickedScreen: verifyEmailLinkClickedScreen, + override: override, + } + ); } /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. @@ -184,7 +192,7 @@ function normaliseEmailVerificationFeature(config) { * under the License. */ var EmailVerification = /** @class */ (function (_super) { - superTokens.__extends(EmailVerification, _super); + genericComponentOverrideContext.__extends(EmailVerification, _super); function EmailVerification(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = EmailVerificationWebJS__default.default; @@ -193,9 +201,9 @@ var EmailVerification = /** @class */ (function (_super) { _this.webJSRecipe = webJSRecipe; _this.recipeID = EmailVerification.RECIPE_ID; _this.getDefaultRedirectionURL = function (context) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var verifyEmailPath; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { if (context.action === "VERIFY_EMAIL") { verifyEmailPath = new NormalisedURLPath__default.default(DEFAULT_VERIFY_EMAIL_PATH); return [ @@ -227,24 +235,27 @@ var EmailVerification = /** @class */ (function (_super) { recipeID: EmailVerification.RECIPE_ID, authReact: function (appInfo) { EmailVerification.instance = new EmailVerification( - superTokens.__assign(superTokens.__assign({}, normalisedConfig), { - appInfo: appInfo, - recipeId: EmailVerification.RECIPE_ID, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { appInfo: appInfo, recipeId: EmailVerification.RECIPE_ID } + ) ); return EmailVerification.instance; }, webJS: EmailVerificationWebJS__default.default.init( - superTokens.__assign(superTokens.__assign({}, normalisedConfig), { - override: { - functions: function (originalImpl, builder) { - var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); - builder.override(functions); - builder.override(normalisedConfig.override.functions); - return originalImpl; + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { + override: { + functions: function (originalImpl, builder) { + var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); + builder.override(functions); + builder.override(normalisedConfig.override.functions); + return originalImpl; + }, }, - }, - }) + } + ) ), }; }; @@ -253,15 +264,15 @@ var EmailVerification = /** @class */ (function (_super) { var error = "No instance of EmailVerification found. Make sure to call the EmailVerification.init method."; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { - error = error + superTokens.SSR_ERROR; + error = error + genericComponentOverrideContext.SSR_ERROR; } throw Error(error); } return EmailVerification.instance; }; EmailVerification.prototype.isEmailVerified = function (userContext) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -277,7 +288,7 @@ var EmailVerification = /** @class */ (function (_super) { }); }; EmailVerification.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } EmailVerification.instance = undefined; diff --git a/lib/build/emailverification-shared2.js b/lib/build/emailverification-shared2.js index 054d62c03..3ab790cf0 100644 --- a/lib/build/emailverification-shared2.js +++ b/lib/build/emailverification-shared2.js @@ -2,7 +2,7 @@ var jsxRuntime = require("react/jsx-runtime"); var React = require("react"); -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var uiEntry = require("./index2.js"); var styles = @@ -27,24 +27,27 @@ var ThemeBase = function (_a) { }; var defaultTranslationsEmailVerification = { - en: superTokens.__assign(superTokens.__assign({}, uiEntry.defaultTranslationsCommon.en), { - EMAIL_VERIFICATION_RESEND_SUCCESS: "Email resent", - EMAIL_VERIFICATION_SEND_TITLE: "Verify your email address", - EMAIL_VERIFICATION_SEND_DESC_START: "", - EMAIL_VERIFICATION_SEND_DESC_STRONG: "Please click on the link", - EMAIL_VERIFICATION_SEND_DESC_END: " in the email we just sent you to confirm your email address.", - EMAIL_VERIFICATION_RESEND_BTN: "Resend Email", - EMAIL_VERIFICATION_LOGOUT: "Logout ", - EMAIL_VERIFICATION_SUCCESS: "Email verification successful!", - EMAIL_VERIFICATION_CONTINUE_BTN: "CONTINUE", - EMAIL_VERIFICATION_CONTINUE_LINK: "Continue", - EMAIL_VERIFICATION_EXPIRED: "The email verification link has expired", - EMAIL_VERIFICATION_ERROR_TITLE: "Something went wrong", - EMAIL_VERIFICATION_ERROR_DESC: "We encountered an unexpected error. Please contact support for assistance", - EMAIL_VERIFICATION_LINK_CLICKED_HEADER: "Verify your email address", - EMAIL_VERIFICATION_LINK_CLICKED_DESC: "Please click on the button below to verify your email address", - EMAIL_VERIFICATION_LINK_CLICKED_CONTINUE_BUTTON: "CONTINUE", - }), + en: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, uiEntry.defaultTranslationsCommon.en), + { + EMAIL_VERIFICATION_RESEND_SUCCESS: "Email resent", + EMAIL_VERIFICATION_SEND_TITLE: "Verify your email address", + EMAIL_VERIFICATION_SEND_DESC_START: "", + EMAIL_VERIFICATION_SEND_DESC_STRONG: "Please click on the link", + EMAIL_VERIFICATION_SEND_DESC_END: " in the email we just sent you to confirm your email address.", + EMAIL_VERIFICATION_RESEND_BTN: "Resend Email", + EMAIL_VERIFICATION_LOGOUT: "Logout ", + EMAIL_VERIFICATION_SUCCESS: "Email verification successful!", + EMAIL_VERIFICATION_CONTINUE_BTN: "CONTINUE", + EMAIL_VERIFICATION_CONTINUE_LINK: "Continue", + EMAIL_VERIFICATION_EXPIRED: "The email verification link has expired", + EMAIL_VERIFICATION_ERROR_TITLE: "Something went wrong", + EMAIL_VERIFICATION_ERROR_DESC: "We encountered an unexpected error. Please contact support for assistance", + EMAIL_VERIFICATION_LINK_CLICKED_HEADER: "Verify your email address", + EMAIL_VERIFICATION_LINK_CLICKED_DESC: "Please click on the button below to verify your email address", + EMAIL_VERIFICATION_LINK_CLICKED_CONTINUE_BUTTON: "CONTINUE", + } + ), }; exports.ThemeBase = ThemeBase; diff --git a/lib/build/emailverification.js b/lib/build/emailverification.js index 4c72c2735..57f8143f7 100644 --- a/lib/build/emailverification.js +++ b/lib/build/emailverification.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var recipe = require("./emailverification-shared.js"); require("supertokens-web-js"); require("supertokens-web-js/utils/cookieHandler"); @@ -13,7 +13,6 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); -require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); require("supertokens-web-js/recipe/emailverification"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); @@ -39,13 +38,13 @@ var Wrapper = /** @class */ (function () { return recipe.EmailVerification.init(config); }; Wrapper.isEmailVerified = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailVerification.getInstanceOrThrow().webJSRecipe.isEmailVerified( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -55,13 +54,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.verifyEmail = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailVerification.getInstanceOrThrow().webJSRecipe.verifyEmail( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -71,13 +70,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.sendVerificationEmail = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.EmailVerification.getInstanceOrThrow().webJSRecipe.sendVerificationEmail( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -88,8 +87,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.getEmailVerificationTokenFromURL = function (input) { return recipe.EmailVerification.getInstanceOrThrow().webJSRecipe.getEmailVerificationTokenFromURL( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) diff --git a/lib/build/emailverificationprebuiltui.js b/lib/build/emailverificationprebuiltui.js index 1262bec05..90aaa3ac0 100644 --- a/lib/build/emailverificationprebuiltui.js +++ b/lib/build/emailverificationprebuiltui.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var jsxRuntime = require("react/jsx-runtime"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); var uiEntry = require("./index2.js"); @@ -22,7 +22,6 @@ require("supertokens-web-js/utils"); require("supertokens-web-js/utils/normalisedURLDomain"); require("react-dom"); require("./multitenancy-shared.js"); -require("./genericComponentOverrideContext.js"); require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); @@ -93,7 +92,7 @@ function ArrowRightIcon(_a) { var color = _a.color; return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "11.272", @@ -124,9 +123,9 @@ var EmailVerificationSendVerifyEmail = function (props) { errorMessage = _b[0], setErrorMessage = _b[1]; var resendEmail = function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var response, e_1; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 5, , 6]); @@ -164,9 +163,9 @@ var EmailVerificationSendVerifyEmail = function (props) { }); }; var logout = function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var e_2; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); @@ -197,8 +196,8 @@ var EmailVerificationSendVerifyEmail = function (props) { ); var checkSendResponse = React.useCallback( function (response) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: if (!(response.status === "EMAIL_ALREADY_VERIFIED_ERROR")) return [3 /*break*/, 2]; @@ -215,8 +214,8 @@ var EmailVerificationSendVerifyEmail = function (props) { [props.config, props.recipeImplementation, props.onEmailAlreadyVerified] ); var handleSendError = React.useCallback(function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -235,15 +234,15 @@ var EmailVerificationSendVerifyEmail = function (props) { }); }); }, []); - superTokens.useOnMountAPICall(sendVerificationEmail, checkSendResponse, handleSendError); + genericComponentOverrideContext.useOnMountAPICall(sendVerificationEmail, checkSendResponse, handleSendError); return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: [ @@ -254,28 +253,28 @@ var EmailVerificationSendVerifyEmail = function (props) { status === "EMAIL_RESENT" && jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "generalSuccess" }, { children: t("EMAIL_VERIFICATION_RESEND_SUCCESS") } ) ), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "sendVerifyEmailIcon" }, { children: jsxRuntime.jsx(emailLargeIcon.EmailLargeIcon, {}) } ) ), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle headerTinyTitle" }, { children: t("EMAIL_VERIFICATION_SEND_TITLE") } ) ), jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "primaryText sendVerifyEmailText" }, { children: [ @@ -291,14 +290,14 @@ var EmailVerificationSendVerifyEmail = function (props) { status !== "EMAIL_RESENT" && jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "link sendVerifyEmailResend", onClick: resendEmail }, { children: t("EMAIL_VERIFICATION_RESEND_BTN") } ) ), jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "secondaryText secondaryLinkWithArrow", onClick: logout }, { children: [ @@ -343,7 +342,7 @@ var SendVerifyEmail = uiEntry.withOverride("EmailVerificationSendVerifyEmail", E function CheckedRoundIcon() { return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "33", @@ -354,7 +353,7 @@ function CheckedRoundIcon() { { children: jsxRuntime.jsxs( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { fill: "rgb(var(--palette-success))", stroke: "rgb(var(--palette-success))" }, { children: [ @@ -399,7 +398,7 @@ function CheckedRoundIcon() { function ErrorLargeIcon() { return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "33", @@ -412,7 +411,7 @@ function ErrorLargeIcon() { children: [ jsxRuntime.jsx( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { fill: "rgb(var(--palette-error))" }, { children: jsxRuntime.jsx("path", { @@ -424,7 +423,7 @@ function ErrorLargeIcon() { ), jsxRuntime.jsx( "text", - superTokens.__assign( + genericComponentOverrideContext.__assign( { fill: "#fff", "font-family": "Rubik-Bold, Rubik", @@ -435,7 +434,7 @@ function ErrorLargeIcon() { { children: jsxRuntime.jsx( "tspan", - superTokens.__assign({ x: "0", y: "0" }, { children: "!" }) + genericComponentOverrideContext.__assign({ x: "0", y: "0" }, { children: "!" }) ), } ) @@ -462,8 +461,8 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { setVerifyLoading = _c[1]; var verifyEmailOnMount = React.useCallback( function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { if (sessionContext.loading === true) { // This callback should only be called if the session is already loaded throw new Error("Should never come here"); @@ -487,8 +486,8 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { ); var handleVerifyResp = React.useCallback( function (response) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { if (response === "INTERACTION_REQUIRED") { setStatus("INTERACTION_REQUIRED"); } else if (response.status === "EMAIL_VERIFICATION_INVALID_TOKEN_ERROR") { @@ -511,23 +510,28 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { }, [setStatus, setErrorMessage] ); - superTokens.useOnMountAPICall(verifyEmailOnMount, handleVerifyResp, handleError, sessionContext.loading === false); + genericComponentOverrideContext.useOnMountAPICall( + verifyEmailOnMount, + handleVerifyResp, + handleError, + sessionContext.loading === false + ); var onTokenInvalidRedirect = props.onTokenInvalidRedirect, onSuccess = props.onSuccess; if (status === "LOADING") { return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "spinner" }, { children: jsxRuntime.jsx(uiEntry.SpinnerIcon, {}) } ) @@ -542,25 +546,25 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { if (status === "INTERACTION_REQUIRED") { return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row noFormRow" }, { children: [ jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle" }, { children: t("EMAIL_VERIFICATION_LINK_CLICKED_HEADER") } ) ), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: t("EMAIL_VERIFICATION_LINK_CLICKED_DESC") } ) @@ -568,36 +572,44 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { jsxRuntime.jsx(button.Button, { isLoading: verifyLoading, onClick: function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - var resp, err_1; - return superTokens.__generator(this, function (_a) { - switch (_a.label) { - case 0: - setVerifyLoading(true); - _a.label = 1; - case 1: - _a.trys.push([1, 4, , 5]); - return [ - 4 /*yield*/, - props.recipeImplementation.verifyEmail({ - userContext: userContext, - }), - ]; - case 2: - resp = _a.sent(); - return [4 /*yield*/, handleVerifyResp(resp)]; - case 3: - _a.sent(); - return [3 /*break*/, 5]; - case 4: - err_1 = _a.sent(); - void handleError(err_1); - return [3 /*break*/, 5]; - case 5: - return [2 /*return*/]; - } - }); - }); + return genericComponentOverrideContext.__awaiter( + void 0, + void 0, + void 0, + function () { + var resp, err_1; + return genericComponentOverrideContext.__generator( + this, + function (_a) { + switch (_a.label) { + case 0: + setVerifyLoading(true); + _a.label = 1; + case 1: + _a.trys.push([1, 4, , 5]); + return [ + 4 /*yield*/, + props.recipeImplementation.verifyEmail({ + userContext: userContext, + }), + ]; + case 2: + resp = _a.sent(); + return [4 /*yield*/, handleVerifyResp(resp)]; + case 3: + _a.sent(); + return [3 /*break*/, 5]; + case 4: + err_1 = _a.sent(); + void handleError(err_1); + return [3 /*break*/, 5]; + case 5: + return [2 /*return*/]; + } + } + ); + } + ); }, type: "button", label: "EMAIL_VERIFICATION_LINK_CLICKED_CONTINUE_BUTTON", @@ -613,26 +625,26 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { if (status === "SUCCESSFUL") { return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row noFormRow" }, { children: [ jsxRuntime.jsx(CheckedRoundIcon, {}), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle headerTinyTitle" }, { children: t("EMAIL_VERIFICATION_SUCCESS") } ) ), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "emailVerificationButtonWrapper" }, { children: jsxRuntime.jsx(button.Button, { @@ -655,25 +667,25 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { if (status === "INVALID") { return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row noFormRow" }, { children: [ jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle headerTinyTitle" }, { children: t("EMAIL_VERIFICATION_EXPIRED") } ) ), jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { onClick: onTokenInvalidRedirect, "data-supertokens": "secondaryText secondaryLinkWithArrow", @@ -698,18 +710,18 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { } return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row noFormRow" }, { children: [ jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle error" }, { children: [ @@ -721,7 +733,7 @@ var EmailVerificationVerifyEmailLinkClicked = function (props) { ), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "primaryText" }, { children: t( @@ -749,26 +761,32 @@ function EmailVerificationTheme(props) { var sessionContext = session.useSessionContext(); // If we have a token, return VerifyEmailLinkClicked. if (props.verifyEmailLinkClickedScreen !== undefined) { - return jsxRuntime.jsx(VerifyEmailLinkClicked, superTokens.__assign({}, props.verifyEmailLinkClickedScreen)); + return jsxRuntime.jsx( + VerifyEmailLinkClicked, + genericComponentOverrideContext.__assign({}, props.verifyEmailLinkClickedScreen) + ); } // If we have an active session, we want to send the verification email if (sessionContext.loading === false && sessionContext.doesSessionExist === true) { - return jsxRuntime.jsx(SendVerifyEmail, superTokens.__assign({}, props.sendVerifyEmailScreen)); + return jsxRuntime.jsx( + SendVerifyEmail, + genericComponentOverrideContext.__assign({}, props.sendVerifyEmailScreen) + ); } // Otherwise, return an empty screen, waiting for the feature component to redirection to complete. return jsxRuntime.jsx(jsxRuntime.Fragment, {}); } function EmailVerificationThemeWrapper(props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( translations.ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [ @@ -779,7 +797,12 @@ function EmailVerificationThemeWrapper(props) { : props.config.verifyEmailLinkClickedScreen.style, ], }, - { children: jsxRuntime.jsx(EmailVerificationTheme, superTokens.__assign({}, props)) } + { + children: jsxRuntime.jsx( + EmailVerificationTheme, + genericComponentOverrideContext.__assign({}, props) + ), + } ) ), } @@ -793,7 +816,7 @@ var EmailVerification$1 = function (props) { var _b = React.useState("LOADING"), status = _b[0], setStatus = _b[1]; - var rethrowInRender = superTokens.useRethrowInRender(); + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); var recipeComponentOverrides = props.useComponentOverrides(); var userContext = uiEntry.useUserContext(); if (props.userContext !== undefined) { @@ -801,8 +824,8 @@ var EmailVerification$1 = function (props) { } var redirectToAuthWithHistory = React.useCallback( function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -820,30 +843,33 @@ var EmailVerification$1 = function (props) { ); var modifiedRecipeImplementation = React.useMemo( function () { - return superTokens.__assign(superTokens.__assign({}, props.recipe.webJSRecipe), { - sendVerificationEmail: function (input) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - var response; - return superTokens.__generator(this, function (_a) { - switch (_a.label) { - case 0: - return [4 /*yield*/, props.recipe.webJSRecipe.sendVerificationEmail(input)]; - case 1: - response = _a.sent(); - superTokens.clearQueryParams(["token"]); - return [2 /*return*/, response]; - } + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, props.recipe.webJSRecipe), + { + sendVerificationEmail: function (input) { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + var response; + return genericComponentOverrideContext.__generator(this, function (_a) { + switch (_a.label) { + case 0: + return [4 /*yield*/, props.recipe.webJSRecipe.sendVerificationEmail(input)]; + case 1: + response = _a.sent(); + genericComponentOverrideContext.clearQueryParams(["token"]); + return [2 /*return*/, response]; + } + }); }); - }); - }, - }); + }, + } + ); }, [props.recipe] ); var onSuccess = React.useCallback( function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, types.Session.getInstanceOrThrow() @@ -863,10 +889,10 @@ var EmailVerification$1 = function (props) { ); var fetchIsEmailVerified = React.useCallback( function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var token; var _a; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: if (sessionContext.loading === true) { @@ -874,7 +900,9 @@ var EmailVerification$1 = function (props) { throw new Error("Should never come here"); } token = - (_a = superTokens.getQueryParams("token")) !== null && _a !== void 0 ? _a : undefined; + (_a = genericComponentOverrideContext.getQueryParams("token")) !== null && _a !== void 0 + ? _a + : undefined; if (!(token === undefined)) return [3 /*break*/, 4]; if (!!sessionContext.doesSessionExist) return [3 /*break*/, 2]; return [4 /*yield*/, redirectToAuthWithHistory()]; @@ -899,8 +927,8 @@ var EmailVerification$1 = function (props) { ); var checkIsEmailVerified = React.useCallback( function (isVerified) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { if (isVerified) { return [2 /*return*/, onSuccess()]; } @@ -913,8 +941,8 @@ var EmailVerification$1 = function (props) { ); var handleError = React.useCallback( function (err) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -937,7 +965,7 @@ var EmailVerification$1 = function (props) { }, [redirectToAuthWithHistory] ); - superTokens.useOnMountAPICall( + genericComponentOverrideContext.useOnMountAPICall( fetchIsEmailVerified, checkIsEmailVerified, handleError, @@ -945,9 +973,9 @@ var EmailVerification$1 = function (props) { ); var signOut = React.useCallback( function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var session; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: session = types.Session.getInstanceOrThrow(); @@ -974,7 +1002,8 @@ var EmailVerification$1 = function (props) { redirectToAuth: redirectToAuthWithHistory, }; var verifyEmailLinkClickedScreenFeature = props.recipe.config.verifyEmailLinkClickedScreen; - var token = (_a = superTokens.getQueryParams("token")) !== null && _a !== void 0 ? _a : undefined; + var token = + (_a = genericComponentOverrideContext.getQueryParams("token")) !== null && _a !== void 0 ? _a : undefined; var verifyEmailLinkClickedScreen = token === undefined ? undefined @@ -994,14 +1023,14 @@ var EmailVerification$1 = function (props) { }; return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { - useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, + useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, defaultStore: translations.defaultTranslationsEmailVerification, }, { @@ -1010,7 +1039,7 @@ var EmailVerification$1 = function (props) { props.children === undefined && jsxRuntime.jsx( EmailVerificationThemeWrapper, - superTokens.__assign({}, childProps) + genericComponentOverrideContext.__assign({}, childProps) ), props.children && React__namespace.Children.map(props.children, function (child) { @@ -1030,7 +1059,7 @@ var EmailVerification$1 = function (props) { }; var EmailVerificationPreBuiltUI = /** @class */ (function (_super) { - superTokens.__extends(EmailVerificationPreBuiltUI, _super); + genericComponentOverrideContext.__extends(EmailVerificationPreBuiltUI, _super); function EmailVerificationPreBuiltUI(recipeInstance) { var _this = _super.call(this) || this; _this.recipeInstance = recipeInstance; @@ -1046,7 +1075,9 @@ var EmailVerificationPreBuiltUI = /** @class */ (function (_super) { new NormalisedURLPath__default.default(recipe.DEFAULT_VERIFY_EMAIL_PATH) ); features[normalisedFullPath.getAsStringDangerous()] = { - matches: superTokens.matchRecipeIdUsingQueryParams(_this.recipeInstance.config.recipeId), + matches: genericComponentOverrideContext.matchRecipeIdUsingQueryParams( + _this.recipeInstance.config.recipeId + ), component: function (props) { return _this.getFeatureComponent("emailverification", props, useComponentOverrides); }, @@ -1066,12 +1097,12 @@ var EmailVerificationPreBuiltUI = /** @class */ (function (_super) { } return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( session.SessionAuth, - superTokens.__assign( + genericComponentOverrideContext.__assign( { requireAuth: false, overrideGlobalClaimValidators: function () { @@ -1083,15 +1114,18 @@ var EmailVerificationPreBuiltUI = /** @class */ (function (_super) { children: function (value) { return jsxRuntime.jsx( EmailVerification$1, - superTokens.__assign( + genericComponentOverrideContext.__assign( { recipe: _this.recipeInstance, useComponentOverrides: useComponentOverrides, }, - superTokens.__assign(superTokens.__assign({}, props), { - // We do this to make sure it does not add another provider - userContext: value, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, props), + { + // We do this to make sure it does not add another provider + userContext: value, + } + ) ) ); }, @@ -1134,7 +1168,7 @@ var EmailVerificationPreBuiltUI = /** @class */ (function (_super) { }; // For tests EmailVerificationPreBuiltUI.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } EmailVerificationPreBuiltUI.instance = undefined; diff --git a/lib/build/genericComponentOverrideContext.js b/lib/build/genericComponentOverrideContext.js index 4d5d3f5d7..8cb5d736f 100644 --- a/lib/build/genericComponentOverrideContext.js +++ b/lib/build/genericComponentOverrideContext.js @@ -1,14 +1,1421 @@ "use strict"; -var superTokens = require("./superTokens.js"); -var jsxRuntime = require("react/jsx-runtime"); +var SuperTokensWebJS = require("supertokens-web-js"); +var cookieHandler = require("supertokens-web-js/utils/cookieHandler"); +var postSuperTokensInitCallbacks = require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); +var windowHandler = require("supertokens-web-js/utils/windowHandler"); +var MultitenancyWebJS = require("supertokens-web-js/recipe/multitenancy"); +var utils = require("supertokens-web-js/utils"); var React = require("react"); +var NormalisedURLDomain = require("supertokens-web-js/utils/normalisedURLDomain"); +var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); +var jsxRuntime = require("react/jsx-runtime"); function _interopDefault(e) { return e && e.__esModule ? e : { default: e }; } +var SuperTokensWebJS__default = /*#__PURE__*/ _interopDefault(SuperTokensWebJS); +var MultitenancyWebJS__default = /*#__PURE__*/ _interopDefault(MultitenancyWebJS); var React__default = /*#__PURE__*/ _interopDefault(React); +var NormalisedURLDomain__default = /*#__PURE__*/ _interopDefault(NormalisedURLDomain); +var NormalisedURLPath__default = /*#__PURE__*/ _interopDefault(NormalisedURLPath); + +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise, SuppressedError, Symbol */ + +var extendStatics = function (d, b) { + extendStatics = + Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && + function (d, b) { + d.__proto__ = b; + }) || + function (d, b) { + for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; + }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); +} + +exports.__assign = function () { + exports.__assign = + Object.assign || + function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return exports.__assign.apply(this, arguments); +}; + +function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; + } + return t; +} + +function __awaiter(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function (resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +function __generator(thisArg, body) { + var _ = { + label: 0, + sent: function () { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === "function" && + (g[Symbol.iterator] = function () { + return this; + }), + g + ); + function verb(n) { + return function (v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while ((g && ((g = 0), op[0] && (_ = 0)), _)) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y["return"] + : op[0] + ? y["throw"] || ((t = y["return"]) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if (!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && (op[0] === 6 || op[0] === 2)) { + _ = 0; + continue; + } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) + for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +} + +typeof SuppressedError === "function" + ? SuppressedError + : function (error, suppressed, message) { + var e = new Error(message); + return (e.name = "SuppressedError"), (e.error = error), (e.suppressed = suppressed), e; + }; + +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +/* + * Consts. + */ +var RECIPE_ID_QUERY_PARAM = "rid"; +var DEFAULT_API_BASE_PATH = "/auth"; +var DEFAULT_WEBSITE_BASE_PATH = "/auth"; +var ST_ROOT_ID = "supertokens-root"; +var SSR_ERROR = + "\nIf you are trying to use this method doing server-side-rendering, please make sure you move this method inside a componentDidMount method or useEffect hook."; + +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +var package_version = "0.42.2"; + +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +var SUPERTOKENS_DEBUG_NAMESPACE = "com.supertokens.auth-react"; +var __debugLogsEnabled = false; +function enableLogging() { + __debugLogsEnabled = true; +} +function logDebugMessage(message) { + if (__debugLogsEnabled) { + // eslint-disable-next-line no-console + console.log( + "" + .concat(SUPERTOKENS_DEBUG_NAMESPACE, ' {t: "') + .concat(new Date().toISOString(), '", message: "') + .concat(message, '", supertokens-auth-react-ver: "') + .concat(package_version, '"}') + ); + } +} + +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +/* + * getRecipeIdFromPath + * Input: + * Output: The "rid" query param if present, null otherwise. + */ +function getRecipeIdFromSearch(search) { + var urlParams = new URLSearchParams(search); + return urlParams.get(RECIPE_ID_QUERY_PARAM); +} +function clearQueryParams(paramNames) { + var newURL = new URL(windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHref()); + for (var _i = 0, paramNames_1 = paramNames; _i < paramNames_1.length; _i++) { + var param = paramNames_1[_i]; + newURL.searchParams.delete(param); + } + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.replaceState( + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.getState(), + "", + newURL.toString() + ); +} +function updateQueryParam(name, value) { + var newURL = new URL(windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHref()); + newURL.searchParams.set(name, value); + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.replaceState( + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.getState(), + "", + newURL.toString() + ); +} +function clearErrorQueryParam() { + clearQueryParams(["error", "message"]); +} +function getQueryParams(param) { + var urlParams = new URLSearchParams( + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getSearch() + ); + return urlParams.get(param); +} +function getURLHash() { + // By default it is returined with the "#" at the beginning, we cut that off here. + return windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHash().substr(1); +} +function getRedirectToPathFromURL() { + var redirectToPath = getQueryParams("redirectToPath"); + if (redirectToPath === null) { + return undefined; + } else { + try { + var url = void 0; + try { + url = new URL(redirectToPath); + } catch (error) { + var fakeDomain = redirectToPath.startsWith("/") ? "http://localhost" : "http://localhost/"; + url = new URL("".concat(fakeDomain).concat(redirectToPath)); + } + // Prevent Open redirects by normalising path. + var normalisedURLPath = new NormalisedURLPath__default.default(redirectToPath).getAsStringDangerous(); + var pathQueryParams = url.search || ""; // url.search contains the leading ? + var pathHash = url.hash || ""; // url.hash contains the leading # + var pathWithQueryParamsAndHash = normalisedURLPath + pathQueryParams + pathHash; + // Ensure a leading "/" if `normalisedUrlPath` is empty but `pathWithQueryParamsAndHash` is not to ensure proper redirection. + // Example: "?test=1" will not redirect the user to `/?test=1` if we don't add a leading "/". + if ( + normalisedURLPath.length === 0 && + pathWithQueryParamsAndHash.length > 0 && + !pathWithQueryParamsAndHash.startsWith("/") + ) { + return "/" + pathWithQueryParamsAndHash; + } + return pathWithQueryParamsAndHash; + } catch (_a) { + return undefined; + } + } +} +/* + * isTest + */ +function isTest() { + try { + return process.env.TEST_MODE === "testing" || process.env.REACT_APP_TEST_MODE === "testing"; + } catch (err) { + // can get Uncaught ReferenceError: process is not defined error + return false; + } +} +function normaliseInputAppInfoOrThrowError(appInfo) { + if (appInfo === undefined) { + throw new Error("Please provide the appInfo object when calling supertokens.init"); + } + if (appInfo.apiDomain === undefined) { + throw new Error("Please provide your apiDomain inside the appInfo object when calling supertokens.init"); + } + if (appInfo.appName === undefined) { + throw new Error("Please provide your appName inside the appInfo object when calling supertokens.init"); + } + if (appInfo.websiteDomain === undefined) { + throw new Error("Please provide your websiteDomain inside the appInfo object when calling supertokens.init"); + } + var apiGatewayPath = new NormalisedURLPath__default.default(""); + if (appInfo.apiGatewayPath !== undefined) { + apiGatewayPath = new NormalisedURLPath__default.default(appInfo.apiGatewayPath); + } + return { + appName: appInfo.appName, + apiDomain: new NormalisedURLDomain__default.default(appInfo.apiDomain), + websiteDomain: new NormalisedURLDomain__default.default(appInfo.websiteDomain), + apiBasePath: apiGatewayPath.appendPath( + getNormalisedURLPathOrDefault(DEFAULT_API_BASE_PATH, appInfo.apiBasePath) + ), + websiteBasePath: getNormalisedURLPathOrDefault(DEFAULT_WEBSITE_BASE_PATH, appInfo.websiteBasePath), + }; +} +function getNormalisedURLPathOrDefault(defaultPath, path) { + if (path !== undefined) { + return new NormalisedURLPath__default.default(path); + } else { + return new NormalisedURLPath__default.default(defaultPath); + } +} +/* + * validateForm + */ +// We check that the number of fields in input and config form field is the same. +// We check that each item in the config form field is also present in the input form field +function validateForm(inputs, configFormFields) { + return __awaiter(this, void 0, void 0, function () { + var validationErrors, _loop_1, i; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + validationErrors = []; + if (configFormFields.length !== inputs.length) { + throw Error("Are you sending too many / too few formFields?"); + } + _loop_1 = function (i) { + var field, input, value, error; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + field = configFormFields[i]; + input = inputs.find(function (i) { + return i.id === field.id; + }); + value = input.value; + if (input.id === "email") { + value = value.trim(); + } + return [4 /*yield*/, field.validate(value)]; + case 1: + error = _b.sent(); + // If error, add it. + if (error !== undefined) { + validationErrors.push({ + error: error, + id: field.id, + }); + } + return [2 /*return*/]; + } + }); + }; + i = 0; + _a.label = 1; + case 1: + if (!(i < configFormFields.length)) return [3 /*break*/, 4]; + return [5 /*yield**/, _loop_1(i)]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + i++; + return [3 /*break*/, 1]; + case 4: + return [2 /*return*/, validationErrors]; + } + }); + }); +} +/* + * getCurrentNormalisedUrlPath + */ +function getCurrentNormalisedUrlPath() { + return new NormalisedURLPath__default.default( + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getPathName() + ); +} +function getCurrentNormalisedUrlPathWithQueryParamsAndFragments() { + var normalisedUrlPath = getCurrentNormalisedUrlPath().getAsStringDangerous(); + return ( + normalisedUrlPath + + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getSearch() + + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHash() + ); +} +function appendQueryParamsToURL(stringUrl, queryParams) { + if (queryParams === undefined) { + return stringUrl; + } + try { + var url_1 = new URL(stringUrl); + Object.entries(queryParams).forEach(function (_a) { + var key = _a[0], + value = _a[1]; + url_1.searchParams.set(key, value); + }); + return url_1.href; + } catch (e) { + var fakeDomain = stringUrl.startsWith("/") ? "http://localhost" : "http://localhost/"; + var url_2 = new URL("".concat(fakeDomain).concat(stringUrl)); + Object.entries(queryParams).forEach(function (_a) { + var key = _a[0], + value = _a[1]; + url_2.searchParams.set(key, value); + }); + return "".concat(url_2.pathname).concat(url_2.search).concat(url_2.hash); + } +} +function appendTrailingSlashToURL(stringUrl) { + return stringUrl.endsWith("/") ? stringUrl : stringUrl + "/"; +} +/* + * Default method for matching recipe route based on query params. + */ +function matchRecipeIdUsingQueryParams(recipeId) { + return function () { + var recipeIdFromSearch = getRecipeIdFromSearch( + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getSearch() + ); + return recipeIdFromSearch === recipeId; + }; +} +function redirectWithFullPageReload(to) { + if (to.trim() === "") { + to = "/"; + } + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.setHref(to); +} +function redirectWithNavigate(to, navigate) { + if (to.trim() === "") { + to = "/"; + } + if ("push" in navigate) { + // we are using react-router-dom that is before v6 + navigate.push(to); + } else { + // in react-router-dom v6, it is just navigate(to) + navigate(to); + } +} +function getOriginOfPage() { + return new NormalisedURLDomain__default.default( + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getOrigin() + ); +} +function getLocalStorage(key) { + return __awaiter(this, void 0, void 0, function () { + var res; + return __generator(this, function (_a) { + res = windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.localStorage.getItem(key); + if (res === null || res === undefined) { + return [2 /*return*/, null]; + } + return [2 /*return*/, res]; + }); + }); +} +function setLocalStorage(key, value) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + return [ + 4 /*yield*/, + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.localStorage.setItem( + key, + value + ), + ]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); +} +function removeFromLocalStorage(key) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + return [ + 4 /*yield*/, + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.localStorage.removeItem( + key + ), + ]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); +} +function mergeObjects(obj1, obj2) { + var res = exports.__assign({}, obj1); + for (var key in obj2) { + if (typeof res[key] === "object" && typeof obj2[key] === "object") { + res[key] = mergeObjects(res[key], obj2[key]); + } else { + res[key] = obj2[key]; + } + } + return res; +} +function normaliseCookieScopeOrThrowError(cookieScope) { + function helper(cookieScope) { + cookieScope = cookieScope.trim().toLowerCase(); + // first we convert it to a URL so that we can use the URL class + if (cookieScope.startsWith(".")) { + cookieScope = cookieScope.substr(1); + } + if (!cookieScope.startsWith("http://") && !cookieScope.startsWith("https://")) { + cookieScope = "http://" + cookieScope; + } + try { + var urlObj = new URL(cookieScope); + cookieScope = urlObj.hostname; + // remove leading dot + if (cookieScope.startsWith(".")) { + cookieScope = cookieScope.substr(1); + } + return cookieScope; + } catch (err) { + throw new Error("Please provide a valid cookie scope"); + } + } + function isAnIpAddress(ipaddress) { + return /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test( + ipaddress + ); + } + var noDotNormalised = helper(cookieScope); + if (noDotNormalised === "localhost" || isAnIpAddress(noDotNormalised)) { + return noDotNormalised; + } + if (cookieScope.startsWith(".")) { + return "." + noDotNormalised; + } + return noDotNormalised; +} +function getDefaultCookieScope() { + try { + return normaliseCookieScopeOrThrowError( + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHostName() + ); + } catch (_a) { + return undefined; + } +} +function getCookieValue(name) { + return __awaiter(this, void 0, void 0, function () { + var value, _a, parts, last, temp; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _a = "; "; + return [ + 4 /*yield*/, + cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.getCookie(), + ]; + case 1: + value = _a + _b.sent(); + parts = value.split("; " + name + "="); + if (parts.length >= 2) { + last = parts.pop(); + if (last !== undefined) { + temp = last.split(";").shift(); + if (temp === undefined) { + return [2 /*return*/, null]; + } + return [2 /*return*/, temp]; + } + } + return [2 /*return*/, null]; + } + }); + }); +} +// undefined value will remove the cookie +function setFrontendCookie(name, value, scope) { + return __awaiter(this, void 0, void 0, function () { + var expires, cookieVal; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + expires = "Thu, 01 Jan 1970 00:00:01 GMT"; + cookieVal = ""; + if (value !== undefined) { + cookieVal = value; + expires = undefined; // set cookie without expiry + } + if ( + !( + scope === "localhost" || + scope === + windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHostName() || + scope === undefined + ) + ) + return [3 /*break*/, 5]; + if (!(expires !== undefined)) return [3 /*break*/, 2]; + return [ + 4 /*yield*/, + cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( + "".concat(name, "=").concat(cookieVal, ";expires=").concat(expires, ";path=/;samesite=lax") + ), + ]; + case 1: + _a.sent(); + return [3 /*break*/, 4]; + case 2: + return [ + 4 /*yield*/, + cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( + "" + .concat(name, "=") + .concat(cookieVal, ";expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/;samesite=lax") + ), + ]; + case 3: + _a.sent(); + _a.label = 4; + case 4: + return [3 /*break*/, 9]; + case 5: + if (!(expires !== undefined)) return [3 /*break*/, 7]; + return [ + 4 /*yield*/, + cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( + "" + .concat(name, "=") + .concat(cookieVal, ";expires=") + .concat(expires, ";domain=") + .concat(scope, ";path=/;samesite=lax") + ), + ]; + case 6: + _a.sent(); + return [3 /*break*/, 9]; + case 7: + return [ + 4 /*yield*/, + cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( + "" + .concat(name, "=") + .concat(cookieVal, ";domain=") + .concat(scope, ";expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/;samesite=lax") + ), + ]; + case 8: + _a.sent(); + _a.label = 9; + case 9: + return [2 /*return*/]; + } + }); + }); +} +function getNormalisedUserContext(userContext) { + return userContext === undefined ? {} : userContext; +} +/** + * This function handles calling APIs that should only be called once during mount (mostly on mount of a route/feature component). + * It's split into multiple callbacks (fetch + handleResponse/handleError) because we expect fetch to take longer and + * and the component may be unmounted during the first fetch, in which case we want to avoid updating state/redirecting. + * This is especially relevant for development in strict mode with React 18 (and in the future for concurrent rendering). + * + * @param fetch This is a callback that is only called once on mount. Mostly it's for consuming tokens/doing one time only API calls + * @param handleResponse This is called with the result of the first (fetch) call if it succeeds. + * @param handleError This is called with the error of the first (fetch) call if it rejects. + * @param startLoading Will start the whole process if this is set to true (or omitted). Mostly used to wait for session loading. + */ +var useOnMountAPICall = function (fetch, handleResponse, handleError, startLoading) { + if (startLoading === void 0) { + startLoading = true; + } + var consumeReq = React.useRef(); + var _a = React.useState(undefined), + error = _a[0], + setError = _a[1]; + React.useEffect( + function () { + var effect = function (signal) { + return __awaiter(void 0, void 0, void 0, function () { + var resp, err_1, err_2; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + _a.trys.push([0, 2, , 9]); + if (consumeReq.current === undefined) { + consumeReq.current = fetch(); + } + return [4 /*yield*/, consumeReq.current]; + case 1: + resp = _a.sent(); + if (!signal.aborted) { + void handleResponse(resp); + } + return [3 /*break*/, 9]; + case 2: + err_1 = _a.sent(); + if (!!signal.aborted) return [3 /*break*/, 8]; + if (!(handleError !== undefined)) return [3 /*break*/, 7]; + _a.label = 3; + case 3: + _a.trys.push([3, 5, , 6]); + return [4 /*yield*/, handleError(err_1, resp)]; + case 4: + _a.sent(); + return [3 /*break*/, 6]; + case 5: + err_2 = _a.sent(); + setError(err_2); + return [3 /*break*/, 6]; + case 6: + return [3 /*break*/, 8]; + case 7: + setError(err_1); + _a.label = 8; + case 8: + return [3 /*break*/, 9]; + case 9: + return [2 /*return*/]; + } + }); + }); + }; + if (startLoading) { + var ctrl_1 = new AbortController(); + void effect(ctrl_1.signal); + return function () { + ctrl_1.abort(); + }; + } + return; + }, + [setError, consumeReq, fetch, handleResponse, handleError, startLoading] + ); + if (error) { + throw error; + } +}; +function useRethrowInRender() { + var _a = React.useState(undefined), + error = _a[0], + setError = _a[1]; + if (error) { + throw error; + } + return setError; +} + +var BaseRecipeModule = /** @class */ (function () { + /* + * Constructor. + */ + function BaseRecipeModule(config) { + this.config = config; + } + return BaseRecipeModule; +})(); + +function normaliseRecipeModuleConfig(config) { + var _this = this; + if (config === undefined) { + config = {}; + } + var onHandleEvent = config.onHandleEvent, + getRedirectionURL = config.getRedirectionURL, + preAPIHook = config.preAPIHook, + postAPIHook = config.postAPIHook; + if (onHandleEvent === undefined) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function + onHandleEvent = function (_) {}; + } + if (getRedirectionURL === undefined) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getRedirectionURL = function (_) { + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/, undefined]; + }); + }); + }; + } + if (preAPIHook === undefined) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + preAPIHook = function (context) { + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/, context]; + }); + }); + }; + } + if (postAPIHook === undefined) { + // eslint-disable-next-line @typescript-eslint/no-empty-function + postAPIHook = function () { + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/]; + }); + }); + }; + } + var rootStyle = config.style === undefined ? "" : config.style; + return exports.__assign(exports.__assign({}, config), { + getRedirectionURL: getRedirectionURL, + onHandleEvent: onHandleEvent, + preAPIHook: preAPIHook, + postAPIHook: postAPIHook, + recipeRootStyle: rootStyle, + }); +} + +function normaliseMultitenancyConfig(config) { + return exports.__assign(exports.__assign({}, normaliseRecipeModuleConfig(config)), { + override: exports.__assign( + { + functions: function (originalImplementation) { + return originalImplementation; + }, + }, + config === null || config === void 0 ? void 0 : config.override + ), + }); +} +function hasIntersectingRecipes(tenantMethods, recipeList) { + return tenantMethods.firstFactors.some(function (factorId) { + return recipeList.some(function (r) { + return r.firstFactorIds.includes(factorId); + }); + }); +} + +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +/* + * Class. + */ +var Multitenancy = /** @class */ (function (_super) { + __extends(Multitenancy, _super); + function Multitenancy(config, webJSRecipe) { + if (webJSRecipe === void 0) { + webJSRecipe = MultitenancyWebJS__default.default; + } + var _this = _super.call(this, config) || this; + _this.webJSRecipe = webJSRecipe; + _this.recipeID = Multitenancy.RECIPE_ID; + _this.dynamicLoginMethodsCache = {}; + return _this; + } + Multitenancy.prototype.getCurrentDynamicLoginMethods = function (input) { + var _a; + return __awaiter(this, void 0, void 0, function () { + var userContext, tenantId, tenantMethods; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (SuperTokens.usesDynamicLoginMethods === false) { + return [2 /*return*/, undefined]; + } + userContext = utils.getNormalisedUserContext(input.userContext); + return [4 /*yield*/, Multitenancy.getInstanceOrThrow().webJSRecipe.getTenantId()]; + case 1: + tenantId = (_a = _b.sent()) !== null && _a !== void 0 ? _a : "public"; + if (this.dynamicLoginMethodsCache[tenantId] === undefined) { + this.dynamicLoginMethodsCache[tenantId] = Multitenancy.getDynamicLoginMethods({ + tenantId: tenantId, + userContext: userContext, + }); + } + return [4 /*yield*/, this.dynamicLoginMethodsCache[tenantId]]; + case 2: + tenantMethods = _b.sent(); + if ( + !hasIntersectingRecipes( + tenantMethods, + SuperTokens.getInstanceOrThrow().recipeList.filter(function (recipe) { + return "firstFactorIds" in recipe; + }) + ) + ) { + throw new Error( + "Initialized recipes have no overlap with core recipes or could not load login methods" + ); + } + return [2 /*return*/, tenantMethods]; + } + }); + }); + }; + Multitenancy.getDynamicLoginMethods = function (input) { + return __awaiter(this, void 0, void 0, function () { + var _a, thirdParty, firstFactors; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + return [4 /*yield*/, MultitenancyWebJS__default.default.getLoginMethods(input)]; + case 1: + (_a = _b.sent()), (thirdParty = _a.thirdParty), (firstFactors = _a.firstFactors); + return [ + 2 /*return*/, + { + thirdparty: thirdParty, + firstFactors: firstFactors, + }, + ]; + } + }); + }); + }; + Multitenancy.init = function (config) { + var normalisedConfig = normaliseMultitenancyConfig(config); + return { + recipeID: Multitenancy.RECIPE_ID, + authReact: function (appInfo) { + Multitenancy.instance = new Multitenancy( + exports.__assign(exports.__assign({}, normalisedConfig), { + appInfo: appInfo, + recipeId: Multitenancy.RECIPE_ID, + }) + ); + return Multitenancy.instance; + }, + webJS: MultitenancyWebJS__default.default.init(exports.__assign({}, normalisedConfig)), + }; + }; + Multitenancy.getInstanceOrThrow = function () { + if (Multitenancy.instance === undefined) { + var error = + "No instance of Multitenancy found. Make sure to call the Multitenancy.init method." + + "See https://supertokens.io/docs/multitenancy/quick-setup/frontend"; + // eslint-disable-next-line supertokens-auth-react/no-direct-window-object + if (typeof window === "undefined") { + error = error + SSR_ERROR; + } + throw Error(error); + } + return Multitenancy.instance; + }; + /* + * Tests methods. + */ + Multitenancy.reset = function () { + if (!isTest()) { + return; + } + Multitenancy.instance = undefined; + return; + }; + Multitenancy.RECIPE_ID = "multitenancy"; + return Multitenancy; +})(BaseRecipeModule); + +var TranslationController = /** @class */ (function () { + function TranslationController() { + this.handlers = new Map(); + } + TranslationController.prototype.emit = function (event, detail) { + var handlerList = this.handlers.get(event) || []; + for (var _i = 0, handlerList_1 = handlerList; _i < handlerList_1.length; _i++) { + var h = handlerList_1[_i]; + h(event, detail); + } + }; + TranslationController.prototype.on = function (event, handler) { + var handlerList = this.handlers.get(event) || []; + this.handlers.set(event, handlerList.concat(handler)); + }; + TranslationController.prototype.off = function (event, handler) { + var handlerList = this.handlers.get(event) || []; + this.handlers.set( + event, + handlerList.filter(function (h) { + return h !== handler; + }) + ); + }; + return TranslationController; +})(); +var CURRENT_LANGUAGE_COOKIE_NAME = "sCurrLanguage"; +function saveCurrentLanguage(language, cookieDomain) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _b.trys.push([0, 2, , 3]); + return [4 /*yield*/, setFrontendCookie(CURRENT_LANGUAGE_COOKIE_NAME, language, cookieDomain)]; + case 1: + _b.sent(); + return [3 /*break*/, 3]; + case 2: + _b.sent(); + return [3 /*break*/, 3]; + case 3: + return [2 /*return*/]; + } + }); + }); +} +function getCurrentLanguageFromCookie() { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _b.trys.push([0, 2, , 3]); + return [4 /*yield*/, getCookieValue(CURRENT_LANGUAGE_COOKIE_NAME)]; + case 1: + return [2 /*return*/, _b.sent()]; + case 2: + _b.sent(); + // This can throw if we are not in a browser + // Since this is just loading a preference we can safely ignore the exception + return [2 /*return*/, null]; + case 3: + return [2 /*return*/]; + } + }); + }); +} + +/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +/* + * Class. + */ +var SuperTokens = /** @class */ (function () { + /* + * Constructor. + */ + function SuperTokens(config) { + var _this = this; + var _a, _b, _c, _d; + this.recipeList = []; + this.changeLanguage = function (lang) { + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + return [ + 4 /*yield*/, + saveCurrentLanguage(lang, this.languageTranslations.currentLanguageCookieScope), + ]; + case 1: + _a.sent(); + this.languageTranslations.translationEventSource.emit("LanguageChange", lang); + return [2 /*return*/]; + } + }); + }); + }; + this.redirectToAuth = function (options) { + return __awaiter(_this, void 0, void 0, function () { + var queryParams, redirectUrl; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + queryParams = options.queryParams === undefined ? {} : options.queryParams; + if (options.show !== undefined) { + queryParams.show = options.show; + } + if (options.redirectBack === true) { + queryParams.redirectToPath = getCurrentNormalisedUrlPathWithQueryParamsAndFragments(); + } + return [ + 4 /*yield*/, + this.getRedirectUrl( + { + action: "TO_AUTH", + showSignIn: options.show === "signin", + }, + options.userContext + ), + ]; + case 1: + redirectUrl = _a.sent(); + if (redirectUrl === null) { + logDebugMessage("Skipping redirection because the user override returned null"); + return [2 /*return*/]; + } + redirectUrl = appendQueryParamsToURL(redirectUrl, queryParams); + return [2 /*return*/, this.redirectToUrl(redirectUrl, options.navigate)]; + } + }); + }); + }; + this.redirectToUrl = function (redirectUrl, navigate) { + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + doRedirection(this.appInfo, redirectUrl, navigate); + return [2 /*return*/]; + }); + }); + }; + this.redirect = function (context, navigate, queryParams, userContext) { + return __awaiter(_this, void 0, void 0, function () { + var redirectUrl; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + return [4 /*yield*/, this.getRedirectUrl(context, getNormalisedUserContext(userContext))]; + case 1: + redirectUrl = _a.sent(); + if (redirectUrl === null) { + logDebugMessage( + "Skipping redirection because the user override returned null for context ".concat( + JSON.stringify(context, null, 2) + ) + ); + return [2 /*return*/]; + } + redirectUrl = appendQueryParamsToURL(redirectUrl, queryParams); + return [ + 2 /*return*/, + SuperTokens.getInstanceOrThrow().redirectToUrl(redirectUrl, navigate), + ]; + } + }); + }); + }; + this.appInfo = normaliseInputAppInfoOrThrowError(config.appInfo); + if (config.recipeList === undefined || config.recipeList.length === 0) { + throw new Error( + "Please provide at least one recipe to the supertokens.init function call. See https://supertokens.io/docs/emailpassword/quick-setup/frontend" + ); + } + var translationConfig = config.languageTranslations === undefined ? {} : config.languageTranslations; + this.languageTranslations = { + defaultLanguage: translationConfig.defaultLanguage === undefined ? "en" : translationConfig.defaultLanguage, + currentLanguageCookieScope: + translationConfig.currentLanguageCookieScope !== undefined + ? normaliseCookieScopeOrThrowError(translationConfig.currentLanguageCookieScope) + : getDefaultCookieScope(), + userTranslationStore: translationConfig.translations !== undefined ? translationConfig.translations : {}, + translationEventSource: new TranslationController(), + userTranslationFunc: translationConfig.translationFunc, + }; + var enableDebugLogs = Boolean(config === null || config === void 0 ? void 0 : config.enableDebugLogs); + if (enableDebugLogs) { + enableLogging(); + } + this.userGetRedirectionURL = config.getRedirectionURL; + this.recipeList = config.recipeList.map(function (_a) { + var authReact = _a.authReact; + return authReact(_this.appInfo, enableDebugLogs); + }); + this.rootStyle = (_a = config.style) !== null && _a !== void 0 ? _a : ""; + this.privacyPolicyLink = config.privacyPolicyLink; + this.termsOfServiceLink = config.termsOfServiceLink; + this.useShadowDom = (_b = config.useShadowDom) !== null && _b !== void 0 ? _b : true; + this.defaultToSignUp = (_c = config.defaultToSignUp) !== null && _c !== void 0 ? _c : false; + this.disableAuthRoute = (_d = config.disableAuthRoute) !== null && _d !== void 0 ? _d : false; + } + /* + * Static Methods. + */ + SuperTokens.init = function (config) { + var _a; + cookieHandler.CookieHandlerReference.init(config.cookieHandler); + windowHandler.WindowHandlerReference.init(config.windowHandler); + if (SuperTokens.instance !== undefined) { + console.warn("SuperTokens was already initialized"); + return; + } + SuperTokens.usesDynamicLoginMethods = + (_a = config.usesDynamicLoginMethods) !== null && _a !== void 0 ? _a : false; + var recipes = + config.recipeList.find(function (recipe) { + return recipe.recipeID === Multitenancy.RECIPE_ID; + }) !== undefined + ? config.recipeList + : config.recipeList.concat(Multitenancy.init({})); + SuperTokensWebJS__default.default.init( + exports.__assign(exports.__assign({}, config), { + recipeList: recipes.map(function (_a) { + var webJS = _a.webJS; + return webJS; + }), + }) + ); + SuperTokens.instance = new SuperTokens(exports.__assign(exports.__assign({}, config), { recipeList: recipes })); + postSuperTokensInitCallbacks.PostSuperTokensInitCallbacks.runPostInitCallbacks(); + }; + SuperTokens.getInstanceOrThrow = function () { + if (SuperTokens.instance === undefined) { + var error = "SuperTokens must be initialized before calling this method."; + // eslint-disable-next-line supertokens-auth-react/no-direct-window-object + if (typeof window === "undefined") { + error = error + SSR_ERROR; + } + throw new Error(error); + } + return SuperTokens.instance; + }; + SuperTokens.prototype.getRecipeOrThrow = function (recipeId) { + var recipe = this.recipeList.find(function (recipe) { + return recipe.config.recipeId === recipeId; + }); + if (recipe === undefined) { + throw new Error("Missing recipe: ".concat(recipeId)); + } + return recipe; + }; + SuperTokens.prototype.loadTranslation = function (store) { + this.languageTranslations.translationEventSource.emit("TranslationLoaded", store); + }; + SuperTokens.prototype.getRedirectUrl = function (context, userContext) { + var _a; + return __awaiter(this, void 0, void 0, function () { + var userRes, redirectUrl; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!this.userGetRedirectionURL) return [3 /*break*/, 2]; + return [4 /*yield*/, this.userGetRedirectionURL(context, userContext)]; + case 1: + userRes = _b.sent(); + if (userRes !== undefined) { + return [2 /*return*/, userRes]; + } + _b.label = 2; + case 2: + if (context.action === "TO_AUTH") { + redirectUrl = this.appInfo.websiteBasePath.getAsStringDangerous(); + return [2 /*return*/, appendTrailingSlashToURL(redirectUrl)]; + } else if (context.action === "SUCCESS") { + return [2 /*return*/, (_a = context.redirectToPath) !== null && _a !== void 0 ? _a : "/"]; + } + throw new Error("Should never come here: unexpected redirection context"); + } + }); + }); + }; + /* + * Tests methods. + */ + SuperTokens.reset = function () { + if (!isTest()) { + return; + } + SuperTokens.instance = undefined; + return; + }; + SuperTokens.usesDynamicLoginMethods = false; + return SuperTokens; +})(); +function doRedirection(appInfo, redirectUrl, navigate) { + try { + new URL(redirectUrl); // If full URL, no error thrown, skip in app redirection. + } catch (e) { + // For multi tenancy, If mismatch between websiteDomain and current location, prepend URL relative path with websiteDomain. + var origin_1 = getOriginOfPage().getAsStringDangerous(); + if (origin_1 !== appInfo.websiteDomain.getAsStringDangerous()) { + redirectUrl = "".concat(appInfo.websiteDomain.getAsStringDangerous()).concat(redirectUrl); + redirectWithFullPageReload(redirectUrl); + return; + } + // If navigate was provided, use to redirect without reloading. + if (navigate !== undefined) { + redirectWithNavigate(redirectUrl, navigate); + return; + } + } + // Otherwise, redirect in app. + redirectWithFullPageReload(redirectUrl); +} var createGenericComponentsOverrideContext = function (v) { if (v === void 0) { @@ -21,12 +1428,42 @@ var createGenericComponentsOverrideContext = function (v) { var Provider = function (_a) { var children = _a.children, components = _a.components; - return jsxRuntime.jsx( - genericContext.Provider, - superTokens.__assign({ value: components }, { children: children }) - ); + return jsxRuntime.jsx(genericContext.Provider, exports.__assign({ value: components }, { children: children })); }; return [useComponentsOverrideContext, Provider, genericContext.Consumer]; }; +exports.BaseRecipeModule = BaseRecipeModule; +exports.Multitenancy = Multitenancy; +exports.SSR_ERROR = SSR_ERROR; +exports.ST_ROOT_ID = ST_ROOT_ID; +exports.SuperTokens = SuperTokens; +exports.__awaiter = __awaiter; +exports.__extends = __extends; +exports.__generator = __generator; +exports.__rest = __rest; +exports.__spreadArray = __spreadArray; +exports.appendQueryParamsToURL = appendQueryParamsToURL; +exports.clearErrorQueryParam = clearErrorQueryParam; +exports.clearQueryParams = clearQueryParams; exports.createGenericComponentsOverrideContext = createGenericComponentsOverrideContext; +exports.getCurrentLanguageFromCookie = getCurrentLanguageFromCookie; +exports.getCurrentNormalisedUrlPath = getCurrentNormalisedUrlPath; +exports.getCurrentNormalisedUrlPathWithQueryParamsAndFragments = getCurrentNormalisedUrlPathWithQueryParamsAndFragments; +exports.getLocalStorage = getLocalStorage; +exports.getNormalisedUserContext = getNormalisedUserContext; +exports.getQueryParams = getQueryParams; +exports.getRedirectToPathFromURL = getRedirectToPathFromURL; +exports.getURLHash = getURLHash; +exports.isTest = isTest; +exports.logDebugMessage = logDebugMessage; +exports.matchRecipeIdUsingQueryParams = matchRecipeIdUsingQueryParams; +exports.mergeObjects = mergeObjects; +exports.normaliseRecipeModuleConfig = normaliseRecipeModuleConfig; +exports.redirectWithFullPageReload = redirectWithFullPageReload; +exports.removeFromLocalStorage = removeFromLocalStorage; +exports.setLocalStorage = setLocalStorage; +exports.updateQueryParam = updateQueryParam; +exports.useOnMountAPICall = useOnMountAPICall; +exports.useRethrowInRender = useRethrowInRender; +exports.validateForm = validateForm; diff --git a/lib/build/index.js b/lib/build/index.js index 11217f2b2..b2a26c6c8 100644 --- a/lib/build/index.js +++ b/lib/build/index.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -require("./superTokens.js"); +require("./genericComponentOverrideContext.js"); var uiEntry = require("./index2.js"); var translationContext = require("./translationContext.js"); require("supertokens-web-js"); @@ -17,7 +17,6 @@ require("supertokens-web-js/utils/normalisedURLPath"); require("react/jsx-runtime"); require("react-dom"); require("./multitenancy-shared.js"); -require("./genericComponentOverrideContext.js"); require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); diff --git a/lib/build/index2.js b/lib/build/index2.js index 77de0cac3..afe235f69 100644 --- a/lib/build/index2.js +++ b/lib/build/index2.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var jsxRuntime = require("react/jsx-runtime"); var React = require("react"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); @@ -11,7 +11,6 @@ var componentOverrideContext = require("./multitenancy-shared.js"); var recipe$1 = require("./multifactorauth-shared2.js"); var types = require("./multifactorauth-shared.js"); var recipe = require("./oauth2provider-shared.js"); -var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var utils = require("./authRecipe-shared.js"); var NormalisedURLPath$1 = require("supertokens-web-js/lib/build/normalisedURLPath"); @@ -48,12 +47,12 @@ var ComponentOverrideContext = React__default.default.createContext("IS_DEFAULT" function SpinnerIcon() { return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { version: "1.1", viewBox: "25 25 50 50", "data-supertokens": "spinnerIcon" }, { children: jsxRuntime.jsxs( "circle", - superTokens.__assign( + genericComponentOverrideContext.__assign( { cx: "50", cy: "50", @@ -114,10 +113,10 @@ var withOverride = function (overrideKey, DefaultComponent) { if (OverrideComponent !== null) { return jsxRuntime.jsx( OverrideComponent, - superTokens.__assign({ DefaultComponent: DefaultComponent }, props) + genericComponentOverrideContext.__assign({ DefaultComponent: DefaultComponent }, props) ); } - return jsxRuntime.jsx(DefaultComponent, superTokens.__assign({}, props)); + return jsxRuntime.jsx(DefaultComponent, genericComponentOverrideContext.__assign({}, props)); }; }; @@ -145,17 +144,17 @@ var ThemeBase$1 = function (_a) { var MultitenancyDynamicLoginMethodsSpinnerTheme = function () { return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container delayedRender" }, { children: jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "spinner delayedRender" }, { children: jsxRuntime.jsx(SpinnerIcon, {}) } ) @@ -172,10 +171,10 @@ var DynamicLoginMethodsSpinnerThemeWithOverride = withOverride( MultitenancyDynamicLoginMethodsSpinnerTheme ); var DynamicLoginMethodsSpinnerTheme = function (props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; return jsxRuntime.jsx( ThemeBase$1, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: false, userStyles: [rootStyle, props.config.recipeRootStyle] }, { children: jsxRuntime.jsx(DynamicLoginMethodsSpinnerThemeWithOverride, {}) } ) @@ -187,17 +186,17 @@ var DynamicLoginMethodsSpinnerTheme = function (props) { // - it's used inside FeatureWrapper & RoutingComponent (meaning it can't use FeatureWrapper) // - it's not used in any specific route (multitenancy doesn't have a pre-built UI) var DynamicLoginMethodsSpinner = function () { - var recipe = superTokens.Multitenancy.getInstanceOrThrow(); + var recipe = genericComponentOverrideContext.Multitenancy.getInstanceOrThrow(); var recipeComponentOverrides = componentOverrideContext.useContext(); return jsxRuntime.jsx( ComponentOverrideContext.Provider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( WithOrWithoutShadowDom, - superTokens.__assign( - { useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom }, + genericComponentOverrideContext.__assign( + { useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom }, { children: jsxRuntime.jsx(DynamicLoginMethodsSpinnerTheme, { config: recipe.config }) } ) ), @@ -220,7 +219,7 @@ var DynamicLoginMethodsProvider = function (_a) { var contextValue = value === undefined ? { loaded: false } : { loaded: true, loginMethods: value }; return jsxRuntime.jsx( dynamicLoginMethodsContext.Provider, - superTokens.__assign({ value: contextValue }, { children: children }) + genericComponentOverrideContext.__assign({ value: contextValue }, { children: children }) ); }; @@ -231,10 +230,10 @@ var useUserContext = function () { var UserContextProvider = function (_a) { var children = _a.children, userContext = _a.userContext; - var currentUserContext = React.useState(superTokens.getNormalisedUserContext(userContext))[0]; + var currentUserContext = React.useState(genericComponentOverrideContext.getNormalisedUserContext(userContext))[0]; return jsxRuntime.jsx( UserContextContext.Provider, - superTokens.__assign({ value: currentUserContext }, { children: children }) + genericComponentOverrideContext.__assign({ value: currentUserContext }, { children: children }) ); }; @@ -243,17 +242,17 @@ function FeatureWrapper(_a) { useShadowDom = _a.useShadowDom, defaultStore = _a.defaultStore; var userContext = useUserContext(); - var rethrowInRender = superTokens.useRethrowInRender(); + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); var _b = React.useState(undefined), loadedDynamicLoginMethods = _b[0], setLoadedDynamicLoginMethods = _b[1]; - var st = superTokens.SuperTokens.getInstanceOrThrow(); + var st = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow(); React.useEffect( function () { if (loadedDynamicLoginMethods) { return; } - superTokens.Multitenancy.getInstanceOrThrow() + genericComponentOverrideContext.Multitenancy.getInstanceOrThrow() .getCurrentDynamicLoginMethods({ userContext: userContext }) .then( function (loginMethods) { @@ -266,20 +265,20 @@ function FeatureWrapper(_a) { }, [loadedDynamicLoginMethods, setLoadedDynamicLoginMethods] ); - if (superTokens.SuperTokens.usesDynamicLoginMethods && !loadedDynamicLoginMethods) { + if (genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods && !loadedDynamicLoginMethods) { return jsxRuntime.jsx(DynamicLoginMethodsSpinner, {}); } return jsxRuntime.jsx( DynamicLoginMethodsProvider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { value: loadedDynamicLoginMethods }, { children: jsxRuntime.jsx( translationContext.TranslationContextProvider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { defaultLanguage: st.languageTranslations.defaultLanguage, - defaultStore: superTokens.mergeObjects( + defaultStore: genericComponentOverrideContext.mergeObjects( defaultStore, st.languageTranslations.userTranslationStore ), @@ -289,7 +288,10 @@ function FeatureWrapper(_a) { { children: jsxRuntime.jsx( WithOrWithoutShadowDom, - superTokens.__assign({ useShadowDom: useShadowDom }, { children: children }) + genericComponentOverrideContext.__assign( + { useShadowDom: useShadowDom }, + { children: children } + ) ), } ) @@ -322,8 +324,8 @@ function WithShadowDom(_a) { // Otherwise, use shadow dom. return jsxRuntime.jsx( "div", - superTokens.__assign( - { id: superTokens.ST_ROOT_ID, ref: rootDiv }, + genericComponentOverrideContext.__assign( + { id: genericComponentOverrideContext.ST_ROOT_ID, ref: rootDiv }, { children: shadowRoot && reactDom.createPortal(children, shadowRoot) } ) ); @@ -335,8 +337,8 @@ function WithOrWithoutShadowDom(_a) { if (useShadowDom === false) { return jsxRuntime.jsxs( "div", - superTokens.__assign( - { id: superTokens.ST_ROOT_ID }, + genericComponentOverrideContext.__assign( + { id: genericComponentOverrideContext.ST_ROOT_ID }, { children: [children, jsxRuntime.jsx(DisableAutoFillInput, {})] } ) ); @@ -347,7 +349,7 @@ function DisableAutoFillInput() { /* eslint-disable react/jsx-no-literals */ return jsxRuntime.jsx( "style", - superTokens.__assign( + genericComponentOverrideContext.__assign( { type: "text/css" }, { children: @@ -404,7 +406,7 @@ function SuperTokensBranding() { var t = translationContext.useTranslation(); return jsxRuntime.jsxs( "a", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "superTokensBranding", href: "https://supertokens.com?utm_campaign=poweredby", @@ -454,7 +456,7 @@ function UserContextWrapper(props) { if (props.userContext !== undefined) { return jsxRuntime.jsx( UserContextProvider, - superTokens.__assign({ userContext: props.userContext }, { children: props.children }) + genericComponentOverrideContext.__assign({ userContext: props.userContext }, { children: props.children }) ); } return jsxRuntime.jsx(UserContextContext.Consumer, { @@ -484,7 +486,10 @@ function UserContextWrapper(props) { function GeneralError(_a) { var error = _a.error; var t = translationContext.useTranslation(); - return jsxRuntime.jsx("div", superTokens.__assign({ "data-supertokens": "generalError" }, { children: t(error) })); + return jsxRuntime.jsx( + "div", + genericComponentOverrideContext.__assign({ "data-supertokens": "generalError" }, { children: t(error) }) + ); } var styles = @@ -515,14 +520,14 @@ var AuthPageComponentList = withOverride("AuthPageComponentList", function AuthP list.push(function () { return jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "dividerWithOr" }, { children: [ jsxRuntime.jsx("div", { "data-supertokens": "divider" }), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "dividerText" }, { children: t("DIVIDER_OR") } ) @@ -541,11 +546,11 @@ var AuthPageComponentList = withOverride("AuthPageComponentList", function AuthP } return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "authComponentList" }, { children: list.map(function (i) { - return i(superTokens.__assign({}, props)); + return i(genericComponentOverrideContext.__assign({}, props)); }), } ) @@ -566,7 +571,7 @@ var AuthPageFooter = withOverride("AuthPageFooter", function AuthPageFooter(_a) } return jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "secondaryText privacyPolicyAndTermsAndConditions" }, { children: [ @@ -574,7 +579,7 @@ var AuthPageFooter = withOverride("AuthPageFooter", function AuthPageFooter(_a) termsOfServiceLink !== undefined && jsxRuntime.jsx( "a", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "link", href: termsOfServiceLink, @@ -588,7 +593,7 @@ var AuthPageFooter = withOverride("AuthPageFooter", function AuthPageFooter(_a) privacyPolicyLink !== undefined && jsxRuntime.jsx( "a", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "link", href: privacyPolicyLink, @@ -629,7 +634,7 @@ function HeavyArrowLeftIcon(_a) { var color = _a.color; return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "16", @@ -655,7 +660,7 @@ function BackButton(_a) { var onClick = _a.onClick; return jsxRuntime.jsx( "button", - superTokens.__assign( + genericComponentOverrideContext.__assign( { onClick: onClick, "data-supertokens": "backButton backButtonCommon" }, { children: jsxRuntime.jsx(HeavyArrowLeftIcon, { color: "rgb(var(--palette-textTitle))" }) } ) @@ -680,7 +685,7 @@ var AuthPageHeader = withOverride("AuthPageHeader", function AuthPageHeader(_a) }), jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle withBackButton" }, { children: [ @@ -702,7 +707,7 @@ var AuthPageHeader = withOverride("AuthPageHeader", function AuthPageHeader(_a) oauth2ClientInfo && jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "authPageTitleOAuthClient" }, { children: [ @@ -710,7 +715,7 @@ var AuthPageHeader = withOverride("AuthPageHeader", function AuthPageHeader(_a) oauth2ClientInfo.clientUri !== undefined ? jsxRuntime.jsx( "a", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "authPageTitleOAuthClientUrl link", href: oauth2ClientInfo.clientUri, @@ -720,7 +725,7 @@ var AuthPageHeader = withOverride("AuthPageHeader", function AuthPageHeader(_a) ) : jsxRuntime.jsx( "span", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "authPageTitleOAuthClientName" }, { children: oauth2ClientInfo.clientName } ) @@ -733,14 +738,14 @@ var AuthPageHeader = withOverride("AuthPageHeader", function AuthPageHeader(_a) (!isSignUp ? jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: [ t("AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_START"), jsxRuntime.jsx( "span", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "link", onClick: onSignInUpSwitcherClick }, { children: t("AUTH_PAGE_HEADER_SUBTITLE_SIGN_IN_SIGN_UP_LINK") } ) @@ -752,14 +757,14 @@ var AuthPageHeader = withOverride("AuthPageHeader", function AuthPageHeader(_a) ) : jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: [ t("AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_START"), jsxRuntime.jsx( "span", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "link", onClick: onSignInUpSwitcherClick }, { children: t("AUTH_PAGE_HEADER_SUBTITLE_SIGN_UP_SIGN_IN_LINK") } ) @@ -778,7 +783,7 @@ function AuthPageTheme(props) { if (props.fullPageCompWithPreloadedInfo) { return jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.fullPageCompWithPreloadedInfo.component( - superTokens.__assign(superTokens.__assign({}, props), { + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, props), { preloadInfo: props.fullPageCompWithPreloadedInfo.preloadInfo, }) ), @@ -786,7 +791,7 @@ function AuthPageTheme(props) { } return jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container authPage ".concat( props.factorIds.length > 1 ? "multiFactor" : "singleFactor" @@ -796,7 +801,7 @@ function AuthPageTheme(props) { children: [ jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: [ @@ -810,7 +815,10 @@ function AuthPageTheme(props) { oauth2ClientInfo: props.oauth2ClientInfo, }), props.error !== undefined && jsxRuntime.jsx(GeneralError, { error: props.error }), - jsxRuntime.jsx(AuthPageComponentList, superTokens.__assign({}, props)), + jsxRuntime.jsx( + AuthPageComponentList, + genericComponentOverrideContext.__assign({}, props) + ), jsxRuntime.jsx(AuthPageFooter, { factorIds: props.factorIds, isSignUp: props.isSignUp, @@ -829,18 +837,18 @@ function AuthPageTheme(props) { ); } function AuthPageThemeWrapper(props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = hasFontDefined(rootStyle); return jsxRuntime.jsx( UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle] }, - { children: jsxRuntime.jsx(AuthPageTheme, superTokens.__assign({}, props)) } + { children: jsxRuntime.jsx(AuthPageTheme, genericComponentOverrideContext.__assign({}, props)) } ) ), } @@ -857,19 +865,24 @@ var AuthPageWrapper = function (props) { var authRecipeComponentOverrides = useContext(); return jsxRuntime.jsx( UserContextProvider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( SessionAuthWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { requireAuth: false, doRedirection: false }, { children: jsxRuntime.jsx( ComponentOverrideContext.Provider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { value: authRecipeComponentOverrides }, - { children: jsxRuntime.jsx(AuthPageInner, superTokens.__assign({}, props)) } + { + children: jsxRuntime.jsx( + AuthPageInner, + genericComponentOverrideContext.__assign({}, props) + ), + } ) ), } @@ -910,7 +923,7 @@ var AuthPageInner = function (props) { var forceFreshAuth = search.get("forceFreshAuth") === "true"; var sessionContext = useSessionContext(); var userContext = useUserContext(); - var rethrowInRender = superTokens.useRethrowInRender(); + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); var _f = React.useState(undefined), loadedDynamicLoginMethods = _f[0], setLoadedDynamicLoginMethods = _f[1]; @@ -923,7 +936,7 @@ var AuthPageInner = function (props) { var _j = React.useState(false), sessionLoadedAndNotRedirecting = _j[0], setSessionLoadedAndNotRedirecting = _j[1]; - var st = superTokens.SuperTokens.getInstanceOrThrow(); + var st = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow(); var _k = React.useState(props.factors), factorList = _k[0], setFactorList = _k[1]; @@ -965,7 +978,7 @@ var AuthPageInner = function (props) { var onSignInUpSwitcherClick = React.useCallback( function () { if (props.useSignUpStateFromQueryString === true) { - superTokens.updateQueryParam("show", isSignUp ? "signin" : "signup"); + genericComponentOverrideContext.updateQueryParam("show", isSignUp ? "signin" : "signup"); } setError(undefined); setIsSignUp(!isSignUp); @@ -980,7 +993,7 @@ var AuthPageInner = function (props) { if (loadedDynamicLoginMethods) { return; } - superTokens.Multitenancy.getInstanceOrThrow() + genericComponentOverrideContext.Multitenancy.getInstanceOrThrow() .getCurrentDynamicLoginMethods({ userContext: userContext }) .then( function (loginMethods) { @@ -1038,7 +1051,7 @@ var AuthPageInner = function (props) { recipeId: types.Session.RECIPE_ID, }, types.Session.RECIPE_ID, - superTokens.getRedirectToPathFromURL(), + genericComponentOverrideContext.getRedirectToPathFromURL(), userContext, props.navigate ) @@ -1048,7 +1061,7 @@ var AuthPageInner = function (props) { .validateGlobalClaimsAndHandleSuccessRedirection( undefined, types.Session.RECIPE_ID, - superTokens.getRedirectToPathFromURL(), + genericComponentOverrideContext.getRedirectToPathFromURL(), userContext, props.navigate ) @@ -1073,7 +1086,7 @@ var AuthPageInner = function (props) { props.factors.some(function (id) { return !factorList.includes(id); })); - var stInstance = superTokens.SuperTokens.getInstanceOrThrow(); + var stInstance = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow(); var privacyPolicyLink = stInstance.privacyPolicyLink; var termsOfServiceLink = stInstance.termsOfServiceLink; React.useEffect( @@ -1084,7 +1097,8 @@ var AuthPageInner = function (props) { } if ( sessionLoadedAndNotRedirecting && - (loadedDynamicLoginMethods !== undefined || !superTokens.SuperTokens.usesDynamicLoginMethods) + (loadedDynamicLoginMethods !== undefined || + !genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods) ) { void buildAndSetChildProps( props.preBuiltUIList, @@ -1119,16 +1133,16 @@ var AuthPageInner = function (props) { function (ctx) { return types.Session.getInstanceOrThrow().validateGlobalClaimsAndHandleSuccessRedirection( loginChallenge !== null - ? superTokens.__assign(superTokens.__assign({}, ctx), { + ? genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, ctx), { action: "SUCCESS_OAUTH2", loginChallenge: loginChallenge, }) - : superTokens.__assign(superTokens.__assign({}, ctx), { + : genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, ctx), { action: "SUCCESS", - redirectToPath: superTokens.getRedirectToPathFromURL(), + redirectToPath: genericComponentOverrideContext.getRedirectToPathFromURL(), }), ctx.recipeId, - superTokens.getRedirectToPathFromURL(), + genericComponentOverrideContext.getRedirectToPathFromURL(), userContext, props.navigate ); @@ -1137,40 +1151,43 @@ var AuthPageInner = function (props) { ); var childProps = authComponentListInfo !== undefined && (loginChallenge === null || oauth2ClientInfo !== undefined) - ? superTokens.__assign(superTokens.__assign({}, authComponentListInfo), { - oauth2ClientInfo: oauth2ClientInfo, - onAuthSuccess: onAuthSuccess, - error: error, - onError: function (err) { - setError(err); - }, - clearError: function () { - return setError(undefined); - }, - navigate: props.navigate, - onSignInUpSwitcherClick: onSignInUpSwitcherClick, - privacyPolicyLink: privacyPolicyLink, - rebuildAuthPage: function () { - return setRebuildReqCount(function (v) { - return v + 1; - }); - }, - setFactorList: function (factorIds) { - setFactorList(factorIds); - setRebuildReqCount(function (v) { - return v + 1; - }); - }, - resetFactorList: function () { - setFactorList(props.factors); - setRebuildReqCount(function (v) { - return v + 1; - }); - }, - showBackButton: showUseAnotherLink, - termsOfServiceLink: termsOfServiceLink, - userContext: userContext, - }) + ? genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, authComponentListInfo), + { + oauth2ClientInfo: oauth2ClientInfo, + onAuthSuccess: onAuthSuccess, + error: error, + onError: function (err) { + setError(err); + }, + clearError: function () { + return setError(undefined); + }, + navigate: props.navigate, + onSignInUpSwitcherClick: onSignInUpSwitcherClick, + privacyPolicyLink: privacyPolicyLink, + rebuildAuthPage: function () { + return setRebuildReqCount(function (v) { + return v + 1; + }); + }, + setFactorList: function (factorIds) { + setFactorList(factorIds); + setRebuildReqCount(function (v) { + return v + 1; + }); + }, + resetFactorList: function () { + setFactorList(props.factors); + setRebuildReqCount(function (v) { + return v + 1; + }); + }, + showBackButton: showUseAnotherLink, + termsOfServiceLink: termsOfServiceLink, + userContext: userContext, + } + ) : undefined; var mergedTranslations = React.useMemo( function () { @@ -1178,10 +1195,10 @@ var AuthPageInner = function (props) { if (authComponentListInfo !== undefined) { for (var _i = 0, _a = props.preBuiltUIList; _i < _a.length; _i++) { var ui = _a[_i]; - res = superTokens.mergeObjects(res, ui.languageTranslations); + res = genericComponentOverrideContext.mergeObjects(res, ui.languageTranslations); } } - res = superTokens.mergeObjects(res, st.languageTranslations.userTranslationStore); + res = genericComponentOverrideContext.mergeObjects(res, st.languageTranslations.userTranslationStore); return res; }, [st.languageTranslations.userTranslationStore, authComponentListInfo] @@ -1191,12 +1208,12 @@ var AuthPageInner = function (props) { } else { return jsxRuntime.jsx( DynamicLoginMethodsProvider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { value: loadedDynamicLoginMethods }, { children: jsxRuntime.jsx( translationContext.TranslationContextProvider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { defaultLanguage: st.languageTranslations.defaultLanguage, defaultStore: mergedTranslations, @@ -1206,7 +1223,7 @@ var AuthPageInner = function (props) { { children: jsxRuntime.jsx( WithOrWithoutShadowDom, - superTokens.__assign( + genericComponentOverrideContext.__assign( { useShadowDom: st.useShadowDom }, { children: jsxRuntime.jsxs(React.Fragment, { @@ -1214,7 +1231,7 @@ var AuthPageInner = function (props) { props.children === undefined && jsxRuntime.jsx( AuthPageThemeWrapper, - superTokens.__assign({}, childProps) + genericComponentOverrideContext.__assign({}, childProps) ), props.children && React__default.default.Children.map( @@ -1252,7 +1269,7 @@ function buildAndSetChildProps( abort ) { var _a, _b, _c, _d; - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var authRecipesInited, firstFactors, missingPreBuiltUIs, @@ -1269,14 +1286,15 @@ function buildAndSetChildProps( preloadRes, partialAuthComps, selectedComponents; - return superTokens.__generator(this, function (_f) { + return genericComponentOverrideContext.__generator(this, function (_f) { switch (_f.label) { case 0: - authRecipesInited = superTokens.SuperTokens.getInstanceOrThrow().recipeList.filter(function ( - recipe - ) { - return "firstFactorIds" in recipe; - }); + authRecipesInited = + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().recipeList.filter(function ( + recipe + ) { + return "firstFactorIds" in recipe; + }); firstFactors = (_c = (_a = @@ -1291,8 +1309,8 @@ function buildAndSetChildProps( : _b.config.firstFactors) !== null && _c !== void 0 ? _c : authRecipesInited.reduce(function (acc, recipe) { - return superTokens.__spreadArray( - superTokens.__spreadArray([], acc, true), + return genericComponentOverrideContext.__spreadArray( + genericComponentOverrideContext.__spreadArray([], acc, true), recipe.getFirstFactorsForAuthPage(), true ); @@ -1333,7 +1351,7 @@ function buildAndSetChildProps( // We have no provider defined for the tenant either if ( thirdPartyPreBuiltUI.recipeInstance.config.signInAndUpFeature.providers.length === 0 && - (!superTokens.SuperTokens.usesDynamicLoginMethods || + (!genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods || loadedDynamicLoginMethods.thirdparty.providers.length === 0) ) { firstFactors = firstFactors.filter(function (f) { @@ -1482,7 +1500,7 @@ function chooseComponentBasedOnFirstFactors(firstFactors, routeComponents) { fallbackRid = rid; fallbackComponent = matchingComp; if (firstFactors.length === factorsProvided.length) { - superTokens.logDebugMessage( + genericComponentOverrideContext.logDebugMessage( "Rendering ".concat(rid, " because it matches factors: ").concat(firstFactors, " exactly") ); return { value: matchingComp }; @@ -1524,7 +1542,7 @@ function chooseComponentBasedOnFirstFactors(firstFactors, routeComponents) { if (typeof state_1 === "object") return state_1.value; } if (fallbackComponent !== undefined) { - superTokens.logDebugMessage( + genericComponentOverrideContext.logDebugMessage( "Rendering ".concat(fallbackRid, " to cover ").concat(firstFactors, " as a fallback") ); return fallbackComponent; @@ -1555,7 +1573,7 @@ function chooseComponentBasedOnFirstFactors(firstFactors, routeComponents) { ) { enabledLoginMethods.push("passwordless"); } - superTokens.logDebugMessage( + genericComponentOverrideContext.logDebugMessage( "Choosing component using fallback logic w/ ".concat(enabledLoginMethods.join(", "), " enabled") ); var enabledRecipeCount = enabledLoginMethods.length; @@ -1640,7 +1658,8 @@ var RecipeRouter = /** @class */ (function () { var path = normalisedUrl.getAsStringDangerous(); // We check if we are on the auth page to later see if we should take first factors into account. var isAuthPage = - path === superTokens.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous(); + path === + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous(); // We get all components that can handle the current path var routeComponents = preBuiltUIList.reduce(function (components, c) { var routes = c.getPathsToFeatureComponentWithRecipeIdMap(); @@ -1688,7 +1707,7 @@ var RecipeRouter = /** @class */ (function () { return ( !ridlist.includes(comp.comp.recipeID) || comp.route !== - superTokens.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous() + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous() ); }); if (matchingNonAuthComponent) { @@ -1700,7 +1719,7 @@ var RecipeRouter = /** @class */ (function () { return defaultComp; } var mfaRecipe = recipe$1.MultiFactorAuth.getInstance(); - if (superTokens.SuperTokens.usesDynamicLoginMethods === false) { + if (genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods === false) { // If we are not using dynamic login methods, we can use the rid requested by the app if (componentMatchingRid) { return componentMatchingRid.comp; @@ -1762,7 +1781,7 @@ var RecipeRouter = /** @class */ (function () { function RoutingComponent(props) { var _a, _b; var userContext = useUserContext(); - var rethrowInRender = superTokens.useRethrowInRender(); + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); var _c = React.useState(undefined), loadedDynamicLoginMethods = _c[0], setLoadedDynamicLoginMethods = _c[1]; @@ -1770,7 +1789,8 @@ function RoutingComponent(props) { (_a = props.getReactRouterDomWithCustomHistory()) === null || _a === void 0 ? void 0 : _a.useHistoryCustom(); var path = props.path; var isAuthPage = - path === superTokens.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous(); + path === + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous(); var location = (_b = props.getReactRouterDomWithCustomHistory()) === null || _b === void 0 ? void 0 : _b.useLocation(); var componentToRender = React__default.default.useMemo( @@ -1782,14 +1802,20 @@ function RoutingComponent(props) { // During development, this runs twice so as to warn devs of if there // are any side effects that happen here. So in tests, it will result in // the console log twice - if (loadedDynamicLoginMethods !== undefined || superTokens.SuperTokens.usesDynamicLoginMethods === false) { + if ( + loadedDynamicLoginMethods !== undefined || + genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods === false + ) { var result = RecipeRouter.getMatchingComponentForRouteAndRecipeIdFromPreBuiltUIList( normalizedPath, props.preBuiltUIList, false, loadedDynamicLoginMethods ); - if (result === undefined && superTokens.SuperTokens.usesDynamicLoginMethods === true) { + if ( + result === undefined && + genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods === true + ) { void redirectToAuth({ navigate: navigate, redirectBack: false }); } return result; @@ -1805,7 +1831,7 @@ function RoutingComponent(props) { if (loadedDynamicLoginMethods) { return; } - superTokens.Multitenancy.getInstanceOrThrow() + genericComponentOverrideContext.Multitenancy.getInstanceOrThrow() .getCurrentDynamicLoginMethods({ userContext: userContext }) .then( function (loginMethods) { @@ -1825,12 +1851,15 @@ function RoutingComponent(props) { useSignUpStateFromQueryString: true, }); } - if (superTokens.SuperTokens.usesDynamicLoginMethods && loadedDynamicLoginMethods === undefined) { + if ( + genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods && + loadedDynamicLoginMethods === undefined + ) { return jsxRuntime.jsx(DynamicLoginMethodsSpinner, {}); } if ( componentToRender === undefined || - (loadedDynamicLoginMethods === undefined && superTokens.SuperTokens.usesDynamicLoginMethods) + (loadedDynamicLoginMethods === undefined && genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods) ) { return null; } @@ -1858,7 +1887,7 @@ function getSuperTokensRoutesForReactRouterDom$1(_a) { if (!(path in routes)) { routes[path] = jsxRuntime.jsx( Route, - superTokens.__assign( + genericComponentOverrideContext.__assign( { exact: true, path: pathForRouter }, { children: jsxRuntime.jsx(RoutingComponent, { @@ -1876,18 +1905,18 @@ function getSuperTokensRoutesForReactRouterDom$1(_a) { }, {}) ); if ( - !superTokens.SuperTokens.getInstanceOrThrow().disableAuthRoute && + !genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().disableAuthRoute && recipeList.some(function (ui) { return ui.getAuthComponents().length !== 0; }) ) { - var path = superTokens.SuperTokens.getInstanceOrThrow() + var path = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow() .appInfo.websiteBasePath.appendPath(new NormalisedURLPath__default$1.default("/")) .getAsStringDangerous(); routes.push( jsxRuntime.jsx( Route, - superTokens.__assign( + genericComponentOverrideContext.__assign( { exact: true, path: getPathForRouter$1(basePath, path) }, { children: jsxRuntime.jsx(RoutingComponent, { @@ -1955,12 +1984,12 @@ function getSuperTokensRoutesForReactRouterDomV6(_a) { }, {}) ); if ( - !superTokens.SuperTokens.getInstanceOrThrow().disableAuthRoute && + !genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().disableAuthRoute && recipeList.some(function (ui) { return ui.getAuthComponents().length !== 0; }) ) { - var path = superTokens.SuperTokens.getInstanceOrThrow() + var path = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow() .appInfo.websiteBasePath.appendPath(new NormalisedURLPath__default$1.default("/")) .getAsStringDangerous(); routes.push( @@ -2065,15 +2094,16 @@ var UI = /** @class */ (function () { var recipeList = preBuiltUiClassList.map(function (r) { return r.getInstanceOrInitAndGetInstance(); }); - var path = superTokens.getCurrentNormalisedUrlPath().getAsStringDangerous(); + var path = genericComponentOverrideContext.getCurrentNormalisedUrlPath().getAsStringDangerous(); var isAuthPage = - path === superTokens.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous(); + path === + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous(); if (isAuthPage) { - return !superTokens.SuperTokens.getInstanceOrThrow().disableAuthRoute; + return !genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().disableAuthRoute; } return ( RecipeRouter.getMatchingComponentForRouteAndRecipeIdFromPreBuiltUIList( - superTokens.getCurrentNormalisedUrlPath(), + genericComponentOverrideContext.getCurrentNormalisedUrlPath(), recipeList, true ) !== undefined @@ -2085,7 +2115,7 @@ var UI = /** @class */ (function () { }); return jsxRuntime.jsx(RoutingComponent, { getReactRouterDomWithCustomHistory: UI.getReactRouterDomWithCustomHistory, - path: superTokens.getCurrentNormalisedUrlPath().getAsStringDangerous(), + path: genericComponentOverrideContext.getCurrentNormalisedUrlPath().getAsStringDangerous(), preBuiltUIList: recipeList, }); }; @@ -2095,7 +2125,7 @@ var UI = /** @class */ (function () { UI.AuthPage = function (props) { return jsxRuntime.jsx( AuthPageWrapper, - superTokens.__assign({}, props, { + genericComponentOverrideContext.__assign({}, props, { preBuiltUIList: props.preBuiltUIList.map(function (r) { return r.getInstanceOrInitAndGetInstance(); }), @@ -2117,7 +2147,7 @@ var AuthPage = UI.AuthPage; var SessionAuth = function (_a) { var _b; var children = _a.children, - props = superTokens.__rest(_a, ["children"]); + props = genericComponentOverrideContext.__rest(_a, ["children"]); var requireAuth = React.useRef(props.requireAuth); if (props.requireAuth !== requireAuth.current) { throw new Error( @@ -2145,19 +2175,19 @@ var SessionAuth = function (_a) { // the app is using react-router-dom but added a session auth outside of the router. } var userContext = useUserContext(); - var rethrowInRender = superTokens.useRethrowInRender(); + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); var redirectToLogin = React.useCallback(function () { - void superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ + void genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: navigate, userContext: userContext, redirectBack: true, }); }, []); var buildContext = React.useCallback(function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var sessionExists, invalidClaims, err_1, err_2; var _a; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: if (session.current === undefined) { @@ -2277,9 +2307,9 @@ var SessionAuth = function (_a) { }, []); var setInitialContextAndMaybeRedirect = React.useCallback( function (toSetContext) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var failureRedirectInfo, err_3; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: if (context.loading === false) { @@ -2317,7 +2347,7 @@ var SessionAuth = function (_a) { case 3: return [ 4 /*yield*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToUrl( + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToUrl( failureRedirectInfo.redirectPath, navigate ), @@ -2342,9 +2372,10 @@ var SessionAuth = function (_a) { return [ 2 /*return*/, setContext( - superTokens.__assign(superTokens.__assign({}, toSetContext), { - accessDeniedValidatorError: failureRedirectInfo.failedClaim, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, toSetContext), + { accessDeniedValidatorError: failureRedirectInfo.failedClaim } + ) ), ]; } @@ -2367,14 +2398,14 @@ var SessionAuth = function (_a) { navigate, ] ); - superTokens.useOnMountAPICall(buildContext, setInitialContextAndMaybeRedirect); + genericComponentOverrideContext.useOnMountAPICall(buildContext, setInitialContextAndMaybeRedirect); // subscribe to events on mount React.useEffect( function () { function onHandleEvent(event) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var _a, invalidClaims, failureRedirectInfo, err_4; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: _a = event.action; @@ -2426,16 +2457,16 @@ var SessionAuth = function (_a) { ) return [3 /*break*/, 5]; setContext( - superTokens.__assign(superTokens.__assign({}, event.sessionContext), { - loading: false, - invalidClaims: invalidClaims, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, event.sessionContext), + { loading: false, invalidClaims: invalidClaims } + ) ); return [3 /*break*/, 7]; case 5: return [ 4 /*yield*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToUrl( + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToUrl( failureRedirectInfo.redirectPath, navigate ), @@ -2460,37 +2491,40 @@ var SessionAuth = function (_a) { return [ 2 /*return*/, setContext( - superTokens.__assign(superTokens.__assign({}, event.sessionContext), { - loading: false, - invalidClaims: invalidClaims, - accessDeniedValidatorError: failureRedirectInfo.failedClaim, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, event.sessionContext), + { + loading: false, + invalidClaims: invalidClaims, + accessDeniedValidatorError: failureRedirectInfo.failedClaim, + } + ) ), ]; } _b.label = 10; case 10: setContext( - superTokens.__assign(superTokens.__assign({}, event.sessionContext), { - loading: false, - invalidClaims: invalidClaims, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, event.sessionContext), + { loading: false, invalidClaims: invalidClaims } + ) ); return [2 /*return*/]; case 11: setContext( - superTokens.__assign(superTokens.__assign({}, event.sessionContext), { - loading: false, - invalidClaims: [], - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, event.sessionContext), + { loading: false, invalidClaims: [] } + ) ); return [2 /*return*/]; case 12: setContext( - superTokens.__assign(superTokens.__assign({}, event.sessionContext), { - loading: false, - invalidClaims: [], - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, event.sessionContext), + { loading: false, invalidClaims: [] } + ) ); if (props.onSessionExpired !== undefined) { props.onSessionExpired(); @@ -2527,14 +2561,17 @@ var SessionAuth = function (_a) { validationError: context.accessDeniedValidatorError, }); } - return jsxRuntime.jsx(SessionContext.Provider, superTokens.__assign({ value: context }, { children: children })); + return jsxRuntime.jsx( + SessionContext.Provider, + genericComponentOverrideContext.__assign({ value: context }, { children: children }) + ); }; var SessionAuthWrapper = function (props) { return jsxRuntime.jsx( UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, - { children: jsxRuntime.jsx(SessionAuth, superTokens.__assign({}, props)) } + { children: jsxRuntime.jsx(SessionAuth, genericComponentOverrideContext.__assign({}, props)) } ) ); }; @@ -2542,7 +2579,7 @@ var SessionAuthWrapper = function (props) { var SuperTokensWrapper = function (props) { return jsxRuntime.jsx( SessionAuthWrapper, - superTokens.__assign({}, props, { requireAuth: false, doRedirection: false }) + genericComponentOverrideContext.__assign({}, props, { requireAuth: false, doRedirection: false }) ); }; @@ -2566,34 +2603,37 @@ var SuperTokensWrapper = function (props) { var SuperTokensAPIWrapper = /** @class */ (function () { function SuperTokensAPIWrapper() {} SuperTokensAPIWrapper.init = function (config) { - superTokens.SuperTokens.init(config); + genericComponentOverrideContext.SuperTokens.init(config); }; SuperTokensAPIWrapper.changeLanguage = function (language) { - return superTokens.SuperTokens.getInstanceOrThrow().changeLanguage(language); + return genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().changeLanguage(language); }; SuperTokensAPIWrapper.loadTranslation = function (store) { - return superTokens.SuperTokens.getInstanceOrThrow().loadTranslation(store); + return genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().loadTranslation(store); }; var _a; _a = SuperTokensAPIWrapper; SuperTokensAPIWrapper.SuperTokensWrapper = SuperTokensWrapper; SuperTokensAPIWrapper.redirectToAuth = function (options) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var _b; - return superTokens.__generator(_a, function (_c) { + return genericComponentOverrideContext.__generator(_a, function (_c) { return [ 2 /*return*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth( - superTokens.__assign(superTokens.__assign({}, options), { - redirectBack: - (_b = options === null || options === void 0 ? void 0 : options.redirectBack) !== - null && _b !== void 0 - ? _b - : true, - userContext: superTokens.getNormalisedUserContext( - options === null || options === void 0 ? void 0 : options.userContext - ), - }) + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth( + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, options), + { + redirectBack: + (_b = options === null || options === void 0 ? void 0 : options.redirectBack) !== + null && _b !== void 0 + ? _b + : true, + userContext: genericComponentOverrideContext.getNormalisedUserContext( + options === null || options === void 0 ? void 0 : options.userContext + ), + } + ) ), ]; }); @@ -2615,6 +2655,7 @@ exports.AuthPageHeader = AuthPageHeader; exports.AuthPageTheme = AuthPageTheme; exports.BackButton = BackButton; exports.ComponentOverrideContext = ComponentOverrideContext; +exports.DynamicLoginMethodsSpinner = DynamicLoginMethodsSpinner; exports.FeatureWrapper = FeatureWrapper; exports.GeneralError = GeneralError; exports.Provider = Provider; diff --git a/lib/build/multifactorauth-shared.js b/lib/build/multifactorauth-shared.js index a2ee8cc66..9da088995 100644 --- a/lib/build/multifactorauth-shared.js +++ b/lib/build/multifactorauth-shared.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var WebJSSessionRecipe = require("supertokens-web-js/recipe/session"); var recipe = require("./oauth2provider-shared.js"); var index = require("./recipeModule-shared.js"); @@ -39,7 +39,7 @@ function normaliseSessionConfig(config) { var accessDeniedScreen = { style: accessDeniedScreenStyle, }; - var override = superTokens.__assign( + var override = genericComponentOverrideContext.__assign( { functions: function (originalImplementation) { return originalImplementation; @@ -47,20 +47,26 @@ function normaliseSessionConfig(config) { }, config.override ); - return superTokens.__assign(superTokens.__assign({}, superTokens.normaliseRecipeModuleConfig(config)), { - // TODO: ideally we'd get the default (or normalized) value from supertokens-website - invalidClaimStatusCode: (_c = config.invalidClaimStatusCode) !== null && _c !== void 0 ? _c : 403, - accessDeniedScreen: accessDeniedScreen, - override: override, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign( + {}, + genericComponentOverrideContext.normaliseRecipeModuleConfig(config) + ), + { + // TODO: ideally we'd get the default (or normalized) value from supertokens-website + invalidClaimStatusCode: (_c = config.invalidClaimStatusCode) !== null && _c !== void 0 ? _c : 403, + accessDeniedScreen: accessDeniedScreen, + override: override, + } + ); } var getFailureRedirectionInfo = function (_a) { var invalidClaims = _a.invalidClaims, overrideGlobalClaimValidators = _a.overrideGlobalClaimValidators, userContext = _a.userContext; - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var globalValidators, failedClaim, _loop_1, _i, globalValidators_1, validator, state_1; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: globalValidators = utils.getGlobalClaimValidators({ @@ -70,7 +76,7 @@ var getFailureRedirectionInfo = function (_a) { failedClaim = undefined; _loop_1 = function (validator) { var claim, failureCallback, redirectPath; - return superTokens.__generator(this, function (_c) { + return genericComponentOverrideContext.__generator(this, function (_c) { switch (_c.label) { case 0: claim = invalidClaims.find(function (c) { @@ -143,7 +149,7 @@ function validateAndCompareOnFailureRedirectionURLToCurrent(redirectURL) { if (!redirectURL.startsWith("/")) { throw new Error("onFailureRedirectionURL returned a relative url: ".concat(redirectURL)); } - var appInfo = superTokens.SuperTokens.getInstanceOrThrow().appInfo; + var appInfo = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().appInfo; // otherwise we prepend the websiteDomain fullRedirectURL = "".concat(appInfo.websiteDomain.getAsStringDangerous()).concat(redirectURL); } @@ -165,7 +171,7 @@ function validateAndCompareOnFailureRedirectionURLToCurrent(redirectURL) { * under the License. */ var Session = /** @class */ (function (_super) { - superTokens.__extends(Session, _super); + genericComponentOverrideContext.__extends(Session, _super); function Session(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = WebJSSessionRecipe__default.default; @@ -184,8 +190,8 @@ var Session = /** @class */ (function (_super) { return _this.webJSRecipe.getClaimValue(input); }; _this.getAccessTokenPayloadSecurely = function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [2 /*return*/, this.webJSRecipe.getAccessTokenPayloadSecurely(input)]; }); }); @@ -197,8 +203,8 @@ var Session = /** @class */ (function (_super) { return _this.webJSRecipe.signOut(input); }; _this.attemptRefreshingSession = function () { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [2 /*return*/, this.webJSRecipe.attemptRefreshingSession()]; }); }); @@ -229,12 +235,12 @@ var Session = /** @class */ (function (_super) { userContext, navigate ) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var invalidClaims, jsonContext, failureRedirectInfo, successContextStr, storedContext; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: - userContext = superTokens.getNormalisedUserContext(userContext); + userContext = genericComponentOverrideContext.getNormalisedUserContext(userContext); return [4 /*yield*/, this.doesSessionExist({ userContext: userContext })]; case 1: // First we check if there is an active session @@ -243,7 +249,7 @@ var Session = /** @class */ (function (_super) { // This can happen e.g.: if the user clicked on the email verification link in a browser without an active session return [ 2 /*return*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: navigate, redirectBack: false, userContext: userContext, @@ -261,7 +267,10 @@ var Session = /** @class */ (function (_super) { }); return [ 4 /*yield*/, - superTokens.setLocalStorage("supertokens-success-redirection-context", jsonContext), + genericComponentOverrideContext.setLocalStorage( + "supertokens-success-redirection-context", + jsonContext + ), ]; case 3: _a.sent(); @@ -292,7 +301,7 @@ var Session = /** @class */ (function (_super) { } return [ 2 /*return*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToUrl( + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToUrl( failureRedirectInfo.redirectPath, navigate ), @@ -303,7 +312,9 @@ var Session = /** @class */ (function (_super) { if (!(successRedirectContext === undefined)) return [3 /*break*/, 13]; return [ 4 /*yield*/, - superTokens.getLocalStorage("supertokens-success-redirection-context"), + genericComponentOverrideContext.getLocalStorage( + "supertokens-success-redirection-context" + ), ]; case 7: successContextStr = _a.sent(); @@ -321,7 +332,9 @@ var Session = /** @class */ (function (_super) { case 9: return [ 4 /*yield*/, - superTokens.removeFromLocalStorage("supertokens-success-redirection-context"), + genericComponentOverrideContext.removeFromLocalStorage( + "supertokens-success-redirection-context" + ), ]; case 10: _a.sent(); @@ -360,7 +373,7 @@ var Session = /** @class */ (function (_super) { } return [ 2 /*return*/, - superTokens.SuperTokens.getInstanceOrThrow().redirect( + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirect( successRedirectContext, navigate, {}, @@ -376,16 +389,16 @@ var Session = /** @class */ (function (_super) { * @returns "/" */ _this.getDefaultRedirectionURL = function () { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [2 /*return*/, "/"]; }); }); }; _this.notifyListeners = function (event) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var sessionContext; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.getSessionContext(event)]; @@ -394,7 +407,9 @@ var Session = /** @class */ (function (_super) { // We copy this.eventListeners into a new array to "freeze" it for the loop // We do this to avoid an infinite loop in case one of the listeners causes a new listener to be added (e.g.: through re-rendering) Array.from(this.eventListeners).forEach(function (listener) { - return listener(superTokens.__assign({ sessionContext: sessionContext }, event)); + return listener( + genericComponentOverrideContext.__assign({ sessionContext: sessionContext }, event) + ); }); return [2 /*return*/]; } @@ -406,9 +421,9 @@ var Session = /** @class */ (function (_super) { Session.prototype.getSessionContext = function (_a) { var action = _a.action, userContext = _a.userContext; - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var _b, userId, accessTokenPayload; - return superTokens.__generator(this, function (_c) { + return genericComponentOverrideContext.__generator(this, function (_c) { switch (_c.label) { case 0: if ( @@ -468,42 +483,54 @@ var Session = /** @class */ (function (_super) { recipeID: Session.RECIPE_ID, authReact: function (appInfo) { Session.instance = new Session( - superTokens.__assign(superTokens.__assign({}, normalisedConfig), { - appInfo: appInfo, - recipeId: Session.RECIPE_ID, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { appInfo: appInfo, recipeId: Session.RECIPE_ID } + ) ); return Session.instance; }, webJS: WebJSSessionRecipe__default.default.init( - superTokens.__assign(superTokens.__assign({}, normalisedConfig), { - onHandleEvent: function (event) { - if (normalisedConfig.onHandleEvent !== undefined) { - normalisedConfig.onHandleEvent(event); - } - void Session.getInstanceOrThrow().notifyListeners(event); - }, - preAPIHook: function (context) { - return superTokens.__awaiter(_this, void 0, void 0, function () { - var response; - return superTokens.__generator(this, function (_a) { - response = superTokens.__assign(superTokens.__assign({}, context), { - requestInit: superTokens.__assign(superTokens.__assign({}, context.requestInit), { - headers: superTokens.__assign( - superTokens.__assign({}, context.requestInit.headers), - { rid: Session.RECIPE_ID } - ), - }), + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { + onHandleEvent: function (event) { + if (normalisedConfig.onHandleEvent !== undefined) { + normalisedConfig.onHandleEvent(event); + } + void Session.getInstanceOrThrow().notifyListeners(event); + }, + preAPIHook: function (context) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + var response; + return genericComponentOverrideContext.__generator(this, function (_a) { + response = genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, context), + { + requestInit: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, context.requestInit), + { + headers: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign( + {}, + context.requestInit.headers + ), + { rid: Session.RECIPE_ID } + ), + } + ), + } + ); + if (normalisedConfig.preAPIHook === undefined) { + return [2 /*return*/, response]; + } else { + return [2 /*return*/, normalisedConfig.preAPIHook(context)]; + } }); - if (normalisedConfig.preAPIHook === undefined) { - return [2 /*return*/, response]; - } else { - return [2 /*return*/, normalisedConfig.preAPIHook(context)]; - } }); - }); - }, - }) + }, + } + ) ), }; }; @@ -519,7 +546,7 @@ var Session = /** @class */ (function (_super) { return Session.instance; }; Session.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } Session.instance = undefined; diff --git a/lib/build/multifactorauth-shared2.js b/lib/build/multifactorauth-shared2.js index c42157764..4eb51565b 100644 --- a/lib/build/multifactorauth-shared2.js +++ b/lib/build/multifactorauth-shared2.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var MultiFactorAuthWebJS = require("supertokens-web-js/recipe/multifactorauth"); var utils = require("supertokens-web-js/utils"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); @@ -42,11 +42,11 @@ var getFunctionOverrides = function ( _onHandleEvent ) { return function (originalImp) { - return superTokens.__assign(superTokens.__assign({}, originalImp), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImp), { resyncSessionAndFetchMFAInfo: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var stWindow, stored, parsed, unlock, stored_1, parsed, val; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: stWindow = windowHandler.WindowHandlerReference.getReferenceOrThrow(); @@ -63,11 +63,14 @@ var getFunctionOverrides = function ( if (parsed.t > Date.now() - 1000) { return [ 2 /*return*/, - superTokens.__assign(superTokens.__assign({}, parsed.v), { - // Adding a fake response is not great, but we do want to add something and this way it's detectable by the app - // so they could even add specific handling for it if they preferred. - fetchResponse: new Response(null, { status: 304 }), - }), + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, parsed.v), + { + // Adding a fake response is not great, but we do want to add something and this way it's detectable by the app + // so they could even add specific handling for it if they preferred. + fetchResponse: new Response(null, { status: 304 }), + } + ), ]; } } @@ -93,11 +96,14 @@ var getFunctionOverrides = function ( if (parsed.t > Date.now() - 1000) { return [ 2 /*return*/, - superTokens.__assign(superTokens.__assign({}, parsed.v), { - // Adding a fake response is not great, but we do want to add something and this way it's detectable by the app - // so they could even add specific handling for it if they preferred. - fetchResponse: new Response(null, { status: 304 }), - }), + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, parsed.v), + { + // Adding a fake response is not great, but we do want to add something and this way it's detectable by the app + // so they could even add specific handling for it if they preferred. + fetchResponse: new Response(null, { status: 304 }), + } + ), ]; } } @@ -155,9 +161,9 @@ var MultiFactorAuthClaimClass = /** @class */ (function () { var defaultOnFailureRedirection = function (_a) { var reason = _a.reason, userContext = _a.userContext; - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var recipe, nextFactorOptions, availableFactors, mfaInfo_1, availableFactors; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: recipe = getRecipe(); @@ -166,7 +172,7 @@ var MultiFactorAuthClaimClass = /** @class */ (function () { reason.allOfInAnyOrder || (reason.factorId !== undefined ? [reason.factorId] : undefined); if (!(nextFactorOptions !== undefined)) return [3 /*break*/, 1]; - superTokens.logDebugMessage( + genericComponentOverrideContext.logDebugMessage( "Redirecting to MFA on next array from validation failure: " + nextFactorOptions.join(", ") ); @@ -211,7 +217,7 @@ var MultiFactorAuthClaimClass = /** @class */ (function () { .map(function (v) { return v.id; }); - superTokens.logDebugMessage( + genericComponentOverrideContext.logDebugMessage( "Redirecting to MFA on next array from backend: " + availableFactors.join(", ") ); if (availableFactors.length === 1) { @@ -233,52 +239,67 @@ var MultiFactorAuthClaimClass = /** @class */ (function () { }); }); }; - this.validators = superTokens.__assign(superTokens.__assign({}, this.webJSClaim.validators), { - hasCompletedMFARequirementsForAuth: function (doRedirection, showAccessDeniedOnFailure) { - if (doRedirection === void 0) { - doRedirection = true; - } - if (showAccessDeniedOnFailure === void 0) { - showAccessDeniedOnFailure = true; - } - var orig = _this.webJSClaim.validators.hasCompletedMFARequirementsForAuth(); - return superTokens.__assign(superTokens.__assign({}, orig), { - showAccessDeniedOnFailure: showAccessDeniedOnFailure, - onFailureRedirection: - onFailureRedirection !== null && onFailureRedirection !== void 0 - ? onFailureRedirection - : function (_a) { - var reason = _a.reason, - userContext = _a.userContext; - return doRedirection - ? defaultOnFailureRedirection({ reason: reason, userContext: userContext }) - : undefined; - }, - }); - }, - hasCompletedFactors: function (requirements, doRedirection, showAccessDeniedOnFailure) { - if (doRedirection === void 0) { - doRedirection = true; - } - if (showAccessDeniedOnFailure === void 0) { - showAccessDeniedOnFailure = true; - } - var orig = _this.webJSClaim.validators.hasCompletedFactors(requirements); - return superTokens.__assign(superTokens.__assign({}, orig), { - showAccessDeniedOnFailure: showAccessDeniedOnFailure, - onFailureRedirection: - onFailureRedirection !== null && onFailureRedirection !== void 0 - ? onFailureRedirection - : function (_a) { - var reason = _a.reason, - userContext = _a.userContext; - return doRedirection - ? defaultOnFailureRedirection({ reason: reason, userContext: userContext }) - : undefined; - }, - }); - }, - }); + this.validators = genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, this.webJSClaim.validators), + { + hasCompletedMFARequirementsForAuth: function (doRedirection, showAccessDeniedOnFailure) { + if (doRedirection === void 0) { + doRedirection = true; + } + if (showAccessDeniedOnFailure === void 0) { + showAccessDeniedOnFailure = true; + } + var orig = _this.webJSClaim.validators.hasCompletedMFARequirementsForAuth(); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, orig), + { + showAccessDeniedOnFailure: showAccessDeniedOnFailure, + onFailureRedirection: + onFailureRedirection !== null && onFailureRedirection !== void 0 + ? onFailureRedirection + : function (_a) { + var reason = _a.reason, + userContext = _a.userContext; + return doRedirection + ? defaultOnFailureRedirection({ + reason: reason, + userContext: userContext, + }) + : undefined; + }, + } + ); + }, + hasCompletedFactors: function (requirements, doRedirection, showAccessDeniedOnFailure) { + if (doRedirection === void 0) { + doRedirection = true; + } + if (showAccessDeniedOnFailure === void 0) { + showAccessDeniedOnFailure = true; + } + var orig = _this.webJSClaim.validators.hasCompletedFactors(requirements); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, orig), + { + showAccessDeniedOnFailure: showAccessDeniedOnFailure, + onFailureRedirection: + onFailureRedirection !== null && onFailureRedirection !== void 0 + ? onFailureRedirection + : function (_a) { + var reason = _a.reason, + userContext = _a.userContext; + return doRedirection + ? defaultOnFailureRedirection({ + reason: reason, + userContext: userContext, + }) + : undefined; + }, + } + ); + }, + } + ); } return MultiFactorAuthClaimClass; })(); @@ -303,7 +324,7 @@ function normaliseMultiFactorAuthFeature(config) { config = {}; } var disableDefaultUI = config.disableDefaultUI === true; - var override = superTokens.__assign( + var override = genericComponentOverrideContext.__assign( { functions: function (originalImplementation) { return originalImplementation; @@ -311,15 +332,21 @@ function normaliseMultiFactorAuthFeature(config) { }, config.override ); - return superTokens.__assign(superTokens.__assign({}, superTokens.normaliseRecipeModuleConfig(config)), { - disableDefaultUI: disableDefaultUI, - firstFactors: config === null || config === void 0 ? void 0 : config.firstFactors, - getSecondaryFactorInfo: function (orig) { - return orig; - }, - factorChooserScreen: (_a = config.factorChooserScreen) !== null && _a !== void 0 ? _a : {}, - override: override, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign( + {}, + genericComponentOverrideContext.normaliseRecipeModuleConfig(config) + ), + { + disableDefaultUI: disableDefaultUI, + firstFactors: config === null || config === void 0 ? void 0 : config.firstFactors, + getSecondaryFactorInfo: function (orig) { + return orig; + }, + factorChooserScreen: (_a = config.factorChooserScreen) !== null && _a !== void 0 ? _a : {}, + override: override, + } + ); } function getAvailableFactors(factors, nextArrayQueryParam, recipe, userContext) { // There are 3 cases here: @@ -351,7 +378,7 @@ function getAvailableFactors(factors, nextArrayQueryParam, recipe, userContext) * under the License. */ var MultiFactorAuth = /** @class */ (function (_super) { - superTokens.__extends(MultiFactorAuth, _super); + genericComponentOverrideContext.__extends(MultiFactorAuth, _super); function MultiFactorAuth(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = MultiFactorAuthWebJS__default.default; @@ -361,9 +388,9 @@ var MultiFactorAuth = /** @class */ (function (_super) { _this.recipeID = MultiFactorAuth.RECIPE_ID; _this.secondaryFactors = []; _this.getDefaultRedirectionURL = function (context, userContext) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var chooserPath, url, redirectInfo, url; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { if (context.action === "FACTOR_CHOOSER") { chooserPath = new NormalisedURLPath__default.default(DEFAULT_FACTOR_CHOOSER_PATH); url = this.config.appInfo.websiteBasePath.appendPath(chooserPath).getAsStringDangerous(); @@ -411,24 +438,27 @@ var MultiFactorAuth = /** @class */ (function (_super) { recipeID: MultiFactorAuth.RECIPE_ID, authReact: function (appInfo) { MultiFactorAuth.instance = new MultiFactorAuth( - superTokens.__assign(superTokens.__assign({}, normalisedConfig), { - appInfo: appInfo, - recipeId: MultiFactorAuth.RECIPE_ID, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { appInfo: appInfo, recipeId: MultiFactorAuth.RECIPE_ID } + ) ); return MultiFactorAuth.instance; }, webJS: MultiFactorAuthWebJS__default.default.init( - superTokens.__assign(superTokens.__assign({}, normalisedConfig), { - override: { - functions: function (originalImpl, builder) { - var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); - builder.override(functions); - builder.override(normalisedConfig.override.functions); - return originalImpl; + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { + override: { + functions: function (originalImpl, builder) { + var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); + builder.override(functions); + builder.override(normalisedConfig.override.functions); + return originalImpl; + }, }, - }, - }) + } + ) ), }; }; @@ -440,15 +470,15 @@ var MultiFactorAuth = /** @class */ (function (_super) { var error = "No instance of MultiFactorAuth found. Make sure to call the MultiFactorAuth.init method."; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { - error = error + superTokens.SSR_ERROR; + error = error + genericComponentOverrideContext.SSR_ERROR; } throw Error(error); } return MultiFactorAuth.instance; }; MultiFactorAuth.prototype.addMFAFactors = function (secondaryFactors) { - this.secondaryFactors = superTokens.__spreadArray( - superTokens.__spreadArray( + this.secondaryFactors = genericComponentOverrideContext.__spreadArray( + genericComponentOverrideContext.__spreadArray( [], this.secondaryFactors.filter(function (factor) { return secondaryFactors.every(function (newFactor) { @@ -474,9 +504,9 @@ var MultiFactorAuth = /** @class */ (function (_super) { if (redirectBack === void 0) { redirectBack = false; } - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var url, redirectUrl, redirectUrl; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: return [ @@ -503,17 +533,25 @@ var MultiFactorAuth = /** @class */ (function (_super) { // and is on a custom path that has a redirectToPath set to pathX when calling this function, // then we keep that in the query params if redirectBack is set to false. if (redirectBack) { - redirectUrl = superTokens.getCurrentNormalisedUrlPathWithQueryParamsAndFragments(); - url = superTokens.appendQueryParamsToURL(url, { redirectToPath: redirectUrl }); + redirectUrl = + genericComponentOverrideContext.getCurrentNormalisedUrlPathWithQueryParamsAndFragments(); + url = genericComponentOverrideContext.appendQueryParamsToURL(url, { + redirectToPath: redirectUrl, + }); } else { - redirectUrl = superTokens.getRedirectToPathFromURL(); + redirectUrl = genericComponentOverrideContext.getRedirectToPathFromURL(); if (redirectUrl) { - url = superTokens.appendQueryParamsToURL(url, { redirectToPath: redirectUrl }); + url = genericComponentOverrideContext.appendQueryParamsToURL(url, { + redirectToPath: redirectUrl, + }); } } return [ 2 /*return*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToUrl(url, navigate), + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToUrl( + url, + navigate + ), ]; } }); @@ -531,9 +569,9 @@ var MultiFactorAuth = /** @class */ (function (_super) { if (nextFactorOptions === void 0) { nextFactorOptions = []; } - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var url, redirectUrl, redirectUrl; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: return [ @@ -549,17 +587,25 @@ var MultiFactorAuth = /** @class */ (function (_super) { return [2 /*return*/]; } if (redirectBack) { - redirectUrl = superTokens.getCurrentNormalisedUrlPathWithQueryParamsAndFragments(); - url = superTokens.appendQueryParamsToURL(url, { redirectToPath: redirectUrl }); + redirectUrl = + genericComponentOverrideContext.getCurrentNormalisedUrlPathWithQueryParamsAndFragments(); + url = genericComponentOverrideContext.appendQueryParamsToURL(url, { + redirectToPath: redirectUrl, + }); } else { - redirectUrl = superTokens.getRedirectToPathFromURL(); + redirectUrl = genericComponentOverrideContext.getRedirectToPathFromURL(); if (redirectUrl) { - url = superTokens.appendQueryParamsToURL(url, { redirectToPath: redirectUrl }); + url = genericComponentOverrideContext.appendQueryParamsToURL(url, { + redirectToPath: redirectUrl, + }); } } return [ 2 /*return*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToUrl(url, navigate), + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToUrl( + url, + navigate + ), ]; } }); @@ -569,7 +615,7 @@ var MultiFactorAuth = /** @class */ (function (_super) { * Tests methods. */ MultiFactorAuth.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } MultiFactorAuth.instance = undefined; @@ -583,8 +629,8 @@ var MultiFactorAuth = /** @class */ (function (_super) { return MultiFactorAuth.getInstanceOrThrow(); }, function (context, userContext) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - return superTokens.__generator(_a, function (_b) { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(_a, function (_b) { switch (_b.label) { case 0: return [4 /*yield*/, this.getInstanceOrThrow().getRedirectUrl(context, userContext)]; diff --git a/lib/build/multifactorauth.js b/lib/build/multifactorauth.js index d797015e1..e1fc17566 100644 --- a/lib/build/multifactorauth.js +++ b/lib/build/multifactorauth.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var componentOverrideContext = require("./multifactorauth-shared3.js"); var recipe = require("./multifactorauth-shared2.js"); var types = require("./multifactorauth-shared.js"); @@ -15,7 +15,6 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); -require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); @@ -45,8 +44,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.resyncSessionAndFetchMFAInfo = function (input) { return recipe.MultiFactorAuth.getInstanceOrThrow().webJSRecipe.resyncSessionAndFetchMFAInfo( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) diff --git a/lib/build/multifactorauthprebuiltui.js b/lib/build/multifactorauthprebuiltui.js index 3aa6244e1..fb11e2556 100644 --- a/lib/build/multifactorauthprebuiltui.js +++ b/lib/build/multifactorauthprebuiltui.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var jsxRuntime = require("react/jsx-runtime"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); var uiEntry = require("./index2.js"); @@ -21,7 +21,6 @@ require("supertokens-web-js/utils"); require("supertokens-web-js/utils/normalisedURLDomain"); require("react-dom"); require("./multitenancy-shared.js"); -require("./genericComponentOverrideContext.js"); require("./oauth2provider-shared.js"); require("supertokens-web-js/recipe/oauth2provider"); require("./recipeModule-shared.js"); @@ -91,12 +90,12 @@ var FactorChooserFooter = uiEntry.withOverride("MFAFactorChooserFooter", functio var t = translationContext.useTranslation(); return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row factorChooserFooter" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: logout }, { children: [ @@ -117,12 +116,12 @@ var FactorChooserHeader = uiEntry.withOverride("MFAFactorChooserHeader", functio var t = translationContext.useTranslation(); return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row factorChooserHeader" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle withBackButton" }, { children: [ @@ -153,30 +152,33 @@ var FactorOption = uiEntry.withOverride("MFAFactorOption", function MFAFactorOpt var t = translationContext.useTranslation(); return jsxRuntime.jsxs( "a", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "factorChooserOption ".concat(id), onClick: onClick }, { children: [ jsxRuntime.jsxs( "div", - superTokens.__assign({ "data-supertokens": "factorLogo" }, { children: [" ", logo({})] }) + genericComponentOverrideContext.__assign( + { "data-supertokens": "factorLogo" }, + { children: [" ", logo({})] } + ) ), jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "factorOptionText" }, { children: [ jsxRuntime.jsx( "h6", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "factorName" }, { children: t(name) } ) ), jsxRuntime.jsx( "p", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "factorDescription" }, { children: t(description) } ) @@ -196,7 +198,7 @@ var FactorList = uiEntry.withOverride("MFAFactorList", function MFAFactorList(_a navigateToFactor = _a.navigateToFactor; return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row factorChooserList" }, { children: availableFactors.map(function (factor) { @@ -229,7 +231,7 @@ function FactorChooserTheme(props) { } return jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container mfa" }, { children: [ @@ -249,16 +251,16 @@ function FactorChooserTheme(props) { ); } function FactorChooserThemeWrapper(props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [ @@ -267,7 +269,12 @@ function FactorChooserThemeWrapper(props) { props.config.factorChooserScreen.style, ], }, - { children: jsxRuntime.jsx(FactorChooserTheme, superTokens.__assign({}, props)) } + { + children: jsxRuntime.jsx( + FactorChooserTheme, + genericComponentOverrideContext.__assign({}, props) + ), + } ) ), } @@ -276,20 +283,23 @@ function FactorChooserThemeWrapper(props) { } var defaultTranslationsMultiFactorAuth = { - en: superTokens.__assign(superTokens.__assign({}, uiEntry.defaultTranslationsCommon.en), { - MULTI_FACTOR_CHOOSER_HEADER_TITLE: "Please select a factor", - MULTI_FACTOR_AUTH_LOGOUT: "Log out", - PWLESS_MFA_OTP_PHONE_NAME: "SMS based OTP", - PWLESS_MFA_OTP_PHONE_DESCRIPTION: "Get an OTP code on your phone to complete the authentication request", - PWLESS_MFA_OTP_EMAIL_NAME: "Email based OTP", - PWLESS_MFA_OTP_EMAIL_DESCRIPTION: - "Get an OTP code on your email address to complete the authentication request", - TOTP_MFA_NAME: "TOTP", - TOTP_MFA_DESCRIPTION: "Use an authenticator app to complete the authentication request", - MFA_NO_AVAILABLE_OPTIONS: "You have no available secondary factors.", - MFA_NO_AVAILABLE_OPTIONS_LOGIN: - "You have no available secondary factors and cannot complete the sign-in process. Please contact support.", - }), + en: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, uiEntry.defaultTranslationsCommon.en), + { + MULTI_FACTOR_CHOOSER_HEADER_TITLE: "Please select a factor", + MULTI_FACTOR_AUTH_LOGOUT: "Log out", + PWLESS_MFA_OTP_PHONE_NAME: "SMS based OTP", + PWLESS_MFA_OTP_PHONE_DESCRIPTION: "Get an OTP code on your phone to complete the authentication request", + PWLESS_MFA_OTP_EMAIL_NAME: "Email based OTP", + PWLESS_MFA_OTP_EMAIL_DESCRIPTION: + "Get an OTP code on your email address to complete the authentication request", + TOTP_MFA_NAME: "TOTP", + TOTP_MFA_DESCRIPTION: "Use an authenticator app to complete the authentication request", + MFA_NO_AVAILABLE_OPTIONS: "You have no available secondary factors.", + MFA_NO_AVAILABLE_OPTIONS_LOGIN: + "You have no available secondary factors and cannot complete the sign-in process. Please contact support.", + } + ), }; var FactorChooser$1 = function (props) { @@ -303,11 +313,12 @@ var FactorChooser$1 = function (props) { userContext = props.userContext; } var recipeComponentOverrides = props.useComponentOverrides(); - var nextQueryParam = (_a = superTokens.getQueryParams("n")) !== null && _a !== void 0 ? _a : undefined; + var nextQueryParam = + (_a = genericComponentOverrideContext.getQueryParams("n")) !== null && _a !== void 0 ? _a : undefined; var redirectToAuthWithHistory = React.useCallback( function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -325,8 +336,8 @@ var FactorChooser$1 = function (props) { ); var fetchMFAInfo = React.useCallback( function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, props.recipe.webJSRecipe.resyncSessionAndFetchMFAInfo({ userContext: userContext }), @@ -338,8 +349,8 @@ var FactorChooser$1 = function (props) { ); var checkMFAInfo = React.useCallback( function (mfaInfo) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { setMFAInfo({ factors: mfaInfo.factors, phoneNumbers: mfaInfo.phoneNumbers, @@ -353,8 +364,8 @@ var FactorChooser$1 = function (props) { ); var handleError = React.useCallback( function (err) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -377,7 +388,12 @@ var FactorChooser$1 = function (props) { }, [redirectToAuthWithHistory] ); - superTokens.useOnMountAPICall(fetchMFAInfo, checkMFAInfo, handleError, sessionContext.loading === false); + genericComponentOverrideContext.useOnMountAPICall( + fetchMFAInfo, + checkMFAInfo, + handleError, + sessionContext.loading === false + ); var navigateToFactor = React.useCallback( function (factorId) { props.recipe.config.onHandleEvent({ @@ -390,9 +406,9 @@ var FactorChooser$1 = function (props) { ); var signOut = React.useCallback( function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var session; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: session = types.Session.getInstanceOrThrow(); @@ -441,21 +457,24 @@ var FactorChooser$1 = function (props) { }; return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { - useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, + useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, defaultStore: defaultTranslationsMultiFactorAuth, }, { children: jsxRuntime.jsxs(React.Fragment, { children: [ props.children === undefined && - jsxRuntime.jsx(FactorChooserThemeWrapper, superTokens.__assign({}, childProps)), + jsxRuntime.jsx( + FactorChooserThemeWrapper, + genericComponentOverrideContext.__assign({}, childProps) + ), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { @@ -474,7 +493,7 @@ var FactorChooser$1 = function (props) { }; var MultiFactorAuthPreBuiltUI = /** @class */ (function (_super) { - superTokens.__extends(MultiFactorAuthPreBuiltUI, _super); + genericComponentOverrideContext.__extends(MultiFactorAuthPreBuiltUI, _super); function MultiFactorAuthPreBuiltUI(recipeInstance) { var _this = _super.call(this) || this; _this.recipeInstance = recipeInstance; @@ -490,7 +509,9 @@ var MultiFactorAuthPreBuiltUI = /** @class */ (function (_super) { new NormalisedURLPath__default.default(recipe.DEFAULT_FACTOR_CHOOSER_PATH) ); features[normalisedFullPath.getAsStringDangerous()] = { - matches: superTokens.matchRecipeIdUsingQueryParams(_this.recipeInstance.config.recipeId), + matches: genericComponentOverrideContext.matchRecipeIdUsingQueryParams( + _this.recipeInstance.config.recipeId + ), component: function (props) { return _this.getFeatureComponent("factorchooser", props, useComponentOverrides); }, @@ -510,12 +531,12 @@ var MultiFactorAuthPreBuiltUI = /** @class */ (function (_super) { } return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( session.SessionAuth, - superTokens.__assign( + genericComponentOverrideContext.__assign( { overrideGlobalClaimValidators: function () { return []; @@ -524,7 +545,7 @@ var MultiFactorAuthPreBuiltUI = /** @class */ (function (_super) { { children: jsxRuntime.jsx( FactorChooser$1, - superTokens.__assign( + genericComponentOverrideContext.__assign( { recipe: _this.recipeInstance, useComponentOverrides: useComponentOverrides, @@ -570,7 +591,7 @@ var MultiFactorAuthPreBuiltUI = /** @class */ (function (_super) { }; // For tests MultiFactorAuthPreBuiltUI.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } MultiFactorAuthPreBuiltUI.instance = undefined; diff --git a/lib/build/multitenancy.js b/lib/build/multitenancy.js index 7c2f0e43d..05284f52e 100644 --- a/lib/build/multitenancy.js +++ b/lib/build/multitenancy.js @@ -4,17 +4,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); var MultitenancyWebJS = require("supertokens-web-js/recipe/multitenancy"); var componentOverrideContext = require("./multitenancy-shared.js"); -var superTokens = require("./superTokens.js"); -require("./genericComponentOverrideContext.js"); -require("react/jsx-runtime"); -require("react"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); require("supertokens-web-js"); require("supertokens-web-js/utils/cookieHandler"); require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); require("supertokens-web-js/utils/windowHandler"); require("supertokens-web-js/utils"); +require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); +require("react/jsx-runtime"); /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. * @@ -33,7 +32,7 @@ require("supertokens-web-js/utils/normalisedURLPath"); var Wrapper = /** @class */ (function () { function Wrapper() {} Wrapper.init = function (config) { - return superTokens.Multitenancy.init(config); + return genericComponentOverrideContext.Multitenancy.init(config); }; Wrapper.AllowedDomainsClaim = MultitenancyWebJS.AllowedDomainsClaim; Wrapper.ComponentsOverrideProvider = componentOverrideContext.Provider; diff --git a/lib/build/oauth2provider-shared.js b/lib/build/oauth2provider-shared.js index 03b573a62..ce379f3d3 100644 --- a/lib/build/oauth2provider-shared.js +++ b/lib/build/oauth2provider-shared.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var OAuth2WebJS = require("supertokens-web-js/recipe/oauth2provider"); var index = require("./recipeModule-shared.js"); @@ -10,17 +10,55 @@ function _interopDefault(e) { var OAuth2WebJS__default = /*#__PURE__*/ _interopDefault(OAuth2WebJS); -function normaliseOAuth2Config(config) { - return superTokens.__assign(superTokens.__assign({}, superTokens.normaliseRecipeModuleConfig(config)), { - override: superTokens.__assign( - { - functions: function (originalImplementation) { - return originalImplementation; - }, +var getFunctionOverrides = function (onHandleEvent) { + return function (originalImp) { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImp), { + getLoginChallengeInfo: function (input) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + var response; + return genericComponentOverrideContext.__generator(this, function (_a) { + switch (_a.label) { + case 0: + return [4 /*yield*/, originalImp.getLoginChallengeInfo(input)]; + case 1: + response = _a.sent(); + onHandleEvent({ + action: "LOADED_LOGIN_CHALLENGE", + loginChallenge: input.loginChallenge, + loginInfo: response.info, + userContext: input.userContext, + }); + return [2 /*return*/, response]; + } + }); + }); }, - config === null || config === void 0 ? void 0 : config.override + }); + }; +}; + +function normaliseOAuth2Config(config) { + var _a; + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign( + {}, + genericComponentOverrideContext.normaliseRecipeModuleConfig(config) ), - }); + { + disableDefaultUI: + (_a = config === null || config === void 0 ? void 0 : config.disableDefaultUI) !== null && _a !== void 0 + ? _a + : false, + override: genericComponentOverrideContext.__assign( + { + functions: function (originalImplementation) { + return originalImplementation; + }, + }, + config === null || config === void 0 ? void 0 : config.override + ), + } + ); } /* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. @@ -41,7 +79,7 @@ function normaliseOAuth2Config(config) { * Class. */ var OAuth2Provider = /** @class */ (function (_super) { - superTokens.__extends(OAuth2Provider, _super); + genericComponentOverrideContext.__extends(OAuth2Provider, _super); function OAuth2Provider(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = OAuth2WebJS__default.default; @@ -57,14 +95,28 @@ var OAuth2Provider = /** @class */ (function (_super) { recipeID: OAuth2Provider.RECIPE_ID, authReact: function (appInfo) { OAuth2Provider.instance = new OAuth2Provider( - superTokens.__assign(superTokens.__assign({}, normalisedConfig), { - appInfo: appInfo, - recipeId: OAuth2Provider.RECIPE_ID, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { appInfo: appInfo, recipeId: OAuth2Provider.RECIPE_ID } + ) ); return OAuth2Provider.instance; }, - webJS: OAuth2WebJS__default.default.init(superTokens.__assign({}, normalisedConfig)), + webJS: OAuth2WebJS__default.default.init( + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { + override: { + functions: function (originalImpl, builder) { + var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); + builder.override(functions); + builder.override(normalisedConfig.override.functions); + return originalImpl; + }, + }, + } + ) + ), }; }; OAuth2Provider.getInstanceOrThrow = function () { @@ -74,7 +126,7 @@ var OAuth2Provider = /** @class */ (function (_super) { "See https://supertokens.io/docs/oauth2/quick-setup/frontend"; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { - error = error + superTokens.SSR_ERROR; + error = error + genericComponentOverrideContext.SSR_ERROR; } throw Error(error); } @@ -84,10 +136,10 @@ var OAuth2Provider = /** @class */ (function (_super) { return OAuth2Provider.instance; }; OAuth2Provider.prototype.getDefaultRedirectionURL = function (ctx) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var domain, basePath; - return superTokens.__generator(this, function (_a) { - if (ctx.action === "SUCCESS_OAUTH2") { + return genericComponentOverrideContext.__generator(this, function (_a) { + if (ctx.action === "SUCCESS_OAUTH2" || ctx.action === "CONTINUE_OAUTH2_AFTER_REFRESH") { domain = this.config.appInfo.apiDomain.getAsStringDangerous(); basePath = this.config.appInfo.apiBasePath.getAsStringDangerous(); return [ @@ -106,7 +158,7 @@ var OAuth2Provider = /** @class */ (function (_super) { * Tests methods. */ OAuth2Provider.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } OAuth2Provider.instance = undefined; diff --git a/lib/build/oauth2provider-shared2.js b/lib/build/oauth2provider-shared2.js new file mode 100644 index 000000000..bd3b554b5 --- /dev/null +++ b/lib/build/oauth2provider-shared2.js @@ -0,0 +1,10 @@ +"use strict"; + +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); + +var _a = genericComponentOverrideContext.createGenericComponentsOverrideContext(), + useContext = _a[0], + Provider = _a[1]; + +exports.Provider = Provider; +exports.useContext = useContext; diff --git a/lib/build/oauth2provider.js b/lib/build/oauth2provider.js index 7887de699..9be189f33 100644 --- a/lib/build/oauth2provider.js +++ b/lib/build/oauth2provider.js @@ -2,8 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); +var componentOverrideContext = require("./oauth2provider-shared2.js"); var recipe = require("./oauth2provider-shared.js"); -require("./superTokens.js"); +require("./genericComponentOverrideContext.js"); require("supertokens-web-js"); require("supertokens-web-js/utils/cookieHandler"); require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); @@ -13,6 +14,7 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); +require("react/jsx-runtime"); require("supertokens-web-js/recipe/oauth2provider"); require("./recipeModule-shared.js"); @@ -51,11 +53,13 @@ var Wrapper = /** @class */ (function () { Wrapper.getLoginChallengeInfo = function (input) { return recipe.OAuth2Provider.getInstanceOrThrow().webJSRecipe.getLoginChallengeInfo(input); }; + Wrapper.ComponentsOverrideProvider = componentOverrideContext.Provider; return Wrapper; })(); var init = Wrapper.init; var getLoginChallengeInfo = Wrapper.getLoginChallengeInfo; +exports.RecipeComponentsOverrideContextProvider = componentOverrideContext.Provider; exports.default = Wrapper; exports.getLoginChallengeInfo = getLoginChallengeInfo; exports.init = init; diff --git a/lib/build/oauth2providerprebuiltui.js b/lib/build/oauth2providerprebuiltui.js new file mode 100644 index 000000000..c81dbc606 --- /dev/null +++ b/lib/build/oauth2providerprebuiltui.js @@ -0,0 +1,261 @@ +"use strict"; + +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); +var jsxRuntime = require("react/jsx-runtime"); +var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); +var uiEntry = require("./index2.js"); +var session = require("./session.js"); +var componentOverrideContext = require("./oauth2provider-shared2.js"); +var React = require("react"); +var recipe = require("./oauth2provider-shared.js"); +require("supertokens-web-js"); +require("supertokens-web-js/utils/cookieHandler"); +require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); +require("supertokens-web-js/utils/windowHandler"); +require("supertokens-web-js/recipe/multitenancy"); +require("supertokens-web-js/utils"); +require("supertokens-web-js/utils/normalisedURLDomain"); +require("./translationContext.js"); +require("react-dom"); +require("./multitenancy-shared.js"); +require("./multifactorauth-shared2.js"); +require("supertokens-web-js/recipe/multifactorauth"); +require("supertokens-web-js/utils/sessionClaimValidatorStore"); +require("./recipeModule-shared.js"); +require("./multifactorauth-shared.js"); +require("supertokens-web-js/recipe/session"); +require("./authRecipe-shared.js"); +require("supertokens-web-js/lib/build/normalisedURLPath"); +require("./session-shared.js"); +require("supertokens-web-js/recipe/oauth2provider"); + +function _interopDefault(e) { + return e && e.__esModule ? e : { default: e }; +} + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== "default") { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty( + n, + k, + d.get + ? d + : { + enumerable: true, + get: function () { + return e[k]; + }, + } + ); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +var NormalisedURLPath__default = /*#__PURE__*/ _interopDefault(NormalisedURLPath); +var React__namespace = /*#__PURE__*/ _interopNamespace(React); + +var defaultTranslationsOAuth2Provider = { + en: {}, +}; + +var TryRefreshPage$1 = function (props) { + var _a; + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); + var sessionContext = React.useContext(uiEntry.SessionContext); + var loginChallenge = + (_a = genericComponentOverrideContext.getQueryParams("loginChallenge")) !== null && _a !== void 0 + ? _a + : undefined; + var userContext = uiEntry.useUserContext(); + if (props.userContext !== undefined) { + userContext = props.userContext; + } + React__namespace.useEffect( + function () { + if (sessionContext.loading === false) { + void props.recipe + .redirect( + { + action: "CONTINUE_OAUTH2_AFTER_REFRESH", + loginChallenge: loginChallenge !== null && loginChallenge !== void 0 ? loginChallenge : "", + recipeId: "oauth2provider", + }, + props.navigate, + {}, + userContext + ) + .catch(rethrowInRender); + } + }, + [loginChallenge, props.recipe, props.navigate, userContext, sessionContext] + ); + var childProps = { + config: props.recipe.config, + }; + return jsxRuntime.jsx( + uiEntry.FeatureWrapper, + genericComponentOverrideContext.__assign( + { + useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, + defaultStore: defaultTranslationsOAuth2Provider, + }, + { + children: jsxRuntime.jsxs(React.Fragment, { + children: [ + props.children === undefined && jsxRuntime.jsx(uiEntry.DynamicLoginMethodsSpinner, {}), + props.children && + React__namespace.Children.map(props.children, function (child) { + if (React__namespace.isValidElement(child)) { + return React__namespace.cloneElement(child, childProps); + } + return child; + }), + ], + }), + } + ) + ); +}; + +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +var DEFAULT_TRY_REFRESH_PATH = "/try-refresh"; + +var OAuth2ProviderPreBuiltUI = /** @class */ (function (_super) { + genericComponentOverrideContext.__extends(OAuth2ProviderPreBuiltUI, _super); + function OAuth2ProviderPreBuiltUI(recipeInstance) { + var _this = _super.call(this) || this; + _this.recipeInstance = recipeInstance; + _this.languageTranslations = defaultTranslationsOAuth2Provider; + // Instance methods + _this.getFeatures = function (useComponentOverrides) { + if (useComponentOverrides === void 0) { + useComponentOverrides = componentOverrideContext.useContext; + } + var features = {}; + if (_this.recipeInstance.config.disableDefaultUI !== true) { + var normalisedFullPath = _this.recipeInstance.config.appInfo.websiteBasePath.appendPath( + new NormalisedURLPath__default.default(DEFAULT_TRY_REFRESH_PATH) + ); + features[normalisedFullPath.getAsStringDangerous()] = { + matches: genericComponentOverrideContext.matchRecipeIdUsingQueryParams( + _this.recipeInstance.config.recipeId + ), + component: function (props) { + return _this.getFeatureComponent("try-refresh-page", props, useComponentOverrides); + }, + recipeID: recipe.OAuth2Provider.RECIPE_ID, + }; + } + return features; + }; + _this.getFeatureComponent = function ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _, + props, + useComponentOverrides + ) { + if (useComponentOverrides === void 0) { + useComponentOverrides = componentOverrideContext.useContext; + } + return jsxRuntime.jsx( + uiEntry.UserContextWrapper, + genericComponentOverrideContext.__assign( + { userContext: props.userContext }, + { + children: jsxRuntime.jsx( + session.SessionAuth, + genericComponentOverrideContext.__assign( + { + requireAuth: false, + overrideGlobalClaimValidators: function () { + return []; + }, + }, + { + children: jsxRuntime.jsx( + TryRefreshPage$1, + genericComponentOverrideContext.__assign( + { + recipe: _this.recipeInstance, + useComponentOverrides: useComponentOverrides, + }, + props + ) + ), + } + ) + ), + } + ) + ); + }; + return _this; + } + // Static methods + OAuth2ProviderPreBuiltUI.getInstanceOrInitAndGetInstance = function () { + if (OAuth2ProviderPreBuiltUI.instance === undefined) { + var recipeInstance = recipe.OAuth2Provider.getInstanceOrThrow(); + OAuth2ProviderPreBuiltUI.instance = new OAuth2ProviderPreBuiltUI(recipeInstance); + } + return OAuth2ProviderPreBuiltUI.instance; + }; + OAuth2ProviderPreBuiltUI.getFeatures = function (useComponentOverrides) { + if (useComponentOverrides === void 0) { + useComponentOverrides = componentOverrideContext.useContext; + } + return OAuth2ProviderPreBuiltUI.getInstanceOrInitAndGetInstance().getFeatures(useComponentOverrides); + }; + OAuth2ProviderPreBuiltUI.getFeatureComponent = function (componentName, props, useComponentOverrides) { + if (useComponentOverrides === void 0) { + useComponentOverrides = componentOverrideContext.useContext; + } + return OAuth2ProviderPreBuiltUI.getInstanceOrInitAndGetInstance().getFeatureComponent( + componentName, + props, + useComponentOverrides + ); + }; + OAuth2ProviderPreBuiltUI.prototype.getAuthComponents = function () { + return []; + }; + // For tests + OAuth2ProviderPreBuiltUI.reset = function () { + if (!genericComponentOverrideContext.isTest()) { + return; + } + OAuth2ProviderPreBuiltUI.instance = undefined; + return; + }; + OAuth2ProviderPreBuiltUI.TryRefreshPage = function (props) { + return OAuth2ProviderPreBuiltUI.getInstanceOrInitAndGetInstance().getFeatureComponent( + "try-refresh-page", + props + ); + }; + return OAuth2ProviderPreBuiltUI; +})(uiEntry.RecipeRouter); +var TryRefreshPage = OAuth2ProviderPreBuiltUI.TryRefreshPage; + +exports.OAuth2ProviderPreBuiltUI = OAuth2ProviderPreBuiltUI; +exports.TryRefreshPage = TryRefreshPage; diff --git a/lib/build/passwordless-shared.js b/lib/build/passwordless-shared.js index 79b224e8b..9a5e31150 100644 --- a/lib/build/passwordless-shared.js +++ b/lib/build/passwordless-shared.js @@ -1,7 +1,6 @@ "use strict"; var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); -var superTokens = require("./superTokens.js"); var PasswordlessWebJS = require("supertokens-web-js/recipe/passwordless"); var postSuperTokensInitCallbacks = require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); var jsxRuntime = require("react/jsx-runtime"); @@ -23,7 +22,7 @@ var _a = genericComponentOverrideContext.createGenericComponentsOverrideContext( var OTPEmailIcon = function () { return jsxRuntime.jsxs( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { width: "17", height: "15", viewBox: "0 0 17 15", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [ @@ -37,7 +36,7 @@ var OTPEmailIcon = function () { jsxRuntime.jsx("defs", { children: jsxRuntime.jsxs( "linearGradient", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "paint0_linear_4445_310", x1: "8.5", @@ -64,7 +63,7 @@ var OTPEmailIcon = function () { var OTPSMSIcon = function () { return jsxRuntime.jsxs( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { width: "17", height: "15", viewBox: "0 0 17 15", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [ @@ -78,7 +77,7 @@ var OTPSMSIcon = function () { jsxRuntime.jsx("defs", { children: jsxRuntime.jsxs( "linearGradient", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "paint0_linear_4445_316", x1: "8.5", @@ -104,11 +103,11 @@ var OTPSMSIcon = function () { var getFunctionOverrides = function (onHandleEvent) { return function (originalImp) { - return superTokens.__assign(superTokens.__assign({}, originalImp), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImp), { createCode: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.createCode(input)]; @@ -126,9 +125,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, resendCode: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.resendCode(input)]; @@ -150,9 +149,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, consumeCode: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var payloadBeforeCall, response, payloadAfterCall; - return superTokens.__generator(this, function (_c) { + return genericComponentOverrideContext.__generator(this, function (_c) { switch (_c.label) { case 0: _c.trys.push([0, 2, , 3]); @@ -217,17 +216,20 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, setLoginAttemptInfo: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, originalImp.setLoginAttemptInfo( - superTokens.__assign(superTokens.__assign({}, input), { - attemptInfo: superTokens.__assign( - superTokens.__assign({}, input.attemptInfo), - input.userContext.additionalAttemptInfo - ), - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, input), + { + attemptInfo: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, input.attemptInfo), + input.userContext.additionalAttemptInfo + ), + } + ) ), ]; }); @@ -268,8 +270,8 @@ function defaultEmailValidator(value) { return undefined; } function userInputCodeValidate(value) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { if (typeof value !== "string") { return [2 /*return*/, "GENERAL_ERROR_OTP_NON_STRING"]; } @@ -285,8 +287,8 @@ function userInputCodeValidate(value) { */ // eslint-disable-next-line @typescript-eslint/no-unused-vars function defaultValidate(_) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [2 /*return*/, undefined]; }); }); @@ -314,7 +316,7 @@ function normalisePasswordlessConfig(config) { throw new Error("Please pass one of 'PHONE', 'EMAIL' or 'EMAIL_OR_PHONE' as the contactMethod"); } var signInUpFeature = normalizeSignInUpFeatureConfig(config.signInUpFeature, config); - var override = superTokens.__assign( + var override = genericComponentOverrideContext.__assign( { functions: function (originalImplementation) { return originalImplementation; @@ -336,15 +338,18 @@ function normalisePasswordlessConfig(config) { ) { validatePhoneNumber = config.validatePhoneNumber; } - return superTokens.__assign(superTokens.__assign({}, utils.normaliseAuthRecipe(config)), { - validateEmailAddress: validateEmailAddress, - validatePhoneNumber: validatePhoneNumber, - signInUpFeature: signInUpFeature, - linkClickedScreenFeature: normalisePasswordlessBaseConfig(config.linkClickedScreenFeature), - mfaFeature: normalisePasswordlessBaseConfig(config.mfaFeature), - contactMethod: config.contactMethod, - override: override, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, utils.normaliseAuthRecipe(config)), + { + validateEmailAddress: validateEmailAddress, + validatePhoneNumber: validatePhoneNumber, + signInUpFeature: signInUpFeature, + linkClickedScreenFeature: normalisePasswordlessBaseConfig(config.linkClickedScreenFeature), + mfaFeature: normalisePasswordlessBaseConfig(config.mfaFeature), + contactMethod: config.contactMethod, + override: override, + } + ); } function normalizeSignInUpFeatureConfig(signInUpInput, config) { if ( @@ -354,7 +359,7 @@ function normalizeSignInUpFeatureConfig(signInUpInput, config) { ) { throw new Error("Please pass a positive number as resendEmailOrSMSGapInSeconds"); } - return superTokens.__assign(superTokens.__assign({}, signInUpInput), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, signInUpInput), { resendEmailOrSMSGapInSeconds: (signInUpInput === null || signInUpInput === void 0 ? void 0 @@ -392,7 +397,9 @@ function normalizeSignInUpFeatureConfig(signInUpInput, config) { } function normalisePasswordlessBaseConfig(config) { var style = config && config.style !== undefined ? config.style : ""; - return superTokens.__assign(superTokens.__assign({}, config), { style: style }); + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, config), { + style: style, + }); } /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. @@ -427,7 +434,7 @@ var otpEmailFactor = { * Class. */ var Passwordless = /** @class */ (function (_super) { - superTokens.__extends(Passwordless, _super); + genericComponentOverrideContext.__extends(Passwordless, _super); function Passwordless(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = PasswordlessWebJS__default.default; @@ -442,8 +449,8 @@ var Passwordless = /** @class */ (function (_super) { types.FactorIds.LINK_PHONE, ]; _this.getDefaultRedirectionURL = function (context) { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [2 /*return*/, this.getAuthRecipeDefaultRedirectionURL(context)]; }); }); @@ -472,24 +479,27 @@ var Passwordless = /** @class */ (function (_super) { recipeID: Passwordless.RECIPE_ID, authReact: function (appInfo) { Passwordless.instance = new Passwordless( - superTokens.__assign(superTokens.__assign({}, normalisedConfig), { - appInfo: appInfo, - recipeId: Passwordless.RECIPE_ID, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { appInfo: appInfo, recipeId: Passwordless.RECIPE_ID } + ) ); return Passwordless.instance; }, webJS: PasswordlessWebJS__default.default.init( - superTokens.__assign(superTokens.__assign({}, normalisedConfig), { - override: { - functions: function (originalImpl, builder) { - var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); - builder.override(functions); - builder.override(normalisedConfig.override.functions); - return originalImpl; + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { + override: { + functions: function (originalImpl, builder) { + var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); + builder.override(functions); + builder.override(normalisedConfig.override.functions); + return originalImpl; + }, }, - }, - }) + } + ) ), }; }; @@ -500,7 +510,7 @@ var Passwordless = /** @class */ (function (_super) { "See https://supertokens.io/docs/passwordless/quick-setup/frontend"; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { - error = error + superTokens.SSR_ERROR; + error = error + genericComponentOverrideContext.SSR_ERROR; } throw Error(error); } @@ -510,7 +520,7 @@ var Passwordless = /** @class */ (function (_super) { * Tests methods. */ Passwordless.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } Passwordless.instance = undefined; diff --git a/lib/build/passwordless.js b/lib/build/passwordless.js index 0892e826d..1b2c514be 100644 --- a/lib/build/passwordless.js +++ b/lib/build/passwordless.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var recipe = require("./passwordless-shared.js"); require("supertokens-web-js"); require("supertokens-web-js/utils/cookieHandler"); @@ -13,7 +13,6 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); -require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); require("supertokens-web-js/recipe/passwordless"); require("./authRecipe-shared2.js"); @@ -47,12 +46,12 @@ var Wrapper = /** @class */ (function () { return recipe.Passwordless.init(config); }; Wrapper.signOut = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().signOut({ - userContext: superTokens.getNormalisedUserContext( + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -61,13 +60,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.createCode = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.createCode( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -77,13 +76,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.resendCode = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.resendCode( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -93,13 +92,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.consumeCode = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.consumeCode( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -110,8 +109,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.getLinkCodeFromURL = function (input) { return recipe.Passwordless.getInstanceOrThrow().webJSRecipe.getLinkCodeFromURL( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -119,21 +118,21 @@ var Wrapper = /** @class */ (function () { }; Wrapper.getPreAuthSessionIdFromURL = function (input) { return recipe.Passwordless.getInstanceOrThrow().webJSRecipe.getPreAuthSessionIdFromURL( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) ); }; Wrapper.doesEmailExist = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.doesEmailExist( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext(input.userContext), + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), }) ), ]; @@ -141,13 +140,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.doesPhoneNumberExist = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.doesPhoneNumberExist( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext(input.userContext), + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), }) ), ]; @@ -155,13 +154,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.getLoginAttemptInfo = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.getLoginAttemptInfo( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -171,13 +170,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.setLoginAttemptInfo = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.setLoginAttemptInfo( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext(input.userContext), + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), }) ), ]; @@ -185,13 +184,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.clearLoginAttemptInfo = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.Passwordless.getInstanceOrThrow().webJSRecipe.clearLoginAttemptInfo( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) diff --git a/lib/build/passwordlessprebuiltui.js b/lib/build/passwordlessprebuiltui.js index b58501178..615fa049d 100644 --- a/lib/build/passwordlessprebuiltui.js +++ b/lib/build/passwordlessprebuiltui.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var React = require("react"); var jsxRuntime = require("react/jsx-runtime"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); @@ -31,7 +31,6 @@ require("supertokens-web-js/utils"); require("supertokens-web-js/utils/normalisedURLDomain"); require("react-dom"); require("./multitenancy-shared.js"); -require("./genericComponentOverrideContext.js"); require("./oauth2provider-shared.js"); require("supertokens-web-js/recipe/oauth2provider"); require("./recipeModule-shared.js"); @@ -107,7 +106,7 @@ var ThemeBase = function (_a) { var ContinueWithPasswordless = function (props) { return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "continueWithPasswordlessButtonWrapper" }, { children: jsxRuntime.jsx(button.Button, { @@ -127,13 +126,18 @@ var ContinueWithPasswordlessWithOverride = uiEntry.withOverride( ContinueWithPasswordless ); var ContinueWithPasswordlessTheme = function (props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); return jsxRuntime.jsx( ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle] }, - { children: jsxRuntime.jsx(ContinueWithPasswordlessWithOverride, superTokens.__assign({}, props)) } + { + children: jsxRuntime.jsx( + ContinueWithPasswordlessWithOverride, + genericComponentOverrideContext.__assign({}, props) + ), + } ) ); }; @@ -142,12 +146,12 @@ var ContinueWithPasswordlessFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { recipeComponentOverrides: recipeComponentOverrides }, { children: jsxRuntime.jsx( ContinueWithPasswordlessTheme, - superTokens.__assign({}, props, { + genericComponentOverrideContext.__assign({}, props, { continueWithPasswordlessClicked: function () { return props.setFactorList(props.factorIds); }, @@ -166,12 +170,12 @@ var PasswordlessLinkClickedScreen = function (props) { setLoading = _a[1]; return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: @@ -180,21 +184,21 @@ var PasswordlessLinkClickedScreen = function (props) { children: [ jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle" }, { children: t("PWLESS_LINK_CLICKED_CONTINUE_HEADER") } ) ), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: t("PWLESS_LINK_CLICKED_CONTINUE_DESC") } ) ), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "continueButtonWrapper" }, { children: jsxRuntime.jsx(button.Button, { @@ -213,7 +217,7 @@ var PasswordlessLinkClickedScreen = function (props) { }) : jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "spinner" }, { children: jsxRuntime.jsx(uiEntry.SpinnerIcon, {}) } ) @@ -230,89 +234,97 @@ var LinkClickedScreenWithOverride = uiEntry.withOverride( PasswordlessLinkClickedScreen ); var LinkClickedScreen$1 = function (props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); return jsxRuntime.jsx( ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, props.config.linkClickedScreenFeature.style], }, - { children: jsxRuntime.jsx(LinkClickedScreenWithOverride, superTokens.__assign({}, props)) } + { + children: jsxRuntime.jsx( + LinkClickedScreenWithOverride, + genericComponentOverrideContext.__assign({}, props) + ), + } ) ); }; var defaultTranslationsPasswordless = { - en: superTokens.__assign(superTokens.__assign({}, uiEntry.defaultTranslationsCommon.en), { - GENERAL_ERROR_EMAIL_UNDEFINED: "Please set your email", - GENERAL_ERROR_EMAIL_NON_STRING: "Email must be of type string", - GENERAL_ERROR_EMAIL_INVALID: "Email is invalid", - GENERAL_ERROR_PHONE_UNDEFINED: "Please set your phone number", - GENERAL_ERROR_PHONE_NON_STRING: "Phone number must be of type string", - GENERAL_ERROR_PHONE_INVALID: "Phone number is invalid", - GENERAL_ERROR_OTP_UNDEFINED: "Please fill your OTP", - GENERAL_ERROR_OTP_INVALID: "Invalid OTP", - GENERAL_ERROR_OTP_EXPIRED: "Expired OTP.", - GENERAL_ERROR_OTP_NON_STRING: "OTP must be of type string", - GENERAL_ERROR_OTP_EMPTY: "OTP cannot be empty", - ERROR_SIGN_IN_UP_LINK: "Invalid magic link. Please try again.", - ERROR_SIGN_IN_UP_RESEND_RESTART_FLOW: "Login timed out. Please try again.", - ERROR_SIGN_IN_UP_CODE_CONSUME_RESTART_FLOW: "Login unsuccessful. Please try again.", - PWLESS_SIGN_IN_UP_EMAIL_LABEL: "Email", - PWLESS_SIGN_IN_UP_PHONE_LABEL: "Phone Number", - PWLESS_SIGN_IN_UP_SWITCH_TO_PHONE: "Use a Phone number", - PWLESS_SIGN_IN_UP_SWITCH_TO_EMAIL: "Use an Email", - PWLESS_SIGN_IN_UP_CONTINUE_BUTTON: "CONTINUE", - PWLESS_COMBO_CONTINUE_WITH_PASSWORDLESS_LINK: "Continue with passwordless", - PWLESS_COMBO_CONTINUE_WITH_PASSWORDLESS_BUTTON: "CONTINUE WITH PASSWORDLESS", - PWLESS_COMBO_PASSWORD_LABEL: "Password", - PWLESS_COMBO_FORGOT_PW_LINK: "Forgot password?", - PWLESS_LINK_SENT_RESEND_SUCCESS: "Link resent", - PWLESS_LINK_SENT_RESEND_TITLE: "Link sent!", - PWLESS_LINK_SENT_RESEND_DESC_START_EMAIL: "We sent a link to ", - PWLESS_LINK_SENT_RESEND_DESC_START_PHONE: "We sent a link to your phone number ", - PWLESS_LINK_SENT_RESEND_DESC_END_EMAIL: " Click the link to login or sign up", - PWLESS_LINK_SENT_RESEND_DESC_END_PHONE: "", - PWLESS_SIGN_IN_UP_CHANGE_CONTACT_INFO_EMAIL: "Change email", - PWLESS_SIGN_IN_UP_CHANGE_CONTACT_INFO_PHONE: "Change phone number", - PWLESS_LINK_CLICKED_CONTINUE_HEADER: "Sign Up or Log In", - PWLESS_LINK_CLICKED_CONTINUE_DESC: "Click the button below to log in on this device", - PWLESS_LINK_CLICKED_CONTINUE_BUTTON: "CONTINUE", - PWLESS_RESEND_SUCCESS_EMAIL: "Email resent", - PWLESS_RESEND_SUCCESS_PHONE: "SMS resent", - PWLESS_RESEND_BTN_DISABLED_START: "Resend in ", - PWLESS_RESEND_BTN_DISABLED_END: "", - PWLESS_RESEND_BTN_EMAIL: "Resend Email", - PWLESS_RESEND_BTN_PHONE: "Resend SMS", - PWLESS_USER_INPUT_CODE_HEADER_TITLE: "Enter OTP", - PWLESS_USER_INPUT_CODE_HEADER_SUBTITLE: "An OTP was sent to you at", - PWLESS_USER_INPUT_CODE_HEADER_SUBTITLE_LINK: "An OTP and a magic link was sent to you at", - PWLESS_USER_INPUT_CODE_INPUT_LABEL: "OTP", - PWLESS_MFA_HEADER_TITLE_PHONE: "SMS based OTP", - PWLESS_MFA_HEADER_TITLE_EMAIL: "Email based OTP", - PWLESS_MFA_FOOTER_LOGOUT: "Logout", - /* - * The following are error messages from our backend SDK. - * These are returned as full messages to preserver compatibilty, but they work just like the keys above. - * They are shown as is by default (setting the value to undefined will display the raw translation key) - */ - "Failed to generate a one time code. Please try again": undefined, - "Phone number is invalid": undefined, - "Email is invalid": undefined, - "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_002)": - undefined, - "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_003)": - undefined, - "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_017)": undefined, - "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_018)": undefined, - "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_019)": undefined, - }), + en: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, uiEntry.defaultTranslationsCommon.en), + { + GENERAL_ERROR_EMAIL_UNDEFINED: "Please set your email", + GENERAL_ERROR_EMAIL_NON_STRING: "Email must be of type string", + GENERAL_ERROR_EMAIL_INVALID: "Email is invalid", + GENERAL_ERROR_PHONE_UNDEFINED: "Please set your phone number", + GENERAL_ERROR_PHONE_NON_STRING: "Phone number must be of type string", + GENERAL_ERROR_PHONE_INVALID: "Phone number is invalid", + GENERAL_ERROR_OTP_UNDEFINED: "Please fill your OTP", + GENERAL_ERROR_OTP_INVALID: "Invalid OTP", + GENERAL_ERROR_OTP_EXPIRED: "Expired OTP.", + GENERAL_ERROR_OTP_NON_STRING: "OTP must be of type string", + GENERAL_ERROR_OTP_EMPTY: "OTP cannot be empty", + ERROR_SIGN_IN_UP_LINK: "Invalid magic link. Please try again.", + ERROR_SIGN_IN_UP_RESEND_RESTART_FLOW: "Login timed out. Please try again.", + ERROR_SIGN_IN_UP_CODE_CONSUME_RESTART_FLOW: "Login unsuccessful. Please try again.", + PWLESS_SIGN_IN_UP_EMAIL_LABEL: "Email", + PWLESS_SIGN_IN_UP_PHONE_LABEL: "Phone Number", + PWLESS_SIGN_IN_UP_SWITCH_TO_PHONE: "Use a Phone number", + PWLESS_SIGN_IN_UP_SWITCH_TO_EMAIL: "Use an Email", + PWLESS_SIGN_IN_UP_CONTINUE_BUTTON: "CONTINUE", + PWLESS_COMBO_CONTINUE_WITH_PASSWORDLESS_LINK: "Continue with passwordless", + PWLESS_COMBO_CONTINUE_WITH_PASSWORDLESS_BUTTON: "CONTINUE WITH PASSWORDLESS", + PWLESS_COMBO_PASSWORD_LABEL: "Password", + PWLESS_COMBO_FORGOT_PW_LINK: "Forgot password?", + PWLESS_LINK_SENT_RESEND_SUCCESS: "Link resent", + PWLESS_LINK_SENT_RESEND_TITLE: "Link sent!", + PWLESS_LINK_SENT_RESEND_DESC_START_EMAIL: "We sent a link to ", + PWLESS_LINK_SENT_RESEND_DESC_START_PHONE: "We sent a link to your phone number ", + PWLESS_LINK_SENT_RESEND_DESC_END_EMAIL: " Click the link to login or sign up", + PWLESS_LINK_SENT_RESEND_DESC_END_PHONE: "", + PWLESS_SIGN_IN_UP_CHANGE_CONTACT_INFO_EMAIL: "Change email", + PWLESS_SIGN_IN_UP_CHANGE_CONTACT_INFO_PHONE: "Change phone number", + PWLESS_LINK_CLICKED_CONTINUE_HEADER: "Sign Up or Log In", + PWLESS_LINK_CLICKED_CONTINUE_DESC: "Click the button below to log in on this device", + PWLESS_LINK_CLICKED_CONTINUE_BUTTON: "CONTINUE", + PWLESS_RESEND_SUCCESS_EMAIL: "Email resent", + PWLESS_RESEND_SUCCESS_PHONE: "SMS resent", + PWLESS_RESEND_BTN_DISABLED_START: "Resend in ", + PWLESS_RESEND_BTN_DISABLED_END: "", + PWLESS_RESEND_BTN_EMAIL: "Resend Email", + PWLESS_RESEND_BTN_PHONE: "Resend SMS", + PWLESS_USER_INPUT_CODE_HEADER_TITLE: "Enter OTP", + PWLESS_USER_INPUT_CODE_HEADER_SUBTITLE: "An OTP was sent to you at", + PWLESS_USER_INPUT_CODE_HEADER_SUBTITLE_LINK: "An OTP and a magic link was sent to you at", + PWLESS_USER_INPUT_CODE_INPUT_LABEL: "OTP", + PWLESS_MFA_HEADER_TITLE_PHONE: "SMS based OTP", + PWLESS_MFA_HEADER_TITLE_EMAIL: "Email based OTP", + PWLESS_MFA_FOOTER_LOGOUT: "Logout", + /* + * The following are error messages from our backend SDK. + * These are returned as full messages to preserver compatibilty, but they work just like the keys above. + * They are shown as is by default (setting the value to undefined will display the raw translation key) + */ + "Failed to generate a one time code. Please try again": undefined, + "Phone number is invalid": undefined, + "Email is invalid": undefined, + "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_002)": + undefined, + "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_003)": + undefined, + "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_017)": undefined, + "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_018)": undefined, + "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_019)": undefined, + } + ), }; var LinkClickedScreen = function (props) { - var rethrowInRender = superTokens.useRethrowInRender(); + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); var userContext = uiEntry.useUserContext(); if (props.userContext !== undefined) { userContext = props.userContext; @@ -322,19 +334,19 @@ var LinkClickedScreen = function (props) { setRequireUserInteraction = _a[1]; var consumeCodeAtMount = React.useCallback( function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var preAuthSessionId, linkCode, loginAttemptInfo, payloadBeforeCall; var _b; - return superTokens.__generator(this, function (_c) { + return genericComponentOverrideContext.__generator(this, function (_c) { switch (_c.label) { case 0: - preAuthSessionId = superTokens.getQueryParams("preAuthSessionId"); - linkCode = superTokens.getURLHash(); + preAuthSessionId = genericComponentOverrideContext.getQueryParams("preAuthSessionId"); + linkCode = genericComponentOverrideContext.getURLHash(); if (!(preAuthSessionId === null || preAuthSessionId.length === 0 || linkCode.length === 0)) return [3 /*break*/, 2]; return [ 4 /*yield*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: "signin", @@ -397,9 +409,9 @@ var LinkClickedScreen = function (props) { ); var handleConsumeResp = React.useCallback( function (consumeRes) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var response, payloadBeforeCall, payloadAfterCall, loginAttemptInfo; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: if (consumeRes === "REQUIRES_INTERACTION") { @@ -414,7 +426,7 @@ var LinkClickedScreen = function (props) { if (response.status === "RESTART_FLOW_ERROR") { return [ 2 /*return*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: "restart_link", @@ -427,7 +439,7 @@ var LinkClickedScreen = function (props) { if (response.status === "SIGN_IN_UP_NOT_ALLOWED") { return [ 2 /*return*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: response.reason, @@ -508,7 +520,7 @@ var LinkClickedScreen = function (props) { var handleConsumeError = React.useCallback( function (err) { if (STGeneralError__default.default.isThisError(err)) { - return superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ + return genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: "custom", @@ -518,7 +530,7 @@ var LinkClickedScreen = function (props) { userContext: userContext, }); } else { - return superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ + return genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: "signin", @@ -530,16 +542,16 @@ var LinkClickedScreen = function (props) { }, [props.navigate, userContext] ); - superTokens.useOnMountAPICall(consumeCodeAtMount, handleConsumeResp, handleConsumeError); + genericComponentOverrideContext.useOnMountAPICall(consumeCodeAtMount, handleConsumeResp, handleConsumeError); var recipeComponentOverrides = props.useComponentOverrides(); var childProps = { recipeImplementation: props.recipe.webJSRecipe, config: props.recipe.config, requireUserInteraction: requireUserInteraction, consumeCode: function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var payloadBeforeCall, consumeResp, err_1; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 7, , 8]); @@ -590,21 +602,24 @@ var LinkClickedScreen = function (props) { }; return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { - useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, + useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, defaultStore: defaultTranslationsPasswordless, }, { children: jsxRuntime.jsxs(React.Fragment, { children: [ props.children === undefined && - jsxRuntime.jsx(LinkClickedScreen$1, superTokens.__assign({}, childProps)), + jsxRuntime.jsx( + LinkClickedScreen$1, + genericComponentOverrideContext.__assign({}, childProps) + ), props.children && React__namespace.default.Children.map(props.children, function (child) { if (React__namespace.default.isValidElement(child)) { @@ -645,29 +660,29 @@ var LinkClickedScreen = function (props) { function SMSLargeIcon() { return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "52.013", height: "41.889", viewBox: "0 0 52.013 41.889" }, { children: jsxRuntime.jsx( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "Group_10400", "data-name": "Group 10400", transform: "translate(-724.625 -241.125)" }, { children: jsxRuntime.jsxs( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "Group_10399", "data-name": "Group 10399" }, { children: [ jsxRuntime.jsxs( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "Group_10398", "data-name": "Group 10398" }, { children: [ jsxRuntime.jsxs( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "_2639922_sms_icon", "data-name": "2639922_sms_icon", @@ -717,7 +732,7 @@ function SMSLargeIcon() { ), jsxRuntime.jsxs( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "_2639922_sms_icon-2", "data-name": "2639922_sms_icon", @@ -749,7 +764,7 @@ function SMSLargeIcon() { ), jsxRuntime.jsxs( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "Group_10397", "data-name": "Group 10397" }, { children: [ @@ -779,7 +794,7 @@ function SMSLargeIcon() { ), jsxRuntime.jsxs( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "Group_10396", "data-name": "Group 10396" }, { children: [ @@ -816,7 +831,7 @@ function SMSLargeIcon() { }), jsxRuntime.jsxs( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "Group_10395", "data-name": "Group 10395" }, { children: [ @@ -890,7 +905,7 @@ var ResendButton = uiEntry.withOverride("PasswordlessResendButton", function Pas ); return jsxRuntime.jsx( "button", - superTokens.__assign( + genericComponentOverrideContext.__assign( { type: "button", disabled: secsUntilResend !== undefined, @@ -941,9 +956,9 @@ var PasswordlessLinkSent = function (props) { }, []); var resendEmail = React.useCallback( function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var response, generalError, e_1; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 5, , 6]); @@ -1001,12 +1016,12 @@ var PasswordlessLinkSent = function (props) { var resendActive = status === "LINK_RESENT"; return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: [ @@ -1017,14 +1032,14 @@ var PasswordlessLinkSent = function (props) { resendActive && jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "generalSuccess" }, { children: t("PWLESS_LINK_SENT_RESEND_SUCCESS") } ) ), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "sendCodeIcon" }, { children: @@ -1036,14 +1051,14 @@ var PasswordlessLinkSent = function (props) { ), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle headerTinyTitle" }, { children: t("PWLESS_LINK_SENT_RESEND_TITLE") } ) ), jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "primaryText sendCodeText" }, { children: [ @@ -1068,7 +1083,7 @@ var PasswordlessLinkSent = function (props) { }), jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: function () { @@ -1099,22 +1114,22 @@ var PasswordlessLinkSent = function (props) { }; var LinkSent = uiEntry.withOverride("PasswordlessLinkSent", PasswordlessLinkSent); function LinkSentWrapper(props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeStyle = props.config.signInUpFeature.linkSentScreenStyle; return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, activeStyle], }, - { children: jsxRuntime.jsx(LinkSent, superTokens.__assign({}, props)) } + { children: jsxRuntime.jsx(LinkSent, genericComponentOverrideContext.__assign({}, props)) } ) ), } @@ -1140,15 +1155,15 @@ function useChildProps$4( }, [recipe$1, onError, rebuildAuthPage] ); - var rethrowInRender = superTokens.useRethrowInRender(); + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); return React.useMemo( function () { return { userContext: userContext, onSuccess: function (result) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var payloadAfterCall; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, , 3]); @@ -1185,7 +1200,7 @@ function useChildProps$4( recipeId: recipe$1.recipeID, }, recipe$1.recipeID, - superTokens.getRedirectToPathFromURL(), + genericComponentOverrideContext.getRedirectToPathFromURL(), userContext, navigate ) @@ -1196,9 +1211,9 @@ function useChildProps$4( }); }, onFetchError: function (err) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var invalidClaims, evInstance; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -1278,12 +1293,15 @@ var LinkSentFeatureInner = function (props) { props.children === undefined && jsxRuntime.jsx( LinkSentWrapper, - superTokens.__assign({}, childProps, { userContext: props.userContext }) + genericComponentOverrideContext.__assign({}, childProps, { userContext: props.userContext }) ), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { - return React__namespace.cloneElement(child, superTokens.__assign({}, childProps)); + return React__namespace.cloneElement( + child, + genericComponentOverrideContext.__assign({}, childProps) + ); } return child; }), @@ -1294,20 +1312,20 @@ var LinkSentFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { recipeComponentOverrides: recipeComponentOverrides }, - { children: jsxRuntime.jsx(LinkSentFeatureInner, superTokens.__assign({}, props)) } + { children: jsxRuntime.jsx(LinkSentFeatureInner, genericComponentOverrideContext.__assign({}, props)) } ) ); }; function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPage) { var _this = this; - return superTokens.__assign(superTokens.__assign({}, originalImpl), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImpl), { resendCode: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var res, loginAttemptInfo, timestamp; var _a; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: return [4 /*yield*/, originalImpl.resendCode(input)]; @@ -1328,13 +1346,17 @@ function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPa 4 /*yield*/, originalImpl.setLoginAttemptInfo({ userContext: input.userContext, - attemptInfo: superTokens.__assign(superTokens.__assign({}, loginAttemptInfo), { - tryLinkingWithSessionUser: - (_a = loginAttemptInfo.tryLinkingWithSessionUser) !== null && _a !== void 0 - ? _a - : false, - lastResend: timestamp, - }), + attemptInfo: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, loginAttemptInfo), + { + tryLinkingWithSessionUser: + (_a = loginAttemptInfo.tryLinkingWithSessionUser) !== null && + _a !== void 0 + ? _a + : false, + lastResend: timestamp, + } + ), }), ]; case 3: @@ -1362,9 +1384,9 @@ function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPa }); }, consumeCode: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var res; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.consumeCode(input)]; @@ -1413,8 +1435,8 @@ function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPa }); }, clearLoginAttemptInfo: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -1425,7 +1447,7 @@ function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPa ]; case 1: _a.sent(); - superTokens.clearErrorQueryParam(); + genericComponentOverrideContext.clearErrorQueryParam(); rebuildAuthPage(); return [2 /*return*/]; } @@ -1437,9 +1459,9 @@ function getModifiedRecipeImplementation$4(originalImpl, setError, rebuildAuthPa var phoneNumberUtilsImport; function getPhoneNumberUtils() { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var global; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, preloadPhoneNumberUtils()]; @@ -1466,9 +1488,9 @@ function preloadPhoneNumberUtils() { // This was moved to a separate file to make tree-shaking more effective, since we do not want to include the phoneNumberUtils // in the base pwless recipe because it increases the bundle size by a lot function defaultPhoneNumberValidator(value) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var intlTelInputUtils; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: if (typeof value !== "string") { @@ -1509,10 +1531,10 @@ var EmailForm = uiEntry.withOverride("PasswordlessEmailForm", function Passwordl buttonLabel: "PWLESS_SIGN_IN_UP_CONTINUE_BUTTON", onSuccess: props.onSuccess, callAPI: function (formFields) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var email, validationRes, response; var _a; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: email = @@ -3542,7 +3564,7 @@ function PhoneNumberInput(_a) { // if it detects a mobile environment, but this doesn't work with our styling if we use shadow dom var anyIti = itiRef; if (anyIti.isMobile) { - var root = document.getElementById(superTokens.ST_ROOT_ID); + var root = document.getElementById(genericComponentOverrideContext.ST_ROOT_ID); // We only have to do this if we are using shadowDom and we need access to the dom element anyway // so passing the shadowroot element here would be both impractical and not too useful if (root === null || root === void 0 ? void 0 : root.shadowRoot) { @@ -3564,13 +3586,13 @@ function PhoneNumberInput(_a) { */ return jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "inputContainer" }, { children: [ jsxRuntime.jsxs( "style", - superTokens.__assign( + genericComponentOverrideContext.__assign( { type: "text/css" }, { children: [ @@ -3582,7 +3604,7 @@ function PhoneNumberInput(_a) { ), jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "phoneInputWrapper inputWrapper ".concat( hasError ? "inputError" : "" @@ -3614,7 +3636,7 @@ function PhoneNumberInput(_a) { hasError === true && jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "inputAdornment inputAdornmentError" }, { children: jsxRuntime.jsx(formBase.ErrorIcon, {}) } ) @@ -3632,7 +3654,7 @@ function PhoneNumberInput(_a) { // TODO: type props var phoneNumberInputWithInjectedProps = function (injectedProps) { return function (props) { - return jsxRuntime.jsx(PhoneNumberInput, superTokens.__assign({}, injectedProps, props)); + return jsxRuntime.jsx(PhoneNumberInput, genericComponentOverrideContext.__assign({}, injectedProps, props)); }; }; @@ -3670,10 +3692,10 @@ var PhoneForm = uiEntry.withOverride("PasswordlessPhoneForm", function Passwordl buttonLabel: "PWLESS_SIGN_IN_UP_CONTINUE_BUTTON", onSuccess: props.onSuccess, callAPI: function (formFields) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var phoneNumber, validationRes, response; var _a; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: phoneNumber = @@ -3725,7 +3747,7 @@ var UserInputCodeFormFooter = uiEntry.withOverride( return jsxRuntime.jsx(React.Fragment, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: function () { @@ -3757,14 +3779,14 @@ var UserInputCodeFormHeader = uiEntry.withOverride( children: [ jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle" }, { children: t("PWLESS_USER_INPUT_CODE_HEADER_TITLE") } ) ), jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: [ @@ -3786,20 +3808,26 @@ var UserInputCodeFormHeader = uiEntry.withOverride( var UserInputCodeFormScreen = function (props) { return jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container" }, { children: [ jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: [ - jsxRuntime.jsx(UserInputCodeFormHeader, superTokens.__assign({}, props)), + jsxRuntime.jsx( + UserInputCodeFormHeader, + genericComponentOverrideContext.__assign({}, props) + ), props.error !== undefined && jsxRuntime.jsx(uiEntry.GeneralError, { error: props.error }), - jsxRuntime.jsx(UserInputCodeForm, superTokens.__assign({}, props)), + jsxRuntime.jsx( + UserInputCodeForm, + genericComponentOverrideContext.__assign({}, props) + ), ], } ) @@ -3829,9 +3857,9 @@ var UserInputCodeForm = uiEntry.withOverride("PasswordlessUserInputCodeForm", fu ); var resend = React.useCallback( function resend() { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var response, generalError, e_1; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 5, , 6]); @@ -3890,7 +3918,7 @@ var UserInputCodeForm = uiEntry.withOverride("PasswordlessUserInputCodeForm", fu clearResendNotifTimeout !== undefined && jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "generalSuccess" }, { children: @@ -3910,7 +3938,7 @@ var UserInputCodeForm = uiEntry.withOverride("PasswordlessUserInputCodeForm", fu label: "", labelComponent: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ @@ -3939,10 +3967,10 @@ var UserInputCodeForm = uiEntry.withOverride("PasswordlessUserInputCodeForm", fu onSuccess: props.onSuccess, buttonLabel: "PWLESS_SIGN_IN_UP_CONTINUE_BUTTON", callAPI: function (formFields) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var userInputCode, response; var _a; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: userInputCode = @@ -3990,29 +4018,36 @@ var UserInputCodeForm = uiEntry.withOverride("PasswordlessUserInputCodeForm", fu ? _a : jsxRuntime.jsx( UserInputCodeFormFooter, - superTokens.__assign({}, props, { loginAttemptInfo: props.loginAttemptInfo }) + genericComponentOverrideContext.__assign({}, props, { + loginAttemptInfo: props.loginAttemptInfo, + }) ), }), ], }); }); function UserInputCodeFormScreenWrapper(props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeStyle = props.config.signInUpFeature.userInputCodeFormStyle; return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, activeStyle], }, - { children: jsxRuntime.jsx(UserInputCodeFormScreen, superTokens.__assign({}, props)) } + { + children: jsxRuntime.jsx( + UserInputCodeFormScreen, + genericComponentOverrideContext.__assign({}, props) + ), + } ) ), } @@ -4023,17 +4058,17 @@ function UserInputCodeFormScreenWrapper(props) { var OTPLoadingScreen = function () { return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container delayedRender pwless-mfa loadingScreen" }, { children: jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "spinner delayedRender" }, { children: jsxRuntime.jsx(uiEntry.SpinnerIcon, {}) } ) @@ -4051,12 +4086,12 @@ var MFAFooter = uiEntry.withOverride("PasswordlessMFAFooter", function Passwordl var t = translationContext.useTranslation(); return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "footerLinkGroupVert pwless-mfa footer" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: props.onSignOutClicked, @@ -4082,7 +4117,7 @@ var MFAHeader = uiEntry.withOverride("PasswordlessMFAHeader", function Passwordl children: [ jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle withBackButton pwless-mfa header" }, { children: [ @@ -4113,14 +4148,14 @@ var MFAOTPFooter = uiEntry.withOverride("PasswordlessMFAOTPFooter", function Pas var userContext = uiEntry.useUserContext(); return jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "footerLinkGroupVert pwless-mfa otpFooter" }, { children: [ canChangeEmail && jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "secondaryText", onClick: function () { @@ -4139,7 +4174,7 @@ var MFAOTPFooter = uiEntry.withOverride("PasswordlessMFAOTPFooter", function Pas ), jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: onSignOutClicked, @@ -4170,7 +4205,7 @@ var MFAOTPHeader = uiEntry.withOverride("PasswordlessMFAOTPHeader", function Pas children: [ jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle withBackButton pwless-mfa otpHeader" }, { children: [ @@ -4187,7 +4222,7 @@ var MFAOTPHeader = uiEntry.withOverride("PasswordlessMFAOTPHeader", function Pas ), jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: [ @@ -4217,7 +4252,7 @@ var MFATheme = function (_a) { var activeScreen = _a.activeScreen, featureState = _a.featureState, onBackButtonClicked = _a.onBackButtonClicked, - props = superTokens.__rest(_a, ["activeScreen", "featureState", "onBackButtonClicked"]); + props = genericComponentOverrideContext.__rest(_a, ["activeScreen", "featureState", "onBackButtonClicked"]); var t = translationContext.useTranslation(); var commonProps = { recipeImplementation: props.recipeImplementation, @@ -4242,13 +4277,13 @@ var MFATheme = function (_a) { }) : jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container pwless-mfa" }, { children: [ jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: jsxRuntime.jsxs(React__namespace.default.Fragment, { @@ -4256,7 +4291,7 @@ var MFATheme = function (_a) { activeScreen === MFAScreens.UserInputCodeForm ? jsxRuntime.jsx( MFAOTPHeader, - superTokens.__assign({}, commonProps, { + genericComponentOverrideContext.__assign({}, commonProps, { showBackButton: featureState.showBackButton, loginAttemptInfo: featureState.loginAttemptInfo, canChangeEmail: featureState.canChangeEmail, @@ -4265,7 +4300,7 @@ var MFATheme = function (_a) { ) : jsxRuntime.jsx( MFAHeader, - superTokens.__assign({}, commonProps, { + genericComponentOverrideContext.__assign({}, commonProps, { showBackButton: featureState.showBackButton, onBackButtonClicked: onBackButtonClicked, contactMethod: @@ -4279,42 +4314,54 @@ var MFATheme = function (_a) { activeScreen === MFAScreens.EmailForm ? jsxRuntime.jsx( EmailForm, - superTokens.__assign({}, commonProps, { + genericComponentOverrideContext.__assign({}, commonProps, { footer: jsxRuntime.jsx( MFAFooter, - superTokens.__assign({}, commonProps, { - onSignOutClicked: props.onSignOutClicked, - canChangeEmail: featureState.canChangeEmail, - }) + genericComponentOverrideContext.__assign( + {}, + commonProps, + { + onSignOutClicked: props.onSignOutClicked, + canChangeEmail: featureState.canChangeEmail, + } + ) ), }) ) : activeScreen === MFAScreens.PhoneForm ? jsxRuntime.jsx( PhoneForm, - superTokens.__assign({}, commonProps, { + genericComponentOverrideContext.__assign({}, commonProps, { footer: jsxRuntime.jsx( MFAFooter, - superTokens.__assign({}, commonProps, { - onSignOutClicked: props.onSignOutClicked, - canChangeEmail: featureState.canChangeEmail, - }) + genericComponentOverrideContext.__assign( + {}, + commonProps, + { + onSignOutClicked: props.onSignOutClicked, + canChangeEmail: featureState.canChangeEmail, + } + ) ), }) ) : activeScreen === MFAScreens.UserInputCodeForm ? jsxRuntime.jsx( UserInputCodeForm, - superTokens.__assign({}, commonProps, { + genericComponentOverrideContext.__assign({}, commonProps, { loginAttemptInfo: featureState.loginAttemptInfo, onSuccess: props.onSuccess, footer: jsxRuntime.jsx( MFAOTPFooter, - superTokens.__assign({}, commonProps, { - onSignOutClicked: props.onSignOutClicked, - canChangeEmail: featureState.canChangeEmail, - loginAttemptInfo: featureState.loginAttemptInfo, - }) + genericComponentOverrideContext.__assign( + {}, + commonProps, + { + onSignOutClicked: props.onSignOutClicked, + canChangeEmail: featureState.canChangeEmail, + loginAttemptInfo: featureState.loginAttemptInfo, + } + ) ), }) ) @@ -4331,7 +4378,7 @@ var MFATheme = function (_a) { ); }; function MFAThemeWrapper(props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeScreen = getActiveScreen$2(props); var activeStyle; @@ -4346,12 +4393,12 @@ function MFAThemeWrapper(props) { } return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [ @@ -4364,7 +4411,7 @@ function MFAThemeWrapper(props) { { children: jsxRuntime.jsx( MFATheme, - superTokens.__assign({}, props, { activeScreen: activeScreen }) + genericComponentOverrideContext.__assign({}, props, { activeScreen: activeScreen }) ), } ) @@ -4404,30 +4451,31 @@ var useFeatureReducer = function () { if (!oldState.loginAttemptInfo) { return oldState; } - return superTokens.__assign(superTokens.__assign({}, oldState), { - error: undefined, - loginAttemptInfo: superTokens.__assign(superTokens.__assign({}, oldState.loginAttemptInfo), { - lastResend: action.timestamp, - }), - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, oldState), + { + error: undefined, + loginAttemptInfo: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, oldState.loginAttemptInfo), + { lastResend: action.timestamp } + ), + } + ); case "restartFlow": - return superTokens.__assign(superTokens.__assign({}, oldState), { - error: action.error, - loginAttemptInfo: undefined, - showAccessDenied: !oldState.canChangeEmail, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, oldState), + { error: action.error, loginAttemptInfo: undefined, showAccessDenied: !oldState.canChangeEmail } + ); case "setError": - return superTokens.__assign(superTokens.__assign({}, oldState), { - loaded: true, - error: action.error, - showAccessDenied: action.showAccessDenied, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, oldState), + { loaded: true, error: action.error, showAccessDenied: action.showAccessDenied } + ); case "startVerify": - return superTokens.__assign(superTokens.__assign({}, oldState), { - loaded: true, - loginAttemptInfo: action.loginAttemptInfo, - error: undefined, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, oldState), + { loaded: true, loginAttemptInfo: action.loginAttemptInfo, error: undefined } + ); default: return oldState; } @@ -4442,23 +4490,25 @@ var useFeatureReducer = function () { }, function (initArg) { var error = undefined; - var errorQueryParam = superTokens.getQueryParams("error"); + var errorQueryParam = genericComponentOverrideContext.getQueryParams("error"); if (errorQueryParam !== null) { error = "SOMETHING_WENT_WRONG_ERROR"; } - return superTokens.__assign(superTokens.__assign({}, initArg), { error: error }); + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, initArg), { + error: error, + }); } ); }; function useChildProps$3(recipe$1, recipeImplementation, state, contactMethod, dispatch, userContext, navigate) { var _this = this; - var rethrowInRender = superTokens.useRethrowInRender(); + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); return React.useMemo( function () { var _a; return { onSuccess: function () { - var redirectToPath = superTokens.getRedirectToPathFromURL(); + var redirectToPath = genericComponentOverrideContext.getRedirectToPathFromURL(); return types.Session.getInstanceOrThrow() .validateGlobalClaimsAndHandleSuccessRedirection( undefined, @@ -4470,8 +4520,8 @@ function useChildProps$3(recipe$1, recipeImplementation, state, contactMethod, d .catch(rethrowInRender); }, onSignOutClicked: function () { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -4498,8 +4548,8 @@ function useChildProps$3(recipe$1, recipeImplementation, state, contactMethod, d }); }, onBackButtonClicked: function () { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: if (!state.loginAttemptInfo) return [3 /*break*/, 2]; @@ -4531,9 +4581,9 @@ function useChildProps$3(recipe$1, recipeImplementation, state, contactMethod, d }); }, onFetchError: function (err) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var invalidClaims, evInstance; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -4631,17 +4681,20 @@ var MFAFeatureInner = function (props) { props.children === undefined && jsxRuntime.jsx( MFAThemeWrapper, - superTokens.__assign({}, childProps, { featureState: state, dispatch: dispatch }) + genericComponentOverrideContext.__assign({}, childProps, { + featureState: state, + dispatch: dispatch, + }) ), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { return React__namespace.cloneElement( child, - superTokens.__assign(superTokens.__assign({}, childProps), { - featureState: state, - dispatch: dispatch, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, childProps), + { featureState: state, dispatch: dispatch } + ) ); } return child; @@ -4653,17 +4706,22 @@ var MFAFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { - useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, + useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, defaultStore: defaultTranslationsPasswordless, }, - { children: jsxRuntime.jsx(MFAFeatureInner, superTokens.__assign({}, props)) } + { + children: jsxRuntime.jsx( + MFAFeatureInner, + genericComponentOverrideContext.__assign({}, props) + ), + } ) ), } @@ -4674,8 +4732,8 @@ function useOnLoad(props, recipeImplementation, dispatch, userContext) { var _this = this; var fetchMFAInfo = React__namespace.useCallback( function () { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe$3.MultiFactorAuth.getInstanceOrThrow().webJSRecipe.resyncSessionAndFetchMFAInfo({ @@ -4695,7 +4753,7 @@ function useOnLoad(props, recipeImplementation, dispatch, userContext) { ); var onLoad = React__namespace.useCallback( function (mfaInfo) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var error, errorQueryParam, doSetup, @@ -4708,12 +4766,12 @@ function useOnLoad(props, recipeImplementation, dispatch, userContext) { err_1, invalidClaims, evInstance; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: error = undefined; - errorQueryParam = superTokens.getQueryParams("error"); - doSetup = superTokens.getQueryParams("setup"); + errorQueryParam = genericComponentOverrideContext.getQueryParams("error"); + doSetup = genericComponentOverrideContext.getQueryParams("setup"); if (errorQueryParam !== null) { error = "SOMETHING_WENT_WRONG_ERROR"; } @@ -4774,10 +4832,10 @@ function useOnLoad(props, recipeImplementation, dispatch, userContext) { return [ 4 /*yield*/, recipeImplementation.createCode( - superTokens.__assign(superTokens.__assign({}, createCodeInfo), { - tryLinkingWithSessionUser: true, - userContext: userContext, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, createCodeInfo), + { tryLinkingWithSessionUser: true, userContext: userContext } + ) ), ]; case 5: @@ -4880,15 +4938,15 @@ function useOnLoad(props, recipeImplementation, dispatch, userContext) { }, [dispatch, recipeImplementation, props.contactMethod, userContext] ); - superTokens.useOnMountAPICall(fetchMFAInfo, onLoad, handleLoadError); + genericComponentOverrideContext.useOnMountAPICall(fetchMFAInfo, onLoad, handleLoadError); } function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { var _this = this; - return superTokens.__assign(superTokens.__assign({}, originalImpl), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImpl), { createCode: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var contactInfo, phoneNumberUtils, contactMethod, additionalAttemptInfo, res, loginAttemptInfo; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, getPhoneNumberUtils()]; @@ -4908,17 +4966,21 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { lastResend: Date.now(), contactMethod: contactMethod, contactInfo: contactInfo, - redirectToPath: superTokens.getRedirectToPathFromURL(), + redirectToPath: genericComponentOverrideContext.getRedirectToPathFromURL(), }; return [ 4 /*yield*/, originalImpl.createCode( - superTokens.__assign(superTokens.__assign({}, input), { - tryLinkingWithSessionUser: true, - userContext: superTokens.__assign(superTokens.__assign({}, input.userContext), { - additionalAttemptInfo: additionalAttemptInfo, - }), - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, input), + { + tryLinkingWithSessionUser: true, + userContext: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, input.userContext), + { additionalAttemptInfo: additionalAttemptInfo } + ), + } + ) ), ]; case 2: @@ -4941,10 +5003,10 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { }); }, resendCode: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var res, loginAttemptInfo, timestamp; var _a; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: return [4 /*yield*/, originalImpl.resendCode(input)]; @@ -4965,13 +5027,17 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { 4 /*yield*/, originalImpl.setLoginAttemptInfo({ userContext: input.userContext, - attemptInfo: superTokens.__assign(superTokens.__assign({}, loginAttemptInfo), { - tryLinkingWithSessionUser: - (_a = loginAttemptInfo.tryLinkingWithSessionUser) !== null && _a !== void 0 - ? _a - : true, - lastResend: timestamp, - }), + attemptInfo: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, loginAttemptInfo), + { + tryLinkingWithSessionUser: + (_a = loginAttemptInfo.tryLinkingWithSessionUser) !== null && + _a !== void 0 + ? _a + : true, + lastResend: timestamp, + } + ), }), ]; case 3: @@ -4999,9 +5065,9 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { }); }, consumeCode: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var res; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.consumeCode(input)]; @@ -5052,8 +5118,8 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { }); }, clearLoginAttemptInfo: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -5064,7 +5130,7 @@ function getModifiedRecipeImplementation$3(originalImpl, config, dispatch) { ]; case 1: _a.sent(); - superTokens.clearErrorQueryParam(); + genericComponentOverrideContext.clearErrorQueryParam(); dispatch({ type: "restartFlow", error: undefined }); return [2 /*return*/]; } @@ -5106,14 +5172,14 @@ var EmailOrPhoneForm = uiEntry.withOverride( label: "", labelComponent: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ jsxRuntime.jsx(formBase.Label, { value: "PWLESS_SIGN_IN_UP_PHONE_LABEL" }), jsxRuntime.jsx( "a", - superTokens.__assign( + genericComponentOverrideContext.__assign( { onClick: function () { return setIsPhoneNumber(false); @@ -5142,7 +5208,7 @@ var EmailOrPhoneForm = uiEntry.withOverride( label: "", labelComponent: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ @@ -5152,7 +5218,7 @@ var EmailOrPhoneForm = uiEntry.withOverride( }), jsxRuntime.jsx( "a", - superTokens.__assign( + genericComponentOverrideContext.__assign( { onClick: function () { return setIsPhoneNumber(function (v) { @@ -5180,10 +5246,10 @@ var EmailOrPhoneForm = uiEntry.withOverride( buttonLabel: "PWLESS_SIGN_IN_UP_CONTINUE_BUTTON", onSuccess: props.onSuccess, callAPI: function (formFields) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var contactInfo, phoneNumber, validationRes, email, validationRes, response; var _a, _b; - return superTokens.__generator(this, function (_c) { + return genericComponentOverrideContext.__generator(this, function (_c) { switch (_c.label) { case 0: if (!isPhoneNumber) return [3 /*break*/, 2]; @@ -5226,10 +5292,13 @@ var EmailOrPhoneForm = uiEntry.withOverride( return [ 4 /*yield*/, props.recipeImplementation.createCode( - superTokens.__assign(superTokens.__assign({}, contactInfo), { - // tryLinkingWithSessionUser is set by the fn override - userContext: userContext, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, contactInfo), + { + // tryLinkingWithSessionUser is set by the fn override + userContext: userContext, + } + ) ), ]; case 5: @@ -5260,7 +5329,7 @@ var SignInUpScreens; */ var SignInUpTheme$1 = function (_a) { var activeScreen = _a.activeScreen, - props = superTokens.__rest(_a, ["activeScreen"]); + props = genericComponentOverrideContext.__rest(_a, ["activeScreen"]); var commonProps = { recipeImplementation: props.recipeImplementation, config: props.config, @@ -5271,15 +5340,15 @@ var SignInUpTheme$1 = function (_a) { validatePhoneNumber: props.validatePhoneNumber, }; return activeScreen === SignInUpScreens.EmailForm - ? jsxRuntime.jsx(EmailForm, superTokens.__assign({}, commonProps)) + ? jsxRuntime.jsx(EmailForm, genericComponentOverrideContext.__assign({}, commonProps)) : activeScreen === SignInUpScreens.PhoneForm - ? jsxRuntime.jsx(PhoneForm, superTokens.__assign({}, commonProps)) + ? jsxRuntime.jsx(PhoneForm, genericComponentOverrideContext.__assign({}, commonProps)) : activeScreen === SignInUpScreens.EmailOrPhoneForm - ? jsxRuntime.jsx(EmailOrPhoneForm, superTokens.__assign({}, commonProps)) + ? jsxRuntime.jsx(EmailOrPhoneForm, genericComponentOverrideContext.__assign({}, commonProps)) : null; }; function SignInUpThemeWrapper$1(props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeScreen = getActiveScreen$1(props.factorIds); var activeStyle; @@ -5292,12 +5361,12 @@ function SignInUpThemeWrapper$1(props) { } return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, activeStyle], @@ -5305,7 +5374,7 @@ function SignInUpThemeWrapper$1(props) { { children: jsxRuntime.jsx( SignInUpTheme$1, - superTokens.__assign({}, props, { activeScreen: activeScreen }) + genericComponentOverrideContext.__assign({}, props, { activeScreen: activeScreen }) ), } ) @@ -5347,16 +5416,16 @@ function useChildProps$2( }, [recipe$1] ); - var rethrowInRender = superTokens.useRethrowInRender(); + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); return React.useMemo( function () { var _a; return { userContext: userContext, onSuccess: function (result) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var payloadAfterCall; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, , 3]); @@ -5397,9 +5466,9 @@ function useChildProps$2( onError: onError, clearError: clearError, onFetchError: function (err) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var invalidClaims, evInstance; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -5483,11 +5552,14 @@ var SignInUpFeatureInner = function (props) { return jsxRuntime.jsxs(React.Fragment, { children: [ props.children === undefined && - jsxRuntime.jsx(SignInUpThemeWrapper$1, superTokens.__assign({}, childProps)), + jsxRuntime.jsx(SignInUpThemeWrapper$1, genericComponentOverrideContext.__assign({}, childProps)), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { - return React__namespace.cloneElement(child, superTokens.__assign({}, childProps)); + return React__namespace.cloneElement( + child, + genericComponentOverrideContext.__assign({}, childProps) + ); } return child; }), @@ -5498,19 +5570,19 @@ var SignInUpFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { recipeComponentOverrides: recipeComponentOverrides }, - { children: jsxRuntime.jsx(SignInUpFeatureInner, superTokens.__assign({}, props)) } + { children: jsxRuntime.jsx(SignInUpFeatureInner, genericComponentOverrideContext.__assign({}, props)) } ) ); }; function getModifiedRecipeImplementation$2(originalImpl, config, rebuildAuthPage) { var _this = this; - return superTokens.__assign(superTokens.__assign({}, originalImpl), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImpl), { createCode: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var contactInfo, phoneNumberUtils, contactMethod, additionalAttemptInfo, res; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, getPhoneNumberUtils()]; @@ -5530,17 +5602,21 @@ function getModifiedRecipeImplementation$2(originalImpl, config, rebuildAuthPage lastResend: Date.now(), contactMethod: contactMethod, contactInfo: contactInfo, - redirectToPath: superTokens.getRedirectToPathFromURL(), + redirectToPath: genericComponentOverrideContext.getRedirectToPathFromURL(), }; return [ 4 /*yield*/, originalImpl.createCode( - superTokens.__assign(superTokens.__assign({}, input), { - tryLinkingWithSessionUser: false, - userContext: superTokens.__assign(superTokens.__assign({}, input.userContext), { - additionalAttemptInfo: additionalAttemptInfo, - }), - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, input), + { + tryLinkingWithSessionUser: false, + userContext: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, input.userContext), + { additionalAttemptInfo: additionalAttemptInfo } + ), + } + ) ), ]; case 2: @@ -5571,14 +5647,14 @@ var ContinueWithPasswordlessFooter = function (_a) { } return jsxRuntime.jsx( "a", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "link linkButton continueWithPasswordlessLink", onClick: function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var phoneNumber, validationRes, email, validationRes; var _a, _b; - return superTokens.__generator(this, function (_c) { + return genericComponentOverrideContext.__generator(this, function (_c) { switch (_c.label) { case 0: if (!isPhoneNumber) return [3 /*break*/, 2]; @@ -5656,7 +5732,7 @@ var EPComboEmailForm = uiEntry.withOverride( validate: recipe$2.defaultValidate, labelComponent: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ @@ -5666,7 +5742,7 @@ var EPComboEmailForm = uiEntry.withOverride( }), jsxRuntime.jsx( "a", - superTokens.__assign( + genericComponentOverrideContext.__assign( { onClick: function () { return recipe$1.EmailPassword.getInstanceOrThrow().redirect({ @@ -5692,10 +5768,10 @@ var EPComboEmailForm = uiEntry.withOverride( buttonLabel: "PWLESS_SIGN_IN_UP_CONTINUE_BUTTON", onSuccess: props.onSuccess, callAPI: function (formFields) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var email, validationRes; var _a; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: email = @@ -5761,14 +5837,14 @@ var EPComboEmailOrPhoneForm = uiEntry.withOverride( label: "", labelComponent: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ jsxRuntime.jsx(formBase.Label, { value: "PWLESS_SIGN_IN_UP_PHONE_LABEL" }), jsxRuntime.jsx( "a", - superTokens.__assign( + genericComponentOverrideContext.__assign( { onClick: function () { return props.setIsPhoneNumber(false); @@ -5797,14 +5873,14 @@ var EPComboEmailOrPhoneForm = uiEntry.withOverride( label: "", labelComponent: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ jsxRuntime.jsx(formBase.Label, { value: "PWLESS_SIGN_IN_UP_EMAIL_LABEL" }), jsxRuntime.jsx( "a", - superTokens.__assign( + genericComponentOverrideContext.__assign( { onClick: function () { return props.setIsPhoneNumber(true); @@ -5837,7 +5913,7 @@ var EPComboEmailOrPhoneForm = uiEntry.withOverride( validate: recipe$2.defaultValidate, labelComponent: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "formLabelWithLinkWrapper" }, { children: [ @@ -5847,7 +5923,7 @@ var EPComboEmailOrPhoneForm = uiEntry.withOverride( }), jsxRuntime.jsx( "a", - superTokens.__assign( + genericComponentOverrideContext.__assign( { onClick: function () { return recipe$1.EmailPassword.getInstanceOrThrow().redirect({ @@ -5872,10 +5948,10 @@ var EPComboEmailOrPhoneForm = uiEntry.withOverride( formFields: formFields, buttonLabel: "PWLESS_SIGN_IN_UP_CONTINUE_BUTTON", callAPI: function (formFields) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var phoneNumber, validationRes, email, validationRes; var _a, _b; - return superTokens.__generator(this, function (_c) { + return genericComponentOverrideContext.__generator(this, function (_c) { switch (_c.label) { case 0: if (!props.isPhoneNumber) return [3 /*break*/, 2]; @@ -5948,27 +6024,27 @@ var SignInUpEPComboScreens; */ var SignInUpTheme = function (_a) { var activeScreen = _a.activeScreen, - props = superTokens.__rest(_a, ["activeScreen"]); - var commonProps = superTokens.__assign({}, props); + props = genericComponentOverrideContext.__rest(_a, ["activeScreen"]); + var commonProps = genericComponentOverrideContext.__assign({}, props); return activeScreen === SignInUpEPComboScreens.EmailForm - ? jsxRuntime.jsx(EPComboEmailForm, superTokens.__assign({}, commonProps)) + ? jsxRuntime.jsx(EPComboEmailForm, genericComponentOverrideContext.__assign({}, commonProps)) : activeScreen === SignInUpEPComboScreens.EmailOrPhoneForm - ? jsxRuntime.jsx(EPComboEmailOrPhoneForm, superTokens.__assign({}, commonProps)) + ? jsxRuntime.jsx(EPComboEmailOrPhoneForm, genericComponentOverrideContext.__assign({}, commonProps)) : null; }; function SignInUpThemeWrapper(props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeScreen = getActiveScreen(props.factorIds); var activeStyle = props.config.signInUpFeature.emailOrPhoneFormStyle; return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, activeStyle], @@ -5976,7 +6052,7 @@ function SignInUpThemeWrapper(props) { { children: jsxRuntime.jsx( SignInUpTheme, - superTokens.__assign({}, props, { activeScreen: activeScreen }) + genericComponentOverrideContext.__assign({}, props, { activeScreen: activeScreen }) ), } ) @@ -6023,7 +6099,7 @@ function useChildProps$1( var _c = React__namespace.useState(false), showContinueWithPasswordlessLink = _c[0], setShowContinueWithPasswordlessLink = _c[1]; - var rethrowInRender = superTokens.useRethrowInRender(); + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); return React.useMemo( function () { var _a; @@ -6040,9 +6116,9 @@ function useChildProps$1( showPasswordField: showPasswordField, showContinueWithPasswordlessLink: showContinueWithPasswordlessLink, onContactInfoSubmit: function (contactInfo) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var createRes, email, _a, epExists, pwlessExists, createRes; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: if (!isPhoneNumber) return [3 /*break*/, 2]; @@ -6120,14 +6196,14 @@ function useChildProps$1( }); }, onPasswordSubmit: function (formFields) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var validationErrors, response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, - superTokens.validateForm( + genericComponentOverrideContext.validateForm( formFields, recipe$1.EmailPassword.getInstanceOrThrow().config.signInAndUpFeature .signInForm.formFields @@ -6163,9 +6239,10 @@ function useChildProps$1( } else { return [ 2 /*return*/, - superTokens.__assign(superTokens.__assign({}, response), { - isEmailPassword: true, - }), + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, response), + { isEmailPassword: true } + ), ]; } } @@ -6173,19 +6250,19 @@ function useChildProps$1( }); }, onContinueWithPasswordlessClick: function (contactInfo) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var createInfo, createRes; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: createInfo = isPhoneNumber ? { phoneNumber: contactInfo } : { email: contactInfo }; return [ 4 /*yield*/, recipeImplementation.createCode( - superTokens.__assign(superTokens.__assign({}, createInfo), { - tryLinkingWithSessionUser: false, - userContext: userContext, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, createInfo), + { tryLinkingWithSessionUser: false, userContext: userContext } + ) ), ]; case 1: @@ -6201,9 +6278,9 @@ function useChildProps$1( }); }, onSuccess: function (result) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var payloadAfterCall; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: if (!result.isEmailPassword) { @@ -6251,9 +6328,9 @@ function useChildProps$1( onError: onError, clearError: clearError, onFetchError: function (err) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var invalidClaims, evInstance; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -6344,11 +6421,15 @@ var SignInUpEPComboFeatureInner = function (props) { ); return jsxRuntime.jsxs(React.Fragment, { children: [ - props.children === undefined && jsxRuntime.jsx(SignInUpThemeWrapper, superTokens.__assign({}, childProps)), + props.children === undefined && + jsxRuntime.jsx(SignInUpThemeWrapper, genericComponentOverrideContext.__assign({}, childProps)), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { - return React__namespace.cloneElement(child, superTokens.__assign({}, childProps)); + return React__namespace.cloneElement( + child, + genericComponentOverrideContext.__assign({}, childProps) + ); } return child; }), @@ -6359,19 +6440,24 @@ var SignInUpEPComboFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { recipeComponentOverrides: recipeComponentOverrides }, - { children: jsxRuntime.jsx(SignInUpEPComboFeatureInner, superTokens.__assign({}, props)) } + { + children: jsxRuntime.jsx( + SignInUpEPComboFeatureInner, + genericComponentOverrideContext.__assign({}, props) + ), + } ) ); }; function getModifiedRecipeImplementation$1(originalImpl, config, rebuildAuthPage) { var _this = this; - return superTokens.__assign(superTokens.__assign({}, originalImpl), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImpl), { createCode: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var contactInfo, phoneNumberUtils, contactMethod, additionalAttemptInfo, res; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, getPhoneNumberUtils()]; @@ -6391,17 +6477,21 @@ function getModifiedRecipeImplementation$1(originalImpl, config, rebuildAuthPage lastResend: Date.now(), contactMethod: contactMethod, contactInfo: contactInfo, - redirectToPath: superTokens.getRedirectToPathFromURL(), + redirectToPath: genericComponentOverrideContext.getRedirectToPathFromURL(), }; return [ 4 /*yield*/, originalImpl.createCode( - superTokens.__assign(superTokens.__assign({}, input), { - tryLinkingWithSessionUser: false, - userContext: superTokens.__assign(superTokens.__assign({}, input.userContext), { - additionalAttemptInfo: additionalAttemptInfo, - }), - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, input), + { + tryLinkingWithSessionUser: false, + userContext: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, input.userContext), + { additionalAttemptInfo: additionalAttemptInfo } + ), + } + ) ), ]; case 2: @@ -6436,15 +6526,15 @@ function useChildProps( }, [recipe$1, onError, rebuildAuthPage] ); - var rethrowInRender = superTokens.useRethrowInRender(); + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); return React.useMemo( function () { return { userContext: userContext, onSuccess: function (result) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var payloadAfterCall; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, , 3]); @@ -6482,9 +6572,9 @@ function useChildProps( }); }, onFetchError: function (err) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var invalidClaims, evInstance; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -6565,12 +6655,15 @@ var UserInputCodeFeatureInner = function (props) { props.children === undefined && jsxRuntime.jsx( UserInputCodeFormScreenWrapper, - superTokens.__assign({}, childProps, { userContext: props.userContext }) + genericComponentOverrideContext.__assign({}, childProps, { userContext: props.userContext }) ), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { - return React__namespace.cloneElement(child, superTokens.__assign({}, childProps)); + return React__namespace.cloneElement( + child, + genericComponentOverrideContext.__assign({}, childProps) + ); } return child; }), @@ -6581,20 +6674,20 @@ var UserInputCodeFeature = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { recipeComponentOverrides: recipeComponentOverrides }, - { children: jsxRuntime.jsx(UserInputCodeFeatureInner, superTokens.__assign({}, props)) } + { children: jsxRuntime.jsx(UserInputCodeFeatureInner, genericComponentOverrideContext.__assign({}, props)) } ) ); }; function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage) { var _this = this; - return superTokens.__assign(superTokens.__assign({}, originalImpl), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImpl), { resendCode: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var res, loginAttemptInfo, timestamp; var _a; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: return [4 /*yield*/, originalImpl.resendCode(input)]; @@ -6615,13 +6708,17 @@ function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage 4 /*yield*/, originalImpl.setLoginAttemptInfo({ userContext: input.userContext, - attemptInfo: superTokens.__assign(superTokens.__assign({}, loginAttemptInfo), { - tryLinkingWithSessionUser: - (_a = loginAttemptInfo.tryLinkingWithSessionUser) !== null && _a !== void 0 - ? _a - : false, - lastResend: timestamp, - }), + attemptInfo: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, loginAttemptInfo), + { + tryLinkingWithSessionUser: + (_a = loginAttemptInfo.tryLinkingWithSessionUser) !== null && + _a !== void 0 + ? _a + : false, + lastResend: timestamp, + } + ), }), ]; case 3: @@ -6649,9 +6746,9 @@ function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage }); }, consumeCode: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var res; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.consumeCode(input)]; @@ -6700,8 +6797,8 @@ function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage }); }, clearLoginAttemptInfo: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ @@ -6712,7 +6809,7 @@ function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage ]; case 1: _a.sent(); - superTokens.clearErrorQueryParam(); + genericComponentOverrideContext.clearErrorQueryParam(); rebuildAuthPage(); return [2 /*return*/]; } @@ -6723,7 +6820,7 @@ function getModifiedRecipeImplementation(originalImpl, setError, rebuildAuthPage } var PasswordlessPreBuiltUI = /** @class */ (function (_super) { - superTokens.__extends(PasswordlessPreBuiltUI, _super); + genericComponentOverrideContext.__extends(PasswordlessPreBuiltUI, _super); function PasswordlessPreBuiltUI(recipeInstance) { var _this = _super.call(this) || this; _this.recipeInstance = recipeInstance; @@ -6739,7 +6836,9 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { new NormalisedURLPath__default.default("/verify") ); features[normalisedFullPath.getAsStringDangerous()] = { - matches: superTokens.matchRecipeIdUsingQueryParams(_this.recipeInstance.config.recipeId), + matches: genericComponentOverrideContext.matchRecipeIdUsingQueryParams( + _this.recipeInstance.config.recipeId + ), component: function (props) { return _this.getFeatureComponent("linkClickedScreen", props, useComponentOverrides); }, @@ -6751,7 +6850,9 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { new NormalisedURLPath__default.default("/mfa/otp-phone") ); features[normalisedFullPathPhone.getAsStringDangerous()] = { - matches: superTokens.matchRecipeIdUsingQueryParams(_this.recipeInstance.config.recipeId), + matches: genericComponentOverrideContext.matchRecipeIdUsingQueryParams( + _this.recipeInstance.config.recipeId + ), component: function (props) { return _this.getFeatureComponent("otp-phone", props, useComponentOverrides); }, @@ -6761,7 +6862,9 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { new NormalisedURLPath__default.default("/mfa/otp-email") ); features[normalisedFullPathEmail.getAsStringDangerous()] = { - matches: superTokens.matchRecipeIdUsingQueryParams(_this.recipeInstance.config.recipeId), + matches: genericComponentOverrideContext.matchRecipeIdUsingQueryParams( + _this.recipeInstance.config.recipeId + ), component: function (props) { return _this.getFeatureComponent("otp-email", props, useComponentOverrides); }, @@ -6777,19 +6880,21 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { if (componentName === "linkClickedScreen") { return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( session.SessionAuth, - superTokens.__assign( + genericComponentOverrideContext.__assign( { requireAuth: false, doRedirection: false }, { children: jsxRuntime.jsx( LinkClickedScreen, - superTokens.__assign({ recipe: _this.recipeInstance }, props, { - useComponentOverrides: useComponentOverrides, - }) + genericComponentOverrideContext.__assign( + { recipe: _this.recipeInstance }, + props, + { useComponentOverrides: useComponentOverrides } + ) ), } ) @@ -6801,12 +6906,12 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { if (componentName === "otp-email") { return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( session.SessionAuth, - superTokens.__assign( + genericComponentOverrideContext.__assign( { overrideGlobalClaimValidators: function () { return []; @@ -6815,7 +6920,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { { children: jsxRuntime.jsx( MFAFeature, - superTokens.__assign( + genericComponentOverrideContext.__assign( { recipe: _this.recipeInstance, useComponentOverrides: useComponentOverrides, @@ -6835,12 +6940,12 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { if (componentName === "otp-phone") { return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( session.SessionAuth, - superTokens.__assign( + genericComponentOverrideContext.__assign( { overrideGlobalClaimValidators: function () { return []; @@ -6849,7 +6954,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { { children: jsxRuntime.jsx( MFAFeature, - superTokens.__assign( + genericComponentOverrideContext.__assign( { recipe: _this.recipeInstance, useComponentOverrides: useComponentOverrides, @@ -6902,16 +7007,16 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { types.FactorIds.OTP_EMAIL, types.FactorIds.OTP_PHONE, ]); - var res = superTokens.__spreadArray( - superTokens.__spreadArray( + var res = genericComponentOverrideContext.__spreadArray( + genericComponentOverrideContext.__spreadArray( [ { type: "FULL_PAGE", preloadInfoAndRunChecks: function (firstFactors, userContext) { var _b, _c; - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var loginAttemptInfo; - return superTokens.__generator(this, function (_d) { + return genericComponentOverrideContext.__generator(this, function (_d) { switch (_d.label) { case 0: return [ @@ -6989,10 +7094,10 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { }, component: function (_b) { var preloadInfo = _b.preloadInfo, - props = superTokens.__rest(_b, ["preloadInfo"]); + props = genericComponentOverrideContext.__rest(_b, ["preloadInfo"]); return jsxRuntime.jsx( LinkSentFeature, - superTokens.__assign({}, props, { + genericComponentOverrideContext.__assign({}, props, { recipe: _this.recipeInstance, useComponentOverrides: recipe$2.useContext, loginAttemptInfo: preloadInfo, @@ -7005,9 +7110,9 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { type: "FULL_PAGE", preloadInfoAndRunChecks: function (firstFactors, userContext) { var _b, _c; - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var loginAttemptInfo; - return superTokens.__generator(this, function (_d) { + return genericComponentOverrideContext.__generator(this, function (_d) { switch (_d.label) { case 0: return [ @@ -7085,10 +7190,10 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { }, component: function (_b) { var preloadInfo = _b.preloadInfo, - props = superTokens.__rest(_b, ["preloadInfo"]); + props = genericComponentOverrideContext.__rest(_b, ["preloadInfo"]); return jsxRuntime.jsx( UserInputCodeFeature, - superTokens.__assign({}, props, { + genericComponentOverrideContext.__assign({}, props, { recipe: _this.recipeInstance, useComponentOverrides: recipe$2.useContext, loginAttemptInfo: preloadInfo, @@ -7106,7 +7211,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { component: function (props) { return React.createElement( SignInUpFeature, - superTokens.__assign({}, props, { + genericComponentOverrideContext.__assign({}, props, { key: factors.join("|"), recipe: _this.recipeInstance, useComponentOverrides: recipe$2.useContext, @@ -7126,7 +7231,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { component: function (props) { return jsxRuntime.jsx( ContinueWithPasswordlessFeature, - superTokens.__assign({}, props, { + genericComponentOverrideContext.__assign({}, props, { recipe: _this.recipeInstance, factorIds: factors, useComponentOverrides: recipe$2.useContext, @@ -7146,7 +7251,11 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { res, factorCombos .map(function (combo) { - return superTokens.__spreadArray([types.FactorIds.EMAILPASSWORD], combo, true); + return genericComponentOverrideContext.__spreadArray( + [types.FactorIds.EMAILPASSWORD], + combo, + true + ); }) .map(function (factors) { return { @@ -7156,7 +7265,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { component: function (props) { return React.createElement( SignInUpEPComboFeature, - superTokens.__assign({}, props, { + genericComponentOverrideContext.__assign({}, props, { key: factors.join("|"), recipe: _this.recipeInstance, useComponentOverrides: recipe$2.useContext, @@ -7174,7 +7283,7 @@ var PasswordlessPreBuiltUI = /** @class */ (function (_super) { }; // For tests PasswordlessPreBuiltUI.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } PasswordlessPreBuiltUI.instance = undefined; @@ -7202,10 +7311,10 @@ function getAllChoices(choices) { return [[]]; } var subChoices = getAllChoices(choices.slice(1)); - return superTokens.__spreadArray( - superTokens.__spreadArray([], subChoices, true), + return genericComponentOverrideContext.__spreadArray( + genericComponentOverrideContext.__spreadArray([], subChoices, true), subChoices.map(function (a) { - return superTokens.__spreadArray([choices[0]], a, true); + return genericComponentOverrideContext.__spreadArray([choices[0]], a, true); }), true ); diff --git a/lib/build/recipe/oauth2provider/componentOverrideContext.d.ts b/lib/build/recipe/oauth2provider/componentOverrideContext.d.ts new file mode 100644 index 000000000..288fc18e7 --- /dev/null +++ b/lib/build/recipe/oauth2provider/componentOverrideContext.d.ts @@ -0,0 +1,9 @@ +/// +import type { ComponentOverrideMap } from "./types"; +declare const useContext: () => ComponentOverrideMap, + Provider: import("react").FC< + import("react").PropsWithChildren<{ + components: ComponentOverrideMap; + }> + >; +export { useContext as useRecipeComponentOverrideContext, Provider as RecipeComponentsOverrideContextProvider }; diff --git a/lib/build/recipe/oauth2provider/components/features/tryRefreshPage/index.d.ts b/lib/build/recipe/oauth2provider/components/features/tryRefreshPage/index.d.ts new file mode 100644 index 000000000..dfde96e31 --- /dev/null +++ b/lib/build/recipe/oauth2provider/components/features/tryRefreshPage/index.d.ts @@ -0,0 +1,11 @@ +import * as React from "react"; +import type { FeatureBaseProps, UserContext } from "../../../../../types"; +import type Recipe from "../../../recipe"; +import type { ComponentOverrideMap } from "../../../types"; +declare type Prop = FeatureBaseProps<{ + recipe: Recipe; + userContext?: UserContext; + useComponentOverrides: () => ComponentOverrideMap; +}>; +export declare const TryRefreshPage: React.FC; +export default TryRefreshPage; diff --git a/lib/build/recipe/oauth2provider/components/themes/translations.d.ts b/lib/build/recipe/oauth2provider/components/themes/translations.d.ts new file mode 100644 index 000000000..d361acb41 --- /dev/null +++ b/lib/build/recipe/oauth2provider/components/themes/translations.d.ts @@ -0,0 +1,3 @@ +export declare const defaultTranslationsOAuth2Provider: { + en: {}; +}; diff --git a/lib/build/recipe/oauth2provider/constants.d.ts b/lib/build/recipe/oauth2provider/constants.d.ts new file mode 100644 index 000000000..73ebf72dc --- /dev/null +++ b/lib/build/recipe/oauth2provider/constants.d.ts @@ -0,0 +1 @@ +export declare const DEFAULT_TRY_REFRESH_PATH = "/try-refresh"; diff --git a/lib/build/recipe/oauth2provider/functionOverrides.d.ts b/lib/build/recipe/oauth2provider/functionOverrides.d.ts new file mode 100644 index 000000000..f6163a931 --- /dev/null +++ b/lib/build/recipe/oauth2provider/functionOverrides.d.ts @@ -0,0 +1,6 @@ +import type { OnHandleEventContext } from "./types"; +import type { RecipeOnHandleEventFunction } from "../recipeModule/types"; +import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2provider"; +export declare const getFunctionOverrides: ( + onHandleEvent: RecipeOnHandleEventFunction +) => (originalImp: RecipeInterface) => RecipeInterface; diff --git a/lib/build/recipe/oauth2provider/index.d.ts b/lib/build/recipe/oauth2provider/index.d.ts index 77cd9b408..b37e1525a 100644 --- a/lib/build/recipe/oauth2provider/index.d.ts +++ b/lib/build/recipe/oauth2provider/index.d.ts @@ -1,3 +1,5 @@ +/// +import { RecipeComponentsOverrideContextProvider } from "./componentOverrideContext"; import { UserInput, GetRedirectionURLContext, PreAPIHookContext, OnHandleEventContext } from "./types"; import type { RecipeFunctionOptions, LoginInfo } from "supertokens-web-js/recipe/oauth2provider"; import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2provider"; @@ -25,6 +27,11 @@ export default class Wrapper { info: LoginInfo; fetchResponse: Response; }>; + static ComponentsOverrideProvider: import("react").FC< + import("react").PropsWithChildren<{ + components: import("./types").ComponentOverrideMap; + }> + >; } declare const init: typeof Wrapper.init; declare const getLoginChallengeInfo: typeof Wrapper.getLoginChallengeInfo; @@ -36,4 +43,5 @@ export { OnHandleEventContext, UserInput, RecipeInterface, + RecipeComponentsOverrideContextProvider, }; diff --git a/lib/build/recipe/oauth2provider/prebuiltui.d.ts b/lib/build/recipe/oauth2provider/prebuiltui.d.ts new file mode 100644 index 000000000..51f22d8ff --- /dev/null +++ b/lib/build/recipe/oauth2provider/prebuiltui.d.ts @@ -0,0 +1,42 @@ +/// +import { RecipeRouter } from "../recipeRouter"; +import OAuth2ProviderRecipe from "./recipe"; +import type { GenericComponentOverrideMap } from "../../components/componentOverride/componentOverrideContext"; +import type { FeatureBaseProps, RecipeFeatureComponentMap, UserContext } from "../../types"; +import type { AuthComponent } from "../../types"; +export declare class OAuth2ProviderPreBuiltUI extends RecipeRouter { + readonly recipeInstance: OAuth2ProviderRecipe; + static instance?: OAuth2ProviderPreBuiltUI; + languageTranslations: { + en: {}; + }; + constructor(recipeInstance: OAuth2ProviderRecipe); + static getInstanceOrInitAndGetInstance(): OAuth2ProviderPreBuiltUI; + static getFeatures(useComponentOverrides?: () => GenericComponentOverrideMap): RecipeFeatureComponentMap; + static getFeatureComponent( + componentName: "try-refresh-page", + props: any, + useComponentOverrides?: () => GenericComponentOverrideMap + ): JSX.Element; + getFeatures: (useComponentOverrides?: () => GenericComponentOverrideMap) => RecipeFeatureComponentMap; + getFeatureComponent: ( + _: "try-refresh-page", + props: FeatureBaseProps<{ + userContext?: UserContext; + }>, + useComponentOverrides?: () => GenericComponentOverrideMap + ) => JSX.Element; + getAuthComponents(): AuthComponent[]; + static reset(): void; + static TryRefreshPage: ( + props: FeatureBaseProps<{ + userContext?: UserContext; + }> + ) => JSX.Element; +} +declare const TryRefreshPage: ( + props: FeatureBaseProps<{ + userContext?: UserContext; + }> +) => JSX.Element; +export { TryRefreshPage }; diff --git a/lib/build/recipe/oauth2provider/recipe.d.ts b/lib/build/recipe/oauth2provider/recipe.d.ts index 3911833f7..88f243b82 100644 --- a/lib/build/recipe/oauth2provider/recipe.d.ts +++ b/lib/build/recipe/oauth2provider/recipe.d.ts @@ -7,12 +7,7 @@ import type { PreAndPostAPIHookAction, UserInput, } from "./types"; -import type { - RecipeInitResult, - NormalisedConfigWithAppInfoAndRecipeID, - WebJSRecipeInterface, - SuccessRedirectContextOAuth2, -} from "../../types"; +import type { RecipeInitResult, NormalisedConfigWithAppInfoAndRecipeID, WebJSRecipeInterface } from "../../types"; export default class OAuth2Provider extends RecipeModule< GetRedirectionURLContext, PreAndPostAPIHookAction, @@ -30,6 +25,6 @@ export default class OAuth2Provider extends RecipeModule< static init(config?: UserInput): RecipeInitResult; static getInstanceOrThrow(): OAuth2Provider; static getInstance(): OAuth2Provider | undefined; - getDefaultRedirectionURL(ctx: SuccessRedirectContextOAuth2): Promise; + getDefaultRedirectionURL(ctx: GetRedirectionURLContext): Promise; static reset(): void; } diff --git a/lib/build/recipe/oauth2provider/types.d.ts b/lib/build/recipe/oauth2provider/types.d.ts index 0221c29c1..874e3fcd5 100644 --- a/lib/build/recipe/oauth2provider/types.d.ts +++ b/lib/build/recipe/oauth2provider/types.d.ts @@ -4,7 +4,7 @@ import type { NormalisedConfig as NormalisedRecipeModuleConfig, } from "../recipeModule/types"; import type OverrideableBuilder from "supertokens-js-override"; -import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2provider/types"; +import type { LoginInfo, RecipeInterface } from "supertokens-web-js/recipe/oauth2provider/types"; export declare type PreAndPostAPIHookAction = "GET_LOGIN_CHALLENGE_INFO"; export declare type PreAPIHookContext = { action: PreAndPostAPIHookAction; @@ -13,6 +13,7 @@ export declare type PreAPIHookContext = { userContext: UserContext; }; export declare type UserInput = { + disableDefaultUI?: boolean; override?: { functions?: ( originalImplementation: RecipeInterface, @@ -25,12 +26,24 @@ export declare type NormalisedConfig = NormalisedRecipeModuleConfig< PreAndPostAPIHookAction, OnHandleEventContext > & { + disableDefaultUI: boolean; override: { - functions?: ( + functions: ( originalImplementation: RecipeInterface, builder: OverrideableBuilder ) => RecipeInterface; }; }; -export declare type GetRedirectionURLContext = SuccessRedirectContextOAuth2; -export declare type OnHandleEventContext = any; +export declare type ContinueOAuth2AfterRefreshRedirectContext = { + recipeId: "oauth2provider"; + action: "CONTINUE_OAUTH2_AFTER_REFRESH"; + loginChallenge: string; +}; +export declare type GetRedirectionURLContext = SuccessRedirectContextOAuth2 | ContinueOAuth2AfterRefreshRedirectContext; +export declare type OnHandleEventContext = { + action: "LOADED_LOGIN_CHALLENGE"; + loginChallenge: string; + loginInfo: LoginInfo; + userContext: UserContext; +}; +export declare type ComponentOverrideMap = any; diff --git a/lib/build/recipeModule-shared.js b/lib/build/recipeModule-shared.js index 096e6ddb4..709d6a3fe 100644 --- a/lib/build/recipeModule-shared.js +++ b/lib/build/recipeModule-shared.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. * @@ -17,33 +17,42 @@ var superTokens = require("./superTokens.js"); * under the License. */ var RecipeModule = /** @class */ (function (_super) { - superTokens.__extends(RecipeModule, _super); + genericComponentOverrideContext.__extends(RecipeModule, _super); function RecipeModule() { var _this = (_super !== null && _super.apply(this, arguments)) || this; _this.redirect = function (context, navigate, queryParams, userContext) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var redirectUrl; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, - this.getRedirectUrl(context, superTokens.getNormalisedUserContext(userContext)), + this.getRedirectUrl( + context, + genericComponentOverrideContext.getNormalisedUserContext(userContext) + ), ]; case 1: redirectUrl = _a.sent(); if (redirectUrl === null) { - superTokens.logDebugMessage( + genericComponentOverrideContext.logDebugMessage( "Skipping redirection because the user override returned null for context ".concat( JSON.stringify(context, null, 2) ) ); return [2 /*return*/]; } - redirectUrl = superTokens.appendQueryParamsToURL(redirectUrl, queryParams); + redirectUrl = genericComponentOverrideContext.appendQueryParamsToURL( + redirectUrl, + queryParams + ); return [ 2 /*return*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToUrl(redirectUrl, navigate), + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToUrl( + redirectUrl, + navigate + ), ]; } }); @@ -51,9 +60,9 @@ var RecipeModule = /** @class */ (function (_super) { }; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types _this.getRedirectUrl = function (context, userContext) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var redirectUrl; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.config.getRedirectionURL(context, userContext)]; @@ -74,13 +83,13 @@ var RecipeModule = /** @class */ (function (_super) { } // eslint-disable-next-line @typescript-eslint/no-unused-vars RecipeModule.prototype.getDefaultRedirectionURL = function (_, _userContext) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { throw new Error("getDefaultRedirectionURL is not implemented."); }); }); }; return RecipeModule; -})(superTokens.BaseRecipeModule); +})(genericComponentOverrideContext.BaseRecipeModule); exports.RecipeModule = RecipeModule; diff --git a/lib/build/session.js b/lib/build/session.js index b805d24cc..9fb87e239 100644 --- a/lib/build/session.js +++ b/lib/build/session.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var WebJSSessionRecipe = require("supertokens-web-js/recipe/session"); var componentOverrideContext = require("./session-shared.js"); var types = require("./multifactorauth-shared.js"); @@ -16,7 +16,6 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); -require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); require("./oauth2provider-shared.js"); require("supertokens-web-js/recipe/oauth2provider"); @@ -31,10 +30,10 @@ require("./authRecipe-shared.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); var BooleanClaim = /** @class */ (function (_super) { - superTokens.__extends(BooleanClaim, _super); + genericComponentOverrideContext.__extends(BooleanClaim, _super); function BooleanClaim(config) { var _this = _super.call(this, config) || this; - var validatorsWithCallbacks = superTokens.__assign({}, _this.validators); + var validatorsWithCallbacks = genericComponentOverrideContext.__assign({}, _this.validators); var _loop_1 = function (key) { var validator = validatorsWithCallbacks[key]; validatorsWithCallbacks[key] = function () { @@ -42,10 +41,13 @@ var BooleanClaim = /** @class */ (function (_super) { for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return superTokens.__assign(superTokens.__assign({}, validator.apply(void 0, args)), { - onFailureRedirection: config.onFailureRedirection, - showAccessDeniedOnFailure: config.showAccessDeniedOnFailure, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, validator.apply(void 0, args)), + { + onFailureRedirection: config.onFailureRedirection, + showAccessDeniedOnFailure: config.showAccessDeniedOnFailure, + } + ); }; }; for (var key in validatorsWithCallbacks) { @@ -58,10 +60,10 @@ var BooleanClaim = /** @class */ (function (_super) { })(WebJSSessionRecipe.BooleanClaim); var PrimitiveArrayClaim = /** @class */ (function (_super) { - superTokens.__extends(PrimitiveArrayClaim, _super); + genericComponentOverrideContext.__extends(PrimitiveArrayClaim, _super); function PrimitiveArrayClaim(config) { var _this = _super.call(this, config) || this; - var validatorsWithCallbacks = superTokens.__assign({}, _this.validators); + var validatorsWithCallbacks = genericComponentOverrideContext.__assign({}, _this.validators); var _loop_1 = function (key) { var validator = validatorsWithCallbacks[key]; validatorsWithCallbacks[key] = function () { @@ -69,10 +71,13 @@ var PrimitiveArrayClaim = /** @class */ (function (_super) { for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return superTokens.__assign(superTokens.__assign({}, validator.apply(void 0, args)), { - onFailureRedirection: config.onFailureRedirection, - showAccessDeniedOnFailure: config.showAccessDeniedOnFailure, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, validator.apply(void 0, args)), + { + onFailureRedirection: config.onFailureRedirection, + showAccessDeniedOnFailure: config.showAccessDeniedOnFailure, + } + ); }; }; for (var key in validatorsWithCallbacks) { @@ -85,10 +90,10 @@ var PrimitiveArrayClaim = /** @class */ (function (_super) { })(WebJSSessionRecipe.PrimitiveArrayClaim); var PrimitiveClaim = /** @class */ (function (_super) { - superTokens.__extends(PrimitiveClaim, _super); + genericComponentOverrideContext.__extends(PrimitiveClaim, _super); function PrimitiveClaim(config) { var _this = _super.call(this, config) || this; - var validatorsWithCallbacks = superTokens.__assign({}, _this.validators); + var validatorsWithCallbacks = genericComponentOverrideContext.__assign({}, _this.validators); var _loop_1 = function (key) { var validator = validatorsWithCallbacks[key]; validatorsWithCallbacks[key] = function () { @@ -96,10 +101,13 @@ var PrimitiveClaim = /** @class */ (function (_super) { for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return superTokens.__assign(superTokens.__assign({}, validator.apply(void 0, args)), { - onFailureRedirection: config.onFailureRedirection, - showAccessDeniedOnFailure: config.showAccessDeniedOnFailure, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, validator.apply(void 0, args)), + { + onFailureRedirection: config.onFailureRedirection, + showAccessDeniedOnFailure: config.showAccessDeniedOnFailure, + } + ); }; }; for (var key in validatorsWithCallbacks) { @@ -152,12 +160,12 @@ var SessionAPIWrapper = /** @class */ (function () { return types.Session.init(config); }; SessionAPIWrapper.getUserId = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, types.Session.getInstanceOrThrow().getUserId({ - userContext: superTokens.getNormalisedUserContext( + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -166,12 +174,12 @@ var SessionAPIWrapper = /** @class */ (function () { }); }; SessionAPIWrapper.getAccessToken = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, types.Session.getInstanceOrThrow().getAccessToken({ - userContext: superTokens.getNormalisedUserContext( + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -180,12 +188,12 @@ var SessionAPIWrapper = /** @class */ (function () { }); }; SessionAPIWrapper.getAccessTokenPayloadSecurely = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, types.Session.getInstanceOrThrow().getAccessTokenPayloadSecurely({ - userContext: superTokens.getNormalisedUserContext( + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -194,19 +202,19 @@ var SessionAPIWrapper = /** @class */ (function () { }); }; SessionAPIWrapper.attemptRefreshingSession = function () { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [2 /*return*/, types.Session.getInstanceOrThrow().attemptRefreshingSession()]; }); }); }; SessionAPIWrapper.doesSessionExist = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, types.Session.getInstanceOrThrow().doesSessionExist({ - userContext: superTokens.getNormalisedUserContext( + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -218,15 +226,18 @@ var SessionAPIWrapper = /** @class */ (function () { * @deprecated */ SessionAPIWrapper.addAxiosInterceptors = function (axiosInstance, userContext) { - return types.Session.addAxiosInterceptors(axiosInstance, superTokens.getNormalisedUserContext(userContext)); + return types.Session.addAxiosInterceptors( + axiosInstance, + genericComponentOverrideContext.getNormalisedUserContext(userContext) + ); }; SessionAPIWrapper.signOut = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, types.Session.getInstanceOrThrow().signOut({ - userContext: superTokens.getNormalisedUserContext( + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -238,7 +249,7 @@ var SessionAPIWrapper = /** @class */ (function () { return types.Session.getInstanceOrThrow().validateClaims({ overrideGlobalClaimValidators: input === null || input === void 0 ? void 0 : input.overrideGlobalClaimValidators, - userContext: superTokens.getNormalisedUserContext( + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }); @@ -249,7 +260,7 @@ var SessionAPIWrapper = /** @class */ (function () { SessionAPIWrapper.getClaimValue = function (input) { return types.Session.getInstanceOrThrow().getClaimValue({ claim: input.claim, - userContext: superTokens.getNormalisedUserContext( + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }); diff --git a/lib/build/sessionprebuiltui.js b/lib/build/sessionprebuiltui.js index 965c551fb..0541541a0 100644 --- a/lib/build/sessionprebuiltui.js +++ b/lib/build/sessionprebuiltui.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var jsxRuntime = require("react/jsx-runtime"); var uiEntry = require("./index2.js"); var componentOverrideContext = require("./session-shared.js"); @@ -18,7 +18,6 @@ require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); require("react-dom"); require("./multitenancy-shared.js"); -require("./genericComponentOverrideContext.js"); require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); @@ -32,7 +31,7 @@ require("supertokens-web-js/recipe/session"); function ErrorRoundIcon() { return jsxRuntime.jsxs( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { width: "32", height: "32", viewBox: "0 0 32 32", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [ @@ -58,7 +57,7 @@ function BackButton(_a) { var t = translationContext.useTranslation(); return jsxRuntime.jsx( "button", - superTokens.__assign( + genericComponentOverrideContext.__assign( { onClick: onClick, "data-supertokens": "buttonBase backButton" }, { children: t("GO_BACK") } ) @@ -73,7 +72,7 @@ function LogoutButton(_a) { var t = translationContext.useTranslation(); return jsxRuntime.jsxs( "button", - superTokens.__assign( + genericComponentOverrideContext.__assign( { onClick: onClick, "data-supertokens": "buttonBase logoutButton" }, { children: [ @@ -110,8 +109,8 @@ var AccessDeniedScreen$2 = function (props) { var userContext = uiEntry.useUserContext(); var t = translationContext.useTranslation(); var onLogout = function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, props.recipe.signOut({ userContext: userContext })]; @@ -119,7 +118,7 @@ var AccessDeniedScreen$2 = function (props) { _a.sent(); return [ 4 /*yield*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ show: "signin", redirectBack: false, userContext: userContext, @@ -148,24 +147,24 @@ var AccessDeniedScreen$2 = function (props) { }; return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "center accessDenied" }, { children: jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: [ jsxRuntime.jsx(ErrorRoundIcon, {}), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle" }, { children: t("ACCESS_DENIED") } ) @@ -174,14 +173,14 @@ var AccessDeniedScreen$2 = function (props) { props.error && jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "primaryText accessDeniedError" }, { children: [" ", props.error] } ) ), jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "buttonsGroup" }, { children: [ @@ -206,26 +205,30 @@ var AccessDeniedScreen$2 = function (props) { }; var AccessDeniedThemeWithOverride = uiEntry.withOverride("SessionAccessDenied", AccessDeniedScreen$2); var AccessDeniedScreenTheme = function (props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); return jsxRuntime.jsx( ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, props.config.accessDeniedScreen.style], }, - { children: jsxRuntime.jsx(AccessDeniedThemeWithOverride, superTokens.__assign({}, props)) } + { + children: jsxRuntime.jsx( + AccessDeniedThemeWithOverride, + genericComponentOverrideContext.__assign({}, props) + ), + } ) ); }; var defaultTranslationsSession = { - en: superTokens.__assign(superTokens.__assign({}, uiEntry.defaultTranslationsCommon.en), { - ACCESS_DENIED: "Access denied", - GO_BACK: "Go back", - LOGOUT: "Log out", - }), + en: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, uiEntry.defaultTranslationsCommon.en), + { ACCESS_DENIED: "Access denied", GO_BACK: "Go back", LOGOUT: "Log out" } + ), }; var AccessDeniedScreen$1 = function (props) { @@ -239,18 +242,18 @@ var AccessDeniedScreen$1 = function (props) { : _b.useHistoryCustom(); return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { defaultStore: defaultTranslationsSession, useShadowDom: (_c = props.useShadowDom) !== null && _c !== void 0 ? _c - : superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, + : genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, }, { children: jsxRuntime.jsx(AccessDeniedScreenTheme, { @@ -268,7 +271,7 @@ var AccessDeniedScreen$1 = function (props) { }; var SessionPreBuiltUI = /** @class */ (function (_super) { - superTokens.__extends(SessionPreBuiltUI, _super); + genericComponentOverrideContext.__extends(SessionPreBuiltUI, _super); function SessionPreBuiltUI(recipeInstance) { var _this = _super.call(this) || this; _this.recipeInstance = recipeInstance; @@ -287,7 +290,7 @@ var SessionPreBuiltUI = /** @class */ (function (_super) { if (componentName === "accessDenied") { return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx(AccessDeniedScreen$1, { @@ -333,7 +336,7 @@ var SessionPreBuiltUI = /** @class */ (function (_super) { }; // For tests SessionPreBuiltUI.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } SessionPreBuiltUI.instance = undefined; diff --git a/lib/build/superTokens.js b/lib/build/superTokens.js deleted file mode 100644 index 6f3e33976..000000000 --- a/lib/build/superTokens.js +++ /dev/null @@ -1,1450 +0,0 @@ -"use strict"; - -var SuperTokensWebJS = require("supertokens-web-js"); -var cookieHandler = require("supertokens-web-js/utils/cookieHandler"); -var postSuperTokensInitCallbacks = require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); -var windowHandler = require("supertokens-web-js/utils/windowHandler"); -var MultitenancyWebJS = require("supertokens-web-js/recipe/multitenancy"); -var utils = require("supertokens-web-js/utils"); -var React = require("react"); -var NormalisedURLDomain = require("supertokens-web-js/utils/normalisedURLDomain"); -var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); - -function _interopDefault(e) { - return e && e.__esModule ? e : { default: e }; -} - -var SuperTokensWebJS__default = /*#__PURE__*/ _interopDefault(SuperTokensWebJS); -var MultitenancyWebJS__default = /*#__PURE__*/ _interopDefault(MultitenancyWebJS); -var NormalisedURLDomain__default = /*#__PURE__*/ _interopDefault(NormalisedURLDomain); -var NormalisedURLPath__default = /*#__PURE__*/ _interopDefault(NormalisedURLPath); - -/****************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -/* global Reflect, Promise, SuppressedError, Symbol */ - -var extendStatics = function (d, b) { - extendStatics = - Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && - function (d, b) { - d.__proto__ = b; - }) || - function (d, b) { - for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; - }; - return extendStatics(d, b); -}; - -function __extends(d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { - this.constructor = d; - } - d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); -} - -exports.__assign = function () { - exports.__assign = - Object.assign || - function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - return exports.__assign.apply(this, arguments); -}; - -function __rest(s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; - } - return t; -} - -function __awaiter(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function (resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} - -function __generator(thisArg, body) { - var _ = { - label: 0, - sent: function () { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [], - }, - f, - y, - t, - g; - return ( - (g = { next: verb(0), throw: verb(1), return: verb(2) }), - typeof Symbol === "function" && - (g[Symbol.iterator] = function () { - return this; - }), - g - ); - function verb(n) { - return function (v) { - return step([n, v]); - }; - } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while ((g && ((g = 0), op[0] && (_ = 0)), _)) - try { - if ( - ((f = 1), - y && - (t = - op[0] & 2 - ? y["return"] - : op[0] - ? y["throw"] || ((t = y["return"]) && t.call(y), 0) - : y.next) && - !(t = t.call(y, op[1])).done) - ) - return t; - if (((y = 0), t)) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if (!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && (op[0] === 6 || op[0] === 2)) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; - } -} - -function __spreadArray(to, from, pack) { - if (pack || arguments.length === 2) - for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -} - -typeof SuppressedError === "function" - ? SuppressedError - : function (error, suppressed, message) { - var e = new Error(message); - return (e.name = "SuppressedError"), (e.error = error), (e.suppressed = suppressed), e; - }; - -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. - * - * This software is licensed under the Apache License, Version 2.0 (the - * "License") as published by the Apache Software Foundation. - * - * You may not use this file except in compliance with the License. You may - * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -/* - * Consts. - */ -var RECIPE_ID_QUERY_PARAM = "rid"; -var DEFAULT_API_BASE_PATH = "/auth"; -var DEFAULT_WEBSITE_BASE_PATH = "/auth"; -var ST_ROOT_ID = "supertokens-root"; -var SSR_ERROR = - "\nIf you are trying to use this method doing server-side-rendering, please make sure you move this method inside a componentDidMount method or useEffect hook."; - -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. - * - * This software is licensed under the Apache License, Version 2.0 (the - * "License") as published by the Apache Software Foundation. - * - * You may not use this file except in compliance with the License. You may - * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -var package_version = "0.42.2"; - -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. - * - * This software is licensed under the Apache License, Version 2.0 (the - * "License") as published by the Apache Software Foundation. - * - * You may not use this file except in compliance with the License. You may - * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -var SUPERTOKENS_DEBUG_NAMESPACE = "com.supertokens.auth-react"; -var __debugLogsEnabled = false; -function enableLogging() { - __debugLogsEnabled = true; -} -function logDebugMessage(message) { - if (__debugLogsEnabled) { - // eslint-disable-next-line no-console - console.log( - "" - .concat(SUPERTOKENS_DEBUG_NAMESPACE, ' {t: "') - .concat(new Date().toISOString(), '", message: "') - .concat(message, '", supertokens-auth-react-ver: "') - .concat(package_version, '"}') - ); - } -} - -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. - * - * This software is licensed under the Apache License, Version 2.0 (the - * "License") as published by the Apache Software Foundation. - * - * You may not use this file except in compliance with the License. You may - * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -/* - * getRecipeIdFromPath - * Input: - * Output: The "rid" query param if present, null otherwise. - */ -function getRecipeIdFromSearch(search) { - var urlParams = new URLSearchParams(search); - return urlParams.get(RECIPE_ID_QUERY_PARAM); -} -function clearQueryParams(paramNames) { - var newURL = new URL(windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHref()); - for (var _i = 0, paramNames_1 = paramNames; _i < paramNames_1.length; _i++) { - var param = paramNames_1[_i]; - newURL.searchParams.delete(param); - } - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.replaceState( - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.getState(), - "", - newURL.toString() - ); -} -function updateQueryParam(name, value) { - var newURL = new URL(windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHref()); - newURL.searchParams.set(name, value); - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.replaceState( - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.history.getState(), - "", - newURL.toString() - ); -} -function clearErrorQueryParam() { - clearQueryParams(["error", "message"]); -} -function getQueryParams(param) { - var urlParams = new URLSearchParams( - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getSearch() - ); - return urlParams.get(param); -} -function getURLHash() { - // By default it is returined with the "#" at the beginning, we cut that off here. - return windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHash().substr(1); -} -function getRedirectToPathFromURL() { - var redirectToPath = getQueryParams("redirectToPath"); - if (redirectToPath === null) { - return undefined; - } else { - try { - var url = void 0; - try { - url = new URL(redirectToPath); - } catch (error) { - var fakeDomain = redirectToPath.startsWith("/") ? "http://localhost" : "http://localhost/"; - url = new URL("".concat(fakeDomain).concat(redirectToPath)); - } - // Prevent Open redirects by normalising path. - var normalisedURLPath = new NormalisedURLPath__default.default(redirectToPath).getAsStringDangerous(); - var pathQueryParams = url.search || ""; // url.search contains the leading ? - var pathHash = url.hash || ""; // url.hash contains the leading # - var pathWithQueryParamsAndHash = normalisedURLPath + pathQueryParams + pathHash; - // Ensure a leading "/" if `normalisedUrlPath` is empty but `pathWithQueryParamsAndHash` is not to ensure proper redirection. - // Example: "?test=1" will not redirect the user to `/?test=1` if we don't add a leading "/". - if ( - normalisedURLPath.length === 0 && - pathWithQueryParamsAndHash.length > 0 && - !pathWithQueryParamsAndHash.startsWith("/") - ) { - return "/" + pathWithQueryParamsAndHash; - } - return pathWithQueryParamsAndHash; - } catch (_a) { - return undefined; - } - } -} -/* - * isTest - */ -function isTest() { - try { - return process.env.TEST_MODE === "testing" || process.env.REACT_APP_TEST_MODE === "testing"; - } catch (err) { - // can get Uncaught ReferenceError: process is not defined error - return false; - } -} -function normaliseInputAppInfoOrThrowError(appInfo) { - if (appInfo === undefined) { - throw new Error("Please provide the appInfo object when calling supertokens.init"); - } - if (appInfo.apiDomain === undefined) { - throw new Error("Please provide your apiDomain inside the appInfo object when calling supertokens.init"); - } - if (appInfo.appName === undefined) { - throw new Error("Please provide your appName inside the appInfo object when calling supertokens.init"); - } - if (appInfo.websiteDomain === undefined) { - throw new Error("Please provide your websiteDomain inside the appInfo object when calling supertokens.init"); - } - var apiGatewayPath = new NormalisedURLPath__default.default(""); - if (appInfo.apiGatewayPath !== undefined) { - apiGatewayPath = new NormalisedURLPath__default.default(appInfo.apiGatewayPath); - } - return { - appName: appInfo.appName, - apiDomain: new NormalisedURLDomain__default.default(appInfo.apiDomain), - websiteDomain: new NormalisedURLDomain__default.default(appInfo.websiteDomain), - apiBasePath: apiGatewayPath.appendPath( - getNormalisedURLPathOrDefault(DEFAULT_API_BASE_PATH, appInfo.apiBasePath) - ), - websiteBasePath: getNormalisedURLPathOrDefault(DEFAULT_WEBSITE_BASE_PATH, appInfo.websiteBasePath), - }; -} -function getNormalisedURLPathOrDefault(defaultPath, path) { - if (path !== undefined) { - return new NormalisedURLPath__default.default(path); - } else { - return new NormalisedURLPath__default.default(defaultPath); - } -} -/* - * validateForm - */ -// We check that the number of fields in input and config form field is the same. -// We check that each item in the config form field is also present in the input form field -function validateForm(inputs, configFormFields) { - return __awaiter(this, void 0, void 0, function () { - var validationErrors, _loop_1, i; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - validationErrors = []; - if (configFormFields.length !== inputs.length) { - throw Error("Are you sending too many / too few formFields?"); - } - _loop_1 = function (i) { - var field, input, value, error; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - field = configFormFields[i]; - input = inputs.find(function (i) { - return i.id === field.id; - }); - value = input.value; - if (input.id === "email") { - value = value.trim(); - } - return [4 /*yield*/, field.validate(value)]; - case 1: - error = _b.sent(); - // If error, add it. - if (error !== undefined) { - validationErrors.push({ - error: error, - id: field.id, - }); - } - return [2 /*return*/]; - } - }); - }; - i = 0; - _a.label = 1; - case 1: - if (!(i < configFormFields.length)) return [3 /*break*/, 4]; - return [5 /*yield**/, _loop_1(i)]; - case 2: - _a.sent(); - _a.label = 3; - case 3: - i++; - return [3 /*break*/, 1]; - case 4: - return [2 /*return*/, validationErrors]; - } - }); - }); -} -/* - * getCurrentNormalisedUrlPath - */ -function getCurrentNormalisedUrlPath() { - return new NormalisedURLPath__default.default( - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getPathName() - ); -} -function getCurrentNormalisedUrlPathWithQueryParamsAndFragments() { - var normalisedUrlPath = getCurrentNormalisedUrlPath().getAsStringDangerous(); - return ( - normalisedUrlPath + - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getSearch() + - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHash() - ); -} -function appendQueryParamsToURL(stringUrl, queryParams) { - if (queryParams === undefined) { - return stringUrl; - } - try { - var url_1 = new URL(stringUrl); - Object.entries(queryParams).forEach(function (_a) { - var key = _a[0], - value = _a[1]; - url_1.searchParams.set(key, value); - }); - return url_1.href; - } catch (e) { - var fakeDomain = stringUrl.startsWith("/") ? "http://localhost" : "http://localhost/"; - var url_2 = new URL("".concat(fakeDomain).concat(stringUrl)); - Object.entries(queryParams).forEach(function (_a) { - var key = _a[0], - value = _a[1]; - url_2.searchParams.set(key, value); - }); - return "".concat(url_2.pathname).concat(url_2.search).concat(url_2.hash); - } -} -function appendTrailingSlashToURL(stringUrl) { - return stringUrl.endsWith("/") ? stringUrl : stringUrl + "/"; -} -/* - * Default method for matching recipe route based on query params. - */ -function matchRecipeIdUsingQueryParams(recipeId) { - return function () { - var recipeIdFromSearch = getRecipeIdFromSearch( - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getSearch() - ); - return recipeIdFromSearch === recipeId; - }; -} -function redirectWithFullPageReload(to) { - if (to.trim() === "") { - to = "/"; - } - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.setHref(to); -} -function redirectWithNavigate(to, navigate) { - if (to.trim() === "") { - to = "/"; - } - if ("push" in navigate) { - // we are using react-router-dom that is before v6 - navigate.push(to); - } else { - // in react-router-dom v6, it is just navigate(to) - navigate(to); - } -} -function getOriginOfPage() { - return new NormalisedURLDomain__default.default( - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getOrigin() - ); -} -function getLocalStorage(key) { - return __awaiter(this, void 0, void 0, function () { - var res; - return __generator(this, function (_a) { - res = windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.localStorage.getItem(key); - if (res === null || res === undefined) { - return [2 /*return*/, null]; - } - return [2 /*return*/, res]; - }); - }); -} -function setLocalStorage(key, value) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - return [ - 4 /*yield*/, - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.localStorage.setItem( - key, - value - ), - ]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); -} -function removeFromLocalStorage(key) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - return [ - 4 /*yield*/, - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.localStorage.removeItem( - key - ), - ]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); -} -function mergeObjects(obj1, obj2) { - var res = exports.__assign({}, obj1); - for (var key in obj2) { - if (typeof res[key] === "object" && typeof obj2[key] === "object") { - res[key] = mergeObjects(res[key], obj2[key]); - } else { - res[key] = obj2[key]; - } - } - return res; -} -function normaliseCookieScopeOrThrowError(cookieScope) { - function helper(cookieScope) { - cookieScope = cookieScope.trim().toLowerCase(); - // first we convert it to a URL so that we can use the URL class - if (cookieScope.startsWith(".")) { - cookieScope = cookieScope.substr(1); - } - if (!cookieScope.startsWith("http://") && !cookieScope.startsWith("https://")) { - cookieScope = "http://" + cookieScope; - } - try { - var urlObj = new URL(cookieScope); - cookieScope = urlObj.hostname; - // remove leading dot - if (cookieScope.startsWith(".")) { - cookieScope = cookieScope.substr(1); - } - return cookieScope; - } catch (err) { - throw new Error("Please provide a valid cookie scope"); - } - } - function isAnIpAddress(ipaddress) { - return /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test( - ipaddress - ); - } - var noDotNormalised = helper(cookieScope); - if (noDotNormalised === "localhost" || isAnIpAddress(noDotNormalised)) { - return noDotNormalised; - } - if (cookieScope.startsWith(".")) { - return "." + noDotNormalised; - } - return noDotNormalised; -} -function getDefaultCookieScope() { - try { - return normaliseCookieScopeOrThrowError( - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHostName() - ); - } catch (_a) { - return undefined; - } -} -function getCookieValue(name) { - return __awaiter(this, void 0, void 0, function () { - var value, _a, parts, last, temp; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - _a = "; "; - return [ - 4 /*yield*/, - cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.getCookie(), - ]; - case 1: - value = _a + _b.sent(); - parts = value.split("; " + name + "="); - if (parts.length >= 2) { - last = parts.pop(); - if (last !== undefined) { - temp = last.split(";").shift(); - if (temp === undefined) { - return [2 /*return*/, null]; - } - return [2 /*return*/, temp]; - } - } - return [2 /*return*/, null]; - } - }); - }); -} -// undefined value will remove the cookie -function setFrontendCookie(name, value, scope) { - return __awaiter(this, void 0, void 0, function () { - var expires, cookieVal; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - expires = "Thu, 01 Jan 1970 00:00:01 GMT"; - cookieVal = ""; - if (value !== undefined) { - cookieVal = value; - expires = undefined; // set cookie without expiry - } - if ( - !( - scope === "localhost" || - scope === - windowHandler.WindowHandlerReference.getReferenceOrThrow().windowHandler.location.getHostName() || - scope === undefined - ) - ) - return [3 /*break*/, 5]; - if (!(expires !== undefined)) return [3 /*break*/, 2]; - return [ - 4 /*yield*/, - cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( - "".concat(name, "=").concat(cookieVal, ";expires=").concat(expires, ";path=/;samesite=lax") - ), - ]; - case 1: - _a.sent(); - return [3 /*break*/, 4]; - case 2: - return [ - 4 /*yield*/, - cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( - "" - .concat(name, "=") - .concat(cookieVal, ";expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/;samesite=lax") - ), - ]; - case 3: - _a.sent(); - _a.label = 4; - case 4: - return [3 /*break*/, 9]; - case 5: - if (!(expires !== undefined)) return [3 /*break*/, 7]; - return [ - 4 /*yield*/, - cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( - "" - .concat(name, "=") - .concat(cookieVal, ";expires=") - .concat(expires, ";domain=") - .concat(scope, ";path=/;samesite=lax") - ), - ]; - case 6: - _a.sent(); - return [3 /*break*/, 9]; - case 7: - return [ - 4 /*yield*/, - cookieHandler.CookieHandlerReference.getReferenceOrThrow().cookieHandler.setCookie( - "" - .concat(name, "=") - .concat(cookieVal, ";domain=") - .concat(scope, ";expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/;samesite=lax") - ), - ]; - case 8: - _a.sent(); - _a.label = 9; - case 9: - return [2 /*return*/]; - } - }); - }); -} -function getNormalisedUserContext(userContext) { - return userContext === undefined ? {} : userContext; -} -/** - * This function handles calling APIs that should only be called once during mount (mostly on mount of a route/feature component). - * It's split into multiple callbacks (fetch + handleResponse/handleError) because we expect fetch to take longer and - * and the component may be unmounted during the first fetch, in which case we want to avoid updating state/redirecting. - * This is especially relevant for development in strict mode with React 18 (and in the future for concurrent rendering). - * - * @param fetch This is a callback that is only called once on mount. Mostly it's for consuming tokens/doing one time only API calls - * @param handleResponse This is called with the result of the first (fetch) call if it succeeds. - * @param handleError This is called with the error of the first (fetch) call if it rejects. - * @param startLoading Will start the whole process if this is set to true (or omitted). Mostly used to wait for session loading. - */ -var useOnMountAPICall = function (fetch, handleResponse, handleError, startLoading) { - if (startLoading === void 0) { - startLoading = true; - } - var consumeReq = React.useRef(); - var _a = React.useState(undefined), - error = _a[0], - setError = _a[1]; - React.useEffect( - function () { - var effect = function (signal) { - return __awaiter(void 0, void 0, void 0, function () { - var resp, err_1, err_2; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 9]); - if (consumeReq.current === undefined) { - consumeReq.current = fetch(); - } - return [4 /*yield*/, consumeReq.current]; - case 1: - resp = _a.sent(); - if (!signal.aborted) { - void handleResponse(resp); - } - return [3 /*break*/, 9]; - case 2: - err_1 = _a.sent(); - if (!!signal.aborted) return [3 /*break*/, 8]; - if (!(handleError !== undefined)) return [3 /*break*/, 7]; - _a.label = 3; - case 3: - _a.trys.push([3, 5, , 6]); - return [4 /*yield*/, handleError(err_1, resp)]; - case 4: - _a.sent(); - return [3 /*break*/, 6]; - case 5: - err_2 = _a.sent(); - setError(err_2); - return [3 /*break*/, 6]; - case 6: - return [3 /*break*/, 8]; - case 7: - setError(err_1); - _a.label = 8; - case 8: - return [3 /*break*/, 9]; - case 9: - return [2 /*return*/]; - } - }); - }); - }; - if (startLoading) { - var ctrl_1 = new AbortController(); - void effect(ctrl_1.signal); - return function () { - ctrl_1.abort(); - }; - } - return; - }, - [setError, consumeReq, fetch, handleResponse, handleError, startLoading] - ); - if (error) { - throw error; - } -}; -function useRethrowInRender() { - var _a = React.useState(undefined), - error = _a[0], - setError = _a[1]; - if (error) { - throw error; - } - return setError; -} - -var BaseRecipeModule = /** @class */ (function () { - /* - * Constructor. - */ - function BaseRecipeModule(config) { - this.config = config; - } - return BaseRecipeModule; -})(); - -function normaliseRecipeModuleConfig(config) { - var _this = this; - if (config === undefined) { - config = {}; - } - var onHandleEvent = config.onHandleEvent, - getRedirectionURL = config.getRedirectionURL, - preAPIHook = config.preAPIHook, - postAPIHook = config.postAPIHook; - if (onHandleEvent === undefined) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function - onHandleEvent = function (_) {}; - } - if (getRedirectionURL === undefined) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - getRedirectionURL = function (_) { - return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2 /*return*/, undefined]; - }); - }); - }; - } - if (preAPIHook === undefined) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - preAPIHook = function (context) { - return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2 /*return*/, context]; - }); - }); - }; - } - if (postAPIHook === undefined) { - // eslint-disable-next-line @typescript-eslint/no-empty-function - postAPIHook = function () { - return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2 /*return*/]; - }); - }); - }; - } - var rootStyle = config.style === undefined ? "" : config.style; - return exports.__assign(exports.__assign({}, config), { - getRedirectionURL: getRedirectionURL, - onHandleEvent: onHandleEvent, - preAPIHook: preAPIHook, - postAPIHook: postAPIHook, - recipeRootStyle: rootStyle, - }); -} - -function normaliseMultitenancyConfig(config) { - return exports.__assign(exports.__assign({}, normaliseRecipeModuleConfig(config)), { - override: exports.__assign( - { - functions: function (originalImplementation) { - return originalImplementation; - }, - }, - config === null || config === void 0 ? void 0 : config.override - ), - }); -} -function hasIntersectingRecipes(tenantMethods, recipeList) { - return tenantMethods.firstFactors.some(function (factorId) { - return recipeList.some(function (r) { - return r.firstFactorIds.includes(factorId); - }); - }); -} - -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. - * - * This software is licensed under the Apache License, Version 2.0 (the - * "License") as published by the Apache Software Foundation. - * - * You may not use this file except in compliance with the License. You may - * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -/* - * Class. - */ -var Multitenancy = /** @class */ (function (_super) { - __extends(Multitenancy, _super); - function Multitenancy(config, webJSRecipe) { - if (webJSRecipe === void 0) { - webJSRecipe = MultitenancyWebJS__default.default; - } - var _this = _super.call(this, config) || this; - _this.webJSRecipe = webJSRecipe; - _this.recipeID = Multitenancy.RECIPE_ID; - _this.dynamicLoginMethodsCache = {}; - return _this; - } - Multitenancy.prototype.getCurrentDynamicLoginMethods = function (input) { - var _a; - return __awaiter(this, void 0, void 0, function () { - var userContext, tenantId, tenantMethods; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - if (SuperTokens.usesDynamicLoginMethods === false) { - return [2 /*return*/, undefined]; - } - userContext = utils.getNormalisedUserContext(input.userContext); - return [4 /*yield*/, Multitenancy.getInstanceOrThrow().webJSRecipe.getTenantId()]; - case 1: - tenantId = (_a = _b.sent()) !== null && _a !== void 0 ? _a : "public"; - if (this.dynamicLoginMethodsCache[tenantId] === undefined) { - this.dynamicLoginMethodsCache[tenantId] = Multitenancy.getDynamicLoginMethods({ - tenantId: tenantId, - userContext: userContext, - }); - } - return [4 /*yield*/, this.dynamicLoginMethodsCache[tenantId]]; - case 2: - tenantMethods = _b.sent(); - if ( - !hasIntersectingRecipes( - tenantMethods, - SuperTokens.getInstanceOrThrow().recipeList.filter(function (recipe) { - return "firstFactorIds" in recipe; - }) - ) - ) { - throw new Error( - "Initialized recipes have no overlap with core recipes or could not load login methods" - ); - } - return [2 /*return*/, tenantMethods]; - } - }); - }); - }; - Multitenancy.getDynamicLoginMethods = function (input) { - return __awaiter(this, void 0, void 0, function () { - var _a, thirdParty, firstFactors; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - return [4 /*yield*/, MultitenancyWebJS__default.default.getLoginMethods(input)]; - case 1: - (_a = _b.sent()), (thirdParty = _a.thirdParty), (firstFactors = _a.firstFactors); - return [ - 2 /*return*/, - { - thirdparty: thirdParty, - firstFactors: firstFactors, - }, - ]; - } - }); - }); - }; - Multitenancy.init = function (config) { - var normalisedConfig = normaliseMultitenancyConfig(config); - return { - recipeID: Multitenancy.RECIPE_ID, - authReact: function (appInfo) { - Multitenancy.instance = new Multitenancy( - exports.__assign(exports.__assign({}, normalisedConfig), { - appInfo: appInfo, - recipeId: Multitenancy.RECIPE_ID, - }) - ); - return Multitenancy.instance; - }, - webJS: MultitenancyWebJS__default.default.init(exports.__assign({}, normalisedConfig)), - }; - }; - Multitenancy.getInstanceOrThrow = function () { - if (Multitenancy.instance === undefined) { - var error = - "No instance of Multitenancy found. Make sure to call the Multitenancy.init method." + - "See https://supertokens.io/docs/multitenancy/quick-setup/frontend"; - // eslint-disable-next-line supertokens-auth-react/no-direct-window-object - if (typeof window === "undefined") { - error = error + SSR_ERROR; - } - throw Error(error); - } - return Multitenancy.instance; - }; - /* - * Tests methods. - */ - Multitenancy.reset = function () { - if (!isTest()) { - return; - } - Multitenancy.instance = undefined; - return; - }; - Multitenancy.RECIPE_ID = "multitenancy"; - return Multitenancy; -})(BaseRecipeModule); - -var TranslationController = /** @class */ (function () { - function TranslationController() { - this.handlers = new Map(); - } - TranslationController.prototype.emit = function (event, detail) { - var handlerList = this.handlers.get(event) || []; - for (var _i = 0, handlerList_1 = handlerList; _i < handlerList_1.length; _i++) { - var h = handlerList_1[_i]; - h(event, detail); - } - }; - TranslationController.prototype.on = function (event, handler) { - var handlerList = this.handlers.get(event) || []; - this.handlers.set(event, handlerList.concat(handler)); - }; - TranslationController.prototype.off = function (event, handler) { - var handlerList = this.handlers.get(event) || []; - this.handlers.set( - event, - handlerList.filter(function (h) { - return h !== handler; - }) - ); - }; - return TranslationController; -})(); -var CURRENT_LANGUAGE_COOKIE_NAME = "sCurrLanguage"; -function saveCurrentLanguage(language, cookieDomain) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - _b.trys.push([0, 2, , 3]); - return [4 /*yield*/, setFrontendCookie(CURRENT_LANGUAGE_COOKIE_NAME, language, cookieDomain)]; - case 1: - _b.sent(); - return [3 /*break*/, 3]; - case 2: - _b.sent(); - return [3 /*break*/, 3]; - case 3: - return [2 /*return*/]; - } - }); - }); -} -function getCurrentLanguageFromCookie() { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - _b.trys.push([0, 2, , 3]); - return [4 /*yield*/, getCookieValue(CURRENT_LANGUAGE_COOKIE_NAME)]; - case 1: - return [2 /*return*/, _b.sent()]; - case 2: - _b.sent(); - // This can throw if we are not in a browser - // Since this is just loading a preference we can safely ignore the exception - return [2 /*return*/, null]; - case 3: - return [2 /*return*/]; - } - }); - }); -} - -/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. - * - * This software is licensed under the Apache License, Version 2.0 (the - * "License") as published by the Apache Software Foundation. - * - * You may not use this file except in compliance with the License. You may - * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -/* - * Class. - */ -var SuperTokens = /** @class */ (function () { - /* - * Constructor. - */ - function SuperTokens(config) { - var _this = this; - var _a, _b, _c, _d; - this.recipeList = []; - this.changeLanguage = function (lang) { - return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - return [ - 4 /*yield*/, - saveCurrentLanguage(lang, this.languageTranslations.currentLanguageCookieScope), - ]; - case 1: - _a.sent(); - this.languageTranslations.translationEventSource.emit("LanguageChange", lang); - return [2 /*return*/]; - } - }); - }); - }; - this.redirectToAuth = function (options) { - return __awaiter(_this, void 0, void 0, function () { - var queryParams, redirectUrl; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - queryParams = options.queryParams === undefined ? {} : options.queryParams; - if (options.show !== undefined) { - queryParams.show = options.show; - } - if (options.redirectBack === true) { - queryParams.redirectToPath = getCurrentNormalisedUrlPathWithQueryParamsAndFragments(); - } - return [ - 4 /*yield*/, - this.getRedirectUrl( - { - action: "TO_AUTH", - showSignIn: options.show === "signin", - }, - options.userContext - ), - ]; - case 1: - redirectUrl = _a.sent(); - if (redirectUrl === null) { - logDebugMessage("Skipping redirection because the user override returned null"); - return [2 /*return*/]; - } - redirectUrl = appendQueryParamsToURL(redirectUrl, queryParams); - return [2 /*return*/, this.redirectToUrl(redirectUrl, options.navigate)]; - } - }); - }); - }; - this.redirectToUrl = function (redirectUrl, navigate) { - return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - doRedirection(this.appInfo, redirectUrl, navigate); - return [2 /*return*/]; - }); - }); - }; - this.redirect = function (context, navigate, queryParams, userContext) { - return __awaiter(_this, void 0, void 0, function () { - var redirectUrl; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - return [4 /*yield*/, this.getRedirectUrl(context, getNormalisedUserContext(userContext))]; - case 1: - redirectUrl = _a.sent(); - if (redirectUrl === null) { - logDebugMessage( - "Skipping redirection because the user override returned null for context ".concat( - JSON.stringify(context, null, 2) - ) - ); - return [2 /*return*/]; - } - redirectUrl = appendQueryParamsToURL(redirectUrl, queryParams); - return [ - 2 /*return*/, - SuperTokens.getInstanceOrThrow().redirectToUrl(redirectUrl, navigate), - ]; - } - }); - }); - }; - this.appInfo = normaliseInputAppInfoOrThrowError(config.appInfo); - if (config.recipeList === undefined || config.recipeList.length === 0) { - throw new Error( - "Please provide at least one recipe to the supertokens.init function call. See https://supertokens.io/docs/emailpassword/quick-setup/frontend" - ); - } - var translationConfig = config.languageTranslations === undefined ? {} : config.languageTranslations; - this.languageTranslations = { - defaultLanguage: translationConfig.defaultLanguage === undefined ? "en" : translationConfig.defaultLanguage, - currentLanguageCookieScope: - translationConfig.currentLanguageCookieScope !== undefined - ? normaliseCookieScopeOrThrowError(translationConfig.currentLanguageCookieScope) - : getDefaultCookieScope(), - userTranslationStore: translationConfig.translations !== undefined ? translationConfig.translations : {}, - translationEventSource: new TranslationController(), - userTranslationFunc: translationConfig.translationFunc, - }; - var enableDebugLogs = Boolean(config === null || config === void 0 ? void 0 : config.enableDebugLogs); - if (enableDebugLogs) { - enableLogging(); - } - this.userGetRedirectionURL = config.getRedirectionURL; - this.recipeList = config.recipeList.map(function (_a) { - var authReact = _a.authReact; - return authReact(_this.appInfo, enableDebugLogs); - }); - this.rootStyle = (_a = config.style) !== null && _a !== void 0 ? _a : ""; - this.privacyPolicyLink = config.privacyPolicyLink; - this.termsOfServiceLink = config.termsOfServiceLink; - this.useShadowDom = (_b = config.useShadowDom) !== null && _b !== void 0 ? _b : true; - this.defaultToSignUp = (_c = config.defaultToSignUp) !== null && _c !== void 0 ? _c : false; - this.disableAuthRoute = (_d = config.disableAuthRoute) !== null && _d !== void 0 ? _d : false; - } - /* - * Static Methods. - */ - SuperTokens.init = function (config) { - var _a; - cookieHandler.CookieHandlerReference.init(config.cookieHandler); - windowHandler.WindowHandlerReference.init(config.windowHandler); - if (SuperTokens.instance !== undefined) { - console.warn("SuperTokens was already initialized"); - return; - } - SuperTokens.usesDynamicLoginMethods = - (_a = config.usesDynamicLoginMethods) !== null && _a !== void 0 ? _a : false; - var recipes = - config.recipeList.find(function (recipe) { - return recipe.recipeID === Multitenancy.RECIPE_ID; - }) !== undefined - ? config.recipeList - : config.recipeList.concat(Multitenancy.init({})); - SuperTokensWebJS__default.default.init( - exports.__assign(exports.__assign({}, config), { - recipeList: recipes.map(function (_a) { - var webJS = _a.webJS; - return webJS; - }), - }) - ); - SuperTokens.instance = new SuperTokens(exports.__assign(exports.__assign({}, config), { recipeList: recipes })); - postSuperTokensInitCallbacks.PostSuperTokensInitCallbacks.runPostInitCallbacks(); - }; - SuperTokens.getInstanceOrThrow = function () { - if (SuperTokens.instance === undefined) { - var error = "SuperTokens must be initialized before calling this method."; - // eslint-disable-next-line supertokens-auth-react/no-direct-window-object - if (typeof window === "undefined") { - error = error + SSR_ERROR; - } - throw new Error(error); - } - return SuperTokens.instance; - }; - SuperTokens.prototype.getRecipeOrThrow = function (recipeId) { - var recipe = this.recipeList.find(function (recipe) { - return recipe.config.recipeId === recipeId; - }); - if (recipe === undefined) { - throw new Error("Missing recipe: ".concat(recipeId)); - } - return recipe; - }; - SuperTokens.prototype.loadTranslation = function (store) { - this.languageTranslations.translationEventSource.emit("TranslationLoaded", store); - }; - SuperTokens.prototype.getRedirectUrl = function (context, userContext) { - var _a; - return __awaiter(this, void 0, void 0, function () { - var userRes, redirectUrl; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - if (!this.userGetRedirectionURL) return [3 /*break*/, 2]; - return [4 /*yield*/, this.userGetRedirectionURL(context, userContext)]; - case 1: - userRes = _b.sent(); - if (userRes !== undefined) { - return [2 /*return*/, userRes]; - } - _b.label = 2; - case 2: - if (context.action === "TO_AUTH") { - redirectUrl = this.appInfo.websiteBasePath.getAsStringDangerous(); - return [2 /*return*/, appendTrailingSlashToURL(redirectUrl)]; - } else if (context.action === "SUCCESS") { - return [2 /*return*/, (_a = context.redirectToPath) !== null && _a !== void 0 ? _a : "/"]; - } - throw new Error("Should never come here: unexpected redirection context"); - } - }); - }); - }; - /* - * Tests methods. - */ - SuperTokens.reset = function () { - if (!isTest()) { - return; - } - SuperTokens.instance = undefined; - return; - }; - SuperTokens.usesDynamicLoginMethods = false; - return SuperTokens; -})(); -function doRedirection(appInfo, redirectUrl, navigate) { - try { - new URL(redirectUrl); // If full URL, no error thrown, skip in app redirection. - } catch (e) { - // For multi tenancy, If mismatch between websiteDomain and current location, prepend URL relative path with websiteDomain. - var origin_1 = getOriginOfPage().getAsStringDangerous(); - if (origin_1 !== appInfo.websiteDomain.getAsStringDangerous()) { - redirectUrl = "".concat(appInfo.websiteDomain.getAsStringDangerous()).concat(redirectUrl); - redirectWithFullPageReload(redirectUrl); - return; - } - // If navigate was provided, use to redirect without reloading. - if (navigate !== undefined) { - redirectWithNavigate(redirectUrl, navigate); - return; - } - } - // Otherwise, redirect in app. - redirectWithFullPageReload(redirectUrl); -} - -exports.BaseRecipeModule = BaseRecipeModule; -exports.Multitenancy = Multitenancy; -exports.SSR_ERROR = SSR_ERROR; -exports.ST_ROOT_ID = ST_ROOT_ID; -exports.SuperTokens = SuperTokens; -exports.__awaiter = __awaiter; -exports.__extends = __extends; -exports.__generator = __generator; -exports.__rest = __rest; -exports.__spreadArray = __spreadArray; -exports.appendQueryParamsToURL = appendQueryParamsToURL; -exports.clearErrorQueryParam = clearErrorQueryParam; -exports.clearQueryParams = clearQueryParams; -exports.getCurrentLanguageFromCookie = getCurrentLanguageFromCookie; -exports.getCurrentNormalisedUrlPath = getCurrentNormalisedUrlPath; -exports.getCurrentNormalisedUrlPathWithQueryParamsAndFragments = getCurrentNormalisedUrlPathWithQueryParamsAndFragments; -exports.getLocalStorage = getLocalStorage; -exports.getNormalisedUserContext = getNormalisedUserContext; -exports.getQueryParams = getQueryParams; -exports.getRedirectToPathFromURL = getRedirectToPathFromURL; -exports.getURLHash = getURLHash; -exports.isTest = isTest; -exports.logDebugMessage = logDebugMessage; -exports.matchRecipeIdUsingQueryParams = matchRecipeIdUsingQueryParams; -exports.mergeObjects = mergeObjects; -exports.normaliseRecipeModuleConfig = normaliseRecipeModuleConfig; -exports.redirectWithFullPageReload = redirectWithFullPageReload; -exports.removeFromLocalStorage = removeFromLocalStorage; -exports.setLocalStorage = setLocalStorage; -exports.updateQueryParam = updateQueryParam; -exports.useOnMountAPICall = useOnMountAPICall; -exports.useRethrowInRender = useRethrowInRender; -exports.validateForm = validateForm; diff --git a/lib/build/thirdparty-shared.js b/lib/build/thirdparty-shared.js index 626dfd0fe..c34e7f232 100644 --- a/lib/build/thirdparty-shared.js +++ b/lib/build/thirdparty-shared.js @@ -1,7 +1,6 @@ "use strict"; var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); -var superTokens = require("./superTokens.js"); var ThirdpartyWebJS = require("supertokens-web-js/recipe/thirdparty"); var index = require("./authRecipe-shared2.js"); var types = require("./multifactorauth-shared.js"); @@ -31,24 +30,24 @@ function ProviderButton(_a) { var providerStyleName = "provider".concat(providerName); return jsxRuntime.jsxs( "button", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "button providerButton ".concat(providerStyleName) }, { children: [ logo !== undefined && jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "providerButtonLeft" }, { children: jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "providerButtonLogo" }, { children: jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "providerButtonLogoCenter" }, { children: logo } ) @@ -61,7 +60,7 @@ function ProviderButton(_a) { ), jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "providerButtonText" }, { children: [ @@ -120,9 +119,10 @@ var Provider = /** @class */ (function () { if (this.config.getRedirectURL) { return this.config.getRedirectURL(this.config.id); } - var domain = superTokens.SuperTokens.getInstanceOrThrow().appInfo.websiteDomain.getAsStringDangerous(); + var domain = + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().appInfo.websiteDomain.getAsStringDangerous(); var callbackPath = new NormalisedURLPath__default.default("/callback/".concat(this.config.id)); - var path = superTokens.SuperTokens.getInstanceOrThrow() + var path = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow() .appInfo.websiteBasePath.appendPath(callbackPath) .getAsStringDangerous(); return "".concat(domain).concat(path); @@ -137,18 +137,20 @@ var Provider = /** @class */ (function () { * Class. */ var ActiveDirectory = /** @class */ (function (_super) { - superTokens.__extends(ActiveDirectory, _super); + genericComponentOverrideContext.__extends(ActiveDirectory, _super); /* * Constructor. */ function ActiveDirectory(config) { var _this = - _super.call(this, superTokens.__assign({ id: "active-directory", name: "Active Directory" }, config)) || - this; + _super.call( + this, + genericComponentOverrideContext.__assign({ id: "active-directory", name: "Active Directory" }, config) + ) || this; _this.getLogo = function () { return jsxRuntime.jsxs( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { width: "18", height: "16", @@ -160,7 +162,7 @@ var ActiveDirectory = /** @class */ (function (_super) { children: [ jsxRuntime.jsxs( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { clipPath: "url(#clip0_402_84)" }, { children: [ @@ -187,7 +189,7 @@ var ActiveDirectory = /** @class */ (function (_super) { jsxRuntime.jsx("defs", { children: jsxRuntime.jsx( "clipPath", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "clip0_402_84" }, { children: jsxRuntime.jsx("rect", { @@ -221,7 +223,7 @@ var ActiveDirectory = /** @class */ (function (_super) { * Tests methods. */ ActiveDirectory.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } ActiveDirectory.instance = undefined; @@ -234,16 +236,17 @@ var ActiveDirectory = /** @class */ (function (_super) { * Class. */ var Apple = /** @class */ (function (_super) { - superTokens.__extends(Apple, _super); + genericComponentOverrideContext.__extends(Apple, _super); /* * Constructor. */ function Apple(config) { - var _this = _super.call(this, superTokens.__assign({ id: "apple", name: "Apple" }, config)) || this; + var _this = + _super.call(this, genericComponentOverrideContext.__assign({ id: "apple", name: "Apple" }, config)) || this; _this.getLogo = function () { return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "15.614", @@ -253,7 +256,7 @@ var Apple = /** @class */ (function (_super) { { children: jsxRuntime.jsxs( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "iconfinder_logo_brand_brands_logos_apple_ios_2993701", transform: "translate(-2)", @@ -312,9 +315,10 @@ var Apple = /** @class */ (function (_super) { return _this; } Apple.prototype.getRedirectURIOnProviderDashboard = function () { - var domain = superTokens.SuperTokens.getInstanceOrThrow().appInfo.apiDomain.getAsStringDangerous(); + var domain = + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().appInfo.apiDomain.getAsStringDangerous(); var callbackPath = new NormalisedURLPath__default$1.default("/callback/".concat(this.id)); - var path = superTokens.SuperTokens.getInstanceOrThrow() + var path = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow() .appInfo.apiBasePath.appendPath(callbackPath) .getAsStringDangerous(); return "".concat(domain).concat(path); @@ -334,7 +338,7 @@ var Apple = /** @class */ (function (_super) { * Tests methods. */ Apple.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } Apple.instance = undefined; @@ -347,16 +351,20 @@ var Apple = /** @class */ (function (_super) { * Class. */ var Bitbucket = /** @class */ (function (_super) { - superTokens.__extends(Bitbucket, _super); + genericComponentOverrideContext.__extends(Bitbucket, _super); /* * Constructor. */ function Bitbucket(config) { - var _this = _super.call(this, superTokens.__assign({ id: "bitbucket", name: "Bitbucket" }, config)) || this; + var _this = + _super.call( + this, + genericComponentOverrideContext.__assign({ id: "bitbucket", name: "Bitbucket" }, config) + ) || this; _this.getLogo = function () { return jsxRuntime.jsxs( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { width: "19", height: "17", @@ -377,7 +385,7 @@ var Bitbucket = /** @class */ (function (_super) { jsxRuntime.jsx("defs", { children: jsxRuntime.jsxs( "linearGradient", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "paint0_linear_4108_67124", x1: "19.2748", @@ -417,7 +425,7 @@ var Bitbucket = /** @class */ (function (_super) { * Tests methods. */ Bitbucket.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } Bitbucket.instance = undefined; @@ -430,16 +438,20 @@ var Bitbucket = /** @class */ (function (_super) { * Class. */ var BoxySAML = /** @class */ (function (_super) { - superTokens.__extends(BoxySAML, _super); + genericComponentOverrideContext.__extends(BoxySAML, _super); /* * Constructor. */ function BoxySAML(config) { - var _this = _super.call(this, superTokens.__assign({ id: "boxy-saml", name: "BoxySAML" }, config)) || this; + var _this = + _super.call( + this, + genericComponentOverrideContext.__assign({ id: "boxy-saml", name: "BoxySAML" }, config) + ) || this; _this.getLogo = function () { return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { width: "18", height: "18", @@ -475,7 +487,7 @@ var BoxySAML = /** @class */ (function (_super) { * Tests methods. */ BoxySAML.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } BoxySAML.instance = undefined; @@ -488,16 +500,18 @@ var BoxySAML = /** @class */ (function (_super) { * Class. */ var Discord = /** @class */ (function (_super) { - superTokens.__extends(Discord, _super); + genericComponentOverrideContext.__extends(Discord, _super); /* * Constructor. */ function Discord(config) { - var _this = _super.call(this, superTokens.__assign({ id: "discord", name: "Discord" }, config)) || this; + var _this = + _super.call(this, genericComponentOverrideContext.__assign({ id: "discord", name: "Discord" }, config)) || + this; _this.getLogo = function () { return jsxRuntime.jsxs( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { width: "18", height: "14", @@ -509,7 +523,7 @@ var Discord = /** @class */ (function (_super) { children: [ jsxRuntime.jsx( "g", - superTokens.__assign( + genericComponentOverrideContext.__assign( { clipPath: "url(#clip0_4108_67056)" }, { children: jsxRuntime.jsx("path", { @@ -522,7 +536,7 @@ var Discord = /** @class */ (function (_super) { jsxRuntime.jsx("defs", { children: jsxRuntime.jsx( "clipPath", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "clip0_4108_67056" }, { children: jsxRuntime.jsx("rect", { @@ -556,7 +570,7 @@ var Discord = /** @class */ (function (_super) { * Tests methods. */ Discord.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } Discord.instance = undefined; @@ -569,16 +583,18 @@ var Discord = /** @class */ (function (_super) { * Class. */ var Facebook = /** @class */ (function (_super) { - superTokens.__extends(Facebook, _super); + genericComponentOverrideContext.__extends(Facebook, _super); /* * Constructor. */ function Facebook(config) { - var _this = _super.call(this, superTokens.__assign({ id: "facebook", name: "Facebook" }, config)) || this; + var _this = + _super.call(this, genericComponentOverrideContext.__assign({ id: "facebook", name: "Facebook" }, config)) || + this; _this.getLogo = function () { return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { fill: "#1777F2", xmlns: "http://www.w3.org/2000/svg", @@ -611,7 +627,7 @@ var Facebook = /** @class */ (function (_super) { * Tests methods. */ Facebook.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } Facebook.instance = undefined; @@ -624,16 +640,18 @@ var Facebook = /** @class */ (function (_super) { * Class. */ var Github = /** @class */ (function (_super) { - superTokens.__extends(Github, _super); + genericComponentOverrideContext.__extends(Github, _super); /* * Constructor. */ function Github(config) { - var _this = _super.call(this, superTokens.__assign({ id: "github", name: "GitHub" }, config)) || this; + var _this = + _super.call(this, genericComponentOverrideContext.__assign({ id: "github", name: "GitHub" }, config)) || + this; _this.getLogo = function () { return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "17.556", viewBox: "0 0 18 17.556" }, { children: jsxRuntime.jsx("path", { @@ -663,7 +681,7 @@ var Github = /** @class */ (function (_super) { * Tests methods. */ Github.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } Github.instance = undefined; @@ -676,16 +694,18 @@ var Github = /** @class */ (function (_super) { * Class. */ var Gitlab = /** @class */ (function (_super) { - superTokens.__extends(Gitlab, _super); + genericComponentOverrideContext.__extends(Gitlab, _super); /* * Constructor. */ function Gitlab(config) { - var _this = _super.call(this, superTokens.__assign({ id: "gitlab", name: "Gitlab" }, config)) || this; + var _this = + _super.call(this, genericComponentOverrideContext.__assign({ id: "gitlab", name: "Gitlab" }, config)) || + this; _this.getLogo = function () { return jsxRuntime.jsxs( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { width: "18", height: "18", @@ -733,7 +753,7 @@ var Gitlab = /** @class */ (function (_super) { * Tests methods. */ Gitlab.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } Gitlab.instance = undefined; @@ -746,16 +766,18 @@ var Gitlab = /** @class */ (function (_super) { * Class. */ var Google = /** @class */ (function (_super) { - superTokens.__extends(Google, _super); + genericComponentOverrideContext.__extends(Google, _super); /* * Constructor. */ function Google(config) { - var _this = _super.call(this, superTokens.__assign({ id: "google", name: "Google" }, config)) || this; + var _this = + _super.call(this, genericComponentOverrideContext.__assign({ id: "google", name: "Google" }, config)) || + this; _this.getLogo = function () { return jsxRuntime.jsxs( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48", width: "18px", height: "18px" }, { children: [ @@ -797,7 +819,7 @@ var Google = /** @class */ (function (_super) { * Tests methods. */ Google.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } Google.instance = undefined; @@ -807,15 +829,17 @@ var Google = /** @class */ (function (_super) { })(Provider); var GoogleWorkspaces = /** @class */ (function (_super) { - superTokens.__extends(GoogleWorkspaces, _super); + genericComponentOverrideContext.__extends(GoogleWorkspaces, _super); function GoogleWorkspaces(config) { var _this = - _super.call(this, superTokens.__assign({ id: "google-workspaces", name: "Google Workspaces" }, config)) || - this; + _super.call( + this, + genericComponentOverrideContext.__assign({ id: "google-workspaces", name: "Google Workspaces" }, config) + ) || this; _this.getLogo = function () { return jsxRuntime.jsxs( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48", width: "18px", height: "18px" }, { children: [ @@ -857,7 +881,7 @@ var GoogleWorkspaces = /** @class */ (function (_super) { * Tests methods. */ GoogleWorkspaces.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } GoogleWorkspaces.instance = undefined; @@ -870,16 +894,18 @@ var GoogleWorkspaces = /** @class */ (function (_super) { * Class. */ var LinkedIn = /** @class */ (function (_super) { - superTokens.__extends(LinkedIn, _super); + genericComponentOverrideContext.__extends(LinkedIn, _super); /* * Constructor. */ function LinkedIn(config) { - var _this = _super.call(this, superTokens.__assign({ id: "linkedin", name: "LinkedIn" }, config)) || this; + var _this = + _super.call(this, genericComponentOverrideContext.__assign({ id: "linkedin", name: "LinkedIn" }, config)) || + this; _this.getLogo = function () { return jsxRuntime.jsxs( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48", width: "20", height: "20" }, { children: [ @@ -913,7 +939,7 @@ var LinkedIn = /** @class */ (function (_super) { * Tests methods. */ LinkedIn.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } LinkedIn.instance = undefined; @@ -926,16 +952,17 @@ var LinkedIn = /** @class */ (function (_super) { * Class. */ var Okta = /** @class */ (function (_super) { - superTokens.__extends(Okta, _super); + genericComponentOverrideContext.__extends(Okta, _super); /* * Constructor. */ function Okta(config) { - var _this = _super.call(this, superTokens.__assign({ id: "okta", name: "Okta" }, config)) || this; + var _this = + _super.call(this, genericComponentOverrideContext.__assign({ id: "okta", name: "Okta" }, config)) || this; _this.getLogo = function () { return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { width: "18", height: "18", @@ -971,7 +998,7 @@ var Okta = /** @class */ (function (_super) { * Tests methods. */ Okta.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } Okta.instance = undefined; @@ -984,7 +1011,7 @@ var Okta = /** @class */ (function (_super) { * Class. */ var Twitter = /** @class */ (function (_super) { - superTokens.__extends(Twitter, _super); + genericComponentOverrideContext.__extends(Twitter, _super); /* * Constructor. */ @@ -996,13 +1023,14 @@ var Twitter = /** @class */ (function (_super) { if (normalisedUseLegacyTwitterLogo) { name = "Twitter"; } - _this = _super.call(this, superTokens.__assign({ id: "twitter", name: name }, config)) || this; + _this = + _super.call(this, genericComponentOverrideContext.__assign({ id: "twitter", name: name }, config)) || this; _this.useLegacyTwitterLogo = false; _this.getLogo = function () { if (_this.useLegacyTwitterLogo === true) { return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "20.129", @@ -1026,7 +1054,7 @@ var Twitter = /** @class */ (function (_super) { } return jsxRuntime.jsx( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 1200 1227" }, { children: jsxRuntime.jsx("path", { @@ -1055,7 +1083,7 @@ var Twitter = /** @class */ (function (_super) { * Tests methods. */ Twitter.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } Twitter.instance = undefined; @@ -1066,11 +1094,11 @@ var Twitter = /** @class */ (function (_super) { var getFunctionOverrides = function (recipeId, onHandleEvent) { return function (originalImp) { - return superTokens.__assign(superTokens.__assign({}, originalImp), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImp), { signInAndUp: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var payloadBeforeCall, response, payloadAfterCall; - return superTokens.__generator(this, function (_c) { + return genericComponentOverrideContext.__generator(this, function (_c) { switch (_c.label) { case 0: _c.trys.push([0, 2, , 3]); @@ -1132,13 +1160,18 @@ var getFunctionOverrides = function (recipeId, onHandleEvent) { setStateAndOtherInfoToStorage: function (input) { var _a; var loginChallenge = - (_a = superTokens.getQueryParams("loginChallenge")) !== null && _a !== void 0 ? _a : undefined; + (_a = genericComponentOverrideContext.getQueryParams("loginChallenge")) !== null && _a !== void 0 + ? _a + : undefined; return originalImp.setStateAndOtherInfoToStorage({ - state: superTokens.__assign(superTokens.__assign({}, input.state), { - rid: recipeId, - oauth2LoginChallenge: loginChallenge, - redirectToPath: superTokens.getRedirectToPathFromURL(), - }), + state: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, input.state), + { + rid: recipeId, + oauth2LoginChallenge: loginChallenge, + redirectToPath: genericComponentOverrideContext.getRedirectToPathFromURL(), + } + ), userContext: input.userContext, }); }, @@ -1150,7 +1183,7 @@ var getFunctionOverrides = function (recipeId, onHandleEvent) { * Class. */ var Custom = /** @class */ (function (_super) { - superTokens.__extends(Custom, _super); + genericComponentOverrideContext.__extends(Custom, _super); /* * Constructor. */ @@ -1198,7 +1231,7 @@ function normaliseThirdPartyConfig(config) { var signInAndUpFeature = normaliseSignInAndUpFeature(config.signInAndUpFeature); var oAuthCallbackScreen = config.oAuthCallbackScreen === undefined ? {} : { style: config.oAuthCallbackScreen.style }; - var override = superTokens.__assign( + var override = genericComponentOverrideContext.__assign( { functions: function (originalImplementation) { return originalImplementation; @@ -1206,11 +1239,10 @@ function normaliseThirdPartyConfig(config) { }, config.override ); - return superTokens.__assign(superTokens.__assign({}, utils.normaliseAuthRecipe(config)), { - signInAndUpFeature: signInAndUpFeature, - oAuthCallbackScreen: oAuthCallbackScreen, - override: override, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, utils.normaliseAuthRecipe(config)), + { signInAndUpFeature: signInAndUpFeature, oAuthCallbackScreen: oAuthCallbackScreen, override: override } + ); } function normaliseSignInAndUpFeature(config) { if (config === undefined) { @@ -1263,16 +1295,18 @@ function matchRecipeIdUsingState(recipe, userContext) { return false; } function redirectToThirdPartyLogin(input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var loginMethods, tenantProviders, providers, provider, response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [ 4 /*yield*/, - superTokens.Multitenancy.getInstanceOrThrow().getCurrentDynamicLoginMethods({ - userContext: input.userContext, - }), + genericComponentOverrideContext.Multitenancy.getInstanceOrThrow().getCurrentDynamicLoginMethods( + { + userContext: input.userContext, + } + ), ]; case 1: loginMethods = _a.sent(); @@ -1305,7 +1339,7 @@ function redirectToThirdPartyLogin(input) { ]; case 2: response = _a.sent(); - superTokens.redirectWithFullPageReload(response); + genericComponentOverrideContext.redirectWithFullPageReload(response); return [2 /*return*/, { status: "OK" }]; } }); @@ -1331,7 +1365,7 @@ var mergeProviders = function (_a) { twitter: Twitter, facebook: Facebook, }; - var usesDynamicLoginMethods = superTokens.SuperTokens.usesDynamicLoginMethods === true; + var usesDynamicLoginMethods = genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods === true; if ( usesDynamicLoginMethods === false && (clientProviders === null || clientProviders === void 0 ? void 0 : clientProviders.length) === 0 @@ -1361,11 +1395,14 @@ var mergeProviders = function (_a) { if (provider !== undefined) { providers.push( Custom.init( - superTokens.__assign(superTokens.__assign({}, provider.config), { - id: tenantProvider.id, - name: tenantProvider.name, - buttonComponent: provider.getButton(tenantProvider.name), - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, provider.config), + { + id: tenantProvider.id, + name: tenantProvider.name, + buttonComponent: provider.getButton(tenantProvider.name), + } + ) ) ); } else { @@ -1409,14 +1446,14 @@ var mergeProviders = function (_a) { * Class. */ var ThirdParty = /** @class */ (function (_super) { - superTokens.__extends(ThirdParty, _super); + genericComponentOverrideContext.__extends(ThirdParty, _super); function ThirdParty(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = ThirdpartyWebJS__default.default; } var _this = this; if ( - superTokens.SuperTokens.usesDynamicLoginMethods === false && + genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods === false && config.signInAndUpFeature.providers.length === 0 ) { throw new Error("ThirdParty signInAndUpFeature providers array cannot be empty."); @@ -1429,8 +1466,8 @@ var ThirdParty = /** @class */ (function (_super) { * Instance methods. */ _this.getDefaultRedirectionURL = function (context) { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [2 /*return*/, this.getAuthRecipeDefaultRedirectionURL(context)]; }); }); @@ -1447,24 +1484,30 @@ var ThirdParty = /** @class */ (function (_super) { recipeID: ThirdParty.RECIPE_ID, authReact: function (appInfo) { ThirdParty.instance = new ThirdParty( - superTokens.__assign(superTokens.__assign({}, normalisedConfig), { - appInfo: appInfo, - recipeId: ThirdParty.RECIPE_ID, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { appInfo: appInfo, recipeId: ThirdParty.RECIPE_ID } + ) ); return ThirdParty.instance; }, webJS: ThirdpartyWebJS__default.default.init( - superTokens.__assign(superTokens.__assign({}, normalisedConfig), { - override: { - functions: function (originalImpl, builder) { - var functions = getFunctionOverrides(ThirdParty.RECIPE_ID, normalisedConfig.onHandleEvent); - builder.override(functions); - builder.override(normalisedConfig.override.functions); - return originalImpl; + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { + override: { + functions: function (originalImpl, builder) { + var functions = getFunctionOverrides( + ThirdParty.RECIPE_ID, + normalisedConfig.onHandleEvent + ); + builder.override(functions); + builder.override(normalisedConfig.override.functions); + return originalImpl; + }, }, - }, - }) + } + ) ), }; }; @@ -1475,7 +1518,7 @@ var ThirdParty = /** @class */ (function (_super) { "See https://supertokens.io/docs/thirdparty/quick-setup/frontend"; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { - error = error + superTokens.SSR_ERROR; + error = error + genericComponentOverrideContext.SSR_ERROR; } throw Error(error); } @@ -1485,7 +1528,7 @@ var ThirdParty = /** @class */ (function (_super) { * Tests methods. */ ThirdParty.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } ThirdParty.instance = undefined; diff --git a/lib/build/thirdparty.js b/lib/build/thirdparty.js index 679cc22d8..cfbb03296 100644 --- a/lib/build/thirdparty.js +++ b/lib/build/thirdparty.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var recipe = require("./thirdparty-shared.js"); require("supertokens-web-js"); require("supertokens-web-js/utils/cookieHandler"); @@ -13,7 +13,6 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); -require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); require("supertokens-web-js/recipe/thirdparty"); require("./authRecipe-shared2.js"); @@ -49,12 +48,12 @@ var Wrapper = /** @class */ (function () { return recipe.ThirdParty.init(config); }; Wrapper.signOut = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.ThirdParty.getInstanceOrThrow().signOut({ - userContext: superTokens.getNormalisedUserContext( + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }), @@ -63,16 +62,16 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.redirectToThirdPartyLogin = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var recipeInstance; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { recipeInstance = recipe.ThirdParty.getInstanceOrThrow(); return [ 2 /*return*/, recipe.redirectToThirdPartyLogin({ thirdPartyId: input.thirdPartyId, config: recipeInstance.config, - userContext: superTokens.getNormalisedUserContext(input.userContext), + userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), recipeImplementation: recipeInstance.webJSRecipe, }), ]; @@ -81,21 +80,21 @@ var Wrapper = /** @class */ (function () { }; Wrapper.getStateAndOtherInfoFromStorage = function (input) { return recipe.ThirdParty.getInstanceOrThrow().webJSRecipe.getStateAndOtherInfoFromStorage( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) ); }; Wrapper.getAuthorisationURLWithQueryParamsAndSetState = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.ThirdParty.getInstanceOrThrow().webJSRecipe.getAuthorisationURLWithQueryParamsAndSetState( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext(input.userContext), + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext(input.userContext), }) ), ]; @@ -103,13 +102,13 @@ var Wrapper = /** @class */ (function () { }); }; Wrapper.signInAndUp = function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe.ThirdParty.getInstanceOrThrow().webJSRecipe.signInAndUp( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) diff --git a/lib/build/thirdpartyprebuiltui.js b/lib/build/thirdpartyprebuiltui.js index d2c6f67b9..de2b8a93e 100644 --- a/lib/build/thirdpartyprebuiltui.js +++ b/lib/build/thirdpartyprebuiltui.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var jsxRuntime = require("react/jsx-runtime"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); var uiEntry = require("./index2.js"); @@ -23,7 +23,6 @@ require("supertokens-web-js/utils/normalisedURLDomain"); require("./translationContext.js"); require("react-dom"); require("./multitenancy-shared.js"); -require("./genericComponentOverrideContext.js"); require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); @@ -97,9 +96,9 @@ var ThemeBase = function (_a) { var ThirdPartySignInAndUpProvidersForm = function (props) { var userContext = uiEntry.useUserContext(); var signInClick = function (providerId) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var response, generalError, e_1; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 5, , 6]); @@ -154,12 +153,12 @@ var ThirdPartySignInAndUpProvidersForm = function (props) { children: props.providers.map(function (provider) { return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "providerContainer" }, { children: jsxRuntime.jsx( "span", - superTokens.__assign( + genericComponentOverrideContext.__assign( { onClick: function () { return signInClick(provider.id); @@ -178,16 +177,16 @@ var ThirdPartySignInAndUpProvidersForm = function (props) { var ProvidersForm = uiEntry.withOverride("ThirdPartySignInAndUpProvidersForm", ThirdPartySignInAndUpProvidersForm); var SignInAndUpThemeWrapper = function (props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [ @@ -196,7 +195,7 @@ var SignInAndUpThemeWrapper = function (props) { props.config.signInAndUpFeature.style, ], }, - { children: jsxRuntime.jsx(ProvidersForm, superTokens.__assign({}, props)) } + { children: jsxRuntime.jsx(ProvidersForm, genericComponentOverrideContext.__assign({}, props)) } ) ), } @@ -225,7 +224,7 @@ function useChildProps( return React.useMemo( function () { var tenantProviders; - if (superTokens.SuperTokens.usesDynamicLoginMethods) { + if (genericComponentOverrideContext.SuperTokens.usesDynamicLoginMethods) { if (dynamicLoginMethods.loaded === false) { throw new Error("Component requiring dynamicLoginMethods rendered without FeatureWrapper."); } else { @@ -267,15 +266,21 @@ var SignInAndUpFeature = function (props) { props.navigate, props.userContext ); - var themeProps = superTokens.__assign(superTokens.__assign({}, childProps), { providers: childProps.providers }); + var themeProps = genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, childProps), + { providers: childProps.providers } + ); return jsxRuntime.jsxs(React.Fragment, { children: [ props.children === undefined && - jsxRuntime.jsx(SignInAndUpThemeWrapper, superTokens.__assign({}, themeProps)), + jsxRuntime.jsx(SignInAndUpThemeWrapper, genericComponentOverrideContext.__assign({}, themeProps)), props.children && React__namespace.Children.map(props.children, function (child) { if (React__namespace.isValidElement(child)) { - return React__namespace.cloneElement(child, superTokens.__assign({}, childProps)); + return React__namespace.cloneElement( + child, + genericComponentOverrideContext.__assign({}, childProps) + ); } return child; }), @@ -286,21 +291,21 @@ var SignInAndUpFeatureWrapper = function (props) { var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( authCompWrapper.AuthComponentWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { recipeComponentOverrides: recipeComponentOverrides }, - { children: jsxRuntime.jsx(SignInAndUpFeature, superTokens.__assign({}, props)) } + { children: jsxRuntime.jsx(SignInAndUpFeature, genericComponentOverrideContext.__assign({}, props)) } ) ); }; var getModifiedRecipeImplementation = function (origImpl) { - return superTokens.__assign({}, origImpl); + return genericComponentOverrideContext.__assign({}, origImpl); }; /* * Component. */ var ThirdPartySignInAndUpCallbackTheme = /** @class */ (function (_super) { - superTokens.__extends(ThirdPartySignInAndUpCallbackTheme, _super); + genericComponentOverrideContext.__extends(ThirdPartySignInAndUpCallbackTheme, _super); function ThirdPartySignInAndUpCallbackTheme() { /* * Methods. @@ -309,17 +314,17 @@ var ThirdPartySignInAndUpCallbackTheme = /** @class */ (function (_super) { _this.render = function () { return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container" }, { children: jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "spinner" }, { children: jsxRuntime.jsx(uiEntry.SpinnerIcon, {}) } ) @@ -340,11 +345,11 @@ var SignInAndUpCallbackThemeWithOverride = uiEntry.withOverride( ThirdPartySignInAndUpCallbackTheme ); var SignInAndUpCallbackTheme = function (props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); return jsxRuntime.jsx( ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, props.config.signInAndUpFeature.style], @@ -355,26 +360,29 @@ var SignInAndUpCallbackTheme = function (props) { }; var defaultTranslationsThirdParty = { - en: superTokens.__assign(superTokens.__assign({}, uiEntry.defaultTranslationsCommon.en), { - THIRD_PARTY_PROVIDER_DEFAULT_BTN_START: "Continue with ", - THIRD_PARTY_PROVIDER_DEFAULT_BTN_END: "", - THIRD_PARTY_ERROR_NO_EMAIL: "Could not retrieve email. Please try a different method.", - /* - * The following are error messages from our backend SDK. - * These are returned as full messages to preserver compatibilty, but they work just like the keys above. - * They are shown as is by default (setting the value to undefined will display the raw translation key) - */ - "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_004)": - undefined, - "Cannot sign in / up because new email cannot be applied to existing account. Please contact support. (ERR_CODE_005)": - undefined, - "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_006)": - undefined, - "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_020)": undefined, - "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_021)": undefined, - "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_022)": undefined, - "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_023)": undefined, - }), + en: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, uiEntry.defaultTranslationsCommon.en), + { + THIRD_PARTY_PROVIDER_DEFAULT_BTN_START: "Continue with ", + THIRD_PARTY_PROVIDER_DEFAULT_BTN_END: "", + THIRD_PARTY_ERROR_NO_EMAIL: "Could not retrieve email. Please try a different method.", + /* + * The following are error messages from our backend SDK. + * These are returned as full messages to preserver compatibilty, but they work just like the keys above. + * They are shown as is by default (setting the value to undefined will display the raw translation key) + */ + "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_004)": + undefined, + "Cannot sign in / up because new email cannot be applied to existing account. Please contact support. (ERR_CODE_005)": + undefined, + "Cannot sign in / up due to security reasons. Please try a different login method or contact support. (ERR_CODE_006)": + undefined, + "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_020)": undefined, + "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_021)": undefined, + "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_022)": undefined, + "Cannot sign in / up due to security reasons. Please contact support. (ERR_CODE_023)": undefined, + } + ), }; var SignInAndUpCallback$1 = function (props) { @@ -382,13 +390,13 @@ var SignInAndUpCallback$1 = function (props) { if (props.userContext !== undefined) { userContext = props.userContext; } - var rethrowInRender = superTokens.useRethrowInRender(); + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); var verifyCode = React.useCallback( function () { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var payloadBeforeCall; var _b; - return superTokens.__generator(this, function (_c) { + return genericComponentOverrideContext.__generator(this, function (_c) { switch (_c.label) { case 0: _c.trys.push([0, 2, , 3]); @@ -428,15 +436,15 @@ var SignInAndUpCallback$1 = function (props) { function (_a) { var response = _a.response, payloadBeforeCall = _a.payloadBeforeCall; - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var payloadAfterCall, stateResponse, redirectToPath, loginChallenge; - return superTokens.__generator(this, function (_c) { + return genericComponentOverrideContext.__generator(this, function (_c) { switch (_c.label) { case 0: if (response.status === "NO_EMAIL_GIVEN_BY_PROVIDER") { return [ 2 /*return*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: "no_email_present", @@ -449,7 +457,7 @@ var SignInAndUpCallback$1 = function (props) { if (response.status === "SIGN_IN_UP_NOT_ALLOWED") { return [ 2 /*return*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: response.status, @@ -536,9 +544,9 @@ var SignInAndUpCallback$1 = function (props) { ); var handleError = React.useCallback( function (err) { - return superTokens.__awaiter(void 0, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(void 0, void 0, void 0, function () { var invalidClaims, evInstance; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: if ( @@ -585,7 +593,7 @@ var SignInAndUpCallback$1 = function (props) { if (STGeneralError__default.default.isThisError(err)) { return [ 2 /*return*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: "custom", @@ -598,7 +606,7 @@ var SignInAndUpCallback$1 = function (props) { } return [ 2 /*return*/, - superTokens.SuperTokens.getInstanceOrThrow().redirectToAuth({ + genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().redirectToAuth({ navigate: props.navigate, queryParams: { error: "signin", @@ -613,18 +621,18 @@ var SignInAndUpCallback$1 = function (props) { }, [props.navigate, userContext] ); - superTokens.useOnMountAPICall(verifyCode, handleVerifyResponse, handleError); + genericComponentOverrideContext.useOnMountAPICall(verifyCode, handleVerifyResponse, handleError); var recipeComponentOverrides = props.useComponentOverrides(); return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { - useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, + useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, defaultStore: defaultTranslationsThirdParty, }, { @@ -644,7 +652,7 @@ var SignInAndUpCallback$1 = function (props) { }; var ThirdPartyPreBuiltUI = /** @class */ (function (_super) { - superTokens.__extends(ThirdPartyPreBuiltUI, _super); + genericComponentOverrideContext.__extends(ThirdPartyPreBuiltUI, _super); function ThirdPartyPreBuiltUI(recipeInstance) { var _this = _super.call(this) || this; _this.recipeInstance = recipeInstance; @@ -677,19 +685,21 @@ var ThirdPartyPreBuiltUI = /** @class */ (function (_super) { if (componentName === "signinupcallback") { return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( session.SessionAuth, - superTokens.__assign( + genericComponentOverrideContext.__assign( { requireAuth: false, doRedirection: false }, { children: jsxRuntime.jsx( SignInAndUpCallback$1, - superTokens.__assign({ recipe: _this.recipeInstance }, props, { - useComponentOverrides: useComponentOverrides, - }) + genericComponentOverrideContext.__assign( + { recipe: _this.recipeInstance }, + props, + { useComponentOverrides: useComponentOverrides } + ) ), } ) @@ -734,7 +744,7 @@ var ThirdPartyPreBuiltUI = /** @class */ (function (_super) { component: function (props) { return jsxRuntime.jsx( SignInAndUpFeatureWrapper, - superTokens.__assign({}, props, { + genericComponentOverrideContext.__assign({}, props, { recipe: _this.recipeInstance, useComponentOverrides: recipe.useContext, }), @@ -749,7 +759,7 @@ var ThirdPartyPreBuiltUI = /** @class */ (function (_super) { }; // For tests ThirdPartyPreBuiltUI.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } ThirdPartyPreBuiltUI.instance = undefined; diff --git a/lib/build/totp-shared.js b/lib/build/totp-shared.js index 19bcbbaf7..ce1ea7bc5 100644 --- a/lib/build/totp-shared.js +++ b/lib/build/totp-shared.js @@ -1,7 +1,6 @@ "use strict"; var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); -var superTokens = require("./superTokens.js"); var TOTPWebJS = require("supertokens-web-js/recipe/totp"); var postSuperTokensInitCallbacks = require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); var jsxRuntime = require("react/jsx-runtime"); @@ -22,7 +21,7 @@ var _a = genericComponentOverrideContext.createGenericComponentsOverrideContext( var TOTPIcon = function () { return jsxRuntime.jsxs( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { width: "20", height: "19", viewBox: "0 0 20 19", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [ @@ -35,7 +34,7 @@ var TOTPIcon = function () { jsxRuntime.jsx("defs", { children: jsxRuntime.jsxs( "linearGradient", - superTokens.__assign( + genericComponentOverrideContext.__assign( { id: "paint0_linear_4901_3396", x1: "10", @@ -61,11 +60,11 @@ var TOTPIcon = function () { var getFunctionOverrides = function (onHandleEvent) { return function (originalImp) { - return superTokens.__assign(superTokens.__assign({}, originalImp), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImp), { createDevice: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.createDevice(input)]; @@ -84,9 +83,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, verifyDevice: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.verifyDevice(input)]; @@ -106,9 +105,9 @@ var getFunctionOverrides = function (onHandleEvent) { }); }, verifyCode: function (input) { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var response; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImp.verifyCode(input)]; @@ -147,7 +146,7 @@ function normaliseMultiFactorAuthFeature(config) { if (config === undefined) { config = {}; } - var override = superTokens.__assign( + var override = genericComponentOverrideContext.__assign( { functions: function (originalImplementation) { return originalImplementation; @@ -155,23 +154,29 @@ function normaliseMultiFactorAuthFeature(config) { }, config.override ); - return superTokens.__assign(superTokens.__assign({}, superTokens.normaliseRecipeModuleConfig(config)), { - totpMFAScreen: superTokens.__assign( - { - disableDefaultUI: false, - blockedScreenStyle: "", - setupScreenStyle: "", - verificationScreenStyle: "", - loadingScreenStyle: "", - }, - config.totpMFAScreen + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign( + {}, + genericComponentOverrideContext.normaliseRecipeModuleConfig(config) ), - override: override, - }); + { + totpMFAScreen: genericComponentOverrideContext.__assign( + { + disableDefaultUI: false, + blockedScreenStyle: "", + setupScreenStyle: "", + verificationScreenStyle: "", + loadingScreenStyle: "", + }, + config.totpMFAScreen + ), + override: override, + } + ); } function totpCodeValidate(value) { - return superTokens.__awaiter(this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { if (typeof value !== "string") { return [2 /*return*/, "GENERAL_ERROR_TOTP_NON_STRING"]; } @@ -205,7 +210,7 @@ var totpFactor = { logo: TOTPIcon, }; var TOTP = /** @class */ (function (_super) { - superTokens.__extends(TOTP, _super); + genericComponentOverrideContext.__extends(TOTP, _super); function TOTP(config, webJSRecipe) { if (webJSRecipe === void 0) { webJSRecipe = TOTPWebJS__default.default; @@ -215,8 +220,8 @@ var TOTP = /** @class */ (function (_super) { _this.recipeID = TOTP.RECIPE_ID; // eslint-disable-next-line @typescript-eslint/no-unused-vars _this.getDefaultRedirectionURL = function (_context) { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { throw new Error("Should never come here"); }); }); @@ -235,24 +240,27 @@ var TOTP = /** @class */ (function (_super) { recipeID: TOTP.RECIPE_ID, authReact: function (appInfo) { TOTP.instance = new TOTP( - superTokens.__assign(superTokens.__assign({}, normalisedConfig), { - appInfo: appInfo, - recipeId: TOTP.RECIPE_ID, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { appInfo: appInfo, recipeId: TOTP.RECIPE_ID } + ) ); return TOTP.instance; }, webJS: TOTPWebJS__default.default.init( - superTokens.__assign(superTokens.__assign({}, normalisedConfig), { - override: { - functions: function (originalImpl, builder) { - var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); - builder.override(functions); - builder.override(normalisedConfig.override.functions); - return originalImpl; + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, normalisedConfig), + { + override: { + functions: function (originalImpl, builder) { + var functions = getFunctionOverrides(normalisedConfig.onHandleEvent); + builder.override(functions); + builder.override(normalisedConfig.override.functions); + return originalImpl; + }, }, - }, - }) + } + ) ), }; }; @@ -264,7 +272,7 @@ var TOTP = /** @class */ (function (_super) { var error = "No instance of TOTP found. Make sure to call the TOTP.init method."; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { - error = error + superTokens.SSR_ERROR; + error = error + genericComponentOverrideContext.SSR_ERROR; } throw Error(error); } diff --git a/lib/build/totp.js b/lib/build/totp.js index 61a7a7d57..05a5da4c6 100644 --- a/lib/build/totp.js +++ b/lib/build/totp.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var recipe = require("./totp-shared.js"); require("supertokens-web-js"); require("supertokens-web-js/utils/cookieHandler"); @@ -13,7 +13,6 @@ require("supertokens-web-js/utils"); require("react"); require("supertokens-web-js/utils/normalisedURLDomain"); require("supertokens-web-js/utils/normalisedURLPath"); -require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); require("supertokens-web-js/recipe/totp"); require("./multifactorauth-shared2.js"); @@ -46,8 +45,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.createDevice = function (input) { return recipe.TOTP.getInstanceOrThrow().webJSRecipe.createDevice( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -55,8 +54,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.verifyCode = function (input) { return recipe.TOTP.getInstanceOrThrow().webJSRecipe.verifyCode( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -64,8 +63,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.verifyDevice = function (input) { return recipe.TOTP.getInstanceOrThrow().webJSRecipe.verifyDevice( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -73,8 +72,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.removeDevice = function (input) { return recipe.TOTP.getInstanceOrThrow().webJSRecipe.removeDevice( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) @@ -82,8 +81,8 @@ var Wrapper = /** @class */ (function () { }; Wrapper.listDevices = function (input) { return recipe.TOTP.getInstanceOrThrow().webJSRecipe.listDevices( - superTokens.__assign(superTokens.__assign({}, input), { - userContext: superTokens.getNormalisedUserContext( + genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, input), { + userContext: genericComponentOverrideContext.getNormalisedUserContext( input === null || input === void 0 ? void 0 : input.userContext ), }) diff --git a/lib/build/totpprebuiltui.js b/lib/build/totpprebuiltui.js index 72c1c7604..3b1125a98 100644 --- a/lib/build/totpprebuiltui.js +++ b/lib/build/totpprebuiltui.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var jsxRuntime = require("react/jsx-runtime"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); var uiEntry = require("./index2.js"); @@ -23,7 +23,6 @@ require("supertokens-web-js/utils"); require("supertokens-web-js/utils/normalisedURLDomain"); require("react-dom"); require("./multitenancy-shared.js"); -require("./genericComponentOverrideContext.js"); require("./oauth2provider-shared.js"); require("supertokens-web-js/recipe/oauth2provider"); require("./recipeModule-shared.js"); @@ -95,7 +94,7 @@ var ThemeBase = function (_a) { var BlockedIcon = function () { return jsxRuntime.jsxs( "svg", - superTokens.__assign( + genericComponentOverrideContext.__assign( { xmlns: "http://www.w3.org/2000/svg", width: "65", height: "65", viewBox: "0 0 65 65", fill: "none" }, { children: [ @@ -147,7 +146,7 @@ var RetryButton = function (_a) { ); return jsxRuntime.jsx( "button", - superTokens.__assign( + genericComponentOverrideContext.__assign( { type: "button", disabled: secsUntilRetry !== undefined, @@ -182,26 +181,26 @@ var TOTPBlockedScreen = function (props) { var t = translationContext.useTranslation(); return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container totp-mfa blockedScreen" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row noFormRow" }, { children: [ jsxRuntime.jsx(BlockedIcon, {}), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle" }, { children: t("TOTP_BLOCKED_TITLE") } ) ), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: t("TOTP_BLOCKED_SUBTITLE") } ) @@ -219,7 +218,7 @@ var TOTPBlockedScreen = function (props) { ), jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: props.onSignOutClicked, @@ -247,17 +246,17 @@ var BlockedScreen = uiEntry.withOverride("TOTPBlockedScreen", TOTPBlockedScreen) var TOTPLoadingScreen = function () { return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container delayedRender totp-mfa loadingScreen" }, { children: jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "spinner delayedRender" }, { children: jsxRuntime.jsx(uiEntry.SpinnerIcon, {}) } ) @@ -294,10 +293,10 @@ var CodeForm = uiEntry.withOverride("TOTPCodeForm", function TOTPCodeForm(props) onSuccess: props.onSuccess, buttonLabel: "TOTP_CODE_CONTINUE_BUTTON", callAPI: function (formFields) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var totp, response; var _a; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: totp = @@ -362,12 +361,12 @@ var CodeVerificationFooter = uiEntry.withOverride( var t = translationContext.useTranslation(); return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "footerLinkGroupVert totp-mfa codeVerificationFooter" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: onSignOutClicked, @@ -396,7 +395,7 @@ var CodeVerificationHeader = uiEntry.withOverride( children: [ jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle withBackButton totp-mfa codeVerificationHeader" }, { children: [ @@ -415,7 +414,7 @@ var CodeVerificationHeader = uiEntry.withOverride( ), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: t("TOTP_CODE_VERIFICATION_HEADER_SUBTITLE") } ) @@ -3356,7 +3355,7 @@ var DeviceInfoSection = uiEntry.withOverride("TOTPDeviceInfoSection", function T children: [ jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "totpDeviceInfoWithQR totp-mfa deviceInfoSection" }, { children: [ @@ -3367,14 +3366,14 @@ var DeviceInfoSection = uiEntry.withOverride("TOTPDeviceInfoSection", function T }), jsxRuntime.jsxs( "span", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "showTOTPSecret" }, { children: [ t("TOTP_SHOW_SECRET_START"), jsxRuntime.jsx( "button", - superTokens.__assign( + genericComponentOverrideContext.__assign( { type: "button", onClick: props.onShowSecretClicked, @@ -3391,7 +3390,7 @@ var DeviceInfoSection = uiEntry.withOverride("TOTPDeviceInfoSection", function T props.showSecret && jsxRuntime.jsx( "span", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "totpSecret" }, { children: props.deviceInfo.secret } ) @@ -3410,12 +3409,12 @@ var DeviceSetupFooter = uiEntry.withOverride("TOTPDeviceSetupFooter", function T var t = translationContext.useTranslation(); return jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "footerLinkGroupVert totp-mfa deviceSetupFooter" }, { children: jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "secondaryText secondaryLinkWithLeftArrow", onClick: onSignOutClicked }, { children: [ @@ -3438,7 +3437,7 @@ var DeviceSetupHeader = uiEntry.withOverride("TOTPDeviceSetupHeader", function T children: [ jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerTitle withBackButton totp-mfa deviceSetupHeader" }, { children: [ @@ -3455,7 +3454,7 @@ var DeviceSetupHeader = uiEntry.withOverride("TOTPDeviceSetupHeader", function T ), jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "headerSubtitle secondaryText" }, { children: t("TOTP_DEVICE_SETUP_HEADER_SUBTITLE") } ) @@ -3476,7 +3475,7 @@ var TOTPMFAScreens; var TOTPMFATheme = function (_a) { var activeScreen = _a.activeScreen, featureState = _a.featureState, - props = superTokens.__rest(_a, ["activeScreen", "featureState"]); + props = genericComponentOverrideContext.__rest(_a, ["activeScreen", "featureState"]); var t = translationContext.useTranslation(); var commonProps = { featureState: featureState, @@ -3504,13 +3503,13 @@ var TOTPMFATheme = function (_a) { ? jsxRuntime.jsx(LoadingScreen, {}) : jsxRuntime.jsxs( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "container totp-mfa" }, { children: [ jsxRuntime.jsx( "div", - superTokens.__assign( + genericComponentOverrideContext.__assign( { "data-supertokens": "row" }, { children: @@ -3520,14 +3519,14 @@ var TOTPMFATheme = function (_a) { activeScreen === TOTPMFAScreens.DeviceSetup ? jsxRuntime.jsx( DeviceSetupHeader, - superTokens.__assign({}, commonProps, { + genericComponentOverrideContext.__assign({}, commonProps, { showBackButton: featureState.showBackButton, onBackButtonClicked: props.onBackButtonClicked, }) ) : jsxRuntime.jsx( CodeVerificationHeader, - superTokens.__assign({}, commonProps, { + genericComponentOverrideContext.__assign({}, commonProps, { showBackButton: featureState.showBackButton, onBackButtonClicked: props.onBackButtonClicked, }) @@ -3535,7 +3534,7 @@ var TOTPMFATheme = function (_a) { activeScreen === TOTPMFAScreens.DeviceSetup && jsxRuntime.jsx( DeviceInfoSection, - superTokens.__assign({}, commonProps, { + genericComponentOverrideContext.__assign({}, commonProps, { deviceInfo: featureState.deviceInfo, showSecret: featureState.showSecret, onShowSecretClicked: props.onShowSecretClicked, @@ -3547,21 +3546,25 @@ var TOTPMFATheme = function (_a) { }), jsxRuntime.jsx( CodeForm, - superTokens.__assign({}, commonProps, { + genericComponentOverrideContext.__assign({}, commonProps, { onSuccess: props.onSuccess, footer: activeScreen === TOTPMFAScreens.DeviceSetup ? jsxRuntime.jsx( DeviceSetupFooter, - superTokens.__assign({}, commonProps, { - onSignOutClicked: props.onSignOutClicked, - }) + genericComponentOverrideContext.__assign( + {}, + commonProps, + { onSignOutClicked: props.onSignOutClicked } + ) ) : jsxRuntime.jsx( CodeVerificationFooter, - superTokens.__assign({}, commonProps, { - onSignOutClicked: props.onSignOutClicked, - }) + genericComponentOverrideContext.__assign( + {}, + commonProps, + { onSignOutClicked: props.onSignOutClicked } + ) ), }) ), @@ -3577,7 +3580,7 @@ var TOTPMFATheme = function (_a) { ); }; function TOTPMFAThemeWrapper(props) { - var rootStyle = superTokens.SuperTokens.getInstanceOrThrow().rootStyle; + var rootStyle = genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().rootStyle; var hasFont = uiEntry.hasFontDefined(rootStyle) || uiEntry.hasFontDefined(props.config.recipeRootStyle); var activeScreen = getActiveScreen(props); var activeStyle; @@ -3592,12 +3595,12 @@ function TOTPMFAThemeWrapper(props) { } return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( ThemeBase, - superTokens.__assign( + genericComponentOverrideContext.__assign( { loadDefaultFont: !hasFont, userStyles: [rootStyle, props.config.recipeRootStyle, activeStyle], @@ -3605,7 +3608,7 @@ function TOTPMFAThemeWrapper(props) { { children: jsxRuntime.jsx( TOTPMFATheme, - superTokens.__assign({}, props, { activeScreen: activeScreen }) + genericComponentOverrideContext.__assign({}, props, { activeScreen: activeScreen }) ), } ) @@ -3641,33 +3644,38 @@ function getErrorString(error, state, t) { } var defaultTranslationsTOTP = { - en: superTokens.__assign(superTokens.__assign({}, uiEntry.defaultTranslationsCommon.en), { - TOTP_SHOW_SECRET_START: "Unable to scan? Use a", - TOTP_SHOW_SECRET_LINK: "secret key", - TOTP_SHOW_SECRET_END: "", - TOTP_CODE_VERIFICATION_HEADER_TITLE: "Enter TOTP", - TOTP_CODE_VERIFICATION_HEADER_SUBTITLE: - "Open the two-factor authenticator (TOTP) app on your mobile device to view your authentication code", - TOTP_DEVICE_SETUP_HEADER_TITLE: "Add a TOTP device", - TOTP_DEVICE_SETUP_HEADER_SUBTITLE: "Please scan the given QR code from a phone app like Google Authenticator.", - TOTP_CODE_INPUT_LABEL: "Please enter TOTP", - TOTP_CODE_CONTINUE_BUTTON: "Continue", - TOTP_BLOCKED_TITLE: "Account locked", - TOTP_BLOCKED_SUBTITLE: "Account locked due to multiple failed login attempts.", - TOTP_MFA_BLOCKED_TIMER_START: "", - TOTP_MFA_BLOCKED_TIMER_END: "", - TOTP_MFA_BLOCKED_RETRY: "Try again", - TOTP_MFA_LOGOUT: "Logout", - ERROR_TOTP_INVALID_CODE: "Invalid TOTP. Please try again.", - ERROR_TOTP_INVALID_CODE_RETRY_START: "", - // \xA0 is non breaking space. - // We add it to make sure there is no line break between the number and the rest of the sentence - ERROR_TOTP_INVALID_CODE_RETRY_END: "\xA0attempt(s) remaining before account is temporarily locked.", - ERROR_TOTP_UNKNOWN_DEVICE: "The device was deleted before verification. Please refresh the page to try again.", - GENERAL_ERROR_TOTP_NON_STRING: "TOTP code must be of type string", - GENERAL_ERROR_TOTP_EMPTY: "TOTP code cannot be empty", - GENERAL_ERROR_TOTP_UNDEFINED: "Please fill your TOTP code", - }), + en: genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, uiEntry.defaultTranslationsCommon.en), + { + TOTP_SHOW_SECRET_START: "Unable to scan? Use a", + TOTP_SHOW_SECRET_LINK: "secret key", + TOTP_SHOW_SECRET_END: "", + TOTP_CODE_VERIFICATION_HEADER_TITLE: "Enter TOTP", + TOTP_CODE_VERIFICATION_HEADER_SUBTITLE: + "Open the two-factor authenticator (TOTP) app on your mobile device to view your authentication code", + TOTP_DEVICE_SETUP_HEADER_TITLE: "Add a TOTP device", + TOTP_DEVICE_SETUP_HEADER_SUBTITLE: + "Please scan the given QR code from a phone app like Google Authenticator.", + TOTP_CODE_INPUT_LABEL: "Please enter TOTP", + TOTP_CODE_CONTINUE_BUTTON: "Continue", + TOTP_BLOCKED_TITLE: "Account locked", + TOTP_BLOCKED_SUBTITLE: "Account locked due to multiple failed login attempts.", + TOTP_MFA_BLOCKED_TIMER_START: "", + TOTP_MFA_BLOCKED_TIMER_END: "", + TOTP_MFA_BLOCKED_RETRY: "Try again", + TOTP_MFA_LOGOUT: "Logout", + ERROR_TOTP_INVALID_CODE: "Invalid TOTP. Please try again.", + ERROR_TOTP_INVALID_CODE_RETRY_START: "", + // \xA0 is non breaking space. + // We add it to make sure there is no line break between the number and the rest of the sentence + ERROR_TOTP_INVALID_CODE_RETRY_END: "\xA0attempt(s) remaining before account is temporarily locked.", + ERROR_TOTP_UNKNOWN_DEVICE: + "The device was deleted before verification. Please refresh the page to try again.", + GENERAL_ERROR_TOTP_NON_STRING: "TOTP code must be of type string", + GENERAL_ERROR_TOTP_EMPTY: "TOTP code cannot be empty", + GENERAL_ERROR_TOTP_UNDEFINED: "Please fill your TOTP code", + } + ), }; var useFeatureReducer = function () { @@ -3687,38 +3695,46 @@ var useFeatureReducer = function () { showSecret: false, }; case "setBlocked": - return superTokens.__assign(superTokens.__assign({}, oldState), { - isBlocked: true, - nextRetryAt: action.nextRetryAt, - error: action.error, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, oldState), + { isBlocked: true, nextRetryAt: action.nextRetryAt, error: action.error } + ); case "setError": - return superTokens.__assign(superTokens.__assign({}, oldState), { - loaded: true, - maxAttemptCount: - (_a = action.maxAttemptCount) !== null && _a !== void 0 ? _a : oldState.maxAttemptCount, - currAttemptCount: - (_b = action.currAttemptCount) !== null && _b !== void 0 ? _b : oldState.currAttemptCount, - showAccessDenied: action.showAccessDenied, - error: action.error, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, oldState), + { + loaded: true, + maxAttemptCount: + (_a = action.maxAttemptCount) !== null && _a !== void 0 ? _a : oldState.maxAttemptCount, + currAttemptCount: + (_b = action.currAttemptCount) !== null && _b !== void 0 + ? _b + : oldState.currAttemptCount, + showAccessDenied: action.showAccessDenied, + error: action.error, + } + ); case "createDevice": - return superTokens.__assign(superTokens.__assign({}, oldState), { - deviceInfo: action.deviceInfo, - isBlocked: false, - showSecret: false, - nextRetryAt: undefined, - error: undefined, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, oldState), + { + deviceInfo: action.deviceInfo, + isBlocked: false, + showSecret: false, + nextRetryAt: undefined, + error: undefined, + } + ); case "showSecret": - return superTokens.__assign(superTokens.__assign({}, oldState), { showSecret: true }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, oldState), + { showSecret: true } + ); case "restartFlow": - return superTokens.__assign(superTokens.__assign({}, oldState), { - isBlocked: false, - showSecret: false, - nextRetryAt: undefined, - error: action.error, - }); + return genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, oldState), + { isBlocked: false, showSecret: false, nextRetryAt: undefined, error: action.error } + ); default: return oldState; } @@ -3734,11 +3750,13 @@ var useFeatureReducer = function () { }, function (initArg) { var error = undefined; - var errorQueryParam = superTokens.getQueryParams("error"); + var errorQueryParam = genericComponentOverrideContext.getQueryParams("error"); if (errorQueryParam !== null) { error = "SOMETHING_WENT_WRONG_ERROR"; } - return superTokens.__assign(superTokens.__assign({}, initArg), { error: error }); + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, initArg), { + error: error, + }); } ); }; @@ -3746,8 +3764,8 @@ function useOnLoad(recipeImpl, dispatch, userContext) { var _this = this; var fetchMFAInfo = React__namespace.useCallback( function () { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { return [ 2 /*return*/, recipe$1.MultiFactorAuth.getInstanceOrThrow().webJSRecipe.resyncSessionAndFetchMFAInfo({ @@ -3767,14 +3785,14 @@ function useOnLoad(recipeImpl, dispatch, userContext) { ); var onLoad = React__namespace.useCallback( function (mfaInfo) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var error, errorQueryParam, doSetup, alreadySetup, showBackButton, deviceInfo, createResp; - return superTokens.__generator(this, function (_b) { + return genericComponentOverrideContext.__generator(this, function (_b) { switch (_b.label) { case 0: error = undefined; - errorQueryParam = superTokens.getQueryParams("error"); - doSetup = superTokens.getQueryParams("setup"); + errorQueryParam = genericComponentOverrideContext.getQueryParams("error"); + doSetup = genericComponentOverrideContext.getQueryParams("setup"); if (errorQueryParam !== null) { error = "SOMETHING_WENT_WRONG_ERROR"; } @@ -3821,7 +3839,7 @@ function useOnLoad(recipeImpl, dispatch, userContext) { }); return [2 /*return*/]; } - deviceInfo = superTokens.__assign({}, createResp); + deviceInfo = genericComponentOverrideContext.__assign({}, createResp); delete deviceInfo.status; _b.label = 5; case 5: @@ -3841,11 +3859,11 @@ function useOnLoad(recipeImpl, dispatch, userContext) { }, [dispatch, recipeImpl, userContext] ); - superTokens.useOnMountAPICall(fetchMFAInfo, onLoad, handleLoadError); + genericComponentOverrideContext.useOnMountAPICall(fetchMFAInfo, onLoad, handleLoadError); } function useChildProps(recipe, recipeImplementation, state, dispatch, userContext, navigate) { var _this = this; - var rethrowInRender = superTokens.useRethrowInRender(); + var rethrowInRender = genericComponentOverrideContext.useRethrowInRender(); return React.useMemo( function () { return { @@ -3853,8 +3871,8 @@ function useChildProps(recipe, recipeImplementation, state, dispatch, userContex dispatch({ type: "showSecret" }); }, onBackButtonClicked: function () { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: if (!state.deviceInfo) return [3 /*break*/, 2]; @@ -3892,8 +3910,8 @@ function useChildProps(recipe, recipeImplementation, state, dispatch, userContex dispatch({ type: "restartFlow", error: undefined }); }, onSignOutClicked: function () { - return superTokens.__awaiter(_this, void 0, void 0, function () { - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: if (!state.deviceInfo) return [3 /*break*/, 2]; @@ -3926,7 +3944,7 @@ function useChildProps(recipe, recipeImplementation, state, dispatch, userContex }); }, onSuccess: function () { - var redirectToPath = superTokens.getRedirectToPathFromURL(); + var redirectToPath = genericComponentOverrideContext.getRedirectToPathFromURL(); return types.Session.getInstanceOrThrow() .validateGlobalClaimsAndHandleSuccessRedirection( undefined, @@ -3960,14 +3978,14 @@ var SignInUpFeature = function (props) { useOnLoad(recipeImplementation, dispatch, userContext); return jsxRuntime.jsx( uiEntry.ComponentOverrideContext.Provider, - superTokens.__assign( + genericComponentOverrideContext.__assign( { value: recipeComponentOverrides }, { children: jsxRuntime.jsx( uiEntry.FeatureWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { - useShadowDom: superTokens.SuperTokens.getInstanceOrThrow().useShadowDom, + useShadowDom: genericComponentOverrideContext.SuperTokens.getInstanceOrThrow().useShadowDom, defaultStore: defaultTranslationsTOTP, }, { @@ -3976,7 +3994,7 @@ var SignInUpFeature = function (props) { props.children === undefined && jsxRuntime.jsx( TOTPMFAThemeWrapper, - superTokens.__assign({}, childProps, { + genericComponentOverrideContext.__assign({}, childProps, { featureState: state, dispatch: dispatch, }) @@ -3986,10 +4004,10 @@ var SignInUpFeature = function (props) { if (React__namespace.isValidElement(child)) { return React__namespace.cloneElement( child, - superTokens.__assign(superTokens.__assign({}, childProps), { - featureState: state, - dispatch: dispatch, - }) + genericComponentOverrideContext.__assign( + genericComponentOverrideContext.__assign({}, childProps), + { featureState: state, dispatch: dispatch } + ) ); } return child; @@ -4005,18 +4023,18 @@ var SignInUpFeature = function (props) { }; function getModifiedRecipeImplementation(originalImpl, dispatch) { var _this = this; - return superTokens.__assign(superTokens.__assign({}, originalImpl), { + return genericComponentOverrideContext.__assign(genericComponentOverrideContext.__assign({}, originalImpl), { createDevice: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var res, deviceInfo; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.createDevice(input)]; case 1: res = _a.sent(); if (res.status === "OK") { - deviceInfo = superTokens.__assign({}, res); + deviceInfo = genericComponentOverrideContext.__assign({}, res); delete deviceInfo.status; dispatch({ type: "createDevice", deviceInfo: deviceInfo }); } @@ -4026,9 +4044,9 @@ function getModifiedRecipeImplementation(originalImpl, dispatch) { }); }, verifyCode: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var res; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.verifyCode(input)]; @@ -4055,9 +4073,9 @@ function getModifiedRecipeImplementation(originalImpl, dispatch) { }); }, verifyDevice: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var res; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.verifyDevice(input)]; @@ -4090,9 +4108,9 @@ function getModifiedRecipeImplementation(originalImpl, dispatch) { }); }, removeDevice: function (input) { - return superTokens.__awaiter(_this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { var res; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, originalImpl.removeDevice(input)]; @@ -4124,7 +4142,7 @@ function getModifiedRecipeImplementation(originalImpl, dispatch) { var DEFAULT_TOTP_PATH = "/mfa/totp"; var TOTPPreBuiltUI = /** @class */ (function (_super) { - superTokens.__extends(TOTPPreBuiltUI, _super); + genericComponentOverrideContext.__extends(TOTPPreBuiltUI, _super); function TOTPPreBuiltUI(recipeInstance) { var _this = _super.call(this) || this; _this.recipeInstance = recipeInstance; @@ -4140,7 +4158,9 @@ var TOTPPreBuiltUI = /** @class */ (function (_super) { new NormalisedURLPath__default.default(DEFAULT_TOTP_PATH) ); features[normalisedFullPath.getAsStringDangerous()] = { - matches: superTokens.matchRecipeIdUsingQueryParams(_this.recipeInstance.config.recipeId), + matches: genericComponentOverrideContext.matchRecipeIdUsingQueryParams( + _this.recipeInstance.config.recipeId + ), component: function (props) { return _this.getFeatureComponent("mfaTOTP", props, useComponentOverrides); }, @@ -4160,12 +4180,12 @@ var TOTPPreBuiltUI = /** @class */ (function (_super) { } return jsxRuntime.jsx( uiEntry.UserContextWrapper, - superTokens.__assign( + genericComponentOverrideContext.__assign( { userContext: props.userContext }, { children: jsxRuntime.jsx( session.SessionAuth, - superTokens.__assign( + genericComponentOverrideContext.__assign( { overrideGlobalClaimValidators: function () { return []; @@ -4174,7 +4194,7 @@ var TOTPPreBuiltUI = /** @class */ (function (_super) { { children: jsxRuntime.jsx( SignInUpFeature, - superTokens.__assign( + genericComponentOverrideContext.__assign( { recipe: _this.recipeInstance, useComponentOverrides: useComponentOverrides, @@ -4220,7 +4240,7 @@ var TOTPPreBuiltUI = /** @class */ (function (_super) { }; // For tests TOTPPreBuiltUI.reset = function () { - if (!superTokens.isTest()) { + if (!genericComponentOverrideContext.isTest()) { return; } TOTPPreBuiltUI.instance = undefined; diff --git a/lib/build/translationContext.js b/lib/build/translationContext.js index 01ccda532..f74c9f995 100644 --- a/lib/build/translationContext.js +++ b/lib/build/translationContext.js @@ -1,6 +1,6 @@ "use strict"; -var superTokens = require("./superTokens.js"); +var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var jsxRuntime = require("react/jsx-runtime"); var React = require("react"); @@ -34,12 +34,12 @@ var TranslationContextProvider = function (_a) { React.useEffect( function () { function loadLanguageFromCookies() { - return superTokens.__awaiter(this, void 0, void 0, function () { + return genericComponentOverrideContext.__awaiter(this, void 0, void 0, function () { var cookieLang, cookieLangTemp; - return superTokens.__generator(this, function (_a) { + return genericComponentOverrideContext.__generator(this, function (_a) { switch (_a.label) { case 0: - return [4 /*yield*/, superTokens.getCurrentLanguageFromCookie()]; + return [4 /*yield*/, genericComponentOverrideContext.getCurrentLanguageFromCookie()]; case 1: cookieLang = _a.sent(); cookieLangTemp = cookieLang === null ? defaultLanguage : cookieLang; @@ -70,7 +70,7 @@ var TranslationContextProvider = function (_a) { // eslint-disable-next-line @typescript-eslint/no-unused-vars var loadHandler = function (_eventName, detail) { setTranslationStore(function (os) { - return superTokens.mergeObjects(os, detail); + return genericComponentOverrideContext.mergeObjects(os, detail); }); }; translationControlEventSource.on("LanguageChange", changeHandler); @@ -105,7 +105,7 @@ var TranslationContextProvider = function (_a) { } return jsxRuntime.jsx( TranslationContext.Provider, - superTokens.__assign({ value: { translate: translateFunc } }, { children: children }) + genericComponentOverrideContext.__assign({ value: { translate: translateFunc } }, { children: children }) ); }; diff --git a/lib/build/ui-entry.js b/lib/build/ui-entry.js index 941fd497d..c91525c6e 100644 --- a/lib/build/ui-entry.js +++ b/lib/build/ui-entry.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -require("./superTokens.js"); +require("./genericComponentOverrideContext.js"); require("react/jsx-runtime"); require("react"); var uiEntry = require("./index2.js"); @@ -17,7 +17,6 @@ require("supertokens-web-js/utils/normalisedURLPath"); require("./translationContext.js"); require("react-dom"); require("./multitenancy-shared.js"); -require("./genericComponentOverrideContext.js"); require("./multifactorauth-shared2.js"); require("supertokens-web-js/recipe/multifactorauth"); require("supertokens-web-js/utils/sessionClaimValidatorStore"); diff --git a/lib/ts/recipe/oauth2provider/componentOverrideContext.tsx b/lib/ts/recipe/oauth2provider/componentOverrideContext.tsx new file mode 100644 index 000000000..467bd5485 --- /dev/null +++ b/lib/ts/recipe/oauth2provider/componentOverrideContext.tsx @@ -0,0 +1,7 @@ +import { createGenericComponentsOverrideContext } from "../../components/componentOverride/genericComponentOverrideContext"; + +import type { ComponentOverrideMap } from "./types"; + +const [useContext, Provider] = createGenericComponentsOverrideContext(); + +export { useContext as useRecipeComponentOverrideContext, Provider as RecipeComponentsOverrideContextProvider }; diff --git a/lib/ts/recipe/oauth2provider/components/features/tryRefreshPage/index.tsx b/lib/ts/recipe/oauth2provider/components/features/tryRefreshPage/index.tsx new file mode 100644 index 000000000..9392157f1 --- /dev/null +++ b/lib/ts/recipe/oauth2provider/components/features/tryRefreshPage/index.tsx @@ -0,0 +1,90 @@ +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +/* + * Imports. + */ +import * as React from "react"; +import { useContext, Fragment } from "react"; + +import FeatureWrapper from "../../../../../components/featureWrapper"; +import SuperTokens from "../../../../../superTokens"; +import { useUserContext } from "../../../../../usercontext"; +import { getQueryParams, useRethrowInRender } from "../../../../../utils"; +import DynamicLoginMethodsSpinner from "../../../../multitenancy/components/features/dynamicLoginMethodsSpinner"; +import { SessionContext } from "../../../../session"; +import { defaultTranslationsOAuth2Provider } from "../../themes/translations"; + +import type { FeatureBaseProps, UserContext } from "../../../../../types"; +import type Recipe from "../../../recipe"; +import type { ComponentOverrideMap } from "../../../types"; + +type Prop = FeatureBaseProps<{ + recipe: Recipe; + userContext?: UserContext; + useComponentOverrides: () => ComponentOverrideMap; +}>; + +export const TryRefreshPage: React.FC = (props) => { + const rethrowInRender = useRethrowInRender(); + const sessionContext = useContext(SessionContext); + const loginChallenge = getQueryParams("loginChallenge") ?? undefined; + let userContext = useUserContext(); + if (props.userContext !== undefined) { + userContext = props.userContext; + } + + React.useEffect(() => { + if (sessionContext.loading === false) { + void props.recipe + .redirect( + { + action: "CONTINUE_OAUTH2_AFTER_REFRESH", + loginChallenge: loginChallenge ?? "", + recipeId: "oauth2provider", + }, + props.navigate, + {}, + userContext + ) + .catch(rethrowInRender); + } + }, [loginChallenge, props.recipe, props.navigate, userContext, sessionContext]); + + const childProps = { + config: props.recipe.config, + }; + return ( + + + {/* No custom theme, use default. */} + {props.children === undefined && } + {/* Otherwise, custom theme is provided, propagate props. */} + {props.children && + React.Children.map(props.children, (child) => { + if (React.isValidElement(child)) { + return React.cloneElement(child, childProps); + } + + return child; + })} + + + ); +}; + +export default TryRefreshPage; diff --git a/lib/ts/recipe/oauth2provider/components/themes/translations.ts b/lib/ts/recipe/oauth2provider/components/themes/translations.ts new file mode 100644 index 000000000..46e47ec58 --- /dev/null +++ b/lib/ts/recipe/oauth2provider/components/themes/translations.ts @@ -0,0 +1,3 @@ +export const defaultTranslationsOAuth2Provider = { + en: {}, +}; diff --git a/lib/ts/recipe/oauth2provider/constants.ts b/lib/ts/recipe/oauth2provider/constants.ts new file mode 100644 index 000000000..13c4c4e90 --- /dev/null +++ b/lib/ts/recipe/oauth2provider/constants.ts @@ -0,0 +1,15 @@ +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +export const DEFAULT_TRY_REFRESH_PATH = "/try-refresh"; diff --git a/lib/ts/recipe/oauth2provider/functionOverrides.ts b/lib/ts/recipe/oauth2provider/functionOverrides.ts new file mode 100644 index 000000000..7e0fc33d5 --- /dev/null +++ b/lib/ts/recipe/oauth2provider/functionOverrides.ts @@ -0,0 +1,19 @@ +import type { OnHandleEventContext } from "./types"; +import type { RecipeOnHandleEventFunction } from "../recipeModule/types"; +import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2provider"; + +export const getFunctionOverrides = + (onHandleEvent: RecipeOnHandleEventFunction) => + (originalImp: RecipeInterface): RecipeInterface => ({ + ...originalImp, + async getLoginChallengeInfo(input) { + const response = await originalImp.getLoginChallengeInfo(input); + onHandleEvent({ + action: "LOADED_LOGIN_CHALLENGE", + loginChallenge: input.loginChallenge, + loginInfo: response.info, + userContext: input.userContext, + }); + return response; + }, + }); diff --git a/lib/ts/recipe/oauth2provider/index.ts b/lib/ts/recipe/oauth2provider/index.ts index 980b8efe8..43f9a1146 100644 --- a/lib/ts/recipe/oauth2provider/index.ts +++ b/lib/ts/recipe/oauth2provider/index.ts @@ -13,6 +13,7 @@ * under the License. */ +import { RecipeComponentsOverrideContextProvider } from "./componentOverrideContext"; import OAuth2Provider from "./recipe"; import { UserInput, GetRedirectionURLContext, PreAPIHookContext, OnHandleEventContext } from "./types"; @@ -47,6 +48,8 @@ export default class Wrapper { }> { return OAuth2Provider.getInstanceOrThrow().webJSRecipe.getLoginChallengeInfo(input); } + + static ComponentsOverrideProvider = RecipeComponentsOverrideContextProvider; } const init = Wrapper.init; @@ -60,4 +63,5 @@ export { OnHandleEventContext, UserInput, RecipeInterface, + RecipeComponentsOverrideContextProvider, }; diff --git a/lib/ts/recipe/oauth2provider/prebuiltui.tsx b/lib/ts/recipe/oauth2provider/prebuiltui.tsx new file mode 100644 index 000000000..0e3c511a3 --- /dev/null +++ b/lib/ts/recipe/oauth2provider/prebuiltui.tsx @@ -0,0 +1,108 @@ +import NormalisedURLPath from "supertokens-web-js/utils/normalisedURLPath"; + +import UserContextWrapper from "../../usercontext/userContextWrapper"; +import { isTest, matchRecipeIdUsingQueryParams } from "../../utils"; +import { RecipeRouter } from "../recipeRouter"; +import { SessionAuth } from "../session"; + +import { useRecipeComponentOverrideContext } from "./componentOverrideContext"; +import { default as TryRefreshPageFeature } from "./components/features/tryRefreshPage"; +import { defaultTranslationsOAuth2Provider } from "./components/themes/translations"; +import { DEFAULT_TRY_REFRESH_PATH } from "./constants"; +import OAuth2ProviderRecipe from "./recipe"; + +import type { GenericComponentOverrideMap } from "../../components/componentOverride/componentOverrideContext"; +import type { FeatureBaseProps, RecipeFeatureComponentMap, UserContext } from "../../types"; +import type { AuthComponent } from "../../types"; + +export class OAuth2ProviderPreBuiltUI extends RecipeRouter { + static instance?: OAuth2ProviderPreBuiltUI; + languageTranslations = defaultTranslationsOAuth2Provider; + + constructor(public readonly recipeInstance: OAuth2ProviderRecipe) { + super(); + } + + // Static methods + static getInstanceOrInitAndGetInstance(): OAuth2ProviderPreBuiltUI { + if (OAuth2ProviderPreBuiltUI.instance === undefined) { + const recipeInstance = OAuth2ProviderRecipe.getInstanceOrThrow(); + OAuth2ProviderPreBuiltUI.instance = new OAuth2ProviderPreBuiltUI(recipeInstance); + } + + return OAuth2ProviderPreBuiltUI.instance; + } + static getFeatures( + useComponentOverrides: () => GenericComponentOverrideMap = useRecipeComponentOverrideContext + ): RecipeFeatureComponentMap { + return OAuth2ProviderPreBuiltUI.getInstanceOrInitAndGetInstance().getFeatures(useComponentOverrides); + } + static getFeatureComponent( + componentName: "try-refresh-page", + props: any, + useComponentOverrides: () => GenericComponentOverrideMap = useRecipeComponentOverrideContext + ): JSX.Element { + return OAuth2ProviderPreBuiltUI.getInstanceOrInitAndGetInstance().getFeatureComponent( + componentName, + props, + useComponentOverrides + ); + } + + // Instance methods + getFeatures = ( + useComponentOverrides: () => GenericComponentOverrideMap = useRecipeComponentOverrideContext + ): RecipeFeatureComponentMap => { + const features: RecipeFeatureComponentMap = {}; + if (this.recipeInstance.config.disableDefaultUI !== true) { + const normalisedFullPath = this.recipeInstance.config.appInfo.websiteBasePath.appendPath( + new NormalisedURLPath(DEFAULT_TRY_REFRESH_PATH) + ); + features[normalisedFullPath.getAsStringDangerous()] = { + matches: matchRecipeIdUsingQueryParams(this.recipeInstance.config.recipeId), + component: (props: any) => this.getFeatureComponent("try-refresh-page", props, useComponentOverrides), + recipeID: OAuth2ProviderRecipe.RECIPE_ID, + }; + } + return features; + }; + getFeatureComponent = ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _: "try-refresh-page", + props: FeatureBaseProps<{ userContext?: UserContext }>, + useComponentOverrides: () => GenericComponentOverrideMap = useRecipeComponentOverrideContext + ): JSX.Element => { + return ( + + []}> + + + + ); + }; + + getAuthComponents(): AuthComponent[] { + return []; + } + + // For tests + static reset(): void { + if (!isTest()) { + return; + } + + OAuth2ProviderPreBuiltUI.instance = undefined; + return; + } + + static TryRefreshPage = (props: FeatureBaseProps<{ userContext?: UserContext }>) => + OAuth2ProviderPreBuiltUI.getInstanceOrInitAndGetInstance().getFeatureComponent("try-refresh-page", props); +} + +const TryRefreshPage = OAuth2ProviderPreBuiltUI.TryRefreshPage; + +export { TryRefreshPage }; diff --git a/lib/ts/recipe/oauth2provider/recipe.ts b/lib/ts/recipe/oauth2provider/recipe.ts index d88503db1..9018d4413 100644 --- a/lib/ts/recipe/oauth2provider/recipe.ts +++ b/lib/ts/recipe/oauth2provider/recipe.ts @@ -23,6 +23,7 @@ import { SSR_ERROR } from "../../constants"; import { isTest } from "../../utils"; import RecipeModule from "../recipeModule"; +import { getFunctionOverrides } from "./functionOverrides"; import { normaliseOAuth2Config } from "./utils"; import type { @@ -32,12 +33,7 @@ import type { PreAndPostAPIHookAction, UserInput, } from "./types"; -import type { - RecipeInitResult, - NormalisedConfigWithAppInfoAndRecipeID, - WebJSRecipeInterface, - SuccessRedirectContextOAuth2, -} from "../../types"; +import type { RecipeInitResult, NormalisedConfigWithAppInfoAndRecipeID, WebJSRecipeInterface } from "../../types"; import type { NormalisedAppInfo } from "../../types"; /* @@ -82,6 +78,14 @@ export default class OAuth2Provider extends RecipeModule< }, webJS: OAuth2WebJS.init({ ...normalisedConfig, + override: { + functions: (originalImpl, builder) => { + const functions = getFunctionOverrides(normalisedConfig.onHandleEvent); + builder.override(functions); + builder.override(normalisedConfig.override.functions); + return originalImpl; + }, + }, }), }; } @@ -106,8 +110,8 @@ export default class OAuth2Provider extends RecipeModule< return OAuth2Provider.instance; } - async getDefaultRedirectionURL(ctx: SuccessRedirectContextOAuth2): Promise { - if (ctx.action === "SUCCESS_OAUTH2") { + async getDefaultRedirectionURL(ctx: GetRedirectionURLContext): Promise { + if (ctx.action === "SUCCESS_OAUTH2" || ctx.action === "CONTINUE_OAUTH2_AFTER_REFRESH") { const domain = this.config.appInfo.apiDomain.getAsStringDangerous(); const basePath = this.config.appInfo.apiBasePath.getAsStringDangerous(); diff --git a/lib/ts/recipe/oauth2provider/types.ts b/lib/ts/recipe/oauth2provider/types.ts index 0a43695f2..36511eb27 100644 --- a/lib/ts/recipe/oauth2provider/types.ts +++ b/lib/ts/recipe/oauth2provider/types.ts @@ -4,7 +4,7 @@ import type { NormalisedConfig as NormalisedRecipeModuleConfig, } from "../recipeModule/types"; import type OverrideableBuilder from "supertokens-js-override"; -import type { RecipeInterface } from "supertokens-web-js/recipe/oauth2provider/types"; +import type { LoginInfo, RecipeInterface } from "supertokens-web-js/recipe/oauth2provider/types"; export type PreAndPostAPIHookAction = "GET_LOGIN_CHALLENGE_INFO"; @@ -16,6 +16,7 @@ export type PreAPIHookContext = { }; export type UserInput = { + disableDefaultUI?: boolean; override?: { functions?: ( originalImplementation: RecipeInterface, @@ -29,14 +30,32 @@ export type NormalisedConfig = NormalisedRecipeModuleConfig< PreAndPostAPIHookAction, OnHandleEventContext > & { + disableDefaultUI: boolean; override: { - functions?: ( + functions: ( originalImplementation: RecipeInterface, builder: OverrideableBuilder ) => RecipeInterface; }; }; -export type GetRedirectionURLContext = SuccessRedirectContextOAuth2; +export type ContinueOAuth2AfterRefreshRedirectContext = { + recipeId: "oauth2provider"; + action: "CONTINUE_OAUTH2_AFTER_REFRESH"; + loginChallenge: string; +}; + +export type GetRedirectionURLContext = SuccessRedirectContextOAuth2 | ContinueOAuth2AfterRefreshRedirectContext; + +export type OnHandleEventContext = { + /* + * On Handle Event actions + */ + action: "LOADED_LOGIN_CHALLENGE"; + loginChallenge: string; + loginInfo: LoginInfo; + userContext: UserContext; +}; -export type OnHandleEventContext = any; +// TODO: update this whenever we add components +export type ComponentOverrideMap = any; diff --git a/lib/ts/recipe/oauth2provider/utils.ts b/lib/ts/recipe/oauth2provider/utils.ts index 5302c9c4b..8402f7ba8 100644 --- a/lib/ts/recipe/oauth2provider/utils.ts +++ b/lib/ts/recipe/oauth2provider/utils.ts @@ -5,6 +5,7 @@ import type { UserInput, NormalisedConfig } from "./types"; export function normaliseOAuth2Config(config?: UserInput): NormalisedConfig { return { ...normaliseRecipeModuleConfig(config), + disableDefaultUI: config?.disableDefaultUI ?? false, override: { functions: (originalImplementation) => originalImplementation, ...config?.override, diff --git a/package-lock.json b/package-lock.json index f34f9a2ad..fba0274e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23890,8 +23890,7 @@ }, "node_modules/supertokens-web-js": { "version": "0.12.0", - "resolved": "git+ssh://git@github.com/supertokens/supertokens-web-js.git#d7cc0fe8b4736f083216546ac66a0a23b2eff964", - "license": "Apache-2.0", + "resolved": "git+ssh://git@github.com/supertokens/supertokens-web-js.git#b450dfedd971c8d8d0b13c372a735fea7c5187b6", "peer": true, "dependencies": { "supertokens-js-override": "0.0.4", @@ -23899,9 +23898,9 @@ } }, "node_modules/supertokens-website": { - "version": "20.0.2", - "resolved": "git+ssh://git@github.com/supertokens/supertokens-website.git#e8b03b341a9098d0b5119a978a1174c92d5060ae", - "license": "Apache-2.0", + "version": "20.1.4", + "resolved": "https://registry.npmjs.org/supertokens-website/-/supertokens-website-20.1.4.tgz", + "integrity": "sha512-2hbB/MWJew4W8bq5q0M75tjUnniahLzXVOnu+535j3HB4wworwMJ1ZGfg25OL9q1fm4g+ITNKVjJeJgJqEDlmA==", "peer": true, "dependencies": { "browser-tabs-lock": "^1.3.0", @@ -43370,7 +43369,7 @@ "integrity": "sha512-r0JFBjkMIdep3Lbk3JA+MpnpuOtw4RSyrlRAbrzMcxwiYco3GFWl/daimQZ5b1forOiUODpOlXbSOljP/oyurg==" }, "supertokens-web-js": { - "version": "git+ssh://git@github.com/supertokens/supertokens-web-js.git#d7cc0fe8b4736f083216546ac66a0a23b2eff964", + "version": "git+ssh://git@github.com/supertokens/supertokens-web-js.git#b450dfedd971c8d8d0b13c372a735fea7c5187b6", "from": "supertokens-web-js@github:supertokens/supertokens-web-js#feat/oauth2/base", "peer": true, "requires": { @@ -43379,8 +43378,9 @@ } }, "supertokens-website": { - "version": "git+ssh://git@github.com/supertokens/supertokens-website.git#e8b03b341a9098d0b5119a978a1174c92d5060ae", - "from": "supertokens-website@^20.0.1", + "version": "20.1.4", + "resolved": "https://registry.npmjs.org/supertokens-website/-/supertokens-website-20.1.4.tgz", + "integrity": "sha512-2hbB/MWJew4W8bq5q0M75tjUnniahLzXVOnu+535j3HB4wworwMJ1ZGfg25OL9q1fm4g+ITNKVjJeJgJqEDlmA==", "peer": true, "requires": { "browser-tabs-lock": "^1.3.0", diff --git a/recipe/oauth2provider/prebuiltui.d.ts b/recipe/oauth2provider/prebuiltui.d.ts new file mode 100644 index 000000000..c983a1551 --- /dev/null +++ b/recipe/oauth2provider/prebuiltui.d.ts @@ -0,0 +1,17 @@ +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +export * from "../../lib/build/recipe/oauth2provider/prebuiltui"; +import * as _default from "../../lib/build/recipe/oauth2provider/prebuiltui"; +export default _default; diff --git a/recipe/oauth2provider/prebuiltui.js b/recipe/oauth2provider/prebuiltui.js new file mode 100644 index 000000000..c5380476f --- /dev/null +++ b/recipe/oauth2provider/prebuiltui.js @@ -0,0 +1,20 @@ +/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +exports.__esModule = true; +__export(require("../../lib/build/oauth2providerprebuiltui")); diff --git a/rollup.config.mjs b/rollup.config.mjs index 75f56e115..8314eab99 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -26,6 +26,7 @@ export default [ passwordless: "lib/ts/recipe/passwordless/index.ts", passwordlessprebuiltui: "lib/ts/recipe/passwordless/prebuiltui.tsx", oauth2provider: "lib/ts/recipe/oauth2provider/index.ts", + oauth2providerprebuiltui: "lib/ts/recipe/oauth2provider/prebuiltui.tsx", thirdparty: "lib/ts/recipe/thirdparty/index.ts", thirdpartyprebuiltui: "lib/ts/recipe/thirdparty/prebuiltui.tsx", multitenancy: "lib/ts/recipe/multitenancy/index.ts", From 458c80796fd6ba12cbea2d5cb6e56eb9d10f85fd Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Mon, 19 Aug 2024 00:33:30 +0200 Subject: [PATCH 8/9] test: extend/stabilize tests --- test/end-to-end/oauth2provider.test.js | 440 ++++++++++++++++++++++++- test/end-to-end/signin.test.js | 19 +- test/helpers.js | 37 ++- test/server/package-lock.json | 24 +- test/server/package.json | 2 +- test/with-typescript/src/App.tsx | 3 + 6 files changed, 483 insertions(+), 42 deletions(-) diff --git a/test/end-to-end/oauth2provider.test.js b/test/end-to-end/oauth2provider.test.js index 0165ce80b..2c3585b94 100644 --- a/test/end-to-end/oauth2provider.test.js +++ b/test/end-to-end/oauth2provider.test.js @@ -26,8 +26,8 @@ import { backendBeforeEach, waitForUrl, createOAuth2Client, - setOAuth2ClientIdInStorage, - removeOAuth2ClientIdFromStorage, + setOAuth2ClientInfo, + removeOAuth2ClientInfo, getOAuth2LoginButton, getOAuth2LogoutButton, getOAuth2TokenData, @@ -36,10 +36,16 @@ import { signUp, getDefaultSignUpFieldValues, getTestEmail, + getOAuth2Error, } from "../helpers"; import fetch from "isomorphic-fetch"; -import { TEST_CLIENT_BASE_URL, TEST_SERVER_BASE_URL, SIGN_OUT_API } from "../constants"; +import { + TEST_CLIENT_BASE_URL, + TEST_SERVER_BASE_URL, + SIGN_OUT_API, + TEST_APPLICATION_SERVER_BASE_URL, +} from "../constants"; // We do no thave to use a separate domain for the oauth2 client, since the way we are testing // the lib doesn't interact with the supertokens session handling. @@ -65,6 +71,12 @@ describe("SuperTokens OAuth2Provider", function () { await fetch(`${TEST_SERVER_BASE_URL}/startst`, { method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ + coreConfig: { + access_token_validity: 5, // 5 seconds + }, + }), }).catch(console.error); browser = await puppeteer.launch({ @@ -105,13 +117,13 @@ describe("SuperTokens OAuth2Provider", function () { describe("Generic OAuth2 Client Library", function () { afterEach(async function () { - await removeOAuth2ClientIdFromStorage(page); + await removeOAuth2ClientInfo(page); }); it("should successfully complete the OAuth2 flow", async function () { const { client } = await createOAuth2Client({ scope: "offline_access profile openid email", - redirectUris: [`${TEST_CLIENT_BASE_URL}/oauth2/callback`], + redirectUris: [`${TEST_CLIENT_BASE_URL}/oauth/callback`], accessTokenStrategy: "jwt", tokenEndpointAuthMethod: "none", grantTypes: ["authorization_code", "refresh_token"], @@ -119,9 +131,12 @@ describe("SuperTokens OAuth2Provider", function () { skipConsent: true, }); - await setOAuth2ClientIdInStorage(page, client.clientId); + await setOAuth2ClientInfo(page, client.clientId); - await page.goto(`${TEST_CLIENT_BASE_URL}/oauth2/login`); + await Promise.all([ + page.waitForNavigation({ waitUntil: "networkidle0" }), + page.goto(`${TEST_CLIENT_BASE_URL}/oauth/login`), + ]); let loginButton = await getOAuth2LoginButton(page); await loginButton.click(); @@ -132,7 +147,7 @@ describe("SuperTokens OAuth2Provider", function () { const { fieldValues, postValues } = getDefaultSignUpFieldValues({ email: getTestEmail() }); await signUp(page, fieldValues, postValues, "emailpassword"); - await waitForUrl(page, "/oauth2/callback"); + await waitForUrl(page, "/oauth/callback"); // Validate token data const tokenData = await getOAuth2TokenData(page); @@ -142,15 +157,320 @@ describe("SuperTokens OAuth2Provider", function () { const logoutButton = await getOAuth2LogoutButton(page); await logoutButton.click(); + await waitFor(1000); + + await page.waitForSelector("#oauth2-token-data", { hidden: true }); + // Ensure the Login Button is visible after logout is clicked loginButton = await getOAuth2LoginButton(page); - assert.ok(loginButton !== null); + await loginButton.click(); + await waitForUrl(page, "/oauth/callback"); + }); + + it("should login without interaction if the user already has a session", async function () { + const { client } = await createOAuth2Client({ + scope: "offline_access profile openid email", + redirectUris: [`${TEST_CLIENT_BASE_URL}/oauth/callback`], + accessTokenStrategy: "jwt", + tokenEndpointAuthMethod: "none", + grantTypes: ["authorization_code", "refresh_token"], + responseTypes: ["code", "id_token"], + skipConsent: true, + }); + + await setOAuth2ClientInfo(page, client.clientId); + await Promise.all([ + page.waitForNavigation({ waitUntil: "networkidle0" }), + page.goto(`${TEST_CLIENT_BASE_URL}/auth`), + ]); + await toggleSignInSignUp(page); + const { fieldValues, postValues } = getDefaultSignUpFieldValues({ email: getTestEmail() }); + await signUp(page, fieldValues, postValues, "emailpassword"); + + await Promise.all([ + page.waitForNavigation({ waitUntil: "networkidle0" }), + page.goto(`${TEST_CLIENT_BASE_URL}/oauth/login`), + ]); + + let loginButton = await getOAuth2LoginButton(page); + await loginButton.click(); + + await waitForUrl(page, "/oauth/callback"); + + // Validate token data + const tokenData = await getOAuth2TokenData(page); + assert.deepStrictEqual(tokenData.aud, [client.clientId]); + }); + + it("should require logging in again with prompt=login", async function () { + const { client } = await createOAuth2Client({ + scope: "offline_access profile openid email", + redirectUris: [`${TEST_CLIENT_BASE_URL}/oauth/callback`], + accessTokenStrategy: "jwt", + tokenEndpointAuthMethod: "none", + grantTypes: ["authorization_code", "refresh_token"], + responseTypes: ["code", "id_token"], + skipConsent: true, + }); + + await setOAuth2ClientInfo(page, client.clientId); + + await Promise.all([ + page.waitForNavigation({ waitUntil: "networkidle0" }), + page.goto(`${TEST_CLIENT_BASE_URL}/oauth/login`), + ]); + + let loginButton = await getOAuth2LoginButton(page, "prompt-login"); + await loginButton.click(); + + await waitForUrl(page, "/auth"); + + await toggleSignInSignUp(page); + const { fieldValues, postValues } = getDefaultSignUpFieldValues({ email: getTestEmail() }); + await signUp(page, fieldValues, postValues, "emailpassword"); + + await waitForUrl(page, "/oauth/callback"); + + // Validate token data + const tokenData = await getOAuth2TokenData(page); + assert.deepStrictEqual(tokenData.aud, [client.clientId]); + + await Promise.all([ + page.waitForNavigation({ waitUntil: "networkidle0" }), + page.goto(`${TEST_CLIENT_BASE_URL}/oauth/login`), + ]); + + loginButton = await getOAuth2LoginButton(page, "prompt-login"); + await loginButton.click(); + await waitForUrl(page, "/auth"); + }); + + it("should require logging in again with max_age=3 after 3 seconds", async function () { + const { client } = await createOAuth2Client({ + scope: "offline_access profile openid email", + redirectUris: [`${TEST_CLIENT_BASE_URL}/oauth/callback`], + accessTokenStrategy: "jwt", + tokenEndpointAuthMethod: "none", + grantTypes: ["authorization_code", "refresh_token"], + responseTypes: ["code", "id_token"], + skipConsent: true, + }); + + await setOAuth2ClientInfo(page, client.clientId); + + await Promise.all([ + page.waitForNavigation({ waitUntil: "networkidle0" }), + page.goto(`${TEST_CLIENT_BASE_URL}/oauth/login`), + ]); + + let loginButton = await getOAuth2LoginButton(page, "max-age-3"); + await loginButton.click(); + + await waitForUrl(page, "/auth"); + + await toggleSignInSignUp(page); + const { fieldValues, postValues } = getDefaultSignUpFieldValues({ email: getTestEmail() }); + await signUp(page, fieldValues, postValues, "emailpassword"); + + await waitForUrl(page, "/oauth/callback"); + + // Validate token data + const tokenData = await getOAuth2TokenData(page); + assert.deepStrictEqual(tokenData.aud, [client.clientId]); + + await Promise.all([ + page.waitForNavigation({ waitUntil: "networkidle0" }), + page.goto(`${TEST_CLIENT_BASE_URL}/oauth/login`), + ]); + + loginButton = await getOAuth2LoginButton(page, "max-age-3"); + await loginButton.click(); + await waitForUrl(page, "/oauth/callback"); + + await Promise.all([ + page.waitForNavigation({ waitUntil: "networkidle0" }), + page.goto(`${TEST_CLIENT_BASE_URL}/oauth/login`), + ]); + + await waitFor(3000); + loginButton = await getOAuth2LoginButton(page, "max-age-3"); + await loginButton.click(); + await waitForUrl(page, "/auth"); }); it("should successfully refresh the tokens after expiry", async function () { const { client } = await createOAuth2Client({ scope: "offline_access profile openid email", - redirectUris: [`${TEST_CLIENT_BASE_URL}/oauth2/callback`], + redirectUris: [`${TEST_CLIENT_BASE_URL}/oauth/callback`], + accessTokenStrategy: "jwt", + tokenEndpointAuthMethod: "none", + grantTypes: ["authorization_code", "refresh_token"], + responseTypes: ["code", "id_token"], + skipConsent: true, + // The library refreshes the token 60 seconds before it expires. + // We set the token lifespan to 63 seconds to force a refresh in 3 seconds. + authorizationCodeGrantAccessTokenLifespan: "63s", + }); + + await setOAuth2ClientInfo(page, client.clientId); + + await Promise.all([ + page.waitForNavigation({ waitUntil: "networkidle0" }), + page.goto(`${TEST_CLIENT_BASE_URL}/oauth/login`), + ]); + + let loginButton = await getOAuth2LoginButton(page); + await loginButton.click(); + + await waitForUrl(page, "/auth"); + + await toggleSignInSignUp(page); + const { fieldValues, postValues } = getDefaultSignUpFieldValues({ email: getTestEmail() }); + await signUp(page, fieldValues, postValues, "emailpassword"); + + await waitForUrl(page, "/oauth/callback"); + + // Validate token data + const tokenDataAfterLogin = await getOAuth2TokenData(page); + assert.deepStrictEqual(tokenDataAfterLogin.aud, [client.clientId]); + + // Although the react-oidc-context library automatically refreshes the + // token, we wait for 4 seconds and reload the page to ensure a refresh. + await waitFor(4000); + await Promise.all([page.reload(), page.waitForNavigation({ waitUntil: "networkidle0" })]); + + const tokenDataAfterRefresh = await getOAuth2TokenData(page); + assert.deepStrictEqual(tokenDataAfterRefresh.aud, [client.clientId]); + + // Validate the token was refreshed + assert(tokenDataAfterLogin.iat !== tokenDataAfterRefresh.iat); + assert(tokenDataAfterLogin.exp < tokenDataAfterRefresh.exp); + }); + + it("should have roles in the id_token if the scopes is requested", async function () { + const { client } = await createOAuth2Client({ + scope: "offline_access profile openid email roles permissions", + redirectUris: [`${TEST_CLIENT_BASE_URL}/oauth/callback`], + accessTokenStrategy: "jwt", + tokenEndpointAuthMethod: "none", + grantTypes: ["authorization_code", "refresh_token"], + responseTypes: ["code", "id_token"], + skipConsent: true, + }); + + await setOAuth2ClientInfo(page, client.clientId, "offline_access profile openid email roles permissions"); + + await Promise.all([ + page.waitForNavigation({ waitUntil: "networkidle0" }), + page.goto(`${TEST_CLIENT_BASE_URL}/oauth/login`), + ]); + + let loginButton = await getOAuth2LoginButton(page); + await loginButton.click(); + + await waitForUrl(page, "/auth"); + + await toggleSignInSignUp(page); + const { fieldValues, postValues } = getDefaultSignUpFieldValues({ email: getTestEmail() }); + await signUp(page, fieldValues, postValues, "emailpassword"); + + await waitForUrl(page, "/oauth/callback"); + + // Validate token data + const tokenDataAfterLogin = await getOAuth2TokenData(page); + assert.deepStrictEqual(tokenDataAfterLogin.aud, [client.clientId]); + + await page.evaluate( + (url) => + window.fetch(url, { + method: "POST", + headers: [["content-type", "application/json"]], + body: JSON.stringify({ + role: "testRole", + permissions: ["testPerm"], + }), + }), + `${TEST_APPLICATION_SERVER_BASE_URL}/setRole` + ); + + await waitFor(2000); + loginButton = await getOAuth2LoginButton(page, "silent"); + await loginButton.click(); + + await waitFor(1000); + + const tokenDataAfterRefresh = await getOAuth2TokenData(page); + assert.deepStrictEqual(tokenDataAfterRefresh.aud, [client.clientId]); + + // Validate the token was refreshed + assert(tokenDataAfterLogin.iat !== tokenDataAfterRefresh.iat); + assert(tokenDataAfterLogin.exp < tokenDataAfterRefresh.exp); + + assert.deepStrictEqual(tokenDataAfterLogin.roles, []); + assert.deepStrictEqual(tokenDataAfterLogin.permissions, []); + + assert.deepStrictEqual(tokenDataAfterRefresh.roles, ["testRole"]); + assert.deepStrictEqual(tokenDataAfterRefresh.permissions, ["testPerm"]); + }); + + it("should not include email info if the scope is not requested", async function () { + const { client } = await createOAuth2Client({ + scope: "offline_access profile openid roles permissions", + redirectUris: [`${TEST_CLIENT_BASE_URL}/oauth/callback`], + accessTokenStrategy: "jwt", + tokenEndpointAuthMethod: "none", + grantTypes: ["authorization_code", "refresh_token"], + responseTypes: ["code", "id_token"], + skipConsent: true, + // The library refreshes the token 60 seconds before it expires. + // We set the token lifespan to 63 seconds to force a refresh in 3 seconds. + authorizationCodeGrantAccessTokenLifespan: "63s", + }); + + await setOAuth2ClientInfo(page, client.clientId, "offline_access profile openid roles permissions"); + + await Promise.all([ + page.waitForNavigation({ waitUntil: "networkidle0" }), + page.goto(`${TEST_CLIENT_BASE_URL}/oauth/login`), + ]); + + let loginButton = await getOAuth2LoginButton(page); + await loginButton.click(); + + await waitForUrl(page, "/auth"); + + await toggleSignInSignUp(page); + const { fieldValues, postValues } = getDefaultSignUpFieldValues({ email: getTestEmail() }); + await signUp(page, fieldValues, postValues, "emailpassword"); + + await waitForUrl(page, "/oauth/callback"); + + // Validate token data + const tokenDataAfterLogin = await getOAuth2TokenData(page); + assert.deepStrictEqual(tokenDataAfterLogin.aud, [client.clientId]); + + // Although the react-oidc-context library automatically refreshes the + // token, we wait for 4 seconds and reload the page to ensure a refresh. + await waitFor(4000); + await Promise.all([page.reload(), page.waitForNavigation({ waitUntil: "networkidle0" })]); + + const tokenDataAfterRefresh = await getOAuth2TokenData(page); + assert.deepStrictEqual(tokenDataAfterRefresh.aud, [client.clientId]); + + // Validate the token was refreshed + assert(tokenDataAfterLogin.iat !== tokenDataAfterRefresh.iat); + assert(tokenDataAfterLogin.exp < tokenDataAfterRefresh.exp); + + assert.strictEqual(tokenDataAfterLogin.email, undefined); + assert.strictEqual(tokenDataAfterLogin.email_verified, undefined); + assert.strictEqual(tokenDataAfterRefresh.email, undefined); + assert.strictEqual(tokenDataAfterRefresh.email_verified, undefined); + }); + + it("should work if the scope phoneNumber is requested for emailpassword user", async function () { + const { client } = await createOAuth2Client({ + scope: "offline_access profile openid phoneNumber", + redirectUris: [`${TEST_CLIENT_BASE_URL}/oauth/callback`], accessTokenStrategy: "jwt", tokenEndpointAuthMethod: "none", grantTypes: ["authorization_code", "refresh_token"], @@ -161,9 +481,12 @@ describe("SuperTokens OAuth2Provider", function () { authorizationCodeGrantAccessTokenLifespan: "63s", }); - await setOAuth2ClientIdInStorage(page, client.clientId); + await setOAuth2ClientInfo(page, client.clientId, "offline_access profile openid phoneNumber"); - await page.goto(`${TEST_CLIENT_BASE_URL}/oauth2/login`); + await Promise.all([ + page.waitForNavigation({ waitUntil: "networkidle0" }), + page.goto(`${TEST_CLIENT_BASE_URL}/oauth/login`), + ]); let loginButton = await getOAuth2LoginButton(page); await loginButton.click(); @@ -174,7 +497,7 @@ describe("SuperTokens OAuth2Provider", function () { const { fieldValues, postValues } = getDefaultSignUpFieldValues({ email: getTestEmail() }); await signUp(page, fieldValues, postValues, "emailpassword"); - await waitForUrl(page, "/oauth2/callback"); + await waitForUrl(page, "/oauth/callback"); // Validate token data const tokenDataAfterLogin = await getOAuth2TokenData(page); @@ -183,8 +506,95 @@ describe("SuperTokens OAuth2Provider", function () { // Although the react-oidc-context library automatically refreshes the // token, we wait for 4 seconds and reload the page to ensure a refresh. await waitFor(4000); - await page.reload(); - await page.waitForNavigation({ waitUntil: "networkidle0" }); + await Promise.all([page.reload(), page.waitForNavigation({ waitUntil: "networkidle0" })]); + + const tokenDataAfterRefresh = await getOAuth2TokenData(page); + assert.deepStrictEqual(tokenDataAfterRefresh.aud, [client.clientId]); + + // Validate the token was refreshed + assert(tokenDataAfterLogin.iat !== tokenDataAfterRefresh.iat); + assert(tokenDataAfterLogin.exp < tokenDataAfterRefresh.exp); + + assert.strictEqual(tokenDataAfterLogin.email, undefined); + assert.strictEqual(tokenDataAfterLogin.email_verified, undefined); + assert.strictEqual(tokenDataAfterRefresh.email, undefined); + assert.strictEqual(tokenDataAfterRefresh.email_verified, undefined); + assert.strictEqual(tokenDataAfterLogin.phoneNumber, undefined); + assert.notStrictEqual(tokenDataAfterLogin.phoneNumber_verified, undefined); + assert.strictEqual(tokenDataAfterRefresh.phoneNumber, undefined); + assert.notStrictEqual(tokenDataAfterRefresh.phoneNumber_verified, undefined); + }); + + it("should reject the login if the wrong scope is requested", async function () { + const { client } = await createOAuth2Client({ + scope: "offline_access profile openid", + redirectUris: [`${TEST_CLIENT_BASE_URL}/oauth/callback`], + accessTokenStrategy: "jwt", + tokenEndpointAuthMethod: "none", + grantTypes: ["authorization_code", "refresh_token"], + responseTypes: ["code", "id_token"], + skipConsent: true, + // The library refreshes the token 60 seconds before it expires. + // We set the token lifespan to 63 seconds to force a refresh in 3 seconds. + authorizationCodeGrantAccessTokenLifespan: "63s", + }); + + await setOAuth2ClientInfo(page, client.clientId, "offline_access profile openid roles permissions"); + + await Promise.all([ + page.waitForNavigation({ waitUntil: "networkidle0" }), + page.goto(`${TEST_CLIENT_BASE_URL}/oauth/login`), + ]); + + let loginButton = await getOAuth2LoginButton(page); + await loginButton.click(); + + assert.strictEqual( + await getOAuth2Error(page), + `Error: The requested scope is invalid, unknown, or malformed. The OAuth 2.0 Client is not allowed to request scope 'roles'.` + ); + }); + + it("should work even if the supertokens session is expired", async function () { + const { client } = await createOAuth2Client({ + scope: "offline_access profile openid email", + redirectUris: [`${TEST_CLIENT_BASE_URL}/oauth/callback`], + accessTokenStrategy: "jwt", + tokenEndpointAuthMethod: "none", + grantTypes: ["authorization_code", "refresh_token"], + responseTypes: ["code", "id_token"], + skipConsent: true, + // The library refreshes the token 60 seconds before it expires. + // We set the token lifespan to 63 seconds to force a refresh in 3 seconds. + authorizationCodeGrantAccessTokenLifespan: "63s", + }); + + await setOAuth2ClientInfo(page, client.clientId); + + await toggleSignInSignUp(page); + const { fieldValues, postValues } = getDefaultSignUpFieldValues({ email: getTestEmail() }); + await signUp(page, fieldValues, postValues, "emailpassword"); + + await waitFor(6000); + + await Promise.all([ + page.waitForNavigation({ waitUntil: "networkidle0" }), + page.goto(`${TEST_CLIENT_BASE_URL}/oauth/login`), + ]); + + let loginButton = await getOAuth2LoginButton(page); + await loginButton.click(); + + await waitForUrl(page, "/oauth/callback"); + + // Validate token data + const tokenDataAfterLogin = await getOAuth2TokenData(page); + assert.deepStrictEqual(tokenDataAfterLogin.aud, [client.clientId]); + + // Although the react-oidc-context library automatically refreshes the + // token, we wait for 6 seconds and reload the page to ensure a refresh. + await waitFor(6000); + await Promise.all([page.reload(), page.waitForNavigation({ waitUntil: "networkidle0" })]); const tokenDataAfterRefresh = await getOAuth2TokenData(page); assert.deepStrictEqual(tokenDataAfterRefresh.aud, [client.clientId]); diff --git a/test/end-to-end/signin.test.js b/test/end-to-end/signin.test.js index 876fd83bd..883218ea3 100644 --- a/test/end-to-end/signin.test.js +++ b/test/end-to-end/signin.test.js @@ -482,7 +482,7 @@ describe("SuperTokens SignIn", function () { await assertSignInRedirectTo( page, `${TEST_CLIENT_BASE_URL}/auth?rid=emailpassword&redirectToPath=%2Fredirect-here`, - `${TEST_CLIENT_BASE_URL}/redirect-here` + `/redirect-here` ); // test that if we visit auth again, we end up in redirect-heree again with query params kept @@ -492,15 +492,14 @@ describe("SuperTokens SignIn", function () { ), page.waitForNavigation({ waitUntil: "networkidle0" }), ]); - const { pathname, search } = await page.evaluate(() => window.location); - assert.deepStrictEqual(pathname + search, "/redirect-heree?foo=bar"); + await waitForUrl(page, "/redirect-heree?foo=bar", false); }); it("Successful Sign In with redirect to, redirectToPath directly without trailing slash", async function () { await assertSignInRedirectTo( page, `${TEST_CLIENT_BASE_URL}/auth?rid=emailpassword&redirectToPath=redirect-here`, - `${TEST_CLIENT_BASE_URL}/redirect-here` + `/redirect-here` ); }); @@ -531,7 +530,7 @@ describe("SuperTokens SignIn", function () { await assertSignInRedirectTo( page, `${TEST_CLIENT_BASE_URL}/auth?rid=emailpassword&redirectToPath=https://attacker.com/path`, - `${TEST_CLIENT_BASE_URL}/path` + `/path` ); }); @@ -540,7 +539,7 @@ describe("SuperTokens SignIn", function () { await assertSignInRedirectTo( page, `${TEST_CLIENT_BASE_URL}/auth?rid=emailpassword&redirectToPath=javascript:alert(1)`, - `${TEST_CLIENT_BASE_URL}/javascript:alert(1)` + `/javascript:alert(1)` ); }); @@ -1054,11 +1053,5 @@ async function assertSignInRedirectTo(page, startUrl, finalUrl) { ]); // Submit. - await Promise.all([ - submitFormReturnRequestAndResponse(page, SIGN_IN_API), - page.waitForNavigation({ waitUntil: "networkidle0" }), - ]); - - let href = await page.evaluate(() => window.location.href); - assert.deepStrictEqual(href, finalUrl); + await Promise.all([submitFormReturnRequestAndResponse(page, SIGN_IN_API), waitForUrl(page, finalUrl, false)]); } diff --git a/test/helpers.js b/test/helpers.js index efe97ed4d..672718e9b 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -1117,16 +1117,41 @@ export async function createOAuth2Client(input) { // For the OAuth2 end-to-end test, we need to provide the created clientId to both the OAuth2 login and callback pages. // We use localStorage to store the clientId instead of query params, as it must be available on the callback page as well. -export async function setOAuth2ClientIdInStorage(page, clientId) { - return page.evaluate((clientId) => localStorage.setItem("oauth2-client-id", clientId), clientId); +export async function setOAuth2ClientInfo(page, clientId, scopes, extraConfig, extraSignInParams, extraSignOutParams) { + await page.evaluate((clientId) => localStorage.setItem("oauth2-client-id", clientId), clientId); + if (scopes) { + await page.evaluate((scopes) => localStorage.setItem("oauth2-scopes", scopes), scopes); + } + if (extraConfig) { + await page.evaluate((extraConfig) => localStorage.setItem("oauth2-extra-config", extraConfig), extraConfig); + } + if (extraSignInParams) { + await page.evaluate( + (extraSignInParams) => localStorage.setItem("oauth2-extra-sign-in-params", extraSignInParams), + extraSignInParams + ); + } + if (extraSignOutParams) { + await page.evaluate( + (extraSignOutParams) => localStorage.setItem("oauth2-extra-sign-out-params", extraSignOutParams), + extraSignOutParams + ); + } +} + +export async function removeOAuth2ClientInfo(page) { + await page.evaluate(() => localStorage.removeItem("oauth2-client-id")); + await page.evaluate(() => localStorage.removeItem("oauth2-scopes")); } -export async function removeOAuth2ClientIdFromStorage(page) { - return page.evaluate(() => localStorage.removeItem("oauth2-client-id")); +export async function getOAuth2LoginButton(page, type = "default") { + const id = type === "default" ? "#oauth2-login-button" : `#oauth2-login-button-${type}`; + return page.waitForSelector(id); } -export async function getOAuth2LoginButton(page) { - return page.waitForSelector("#oauth2-login-button"); +export async function getOAuth2Error(page) { + const ele = await page.waitForSelector("#oauth2-error-message"); + return await ele.evaluate((el) => el.textContent); } export async function getOAuth2LogoutButton(page) { diff --git a/test/server/package-lock.json b/test/server/package-lock.json index 80f265cec..6cf95278b 100644 --- a/test/server/package-lock.json +++ b/test/server/package-lock.json @@ -16,7 +16,7 @@ "express": "4.17.1", "morgan": "^1.10.0", "otpauth": "^9.2.0", - "supertokens-node": "18.0" + "supertokens-node": "github:supertokens/supertokens-node#feat/oauth2/base" } }, "node_modules/accepts": { @@ -995,6 +995,11 @@ "node": ">= 0.8.0" } }, + "node_modules/set-cookie-parser": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.0.tgz", + "integrity": "sha512-lXLOiqpkUumhRdFF3k1osNXCy9akgx/dyPZ5p8qAg9seJzXr5ZrlqZuWIMuY6ejOsVLE6flJ5/h3lsn57fQ/PQ==" + }, "node_modules/set-function-length": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz", @@ -1041,9 +1046,8 @@ "integrity": "sha512-r0JFBjkMIdep3Lbk3JA+MpnpuOtw4RSyrlRAbrzMcxwiYco3GFWl/daimQZ5b1forOiUODpOlXbSOljP/oyurg==" }, "node_modules/supertokens-node": { - "version": "18.0.0", - "resolved": "https://registry.npmjs.org/supertokens-node/-/supertokens-node-18.0.0.tgz", - "integrity": "sha512-NPFPShZu44EI3jJK0qW8Wm8GfNhM4xUOWFJ/1EvNW1pzVN0EmJkIzqlmzeBExg5oc03fZXKS4YnUTt6PAnlD1w==", + "version": "20.0.2", + "resolved": "git+ssh://git@github.com/supertokens/supertokens-node.git#905b5cd6e9babe50488318e32295a353523b8069", "dependencies": { "content-type": "^1.0.5", "cookie": "0.4.0", @@ -1055,6 +1059,7 @@ "nodemailer": "^6.7.2", "pkce-challenge": "^3.0.0", "psl": "1.8.0", + "set-cookie-parser": "^2.6.0", "supertokens-js-override": "^0.0.4", "twilio": "^4.19.3" } @@ -1976,6 +1981,11 @@ "send": "0.17.1" } }, + "set-cookie-parser": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.0.tgz", + "integrity": "sha512-lXLOiqpkUumhRdFF3k1osNXCy9akgx/dyPZ5p8qAg9seJzXr5ZrlqZuWIMuY6ejOsVLE6flJ5/h3lsn57fQ/PQ==" + }, "set-function-length": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz", @@ -2013,9 +2023,8 @@ "integrity": "sha512-r0JFBjkMIdep3Lbk3JA+MpnpuOtw4RSyrlRAbrzMcxwiYco3GFWl/daimQZ5b1forOiUODpOlXbSOljP/oyurg==" }, "supertokens-node": { - "version": "18.0.0", - "resolved": "https://registry.npmjs.org/supertokens-node/-/supertokens-node-18.0.0.tgz", - "integrity": "sha512-NPFPShZu44EI3jJK0qW8Wm8GfNhM4xUOWFJ/1EvNW1pzVN0EmJkIzqlmzeBExg5oc03fZXKS4YnUTt6PAnlD1w==", + "version": "git+ssh://git@github.com/supertokens/supertokens-node.git#905b5cd6e9babe50488318e32295a353523b8069", + "from": "supertokens-node@github:supertokens/supertokens-node#feat/oauth2/base", "requires": { "content-type": "^1.0.5", "cookie": "0.4.0", @@ -2027,6 +2036,7 @@ "nodemailer": "^6.7.2", "pkce-challenge": "^3.0.0", "psl": "1.8.0", + "set-cookie-parser": "^2.6.0", "supertokens-js-override": "^0.0.4", "twilio": "^4.19.3" }, diff --git a/test/server/package.json b/test/server/package.json index 0fdaf93f1..a36e4efd1 100644 --- a/test/server/package.json +++ b/test/server/package.json @@ -16,6 +16,6 @@ "express": "4.17.1", "morgan": "^1.10.0", "otpauth": "^9.2.0", - "supertokens-node": "18.0" + "supertokens-node": "github:supertokens/supertokens-node#feat/oauth2/base" } } diff --git a/test/with-typescript/src/App.tsx b/test/with-typescript/src/App.tsx index 64ae7db8e..6cfc6b85d 100644 --- a/test/with-typescript/src/App.tsx +++ b/test/with-typescript/src/App.tsx @@ -281,6 +281,9 @@ function getRecipeList() { } return context; }, + postAPIHook: async (context) => { + context.userContext; + }, override: { functions: (oI) => { return { From dac170ec6e534643c61c3b034d2e175f6f243db4 Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Tue, 27 Aug 2024 21:20:04 +0530 Subject: [PATCH 9/9] feat: Add functions and prebuiltUI for oauth2 logout (#850) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Add functions and prebuiltUI for oauth2 logout * Update lib/ts/recipe/oauth2provider/components/themes/themeBase.tsx Co-authored-by: Mihály Lengyel * fix: PR changes * fix: PR changes --------- Co-authored-by: Mihály Lengyel --- examples/for-tests/src/OAuth2Page.js | 5 +- lib/build/components/assets/logoutIcon.d.ts | 2 + lib/build/oauth2provider-shared.js | 25 ++ lib/build/oauth2provider.js | 18 + lib/build/oauth2providerprebuiltui.js | 379 ++++++++++++++++-- .../features/oauth2LogoutScreen/index.d.ts | 11 + .../OAuth2LogoutScreenInner.d.ts | 5 + .../themes/oauth2LogoutScreen/index.d.ts | 3 + .../components/themes/themeBase.d.ts | 7 + .../components/themes/translations.d.ts | 26 +- .../recipe/oauth2provider/constants.d.ts | 1 + lib/build/recipe/oauth2provider/index.d.ts | 20 + .../recipe/oauth2provider/prebuiltui.d.ts | 35 +- lib/build/recipe/oauth2provider/types.d.ts | 47 ++- lib/ts/components/assets/logoutIcon.tsx | 27 ++ .../features/oauth2LogoutScreen/index.tsx | 130 ++++++ .../OAuth2LogoutScreenInner.tsx | 41 ++ .../themes/oauth2LogoutScreen/index.tsx | 36 ++ .../components/themes/styles.css | 31 ++ .../components/themes/themeBase.tsx | 36 ++ .../components/themes/translations.ts | 9 +- lib/ts/recipe/oauth2provider/constants.ts | 1 + .../oauth2provider/functionOverrides.ts | 9 + lib/ts/recipe/oauth2provider/index.ts | 23 ++ lib/ts/recipe/oauth2provider/prebuiltui.tsx | 57 ++- lib/ts/recipe/oauth2provider/recipe.ts | 2 + lib/ts/recipe/oauth2provider/types.ts | 57 ++- lib/ts/recipe/oauth2provider/utils.ts | 5 + stories/oauth2provider.stories.tsx | 81 ++++ test/end-to-end/oauth2provider.test.js | 63 +++ test/helpers.js | 8 +- test/unit/componentOverrides.test.tsx | 7 +- 32 files changed, 1129 insertions(+), 78 deletions(-) create mode 100644 lib/build/components/assets/logoutIcon.d.ts create mode 100644 lib/build/recipe/oauth2provider/components/features/oauth2LogoutScreen/index.d.ts create mode 100644 lib/build/recipe/oauth2provider/components/themes/oauth2LogoutScreen/OAuth2LogoutScreenInner.d.ts create mode 100644 lib/build/recipe/oauth2provider/components/themes/oauth2LogoutScreen/index.d.ts create mode 100644 lib/build/recipe/oauth2provider/components/themes/themeBase.d.ts create mode 100644 lib/ts/components/assets/logoutIcon.tsx create mode 100644 lib/ts/recipe/oauth2provider/components/features/oauth2LogoutScreen/index.tsx create mode 100644 lib/ts/recipe/oauth2provider/components/themes/oauth2LogoutScreen/OAuth2LogoutScreenInner.tsx create mode 100644 lib/ts/recipe/oauth2provider/components/themes/oauth2LogoutScreen/index.tsx create mode 100644 lib/ts/recipe/oauth2provider/components/themes/styles.css create mode 100644 lib/ts/recipe/oauth2provider/components/themes/themeBase.tsx create mode 100644 stories/oauth2provider.stories.tsx diff --git a/examples/for-tests/src/OAuth2Page.js b/examples/for-tests/src/OAuth2Page.js index aa5b03839..3db24f8b8 100644 --- a/examples/for-tests/src/OAuth2Page.js +++ b/examples/for-tests/src/OAuth2Page.js @@ -23,7 +23,7 @@ const oidcConfig = { }; function AuthPage() { - const { signinRedirect, signinSilent, signoutSilent, user, error } = useAuth(); + const { signinRedirect, signinSilent, signoutSilent, signoutRedirect, user, error } = useAuth(); return (
@@ -36,6 +36,9 @@ function AuthPage() { + )}