@descope/react-sdk 2.17.1 → 2.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Descope.js.map +1 -1
- package/dist/cjs/constants.js +1 -1
- package/dist/esm/components/Descope.js.map +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/index.d.ts +12 -147
- package/dist/index.umd.js +2 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/types/sdk.d.ts +30 -423
- package/package.json +12 -12
|
@@ -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\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":"saAiBA,MAAMA,EAAYC,EAAIA,MAACC,YAWnB,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,EAAKV,QAACW,YACJ,CAACC,EAA6DC,SAA3D,sBAAuBC,GAAiBF,EAAKG,EAAKC,EAAAA,OAAAJ,EAApD,yBAMC,OAJAK,EAAAA,SAAQ,KAtCY,IAACC,EAAaC,EAAbD,EAuCC,kBAvCYC,EAuCML,GArC5CZ,cAAYgB,GAAOC,SAEZjB,EAAAA,YAAYgB,EAmC2C,GACvD,CAACJ,IAEGJ,oDAAYG,IAAKA,GAASE,GAAS,SAO9CK,EAAUV,EAAKV,QAACW,YACpB,EAEIU,SACAC,YACAC,UACAC,UACAC,SACAC,SACAC,QACAC,QACAC,SACAC,QACAC,SACAC,OACAC,eACAC,c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MvB,EAGZ,OAFIrB,IAAS4C,SAAAA,EAAKC,iBAAiB,QAAS7C,IAErC,KACDA,IAAS4C,SAAAA,EAAKE,oBAAoB,QAAS9C,GAAQ,CACxD,GACA,CAACqB,EAAUrB,IASjBd,UAAA6D,cAAA,OAAA,KACC7D,EAAAA,QAAA6D,cAACC,EAAAA,SAAQ,CAACC,SAAU,MACnB/D,EAAAV,QAAAuE,cAAC/E,EAAS,CACDyD,UAAWA,EACX5B,OAAQA,EACR6B,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZvC,IAAKiC,EACLb,aAAcA,EACdC,YAAaA,EACbC,UAAWA,EACXI,QAASA,EACTH,eAAgBA,EAChBC,eAAgBA,EAChBiB,qCACEA,EAEF5B,OAAQA,EACRZ,kBAAmBA,EAGjB,aAAca,EACd,aAAcC,EACd,cAAeC,EACf,YAAaG,EACb,cAAeD,EACf,aAAcD,EACd,uBAAwBY,EACxB,2BAA4BC,EAC5B,qCAAsCU,EACtC,yBAA0BE,EAC1B,qCAAsCd,EAEtC,wBAAyBH,EACzB,cAAeb,EACf,sBAAuBe,GAGhCI,IAIC"}
|
|
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":"saAiBA,MAAMA,EAAYC,EAAIA,MAACC,YAUnB,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,EAAKV,QAACW,YACJ,CAACC,EAA6DC,SAA3D,sBAAuBC,GAAiB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C,EAAMvB,EAEZ,OADAuB,SAAAA,EAAKC,iBAAiB,UAAWV,GAC1B,KACLS,SAAAA,EAAKE,oBAAoB,UAAWX,EAAc,CACnD,GACA,CAACd,EAAUc,IAGdQ,EAAAA,WAAU,KACR,MAAMC,EAAMvB,EAGZ,OAFItB,IAAS6C,SAAAA,EAAKC,iBAAiB,QAAS9C,IAErC,KACDA,IAAS6C,SAAAA,EAAKE,oBAAoB,QAAS/C,GAAQ,CACxD,GACA,CAACsB,EAAUtB,IAGd4C,EAAAA,WAAU,KACR,MAAMC,EAAMvB,EAGZ,OAFIrB,IAAS4C,SAAAA,EAAKC,iBAAiB,QAAS7C,IAErC,KACDA,IAAS4C,SAAAA,EAAKE,oBAAoB,QAAS9C,GAAQ,CACxD,GACA,CAACqB,EAAUrB,IASjBd,UAAA6D,cAAA,OAAA,KACC7D,EAAAA,QAAA6D,cAACC,EAAAA,SAAQ,CAACC,SAAU,MACnB/D,EAAAV,QAAAuE,cAAC/E,EAAS,CACDyD,UAAWA,EACX5B,OAAQA,EACR6B,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZvC,IAAKiC,EACLb,aAAcA,EACdC,YAAaA,EACbC,UAAWA,EACXI,QAASA,EACTH,eAAgBA,EAChBC,eAAgBA,EAChBiB,qCACEA,EAEF5B,OAAQA,EACRZ,kBAAmBA,EAGjB,aAAca,EACd,aAAcC,EACd,cAAeC,EACf,YAAaG,EACb,cAAeD,EACf,aAAcD,EACd,uBAAwBY,EACxB,2BAA4BC,EAC5B,qCAAsCU,EACtC,yBAA0BE,EAC1B,qCAAsCd,EAEtC,wBAAyBH,EACzB,cAAeb,EACf,sBAAuBe,GAGhCI,IAIC"}
|
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.18.1"};
|
|
2
2
|
//# sourceMappingURL=constants.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\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":"kcAiBA,MAAMA,EAAYC,GAAKC,YAWnB,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,YACJ,CAACC,EAA6DC,SAA3D,sBAAuBC,GAAiBF,EAAKG,EAAKC,EAAAJ,EAApD,yBAMC,OAJAK,GAAQ,KAtCY,IAACC,EAAaC,EAAbD,EAuCC,kBAvCYC,EAuCML,GArC5CZ,EAAYgB,GAAOC,SAEZjB,EAAYgB,EAmC2C,GACvD,CAACJ,IAEGJ,4CAAYG,IAAKA,GAASE,GAAS,SAO9CK,EAAUV,EAAMC,YACpB,EAEIU,SACAC,YACAC,UACAC,UACAC,SACAC,SACAC,QACAC,QACAC,SACAC,QACAC,SACAC,OACAC,eACAC,cACAC,YACAC,iBACAC,iBACAC,mBACAC,UACAC,iBACAC,4BACAC,gBACAC,oBACAC,WACA9B,qBAEFD,KAEA,MAAOgC,EAAUC,GAAeC,EAAS,MAEzCC,EAAoBnC,GAAK,IAAMgC,IAE/B,MAAMI,UACJA,EAASC,QACTA,EAAOC,cACPA,EAAaC,WACbA,EAAUC,2BACVA,EAA0BC,qCAC1BA,EAAoCC,kBACpCA,EAAiBC,IACjBA,GACE9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b,aAAcA,EACdC,YAAaA,EACbC,UAAWA,EACXI,QAASA,EACTH,eAAgBA,EAChBC,eAAgBA,EAChBiB,qCACEA,EAEF5B,OAAQA,EACRZ,kBAAmBA,EAGjB,aAAca,EACd,aAAcC,EACd,cAAeC,EACf,YAAaG,EACb,cAAeD,EACf,aAAcD,EACd,uBAAwBY,EACxB,2BAA4BC,EAC5B,qCAAsCU,EACtC,yBAA0BE,EAC1B,qCAAsCd,EAEtC,wBAAyBH,EACzB,cAAeb,EACf,sBAAuBe,GAGhCI,IAIC"}
|
|
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":"kcAiBA,MAAMA,EAAYC,GAAKC,YAUnB,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,YACJ,CAACC,EAA6DC,SAA3D,sBAAuBC,GAAiBF,EAAKG,EAAKC,EAAAJ,EAApD,yBAMC,OAJAK,GAAQ,KAtCY,IAACC,EAAaC,EAAbD,EAuCC,kBAvCYC,EAuCML,GArC5CZ,EAAYgB,GAAOC,SAEZjB,EAAYgB,EAmC2C,GACvD,CAACJ,IAEGJ,4CAAYG,IAAKA,GAASE,GAAS,SAO9CK,EAAUV,EAAMC,YACpB,EAEIU,SACAC,YACAC,UACAC,UACAC,SACAC,SACAC,QACAC,QACAC,SACAC,QACAC,SACAC,OACAC,eACAC,cACAC,YACAC,iBACAC,iBACAC,mBACAC,UACAC,iBACAC,4BACAC,gBACAC,oBAC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,CACxD,GACA,CAACqB,EAAUrB,IASjBd,EAAA6D,cAAA,OAAA,KACC7D,EAAA6D,cAACC,EAAQ,CAACC,SAAU,MACnB/D,EAAA6D,cAAC/E,EAAS,CACDyD,UAAWA,EACX5B,OAAQA,EACR6B,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZvC,IAAKiC,EACLb,aAAcA,EACdC,YAAaA,EACbC,UAAWA,EACXI,QAASA,EACTH,eAAgBA,EAChBC,eAAgBA,EAChBiB,qCACEA,EAEF5B,OAAQA,EACRZ,kBAAmBA,EAGjB,aAAca,EACd,aAAcC,EACd,cAAeC,EACf,YAAaG,EACb,cAAeD,EACf,aAAcD,EACd,uBAAwBY,EACxB,2BAA4BC,EAC5B,qCAAsCU,EACtC,yBAA0BE,EAC1B,qCAAsCd,EAEtC,wBAAyBH,EACzB,cAAeb,EACf,sBAAuBe,GAGhCI,IAIC"}
|
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.18.1"},d="undefined"!=typeof window;export{d as IS_BROWSER,e as baseHeaders};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ interface IAuthProviderProps {
|
|
|
31
31
|
}
|
|
32
32
|
declare const AuthProvider: FC<IAuthProviderProps>;
|
|
33
33
|
|
|
34
|
-
declare const createSdkWrapper: <P extends
|
|
34
|
+
declare const createSdkWrapper: <P extends {
|
|
35
35
|
projectId: string;
|
|
36
36
|
logger?: {
|
|
37
37
|
error: {
|
|
@@ -53,20 +53,14 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
53
53
|
};
|
|
54
54
|
baseUrl?: string;
|
|
55
55
|
hooks?: {
|
|
56
|
-
beforeRequest?: (config: _1.RequestConfig) => _1.RequestConfig;
|
|
57
|
-
afterRequest?: (req: _1.RequestConfig, res: Response) => void | Promise<void
|
|
56
|
+
beforeRequest?: ((config: _1.RequestConfig) => _1.RequestConfig) | ((config: _1.RequestConfig) => _1.RequestConfig)[];
|
|
57
|
+
afterRequest?: ((req: _1.RequestConfig, res: Response) => void | Promise<void>) | ((req: _1.RequestConfig, res: Response) => void | Promise<void>)[];
|
|
58
58
|
transformResponse?: (mutableResponse: _1.ExtendedResponse) => Promise<_1.ExtendedResponse>;
|
|
59
59
|
};
|
|
60
60
|
cookiePolicy?: RequestCredentials;
|
|
61
61
|
baseHeaders?: HeadersInit;
|
|
62
62
|
refreshCookieName?: string;
|
|
63
63
|
fetch?: typeof fetch;
|
|
64
|
-
}, "hooks"> & {
|
|
65
|
-
hooks?: {
|
|
66
|
-
beforeRequest?: ((config: _1.RequestConfig) => _1.RequestConfig) | ((config: _1.RequestConfig) => _1.RequestConfig)[];
|
|
67
|
-
afterRequest?: ((req: _1.RequestConfig, res: Response) => void | Promise<void>) | ((req: _1.RequestConfig, res: Response) => void | Promise<void>)[];
|
|
68
|
-
transformResponse?: (mutableResponse: _1.ExtendedResponse) => Promise<_1.ExtendedResponse>;
|
|
69
|
-
};
|
|
70
64
|
} & {
|
|
71
65
|
oidcConfig?: _descope_web_js_sdk.OidcConfig;
|
|
72
66
|
getExternalToken?: () => Promise<string>;
|
|
@@ -117,6 +111,7 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
117
111
|
locale?: string;
|
|
118
112
|
oidcPrompt?: string;
|
|
119
113
|
oidcErrorRedirectUri?: string;
|
|
114
|
+
oidcResource?: string;
|
|
120
115
|
nativeOptions?: {
|
|
121
116
|
platform: "ios" | "android";
|
|
122
117
|
oauthProvider?: string;
|
|
@@ -126,7 +121,7 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
126
121
|
applicationScopes?: string;
|
|
127
122
|
outboundAppId?: string;
|
|
128
123
|
outboundAppScopes?: string[];
|
|
129
|
-
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
124
|
+
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
130
125
|
lastAuth?: Omit<{
|
|
131
126
|
authMethod?: "webauthn" | "otp" | "oauth" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
132
127
|
oauthProvider?: string;
|
|
@@ -709,51 +704,7 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
709
704
|
getJwtPermissions: (token: string, tenant?: string) => string[];
|
|
710
705
|
getJwtRoles: (token: string, tenant?: string) => string[];
|
|
711
706
|
getCurrentTenant: (token: string) => string;
|
|
712
|
-
httpClient:
|
|
713
|
-
get: (path: string, config?: {
|
|
714
|
-
headers?: HeadersInit;
|
|
715
|
-
queryParams?: {
|
|
716
|
-
[key: string]: string;
|
|
717
|
-
};
|
|
718
|
-
token?: string;
|
|
719
|
-
}) => Promise<Response>;
|
|
720
|
-
post: (path: string, body?: any, config?: {
|
|
721
|
-
headers?: HeadersInit;
|
|
722
|
-
queryParams?: {
|
|
723
|
-
[key: string]: string;
|
|
724
|
-
};
|
|
725
|
-
token?: string;
|
|
726
|
-
}) => Promise<Response>;
|
|
727
|
-
patch: (path: string, body?: any, config?: {
|
|
728
|
-
headers?: HeadersInit;
|
|
729
|
-
queryParams?: {
|
|
730
|
-
[key: string]: string;
|
|
731
|
-
};
|
|
732
|
-
token?: string;
|
|
733
|
-
}) => Promise<Response>;
|
|
734
|
-
put: (path: string, body?: any, config?: {
|
|
735
|
-
headers?: HeadersInit;
|
|
736
|
-
queryParams?: {
|
|
737
|
-
[key: string]: string;
|
|
738
|
-
};
|
|
739
|
-
token?: string;
|
|
740
|
-
}) => Promise<Response>;
|
|
741
|
-
delete: (path: string, config?: {
|
|
742
|
-
headers?: HeadersInit;
|
|
743
|
-
queryParams?: {
|
|
744
|
-
[key: string]: string;
|
|
745
|
-
};
|
|
746
|
-
token?: string;
|
|
747
|
-
}) => Promise<Response>;
|
|
748
|
-
hooks?: {
|
|
749
|
-
beforeRequest?: (config: _1.RequestConfig) => _1.RequestConfig;
|
|
750
|
-
afterRequest?: (req: _1.RequestConfig, res: Response) => void | Promise<void>;
|
|
751
|
-
transformResponse?: (mutableResponse: _1.ExtendedResponse) => Promise<_1.ExtendedResponse>;
|
|
752
|
-
};
|
|
753
|
-
buildUrl: (path: string, queryParams?: {
|
|
754
|
-
[key: string]: string;
|
|
755
|
-
}) => string;
|
|
756
|
-
};
|
|
707
|
+
httpClient: _1.HttpClient;
|
|
757
708
|
} | {
|
|
758
709
|
refresh: (token?: string) => Promise<_1.SdkResponse<_1.JWTResponse>>;
|
|
759
710
|
logout: (token?: string) => Promise<_1.SdkResponse<never>>;
|
|
@@ -788,6 +739,7 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
788
739
|
locale?: string;
|
|
789
740
|
oidcPrompt?: string;
|
|
790
741
|
oidcErrorRedirectUri?: string;
|
|
742
|
+
oidcResource?: string;
|
|
791
743
|
nativeOptions?: {
|
|
792
744
|
platform: "ios" | "android";
|
|
793
745
|
oauthProvider?: string;
|
|
@@ -797,7 +749,7 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
797
749
|
applicationScopes?: string;
|
|
798
750
|
outboundAppId?: string;
|
|
799
751
|
outboundAppScopes?: string[];
|
|
800
|
-
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
752
|
+
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
801
753
|
lastAuth?: Omit<{
|
|
802
754
|
authMethod?: "webauthn" | "otp" | "oauth" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
803
755
|
oauthProvider?: string;
|
|
@@ -1380,51 +1332,7 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
1380
1332
|
getJwtPermissions: (token: string, tenant?: string) => string[];
|
|
1381
1333
|
getJwtRoles: (token: string, tenant?: string) => string[];
|
|
1382
1334
|
getCurrentTenant: (token: string) => string;
|
|
1383
|
-
httpClient:
|
|
1384
|
-
get: (path: string, config?: {
|
|
1385
|
-
headers?: HeadersInit;
|
|
1386
|
-
queryParams?: {
|
|
1387
|
-
[key: string]: string;
|
|
1388
|
-
};
|
|
1389
|
-
token?: string;
|
|
1390
|
-
}) => Promise<Response>;
|
|
1391
|
-
post: (path: string, body?: any, config?: {
|
|
1392
|
-
headers?: HeadersInit;
|
|
1393
|
-
queryParams?: {
|
|
1394
|
-
[key: string]: string;
|
|
1395
|
-
};
|
|
1396
|
-
token?: string;
|
|
1397
|
-
}) => Promise<Response>;
|
|
1398
|
-
patch: (path: string, body?: any, config?: {
|
|
1399
|
-
headers?: HeadersInit;
|
|
1400
|
-
queryParams?: {
|
|
1401
|
-
[key: string]: string;
|
|
1402
|
-
};
|
|
1403
|
-
token?: string;
|
|
1404
|
-
}) => Promise<Response>;
|
|
1405
|
-
put: (path: string, body?: any, config?: {
|
|
1406
|
-
headers?: HeadersInit;
|
|
1407
|
-
queryParams?: {
|
|
1408
|
-
[key: string]: string;
|
|
1409
|
-
};
|
|
1410
|
-
token?: string;
|
|
1411
|
-
}) => Promise<Response>;
|
|
1412
|
-
delete: (path: string, config?: {
|
|
1413
|
-
headers?: HeadersInit;
|
|
1414
|
-
queryParams?: {
|
|
1415
|
-
[key: string]: string;
|
|
1416
|
-
};
|
|
1417
|
-
token?: string;
|
|
1418
|
-
}) => Promise<Response>;
|
|
1419
|
-
hooks?: {
|
|
1420
|
-
beforeRequest?: (config: _1.RequestConfig) => _1.RequestConfig;
|
|
1421
|
-
afterRequest?: (req: _1.RequestConfig, res: Response) => void | Promise<void>;
|
|
1422
|
-
transformResponse?: (mutableResponse: _1.ExtendedResponse) => Promise<_1.ExtendedResponse>;
|
|
1423
|
-
};
|
|
1424
|
-
buildUrl: (path: string, queryParams?: {
|
|
1425
|
-
[key: string]: string;
|
|
1426
|
-
}) => string;
|
|
1427
|
-
};
|
|
1335
|
+
httpClient: _1.HttpClient;
|
|
1428
1336
|
} | {
|
|
1429
1337
|
refresh: (token?: string) => Promise<_1.SdkResponse<_1.JWTResponse>>;
|
|
1430
1338
|
logout: (token?: string) => Promise<_1.SdkResponse<never>>;
|
|
@@ -1459,6 +1367,7 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
1459
1367
|
locale?: string;
|
|
1460
1368
|
oidcPrompt?: string;
|
|
1461
1369
|
oidcErrorRedirectUri?: string;
|
|
1370
|
+
oidcResource?: string;
|
|
1462
1371
|
nativeOptions?: {
|
|
1463
1372
|
platform: "ios" | "android";
|
|
1464
1373
|
oauthProvider?: string;
|
|
@@ -1468,7 +1377,7 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
1468
1377
|
applicationScopes?: string;
|
|
1469
1378
|
outboundAppId?: string;
|
|
1470
1379
|
outboundAppScopes?: string[];
|
|
1471
|
-
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
1380
|
+
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
1472
1381
|
lastAuth?: Omit<{
|
|
1473
1382
|
authMethod?: "webauthn" | "otp" | "oauth" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
1474
1383
|
oauthProvider?: string;
|
|
@@ -2051,51 +1960,7 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
2051
1960
|
getJwtPermissions: (token: string, tenant?: string) => string[];
|
|
2052
1961
|
getJwtRoles: (token: string, tenant?: string) => string[];
|
|
2053
1962
|
getCurrentTenant: (token: string) => string;
|
|
2054
|
-
httpClient:
|
|
2055
|
-
get: (path: string, config?: {
|
|
2056
|
-
headers?: HeadersInit;
|
|
2057
|
-
queryParams?: {
|
|
2058
|
-
[key: string]: string;
|
|
2059
|
-
};
|
|
2060
|
-
token?: string;
|
|
2061
|
-
}) => Promise<Response>;
|
|
2062
|
-
post: (path: string, body?: any, config?: {
|
|
2063
|
-
headers?: HeadersInit;
|
|
2064
|
-
queryParams?: {
|
|
2065
|
-
[key: string]: string;
|
|
2066
|
-
};
|
|
2067
|
-
token?: string;
|
|
2068
|
-
}) => Promise<Response>;
|
|
2069
|
-
patch: (path: string, body?: any, config?: {
|
|
2070
|
-
headers?: HeadersInit;
|
|
2071
|
-
queryParams?: {
|
|
2072
|
-
[key: string]: string;
|
|
2073
|
-
};
|
|
2074
|
-
token?: string;
|
|
2075
|
-
}) => Promise<Response>;
|
|
2076
|
-
put: (path: string, body?: any, config?: {
|
|
2077
|
-
headers?: HeadersInit;
|
|
2078
|
-
queryParams?: {
|
|
2079
|
-
[key: string]: string;
|
|
2080
|
-
};
|
|
2081
|
-
token?: string;
|
|
2082
|
-
}) => Promise<Response>;
|
|
2083
|
-
delete: (path: string, config?: {
|
|
2084
|
-
headers?: HeadersInit;
|
|
2085
|
-
queryParams?: {
|
|
2086
|
-
[key: string]: string;
|
|
2087
|
-
};
|
|
2088
|
-
token?: string;
|
|
2089
|
-
}) => Promise<Response>;
|
|
2090
|
-
hooks?: {
|
|
2091
|
-
beforeRequest?: (config: _1.RequestConfig) => _1.RequestConfig;
|
|
2092
|
-
afterRequest?: (req: _1.RequestConfig, res: Response) => void | Promise<void>;
|
|
2093
|
-
transformResponse?: (mutableResponse: _1.ExtendedResponse) => Promise<_1.ExtendedResponse>;
|
|
2094
|
-
};
|
|
2095
|
-
buildUrl: (path: string, queryParams?: {
|
|
2096
|
-
[key: string]: string;
|
|
2097
|
-
}) => string;
|
|
2098
|
-
};
|
|
1963
|
+
httpClient: _1.HttpClient;
|
|
2099
1964
|
}) & {
|
|
2100
1965
|
onSessionTokenChange: (cb: (data: string) => void) => () => any[];
|
|
2101
1966
|
onUserChange: (cb: (data: _1.UserResponse) => void) => () => any[];
|