@descope/react-sdk 2.4.0 → 2.6.0
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 +3 -0
- 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/Descope.js.map +1 -1
- package/dist/cjs/components/RoleManagement.js.map +1 -1
- package/dist/cjs/components/UserManagement.js.map +1 -1
- package/dist/cjs/constants.js +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/Descope.js.map +1 -1
- package/dist/esm/components/RoleManagement.js.map +1 -1
- package/dist/esm/components/UserManagement.js.map +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/types/components/AuthProvider/AuthProvider.d.ts +4 -1
- package/dist/types/sdk.d.ts +6 -2
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -370,6 +370,9 @@ Note:
|
|
|
370
370
|
The session token cookie is set as a [`Secure`](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.5) cookie. It will be sent only over HTTPS connections.
|
|
371
371
|
In addition, some browsers (e.g. Safari) may not store `Secure` cookie if the hosted page is running on an HTTP protocol.
|
|
372
372
|
|
|
373
|
+
The session token cookie is set to [`SameSite=Strict`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value) by default.
|
|
374
|
+
If you need to customize this, you can set `sessionTokenViaCookie={sameSite: 'Lax'}`
|
|
375
|
+
|
|
373
376
|
### Helper Functions
|
|
374
377
|
|
|
375
378
|
You can also use the following functions to assist with various actions managing your JWT.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessKeyManagement.js","sources":["../../../src/components/AccessKeyManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } from 'react';\nimport Context from '../hooks/Context';\nimport { AccessKeyManagementProps } 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 AccessKeyManagementWC = lazy(async () => {\n await import('@descope/access-key-management-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n
|
|
1
|
+
{"version":3,"file":"AccessKeyManagement.js","sources":["../../../src/components/AccessKeyManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } from 'react';\nimport Context from '../hooks/Context';\nimport { AccessKeyManagementProps } 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 AccessKeyManagementWC = lazy(async () => {\n await import('@descope/access-key-management-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-access-key-management-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst AccessKeyManagement = React.forwardRef<\n HTMLElement,\n AccessKeyManagementProps\n>(({ logger, tenant, theme, debug, widgetId, styleId }, ref) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl } =\n React.useContext(Context);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<AccessKeyManagementWC\n projectId={projectId}\n widgetId={widgetId}\n tenant={tenant}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n innerRef={setInnerRef}\n {...{\n // attributes\n 'theme.attr': theme,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n // props\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n});\n\nexport default AccessKeyManagement;\n"],"names":["AccessKeyManagementWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","AccessKeyManagement","logger","tenant","theme","debug","widgetId","styleId","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","useContext","Context","Suspense","fallback"],"mappings":"mOAMA,MAAMA,EAAwBC,EAAIA,MAACC,gBAC3BC,OAAO,yCAEN,CACLC,QAASC,EAAgBD,QACvBE,UAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAAA,QAAsCI,cAAA,uCAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAM/CK,EAAsBP,EAAKF,QAACG,YAGhC,EAAGO,SAAQC,SAAQC,QAAOC,QAAOC,WAAUC,WAAWV,KACtD,MAAOW,EAAUC,GAAeC,EAAQA,SAAC,MAEzCC,sBAAoBd,GAAK,IAAMW,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,GACzCrB,EAAKF,QAACwB,WAAWC,EAAAA,SAEnB,OACDvB,EAACF,QAAAM,cAAAoB,EAAQA,SAAC,CAAAC,SAAU,MACnBzB,EAAAF,QAAAM,cAACV,EAAqB,CAChBwB,UAAWA,EACXN,SAAUA,EACVH,OAAQA,EACRU,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZP,SAAUC,EAGR,aAAcL,EACd,aAAcC,EACd,eAAgBE,EAEhB,cAAeL,IAIrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationsPortal.js","sources":["../../../src/components/ApplicationsPortal.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } from 'react';\nimport Context from '../hooks/Context';\nimport { ApplicationsPortalProps } 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 ApplicationsPortalWC = lazy(async () => {\n await import('@descope/applications-portal-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n
|
|
1
|
+
{"version":3,"file":"ApplicationsPortal.js","sources":["../../../src/components/ApplicationsPortal.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } from 'react';\nimport Context from '../hooks/Context';\nimport { ApplicationsPortalProps } 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 ApplicationsPortalWC = lazy(async () => {\n await import('@descope/applications-portal-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-applications-portal-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst ApplicationsPortal = React.forwardRef<\n HTMLElement,\n ApplicationsPortalProps\n>(({ logger, theme, debug, widgetId, styleId }, ref) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl } =\n React.useContext(Context);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<ApplicationsPortalWC\n projectId={projectId}\n widgetId={widgetId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n innerRef={setInnerRef}\n {...{\n // attributes\n 'theme.attr': theme,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n // props\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n});\n\nexport default ApplicationsPortal;\n"],"names":["ApplicationsPortalWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","ApplicationsPortal","logger","theme","debug","widgetId","styleId","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","useContext","Context","Suspense","fallback"],"mappings":"mOAMA,MAAMA,EAAuBC,EAAIA,MAACC,gBAC1BC,OAAO,uCAEN,CACLC,QAASC,EAAgBD,QACvBE,UAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAAA,QAAoCI,cAAA,qCAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAM7CK,EAAqBP,EAAKF,QAACG,YAG/B,EAAGO,SAAQC,QAAOC,QAAOC,WAAUC,WAAWT,KAC9C,MAAOU,EAAUC,GAAeC,EAAQA,SAAC,MAEzCC,sBAAoBb,GAAK,IAAMU,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,GACzCpB,EAAKF,QAACuB,WAAWC,EAAAA,SAEnB,OACDtB,EAACF,QAAAM,cAAAmB,EAAQA,SAAC,CAAAC,SAAU,MACnBxB,EAACF,QAAAM,cAAAV,EACK,CAAAuB,UAAWA,EACXN,SAAUA,EACVO,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZP,SAAUC,EAGR,aAAcL,EACd,aAAcC,EACd,eAAgBE,EAEhB,cAAeJ,IAIrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuditManagement.js","sources":["../../../src/components/AuditManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } from 'react';\nimport Context from '../hooks/Context';\nimport { AuditManagementProps } 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 AuditManagementWC = lazy(async () => {\n await import('@descope/audit-management-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n
|
|
1
|
+
{"version":3,"file":"AuditManagement.js","sources":["../../../src/components/AuditManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } from 'react';\nimport Context from '../hooks/Context';\nimport { AuditManagementProps } 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 AuditManagementWC = lazy(async () => {\n await import('@descope/audit-management-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-audit-management-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst AuditManagement = React.forwardRef<HTMLElement, AuditManagementProps>(\n ({ logger, tenant, theme, debug, widgetId, styleId }, ref) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl } =\n React.useContext(Context);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<AuditManagementWC\n projectId={projectId}\n widgetId={widgetId}\n tenant={tenant}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n innerRef={setInnerRef}\n {...{\n // attributes\n 'theme.attr': theme,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n // props\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default AuditManagement;\n"],"names":["AuditManagementWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","AuditManagement","logger","tenant","theme","debug","widgetId","styleId","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","useContext","Context","Suspense","fallback"],"mappings":"mOAMA,MAAMA,EAAoBC,EAAIA,MAACC,gBACvBC,OAAO,oCAEN,CACLC,QAASC,EAAgBD,QACvBE,UAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAAA,QAAiCI,cAAA,kCAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAM1CK,EAAkBP,EAAKF,QAACG,YAC5B,EAAGO,SAAQC,SAAQC,QAAOC,QAAOC,WAAUC,WAAWV,KACpD,MAAOW,EAAUC,GAAeC,EAAQA,SAAC,MAEzCC,sBAAoBd,GAAK,IAAMW,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,GACzCrB,EAAKF,QAACwB,WAAWC,EAAAA,SAEnB,OACHvB,EAACF,QAAAM,cAAAoB,EAAQA,SAAC,CAAAC,SAAU,MACnBzB,EAAAF,QAAAM,cAACV,EAAiB,CACVwB,UAAWA,EACXN,SAAUA,EACVH,OAAQA,EACRU,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZP,SAAUC,EAGR,aAAcL,EACd,aAAcC,EACd,eAAgBE,EAEhB,cAAeL,IAIrB"}
|
|
@@ -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 Context from '../../hooks/Context';\nimport { IContext, User } from '../../types';\nimport { withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ninterface IAuthProviderProps {\n projectId: string;\n baseUrl?: string;\n // allows to override the base URL that is used to fetch static files\n baseStaticUrl?: string;\n // If true, tokens will be stored on local storage and can accessed with getToken function\n persistTokens?: boolean;\n // If true, session token (jwt) will be stored on cookie. Otherwise, the session token will be\n // stored on local storage and can accessed with getSessionToken function\n // Use this option if session token will stay small (less than 1k)\n // NOTE: Session token can grow, especially in cases of using authorization, or adding custom claims\n sessionTokenViaCookie?: boolean;\n // If true, last authenticated user will be stored on local storage and can accessed with getUser function\n storeLastAuthenticatedUser?: boolean;\n // If true, last authenticated user will not be removed after logout\n keepLastAuthenticatedUserAfterLogout?: boolean;\n children?: React.ReactNode;\n}\n\nconst AuthProvider: FC<IAuthProviderProps> = ({\n projectId,\n baseUrl = '',\n baseStaticUrl = '',\n sessionTokenViaCookie = false,\n persistTokens = true,\n storeLastAuthenticatedUser = true,\n keepLastAuthenticatedUserAfterLogout = false,\n children = undefined,\n}) => {\n const [user, setUser] = useState<User>();\n const [session, setSession] = useState<string>();\n\n const [isUserLoading, setIsUserLoading] = useState(false);\n const [isSessionLoading, setIsSessionLoading] = useState(false);\n\n const sdk = useSdk({\n projectId,\n baseUrl,\n persistTokens,\n sessionTokenViaCookie,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n });\n\n useEffect(() => {\n if (sdk) {\n const unsubscribeSessionToken = sdk.onSessionTokenChange(setSession);\n const unsubscribeUser = sdk.onUserChange(setUser);\n\n return () => {\n unsubscribeSessionToken();\n unsubscribeUser();\n };\n }\n return undefined;\n }, [sdk]);\n\n const isSessionFetched = useRef(false);\n const isUserFetched = useRef(false);\n\n const fetchSession = useCallback(() => {\n // We want that the session will fetched only once\n if (isSessionFetched.current) return;\n isSessionFetched.current = true;\n\n setIsSessionLoading(true);\n withValidation(sdk?.refresh)().then(() => {\n setIsSessionLoading(false);\n });\n }, [sdk]);\n\n const fetchUser = useCallback(() => {\n // 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 isSessionLoading,\n isSessionFetched: isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n setUser,\n setSession,\n sdk,\n }),\n [\n fetchUser,\n user,\n isUserLoading,\n isUserFetched.current,\n fetchSession,\n session,\n isSessionLoading,\n isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n setUser,\n setSession,\n sdk,\n ],\n );\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport default AuthProvider;\n"],"names":["projectId","baseUrl","baseStaticUrl","sessionTokenViaCookie","persistTokens","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","children","user","setUser","useState","session","setSession","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","sdk","useSdk","useEffect","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","isSessionFetched","useRef","isUserFetched","fetchSession","useCallback","current","withValidation","refresh","then","fetchUser","me","value","useMemo","React","default","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 Context from '../../hooks/Context';\nimport { IContext, User } from '../../types';\nimport { withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ntype SameSite = 'Strict' | 'Lax' | 'None';\ninterface IAuthProviderProps {\n projectId: string;\n baseUrl?: string;\n // allows to override the base URL that is used to fetch static files\n baseStaticUrl?: string;\n // If true, tokens will be stored on local storage and can accessed with getToken function\n persistTokens?: boolean;\n // If true, session token (jwt) will be stored on cookie. Otherwise, the session token will be\n // stored on local storage and can accessed with getSessionToken function\n // Use this option if session token will stay small (less than 1k)\n // NOTE: Session token can grow, especially in cases of using authorization, or adding custom claims\n sessionTokenViaCookie?: boolean | { sameSite: SameSite };\n // If true, last authenticated user will be stored on local storage and can accessed with getUser function\n storeLastAuthenticatedUser?: boolean;\n // If true, last authenticated user will not be removed after logout\n keepLastAuthenticatedUserAfterLogout?: boolean;\n children?: React.ReactNode;\n}\n\nconst AuthProvider: FC<IAuthProviderProps> = ({\n projectId,\n baseUrl = '',\n baseStaticUrl = '',\n sessionTokenViaCookie = false,\n persistTokens = true,\n storeLastAuthenticatedUser = true,\n keepLastAuthenticatedUserAfterLogout = false,\n children = undefined,\n}) => {\n const [user, setUser] = useState<User>();\n const [session, setSession] = useState<string>();\n\n const [isUserLoading, setIsUserLoading] = useState(false);\n const [isSessionLoading, setIsSessionLoading] = useState(false);\n\n const sdk = useSdk({\n projectId,\n baseUrl,\n persistTokens,\n sessionTokenViaCookie,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n });\n\n useEffect(() => {\n if (sdk) {\n const unsubscribeSessionToken = sdk.onSessionTokenChange(setSession);\n const unsubscribeUser = sdk.onUserChange(setUser);\n\n return () => {\n unsubscribeSessionToken();\n unsubscribeUser();\n };\n }\n return undefined;\n }, [sdk]);\n\n const isSessionFetched = useRef(false);\n const isUserFetched = useRef(false);\n\n const fetchSession = useCallback(() => {\n // We want that the session will fetched only once\n if (isSessionFetched.current) return;\n isSessionFetched.current = true;\n\n setIsSessionLoading(true);\n withValidation(sdk?.refresh)().then(() => {\n setIsSessionLoading(false);\n });\n }, [sdk]);\n\n const fetchUser = useCallback(() => {\n // 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 isSessionLoading,\n isSessionFetched: isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n setUser,\n setSession,\n sdk,\n }),\n [\n fetchUser,\n user,\n isUserLoading,\n isUserFetched.current,\n fetchSession,\n session,\n isSessionLoading,\n isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n setUser,\n setSession,\n sdk,\n ],\n );\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport default AuthProvider;\n"],"names":["projectId","baseUrl","baseStaticUrl","sessionTokenViaCookie","persistTokens","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","children","user","setUser","useState","session","setSession","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","sdk","useSdk","useEffect","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","isSessionFetched","useRef","isUserFetched","fetchSession","useCallback","current","withValidation","refresh","then","fetchUser","me","value","useMemo","React","default","createElement","Context","Provider"],"mappings":"kQAiC6C,EAC3CA,YACAC,UAAU,GACVC,gBAAgB,GAChBC,yBAAwB,EACxBC,iBAAgB,EAChBC,8BAA6B,EAC7BC,wCAAuC,EACvCC,eAEA,MAAOC,EAAMC,GAAWC,EAAQA,YACzBC,EAASC,GAAcF,EAAQA,YAE/BG,EAAeC,GAAoBJ,EAAQA,UAAC,IAC5CK,EAAkBC,GAAuBN,EAAQA,UAAC,GAEnDO,EAAMC,EAAAA,QAAO,CACjBlB,YACAC,UACAG,gBACAD,wBACAE,6BACAC,yCAGFa,EAAAA,WAAU,KACR,GAAIF,EAAK,CACP,MAAMG,EAA0BH,EAAII,qBAAqBT,GACnDU,EAAkBL,EAAIM,aAAad,GAEzC,MAAO,KACLW,IACAE,GAAiB,CAEpB,CACe,GACf,CAACL,IAEJ,MAAMO,EAAmBC,UAAO,GAC1BC,EAAgBD,UAAO,GAEvBE,EAAeC,EAAAA,aAAY,KAE3BJ,EAAiBK,UACrBL,EAAiBK,SAAU,EAE3Bb,GAAoB,GACpBc,EAAAA,eAAeb,eAAAA,EAAKc,QAApBD,GAA+BE,MAAK,KAClChB,GAAoB,EAAM,IAC1B,GACD,CAACC,IAEEgB,EAAYL,EAAAA,aAAY,KAExBF,EAAcG,UAClBH,EAAcG,SAAU,EAExBf,GAAiB,GACjBgB,EAAAA,eAAeb,EAAIiB,GAAnBJ,GAAyBE,MAAK,KAC5BlB,GAAiB,EAAM,IACvB,GACD,CAACG,IAEEkB,EAAQC,EAAAA,SACZ,KAAO,CACLH,YACAzB,OACAK,gBACAa,cAAeA,EAAcG,QAC7BF,eACAhB,UACAI,mBACAS,iBAAkBA,EAAiBK,QACnC7B,YACAC,UACAC,gBACAG,6BACAC,uCACAG,UACAG,aACAK,SAEF,CACEgB,EACAzB,EACAK,EACAa,EAAcG,QACdF,EACAhB,EACAI,EACAS,EAAiBK,QACjB7B,EACAC,EACAC,EACAO,EACAG,EACAK,IAGJ,OAAOoB,EAAAC,QAAAC,cAACC,UAAQC,SAAQ,CAACN,MAAOA,GAAQ5B,EAA4B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Descope.js","sources":["../../../src/components/Descope.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\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 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>((props, ref) => (\n
|
|
1
|
+
{"version":3,"file":"Descope.js","sources":["../../../src/components/Descope.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\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 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>((props, ref) => (\n\t<descope-wc ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst Descope = React.forwardRef<HTMLElement, DescopeProps>(\n (\n {\n flowId,\n onSuccess,\n onError,\n onReady,\n logger,\n tenant,\n theme,\n locale,\n debug,\n client,\n form,\n telemetryKey,\n redirectUrl,\n autoFocus,\n validateOnBlur,\n restartOnError,\n errorTransformer,\n styleId,\n onScreenUpdate,\n children,\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 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 {...{\n // attributes\n 'theme.attr': theme,\n 'locale.attr': locale,\n 'form.attr': form,\n 'client.attr': client,\n 'debug.attr': debug,\n 'store-last-authenticated-user.attr': storeLastAuthenticatedUser,\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","props","ref","createElement","Object","assign","Descope","flowId","onSuccess","onError","onReady","logger","tenant","theme","locale","debug","client","form","telemetryKey","redirectUrl","autoFocus","validateOnBlur","restartOnError","errorTransformer","styleId","onScreenUpdate","children","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","sdk","useContext","Context","handleSuccess","useCallback","e","afterRequest","Response","JSON","stringify","detail","useEffect","ele","addEventListener","removeEventListener","Suspense","fallback"],"mappings":"uRAeA,MAAMA,EAAYC,EAAIA,MAACC,YAEnB,OAAAC,qBAAA,IAAAA,oBAAA,EAAAA,eAAgBC,IAAI,sBACbC,OAAO,0BAA0BC,MAAMC,GAAWA,EAAOC,WAErDC,mBAAqB,aAEhCC,EAAWA,YAIXC,eAAe,EACfC,MAAO,CACL,iBAAIC,GAIF,OAAOC,iBAAeC,WAAWH,MAAMC,aACxC,EACD,iBAAIA,CAAcG,GAGjB,IAIE,CACLR,QAASS,EAAgBT,QACvBU,UAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAAA,QAAYI,cAAA,aAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAMrBK,EAAUP,EAAKV,QAACW,YACpB,EAEIO,SACAC,YACAC,UACAC,UACAC,SACAC,SACAC,QACAC,SACAC,QACAC,SACAC,OACAC,eACAC,cACAC,YACAC,iBACAC,iBACAC,mBACAC,UACAC,iBACAC,YAEFxB,KAEA,MAAOyB,EAAUC,GAAeC,EAAQA,SAAC,MAEzCC,sBAAoB5B,GAAK,IAAMyB,IAE/B,MAAMI,UACJA,EAASC,QACTA,EAAOC,cACPA,EAAaC,WACbA,EAAUC,2BACVA,EAA0BC,qCAC1BA,EAAoCC,IACpCA,GACEtC,EAAAA,QAAMuC,WAAWC,EAAOlD,SAEtBmD,EAAgBC,eACpB1D,MAAO2D,UAGCL,EAAIzC,WAAWH,MAAMkD,aACzB,CAAA,EACA,IAAIC,SAASC,KAAKC,UAAUJ,EAAEK,UAE5BvC,GACFA,EAAUkC,EACX,GAEH,CAAClC,IA8CH,OA3CAwC,EAAAA,WAAU,KACR,MAAMC,EAAMtB,EAKZ,OAJAsB,SAAAA,EAAKC,iBAAiB,UAAWV,GAC7B/B,IAASwC,SAAAA,EAAKC,iBAAiB,QAASzC,IACxCC,IAASuC,SAAAA,EAAKC,iBAAiB,QAASxC,IAErC,KACDD,IAASwC,SAAAA,EAAKE,oBAAoB,QAAS1C,IAC3CC,IAASuC,SAAAA,EAAKE,oBAAoB,QAASzC,IAE/CuC,SAAAA,EAAKE,oBAAoB,UAAWX,EAAc,CACnD,GACA,CAACb,EAAUlB,EAAS+B,IAGvBQ,EAAAA,WAAU,KACR,MAAMC,EAAMtB,EAEZ,OADAsB,SAAAA,EAAKC,iBAAiB,UAAWV,GAC1B,KACLS,SAAAA,EAAKE,oBAAoB,UAAWX,EAAc,CACnD,GACA,CAACb,EAAUa,IAGdQ,EAAAA,WAAU,KACR,MAAMC,EAAMtB,EAGZ,OAFIlB,IAASwC,SAAAA,EAAKC,iBAAiB,QAASzC,IAErC,KACDA,IAASwC,SAAAA,EAAKE,oBAAoB,QAAS1C,GAAQ,CACxD,GACA,CAACkB,EAAUlB,IAGduC,EAAAA,WAAU,KACR,MAAMC,EAAMtB,EAGZ,OAFIjB,IAASuC,SAAAA,EAAKC,iBAAiB,QAASxC,IAErC,KACDA,IAASuC,SAAAA,EAAKE,oBAAoB,QAASzC,GAAQ,CACxD,GACA,CAACiB,EAAUjB,IASjBX,UAAAI,cAAA,OAAA,KACCJ,EAAAA,QAAAI,cAACiD,EAAAA,SAAQ,CAACC,SAAU,MACnBtD,EAACV,QAAAc,cAAAtB,EACQ,CAAAkD,UAAWA,EACXxB,OAAQA,EACRyB,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZhC,IAAK0B,EACLV,aAAcA,EACdC,YAAaA,EACbC,UAAWA,EACXI,QAASA,EACTH,eAAgBA,EAChBC,eAAgBA,EAChBc,qCACEA,EAEFxB,OAAQA,EAGN,aAAcC,EACd,cAAeC,EACf,YAAaG,EACb,cAAeD,EACf,aAAcD,EACd,qCAAsCoB,EAEtC,wBAAyBZ,EACzB,cAAeZ,EACf,sBAAuBc,GAGhCC,IAIC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoleManagement.js","sources":["../../../src/components/RoleManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } 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
|
|
1
|
+
{"version":3,"file":"RoleManagement.js","sources":["../../../src/components/RoleManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } 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 }, ref) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl } =\n React.useContext(Context);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<RoleManagementWC\n projectId={projectId}\n widgetId={widgetId}\n tenant={tenant}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n innerRef={setInnerRef}\n {...{\n // attributes\n 'theme.attr': theme,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\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","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","useContext","Context","Suspense","fallback"],"mappings":"mOAMA,MAAMA,EAAmBC,EAAIA,MAACC,gBACtBC,OAAO,mCAEN,CACLC,QAASC,EAAgBD,QACvBE,UAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAAA,QAAgCI,cAAA,iCAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAMzCK,EAAiBP,EAAKF,QAACG,YAC3B,EAAGO,SAAQC,SAAQC,QAAOC,QAAOC,WAAUC,WAAWV,KACpD,MAAOW,EAAUC,GAAeC,EAAQA,SAAC,MAEzCC,sBAAoBd,GAAK,IAAMW,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,GACzCrB,EAAKF,QAACwB,WAAWC,EAAAA,SAEnB,OACHvB,EAACF,QAAAM,cAAAoB,EAAQA,SAAC,CAAAC,SAAU,MACnBzB,EAAAF,QAAAM,cAACV,EAAgB,CACTwB,UAAWA,EACXN,SAAUA,EACVH,OAAQA,EACRU,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZP,SAAUC,EAGR,aAAcL,EACd,aAAcC,EACd,eAAgBE,EAEhB,cAAeL,IAIrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserManagement.js","sources":["../../../src/components/UserManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } 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
|
|
1
|
+
{"version":3,"file":"UserManagement.js","sources":["../../../src/components/UserManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } 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 }, ref) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl } =\n React.useContext(Context);\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 // 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","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","useContext","Context","Suspense","fallback"],"mappings":"mOAMA,MAAMA,EAAmBC,EAAIA,MAACC,gBACtBC,OAAO,mCAEN,CACLC,QAASC,EAAgBD,QACvBE,UAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAAA,QAAgCI,cAAA,iCAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAMzCK,EAAiBP,EAAKF,QAACG,YAC3B,EAAGO,SAAQC,SAAQC,QAAOC,QAAOC,WAAUC,WAAWV,KACpD,MAAOW,EAAUC,GAAeC,EAAQA,SAAC,MAEzCC,sBAAoBd,GAAK,IAAMW,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,GACzCrB,EAAKF,QAACwB,WAAWC,EAAAA,SAEnB,OACHvB,EAACF,QAAAM,cAAAoB,EAAQA,SAAC,CAAAC,SAAU,MACnBzB,EAAAF,QAAAM,cAACV,EAAgB,CACTwB,UAAWA,EACXN,SAAUA,EACVH,OAAQA,EACRU,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZlB,IAAKY,EAGH,aAAcL,EACd,aAAcC,EACd,eAAgBE,EAEhB,cAAeL,IAIrB"}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const e="undefined"!=typeof window;exports.IS_BROWSER=e,exports.baseHeaders={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.
|
|
1
|
+
"use strict";const e="undefined"!=typeof window;exports.IS_BROWSER=e,exports.baseHeaders={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.6.0"};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessKeyManagement.js","sources":["../../../src/components/AccessKeyManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } from 'react';\nimport Context from '../hooks/Context';\nimport { AccessKeyManagementProps } 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 AccessKeyManagementWC = lazy(async () => {\n await import('@descope/access-key-management-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n
|
|
1
|
+
{"version":3,"file":"AccessKeyManagement.js","sources":["../../../src/components/AccessKeyManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } from 'react';\nimport Context from '../hooks/Context';\nimport { AccessKeyManagementProps } 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 AccessKeyManagementWC = lazy(async () => {\n await import('@descope/access-key-management-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-access-key-management-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst AccessKeyManagement = React.forwardRef<\n HTMLElement,\n AccessKeyManagementProps\n>(({ logger, tenant, theme, debug, widgetId, styleId }, ref) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl } =\n React.useContext(Context);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<AccessKeyManagementWC\n projectId={projectId}\n widgetId={widgetId}\n tenant={tenant}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n innerRef={setInnerRef}\n {...{\n // attributes\n 'theme.attr': theme,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n // props\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n});\n\nexport default AccessKeyManagement;\n"],"names":["AccessKeyManagementWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","AccessKeyManagement","logger","tenant","theme","debug","widgetId","styleId","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","useContext","Context","Suspense","fallback"],"mappings":"mKAMA,MAAMA,EAAwBC,GAAKC,gBAC3BC,OAAO,yCAEN,CACLC,QAASC,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAsCI,cAAA,uCAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAM/CK,EAAsBP,EAAMC,YAGhC,EAAGO,SAAQC,SAAQC,QAAOC,QAAOC,WAAUC,WAAWV,KACtD,MAAOW,EAAUC,GAAeC,EAAS,MAEzCC,EAAoBd,GAAK,IAAMW,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,GACzCrB,EAAMsB,WAAWC,GAEnB,OACDvB,EAACI,cAAAoB,EAAS,CAAAC,SAAU,MACnBzB,EAAAI,cAACV,EAAqB,CAChBwB,UAAWA,EACXN,SAAUA,EACVH,OAAQA,EACRU,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZP,SAAUC,EAGR,aAAcL,EACd,aAAcC,EACd,eAAgBE,EAEhB,cAAeL,IAIrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationsPortal.js","sources":["../../../src/components/ApplicationsPortal.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } from 'react';\nimport Context from '../hooks/Context';\nimport { ApplicationsPortalProps } 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 ApplicationsPortalWC = lazy(async () => {\n await import('@descope/applications-portal-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n
|
|
1
|
+
{"version":3,"file":"ApplicationsPortal.js","sources":["../../../src/components/ApplicationsPortal.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } from 'react';\nimport Context from '../hooks/Context';\nimport { ApplicationsPortalProps } 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 ApplicationsPortalWC = lazy(async () => {\n await import('@descope/applications-portal-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-applications-portal-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst ApplicationsPortal = React.forwardRef<\n HTMLElement,\n ApplicationsPortalProps\n>(({ logger, theme, debug, widgetId, styleId }, ref) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl } =\n React.useContext(Context);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<ApplicationsPortalWC\n projectId={projectId}\n widgetId={widgetId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n innerRef={setInnerRef}\n {...{\n // attributes\n 'theme.attr': theme,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n // props\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n});\n\nexport default ApplicationsPortal;\n"],"names":["ApplicationsPortalWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","ApplicationsPortal","logger","theme","debug","widgetId","styleId","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","useContext","Context","Suspense","fallback"],"mappings":"mKAMA,MAAMA,EAAuBC,GAAKC,gBAC1BC,OAAO,uCAEN,CACLC,QAASC,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAoCI,cAAA,qCAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAM7CK,EAAqBP,EAAMC,YAG/B,EAAGO,SAAQC,QAAOC,QAAOC,WAAUC,WAAWT,KAC9C,MAAOU,EAAUC,GAAeC,EAAS,MAEzCC,EAAoBb,GAAK,IAAMU,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,GACzCpB,EAAMqB,WAAWC,GAEnB,OACDtB,EAACI,cAAAmB,EAAS,CAAAC,SAAU,MACnBxB,EAACI,cAAAV,EACK,CAAAuB,UAAWA,EACXN,SAAUA,EACVO,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZP,SAAUC,EAGR,aAAcL,EACd,aAAcC,EACd,eAAgBE,EAEhB,cAAeJ,IAIrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuditManagement.js","sources":["../../../src/components/AuditManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } from 'react';\nimport Context from '../hooks/Context';\nimport { AuditManagementProps } 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 AuditManagementWC = lazy(async () => {\n await import('@descope/audit-management-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n
|
|
1
|
+
{"version":3,"file":"AuditManagement.js","sources":["../../../src/components/AuditManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } from 'react';\nimport Context from '../hooks/Context';\nimport { AuditManagementProps } 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 AuditManagementWC = lazy(async () => {\n await import('@descope/audit-management-widget');\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-audit-management-widget ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst AuditManagement = React.forwardRef<HTMLElement, AuditManagementProps>(\n ({ logger, tenant, theme, debug, widgetId, styleId }, ref) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl } =\n React.useContext(Context);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<AuditManagementWC\n projectId={projectId}\n widgetId={widgetId}\n tenant={tenant}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n innerRef={setInnerRef}\n {...{\n // attributes\n 'theme.attr': theme,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\n // props\n 'logger.prop': logger,\n }}\n />\n\t</Suspense>\n );\n },\n);\n\nexport default AuditManagement;\n"],"names":["AuditManagementWC","lazy","async","import","default","withPropsMapping","React","forwardRef","props","ref","createElement","Object","assign","AuditManagement","logger","tenant","theme","debug","widgetId","styleId","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","useContext","Context","Suspense","fallback"],"mappings":"mKAMA,MAAMA,EAAoBC,GAAKC,gBACvBC,OAAO,oCAEN,CACLC,QAASC,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAiCI,cAAA,kCAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAM1CK,EAAkBP,EAAMC,YAC5B,EAAGO,SAAQC,SAAQC,QAAOC,QAAOC,WAAUC,WAAWV,KACpD,MAAOW,EAAUC,GAAeC,EAAS,MAEzCC,EAAoBd,GAAK,IAAMW,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,GACzCrB,EAAMsB,WAAWC,GAEnB,OACHvB,EAACI,cAAAoB,EAAS,CAAAC,SAAU,MACnBzB,EAAAI,cAACV,EAAiB,CACVwB,UAAWA,EACXN,SAAUA,EACVH,OAAQA,EACRU,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZP,SAAUC,EAGR,aAAcL,EACd,aAAcC,EACd,eAAgBE,EAEhB,cAAeL,IAIrB"}
|
|
@@ -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 Context from '../../hooks/Context';\nimport { IContext, User } from '../../types';\nimport { withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ninterface IAuthProviderProps {\n projectId: string;\n baseUrl?: string;\n // allows to override the base URL that is used to fetch static files\n baseStaticUrl?: string;\n // If true, tokens will be stored on local storage and can accessed with getToken function\n persistTokens?: boolean;\n // If true, session token (jwt) will be stored on cookie. Otherwise, the session token will be\n // stored on local storage and can accessed with getSessionToken function\n // Use this option if session token will stay small (less than 1k)\n // NOTE: Session token can grow, especially in cases of using authorization, or adding custom claims\n sessionTokenViaCookie?: boolean;\n // If true, last authenticated user will be stored on local storage and can accessed with getUser function\n storeLastAuthenticatedUser?: boolean;\n // If true, last authenticated user will not be removed after logout\n keepLastAuthenticatedUserAfterLogout?: boolean;\n children?: React.ReactNode;\n}\n\nconst AuthProvider: FC<IAuthProviderProps> = ({\n projectId,\n baseUrl = '',\n baseStaticUrl = '',\n sessionTokenViaCookie = false,\n persistTokens = true,\n storeLastAuthenticatedUser = true,\n keepLastAuthenticatedUserAfterLogout = false,\n children = undefined,\n}) => {\n const [user, setUser] = useState<User>();\n const [session, setSession] = useState<string>();\n\n const [isUserLoading, setIsUserLoading] = useState(false);\n const [isSessionLoading, setIsSessionLoading] = useState(false);\n\n const sdk = useSdk({\n projectId,\n baseUrl,\n persistTokens,\n sessionTokenViaCookie,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n });\n\n useEffect(() => {\n if (sdk) {\n const unsubscribeSessionToken = sdk.onSessionTokenChange(setSession);\n const unsubscribeUser = sdk.onUserChange(setUser);\n\n return () => {\n unsubscribeSessionToken();\n unsubscribeUser();\n };\n }\n return undefined;\n }, [sdk]);\n\n const isSessionFetched = useRef(false);\n const isUserFetched = useRef(false);\n\n const fetchSession = useCallback(() => {\n // We want that the session will fetched only once\n if (isSessionFetched.current) return;\n isSessionFetched.current = true;\n\n setIsSessionLoading(true);\n withValidation(sdk?.refresh)().then(() => {\n setIsSessionLoading(false);\n });\n }, [sdk]);\n\n const fetchUser = useCallback(() => {\n // 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 isSessionLoading,\n isSessionFetched: isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n setUser,\n setSession,\n sdk,\n }),\n [\n fetchUser,\n user,\n isUserLoading,\n isUserFetched.current,\n fetchSession,\n session,\n isSessionLoading,\n isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n setUser,\n setSession,\n sdk,\n ],\n );\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport default AuthProvider;\n"],"names":["AuthProvider","projectId","baseUrl","baseStaticUrl","sessionTokenViaCookie","persistTokens","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","children","user","setUser","useState","session","setSession","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","sdk","useSdk","useEffect","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","isSessionFetched","useRef","isUserFetched","fetchSession","useCallback","current","withValidation","refresh","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 Context from '../../hooks/Context';\nimport { IContext, User } from '../../types';\nimport { withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ntype SameSite = 'Strict' | 'Lax' | 'None';\ninterface IAuthProviderProps {\n projectId: string;\n baseUrl?: string;\n // allows to override the base URL that is used to fetch static files\n baseStaticUrl?: string;\n // If true, tokens will be stored on local storage and can accessed with getToken function\n persistTokens?: boolean;\n // If true, session token (jwt) will be stored on cookie. Otherwise, the session token will be\n // stored on local storage and can accessed with getSessionToken function\n // Use this option if session token will stay small (less than 1k)\n // NOTE: Session token can grow, especially in cases of using authorization, or adding custom claims\n sessionTokenViaCookie?: boolean | { sameSite: SameSite };\n // If true, last authenticated user will be stored on local storage and can accessed with getUser function\n storeLastAuthenticatedUser?: boolean;\n // If true, last authenticated user will not be removed after logout\n keepLastAuthenticatedUserAfterLogout?: boolean;\n children?: React.ReactNode;\n}\n\nconst AuthProvider: FC<IAuthProviderProps> = ({\n projectId,\n baseUrl = '',\n baseStaticUrl = '',\n sessionTokenViaCookie = false,\n persistTokens = true,\n storeLastAuthenticatedUser = true,\n keepLastAuthenticatedUserAfterLogout = false,\n children = undefined,\n}) => {\n const [user, setUser] = useState<User>();\n const [session, setSession] = useState<string>();\n\n const [isUserLoading, setIsUserLoading] = useState(false);\n const [isSessionLoading, setIsSessionLoading] = useState(false);\n\n const sdk = useSdk({\n projectId,\n baseUrl,\n persistTokens,\n sessionTokenViaCookie,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n });\n\n useEffect(() => {\n if (sdk) {\n const unsubscribeSessionToken = sdk.onSessionTokenChange(setSession);\n const unsubscribeUser = sdk.onUserChange(setUser);\n\n return () => {\n unsubscribeSessionToken();\n unsubscribeUser();\n };\n }\n return undefined;\n }, [sdk]);\n\n const isSessionFetched = useRef(false);\n const isUserFetched = useRef(false);\n\n const fetchSession = useCallback(() => {\n // We want that the session will fetched only once\n if (isSessionFetched.current) return;\n isSessionFetched.current = true;\n\n setIsSessionLoading(true);\n withValidation(sdk?.refresh)().then(() => {\n setIsSessionLoading(false);\n });\n }, [sdk]);\n\n const fetchUser = useCallback(() => {\n // 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 isSessionLoading,\n isSessionFetched: isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n setUser,\n setSession,\n sdk,\n }),\n [\n fetchUser,\n user,\n isUserLoading,\n isUserFetched.current,\n fetchSession,\n session,\n isSessionLoading,\n isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n setUser,\n setSession,\n sdk,\n ],\n );\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport default AuthProvider;\n"],"names":["AuthProvider","projectId","baseUrl","baseStaticUrl","sessionTokenViaCookie","persistTokens","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","children","user","setUser","useState","session","setSession","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","sdk","useSdk","useEffect","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","isSessionFetched","useRef","isUserFetched","fetchSession","useCallback","current","withValidation","refresh","then","fetchUser","me","value","useMemo","React","createElement","Context","Provider"],"mappings":"8MAiCA,MAAMA,EAAuC,EAC3CC,YACAC,UAAU,GACVC,gBAAgB,GAChBC,yBAAwB,EACxBC,iBAAgB,EAChBC,8BAA6B,EAC7BC,wCAAuC,EACvCC,eAEA,MAAOC,EAAMC,GAAWC,KACjBC,EAASC,GAAcF,KAEvBG,EAAeC,GAAoBJ,GAAS,IAC5CK,EAAkBC,GAAuBN,GAAS,GAEnDO,EAAMC,EAAO,CACjBlB,YACAC,UACAG,gBACAD,wBACAE,6BACAC,yCAGFa,GAAU,KACR,GAAIF,EAAK,CACP,MAAMG,EAA0BH,EAAII,qBAAqBT,GACnDU,EAAkBL,EAAIM,aAAad,GAEzC,MAAO,KACLW,IACAE,GAAiB,CAEpB,CACe,GACf,CAACL,IAEJ,MAAMO,EAAmBC,GAAO,GAC1BC,EAAgBD,GAAO,GAEvBE,EAAeC,GAAY,KAE3BJ,EAAiBK,UACrBL,EAAiBK,SAAU,EAE3Bb,GAAoB,GACpBc,EAAeb,eAAAA,EAAKc,QAApBD,GAA+BE,MAAK,KAClChB,GAAoB,EAAM,IAC1B,GACD,CAACC,IAEEgB,EAAYL,GAAY,KAExBF,EAAcG,UAClBH,EAAcG,SAAU,EAExBf,GAAiB,GACjBgB,EAAeb,EAAIiB,GAAnBJ,GAAyBE,MAAK,KAC5BlB,GAAiB,EAAM,IACvB,GACD,CAACG,IAEEkB,EAAQC,GACZ,KAAO,CACLH,YACAzB,OACAK,gBACAa,cAAeA,EAAcG,QAC7BF,eACAhB,UACAI,mBACAS,iBAAkBA,EAAiBK,QACnC7B,YACAC,UACAC,gBACAG,6BACAC,uCACAG,UACAG,aACAK,SAEF,CACEgB,EACAzB,EACAK,EACAa,EAAcG,QACdF,EACAhB,EACAI,EACAS,EAAiBK,QACjB7B,EACAC,EACAC,EACAO,EACAG,EACAK,IAGJ,OAAOoB,EAAAC,cAACC,EAAQC,SAAQ,CAACL,MAAOA,GAAQ5B,EAA4B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Descope.js","sources":["../../../src/components/Descope.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\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 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>((props, ref) => (\n
|
|
1
|
+
{"version":3,"file":"Descope.js","sources":["../../../src/components/Descope.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\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 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>((props, ref) => (\n\t<descope-wc ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst Descope = React.forwardRef<HTMLElement, DescopeProps>(\n (\n {\n flowId,\n onSuccess,\n onError,\n onReady,\n logger,\n tenant,\n theme,\n locale,\n debug,\n client,\n form,\n telemetryKey,\n redirectUrl,\n autoFocus,\n validateOnBlur,\n restartOnError,\n errorTransformer,\n styleId,\n onScreenUpdate,\n children,\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 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 {...{\n // attributes\n 'theme.attr': theme,\n 'locale.attr': locale,\n 'form.attr': form,\n 'client.attr': client,\n 'debug.attr': debug,\n 'store-last-authenticated-user.attr': storeLastAuthenticatedUser,\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","props","ref","createElement","Object","assign","Descope","flowId","onSuccess","onError","onReady","logger","tenant","theme","locale","debug","client","form","telemetryKey","redirectUrl","autoFocus","validateOnBlur","restartOnError","errorTransformer","styleId","onScreenUpdate","children","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","sdk","useContext","Context","handleSuccess","useCallback","e","afterRequest","Response","JSON","stringify","detail","useEffect","ele","addEventListener","removeEventListener","Suspense","fallback"],"mappings":"0RAeA,MAAMA,EAAYC,GAAKC,YAEnB,OAAAC,qBAAA,IAAAA,oBAAA,EAAAA,eAAgBC,IAAI,sBACbC,OAAO,0BAA0BC,MAAMC,GAAWA,EAAOC,WAErDC,mBAAqB,CAEhCC,cAIAC,eAAe,EACfC,MAAO,CACL,iBAAIC,GAIF,OAAOC,IAAeC,WAAWH,MAAMC,aACxC,EACD,iBAAIA,CAAcG,GAGjB,IAIE,CACLR,QAASS,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAYI,cAAA,aAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAMrBK,EAAUP,EAAMC,YACpB,EAEIO,SACAC,YACAC,UACAC,UACAC,SACAC,SACAC,QACAC,SACAC,QACAC,SACAC,OACAC,eACAC,cACAC,YACAC,iBACAC,iBACAC,mBACAC,UACAC,iBACAC,YAEFxB,KAEA,MAAOyB,EAAUC,GAAeC,EAAS,MAEzCC,EAAoB5B,GAAK,IAAMyB,IAE/B,MAAMI,UACJA,EAASC,QACTA,EAAOC,cACPA,EAAaC,WACbA,EAAUC,2BACVA,EAA0BC,qCAC1BA,EAAoCC,IACpCA,GACEtC,EAAMuC,WAAWC,GAEfC,EAAgBC,GACpB1D,MAAO2D,UAGCL,EAAIzC,WAAWH,MAAMkD,aACzB,CAAA,EACA,IAAIC,SAASC,KAAKC,UAAUJ,EAAEK,UAE5BvC,GACFA,EAAUkC,EACX,GAEH,CAAClC,IA8CH,OA3CAwC,GAAU,KACR,MAAMC,EAAMtB,EAKZ,OAJAsB,SAAAA,EAAKC,iBAAiB,UAAWV,GAC7B/B,IAASwC,SAAAA,EAAKC,iBAAiB,QAASzC,IACxCC,IAASuC,SAAAA,EAAKC,iBAAiB,QAASxC,IAErC,KACDD,IAASwC,SAAAA,EAAKE,oBAAoB,QAAS1C,IAC3CC,IAASuC,SAAAA,EAAKE,oBAAoB,QAASzC,IAE/CuC,SAAAA,EAAKE,oBAAoB,UAAWX,EAAc,CACnD,GACA,CAACb,EAAUlB,EAAS+B,IAGvBQ,GAAU,KACR,MAAMC,EAAMtB,EAEZ,OADAsB,SAAAA,EAAKC,iBAAiB,UAAWV,GAC1B,KACLS,SAAAA,EAAKE,oBAAoB,UAAWX,EAAc,CACnD,GACA,CAACb,EAAUa,IAGdQ,GAAU,KACR,MAAMC,EAAMtB,EAGZ,OAFIlB,IAASwC,SAAAA,EAAKC,iBAAiB,QAASzC,IAErC,KACDA,IAASwC,SAAAA,EAAKE,oBAAoB,QAAS1C,GAAQ,CACxD,GACA,CAACkB,EAAUlB,IAGduC,GAAU,KACR,MAAMC,EAAMtB,EAGZ,OAFIjB,IAASuC,SAAAA,EAAKC,iBAAiB,QAASxC,IAErC,KACDA,IAASuC,SAAAA,EAAKE,oBAAoB,QAASzC,GAAQ,CACxD,GACA,CAACiB,EAAUjB,IASjBX,EAAAI,cAAA,OAAA,KACCJ,EAAAI,cAACiD,EAAQ,CAACC,SAAU,MACnBtD,EAACI,cAAAtB,EACQ,CAAAkD,UAAWA,EACXxB,OAAQA,EACRyB,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZhC,IAAK0B,EACLV,aAAcA,EACdC,YAAaA,EACbC,UAAWA,EACXI,QAASA,EACTH,eAAgBA,EAChBC,eAAgBA,EAChBc,qCACEA,EAEFxB,OAAQA,EAGN,aAAcC,EACd,cAAeC,EACf,YAAaG,EACb,cAAeD,EACf,aAAcD,EACd,qCAAsCoB,EAEtC,wBAAyBZ,EACzB,cAAeZ,EACf,sBAAuBc,GAGhCC,IAIC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoleManagement.js","sources":["../../../src/components/RoleManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } 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
|
|
1
|
+
{"version":3,"file":"RoleManagement.js","sources":["../../../src/components/RoleManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } 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 }, ref) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl } =\n React.useContext(Context);\n\n return (\n\t<Suspense fallback={null}>\n\t\t<RoleManagementWC\n projectId={projectId}\n widgetId={widgetId}\n tenant={tenant}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n innerRef={setInnerRef}\n {...{\n // attributes\n 'theme.attr': theme,\n 'debug.attr': debug,\n 'styleId.attr': styleId,\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","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","useContext","Context","Suspense","fallback"],"mappings":"mKAMA,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,WAAWV,KACpD,MAAOW,EAAUC,GAAeC,EAAS,MAEzCC,EAAoBd,GAAK,IAAMW,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,GACzCrB,EAAMsB,WAAWC,GAEnB,OACHvB,EAACI,cAAAoB,EAAS,CAAAC,SAAU,MACnBzB,EAAAI,cAACV,EAAgB,CACTwB,UAAWA,EACXN,SAAUA,EACVH,OAAQA,EACRU,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZP,SAAUC,EAGR,aAAcL,EACd,aAAcC,EACd,eAAgBE,EAEhB,cAAeL,IAIrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserManagement.js","sources":["../../../src/components/UserManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } 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
|
|
1
|
+
{"version":3,"file":"UserManagement.js","sources":["../../../src/components/UserManagement.tsx"],"sourcesContent":["import React, { lazy, Suspense, useImperativeHandle, useState } 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 }, ref) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const { projectId, baseUrl, baseStaticUrl, baseCdnUrl } =\n React.useContext(Context);\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 // 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","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","useContext","Context","Suspense","fallback"],"mappings":"mKAMA,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,WAAWV,KACpD,MAAOW,EAAUC,GAAeC,EAAS,MAEzCC,EAAoBd,GAAK,IAAMW,IAE/B,MAAMI,UAAEA,EAASC,QAAEA,EAAOC,cAAEA,EAAaC,WAAEA,GACzCrB,EAAMsB,WAAWC,GAEnB,OACHvB,EAACI,cAAAoB,EAAS,CAAAC,SAAU,MACnBzB,EAAAI,cAACV,EAAgB,CACTwB,UAAWA,EACXN,SAAUA,EACVH,OAAQA,EACRU,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZlB,IAAKY,EAGH,aAAcL,EACd,aAAcC,EACd,eAAgBE,EAEhB,cAAeL,IAIrB"}
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.
|
|
1
|
+
const e={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.6.0"},d="undefined"!=typeof window;export{d as IS_BROWSER,e as baseHeaders};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -11,12 +11,15 @@ import ApplicationsPortalWidget from '@descope/applications-portal-widget';
|
|
|
11
11
|
import * as _descope_web_js_sdk from '@descope/web-js-sdk';
|
|
12
12
|
import * as _1 from '@descope/core-js-sdk';
|
|
13
13
|
|
|
14
|
+
type SameSite = 'Strict' | 'Lax' | 'None';
|
|
14
15
|
interface IAuthProviderProps {
|
|
15
16
|
projectId: string;
|
|
16
17
|
baseUrl?: string;
|
|
17
18
|
baseStaticUrl?: string;
|
|
18
19
|
persistTokens?: boolean;
|
|
19
|
-
sessionTokenViaCookie?: boolean
|
|
20
|
+
sessionTokenViaCookie?: boolean | {
|
|
21
|
+
sameSite: SameSite;
|
|
22
|
+
};
|
|
20
23
|
storeLastAuthenticatedUser?: boolean;
|
|
21
24
|
keepLastAuthenticatedUserAfterLogout?: boolean;
|
|
22
25
|
children?: React.ReactNode;
|
|
@@ -67,10 +70,14 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
67
70
|
storeLastAuthenticatedUser?: boolean;
|
|
68
71
|
keepLastAuthenticatedUserAfterLogout?: boolean;
|
|
69
72
|
} & {
|
|
70
|
-
persistTokens?: boolean
|
|
73
|
+
persistTokens?: boolean | {
|
|
74
|
+
sameSite: "Strict" | "Lax" | "None";
|
|
75
|
+
};
|
|
71
76
|
storagePrefix?: string;
|
|
72
77
|
preview?: boolean;
|
|
73
|
-
sessionTokenViaCookie?: boolean
|
|
78
|
+
sessionTokenViaCookie?: boolean | {
|
|
79
|
+
sameSite: "Strict" | "Lax" | "None";
|
|
80
|
+
};
|
|
74
81
|
}>(config: P) => ((({
|
|
75
82
|
refresh: (token?: string) => Promise<_1.SdkResponse<_1.JWTResponse>>;
|
|
76
83
|
flow: {
|