@descope/react-sdk 3.1.0 → 3.2.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 +2 -0
- package/dist/cjs/components/Descope.js +1 -1
- package/dist/cjs/components/Descope.js.map +1 -1
- package/dist/cjs/constants.js +1 -1
- package/dist/esm/components/Descope.js +1 -1
- package/dist/esm/components/Descope.js.map +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/index.d.ts +7 -135
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/types/sdk.d.ts +18 -405
- package/dist/types/types.d.ts +1 -0
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -123,6 +123,8 @@ const App = () => {
|
|
|
123
123
|
|
|
124
124
|
// restartOnError: if set to true, in case of flow version mismatch, will restart the flow if the components version was not changed. Default is false
|
|
125
125
|
|
|
126
|
+
// sendSessionToken: if set to true, flow start/next requests include the current session JWT, exposing its validated claims to the flow via the sessionJwtClaims context key. Default is false
|
|
127
|
+
|
|
126
128
|
// errorTransformer is a function that receives an error object and returns a string. The returned string will be displayed to the user.
|
|
127
129
|
// NOTE: errorTransformer is not required. If not provided, the error object will be displayed as is.
|
|
128
130
|
// Example:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),r=require("../constants.js"),s=require("../hooks/Context.js"),n=require("../sdk.js"),o=require("./withPropsMapping/index.js");function a(e){return e&&e.__esModule?e:{default:e}}var u=a(t);const l=t.lazy((async()=>(((null===customElements||void 0===customElements?void 0:customElements.get("descope-wc"))||await import("@descope/web-component").then((e=>e.default))).sdkConfigOverrides={baseHeaders:r.baseHeaders,persistTokens:!1,hooks:{get beforeRequest(){return n.getGlobalSdk().httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:o.default(u.default.forwardRef(((s,n)=>{var{"external-request-id":o}=s,a=e.__rest(s,["external-request-id"]);return t.useMemo((()=>{var e,t;e="x-external-rid",(t=o)?r.baseHeaders[e]=t:delete r.baseHeaders[e]}),[o]),u.default.createElement("descope-wc",Object.assign({ref:n},a))})))}))),d=u.default.forwardRef((({flowId:e,onSuccess:r,onError:n,onReady:o,logger:a,tenant:d,theme:c,nonce:i,locale:p,debug:f,client:m,form:v,telemetryKey:E,redirectUrl:b,autoFocus:g,validateOnBlur:h,restartOnError:L,errorTransformer:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),r=require("../constants.js"),s=require("../hooks/Context.js"),n=require("../sdk.js"),o=require("./withPropsMapping/index.js");function a(e){return e&&e.__esModule?e:{default:e}}var u=a(t);const l=t.lazy((async()=>(((null===customElements||void 0===customElements?void 0:customElements.get("descope-wc"))||await import("@descope/web-component").then((e=>e.default))).sdkConfigOverrides={baseHeaders:r.baseHeaders,persistTokens:!1,hooks:{get beforeRequest(){return n.getGlobalSdk().httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:o.default(u.default.forwardRef(((s,n)=>{var{"external-request-id":o}=s,a=e.__rest(s,["external-request-id"]);return t.useMemo((()=>{var e,t;e="x-external-rid",(t=o)?r.baseHeaders[e]=t:delete r.baseHeaders[e]}),[o]),u.default.createElement("descope-wc",Object.assign({ref:n},a))})))}))),d=u.default.forwardRef((({flowId:e,onSuccess:r,onError:n,onReady:o,logger:a,tenant:d,theme:c,nonce:i,locale:p,debug:f,client:m,form:v,telemetryKey:E,redirectUrl:b,autoFocus:g,validateOnBlur:h,restartOnError:k,sendSessionToken:L,errorTransformer:y,styleId:S,onScreenUpdate:q,dismissScreenErrorOnInput:U,outboundAppId:O,outboundAppScopes:w,popupOrigin:x,children:I,externalRequestId:C,themeOverride:R},j)=>{const[A,_]=t.useState(null);t.useImperativeHandle(j,(()=>A));const{projectId:H,baseUrl:M,baseStaticUrl:T,baseCdnUrl:N,storeLastAuthenticatedUser:B,keepLastAuthenticatedUserAfterLogout:F,refreshCookieName:K,customStorage:P,sdk:z}=u.default.useContext(s.default),G=t.useCallback((async e=>{await z.httpClient.hooks.afterRequest({},new Response(JSON.stringify(e.detail))),r&&r(e)}),[r]);return t.useEffect((()=>{const e=A;return null==e||e.addEventListener("success",G),n&&(null==e||e.addEventListener("error",n)),o&&(null==e||e.addEventListener("ready",o)),()=>{n&&(null==e||e.removeEventListener("error",n)),o&&(null==e||e.removeEventListener("ready",o)),null==e||e.removeEventListener("success",G)}}),[A,n,G]),t.useEffect((()=>{const e=A;return null==e||e.addEventListener("success",G),()=>{null==e||e.removeEventListener("success",G)}}),[A,G]),t.useEffect((()=>{const e=A;return n&&(null==e||e.addEventListener("error",n)),()=>{n&&(null==e||e.removeEventListener("error",n))}}),[A,n]),t.useEffect((()=>{const e=A;return o&&(null==e||e.addEventListener("ready",o)),()=>{o&&(null==e||e.removeEventListener("error",o))}}),[A,o]),u.default.createElement("form",null,u.default.createElement(t.Suspense,{fallback:null},u.default.createElement(l,{projectId:H,flowId:e,baseUrl:M,baseStaticUrl:T,baseCdnUrl:N,ref:_,telemetryKey:E,redirectUrl:b,autoFocus:g,styleId:S,validateOnBlur:h,restartOnError:k,keepLastAuthenticatedUserAfterLogout:F,tenant:d,externalRequestId:C,customStorage:P,themeOverride:R,"theme.attr":c,"nonce.attr":i,"locale.attr":p,"form.attr":v,"client.attr":m,"debug.attr":f,"outbound-app-id.attr":O,"outbound-app-scopes.attr":w,"popup-origin.attr":x,"store-last-authenticated-user.attr":B,"send-session-token.attr":L,"refreshCookieName.attr":K,"dismiss-screen-error-on-input.attr":U,"errorTransformer.prop":y,"logger.prop":a,"onScreenUpdate.prop":q,"customStorage.prop":P},I)))}));exports.default=d;
|
|
2
2
|
//# sourceMappingURL=Descope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Descope.js","sources":["../../../src/components/Descope.tsx"],"sourcesContent":["/* eslint-disable react/prop-types */\nimport React, {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react';\nimport { baseHeaders } from '../constants';\nimport Context from '../hooks/Context';\nimport { DescopeProps } from '../types';\nimport { getGlobalSdk } from '../sdk';\nimport withPropsMapping from './withPropsMapping';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst DescopeWC = lazy(async () => {\n const updateDynamicHeader = (key: string, value: string) => {\n if (value) {\n baseHeaders[key] = value;\n } else {\n delete baseHeaders[key];\n }\n };\n\n const WebComponent: any =\n customElements?.get('descope-wc') ||\n (await import('@descope/web-component').then((module) => module.default));\n\n WebComponent.sdkConfigOverrides = {\n // Overrides the web-component's base headers to indicate usage via the React SDK\n baseHeaders,\n // Disables token persistence within the web-component to delegate token management\n // to the global SDK hooks. This ensures token handling aligns with the SDK's configuration,\n // and web-component requests leverage the global SDK's beforeRequest hooks for consistency\n persistTokens: false,\n hooks: {\n get beforeRequest() {\n // Retrieves the beforeRequest hook from the global SDK, which is initialized\n // within the AuthProvider using the desired configuration. This approach ensures\n // the web-component utilizes the same beforeRequest hooks as the global SDK\n return getGlobalSdk().httpClient.hooks.beforeRequest;\n },\n set beforeRequest(_) {\n // The empty setter prevents runtime errors when attempts are made to assign a value to 'beforeRequest'.\n // JavaScript objects default to having both getters and setters\n },\n },\n };\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>(\n ({ 'external-request-id': externalRequestId, ...props }: any, ref) => {\n // update the dynamic headers with the external request ID if provided\n useMemo(() => {\n updateDynamicHeader('x-external-rid', externalRequestId);\n }, [externalRequestId]);\n\n return <descope-wc ref={ref} {...props} />;\n },\n ),\n ),\n };\n});\n\nconst Descope = React.forwardRef<HTMLElement, DescopeProps>(\n (\n {\n flowId,\n onSuccess,\n onError,\n onReady,\n logger,\n tenant,\n theme,\n nonce,\n locale,\n debug,\n client,\n form,\n telemetryKey,\n redirectUrl,\n autoFocus,\n validateOnBlur,\n restartOnError,\n errorTransformer,\n styleId,\n onScreenUpdate,\n dismissScreenErrorOnInput,\n outboundAppId,\n outboundAppScopes,\n popupOrigin,\n children,\n externalRequestId,\n themeOverride,\n },\n ref,\n ) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const {\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n customStorage,\n sdk,\n } = React.useContext(Context);\n\n const handleSuccess = useCallback(\n async (e: CustomEvent) => {\n // In order to make sure all the after-hooks are running with the success response\n // we are generating a fake response with the success data and calling the http client after hook fn with it\n await sdk.httpClient.hooks.afterRequest(\n {} as any,\n new Response(JSON.stringify(e.detail)),\n );\n if (onSuccess) {\n onSuccess(e);\n }\n },\n [onSuccess],\n );\n\n useEffect(() => {\n const ele = innerRef;\n ele?.addEventListener('success', handleSuccess);\n if (onError) ele?.addEventListener('error', onError);\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onError) ele?.removeEventListener('error', onError);\n if (onReady) ele?.removeEventListener('ready', onReady);\n\n ele?.removeEventListener('success', handleSuccess);\n };\n }, [innerRef, onError, handleSuccess]);\n\n // Success event\n useEffect(() => {\n const ele = innerRef;\n ele?.addEventListener('success', handleSuccess);\n return () => {\n ele?.removeEventListener('success', handleSuccess);\n };\n }, [innerRef, handleSuccess]);\n\n // Error event\n useEffect(() => {\n const ele = innerRef;\n if (onError) ele?.addEventListener('error', onError);\n\n return () => {\n if (onError) ele?.removeEventListener('error', onError);\n };\n }, [innerRef, onError]);\n\n // Ready event\n useEffect(() => {\n const ele = innerRef;\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onReady) ele?.removeEventListener('error', onReady);\n };\n }, [innerRef, onReady]);\n\n return (\n /**\n * in order to avoid redundant remounting of the WC, we are wrapping it with a form element\n * this workaround is done in order to support webauthn passkeys\n * it can be removed once this issue will be solved\n * https://bugs.chromium.org/p/chromium/issues/detail?id=1404106#c2\n */\n\t<form>\n\t\t<Suspense fallback={null}>\n\t\t\t<DescopeWC\n projectId={projectId}\n flowId={flowId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n ref={setInnerRef}\n telemetryKey={telemetryKey}\n redirectUrl={redirectUrl}\n autoFocus={autoFocus}\n styleId={styleId}\n validateOnBlur={validateOnBlur}\n restartOnError={restartOnError}\n keepLastAuthenticatedUserAfterLogout={\n keepLastAuthenticatedUserAfterLogout\n }\n tenant={tenant}\n externalRequestId={externalRequestId}\n customStorage={customStorage}\n themeOverride={themeOverride}\n {...{\n // attributes\n 'theme.attr': theme,\n 'nonce.attr': nonce,\n 'locale.attr': locale,\n 'form.attr': form,\n 'client.attr': client,\n 'debug.attr': debug,\n 'outbound-app-id.attr': outboundAppId,\n 'outbound-app-scopes.attr': outboundAppScopes,\n 'popup-origin.attr': popupOrigin,\n 'store-last-authenticated-user.attr': storeLastAuthenticatedUser,\n 'refreshCookieName.attr': refreshCookieName,\n 'dismiss-screen-error-on-input.attr': dismissScreenErrorOnInput,\n // props\n 'errorTransformer.prop': errorTransformer,\n 'logger.prop': logger,\n 'onScreenUpdate.prop': onScreenUpdate,\n 'customStorage.prop': customStorage,\n }}\n >\n\t\t\t\t{children}\n\t\t\t</DescopeWC>\n\t\t</Suspense>\n\t</form>\n );\n },\n);\n\nexport default Descope;\n"],"names":["DescopeWC","lazy","async","customElements","get","import","then","module","default","sdkConfigOverrides","baseHeaders","persistTokens","hooks","beforeRequest","getGlobalSdk","httpClient","_","withPropsMapping","React","forwardRef","_a","ref","externalRequestId","props","__rest","useMemo","key","value","Descope","flowId","onSuccess","onError","onReady","logger","tenant","theme","nonce","locale","debug","client","form","telemetryKey","redirectUrl","autoFocus","validateOnBlur","restartOnError","errorTransformer","styleId","onScreenUpdate","dismissScreenErrorOnInput","outboundAppId","outboundAppScopes","popupOrigin","children","themeOverride","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","refreshCookieName","customStorage","sdk","useContext","Context","handleSuccess","useCallback","e","afterRequest","Response","JSON","stringify","detail","useEffect","ele","addEventListener","removeEventListener","createElement","Suspense","fallback"],"mappings":"0SAiBA,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,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,cACAC,YACAC,iBACAC,iBACAC,mBACAC,UACAC,iBACAC,4BACAC,gBACAC,oBACAC,cACAC,WACA/B,oBACAgC,iBAEFjC,KAEA,MAAOkC,EAAUC,GAAeC,EAAQA,SAAC,MAEzCC,sBAAoBrC,GAAK,IAAMkC,IAE/B,MAAMI,UACJA,EAASC,QACTA,EAAOC,cACPA,EAAaC,WACbA,EAAUC,2BACVA,EAA0BC,qCAC1BA,EAAoCC,kBACpCA,EAAiBC,cACjBA,EAAaC,IACbA,GACEjD,EAAKV,QAAC4D,WAAWC,EAA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AAYA,EACZzC,IAAKmC,EACLf,aAAcA,EACdC,YAAaA,EACbC,UAAWA,EACXI,QAASA,EACTH,eAAgBA,EAChBC,eAAgBA,EAChBmB,qCACEA,EAEF9B,OAAQA,EACRZ,kBAAmBA,EACnB4C,cAAeA,EACfZ,cAAeA,EAGb,aAAcnB,EACd,aAAcC,EACd,cAAeC,EACf,YAAaG,EACb,cAAeD,EACf,aAAcD,EACd,uBAAwBY,EACxB,2BAA4BC,EAC5B,oBAAqBC,EACrB,qCAAsCW,EACtC,yBAA0BE,EAC1B,qCAAsChB,EAEtC,wBAAyBH,EACzB,cAAeb,EACf,sBAAuBe,EACvB,qBAAsBkB,GAG/Bb,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 sendSessionToken,\n errorTransformer,\n styleId,\n onScreenUpdate,\n dismissScreenErrorOnInput,\n outboundAppId,\n outboundAppScopes,\n popupOrigin,\n children,\n externalRequestId,\n themeOverride,\n },\n ref,\n ) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const {\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n customStorage,\n sdk,\n } = React.useContext(Context);\n\n const handleSuccess = useCallback(\n async (e: CustomEvent) => {\n // In order to make sure all the after-hooks are running with the success response\n // we are generating a fake response with the success data and calling the http client after hook fn with it\n await sdk.httpClient.hooks.afterRequest(\n {} as any,\n new Response(JSON.stringify(e.detail)),\n );\n if (onSuccess) {\n onSuccess(e);\n }\n },\n [onSuccess],\n );\n\n useEffect(() => {\n const ele = innerRef;\n ele?.addEventListener('success', handleSuccess);\n if (onError) ele?.addEventListener('error', onError);\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onError) ele?.removeEventListener('error', onError);\n if (onReady) ele?.removeEventListener('ready', onReady);\n\n ele?.removeEventListener('success', handleSuccess);\n };\n }, [innerRef, onError, handleSuccess]);\n\n // Success event\n useEffect(() => {\n const ele = innerRef;\n ele?.addEventListener('success', handleSuccess);\n return () => {\n ele?.removeEventListener('success', handleSuccess);\n };\n }, [innerRef, handleSuccess]);\n\n // Error event\n useEffect(() => {\n const ele = innerRef;\n if (onError) ele?.addEventListener('error', onError);\n\n return () => {\n if (onError) ele?.removeEventListener('error', onError);\n };\n }, [innerRef, onError]);\n\n // Ready event\n useEffect(() => {\n const ele = innerRef;\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onReady) ele?.removeEventListener('error', onReady);\n };\n }, [innerRef, onReady]);\n\n return (\n /**\n * in order to avoid redundant remounting of the WC, we are wrapping it with a form element\n * this workaround is done in order to support webauthn passkeys\n * it can be removed once this issue will be solved\n * https://bugs.chromium.org/p/chromium/issues/detail?id=1404106#c2\n */\n\t<form>\n\t\t<Suspense fallback={null}>\n\t\t\t<DescopeWC\n projectId={projectId}\n flowId={flowId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n ref={setInnerRef}\n telemetryKey={telemetryKey}\n redirectUrl={redirectUrl}\n autoFocus={autoFocus}\n styleId={styleId}\n validateOnBlur={validateOnBlur}\n restartOnError={restartOnError}\n keepLastAuthenticatedUserAfterLogout={\n keepLastAuthenticatedUserAfterLogout\n }\n tenant={tenant}\n externalRequestId={externalRequestId}\n customStorage={customStorage}\n themeOverride={themeOverride}\n {...{\n // attributes\n 'theme.attr': theme,\n 'nonce.attr': nonce,\n 'locale.attr': locale,\n 'form.attr': form,\n 'client.attr': client,\n 'debug.attr': debug,\n 'outbound-app-id.attr': outboundAppId,\n 'outbound-app-scopes.attr': outboundAppScopes,\n 'popup-origin.attr': popupOrigin,\n 'store-last-authenticated-user.attr': storeLastAuthenticatedUser,\n 'send-session-token.attr': sendSessionToken,\n 'refreshCookieName.attr': refreshCookieName,\n 'dismiss-screen-error-on-input.attr': dismissScreenErrorOnInput,\n // props\n 'errorTransformer.prop': errorTransformer,\n 'logger.prop': logger,\n 'onScreenUpdate.prop': onScreenUpdate,\n 'customStorage.prop': customStorage,\n }}\n >\n\t\t\t\t{children}\n\t\t\t</DescopeWC>\n\t\t</Suspense>\n\t</form>\n );\n },\n);\n\nexport default Descope;\n"],"names":["DescopeWC","lazy","async","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","sendSessionToken","errorTransformer","styleId","onScreenUpdate","dismissScreenErrorOnInput","outboundAppId","outboundAppScopes","popupOrigin","children","themeOverride","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","refreshCookieName","customStorage","sdk","useContext","Context","handleSuccess","useCallback","e","afterRequest","Response","JSON","stringify","detail","useEffect","ele","addEventListener","removeEventListener","createElement","Suspense","fallback"],"mappings":"0SAiBA,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,GAAiBF,EAAKG,EAAKC,EAAAA,OAAAJ,EAApD,yBAMC,OAJAK,EAAAA,SAAQ,KAtCY,IAACC,EAAaC,EA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KACLS,SAAAA,EAAKE,oBAAoB,UAAWX,EAAc,CACnD,GACA,CAACf,EAAUe,IAGdQ,EAAAA,WAAU,KACR,MAAMC,EAAMxB,EAGZ,OAFIzB,IAASiD,SAAAA,EAAKC,iBAAiB,QAASlD,IAErC,KACDA,IAASiD,SAAAA,EAAKE,oBAAoB,QAASnD,GAAQ,CACxD,GACA,CAACyB,EAAUzB,IAGdgD,EAAAA,WAAU,KACR,MAAMC,EAAMxB,EAGZ,OAFIxB,IAASgD,SAAAA,EAAKC,iBAAiB,QAASjD,IAErC,KACDA,IAASgD,SAAAA,EAAKE,oBAAoB,QAASlD,GAAQ,CACxD,GACA,CAACwB,EAAUxB,IASjBd,UAAAiE,cAAA,OAAA,KACCjE,EAAAA,QAAAiE,cAACC,EAAAA,SAAQ,CAACC,SAAU,MACnBnE,EAAAV,QAAA2E,cAACnF,EAAS,CACD4D,UAAWA,EACX/B,OAAQA,EACRgC,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZ1C,IAAKoC,EACLhB,aAAcA,EACdC,YAAaA,EACbC,UAAWA,EACXK,QAASA,EACTJ,eAAgBA,EAChBC,eAAgBA,EAChBoB,qCACEA,EAEF/B,OAAQA,EACRZ,kBAAmBA,EACnB6C,cAAeA,EACfZ,cAAeA,EAGb,aAAcpB,EACd,aAAcC,EACd,cAAeC,EACf,YAAaG,EACb,cAAeD,EACf,aAAcD,EACd,uBAAwBa,EACxB,2BAA4BC,EAC5B,oBAAqBC,EACrB,qCAAsCW,EACtC,0BAA2BlB,EAC3B,yBAA0BoB,EAC1B,qCAAsChB,EAEtC,wBAAyBH,EACzB,cAAed,EACf,sBAAuBgB,EACvB,qBAAsBkB,GAG/Bb,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":"3.
|
|
1
|
+
"use strict";const e="undefined"!=typeof window;exports.IS_BROWSER=e,exports.baseHeaders={"x-descope-sdk-name":"react","x-descope-sdk-version":"3.2.0"};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__rest as e}from"tslib";import t,{lazy as r,useMemo as n,useState as o,useImperativeHandle as s,useCallback as a,useEffect as l,Suspense as u}from"react";import{baseHeaders as d}from"../constants.js";import i from"../hooks/Context.js";import{getGlobalSdk as c}from"../sdk.js";import p from"./withPropsMapping/index.js";const m=r((async()=>(((null===customElements||void 0===customElements?void 0:customElements.get("descope-wc"))||await import("@descope/web-component").then((e=>e.default))).sdkConfigOverrides={baseHeaders:d,persistTokens:!1,hooks:{get beforeRequest(){return c().httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:p(t.forwardRef(((r,o)=>{var{"external-request-id":s}=r,a=e(r,["external-request-id"]);return n((()=>{var e,t;e="x-external-rid",(t=s)?d[e]=t:delete d[e]}),[s]),t.createElement("descope-wc",Object.assign({ref:o},a))})))}))),f=t.forwardRef((({flowId:e,onSuccess:r,onError:n,onReady:d,logger:c,tenant:p,theme:f,nonce:v,locale:E,debug:b,client:g,form:h,telemetryKey:L,redirectUrl:k,autoFocus:y,validateOnBlur:U,restartOnError:w,errorTransformer:O,styleId:
|
|
1
|
+
import{__rest as e}from"tslib";import t,{lazy as r,useMemo as n,useState as o,useImperativeHandle as s,useCallback as a,useEffect as l,Suspense as u}from"react";import{baseHeaders as d}from"../constants.js";import i from"../hooks/Context.js";import{getGlobalSdk as c}from"../sdk.js";import p from"./withPropsMapping/index.js";const m=r((async()=>(((null===customElements||void 0===customElements?void 0:customElements.get("descope-wc"))||await import("@descope/web-component").then((e=>e.default))).sdkConfigOverrides={baseHeaders:d,persistTokens:!1,hooks:{get beforeRequest(){return c().httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:p(t.forwardRef(((r,o)=>{var{"external-request-id":s}=r,a=e(r,["external-request-id"]);return n((()=>{var e,t;e="x-external-rid",(t=s)?d[e]=t:delete d[e]}),[s]),t.createElement("descope-wc",Object.assign({ref:o},a))})))}))),f=t.forwardRef((({flowId:e,onSuccess:r,onError:n,onReady:d,logger:c,tenant:p,theme:f,nonce:v,locale:E,debug:b,client:g,form:h,telemetryKey:L,redirectUrl:k,autoFocus:y,validateOnBlur:U,restartOnError:S,sendSessionToken:w,errorTransformer:O,styleId:x,onScreenUpdate:I,dismissScreenErrorOnInput:R,outboundAppId:C,outboundAppScopes:q,popupOrigin:j,children:A,externalRequestId:T,themeOverride:N},B)=>{const[F,K]=o(null);s(B,(()=>F));const{projectId:H,baseUrl:J,baseStaticUrl:M,baseCdnUrl:P,storeLastAuthenticatedUser:z,keepLastAuthenticatedUserAfterLogout:D,refreshCookieName:G,customStorage:Q,sdk:V}=t.useContext(i),W=a((async e=>{await V.httpClient.hooks.afterRequest({},new Response(JSON.stringify(e.detail))),r&&r(e)}),[r]);return l((()=>{const e=F;return null==e||e.addEventListener("success",W),n&&(null==e||e.addEventListener("error",n)),d&&(null==e||e.addEventListener("ready",d)),()=>{n&&(null==e||e.removeEventListener("error",n)),d&&(null==e||e.removeEventListener("ready",d)),null==e||e.removeEventListener("success",W)}}),[F,n,W]),l((()=>{const e=F;return null==e||e.addEventListener("success",W),()=>{null==e||e.removeEventListener("success",W)}}),[F,W]),l((()=>{const e=F;return n&&(null==e||e.addEventListener("error",n)),()=>{n&&(null==e||e.removeEventListener("error",n))}}),[F,n]),l((()=>{const e=F;return d&&(null==e||e.addEventListener("ready",d)),()=>{d&&(null==e||e.removeEventListener("error",d))}}),[F,d]),t.createElement("form",null,t.createElement(u,{fallback:null},t.createElement(m,{projectId:H,flowId:e,baseUrl:J,baseStaticUrl:M,baseCdnUrl:P,ref:K,telemetryKey:L,redirectUrl:k,autoFocus:y,styleId:x,validateOnBlur:U,restartOnError:S,keepLastAuthenticatedUserAfterLogout:D,tenant:p,externalRequestId:T,customStorage:Q,themeOverride:N,"theme.attr":f,"nonce.attr":v,"locale.attr":E,"form.attr":h,"client.attr":g,"debug.attr":b,"outbound-app-id.attr":C,"outbound-app-scopes.attr":q,"popup-origin.attr":j,"store-last-authenticated-user.attr":z,"send-session-token.attr":w,"refreshCookieName.attr":G,"dismiss-screen-error-on-input.attr":R,"errorTransformer.prop":O,"logger.prop":c,"onScreenUpdate.prop":I,"customStorage.prop":Q},A)))}));export{f as default};
|
|
2
2
|
//# sourceMappingURL=Descope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Descope.js","sources":["../../../src/components/Descope.tsx"],"sourcesContent":["/* eslint-disable react/prop-types */\nimport React, {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react';\nimport { baseHeaders } from '../constants';\nimport Context from '../hooks/Context';\nimport { DescopeProps } from '../types';\nimport { getGlobalSdk } from '../sdk';\nimport withPropsMapping from './withPropsMapping';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst DescopeWC = lazy(async () => {\n const updateDynamicHeader = (key: string, value: string) => {\n if (value) {\n baseHeaders[key] = value;\n } else {\n delete baseHeaders[key];\n }\n };\n\n const WebComponent: any =\n customElements?.get('descope-wc') ||\n (await import('@descope/web-component').then((module) => module.default));\n\n WebComponent.sdkConfigOverrides = {\n // Overrides the web-component's base headers to indicate usage via the React SDK\n baseHeaders,\n // Disables token persistence within the web-component to delegate token management\n // to the global SDK hooks. This ensures token handling aligns with the SDK's configuration,\n // and web-component requests leverage the global SDK's beforeRequest hooks for consistency\n persistTokens: false,\n hooks: {\n get beforeRequest() {\n // Retrieves the beforeRequest hook from the global SDK, which is initialized\n // within the AuthProvider using the desired configuration. This approach ensures\n // the web-component utilizes the same beforeRequest hooks as the global SDK\n return getGlobalSdk().httpClient.hooks.beforeRequest;\n },\n set beforeRequest(_) {\n // The empty setter prevents runtime errors when attempts are made to assign a value to 'beforeRequest'.\n // JavaScript objects default to having both getters and setters\n },\n },\n };\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>(\n ({ 'external-request-id': externalRequestId, ...props }: any, ref) => {\n // update the dynamic headers with the external request ID if provided\n useMemo(() => {\n updateDynamicHeader('x-external-rid', externalRequestId);\n }, [externalRequestId]);\n\n return <descope-wc ref={ref} {...props} />;\n },\n ),\n ),\n };\n});\n\nconst Descope = React.forwardRef<HTMLElement, DescopeProps>(\n (\n {\n flowId,\n onSuccess,\n onError,\n onReady,\n logger,\n tenant,\n theme,\n nonce,\n locale,\n debug,\n client,\n form,\n telemetryKey,\n redirectUrl,\n autoFocus,\n validateOnBlur,\n restartOnError,\n errorTransformer,\n styleId,\n onScreenUpdate,\n dismissScreenErrorOnInput,\n outboundAppId,\n outboundAppScopes,\n popupOrigin,\n children,\n externalRequestId,\n themeOverride,\n },\n ref,\n ) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const {\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n customStorage,\n sdk,\n } = React.useContext(Context);\n\n const handleSuccess = useCallback(\n async (e: CustomEvent) => {\n // In order to make sure all the after-hooks are running with the success response\n // we are generating a fake response with the success data and calling the http client after hook fn with it\n await sdk.httpClient.hooks.afterRequest(\n {} as any,\n new Response(JSON.stringify(e.detail)),\n );\n if (onSuccess) {\n onSuccess(e);\n }\n },\n [onSuccess],\n );\n\n useEffect(() => {\n const ele = innerRef;\n ele?.addEventListener('success', handleSuccess);\n if (onError) ele?.addEventListener('error', onError);\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onError) ele?.removeEventListener('error', onError);\n if (onReady) ele?.removeEventListener('ready', onReady);\n\n ele?.removeEventListener('success', handleSuccess);\n };\n }, [innerRef, onError, handleSuccess]);\n\n // Success event\n useEffect(() => {\n const ele = innerRef;\n ele?.addEventListener('success', handleSuccess);\n return () => {\n ele?.removeEventListener('success', handleSuccess);\n };\n }, [innerRef, handleSuccess]);\n\n // Error event\n useEffect(() => {\n const ele = innerRef;\n if (onError) ele?.addEventListener('error', onError);\n\n return () => {\n if (onError) ele?.removeEventListener('error', onError);\n };\n }, [innerRef, onError]);\n\n // Ready event\n useEffect(() => {\n const ele = innerRef;\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onReady) ele?.removeEventListener('error', onReady);\n };\n }, [innerRef, onReady]);\n\n return (\n /**\n * in order to avoid redundant remounting of the WC, we are wrapping it with a form element\n * this workaround is done in order to support webauthn passkeys\n * it can be removed once this issue will be solved\n * https://bugs.chromium.org/p/chromium/issues/detail?id=1404106#c2\n */\n\t<form>\n\t\t<Suspense fallback={null}>\n\t\t\t<DescopeWC\n projectId={projectId}\n flowId={flowId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n ref={setInnerRef}\n telemetryKey={telemetryKey}\n redirectUrl={redirectUrl}\n autoFocus={autoFocus}\n styleId={styleId}\n validateOnBlur={validateOnBlur}\n restartOnError={restartOnError}\n keepLastAuthenticatedUserAfterLogout={\n keepLastAuthenticatedUserAfterLogout\n }\n tenant={tenant}\n externalRequestId={externalRequestId}\n customStorage={customStorage}\n themeOverride={themeOverride}\n {...{\n // attributes\n 'theme.attr': theme,\n 'nonce.attr': nonce,\n 'locale.attr': locale,\n 'form.attr': form,\n 'client.attr': client,\n 'debug.attr': debug,\n 'outbound-app-id.attr': outboundAppId,\n 'outbound-app-scopes.attr': outboundAppScopes,\n 'popup-origin.attr': popupOrigin,\n 'store-last-authenticated-user.attr': storeLastAuthenticatedUser,\n 'refreshCookieName.attr': refreshCookieName,\n 'dismiss-screen-error-on-input.attr': dismissScreenErrorOnInput,\n // props\n 'errorTransformer.prop': errorTransformer,\n 'logger.prop': logger,\n 'onScreenUpdate.prop': onScreenUpdate,\n 'customStorage.prop': customStorage,\n }}\n >\n\t\t\t\t{children}\n\t\t\t</DescopeWC>\n\t\t</Suspense>\n\t</form>\n );\n },\n);\n\nexport default Descope;\n"],"names":["DescopeWC","lazy","async","customElements","get","import","then","module","default","sdkConfigOverrides","baseHeaders","persistTokens","hooks","beforeRequest","getGlobalSdk","httpClient","_","withPropsMapping","React","forwardRef","_a","ref","externalRequestId","props","__rest","useMemo","key","value","Descope","flowId","onSuccess","onError","onReady","logger","tenant","theme","nonce","locale","debug","client","form","telemetryKey","redirectUrl","autoFocus","validateOnBlur","restartOnError","errorTransformer","styleId","onScreenUpdate","dismissScreenErrorOnInput","outboundAppId","outboundAppScopes","popupOrigin","children","themeOverride","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","refreshCookieName","customStorage","sdk","useContext","Context","handleSuccess","useCallback","e","afterRequest","Response","JSON","stringify","detail","useEffect","ele","addEventListener","removeEventListener","createElement","Suspense","fallback"],"mappings":"sUAiBA,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,Q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,OAFIvB,IAAS+C,SAAAA,EAAKC,iBAAiB,QAAShD,IAErC,KACDA,IAAS+C,SAAAA,EAAKE,oBAAoB,QAASjD,GAAQ,CACxD,GACA,CAACuB,EAAUvB,IASjBd,EAAAgE,cAAA,OAAA,KACChE,EAAAgE,cAACC,EAAQ,CAACC,SAAU,MACnBlE,EAAAgE,cAAClF,EAAS,CACD2D,UAAWA,EACX9B,OAAQA,EACR+B,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZzC,IAAKmC,EACLf,aAAcA,EACdC,YAAaA,EACbC,UAAWA,EACXI,QAASA,EACTH,eAAgBA,EAChBC,eAAgBA,EAChBmB,qCACEA,EAEF9B,OAAQA,EACRZ,kBAAmBA,EACnB4C,cAAeA,EACfZ,cAAeA,EAGb,aAAcnB,EACd,aAAcC,EACd,cAAeC,EACf,YAAaG,EACb,cAAeD,EACf,aAAcD,EACd,uBAAwBY,EACxB,2BAA4BC,EAC5B,oBAAqBC,EACrB,qCAAsCW,EACtC,yBAA0BE,EAC1B,qCAAsChB,EAEtC,wBAAyBH,EACzB,cAAeb,EACf,sBAAuBe,EACvB,qBAAsBkB,GAG/Bb,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 sendSessionToken,\n errorTransformer,\n styleId,\n onScreenUpdate,\n dismissScreenErrorOnInput,\n outboundAppId,\n outboundAppScopes,\n popupOrigin,\n children,\n externalRequestId,\n themeOverride,\n },\n ref,\n ) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const {\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n customStorage,\n sdk,\n } = React.useContext(Context);\n\n const handleSuccess = useCallback(\n async (e: CustomEvent) => {\n // In order to make sure all the after-hooks are running with the success response\n // we are generating a fake response with the success data and calling the http client after hook fn with it\n await sdk.httpClient.hooks.afterRequest(\n {} as any,\n new Response(JSON.stringify(e.detail)),\n );\n if (onSuccess) {\n onSuccess(e);\n }\n },\n [onSuccess],\n );\n\n useEffect(() => {\n const ele = innerRef;\n ele?.addEventListener('success', handleSuccess);\n if (onError) ele?.addEventListener('error', onError);\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onError) ele?.removeEventListener('error', onError);\n if (onReady) ele?.removeEventListener('ready', onReady);\n\n ele?.removeEventListener('success', handleSuccess);\n };\n }, [innerRef, onError, handleSuccess]);\n\n // Success event\n useEffect(() => {\n const ele = innerRef;\n ele?.addEventListener('success', handleSuccess);\n return () => {\n ele?.removeEventListener('success', handleSuccess);\n };\n }, [innerRef, handleSuccess]);\n\n // Error event\n useEffect(() => {\n const ele = innerRef;\n if (onError) ele?.addEventListener('error', onError);\n\n return () => {\n if (onError) ele?.removeEventListener('error', onError);\n };\n }, [innerRef, onError]);\n\n // Ready event\n useEffect(() => {\n const ele = innerRef;\n if (onReady) ele?.addEventListener('ready', onReady);\n\n return () => {\n if (onReady) ele?.removeEventListener('error', onReady);\n };\n }, [innerRef, onReady]);\n\n return (\n /**\n * in order to avoid redundant remounting of the WC, we are wrapping it with a form element\n * this workaround is done in order to support webauthn passkeys\n * it can be removed once this issue will be solved\n * https://bugs.chromium.org/p/chromium/issues/detail?id=1404106#c2\n */\n\t<form>\n\t\t<Suspense fallback={null}>\n\t\t\t<DescopeWC\n projectId={projectId}\n flowId={flowId}\n baseUrl={baseUrl}\n baseStaticUrl={baseStaticUrl}\n baseCdnUrl={baseCdnUrl}\n ref={setInnerRef}\n telemetryKey={telemetryKey}\n redirectUrl={redirectUrl}\n autoFocus={autoFocus}\n styleId={styleId}\n validateOnBlur={validateOnBlur}\n restartOnError={restartOnError}\n keepLastAuthenticatedUserAfterLogout={\n keepLastAuthenticatedUserAfterLogout\n }\n tenant={tenant}\n externalRequestId={externalRequestId}\n customStorage={customStorage}\n themeOverride={themeOverride}\n {...{\n // attributes\n 'theme.attr': theme,\n 'nonce.attr': nonce,\n 'locale.attr': locale,\n 'form.attr': form,\n 'client.attr': client,\n 'debug.attr': debug,\n 'outbound-app-id.attr': outboundAppId,\n 'outbound-app-scopes.attr': outboundAppScopes,\n 'popup-origin.attr': popupOrigin,\n 'store-last-authenticated-user.attr': storeLastAuthenticatedUser,\n 'send-session-token.attr': sendSessionToken,\n 'refreshCookieName.attr': refreshCookieName,\n 'dismiss-screen-error-on-input.attr': dismissScreenErrorOnInput,\n // props\n 'errorTransformer.prop': errorTransformer,\n 'logger.prop': logger,\n 'onScreenUpdate.prop': onScreenUpdate,\n 'customStorage.prop': customStorage,\n }}\n >\n\t\t\t\t{children}\n\t\t\t</DescopeWC>\n\t\t</Suspense>\n\t</form>\n );\n },\n);\n\nexport default Descope;\n"],"names":["DescopeWC","lazy","async","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","sendSessionToken","errorTransformer","styleId","onScreenUpdate","dismissScreenErrorOnInput","outboundAppId","outboundAppScopes","popupOrigin","children","themeOverride","innerRef","setInnerRef","useState","useImperativeHandle","projectId","baseUrl","baseStaticUrl","baseCdnUrl","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","refreshCookieName","customStorage","sdk","useContext","Context","handleSuccess","useCallback","e","afterRequest","Response","JSON","stringify","detail","useEffect","ele","addEventListener","removeEventListener","createElement","Suspense","fallback"],"mappings":"sUAiBA,MAAMA,EAAYC,GAAKC,YAUnB,OAAAC,qBAAA,IAAAA,oBAAA,EAAAA,eAAgBC,IAAI,sBACbC,OAAO,0BAA0BC,MAAMC,GAAWA,EAAOC,WAErDC,mBAAqB,CAEhCC,cAIAC,eA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js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={"x-descope-sdk-name":"react","x-descope-sdk-version":"3.
|
|
1
|
+
const e={"x-descope-sdk-name":"react","x-descope-sdk-version":"3.2.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
|
@@ -69,50 +69,7 @@ declare const createSdkWrapper: <P extends {
|
|
|
69
69
|
refresh: (token?: string, tryRefresh?: boolean) => Promise<_1.SdkResponse<_1.JWTResponse>>;
|
|
70
70
|
logout: (token?: string) => Promise<_1.SdkResponse<never>>;
|
|
71
71
|
flow: {
|
|
72
|
-
start: (flowId: string, options?: Pick<{
|
|
73
|
-
redirectUrl?: string;
|
|
74
|
-
location?: string;
|
|
75
|
-
tenant?: string;
|
|
76
|
-
deviceInfo?: {
|
|
77
|
-
webAuthnSupport?: boolean;
|
|
78
|
-
};
|
|
79
|
-
lastAuth?: {
|
|
80
|
-
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
81
|
-
oauthProvider?: string;
|
|
82
|
-
name?: string;
|
|
83
|
-
loginId?: string;
|
|
84
|
-
};
|
|
85
|
-
redirectAuth?: {
|
|
86
|
-
callbackUrl: string;
|
|
87
|
-
codeChallenge: string;
|
|
88
|
-
};
|
|
89
|
-
oidcIdpStateId?: string;
|
|
90
|
-
preview?: boolean;
|
|
91
|
-
samlIdpStateId?: string;
|
|
92
|
-
wsfedIdpStateId?: string;
|
|
93
|
-
samlIdpUsername?: string;
|
|
94
|
-
ssoAppId?: string;
|
|
95
|
-
customAppId?: string;
|
|
96
|
-
thirdPartyAppId?: string;
|
|
97
|
-
oidcLoginHint?: string;
|
|
98
|
-
abTestingKey?: number;
|
|
99
|
-
startOptionsVersion?: number;
|
|
100
|
-
client?: Record<string, any>;
|
|
101
|
-
locale?: string;
|
|
102
|
-
oidcPrompt?: string;
|
|
103
|
-
oidcErrorRedirectUri?: string;
|
|
104
|
-
oidcResource?: string;
|
|
105
|
-
nativeOptions?: {
|
|
106
|
-
platform: "ios" | "android";
|
|
107
|
-
oauthProvider?: string;
|
|
108
|
-
oauthRedirect?: string;
|
|
109
|
-
externalAuthRedirect?: string;
|
|
110
|
-
};
|
|
111
|
-
thirdPartyAppStateId?: string;
|
|
112
|
-
applicationScopes?: string;
|
|
113
|
-
outboundAppId?: string;
|
|
114
|
-
outboundAppScopes?: string[];
|
|
115
|
-
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
72
|
+
start: (flowId: string, options?: Pick<_1.FlowStartOptions, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
116
73
|
lastAuth?: Omit<{
|
|
117
74
|
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
118
75
|
oauthProvider?: string;
|
|
@@ -124,7 +81,7 @@ declare const createSdkWrapper: <P extends {
|
|
|
124
81
|
}, isCustomScreen?: any) => Promise<_1.SdkResponse<_1.FlowResponse>>;
|
|
125
82
|
next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: {
|
|
126
83
|
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any[])[])[])[])[])[])[])[])[])[])[];
|
|
127
|
-
}, isCustomScreen?: any) => Promise<_1.SdkResponse<_1.FlowResponse>>;
|
|
84
|
+
}, isCustomScreen?: any, options?: _1.FlowNextOptions) => Promise<_1.SdkResponse<_1.FlowResponse>>;
|
|
128
85
|
};
|
|
129
86
|
webauthn: {
|
|
130
87
|
signUp: ((identifier: string, name: string, passkeyOptions?: _1.PasskeyOptions) => Promise<_1.SdkResponse<_1.JWTResponse>>) & {
|
|
@@ -831,50 +788,7 @@ declare const createSdkWrapper: <P extends {
|
|
|
831
788
|
refresh: (token?: string, tryRefresh?: boolean) => Promise<_1.SdkResponse<_1.JWTResponse>>;
|
|
832
789
|
logout: (token?: string) => Promise<_1.SdkResponse<never>>;
|
|
833
790
|
flow: {
|
|
834
|
-
start: (flowId: string, options?: Pick<{
|
|
835
|
-
redirectUrl?: string;
|
|
836
|
-
location?: string;
|
|
837
|
-
tenant?: string;
|
|
838
|
-
deviceInfo?: {
|
|
839
|
-
webAuthnSupport?: boolean;
|
|
840
|
-
};
|
|
841
|
-
lastAuth?: {
|
|
842
|
-
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
843
|
-
oauthProvider?: string;
|
|
844
|
-
name?: string;
|
|
845
|
-
loginId?: string;
|
|
846
|
-
};
|
|
847
|
-
redirectAuth?: {
|
|
848
|
-
callbackUrl: string;
|
|
849
|
-
codeChallenge: string;
|
|
850
|
-
};
|
|
851
|
-
oidcIdpStateId?: string;
|
|
852
|
-
preview?: boolean;
|
|
853
|
-
samlIdpStateId?: string;
|
|
854
|
-
wsfedIdpStateId?: string;
|
|
855
|
-
samlIdpUsername?: string;
|
|
856
|
-
ssoAppId?: string;
|
|
857
|
-
customAppId?: string;
|
|
858
|
-
thirdPartyAppId?: string;
|
|
859
|
-
oidcLoginHint?: string;
|
|
860
|
-
abTestingKey?: number;
|
|
861
|
-
startOptionsVersion?: number;
|
|
862
|
-
client?: Record<string, any>;
|
|
863
|
-
locale?: string;
|
|
864
|
-
oidcPrompt?: string;
|
|
865
|
-
oidcErrorRedirectUri?: string;
|
|
866
|
-
oidcResource?: string;
|
|
867
|
-
nativeOptions?: {
|
|
868
|
-
platform: "ios" | "android";
|
|
869
|
-
oauthProvider?: string;
|
|
870
|
-
oauthRedirect?: string;
|
|
871
|
-
externalAuthRedirect?: string;
|
|
872
|
-
};
|
|
873
|
-
thirdPartyAppStateId?: string;
|
|
874
|
-
applicationScopes?: string;
|
|
875
|
-
outboundAppId?: string;
|
|
876
|
-
outboundAppScopes?: string[];
|
|
877
|
-
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
791
|
+
start: (flowId: string, options?: Pick<_1.FlowStartOptions, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
878
792
|
lastAuth?: Omit<{
|
|
879
793
|
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
880
794
|
oauthProvider?: string;
|
|
@@ -886,7 +800,7 @@ declare const createSdkWrapper: <P extends {
|
|
|
886
800
|
}, isCustomScreen?: any) => Promise<_1.SdkResponse<_1.FlowResponse>>;
|
|
887
801
|
next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: {
|
|
888
802
|
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any[])[])[])[])[])[])[])[])[])[])[];
|
|
889
|
-
}, isCustomScreen?: any) => Promise<_1.SdkResponse<_1.FlowResponse>>;
|
|
803
|
+
}, isCustomScreen?: any, options?: _1.FlowNextOptions) => Promise<_1.SdkResponse<_1.FlowResponse>>;
|
|
890
804
|
};
|
|
891
805
|
webauthn: {
|
|
892
806
|
signUp: ((identifier: string, name: string, passkeyOptions?: _1.PasskeyOptions) => Promise<_1.SdkResponse<_1.JWTResponse>>) & {
|
|
@@ -1593,50 +1507,7 @@ declare const createSdkWrapper: <P extends {
|
|
|
1593
1507
|
refresh: (token?: string, tryRefresh?: boolean) => Promise<_1.SdkResponse<_1.JWTResponse>>;
|
|
1594
1508
|
logout: (token?: string) => Promise<_1.SdkResponse<never>>;
|
|
1595
1509
|
flow: {
|
|
1596
|
-
start: (flowId: string, options?: Pick<{
|
|
1597
|
-
redirectUrl?: string;
|
|
1598
|
-
location?: string;
|
|
1599
|
-
tenant?: string;
|
|
1600
|
-
deviceInfo?: {
|
|
1601
|
-
webAuthnSupport?: boolean;
|
|
1602
|
-
};
|
|
1603
|
-
lastAuth?: {
|
|
1604
|
-
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
1605
|
-
oauthProvider?: string;
|
|
1606
|
-
name?: string;
|
|
1607
|
-
loginId?: string;
|
|
1608
|
-
};
|
|
1609
|
-
redirectAuth?: {
|
|
1610
|
-
callbackUrl: string;
|
|
1611
|
-
codeChallenge: string;
|
|
1612
|
-
};
|
|
1613
|
-
oidcIdpStateId?: string;
|
|
1614
|
-
preview?: boolean;
|
|
1615
|
-
samlIdpStateId?: string;
|
|
1616
|
-
wsfedIdpStateId?: string;
|
|
1617
|
-
samlIdpUsername?: string;
|
|
1618
|
-
ssoAppId?: string;
|
|
1619
|
-
customAppId?: string;
|
|
1620
|
-
thirdPartyAppId?: string;
|
|
1621
|
-
oidcLoginHint?: string;
|
|
1622
|
-
abTestingKey?: number;
|
|
1623
|
-
startOptionsVersion?: number;
|
|
1624
|
-
client?: Record<string, any>;
|
|
1625
|
-
locale?: string;
|
|
1626
|
-
oidcPrompt?: string;
|
|
1627
|
-
oidcErrorRedirectUri?: string;
|
|
1628
|
-
oidcResource?: string;
|
|
1629
|
-
nativeOptions?: {
|
|
1630
|
-
platform: "ios" | "android";
|
|
1631
|
-
oauthProvider?: string;
|
|
1632
|
-
oauthRedirect?: string;
|
|
1633
|
-
externalAuthRedirect?: string;
|
|
1634
|
-
};
|
|
1635
|
-
thirdPartyAppStateId?: string;
|
|
1636
|
-
applicationScopes?: string;
|
|
1637
|
-
outboundAppId?: string;
|
|
1638
|
-
outboundAppScopes?: string[];
|
|
1639
|
-
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
1510
|
+
start: (flowId: string, options?: Pick<_1.FlowStartOptions, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
1640
1511
|
lastAuth?: Omit<{
|
|
1641
1512
|
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
1642
1513
|
oauthProvider?: string;
|
|
@@ -1648,7 +1519,7 @@ declare const createSdkWrapper: <P extends {
|
|
|
1648
1519
|
}, isCustomScreen?: any) => Promise<_1.SdkResponse<_1.FlowResponse>>;
|
|
1649
1520
|
next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: {
|
|
1650
1521
|
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any[])[])[])[])[])[])[])[])[])[])[];
|
|
1651
|
-
}, isCustomScreen?: any) => Promise<_1.SdkResponse<_1.FlowResponse>>;
|
|
1522
|
+
}, isCustomScreen?: any, options?: _1.FlowNextOptions) => Promise<_1.SdkResponse<_1.FlowResponse>>;
|
|
1652
1523
|
};
|
|
1653
1524
|
webauthn: {
|
|
1654
1525
|
signUp: ((identifier: string, name: string, passkeyOptions?: _1.PasskeyOptions) => Promise<_1.SdkResponse<_1.JWTResponse>>) & {
|
|
@@ -2456,6 +2327,7 @@ type DescopeProps = {
|
|
|
2456
2327
|
autoFocus?: AutoFocusOptions;
|
|
2457
2328
|
validateOnBlur?: boolean;
|
|
2458
2329
|
restartOnError?: boolean;
|
|
2330
|
+
sendSessionToken?: boolean;
|
|
2459
2331
|
debug?: boolean;
|
|
2460
2332
|
telemetryKey?: string;
|
|
2461
2333
|
redirectUrl?: string;
|