@descope/react-sdk 3.4.3 → 3.4.4
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.
- package/dist/cjs/components/AccessKeyManagement.js.map +1 -1
- package/dist/cjs/components/ApplicationsPortal.js.map +1 -1
- package/dist/cjs/components/AuditManagement.js.map +1 -1
- package/dist/cjs/components/AuthProvider/AuthProvider.js.map +1 -1
- package/dist/cjs/components/AuthProvider/useSdk.js.map +1 -1
- package/dist/cjs/components/DefaultFlows.js.map +1 -1
- package/dist/cjs/components/Descope.js.map +1 -1
- package/dist/cjs/components/OutboundApplications.js.map +1 -1
- package/dist/cjs/components/RoleManagement.js.map +1 -1
- package/dist/cjs/components/TenantProfile.js.map +1 -1
- package/dist/cjs/components/UserManagement.js.map +1 -1
- package/dist/cjs/components/UserProfile.js.map +1 -1
- package/dist/cjs/components/withPropsMapping/index.js.map +1 -1
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/hooks/Context.js.map +1 -1
- package/dist/cjs/hooks/useContext.js.map +1 -1
- package/dist/cjs/hooks/useDescope.js.map +1 -1
- package/dist/cjs/hooks/useSession.js.map +1 -1
- package/dist/cjs/hooks/useUser.js.map +1 -1
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/components/AccessKeyManagement.js.map +1 -1
- package/dist/esm/components/ApplicationsPortal.js.map +1 -1
- package/dist/esm/components/AuditManagement.js.map +1 -1
- package/dist/esm/components/AuthProvider/AuthProvider.js.map +1 -1
- package/dist/esm/components/DefaultFlows.js.map +1 -1
- package/dist/esm/components/Descope.js.map +1 -1
- package/dist/esm/components/OutboundApplications.js.map +1 -1
- package/dist/esm/components/RoleManagement.js.map +1 -1
- package/dist/esm/components/TenantProfile.js.map +1 -1
- package/dist/esm/components/UserManagement.js.map +1 -1
- package/dist/esm/components/UserProfile.js.map +1 -1
- package/dist/esm/components/withPropsMapping/index.js +1 -1
- package/dist/esm/components/withPropsMapping/index.js.map +1 -1
- package/dist/esm/components/withPropsMapping/utils.js.map +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/hooks/Context.js.map +1 -1
- package/dist/esm/hooks/useDescope.js.map +1 -1
- package/dist/esm/hooks/useSession.js.map +1 -1
- package/dist/esm/hooks/useUser.js.map +1 -1
- package/dist/esm/sdk.js.map +1 -1
- package/dist/esm/utils.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthProvider.js","sources":["../../../../src/components/AuthProvider/AuthProvider.tsx"],"sourcesContent":["import React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport {\n CookieConfig,\n OidcConfig,\n AutoRefreshConfig,\n} from '@descope/web-js-sdk';\nimport { Claims } from '@descope/core-js-sdk';\nimport { CustomStorage } from '@descope/web-component';\nimport Context from '../../hooks/Context';\nimport { IContext, User } from '../../types';\nimport { isDescopeBridge, withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ntype Hooks = Parameters<typeof useSdk>[0]['hooks'];\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 // allows to override the base URL that is used to fetch external script files\n baseCdnUrl?: string;\n // Default is true. If true, tokens will be stored on local storage and can accessed with getToken function\n persistTokens?: boolean;\n // Default is true. If true, the SDK will automatically refresh the session token when it is about to expire.\n // Pass `{ customActivityTracking: true }` to skip refresh for idle users — you must call `sdk.markUserActive()` to signal activity.\n autoRefresh?: AutoRefreshConfig;\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?: CookieConfig;\n // If true, refresh token will be stored on cookie. Otherwise, the refresh token will be\n // stored on local storage and can be accessed with getRefreshToken function\n // Use this option if you need server-side access to the refresh token (e.g., in Next.js middleware)\n // to enable refreshing sessions on the server before they expire\n refreshTokenViaCookie?: CookieConfig;\n hooks?: Hooks;\n // If truthy he SDK refresh and logout functions will use the OIDC client\n // Accepts boolean or OIDC configuration\n oidcConfig?: OidcConfig;\n // Default is true. 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 // Use this option if the authentication is done via cookie, and configured with a different name\n // Currently, this is done using Descope Flows\n refreshCookieName?: string;\n // Function to get external token, for seamless migration from external system\n getExternalToken?: () => Promise<string>;\n // Custom storage object for authentication related data\n customStorage?: CustomStorage;\n children?: React.ReactNode;\n}\n\nconst AuthProvider: FC<IAuthProviderProps> = ({\n projectId,\n baseUrl = '',\n baseStaticUrl = '',\n baseCdnUrl = '',\n sessionTokenViaCookie = false,\n refreshTokenViaCookie = false,\n hooks = undefined,\n persistTokens = true,\n autoRefresh = true,\n oidcConfig = undefined,\n storeLastAuthenticatedUser = true,\n keepLastAuthenticatedUserAfterLogout = false,\n refreshCookieName = '',\n getExternalToken = undefined,\n customStorage = undefined,\n children = undefined,\n}) => {\n const [user, setUser] = useState<User>();\n const [session, setSession] = useState<string>();\n const [claims, setClaims] = useState<Claims>();\n const [isAuthenticated, setIsAuthenticated] = useState(false);\n\n const [isUserLoading, setIsUserLoading] = useState(false);\n const [isSessionLoading, setIsSessionLoading] = useState(false);\n\n // if oidc config is enabled, we attempt to finish the login, so we start as loading\n const [isOidcLoading, setIsOidcLoading] = useState(!!oidcConfig);\n // flips once when the first session fetch settles - unlike isSessionLoading, this change\n // can't be lost if React batches the loading true/false updates into a single render\n const [isSessionFetchCompleted, setIsSessionFetchCompleted] = useState(false);\n // same as isSessionFetchCompleted, for the user fetch\n const [isUserFetchCompleted, setIsUserFetchCompleted] = useState(false);\n const isOidcFinishedLogin = useRef(false);\n\n const sdk = useSdk({\n projectId,\n baseUrl,\n persistTokens,\n autoRefresh,\n sessionTokenViaCookie,\n refreshTokenViaCookie,\n hooks,\n oidcConfig,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n getExternalToken,\n customStorage,\n });\n\n useEffect(() => {\n if (sdk) {\n const unsubscribeSessionToken = sdk.onSessionTokenChange(setSession);\n const unsubscribeUser = sdk.onUserChange(setUser);\n const unsubscribeIsAuthenticated =\n sdk.onIsAuthenticatedChange(setIsAuthenticated);\n const unsubscribeClaims = sdk.onClaimsChange(setClaims);\n\n return () => {\n unsubscribeSessionToken();\n unsubscribeUser();\n unsubscribeIsAuthenticated();\n unsubscribeClaims();\n };\n }\n return undefined;\n }, [sdk]);\n\n const isSessionFetchStarted = useRef(false);\n const isUserFetchStarted = useRef(false);\n\n // if oidc config is enabled, and we have oidc params in the url\n // we will finish the login (this should run only once)\n useEffect(() => {\n if (sdk && oidcConfig && !isOidcFinishedLogin.current) {\n isOidcFinishedLogin.current = true;\n sdk.oidc.finishLoginIfNeed().finally(() => {\n setIsOidcLoading(false);\n // finishing the OIDC login already fetched the session, so mark the fetch as both\n // started (fetchSession won't run again) and completed, even though it never ran\n isSessionFetchStarted.current = true;\n setIsSessionFetchCompleted(true);\n });\n }\n }, []);\n\n const fetchSession = useCallback(() => {\n // Don't load the session in native flows, though we'd usually not get here at all from useSession in this case\n if (isDescopeBridge()) return;\n\n // We want that the session will fetched only once\n if (isSessionFetchStarted.current) return;\n isSessionFetchStarted.current = true;\n\n setIsSessionLoading(true);\n const stopSessionLoading = () => {\n setIsSessionLoading(false);\n setIsSessionFetchCompleted(true);\n };\n // Clear the loading state on both fulfilment and rejection. A rejected\n // refresh (e.g. a transient network failure on the proactive refresh) must\n // still clear `isSessionLoading` - `isSessionFetchStarted` is already set so\n // `fetchSession` never re-runs, and consumers (e.g. useSession) would\n // otherwise hang on \"loading\" forever despite a valid session.\n withValidation(sdk?.refresh)(undefined, true).then(\n stopSessionLoading,\n stopSessionLoading,\n );\n }, [sdk]);\n\n const fetchUser = useCallback(() => {\n // We want that the user will fetched only once\n if (isUserFetchStarted.current) return;\n isUserFetchStarted.current = true;\n\n setIsUserLoading(true);\n // Clear the loading state on both fulfilment and rejection so a failed\n // `me()` doesn't leave `isUserLoading` stuck `true` (see fetchSession).\n const stopUserLoading = () => {\n setIsUserLoading(false);\n setIsUserFetchCompleted(true);\n };\n withValidation(sdk.me)().then(stopUserLoading, stopUserLoading);\n }, [sdk]);\n\n const value = useMemo<IContext>(\n () => ({\n fetchUser,\n user,\n isUserLoading,\n isUserFetchStarted: isUserFetchStarted.current,\n isUserFetchCompleted,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetchStarted: isSessionFetchStarted.current,\n isSessionFetchCompleted,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n sessionTokenViaCookie,\n refreshTokenViaCookie,\n customStorage,\n setUser,\n setSession,\n setIsAuthenticated,\n claims,\n sdk,\n }),\n [\n fetchUser,\n user,\n isUserLoading,\n isUserFetchStarted.current,\n isUserFetchCompleted,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetchStarted.current,\n isSessionFetchCompleted,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n // stringified so inline object literals don't create a new context value on every render\n JSON.stringify(sessionTokenViaCookie),\n JSON.stringify(refreshTokenViaCookie),\n customStorage,\n setUser,\n setSession,\n setIsAuthenticated,\n claims,\n sdk,\n ],\n );\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport default AuthProvider;\n"],"names":["AuthProvider","projectId","baseUrl","baseStaticUrl","baseCdnUrl","sessionTokenViaCookie","refreshTokenViaCookie","hooks","persistTokens","autoRefresh","oidcConfig","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","refreshCookieName","getExternalToken","customStorage","children","user","setUser","useState","session","setSession","claims","setClaims","isAuthenticated","setIsAuthenticated","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","isOidcLoading","setIsOidcLoading","isSessionFetchCompleted","setIsSessionFetchCompleted","isUserFetchCompleted","setIsUserFetchCompleted","isOidcFinishedLogin","useRef","sdk","useSdk","useEffect","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","unsubscribeIsAuthenticated","onIsAuthenticatedChange","unsubscribeClaims","onClaimsChange","isSessionFetchStarted","isUserFetchStarted","current","oidc","finishLoginIfNeed","finally","fetchSession","useCallback","isDescopeBridge","stopSessionLoading","withValidation","refresh","undefined","then","fetchUser","stopUserLoading","me","value","useMemo","JSON","stringify","React","createElement","Context","Provider"],"mappings":"mOA8DA,MAAMA,EAAuC,EAC3CC,YACAC,UAAU,GACVC,gBAAgB,GAChBC,aAAa,GACbC,yBAAwB,EACxBC,yBAAwB,EACxBC,QACAC,iBAAgB,EAChBC,eAAc,EACdC,aACAC,8BAA6B,EAC7BC,wCAAuC,EACvCC,oBAAoB,GACpBC,mBACAC,gBACAC,eAEA,MAAOC,EAAMC,GAAWC,KACjBC,EAASC,GAAcF,KACvBG,EAAQC,GAAaJ,KACrBK,EAAiBC,GAAsBN,GAAS,IAEhDO,EAAeC,GAAoBR,GAAS,IAC5CS,EAAkBC,GAAuBV,GAAS,IAGlDW,EAAeC,GAAoBZ,IAAWT,IAG9CsB,EAAyBC,GAA8Bd,GAAS,IAEhEe,EAAsBC,GAA2BhB,GAAS,GAC3DiB,EAAsBC,GAAO,GAE7BC,EAAMC,EAAO,CACjBtC,YACAC,UACAM,gBACAC,cACAJ,wBACAC,wBACAC,QACAG,aACAC,6BACAC,uCACAC,oBACAC,mBACAC,kBAGFyB,GAAU,KACR,GAAIF,EAAK,CACP,MAAMG,EAA0BH,EAAII,qBAAqBrB,GACnDsB,EAAkBL,EAAIM,aAAa1B,GACnC2B,EACJP,EAAIQ,wBAAwBrB,GACxBsB,EAAoBT,EAAIU,eAAezB,GAE7C,MAAO,KACLkB,IACAE,IACAE,IACAE,GAAmB,CAEtB,CACe,GACf,CAACT,IAEJ,MAAMW,EAAwBZ,GAAO,GAC/Ba,EAAqBb,GAAO,GAIlCG,GAAU,KACJF,GAAO5B,IAAe0B,EAAoBe,UAC5Cf,EAAoBe,SAAU,EAC9Bb,EAAIc,KAAKC,oBAAoBC,SAAQ,KACnCvB,GAAiB,GAGjBkB,EAAsBE,SAAU,EAChClB,GAA2B,EAAK,IAEnC,GACA,IAEH,MAAMsB,EAAeC,GAAY,KAE/B,GAAIC,IAAmB,OAGvB,GAAIR,EAAsBE,QAAS,OACnCF,EAAsBE,SAAU,EAEhCtB,GAAoB,GACpB,MAAM6B,EAAqB,KACzB7B,GAAoB,GACpBI,GAA2B,EAAK,EAOlC0B,EAAerB,eAAAA,EAAKsB,QAApBD,MAA6BE,GAAW,GAAMC,KAC5CJ,EACAA,EACD,GACA,CAACpB,IAEEyB,EAAYP,GAAY,KAE5B,GAAIN,EAAmBC,QAAS,OAChCD,EAAmBC,SAAU,EAE7BxB,GAAiB,GAGjB,MAAMqC,EAAkB,KACtBrC,GAAiB,GACjBQ,GAAwB,EAAK,EAE/BwB,EAAerB,EAAI2B,GAAnBN,GAAyBG,KAAKE,EAAiBA,EAAgB,GAC9D,CAAC1B,IAEE4B,EAAQC,GACZ,KAAO,CACLJ,YACA9C,OACAS,gBACAwB,mBAAoBA,EAAmBC,QACvCjB,uBACAqB,eACAnC,UACAI,kBACAI,mBACAE,gBACAmB,sBAAuBA,EAAsBE,QAC7CnB,0BACA/B,YACAC,UACAC,gBACAC,aACAO,6BACAC,uCACAC,oBACAR,wBACAC,wBACAS,gBACAG,UACAG,aACAI,qBACAH,SACAgB,SAEF,CACEyB,EACA9C,EACAS,EACAwB,EAAmBC,QACnBjB,EACAqB,EACAnC,EACAI,EACAI,EACAE,EACAmB,EAAsBE,QACtBnB,EACA/B,EACAC,EACAC,EACAC,EACAQ,EACAC,EAEAuD,KAAKC,UAAUhE,GACf+D,KAAKC,UAAU/D,GACfS,EACAG,EACAG,EACAI,EACAH,EACAgB,IAGJ,OAAOgC,EAAAC,cAACC,EAAQC,SAAQ,CAACP,MAAOA,GAAQlD,EAA4B"}
|
|
1
|
+
{"version":3,"file":"AuthProvider.js","sources":["../../../../src/components/AuthProvider/AuthProvider.tsx"],"sourcesContent":["import React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport {\n CookieConfig,\n OidcConfig,\n AutoRefreshConfig,\n} from '@descope/web-js-sdk';\nimport { Claims } from '@descope/core-js-sdk';\nimport { CustomStorage } from '@descope/web-component';\nimport Context from '../../hooks/Context';\nimport { IContext, User } from '../../types';\nimport { isDescopeBridge, withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ntype Hooks = Parameters<typeof useSdk>[0]['hooks'];\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 // allows to override the base URL that is used to fetch external script files\n baseCdnUrl?: string;\n // Default is true. If true, tokens will be stored on local storage and can accessed with getToken function\n persistTokens?: boolean;\n // Default is true. If true, the SDK will automatically refresh the session token when it is about to expire.\n // Pass `{ customActivityTracking: true }` to skip refresh for idle users — you must call `sdk.markUserActive()` to signal activity.\n autoRefresh?: AutoRefreshConfig;\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?: CookieConfig;\n // If true, refresh token will be stored on cookie. Otherwise, the refresh token will be\n // stored on local storage and can be accessed with getRefreshToken function\n // Use this option if you need server-side access to the refresh token (e.g., in Next.js middleware)\n // to enable refreshing sessions on the server before they expire\n refreshTokenViaCookie?: CookieConfig;\n hooks?: Hooks;\n // If truthy he SDK refresh and logout functions will use the OIDC client\n // Accepts boolean or OIDC configuration\n oidcConfig?: OidcConfig;\n // Default is true. 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 // Use this option if the authentication is done via cookie, and configured with a different name\n // Currently, this is done using Descope Flows\n refreshCookieName?: string;\n // Function to get external token, for seamless migration from external system\n getExternalToken?: () => Promise<string>;\n // Custom storage object for authentication related data\n customStorage?: CustomStorage;\n children?: React.ReactNode;\n}\n\nconst AuthProvider: FC<IAuthProviderProps> = ({\n projectId,\n baseUrl = '',\n baseStaticUrl = '',\n baseCdnUrl = '',\n sessionTokenViaCookie = false,\n refreshTokenViaCookie = false,\n hooks = undefined,\n persistTokens = true,\n autoRefresh = true,\n oidcConfig = undefined,\n storeLastAuthenticatedUser = true,\n keepLastAuthenticatedUserAfterLogout = false,\n refreshCookieName = '',\n getExternalToken = undefined,\n customStorage = undefined,\n children = undefined,\n}) => {\n const [user, setUser] = useState<User>();\n const [session, setSession] = useState<string>();\n const [claims, setClaims] = useState<Claims>();\n const [isAuthenticated, setIsAuthenticated] = useState(false);\n\n const [isUserLoading, setIsUserLoading] = useState(false);\n const [isSessionLoading, setIsSessionLoading] = useState(false);\n\n // if oidc config is enabled, we attempt to finish the login, so we start as loading\n const [isOidcLoading, setIsOidcLoading] = useState(!!oidcConfig);\n // flips once when the first session fetch settles - unlike isSessionLoading, this change\n // can't be lost if React batches the loading true/false updates into a single render\n const [isSessionFetchCompleted, setIsSessionFetchCompleted] = useState(false);\n // same as isSessionFetchCompleted, for the user fetch\n const [isUserFetchCompleted, setIsUserFetchCompleted] = useState(false);\n const isOidcFinishedLogin = useRef(false);\n\n const sdk = useSdk({\n projectId,\n baseUrl,\n persistTokens,\n autoRefresh,\n sessionTokenViaCookie,\n refreshTokenViaCookie,\n hooks,\n oidcConfig,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n getExternalToken,\n customStorage,\n });\n\n useEffect(() => {\n if (sdk) {\n const unsubscribeSessionToken = sdk.onSessionTokenChange(setSession);\n const unsubscribeUser = sdk.onUserChange(setUser);\n const unsubscribeIsAuthenticated =\n sdk.onIsAuthenticatedChange(setIsAuthenticated);\n const unsubscribeClaims = sdk.onClaimsChange(setClaims);\n\n return () => {\n unsubscribeSessionToken();\n unsubscribeUser();\n unsubscribeIsAuthenticated();\n unsubscribeClaims();\n };\n }\n return undefined;\n }, [sdk]);\n\n const isSessionFetchStarted = useRef(false);\n const isUserFetchStarted = useRef(false);\n\n // if oidc config is enabled, and we have oidc params in the url\n // we will finish the login (this should run only once)\n useEffect(() => {\n if (sdk && oidcConfig && !isOidcFinishedLogin.current) {\n isOidcFinishedLogin.current = true;\n sdk.oidc.finishLoginIfNeed().finally(() => {\n setIsOidcLoading(false);\n // finishing the OIDC login already fetched the session, so mark the fetch as both\n // started (fetchSession won't run again) and completed, even though it never ran\n isSessionFetchStarted.current = true;\n setIsSessionFetchCompleted(true);\n });\n }\n }, []);\n\n const fetchSession = useCallback(() => {\n // Don't load the session in native flows, though we'd usually not get here at all from useSession in this case\n if (isDescopeBridge()) return;\n\n // We want that the session will fetched only once\n if (isSessionFetchStarted.current) return;\n isSessionFetchStarted.current = true;\n\n setIsSessionLoading(true);\n const stopSessionLoading = () => {\n setIsSessionLoading(false);\n setIsSessionFetchCompleted(true);\n };\n // Clear the loading state on both fulfilment and rejection. A rejected\n // refresh (e.g. a transient network failure on the proactive refresh) must\n // still clear `isSessionLoading` - `isSessionFetchStarted` is already set so\n // `fetchSession` never re-runs, and consumers (e.g. useSession) would\n // otherwise hang on \"loading\" forever despite a valid session.\n withValidation(sdk?.refresh)(undefined, true).then(\n stopSessionLoading,\n stopSessionLoading,\n );\n }, [sdk]);\n\n const fetchUser = useCallback(() => {\n // We want that the user will fetched only once\n if (isUserFetchStarted.current) return;\n isUserFetchStarted.current = true;\n\n setIsUserLoading(true);\n // Clear the loading state on both fulfilment and rejection so a failed\n // `me()` doesn't leave `isUserLoading` stuck `true` (see fetchSession).\n const stopUserLoading = () => {\n setIsUserLoading(false);\n setIsUserFetchCompleted(true);\n };\n withValidation(sdk.me)().then(stopUserLoading, stopUserLoading);\n }, [sdk]);\n\n const value = useMemo<IContext>(\n () => ({\n fetchUser,\n user,\n isUserLoading,\n isUserFetchStarted: isUserFetchStarted.current,\n isUserFetchCompleted,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetchStarted: isSessionFetchStarted.current,\n isSessionFetchCompleted,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n sessionTokenViaCookie,\n refreshTokenViaCookie,\n customStorage,\n setUser,\n setSession,\n setIsAuthenticated,\n claims,\n sdk,\n }),\n [\n fetchUser,\n user,\n isUserLoading,\n isUserFetchStarted.current,\n isUserFetchCompleted,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetchStarted.current,\n isSessionFetchCompleted,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n // stringified so inline object literals don't create a new context value on every render\n JSON.stringify(sessionTokenViaCookie),\n JSON.stringify(refreshTokenViaCookie),\n customStorage,\n setUser,\n setSession,\n setIsAuthenticated,\n claims,\n sdk,\n ],\n );\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport default AuthProvider;\n"],"names":["AuthProvider","projectId","baseUrl","baseStaticUrl","baseCdnUrl","sessionTokenViaCookie","refreshTokenViaCookie","hooks","persistTokens","autoRefresh","oidcConfig","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","refreshCookieName","getExternalToken","customStorage","children","user","setUser","useState","session","setSession","claims","setClaims","isAuthenticated","setIsAuthenticated","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","isOidcLoading","setIsOidcLoading","isSessionFetchCompleted","setIsSessionFetchCompleted","isUserFetchCompleted","setIsUserFetchCompleted","isOidcFinishedLogin","useRef","sdk","useSdk","useEffect","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","unsubscribeIsAuthenticated","onIsAuthenticatedChange","unsubscribeClaims","onClaimsChange","isSessionFetchStarted","isUserFetchStarted","current","oidc","finishLoginIfNeed","finally","fetchSession","useCallback","isDescopeBridge","stopSessionLoading","withValidation","refresh","undefined","then","fetchUser","stopUserLoading","me","value","useMemo","JSON","stringify","React","createElement","Context","Provider"],"mappings":"mOA8DA,MAAMA,EAAuC,EAC3CC,YACAC,UAAU,GACVC,gBAAgB,GAChBC,aAAa,GACbC,yBAAwB,EACxBC,yBAAwB,EACxBC,QACAC,iBAAgB,EAChBC,eAAc,EACdC,aACAC,8BAA6B,EAC7BC,wCAAuC,EACvCC,oBAAoB,GACpBC,mBACAC,gBACAC,eAEA,MAAOC,EAAMC,GAAWC,KACjBC,EAASC,GAAcF,KACvBG,EAAQC,GAAaJ,KACrBK,EAAiBC,GAAsBN,GAAS,IAEhDO,EAAeC,GAAoBR,GAAS,IAC5CS,EAAkBC,GAAuBV,GAAS,IAGlDW,EAAeC,GAAoBZ,IAAWT,IAG9CsB,EAAyBC,GAA8Bd,GAAS,IAEhEe,EAAsBC,GAA2BhB,GAAS,GAC3DiB,EAAsBC,GAAO,GAE7BC,EAAMC,EAAO,CACjBtC,YACAC,UACAM,gBACAC,cACAJ,wBACAC,wBACAC,QACAG,aACAC,6BACAC,uCACAC,oBACAC,mBACAC,kBAGFyB,GAAU,KACR,GAAIF,EAAK,CACP,MAAMG,EAA0BH,EAAII,qBAAqBrB,GACnDsB,EAAkBL,EAAIM,aAAa1B,GACnC2B,EACJP,EAAIQ,wBAAwBrB,GACxBsB,EAAoBT,EAAIU,eAAezB,GAE7C,MAAO,KACLkB,IACAE,IACAE,IACAE,GAAmB,CAEvB,CACgB,GACf,CAACT,IAEJ,MAAMW,EAAwBZ,GAAO,GAC/Ba,EAAqBb,GAAO,GAIlCG,GAAU,KACJF,GAAO5B,IAAe0B,EAAoBe,UAC5Cf,EAAoBe,SAAU,EAC9Bb,EAAIc,KAAKC,oBAAoBC,SAAQ,KACnCvB,GAAiB,GAGjBkB,EAAsBE,SAAU,EAChClB,GAA2B,EAAK,IAEpC,GACC,IAEH,MAAMsB,EAAeC,GAAY,KAE/B,GAAIC,IAAmB,OAGvB,GAAIR,EAAsBE,QAAS,OACnCF,EAAsBE,SAAU,EAEhCtB,GAAoB,GACpB,MAAM6B,EAAqB,KACzB7B,GAAoB,GACpBI,GAA2B,EAAK,EAOlC0B,EAAerB,eAAAA,EAAKsB,QAApBD,MAA6BE,GAAW,GAAMC,KAC5CJ,EACAA,EACD,GACA,CAACpB,IAEEyB,EAAYP,GAAY,KAE5B,GAAIN,EAAmBC,QAAS,OAChCD,EAAmBC,SAAU,EAE7BxB,GAAiB,GAGjB,MAAMqC,EAAkB,KACtBrC,GAAiB,GACjBQ,GAAwB,EAAK,EAE/BwB,EAAerB,EAAI2B,GAAnBN,GAAyBG,KAAKE,EAAiBA,EAAgB,GAC9D,CAAC1B,IAEE4B,EAAQC,GACZ,KAAA,CACEJ,YACA9C,OACAS,gBACAwB,mBAAoBA,EAAmBC,QACvCjB,uBACAqB,eACAnC,UACAI,kBACAI,mBACAE,gBACAmB,sBAAuBA,EAAsBE,QAC7CnB,0BACA/B,YACAC,UACAC,gBACAC,aACAO,6BACAC,uCACAC,oBACAR,wBACAC,wBACAS,gBACAG,UACAG,aACAI,qBACAH,SACAgB,SAEF,CACEyB,EACA9C,EACAS,EACAwB,EAAmBC,QACnBjB,EACAqB,EACAnC,EACAI,EACAI,EACAE,EACAmB,EAAsBE,QACtBnB,EACA/B,EACAC,EACAC,EACAC,EACAQ,EACAC,EAEAuD,KAAKC,UAAUhE,GACf+D,KAAKC,UAAU/D,GACfS,EACAG,EACAG,EACAI,EACAH,EACAgB,IAGJ,OAAOgC,EAAAC,cAACC,EAAQC,SAAQ,CAACP,MAAOA,GAAQlD,EAA4B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultFlows.js","sources":["../../../src/components/DefaultFlows.tsx"],"sourcesContent":["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"],"names":["SignInFlow","props","React","Descope","Object","assign","flowId","SignUpFlow","SignUpOrInFlow"],"mappings":"uDAIaA,EAAcC,GAC1BC,gBAACC,EAAOC,OAAAC,OAAA,CAAA,EAAKJ,
|
|
1
|
+
{"version":3,"file":"DefaultFlows.js","sources":["../../../src/components/DefaultFlows.tsx"],"sourcesContent":["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"],"names":["SignInFlow","props","React","Descope","Object","assign","flowId","SignUpFlow","SignUpOrInFlow"],"mappings":"uDAIaA,EAAcC,GAC1BC,gBAACC,EAAOC,OAAAC,OAAA,CAAA,EAAKJ,EAAK,CAAEK,OAAO,aAGfC,EAAcN,GAC1BC,gBAACC,EAAOC,OAAAC,OAAA,CAAA,EAAKJ,EAAK,CAAEK,OAAO,aAGfE,EAAkBP,GAC9BC,gBAACC,EAAOC,OAAAC,OAAA,CAAA,EAAKJ,EAAK,CAAEK,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Descope.js","sources":["../../../src/components/Descope.tsx"],"sourcesContent":["/* eslint-disable react/prop-types */\nimport 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';\nimport withPropsMapping from './withPropsMapping';\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 updateDynamicHeader = (key: string, value: string) => {\n if (value) {\n baseHeaders[key] = value;\n } else {\n delete baseHeaders[key];\n }\n };\n\n const WebComponent: any =\n // `customElements` is undeclared (not just undefined) on the server, so it\n // has to be reached through `globalThis` - `customElements?.` alone throws\n // a ReferenceError and defeats the lazy loading above.\n globalThis.customElements?.get('descope-wc') ||\n (await import('@descope/web-component').then((module) => module.default));\n\n WebComponent.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: withPropsMapping(\n React.forwardRef<HTMLElement>(\n ({ 'external-request-id': externalRequestId, ...props }: any, ref) => {\n // update the dynamic headers with the external request ID if provided\n useMemo(() => {\n updateDynamicHeader('x-external-rid', externalRequestId);\n }, [externalRequestId]);\n\n return <descope-wc ref={ref} {...props} />;\n },\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 nonce,\n locale,\n debug,\n client,\n form,\n telemetryKey,\n redirectUrl,\n autoFocus,\n validateOnBlur,\n restartOnError,\n sendSessionToken,\n errorTransformer,\n styleId,\n onScreenUpdate,\n dismissScreenErrorOnInput,\n outboundAppId,\n outboundAppScopes,\n popupOrigin,\n children,\n externalRequestId,\n themeOverride,\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 baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n customStorage,\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 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 baseCdnUrl={baseCdnUrl}\n ref={setInnerRef}\n telemetryKey={telemetryKey}\n redirectUrl={redirectUrl}\n autoFocus={autoFocus}\n styleId={styleId}\n validateOnBlur={validateOnBlur}\n restartOnError={restartOnError}\n keepLastAuthenticatedUserAfterLogout={\n keepLastAuthenticatedUserAfterLogout\n }\n tenant={tenant}\n externalRequestId={externalRequestId}\n customStorage={customStorage}\n themeOverride={themeOverride}\n {...{\n // attributes\n 'theme.attr': theme,\n 'nonce.attr': nonce,\n 'locale.attr': locale,\n 'form.attr': form,\n 'client.attr': client,\n 'debug.attr': debug,\n 'outbound-app-id.attr': outboundAppId,\n 'outbound-app-scopes.attr': outboundAppScopes,\n 'popup-origin.attr': popupOrigin,\n 'store-last-authenticated-user.attr': storeLastAuthenticatedUser,\n 'send-session-token.attr': sendSessionToken,\n 'refreshCookieName.attr': refreshCookieName,\n 'dismiss-screen-error-on-input.attr': dismissScreenErrorOnInput,\n // props\n 'errorTransformer.prop': errorTransformer,\n 'logger.prop': logger,\n 'onScreenUpdate.prop': onScreenUpdate,\n 'customStorage.prop': customStorage,\n }}\n >\n\t\t\t\t{children}\n\t\t\t</DescopeWC>\n\t\t</Suspense>\n\t</form>\n );\n },\n);\n\nexport default Descope;\n"],"names":["DescopeWC","lazy","async","_a","globalThis","customElements","get","import","then","module","default","sdkConfigOverrides","baseHeaders","persistTokens","hooks","beforeRequest","getGlobalSdk","httpClient","_","withPropsMapping","React","forwardRef","ref","externalRequestId","props","__rest","useMemo","key","value","Descope","flowId","onSuccess","onError","onReady","logger","tenant","theme","nonce","locale","debug","client","form","telemetryKey","redirectUrl","autoFocus","validateOnBlur","restartOnError","sendSessionToken","errorTransformer","styleId","onScreenUpdate","dismissScreenErrorOnInput","outboundAppId","outboundAppScopes","popupOrigin","children","themeOverride","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","refreshCookieName","customStorage","sdk","useContext","Context","handleSuccess","useCallback","e","afterRequest","Response","JSON","stringify","detail","useEffect","ele","addEventListener","removeEventListener","createElement","Suspense","fallback"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"Descope.js","sources":["../../../src/components/Descope.tsx"],"sourcesContent":["/* eslint-disable react/prop-types */\nimport 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';\nimport withPropsMapping from './withPropsMapping';\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 updateDynamicHeader = (key: string, value: string) => {\n if (value) {\n baseHeaders[key] = value;\n } else {\n delete baseHeaders[key];\n }\n };\n\n const WebComponent: any =\n // `customElements` is undeclared (not just undefined) on the server, so it\n // has to be reached through `globalThis` - `customElements?.` alone throws\n // a ReferenceError and defeats the lazy loading above.\n globalThis.customElements?.get('descope-wc') ||\n (await import('@descope/web-component').then((module) => module.default));\n\n WebComponent.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: withPropsMapping(\n React.forwardRef<HTMLElement>(\n ({ 'external-request-id': externalRequestId, ...props }: any, ref) => {\n // update the dynamic headers with the external request ID if provided\n useMemo(() => {\n updateDynamicHeader('x-external-rid', externalRequestId);\n }, [externalRequestId]);\n\n return <descope-wc ref={ref} {...props} />;\n },\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 nonce,\n locale,\n debug,\n client,\n form,\n telemetryKey,\n redirectUrl,\n autoFocus,\n validateOnBlur,\n restartOnError,\n sendSessionToken,\n errorTransformer,\n styleId,\n onScreenUpdate,\n dismissScreenErrorOnInput,\n outboundAppId,\n outboundAppScopes,\n popupOrigin,\n children,\n externalRequestId,\n themeOverride,\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 baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n customStorage,\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 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 baseCdnUrl={baseCdnUrl}\n ref={setInnerRef}\n telemetryKey={telemetryKey}\n redirectUrl={redirectUrl}\n autoFocus={autoFocus}\n styleId={styleId}\n validateOnBlur={validateOnBlur}\n restartOnError={restartOnError}\n keepLastAuthenticatedUserAfterLogout={\n keepLastAuthenticatedUserAfterLogout\n }\n tenant={tenant}\n externalRequestId={externalRequestId}\n customStorage={customStorage}\n themeOverride={themeOverride}\n {...{\n // attributes\n 'theme.attr': theme,\n 'nonce.attr': nonce,\n 'locale.attr': locale,\n 'form.attr': form,\n 'client.attr': client,\n 'debug.attr': debug,\n 'outbound-app-id.attr': outboundAppId,\n 'outbound-app-scopes.attr': outboundAppScopes,\n 'popup-origin.attr': popupOrigin,\n 'store-last-authenticated-user.attr': storeLastAuthenticatedUser,\n 'send-session-token.attr': sendSessionToken,\n 'refreshCookieName.attr': refreshCookieName,\n 'dismiss-screen-error-on-input.attr': dismissScreenErrorOnInput,\n // props\n 'errorTransformer.prop': errorTransformer,\n 'logger.prop': logger,\n 'onScreenUpdate.prop': onScreenUpdate,\n 'customStorage.prop': customStorage,\n }}\n >\n\t\t\t\t{children}\n\t\t\t</DescopeWC>\n\t\t</Suspense>\n\t</form>\n );\n },\n);\n\nexport default Descope;\n"],"names":["DescopeWC","lazy","async","_a","globalThis","customElements","get","import","then","module","default","sdkConfigOverrides","baseHeaders","persistTokens","hooks","beforeRequest","getGlobalSdk","httpClient","_","withPropsMapping","React","forwardRef","ref","externalRequestId","props","__rest","useMemo","key","value","Descope","flowId","onSuccess","onError","onReady","logger","tenant","theme","nonce","locale","debug","client","form","telemetryKey","redirectUrl","autoFocus","validateOnBlur","restartOnError","sendSessionToken","errorTransformer","styleId","onScreenUpdate","dismissScreenErrorOnInput","outboundAppId","outboundAppScopes","popupOrigin","children","themeOverride","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","refreshCookieName","customStorage","sdk","useContext","Context","handleSuccess","useCallback","e","afterRequest","Response","JSON","stringify","detail","useEffect","ele","addEventListener","removeEventListener","createElement","Suspense","fallback"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OutboundApplications.js","sources":["../../../src/components/OutboundApplications.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useImperativeHandle,\n useState,\n useEffect,\n} from 'react';\nimport Context from '../hooks/Context';\nimport { OutboundApplicationsProps } from '../types';\nimport withPropsMapping from './withPropsMapping';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst OutboundApplicationsWC = lazy(async () => {\n await import('@descope/outbound-applications-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-outbound-applications-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst OutboundApplications = React.forwardRef<\n HTMLElement,\n OutboundApplicationsProps\n>(\n (\n { logger, theme, locale, debug, widgetId, styleId, onReady, client, form },\n ref,\n ) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl, refreshCookieName } =\n React.useContext(Context);\n\n useEffect(() => {\n const ele = innerRef;\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onReady) ele?.removeEventListener('ready', onReady);\n };\n }, [innerRef, onReady]);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<OutboundApplicationsWC\n ref={setInnerRef}\n projectId={projectId}\n widgetId={widgetId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n {...{\n // attributes\n 'theme.attr': theme,\n 'locale.attr': locale,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n 'refreshCookieName.attr': refreshCookieName,\n 'client.attr': client,\n 'form.attr': form,\n // props\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default OutboundApplications;\n"],"names":["OutboundApplicationsWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","OutboundApplications","logger","theme","locale","debug","widgetId","styleId","onReady","client","form","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","refreshCookieName","useContext","Context","useEffect","ele","addEventListener","removeEventListener","Suspense","fallback"],"mappings":"kLAYA,MAAMA,EAAyBC,GAAKC,gBAC5BC,OAAO,yCAEN,CACLC,QAASC,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,
|
|
1
|
+
{"version":3,"file":"OutboundApplications.js","sources":["../../../src/components/OutboundApplications.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useImperativeHandle,\n useState,\n useEffect,\n} from 'react';\nimport Context from '../hooks/Context';\nimport { OutboundApplicationsProps } from '../types';\nimport withPropsMapping from './withPropsMapping';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst OutboundApplicationsWC = lazy(async () => {\n await import('@descope/outbound-applications-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-outbound-applications-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst OutboundApplications = React.forwardRef<\n HTMLElement,\n OutboundApplicationsProps\n>(\n (\n { logger, theme, locale, debug, widgetId, styleId, onReady, client, form },\n ref,\n ) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl, refreshCookieName } =\n React.useContext(Context);\n\n useEffect(() => {\n const ele = innerRef;\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onReady) ele?.removeEventListener('ready', onReady);\n };\n }, [innerRef, onReady]);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<OutboundApplicationsWC\n ref={setInnerRef}\n projectId={projectId}\n widgetId={widgetId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n {...{\n // attributes\n 'theme.attr': theme,\n 'locale.attr': locale,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n 'refreshCookieName.attr': refreshCookieName,\n 'client.attr': client,\n 'form.attr': form,\n // props\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default OutboundApplications;\n"],"names":["OutboundApplicationsWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","OutboundApplications","logger","theme","locale","debug","widgetId","styleId","onReady","client","form","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","refreshCookieName","useContext","Context","useEffect","ele","addEventListener","removeEventListener","Suspense","fallback"],"mappings":"kLAYA,MAAMA,EAAyBC,GAAKC,gBAC5BC,OAAO,yCAEN,CACLC,QAASC,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAAI,cAAA,uCAAAC,OAAAC,OAAA,CAAsCH,IAAKA,GAASD,WAM/CK,EAAuBP,EAAMC,YAIjC,EACIO,SAAQC,QAAOC,SAAQC,QAAOC,WAAUC,UAASC,UAASC,SAAQC,QACpEb,KAEA,MAAOc,EAAUC,GAAeC,EAAS,MAEzCC,EAAoBjB,GAAK,IAAMc,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,EAAUC,kBAAEA,GACrDzB,EAAM0B,WAAWC,GAWnB,OATAC,GAAU,KACR,MAAMC,EAAMZ,EAGZ,OAFIH,IAASe,SAAAA,EAAKC,iBAAiB,QAAShB,IAErC,KACDA,IAASe,SAAAA,EAAKE,oBAAoB,QAASjB,GAAQ,CACxD,GACA,CAACG,EAAUH,IAGjBd,EAAAI,cAAC4B,EAAQ,CAACC,SAAU,MACnBjC,EAAAI,cAACV,EAAsB,CACfS,IAAKe,EACLG,UAAWA,EACXT,SAAUA,EACVU,QAASA,EACTC,cAAeA,EACfC,WAAYA,EAGV,aAAcf,EACd,cAAeC,EACf,aAAcC,EACd,eAAgBE,EAChB,yBAA0BY,EAC1B,cAAeV,EACf,YAAaC,EAEb,cAAeR,IAGf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoleManagement.js","sources":["../../../src/components/RoleManagement.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useImperativeHandle,\n useState,\n useEffect,\n} from 'react';\nimport Context from '../hooks/Context';\nimport { RoleManagementProps } from '../types';\nimport withPropsMapping from './withPropsMapping';\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: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-role-management-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst RoleManagement = React.forwardRef<HTMLElement, RoleManagementProps>(\n (\n { logger, tenant, theme, locale, debug, widgetId, styleId, onReady },\n ref,\n ) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl, refreshCookieName } =\n React.useContext(Context);\n\n useEffect(() => {\n const ele = innerRef;\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onReady) ele?.removeEventListener('ready', onReady);\n };\n }, [innerRef, onReady]);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<RoleManagementWC\n ref={setInnerRef}\n projectId={projectId}\n widgetId={widgetId}\n tenant={tenant}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n {...{\n // attributes\n 'theme.attr': theme,\n 'locale.attr': locale,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n 'refreshCookieName.attr': refreshCookieName,\n // props\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default RoleManagement;\n"],"names":["RoleManagementWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","RoleManagement","logger","tenant","theme","locale","debug","widgetId","styleId","onReady","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","refreshCookieName","useContext","Context","useEffect","ele","addEventListener","removeEventListener","Suspense","fallback"],"mappings":"kLAYA,MAAMA,EAAmBC,GAAKC,gBACtBC,OAAO,mCAEN,CACLC,QAASC,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,
|
|
1
|
+
{"version":3,"file":"RoleManagement.js","sources":["../../../src/components/RoleManagement.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useImperativeHandle,\n useState,\n useEffect,\n} from 'react';\nimport Context from '../hooks/Context';\nimport { RoleManagementProps } from '../types';\nimport withPropsMapping from './withPropsMapping';\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: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-role-management-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst RoleManagement = React.forwardRef<HTMLElement, RoleManagementProps>(\n (\n { logger, tenant, theme, locale, debug, widgetId, styleId, onReady },\n ref,\n ) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl, refreshCookieName } =\n React.useContext(Context);\n\n useEffect(() => {\n const ele = innerRef;\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onReady) ele?.removeEventListener('ready', onReady);\n };\n }, [innerRef, onReady]);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<RoleManagementWC\n ref={setInnerRef}\n projectId={projectId}\n widgetId={widgetId}\n tenant={tenant}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n {...{\n // attributes\n 'theme.attr': theme,\n 'locale.attr': locale,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n 'refreshCookieName.attr': refreshCookieName,\n // props\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default RoleManagement;\n"],"names":["RoleManagementWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","RoleManagement","logger","tenant","theme","locale","debug","widgetId","styleId","onReady","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","refreshCookieName","useContext","Context","useEffect","ele","addEventListener","removeEventListener","Suspense","fallback"],"mappings":"kLAYA,MAAMA,EAAmBC,GAAKC,gBACtBC,OAAO,mCAEN,CACLC,QAASC,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAAI,cAAA,iCAAAC,OAAAC,OAAA,CAAgCH,IAAKA,GAASD,WAMzCK,EAAiBP,EAAMC,YAC3B,EACIO,SAAQC,SAAQC,QAAOC,SAAQC,QAAOC,WAAUC,UAASC,WAC3DZ,KAEA,MAAOa,EAAUC,GAAeC,EAAS,MAEzCC,EAAoBhB,GAAK,IAAMa,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,EAAUC,kBAAEA,GACrDxB,EAAMyB,WAAWC,GAWnB,OATAC,GAAU,KACR,MAAMC,EAAMZ,EAGZ,OAFID,IAASa,SAAAA,EAAKC,iBAAiB,QAASd,IAErC,KACDA,IAASa,SAAAA,EAAKE,oBAAoB,QAASf,GAAQ,CACxD,GACA,CAACC,EAAUD,IAGjBf,EAAAI,cAAC2B,EAAQ,CAACC,SAAU,MACnBhC,EAAAI,cAACV,EAAgB,CACTS,IAAKc,EACLG,UAAWA,EACXP,SAAUA,EACVJ,OAAQA,EACRY,QAASA,EACTC,cAAeA,EACfC,WAAYA,EAGV,aAAcb,EACd,cAAeC,EACf,aAAcC,EACd,eAAgBE,EAChB,yBAA0BU,EAE1B,cAAehB,IAGf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TenantProfile.js","sources":["../../../src/components/TenantProfile.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useImperativeHandle,\n useState,\n useEffect,\n} from 'react';\nimport Context from '../hooks/Context';\nimport { TenantProfileProps } from '../types';\nimport withPropsMapping from './withPropsMapping';\n\nconst TenantProfileWC = lazy(async () => {\n await import('@descope/tenant-profile-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-tenant-profile-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst TenantProfile = React.forwardRef<HTMLElement, TenantProfileProps>(\n (\n {\n logger,\n theme,\n locale,\n debug,\n widgetId,\n styleId,\n tenant,\n onReady,\n client,\n form,\n },\n ref,\n ) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl, refreshCookieName } =\n React.useContext(Context);\n\n useEffect(() => {\n const ele = innerRef;\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onReady) ele?.removeEventListener('ready', onReady);\n };\n }, [innerRef, onReady]);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<TenantProfileWC\n projectId={projectId}\n widgetId={widgetId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n styleId={styleId}\n tenant={tenant}\n ref={setInnerRef}\n {...{\n 'theme.attr': theme,\n 'locale.attr': locale,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n 'tenant.attr': tenant,\n 'refreshCookieName.attr': refreshCookieName,\n 'client.attr': client,\n 'form.attr': form,\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default TenantProfile;\n"],"names":["TenantProfileWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","TenantProfile","logger","theme","locale","debug","widgetId","styleId","tenant","onReady","client","form","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","refreshCookieName","useContext","Context","useEffect","ele","addEventListener","removeEventListener","Suspense","fallback"],"mappings":"kLAWA,MAAMA,EAAkBC,GAAKC,gBACrBC,OAAO,kCAEN,CACLC,QAASC,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,
|
|
1
|
+
{"version":3,"file":"TenantProfile.js","sources":["../../../src/components/TenantProfile.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useImperativeHandle,\n useState,\n useEffect,\n} from 'react';\nimport Context from '../hooks/Context';\nimport { TenantProfileProps } from '../types';\nimport withPropsMapping from './withPropsMapping';\n\nconst TenantProfileWC = lazy(async () => {\n await import('@descope/tenant-profile-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-tenant-profile-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst TenantProfile = React.forwardRef<HTMLElement, TenantProfileProps>(\n (\n {\n logger,\n theme,\n locale,\n debug,\n widgetId,\n styleId,\n tenant,\n onReady,\n client,\n form,\n },\n ref,\n ) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl, refreshCookieName } =\n React.useContext(Context);\n\n useEffect(() => {\n const ele = innerRef;\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onReady) ele?.removeEventListener('ready', onReady);\n };\n }, [innerRef, onReady]);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<TenantProfileWC\n projectId={projectId}\n widgetId={widgetId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n styleId={styleId}\n tenant={tenant}\n ref={setInnerRef}\n {...{\n 'theme.attr': theme,\n 'locale.attr': locale,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n 'tenant.attr': tenant,\n 'refreshCookieName.attr': refreshCookieName,\n 'client.attr': client,\n 'form.attr': form,\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default TenantProfile;\n"],"names":["TenantProfileWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","TenantProfile","logger","theme","locale","debug","widgetId","styleId","tenant","onReady","client","form","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","refreshCookieName","useContext","Context","useEffect","ele","addEventListener","removeEventListener","Suspense","fallback"],"mappings":"kLAWA,MAAMA,EAAkBC,GAAKC,gBACrBC,OAAO,kCAEN,CACLC,QAASC,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAAI,cAAA,gCAAAC,OAAAC,OAAA,CAA+BH,IAAKA,GAASD,WAMxCK,EAAgBP,EAAMC,YAC1B,EAEIO,SACAC,QACAC,SACAC,QACAC,WACAC,UACAC,SACAC,UACAC,SACAC,QAEFd,KAEA,MAAOe,EAAUC,GAAeC,EAAS,MAEzCC,EAAoBlB,GAAK,IAAMe,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,EAAUC,kBAAEA,GACrD1B,EAAM2B,WAAWC,GAWnB,OATAC,GAAU,KACR,MAAMC,EAAMZ,EAGZ,OAFIH,IAASe,SAAAA,EAAKC,iBAAiB,QAAShB,IAErC,KACDA,IAASe,SAAAA,EAAKE,oBAAoB,QAASjB,GAAQ,CACxD,GACA,CAACG,EAAUH,IAGjBf,EAAAI,cAAC6B,EAAQ,CAACC,SAAU,MACnBlC,EAAAI,cAACV,EAAe,CACR4B,UAAWA,EACXV,SAAUA,EACVW,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZZ,QAASA,EACTC,OAAQA,EACRX,IAAKgB,EAEH,aAAcV,EACd,cAAeC,EACf,aAAcC,EACd,eAAgBE,EAChB,cAAeC,EACf,yBAA0BY,EAC1B,cAAeV,EACf,YAAaC,EACb,cAAeT,IAGf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserManagement.js","sources":["../../../src/components/UserManagement.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useImperativeHandle,\n useState,\n useEffect,\n} from 'react';\nimport Context from '../hooks/Context';\nimport { UserManagementProps } from '../types';\nimport withPropsMapping from './withPropsMapping';\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: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-user-management-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst UserManagement = React.forwardRef<HTMLElement, UserManagementProps>(\n (\n {\n logger,\n tenant,\n theme,\n locale,\n debug,\n widgetId,\n styleId,\n onReady,\n client,\n form,\n },\n ref,\n ) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl, refreshCookieName } =\n React.useContext(Context);\n\n useEffect(() => {\n const ele = innerRef;\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onReady) ele?.removeEventListener('ready', onReady);\n };\n }, [innerRef, onReady]);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<UserManagementWC\n projectId={projectId}\n widgetId={widgetId}\n tenant={tenant}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n ref={setInnerRef}\n {...{\n // attributes\n 'theme.attr': theme,\n 'locale.attr': locale,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n 'refreshCookieName.attr': refreshCookieName,\n 'client.attr': client,\n 'form.attr': form,\n // props\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default UserManagement;\n"],"names":["UserManagementWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","UserManagement","logger","tenant","theme","locale","debug","widgetId","styleId","onReady","client","form","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","refreshCookieName","useContext","Context","useEffect","ele","addEventListener","removeEventListener","Suspense","fallback"],"mappings":"kLAYA,MAAMA,EAAmBC,GAAKC,gBACtBC,OAAO,mCAEN,CACLC,QAASC,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,
|
|
1
|
+
{"version":3,"file":"UserManagement.js","sources":["../../../src/components/UserManagement.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useImperativeHandle,\n useState,\n useEffect,\n} from 'react';\nimport Context from '../hooks/Context';\nimport { UserManagementProps } from '../types';\nimport withPropsMapping from './withPropsMapping';\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: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-user-management-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst UserManagement = React.forwardRef<HTMLElement, UserManagementProps>(\n (\n {\n logger,\n tenant,\n theme,\n locale,\n debug,\n widgetId,\n styleId,\n onReady,\n client,\n form,\n },\n ref,\n ) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl, refreshCookieName } =\n React.useContext(Context);\n\n useEffect(() => {\n const ele = innerRef;\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onReady) ele?.removeEventListener('ready', onReady);\n };\n }, [innerRef, onReady]);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<UserManagementWC\n projectId={projectId}\n widgetId={widgetId}\n tenant={tenant}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n ref={setInnerRef}\n {...{\n // attributes\n 'theme.attr': theme,\n 'locale.attr': locale,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n 'refreshCookieName.attr': refreshCookieName,\n 'client.attr': client,\n 'form.attr': form,\n // props\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default UserManagement;\n"],"names":["UserManagementWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","UserManagement","logger","tenant","theme","locale","debug","widgetId","styleId","onReady","client","form","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","refreshCookieName","useContext","Context","useEffect","ele","addEventListener","removeEventListener","Suspense","fallback"],"mappings":"kLAYA,MAAMA,EAAmBC,GAAKC,gBACtBC,OAAO,mCAEN,CACLC,QAASC,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAAI,cAAA,iCAAAC,OAAAC,OAAA,CAAgCH,IAAKA,GAASD,WAMzCK,EAAiBP,EAAMC,YAC3B,EAEIO,SACAC,SACAC,QACAC,SACAC,QACAC,WACAC,UACAC,UACAC,SACAC,QAEFd,KAEA,MAAOe,EAAUC,GAAeC,EAAS,MAEzCC,EAAoBlB,GAAK,IAAMe,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,EAAUC,kBAAEA,GACrD1B,EAAM2B,WAAWC,GAWnB,OATAC,GAAU,KACR,MAAMC,EAAMZ,EAGZ,OAFIH,IAASe,SAAAA,EAAKC,iBAAiB,QAAShB,IAErC,KACDA,IAASe,SAAAA,EAAKE,oBAAoB,QAASjB,GAAQ,CACxD,GACA,CAACG,EAAUH,IAGjBf,EAAAI,cAAC6B,EAAQ,CAACC,SAAU,MACnBlC,EAAAI,cAACV,EAAgB,CACT4B,UAAWA,EACXT,SAAUA,EACVJ,OAAQA,EACRc,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZtB,IAAKgB,EAGH,aAAcT,EACd,cAAeC,EACf,aAAcC,EACd,eAAgBE,EAChB,yBAA0BY,EAC1B,cAAeV,EACf,YAAaC,EAEb,cAAeT,IAGf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserProfile.js","sources":["../../../src/components/UserProfile.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport Context from '../hooks/Context';\nimport { UserProfileProps } from '../types';\nimport withPropsMapping from './withPropsMapping';\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: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-user-profile-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst UserProfile = React.forwardRef<HTMLElement, UserProfileProps>(\n (\n {\n logger,\n theme,\n locale,\n debug,\n widgetId,\n onLogout,\n styleId,\n onReady,\n client,\n form,\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 baseCdnUrl,\n refreshCookieName,\n sessionTokenViaCookie,\n refreshTokenViaCookie,\n setSession,\n setUser,\n setIsAuthenticated,\n } = React.useContext(Context);\n\n const handleLogout = useCallback(\n (e: CustomEvent) => {\n if (onLogout) {\n onLogout(e);\n }\n // we want to clear the session and user when the logout event is triggered\n setIsAuthenticated(false);\n setSession('');\n setUser(null);\n },\n [onLogout, setSession, setIsAuthenticated, setUser],\n );\n\n useEffect(() => {\n if (innerRef) {\n innerRef.addEventListener('logout', handleLogout);\n return () => innerRef.removeEventListener('logout', handleLogout);\n }\n return undefined;\n }, [innerRef, handleLogout]);\n\n useEffect(() => {\n const ele = innerRef;\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onReady) ele?.removeEventListener('ready', onReady);\n };\n }, [innerRef, onReady]);\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 baseCdnUrl={baseCdnUrl}\n styleId={styleId}\n ref={setInnerRef}\n {...{\n // attributes\n 'theme.attr': theme,\n 'locale.attr': locale,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n 'refreshCookieName.attr': refreshCookieName,\n 'sessionTokenViaCookie.attr': sessionTokenViaCookie,\n 'refreshTokenViaCookie.attr': refreshTokenViaCookie,\n 'client.attr': client,\n 'form.attr': form,\n // props\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default UserProfile;\n"],"names":["UserProfileWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","UserProfile","logger","theme","locale","debug","widgetId","onLogout","styleId","onReady","client","form","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","refreshCookieName","sessionTokenViaCookie","refreshTokenViaCookie","setSession","setUser","setIsAuthenticated","useContext","Context","handleLogout","useCallback","e","useEffect","addEventListener","removeEventListener","ele","Suspense","fallback"],"mappings":"mMAaA,MAAMA,EAAgBC,GAAKC,gBACnBC,OAAO,gCAEN,CACLC,QAASC,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,
|
|
1
|
+
{"version":3,"file":"UserProfile.js","sources":["../../../src/components/UserProfile.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport Context from '../hooks/Context';\nimport { UserProfileProps } from '../types';\nimport withPropsMapping from './withPropsMapping';\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: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-user-profile-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst UserProfile = React.forwardRef<HTMLElement, UserProfileProps>(\n (\n {\n logger,\n theme,\n locale,\n debug,\n widgetId,\n onLogout,\n styleId,\n onReady,\n client,\n form,\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 baseCdnUrl,\n refreshCookieName,\n sessionTokenViaCookie,\n refreshTokenViaCookie,\n setSession,\n setUser,\n setIsAuthenticated,\n } = React.useContext(Context);\n\n const handleLogout = useCallback(\n (e: CustomEvent) => {\n if (onLogout) {\n onLogout(e);\n }\n // we want to clear the session and user when the logout event is triggered\n setIsAuthenticated(false);\n setSession('');\n setUser(null);\n },\n [onLogout, setSession, setIsAuthenticated, setUser],\n );\n\n useEffect(() => {\n if (innerRef) {\n innerRef.addEventListener('logout', handleLogout);\n return () => innerRef.removeEventListener('logout', handleLogout);\n }\n return undefined;\n }, [innerRef, handleLogout]);\n\n useEffect(() => {\n const ele = innerRef;\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onReady) ele?.removeEventListener('ready', onReady);\n };\n }, [innerRef, onReady]);\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 baseCdnUrl={baseCdnUrl}\n styleId={styleId}\n ref={setInnerRef}\n {...{\n // attributes\n 'theme.attr': theme,\n 'locale.attr': locale,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n 'refreshCookieName.attr': refreshCookieName,\n 'sessionTokenViaCookie.attr': sessionTokenViaCookie,\n 'refreshTokenViaCookie.attr': refreshTokenViaCookie,\n 'client.attr': client,\n 'form.attr': form,\n // props\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default UserProfile;\n"],"names":["UserProfileWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","UserProfile","logger","theme","locale","debug","widgetId","onLogout","styleId","onReady","client","form","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","refreshCookieName","sessionTokenViaCookie","refreshTokenViaCookie","setSession","setUser","setIsAuthenticated","useContext","Context","handleLogout","useCallback","e","useEffect","addEventListener","removeEventListener","ele","Suspense","fallback"],"mappings":"mMAaA,MAAMA,EAAgBC,GAAKC,gBACnBC,OAAO,gCAEN,CACLC,QAASC,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAAI,cAAA,8BAAAC,OAAAC,OAAA,CAA6BH,IAAKA,GAASD,WAMtCK,EAAcP,EAAMC,YACxB,EAEIO,SACAC,QACAC,SACAC,QACAC,WACAC,WACAC,UACAC,UACAC,SACAC,QAEFd,KAEA,MAAOe,EAAUC,GAAeC,EAAS,MAEzCC,EAAoBlB,GAAK,IAAMe,IAE/B,MAAMI,UACJA,EAASC,QACTA,EAAOC,cACPA,EAAaC,WACbA,EAAUC,kBACVA,EAAiBC,sBACjBA,EAAqBC,sBACrBA,EAAqBC,WACrBA,EAAUC,QACVA,EAAOC,mBACPA,GACE/B,EAAMgC,WAAWC,GAEfC,EAAeC,GAClBC,IACKvB,GACFA,EAASuB,GAGXL,GAAmB,GACnBF,EAAW,IACXC,EAAQ,KAAK,GAEf,CAACjB,EAAUgB,EAAYE,EAAoBD,IAoB7C,OAjBAO,GAAU,KACR,GAAInB,EAEF,OADAA,EAASoB,iBAAiB,SAAUJ,GAC7B,IAAMhB,EAASqB,oBAAoB,SAAUL,EAEtC,GACf,CAAChB,EAAUgB,IAEdG,GAAU,KACR,MAAMG,EAAMtB,EAGZ,OAFIH,IAASyB,SAAAA,EAAKF,iBAAiB,QAASvB,IAErC,KACDA,IAASyB,SAAAA,EAAKD,oBAAoB,QAASxB,GAAQ,CACxD,GACA,CAACG,EAAUH,IAGjBf,EAAAI,cAACqC,EAAQ,CAACC,SAAU,MACnB1C,EAAAI,cAACV,EAAa,CACN4B,UAAWA,EACXV,SAAUA,EACVW,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZX,QAASA,EACTX,IAAKgB,EAGH,aAAcV,EACd,cAAeC,EACf,aAAcC,EACd,eAAgBG,EAChB,yBAA0BY,EAC1B,6BAA8BC,EAC9B,6BAA8BC,EAC9B,cAAeZ,EACf,YAAaC,EAEb,cAAeT,IAGf"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import r,{useMemo as t,useRef as e,useCallback as o,useImperativeHandle as s}from"react";import{kebabCase as c}from"@descope/sdk-helpers";import{
|
|
1
|
+
import r,{useMemo as t,useRef as e,useCallback as o,useImperativeHandle as s}from"react";import{kebabCase as c}from"@descope/sdk-helpers";import{transformKey as p,transformAttrValue as a}from"./utils.js";const n=n=>r.forwardRef(((u,i)=>{const{prop:m,attr:f,rest:l}=t((()=>Object.entries(u).reduce(((r,[t,e])=>{const{trimmedKey:o,category:s}=p(t);return"prop"===s?r.prop.push([o,e]):"attr"===s?r.attr.push([c(o),a(e)]):Object.assign(r.rest,{[c(o)]:e}),r}),{attr:[],prop:[],rest:{}})),[u]),d=e(null),b=o((r=>{d.current=r,r&&(m.forEach((([r,t])=>{d.current[r]=t})),f.forEach((([t,e])=>{null==e?r.removeAttribute(t):r.setAttribute(t,e)})))}),[m,f,d]);return s(i,(()=>d.current)),r.createElement(n,Object.assign({ref:b},l))}));export{n as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/withPropsMapping/index.tsx"],"sourcesContent":["import React, {\n useImperativeHandle,\n useMemo,\n ComponentType,\n useCallback,\n useRef,\n} from 'react';\nimport { kebabCase } from '@descope/sdk-helpers';\nimport { transformAttrValue, transformKey } from './utils';\n\n/**\n * withPropsMapping is a React HOC that adapts React props to work seamlessly\n * with web components by setting attributes and properties.\n *\n * - Props ending in `.prop` are set as properties on the web component.\n * - Props ending in `.attr` are transformed to kebab-case and set as attributes on the web component.\n * - All other props are set as kebab-case props\n *\n * This resolves attribute/property behavior differences in React 19.\n *\n * @see https://github.com/facebook/react/issues/29037\n */\nconst withPropsMapping = <P extends Record<string, any>>(\n Component: ComponentType<any>,\n) =>\n React.forwardRef<HTMLElement, P>((props, ref) => {\n const { prop, attr, rest } = useMemo(\n () =>\n Object.entries(props).reduce(\n (acc, [key, value]) => {\n const { trimmedKey, category } = transformKey(key);\n if (category === 'prop') acc.prop.push([trimmedKey, value]);\n else if (category === 'attr')\n acc.attr.push([kebabCase(trimmedKey), transformAttrValue(value)]);\n else Object.assign(acc.rest, { [kebabCase(trimmedKey)]: value });\n return acc;\n },\n { attr: [], prop: [], rest: {} },\n ),\n [props],\n );\n\n const currRef = useRef<HTMLElement | null>(null);\n\n const setInnerRef = useCallback(\n (innerRef) => {\n currRef.current = innerRef;\n if (innerRef) {\n prop.forEach(([key, value]) => {\n currRef.current[key] = value;\n });\n\n attr.forEach(([key, value]) => {\n if (value === undefined || value === null) {\n innerRef.removeAttribute(key);\n } else {\n innerRef.setAttribute(key, value);\n }\n });\n }\n },\n [prop, attr, currRef],\n );\n\n useImperativeHandle(ref, () => currRef.current);\n\n return <Component ref={setInnerRef} {...rest} />;\n });\n\nexport default withPropsMapping;\n"],"names":["withPropsMapping","Component","React","forwardRef","props","ref","prop","attr","rest","useMemo","Object","entries","reduce","acc","key","value","trimmedKey","category","transformKey","push","kebabCase","transformAttrValue","assign","currRef","useRef","setInnerRef","useCallback","innerRef","current","forEach","removeAttribute","setAttribute","useImperativeHandle","createElement"],"mappings":"4MAsBA,MAAMA,EACJC,GAEAC,EAAMC,YAA2B,CAACC,EAAOC,KACvC,MAAMC,KAAEA,EAAIC,KAAEA,EAAIC,KAAEA,GAASC,GAC3B,IACEC,OAAOC,QAAQP,GAAOQ,QACpB,CAACC,GAAMC,EAAKC,MACV,MAAMC,WAAEA,EAAUC,SAAEA,GAAaC,EAAaJ,GAK9C,MAJiB,SAAbG,EAAqBJ,EAAIP,KAAKa,KAAK,CAACH,EAAYD,IAC9B,SAAbE,EACPJ,EAAIN,KAAKY,KAAK,CAACC,EAAUJ,GAAaK,EAAmBN,KACtDL,OAAOY,OAAOT,EAAIL,KAAM,CAAE,CAACY,EAAUJ,IAAcD,IACjDF,CAAG,GAEZ,CAAEN,KAAM,GAAID,KAAM,GAAIE,KAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/withPropsMapping/index.tsx"],"sourcesContent":["import React, {\n useImperativeHandle,\n useMemo,\n ComponentType,\n useCallback,\n useRef,\n} from 'react';\nimport { kebabCase } from '@descope/sdk-helpers';\nimport { transformAttrValue, transformKey } from './utils';\n\n/**\n * withPropsMapping is a React HOC that adapts React props to work seamlessly\n * with web components by setting attributes and properties.\n *\n * - Props ending in `.prop` are set as properties on the web component.\n * - Props ending in `.attr` are transformed to kebab-case and set as attributes on the web component.\n * - All other props are set as kebab-case props\n *\n * This resolves attribute/property behavior differences in React 19.\n *\n * @see https://github.com/facebook/react/issues/29037\n */\nconst withPropsMapping = <P extends Record<string, any>>(\n Component: ComponentType<any>,\n) =>\n React.forwardRef<HTMLElement, P>((props, ref) => {\n const { prop, attr, rest } = useMemo(\n () =>\n Object.entries(props).reduce(\n (acc, [key, value]) => {\n const { trimmedKey, category } = transformKey(key);\n if (category === 'prop') acc.prop.push([trimmedKey, value]);\n else if (category === 'attr')\n acc.attr.push([kebabCase(trimmedKey), transformAttrValue(value)]);\n else Object.assign(acc.rest, { [kebabCase(trimmedKey)]: value });\n return acc;\n },\n { attr: [], prop: [], rest: {} },\n ),\n [props],\n );\n\n const currRef = useRef<HTMLElement | null>(null);\n\n const setInnerRef = useCallback(\n (innerRef) => {\n currRef.current = innerRef;\n if (innerRef) {\n prop.forEach(([key, value]) => {\n currRef.current[key] = value;\n });\n\n attr.forEach(([key, value]) => {\n if (value === undefined || value === null) {\n innerRef.removeAttribute(key);\n } else {\n innerRef.setAttribute(key, value);\n }\n });\n }\n },\n [prop, attr, currRef],\n );\n\n useImperativeHandle(ref, () => currRef.current);\n\n return <Component ref={setInnerRef} {...rest} />;\n });\n\nexport default withPropsMapping;\n"],"names":["withPropsMapping","Component","React","forwardRef","props","ref","prop","attr","rest","useMemo","Object","entries","reduce","acc","key","value","trimmedKey","category","transformKey","push","kebabCase","transformAttrValue","assign","currRef","useRef","setInnerRef","useCallback","innerRef","current","forEach","removeAttribute","setAttribute","useImperativeHandle","createElement"],"mappings":"4MAsBA,MAAMA,EACJC,GAEAC,EAAMC,YAA2B,CAACC,EAAOC,KACvC,MAAMC,KAAEA,EAAIC,KAAEA,EAAIC,KAAEA,GAASC,GAC3B,IACEC,OAAOC,QAAQP,GAAOQ,QACpB,CAACC,GAAMC,EAAKC,MACV,MAAMC,WAAEA,EAAUC,SAAEA,GAAaC,EAAaJ,GAK9C,MAJiB,SAAbG,EAAqBJ,EAAIP,KAAKa,KAAK,CAACH,EAAYD,IAC9B,SAAbE,EACPJ,EAAIN,KAAKY,KAAK,CAACC,EAAUJ,GAAaK,EAAmBN,KACtDL,OAAOY,OAAOT,EAAIL,KAAM,CAAE,CAACY,EAAUJ,IAAcD,IACjDF,CAAG,GAEZ,CAAEN,KAAM,GAAID,KAAM,GAAIE,KAAM,MAEhC,CAACJ,IAGGmB,EAAUC,EAA2B,MAErCC,EAAcC,GACjBC,IACCJ,EAAQK,QAAUD,EACdA,IACFrB,EAAKuB,SAAQ,EAAEf,EAAKC,MAClBQ,EAAQK,QAAQd,GAAOC,CAAK,IAG9BR,EAAKsB,SAAQ,EAAEf,EAAKC,MACdA,QACFY,EAASG,gBAAgBhB,GAEzBa,EAASI,aAAajB,EAAKC,EAC7B,IAEJ,GAEF,CAACT,EAAMC,EAAMgB,IAKf,OAFAS,EAAoB3B,GAAK,IAAMkB,EAAQK,UAEhC1B,EAAA+B,cAAChC,EAASS,OAAAY,OAAA,CAACjB,IAAKoB,GAAiBjB,GAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../src/components/withPropsMapping/utils.ts"],"sourcesContent":["export const transformKey = (key: string) => {\n // eslint-disable-next-line no-sparse-arrays\n const [, trimmedKey, category] = /(.*)\\.(prop|attr)$/.exec(key) || [\n ,\n key,\n 'rest',\n ];\n return { trimmedKey, category };\n};\n\nexport const transformAttrValue = (value: any) =>\n typeof value === 'string' || value == null ? value : JSON.stringify(value);\n"],"names":["transformKey","key","trimmedKey","category","exec","transformAttrValue","value","JSON","stringify"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../src/components/withPropsMapping/utils.ts"],"sourcesContent":["export const transformKey = (key: string) => {\n // eslint-disable-next-line no-sparse-arrays\n const [, trimmedKey, category] = /(.*)\\.(prop|attr)$/.exec(key) || [\n ,\n key,\n 'rest',\n ];\n return { trimmedKey, category };\n};\n\nexport const transformAttrValue = (value: any) =>\n typeof value === 'string' || value == null ? value : JSON.stringify(value);\n"],"names":["transformKey","key","trimmedKey","category","exec","transformAttrValue","value","JSON","stringify"],"mappings":"AAAO,MAAMA,EAAgBC,IAE3B,MAAM,CAAGC,EAAYC,GAAY,qBAAqBC,KAAKH,IAAQ,EAEjEA,EACA,QAEF,MAAO,CAAEC,aAAYC,WAAU,EAGpBE,EAAsBC,GAChB,iBAAVA,GAA+B,MAATA,EAAgBA,EAAQC,KAAKC,UAAUF"}
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={"x-descope-sdk-name":"react","x-descope-sdk-version":"3.4.
|
|
1
|
+
const e={"x-descope-sdk-name":"react","x-descope-sdk-version":"3.4.4"},d="undefined"!=typeof window;export{d as IS_BROWSER,e as baseHeaders};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../src/constants.ts"],"sourcesContent":["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"],"names":["baseHeaders","IS_BROWSER","window"],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../src/constants.ts"],"sourcesContent":["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"],"names":["baseHeaders","IS_BROWSER","window"],"mappings":"AAEO,MAAMA,EAAc,CACzB,qBAAsB,QACtB,wBAAyB,SAIdC,EAA+B,oBAAXC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sources":["../../../src/hooks/Context.ts"],"sourcesContent":["import React from 'react';\nimport { IContext } from '../types';\n\nconst Context = React.createContext<IContext>(undefined);\n\nexport default Context;\n"],"names":["Context","React","createContext","undefined"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Context.js","sources":["../../../src/hooks/Context.ts"],"sourcesContent":["import React from 'react';\nimport { IContext } from '../types';\n\nconst Context = React.createContext<IContext>(undefined);\n\nexport default Context;\n"],"names":["Context","React","createContext","undefined"],"mappings":"qBAGA,MAAMA,EAAUC,EAAMC,mBAAwBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDescope.js","sources":["../../../src/hooks/useDescope.ts"],"sourcesContent":["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"],"names":["generateErrorMsg","entryType","proxyThrowHandler","get","target","key","Proxy","Error","useDescope","sdk","useContext","useMemo","createTempSdk"],"mappings":"yGAKA,MAAMA,EAAoBC,GACxB,yBAAyBA,4FAGrBC,EAAoB,CAExB,GAAAC,CAAIC,EAA6BC,GAC/B,GAA2B,iBAAhBD,EAAOC,IAAqC,OAAhBD,EAAOC,GAC5C,OAAO,IAAIC,MAAMF,EAAOC,GAAMH,GAGhC,GAA2B,mBAAhBE,EAAOC,GAChB,MAAO,KACL,MAAME,MAAMP,EAAiB,YAAY,EAI7C,MAAMO,MAAMP,EAAiB,
|
|
1
|
+
{"version":3,"file":"useDescope.js","sources":["../../../src/hooks/useDescope.ts"],"sourcesContent":["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"],"names":["generateErrorMsg","entryType","proxyThrowHandler","get","target","key","Proxy","Error","useDescope","sdk","useContext","useMemo","createTempSdk"],"mappings":"yGAKA,MAAMA,EAAoBC,GACxB,yBAAyBA,4FAGrBC,EAAoB,CAExB,GAAAC,CAAIC,EAA6BC,GAC/B,GAA2B,iBAAhBD,EAAOC,IAAqC,OAAhBD,EAAOC,GAC5C,OAAO,IAAIC,MAAMF,EAAOC,GAAMH,GAGhC,GAA2B,mBAAhBE,EAAOC,GAChB,MAAO,KACL,MAAME,MAAMP,EAAiB,YAAY,EAI7C,MAAMO,MAAMP,EAAiB,aAC/B,GAGIQ,EAAa,KACjB,MAAMC,IAAEA,GAAQC,IAEhB,OAAOC,GAAQ,IACRF,GAEI,IAAIH,MAAMM,IAAiBV,IAInC,CAACO,GAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSession.js","sources":["../../../src/hooks/useSession.ts"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react';\nimport useContext from './useContext';\nimport { isDescopeBridge } from '../utils';\n\nconst useSession = () => {\n const {\n session,\n claims,\n isSessionLoading,\n isOidcLoading,\n fetchSession,\n isSessionFetchStarted,\n isSessionFetchCompleted,\n isAuthenticated,\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 || isOidcLoading);\n\n // we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n // isSessionFetchCompleted guarantees a re-run when the fetch settles, even if isSessionLoading never visibly changed\n useMemo(() => {\n isLoading.current = isSessionLoading || isOidcLoading;\n }, [isSessionLoading, isOidcLoading, isSessionFetchCompleted]);\n\n // In case we're in a native flow, we won't refresh the session anyway, so no point in marking the state as loading\n const shouldFetchSession = !isAuthenticated && !isSessionLoading && !isDescopeBridge();\n\n // we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n useMemo(() => {\n if (shouldFetchSession && !isSessionFetchStarted) {\n isLoading.current = true;\n }\n }, [isSessionFetchStarted]);\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 claims,\n isAuthenticated,\n };\n};\n\nexport default useSession;\n"],"names":["useSession","session","claims","isSessionLoading","isOidcLoading","fetchSession","isSessionFetchStarted","isSessionFetchCompleted","isAuthenticated","useContext","isLoading","useRef","useMemo","current","shouldFetchSession","isDescopeBridge","useEffect","sessionToken"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSession.js","sources":["../../../src/hooks/useSession.ts"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react';\nimport useContext from './useContext';\nimport { isDescopeBridge } from '../utils';\n\nconst useSession = () => {\n const {\n session,\n claims,\n isSessionLoading,\n isOidcLoading,\n fetchSession,\n isSessionFetchStarted,\n isSessionFetchCompleted,\n isAuthenticated,\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 || isOidcLoading);\n\n // we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n // isSessionFetchCompleted guarantees a re-run when the fetch settles, even if isSessionLoading never visibly changed\n useMemo(() => {\n isLoading.current = isSessionLoading || isOidcLoading;\n }, [isSessionLoading, isOidcLoading, isSessionFetchCompleted]);\n\n // In case we're in a native flow, we won't refresh the session anyway, so no point in marking the state as loading\n const shouldFetchSession = !isAuthenticated && !isSessionLoading && !isDescopeBridge();\n\n // we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n useMemo(() => {\n if (shouldFetchSession && !isSessionFetchStarted) {\n isLoading.current = true;\n }\n }, [isSessionFetchStarted]);\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 claims,\n isAuthenticated,\n };\n};\n\nexport default useSession;\n"],"names":["useSession","session","claims","isSessionLoading","isOidcLoading","fetchSession","isSessionFetchStarted","isSessionFetchCompleted","isAuthenticated","useContext","isLoading","useRef","useMemo","current","shouldFetchSession","isDescopeBridge","useEffect","sessionToken"],"mappings":"wIAIA,MAAMA,EAAa,KACjB,MAAMC,QACJA,EAAOC,OACPA,EAAMC,iBACNA,EAAgBC,cAChBA,EAAaC,aACbA,EAAYC,sBACZA,EAAqBC,wBACrBA,EAAuBC,gBACvBA,GACEC,IAIEC,EAAYC,EAAOR,GAAoBC,GAI7CQ,GAAQ,KACNF,EAAUG,QAAUV,GAAoBC,CAAa,GACpD,CAACD,EAAkBC,EAAeG,IAGrC,MAAMO,GAAsBN,IAAoBL,IAAqBY,IAgBrE,OAbAH,GAAQ,KACFE,IAAuBR,IACzBI,EAAUG,SAAU,EACtB,GACC,CAACP,IAIJU,GAAU,KACJF,GACFT,GACF,GACC,CAACA,IACG,CACLF,iBAAkBO,EAAUG,QAC5BI,aAAchB,EACdC,SACAM,kBACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUser.js","sources":["../../../src/hooks/useUser.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\nimport useContext from './useContext';\n\nconst useUser = () => {\n const {\n user,\n fetchUser,\n isUserLoading,\n isAuthenticated,\n isUserFetchStarted,\n isUserFetchCompleted,\n } = 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 && isAuthenticated && !isInit,\n [fetchUser, isAuthenticated, isInit],\n );\n\n // we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n // isUserFetchCompleted guarantees a re-run when the fetch settles, even if isUserLoading never visibly changed\n useMemo(() => {\n isLoading.current = isUserLoading;\n }, [isUserLoading, isUserFetchCompleted]);\n\n // we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n useMemo(() => {\n if (shouldFetchUser && !isUserFetchStarted) {\n isLoading.current = true;\n }\n }, [shouldFetchUser, isUserFetchStarted]);\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":["useUser","user","fetchUser","isUserLoading","isAuthenticated","isUserFetchStarted","isUserFetchCompleted","useContext","isInit","setIsInit","useState","isLoading","useRef","shouldFetchUser","useMemo","current","useEffect"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUser.js","sources":["../../../src/hooks/useUser.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\nimport useContext from './useContext';\n\nconst useUser = () => {\n const {\n user,\n fetchUser,\n isUserLoading,\n isAuthenticated,\n isUserFetchStarted,\n isUserFetchCompleted,\n } = 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 && isAuthenticated && !isInit,\n [fetchUser, isAuthenticated, isInit],\n );\n\n // we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n // isUserFetchCompleted guarantees a re-run when the fetch settles, even if isUserLoading never visibly changed\n useMemo(() => {\n isLoading.current = isUserLoading;\n }, [isUserLoading, isUserFetchCompleted]);\n\n // we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n useMemo(() => {\n if (shouldFetchUser && !isUserFetchStarted) {\n isLoading.current = true;\n }\n }, [shouldFetchUser, isUserFetchStarted]);\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":["useUser","user","fetchUser","isUserLoading","isAuthenticated","isUserFetchStarted","isUserFetchCompleted","useContext","isInit","setIsInit","useState","isLoading","useRef","shouldFetchUser","useMemo","current","useEffect"],"mappings":"wGAGA,MAAMA,EAAU,KACd,MAAMC,KACJA,EAAIC,UACJA,EAASC,cACTA,EAAaC,gBACbA,EAAeC,mBACfA,EAAkBC,qBAClBA,GACEC,KACGC,EAAQC,GAAaC,GAAS,GAI/BC,EAAYC,EAAOT,GAEnBU,EAAkBC,GACtB,KAAOb,IAASE,GAAiBC,IAAoBI,GACrD,CAACN,EAAWE,EAAiBI,IAuB/B,OAlBAM,GAAQ,KACNH,EAAUI,QAAUZ,CAAa,GAChC,CAACA,EAAeG,IAGnBQ,GAAQ,KACFD,IAAoBR,IACtBM,EAAUI,SAAU,EACtB,GACC,CAACF,EAAiBR,IAErBW,GAAU,KACJH,IACFJ,GAAU,GACVP,IACF,GACC,CAACW,IAEG,CAAEV,cAAeQ,EAAUI,QAASd,OAAM"}
|
package/dist/esm/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["// workaround for TS issue https://github.com/microsoft/TypeScript/issues/42873\n// eslint-disable-next-line\nimport type * as _1 from '@descope/core-js-sdk';\nimport { createSdk } from '@descope/web-js-sdk';\nimport type * as _2 from 'oidc-client-ts'; // eslint-disable-line\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 getCurrentTenant = wrapInTry(\n (token = getSessionToken()) => globalSdk?.getCurrentTenant(token),\n);\n\nexport const refresh = (token = getRefreshToken()) => globalSdk?.refresh(token);\n\nexport const getGlobalSdk = () => globalSdk;\n\nexport default createSdkWrapper;\n"],"names":["globalSdk","createSdkWrapper","config","sdk","createSdk","Object","assign","persistTokens","IS_BROWSER","autoRefresh","createTempSdk","projectId","storeLastAuthenticatedUser","getSessionToken","console","warn","getRefreshToken","isSessionTokenExpired","token","isJwtExpired","isRefreshTokenExpired","getJwtPermissions","wrapInTry","tenant","getJwtRoles","getCurrentTenant","refresh","getGlobalSdk"],"mappings":"mIASA,IAAIA,EAEJ,MAAMC,EACJC,IAEA,MAAMC,EAAMC,EAASC,OAAAC,OAAA,CACnBC,cAAeC,EACfC,YAAaD,GACVN,IAIL,OAFAF,EAAYG,EAELA,CAAG,EAICO,EAAgB,IAC3BT,EAAiB,CACfU,UAAW,WACXJ,eAAe,EACfE,aAAa,EACbG,4BAA4B,IAUhCZ,EAAYU,IAEL,MAAMG,EAAkB,IACzBL,EACKR,aAAS,EAATA,EAAWa,mBAIpBC,QAAQC,KAAK,6CACN,IAGIC,EAAkB,IACzBR,EACKR,aAAS,EAATA,EAAWgB,mBAGpBF,QAAQC,KAAK,6CACN,IAGIE,EAAwB,CAACC,EAAQL,MAC5Cb,
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["// workaround for TS issue https://github.com/microsoft/TypeScript/issues/42873\n// eslint-disable-next-line\nimport type * as _1 from '@descope/core-js-sdk';\nimport { createSdk } from '@descope/web-js-sdk';\nimport type * as _2 from 'oidc-client-ts'; // eslint-disable-line\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 getCurrentTenant = wrapInTry(\n (token = getSessionToken()) => globalSdk?.getCurrentTenant(token),\n);\n\nexport const refresh = (token = getRefreshToken()) => globalSdk?.refresh(token);\n\nexport const getGlobalSdk = () => globalSdk;\n\nexport default createSdkWrapper;\n"],"names":["globalSdk","createSdkWrapper","config","sdk","createSdk","Object","assign","persistTokens","IS_BROWSER","autoRefresh","createTempSdk","projectId","storeLastAuthenticatedUser","getSessionToken","console","warn","getRefreshToken","isSessionTokenExpired","token","isJwtExpired","isRefreshTokenExpired","getJwtPermissions","wrapInTry","tenant","getJwtRoles","getCurrentTenant","refresh","getGlobalSdk"],"mappings":"mIASA,IAAIA,EAEJ,MAAMC,EACJC,IAEA,MAAMC,EAAMC,EAASC,OAAAC,OAAA,CACnBC,cAAeC,EACfC,YAAaD,GACVN,IAIL,OAFAF,EAAYG,EAELA,CAAG,EAICO,EAAgB,IAC3BT,EAAiB,CACfU,UAAW,WACXJ,eAAe,EACfE,aAAa,EACbG,4BAA4B,IAUhCZ,EAAYU,IAEL,MAAMG,EAAkB,IACzBL,EACKR,aAAS,EAATA,EAAWa,mBAIpBC,QAAQC,KAAK,6CACN,IAGIC,EAAkB,IACzBR,EACKR,aAAS,EAATA,EAAWgB,mBAGpBF,QAAQC,KAAK,6CACN,IAGIE,EAAwB,CAACC,EAAQL,MAC5Cb,aAAS,EAATA,EAAWmB,aAAaD,GAEbE,EAAwB,CAACF,EAAQF,MAC5ChB,aAAS,EAATA,EAAWmB,aAAaD,GAEbG,EAAoBC,GAC/B,CAACJ,EAAQL,IAAmBU,IAC1BvB,aAAS,EAATA,EAAWqB,kBAAkBH,EAAOK,KAG3BC,EAAcF,GACzB,CAACJ,EAAQL,IAAmBU,IAC1BvB,aAAS,EAATA,EAAWwB,YAAYN,EAAOK,KAGrBE,EAAmBH,GAC9B,CAACJ,EAAQL,MAAsBb,aAAS,EAATA,EAAWyB,iBAAiBP,KAGhDQ,EAAU,CAACR,EAAQF,MAAsBhB,aAAS,EAATA,EAAW0B,QAAQR,GAE5DS,EAAe,IAAM3B"}
|
package/dist/esm/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["/**\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\n// Detect if running in a native flow (e.g., mobile app with Descope bridge in a webview)\nexport const isDescopeBridge = () =>\n typeof window !== 'undefined' && !!window['descopeBridge'];\n"],"names":["withValidation","fn","args","Error","wrapInTry","res","err","console","error","isDescopeBridge","window"],"mappings":"AAKO,MAAMA,EACeC,GAC1B,IAAIC,KACF,IAAKD,EACH,MAAME,MACJ,0HAGJ,OAAOF,KAAMC,EAAK,EAGTE,EACeH,GAC1B,IAAIC,KACF,IAAIG,EACJ,IACEA,EAAMJ,KAAMC,
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["/**\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\n// Detect if running in a native flow (e.g., mobile app with Descope bridge in a webview)\nexport const isDescopeBridge = () =>\n typeof window !== 'undefined' && !!window['descopeBridge'];\n"],"names":["withValidation","fn","args","Error","wrapInTry","res","err","console","error","isDescopeBridge","window"],"mappings":"AAKO,MAAMA,EACeC,GAC1B,IAAIC,KACF,IAAKD,EACH,MAAME,MACJ,0HAGJ,OAAOF,KAAMC,EAAK,EAGTE,EACeH,GAC1B,IAAIC,KACF,IAAIG,EACJ,IACEA,EAAMJ,KAAMC,EACd,CAAE,MAAOI,GACPC,QAAQC,MAAMF,EAChB,CACA,OAAOD,CAAG,EAIDI,EAAkB,IACX,oBAAXC,UAA4BA,OAAsB"}
|