@descope/react-sdk 2.13.2 → 2.14.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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../constants.js"),r=require("../hooks/Context.js"),s=require("../sdk.js"),n=require("./withPropsMapping/index.js");function a(e){return e&&e.__esModule?e:{default:e}}var o=a(e);const l=e.lazy((async()=>(((null===customElements||void 0===customElements?void 0:customElements.get("descope-wc"))||await import("@descope/web-component").then((e=>e.default))).sdkConfigOverrides={baseHeaders:t.baseHeaders,persistTokens:!1,hooks:{get beforeRequest(){return s.getGlobalSdk().httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:n.default(o.default.forwardRef(((e,t)=>o.default.createElement("descope-wc",Object.assign({ref:t},e)))))}))),u=o.default.forwardRef((({flowId:t,onSuccess:s,onError:n,onReady:a,logger:u,tenant:d,theme:c,nonce:i,locale:f,debug:m,client:p,form:v,telemetryKey:E,redirectUrl:b,autoFocus:h,validateOnBlur:L,restartOnError:g,errorTransformer:k,styleId:y,onScreenUpdate:U,dismissScreenErrorOnInput:w,children:C},S)=>{const[q,O]=e.useState(null);e.useImperativeHandle(S,(()=>q));const{projectId:j,baseUrl:I,baseStaticUrl:R,baseCdnUrl:x,storeLastAuthenticatedUser:A,keepLastAuthenticatedUserAfterLogout:_,refreshCookieName:H,sdk:M}=o.default.useContext(r.default),N=e.useCallback((async e=>{await M.httpClient.hooks.afterRequest({},new Response(JSON.stringify(e.detail))),s&&s(e)}),[s]);return e.useEffect((()=>{const e=q;return null==e||e.addEventListener("success",N),n&&(null==e||e.addEventListener("error",n)),a&&(null==e||e.addEventListener("ready",a)),()=>{n&&(null==e||e.removeEventListener("error",n)),a&&(null==e||e.removeEventListener("ready",a)),null==e||e.removeEventListener("success",N)}}),[q,n,N]),e.useEffect((()=>{const e=q;return null==e||e.addEventListener("success",N),()=>{null==e||e.removeEventListener("success",N)}}),[q,N]),e.useEffect((()=>{const e=q;return n&&(null==e||e.addEventListener("error",n)),()=>{n&&(null==e||e.removeEventListener("error",n))}}),[q,n]),e.useEffect((()=>{const e=q;return a&&(null==e||e.addEventListener("ready",a)),()=>{a&&(null==e||e.removeEventListener("error",a))}}),[q,a]),o.default.createElement("form",null,o.default.createElement(e.Suspense,{fallback:null},o.default.createElement(l,{projectId:j,flowId:t,baseUrl:I,baseStaticUrl:R,baseCdnUrl:x,ref:O,telemetryKey:E,redirectUrl:b,autoFocus:h,styleId:y,validateOnBlur:L,restartOnError:g,keepLastAuthenticatedUserAfterLogout:_,tenant:d,"theme.attr":c,"nonce.attr":i,"locale.attr":f,"form.attr":v,"client.attr":p,"debug.attr":m,"store-last-authenticated-user.attr":A,"refreshCookieName.attr":H,"dismiss-screen-error-on-input.attr":w,"errorTransformer.prop":k,"logger.prop":u,"onScreenUpdate.prop":U},C)))}));exports.default=u;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../constants.js"),r=require("../hooks/Context.js"),s=require("../sdk.js"),n=require("./withPropsMapping/index.js");function o(e){return e&&e.__esModule?e:{default:e}}var a=o(e);const l=e.lazy((async()=>(((null===customElements||void 0===customElements?void 0:customElements.get("descope-wc"))||await import("@descope/web-component").then((e=>e.default))).sdkConfigOverrides={baseHeaders:t.baseHeaders,persistTokens:!1,hooks:{get beforeRequest(){return s.getGlobalSdk().httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:n.default(a.default.forwardRef(((e,t)=>a.default.createElement("descope-wc",Object.assign({ref:t},e)))))}))),u=a.default.forwardRef((({flowId:t,onSuccess:s,onError:n,onReady:o,logger:u,tenant:d,theme:c,nonce:i,locale:f,debug:p,client:m,form:v,telemetryKey:E,redirectUrl:b,autoFocus:h,validateOnBlur:L,restartOnError:g,errorTransformer:k,styleId:y,onScreenUpdate:U,dismissScreenErrorOnInput:w,outboundAppId:S,outboundAppScopes:C,children:q},I)=>{const[O,j]=e.useState(null);e.useImperativeHandle(I,(()=>O));const{projectId:R,baseUrl:A,baseStaticUrl:x,baseCdnUrl:_,storeLastAuthenticatedUser:H,keepLastAuthenticatedUserAfterLogout:M,refreshCookieName:N,sdk:T}=a.default.useContext(r.default),B=e.useCallback((async e=>{await T.httpClient.hooks.afterRequest({},new Response(JSON.stringify(e.detail))),s&&s(e)}),[s]);return e.useEffect((()=>{const e=O;return null==e||e.addEventListener("success",B),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",B)}}),[O,n,B]),e.useEffect((()=>{const e=O;return null==e||e.addEventListener("success",B),()=>{null==e||e.removeEventListener("success",B)}}),[O,B]),e.useEffect((()=>{const e=O;return n&&(null==e||e.addEventListener("error",n)),()=>{n&&(null==e||e.removeEventListener("error",n))}}),[O,n]),e.useEffect((()=>{const e=O;return o&&(null==e||e.addEventListener("ready",o)),()=>{o&&(null==e||e.removeEventListener("error",o))}}),[O,o]),a.default.createElement("form",null,a.default.createElement(e.Suspense,{fallback:null},a.default.createElement(l,{projectId:R,flowId:t,baseUrl:A,baseStaticUrl:x,baseCdnUrl:_,ref:j,telemetryKey:E,redirectUrl:b,autoFocus:h,styleId:y,validateOnBlur:L,restartOnError:g,keepLastAuthenticatedUserAfterLogout:M,tenant:d,"theme.attr":c,"nonce.attr":i,"locale.attr":f,"form.attr":v,"client.attr":m,"debug.attr":p,"outbound-app-id.attr":S,"outbound-app-scopes.attr":C,"store-last-authenticated-user.attr":H,"refreshCookieName.attr":N,"dismiss-screen-error-on-input.attr":w,"errorTransformer.prop":k,"logger.prop":u,"onScreenUpdate.prop":U},q)))}));exports.default=u;
2
2
  //# sourceMappingURL=Descope.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Descope.js","sources":["../../../src/components/Descope.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport { baseHeaders } from '../constants';\nimport Context from '../hooks/Context';\nimport { DescopeProps } from '../types';\nimport { getGlobalSdk } from '../sdk';\nimport withPropsMapping from './withPropsMapping';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst DescopeWC = lazy(async () => {\n const WebComponent: any =\n customElements?.get('descope-wc') ||\n (await import('@descope/web-component').then((module) => module.default));\n\n WebComponent.sdkConfigOverrides = {\n // Overrides the web-component's base headers to indicate usage via the React SDK\n baseHeaders,\n // Disables token persistence within the web-component to delegate token management\n // to the global SDK hooks. This ensures token handling aligns with the SDK's configuration,\n // and web-component requests leverage the global SDK's beforeRequest hooks for consistency\n persistTokens: false,\n hooks: {\n get beforeRequest() {\n // Retrieves the beforeRequest hook from the global SDK, which is initialized\n // within the AuthProvider using the desired configuration. This approach ensures\n // the web-component utilizes the same beforeRequest hooks as the global SDK\n return getGlobalSdk().httpClient.hooks.beforeRequest;\n },\n set beforeRequest(_) {\n // The empty setter prevents runtime errors when attempts are made to assign a value to 'beforeRequest'.\n // JavaScript objects default to having both getters and setters\n },\n },\n };\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-wc ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst Descope = React.forwardRef<HTMLElement, DescopeProps>(\n (\n {\n flowId,\n onSuccess,\n onError,\n onReady,\n logger,\n tenant,\n theme,\n 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 children,\n },\n ref,\n ) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const {\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n 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 {...{\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 '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","props","ref","createElement","Object","assign","Descope","flowId","onSuccess","onError","onReady","logger","tenant","theme","nonce","locale","debug","client","form","telemetryKey","redirectUrl","autoFocus","validateOnBlur","restartOnError","errorTransformer","styleId","onScreenUpdate","dismissScreenErrorOnInput","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","Suspense","fallback"],"mappings":"uRAeA,MAAMA,EAAYC,EAAIA,MAACC,YAEnB,OAAAC,qBAAA,IAAAA,oBAAA,EAAAA,eAAgBC,IAAI,sBACbC,OAAO,0BAA0BC,MAAMC,GAAWA,EAAOC,WAErDC,mBAAqB,aAEhCC,EAAWA,YAIXC,eAAe,EACfC,MAAO,CACL,iBAAIC,GAIF,OAAOC,iBAAeC,WAAWH,MAAMC,aACxC,EACD,iBAAIA,CAAcG,GAGjB,IAIE,CACLR,QAASS,EAAgBT,QACvBU,U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KACR,MAAMC,EAAMvB,EAGZ,OAFIpB,IAAS2C,SAAAA,EAAKC,iBAAiB,QAAS5C,IAErC,KACDA,IAAS2C,SAAAA,EAAKE,oBAAoB,QAAS7C,GAAQ,CACxD,GACA,CAACoB,EAAUpB,IAGd0C,EAAAA,WAAU,KACR,MAAMC,EAAMvB,EAGZ,OAFInB,IAAS0C,SAAAA,EAAKC,iBAAiB,QAAS3C,IAErC,KACDA,IAAS0C,SAAAA,EAAKE,oBAAoB,QAAS5C,GAAQ,CACxD,GACA,CAACmB,EAAUnB,IASjBX,UAAAI,cAAA,OAAA,KACCJ,EAAAA,QAAAI,cAACoD,EAAAA,SAAQ,CAACC,SAAU,MACnBzD,EAACV,QAAAc,cAAAtB,EACQ,CAAAoD,UAAWA,EACX1B,OAAQA,EACR2B,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZlC,IAAK4B,EACLX,aAAcA,EACdC,YAAaA,EACbC,UAAWA,EACXI,QAASA,EACTH,eAAgBA,EAChBC,eAAgBA,EAChBe,qCACEA,EAEF1B,OAAQA,EAGN,aAAcC,EACd,aAAcC,EACd,cAAeC,EACf,YAAaG,EACb,cAAeD,EACf,aAAcD,EACd,qCAAsCqB,EACtC,yBAA0BE,EAC1B,qCAAsCZ,EAEtC,wBAAyBH,EACzB,cAAeb,EACf,sBAAuBe,GAGhCE,IAIC"}
1
+ {"version":3,"file":"Descope.js","sources":["../../../src/components/Descope.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport { baseHeaders } from '../constants';\nimport Context from '../hooks/Context';\nimport { DescopeProps } from '../types';\nimport { getGlobalSdk } from '../sdk';\nimport withPropsMapping from './withPropsMapping';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst DescopeWC = lazy(async () => {\n const WebComponent: any =\n customElements?.get('descope-wc') ||\n (await import('@descope/web-component').then((module) => module.default));\n\n WebComponent.sdkConfigOverrides = {\n // Overrides the web-component's base headers to indicate usage via the React SDK\n baseHeaders,\n // Disables token persistence within the web-component to delegate token management\n // to the global SDK hooks. This ensures token handling aligns with the SDK's configuration,\n // and web-component requests leverage the global SDK's beforeRequest hooks for consistency\n persistTokens: false,\n hooks: {\n get beforeRequest() {\n // Retrieves the beforeRequest hook from the global SDK, which is initialized\n // within the AuthProvider using the desired configuration. This approach ensures\n // the web-component utilizes the same beforeRequest hooks as the global SDK\n return getGlobalSdk().httpClient.hooks.beforeRequest;\n },\n set beforeRequest(_) {\n // The empty setter prevents runtime errors when attempts are made to assign a value to 'beforeRequest'.\n // JavaScript objects default to having both getters and setters\n },\n },\n };\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-wc ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst Descope = React.forwardRef<HTMLElement, DescopeProps>(\n (\n {\n flowId,\n onSuccess,\n onError,\n onReady,\n logger,\n tenant,\n theme,\n 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 },\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 {...{\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","props","ref","createElement","Object","assign","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","Suspense","fallback"],"mappings":"uRAeA,MAAMA,EAAYC,EAAIA,MAACC,YAEnB,OAAAC,qBAAA,IAAAA,oBAAA,EAAAA,eAAgBC,IAAI,sBACbC,OAAO,0BAA0BC,MAAMC,GAAWA,EAAOC,WAErDC,mBAAqB,aAEhCC,EAAWA,YAIXC,eAAe,EACfC,MAAO,CACL,iBAAIC,GAIF,OAAOC,iBAAeC,WAAWH,MAAMC,aACxC,EACD,iBAAIA,CAAcG,GAGjB,IAIE,CACLR,QAASS,EAAgBT,QACvBU,UAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAAA,QAAYI,cAAA,aAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAMrBK,EAAUP,EAAAA,QAAMC,YACpB,EAEIO,SACAC,YACAC,UACAC,UACAC,SACAC,SACAC,QACAC,QACAC,SACAC,QACAC,S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MAAMC,EAAMvB,EAGZ,OAFIrB,IAAS4C,SAAAA,EAAKC,iBAAiB,QAAS7C,IAErC,KACDA,IAAS4C,SAAAA,EAAKE,oBAAoB,QAAS9C,GAAQ,CACxD,GACA,CAACqB,EAAUrB,IASjBX,UAAAI,cAAA,OAAA,KACCJ,EAAAA,QAAAI,cAACsD,EAAAA,SAAQ,CAACC,SAAU,MACnB3D,EAACV,QAAAc,cAAAtB,EACQ,CAAAsD,UAAWA,EACX5B,OAAQA,EACR6B,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZpC,IAAK8B,EACLb,aAAcA,EACdC,YAAaA,EACbC,UAAWA,EACXI,QAASA,EACTH,eAAgBA,EAChBC,eAAgBA,EAChBiB,qCACEA,EAEF5B,OAAQA,EAGN,aAAcC,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,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.13.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.14.1"};
2
2
  //# sourceMappingURL=constants.js.map
@@ -1,2 +1,2 @@
1
- import e,{lazy as t,useState as r,useImperativeHandle as n,useCallback as s,useEffect as o,Suspense as a}from"react";import{baseHeaders as l}from"../constants.js";import c from"../hooks/Context.js";import{getGlobalSdk as d}from"../sdk.js";import u from"./withPropsMapping/index.js";const i=t((async()=>(((null===customElements||void 0===customElements?void 0:customElements.get("descope-wc"))||await import("@descope/web-component").then((e=>e.default))).sdkConfigOverrides={baseHeaders:l,persistTokens:!1,hooks:{get beforeRequest(){return d().httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:u(e.forwardRef(((t,r)=>e.createElement("descope-wc",Object.assign({ref:r},t)))))}))),m=e.forwardRef((({flowId:t,onSuccess:l,onError:d,onReady:u,logger:m,tenant:f,theme:p,nonce:v,locale:E,debug:h,client:L,form:b,telemetryKey:g,redirectUrl:k,autoFocus:y,validateOnBlur:U,restartOnError:w,errorTransformer:C,styleId:O,onScreenUpdate:R,dismissScreenErrorOnInput:j,children:I},S)=>{const[A,q]=r(null);n(S,(()=>A));const{projectId:x,baseUrl:N,baseStaticUrl:T,baseCdnUrl:B,storeLastAuthenticatedUser:F,keepLastAuthenticatedUserAfterLogout:K,refreshCookieName:H,sdk:J}=e.useContext(c),M=s((async e=>{await J.httpClient.hooks.afterRequest({},new Response(JSON.stringify(e.detail))),l&&l(e)}),[l]);return o((()=>{const e=A;return null==e||e.addEventListener("success",M),d&&(null==e||e.addEventListener("error",d)),u&&(null==e||e.addEventListener("ready",u)),()=>{d&&(null==e||e.removeEventListener("error",d)),u&&(null==e||e.removeEventListener("ready",u)),null==e||e.removeEventListener("success",M)}}),[A,d,M]),o((()=>{const e=A;return null==e||e.addEventListener("success",M),()=>{null==e||e.removeEventListener("success",M)}}),[A,M]),o((()=>{const e=A;return d&&(null==e||e.addEventListener("error",d)),()=>{d&&(null==e||e.removeEventListener("error",d))}}),[A,d]),o((()=>{const e=A;return u&&(null==e||e.addEventListener("ready",u)),()=>{u&&(null==e||e.removeEventListener("error",u))}}),[A,u]),e.createElement("form",null,e.createElement(a,{fallback:null},e.createElement(i,{projectId:x,flowId:t,baseUrl:N,baseStaticUrl:T,baseCdnUrl:B,ref:q,telemetryKey:g,redirectUrl:k,autoFocus:y,styleId:O,validateOnBlur:U,restartOnError:w,keepLastAuthenticatedUserAfterLogout:K,tenant:f,"theme.attr":p,"nonce.attr":v,"locale.attr":E,"form.attr":b,"client.attr":L,"debug.attr":h,"store-last-authenticated-user.attr":F,"refreshCookieName.attr":H,"dismiss-screen-error-on-input.attr":j,"errorTransformer.prop":C,"logger.prop":m,"onScreenUpdate.prop":R},I)))}));export{m as default};
1
+ import e,{lazy as t,useState as r,useImperativeHandle as n,useCallback as o,useEffect as s,Suspense as a}from"react";import{baseHeaders as l}from"../constants.js";import u from"../hooks/Context.js";import{getGlobalSdk as d}from"../sdk.js";import c from"./withPropsMapping/index.js";const i=t((async()=>(((null===customElements||void 0===customElements?void 0:customElements.get("descope-wc"))||await import("@descope/web-component").then((e=>e.default))).sdkConfigOverrides={baseHeaders:l,persistTokens:!1,hooks:{get beforeRequest(){return d().httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:c(e.forwardRef(((t,r)=>e.createElement("descope-wc",Object.assign({ref:r},t)))))}))),p=e.forwardRef((({flowId:t,onSuccess:l,onError:d,onReady:c,logger:p,tenant:m,theme:f,nonce:v,locale:E,debug:b,client:h,form:L,telemetryKey:g,redirectUrl:k,autoFocus:y,validateOnBlur:U,restartOnError:w,errorTransformer:C,styleId:I,onScreenUpdate:O,dismissScreenErrorOnInput:R,outboundAppId:S,outboundAppScopes:j,children:A},q)=>{const[x,N]=r(null);n(q,(()=>x));const{projectId:T,baseUrl:B,baseStaticUrl:F,baseCdnUrl:K,storeLastAuthenticatedUser:H,keepLastAuthenticatedUserAfterLogout:J,refreshCookieName:M,sdk:P}=e.useContext(u),z=o((async e=>{await P.httpClient.hooks.afterRequest({},new Response(JSON.stringify(e.detail))),l&&l(e)}),[l]);return s((()=>{const e=x;return null==e||e.addEventListener("success",z),d&&(null==e||e.addEventListener("error",d)),c&&(null==e||e.addEventListener("ready",c)),()=>{d&&(null==e||e.removeEventListener("error",d)),c&&(null==e||e.removeEventListener("ready",c)),null==e||e.removeEventListener("success",z)}}),[x,d,z]),s((()=>{const e=x;return null==e||e.addEventListener("success",z),()=>{null==e||e.removeEventListener("success",z)}}),[x,z]),s((()=>{const e=x;return d&&(null==e||e.addEventListener("error",d)),()=>{d&&(null==e||e.removeEventListener("error",d))}}),[x,d]),s((()=>{const e=x;return c&&(null==e||e.addEventListener("ready",c)),()=>{c&&(null==e||e.removeEventListener("error",c))}}),[x,c]),e.createElement("form",null,e.createElement(a,{fallback:null},e.createElement(i,{projectId:T,flowId:t,baseUrl:B,baseStaticUrl:F,baseCdnUrl:K,ref:N,telemetryKey:g,redirectUrl:k,autoFocus:y,styleId:I,validateOnBlur:U,restartOnError:w,keepLastAuthenticatedUserAfterLogout:J,tenant:m,"theme.attr":f,"nonce.attr":v,"locale.attr":E,"form.attr":L,"client.attr":h,"debug.attr":b,"outbound-app-id.attr":S,"outbound-app-scopes.attr":j,"store-last-authenticated-user.attr":H,"refreshCookieName.attr":M,"dismiss-screen-error-on-input.attr":R,"errorTransformer.prop":C,"logger.prop":p,"onScreenUpdate.prop":O},A)))}));export{p as default};
2
2
  //# sourceMappingURL=Descope.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Descope.js","sources":["../../../src/components/Descope.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport { baseHeaders } from '../constants';\nimport Context from '../hooks/Context';\nimport { DescopeProps } from '../types';\nimport { getGlobalSdk } from '../sdk';\nimport withPropsMapping from './withPropsMapping';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst DescopeWC = lazy(async () => {\n const WebComponent: any =\n customElements?.get('descope-wc') ||\n (await import('@descope/web-component').then((module) => module.default));\n\n WebComponent.sdkConfigOverrides = {\n // Overrides the web-component's base headers to indicate usage via the React SDK\n baseHeaders,\n // Disables token persistence within the web-component to delegate token management\n // to the global SDK hooks. This ensures token handling aligns with the SDK's configuration,\n // and web-component requests leverage the global SDK's beforeRequest hooks for consistency\n persistTokens: false,\n hooks: {\n get beforeRequest() {\n // Retrieves the beforeRequest hook from the global SDK, which is initialized\n // within the AuthProvider using the desired configuration. This approach ensures\n // the web-component utilizes the same beforeRequest hooks as the global SDK\n return getGlobalSdk().httpClient.hooks.beforeRequest;\n },\n set beforeRequest(_) {\n // The empty setter prevents runtime errors when attempts are made to assign a value to 'beforeRequest'.\n // JavaScript objects default to having both getters and setters\n },\n },\n };\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-wc ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst Descope = React.forwardRef<HTMLElement, DescopeProps>(\n (\n {\n flowId,\n onSuccess,\n onError,\n onReady,\n logger,\n tenant,\n theme,\n 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 children,\n },\n ref,\n ) => {\n const [innerRef, setInnerRef] = useState(null);\n\n useImperativeHandle(ref, () => innerRef);\n\n const {\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n 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 {...{\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 '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","props","ref","createElement","Object","assign","Descope","flowId","onSuccess","onError","onReady","logger","tenant","theme","nonce","locale","debug","client","form","telemetryKey","redirectUrl","autoFocus","validateOnBlur","restartOnError","errorTransformer","styleId","onScreenUpdate","dismissScreenErrorOnInput","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","Suspense","fallback"],"mappings":"0RAeA,MAAMA,EAAYC,GAAKC,YAEnB,OAAAC,qBAAA,IAAAA,oBAAA,EAAAA,eAAgBC,IAAI,sBACbC,OAAO,0BAA0BC,MAAMC,GAAWA,EAAOC,WAErDC,mBAAqB,CAEhCC,cAIAC,eAAe,EACfC,MAAO,CACL,iBAAIC,GAIF,OAAOC,IAAeC,WAAWH,MAAMC,aACxC,EACD,iBAAIA,CAAcG,GAGjB,IAIE,CACLR,QAASS,EACPC,EAAMC,YAAwB,CAACC,EAAOC,IAC3CH,EAAYI,cAAA,aAAAC,OAAAC,OAAA,CAAAH,IAAKA,GAASD,WAMrBK,EAAUP,EAAMC,YACpB,EAEIO,SACAC,YACAC,UACAC,UACAC,SACAC,SACAC,QACAC,QACAC,SACAC,QACAC,SACAC,OACAC,eACAC,cACAC,YACAC,iBACAC,iBACAC,mBACAC,UACAC,iBACAC,4BACAC,YAEF1B,KAEA,MAAO2B,EAAUC,GAAeC,EAAS,MAEzCC,EAAoB9B,GAAK,IAAM2B,IAE/B,MAAMI,UACJA,EAASC,QACTA,EAAOC,cACPA,EAAaC,WACbA,EAAUC,2BACVA,EAA0BC,qCAC1BA,EAAoCC,kBACpCA,EAAiBC,IACjBA,GACEzC,EAAM0C,WAAWC,GAEfC,EAAgBC,GACpB7D,MAAO8D,UAGCL,EAAI5C,WAAWH,MAAMqD,aACzB,CAAA,EACA,IAAIC,SAASC,KAAKC,UAAUJ,EAAEK,UAE5B1C,GACFA,EAAUqC,EACX,GAEH,C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,aAAcD,EACd,qCAAsCqB,EACtC,yBAA0BE,EAC1B,qCAAsCZ,EAEtC,wBAAyBH,EACzB,cAAeb,EACf,sBAAuBe,GAGhCE,IAIC"}
1
+ {"version":3,"file":"Descope.js","sources":["../../../src/components/Descope.tsx"],"sourcesContent":["import React, {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport { baseHeaders } from '../constants';\nimport Context from '../hooks/Context';\nimport { DescopeProps } from '../types';\nimport { getGlobalSdk } from '../sdk';\nimport withPropsMapping from './withPropsMapping';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst DescopeWC = lazy(async () => {\n const WebComponent: any =\n customElements?.get('descope-wc') ||\n (await import('@descope/web-component').then((module) => module.default));\n\n WebComponent.sdkConfigOverrides = {\n // Overrides the web-component's base headers to indicate usage via the React SDK\n baseHeaders,\n // Disables token persistence within the web-component to delegate token management\n // to the global SDK hooks. This ensures token handling aligns with the SDK's configuration,\n // and web-component requests leverage the global SDK's beforeRequest hooks for consistency\n persistTokens: false,\n hooks: {\n get beforeRequest() {\n // Retrieves the beforeRequest hook from the global SDK, which is initialized\n // within the AuthProvider using the desired configuration. This approach ensures\n // the web-component utilizes the same beforeRequest hooks as the global SDK\n return getGlobalSdk().httpClient.hooks.beforeRequest;\n },\n set beforeRequest(_) {\n // The empty setter prevents runtime errors when attempts are made to assign a value to 'beforeRequest'.\n // JavaScript objects default to having both getters and setters\n },\n },\n };\n\n return {\n default: withPropsMapping(\n React.forwardRef<HTMLElement>((props, ref) => (\n\t<descope-wc ref={ref} {...props} />\n )),\n ),\n };\n});\n\nconst Descope = React.forwardRef<HTMLElement, DescopeProps>(\n (\n {\n flowId,\n onSuccess,\n onError,\n onReady,\n logger,\n tenant,\n theme,\n 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 },\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 {...{\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","props","ref","createElement","Object","assign","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","Suspense","fallback"],"mappings":"0RA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SAAAA,EAAKE,oBAAoB,UAAWX,EAAc,CACnD,GACA,CAACd,EAAUtB,EAASoC,IAGvBQ,GAAU,KACR,MAAMC,EAAMvB,EAEZ,OADAuB,SAAAA,EAAKC,iBAAiB,UAAWV,GAC1B,KACLS,SAAAA,EAAKE,oBAAoB,UAAWX,EAAc,CACnD,GACA,CAACd,EAAUc,IAGdQ,GAAU,KACR,MAAMC,EAAMvB,EAGZ,OAFItB,IAAS6C,SAAAA,EAAKC,iBAAiB,QAAS9C,IAErC,KACDA,IAAS6C,SAAAA,EAAKE,oBAAoB,QAAS/C,GAAQ,CACxD,GACA,CAACsB,EAAUtB,IAGd4C,GAAU,KACR,MAAMC,EAAMvB,EAGZ,OAFIrB,IAAS4C,SAAAA,EAAKC,iBAAiB,QAAS7C,IAErC,KACDA,IAAS4C,SAAAA,EAAKE,oBAAoB,QAAS9C,GAAQ,CACxD,GACA,CAACqB,EAAUrB,IASjBX,EAAAI,cAAA,OAAA,KACCJ,EAAAI,cAACsD,EAAQ,CAACC,SAAU,MACnB3D,EAACI,cAAAtB,EACQ,CAAAsD,UAAWA,EACX5B,OAAQA,EACR6B,QAASA,EACTC,cAAeA,EACfC,WAAYA,EACZpC,IAAK8B,EACLb,aAAcA,EACdC,YAAaA,EACbC,UAAWA,EACXI,QAASA,EACTH,eAAgBA,EAChBC,eAAgBA,EAChBiB,qCACEA,EAEF5B,OAAQA,EAGN,aAAcC,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,2 +1,2 @@
1
- const e={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.13.2"},d="undefined"!=typeof window;export{d as IS_BROWSER,e as baseHeaders};
1
+ const e={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.14.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
@@ -121,7 +121,9 @@ declare const createSdkWrapper: <P extends Omit<{
121
121
  };
122
122
  thirdPartyAppStateId?: string;
123
123
  applicationScopes?: string;
124
- }, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes"> & {
124
+ outboundAppId?: string;
125
+ outboundAppScopes?: string[];
126
+ }, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
125
127
  lastAuth?: Omit<{
126
128
  authMethod?: "webauthn" | "otp" | "oauth" | "saml" | "totp" | "magiclink" | "enchantedlink";
127
129
  oauthProvider?: string;
@@ -574,6 +576,12 @@ declare const createSdkWrapper: <P extends Omit<{
574
576
  }>>;
575
577
  exchangeOneTapIDToken: (provider: string, idToken: string, nonce: string, loginOptions?: _1.LoginOptions) => Promise<_1.SdkResponse<_1.JWTResponse>>;
576
578
  };
579
+ outbound: {
580
+ connect: (appId: string, options?: {
581
+ redirectURL?: string;
582
+ scopes?: string[];
583
+ }, token?: string) => Promise<_1.SdkResponse<_1.URLResponse>>;
584
+ };
577
585
  saml: {
578
586
  start: (tenantIdOrEmail: string, redirectUrl?: string, loginOptions?: _1.LoginOptions, token?: string, ssoId?: string) => Promise<_1.SdkResponse<_1.URLResponse>>;
579
587
  exchange: (code: string) => Promise<_1.SdkResponse<_1.JWTResponse>>;
@@ -766,7 +774,9 @@ declare const createSdkWrapper: <P extends Omit<{
766
774
  };
767
775
  thirdPartyAppStateId?: string;
768
776
  applicationScopes?: string;
769
- }, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes"> & {
777
+ outboundAppId?: string;
778
+ outboundAppScopes?: string[];
779
+ }, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
770
780
  lastAuth?: Omit<{
771
781
  authMethod?: "webauthn" | "otp" | "oauth" | "saml" | "totp" | "magiclink" | "enchantedlink";
772
782
  oauthProvider?: string;
@@ -1219,6 +1229,12 @@ declare const createSdkWrapper: <P extends Omit<{
1219
1229
  }>>;
1220
1230
  exchangeOneTapIDToken: (provider: string, idToken: string, nonce: string, loginOptions?: _1.LoginOptions) => Promise<_1.SdkResponse<_1.JWTResponse>>;
1221
1231
  };
1232
+ outbound: {
1233
+ connect: (appId: string, options?: {
1234
+ redirectURL?: string;
1235
+ scopes?: string[];
1236
+ }, token?: string) => Promise<_1.SdkResponse<_1.URLResponse>>;
1237
+ };
1222
1238
  saml: {
1223
1239
  start: (tenantIdOrEmail: string, redirectUrl?: string, loginOptions?: _1.LoginOptions, token?: string, ssoId?: string) => Promise<_1.SdkResponse<_1.URLResponse>>;
1224
1240
  exchange: (code: string) => Promise<_1.SdkResponse<_1.JWTResponse>>;
@@ -1411,7 +1427,9 @@ declare const createSdkWrapper: <P extends Omit<{
1411
1427
  };
1412
1428
  thirdPartyAppStateId?: string;
1413
1429
  applicationScopes?: string;
1414
- }, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes"> & {
1430
+ outboundAppId?: string;
1431
+ outboundAppScopes?: string[];
1432
+ }, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
1415
1433
  lastAuth?: Omit<{
1416
1434
  authMethod?: "webauthn" | "otp" | "oauth" | "saml" | "totp" | "magiclink" | "enchantedlink";
1417
1435
  oauthProvider?: string;
@@ -1864,6 +1882,12 @@ declare const createSdkWrapper: <P extends Omit<{
1864
1882
  }>>;
1865
1883
  exchangeOneTapIDToken: (provider: string, idToken: string, nonce: string, loginOptions?: _1.LoginOptions) => Promise<_1.SdkResponse<_1.JWTResponse>>;
1866
1884
  };
1885
+ outbound: {
1886
+ connect: (appId: string, options?: {
1887
+ redirectURL?: string;
1888
+ scopes?: string[];
1889
+ }, token?: string) => Promise<_1.SdkResponse<_1.URLResponse>>;
1890
+ };
1867
1891
  saml: {
1868
1892
  start: (tenantIdOrEmail: string, redirectUrl?: string, loginOptions?: _1.LoginOptions, token?: string, ssoId?: string) => Promise<_1.SdkResponse<_1.URLResponse>>;
1869
1893
  exchange: (code: string) => Promise<_1.SdkResponse<_1.JWTResponse>>;
@@ -2089,6 +2113,8 @@ type DescopeProps = {
2089
2113
  debug?: boolean;
2090
2114
  telemetryKey?: string;
2091
2115
  redirectUrl?: string;
2116
+ outboundAppId?: string;
2117
+ outboundAppScopes?: string[];
2092
2118
  errorTransformer?: (error: {
2093
2119
  text: string;
2094
2120
  type: string;