@descope/react-sdk 2.0.16 → 2.0.18
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 +20 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.d.ts +148 -14
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -298,6 +298,8 @@ You can also use the following functions to assist with various actions managing
|
|
|
298
298
|
`getSessionToken()` - Get current session token.
|
|
299
299
|
`getRefreshToken()` - Get current refresh token.
|
|
300
300
|
`refresh(token = getRefreshToken())` - Force a refresh on current session token using an existing valid refresh token.
|
|
301
|
+
`isSessionTokenExpired(token = getSessionToken())` - Check whether the current session token is expired. Provide a session token if is not persisted (see [token persistence](#token-persistence))
|
|
302
|
+
`isRefreshTokenExpired(token = getRefreshToken())` - Check whether the current refresh token is expired. Provide a refresh token if is not persisted (see [token persistence](#token-persistence))
|
|
301
303
|
`getJwtRoles(token = getSessionToken(), tenant = '')` - Get current roles from an existing session token. Provide tenant id for specific tenant roles.
|
|
302
304
|
`getJwtPermissions(token = getSessionToken(), tenant = '')` - Fet current permissions from an existing session token. Provide tenant id for specific tenant permissions.
|
|
303
305
|
|
|
@@ -308,6 +310,24 @@ Descope SDK is automatically refreshes the session token when it is about to exp
|
|
|
308
310
|
If the Descope project settings are configured to manage tokens in cookies.
|
|
309
311
|
you must also configure a custom domain, and set it as the `baseUrl` prop in the `AuthProvider` component. See the above [`AuthProvider` usage](https://github.com/descope/react-sdk#wrap-your-app-with-auth-provider) for usage example.
|
|
310
312
|
|
|
313
|
+
### Token Persistence
|
|
314
|
+
|
|
315
|
+
Descope stores two tokens: the session token and the refresh token.
|
|
316
|
+
|
|
317
|
+
- The refresh token is either stored in local storage or an `httpOnly` cookie. This is configurable in the Descope console.
|
|
318
|
+
- The session token is stored in either local storage or a JS cookie. This behavior is configurable via the `sessionTokenViaCookie` prop in the `AuthProvider` component.
|
|
319
|
+
|
|
320
|
+
However, for security reasons, you may choose not to store tokens in the browser. In this case, you can pass `persistTokens={false}` to the `AuthProvider` component. This prevents the SDK from storing the tokens in the browser.
|
|
321
|
+
|
|
322
|
+
Notes:
|
|
323
|
+
|
|
324
|
+
- You must configure the refresh token to be stored in an `httpOnly` cookie in the Descope console. Otherwise, the refresh token will not be stored, and when the page is refreshed, the user will be logged out.
|
|
325
|
+
- You can still retrieve the session token using the `useSession` hook.
|
|
326
|
+
|
|
327
|
+
### Last User Persistence
|
|
328
|
+
|
|
329
|
+
Descope stores the last user information in local storage. If you wish to disable this feature, you can pass `storeLastAuthenticatedUser={false}` to the `AuthProvider` component. Please note that some features related to the last authenticated user may not function as expected if this behavior is disabled.
|
|
330
|
+
|
|
311
331
|
### Widgets
|
|
312
332
|
|
|
313
333
|
Widgets are components that allow you to expose management features for tenant-based implementation. In certain scenarios, your customers may require the capability to perform managerial actions independently, alleviating the necessity to contact you. Widgets serve as a feature enabling you to delegate these capabilities to your customers in a modular manner.
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@descope/web-js-sdk");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@descope/web-js-sdk");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(e),o=r(t);const a=n.default.createContext(void 0),u=e=>(...t)=>{if(!e)throw Error("You can only use this function after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component");return e(...t)},i=e=>(...t)=>{let r;try{r=e(...t)}catch(e){console.error(e)}return r},l={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.0.18"},c="undefined"!=typeof window;let d;const f=e=>{const t=o.default(Object.assign({persistTokens:c,autoRefresh:c},e));return d=t,t},p=()=>f({projectId:"temp pid",persistTokens:!1,autoRefresh:!1,storeLastAuthenticatedUser:!1});d=p();const g=()=>c?null==d?void 0:d.getSessionToken():(console.warn("Get session token is not supported in SSR"),""),m=()=>c?null==d?void 0:d.getRefreshToken():(console.warn("Get refresh token is not supported in SSR"),""),h=i(((e=g(),t)=>null==d?void 0:d.getJwtPermissions(e,t))),b=i(((e=g(),t)=>null==d?void 0:d.getJwtRoles(e,t)));const w=e.lazy((async()=>((await Promise.resolve().then((function(){return s(require("@descope/web-component"))}))).default.sdkConfigOverrides={baseHeaders:l,persistTokens:!1,hooks:{get beforeRequest(){return d.httpClient.hooks.beforeRequest},set beforeRequest(e){}}},{default:({projectId:e,flowId:t,baseUrl:r,innerRef:s,tenant:o,theme:a,locale:u,debug:i,redirectUrl:l,client:c,form:d,autoFocus:f})=>n.default.createElement("descope-wc",{"project-id":e,"flow-id":t,"base-url":r,ref:s,tenant:o,theme:a,locale:u,debug:i,client:c,form:d,"redirect-url":l,"auto-focus":f})}))),k=n.default.forwardRef((({flowId:t,onSuccess:r,onError:s,onReady:o,logger:u,tenant:i,theme:l,locale:c,debug:d,client:f,form:p,telemetryKey:g,redirectUrl:m,autoFocus:h,errorTransformer:b},k)=>{const[v,E]=e.useState(null);e.useImperativeHandle(k,(()=>v));const{projectId:I,baseUrl:y,storeLastAuthenticatedUser:U,sdk:j}=n.default.useContext(a),S=e.useCallback((async e=>{await j.httpClient.hooks.afterRequest({},new Response(JSON.stringify(e.detail))),r&&r(e)}),[r]);e.useEffect((()=>{const e=v;return null==e||e.addEventListener("success",S),s&&(null==e||e.addEventListener("error",s)),o&&(null==e||e.addEventListener("ready",o)),()=>{s&&(null==e||e.removeEventListener("error",s)),o&&(null==e||e.removeEventListener("ready",o)),null==e||e.removeEventListener("success",S)}}),[v,s,S]),e.useEffect((()=>{const e=v;return null==e||e.addEventListener("success",S),()=>{null==e||e.removeEventListener("success",S)}}),[v,S]),e.useEffect((()=>{const e=v;return s&&(null==e||e.addEventListener("error",s)),()=>{s&&(null==e||e.removeEventListener("error",s))}}),[v,s]),e.useEffect((()=>{const e=v;return o&&(null==e||e.addEventListener("ready",o)),()=>{o&&(null==e||e.removeEventListener("error",o))}}),[v,o]),e.useEffect((()=>{v&&(v.errorTransformer=b)}),[v,b]),e.useEffect((()=>{v&&u&&(v.logger=u)}),[v,u]);const{form:R,client:x}=e.useMemo((()=>({form:JSON.stringify(p||{}),client:JSON.stringify(f||{})})),[p,f]);return n.default.createElement("form",null,n.default.createElement(e.Suspense,{fallback:null},n.default.createElement(w,{projectId:I,flowId:t,baseUrl:y,innerRef:E,tenant:i,theme:l,locale:c,debug:d,form:R,client:x,telemetryKey:g,redirectUrl:m,autoFocus:h,storeLastAuthenticatedUser:U})))})),v=e.lazy((async()=>(await Promise.resolve().then((function(){return s(require("@descope/user-management-widget"))})),{default:({projectId:e,baseUrl:t,innerRef:r,tenant:s,widgetId:o,theme:a,debug:u})=>n.default.createElement("descope-user-management-widget",{"project-id":e,"widget-id":o,"base-url":t,theme:a,tenant:s,debug:u,ref:r})}))),E=n.default.forwardRef((({logger:t,tenant:r,theme:s,debug:o,widgetId:u},i)=>{const[l,c]=e.useState(null);e.useImperativeHandle(i,(()=>l));const{projectId:d,baseUrl:f}=n.default.useContext(a);return e.useEffect((()=>{l&&t&&(l.logger=t)}),[l,t]),n.default.createElement(e.Suspense,{fallback:null},n.default.createElement(v,{projectId:d,widgetId:u,baseUrl:f,innerRef:c,tenant:r,theme:s,debug:o}))})),I=e.lazy((async()=>(await Promise.resolve().then((function(){return s(require("@descope/role-management-widget"))})),{default:({projectId:e,baseUrl:t,innerRef:r,tenant:s,widgetId:o,theme:a,debug:u})=>n.default.createElement("descope-role-management-widget",{"project-id":e,"widget-id":o,"base-url":t,theme:a,tenant:s,debug:u,ref:r})}))),y=n.default.forwardRef((({logger:t,tenant:r,theme:s,debug:o,widgetId:u},i)=>{const[l,c]=e.useState(null);e.useImperativeHandle(i,(()=>l));const{projectId:d,baseUrl:f}=n.default.useContext(a);return e.useEffect((()=>{l&&t&&(l.logger=t)}),[l,t]),n.default.createElement(e.Suspense,{fallback:null},n.default.createElement(I,{projectId:d,widgetId:u,baseUrl:f,innerRef:c,tenant:r,theme:s,debug:o}))})),U=e.lazy((async()=>(await Promise.resolve().then((function(){return s(require("@descope/access-key-management-widget"))})),{default:({projectId:e,baseUrl:t,innerRef:r,tenant:s,widgetId:o,theme:a,debug:u})=>n.default.createElement("descope-access-key-management-widget",{"project-id":e,"widget-id":o,"base-url":t,theme:a,tenant:s,debug:u,ref:r})}))),j=n.default.forwardRef((({logger:t,tenant:r,theme:s,debug:o,widgetId:u},i)=>{const[l,c]=e.useState(null);e.useImperativeHandle(i,(()=>l));const{projectId:d,baseUrl:f}=n.default.useContext(a);return e.useEffect((()=>{l&&t&&(l.logger=t)}),[l,t]),n.default.createElement(e.Suspense,{fallback:null},n.default.createElement(U,{projectId:d,widgetId:u,baseUrl:f,innerRef:c,tenant:r,theme:s,debug:o}))}));var S=()=>{const t=e.useContext(a);if(!t)throw Error("You can only use this hook in the context of <AuthProvider />");return t};const R=e=>`You can only use this ${e} after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`,x={get(e,t){if("object"==typeof e[t]&&null!==e[t])return new Proxy(e[t],x);if("function"==typeof e[t])return()=>{throw Error(R("function"))};throw Error(R("attribute"))}};exports.AccessKeyManagement=j,exports.AuthProvider=({projectId:t,baseUrl:r="",sessionTokenViaCookie:s=!1,persistTokens:o=!0,storeLastAuthenticatedUser:i=!0,children:c})=>{const[d,p]=e.useState(),[g,m]=e.useState(),[h,b]=e.useState(!1),[w,k]=e.useState(!1),v=(({projectId:t,baseUrl:r,persistTokens:s,sessionTokenViaCookie:n,storeLastAuthenticatedUser:o})=>e.useMemo((()=>{if(t)return f({projectId:t,baseUrl:r,sessionTokenViaCookie:n,baseHeaders:l,persistTokens:s,storeLastAuthenticatedUser:o,autoRefresh:!0})}),[t,r,n]))({projectId:t,baseUrl:r,persistTokens:o,sessionTokenViaCookie:s,storeLastAuthenticatedUser:i});e.useEffect((()=>{if(v){const e=v.onSessionTokenChange(m),t=v.onUserChange(p);return()=>{e(),t()}}}),[v]);const E=e.useRef(!1),I=e.useCallback((()=>{E.current||(E.current=!0,k(!0),u(null==v?void 0:v.refresh)().then((()=>{k(!1)})))}),[v]),y=e.useCallback((()=>{b(!0),u(v.me)().then((()=>{b(!1)}))}),[v]),U=e.useMemo((()=>({fetchUser:y,user:d,isUserLoading:h,fetchSession:I,session:g,isSessionLoading:w,isSessionFetched:E.current,projectId:t,baseUrl:r,storeLastAuthenticatedUser:i,setUser:p,setSession:m,sdk:v})),[y,d,h,I,g,w,E.current,t,r,p,m,v]);return n.default.createElement(a.Provider,{value:U},c)},exports.Descope=k,exports.RoleManagement=y,exports.SignInFlow=e=>n.default.createElement(k,Object.assign({},e,{flowId:"sign-in"})),exports.SignUpFlow=e=>n.default.createElement(k,Object.assign({},e,{flowId:"sign-up"})),exports.SignUpOrInFlow=e=>n.default.createElement(k,Object.assign({},e,{flowId:"sign-up-or-in"})),exports.UserManagement=E,exports.baseHeaders=l,exports.getJwtPermissions=h,exports.getJwtRoles=b,exports.getRefreshToken=m,exports.getSessionToken=g,exports.refresh=(e=m())=>null==d?void 0:d.refresh(e),exports.useDescope=()=>{const{sdk:t}=S();return e.useMemo((()=>t||new Proxy(p(),x)),[t])},exports.useSession=()=>{const{session:t,isSessionLoading:r,fetchSession:s,isSessionFetched:n}=S(),o=e.useRef(r);e.useMemo((()=>{o.current=r}),[r]);const a=!t&&!r;return e.useMemo((()=>{a&&!n&&(o.current=!0)}),[n]),e.useEffect((()=>{a&&s()}),[s]),{isSessionLoading:o.current,sessionToken:t,isAuthenticated:!!t}},exports.useUser=()=>{const{user:t,fetchUser:r,isUserLoading:s,session:n}=S(),[o,a]=e.useState(!1),u=e.useRef(s),i=e.useMemo((()=>!t&&!s&&n&&!o),[r,n,o]);return e.useMemo((()=>{u.current=s}),[s]),e.useMemo((()=>{i&&(u.current=!0)}),[i]),e.useEffect((()=>{i&&(a(!0),r())}),[i]),{isUserLoading:u.current,user:t}};
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../src/hooks/Context.ts","../../src/utils.ts","../../src/constants.ts","../../src/sdk.ts","../../src/components/AuthProvider/AuthProvider.tsx","../../src/components/Descope.tsx","../../src/components/UserManagement.tsx","../../src/components/RoleManagement.tsx","../../src/components/AccessKeyManagement.tsx","../../src/hooks/useContext.ts","../../src/hooks/useDescope.ts","../../src/components/AuthProvider/useSdk.ts","../../src/components/DefaultFlows.tsx","../../src/hooks/useSession.ts","../../src/hooks/useUser.ts"],"sourcesContent":["import React from 'react';\nimport { IContext } from '../types';\n\nconst Context = React.createContext<IContext>(undefined);\n\nexport default Context;\n","/**\n * Wrap a function with a validation that it exists\n * @param fn The function to wrap with the validation\n * @throws if function does not exist, an error with the relevant message will be thrown\n */\nexport const withValidation =\n\t<T extends Array<any>, U>(fn: (...args: T) => U) =>\n\t(...args: T): U => {\n\t\tif (!fn) {\n\t\t\tthrow Error(\n\t\t\t\t`You can only use this function after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`\n\t\t\t);\n\t\t}\n\t\treturn fn(...args);\n\t};\n\nexport const wrapInTry =\n\t<T extends Array<any>, U>(fn: (...args: T) => U) =>\n\t(...args: T): U => {\n\t\tlet res: U;\n\t\ttry {\n\t\t\tres = fn(...args);\n\t\t} catch (err) {\n\t\t\tconsole.error(err); // eslint-disable-line no-console\n\t\t}\n\t\treturn res;\n\t};\n","declare const BUILD_VERSION: string;\n\nexport const baseHeaders = {\n\t'x-descope-sdk-name': 'react',\n\t'x-descope-sdk-version': BUILD_VERSION\n};\n\n// This sdk can be used in SSR apps\nexport const IS_BROWSER = typeof window !== 'undefined';\n","import createSdk from '@descope/web-js-sdk';\nimport { IS_BROWSER } from './constants';\nimport { wrapInTry } from './utils';\n\ntype Sdk = ReturnType<typeof createSdkWrapper>;\nlet globalSdk: Sdk;\n\nconst createSdkWrapper = <P extends Parameters<typeof createSdk>[0]>(\n\tconfig: P\n) => {\n\tconst sdk = createSdk({\n\t\t...config,\n\t\tpersistTokens: IS_BROWSER as true,\n\t\tautoRefresh: IS_BROWSER as true\n\t});\n\tglobalSdk = sdk;\n\n\treturn sdk;\n};\n\n/**\n * We want to make sure the getSessionToken fn is used only when persistTokens is on\n *\n * So we are keeping the SDK init in a single place,\n * and we are creating a temp instance in order to export the getSessionToken\n * even before the SDK was init\n */\nglobalSdk = createSdkWrapper({ projectId: 'temp pid' });\n\nexport const getSessionToken = () => {\n\tif (IS_BROWSER) {\n\t\treturn globalSdk?.getSessionToken();\n\t}\n\n\t// eslint-disable-next-line no-console\n\tconsole.warn('Get session token is not supported in SSR');\n\treturn '';\n};\n\nexport const getRefreshToken = () => {\n\tif (IS_BROWSER) {\n\t\treturn globalSdk?.getRefreshToken();\n\t}\n\t// eslint-disable-next-line no-console\n\tconsole.warn('Get refresh token is not supported in SSR');\n\treturn '';\n};\n\nexport const getJwtPermissions = wrapInTry(\n\t(token = getSessionToken(), tenant?: string) =>\n\t\tglobalSdk?.getJwtPermissions(token, tenant)\n);\n\nexport const getJwtRoles = wrapInTry(\n\t(token = getSessionToken(), tenant?: string) =>\n\t\tglobalSdk?.getJwtRoles(token, tenant)\n);\n\nexport const refresh = (token = getRefreshToken()) => globalSdk?.refresh(token);\n\nexport const getGlobalSdk = () => globalSdk;\n\nexport default createSdkWrapper;\n","import React, {\n\tFC,\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState\n} from 'react';\nimport Context from '../../hooks/Context';\nimport { IContext, User } from '../../types';\nimport { withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ninterface IAuthProviderProps {\n\tprojectId: string;\n\tbaseUrl?: string;\n\t// If true, session token (jwt) will be stored on cookie. Otherwise, the session token will be\n\t// stored on local storage and can accessed with getSessionToken function\n\t// Use this option if session token will stay small (less than 1k)\n\t// NOTE: Session token can grow, especially in cases of using authorization, or adding custom claims\n\tsessionTokenViaCookie?: boolean;\n\tchildren?: JSX.Element;\n}\n\nconst AuthProvider: FC<IAuthProviderProps> = ({\n\tprojectId,\n\tbaseUrl = '',\n\tsessionTokenViaCookie = false,\n\tchildren = undefined\n}) => {\n\tconst [user, setUser] = useState<User>();\n\tconst [session, setSession] = useState<string>();\n\n\tconst [isUserLoading, setIsUserLoading] = useState(false);\n\tconst [isSessionLoading, setIsSessionLoading] = useState(false);\n\n\tconst sdk = useSdk({ projectId, baseUrl, sessionTokenViaCookie });\n\n\tuseEffect(() => {\n\t\tif (sdk) {\n\t\t\tconst unsubscribeSessionToken = sdk.onSessionTokenChange(setSession);\n\t\t\tconst unsubscribeUser = sdk.onUserChange(setUser);\n\n\t\t\treturn () => {\n\t\t\t\tunsubscribeSessionToken();\n\t\t\t\tunsubscribeUser();\n\t\t\t};\n\t\t}\n\t\treturn undefined;\n\t}, [sdk]);\n\n\tconst isSessionFetched = useRef(false);\n\n\tconst fetchSession = useCallback(() => {\n\t\t// We want that the session will fetched only once\n\t\tif (isSessionFetched.current) return;\n\t\tisSessionFetched.current = true;\n\n\t\tsetIsSessionLoading(true);\n\t\twithValidation(sdk?.refresh)().then(() => {\n\t\t\tsetIsSessionLoading(false);\n\t\t});\n\t}, [sdk]);\n\n\tconst fetchUser = useCallback(() => {\n\t\tsetIsUserLoading(true);\n\t\twithValidation(sdk.me)().then(() => {\n\t\t\tsetIsUserLoading(false);\n\t\t});\n\t}, [sdk]);\n\n\tconst value = useMemo<IContext>(\n\t\t() => ({\n\t\t\tfetchUser,\n\t\t\tuser,\n\t\t\tisUserLoading,\n\t\t\tfetchSession,\n\t\t\tsession,\n\t\t\tisSessionLoading,\n\t\t\tisSessionFetched: isSessionFetched.current,\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tsetUser,\n\t\t\tsetSession,\n\t\t\tsdk\n\t\t}),\n\t\t[\n\t\t\tfetchUser,\n\t\t\tuser,\n\t\t\tisUserLoading,\n\t\t\tfetchSession,\n\t\t\tsession,\n\t\t\tisSessionLoading,\n\t\t\tisSessionFetched.current,\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tsetUser,\n\t\t\tsetSession,\n\t\t\tsdk\n\t\t]\n\t);\n\treturn <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport default AuthProvider;\n","import React, {\n\tlazy,\n\tSuspense,\n\tuseCallback,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseMemo,\n\tuseState\n} from 'react';\nimport { baseHeaders } from '../constants';\nimport Context from '../hooks/Context';\nimport { DescopeProps } from '../types';\nimport { getGlobalSdk } from '../sdk';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst DescopeWC = lazy(async () => {\n\tconst module = await import('@descope/web-component');\n\tmodule.default.sdkConfigOverrides = {\n\t\t// Overrides the web-component's base headers to indicate usage via the React SDK\n\t\tbaseHeaders,\n\t\t// Disables token persistence within the web-component to delegate token management\n\t\t// to the global SDK hooks. This ensures token handling aligns with the SDK's configuration,\n\t\t// and web-component requests leverage the global SDK's beforeRequest hooks for consistency\n\t\tpersistTokens: false,\n\t\thooks: {\n\t\t\tget beforeRequest() {\n\t\t\t\t// Retrieves the beforeRequest hook from the global SDK, which is initialized\n\t\t\t\t// within the AuthProvider using the desired configuration. This approach ensures\n\t\t\t\t// the web-component utilizes the same beforeRequest hooks as the global SDK\n\t\t\t\treturn getGlobalSdk().httpClient.hooks.beforeRequest;\n\t\t\t},\n\t\t\tset beforeRequest(_) {\n\t\t\t\t// The empty setter prevents runtime errors when attempts are made to assign a value to 'beforeRequest'.\n\t\t\t\t// JavaScript objects default to having both getters and setters\n\t\t\t}\n\t\t}\n\t};\n\n\treturn {\n\t\tdefault: ({\n\t\t\tprojectId,\n\t\t\tflowId,\n\t\t\tbaseUrl,\n\t\t\tinnerRef,\n\t\t\ttenant,\n\t\t\ttheme,\n\t\t\tlocale,\n\t\t\tdebug,\n\t\t\tredirectUrl,\n\t\t\tclient,\n\t\t\tform,\n\t\t\tautoFocus\n\t\t}) => (\n\t\t\t<descope-wc\n\t\t\t\tproject-id={projectId}\n\t\t\t\tflow-id={flowId}\n\t\t\t\tbase-url={baseUrl}\n\t\t\t\tref={innerRef}\n\t\t\t\ttenant={tenant}\n\t\t\t\ttheme={theme}\n\t\t\t\tlocale={locale}\n\t\t\t\tdebug={debug}\n\t\t\t\tclient={client}\n\t\t\t\tform={form}\n\t\t\t\tredirect-url={redirectUrl}\n\t\t\t\tauto-focus={autoFocus}\n\t\t\t/>\n\t\t)\n\t};\n});\n\nconst Descope = React.forwardRef<HTMLElement, DescopeProps>(\n\t(\n\t\t{\n\t\t\tflowId,\n\t\t\tonSuccess,\n\t\t\tonError,\n\t\t\tonReady,\n\t\t\tlogger,\n\t\t\ttenant,\n\t\t\ttheme,\n\t\t\tlocale,\n\t\t\tdebug,\n\t\t\tclient,\n\t\t\tform,\n\t\t\ttelemetryKey,\n\t\t\tredirectUrl,\n\t\t\tautoFocus,\n\t\t\terrorTransformer\n\t\t},\n\t\tref\n\t) => {\n\t\tconst [innerRef, setInnerRef] = useState(null);\n\n\t\tuseImperativeHandle(ref, () => innerRef);\n\n\t\tconst { projectId, baseUrl, sdk } = React.useContext(Context);\n\n\t\tconst handleSuccess = useCallback(\n\t\t\tasync (e: CustomEvent) => {\n\t\t\t\t// In order to make sure all the after-hooks are running with the success response\n\t\t\t\t// we are generating a fake response with the success data and calling the http client after hook fn with it\n\t\t\t\tawait sdk.httpClient.hooks.afterRequest(\n\t\t\t\t\t{} as any,\n\t\t\t\t\tnew Response(JSON.stringify(e.detail))\n\t\t\t\t);\n\t\t\t\tif (onSuccess) {\n\t\t\t\t\tonSuccess(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[onSuccess]\n\t\t);\n\n\t\tuseEffect(() => {\n\t\t\tconst ele = innerRef;\n\t\t\tele?.addEventListener('success', handleSuccess);\n\t\t\tif (onError) ele?.addEventListener('error', onError);\n\t\t\tif (onReady) ele?.addEventListener('ready', onReady);\n\n\t\t\treturn () => {\n\t\t\t\tif (onError) ele?.removeEventListener('error', onError);\n\t\t\t\tif (onReady) ele?.removeEventListener('ready', onReady);\n\n\t\t\t\tele?.removeEventListener('success', handleSuccess);\n\t\t\t};\n\t\t}, [innerRef, onError, handleSuccess]);\n\n\t\t// Success event\n\t\tuseEffect(() => {\n\t\t\tconst ele = innerRef;\n\t\t\tele?.addEventListener('success', handleSuccess);\n\t\t\treturn () => {\n\t\t\t\tele?.removeEventListener('success', handleSuccess);\n\t\t\t};\n\t\t}, [innerRef, handleSuccess]);\n\n\t\t// Error event\n\t\tuseEffect(() => {\n\t\t\tconst ele = innerRef;\n\t\t\tif (onError) ele?.addEventListener('error', onError);\n\n\t\t\treturn () => {\n\t\t\t\tif (onError) ele?.removeEventListener('error', onError);\n\t\t\t};\n\t\t}, [innerRef, onError]);\n\n\t\t// Ready event\n\t\tuseEffect(() => {\n\t\t\tconst ele = innerRef;\n\t\t\tif (onReady) ele?.addEventListener('ready', onReady);\n\n\t\t\treturn () => {\n\t\t\t\tif (onReady) ele?.removeEventListener('error', onReady);\n\t\t\t};\n\t\t}, [innerRef, onReady]);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef) {\n\t\t\t\tinnerRef.errorTransformer = errorTransformer;\n\t\t\t}\n\t\t}, [innerRef, errorTransformer]);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef && logger) {\n\t\t\t\tinnerRef.logger = logger;\n\t\t\t}\n\t\t}, [innerRef, logger]);\n\n\t\tconst { form: stringifiedForm, client: stringifiedClient } = useMemo(\n\t\t\t() => ({\n\t\t\t\tform: JSON.stringify(form || {}),\n\t\t\t\tclient: JSON.stringify(client || {})\n\t\t\t}),\n\t\t\t[form, client]\n\t\t);\n\n\t\treturn (\n\t\t\t/**\n\t\t\t * in order to avoid redundant remounting of the WC, we are wrapping it with a form element\n\t\t\t * this workaround is done in order to support webauthn passkeys\n\t\t\t * it can be removed once this issue will be solved\n\t\t\t * https://bugs.chromium.org/p/chromium/issues/detail?id=1404106#c2\n\t\t\t */\n\t\t\t<form>\n\t\t\t\t<Suspense fallback={null}>\n\t\t\t\t\t<DescopeWC\n\t\t\t\t\t\tprojectId={projectId}\n\t\t\t\t\t\tflowId={flowId}\n\t\t\t\t\t\tbaseUrl={baseUrl}\n\t\t\t\t\t\tinnerRef={setInnerRef}\n\t\t\t\t\t\ttenant={tenant}\n\t\t\t\t\t\ttheme={theme}\n\t\t\t\t\t\tlocale={locale}\n\t\t\t\t\t\tdebug={debug}\n\t\t\t\t\t\tform={stringifiedForm}\n\t\t\t\t\t\tclient={stringifiedClient}\n\t\t\t\t\t\ttelemetryKey={telemetryKey}\n\t\t\t\t\t\tredirectUrl={redirectUrl}\n\t\t\t\t\t\tautoFocus={autoFocus}\n\t\t\t\t\t/>\n\t\t\t\t</Suspense>\n\t\t\t</form>\n\t\t);\n\t}\n);\n\nexport default Descope;\n","import React, {\n\tlazy,\n\tSuspense,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseState\n} from 'react';\nimport Context from '../hooks/Context';\nimport { UserManagementProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst UserManagementWC = lazy(async () => {\n\tawait import('@descope/user-management-widget');\n\n\treturn {\n\t\tdefault: ({\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tinnerRef,\n\t\t\ttenant,\n\t\t\twidgetId,\n\t\t\ttheme,\n\t\t\tdebug\n\t\t}) => (\n\t\t\t<descope-user-management-widget\n\t\t\t\tproject-id={projectId}\n\t\t\t\twidget-id={widgetId}\n\t\t\t\tbase-url={baseUrl}\n\t\t\t\ttheme={theme}\n\t\t\t\ttenant={tenant}\n\t\t\t\tdebug={debug}\n\t\t\t\tref={innerRef}\n\t\t\t/>\n\t\t)\n\t};\n});\n\nconst UserManagement = React.forwardRef<HTMLElement, UserManagementProps>(\n\t({ logger, tenant, theme, debug, widgetId }, ref) => {\n\t\tconst [innerRef, setInnerRef] = useState(null);\n\n\t\tuseImperativeHandle(ref, () => innerRef);\n\n\t\tconst { projectId, baseUrl } = React.useContext(Context);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef && logger) {\n\t\t\t\tinnerRef.logger = logger;\n\t\t\t}\n\t\t}, [innerRef, logger]);\n\n\t\treturn (\n\t\t\t<Suspense fallback={null}>\n\t\t\t\t<UserManagementWC\n\t\t\t\t\tprojectId={projectId}\n\t\t\t\t\twidgetId={widgetId}\n\t\t\t\t\tbaseUrl={baseUrl}\n\t\t\t\t\tinnerRef={setInnerRef}\n\t\t\t\t\ttenant={tenant}\n\t\t\t\t\ttheme={theme}\n\t\t\t\t\tdebug={debug}\n\t\t\t\t/>\n\t\t\t</Suspense>\n\t\t);\n\t}\n);\n\nexport default UserManagement;\n","import React, {\n\tlazy,\n\tSuspense,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseState\n} from 'react';\nimport Context from '../hooks/Context';\nimport { RoleManagementProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst RoleManagementWC = lazy(async () => {\n\tawait import('@descope/role-management-widget');\n\n\treturn {\n\t\tdefault: ({\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tinnerRef,\n\t\t\ttenant,\n\t\t\twidgetId,\n\t\t\ttheme,\n\t\t\tdebug\n\t\t}) => (\n\t\t\t<descope-role-management-widget\n\t\t\t\tproject-id={projectId}\n\t\t\t\twidget-id={widgetId}\n\t\t\t\tbase-url={baseUrl}\n\t\t\t\ttheme={theme}\n\t\t\t\ttenant={tenant}\n\t\t\t\tdebug={debug}\n\t\t\t\tref={innerRef}\n\t\t\t/>\n\t\t)\n\t};\n});\n\nconst RoleManagement = React.forwardRef<HTMLElement, RoleManagementProps>(\n\t({ logger, tenant, theme, debug, widgetId }, ref) => {\n\t\tconst [innerRef, setInnerRef] = useState(null);\n\n\t\tuseImperativeHandle(ref, () => innerRef);\n\n\t\tconst { projectId, baseUrl } = React.useContext(Context);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef && logger) {\n\t\t\t\tinnerRef.logger = logger;\n\t\t\t}\n\t\t}, [innerRef, logger]);\n\n\t\treturn (\n\t\t\t<Suspense fallback={null}>\n\t\t\t\t<RoleManagementWC\n\t\t\t\t\tprojectId={projectId}\n\t\t\t\t\twidgetId={widgetId}\n\t\t\t\t\tbaseUrl={baseUrl}\n\t\t\t\t\tinnerRef={setInnerRef}\n\t\t\t\t\ttenant={tenant}\n\t\t\t\t\ttheme={theme}\n\t\t\t\t\tdebug={debug}\n\t\t\t\t/>\n\t\t\t</Suspense>\n\t\t);\n\t}\n);\n\nexport default RoleManagement;\n","import React, {\n\tlazy,\n\tSuspense,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseState\n} from 'react';\nimport Context from '../hooks/Context';\nimport { AccessKeyManagementProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst AccessKeyManagementWC = lazy(async () => {\n\tawait import('@descope/access-key-management-widget');\n\n\treturn {\n\t\tdefault: ({\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tinnerRef,\n\t\t\ttenant,\n\t\t\twidgetId,\n\t\t\ttheme,\n\t\t\tdebug\n\t\t}) => (\n\t\t\t<descope-access-key-management-widget\n\t\t\t\tproject-id={projectId}\n\t\t\t\twidget-id={widgetId}\n\t\t\t\tbase-url={baseUrl}\n\t\t\t\ttheme={theme}\n\t\t\t\ttenant={tenant}\n\t\t\t\tdebug={debug}\n\t\t\t\tref={innerRef}\n\t\t\t/>\n\t\t)\n\t};\n});\n\nconst AccessKeyManagement = React.forwardRef<\n\tHTMLElement,\n\tAccessKeyManagementProps\n>(({ logger, tenant, theme, debug, widgetId }, ref) => {\n\tconst [innerRef, setInnerRef] = useState(null);\n\n\tuseImperativeHandle(ref, () => innerRef);\n\n\tconst { projectId, baseUrl } = React.useContext(Context);\n\n\tuseEffect(() => {\n\t\tif (innerRef && logger) {\n\t\t\tinnerRef.logger = logger;\n\t\t}\n\t}, [innerRef, logger]);\n\n\treturn (\n\t\t<Suspense fallback={null}>\n\t\t\t<AccessKeyManagementWC\n\t\t\t\tprojectId={projectId}\n\t\t\t\twidgetId={widgetId}\n\t\t\t\tbaseUrl={baseUrl}\n\t\t\t\tinnerRef={setInnerRef}\n\t\t\t\ttenant={tenant}\n\t\t\t\ttheme={theme}\n\t\t\t\tdebug={debug}\n\t\t\t/>\n\t\t</Suspense>\n\t);\n});\n\nexport default AccessKeyManagement;\n","import { useContext } from 'react';\nimport Context from './Context';\n\nexport default () => {\n\tconst ctx = useContext(Context);\n\tif (!ctx) {\n\t\tthrow Error(\n\t\t\t`You can only use this hook in the context of <AuthProvider />`\n\t\t);\n\t}\n\n\treturn ctx;\n};\n","import { useMemo } from 'react';\nimport { Sdk } from '../types';\nimport useContext from './useContext';\nimport createSdk from '../sdk';\n\nconst generateErrorMsg = (entryType: string) =>\n\t`You can only use this ${entryType} after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`;\n\n// handler which throw an error for every SDK function\nconst proxyThrowHandler = {\n\t// eslint-disable-next-line prefer-arrow/prefer-arrow-functions\n\tget(target: Record<string, any>, key: string) {\n\t\tif (typeof target[key] === 'object' && target[key] !== null) {\n\t\t\treturn new Proxy(target[key], proxyThrowHandler);\n\t\t}\n\n\t\tif (typeof target[key] === 'function') {\n\t\t\treturn () => {\n\t\t\t\tthrow Error(generateErrorMsg('function'));\n\t\t\t};\n\t\t}\n\n\t\tthrow Error(generateErrorMsg('attribute'));\n\t}\n};\n\nconst useDescope = (): Sdk => {\n\tconst { sdk } = useContext();\n\n\treturn useMemo(() => {\n\t\tif (!sdk) {\n\t\t\t// In case the SDK is not initialized, we want to throw an error when the SDK functions are called\n\t\t\treturn new Proxy(\n\t\t\t\tcreateSdk({ projectId: 'dummy' }),\n\t\t\t\tproxyThrowHandler\n\t\t\t) as Sdk;\n\t\t}\n\n\t\treturn sdk;\n\t}, [sdk]);\n};\n\nexport default useDescope;\n","import { useMemo } from 'react';\nimport { baseHeaders } from '../../constants';\nimport createSdk from '../../sdk';\n\ntype Config = Pick<\n\tParameters<typeof createSdk>[0],\n\t'projectId' | 'baseUrl' | 'sessionTokenViaCookie'\n>;\n\nexport default ({\n\tprojectId,\n\tbaseUrl,\n\tsessionTokenViaCookie\n}: Config): ReturnType<typeof createSdk> =>\n\tuseMemo(() => {\n\t\tif (!projectId) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn createSdk({\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tsessionTokenViaCookie,\n\t\t\tbaseHeaders,\n\t\t\tpersistToken: true,\n\t\t\tautoRefresh: true\n\t\t});\n\t}, [projectId, baseUrl, sessionTokenViaCookie]);\n","import React from 'react';\nimport { DefaultFlowProps } from '../types';\nimport Descope from './Descope';\n\nexport const SignInFlow = (props: DefaultFlowProps) => (\n\t<Descope {...props} flowId=\"sign-in\" />\n);\n\nexport const SignUpFlow = (props: DefaultFlowProps) => (\n\t<Descope {...props} flowId=\"sign-up\" />\n);\n\nexport const SignUpOrInFlow = (props: DefaultFlowProps) => (\n\t<Descope {...props} flowId=\"sign-up-or-in\" />\n);\n","import { useEffect, useMemo, useRef } from 'react';\nimport useContext from './useContext';\n\nconst useSession = () => {\n\tconst { session, isSessionLoading, fetchSession, isSessionFetched } =\n\t\tuseContext();\n\n\t// when session should be received, we want the return value of \"isSessionLoading\" to be true starting from the first call\n\t// (and not only when receiving an update from the context)\n\tconst isLoading = useRef(isSessionLoading);\n\n\t// we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n\tuseMemo(() => {\n\t\tisLoading.current = isSessionLoading;\n\t}, [isSessionLoading]);\n\n\tconst shouldFetchSession = !session && !isSessionLoading;\n\n\t// we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n\tuseMemo(() => {\n\t\tif (shouldFetchSession && !isSessionFetched) {\n\t\t\tisLoading.current = true;\n\t\t}\n\t}, [isSessionFetched]);\n\n\t// Fetch session if it's not already fetched\n\t// We want this to happen only once, so the dependency array should not contain shouldFetchSession\n\tuseEffect(() => {\n\t\tif (shouldFetchSession) {\n\t\t\tfetchSession();\n\t\t}\n\t}, [fetchSession]);\n\treturn {\n\t\tisSessionLoading: isLoading.current,\n\t\tsessionToken: session,\n\t\tisAuthenticated: !!session\n\t};\n};\n\nexport default useSession;\n","import { useEffect, useMemo, useRef, useState } from 'react';\nimport useContext from './useContext';\n\nconst useUser = () => {\n\tconst { user, fetchUser, isUserLoading, session } = useContext();\n\tconst [isInit, setIsInit] = useState(false); // we want to get the user only in the first time we got a session\n\n\t// when session should be received, we want the return value of \"isUserLoading\" to be true starting from the first call\n\t// (and not only when receiving an update from the context)\n\tconst isLoading = useRef(isUserLoading);\n\n\tconst shouldFetchUser = useMemo(\n\t\t() => !user && !isUserLoading && session && !isInit,\n\t\t[fetchUser, session, isInit]\n\t);\n\n\t// we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n\tuseMemo(() => {\n\t\tisLoading.current = isUserLoading;\n\t}, [isUserLoading]);\n\n\t// we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n\tuseMemo(() => {\n\t\tif (shouldFetchUser) {\n\t\t\tisLoading.current = true;\n\t\t}\n\t}, [shouldFetchUser]);\n\n\tuseEffect(() => {\n\t\tif (shouldFetchUser) {\n\t\t\tsetIsInit(true);\n\t\t\tfetchUser();\n\t\t}\n\t}, [shouldFetchUser]);\n\n\treturn { isUserLoading: isLoading.current, user };\n};\n\nexport default useUser;\n"],"names":["Context","React","createContext","undefined","withValidation","fn","args","Error","wrapInTry","res","err","console","error","baseHeaders","IS_BROWSER","window","globalSdk","createSdkWrapper","config","sdk","createSdk","Object","assign","persistTokens","autoRefresh","projectId","getSessionToken","warn","getRefreshToken","getJwtPermissions","token","tenant","getJwtRoles","DescopeWC","lazy","async","Promise","resolve","then","_interopNamespace","require","default","sdkConfigOverrides","hooks","beforeRequest","httpClient","_","flowId","baseUrl","innerRef","theme","locale","debug","redirectUrl","client","form","autoFocus","createElement","ref","Descope","forwardRef","onSuccess","onError","onReady","logger","telemetryKey","errorTransformer","setInnerRef","useState","useImperativeHandle","useContext","handleSuccess","useCallback","e","afterRequest","Response","JSON","stringify","detail","useEffect","ele","addEventListener","removeEventListener","stringifiedForm","stringifiedClient","useMemo","Suspense","fallback","UserManagementWC","widgetId","UserManagement","RoleManagementWC","RoleManagement","AccessKeyManagementWC","AccessKeyManagement","ctx","generateErrorMsg","entryType","proxyThrowHandler","get","target","key","Proxy","sessionTokenViaCookie","children","user","setUser","session","setSession","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","persistToken","useSdk","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","isSessionFetched","useRef","fetchSession","current","refresh","fetchUser","me","value","Provider","props","isLoading","shouldFetchSession","sessionToken","isAuthenticated","isInit","setIsInit","shouldFetchUser"],"mappings":"qfAGA,MAAMA,EAAUC,EAAAA,QAAMC,mBAAwBC,GCEjCC,EACcC,GAC1B,IAAIC,KACH,IAAKD,EACJ,MAAME,MACL,0HAGF,OAAOF,KAAMC,EAAK,EAGPE,EACcH,GAC1B,IAAIC,KACH,IAAIG,EACJ,IACCA,EAAMJ,KAAMC,EAGZ,CAFC,MAAOI,GACRC,QAAQC,MAAMF,EACd,CACD,OAAOD,CAAG,ECvBCI,EAAc,CAC1B,qBAAsB,QACtB,wBAAyB,UAIbC,EAA+B,oBAAXC,OCHjC,IAAIC,EAEJ,MAAMC,EACLC,IAEA,MAAMC,EAAMC,EA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AEhB,OAAOe,EAAOA,SAAC,IACTlE,GAEG,IAAImF,MACVlF,EAAU,CAAEK,UAAW,UACvByE,IAKA,CAAC/E,GAAK,qBGpCS,KAClB,MAAMwF,QAAEA,EAAOI,iBAAEA,EAAgBU,aAAEA,EAAYF,iBAAEA,GAChDjD,IAIK2D,EAAYT,SAAOT,GAGzB1B,EAAAA,SAAQ,KACP4C,EAAUP,QAAUX,CAAgB,GAClC,CAACA,IAEJ,MAAMmB,GAAsBvB,IAAYI,EAgBxC,OAbA1B,EAAAA,SAAQ,KACH6C,IAAuBX,IAC1BU,EAAUP,SAAU,EACpB,GACC,CAACH,IAIJxC,EAAAA,WAAU,KACLmD,GACHT,GACA,GACC,CAACA,IACG,CACNV,iBAAkBkB,EAAUP,QAC5BS,aAAcxB,EACdyB,kBAAmBzB,EACnB,kBCjCc,KACf,MAAMF,KAAEA,EAAImB,UAAEA,EAASf,cAAEA,EAAaF,QAAEA,GAAYrC,KAC7C+D,EAAQC,GAAalE,EAAQA,UAAC,GAI/B6D,EAAYT,SAAOX,GAEnB0B,EAAkBlD,EAAOA,SAC9B,KAAOoB,IAASI,GAAiBF,IAAY0B,GAC7C,CAACT,EAAWjB,EAAS0B,IAsBtB,OAlBAhD,EAAAA,SAAQ,KACP4C,EAAUP,QAAUb,CAAa,GAC/B,CAACA,IAGJxB,EAAAA,SAAQ,KACHkD,IACHN,EAAUP,SAAU,EACpB,GACC,CAACa,IAEJxD,EAAAA,WAAU,KACLwD,IACHD,GAAU,GACVV,IACA,GACC,CAACW,IAEG,CAAE1B,cAAeoB,EAAUP,QAASjB,OAAM"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../src/hooks/Context.ts","../../src/utils.ts","../../src/constants.ts","../../src/sdk.ts","../../src/components/AuthProvider/AuthProvider.tsx","../../src/components/Descope.tsx","../../src/components/UserManagement.tsx","../../src/components/RoleManagement.tsx","../../src/components/AccessKeyManagement.tsx","../../src/hooks/useContext.ts","../../src/hooks/useDescope.ts","../../src/components/AuthProvider/useSdk.ts","../../src/components/DefaultFlows.tsx","../../src/hooks/useSession.ts","../../src/hooks/useUser.ts"],"sourcesContent":["import React from 'react';\nimport { IContext } from '../types';\n\nconst Context = React.createContext<IContext>(undefined);\n\nexport default Context;\n","/**\n * Wrap a function with a validation that it exists\n * @param fn The function to wrap with the validation\n * @throws if function does not exist, an error with the relevant message will be thrown\n */\nexport const withValidation =\n\t<T extends Array<any>, U>(fn: (...args: T) => U) =>\n\t(...args: T): U => {\n\t\tif (!fn) {\n\t\t\tthrow Error(\n\t\t\t\t`You can only use this function after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`\n\t\t\t);\n\t\t}\n\t\treturn fn(...args);\n\t};\n\nexport const wrapInTry =\n\t<T extends Array<any>, U>(fn: (...args: T) => U) =>\n\t(...args: T): U => {\n\t\tlet res: U;\n\t\ttry {\n\t\t\tres = fn(...args);\n\t\t} catch (err) {\n\t\t\tconsole.error(err); // eslint-disable-line no-console\n\t\t}\n\t\treturn res;\n\t};\n","declare const BUILD_VERSION: string;\n\nexport const baseHeaders = {\n\t'x-descope-sdk-name': 'react',\n\t'x-descope-sdk-version': BUILD_VERSION\n};\n\n// This sdk can be used in SSR apps\nexport const IS_BROWSER = typeof window !== 'undefined';\n","import createSdk from '@descope/web-js-sdk';\nimport { IS_BROWSER } from './constants';\nimport { wrapInTry } from './utils';\n\ntype Sdk = ReturnType<typeof createSdkWrapper>;\nlet globalSdk: Sdk;\n\nconst createSdkWrapper = <P extends Parameters<typeof createSdk>[0]>(\n\tconfig: P\n) => {\n\tconst sdk = createSdk({\n\t\tpersistTokens: IS_BROWSER as true,\n\t\tautoRefresh: IS_BROWSER as true,\n\t\t...config\n\t});\n\tglobalSdk = sdk;\n\n\treturn sdk;\n};\n\n// eslint-disable-next-line import/exports-last\nexport const createTempSdk = () =>\n\tcreateSdkWrapper({\n\t\tprojectId: 'temp pid',\n\t\tpersistTokens: false,\n\t\tautoRefresh: false,\n\t\tstoreLastAuthenticatedUser: false\n\t});\n\n/**\n * We want to make sure the getSessionToken fn is used only when persistTokens is on\n *\n * So we are keeping the SDK init in a single place,\n * and we are creating a temp instance in order to export the getSessionToken\n * even before the SDK was init\n */\nglobalSdk = createTempSdk();\n\nexport const getSessionToken = () => {\n\tif (IS_BROWSER) {\n\t\treturn globalSdk?.getSessionToken();\n\t}\n\n\t// eslint-disable-next-line no-console\n\tconsole.warn('Get session token is not supported in SSR');\n\treturn '';\n};\n\nexport const getRefreshToken = () => {\n\tif (IS_BROWSER) {\n\t\treturn globalSdk?.getRefreshToken();\n\t}\n\t// eslint-disable-next-line no-console\n\tconsole.warn('Get refresh token is not supported in SSR');\n\treturn '';\n};\n\nexport const isSessionTokenExpired = (token = getSessionToken()) =>\n\tglobalSdk?.isJwtExpired(token);\n\nexport const isRefreshTokenExpired = (token = getRefreshToken()) =>\n\tglobalSdk?.isJwtExpired(token);\n\nexport const getJwtPermissions = wrapInTry(\n\t(token = getSessionToken(), tenant?: string) =>\n\t\tglobalSdk?.getJwtPermissions(token, tenant)\n);\n\nexport const getJwtRoles = wrapInTry(\n\t(token = getSessionToken(), tenant?: string) =>\n\t\tglobalSdk?.getJwtRoles(token, tenant)\n);\n\nexport const refresh = (token = getRefreshToken()) => globalSdk?.refresh(token);\n\nexport const getGlobalSdk = () => globalSdk;\n\nexport default createSdkWrapper;\n","import React, {\n\tFC,\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState\n} from 'react';\nimport Context from '../../hooks/Context';\nimport { IContext, User } from '../../types';\nimport { withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ninterface IAuthProviderProps {\n\tprojectId: string;\n\tbaseUrl?: string;\n\t// If true, tokens will be stored on local storage and can accessed with getToken function\n\tpersistTokens?: boolean;\n\t// If true, session token (jwt) will be stored on cookie. Otherwise, the session token will be\n\t// stored on local storage and can accessed with getSessionToken function\n\t// Use this option if session token will stay small (less than 1k)\n\t// NOTE: Session token can grow, especially in cases of using authorization, or adding custom claims\n\tsessionTokenViaCookie?: boolean;\n\t// If true, last authenticated user will be stored on local storage and can accessed with getUser function\n\tstoreLastAuthenticatedUser?: boolean;\n\tchildren?: JSX.Element;\n}\n\nconst AuthProvider: FC<IAuthProviderProps> = ({\n\tprojectId,\n\tbaseUrl = '',\n\tsessionTokenViaCookie = false,\n\tpersistTokens = true,\n\tstoreLastAuthenticatedUser = true,\n\tchildren = undefined\n}) => {\n\tconst [user, setUser] = useState<User>();\n\tconst [session, setSession] = useState<string>();\n\n\tconst [isUserLoading, setIsUserLoading] = useState(false);\n\tconst [isSessionLoading, setIsSessionLoading] = useState(false);\n\n\tconst sdk = useSdk({\n\t\tprojectId,\n\t\tbaseUrl,\n\t\tpersistTokens,\n\t\tsessionTokenViaCookie,\n\t\tstoreLastAuthenticatedUser\n\t});\n\n\tuseEffect(() => {\n\t\tif (sdk) {\n\t\t\tconst unsubscribeSessionToken = sdk.onSessionTokenChange(setSession);\n\t\t\tconst unsubscribeUser = sdk.onUserChange(setUser);\n\n\t\t\treturn () => {\n\t\t\t\tunsubscribeSessionToken();\n\t\t\t\tunsubscribeUser();\n\t\t\t};\n\t\t}\n\t\treturn undefined;\n\t}, [sdk]);\n\n\tconst isSessionFetched = useRef(false);\n\n\tconst fetchSession = useCallback(() => {\n\t\t// We want that the session will fetched only once\n\t\tif (isSessionFetched.current) return;\n\t\tisSessionFetched.current = true;\n\n\t\tsetIsSessionLoading(true);\n\t\twithValidation(sdk?.refresh)().then(() => {\n\t\t\tsetIsSessionLoading(false);\n\t\t});\n\t}, [sdk]);\n\n\tconst fetchUser = useCallback(() => {\n\t\tsetIsUserLoading(true);\n\t\twithValidation(sdk.me)().then(() => {\n\t\t\tsetIsUserLoading(false);\n\t\t});\n\t}, [sdk]);\n\n\tconst value = useMemo<IContext>(\n\t\t() => ({\n\t\t\tfetchUser,\n\t\t\tuser,\n\t\t\tisUserLoading,\n\t\t\tfetchSession,\n\t\t\tsession,\n\t\t\tisSessionLoading,\n\t\t\tisSessionFetched: isSessionFetched.current,\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tstoreLastAuthenticatedUser,\n\t\t\tsetUser,\n\t\t\tsetSession,\n\t\t\tsdk\n\t\t}),\n\t\t[\n\t\t\tfetchUser,\n\t\t\tuser,\n\t\t\tisUserLoading,\n\t\t\tfetchSession,\n\t\t\tsession,\n\t\t\tisSessionLoading,\n\t\t\tisSessionFetched.current,\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tsetUser,\n\t\t\tsetSession,\n\t\t\tsdk\n\t\t]\n\t);\n\treturn <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport default AuthProvider;\n","import React, {\n\tlazy,\n\tSuspense,\n\tuseCallback,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseMemo,\n\tuseState\n} from 'react';\nimport { baseHeaders } from '../constants';\nimport Context from '../hooks/Context';\nimport { DescopeProps } from '../types';\nimport { getGlobalSdk } from '../sdk';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst DescopeWC = lazy(async () => {\n\tconst module = await import('@descope/web-component');\n\tmodule.default.sdkConfigOverrides = {\n\t\t// Overrides the web-component's base headers to indicate usage via the React SDK\n\t\tbaseHeaders,\n\t\t// Disables token persistence within the web-component to delegate token management\n\t\t// to the global SDK hooks. This ensures token handling aligns with the SDK's configuration,\n\t\t// and web-component requests leverage the global SDK's beforeRequest hooks for consistency\n\t\tpersistTokens: false,\n\t\thooks: {\n\t\t\tget beforeRequest() {\n\t\t\t\t// Retrieves the beforeRequest hook from the global SDK, which is initialized\n\t\t\t\t// within the AuthProvider using the desired configuration. This approach ensures\n\t\t\t\t// the web-component utilizes the same beforeRequest hooks as the global SDK\n\t\t\t\treturn getGlobalSdk().httpClient.hooks.beforeRequest;\n\t\t\t},\n\t\t\tset beforeRequest(_) {\n\t\t\t\t// The empty setter prevents runtime errors when attempts are made to assign a value to 'beforeRequest'.\n\t\t\t\t// JavaScript objects default to having both getters and setters\n\t\t\t}\n\t\t}\n\t};\n\n\treturn {\n\t\tdefault: ({\n\t\t\tprojectId,\n\t\t\tflowId,\n\t\t\tbaseUrl,\n\t\t\tinnerRef,\n\t\t\ttenant,\n\t\t\ttheme,\n\t\t\tlocale,\n\t\t\tdebug,\n\t\t\tredirectUrl,\n\t\t\tclient,\n\t\t\tform,\n\t\t\tautoFocus\n\t\t}) => (\n\t\t\t<descope-wc\n\t\t\t\tproject-id={projectId}\n\t\t\t\tflow-id={flowId}\n\t\t\t\tbase-url={baseUrl}\n\t\t\t\tref={innerRef}\n\t\t\t\ttenant={tenant}\n\t\t\t\ttheme={theme}\n\t\t\t\tlocale={locale}\n\t\t\t\tdebug={debug}\n\t\t\t\tclient={client}\n\t\t\t\tform={form}\n\t\t\t\tredirect-url={redirectUrl}\n\t\t\t\tauto-focus={autoFocus}\n\t\t\t/>\n\t\t)\n\t};\n});\n\nconst Descope = React.forwardRef<HTMLElement, DescopeProps>(\n\t(\n\t\t{\n\t\t\tflowId,\n\t\t\tonSuccess,\n\t\t\tonError,\n\t\t\tonReady,\n\t\t\tlogger,\n\t\t\ttenant,\n\t\t\ttheme,\n\t\t\tlocale,\n\t\t\tdebug,\n\t\t\tclient,\n\t\t\tform,\n\t\t\ttelemetryKey,\n\t\t\tredirectUrl,\n\t\t\tautoFocus,\n\t\t\terrorTransformer\n\t\t},\n\t\tref\n\t) => {\n\t\tconst [innerRef, setInnerRef] = useState(null);\n\n\t\tuseImperativeHandle(ref, () => innerRef);\n\n\t\tconst { projectId, baseUrl, storeLastAuthenticatedUser, sdk } =\n\t\t\tReact.useContext(Context);\n\n\t\tconst handleSuccess = useCallback(\n\t\t\tasync (e: CustomEvent) => {\n\t\t\t\t// In order to make sure all the after-hooks are running with the success response\n\t\t\t\t// we are generating a fake response with the success data and calling the http client after hook fn with it\n\t\t\t\tawait sdk.httpClient.hooks.afterRequest(\n\t\t\t\t\t{} as any,\n\t\t\t\t\tnew Response(JSON.stringify(e.detail))\n\t\t\t\t);\n\t\t\t\tif (onSuccess) {\n\t\t\t\t\tonSuccess(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[onSuccess]\n\t\t);\n\n\t\tuseEffect(() => {\n\t\t\tconst ele = innerRef;\n\t\t\tele?.addEventListener('success', handleSuccess);\n\t\t\tif (onError) ele?.addEventListener('error', onError);\n\t\t\tif (onReady) ele?.addEventListener('ready', onReady);\n\n\t\t\treturn () => {\n\t\t\t\tif (onError) ele?.removeEventListener('error', onError);\n\t\t\t\tif (onReady) ele?.removeEventListener('ready', onReady);\n\n\t\t\t\tele?.removeEventListener('success', handleSuccess);\n\t\t\t};\n\t\t}, [innerRef, onError, handleSuccess]);\n\n\t\t// Success event\n\t\tuseEffect(() => {\n\t\t\tconst ele = innerRef;\n\t\t\tele?.addEventListener('success', handleSuccess);\n\t\t\treturn () => {\n\t\t\t\tele?.removeEventListener('success', handleSuccess);\n\t\t\t};\n\t\t}, [innerRef, handleSuccess]);\n\n\t\t// Error event\n\t\tuseEffect(() => {\n\t\t\tconst ele = innerRef;\n\t\t\tif (onError) ele?.addEventListener('error', onError);\n\n\t\t\treturn () => {\n\t\t\t\tif (onError) ele?.removeEventListener('error', onError);\n\t\t\t};\n\t\t}, [innerRef, onError]);\n\n\t\t// Ready event\n\t\tuseEffect(() => {\n\t\t\tconst ele = innerRef;\n\t\t\tif (onReady) ele?.addEventListener('ready', onReady);\n\n\t\t\treturn () => {\n\t\t\t\tif (onReady) ele?.removeEventListener('error', onReady);\n\t\t\t};\n\t\t}, [innerRef, onReady]);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef) {\n\t\t\t\tinnerRef.errorTransformer = errorTransformer;\n\t\t\t}\n\t\t}, [innerRef, errorTransformer]);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef && logger) {\n\t\t\t\tinnerRef.logger = logger;\n\t\t\t}\n\t\t}, [innerRef, logger]);\n\n\t\tconst { form: stringifiedForm, client: stringifiedClient } = useMemo(\n\t\t\t() => ({\n\t\t\t\tform: JSON.stringify(form || {}),\n\t\t\t\tclient: JSON.stringify(client || {})\n\t\t\t}),\n\t\t\t[form, client]\n\t\t);\n\n\t\treturn (\n\t\t\t/**\n\t\t\t * in order to avoid redundant remounting of the WC, we are wrapping it with a form element\n\t\t\t * this workaround is done in order to support webauthn passkeys\n\t\t\t * it can be removed once this issue will be solved\n\t\t\t * https://bugs.chromium.org/p/chromium/issues/detail?id=1404106#c2\n\t\t\t */\n\t\t\t<form>\n\t\t\t\t<Suspense fallback={null}>\n\t\t\t\t\t<DescopeWC\n\t\t\t\t\t\tprojectId={projectId}\n\t\t\t\t\t\tflowId={flowId}\n\t\t\t\t\t\tbaseUrl={baseUrl}\n\t\t\t\t\t\tinnerRef={setInnerRef}\n\t\t\t\t\t\ttenant={tenant}\n\t\t\t\t\t\ttheme={theme}\n\t\t\t\t\t\tlocale={locale}\n\t\t\t\t\t\tdebug={debug}\n\t\t\t\t\t\tform={stringifiedForm}\n\t\t\t\t\t\tclient={stringifiedClient}\n\t\t\t\t\t\ttelemetryKey={telemetryKey}\n\t\t\t\t\t\tredirectUrl={redirectUrl}\n\t\t\t\t\t\tautoFocus={autoFocus}\n\t\t\t\t\t\tstoreLastAuthenticatedUser={storeLastAuthenticatedUser}\n\t\t\t\t\t/>\n\t\t\t\t</Suspense>\n\t\t\t</form>\n\t\t);\n\t}\n);\n\nexport default Descope;\n","import React, {\n\tlazy,\n\tSuspense,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseState\n} from 'react';\nimport Context from '../hooks/Context';\nimport { UserManagementProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst UserManagementWC = lazy(async () => {\n\tawait import('@descope/user-management-widget');\n\n\treturn {\n\t\tdefault: ({\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tinnerRef,\n\t\t\ttenant,\n\t\t\twidgetId,\n\t\t\ttheme,\n\t\t\tdebug\n\t\t}) => (\n\t\t\t<descope-user-management-widget\n\t\t\t\tproject-id={projectId}\n\t\t\t\twidget-id={widgetId}\n\t\t\t\tbase-url={baseUrl}\n\t\t\t\ttheme={theme}\n\t\t\t\ttenant={tenant}\n\t\t\t\tdebug={debug}\n\t\t\t\tref={innerRef}\n\t\t\t/>\n\t\t)\n\t};\n});\n\nconst UserManagement = React.forwardRef<HTMLElement, UserManagementProps>(\n\t({ logger, tenant, theme, debug, widgetId }, ref) => {\n\t\tconst [innerRef, setInnerRef] = useState(null);\n\n\t\tuseImperativeHandle(ref, () => innerRef);\n\n\t\tconst { projectId, baseUrl } = React.useContext(Context);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef && logger) {\n\t\t\t\tinnerRef.logger = logger;\n\t\t\t}\n\t\t}, [innerRef, logger]);\n\n\t\treturn (\n\t\t\t<Suspense fallback={null}>\n\t\t\t\t<UserManagementWC\n\t\t\t\t\tprojectId={projectId}\n\t\t\t\t\twidgetId={widgetId}\n\t\t\t\t\tbaseUrl={baseUrl}\n\t\t\t\t\tinnerRef={setInnerRef}\n\t\t\t\t\ttenant={tenant}\n\t\t\t\t\ttheme={theme}\n\t\t\t\t\tdebug={debug}\n\t\t\t\t/>\n\t\t\t</Suspense>\n\t\t);\n\t}\n);\n\nexport default UserManagement;\n","import React, {\n\tlazy,\n\tSuspense,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseState\n} from 'react';\nimport Context from '../hooks/Context';\nimport { RoleManagementProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst RoleManagementWC = lazy(async () => {\n\tawait import('@descope/role-management-widget');\n\n\treturn {\n\t\tdefault: ({\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tinnerRef,\n\t\t\ttenant,\n\t\t\twidgetId,\n\t\t\ttheme,\n\t\t\tdebug\n\t\t}) => (\n\t\t\t<descope-role-management-widget\n\t\t\t\tproject-id={projectId}\n\t\t\t\twidget-id={widgetId}\n\t\t\t\tbase-url={baseUrl}\n\t\t\t\ttheme={theme}\n\t\t\t\ttenant={tenant}\n\t\t\t\tdebug={debug}\n\t\t\t\tref={innerRef}\n\t\t\t/>\n\t\t)\n\t};\n});\n\nconst RoleManagement = React.forwardRef<HTMLElement, RoleManagementProps>(\n\t({ logger, tenant, theme, debug, widgetId }, ref) => {\n\t\tconst [innerRef, setInnerRef] = useState(null);\n\n\t\tuseImperativeHandle(ref, () => innerRef);\n\n\t\tconst { projectId, baseUrl } = React.useContext(Context);\n\n\t\tuseEffect(() => {\n\t\t\tif (innerRef && logger) {\n\t\t\t\tinnerRef.logger = logger;\n\t\t\t}\n\t\t}, [innerRef, logger]);\n\n\t\treturn (\n\t\t\t<Suspense fallback={null}>\n\t\t\t\t<RoleManagementWC\n\t\t\t\t\tprojectId={projectId}\n\t\t\t\t\twidgetId={widgetId}\n\t\t\t\t\tbaseUrl={baseUrl}\n\t\t\t\t\tinnerRef={setInnerRef}\n\t\t\t\t\ttenant={tenant}\n\t\t\t\t\ttheme={theme}\n\t\t\t\t\tdebug={debug}\n\t\t\t\t/>\n\t\t\t</Suspense>\n\t\t);\n\t}\n);\n\nexport default RoleManagement;\n","import React, {\n\tlazy,\n\tSuspense,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseState\n} from 'react';\nimport Context from '../hooks/Context';\nimport { AccessKeyManagementProps } from '../types';\n\n// web-component code uses browser API, but can be used in SSR apps, hence the lazy loading\nconst AccessKeyManagementWC = lazy(async () => {\n\tawait import('@descope/access-key-management-widget');\n\n\treturn {\n\t\tdefault: ({\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tinnerRef,\n\t\t\ttenant,\n\t\t\twidgetId,\n\t\t\ttheme,\n\t\t\tdebug\n\t\t}) => (\n\t\t\t<descope-access-key-management-widget\n\t\t\t\tproject-id={projectId}\n\t\t\t\twidget-id={widgetId}\n\t\t\t\tbase-url={baseUrl}\n\t\t\t\ttheme={theme}\n\t\t\t\ttenant={tenant}\n\t\t\t\tdebug={debug}\n\t\t\t\tref={innerRef}\n\t\t\t/>\n\t\t)\n\t};\n});\n\nconst AccessKeyManagement = React.forwardRef<\n\tHTMLElement,\n\tAccessKeyManagementProps\n>(({ logger, tenant, theme, debug, widgetId }, ref) => {\n\tconst [innerRef, setInnerRef] = useState(null);\n\n\tuseImperativeHandle(ref, () => innerRef);\n\n\tconst { projectId, baseUrl } = React.useContext(Context);\n\n\tuseEffect(() => {\n\t\tif (innerRef && logger) {\n\t\t\tinnerRef.logger = logger;\n\t\t}\n\t}, [innerRef, logger]);\n\n\treturn (\n\t\t<Suspense fallback={null}>\n\t\t\t<AccessKeyManagementWC\n\t\t\t\tprojectId={projectId}\n\t\t\t\twidgetId={widgetId}\n\t\t\t\tbaseUrl={baseUrl}\n\t\t\t\tinnerRef={setInnerRef}\n\t\t\t\ttenant={tenant}\n\t\t\t\ttheme={theme}\n\t\t\t\tdebug={debug}\n\t\t\t/>\n\t\t</Suspense>\n\t);\n});\n\nexport default AccessKeyManagement;\n","import { useContext } from 'react';\nimport Context from './Context';\n\nexport default () => {\n\tconst ctx = useContext(Context);\n\tif (!ctx) {\n\t\tthrow Error(\n\t\t\t`You can only use this hook in the context of <AuthProvider />`\n\t\t);\n\t}\n\n\treturn ctx;\n};\n","import { useMemo } from 'react';\nimport { Sdk } from '../types';\nimport useContext from './useContext';\nimport { createTempSdk } from '../sdk';\n\nconst generateErrorMsg = (entryType: string) =>\n\t`You can only use this ${entryType} after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`;\n\n// handler which throw an error for every SDK function\nconst proxyThrowHandler = {\n\t// eslint-disable-next-line prefer-arrow/prefer-arrow-functions\n\tget(target: Record<string, any>, key: string) {\n\t\tif (typeof target[key] === 'object' && target[key] !== null) {\n\t\t\treturn new Proxy(target[key], proxyThrowHandler);\n\t\t}\n\n\t\tif (typeof target[key] === 'function') {\n\t\t\treturn () => {\n\t\t\t\tthrow Error(generateErrorMsg('function'));\n\t\t\t};\n\t\t}\n\n\t\tthrow Error(generateErrorMsg('attribute'));\n\t}\n};\n\nconst useDescope = (): Sdk => {\n\tconst { sdk } = useContext();\n\n\treturn useMemo(() => {\n\t\tif (!sdk) {\n\t\t\t// In case the SDK is not initialized, we want to throw an error when the SDK functions are called\n\t\t\treturn new Proxy(createTempSdk(), proxyThrowHandler) as Sdk;\n\t\t}\n\n\t\treturn sdk;\n\t}, [sdk]);\n};\n\nexport default useDescope;\n","import { useMemo } from 'react';\nimport { baseHeaders } from '../../constants';\nimport createSdk from '../../sdk';\n\ntype Config = Pick<\n\tParameters<typeof createSdk>[0],\n\t| 'projectId'\n\t| 'baseUrl'\n\t| 'persistTokens'\n\t| 'sessionTokenViaCookie'\n\t| 'storeLastAuthenticatedUser'\n>;\n\nexport default ({\n\tprojectId,\n\tbaseUrl,\n\tpersistTokens,\n\tsessionTokenViaCookie,\n\tstoreLastAuthenticatedUser\n}: Config): ReturnType<typeof createSdk> =>\n\tuseMemo(() => {\n\t\tif (!projectId) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn createSdk({\n\t\t\tprojectId,\n\t\t\tbaseUrl,\n\t\t\tsessionTokenViaCookie,\n\t\t\tbaseHeaders,\n\t\t\tpersistTokens,\n\t\t\tstoreLastAuthenticatedUser,\n\t\t\tautoRefresh: true\n\t\t});\n\t}, [projectId, baseUrl, sessionTokenViaCookie]);\n","import React from 'react';\nimport { DefaultFlowProps } from '../types';\nimport Descope from './Descope';\n\nexport const SignInFlow = (props: DefaultFlowProps) => (\n\t<Descope {...props} flowId=\"sign-in\" />\n);\n\nexport const SignUpFlow = (props: DefaultFlowProps) => (\n\t<Descope {...props} flowId=\"sign-up\" />\n);\n\nexport const SignUpOrInFlow = (props: DefaultFlowProps) => (\n\t<Descope {...props} flowId=\"sign-up-or-in\" />\n);\n","import { useEffect, useMemo, useRef } from 'react';\nimport useContext from './useContext';\n\nconst useSession = () => {\n\tconst { session, isSessionLoading, fetchSession, isSessionFetched } =\n\t\tuseContext();\n\n\t// when session should be received, we want the return value of \"isSessionLoading\" to be true starting from the first call\n\t// (and not only when receiving an update from the context)\n\tconst isLoading = useRef(isSessionLoading);\n\n\t// we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n\tuseMemo(() => {\n\t\tisLoading.current = isSessionLoading;\n\t}, [isSessionLoading]);\n\n\tconst shouldFetchSession = !session && !isSessionLoading;\n\n\t// we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n\tuseMemo(() => {\n\t\tif (shouldFetchSession && !isSessionFetched) {\n\t\t\tisLoading.current = true;\n\t\t}\n\t}, [isSessionFetched]);\n\n\t// Fetch session if it's not already fetched\n\t// We want this to happen only once, so the dependency array should not contain shouldFetchSession\n\tuseEffect(() => {\n\t\tif (shouldFetchSession) {\n\t\t\tfetchSession();\n\t\t}\n\t}, [fetchSession]);\n\treturn {\n\t\tisSessionLoading: isLoading.current,\n\t\tsessionToken: session,\n\t\tisAuthenticated: !!session\n\t};\n};\n\nexport default useSession;\n","import { useEffect, useMemo, useRef, useState } from 'react';\nimport useContext from './useContext';\n\nconst useUser = () => {\n\tconst { user, fetchUser, isUserLoading, session } = useContext();\n\tconst [isInit, setIsInit] = useState(false); // we want to get the user only in the first time we got a session\n\n\t// when session should be received, we want the return value of \"isUserLoading\" to be true starting from the first call\n\t// (and not only when receiving an update from the context)\n\tconst isLoading = useRef(isUserLoading);\n\n\tconst shouldFetchUser = useMemo(\n\t\t() => !user && !isUserLoading && session && !isInit,\n\t\t[fetchUser, session, isInit]\n\t);\n\n\t// we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n\tuseMemo(() => {\n\t\tisLoading.current = isUserLoading;\n\t}, [isUserLoading]);\n\n\t// we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n\tuseMemo(() => {\n\t\tif (shouldFetchUser) {\n\t\t\tisLoading.current = true;\n\t\t}\n\t}, [shouldFetchUser]);\n\n\tuseEffect(() => {\n\t\tif (shouldFetchUser) {\n\t\t\tsetIsInit(true);\n\t\t\tfetchUser();\n\t\t}\n\t}, [shouldFetchUser]);\n\n\treturn { isUserLoading: isLoading.current, user };\n};\n\nexport default useUser;\n"],"names":["Context","React","createContext","undefined","withValidation","fn","args","Error","wrapInTry","res","err","console","error","baseHeaders","IS_BROWSER","window","globalSdk","createSdkWrapper","config","sdk","createSdk","Object","assign","persistTokens","autoRefresh","createTempSdk","projectId","storeLastAuthenticatedUser","getSessionToken","warn","getRefreshToken","getJwtPermissions","token","tenant","getJwtRoles","DescopeWC","lazy","async","Promise","resolve","then","_interopNamespace","require","default","sdkConfigOverrides","hooks","beforeRequest","httpClient","_","flowId","baseUrl","innerRef","theme","locale","debug","redirectUrl","client","form","autoFocus","createElement","ref","Descope","forwardRef","onSuccess","onError","onReady","logger","telemetryKey","errorTransformer","setInnerRef","useState","useImperativeHandle","useContext","handleSuccess","useCallback","e","afterRequest","Response","JSON","stringify","detail","useEffect","ele","addEventListener","removeEventListener","stringifiedForm","stringifiedClient","useMemo","Suspense","fallback","UserManagementWC","widgetId","UserManagement","RoleManagementWC","RoleManagement","AccessKeyManagementWC","AccessKeyManagement","ctx","generateErrorMsg","entryType","proxyThrowHandler","get","target","key","Proxy","sessionTokenViaCookie","children","user","setUser","session","setSession","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","useSdk","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","isSessionFetched","useRef","fetchSession","current","refresh","fetchUser","me","value","Provider","props","isLoading","shouldFetchSession","sessionToken","isAuthenticated","isInit","setIsInit","shouldFetchUser"],"mappings":"qfAGA,MAAMA,EAAUC,EAAAA,QAAMC,mBAAwBC,GCEjCC,EACcC,GAC1B,IAAIC,KACH,IAAKD,EACJ,MAAME,MACL,0HAGF,OAAOF,KAAMC,EAAK,EAGPE,EACcH,GAC1B,IAAIC,KACH,IAAIG,EACJ,IACCA,EAAMJ,KAAMC,EAGZ,CAFC,MAAOI,GACRC,QAAQC,MAAMF,EACd,CACD,OAAOD,CAAG,ECvBCI,EAAc,C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|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,9 @@ import * as _descope_core_js_sdk from '@descope/core-js-sdk';
|
|
|
11
11
|
interface IAuthProviderProps {
|
|
12
12
|
projectId: string;
|
|
13
13
|
baseUrl?: string;
|
|
14
|
+
persistTokens?: boolean;
|
|
14
15
|
sessionTokenViaCookie?: boolean;
|
|
16
|
+
storeLastAuthenticatedUser?: boolean;
|
|
15
17
|
children?: JSX.Element;
|
|
16
18
|
}
|
|
17
19
|
declare const AuthProvider: FC<IAuthProviderProps>;
|
|
@@ -151,6 +153,7 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
151
153
|
otp: {
|
|
152
154
|
verify: {
|
|
153
155
|
sms: (loginId: string, code: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
156
|
+
voice: (loginId: string, code: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
154
157
|
whatsapp: (loginId: string, code: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
155
158
|
email: (loginId: string, code: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
156
159
|
};
|
|
@@ -158,6 +161,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
158
161
|
sms: (loginId: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
159
162
|
maskedPhone: string;
|
|
160
163
|
}>>;
|
|
164
|
+
voice: (loginId: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
165
|
+
maskedPhone: string;
|
|
166
|
+
}>>;
|
|
161
167
|
whatsapp: (loginId: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
162
168
|
maskedPhone: string;
|
|
163
169
|
}>>;
|
|
@@ -181,6 +187,21 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
181
187
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
182
188
|
maskedPhone: string;
|
|
183
189
|
}>>;
|
|
190
|
+
voice: (loginId: string, user?: {
|
|
191
|
+
email?: string;
|
|
192
|
+
name?: string;
|
|
193
|
+
givenName?: string;
|
|
194
|
+
middleName?: string;
|
|
195
|
+
familyName?: string;
|
|
196
|
+
phone?: string;
|
|
197
|
+
}, signUpOptions?: {
|
|
198
|
+
customClaims?: Record<string, any>;
|
|
199
|
+
templateOptions?: {
|
|
200
|
+
[x: string]: string;
|
|
201
|
+
};
|
|
202
|
+
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
203
|
+
maskedPhone: string;
|
|
204
|
+
}>>;
|
|
184
205
|
whatsapp: (loginId: string, user?: {
|
|
185
206
|
email?: string;
|
|
186
207
|
name?: string;
|
|
@@ -216,6 +237,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
216
237
|
sms: (loginId: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
217
238
|
maskedPhone: string;
|
|
218
239
|
}>>;
|
|
240
|
+
voice: (loginId: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
241
|
+
maskedPhone: string;
|
|
242
|
+
}>>;
|
|
219
243
|
whatsapp: (loginId: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
220
244
|
maskedPhone: string;
|
|
221
245
|
}>>;
|
|
@@ -243,7 +267,7 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
243
267
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
244
268
|
maskedPhone: string;
|
|
245
269
|
}>>;
|
|
246
|
-
|
|
270
|
+
voice: <T_1_1 extends boolean>(loginId: string, phone: string, token?: string, updateOptions?: {
|
|
247
271
|
addToLoginIDs?: T_1_1;
|
|
248
272
|
onMergeUseExisting?: T_1_1 extends true ? boolean : never;
|
|
249
273
|
templateOptions?: {
|
|
@@ -252,6 +276,15 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
252
276
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
253
277
|
maskedPhone: string;
|
|
254
278
|
}>>;
|
|
279
|
+
whatsapp: <T_1_2 extends boolean>(loginId: string, phone: string, token?: string, updateOptions?: {
|
|
280
|
+
addToLoginIDs?: T_1_2;
|
|
281
|
+
onMergeUseExisting?: T_1_2 extends true ? boolean : never;
|
|
282
|
+
templateOptions?: {
|
|
283
|
+
[x: string]: string;
|
|
284
|
+
};
|
|
285
|
+
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
286
|
+
maskedPhone: string;
|
|
287
|
+
}>>;
|
|
255
288
|
};
|
|
256
289
|
};
|
|
257
290
|
};
|
|
@@ -261,6 +294,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
261
294
|
sms: (loginId: string, URI: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
262
295
|
maskedPhone: string;
|
|
263
296
|
}>>;
|
|
297
|
+
voice: (loginId: string, URI: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
298
|
+
maskedPhone: string;
|
|
299
|
+
}>>;
|
|
264
300
|
whatsapp: (loginId: string, URI: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
265
301
|
maskedPhone: string;
|
|
266
302
|
}>>;
|
|
@@ -284,6 +320,21 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
284
320
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
285
321
|
maskedPhone: string;
|
|
286
322
|
}>>;
|
|
323
|
+
voice: (loginId: string, URI: string, user?: {
|
|
324
|
+
email?: string;
|
|
325
|
+
name?: string;
|
|
326
|
+
givenName?: string;
|
|
327
|
+
middleName?: string;
|
|
328
|
+
familyName?: string;
|
|
329
|
+
phone?: string;
|
|
330
|
+
}, signUpOptions?: {
|
|
331
|
+
customClaims?: Record<string, any>;
|
|
332
|
+
templateOptions?: {
|
|
333
|
+
[x: string]: string;
|
|
334
|
+
};
|
|
335
|
+
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
336
|
+
maskedPhone: string;
|
|
337
|
+
}>>;
|
|
287
338
|
whatsapp: (loginId: string, URI: string, user?: {
|
|
288
339
|
email?: string;
|
|
289
340
|
name?: string;
|
|
@@ -324,6 +375,14 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
324
375
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
325
376
|
maskedPhone: string;
|
|
326
377
|
}>>;
|
|
378
|
+
voice: (loginId: string, URI?: string, signUpOptions?: {
|
|
379
|
+
customClaims?: Record<string, any>;
|
|
380
|
+
templateOptions?: {
|
|
381
|
+
[x: string]: string;
|
|
382
|
+
};
|
|
383
|
+
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
384
|
+
maskedPhone: string;
|
|
385
|
+
}>>;
|
|
327
386
|
whatsapp: (loginId: string, URI?: string, signUpOptions?: {
|
|
328
387
|
customClaims?: Record<string, any>;
|
|
329
388
|
templateOptions?: {
|
|
@@ -361,7 +420,7 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
361
420
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
362
421
|
maskedPhone: string;
|
|
363
422
|
}>>;
|
|
364
|
-
|
|
423
|
+
voice: <T_3_1 extends boolean>(loginId: string, phone: string, URI?: string, token?: string, updateOptions?: {
|
|
365
424
|
addToLoginIDs?: T_3_1;
|
|
366
425
|
onMergeUseExisting?: T_3_1 extends true ? boolean : never;
|
|
367
426
|
templateOptions?: {
|
|
@@ -370,6 +429,15 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
370
429
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
371
430
|
maskedPhone: string;
|
|
372
431
|
}>>;
|
|
432
|
+
whatsapp: <T_3_2 extends boolean>(loginId: string, phone: string, URI?: string, token?: string, updateOptions?: {
|
|
433
|
+
addToLoginIDs?: T_3_2;
|
|
434
|
+
onMergeUseExisting?: T_3_2 extends true ? boolean : never;
|
|
435
|
+
templateOptions?: {
|
|
436
|
+
[x: string]: string;
|
|
437
|
+
};
|
|
438
|
+
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
439
|
+
maskedPhone: string;
|
|
440
|
+
}>>;
|
|
373
441
|
};
|
|
374
442
|
};
|
|
375
443
|
};
|
|
@@ -603,6 +671,7 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
603
671
|
otp: {
|
|
604
672
|
verify: {
|
|
605
673
|
sms: (loginId: string, code: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
674
|
+
voice: (loginId: string, code: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
606
675
|
whatsapp: (loginId: string, code: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
607
676
|
email: (loginId: string, code: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
608
677
|
};
|
|
@@ -610,6 +679,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
610
679
|
sms: (loginId: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
611
680
|
maskedPhone: string;
|
|
612
681
|
}>>;
|
|
682
|
+
voice: (loginId: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
683
|
+
maskedPhone: string;
|
|
684
|
+
}>>;
|
|
613
685
|
whatsapp: (loginId: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
614
686
|
maskedPhone: string;
|
|
615
687
|
}>>;
|
|
@@ -633,6 +705,21 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
633
705
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
634
706
|
maskedPhone: string;
|
|
635
707
|
}>>;
|
|
708
|
+
voice: (loginId: string, user?: {
|
|
709
|
+
email?: string;
|
|
710
|
+
name?: string;
|
|
711
|
+
givenName?: string;
|
|
712
|
+
middleName?: string;
|
|
713
|
+
familyName?: string;
|
|
714
|
+
phone?: string;
|
|
715
|
+
}, signUpOptions?: {
|
|
716
|
+
customClaims?: Record<string, any>;
|
|
717
|
+
templateOptions?: {
|
|
718
|
+
[x: string]: string;
|
|
719
|
+
};
|
|
720
|
+
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
721
|
+
maskedPhone: string;
|
|
722
|
+
}>>;
|
|
636
723
|
whatsapp: (loginId: string, user?: {
|
|
637
724
|
email?: string;
|
|
638
725
|
name?: string;
|
|
@@ -668,6 +755,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
668
755
|
sms: (loginId: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
669
756
|
maskedPhone: string;
|
|
670
757
|
}>>;
|
|
758
|
+
voice: (loginId: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
759
|
+
maskedPhone: string;
|
|
760
|
+
}>>;
|
|
671
761
|
whatsapp: (loginId: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
672
762
|
maskedPhone: string;
|
|
673
763
|
}>>;
|
|
@@ -686,18 +776,27 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
686
776
|
maskedEmail: string;
|
|
687
777
|
}>>;
|
|
688
778
|
phone: {
|
|
689
|
-
sms: <
|
|
690
|
-
addToLoginIDs?:
|
|
691
|
-
onMergeUseExisting?:
|
|
779
|
+
sms: <T_1_3 extends boolean>(loginId: string, phone: string, token?: string, updateOptions?: {
|
|
780
|
+
addToLoginIDs?: T_1_3;
|
|
781
|
+
onMergeUseExisting?: T_1_3 extends true ? boolean : never;
|
|
692
782
|
templateOptions?: {
|
|
693
783
|
[x: string]: string;
|
|
694
784
|
};
|
|
695
785
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
696
786
|
maskedPhone: string;
|
|
697
787
|
}>>;
|
|
698
|
-
|
|
699
|
-
addToLoginIDs?:
|
|
700
|
-
onMergeUseExisting?:
|
|
788
|
+
voice: <T_1_4 extends boolean>(loginId: string, phone: string, token?: string, updateOptions?: {
|
|
789
|
+
addToLoginIDs?: T_1_4;
|
|
790
|
+
onMergeUseExisting?: T_1_4 extends true ? boolean : never;
|
|
791
|
+
templateOptions?: {
|
|
792
|
+
[x: string]: string;
|
|
793
|
+
};
|
|
794
|
+
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
795
|
+
maskedPhone: string;
|
|
796
|
+
}>>;
|
|
797
|
+
whatsapp: <T_1_5 extends boolean>(loginId: string, phone: string, token?: string, updateOptions?: {
|
|
798
|
+
addToLoginIDs?: T_1_5;
|
|
799
|
+
onMergeUseExisting?: T_1_5 extends true ? boolean : never;
|
|
701
800
|
templateOptions?: {
|
|
702
801
|
[x: string]: string;
|
|
703
802
|
};
|
|
@@ -713,6 +812,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
713
812
|
sms: (loginId: string, URI: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
714
813
|
maskedPhone: string;
|
|
715
814
|
}>>;
|
|
815
|
+
voice: (loginId: string, URI: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
816
|
+
maskedPhone: string;
|
|
817
|
+
}>>;
|
|
716
818
|
whatsapp: (loginId: string, URI: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
717
819
|
maskedPhone: string;
|
|
718
820
|
}>>;
|
|
@@ -736,6 +838,21 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
736
838
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
737
839
|
maskedPhone: string;
|
|
738
840
|
}>>;
|
|
841
|
+
voice: (loginId: string, URI: string, user?: {
|
|
842
|
+
email?: string;
|
|
843
|
+
name?: string;
|
|
844
|
+
givenName?: string;
|
|
845
|
+
middleName?: string;
|
|
846
|
+
familyName?: string;
|
|
847
|
+
phone?: string;
|
|
848
|
+
}, signUpOptions?: {
|
|
849
|
+
customClaims?: Record<string, any>;
|
|
850
|
+
templateOptions?: {
|
|
851
|
+
[x: string]: string;
|
|
852
|
+
};
|
|
853
|
+
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
854
|
+
maskedPhone: string;
|
|
855
|
+
}>>;
|
|
739
856
|
whatsapp: (loginId: string, URI: string, user?: {
|
|
740
857
|
email?: string;
|
|
741
858
|
name?: string;
|
|
@@ -776,6 +893,14 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
776
893
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
777
894
|
maskedPhone: string;
|
|
778
895
|
}>>;
|
|
896
|
+
voice: (loginId: string, URI?: string, signUpOptions?: {
|
|
897
|
+
customClaims?: Record<string, any>;
|
|
898
|
+
templateOptions?: {
|
|
899
|
+
[x: string]: string;
|
|
900
|
+
};
|
|
901
|
+
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
902
|
+
maskedPhone: string;
|
|
903
|
+
}>>;
|
|
779
904
|
whatsapp: (loginId: string, URI?: string, signUpOptions?: {
|
|
780
905
|
customClaims?: Record<string, any>;
|
|
781
906
|
templateOptions?: {
|
|
@@ -804,18 +929,27 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
804
929
|
maskedEmail: string;
|
|
805
930
|
}>>;
|
|
806
931
|
phone: {
|
|
807
|
-
sms: <
|
|
808
|
-
addToLoginIDs?:
|
|
809
|
-
onMergeUseExisting?:
|
|
932
|
+
sms: <T_3_3 extends boolean>(loginId: string, phone: string, URI?: string, token?: string, updateOptions?: {
|
|
933
|
+
addToLoginIDs?: T_3_3;
|
|
934
|
+
onMergeUseExisting?: T_3_3 extends true ? boolean : never;
|
|
810
935
|
templateOptions?: {
|
|
811
936
|
[x: string]: string;
|
|
812
937
|
};
|
|
813
938
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
814
939
|
maskedPhone: string;
|
|
815
940
|
}>>;
|
|
816
|
-
|
|
817
|
-
addToLoginIDs?:
|
|
818
|
-
onMergeUseExisting?:
|
|
941
|
+
voice: <T_3_4 extends boolean>(loginId: string, phone: string, URI?: string, token?: string, updateOptions?: {
|
|
942
|
+
addToLoginIDs?: T_3_4;
|
|
943
|
+
onMergeUseExisting?: T_3_4 extends true ? boolean : never;
|
|
944
|
+
templateOptions?: {
|
|
945
|
+
[x: string]: string;
|
|
946
|
+
};
|
|
947
|
+
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
948
|
+
maskedPhone: string;
|
|
949
|
+
}>>;
|
|
950
|
+
whatsapp: <T_3_5 extends boolean>(loginId: string, phone: string, URI?: string, token?: string, updateOptions?: {
|
|
951
|
+
addToLoginIDs?: T_3_5;
|
|
952
|
+
onMergeUseExisting?: T_3_5 extends true ? boolean : never;
|
|
819
953
|
templateOptions?: {
|
|
820
954
|
[x: string]: string;
|
|
821
955
|
};
|