@descope/react-sdk 2.0.3 → 2.0.5
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 +28 -5
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.d.ts +90 -132
- 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 +2 -2
package/README.md
CHANGED
|
@@ -110,6 +110,25 @@ const App = () => {
|
|
|
110
110
|
// ...
|
|
111
111
|
|
|
112
112
|
|
|
113
|
+
// form is an object the initial form context that is used in screens inputs in the flow execution.
|
|
114
|
+
// Used to inject predefined input values on flow start such as custom inputs, custom attributes and other inputs.
|
|
115
|
+
// Keys passed can be accessed in flows actions, conditions and screens prefixed with "form.".
|
|
116
|
+
// NOTE: form is not required. If not provided, 'form' context key will be empty before user input.
|
|
117
|
+
// Example:
|
|
118
|
+
// ...
|
|
119
|
+
// form={{ email: "predefinedname@domain.com", firstName: "test", "customAttribute.test": "aaaa", "myCustomInput": 12 }}
|
|
120
|
+
// ...
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
// client is an object the initial client context in the flow execution.
|
|
124
|
+
// Keys passed can be accessed in flows actions and conditions prefixed with "client.".
|
|
125
|
+
// NOTE: client is not required. If not provided, context key will be empty.
|
|
126
|
+
// Example:
|
|
127
|
+
// ...
|
|
128
|
+
// client={{ version: "1.2.0" }}
|
|
129
|
+
// ...
|
|
130
|
+
|
|
131
|
+
|
|
113
132
|
// logger is an object describing how to log info, warn and errors.
|
|
114
133
|
// NOTE: logger is not required. If not provided, the logs will be printed to the console.
|
|
115
134
|
// Example:
|
|
@@ -147,17 +166,21 @@ import { useCallback } from 'react';
|
|
|
147
166
|
const App = () => {
|
|
148
167
|
// NOTE - `useDescope`, `useSession`, `useUser` should be used inside `AuthProvider` context,
|
|
149
168
|
// and will throw an exception if this requirement is not met
|
|
150
|
-
|
|
151
|
-
const {
|
|
152
|
-
|
|
169
|
+
// useSession retrieves authentication state, session loading status, and session token
|
|
170
|
+
const { isAuthenticated, isSessionLoading, sessionToken } = useSession();
|
|
171
|
+
// useUser retrieves the logged in user information
|
|
172
|
+
const { user } = useUser();
|
|
173
|
+
// useDescope retrieves Descope SDK for further operations related to authentication
|
|
174
|
+
// such as logout
|
|
175
|
+
const sdk = useDescope();
|
|
153
176
|
|
|
154
177
|
if (isSessionLoading || isUserLoading) {
|
|
155
178
|
return <p>Loading...</p>;
|
|
156
179
|
}
|
|
157
180
|
|
|
158
181
|
const handleLogout = useCallback(() => {
|
|
159
|
-
logout();
|
|
160
|
-
}, [
|
|
182
|
+
sdk.logout();
|
|
183
|
+
}, [sdk]);
|
|
161
184
|
|
|
162
185
|
if (isAuthenticated) {
|
|
163
186
|
return (
|
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 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 o=r(e),n=r(t);const u=o.default.createContext(void 0),i=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)},c=e=>(...t)=>{let r;try{r=e(...t)}catch(e){console.error(e)}return r},a={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.0.
|
|
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 o=r(e),n=r(t);const u=o.default.createContext(void 0),i=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)},c=e=>(...t)=>{let r;try{r=e(...t)}catch(e){console.error(e)}return r},a={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.0.5"},l="undefined"!=typeof window;let f;const d=e=>{const t=n.default({...e,persistTokens:l,autoRefresh:l});return f=t,t};f=d({projectId:"temp pid"});const p=()=>l?f?.getSessionToken():(console.warn("Get session token is not supported in SSR"),""),m=()=>l?f?.getRefreshToken():(console.warn("Get refresh token is not supported in SSR"),""),h=c(((e=p(),t)=>f?.getJwtPermissions(e,t))),g=c(((e=p(),t)=>f?.getJwtRoles(e,t)));const k=e.lazy((async()=>((await Promise.resolve().then((function(){return s(require("@descope/web-component"))}))).default.sdkConfigOverrides={baseHeaders:a},{default:({projectId:e,flowId:t,baseUrl:r,innerRef:s,tenant:n,theme:u,locale:i,debug:c,redirectUrl:a,client:l,form:f,autoFocus:d})=>o.default.createElement("descope-wc",{"project-id":e,"flow-id":t,"base-url":r,ref:s,tenant:n,theme:u,locale:i,debug:c,client:l,form:f,"redirect-url":a,"auto-focus":d})}))),w=o.default.forwardRef((({flowId:t,onSuccess:r,onError:s,logger:n,tenant:i,theme:c,locale:a,debug:l,client:f,form:d,telemetryKey:p,redirectUrl:m,autoFocus:h,errorTransformer:g},w)=>{const[b,S]=e.useState(null);e.useImperativeHandle(w,(()=>b));const{projectId:y,baseUrl:E,sdk:v}=o.default.useContext(u),j=e.useCallback((async e=>{await v.httpClient.hooks.afterRequest({},new Response(JSON.stringify(e.detail))),r&&r(e)}),[r]);e.useEffect((()=>{const e=b;return e?.addEventListener("success",j),s&&e?.addEventListener("error",s),()=>{s&&e?.removeEventListener("error",s),e?.removeEventListener("success",j)}}),[b,s,j]),e.useEffect((()=>{b&&(b.errorTransformer=g)}),[b,g]),e.useEffect((()=>{b&&n&&(b.logger=n)}),[b,n]);const{form:x,client:I}=e.useMemo((()=>({form:JSON.stringify(d||{}),client:JSON.stringify(f||{})})),[d,f]);return o.default.createElement("form",null,o.default.createElement(e.Suspense,{fallback:null},o.default.createElement(k,{projectId:y,flowId:t,baseUrl:E,innerRef:S,tenant:i,theme:c,locale:a,debug:l,form:x,client:I,telemetryKey:p,redirectUrl:m,autoFocus:h})))}));var b=()=>{const t=e.useContext(u);if(!t)throw Error("You can only use this hook in the context of <AuthProvider />");return t};const S=e=>`You can only use this ${e} after sdk initialization. Make sure to supply 'projectId' to <AuthProvider /> component`,y={get(e,t){if("object"==typeof e[t]&&null!==e[t])return new Proxy(e[t],y);if("function"==typeof e[t])return()=>{throw Error(S("function"))};throw Error(S("attribute"))}};exports.AuthProvider=({projectId:t,baseUrl:r="",sessionTokenViaCookie:s=!1,children:n})=>{const[c,l]=e.useState(),[f,p]=e.useState(),[m,h]=e.useState(!1),[g,k]=e.useState(!1),w=(({projectId:t,baseUrl:r,sessionTokenViaCookie:s})=>e.useMemo((()=>{if(t)return d({projectId:t,baseUrl:r,sessionTokenViaCookie:s,baseHeaders:a,persistToken:!0,autoRefresh:!0})}),[t,r,s]))({projectId:t,baseUrl:r,sessionTokenViaCookie:s});e.useEffect((()=>{if(w){const e=w.onSessionTokenChange(p),t=w.onUserChange(l);return()=>{e(),t()}}}),[w]);const b=e.useRef(!1),S=e.useCallback((()=>{b.current||(b.current=!0,k(!0),i(w?.refresh)().then((()=>{k(!1)})))}),[w]),y=e.useCallback((()=>{h(!0),i(w.me)().then((()=>{h(!1)}))}),[w]),E=e.useMemo((()=>({fetchUser:y,user:c,isUserLoading:m,fetchSession:S,session:f,isSessionLoading:g,isSessionFetched:b.current,projectId:t,baseUrl:r,setUser:l,setSession:p,sdk:w})),[y,c,m,S,f,g,b.current,t,r,l,p,w]);return o.default.createElement(u.Provider,{value:E},n)},exports.Descope=w,exports.SignInFlow=e=>o.default.createElement(w,{...e,flowId:"sign-in"}),exports.SignUpFlow=e=>o.default.createElement(w,{...e,flowId:"sign-up"}),exports.SignUpOrInFlow=e=>o.default.createElement(w,{...e,flowId:"sign-up-or-in"}),exports.getJwtPermissions=h,exports.getJwtRoles=g,exports.getRefreshToken=m,exports.getSessionToken=p,exports.refresh=(e=m())=>f?.refresh(e),exports.useDescope=()=>{const{sdk:t}=b();return e.useMemo((()=>t||new Proxy(d({projectId:"dummy"}),y)),[t])},exports.useSession=()=>{const{session:t,isSessionLoading:r,fetchSession:s,isSessionFetched:o}=b(),n=e.useRef(r);return e.useMemo((()=>{n.current=r}),[r]),e.useMemo((()=>{o||(n.current=!0)}),[o]),e.useEffect((()=>{t||r||s()}),[s]),{isSessionLoading:n.current,sessionToken:t,isAuthenticated:!!t}},exports.useUser=()=>{const{user:t,fetchUser:r,isUserLoading:s,session:o}=b(),[n,u]=e.useState(!1),i=e.useRef(s),c=e.useMemo((()=>!t&&!s&&o&&!n),[r,o,n]);return e.useMemo((()=>{i.current=s}),[s]),e.useMemo((()=>{c&&(i.current=!0)}),[c]),e.useEffect((()=>{c&&(u(!0),r())}),[c]),{isUserLoading:i.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/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\n// eslint-disable-next-line import/prefer-default-export\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 sdkInstance: 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\tsdkInstance = 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 */\nsdkInstance = createSdkWrapper({ projectId: 'temp pid' });\n\nexport const getSessionToken = () => {\n\tif (IS_BROWSER) {\n\t\treturn sdkInstance?.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 sdkInstance?.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\tsdkInstance?.getJwtPermissions(token, tenant)\n);\n\nexport const getJwtRoles = wrapInTry(\n\t(token = getSessionToken(), tenant?: string) =>\n\t\tsdkInstance?.getJwtRoles(token, tenant)\n);\n\nexport const refresh = (token = getRefreshToken()) =>\n\tsdkInstance?.refresh(token);\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\tuseState\n} from 'react';\nimport { baseHeaders } from '../constants';\nimport Context from '../hooks/Context';\nimport { DescopeProps } from '../types';\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\t// we want to override the web-component base headers so we can tell that is was used via the React SDK\n\tmodule.default.sdkConfigOverrides = { baseHeaders };\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\ttelemetryKey,\n\t\t\tredirectUrl,\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\ttelemetryKey={telemetryKey}\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\tlogger,\n\t\t\ttenant,\n\t\t\ttheme,\n\t\t\tlocale,\n\t\t\tdebug,\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\n\t\t\treturn () => {\n\t\t\t\tif (onError) ele?.removeEventListener('error', onError);\n\n\t\t\t\tele?.removeEventListener('success', handleSuccess);\n\t\t\t};\n\t\t}, [innerRef, onError, handleSuccess]);\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\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\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 { 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\t// we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n\tuseMemo(() => {\n\t\tif (!isSessionFetched) {\n\t\t\tisLoading.current = true;\n\t\t}\n\t}, [isSessionFetched]);\n\n\tuseEffect(() => {\n\t\tif (!session && !isSessionLoading) {\n\t\t\tfetchSession();\n\t\t}\n\t}, [fetchSession]);\n\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","sdkInstance","createSdkWrapper","config","sdk","createSdk","persistTokens","autoRefresh","projectId","getSessionToken","warn","getRefreshToken","getJwtPermissions","token","tenant","getJwtRoles","DescopeWC","lazy","async","Promise","resolve","then","_interopNamespace","require","default","sdkConfigOverrides","flowId","baseUrl","innerRef","theme","locale","debug","telemetryKey","redirectUrl","autoFocus","ref","Descope","forwardRef","onSuccess","onError","logger","errorTransformer","setInnerRef","useState","useImperativeHandle","useContext","handleSuccess","useCallback","e","httpClient","hooks","afterRequest","Response","JSON","stringify","detail","useEffect","ele","addEventListener","removeEventListener","createElement","Suspense","fallback","ctx","generateErrorMsg","entryType","proxyThrowHandler","get","target","key","Proxy","sessionTokenViaCookie","children","user","setUser","session","setSession","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","useMemo","persistToken","useSdk","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","isSessionFetched","useRef","fetchSession","current","refresh","fetchUser","me","value","Provider","props","isLoading","sessionToken","isAuthenticated","isInit","setIsInit","shouldFetchUser"],"mappings":"qfAGA,MAAMA,EAAUC,EAAAA,QAAMC,mBAAwBC,GCEjCC,EACcC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AAU,EACpB,GACC,CAACY,IAEJ/C,EAAAA,WAAU,KACL+C,IACHD,GAAU,GACVT,IACA,GACC,CAACU,IAEG,CAAE1B,cAAeqB,EAAUP,QAASlB,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/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\n// eslint-disable-next-line import/prefer-default-export\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 sdkInstance: 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\tsdkInstance = 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 */\nsdkInstance = createSdkWrapper({ projectId: 'temp pid' });\n\nexport const getSessionToken = () => {\n\tif (IS_BROWSER) {\n\t\treturn sdkInstance?.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 sdkInstance?.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\tsdkInstance?.getJwtPermissions(token, tenant)\n);\n\nexport const getJwtRoles = wrapInTry(\n\t(token = getSessionToken(), tenant?: string) =>\n\t\tsdkInstance?.getJwtRoles(token, tenant)\n);\n\nexport const refresh = (token = getRefreshToken()) =>\n\tsdkInstance?.refresh(token);\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';\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\t// we want to override the web-component base headers so we can tell that is was used via the React SDK\n\tmodule.default.sdkConfigOverrides = { baseHeaders };\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\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\n\t\t\treturn () => {\n\t\t\t\tif (onError) ele?.removeEventListener('error', onError);\n\n\t\t\t\tele?.removeEventListener('success', handleSuccess);\n\t\t\t};\n\t\t}, [innerRef, onError, handleSuccess]);\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 { 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\t// we want this to happen before returning a value so we are using \"useMemo\" and not \"useEffect\"\n\tuseMemo(() => {\n\t\tif (!isSessionFetched) {\n\t\t\tisLoading.current = true;\n\t\t}\n\t}, [isSessionFetched]);\n\n\tuseEffect(() => {\n\t\tif (!session && !isSessionLoading) {\n\t\t\tfetchSession();\n\t\t}\n\t}, [fetchSession]);\n\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","sdkInstance","createSdkWrapper","config","sdk","createSdk","persistTokens","autoRefresh","projectId","getSessionToken","warn","getRefreshToken","getJwtPermissions","token","tenant","getJwtRoles","DescopeWC","lazy","async","Promise","resolve","then","_interopNamespace","require","default","sdkConfigOverrides","flowId","baseUrl","innerRef","theme","locale","debug","redirectUrl","client","form","autoFocus","createElement","ref","Descope","forwardRef","onSuccess","onError","logger","telemetryKey","errorTransformer","setInnerRef","useState","useImperativeHandle","useContext","handleSuccess","useCallback","e","httpClient","hooks","afterRequest","Response","JSON","stringify","detail","useEffect","ele","addEventListener","removeEventListener","stringifiedForm","stringifiedClient","useMemo","Suspense","fallback","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","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,ECtBCI,EAAc,CAC1B,qBAAsB,QACtB,wBAAyB,SAIbC,EAA+B,oBAAXC,OCJjC,IAAIC,EAEJ,MAAMC,EACLC,IAEA,MAAMC,EAAMC,EAAAA,QAAU,IAClBF,EACHG,cAAeP,EACfQ,YAAaR,IAId,OAFAE,EAAcG,EAEPA,CAAG,EAUXH,EAAcC,EAAiB,CAAEM,UAAW,aAErC,MAAM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@@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
78
78
|
samlIdpStateId?: string;
|
|
79
79
|
samlIdpUsername?: string;
|
|
80
80
|
ssoAppId?: string;
|
|
81
|
+
oidcLoginHint?: string;
|
|
81
82
|
abTestingKey?: number;
|
|
82
|
-
|
|
83
|
+
startOptionsVersion?: number;
|
|
84
|
+
client?: Record<string, any>;
|
|
85
|
+
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "samlIdpUsername" | "ssoAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client"> & {
|
|
83
86
|
lastAuth?: Omit<{
|
|
84
87
|
authMethod?: "webauthn" | "otp" | "oauth" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
85
88
|
oauthProvider?: string;
|
|
@@ -103,11 +106,7 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
103
106
|
finish: (transactionId: string, response: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
104
107
|
};
|
|
105
108
|
signIn: ((identifier: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>) & {
|
|
106
|
-
start: (loginId: string, origin: string, loginOptions?: {
|
|
107
|
-
stepup?: boolean;
|
|
108
|
-
mfa?: boolean;
|
|
109
|
-
customClaims?: Record<string, any>;
|
|
110
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
109
|
+
start: (loginId: string, origin: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
111
110
|
transactionId: string;
|
|
112
111
|
options: string;
|
|
113
112
|
create: boolean;
|
|
@@ -160,6 +159,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
160
159
|
sms: (loginId: string, user?: {
|
|
161
160
|
email?: string;
|
|
162
161
|
name?: string;
|
|
162
|
+
givenName?: string;
|
|
163
|
+
middleName?: string;
|
|
164
|
+
familyName?: string;
|
|
163
165
|
phone?: string;
|
|
164
166
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
165
167
|
maskedPhone: string;
|
|
@@ -167,6 +169,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
167
169
|
whatsapp: (loginId: string, user?: {
|
|
168
170
|
email?: string;
|
|
169
171
|
name?: string;
|
|
172
|
+
givenName?: string;
|
|
173
|
+
middleName?: string;
|
|
174
|
+
familyName?: string;
|
|
170
175
|
phone?: string;
|
|
171
176
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
172
177
|
maskedPhone: string;
|
|
@@ -174,6 +179,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
174
179
|
email: (loginId: string, user?: {
|
|
175
180
|
email?: string;
|
|
176
181
|
name?: string;
|
|
182
|
+
givenName?: string;
|
|
183
|
+
middleName?: string;
|
|
184
|
+
familyName?: string;
|
|
177
185
|
phone?: string;
|
|
178
186
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
179
187
|
maskedEmail: string;
|
|
@@ -230,6 +238,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
230
238
|
sms: (loginId: string, uri: string, user?: {
|
|
231
239
|
email?: string;
|
|
232
240
|
name?: string;
|
|
241
|
+
givenName?: string;
|
|
242
|
+
middleName?: string;
|
|
243
|
+
familyName?: string;
|
|
233
244
|
phone?: string;
|
|
234
245
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
235
246
|
maskedPhone: string;
|
|
@@ -237,6 +248,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
237
248
|
whatsapp: (loginId: string, uri: string, user?: {
|
|
238
249
|
email?: string;
|
|
239
250
|
name?: string;
|
|
251
|
+
givenName?: string;
|
|
252
|
+
middleName?: string;
|
|
253
|
+
familyName?: string;
|
|
240
254
|
phone?: string;
|
|
241
255
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
242
256
|
maskedPhone: string;
|
|
@@ -244,6 +258,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
244
258
|
email: (loginId: string, uri: string, user?: {
|
|
245
259
|
email?: string;
|
|
246
260
|
name?: string;
|
|
261
|
+
givenName?: string;
|
|
262
|
+
middleName?: string;
|
|
263
|
+
familyName?: string;
|
|
247
264
|
phone?: string;
|
|
248
265
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
249
266
|
maskedEmail: string;
|
|
@@ -290,6 +307,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
290
307
|
signUp: (loginId: string, uri: string, user?: {
|
|
291
308
|
email?: string;
|
|
292
309
|
name?: string;
|
|
310
|
+
givenName?: string;
|
|
311
|
+
middleName?: string;
|
|
312
|
+
familyName?: string;
|
|
293
313
|
phone?: string;
|
|
294
314
|
}) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
|
|
295
315
|
waitForSession: (pendingRef: string, config?: {
|
|
@@ -304,84 +324,42 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
304
324
|
};
|
|
305
325
|
};
|
|
306
326
|
oauth: {
|
|
307
|
-
start: ((provider: string, redirectUrl?: string, loginOptions?: {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
github: (redirectURL?: string, loginOptions?: {
|
|
318
|
-
stepup?: boolean;
|
|
319
|
-
mfa?: boolean;
|
|
320
|
-
customClaims?: Record<string, any>;
|
|
321
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
322
|
-
google: (redirectURL?: string, loginOptions?: {
|
|
323
|
-
stepup?: boolean;
|
|
324
|
-
mfa?: boolean;
|
|
325
|
-
customClaims?: Record<string, any>;
|
|
326
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
327
|
-
microsoft: (redirectURL?: string, loginOptions?: {
|
|
328
|
-
stepup?: boolean;
|
|
329
|
-
mfa?: boolean;
|
|
330
|
-
customClaims?: Record<string, any>;
|
|
331
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
332
|
-
gitlab: (redirectURL?: string, loginOptions?: {
|
|
333
|
-
stepup?: boolean;
|
|
334
|
-
mfa?: boolean;
|
|
335
|
-
customClaims?: Record<string, any>;
|
|
336
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
337
|
-
apple: (redirectURL?: string, loginOptions?: {
|
|
338
|
-
stepup?: boolean;
|
|
339
|
-
mfa?: boolean;
|
|
340
|
-
customClaims?: Record<string, any>;
|
|
341
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
342
|
-
discord: (redirectURL?: string, loginOptions?: {
|
|
343
|
-
stepup?: boolean;
|
|
344
|
-
mfa?: boolean;
|
|
345
|
-
customClaims?: Record<string, any>;
|
|
346
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
347
|
-
linkedin: (redirectURL?: string, loginOptions?: {
|
|
348
|
-
stepup?: boolean;
|
|
349
|
-
mfa?: boolean;
|
|
350
|
-
customClaims?: Record<string, any>;
|
|
351
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
352
|
-
slack: (redirectURL?: string, loginOptions?: {
|
|
353
|
-
stepup?: boolean;
|
|
354
|
-
mfa?: boolean;
|
|
355
|
-
customClaims?: Record<string, any>;
|
|
356
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
327
|
+
start: ((provider: string, redirectUrl?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.ResponseData>>) & {
|
|
328
|
+
facebook: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
329
|
+
github: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
330
|
+
google: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
331
|
+
microsoft: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
332
|
+
gitlab: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
333
|
+
apple: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
334
|
+
discord: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
335
|
+
linkedin: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
336
|
+
slack: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
357
337
|
};
|
|
358
338
|
exchange: (code: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
359
339
|
};
|
|
360
340
|
saml: {
|
|
361
|
-
start: (tenantIdOrEmail: string, redirectUrl?: string, loginOptions?:
|
|
362
|
-
stepup?: boolean;
|
|
363
|
-
mfa?: boolean;
|
|
364
|
-
customClaims?: Record<string, any>;
|
|
365
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
341
|
+
start: (tenantIdOrEmail: string, redirectUrl?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
366
342
|
exchange: (code: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
367
343
|
};
|
|
368
344
|
totp: {
|
|
369
345
|
signUp: (loginId: string, user?: {
|
|
370
346
|
email?: string;
|
|
371
347
|
name?: string;
|
|
348
|
+
givenName?: string;
|
|
349
|
+
middleName?: string;
|
|
350
|
+
familyName?: string;
|
|
372
351
|
phone?: string;
|
|
373
352
|
}) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.TOTPResponse>>;
|
|
374
|
-
verify: (loginId: string, code: string, loginOptions?:
|
|
375
|
-
stepup?: boolean;
|
|
376
|
-
mfa?: boolean;
|
|
377
|
-
customClaims?: Record<string, any>;
|
|
378
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
353
|
+
verify: (loginId: string, code: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
379
354
|
update: (loginId: string, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.TOTPResponse>>;
|
|
380
355
|
};
|
|
381
356
|
password: {
|
|
382
357
|
signUp: (loginId: string, password: string, user?: {
|
|
383
358
|
email?: string;
|
|
384
359
|
name?: string;
|
|
360
|
+
givenName?: string;
|
|
361
|
+
middleName?: string;
|
|
362
|
+
familyName?: string;
|
|
385
363
|
phone?: string;
|
|
386
364
|
}) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
387
365
|
signIn: (loginId: string, password: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
@@ -468,8 +446,11 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
468
446
|
samlIdpStateId?: string;
|
|
469
447
|
samlIdpUsername?: string;
|
|
470
448
|
ssoAppId?: string;
|
|
449
|
+
oidcLoginHint?: string;
|
|
471
450
|
abTestingKey?: number;
|
|
472
|
-
|
|
451
|
+
startOptionsVersion?: number;
|
|
452
|
+
client?: Record<string, any>;
|
|
453
|
+
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "samlIdpUsername" | "ssoAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client"> & {
|
|
473
454
|
lastAuth?: Omit<{
|
|
474
455
|
authMethod?: "webauthn" | "otp" | "oauth" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
475
456
|
oauthProvider?: string;
|
|
@@ -493,11 +474,7 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
493
474
|
finish: (transactionId: string, response: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
494
475
|
};
|
|
495
476
|
signIn: ((identifier: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>) & {
|
|
496
|
-
start: (loginId: string, origin: string, loginOptions?: {
|
|
497
|
-
stepup?: boolean;
|
|
498
|
-
mfa?: boolean;
|
|
499
|
-
customClaims?: Record<string, any>;
|
|
500
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
477
|
+
start: (loginId: string, origin: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
501
478
|
transactionId: string;
|
|
502
479
|
options: string;
|
|
503
480
|
create: boolean;
|
|
@@ -550,6 +527,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
550
527
|
sms: (loginId: string, user?: {
|
|
551
528
|
email?: string;
|
|
552
529
|
name?: string;
|
|
530
|
+
givenName?: string;
|
|
531
|
+
middleName?: string;
|
|
532
|
+
familyName?: string;
|
|
553
533
|
phone?: string;
|
|
554
534
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
555
535
|
maskedPhone: string;
|
|
@@ -557,6 +537,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
557
537
|
whatsapp: (loginId: string, user?: {
|
|
558
538
|
email?: string;
|
|
559
539
|
name?: string;
|
|
540
|
+
givenName?: string;
|
|
541
|
+
middleName?: string;
|
|
542
|
+
familyName?: string;
|
|
560
543
|
phone?: string;
|
|
561
544
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
562
545
|
maskedPhone: string;
|
|
@@ -564,6 +547,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
564
547
|
email: (loginId: string, user?: {
|
|
565
548
|
email?: string;
|
|
566
549
|
name?: string;
|
|
550
|
+
givenName?: string;
|
|
551
|
+
middleName?: string;
|
|
552
|
+
familyName?: string;
|
|
567
553
|
phone?: string;
|
|
568
554
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
569
555
|
maskedEmail: string;
|
|
@@ -620,6 +606,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
620
606
|
sms: (loginId: string, uri: string, user?: {
|
|
621
607
|
email?: string;
|
|
622
608
|
name?: string;
|
|
609
|
+
givenName?: string;
|
|
610
|
+
middleName?: string;
|
|
611
|
+
familyName?: string;
|
|
623
612
|
phone?: string;
|
|
624
613
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
625
614
|
maskedPhone: string;
|
|
@@ -627,6 +616,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
627
616
|
whatsapp: (loginId: string, uri: string, user?: {
|
|
628
617
|
email?: string;
|
|
629
618
|
name?: string;
|
|
619
|
+
givenName?: string;
|
|
620
|
+
middleName?: string;
|
|
621
|
+
familyName?: string;
|
|
630
622
|
phone?: string;
|
|
631
623
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
632
624
|
maskedPhone: string;
|
|
@@ -634,6 +626,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
634
626
|
email: (loginId: string, uri: string, user?: {
|
|
635
627
|
email?: string;
|
|
636
628
|
name?: string;
|
|
629
|
+
givenName?: string;
|
|
630
|
+
middleName?: string;
|
|
631
|
+
familyName?: string;
|
|
637
632
|
phone?: string;
|
|
638
633
|
}) => Promise<_descope_core_js_sdk.SdkResponse<{
|
|
639
634
|
maskedEmail: string;
|
|
@@ -680,6 +675,9 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
680
675
|
signUp: (loginId: string, uri: string, user?: {
|
|
681
676
|
email?: string;
|
|
682
677
|
name?: string;
|
|
678
|
+
givenName?: string;
|
|
679
|
+
middleName?: string;
|
|
680
|
+
familyName?: string;
|
|
683
681
|
phone?: string;
|
|
684
682
|
}) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
|
|
685
683
|
waitForSession: (pendingRef: string, config?: {
|
|
@@ -694,84 +692,42 @@ declare const createSdkWrapper: <P extends Omit<{
|
|
|
694
692
|
};
|
|
695
693
|
};
|
|
696
694
|
oauth: {
|
|
697
|
-
start: ((provider: string, redirectUrl?: string, loginOptions?: {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
github: (redirectURL?: string, loginOptions?: {
|
|
708
|
-
stepup?: boolean;
|
|
709
|
-
mfa?: boolean;
|
|
710
|
-
customClaims?: Record<string, any>;
|
|
711
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
712
|
-
google: (redirectURL?: string, loginOptions?: {
|
|
713
|
-
stepup?: boolean;
|
|
714
|
-
mfa?: boolean;
|
|
715
|
-
customClaims?: Record<string, any>;
|
|
716
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
717
|
-
microsoft: (redirectURL?: string, loginOptions?: {
|
|
718
|
-
stepup?: boolean;
|
|
719
|
-
mfa?: boolean;
|
|
720
|
-
customClaims?: Record<string, any>;
|
|
721
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
722
|
-
gitlab: (redirectURL?: string, loginOptions?: {
|
|
723
|
-
stepup?: boolean;
|
|
724
|
-
mfa?: boolean;
|
|
725
|
-
customClaims?: Record<string, any>;
|
|
726
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
727
|
-
apple: (redirectURL?: string, loginOptions?: {
|
|
728
|
-
stepup?: boolean;
|
|
729
|
-
mfa?: boolean;
|
|
730
|
-
customClaims?: Record<string, any>;
|
|
731
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
732
|
-
discord: (redirectURL?: string, loginOptions?: {
|
|
733
|
-
stepup?: boolean;
|
|
734
|
-
mfa?: boolean;
|
|
735
|
-
customClaims?: Record<string, any>;
|
|
736
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
737
|
-
linkedin: (redirectURL?: string, loginOptions?: {
|
|
738
|
-
stepup?: boolean;
|
|
739
|
-
mfa?: boolean;
|
|
740
|
-
customClaims?: Record<string, any>;
|
|
741
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
742
|
-
slack: (redirectURL?: string, loginOptions?: {
|
|
743
|
-
stepup?: boolean;
|
|
744
|
-
mfa?: boolean;
|
|
745
|
-
customClaims?: Record<string, any>;
|
|
746
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
695
|
+
start: ((provider: string, redirectUrl?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.ResponseData>>) & {
|
|
696
|
+
facebook: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
697
|
+
github: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
698
|
+
google: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
699
|
+
microsoft: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
700
|
+
gitlab: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
701
|
+
apple: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
702
|
+
discord: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
703
|
+
linkedin: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
704
|
+
slack: (redirectURL?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
747
705
|
};
|
|
748
706
|
exchange: (code: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
749
707
|
};
|
|
750
708
|
saml: {
|
|
751
|
-
start: (tenantIdOrEmail: string, redirectUrl?: string, loginOptions?:
|
|
752
|
-
stepup?: boolean;
|
|
753
|
-
mfa?: boolean;
|
|
754
|
-
customClaims?: Record<string, any>;
|
|
755
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
709
|
+
start: (tenantIdOrEmail: string, redirectUrl?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.URLResponse>>;
|
|
756
710
|
exchange: (code: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
757
711
|
};
|
|
758
712
|
totp: {
|
|
759
713
|
signUp: (loginId: string, user?: {
|
|
760
714
|
email?: string;
|
|
761
715
|
name?: string;
|
|
716
|
+
givenName?: string;
|
|
717
|
+
middleName?: string;
|
|
718
|
+
familyName?: string;
|
|
762
719
|
phone?: string;
|
|
763
720
|
}) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.TOTPResponse>>;
|
|
764
|
-
verify: (loginId: string, code: string, loginOptions?:
|
|
765
|
-
stepup?: boolean;
|
|
766
|
-
mfa?: boolean;
|
|
767
|
-
customClaims?: Record<string, any>;
|
|
768
|
-
}, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
721
|
+
verify: (loginId: string, code: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
769
722
|
update: (loginId: string, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.TOTPResponse>>;
|
|
770
723
|
};
|
|
771
724
|
password: {
|
|
772
725
|
signUp: (loginId: string, password: string, user?: {
|
|
773
726
|
email?: string;
|
|
774
727
|
name?: string;
|
|
728
|
+
givenName?: string;
|
|
729
|
+
middleName?: string;
|
|
730
|
+
familyName?: string;
|
|
775
731
|
phone?: string;
|
|
776
732
|
}) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
777
733
|
signIn: (loginId: string, password: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
@@ -882,6 +838,8 @@ interface DescopeProps {
|
|
|
882
838
|
text: string;
|
|
883
839
|
type: string;
|
|
884
840
|
}) => string;
|
|
841
|
+
form?: Record<string, any>;
|
|
842
|
+
client?: Record<string, any>;
|
|
885
843
|
}
|
|
886
844
|
|
|
887
845
|
type DefaultFlowProps = Omit<DescopeProps, 'flowId'>;
|