@descope/react-sdk 2.18.2 → 2.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../hooks/Context.js"),s=require("../../utils.js"),r=require("./useSdk.js");function n(e){return e&&e.__esModule?e:{default:e}}var o=n(e);exports.default=({projectId:n,baseUrl:a="",baseStaticUrl:i="",baseCdnUrl:u="",sessionTokenViaCookie:c=!1,persistTokens:d=!0,autoRefresh:f=!0,oidcConfig:l,storeLastAuthenticatedUser:h=!0,keepLastAuthenticatedUserAfterLogout:k=!1,refreshCookieName:U="",getExternalToken:C,children:g})=>{const[S,L]=e.useState(),[A,p]=e.useState(),[b,j]=e.useState(!1),[T,m]=e.useState(!1),[v,I]=e.useState(!1),[x,E]=e.useState(!!l),R=e.useRef(!1),q=r.default({projectId:n,baseUrl:a,persistTokens:d,autoRefresh:f,sessionTokenViaCookie:c,oidcConfig:l,storeLastAuthenticatedUser:h,keepLastAuthenticatedUserAfterLogout:k,refreshCookieName:U,getExternalToken:C});e.useEffect((()=>{if(q){const e=q.onSessionTokenChange(p),t=q.onUserChange(L),s=q.onIsAuthenticatedChange(j);return()=>{e(),t(),s()}}}),[q]);const N=e.useRef(!1),V=e.useRef(!1);e.useEffect((()=>{q&&l&&!R.current&&(R.current=!0,q.oidc.finishLoginIfNeed().finally((()=>{E(!1),N.current=!0})))}),[]);const _=e.useCallback((()=>{N.current||(N.current=!0,I(!0),s.withValidation(null==q?void 0:q.refresh)().then((()=>{I(!1)})))}),[q]),M=e.useCallback((()=>{V.current||(V.current=!0,m(!0),s.withValidation(q.me)().then((()=>{m(!1)})))}),[q]),w=e.useMemo((()=>({fetchUser:M,user:S,isUserLoading:T,isUserFetched:V.current,fetchSession:_,session:A,isAuthenticated:b,isSessionLoading:v,isOidcLoading:x,isSessionFetched:N.current,projectId:n,baseUrl:a,baseStaticUrl:i,baseCdnUrl:u,storeLastAuthenticatedUser:h,keepLastAuthenticatedUserAfterLogout:k,refreshCookieName:U,setUser:L,setSession:p,setIsAuthenticated:j,sdk:q})),[M,S,T,V.current,_,A,b,v,x,N.current,n,a,i,u,k,U,L,p,j,q]);return o.default.createElement(t.default.Provider,{value:w},g)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../hooks/Context.js"),s=require("../../utils.js"),r=require("./useSdk.js");function n(e){return e&&e.__esModule?e:{default:e}}var o=n(e);exports.default=({projectId:n,baseUrl:i="",baseStaticUrl:a="",baseCdnUrl:u="",sessionTokenViaCookie:c=!1,persistTokens:d=!0,autoRefresh:f=!0,oidcConfig:l,storeLastAuthenticatedUser:h=!0,keepLastAuthenticatedUserAfterLogout:k=!1,refreshCookieName:U="",getExternalToken:C,children:g})=>{const[S,L]=e.useState(),[A,p]=e.useState(),[b,j]=e.useState(!1),[v,T]=e.useState(!1),[m,I]=e.useState(!1),[x,E]=e.useState(!!l),R=e.useRef(!1),q=r.default({projectId:n,baseUrl:i,persistTokens:d,autoRefresh:f,sessionTokenViaCookie:c,oidcConfig:l,storeLastAuthenticatedUser:h,keepLastAuthenticatedUserAfterLogout:k,refreshCookieName:U,getExternalToken:C});e.useEffect((()=>{if(q){const e=q.onSessionTokenChange(p),t=q.onUserChange(L),s=q.onIsAuthenticatedChange(j);return()=>{e(),t(),s()}}}),[q]);const N=e.useRef(!1),V=e.useRef(!1);e.useEffect((()=>{q&&l&&!R.current&&(R.current=!0,q.oidc.finishLoginIfNeed().finally((()=>{E(!1),N.current=!0})))}),[]);const _=e.useCallback((()=>{N.current||(N.current=!0,I(!0),s.withValidation(null==q?void 0:q.refresh)(void 0,!0).then((()=>{I(!1)})))}),[q]),M=e.useCallback((()=>{V.current||(V.current=!0,T(!0),s.withValidation(q.me)().then((()=>{T(!1)})))}),[q]),w=e.useMemo((()=>({fetchUser:M,user:S,isUserLoading:v,isUserFetched:V.current,fetchSession:_,session:A,isAuthenticated:b,isSessionLoading:m,isOidcLoading:x,isSessionFetched:N.current,projectId:n,baseUrl:i,baseStaticUrl:a,baseCdnUrl:u,storeLastAuthenticatedUser:h,keepLastAuthenticatedUserAfterLogout:k,refreshCookieName:U,setUser:L,setSession:p,setIsAuthenticated:j,sdk:q})),[M,S,v,V.current,_,A,b,m,x,N.current,n,i,a,u,k,U,L,p,j,q]);return o.default.createElement(t.default.Provider,{value:w},g)};
2
2
  //# sourceMappingURL=AuthProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AuthProvider.js","sources":["../../../../src/components/AuthProvider/AuthProvider.tsx"],"sourcesContent":["import React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { CookieConfig, OidcConfig } from '@descope/web-js-sdk';\nimport Context from '../../hooks/Context';\nimport { IContext, User } from '../../types';\nimport { withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ninterface IAuthProviderProps {\n projectId: string;\n baseUrl?: string;\n // allows to override the base URL that is used to fetch static files\n baseStaticUrl?: string;\n // allows to override the base URL that is used to fetch external script files\n baseCdnUrl?: string;\n // Default is true. If true, tokens will be stored on local storage and can accessed with getToken function\n persistTokens?: boolean;\n // Default is true. If true, the SDK will automatically refresh the session token when it is about to expire\n autoRefresh?: boolean;\n // If true, session token (jwt) will be stored on cookie. Otherwise, the session token will be\n // stored on local storage and can accessed with getSessionToken function\n // Use this option if session token will stay small (less than 1k)\n // NOTE: Session token can grow, especially in cases of using authorization, or adding custom claims\n sessionTokenViaCookie?: CookieConfig;\n // If truthy he SDK refresh and logout functions will use the OIDC client\n // Accepts boolean or OIDC configuration\n oidcConfig?: OidcConfig;\n // Default is true. If true, last authenticated user will be stored on local storage and can accessed with getUser function\n storeLastAuthenticatedUser?: boolean;\n // If true, last authenticated user will not be removed after logout\n keepLastAuthenticatedUserAfterLogout?: boolean;\n // Use this option if the authentication is done via cookie, and configured with a different name\n // Currently, this is done using Descope Flows\n refreshCookieName?: string;\n // Function to get external token, for seamless migration from external system\n getExternalToken?: () => Promise<string>;\n children?: React.ReactNode;\n}\n\nconst AuthProvider: FC<IAuthProviderProps> = ({\n projectId,\n baseUrl = '',\n baseStaticUrl = '',\n baseCdnUrl = '',\n sessionTokenViaCookie = false,\n persistTokens = true,\n autoRefresh = true,\n oidcConfig = undefined,\n storeLastAuthenticatedUser = true,\n keepLastAuthenticatedUserAfterLogout = false,\n refreshCookieName = '',\n getExternalToken = undefined,\n children = undefined,\n}) => {\n const [user, setUser] = useState<User>();\n const [session, setSession] = useState<string>();\n const [isAuthenticated, setIsAuthenticated] = useState(false);\n\n const [isUserLoading, setIsUserLoading] = useState(false);\n const [isSessionLoading, setIsSessionLoading] = useState(false);\n\n // if oidc config is enabled, we attempt to finish the login, so we start as loading\n const [isOidcLoading, setIsOidcLoading] = useState(!!oidcConfig);\n const isOidcFinishedLogin = useRef(false);\n\n const sdk = useSdk({\n projectId,\n baseUrl,\n persistTokens,\n autoRefresh,\n sessionTokenViaCookie,\n oidcConfig,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n getExternalToken,\n });\n\n useEffect(() => {\n if (sdk) {\n const unsubscribeSessionToken = sdk.onSessionTokenChange(setSession);\n const unsubscribeUser = sdk.onUserChange(setUser);\n const unsubscribeIsAuthenticated =\n sdk.onIsAuthenticatedChange(setIsAuthenticated);\n\n return () => {\n unsubscribeSessionToken();\n unsubscribeUser();\n unsubscribeIsAuthenticated();\n };\n }\n return undefined;\n }, [sdk]);\n\n const isSessionFetched = useRef(false);\n const isUserFetched = useRef(false);\n\n // if oidc config is enabled, and we have oidc params in the url\n // we will finish the login (this should run only once)\n useEffect(() => {\n if (sdk && oidcConfig && !isOidcFinishedLogin.current) {\n isOidcFinishedLogin.current = true;\n sdk.oidc.finishLoginIfNeed().finally(() => {\n setIsOidcLoading(false);\n // We want that the session will fetched only once\n isSessionFetched.current = true;\n });\n }\n }, []);\n\n const fetchSession = useCallback(() => {\n // We want that the session will fetched only once\n if (isSessionFetched.current) return;\n isSessionFetched.current = true;\n\n setIsSessionLoading(true);\n withValidation(sdk?.refresh)().then(() => {\n setIsSessionLoading(false);\n });\n }, [sdk]);\n\n const fetchUser = useCallback(() => {\n // We want that the user will fetched only once\n if (isUserFetched.current) return;\n isUserFetched.current = true;\n\n setIsUserLoading(true);\n withValidation(sdk.me)().then(() => {\n setIsUserLoading(false);\n });\n }, [sdk]);\n\n const value = useMemo<IContext>(\n () => ({\n fetchUser,\n user,\n isUserLoading,\n isUserFetched: isUserFetched.current,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetched: isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n setUser,\n setSession,\n setIsAuthenticated,\n sdk,\n }),\n [\n fetchUser,\n user,\n isUserLoading,\n isUserFetched.current,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n setUser,\n setSession,\n setIsAuthenticated,\n sdk,\n ],\n );\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport default AuthProvider;\n"],"names":["projectId","baseUrl","baseStaticUrl","baseCdnUrl","sessionTokenViaCookie","persistTokens","autoRefresh","oidcConfig","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","refreshCookieName","getExternalToken","children","user","setUser","useState","session","setSession","isAuthenticated","setIsAuthenticated","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","isOidcLoading","setIsOidcLoading","isOidcFinishedLogin","useRef","sdk","useSdk","useEffect","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","unsubscribeIsAuthenticated","onIsAuthenticatedChange","isSessionFetched","isUserFetched","current","oidc","finishLoginIfNeed","finally","fetchSession","useCallback","withValidation","refresh","then","fetchUser","me","value","useMemo","React","default","createElement","Context","Provider"],"mappings":"kQA6C6C,EAC3CA,YACAC,UAAU,GACVC,gBAAgB,GAChBC,aAAa,GACbC,yBAAwB,EACxBC,iBAAgB,EAChBC,eAAc,EACdC,aACAC,8BAA6B,EAC7BC,wCAAuC,EACvCC,oBAAoB,GACpBC,mBACAC,eAEA,MAAOC,EAAMC,GAAWC,EAAQA,YACzBC,EAASC,GAAcF,EAAQA,YAC/BG,EAAiBC,GAAsBJ,EAAQA,UAAC,IAEhDK,EAAeC,GAAoBN,EAAQA,UAAC,IAC5CO,EAAkBC,GAAuBR,EAAQA,UAAC,IAGlDS,EAAeC,GAAoBV,EAAAA,WAAWR,GAC/CmB,EAAsBC,UAAO,GAE7BC,EAAMC,EAAAA,QAAO,CACjB7B,YACAC,UACAI,gBACAC,cACAF,wBACAG,aACAC,6BACAC,uCACAC,oBACAC,qBAGFmB,EAAAA,WAAU,KACR,GAAIF,EAAK,CACP,MAAMG,EAA0BH,EAAII,qBAAqBf,GACnDgB,EAAkBL,EAAIM,aAAapB,GACnCqB,EACJP,EAAIQ,wBAAwBjB,GAE9B,MAAO,KACLY,IACAE,IACAE,GAA4B,CAE/B,CACe,GACf,CAACP,IAEJ,MAAMS,EAAmBV,UAAO,GAC1BW,EAAgBX,UAAO,GAI7BG,EAAAA,WAAU,KACJF,GAAOrB,IAAemB,EAAoBa,UAC5Cb,EAAoBa,SAAU,EAC9BX,EAAIY,KAAKC,oBAAoBC,SAAQ,KACnCjB,GAAiB,GAEjBY,EAAiBE,SAAU,CAAI,IAElC,GACA,IAEH,MAAMI,EAAeC,EAAAA,aAAY,KAE3BP,EAAiBE,UACrBF,EAAiBE,SAAU,EAE3BhB,GAAoB,GACpBsB,EAAAA,eAAejB,eAAAA,EAAKkB,QAApBD,GAA+BE,MAAK,KAClCxB,GAAoB,EAAM,IAC1B,GACD,CAACK,IAEEoB,EAAYJ,EAAAA,aAAY,KAExBN,EAAcC,UAClBD,EAAcC,SAAU,EAExBlB,GAAiB,GACjBwB,EAAAA,eAAejB,EAAIqB,GAAnBJ,GAAyBE,MAAK,KAC5B1B,GAAiB,EAAM,IACvB,GACD,CAACO,IAEEsB,EAAQC,EAAAA,SACZ,KAAO,CACLH,YACAnC,OACAO,gBACAkB,cAAeA,EAAcC,QAC7BI,eACA3B,UACAE,kBACAI,mBACAE,gBACAa,iBAAkBA,EAAiBE,QACnCvC,YACAC,UACAC,gBACAC,aACAK,6BACAC,uCACAC,oBACAI,UACAG,aACAE,qBACAS,SAEF,CACEoB,EACAnC,EACAO,EACAkB,EAAcC,QACdI,EACA3B,EACAE,EACAI,EACAE,EACAa,EAAiBE,QACjBvC,EACAC,EACAC,EACAC,EACAM,EACAC,EACAI,EACAG,EACAE,EACAS,IAGJ,OAAOwB,EAAAC,QAAAC,cAACC,UAAQC,SAAQ,CAACN,MAAOA,GAAQtC,EAA4B"}
1
+ {"version":3,"file":"AuthProvider.js","sources":["../../../../src/components/AuthProvider/AuthProvider.tsx"],"sourcesContent":["import React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { CookieConfig, OidcConfig } from '@descope/web-js-sdk';\nimport Context from '../../hooks/Context';\nimport { IContext, User } from '../../types';\nimport { withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ninterface IAuthProviderProps {\n projectId: string;\n baseUrl?: string;\n // allows to override the base URL that is used to fetch static files\n baseStaticUrl?: string;\n // allows to override the base URL that is used to fetch external script files\n baseCdnUrl?: string;\n // Default is true. If true, tokens will be stored on local storage and can accessed with getToken function\n persistTokens?: boolean;\n // Default is true. If true, the SDK will automatically refresh the session token when it is about to expire\n autoRefresh?: boolean;\n // If true, session token (jwt) will be stored on cookie. Otherwise, the session token will be\n // stored on local storage and can accessed with getSessionToken function\n // Use this option if session token will stay small (less than 1k)\n // NOTE: Session token can grow, especially in cases of using authorization, or adding custom claims\n sessionTokenViaCookie?: CookieConfig;\n // If truthy he SDK refresh and logout functions will use the OIDC client\n // Accepts boolean or OIDC configuration\n oidcConfig?: OidcConfig;\n // Default is true. If true, last authenticated user will be stored on local storage and can accessed with getUser function\n storeLastAuthenticatedUser?: boolean;\n // If true, last authenticated user will not be removed after logout\n keepLastAuthenticatedUserAfterLogout?: boolean;\n // Use this option if the authentication is done via cookie, and configured with a different name\n // Currently, this is done using Descope Flows\n refreshCookieName?: string;\n // Function to get external token, for seamless migration from external system\n getExternalToken?: () => Promise<string>;\n children?: React.ReactNode;\n}\n\nconst AuthProvider: FC<IAuthProviderProps> = ({\n projectId,\n baseUrl = '',\n baseStaticUrl = '',\n baseCdnUrl = '',\n sessionTokenViaCookie = false,\n persistTokens = true,\n autoRefresh = true,\n oidcConfig = undefined,\n storeLastAuthenticatedUser = true,\n keepLastAuthenticatedUserAfterLogout = false,\n refreshCookieName = '',\n getExternalToken = undefined,\n children = undefined,\n}) => {\n const [user, setUser] = useState<User>();\n const [session, setSession] = useState<string>();\n const [isAuthenticated, setIsAuthenticated] = useState(false);\n\n const [isUserLoading, setIsUserLoading] = useState(false);\n const [isSessionLoading, setIsSessionLoading] = useState(false);\n\n // if oidc config is enabled, we attempt to finish the login, so we start as loading\n const [isOidcLoading, setIsOidcLoading] = useState(!!oidcConfig);\n const isOidcFinishedLogin = useRef(false);\n\n const sdk = useSdk({\n projectId,\n baseUrl,\n persistTokens,\n autoRefresh,\n sessionTokenViaCookie,\n oidcConfig,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n getExternalToken,\n });\n\n useEffect(() => {\n if (sdk) {\n const unsubscribeSessionToken = sdk.onSessionTokenChange(setSession);\n const unsubscribeUser = sdk.onUserChange(setUser);\n const unsubscribeIsAuthenticated =\n sdk.onIsAuthenticatedChange(setIsAuthenticated);\n\n return () => {\n unsubscribeSessionToken();\n unsubscribeUser();\n unsubscribeIsAuthenticated();\n };\n }\n return undefined;\n }, [sdk]);\n\n const isSessionFetched = useRef(false);\n const isUserFetched = useRef(false);\n\n // if oidc config is enabled, and we have oidc params in the url\n // we will finish the login (this should run only once)\n useEffect(() => {\n if (sdk && oidcConfig && !isOidcFinishedLogin.current) {\n isOidcFinishedLogin.current = true;\n sdk.oidc.finishLoginIfNeed().finally(() => {\n setIsOidcLoading(false);\n // We want that the session will fetched only once\n isSessionFetched.current = true;\n });\n }\n }, []);\n\n const fetchSession = useCallback(() => {\n // We want that the session will fetched only once\n if (isSessionFetched.current) return;\n isSessionFetched.current = true;\n\n setIsSessionLoading(true);\n withValidation(sdk?.refresh)(undefined, true).then(() => {\n setIsSessionLoading(false);\n });\n }, [sdk]);\n\n const fetchUser = useCallback(() => {\n // We want that the user will fetched only once\n if (isUserFetched.current) return;\n isUserFetched.current = true;\n\n setIsUserLoading(true);\n withValidation(sdk.me)().then(() => {\n setIsUserLoading(false);\n });\n }, [sdk]);\n\n const value = useMemo<IContext>(\n () => ({\n fetchUser,\n user,\n isUserLoading,\n isUserFetched: isUserFetched.current,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetched: isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n setUser,\n setSession,\n setIsAuthenticated,\n sdk,\n }),\n [\n fetchUser,\n user,\n isUserLoading,\n isUserFetched.current,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n setUser,\n setSession,\n setIsAuthenticated,\n sdk,\n ],\n );\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport default AuthProvider;\n"],"names":["projectId","baseUrl","baseStaticUrl","baseCdnUrl","sessionTokenViaCookie","persistTokens","autoRefresh","oidcConfig","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","refreshCookieName","getExternalToken","children","user","setUser","useState","session","setSession","isAuthenticated","setIsAuthenticated","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","isOidcLoading","setIsOidcLoading","isOidcFinishedLogin","useRef","sdk","useSdk","useEffect","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","unsubscribeIsAuthenticated","onIsAuthenticatedChange","isSessionFetched","isUserFetched","current","oidc","finishLoginIfNeed","finally","fetchSession","useCallback","withValidation","refresh","undefined","then","fetchUser","me","value","useMemo","React","default","createElement","Context","Provider"],"mappings":"kQA6C6C,EAC3CA,YACAC,UAAU,GACVC,gBAAgB,GAChBC,aAAa,GACbC,yBAAwB,EACxBC,iBAAgB,EAChBC,eAAc,EACdC,aACAC,8BAA6B,EAC7BC,wCAAuC,EACvCC,oBAAoB,GACpBC,mBACAC,eAEA,MAAOC,EAAMC,GAAWC,EAAQA,YACzBC,EAASC,GAAcF,EAAQA,YAC/BG,EAAiBC,GAAsBJ,EAAQA,UAAC,IAEhDK,EAAeC,GAAoBN,EAAQA,UAAC,IAC5CO,EAAkBC,GAAuBR,EAAQA,UAAC,IAGlDS,EAAeC,GAAoBV,EAAAA,WAAWR,GAC/CmB,EAAsBC,UAAO,GAE7BC,EAAMC,EAAAA,QAAO,CACjB7B,YACAC,UACAI,gBACAC,cACAF,wBACAG,aACAC,6BACAC,uCACAC,oBACAC,qBAGFmB,EAAAA,WAAU,KACR,GAAIF,EAAK,CACP,MAAMG,EAA0BH,EAAII,qBAAqBf,GACnDgB,EAAkBL,EAAIM,aAAapB,GACnCqB,EACJP,EAAIQ,wBAAwBjB,GAE9B,MAAO,KACLY,IACAE,IACAE,GAA4B,CAE/B,CACe,GACf,CAACP,IAEJ,MAAMS,EAAmBV,UAAO,GAC1BW,EAAgBX,UAAO,GAI7BG,EAAAA,WAAU,KACJF,GAAOrB,IAAemB,EAAoBa,UAC5Cb,EAAoBa,SAAU,EAC9BX,EAAIY,KAAKC,oBAAoBC,SAAQ,KACnCjB,GAAiB,GAEjBY,EAAiBE,SAAU,CAAI,IAElC,GACA,IAEH,MAAMI,EAAeC,EAAAA,aAAY,KAE3BP,EAAiBE,UACrBF,EAAiBE,SAAU,EAE3BhB,GAAoB,GACpBsB,EAAAA,eAAejB,aAAA,EAAAA,EAAKkB,QAApBD,MAA6BE,GAAW,GAAMC,MAAK,KACjDzB,GAAoB,EAAM,IAC1B,GACD,CAACK,IAEEqB,EAAYL,EAAAA,aAAY,KAExBN,EAAcC,UAClBD,EAAcC,SAAU,EAExBlB,GAAiB,GACjBwB,EAAAA,eAAejB,EAAIsB,GAAnBL,GAAyBG,MAAK,KAC5B3B,GAAiB,EAAM,IACvB,GACD,CAACO,IAEEuB,EAAQC,EAAAA,SACZ,KAAO,CACLH,YACApC,OACAO,gBACAkB,cAAeA,EAAcC,QAC7BI,eACA3B,UACAE,kBACAI,mBACAE,gBACAa,iBAAkBA,EAAiBE,QACnCvC,YACAC,UACAC,gBACAC,aACAK,6BACAC,uCACAC,oBACAI,UACAG,aACAE,qBACAS,SAEF,CACEqB,EACApC,EACAO,EACAkB,EAAcC,QACdI,EACA3B,EACAE,EACAI,EACAE,EACAa,EAAiBE,QACjBvC,EACAC,EACAC,EACAC,EACAM,EACAC,EACAI,EACAG,EACAE,EACAS,IAGJ,OAAOyB,EAAAC,QAAAC,cAACC,UAAQC,SAAQ,CAACN,MAAOA,GAAQvC,EAA4B"}
@@ -1,2 +1,2 @@
1
- "use strict";const e="undefined"!=typeof window;exports.IS_BROWSER=e,exports.baseHeaders={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.18.2"};
1
+ "use strict";const e="undefined"!=typeof window;exports.IS_BROWSER=e,exports.baseHeaders={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.19.0"};
2
2
  //# sourceMappingURL=constants.js.map
@@ -1,2 +1,2 @@
1
- import e,{useState as t,useRef as s,useEffect as r,useCallback as o,useMemo as n}from"react";import i from"../../hooks/Context.js";import{withValidation as a}from"../../utils.js";import c from"./useSdk.js";const u=({projectId:u,baseUrl:d="",baseStaticUrl:h="",baseCdnUrl:f="",sessionTokenViaCookie:k=!1,persistTokens:l=!0,autoRefresh:U=!0,oidcConfig:g,storeLastAuthenticatedUser:m=!0,keepLastAuthenticatedUserAfterLogout:p=!1,refreshCookieName:C="",getExternalToken:L,children:A})=>{const[S,b]=t(),[T,j]=t(),[I,x]=t(!1),[N,v]=t(!1),[E,F]=t(!1),[R,V]=t(!!g),y=s(!1),O=c({projectId:u,baseUrl:d,persistTokens:l,autoRefresh:U,sessionTokenViaCookie:k,oidcConfig:g,storeLastAuthenticatedUser:m,keepLastAuthenticatedUserAfterLogout:p,refreshCookieName:C,getExternalToken:L});r((()=>{if(O){const e=O.onSessionTokenChange(j),t=O.onUserChange(b),s=O.onIsAuthenticatedChange(x);return()=>{e(),t(),s()}}}),[O]);const P=s(!1),q=s(!1);r((()=>{O&&g&&!y.current&&(y.current=!0,O.oidc.finishLoginIfNeed().finally((()=>{V(!1),P.current=!0})))}),[]);const w=o((()=>{P.current||(P.current=!0,F(!0),a(null==O?void 0:O.refresh)().then((()=>{F(!1)})))}),[O]),z=o((()=>{q.current||(q.current=!0,v(!0),a(O.me)().then((()=>{v(!1)})))}),[O]),B=n((()=>({fetchUser:z,user:S,isUserLoading:N,isUserFetched:q.current,fetchSession:w,session:T,isAuthenticated:I,isSessionLoading:E,isOidcLoading:R,isSessionFetched:P.current,projectId:u,baseUrl:d,baseStaticUrl:h,baseCdnUrl:f,storeLastAuthenticatedUser:m,keepLastAuthenticatedUserAfterLogout:p,refreshCookieName:C,setUser:b,setSession:j,setIsAuthenticated:x,sdk:O})),[z,S,N,q.current,w,T,I,E,R,P.current,u,d,h,f,p,C,b,j,x,O]);return e.createElement(i.Provider,{value:B},A)};export{u as default};
1
+ import e,{useState as t,useRef as s,useEffect as r,useCallback as o,useMemo as n}from"react";import i from"../../hooks/Context.js";import{withValidation as a}from"../../utils.js";import c from"./useSdk.js";const u=({projectId:u,baseUrl:d="",baseStaticUrl:h="",baseCdnUrl:f="",sessionTokenViaCookie:k=!1,persistTokens:l=!0,autoRefresh:U=!0,oidcConfig:g,storeLastAuthenticatedUser:m=!0,keepLastAuthenticatedUserAfterLogout:p=!1,refreshCookieName:C="",getExternalToken:L,children:A})=>{const[S,b]=t(),[T,j]=t(),[I,v]=t(!1),[x,N]=t(!1),[E,F]=t(!1),[R,V]=t(!!g),y=s(!1),O=c({projectId:u,baseUrl:d,persistTokens:l,autoRefresh:U,sessionTokenViaCookie:k,oidcConfig:g,storeLastAuthenticatedUser:m,keepLastAuthenticatedUserAfterLogout:p,refreshCookieName:C,getExternalToken:L});r((()=>{if(O){const e=O.onSessionTokenChange(j),t=O.onUserChange(b),s=O.onIsAuthenticatedChange(v);return()=>{e(),t(),s()}}}),[O]);const P=s(!1),q=s(!1);r((()=>{O&&g&&!y.current&&(y.current=!0,O.oidc.finishLoginIfNeed().finally((()=>{V(!1),P.current=!0})))}),[]);const w=o((()=>{P.current||(P.current=!0,F(!0),a(null==O?void 0:O.refresh)(void 0,!0).then((()=>{F(!1)})))}),[O]),z=o((()=>{q.current||(q.current=!0,N(!0),a(O.me)().then((()=>{N(!1)})))}),[O]),B=n((()=>({fetchUser:z,user:S,isUserLoading:x,isUserFetched:q.current,fetchSession:w,session:T,isAuthenticated:I,isSessionLoading:E,isOidcLoading:R,isSessionFetched:P.current,projectId:u,baseUrl:d,baseStaticUrl:h,baseCdnUrl:f,storeLastAuthenticatedUser:m,keepLastAuthenticatedUserAfterLogout:p,refreshCookieName:C,setUser:b,setSession:j,setIsAuthenticated:v,sdk:O})),[z,S,x,q.current,w,T,I,E,R,P.current,u,d,h,f,p,C,b,j,v,O]);return e.createElement(i.Provider,{value:B},A)};export{u as default};
2
2
  //# sourceMappingURL=AuthProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AuthProvider.js","sources":["../../../../src/components/AuthProvider/AuthProvider.tsx"],"sourcesContent":["import React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { CookieConfig, OidcConfig } from '@descope/web-js-sdk';\nimport Context from '../../hooks/Context';\nimport { IContext, User } from '../../types';\nimport { withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ninterface IAuthProviderProps {\n projectId: string;\n baseUrl?: string;\n // allows to override the base URL that is used to fetch static files\n baseStaticUrl?: string;\n // allows to override the base URL that is used to fetch external script files\n baseCdnUrl?: string;\n // Default is true. If true, tokens will be stored on local storage and can accessed with getToken function\n persistTokens?: boolean;\n // Default is true. If true, the SDK will automatically refresh the session token when it is about to expire\n autoRefresh?: boolean;\n // If true, session token (jwt) will be stored on cookie. Otherwise, the session token will be\n // stored on local storage and can accessed with getSessionToken function\n // Use this option if session token will stay small (less than 1k)\n // NOTE: Session token can grow, especially in cases of using authorization, or adding custom claims\n sessionTokenViaCookie?: CookieConfig;\n // If truthy he SDK refresh and logout functions will use the OIDC client\n // Accepts boolean or OIDC configuration\n oidcConfig?: OidcConfig;\n // Default is true. If true, last authenticated user will be stored on local storage and can accessed with getUser function\n storeLastAuthenticatedUser?: boolean;\n // If true, last authenticated user will not be removed after logout\n keepLastAuthenticatedUserAfterLogout?: boolean;\n // Use this option if the authentication is done via cookie, and configured with a different name\n // Currently, this is done using Descope Flows\n refreshCookieName?: string;\n // Function to get external token, for seamless migration from external system\n getExternalToken?: () => Promise<string>;\n children?: React.ReactNode;\n}\n\nconst AuthProvider: FC<IAuthProviderProps> = ({\n projectId,\n baseUrl = '',\n baseStaticUrl = '',\n baseCdnUrl = '',\n sessionTokenViaCookie = false,\n persistTokens = true,\n autoRefresh = true,\n oidcConfig = undefined,\n storeLastAuthenticatedUser = true,\n keepLastAuthenticatedUserAfterLogout = false,\n refreshCookieName = '',\n getExternalToken = undefined,\n children = undefined,\n}) => {\n const [user, setUser] = useState<User>();\n const [session, setSession] = useState<string>();\n const [isAuthenticated, setIsAuthenticated] = useState(false);\n\n const [isUserLoading, setIsUserLoading] = useState(false);\n const [isSessionLoading, setIsSessionLoading] = useState(false);\n\n // if oidc config is enabled, we attempt to finish the login, so we start as loading\n const [isOidcLoading, setIsOidcLoading] = useState(!!oidcConfig);\n const isOidcFinishedLogin = useRef(false);\n\n const sdk = useSdk({\n projectId,\n baseUrl,\n persistTokens,\n autoRefresh,\n sessionTokenViaCookie,\n oidcConfig,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n getExternalToken,\n });\n\n useEffect(() => {\n if (sdk) {\n const unsubscribeSessionToken = sdk.onSessionTokenChange(setSession);\n const unsubscribeUser = sdk.onUserChange(setUser);\n const unsubscribeIsAuthenticated =\n sdk.onIsAuthenticatedChange(setIsAuthenticated);\n\n return () => {\n unsubscribeSessionToken();\n unsubscribeUser();\n unsubscribeIsAuthenticated();\n };\n }\n return undefined;\n }, [sdk]);\n\n const isSessionFetched = useRef(false);\n const isUserFetched = useRef(false);\n\n // if oidc config is enabled, and we have oidc params in the url\n // we will finish the login (this should run only once)\n useEffect(() => {\n if (sdk && oidcConfig && !isOidcFinishedLogin.current) {\n isOidcFinishedLogin.current = true;\n sdk.oidc.finishLoginIfNeed().finally(() => {\n setIsOidcLoading(false);\n // We want that the session will fetched only once\n isSessionFetched.current = true;\n });\n }\n }, []);\n\n const fetchSession = useCallback(() => {\n // We want that the session will fetched only once\n if (isSessionFetched.current) return;\n isSessionFetched.current = true;\n\n setIsSessionLoading(true);\n withValidation(sdk?.refresh)().then(() => {\n setIsSessionLoading(false);\n });\n }, [sdk]);\n\n const fetchUser = useCallback(() => {\n // We want that the user will fetched only once\n if (isUserFetched.current) return;\n isUserFetched.current = true;\n\n setIsUserLoading(true);\n withValidation(sdk.me)().then(() => {\n setIsUserLoading(false);\n });\n }, [sdk]);\n\n const value = useMemo<IContext>(\n () => ({\n fetchUser,\n user,\n isUserLoading,\n isUserFetched: isUserFetched.current,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetched: isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n setUser,\n setSession,\n setIsAuthenticated,\n sdk,\n }),\n [\n fetchUser,\n user,\n isUserLoading,\n isUserFetched.current,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n setUser,\n setSession,\n setIsAuthenticated,\n sdk,\n ],\n );\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport default AuthProvider;\n"],"names":["AuthProvider","projectId","baseUrl","baseStaticUrl","baseCdnUrl","sessionTokenViaCookie","persistTokens","autoRefresh","oidcConfig","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","refreshCookieName","getExternalToken","children","user","setUser","useState","session","setSession","isAuthenticated","setIsAuthenticated","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","isOidcLoading","setIsOidcLoading","isOidcFinishedLogin","useRef","sdk","useSdk","useEffect","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","unsubscribeIsAuthenticated","onIsAuthenticatedChange","isSessionFetched","isUserFetched","current","oidc","finishLoginIfNeed","finally","fetchSession","useCallback","withValidation","refresh","then","fetchUser","me","value","useMemo","React","createElement","Context","Provider"],"mappings":"8MA6CM,MAAAA,EAAuC,EAC3CC,YACAC,UAAU,GACVC,gBAAgB,GAChBC,aAAa,GACbC,yBAAwB,EACxBC,iBAAgB,EAChBC,eAAc,EACdC,aACAC,8BAA6B,EAC7BC,wCAAuC,EACvCC,oBAAoB,GACpBC,mBACAC,eAEA,MAAOC,EAAMC,GAAWC,KACjBC,EAASC,GAAcF,KACvBG,EAAiBC,GAAsBJ,GAAS,IAEhDK,EAAeC,GAAoBN,GAAS,IAC5CO,EAAkBC,GAAuBR,GAAS,IAGlDS,EAAeC,GAAoBV,IAAWR,GAC/CmB,EAAsBC,GAAO,GAE7BC,EAAMC,EAAO,CACjB7B,YACAC,UACAI,gBACAC,cACAF,wBACAG,aACAC,6BACAC,uCACAC,oBACAC,qBAGFmB,GAAU,KACR,GAAIF,EAAK,CACP,MAAMG,EAA0BH,EAAII,qBAAqBf,GACnDgB,EAAkBL,EAAIM,aAAapB,GACnCqB,EACJP,EAAIQ,wBAAwBjB,GAE9B,MAAO,KACLY,IACAE,IACAE,GAA4B,CAE/B,CACe,GACf,CAACP,IAEJ,MAAMS,EAAmBV,GAAO,GAC1BW,EAAgBX,GAAO,GAI7BG,GAAU,KACJF,GAAOrB,IAAemB,EAAoBa,UAC5Cb,EAAoBa,SAAU,EAC9BX,EAAIY,KAAKC,oBAAoBC,SAAQ,KACnCjB,GAAiB,GAEjBY,EAAiBE,SAAU,CAAI,IAElC,GACA,IAEH,MAAMI,EAAeC,GAAY,KAE3BP,EAAiBE,UACrBF,EAAiBE,SAAU,EAE3BhB,GAAoB,GACpBsB,EAAejB,eAAAA,EAAKkB,QAApBD,GAA+BE,MAAK,KAClCxB,GAAoB,EAAM,IAC1B,GACD,CAACK,IAEEoB,EAAYJ,GAAY,KAExBN,EAAcC,UAClBD,EAAcC,SAAU,EAExBlB,GAAiB,GACjBwB,EAAejB,EAAIqB,GAAnBJ,GAAyBE,MAAK,KAC5B1B,GAAiB,EAAM,IACvB,GACD,CAACO,IAEEsB,EAAQC,GACZ,KAAO,CACLH,YACAnC,OACAO,gBACAkB,cAAeA,EAAcC,QAC7BI,eACA3B,UACAE,kBACAI,mBACAE,gBACAa,iBAAkBA,EAAiBE,QACnCvC,YACAC,UACAC,gBACAC,aACAK,6BACAC,uCACAC,oBACAI,UACAG,aACAE,qBACAS,SAEF,CACEoB,EACAnC,EACAO,EACAkB,EAAcC,QACdI,EACA3B,EACAE,EACAI,EACAE,EACAa,EAAiBE,QACjBvC,EACAC,EACAC,EACAC,EACAM,EACAC,EACAI,EACAG,EACAE,EACAS,IAGJ,OAAOwB,EAAAC,cAACC,EAAQC,SAAQ,CAACL,MAAOA,GAAQtC,EAA4B"}
1
+ {"version":3,"file":"AuthProvider.js","sources":["../../../../src/components/AuthProvider/AuthProvider.tsx"],"sourcesContent":["import React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { CookieConfig, OidcConfig } from '@descope/web-js-sdk';\nimport Context from '../../hooks/Context';\nimport { IContext, User } from '../../types';\nimport { withValidation } from '../../utils';\nimport useSdk from './useSdk';\n\ninterface IAuthProviderProps {\n projectId: string;\n baseUrl?: string;\n // allows to override the base URL that is used to fetch static files\n baseStaticUrl?: string;\n // allows to override the base URL that is used to fetch external script files\n baseCdnUrl?: string;\n // Default is true. If true, tokens will be stored on local storage and can accessed with getToken function\n persistTokens?: boolean;\n // Default is true. If true, the SDK will automatically refresh the session token when it is about to expire\n autoRefresh?: boolean;\n // If true, session token (jwt) will be stored on cookie. Otherwise, the session token will be\n // stored on local storage and can accessed with getSessionToken function\n // Use this option if session token will stay small (less than 1k)\n // NOTE: Session token can grow, especially in cases of using authorization, or adding custom claims\n sessionTokenViaCookie?: CookieConfig;\n // If truthy he SDK refresh and logout functions will use the OIDC client\n // Accepts boolean or OIDC configuration\n oidcConfig?: OidcConfig;\n // Default is true. If true, last authenticated user will be stored on local storage and can accessed with getUser function\n storeLastAuthenticatedUser?: boolean;\n // If true, last authenticated user will not be removed after logout\n keepLastAuthenticatedUserAfterLogout?: boolean;\n // Use this option if the authentication is done via cookie, and configured with a different name\n // Currently, this is done using Descope Flows\n refreshCookieName?: string;\n // Function to get external token, for seamless migration from external system\n getExternalToken?: () => Promise<string>;\n children?: React.ReactNode;\n}\n\nconst AuthProvider: FC<IAuthProviderProps> = ({\n projectId,\n baseUrl = '',\n baseStaticUrl = '',\n baseCdnUrl = '',\n sessionTokenViaCookie = false,\n persistTokens = true,\n autoRefresh = true,\n oidcConfig = undefined,\n storeLastAuthenticatedUser = true,\n keepLastAuthenticatedUserAfterLogout = false,\n refreshCookieName = '',\n getExternalToken = undefined,\n children = undefined,\n}) => {\n const [user, setUser] = useState<User>();\n const [session, setSession] = useState<string>();\n const [isAuthenticated, setIsAuthenticated] = useState(false);\n\n const [isUserLoading, setIsUserLoading] = useState(false);\n const [isSessionLoading, setIsSessionLoading] = useState(false);\n\n // if oidc config is enabled, we attempt to finish the login, so we start as loading\n const [isOidcLoading, setIsOidcLoading] = useState(!!oidcConfig);\n const isOidcFinishedLogin = useRef(false);\n\n const sdk = useSdk({\n projectId,\n baseUrl,\n persistTokens,\n autoRefresh,\n sessionTokenViaCookie,\n oidcConfig,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n getExternalToken,\n });\n\n useEffect(() => {\n if (sdk) {\n const unsubscribeSessionToken = sdk.onSessionTokenChange(setSession);\n const unsubscribeUser = sdk.onUserChange(setUser);\n const unsubscribeIsAuthenticated =\n sdk.onIsAuthenticatedChange(setIsAuthenticated);\n\n return () => {\n unsubscribeSessionToken();\n unsubscribeUser();\n unsubscribeIsAuthenticated();\n };\n }\n return undefined;\n }, [sdk]);\n\n const isSessionFetched = useRef(false);\n const isUserFetched = useRef(false);\n\n // if oidc config is enabled, and we have oidc params in the url\n // we will finish the login (this should run only once)\n useEffect(() => {\n if (sdk && oidcConfig && !isOidcFinishedLogin.current) {\n isOidcFinishedLogin.current = true;\n sdk.oidc.finishLoginIfNeed().finally(() => {\n setIsOidcLoading(false);\n // We want that the session will fetched only once\n isSessionFetched.current = true;\n });\n }\n }, []);\n\n const fetchSession = useCallback(() => {\n // We want that the session will fetched only once\n if (isSessionFetched.current) return;\n isSessionFetched.current = true;\n\n setIsSessionLoading(true);\n withValidation(sdk?.refresh)(undefined, true).then(() => {\n setIsSessionLoading(false);\n });\n }, [sdk]);\n\n const fetchUser = useCallback(() => {\n // We want that the user will fetched only once\n if (isUserFetched.current) return;\n isUserFetched.current = true;\n\n setIsUserLoading(true);\n withValidation(sdk.me)().then(() => {\n setIsUserLoading(false);\n });\n }, [sdk]);\n\n const value = useMemo<IContext>(\n () => ({\n fetchUser,\n user,\n isUserLoading,\n isUserFetched: isUserFetched.current,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetched: isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n storeLastAuthenticatedUser,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n setUser,\n setSession,\n setIsAuthenticated,\n sdk,\n }),\n [\n fetchUser,\n user,\n isUserLoading,\n isUserFetched.current,\n fetchSession,\n session,\n isAuthenticated,\n isSessionLoading,\n isOidcLoading,\n isSessionFetched.current,\n projectId,\n baseUrl,\n baseStaticUrl,\n baseCdnUrl,\n keepLastAuthenticatedUserAfterLogout,\n refreshCookieName,\n setUser,\n setSession,\n setIsAuthenticated,\n sdk,\n ],\n );\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport default AuthProvider;\n"],"names":["AuthProvider","projectId","baseUrl","baseStaticUrl","baseCdnUrl","sessionTokenViaCookie","persistTokens","autoRefresh","oidcConfig","storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout","refreshCookieName","getExternalToken","children","user","setUser","useState","session","setSession","isAuthenticated","setIsAuthenticated","isUserLoading","setIsUserLoading","isSessionLoading","setIsSessionLoading","isOidcLoading","setIsOidcLoading","isOidcFinishedLogin","useRef","sdk","useSdk","useEffect","unsubscribeSessionToken","onSessionTokenChange","unsubscribeUser","onUserChange","unsubscribeIsAuthenticated","onIsAuthenticatedChange","isSessionFetched","isUserFetched","current","oidc","finishLoginIfNeed","finally","fetchSession","useCallback","withValidation","refresh","undefined","then","fetchUser","me","value","useMemo","React","createElement","Context","Provider"],"mappings":"8MA6CM,MAAAA,EAAuC,EAC3CC,YACAC,UAAU,GACVC,gBAAgB,GAChBC,aAAa,GACbC,yBAAwB,EACxBC,iBAAgB,EAChBC,eAAc,EACdC,aACAC,8BAA6B,EAC7BC,wCAAuC,EACvCC,oBAAoB,GACpBC,mBACAC,eAEA,MAAOC,EAAMC,GAAWC,KACjBC,EAASC,GAAcF,KACvBG,EAAiBC,GAAsBJ,GAAS,IAEhDK,EAAeC,GAAoBN,GAAS,IAC5CO,EAAkBC,GAAuBR,GAAS,IAGlDS,EAAeC,GAAoBV,IAAWR,GAC/CmB,EAAsBC,GAAO,GAE7BC,EAAMC,EAAO,CACjB7B,YACAC,UACAI,gBACAC,cACAF,wBACAG,aACAC,6BACAC,uCACAC,oBACAC,qBAGFmB,GAAU,KACR,GAAIF,EAAK,CACP,MAAMG,EAA0BH,EAAII,qBAAqBf,GACnDgB,EAAkBL,EAAIM,aAAapB,GACnCqB,EACJP,EAAIQ,wBAAwBjB,GAE9B,MAAO,KACLY,IACAE,IACAE,GAA4B,CAE/B,CACe,GACf,CAACP,IAEJ,MAAMS,EAAmBV,GAAO,GAC1BW,EAAgBX,GAAO,GAI7BG,GAAU,KACJF,GAAOrB,IAAemB,EAAoBa,UAC5Cb,EAAoBa,SAAU,EAC9BX,EAAIY,KAAKC,oBAAoBC,SAAQ,KACnCjB,GAAiB,GAEjBY,EAAiBE,SAAU,CAAI,IAElC,GACA,IAEH,MAAMI,EAAeC,GAAY,KAE3BP,EAAiBE,UACrBF,EAAiBE,SAAU,EAE3BhB,GAAoB,GACpBsB,EAAejB,aAAA,EAAAA,EAAKkB,QAApBD,MAA6BE,GAAW,GAAMC,MAAK,KACjDzB,GAAoB,EAAM,IAC1B,GACD,CAACK,IAEEqB,EAAYL,GAAY,KAExBN,EAAcC,UAClBD,EAAcC,SAAU,EAExBlB,GAAiB,GACjBwB,EAAejB,EAAIsB,GAAnBL,GAAyBG,MAAK,KAC5B3B,GAAiB,EAAM,IACvB,GACD,CAACO,IAEEuB,EAAQC,GACZ,KAAO,CACLH,YACApC,OACAO,gBACAkB,cAAeA,EAAcC,QAC7BI,eACA3B,UACAE,kBACAI,mBACAE,gBACAa,iBAAkBA,EAAiBE,QACnCvC,YACAC,UACAC,gBACAC,aACAK,6BACAC,uCACAC,oBACAI,UACAG,aACAE,qBACAS,SAEF,CACEqB,EACApC,EACAO,EACAkB,EAAcC,QACdI,EACA3B,EACAE,EACAI,EACAE,EACAa,EAAiBE,QACjBvC,EACAC,EACAC,EACAC,EACAM,EACAC,EACAI,EACAG,EACAE,EACAS,IAGJ,OAAOyB,EAAAC,cAACC,EAAQC,SAAQ,CAACL,MAAOA,GAAQvC,EAA4B"}
@@ -1,2 +1,2 @@
1
- const e={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.18.2"},d="undefined"!=typeof window;export{d as IS_BROWSER,e as baseHeaders};
1
+ const e={"x-descope-sdk-name":"react","x-descope-sdk-version":"2.19.0"},d="undefined"!=typeof window;export{d as IS_BROWSER,e as baseHeaders};
2
2
  //# sourceMappingURL=constants.js.map
package/dist/index.d.ts CHANGED
@@ -78,7 +78,7 @@ declare const createSdkWrapper: <P extends {
78
78
  preview?: boolean;
79
79
  sessionTokenViaCookie?: _descope_web_js_sdk.CookieConfig;
80
80
  }>(config: P) => ((({
81
- refresh: (token?: string) => Promise<_1.SdkResponse<_1.JWTResponse>>;
81
+ refresh: (token?: string, tryRefresh?: boolean) => Promise<_1.SdkResponse<_1.JWTResponse>>;
82
82
  logout: (token?: string) => Promise<_1.SdkResponse<never>>;
83
83
  flow: {
84
84
  start: (flowId: string, options?: Pick<{
@@ -596,6 +596,8 @@ declare const createSdkWrapper: <P extends {
596
596
  connect: (appId: string, options?: {
597
597
  redirectUrl?: string;
598
598
  scopes?: string[];
599
+ tenantId?: string;
600
+ tenantLevel?: boolean;
599
601
  }, token?: string) => Promise<_1.SdkResponse<_1.URLResponse>>;
600
602
  };
601
603
  saml: {
@@ -706,7 +708,7 @@ declare const createSdkWrapper: <P extends {
706
708
  getCurrentTenant: (token: string) => string;
707
709
  httpClient: _1.HttpClient;
708
710
  } | {
709
- refresh: (token?: string) => Promise<_1.SdkResponse<_1.JWTResponse>>;
711
+ refresh: (token?: string, tryRefresh?: boolean) => Promise<_1.SdkResponse<_1.JWTResponse>>;
710
712
  logout: (token?: string) => Promise<_1.SdkResponse<never>>;
711
713
  flow: {
712
714
  start: (flowId: string, options?: Pick<{
@@ -1224,6 +1226,8 @@ declare const createSdkWrapper: <P extends {
1224
1226
  connect: (appId: string, options?: {
1225
1227
  redirectUrl?: string;
1226
1228
  scopes?: string[];
1229
+ tenantId?: string;
1230
+ tenantLevel?: boolean;
1227
1231
  }, token?: string) => Promise<_1.SdkResponse<_1.URLResponse>>;
1228
1232
  };
1229
1233
  saml: {
@@ -1334,7 +1338,7 @@ declare const createSdkWrapper: <P extends {
1334
1338
  getCurrentTenant: (token: string) => string;
1335
1339
  httpClient: _1.HttpClient;
1336
1340
  } | {
1337
- refresh: (token?: string) => Promise<_1.SdkResponse<_1.JWTResponse>>;
1341
+ refresh: (token?: string, tryRefresh?: boolean) => Promise<_1.SdkResponse<_1.JWTResponse>>;
1338
1342
  logout: (token?: string) => Promise<_1.SdkResponse<never>>;
1339
1343
  flow: {
1340
1344
  start: (flowId: string, options?: Pick<{
@@ -1852,6 +1856,8 @@ declare const createSdkWrapper: <P extends {
1852
1856
  connect: (appId: string, options?: {
1853
1857
  redirectUrl?: string;
1854
1858
  scopes?: string[];
1859
+ tenantId?: string;
1860
+ tenantLevel?: boolean;
1855
1861
  }, token?: string) => Promise<_1.SdkResponse<_1.URLResponse>>;
1856
1862
  };
1857
1863
  saml: {