@descope/react-sdk 2.20.4 → 2.20.5
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/README.md +11 -5
- package/dist/cjs/components/AccessKeyManagement.js +1 -1
- package/dist/cjs/components/AccessKeyManagement.js.map +1 -1
- package/dist/cjs/components/ApplicationsPortal.js +1 -1
- package/dist/cjs/components/ApplicationsPortal.js.map +1 -1
- package/dist/cjs/components/AuditManagement.js +1 -1
- package/dist/cjs/components/AuditManagement.js.map +1 -1
- package/dist/cjs/components/AuthProvider/AuthProvider.js +1 -1
- package/dist/cjs/components/AuthProvider/AuthProvider.js.map +1 -1
- package/dist/cjs/components/AuthProvider/useSdk.js +1 -1
- package/dist/cjs/components/AuthProvider/useSdk.js.map +1 -1
- package/dist/cjs/components/Descope.js +1 -1
- package/dist/cjs/components/Descope.js.map +1 -1
- package/dist/cjs/components/RoleManagement.js +1 -1
- package/dist/cjs/components/RoleManagement.js.map +1 -1
- package/dist/cjs/components/TenantProfile.js +1 -1
- package/dist/cjs/components/TenantProfile.js.map +1 -1
- package/dist/cjs/components/UserManagement.js +1 -1
- package/dist/cjs/components/UserManagement.js.map +1 -1
- package/dist/cjs/components/UserProfile.js +1 -1
- package/dist/cjs/components/UserProfile.js.map +1 -1
- package/dist/cjs/constants.js +1 -1
- package/dist/esm/components/AccessKeyManagement.js +1 -1
- package/dist/esm/components/AccessKeyManagement.js.map +1 -1
- package/dist/esm/components/ApplicationsPortal.js +1 -1
- package/dist/esm/components/ApplicationsPortal.js.map +1 -1
- package/dist/esm/components/AuditManagement.js +1 -1
- package/dist/esm/components/AuditManagement.js.map +1 -1
- package/dist/esm/components/AuthProvider/AuthProvider.js +1 -1
- package/dist/esm/components/AuthProvider/AuthProvider.js.map +1 -1
- package/dist/esm/components/AuthProvider/useSdk.js +1 -1
- package/dist/esm/components/AuthProvider/useSdk.js.map +1 -1
- package/dist/esm/components/Descope.js +1 -1
- package/dist/esm/components/Descope.js.map +1 -1
- package/dist/esm/components/RoleManagement.js +1 -1
- package/dist/esm/components/RoleManagement.js.map +1 -1
- package/dist/esm/components/TenantProfile.js +1 -1
- package/dist/esm/components/TenantProfile.js.map +1 -1
- package/dist/esm/components/UserManagement.js +1 -1
- package/dist/esm/components/UserManagement.js.map +1 -1
- package/dist/esm/components/UserProfile.js +1 -1
- package/dist/esm/components/UserProfile.js.map +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/index.d.ts +15 -3
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/types/components/AccessKeyManagement.d.ts +1 -0
- package/dist/types/components/ApplicationsPortal.d.ts +1 -0
- package/dist/types/components/AuditManagement.d.ts +1 -0
- package/dist/types/components/AuthProvider/AuthProvider.d.ts +2 -0
- package/dist/types/components/AuthProvider/useSdk.d.ts +2 -2
- package/dist/types/components/RoleManagement.d.ts +1 -0
- package/dist/types/components/TenantProfile.d.ts +1 -0
- package/dist/types/components/UserManagement.d.ts +1 -0
- package/dist/types/components/UserProfile.d.ts +1 -0
- package/dist/types/sdk.d.ts +3 -0
- package/dist/types/types.d.ts +3 -1
- package/package.json +12 -12
|
@@ -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 { CookieConfig, OidcConfig } from '@descope/web-js-sdk';\nimport { Claims } from '@descope/core-js-sdk';\nimport Context from '../../hooks/Context';\nimport { IContext, User } from '../../types';\nimport { withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ninterface IAuthProviderProps {\n projectId: string;\n baseUrl?: string;\n // allows to override the base URL that is used to fetch static files\n baseStaticUrl?: string;\n // 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 autoRefresh?: boolean;\n // If true, session token (jwt) will be stored on cookie. Otherwise, the session token will be\n // stored on local storage and can accessed with getSessionToken function\n // Use this option if session token will stay small (less than 1k)\n // NOTE: Session token can grow, especially in cases of using authorization, or adding custom claims\n sessionTokenViaCookie?: CookieConfig;\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 children?: React.ReactNode;\n}\n\nconst AuthProvider: FC<IAuthProviderProps> = ({\n projectId,\n baseUrl = '',\n baseStaticUrl = '',\n baseCdnUrl = '',\n sessionTokenViaCookie = false,\n persistTokens = true,\n autoRefresh = true,\n oidcConfig = undefined,\n storeLastAuthenticatedUser = true,\n keepLastAuthenticatedUserAfterLogout = false,\n refreshCookieName = '',\n getExternalToken = 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 const isOidcFinishedLogin = useRef(false);\n\n const sdk = useSdk({\n projectId,\n baseUrl,\n persistTokens,\n autoRefresh,\n sessionTokenViaCookie,\n oidcConfig,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n getExternalToken,\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 isSessionFetched = useRef(false);\n const isUserFetched = 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 // We want that the session will fetched only once\n isSessionFetched.current = true;\n });\n }\n }, []);\n\n const fetchSession = useCallback(() => {\n // We want that the session will fetched only once\n if (isSessionFetched.current) return;\n isSessionFetched.current = true;\n\n setIsSessionLoading(true);\n withValidation(sdk?.refresh)(undefined, true).then(() => {\n setIsSessionLoading(false);\n });\n }, [sdk]);\n\n const fetchUser = useCallback(() => {\n // We want that the user will fetched only once\n if (isUserFetched.current) return;\n isUserFetched.current = true;\n\n setIsUserLoading(true);\n withValidation(sdk.me)().then(() => {\n setIsUserLoading(false);\n });\n }, [sdk]);\n\n const value = useMemo<IContext>(\n () => ({\n fetchUser,\n user,\n isUserLoading,\n isUserFetched: isUserFetched.current,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetched: isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n setUser,\n setSession,\n setIsAuthenticated,\n claims,\n sdk,\n }),\n [\n fetchUser,\n user,\n isUserLoading,\n isUserFetched.current,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\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","persistTokens","autoRefresh","oidcConfig","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","refreshCookieName","getExternalToken","children","user","setUser","useState","session","setSession","claims","setClaims","isAuthenticated","setIsAuthenticated","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","isOidcLoading","setIsOidcLoading","isOidcFinishedLogin","useRef","sdk","useSdk","useEffect","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","unsubscribeIsAuthenticated","onIsAuthenticatedChange","unsubscribeClaims","onClaimsChange","isSessionFetched","isUserFetched","current","oidc","finishLoginIfNeed","finally","fetchSession","useCallback","withValidation","refresh","undefined","then","fetchUser","me","value","useMemo","React","createElement","Context","Provider"],"mappings":"
|
|
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 { CookieConfig, OidcConfig } 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 { withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ninterface IAuthProviderProps {\n projectId: string;\n baseUrl?: string;\n // allows to override the base URL that is used to fetch static files\n baseStaticUrl?: string;\n // 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 autoRefresh?: boolean;\n // If true, session token (jwt) will be stored on cookie. Otherwise, the session token will be\n // stored on local storage and can accessed with getSessionToken function\n // Use this option if session token will stay small (less than 1k)\n // NOTE: Session token can grow, especially in cases of using authorization, or adding custom claims\n sessionTokenViaCookie?: CookieConfig;\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 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 const isOidcFinishedLogin = useRef(false);\n\n const sdk = useSdk({\n projectId,\n baseUrl,\n persistTokens,\n autoRefresh,\n sessionTokenViaCookie,\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 isSessionFetched = useRef(false);\n const isUserFetched = 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 // We want that the session will fetched only once\n isSessionFetched.current = true;\n });\n }\n }, []);\n\n const fetchSession = useCallback(() => {\n // We want that the session will fetched only once\n if (isSessionFetched.current) return;\n isSessionFetched.current = true;\n\n setIsSessionLoading(true);\n withValidation(sdk?.refresh)(undefined, true).then(() => {\n setIsSessionLoading(false);\n });\n }, [sdk]);\n\n const fetchUser = useCallback(() => {\n // We want that the user will fetched only once\n if (isUserFetched.current) return;\n isUserFetched.current = true;\n\n setIsUserLoading(true);\n withValidation(sdk.me)().then(() => {\n setIsUserLoading(false);\n });\n }, [sdk]);\n\n const value = useMemo<IContext>(\n () => ({\n fetchUser,\n user,\n isUserLoading,\n isUserFetched: isUserFetched.current,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetched: isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n customStorage,\n setUser,\n setSession,\n setIsAuthenticated,\n claims,\n sdk,\n }),\n [\n fetchUser,\n user,\n isUserLoading,\n isUserFetched.current,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\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","persistTokens","autoRefresh","oidcConfig","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","refreshCookieName","getExternalToken","customStorage","children","user","setUser","useState","session","setSession","claims","setClaims","isAuthenticated","setIsAuthenticated","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","isOidcLoading","setIsOidcLoading","isOidcFinishedLogin","useRef","sdk","useSdk","useEffect","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","unsubscribeIsAuthenticated","onIsAuthenticatedChange","unsubscribeClaims","onClaimsChange","isSessionFetched","isUserFetched","current","oidc","finishLoginIfNeed","finally","fetchSession","useCallback","withValidation","refresh","undefined","then","fetchUser","me","value","useMemo","React","createElement","Context","Provider"],"mappings":"8MAiDM,MAAAA,EAAuC,EAC3CC,YACAC,UAAU,GACVC,gBAAgB,GAChBC,aAAa,GACbC,yBAAwB,EACxBC,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,GAC/CsB,EAAsBC,GAAO,GAE7BC,EAAMC,EAAO,CACjBhC,YACAC,UACAI,gBACAC,cACAF,wBACAG,aACAC,6BACAC,uCACAC,oBACAC,mBACAC,kBAGFqB,GAAU,KACR,GAAIF,EAAK,CACP,MAAMG,EAA0BH,EAAII,qBAAqBjB,GACnDkB,EAAkBL,EAAIM,aAAatB,GACnCuB,EACJP,EAAIQ,wBAAwBjB,GACxBkB,EAAoBT,EAAIU,eAAerB,GAE7C,MAAO,KACLc,IACAE,IACAE,IACAE,GAAmB,CAEtB,CACe,GACf,CAACT,IAEJ,MAAMW,EAAmBZ,GAAO,GAC1Ba,EAAgBb,GAAO,GAI7BG,GAAU,KACJF,GAAOxB,IAAesB,EAAoBe,UAC5Cf,EAAoBe,SAAU,EAC9Bb,EAAIc,KAAKC,oBAAoBC,SAAQ,KACnCnB,GAAiB,GAEjBc,EAAiBE,SAAU,CAAI,IAElC,GACA,IAEH,MAAMI,EAAeC,GAAY,KAE3BP,EAAiBE,UACrBF,EAAiBE,SAAU,EAE3BlB,GAAoB,GACpBwB,EAAenB,aAAA,EAAAA,EAAKoB,QAApBD,MAA6BE,GAAW,GAAMC,MAAK,KACjD3B,GAAoB,EAAM,IAC1B,GACD,CAACK,IAEEuB,EAAYL,GAAY,KAExBN,EAAcC,UAClBD,EAAcC,SAAU,EAExBpB,GAAiB,GACjB0B,EAAenB,EAAIwB,GAAnBL,GAAyBG,MAAK,KAC5B7B,GAAiB,EAAM,IACvB,GACD,CAACO,IAEEyB,EAAQC,GACZ,KAAO,CACLH,YACAxC,OACAS,gBACAoB,cAAeA,EAAcC,QAC7BI,eACA/B,UACAI,kBACAI,mBACAE,gBACAe,iBAAkBA,EAAiBE,QACnC5C,YACAC,UACAC,gBACAC,aACAK,6BACAC,uCACAC,oBACAE,gBACAG,UACAG,aACAI,qBACAH,SACAY,SAEF,CACEuB,EACAxC,EACAS,EACAoB,EAAcC,QACdI,EACA/B,EACAI,EACAI,EACAE,EACAe,EAAiBE,QACjB5C,EACAC,EACAC,EACAC,EACAM,EACAC,EACAE,EACAG,EACAG,EACAI,EACAH,EACAY,IAGJ,OAAO2B,EAAAC,cAACC,EAAQC,SAAQ,CAACL,MAAOA,GAAQ3C,EAA4B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useMemo as e}from"react";import{baseHeaders as t}from"../../constants.js";import o from"../../sdk.js";var s=({projectId:s,baseUrl:r,persistTokens:a,autoRefresh:i,sessionTokenViaCookie:n,refreshCookieName:f,oidcConfig:k,storeLastAuthenticatedUser:
|
|
1
|
+
import{useMemo as e}from"react";import{baseHeaders as t}from"../../constants.js";import o from"../../sdk.js";var s=({projectId:s,baseUrl:r,persistTokens:a,autoRefresh:i,sessionTokenViaCookie:n,refreshCookieName:f,oidcConfig:k,storeLastAuthenticatedUser:c,keepLastAuthenticatedUserAfterLogout:u,getExternalToken:d,customStorage:m})=>e((()=>{if(s)return o({projectId:s,baseUrl:r,sessionTokenViaCookie:n,baseHeaders:t,persistTokens:a,autoRefresh:i,refreshCookieName:f,oidcConfig:k,storeLastAuthenticatedUser:c,keepLastAuthenticatedUserAfterLogout:u,getExternalToken:d,customStorage:m})}),[s,r,JSON.stringify(n),d,m]);export{s as default};
|
|
2
2
|
//# sourceMappingURL=useSdk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSdk.js","sources":["../../../../src/components/AuthProvider/useSdk.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { baseHeaders } from '../../constants';\nimport createSdk from '../../sdk';\n\ntype Config = Pick<\n Parameters<typeof createSdk>[0],\n | 'projectId'\n | 'baseUrl'\n | 'persistTokens'\n | 'autoRefresh'\n | 'sessionTokenViaCookie'\n | 'storeLastAuthenticatedUser'\n | 'oidcConfig'\n | 'keepLastAuthenticatedUserAfterLogout'\n | 'refreshCookieName'\n | 'getExternalToken'\n>;\n\nexport default ({\n projectId,\n baseUrl,\n persistTokens,\n autoRefresh,\n sessionTokenViaCookie,\n refreshCookieName,\n oidcConfig,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n getExternalToken,\n}: Config): ReturnType<typeof createSdk> =>\n useMemo(() => {\n if (!projectId) {\n return undefined;\n }\n return createSdk({\n projectId,\n baseUrl,\n sessionTokenViaCookie,\n baseHeaders,\n persistTokens,\n autoRefresh,\n refreshCookieName,\n oidcConfig,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n getExternalToken,\n });\n }, [projectId
|
|
1
|
+
{"version":3,"file":"useSdk.js","sources":["../../../../src/components/AuthProvider/useSdk.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { baseHeaders } from '../../constants';\nimport createSdk from '../../sdk';\n\ntype Config = Pick<\n Parameters<typeof createSdk>[0],\n | 'projectId'\n | 'baseUrl'\n | 'persistTokens'\n | 'autoRefresh'\n | 'sessionTokenViaCookie'\n | 'storeLastAuthenticatedUser'\n | 'oidcConfig'\n | 'keepLastAuthenticatedUserAfterLogout'\n | 'refreshCookieName'\n | 'getExternalToken'\n | 'customStorage'\n>;\n\nexport default ({\n projectId,\n baseUrl,\n persistTokens,\n autoRefresh,\n sessionTokenViaCookie,\n refreshCookieName,\n oidcConfig,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n getExternalToken,\n customStorage,\n}: Config): ReturnType<typeof createSdk> =>\n useMemo(() => {\n if (!projectId) {\n return undefined;\n }\n return createSdk({\n projectId,\n baseUrl,\n sessionTokenViaCookie,\n baseHeaders,\n persistTokens,\n autoRefresh,\n refreshCookieName,\n oidcConfig,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n getExternalToken,\n customStorage,\n });\n }, [\n projectId,\n baseUrl,\n // NOTE: Avoid creating another instance of the SDK if the consumer of this\n // component forgot to `useMemo` the object.\n // This is also necessary for a workaround with Next.js SSR when including AuthProvider\n // in RootLayout with another component that forces rerenders.\n //\n // See: https://github.com/descope/etc/issues/11965\n JSON.stringify(sessionTokenViaCookie),\n getExternalToken,\n customStorage,\n ]);\n"],"names":["useSdk","projectId","baseUrl","persistTokens","autoRefresh","sessionTokenViaCookie","refreshCookieName","oidcConfig","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","getExternalToken","customStorage","useMemo","createSdk","baseHeaders","JSON","stringify"],"mappings":"6GAmBA,IAAeA,EAAA,EACbC,YACAC,UACAC,gBACAC,cACAC,wBACAC,oBACAC,aACAC,6BACAC,uCACAC,mBACAC,mBAEAC,GAAQ,KACN,GAAKX,EAGL,OAAOY,EAAU,CACfZ,YACAC,UACAG,wBACAS,cACAX,gBACAC,cACAE,oBACAC,aACAC,6BACAC,uCACAC,mBACAC,iBACA,GACD,CACDV,EACAC,EAOAa,KAAKC,UAAUX,GACfK,EACAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__rest as e}from"../node_modules/.pnpm/@rollup_plugin-typescript@11.1.6_rollup@4.22.4_tslib@2.8.1_typescript@5.4.5/node_modules/tslib/tslib.es6.js";import t,{lazy as r,useMemo as
|
|
1
|
+
import{__rest as e}from"../node_modules/.pnpm/@rollup_plugin-typescript@11.1.6_rollup@4.22.4_tslib@2.8.1_typescript@5.4.5/node_modules/tslib/tslib.es6.js";import t,{lazy as r,useMemo as o,useState as n,useImperativeHandle as s,useCallback as a,useEffect as l,Suspense as u}from"react";import{baseHeaders as d}from"../constants.js";import c from"../hooks/Context.js";import{getGlobalSdk as i}from"../sdk.js";import p from"./withPropsMapping/index.js";const m=r((async()=>(((null===customElements||void 0===customElements?void 0:customElements.get("descope-wc"))||await import("@descope/web-component").then((e=>e.default))).sdkConfigOverrides={baseHeaders:d,persistTokens:!1,hooks:{get beforeRequest(){return i().httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:p(t.forwardRef(((r,n)=>{var{"external-request-id":s}=r,a=e(r,["external-request-id"]);return o((()=>{var e,t;e="x-external-rid",(t=s)?d[e]=t:delete d[e]}),[s]),t.createElement("descope-wc",Object.assign({ref:n},a))})))}))),f=t.forwardRef((({flowId:e,onSuccess:r,onError:o,onReady:d,logger:i,tenant:p,theme:f,nonce:v,locale:E,debug:b,client:g,form:h,telemetryKey:L,redirectUrl:y,autoFocus:k,validateOnBlur:U,restartOnError:w,errorTransformer:S,styleId:x,onScreenUpdate:I,dismissScreenErrorOnInput:R,outboundAppId:C,outboundAppScopes:j,children:q,externalRequestId:O},A)=>{const[_,N]=n(null);s(A,(()=>_));const{projectId:T,baseUrl:B,baseStaticUrl:F,baseCdnUrl:K,storeLastAuthenticatedUser:H,keepLastAuthenticatedUserAfterLogout:J,refreshCookieName:M,customStorage:P,sdk:z}=t.useContext(c),D=a((async e=>{await z.httpClient.hooks.afterRequest({},new Response(JSON.stringify(e.detail))),r&&r(e)}),[r]);return l((()=>{const e=_;return null==e||e.addEventListener("success",D),o&&(null==e||e.addEventListener("error",o)),d&&(null==e||e.addEventListener("ready",d)),()=>{o&&(null==e||e.removeEventListener("error",o)),d&&(null==e||e.removeEventListener("ready",d)),null==e||e.removeEventListener("success",D)}}),[_,o,D]),l((()=>{const e=_;return null==e||e.addEventListener("success",D),()=>{null==e||e.removeEventListener("success",D)}}),[_,D]),l((()=>{const e=_;return o&&(null==e||e.addEventListener("error",o)),()=>{o&&(null==e||e.removeEventListener("error",o))}}),[_,o]),l((()=>{const e=_;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("error",d))}}),[_,d]),t.createElement("form",null,t.createElement(u,{fallback:null},t.createElement(m,{projectId:T,flowId:e,baseUrl:B,baseStaticUrl:F,baseCdnUrl:K,ref:N,telemetryKey:L,redirectUrl:y,autoFocus:k,styleId:x,validateOnBlur:U,restartOnError:w,keepLastAuthenticatedUserAfterLogout:J,tenant:p,externalRequestId:O,customStorage:P,"theme.attr":f,"nonce.attr":v,"locale.attr":E,"form.attr":h,"client.attr":g,"debug.attr":b,"outbound-app-id.attr":C,"outbound-app-scopes.attr":j,"store-last-authenticated-user.attr":H,"refreshCookieName.attr":M,"dismiss-screen-error-on-input.attr":R,"errorTransformer.prop":S,"logger.prop":i,"onScreenUpdate.prop":I,"customStorage.prop":P},q)))}));export{f as default};
|
|
2
2
|
//# sourceMappingURL=Descope.js.map
|
|
@@ -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?.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 errorTransformer,\n styleId,\n onScreenUpdate,\n dismissScreenErrorOnInput,\n outboundAppId,\n outboundAppScopes,\n children,\n externalRequestId,\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 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 {...{\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 'store-last-authenticated-user.attr': storeLastAuthenticatedUser,\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 }}\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","customElements","get","import","then","module","default","sdkConfigOverrides","baseHeaders","persistTokens","hooks","beforeRequest","getGlobalSdk","httpClient","_","withPropsMapping","React","forwardRef","_a","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","errorTransformer","styleId","onScreenUpdate","dismissScreenErrorOnInput","outboundAppId","outboundAppScopes","children","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","refreshCookieName","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?.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 errorTransformer,\n styleId,\n onScreenUpdate,\n dismissScreenErrorOnInput,\n outboundAppId,\n outboundAppScopes,\n children,\n externalRequestId,\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 {...{\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 'store-last-authenticated-user.attr': storeLastAuthenticatedUser,\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","customElements","get","import","then","module","default","sdkConfigOverrides","baseHeaders","persistTokens","hooks","beforeRequest","getGlobalSdk","httpClient","_","withPropsMapping","React","forwardRef","_a","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","errorTransformer","styleId","onScreenUpdate","dismissScreenErrorOnInput","outboundAppId","outboundAppScopes","children","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,2 +1,2 @@
|
|
|
1
|
-
import e,{lazy as t,useState as r,useImperativeHandle as a,Suspense as o}from"react";import
|
|
1
|
+
import e,{lazy as t,useState as r,useImperativeHandle as a,useEffect as n,Suspense as o}from"react";import l from"../hooks/Context.js";import s from"./withPropsMapping/index.js";const d=t((async()=>(await import("@descope/role-management-widget"),{default:s(e.forwardRef(((t,r)=>e.createElement("descope-role-management-widget",Object.assign({ref:r},t)))))}))),i=e.forwardRef((({logger:t,tenant:s,theme:i,debug:m,widgetId:c,styleId:f,onReady:g},p)=>{const[u,b]=r(null);a(p,(()=>u));const{projectId:w,baseUrl:h,baseStaticUrl:y,baseCdnUrl:C,refreshCookieName:I}=e.useContext(l);return n((()=>{const e=u;return g&&(null==e||e.addEventListener("ready",g)),()=>{g&&(null==e||e.removeEventListener("ready",g))}}),[u,g]),e.createElement(o,{fallback:null},e.createElement(d,{ref:b,projectId:w,widgetId:c,tenant:s,baseUrl:h,baseStaticUrl:y,baseCdnUrl:C,"theme.attr":i,"debug.attr":m,"styleId.attr":f,"refreshCookieName.attr":I,"logger.prop":t}))}));export{i as default};
|
|
2
2
|
//# sourceMappingURL=RoleManagement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoleManagement.js","sources":["../../../src/components/RoleManagement.tsx"],"sourcesContent":["import React, {
|
|
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 ({ logger, tenant, theme, debug, widgetId, styleId, onReady }, ref) => {\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 '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","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,EAAgCI,cAAA,iCAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAMzCK,EAAiBP,EAAMC,YAC3B,EAAGO,SAAQC,SAAQC,QAAOC,QAAOC,WAAUC,UAASC,WAAWX,KAC7D,MAAOY,EAAUC,GAAeC,EAAS,MAEzCC,EAAoBf,GAAK,IAAMY,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,EAAUC,kBAAEA,GACrDvB,EAAMwB,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,IAGjBd,EAACI,cAAA0B,EAAS,CAAAC,SAAU,MACnB/B,EAAAI,cAACV,EAAgB,CACTS,IAAKa,EACLG,UAAWA,EACXP,SAAUA,EACVH,OAAQA,EACRW,QAASA,EACTC,cAAeA,EACfC,WAAYA,EAGV,aAAcZ,EACd,aAAcC,EACd,eAAgBE,EAChB,yBAA0BU,EAE1B,cAAef,IAIrB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{lazy as t,useState as r,useImperativeHandle as a,Suspense as o}from"react";import
|
|
1
|
+
import e,{lazy as t,useState as r,useImperativeHandle as a,useEffect as n,Suspense as o}from"react";import l from"../hooks/Context.js";import s from"./withPropsMapping/index.js";const d=t((async()=>(await import("@descope/tenant-profile-widget"),{default:s(e.forwardRef(((t,r)=>e.createElement("descope-tenant-profile-widget",Object.assign({ref:r},t)))))}))),i=e.forwardRef((({logger:t,theme:s,debug:i,widgetId:c,styleId:f,tenant:p,onReady:m},g)=>{const[u,b]=r(null);a(g,(()=>u));const{projectId:w,baseUrl:y,baseStaticUrl:I,baseCdnUrl:h,refreshCookieName:C}=e.useContext(l);return n((()=>{const e=u;return m&&(null==e||e.addEventListener("ready",m)),()=>{m&&(null==e||e.removeEventListener("ready",m))}}),[u,m]),e.createElement(o,{fallback:null},e.createElement(d,{projectId:w,widgetId:c,baseUrl:y,baseStaticUrl:I,baseCdnUrl:h,styleId:f,tenant:p,ref:b,"theme.attr":s,"debug.attr":i,"styleId.attr":f,"tenant.attr":p,"refreshCookieName.attr":C,"logger.prop":t}))}));export{i as default};
|
|
2
2
|
//# sourceMappingURL=TenantProfile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TenantProfile.js","sources":["../../../src/components/TenantProfile.tsx"],"sourcesContent":["import React, {
|
|
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 ({ logger, theme, debug, widgetId, styleId, tenant, onReady }, ref) => {\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 'debug.attr': debug,\n 'styleId.attr': styleId,\n 'tenant.attr': tenant,\n 'refreshCookieName.attr': refreshCookieName,\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","debug","widgetId","styleId","tenant","onReady","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,EAA+BI,cAAA,gCAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAMxCK,EAAgBP,EAAMC,YAC1B,EAAGO,SAAQC,QAAOC,QAAOC,WAAUC,UAASC,SAAQC,WAAWX,KAC7D,MAAOY,EAAUC,GAAeC,EAAS,MAEzCC,EAAoBf,GAAK,IAAMY,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,EAAUC,kBAAEA,GACrDvB,EAAMwB,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,IAGjBd,EAACI,cAAA0B,EAAS,CAAAC,SAAU,MACnB/B,EAAAI,cAACV,EACO,CAAAyB,UAAWA,EACXR,SAAUA,EACVS,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZV,QAASA,EACTC,OAAQA,EACRV,IAAKa,EAEH,aAAcP,EACd,aAAcC,EACd,eAAgBE,EAChB,cAAeC,EACf,yBAA0BU,EAC1B,cAAef,IAIrB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{lazy as t,useState as r,useImperativeHandle as a,Suspense as o}from"react";import s from"../hooks/Context.js";import
|
|
1
|
+
import e,{lazy as t,useState as r,useImperativeHandle as a,useEffect as n,Suspense as o}from"react";import s from"../hooks/Context.js";import d from"./withPropsMapping/index.js";const l=t((async()=>(await import("@descope/user-management-widget"),{default:d(e.forwardRef(((t,r)=>e.createElement("descope-user-management-widget",Object.assign({ref:r},t)))))}))),i=e.forwardRef((({logger:t,tenant:d,theme:i,debug:m,widgetId:c,styleId:f,onReady:g},p)=>{const[u,b]=r(null);a(p,(()=>u));const{projectId:w,baseUrl:h,baseStaticUrl:y,baseCdnUrl:C,refreshCookieName:I}=e.useContext(s);return n((()=>{const e=u;return g&&(null==e||e.addEventListener("ready",g)),()=>{g&&(null==e||e.removeEventListener("ready",g))}}),[u,g]),e.createElement(o,{fallback:null},e.createElement(l,{projectId:w,widgetId:c,tenant:d,baseUrl:h,baseStaticUrl:y,baseCdnUrl:C,ref:b,"theme.attr":i,"debug.attr":m,"styleId.attr":f,"refreshCookieName.attr":I,"logger.prop":t}))}));export{i as default};
|
|
2
2
|
//# sourceMappingURL=UserManagement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserManagement.js","sources":["../../../src/components/UserManagement.tsx"],"sourcesContent":["import React, {
|
|
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 ({ logger, tenant, theme, debug, widgetId, styleId, onReady }, ref) => {\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 '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 UserManagement;\n"],"names":["UserManagementWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","UserManagement","logger","tenant","theme","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,EAAgCI,cAAA,iCAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAMzCK,EAAiBP,EAAMC,YAC3B,EAAGO,SAAQC,SAAQC,QAAOC,QAAOC,WAAUC,UAASC,WAAWX,KAC7D,MAAOY,EAAUC,GAAeC,EAAS,MAEzCC,EAAoBf,GAAK,IAAMY,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,EAAUC,kBAAEA,GACrDvB,EAAMwB,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,IAGjBd,EAACI,cAAA0B,EAAS,CAAAC,SAAU,MACnB/B,EAAAI,cAACV,EAAgB,CACTyB,UAAWA,EACXP,SAAUA,EACVH,OAAQA,EACRW,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZnB,IAAKa,EAGH,aAAcN,EACd,aAAcC,EACd,eAAgBE,EAChB,yBAA0BU,EAE1B,cAAef,IAIrB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{lazy as t,useState as r,useImperativeHandle as o,useCallback as s,useEffect as a,Suspense as
|
|
1
|
+
import e,{lazy as t,useState as r,useImperativeHandle as o,useCallback as s,useEffect as a,Suspense as n}from"react";import l from"../hooks/Context.js";import d from"./withPropsMapping/index.js";const i=t((async()=>(await import("@descope/user-profile-widget"),{default:d(e.forwardRef(((t,r)=>e.createElement("descope-user-profile-widget",Object.assign({ref:r},t)))))}))),u=e.forwardRef((({logger:t,theme:d,debug:u,widgetId:c,onLogout:f,styleId:m,onReady:p},g)=>{const[b,w]=r(null);o(g,(()=>b));const{projectId:I,baseUrl:h,baseStaticUrl:y,baseCdnUrl:E,refreshCookieName:U,setSession:v,setUser:C,setIsAuthenticated:j}=e.useContext(l),L=s((e=>{f&&f(e),j(!1),v(""),C(null)}),[f,v,j,C]);return a((()=>{if(b)return b.addEventListener("logout",L),()=>b.removeEventListener("logout",L)}),[b,L]),a((()=>{const e=b;return p&&(null==e||e.addEventListener("ready",p)),()=>{p&&(null==e||e.removeEventListener("ready",p))}}),[b,p]),e.createElement(n,{fallback:null},e.createElement(i,{projectId:I,widgetId:c,baseUrl:h,baseStaticUrl:y,baseCdnUrl:E,styleId:m,ref:w,"theme.attr":d,"debug.attr":u,"styleId.attr":m,"refreshCookieName.attr":U,"logger.prop":t}))}));export{u as default};
|
|
2
2
|
//# sourceMappingURL=UserProfile.js.map
|
|
@@ -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 ({ logger, theme, debug, widgetId, onLogout, styleId }, ref) => {\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 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 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 '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 UserProfile;\n"],"names":["UserProfileWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","UserProfile","logger","theme","debug","widgetId","onLogout","styleId","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","refreshCookieName","setSession","setUser","setIsAuthenticated","useContext","Context","handleLogout","useCallback","e","useEffect","addEventListener","removeEventListener","Suspense","fallback"],"mappings":"mMAaA,MAAMA,EAAgBC,GAAKC,gBACnBC,OAAO,gCAEN,CACLC,QAASC,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAA6BI,cAAA,8BAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAMtCK,EAAcP,EAAMC,YACxB,EAAGO,SAAQC,QAAOC,QAAOC,WAAUC,WAAUC,
|
|
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 ({ logger, theme, debug, widgetId, onLogout, styleId, onReady }, ref) => {\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 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 '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 UserProfile;\n"],"names":["UserProfileWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","UserProfile","logger","theme","debug","widgetId","onLogout","styleId","onReady","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","refreshCookieName","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,EAA6BI,cAAA,8BAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAMtCK,EAAcP,EAAMC,YACxB,EAAGO,SAAQC,QAAOC,QAAOC,WAAUC,WAAUC,UAASC,WAAWX,KAC/D,MAAOY,EAAUC,GAAeC,EAAS,MAEzCC,EAAoBf,GAAK,IAAMY,IAE/B,MAAMI,UACJA,EAASC,QACTA,EAAOC,cACPA,EAAaC,WACbA,EAAUC,kBACVA,EAAiBC,WACjBA,EAAUC,QACVA,EAAOC,mBACPA,GACE1B,EAAM2B,WAAWC,GAEfC,EAAeC,GAClBC,IACKnB,GACFA,EAASmB,GAGXL,GAAmB,GACnBF,EAAW,IACXC,EAAQ,KAAK,GAEf,CAACb,EAAUY,EAAYE,EAAoBD,IAoB7C,OAjBAO,GAAU,KACR,GAAIjB,EAEF,OADAA,EAASkB,iBAAiB,SAAUJ,GAC7B,IAAMd,EAASmB,oBAAoB,SAAUL,EAEtC,GACf,CAACd,EAAUc,IAEdG,GAAU,KACR,MAAMG,EAAMpB,EAGZ,OAFID,IAASqB,SAAAA,EAAKF,iBAAiB,QAASnB,IAErC,KACDA,IAASqB,SAAAA,EAAKD,oBAAoB,QAASpB,GAAQ,CACxD,GACA,CAACC,EAAUD,IAGjBd,EAACI,cAAAgC,EAAS,CAAAC,SAAU,MACnBrC,EAAAI,cAACV,EAAa,CACNyB,UAAWA,EACXR,SAAUA,EACVS,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZT,QAASA,EACTV,IAAKa,EAGH,aAAcP,EACd,aAAcC,EACd,eAAgBG,EAChB,yBAA0BU,EAE1B,cAAef,IAIrB"}
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.20.
|
|
1
|
+
const e={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.20.5"},d="undefined"!=typeof window;export{d as IS_BROWSER,e as baseHeaders};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React, { FC, DOMAttributes } from 'react';
|
|
2
2
|
import * as _descope_web_js_sdk from '@descope/web-js-sdk';
|
|
3
3
|
import { CookieConfig, OidcConfig } from '@descope/web-js-sdk';
|
|
4
|
+
import * as _descope_web_component from '@descope/web-component';
|
|
5
|
+
import _descope_web_component__default, { CustomStorage, ILogger, ThemeOptions, AutoFocusOptions } from '@descope/web-component';
|
|
6
|
+
export { ILogger } from '@descope/web-component';
|
|
4
7
|
import AccessKeyManagementWidget from '@descope/access-key-management-widget';
|
|
5
8
|
import ApplicationsPortalWidget from '@descope/applications-portal-widget';
|
|
6
9
|
import AuditManagementWidget from '@descope/audit-management-widget';
|
|
@@ -8,9 +11,6 @@ import RoleManagementWidget from '@descope/role-management-widget';
|
|
|
8
11
|
import TenantProfileWidget from '@descope/tenant-profile-widget';
|
|
9
12
|
import UserManagementWidget from '@descope/user-management-widget';
|
|
10
13
|
import UserProfileWidget from '@descope/user-profile-widget';
|
|
11
|
-
import * as _descope_web_component from '@descope/web-component';
|
|
12
|
-
import _descope_web_component__default, { ILogger, ThemeOptions, AutoFocusOptions } from '@descope/web-component';
|
|
13
|
-
export { ILogger } from '@descope/web-component';
|
|
14
14
|
import * as _1 from '@descope/core-js-sdk';
|
|
15
15
|
import * as _2 from 'oidc-client-ts';
|
|
16
16
|
|
|
@@ -27,6 +27,7 @@ interface IAuthProviderProps {
|
|
|
27
27
|
keepLastAuthenticatedUserAfterLogout?: boolean;
|
|
28
28
|
refreshCookieName?: string;
|
|
29
29
|
getExternalToken?: () => Promise<string>;
|
|
30
|
+
customStorage?: CustomStorage;
|
|
30
31
|
children?: React.ReactNode;
|
|
31
32
|
}
|
|
32
33
|
declare const AuthProvider: FC<IAuthProviderProps>;
|
|
@@ -64,6 +65,9 @@ declare const createSdkWrapper: <P extends {
|
|
|
64
65
|
} & {
|
|
65
66
|
oidcConfig?: _descope_web_js_sdk.OidcConfig;
|
|
66
67
|
getExternalToken?: () => Promise<string>;
|
|
68
|
+
customStorage?: _descope_web_js_sdk.CustomStorage;
|
|
69
|
+
} & {
|
|
70
|
+
customStorage?: _descope_web_js_sdk.CustomStorage;
|
|
67
71
|
} & {
|
|
68
72
|
fpKey?: string;
|
|
69
73
|
fpLoad?: boolean;
|
|
@@ -2010,6 +2014,7 @@ type WidgetProps = {
|
|
|
2010
2014
|
theme?: ThemeOptions;
|
|
2011
2015
|
debug?: boolean;
|
|
2012
2016
|
styleId?: string;
|
|
2017
|
+
onReady?: CustomEventCb<{}>;
|
|
2013
2018
|
};
|
|
2014
2019
|
type FlowResponse = Awaited<ReturnType<Sdk['flow']['next']>>;
|
|
2015
2020
|
type ErrorResponse = Required<FlowResponse>['error'];
|
|
@@ -2104,6 +2109,7 @@ declare const AccessKeyManagement: React.ForwardRefExoticComponent<{
|
|
|
2104
2109
|
theme?: _descope_web_component.ThemeOptions;
|
|
2105
2110
|
debug?: boolean;
|
|
2106
2111
|
styleId?: string;
|
|
2112
|
+
onReady?: (e: CustomEvent<{}>) => void;
|
|
2107
2113
|
} & React.RefAttributes<HTMLElement>>;
|
|
2108
2114
|
|
|
2109
2115
|
declare const ApplicationsPortal: React.ForwardRefExoticComponent<Omit<{
|
|
@@ -2113,6 +2119,7 @@ declare const ApplicationsPortal: React.ForwardRefExoticComponent<Omit<{
|
|
|
2113
2119
|
theme?: _descope_web_component.ThemeOptions;
|
|
2114
2120
|
debug?: boolean;
|
|
2115
2121
|
styleId?: string;
|
|
2122
|
+
onReady?: (e: CustomEvent<{}>) => void;
|
|
2116
2123
|
}, "tenant"> & {
|
|
2117
2124
|
onLogout?: (e: CustomEvent<any>) => void;
|
|
2118
2125
|
} & React.RefAttributes<HTMLElement>>;
|
|
@@ -2124,6 +2131,7 @@ declare const AuditManagement: React.ForwardRefExoticComponent<{
|
|
|
2124
2131
|
theme?: _descope_web_component.ThemeOptions;
|
|
2125
2132
|
debug?: boolean;
|
|
2126
2133
|
styleId?: string;
|
|
2134
|
+
onReady?: (e: CustomEvent<{}>) => void;
|
|
2127
2135
|
} & React.RefAttributes<HTMLElement>>;
|
|
2128
2136
|
|
|
2129
2137
|
declare const RoleManagement: React.ForwardRefExoticComponent<{
|
|
@@ -2133,6 +2141,7 @@ declare const RoleManagement: React.ForwardRefExoticComponent<{
|
|
|
2133
2141
|
theme?: _descope_web_component.ThemeOptions;
|
|
2134
2142
|
debug?: boolean;
|
|
2135
2143
|
styleId?: string;
|
|
2144
|
+
onReady?: (e: CustomEvent<{}>) => void;
|
|
2136
2145
|
} & React.RefAttributes<HTMLElement>>;
|
|
2137
2146
|
|
|
2138
2147
|
declare const TenantProfile: React.ForwardRefExoticComponent<{
|
|
@@ -2142,6 +2151,7 @@ declare const TenantProfile: React.ForwardRefExoticComponent<{
|
|
|
2142
2151
|
theme?: _descope_web_component.ThemeOptions;
|
|
2143
2152
|
debug?: boolean;
|
|
2144
2153
|
styleId?: string;
|
|
2154
|
+
onReady?: (e: CustomEvent<{}>) => void;
|
|
2145
2155
|
} & React.RefAttributes<HTMLElement>>;
|
|
2146
2156
|
|
|
2147
2157
|
declare const UserManagement: React.ForwardRefExoticComponent<{
|
|
@@ -2151,6 +2161,7 @@ declare const UserManagement: React.ForwardRefExoticComponent<{
|
|
|
2151
2161
|
theme?: _descope_web_component.ThemeOptions;
|
|
2152
2162
|
debug?: boolean;
|
|
2153
2163
|
styleId?: string;
|
|
2164
|
+
onReady?: (e: CustomEvent<{}>) => void;
|
|
2154
2165
|
} & React.RefAttributes<HTMLElement>>;
|
|
2155
2166
|
|
|
2156
2167
|
declare const UserProfile: React.ForwardRefExoticComponent<Omit<{
|
|
@@ -2160,6 +2171,7 @@ declare const UserProfile: React.ForwardRefExoticComponent<Omit<{
|
|
|
2160
2171
|
theme?: _descope_web_component.ThemeOptions;
|
|
2161
2172
|
debug?: boolean;
|
|
2162
2173
|
styleId?: string;
|
|
2174
|
+
onReady?: (e: CustomEvent<{}>) => void;
|
|
2163
2175
|
}, "tenant"> & {
|
|
2164
2176
|
onLogout?: (e: CustomEvent<any>) => void;
|
|
2165
2177
|
} & React.RefAttributes<HTMLElement>>;
|