@descope/react-sdk 2.0.42 → 2.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/hooks/Context.ts","../src/utils.ts","../src/constants.ts","../src/sdk.ts","../src/components/AuthProvider/AuthProvider.tsx","../src/components/AuthProvider/useSdk.ts","../src/components/Descope.tsx","../src/components/DefaultFlows.tsx","../src/components/UserManagement.tsx","../src/components/RoleManagement.tsx","../src/components/AccessKeyManagement.tsx","../src/components/AuditManagement.tsx","../src/components/UserProfile.tsx","../src/hooks/useContext.ts","../src/hooks/useDescope.ts","../src/hooks/useSession.ts","../src/hooks/useUser.ts"],"sourcesContent":["import React from 'react';\nimport { IContext } from '../types';\n\nconst Context = React.createContext<IContext>(undefined);\n\nexport default Context;\n","/**\n * Wrap a function with a validation that it exists\n * @param fn The function to wrap with the validation\n * @throws if function does not exist, an error with the relevant message will be thrown\n */\nexport const withValidation =\n\t<T extends Array<any>, U>(fn: (...args: T) => U) =>\n\t(...args: T): U => {\n\t\tif (!fn) {\n\t\t\tthrow Error(\n\t\t\t\t`You can only use this function after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`\n\t\t\t);\n\t\t}\n\t\treturn fn(...args);\n\t};\n\nexport const wrapInTry =\n\t<T extends Array<any>, U>(fn: (...args: T) => U) =>\n\t(...args: T): U => {\n\t\tlet res: U;\n\t\ttry {\n\t\t\tres = fn(...args);\n\t\t} catch (err) {\n\t\t\tconsole.error(err); // eslint-disable-line no-console\n\t\t}\n\t\treturn res;\n\t};\n","declare const BUILD_VERSION: string;\n\nexport const baseHeaders = {\n\t'x-descope-sdk-name': 'react',\n\t'x-descope-sdk-version': BUILD_VERSION\n};\n\n// This sdk can be used in SSR apps\nexport const IS_BROWSER = typeof window !== 'undefined';\n","import createSdk from '@descope/web-js-sdk';\nimport { IS_BROWSER } from './constants';\nimport { wrapInTry } from './utils';\n\ntype Sdk = ReturnType<typeof createSdkWrapper>;\nlet globalSdk: Sdk;\n\nconst createSdkWrapper = <P extends Parameters<typeof createSdk>[0]>(\n\tconfig: P\n) => {\n\tconst sdk = createSdk({\n\t\tpersistTokens: IS_BROWSER as true,\n\t\tautoRefresh: IS_BROWSER as true,\n\t\t...config\n\t});\n\tglobalSdk = sdk;\n\n\treturn sdk;\n};\n\n// eslint-disable-next-line import/exports-last\nexport const createTempSdk = () =>\n\tcreateSdkWrapper({\n\t\tprojectId: 'temp pid',\n\t\tpersistTokens: false,\n\t\tautoRefresh: false,\n\t\tstoreLastAuthenticatedUser: false\n\t});\n\n/**\n * We want to make sure the getSessionToken fn is used only when persistTokens is on\n *\n * So we are keeping the SDK init in a single place,\n * and we are creating a temp instance in order to export the getSessionToken\n * even before the SDK was init\n */\nglobalSdk = createTempSdk();\n\nexport const getSessionToken = () => {\n\tif (IS_BROWSER) {\n\t\treturn globalSdk?.getSessionToken();\n\t}\n\n\t// eslint-disable-next-line no-console\n\tconsole.warn('Get session token is not supported in SSR');\n\treturn '';\n};\n\nexport const getRefreshToken = () => {\n\tif (IS_BROWSER) {\n\t\treturn globalSdk?.getRefreshToken();\n\t}\n\t// eslint-disable-next-line no-console\n\tconsole.warn('Get refresh token is not supported in SSR');\n\treturn '';\n};\n\nexport const isSessionTokenExpired = (token = getSessionToken()) =>\n\tglobalSdk?.isJwtExpired(token);\n\nexport const isRefreshTokenExpired = (token = getRefreshToken()) =>\n\tglobalSdk?.isJwtExpired(token);\n\nexport const getJwtPermissions = wrapInTry(\n\t(token = getSessionToken(), tenant?: string) =>\n\t\tglobalSdk?.getJwtPermissions(token, tenant)\n);\n\nexport const getJwtRoles = wrapInTry(\n\t(token = getSessionToken(), tenant?: string) =>\n\t\tglobalSdk?.getJwtRoles(token, tenant)\n);\n\nexport const refresh = (token = getRefreshToken()) => globalSdk?.refresh(token);\n\nexport const getGlobalSdk = () => globalSdk;\n\nexport default createSdkWrapper;\n","import React, {\n\tFC,\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState\n} from 'react';\nimport Context from '../../hooks/Context';\nimport { IContext, User } from '../../types';\nimport { withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ninterface IAuthProviderProps {\n\tprojectId: string;\n\tbaseUrl?: string;\n\t// allows to override the base URL that is used to fetch static files\n\tbaseStaticUrl?: string;\n\t// If true, tokens will be stored on local storage and can accessed with getToken function\n\tpersistTokens?: boolean;\n\t// If true, session token (jwt) will be stored on cookie. Otherwise, the session token will be\n\t// stored on local storage and can accessed with getSessionToken function\n\t// Use this option if session token will stay small (less than 1k)\n\t// NOTE: Session token can grow, especially in cases of using authorization, or adding custom claims\n\tsessionTokenViaCookie?: boolean;\n\t// If true, last authenticated user will be stored on local storage and can accessed with getUser function\n\tstoreLastAuthenticatedUser?: boolean;\n\t// If true, last authenticated user will not be removed after logout\n\tkeepLastAuthenticatedUserAfterLogout?: boolean;\n\tchildren?: JSX.Element;\n}\n\nconst AuthProvider: FC<IAuthProviderProps> = ({\n\tprojectId,\n\tbaseUrl = '',\n\tbaseStaticUrl = '',\n\tsessionTokenViaCookie = false,\n\tpersistTokens = true,\n\tstoreLastAuthenticatedUser = true,\n\tkeepLastAuthenticatedUserAfterLogout = false,\n\tchildren = undefined\n}) => {\n\tconst [user, setUser] = useState<User>();\n\tconst [session, setSession] = useState<string>();\n\n\tconst [isUserLoading, setIsUserLoading] = useState(false);\n\tconst [isSessionLoading, setIsSessionLoading] = useState(false);\n\n\tconst sdk = useSdk({\n\t\tprojectId,\n\t\tbaseUrl,\n\t\tpersistTokens,\n\t\tsessionTokenViaCookie,\n\t\tstoreLastAuthenticatedUser,\n\t\tkeepLastAuthenticatedUserAfterLogout\n\t});\n\n\tuseEffect(() => {\n\t\tif (sdk) {\n\t\t\tconst unsubscribeSessionToken = sdk.onSessionTokenChange(setSession);\n\t\t\tconst unsubscribeUser = sdk.onUserChange(setUser);\n\n\t\t\treturn () => {\n\t\t\t\tunsubscribeSessionToken();\n\t\t\t\tunsubscribeUser();\n\t\t\t};\n\t\t}\n\t\treturn undefined;\n\t}, [sdk]);\n\n\tconst isSessionFetched = useRef(false);\n\n\tconst fetchSession = useCallback(() => {\n\t\t// We want that the session will fetched only once\n\t\tif (isSessionFetched.current) return;\n\t\tisSessionFetched.current = true;\n\n\t\tsetIsSessionLoading(true);\n\t\twithValidation(sdk?.refresh)().then(() => {\n\t\t\tsetIsSessionLoading(false);\n\t\t});\n\t}, [sdk]);\n\n\tconst fetchUser = useCallback(() => {\n\t\tsetIsUserLoading(true);\n\t\twithValidation(sdk.me)().then(() => {\n\t\t\tsetIsUserLoading(false);\n\t\t});\n\t}, [sdk]);\n\n\tconst value = useMemo<IContext>(\n\t\t() => ({\n\t\t\tfetchUser,\n\t\t\tuser,\n\t\t\tisUserLoading,\n\t\t\tfetchSession,\n\t\t\tsession,\n\t\t\tisSessionLoading,\n\t\t\tisSessionFetched: isSessionFetched.current,\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tbaseStaticUrl,\n\t\t\tstoreLastAuthenticatedUser,\n\t\t\tkeepLastAuthenticatedUserAfterLogout,\n\t\t\tsetUser,\n\t\t\tsetSession,\n\t\t\tsdk\n\t\t}),\n\t\t[\n\t\t\tfetchUser,\n\t\t\tuser,\n\t\t\tisUserLoading,\n\t\t\tfetchSession,\n\t\t\tsession,\n\t\t\tisSessionLoading,\n\t\t\tisSessionFetched.current,\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tbaseStaticUrl,\n\t\t\tsetUser,\n\t\t\tsetSession,\n\t\t\tsdk\n\t\t]\n\t);\n\treturn <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport default AuthProvider;\n","import { useMemo } from 'react';\nimport { baseHeaders } from '../../constants';\nimport createSdk from '../../sdk';\n\ntype Config = Pick<\n\tParameters<typeof createSdk>[0],\n\t| 'projectId'\n\t| 'baseUrl'\n\t| 'persistTokens'\n\t| 'sessionTokenViaCookie'\n\t| 'storeLastAuthenticatedUser'\n\t| 'keepLastAuthenticatedUserAfterLogout'\n>;\n\nexport default ({\n\tprojectId,\n\tbaseUrl,\n\tpersistTokens,\n\tsessionTokenViaCookie,\n\tstoreLastAuthenticatedUser,\n\tkeepLastAuthenticatedUserAfterLogout\n}: Config): ReturnType<typeof createSdk> =>\n\tuseMemo(() => {\n\t\tif (!projectId) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn createSdk({\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tsessionTokenViaCookie,\n\t\t\tbaseHeaders,\n\t\t\tpersistTokens,\n\t\t\tstoreLastAuthenticatedUser,\n\t\t\tkeepLastAuthenticatedUserAfterLogout,\n\t\t\tautoRefresh: true\n\t\t});\n\t}, [projectId, baseUrl, sessionTokenViaCookie]);\n","import React, {\n\tlazy,\n\tSuspense,\n\tuseCallback,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseMemo,\n\tuseState\n} from 'react';\nimport { baseHeaders } from '../constants';\nimport Context from '../hooks/Context';\nimport { DescopeProps } from '../types';\nimport { getGlobalSdk } from '../sdk';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst DescopeWC = lazy(async () => {\n\tconst module = await import('@descope/web-component');\n\tmodule.default.sdkConfigOverrides = {\n\t\t// Overrides the web-component's base headers to indicate usage via the React SDK\n\t\tbaseHeaders,\n\t\t// Disables token persistence within the web-component to delegate token management\n\t\t// to the global SDK hooks. This ensures token handling aligns with the SDK's configuration,\n\t\t// and web-component requests leverage the global SDK's beforeRequest hooks for consistency\n\t\tpersistTokens: false,\n\t\thooks: {\n\t\t\tget beforeRequest() {\n\t\t\t\t// Retrieves the beforeRequest hook from the global SDK, which is initialized\n\t\t\t\t// within the AuthProvider using the desired configuration. This approach ensures\n\t\t\t\t// the web-component utilizes the same beforeRequest hooks as the global SDK\n\t\t\t\treturn getGlobalSdk().httpClient.hooks.beforeRequest;\n\t\t\t},\n\t\t\tset beforeRequest(_) {\n\t\t\t\t// The empty setter prevents runtime errors when attempts are made to assign a value to 'beforeRequest'.\n\t\t\t\t// JavaScript objects default to having both getters and setters\n\t\t\t}\n\t\t}\n\t};\n\n\treturn {\n\t\tdefault: ({\n\t\t\tprojectId,\n\t\t\tflowId,\n\t\t\tbaseUrl,\n\t\t\tbaseStaticUrl,\n\t\t\tinnerRef,\n\t\t\ttenant,\n\t\t\ttheme,\n\t\t\tlocale,\n\t\t\tdebug,\n\t\t\tredirectUrl,\n\t\t\tclient,\n\t\t\tform,\n\t\t\tautoFocus,\n\t\t\tvalidateOnBlur\n\t\t}) => (\n\t\t\t<descope-wc\n\t\t\t\tproject-id={projectId}\n\t\t\t\tflow-id={flowId}\n\t\t\t\tbase-url={baseUrl}\n\t\t\t\tbase-static-url={baseStaticUrl}\n\t\t\t\tref={innerRef}\n\t\t\t\ttenant={tenant}\n\t\t\t\ttheme={theme}\n\t\t\t\tlocale={locale}\n\t\t\t\tdebug={debug}\n\t\t\t\tclient={client}\n\t\t\t\tform={form}\n\t\t\t\tredirect-url={redirectUrl}\n\t\t\t\tauto-focus={autoFocus}\n\t\t\t\tvalidate-on-blur={validateOnBlur}\n\t\t\t/>\n\t\t)\n\t};\n});\n\nconst Descope = React.forwardRef<HTMLElement, DescopeProps>(\n\t(\n\t\t{\n\t\t\tflowId,\n\t\t\tonSuccess,\n\t\t\tonError,\n\t\t\tonReady,\n\t\t\tlogger,\n\t\t\ttenant,\n\t\t\ttheme,\n\t\t\tlocale,\n\t\t\tdebug,\n\t\t\tclient,\n\t\t\tform,\n\t\t\ttelemetryKey,\n\t\t\tredirectUrl,\n\t\t\tautoFocus,\n\t\t\tvalidateOnBlur,\n\t\t\terrorTransformer\n\t\t},\n\t\tref\n\t) => {\n\t\tconst [innerRef, setInnerRef] = useState(null);\n\n\t\tuseImperativeHandle(ref, () => innerRef);\n\n\t\tconst {\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tbaseStaticUrl,\n\t\t\tstoreLastAuthenticatedUser,\n\t\t\tkeepLastAuthenticatedUserAfterLogout,\n\t\t\tsdk\n\t\t} = React.useContext(Context);\n\n\t\tconst handleSuccess = useCallback(\n\t\t\tasync (e: CustomEvent) => {\n\t\t\t\t// In order to make sure all the after-hooks are running with the success response\n\t\t\t\t// we are generating a fake response with the success data and calling the http client after hook fn with it\n\t\t\t\tawait sdk.httpClient.hooks.afterRequest(\n\t\t\t\t\t{} as any,\n\t\t\t\t\tnew Response(JSON.stringify(e.detail))\n\t\t\t\t);\n\t\t\t\tif (onSuccess) {\n\t\t\t\t\tonSuccess(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[onSuccess]\n\t\t);\n\n\t\tuseEffect(() => {\n\t\t\tconst ele = innerRef;\n\t\t\tele?.addEventListener('success', handleSuccess);\n\t\t\tif (onError) ele?.addEventListener('error', onError);\n\t\t\tif (onReady) ele?.addEventListener('ready', onReady);\n\n\t\t\treturn () => {\n\t\t\t\tif (onError) ele?.removeEventListener('error', onError);\n\t\t\t\tif (onReady) ele?.removeEventListener('ready', onReady);\n\n\t\t\t\tele?.removeEventListener('success', handleSuccess);\n\t\t\t};\n\t\t}, [innerRef, onError, handleSuccess]);\n\n\t\t// Success event\n\t\tuseEffect(() => {\n\t\t\tconst ele = innerRef;\n\t\t\tele?.addEventListener('success', handleSuccess);\n\t\t\treturn () => {\n\t\t\t\tele?.removeEventListener('success', handleSuccess);\n\t\t\t};\n\t\t}, [innerRef, handleSuccess]);\n\n\t\t// Error event\n\t\tuseEffect(() => {\n\t\t\tconst ele = innerRef;\n\t\t\tif (onError) ele?.addEventListener('error', onError);\n\n\t\t\treturn () => {\n\t\t\t\tif (onError) ele?.removeEventListener('error', onError);\n\t\t\t};\n\t\t}, [innerRef, onError]);\n\n\t\t// Ready event\n\t\tuseEffect(() => {\n\t\t\tconst ele = innerRef;\n\t\t\tif (onReady) ele?.addEventListener('ready', onReady);\n\n\t\t\treturn () => {\n\t\t\t\tif (onReady) ele?.removeEventListener('error', onReady);\n\t\t\t};\n\t\t}, [innerRef, onReady]);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef) {\n\t\t\t\tinnerRef.errorTransformer = errorTransformer;\n\t\t\t}\n\t\t}, [innerRef, errorTransformer]);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef && logger) {\n\t\t\t\tinnerRef.logger = logger;\n\t\t\t}\n\t\t}, [innerRef, logger]);\n\n\t\tconst { form: stringifiedForm, client: stringifiedClient } = useMemo(\n\t\t\t() => ({\n\t\t\t\tform: JSON.stringify(form || {}),\n\t\t\t\tclient: JSON.stringify(client || {})\n\t\t\t}),\n\t\t\t[form, client]\n\t\t);\n\n\t\treturn (\n\t\t\t/**\n\t\t\t * in order to avoid redundant remounting of the WC, we are wrapping it with a form element\n\t\t\t * this workaround is done in order to support webauthn passkeys\n\t\t\t * it can be removed once this issue will be solved\n\t\t\t * https://bugs.chromium.org/p/chromium/issues/detail?id=1404106#c2\n\t\t\t */\n\t\t\t<form>\n\t\t\t\t<Suspense fallback={null}>\n\t\t\t\t\t<DescopeWC\n\t\t\t\t\t\tprojectId={projectId}\n\t\t\t\t\t\tflowId={flowId}\n\t\t\t\t\t\tbaseUrl={baseUrl}\n\t\t\t\t\t\tbaseStaticUrl={baseStaticUrl}\n\t\t\t\t\t\tinnerRef={setInnerRef}\n\t\t\t\t\t\ttenant={tenant}\n\t\t\t\t\t\ttheme={theme}\n\t\t\t\t\t\tlocale={locale}\n\t\t\t\t\t\tdebug={debug}\n\t\t\t\t\t\tform={stringifiedForm}\n\t\t\t\t\t\tclient={stringifiedClient}\n\t\t\t\t\t\ttelemetryKey={telemetryKey}\n\t\t\t\t\t\tredirectUrl={redirectUrl}\n\t\t\t\t\t\tautoFocus={autoFocus}\n\t\t\t\t\t\tvalidateOnBlur={validateOnBlur}\n\t\t\t\t\t\tstoreLastAuthenticatedUser={storeLastAuthenticatedUser}\n\t\t\t\t\t\tkeepLastAuthenticatedUserAfterLogout={\n\t\t\t\t\t\t\tkeepLastAuthenticatedUserAfterLogout\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</Suspense>\n\t\t\t</form>\n\t\t);\n\t}\n);\n\nexport default Descope;\n","import React from 'react';\nimport { DefaultFlowProps } from '../types';\nimport Descope from './Descope';\n\nexport const SignInFlow = (props: DefaultFlowProps) => (\n\t<Descope {...props} flowId=\"sign-in\" />\n);\n\nexport const SignUpFlow = (props: DefaultFlowProps) => (\n\t<Descope {...props} flowId=\"sign-up\" />\n);\n\nexport const SignUpOrInFlow = (props: DefaultFlowProps) => (\n\t<Descope {...props} flowId=\"sign-up-or-in\" />\n);\n","import React, {\n\tlazy,\n\tSuspense,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseState\n} from 'react';\nimport Context from '../hooks/Context';\nimport { UserManagementProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst UserManagementWC = lazy(async () => {\n\tawait import('@descope/user-management-widget');\n\n\treturn {\n\t\tdefault: ({\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tbaseStaticUrl,\n\t\t\tinnerRef,\n\t\t\ttenant,\n\t\t\twidgetId,\n\t\t\ttheme,\n\t\t\tdebug\n\t\t}) => (\n\t\t\t<descope-user-management-widget\n\t\t\t\tproject-id={projectId}\n\t\t\t\twidget-id={widgetId}\n\t\t\t\tbase-url={baseUrl}\n\t\t\t\tbase-static-url={baseStaticUrl}\n\t\t\t\ttheme={theme}\n\t\t\t\ttenant={tenant}\n\t\t\t\tdebug={debug}\n\t\t\t\tref={innerRef}\n\t\t\t/>\n\t\t)\n\t};\n});\n\nconst UserManagement = React.forwardRef<HTMLElement, UserManagementProps>(\n\t({ logger, tenant, theme, debug, widgetId }, ref) => {\n\t\tconst [innerRef, setInnerRef] = useState(null);\n\n\t\tuseImperativeHandle(ref, () => innerRef);\n\n\t\tconst { projectId, baseUrl, baseStaticUrl } = React.useContext(Context);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef && logger) {\n\t\t\t\tinnerRef.logger = logger;\n\t\t\t}\n\t\t}, [innerRef, logger]);\n\n\t\treturn (\n\t\t\t<Suspense fallback={null}>\n\t\t\t\t<UserManagementWC\n\t\t\t\t\tprojectId={projectId}\n\t\t\t\t\twidgetId={widgetId}\n\t\t\t\t\tbaseUrl={baseUrl}\n\t\t\t\t\tbaseStaticUrl={baseStaticUrl}\n\t\t\t\t\tinnerRef={setInnerRef}\n\t\t\t\t\ttenant={tenant}\n\t\t\t\t\ttheme={theme}\n\t\t\t\t\tdebug={debug}\n\t\t\t\t/>\n\t\t\t</Suspense>\n\t\t);\n\t}\n);\n\nexport default UserManagement;\n","import React, {\n\tlazy,\n\tSuspense,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseState\n} from 'react';\nimport Context from '../hooks/Context';\nimport { RoleManagementProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst RoleManagementWC = lazy(async () => {\n\tawait import('@descope/role-management-widget');\n\n\treturn {\n\t\tdefault: ({\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tbaseStaticUrl,\n\t\t\tinnerRef,\n\t\t\ttenant,\n\t\t\twidgetId,\n\t\t\ttheme,\n\t\t\tdebug\n\t\t}) => (\n\t\t\t<descope-role-management-widget\n\t\t\t\tproject-id={projectId}\n\t\t\t\twidget-id={widgetId}\n\t\t\t\tbase-url={baseUrl}\n\t\t\t\tbase-static-url={baseStaticUrl}\n\t\t\t\ttheme={theme}\n\t\t\t\ttenant={tenant}\n\t\t\t\tdebug={debug}\n\t\t\t\tref={innerRef}\n\t\t\t/>\n\t\t)\n\t};\n});\n\nconst RoleManagement = React.forwardRef<HTMLElement, RoleManagementProps>(\n\t({ logger, tenant, theme, debug, widgetId }, ref) => {\n\t\tconst [innerRef, setInnerRef] = useState(null);\n\n\t\tuseImperativeHandle(ref, () => innerRef);\n\n\t\tconst { projectId, baseUrl, baseStaticUrl } = React.useContext(Context);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef && logger) {\n\t\t\t\tinnerRef.logger = logger;\n\t\t\t}\n\t\t}, [innerRef, logger]);\n\n\t\treturn (\n\t\t\t<Suspense fallback={null}>\n\t\t\t\t<RoleManagementWC\n\t\t\t\t\tprojectId={projectId}\n\t\t\t\t\twidgetId={widgetId}\n\t\t\t\t\tbaseUrl={baseUrl}\n\t\t\t\t\tbaseStaticUrl={baseStaticUrl}\n\t\t\t\t\tinnerRef={setInnerRef}\n\t\t\t\t\ttenant={tenant}\n\t\t\t\t\ttheme={theme}\n\t\t\t\t\tdebug={debug}\n\t\t\t\t/>\n\t\t\t</Suspense>\n\t\t);\n\t}\n);\n\nexport default RoleManagement;\n","import React, {\n\tlazy,\n\tSuspense,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseState\n} from 'react';\nimport Context from '../hooks/Context';\nimport { AccessKeyManagementProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst AccessKeyManagementWC = lazy(async () => {\n\tawait import('@descope/access-key-management-widget');\n\n\treturn {\n\t\tdefault: ({\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tbaseStaticUrl,\n\t\t\tinnerRef,\n\t\t\ttenant,\n\t\t\twidgetId,\n\t\t\ttheme,\n\t\t\tdebug\n\t\t}) => (\n\t\t\t<descope-access-key-management-widget\n\t\t\t\tproject-id={projectId}\n\t\t\t\twidget-id={widgetId}\n\t\t\t\tbase-url={baseUrl}\n\t\t\t\tbase-static-url={baseStaticUrl}\n\t\t\t\ttheme={theme}\n\t\t\t\ttenant={tenant}\n\t\t\t\tdebug={debug}\n\t\t\t\tref={innerRef}\n\t\t\t/>\n\t\t)\n\t};\n});\n\nconst AccessKeyManagement = React.forwardRef<\n\tHTMLElement,\n\tAccessKeyManagementProps\n>(({ logger, tenant, theme, debug, widgetId }, ref) => {\n\tconst [innerRef, setInnerRef] = useState(null);\n\n\tuseImperativeHandle(ref, () => innerRef);\n\n\tconst { projectId, baseUrl, baseStaticUrl } = React.useContext(Context);\n\n\tuseEffect(() => {\n\t\tif (innerRef && logger) {\n\t\t\tinnerRef.logger = logger;\n\t\t}\n\t}, [innerRef, logger]);\n\n\treturn (\n\t\t<Suspense fallback={null}>\n\t\t\t<AccessKeyManagementWC\n\t\t\t\tprojectId={projectId}\n\t\t\t\twidgetId={widgetId}\n\t\t\t\tbaseUrl={baseUrl}\n\t\t\t\tbaseStaticUrl={baseStaticUrl}\n\t\t\t\tinnerRef={setInnerRef}\n\t\t\t\ttenant={tenant}\n\t\t\t\ttheme={theme}\n\t\t\t\tdebug={debug}\n\t\t\t/>\n\t\t</Suspense>\n\t);\n});\n\nexport default AccessKeyManagement;\n","import React, {\n\tlazy,\n\tSuspense,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseState\n} from 'react';\nimport Context from '../hooks/Context';\nimport { AuditManagementProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst AuditManagementWC = lazy(async () => {\n\tawait import('@descope/audit-management-widget');\n\n\treturn {\n\t\tdefault: ({\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tbaseStaticUrl,\n\t\t\tinnerRef,\n\t\t\ttenant,\n\t\t\twidgetId,\n\t\t\ttheme,\n\t\t\tdebug\n\t\t}) => (\n\t\t\t<descope-audit-management-widget\n\t\t\t\tproject-id={projectId}\n\t\t\t\twidget-id={widgetId}\n\t\t\t\tbase-url={baseUrl}\n\t\t\t\tbase-static-url={baseStaticUrl}\n\t\t\t\ttheme={theme}\n\t\t\t\ttenant={tenant}\n\t\t\t\tdebug={debug}\n\t\t\t\tref={innerRef}\n\t\t\t/>\n\t\t)\n\t};\n});\n\nconst AuditManagement = React.forwardRef<HTMLElement, AuditManagementProps>(\n\t({ logger, tenant, theme, debug, widgetId }, ref) => {\n\t\tconst [innerRef, setInnerRef] = useState(null);\n\n\t\tuseImperativeHandle(ref, () => innerRef);\n\n\t\tconst { projectId, baseUrl, baseStaticUrl } = React.useContext(Context);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef && logger) {\n\t\t\t\tinnerRef.logger = logger;\n\t\t\t}\n\t\t}, [innerRef, logger]);\n\n\t\treturn (\n\t\t\t<Suspense fallback={null}>\n\t\t\t\t<AuditManagementWC\n\t\t\t\t\tprojectId={projectId}\n\t\t\t\t\twidgetId={widgetId}\n\t\t\t\t\tbaseUrl={baseUrl}\n\t\t\t\t\tbaseStaticUrl={baseStaticUrl}\n\t\t\t\t\tinnerRef={setInnerRef}\n\t\t\t\t\ttenant={tenant}\n\t\t\t\t\ttheme={theme}\n\t\t\t\t\tdebug={debug}\n\t\t\t\t/>\n\t\t\t</Suspense>\n\t\t);\n\t}\n);\n\nexport default AuditManagement;\n","import React, {\n\tlazy,\n\tSuspense,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseState\n} from 'react';\nimport Context from '../hooks/Context';\nimport { UserProfileProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst UserProfileWC = lazy(async () => {\n\tawait import('@descope/user-profile-widget');\n\n\treturn {\n\t\tdefault: ({\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tbaseStaticUrl,\n\t\t\tinnerRef,\n\t\t\twidgetId,\n\t\t\ttheme,\n\t\t\tdebug\n\t\t}) => (\n\t\t\t<descope-user-profile-widget\n\t\t\t\tproject-id={projectId}\n\t\t\t\twidget-id={widgetId}\n\t\t\t\tbase-url={baseUrl}\n\t\t\t\tbase-static-url={baseStaticUrl}\n\t\t\t\ttheme={theme}\n\t\t\t\tdebug={debug}\n\t\t\t\tref={innerRef}\n\t\t\t/>\n\t\t)\n\t};\n});\n\nconst UserProfile = React.forwardRef<HTMLElement, UserProfileProps>(\n\t({ logger, theme, debug, widgetId, onLogout }, ref) => {\n\t\tconst [innerRef, setInnerRef] = useState(null);\n\n\t\tuseImperativeHandle(ref, () => innerRef);\n\n\t\tconst { projectId, baseUrl, baseStaticUrl } = React.useContext(Context);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef && logger) {\n\t\t\t\tinnerRef.logger = logger;\n\t\t\t}\n\t\t}, [innerRef, logger]);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef && onLogout) {\n\t\t\t\tinnerRef.addEventListener('logout', onLogout);\n\t\t\t\treturn () => innerRef.removeEventListener('logout', onLogout);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}, [innerRef, onLogout]);\n\n\t\treturn (\n\t\t\t<Suspense fallback={null}>\n\t\t\t\t<UserProfileWC\n\t\t\t\t\tprojectId={projectId}\n\t\t\t\t\twidgetId={widgetId}\n\t\t\t\t\tbaseUrl={baseUrl}\n\t\t\t\t\tbaseStaticUrl={baseStaticUrl}\n\t\t\t\t\tinnerRef={setInnerRef}\n\t\t\t\t\ttheme={theme}\n\t\t\t\t\tdebug={debug}\n\t\t\t\t/>\n\t\t\t</Suspense>\n\t\t);\n\t}\n);\n\nexport default UserProfile;\n","import { useContext } from 'react';\nimport Context from './Context';\n\nexport default () => {\n\tconst ctx = useContext(Context);\n\tif (!ctx) {\n\t\tthrow Error(\n\t\t\t`You can only use this hook in the context of <AuthProvider />`\n\t\t);\n\t}\n\n\treturn ctx;\n};\n","import { useMemo } from 'react';\nimport { Sdk } from '../types';\nimport useContext from './useContext';\nimport { createTempSdk } from '../sdk';\n\nconst generateErrorMsg = (entryType: string) =>\n\t`You can only use this ${entryType} after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`;\n\n// handler which throw an error for every SDK function\nconst proxyThrowHandler = {\n\t// eslint-disable-next-line prefer-arrow/prefer-arrow-functions\n\tget(target: Record<string, any>, key: string) {\n\t\tif (typeof target[key] === 'object' && target[key] !== null) {\n\t\t\treturn new Proxy(target[key], proxyThrowHandler);\n\t\t}\n\n\t\tif (typeof target[key] === 'function') {\n\t\t\treturn () => {\n\t\t\t\tthrow Error(generateErrorMsg('function'));\n\t\t\t};\n\t\t}\n\n\t\tthrow Error(generateErrorMsg('attribute'));\n\t}\n};\n\nconst useDescope = (): Sdk => {\n\tconst { sdk } = useContext();\n\n\treturn useMemo(() => {\n\t\tif (!sdk) {\n\t\t\t// In case the SDK is not initialized, we want to throw an error when the SDK functions are called\n\t\t\treturn new Proxy(createTempSdk(), proxyThrowHandler) as Sdk;\n\t\t}\n\n\t\treturn sdk;\n\t}, [sdk]);\n};\n\nexport default useDescope;\n","import { useEffect, useMemo, useRef } from 'react';\nimport useContext from './useContext';\n\nconst useSession = () => {\n\tconst { session, isSessionLoading, fetchSession, isSessionFetched } =\n\t\tuseContext();\n\n\t// when session should be received, we want the return value of \"isSessionLoading\" to be true starting from the first call\n\t// (and not only when receiving an update from the context)\n\tconst isLoading = useRef(isSessionLoading);\n\n\t// we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n\tuseMemo(() => {\n\t\tisLoading.current = isSessionLoading;\n\t}, [isSessionLoading]);\n\n\tconst shouldFetchSession = !session && !isSessionLoading;\n\n\t// we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n\tuseMemo(() => {\n\t\tif (shouldFetchSession && !isSessionFetched) {\n\t\t\tisLoading.current = true;\n\t\t}\n\t}, [isSessionFetched]);\n\n\t// Fetch session if it's not already fetched\n\t// We want this to happen only once, so the dependency array should not contain shouldFetchSession\n\tuseEffect(() => {\n\t\tif (shouldFetchSession) {\n\t\t\tfetchSession();\n\t\t}\n\t}, [fetchSession]);\n\treturn {\n\t\tisSessionLoading: isLoading.current,\n\t\tsessionToken: session,\n\t\tisAuthenticated: !!session\n\t};\n};\n\nexport default useSession;\n","import { useEffect, useMemo, useRef, useState } from 'react';\nimport useContext from './useContext';\n\nconst useUser = () => {\n\tconst { user, fetchUser, isUserLoading, session } = useContext();\n\tconst [isInit, setIsInit] = useState(false); // we want to get the user only in the first time we got a session\n\n\t// when session should be received, we want the return value of \"isUserLoading\" to be true starting from the first call\n\t// (and not only when receiving an update from the context)\n\tconst isLoading = useRef(isUserLoading);\n\n\tconst shouldFetchUser = useMemo(\n\t\t() => !user && !isUserLoading && session && !isInit,\n\t\t[fetchUser, session, isInit]\n\t);\n\n\t// we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n\tuseMemo(() => {\n\t\tisLoading.current = isUserLoading;\n\t}, [isUserLoading]);\n\n\t// we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n\tuseMemo(() => {\n\t\tif (shouldFetchUser) {\n\t\t\tisLoading.current = true;\n\t\t}\n\t}, [shouldFetchUser]);\n\n\tuseEffect(() => {\n\t\tif (shouldFetchUser) {\n\t\t\tsetIsInit(true);\n\t\t\tfetchUser();\n\t\t}\n\t}, [shouldFetchUser]);\n\n\treturn { isUserLoading: isLoading.current, user };\n};\n\nexport default useUser;\n"],"names":["Context","React","createContext","undefined","withValidation","fn","args","Error","wrapInTry","res","err","console","error","baseHeaders","IS_BROWSER","window","globalSdk","createSdkWrapper","config","sdk","createSdk","Object","assign","persistTokens","autoRefresh","createTempSdk","projectId","storeLastAuthenticatedUser","getSessionToken","warn","getRefreshToken","isSessionTokenExpired","token","isJwtExpired","isRefreshTokenExpired","getJwtPermissions","tenant","getJwtRoles","refresh","AuthProvider","baseUrl","baseStaticUrl","sessionTokenViaCookie","keepLastAuthenticatedUserAfterLogout","children","user","setUser","useState","session","setSession","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","useMemo","useSdk","useEffect","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","isSessionFetched","useRef","fetchSession","useCallback","current","then","fetchUser","me","value","createElement","Provider","DescopeWC","lazy","async","import","default","sdkConfigOverrides","hooks","beforeRequest","httpClient","_","flowId","innerRef","theme","locale","debug","redirectUrl","client","form","autoFocus","validateOnBlur","ref","Descope","forwardRef","onSuccess","onError","onReady","logger","telemetryKey","errorTransformer","setInnerRef","useImperativeHandle","useContext","handleSuccess","e","afterRequest","Response","JSON","stringify","detail","ele","addEventListener","removeEventListener","stringifiedForm","stringifiedClient","Suspense","fallback","SignInFlow","props","SignUpFlow","SignUpOrInFlow","UserManagementWC","widgetId","UserManagement","RoleManagementWC","RoleManagement","AccessKeyManagementWC","AccessKeyManagement","AuditManagementWC","AuditManagement","UserProfileWC","UserProfile","onLogout","ctx","generateErrorMsg","entryType","proxyThrowHandler","get","target","key","Proxy","useDescope","useSession","isLoading","shouldFetchSession","sessionToken","isAuthenticated","useUser","isInit","setIsInit","shouldFetchUser"],"mappings":"iMAGA,MAAMA,EAAUC,EAAMC,mBAAwBC,GCEjCC,EACcC,GAC1B,IAAIC,KACH,IAAKD,EACJ,MAAME,MACL,0HAGF,OAAOF,KAAMC,EAAK,EAGPE,EACcH,GAC1B,IAAIC,KACH,IAAIG,EACJ,IACCA,EAAMJ,KAAMC,EAGZ,CAFC,MAAOI,GACRC,QAAQC,MAAMF,EACd,CACD,OAAOD,CAAG,ECvBCI,EAAc,CAC1B,qBAAsB,QACtB,wBAAyB,UAIbC,EAA+B,oBAAXC,OCHjC,IAAIC,EAEJ,MAAMC,EACLC,IAEA,MAAMC,EAAMC,EAASC,OAAAC,OAAA,CACpBC,cAAeT,EACfU,YAAaV,GACVI,IAIJ,OAFAF,EAAYG,EAELA,CAAG,EAIEM,EAAgB,IAC5BR,EAAiB,CAChBS,UAAW,WACXH,eAAe,EACfC,aAAa,EACbG,4BAA4B,IAU9BX,EAAYS,IAEL,MAAMG,EAAkB,IAC1Bd,EACIE,aAAS,EAATA,EAAWY,mBAInBjB,QAAQkB,KAAK,6CACN,IAGKC,EAAkB,IAC1BhB,EACIE,aAAS,EAATA,EAAWc,mBAGnBnB,QAAQkB,KAAK,6CACN,IAGKE,EAAwB,CAACC,EAAQJ,MAC7CZ,aAAA,EAAAA,EAAWiB,aAAaD,GAEZE,EAAwB,CAACF,EAAQF,MAC7Cd,aAAA,EAAAA,EAAWiB,aAAaD,GAEZG,EAAoB3B,GAChC,CAACwB,EAAQJ,IAAmBQ,IAC3BpB,aAAS,EAATA,EAAWmB,kBAAkBH,EAAOI,KAGzBC,EAAc7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,EAAgBW,aAAEA,EAAYF,iBAAEA,GAChD0C,IAIKyC,EAAYlF,EAAOV,GAGzBE,GAAQ,KACP0F,EAAU/E,QAAUb,CAAgB,GAClC,CAACA,IAEJ,MAAM6F,GAAsBjG,IAAYI,EAgBxC,OAbAE,GAAQ,KACH2F,IAAuBpF,IAC1BmF,EAAU/E,SAAU,EACpB,GACC,CAACJ,IAIJL,GAAU,KACLyF,GACHlF,GACA,GACC,CAACA,IACG,CACNX,iBAAkB4F,EAAU/E,QAC5BiF,aAAclG,EACdmG,kBAAmBnG,EACnB,ECjCIoG,EAAU,KACf,MAAMvG,KAAEA,EAAIsB,UAAEA,EAASjB,cAAEA,EAAaF,QAAEA,GAAYuD,KAC7C8C,EAAQC,GAAavG,GAAS,GAI/BiG,EAAYlF,EAAOZ,GAEnBqG,EAAkBjG,GACvB,KAAOT,IAASK,GAAiBF,IAAYqG,GAC7C,CAAClF,EAAWnB,EAASqG,IAsBtB,OAlBA/F,GAAQ,KACP0F,EAAU/E,QAAUf,CAAa,GAC/B,CAACA,IAGJI,GAAQ,KACHiG,IACHP,EAAU/E,SAAU,EACpB,GACC,CAACsF,IAEJ/F,GAAU,KACL+F,IACHD,GAAU,GACVnF,IACA,GACC,CAACoF,IAEG,CAAErG,cAAe8F,EAAU/E,QAASpB,OAAM"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/hooks/Context.ts","../src/utils.ts","../src/constants.ts","../src/sdk.ts","../src/components/AuthProvider/AuthProvider.tsx","../src/components/AuthProvider/useSdk.ts","../src/components/Descope.tsx","../src/components/DefaultFlows.tsx","../src/components/UserManagement.tsx","../src/components/RoleManagement.tsx","../src/components/AccessKeyManagement.tsx","../src/components/AuditManagement.tsx","../src/components/UserProfile.tsx","../src/hooks/useContext.ts","../src/hooks/useDescope.ts","../src/hooks/useSession.ts","../src/hooks/useUser.ts"],"sourcesContent":["import React from 'react';\nimport { IContext } from '../types';\n\nconst Context = React.createContext<IContext>(undefined);\n\nexport default Context;\n","/**\n * Wrap a function with a validation that it exists\n * @param fn The function to wrap with the validation\n * @throws if function does not exist, an error with the relevant message will be thrown\n */\nexport const withValidation =\n <T extends Array<any>, U>(fn: (...args: T) => U) =>\n (...args: T): U => {\n if (!fn) {\n throw Error(\n `You can only use this function after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`,\n );\n }\n return fn(...args);\n };\n\nexport const wrapInTry =\n <T extends Array<any>, U>(fn: (...args: T) => U) =>\n (...args: T): U => {\n let res: U;\n try {\n res = fn(...args);\n } catch (err) {\n console.error(err); // eslint-disable-line no-console\n }\n return res;\n };\n","declare const BUILD_VERSION: string;\n\nexport const baseHeaders = {\n 'x-descope-sdk-name': 'react',\n 'x-descope-sdk-version': BUILD_VERSION,\n};\n\n// This sdk can be used in SSR apps\nexport const IS_BROWSER = typeof window !== 'undefined';\n","import createSdk from '@descope/web-js-sdk';\nimport '@descope/core-js-sdk';\nimport { IS_BROWSER } from './constants';\nimport { wrapInTry } from './utils';\n\ntype Sdk = ReturnType<typeof createSdkWrapper>;\nlet globalSdk: Sdk;\n\nconst createSdkWrapper = <P extends Parameters<typeof createSdk>[0]>(\n config: P,\n) => {\n const sdk = createSdk({\n persistTokens: IS_BROWSER as true,\n autoRefresh: IS_BROWSER as true,\n ...config,\n });\n globalSdk = sdk;\n\n return sdk;\n};\n\n// eslint-disable-next-line import/exports-last\nexport const createTempSdk = () =>\n createSdkWrapper({\n projectId: 'temp pid',\n persistTokens: false,\n autoRefresh: false,\n storeLastAuthenticatedUser: false,\n });\n\n/**\n * We want to make sure the getSessionToken fn is used only when persistTokens is on\n *\n * So we are keeping the SDK init in a single place,\n * and we are creating a temp instance in order to export the getSessionToken\n * even before the SDK was init\n */\nglobalSdk = createTempSdk();\n\nexport const getSessionToken = () => {\n if (IS_BROWSER) {\n return globalSdk?.getSessionToken();\n }\n\n // eslint-disable-next-line no-console\n console.warn('Get session token is not supported in SSR');\n return '';\n};\n\nexport const getRefreshToken = () => {\n if (IS_BROWSER) {\n return globalSdk?.getRefreshToken();\n }\n // eslint-disable-next-line no-console\n console.warn('Get refresh token is not supported in SSR');\n return '';\n};\n\nexport const isSessionTokenExpired = (token = getSessionToken()) =>\n globalSdk?.isJwtExpired(token);\n\nexport const isRefreshTokenExpired = (token = getRefreshToken()) =>\n globalSdk?.isJwtExpired(token);\n\nexport const getJwtPermissions = wrapInTry(\n (token = getSessionToken(), tenant?: string) =>\n globalSdk?.getJwtPermissions(token, tenant),\n);\n\nexport const getJwtRoles = wrapInTry(\n (token = getSessionToken(), tenant?: string) =>\n globalSdk?.getJwtRoles(token, tenant),\n);\n\nexport const refresh = (token = getRefreshToken()) => globalSdk?.refresh(token);\n\nexport const getGlobalSdk = () => globalSdk;\n\nexport default createSdkWrapper;\n","import React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport Context from '../../hooks/Context';\nimport { IContext, User } from '../../types';\nimport { withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ninterface IAuthProviderProps {\n projectId: string;\n baseUrl?: string;\n // allows to override the base URL that is used to fetch static files\n baseStaticUrl?: string;\n // If true, tokens will be stored on local storage and can accessed with getToken function\n persistTokens?: boolean;\n // If true, session token (jwt) will be stored on cookie. Otherwise, the session token will be\n // stored on local storage and can accessed with getSessionToken function\n // Use this option if session token will stay small (less than 1k)\n // NOTE: Session token can grow, especially in cases of using authorization, or adding custom claims\n sessionTokenViaCookie?: boolean;\n // If true, last authenticated user will be stored on local storage and can accessed with getUser function\n storeLastAuthenticatedUser?: boolean;\n // If true, last authenticated user will not be removed after logout\n keepLastAuthenticatedUserAfterLogout?: boolean;\n children?: JSX.Element;\n}\n\nconst AuthProvider: FC<IAuthProviderProps> = ({\n projectId,\n baseUrl = '',\n baseStaticUrl = '',\n sessionTokenViaCookie = false,\n persistTokens = true,\n storeLastAuthenticatedUser = true,\n keepLastAuthenticatedUserAfterLogout = false,\n children = undefined,\n}) => {\n const [user, setUser] = useState<User>();\n const [session, setSession] = useState<string>();\n\n const [isUserLoading, setIsUserLoading] = useState(false);\n const [isSessionLoading, setIsSessionLoading] = useState(false);\n\n const sdk = useSdk({\n projectId,\n baseUrl,\n persistTokens,\n sessionTokenViaCookie,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n });\n\n useEffect(() => {\n if (sdk) {\n const unsubscribeSessionToken = sdk.onSessionTokenChange(setSession);\n const unsubscribeUser = sdk.onUserChange(setUser);\n\n return () => {\n unsubscribeSessionToken();\n unsubscribeUser();\n };\n }\n return undefined;\n }, [sdk]);\n\n const isSessionFetched = useRef(false);\n\n const fetchSession = useCallback(() => {\n // We want that the session will fetched only once\n if (isSessionFetched.current) return;\n isSessionFetched.current = true;\n\n setIsSessionLoading(true);\n withValidation(sdk?.refresh)().then(() => {\n setIsSessionLoading(false);\n });\n }, [sdk]);\n\n const fetchUser = useCallback(() => {\n setIsUserLoading(true);\n withValidation(sdk.me)().then(() => {\n setIsUserLoading(false);\n });\n }, [sdk]);\n\n const value = useMemo<IContext>(\n () => ({\n fetchUser,\n user,\n isUserLoading,\n fetchSession,\n session,\n isSessionLoading,\n isSessionFetched: isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n setUser,\n setSession,\n sdk,\n }),\n [\n fetchUser,\n user,\n isUserLoading,\n fetchSession,\n session,\n isSessionLoading,\n isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n setUser,\n setSession,\n sdk,\n ],\n );\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport default AuthProvider;\n","import { useMemo } from 'react';\nimport { baseHeaders } from '../../constants';\nimport createSdk from '../../sdk';\n\ntype Config = Pick<\n Parameters<typeof createSdk>[0],\n | 'projectId'\n | 'baseUrl'\n | 'persistTokens'\n | 'sessionTokenViaCookie'\n | 'storeLastAuthenticatedUser'\n | 'keepLastAuthenticatedUserAfterLogout'\n>;\n\nexport default ({\n projectId,\n baseUrl,\n persistTokens,\n sessionTokenViaCookie,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n}: Config): ReturnType<typeof createSdk> =>\n useMemo(() => {\n if (!projectId) {\n return undefined;\n }\n return createSdk({\n projectId,\n baseUrl,\n sessionTokenViaCookie,\n baseHeaders,\n persistTokens,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n autoRefresh: true,\n });\n }, [projectId, baseUrl, sessionTokenViaCookie]);\n","import React, {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react';\nimport { baseHeaders } from '../constants';\nimport Context from '../hooks/Context';\nimport { DescopeProps } from '../types';\nimport { getGlobalSdk } from '../sdk';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst DescopeWC = lazy(async () => {\n const module = await import('@descope/web-component');\n module.default.sdkConfigOverrides = {\n // Overrides the web-component's base headers to indicate usage via the React SDK\n baseHeaders,\n // Disables token persistence within the web-component to delegate token management\n // to the global SDK hooks. This ensures token handling aligns with the SDK's configuration,\n // and web-component requests leverage the global SDK's beforeRequest hooks for consistency\n persistTokens: false,\n hooks: {\n get beforeRequest() {\n // Retrieves the beforeRequest hook from the global SDK, which is initialized\n // within the AuthProvider using the desired configuration. This approach ensures\n // the web-component utilizes the same beforeRequest hooks as the global SDK\n return getGlobalSdk().httpClient.hooks.beforeRequest;\n },\n set beforeRequest(_) {\n // The empty setter prevents runtime errors when attempts are made to assign a value to 'beforeRequest'.\n // JavaScript objects default to having both getters and setters\n },\n },\n };\n\n return {\n default: ({\n projectId,\n flowId,\n baseUrl,\n baseStaticUrl,\n innerRef,\n tenant,\n theme,\n locale,\n debug,\n redirectUrl,\n client,\n form,\n autoFocus,\n validateOnBlur,\n }) => (\n\t<descope-wc\n project-id={projectId}\n flow-id={flowId}\n base-url={baseUrl}\n base-static-url={baseStaticUrl}\n ref={innerRef}\n tenant={tenant}\n theme={theme}\n locale={locale}\n debug={debug}\n client={client}\n form={form}\n redirect-url={redirectUrl}\n auto-focus={autoFocus}\n validate-on-blur={validateOnBlur}\n />\n ),\n };\n});\n\nconst Descope = React.forwardRef<HTMLElement, DescopeProps>(\n (\n {\n flowId,\n onSuccess,\n onError,\n onReady,\n logger,\n tenant,\n theme,\n locale,\n debug,\n client,\n form,\n telemetryKey,\n redirectUrl,\n autoFocus,\n validateOnBlur,\n errorTransformer,\n },\n ref,\n ) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const {\n projectId,\n baseUrl,\n baseStaticUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n sdk,\n } = React.useContext(Context);\n\n const handleSuccess = useCallback(\n async (e: CustomEvent) => {\n // In order to make sure all the after-hooks are running with the success response\n // we are generating a fake response with the success data and calling the http client after hook fn with it\n await sdk.httpClient.hooks.afterRequest(\n {} as any,\n new Response(JSON.stringify(e.detail)),\n );\n if (onSuccess) {\n onSuccess(e);\n }\n },\n [onSuccess],\n );\n\n useEffect(() => {\n const ele = innerRef;\n ele?.addEventListener('success', handleSuccess);\n if (onError) ele?.addEventListener('error', onError);\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onError) ele?.removeEventListener('error', onError);\n if (onReady) ele?.removeEventListener('ready', onReady);\n\n ele?.removeEventListener('success', handleSuccess);\n };\n }, [innerRef, onError, handleSuccess]);\n\n // Success event\n useEffect(() => {\n const ele = innerRef;\n ele?.addEventListener('success', handleSuccess);\n return () => {\n ele?.removeEventListener('success', handleSuccess);\n };\n }, [innerRef, handleSuccess]);\n\n // Error event\n useEffect(() => {\n const ele = innerRef;\n if (onError) ele?.addEventListener('error', onError);\n\n return () => {\n if (onError) ele?.removeEventListener('error', onError);\n };\n }, [innerRef, onError]);\n\n // Ready event\n useEffect(() => {\n const ele = innerRef;\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onReady) ele?.removeEventListener('error', onReady);\n };\n }, [innerRef, onReady]);\n\n useEffect(() => {\n if (innerRef) {\n innerRef.errorTransformer = errorTransformer;\n }\n }, [innerRef, errorTransformer]);\n\n useEffect(() => {\n if (innerRef && logger) {\n innerRef.logger = logger;\n }\n }, [innerRef, logger]);\n\n const { form: stringifiedForm, client: stringifiedClient } = useMemo(\n () => ({\n form: JSON.stringify(form || {}),\n client: JSON.stringify(client || {}),\n }),\n [form, client],\n );\n\n return (\n /**\n * in order to avoid redundant remounting of the WC, we are wrapping it with a form element\n * this workaround is done in order to support webauthn passkeys\n * it can be removed once this issue will be solved\n * https://bugs.chromium.org/p/chromium/issues/detail?id=1404106#c2\n */\n\t<form>\n\t\t<Suspense fallback={null}>\n\t\t\t<DescopeWC\n projectId={projectId}\n flowId={flowId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n innerRef={setInnerRef}\n tenant={tenant}\n theme={theme}\n locale={locale}\n debug={debug}\n form={stringifiedForm}\n client={stringifiedClient}\n telemetryKey={telemetryKey}\n redirectUrl={redirectUrl}\n autoFocus={autoFocus}\n validateOnBlur={validateOnBlur}\n storeLastAuthenticatedUser={storeLastAuthenticatedUser}\n keepLastAuthenticatedUserAfterLogout={\n keepLastAuthenticatedUserAfterLogout\n }\n />\n\t\t</Suspense>\n\t</form>\n );\n },\n);\n\nexport default Descope;\n","import React from 'react';\nimport { DefaultFlowProps } from '../types';\nimport Descope from './Descope';\n\nexport const SignInFlow = (props: DefaultFlowProps) => (\n\t<Descope {...props} flowId=\"sign-in\" />\n);\n\nexport const SignUpFlow = (props: DefaultFlowProps) => (\n\t<Descope {...props} flowId=\"sign-up\" />\n);\n\nexport const SignUpOrInFlow = (props: DefaultFlowProps) => (\n\t<Descope {...props} flowId=\"sign-up-or-in\" />\n);\n","import React, {\n lazy,\n Suspense,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport Context from '../hooks/Context';\nimport { UserManagementProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst UserManagementWC = lazy(async () => {\n await import('@descope/user-management-widget');\n\n return {\n default: ({\n projectId,\n baseUrl,\n baseStaticUrl,\n innerRef,\n tenant,\n widgetId,\n theme,\n debug,\n }) => (\n\t<descope-user-management-widget\n project-id={projectId}\n widget-id={widgetId}\n base-url={baseUrl}\n base-static-url={baseStaticUrl}\n theme={theme}\n tenant={tenant}\n debug={debug}\n ref={innerRef}\n />\n ),\n };\n});\n\nconst UserManagement = React.forwardRef<HTMLElement, UserManagementProps>(\n ({ logger, tenant, theme, debug, widgetId }, ref) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl } = React.useContext(Context);\n\n useEffect(() => {\n if (innerRef && logger) {\n innerRef.logger = logger;\n }\n }, [innerRef, logger]);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<UserManagementWC\n projectId={projectId}\n widgetId={widgetId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n innerRef={setInnerRef}\n tenant={tenant}\n theme={theme}\n debug={debug}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default UserManagement;\n","import React, {\n lazy,\n Suspense,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport Context from '../hooks/Context';\nimport { RoleManagementProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst RoleManagementWC = lazy(async () => {\n await import('@descope/role-management-widget');\n\n return {\n default: ({\n projectId,\n baseUrl,\n baseStaticUrl,\n innerRef,\n tenant,\n widgetId,\n theme,\n debug,\n }) => (\n\t<descope-role-management-widget\n project-id={projectId}\n widget-id={widgetId}\n base-url={baseUrl}\n base-static-url={baseStaticUrl}\n theme={theme}\n tenant={tenant}\n debug={debug}\n ref={innerRef}\n />\n ),\n };\n});\n\nconst RoleManagement = React.forwardRef<HTMLElement, RoleManagementProps>(\n ({ logger, tenant, theme, debug, widgetId }, ref) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl } = React.useContext(Context);\n\n useEffect(() => {\n if (innerRef && logger) {\n innerRef.logger = logger;\n }\n }, [innerRef, logger]);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<RoleManagementWC\n projectId={projectId}\n widgetId={widgetId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n innerRef={setInnerRef}\n tenant={tenant}\n theme={theme}\n debug={debug}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default RoleManagement;\n","import React, {\n lazy,\n Suspense,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport Context from '../hooks/Context';\nimport { AccessKeyManagementProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst AccessKeyManagementWC = lazy(async () => {\n await import('@descope/access-key-management-widget');\n\n return {\n default: ({\n projectId,\n baseUrl,\n baseStaticUrl,\n innerRef,\n tenant,\n widgetId,\n theme,\n debug,\n }) => (\n\t<descope-access-key-management-widget\n project-id={projectId}\n widget-id={widgetId}\n base-url={baseUrl}\n base-static-url={baseStaticUrl}\n theme={theme}\n tenant={tenant}\n debug={debug}\n ref={innerRef}\n />\n ),\n };\n});\n\nconst AccessKeyManagement = React.forwardRef<\n HTMLElement,\n AccessKeyManagementProps\n>(({ logger, tenant, theme, debug, widgetId }, ref) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl } = React.useContext(Context);\n\n useEffect(() => {\n if (innerRef && logger) {\n innerRef.logger = logger;\n }\n }, [innerRef, logger]);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<AccessKeyManagementWC\n projectId={projectId}\n widgetId={widgetId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n innerRef={setInnerRef}\n tenant={tenant}\n theme={theme}\n debug={debug}\n />\n\t</Suspense>\n );\n});\n\nexport default AccessKeyManagement;\n","import React, {\n lazy,\n Suspense,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport Context from '../hooks/Context';\nimport { AuditManagementProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst AuditManagementWC = lazy(async () => {\n await import('@descope/audit-management-widget');\n\n return {\n default: ({\n projectId,\n baseUrl,\n baseStaticUrl,\n innerRef,\n tenant,\n widgetId,\n theme,\n debug,\n }) => (\n\t<descope-audit-management-widget\n project-id={projectId}\n widget-id={widgetId}\n base-url={baseUrl}\n base-static-url={baseStaticUrl}\n theme={theme}\n tenant={tenant}\n debug={debug}\n ref={innerRef}\n />\n ),\n };\n});\n\nconst AuditManagement = React.forwardRef<HTMLElement, AuditManagementProps>(\n ({ logger, tenant, theme, debug, widgetId }, ref) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl } = React.useContext(Context);\n\n useEffect(() => {\n if (innerRef && logger) {\n innerRef.logger = logger;\n }\n }, [innerRef, logger]);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<AuditManagementWC\n projectId={projectId}\n widgetId={widgetId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n innerRef={setInnerRef}\n tenant={tenant}\n theme={theme}\n debug={debug}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default AuditManagement;\n","import React, {\n lazy,\n Suspense,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport Context from '../hooks/Context';\nimport { UserProfileProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst UserProfileWC = lazy(async () => {\n await import('@descope/user-profile-widget');\n\n return {\n default: ({\n projectId,\n baseUrl,\n baseStaticUrl,\n innerRef,\n widgetId,\n theme,\n debug,\n }) => (\n\t<descope-user-profile-widget\n project-id={projectId}\n widget-id={widgetId}\n base-url={baseUrl}\n base-static-url={baseStaticUrl}\n theme={theme}\n debug={debug}\n ref={innerRef}\n />\n ),\n };\n});\n\nconst UserProfile = React.forwardRef<HTMLElement, UserProfileProps>(\n ({ logger, theme, debug, widgetId, onLogout }, ref) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl } = React.useContext(Context);\n\n useEffect(() => {\n if (innerRef && logger) {\n innerRef.logger = logger;\n }\n }, [innerRef, logger]);\n\n useEffect(() => {\n if (innerRef && onLogout) {\n innerRef.addEventListener('logout', onLogout);\n return () => innerRef.removeEventListener('logout', onLogout);\n }\n return undefined;\n }, [innerRef, onLogout]);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<UserProfileWC\n projectId={projectId}\n widgetId={widgetId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n innerRef={setInnerRef}\n theme={theme}\n debug={debug}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default UserProfile;\n","import { useContext } from 'react';\nimport Context from './Context';\n\nexport default () => {\n const ctx = useContext(Context);\n if (!ctx) {\n throw Error(\n `You can only use this hook in the context of <AuthProvider />`,\n );\n }\n\n return ctx;\n};\n","import { useMemo } from 'react';\nimport { Sdk } from '../types';\nimport useContext from './useContext';\nimport { createTempSdk } from '../sdk';\n\nconst generateErrorMsg = (entryType: string) =>\n `You can only use this ${entryType} after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`;\n\n// handler which throw an error for every SDK function\nconst proxyThrowHandler = {\n // eslint-disable-next-line prefer-arrow/prefer-arrow-functions\n get(target: Record<string, any>, key: string) {\n if (typeof target[key] === 'object' && target[key] !== null) {\n return new Proxy(target[key], proxyThrowHandler);\n }\n\n if (typeof target[key] === 'function') {\n return () => {\n throw Error(generateErrorMsg('function'));\n };\n }\n\n throw Error(generateErrorMsg('attribute'));\n },\n};\n\nconst useDescope = (): Sdk => {\n const { sdk } = useContext();\n\n return useMemo(() => {\n if (!sdk) {\n // In case the SDK is not initialized, we want to throw an error when the SDK functions are called\n return new Proxy(createTempSdk(), proxyThrowHandler) as Sdk;\n }\n\n return sdk;\n }, [sdk]);\n};\n\nexport default useDescope;\n","import { useEffect, useMemo, useRef } from 'react';\nimport useContext from './useContext';\n\nconst useSession = () => {\n const { session, isSessionLoading, fetchSession, isSessionFetched } =\n useContext();\n\n // when session should be received, we want the return value of \"isSessionLoading\" to be true starting from the first call\n // (and not only when receiving an update from the context)\n const isLoading = useRef(isSessionLoading);\n\n // we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n useMemo(() => {\n isLoading.current = isSessionLoading;\n }, [isSessionLoading]);\n\n const shouldFetchSession = !session && !isSessionLoading;\n\n // we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n useMemo(() => {\n if (shouldFetchSession && !isSessionFetched) {\n isLoading.current = true;\n }\n }, [isSessionFetched]);\n\n // Fetch session if it's not already fetched\n // We want this to happen only once, so the dependency array should not contain shouldFetchSession\n useEffect(() => {\n if (shouldFetchSession) {\n fetchSession();\n }\n }, [fetchSession]);\n return {\n isSessionLoading: isLoading.current,\n sessionToken: session,\n isAuthenticated: !!session,\n };\n};\n\nexport default useSession;\n","import { useEffect, useMemo, useRef, useState } from 'react';\nimport useContext from './useContext';\n\nconst useUser = () => {\n const { user, fetchUser, isUserLoading, session } = useContext();\n const [isInit, setIsInit] = useState(false); // we want to get the user only in the first time we got a session\n\n // when session should be received, we want the return value of \"isUserLoading\" to be true starting from the first call\n // (and not only when receiving an update from the context)\n const isLoading = useRef(isUserLoading);\n\n const shouldFetchUser = useMemo(\n () => !user && !isUserLoading && session && !isInit,\n [fetchUser, session, isInit],\n );\n\n // we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n useMemo(() => {\n isLoading.current = isUserLoading;\n }, [isUserLoading]);\n\n // we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n useMemo(() => {\n if (shouldFetchUser) {\n isLoading.current = true;\n }\n }, [shouldFetchUser]);\n\n useEffect(() => {\n if (shouldFetchUser) {\n setIsInit(true);\n fetchUser();\n }\n }, [shouldFetchUser]);\n\n return { isUserLoading: isLoading.current, user };\n};\n\nexport default useUser;\n"],"names":["Context","React","createContext","undefined","withValidation","fn","args","Error","wrapInTry","res","err","console","error","baseHeaders","IS_BROWSER","window","globalSdk","createSdkWrapper","config","sdk","createSdk","Object","assign","persistTokens","autoRefresh","createTempSdk","projectId","storeLastAuthenticatedUser","getSessionToken","warn","getRefreshToken","isSessionTokenExpired","token","isJwtExpired","isRefreshTokenExpired","getJwtPermissions","tenant","getJwtRoles","refresh","AuthProvider","baseUrl","baseStaticUrl","sessionTokenViaCookie","keepLastAuthenticatedUserAfterLogout","children","user","setUser","useState","session","setSession","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","useMemo","useSdk","useEffect","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","isSessionFetched","useRef","fetchSession","useCallback","current","then","fetchUser","me","value","createElement","Provider","DescopeWC","lazy","async","import","default","sdkConfigOverrides","hooks","beforeRequest","httpClient","_","flowId","innerRef","theme","locale","debug","redirectUrl","client","form","autoFocus","validateOnBlur","ref","Descope","forwardRef","onSuccess","onError","onReady","logger","telemetryKey","errorTransformer","setInnerRef","useImperativeHandle","useContext","handleSuccess","e","afterRequest","Response","JSON","stringify","detail","ele","addEventListener","removeEventListener","stringifiedForm","stringifiedClient","Suspense","fallback","SignInFlow","props","SignUpFlow","SignUpOrInFlow","UserManagementWC","widgetId","UserManagement","RoleManagementWC","RoleManagement","AccessKeyManagementWC","AccessKeyManagement","AuditManagementWC","AuditManagement","UserProfileWC","UserProfile","onLogout","ctx","generateErrorMsg","entryType","proxyThrowHandler","get","target","key","Proxy","useDescope","useSession","isLoading","shouldFetchSession","sessionToken","isAuthenticated","useUser","isInit","setIsInit","shouldFetchUser"],"mappings":"8NAGA,MAAMA,EAAUC,EAAMC,mBAAwBC,GCEjCC,EACeC,GAC1B,IAAIC,KACF,IAAKD,EACH,MAAME,MACJ,0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