@descope/web-js-sdk 1.51.5 → 1.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.d.ts +13 -271
- 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/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as oidc_client_ts from 'oidc-client-ts';
|
|
2
2
|
import * as _descope_core_js_sdk from '@descope/core-js-sdk';
|
|
3
|
-
export { JWTResponse, UserResponse } from '@descope/core-js-sdk';
|
|
3
|
+
export { FlowNextOptions, FlowStartOptions, JWTResponse, UserResponse } from '@descope/core-js-sdk';
|
|
4
4
|
|
|
5
5
|
type OidcConfigOptions = {
|
|
6
6
|
applicationId?: string;
|
|
@@ -160,50 +160,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
|
|
|
160
160
|
refresh: (token?: string, tryRefresh?: boolean) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
161
161
|
logout: (token?: string) => Promise<_descope_core_js_sdk.SdkResponse<never>>;
|
|
162
162
|
flow: {
|
|
163
|
-
start: (flowId: string, options?: Pick<{
|
|
164
|
-
redirectUrl?: string;
|
|
165
|
-
location?: string;
|
|
166
|
-
tenant?: string;
|
|
167
|
-
deviceInfo?: {
|
|
168
|
-
webAuthnSupport?: boolean;
|
|
169
|
-
};
|
|
170
|
-
lastAuth?: {
|
|
171
|
-
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
172
|
-
oauthProvider?: string;
|
|
173
|
-
name?: string;
|
|
174
|
-
loginId?: string;
|
|
175
|
-
};
|
|
176
|
-
redirectAuth?: {
|
|
177
|
-
callbackUrl: string;
|
|
178
|
-
codeChallenge: string;
|
|
179
|
-
};
|
|
180
|
-
oidcIdpStateId?: string;
|
|
181
|
-
preview?: boolean;
|
|
182
|
-
samlIdpStateId?: string;
|
|
183
|
-
wsfedIdpStateId?: string;
|
|
184
|
-
samlIdpUsername?: string;
|
|
185
|
-
ssoAppId?: string;
|
|
186
|
-
customAppId?: string;
|
|
187
|
-
thirdPartyAppId?: string;
|
|
188
|
-
oidcLoginHint?: string;
|
|
189
|
-
abTestingKey?: number;
|
|
190
|
-
startOptionsVersion?: number;
|
|
191
|
-
client?: Record<string, any>;
|
|
192
|
-
locale?: string;
|
|
193
|
-
oidcPrompt?: string;
|
|
194
|
-
oidcErrorRedirectUri?: string;
|
|
195
|
-
oidcResource?: string;
|
|
196
|
-
nativeOptions?: {
|
|
197
|
-
platform: "ios" | "android";
|
|
198
|
-
oauthProvider?: string;
|
|
199
|
-
oauthRedirect?: string;
|
|
200
|
-
externalAuthRedirect?: string;
|
|
201
|
-
};
|
|
202
|
-
thirdPartyAppStateId?: string;
|
|
203
|
-
applicationScopes?: string;
|
|
204
|
-
outboundAppId?: string;
|
|
205
|
-
outboundAppScopes?: string[];
|
|
206
|
-
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
163
|
+
start: (flowId: string, options?: Pick<_descope_core_js_sdk.FlowStartOptions, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
207
164
|
lastAuth?: Omit<{
|
|
208
165
|
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
209
166
|
oauthProvider?: string;
|
|
@@ -215,7 +172,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
|
|
|
215
172
|
}, isCustomScreen?: any) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
216
173
|
next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: {
|
|
217
174
|
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any)[])[])[])[])[])[])[])[])[])[])[];
|
|
218
|
-
}, isCustomScreen?: any) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
175
|
+
}, isCustomScreen?: any, options?: _descope_core_js_sdk.FlowNextOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
219
176
|
};
|
|
220
177
|
webauthn: {
|
|
221
178
|
signUp: ((identifier: string, name: string, passkeyOptions?: _descope_core_js_sdk.PasskeyOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>) & {
|
|
@@ -922,50 +879,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
|
|
|
922
879
|
refresh: (token?: string, tryRefresh?: boolean) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
923
880
|
logout: (token?: string) => Promise<_descope_core_js_sdk.SdkResponse<never>>;
|
|
924
881
|
flow: {
|
|
925
|
-
start: (flowId: string, options?: Pick<{
|
|
926
|
-
redirectUrl?: string;
|
|
927
|
-
location?: string;
|
|
928
|
-
tenant?: string;
|
|
929
|
-
deviceInfo?: {
|
|
930
|
-
webAuthnSupport?: boolean;
|
|
931
|
-
};
|
|
932
|
-
lastAuth?: {
|
|
933
|
-
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
934
|
-
oauthProvider?: string;
|
|
935
|
-
name?: string;
|
|
936
|
-
loginId?: string;
|
|
937
|
-
};
|
|
938
|
-
redirectAuth?: {
|
|
939
|
-
callbackUrl: string;
|
|
940
|
-
codeChallenge: string;
|
|
941
|
-
};
|
|
942
|
-
oidcIdpStateId?: string;
|
|
943
|
-
preview?: boolean;
|
|
944
|
-
samlIdpStateId?: string;
|
|
945
|
-
wsfedIdpStateId?: string;
|
|
946
|
-
samlIdpUsername?: string;
|
|
947
|
-
ssoAppId?: string;
|
|
948
|
-
customAppId?: string;
|
|
949
|
-
thirdPartyAppId?: string;
|
|
950
|
-
oidcLoginHint?: string;
|
|
951
|
-
abTestingKey?: number;
|
|
952
|
-
startOptionsVersion?: number;
|
|
953
|
-
client?: Record<string, any>;
|
|
954
|
-
locale?: string;
|
|
955
|
-
oidcPrompt?: string;
|
|
956
|
-
oidcErrorRedirectUri?: string;
|
|
957
|
-
oidcResource?: string;
|
|
958
|
-
nativeOptions?: {
|
|
959
|
-
platform: "ios" | "android";
|
|
960
|
-
oauthProvider?: string;
|
|
961
|
-
oauthRedirect?: string;
|
|
962
|
-
externalAuthRedirect?: string;
|
|
963
|
-
};
|
|
964
|
-
thirdPartyAppStateId?: string;
|
|
965
|
-
applicationScopes?: string;
|
|
966
|
-
outboundAppId?: string;
|
|
967
|
-
outboundAppScopes?: string[];
|
|
968
|
-
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
882
|
+
start: (flowId: string, options?: Pick<_descope_core_js_sdk.FlowStartOptions, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
969
883
|
lastAuth?: Omit<{
|
|
970
884
|
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
971
885
|
oauthProvider?: string;
|
|
@@ -977,7 +891,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
|
|
|
977
891
|
}, isCustomScreen?: any) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
978
892
|
next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: {
|
|
979
893
|
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any)[])[])[])[])[])[])[])[])[])[])[];
|
|
980
|
-
}, isCustomScreen?: any) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
894
|
+
}, isCustomScreen?: any, options?: _descope_core_js_sdk.FlowNextOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
981
895
|
};
|
|
982
896
|
webauthn: {
|
|
983
897
|
signUp: ((identifier: string, name: string, passkeyOptions?: _descope_core_js_sdk.PasskeyOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>) & {
|
|
@@ -1684,50 +1598,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
|
|
|
1684
1598
|
refresh: (token?: string, tryRefresh?: boolean) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
1685
1599
|
logout: (token?: string) => Promise<_descope_core_js_sdk.SdkResponse<never>>;
|
|
1686
1600
|
flow: {
|
|
1687
|
-
start: (flowId: string, options?: Pick<{
|
|
1688
|
-
redirectUrl?: string;
|
|
1689
|
-
location?: string;
|
|
1690
|
-
tenant?: string;
|
|
1691
|
-
deviceInfo?: {
|
|
1692
|
-
webAuthnSupport?: boolean;
|
|
1693
|
-
};
|
|
1694
|
-
lastAuth?: {
|
|
1695
|
-
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
1696
|
-
oauthProvider?: string;
|
|
1697
|
-
name?: string;
|
|
1698
|
-
loginId?: string;
|
|
1699
|
-
};
|
|
1700
|
-
redirectAuth?: {
|
|
1701
|
-
callbackUrl: string;
|
|
1702
|
-
codeChallenge: string;
|
|
1703
|
-
};
|
|
1704
|
-
oidcIdpStateId?: string;
|
|
1705
|
-
preview?: boolean;
|
|
1706
|
-
samlIdpStateId?: string;
|
|
1707
|
-
wsfedIdpStateId?: string;
|
|
1708
|
-
samlIdpUsername?: string;
|
|
1709
|
-
ssoAppId?: string;
|
|
1710
|
-
customAppId?: string;
|
|
1711
|
-
thirdPartyAppId?: string;
|
|
1712
|
-
oidcLoginHint?: string;
|
|
1713
|
-
abTestingKey?: number;
|
|
1714
|
-
startOptionsVersion?: number;
|
|
1715
|
-
client?: Record<string, any>;
|
|
1716
|
-
locale?: string;
|
|
1717
|
-
oidcPrompt?: string;
|
|
1718
|
-
oidcErrorRedirectUri?: string;
|
|
1719
|
-
oidcResource?: string;
|
|
1720
|
-
nativeOptions?: {
|
|
1721
|
-
platform: "ios" | "android";
|
|
1722
|
-
oauthProvider?: string;
|
|
1723
|
-
oauthRedirect?: string;
|
|
1724
|
-
externalAuthRedirect?: string;
|
|
1725
|
-
};
|
|
1726
|
-
thirdPartyAppStateId?: string;
|
|
1727
|
-
applicationScopes?: string;
|
|
1728
|
-
outboundAppId?: string;
|
|
1729
|
-
outboundAppScopes?: string[];
|
|
1730
|
-
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
1601
|
+
start: (flowId: string, options?: Pick<_descope_core_js_sdk.FlowStartOptions, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
1731
1602
|
lastAuth?: Omit<{
|
|
1732
1603
|
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
1733
1604
|
oauthProvider?: string;
|
|
@@ -1739,7 +1610,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
|
|
|
1739
1610
|
}, isCustomScreen?: any) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
1740
1611
|
next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: {
|
|
1741
1612
|
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any)[])[])[])[])[])[])[])[])[])[])[];
|
|
1742
|
-
}, isCustomScreen?: any) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
1613
|
+
}, isCustomScreen?: any, options?: _descope_core_js_sdk.FlowNextOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
1743
1614
|
};
|
|
1744
1615
|
webauthn: {
|
|
1745
1616
|
signUp: ((identifier: string, name: string, passkeyOptions?: _descope_core_js_sdk.PasskeyOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>) & {
|
|
@@ -2456,50 +2327,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
|
|
|
2456
2327
|
refresh: (token?: string, tryRefresh?: boolean) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
2457
2328
|
logout: (token?: string) => Promise<_descope_core_js_sdk.SdkResponse<never>>;
|
|
2458
2329
|
flow: {
|
|
2459
|
-
start: (flowId: string, options?: Pick<{
|
|
2460
|
-
redirectUrl?: string;
|
|
2461
|
-
location?: string;
|
|
2462
|
-
tenant?: string;
|
|
2463
|
-
deviceInfo?: {
|
|
2464
|
-
webAuthnSupport?: boolean;
|
|
2465
|
-
};
|
|
2466
|
-
lastAuth?: {
|
|
2467
|
-
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
2468
|
-
oauthProvider?: string;
|
|
2469
|
-
name?: string;
|
|
2470
|
-
loginId?: string;
|
|
2471
|
-
};
|
|
2472
|
-
redirectAuth?: {
|
|
2473
|
-
callbackUrl: string;
|
|
2474
|
-
codeChallenge: string;
|
|
2475
|
-
};
|
|
2476
|
-
oidcIdpStateId?: string;
|
|
2477
|
-
preview?: boolean;
|
|
2478
|
-
samlIdpStateId?: string;
|
|
2479
|
-
wsfedIdpStateId?: string;
|
|
2480
|
-
samlIdpUsername?: string;
|
|
2481
|
-
ssoAppId?: string;
|
|
2482
|
-
customAppId?: string;
|
|
2483
|
-
thirdPartyAppId?: string;
|
|
2484
|
-
oidcLoginHint?: string;
|
|
2485
|
-
abTestingKey?: number;
|
|
2486
|
-
startOptionsVersion?: number;
|
|
2487
|
-
client?: Record<string, any>;
|
|
2488
|
-
locale?: string;
|
|
2489
|
-
oidcPrompt?: string;
|
|
2490
|
-
oidcErrorRedirectUri?: string;
|
|
2491
|
-
oidcResource?: string;
|
|
2492
|
-
nativeOptions?: {
|
|
2493
|
-
platform: "ios" | "android";
|
|
2494
|
-
oauthProvider?: string;
|
|
2495
|
-
oauthRedirect?: string;
|
|
2496
|
-
externalAuthRedirect?: string;
|
|
2497
|
-
};
|
|
2498
|
-
thirdPartyAppStateId?: string;
|
|
2499
|
-
applicationScopes?: string;
|
|
2500
|
-
outboundAppId?: string;
|
|
2501
|
-
outboundAppScopes?: string[];
|
|
2502
|
-
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
2330
|
+
start: (flowId: string, options?: Pick<_descope_core_js_sdk.FlowStartOptions, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
2503
2331
|
lastAuth?: Omit<{
|
|
2504
2332
|
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
2505
2333
|
oauthProvider?: string;
|
|
@@ -2511,7 +2339,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
|
|
|
2511
2339
|
}, isCustomScreen?: any) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
2512
2340
|
next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: {
|
|
2513
2341
|
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any)[])[])[])[])[])[])[])[])[])[])[];
|
|
2514
|
-
}, isCustomScreen?: any) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
2342
|
+
}, isCustomScreen?: any, options?: _descope_core_js_sdk.FlowNextOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
2515
2343
|
};
|
|
2516
2344
|
webauthn: {
|
|
2517
2345
|
signUp: ((identifier: string, name: string, passkeyOptions?: _descope_core_js_sdk.PasskeyOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>) & {
|
|
@@ -3218,50 +3046,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
|
|
|
3218
3046
|
refresh: (token?: string, tryRefresh?: boolean) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
3219
3047
|
logout: (token?: string) => Promise<_descope_core_js_sdk.SdkResponse<never>>;
|
|
3220
3048
|
flow: {
|
|
3221
|
-
start: (flowId: string, options?: Pick<{
|
|
3222
|
-
redirectUrl?: string;
|
|
3223
|
-
location?: string;
|
|
3224
|
-
tenant?: string;
|
|
3225
|
-
deviceInfo?: {
|
|
3226
|
-
webAuthnSupport?: boolean;
|
|
3227
|
-
};
|
|
3228
|
-
lastAuth?: {
|
|
3229
|
-
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
3230
|
-
oauthProvider?: string;
|
|
3231
|
-
name?: string;
|
|
3232
|
-
loginId?: string;
|
|
3233
|
-
};
|
|
3234
|
-
redirectAuth?: {
|
|
3235
|
-
callbackUrl: string;
|
|
3236
|
-
codeChallenge: string;
|
|
3237
|
-
};
|
|
3238
|
-
oidcIdpStateId?: string;
|
|
3239
|
-
preview?: boolean;
|
|
3240
|
-
samlIdpStateId?: string;
|
|
3241
|
-
wsfedIdpStateId?: string;
|
|
3242
|
-
samlIdpUsername?: string;
|
|
3243
|
-
ssoAppId?: string;
|
|
3244
|
-
customAppId?: string;
|
|
3245
|
-
thirdPartyAppId?: string;
|
|
3246
|
-
oidcLoginHint?: string;
|
|
3247
|
-
abTestingKey?: number;
|
|
3248
|
-
startOptionsVersion?: number;
|
|
3249
|
-
client?: Record<string, any>;
|
|
3250
|
-
locale?: string;
|
|
3251
|
-
oidcPrompt?: string;
|
|
3252
|
-
oidcErrorRedirectUri?: string;
|
|
3253
|
-
oidcResource?: string;
|
|
3254
|
-
nativeOptions?: {
|
|
3255
|
-
platform: "ios" | "android";
|
|
3256
|
-
oauthProvider?: string;
|
|
3257
|
-
oauthRedirect?: string;
|
|
3258
|
-
externalAuthRedirect?: string;
|
|
3259
|
-
};
|
|
3260
|
-
thirdPartyAppStateId?: string;
|
|
3261
|
-
applicationScopes?: string;
|
|
3262
|
-
outboundAppId?: string;
|
|
3263
|
-
outboundAppScopes?: string[];
|
|
3264
|
-
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
3049
|
+
start: (flowId: string, options?: Pick<_descope_core_js_sdk.FlowStartOptions, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
3265
3050
|
lastAuth?: Omit<{
|
|
3266
3051
|
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
3267
3052
|
oauthProvider?: string;
|
|
@@ -3273,7 +3058,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
|
|
|
3273
3058
|
}, isCustomScreen?: any) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
3274
3059
|
next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: {
|
|
3275
3060
|
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any)[])[])[])[])[])[])[])[])[])[])[];
|
|
3276
|
-
}, isCustomScreen?: any) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
3061
|
+
}, isCustomScreen?: any, options?: _descope_core_js_sdk.FlowNextOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
3277
3062
|
};
|
|
3278
3063
|
webauthn: {
|
|
3279
3064
|
signUp: ((identifier: string, name: string, passkeyOptions?: _descope_core_js_sdk.PasskeyOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>) & {
|
|
@@ -3980,50 +3765,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
|
|
|
3980
3765
|
refresh: (token?: string, tryRefresh?: boolean) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
|
|
3981
3766
|
logout: (token?: string) => Promise<_descope_core_js_sdk.SdkResponse<never>>;
|
|
3982
3767
|
flow: {
|
|
3983
|
-
start: (flowId: string, options?: Pick<{
|
|
3984
|
-
redirectUrl?: string;
|
|
3985
|
-
location?: string;
|
|
3986
|
-
tenant?: string;
|
|
3987
|
-
deviceInfo?: {
|
|
3988
|
-
webAuthnSupport?: boolean;
|
|
3989
|
-
};
|
|
3990
|
-
lastAuth?: {
|
|
3991
|
-
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
3992
|
-
oauthProvider?: string;
|
|
3993
|
-
name?: string;
|
|
3994
|
-
loginId?: string;
|
|
3995
|
-
};
|
|
3996
|
-
redirectAuth?: {
|
|
3997
|
-
callbackUrl: string;
|
|
3998
|
-
codeChallenge: string;
|
|
3999
|
-
};
|
|
4000
|
-
oidcIdpStateId?: string;
|
|
4001
|
-
preview?: boolean;
|
|
4002
|
-
samlIdpStateId?: string;
|
|
4003
|
-
wsfedIdpStateId?: string;
|
|
4004
|
-
samlIdpUsername?: string;
|
|
4005
|
-
ssoAppId?: string;
|
|
4006
|
-
customAppId?: string;
|
|
4007
|
-
thirdPartyAppId?: string;
|
|
4008
|
-
oidcLoginHint?: string;
|
|
4009
|
-
abTestingKey?: number;
|
|
4010
|
-
startOptionsVersion?: number;
|
|
4011
|
-
client?: Record<string, any>;
|
|
4012
|
-
locale?: string;
|
|
4013
|
-
oidcPrompt?: string;
|
|
4014
|
-
oidcErrorRedirectUri?: string;
|
|
4015
|
-
oidcResource?: string;
|
|
4016
|
-
nativeOptions?: {
|
|
4017
|
-
platform: "ios" | "android";
|
|
4018
|
-
oauthProvider?: string;
|
|
4019
|
-
oauthRedirect?: string;
|
|
4020
|
-
externalAuthRedirect?: string;
|
|
4021
|
-
};
|
|
4022
|
-
thirdPartyAppStateId?: string;
|
|
4023
|
-
applicationScopes?: string;
|
|
4024
|
-
outboundAppId?: string;
|
|
4025
|
-
outboundAppScopes?: string[];
|
|
4026
|
-
}, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
3768
|
+
start: (flowId: string, options?: Pick<_descope_core_js_sdk.FlowStartOptions, "tenant" | "redirectUrl" | "redirectAuth" | "oidcIdpStateId" | "samlIdpStateId" | "wsfedIdpStateId" | "samlIdpUsername" | "ssoAppId" | "thirdPartyAppId" | "oidcLoginHint" | "preview" | "abTestingKey" | "client" | "locale" | "oidcPrompt" | "oidcErrorRedirectUri" | "oidcResource" | "nativeOptions" | "thirdPartyAppStateId" | "applicationScopes" | "outboundAppId" | "outboundAppScopes"> & {
|
|
4027
3769
|
lastAuth?: Omit<{
|
|
4028
3770
|
authMethod?: "webauthn" | "otp" | "oauth" | "sso" | "saml" | "totp" | "magiclink" | "enchantedlink";
|
|
4029
3771
|
oauthProvider?: string;
|
|
@@ -4035,7 +3777,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
|
|
|
4035
3777
|
}, isCustomScreen?: any) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
4036
3778
|
next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: {
|
|
4037
3779
|
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any)[])[])[])[])[])[])[])[])[])[])[];
|
|
4038
|
-
}, isCustomScreen?: any) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
3780
|
+
}, isCustomScreen?: any, options?: _descope_core_js_sdk.FlowNextOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
|
|
4039
3781
|
};
|
|
4040
3782
|
webauthn: {
|
|
4041
3783
|
signUp: ((identifier: string, name: string, passkeyOptions?: _descope_core_js_sdk.PasskeyOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>) & {
|
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__rest as e}from"tslib";import{jwtDecode as t}from"jwt-decode";import n,{wrapWith as o}from"@descope/core-js-sdk";import i from"js-cookie";import{load as r,defaultEndpoint as s,defaultScriptUrlPattern as a}from"@fingerprintjs/fingerprintjs-pro";const l="3.2.0",c="undefined"!=typeof window,d=Math.pow(2,31)-1,u=`https://descopecdn.com/npm/oidc-client-ts@${l}/dist/browser/oidc-client-ts.min.js`,f=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${l}/dist/browser/oidc-client-ts.min.js`;const p=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let v;const g=e=>{try{return t(e).exp}catch(e){return null}},h=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:g(n)},w=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?g(o):void 0)},m=t=>{const{access_token:n,id_token:o,refresh_token:i,refresh_expire_in:r}=t,s=e(t,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:t.sessionJwt||n,idToken:o,refreshJwt:t.refreshJwt||i,sessionExpiration:t.sessionExpiration||w(t),cookieExpiration:t.cookieExpiration||h(t)},s)},y=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},b=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return m(n)},k=()=>c&&!!window.descopeBridge,S=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return p.includes(n)},I=void 0!==v||c&&void 0!==window.localStorage,_=(e,t)=>{var n,o;return null===(o=null===(n=v||c&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o?void 0:o.call(n,e,t)},O=e=>{var t,n;return null===(n=null===(t=v||c&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},x=e=>{var t,n;return null===(n=null===(t=v||c&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},j=e=>{var t,n,o,i,r;return null!==(r=null!==(n=null===(t=null==v?void 0:v.key)||void 0===t?void 0:t.call(v,e))&&void 0!==n?n:c&&(null===(i=null===(o=window.localStorage)||void 0===o?void 0:o.key)||void 0===i?void 0:i.call(o,e)))&&void 0!==r?r:null},D=e=>{var t,n;return c&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},C=e=>{var t,n;try{c&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},U=(...e)=>{console.debug(...e)},A=(...e)=>{console.warn(...e)},T=(e,t)=>{let n;var o;return t>0?(n=1e3*t,U(`Using provided nextRefreshSeconds: ${t}s`)):n=((o=e)?o.getTime()-(new Date).getTime():0)-2e4,n>d&&(U(`Timeout is too large (${n}ms), setting it to ${d}ms`),n=d),n},R="DS",E="DSR",$="DSI",N="DSRCN";function J(e,t,n){if(t){const{cookieDomain:o,cookiePath:r,cookieSameSite:s,cookieExpiration:a,cookieSecure:l}=n,c=new Date(1e3*a),d=P(o);i.set(e,t,{path:r,domain:d?o:void 0,expires:c,sameSite:s,secure:l})}}function P(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const q=e=>(null==e?void 0:e.cookieName)||R,L=e=>(null==e?void 0:e.cookieName)||E;function K(e="",t){return i.get(L(t))||O(`${e}${E}`)||""}function V(e="",t){return i.get(q(t))||O(`${e}${R}`)||""}function F(e=""){return O(`${e}${$}`)||""}function M(e="",t,n,o){x(`${e}${E}`),x(`${e}${R}`),x(`${e}${$}`),x(`${e}${N}`);const r=q(t);i.remove(r,null==o?void 0:o.session);const s=L(n);i.remove(s,null==o?void 0:o.refresh)}const H=(e,t,n)=>o=>{const i=Object.assign(o,{token:o.token||K(e,t)});if(!n){const t=function(e=""){return O(`${e}${N}`)}(e);t&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return O(`${e}DTD`)||""}(e);return r&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-trusted-device-token":r})),i},B=c&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",z="vsid",G="vrid",W="fp",X=(e=!1)=>{const t=O(W);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Z=async(e,t=B)=>{try{if(X())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const l=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",c=r({apiKey:e,endpoint:[o.toString(),s],scriptUrlPattern:[l,a]}),d=await c,{requestId:u}=await d.get({linkedId:n}),f=((e,t)=>({[z]:e,[G]:t}))(n,u);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};_(W,JSON.stringify(t))})(f)}catch(e){console.warn("Could not load fingerprint",e)}},Q=()=>{x(W)},Y=e=>{const t=X(!0);return t&&e.body&&(e.body.fpData=t),e},ee="descopeFlowNonce",te="X-Descope-Flow-Nonce",ne="/v1/flow/start",oe="/v1/flow/next",ie=(e,t=ee)=>`${t}${e}`,re=(e,t=ee)=>{try{const n=ie(e,t),o=O(n);if(!o)return null;const i=JSON.parse(o);return i.expiry<Date.now()?(se(e,t),null):{value:i.value,seq:i.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},se=(e,t=ee)=>{try{const n=ie(e,t);x(n)}catch(e){console.error("Error removing flow nonce:",e)}},ae=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},le=async(e,t)=>{try{const n=t.headers.get(te),o=null===n?void 0:(e=>{const t=e.indexOf(".");if(t<=0)return;const n=e.slice(0,t);if(!/^\d+$/.test(n))return;const o=Number(n);return Number.isSafeInteger(o)?o:void 0})(n);let i=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return i||(i=ce(e)),{nonce:n,seq:o,executionId:ae(i)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}},ce=e=>{var t;return e.path===oe&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?ae(e.body.executionId):null},de="dls_last_user_login_id",ue="dls_last_user_display_name",fe=e=>_(de,e),pe=()=>O(de),ve=()=>O(ue),ge=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=pe(),r=ve();i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r);return await e(...t)},he=e=>t=>async(...n)=>{const o=await t(...n);return e||(x(de),x(ue)),o},we="DSLI",me=e=>async(...t)=>{const n=await e(...t);return C(we),n};function ye(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}const be=(e,t,n,o)=>i=>async(...r)=>{const s=await i(...r);return M(e,t,n,null==o?void 0:o()),s};async function ke(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=De(n.publicKey.challenge),n.publicKey.user.id=De(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=De(e.id)})),n}(e);try{const e=await navigator.credentials.create(t);return n=e,JSON.stringify({id:n.id,rawId:Ce(n.rawId),type:n.type,response:{attestationObject:Ce(n.response.attestationObject),clientDataJSON:Ce(n.response.clientDataJSON)}})}catch(e){throw await _e(e,t,!0)}var n}async function Se(e){const t=xe(e);try{return je(await navigator.credentials.get(t))}catch(e){throw await _e(e,t,!1)}}async function Ie(e,t){const n=xe(e);n.signal=t.signal,n.mediation="conditional";try{return je(await navigator.credentials.get(n))}catch(e){throw await _e(e,n,!1)}}async function _e(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var o,i;const r=null==e?void 0:e.name;if("AbortError"===r&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===r&&n)return"authenticator_already_registered";if("NotSupportedError"===r)return"no_supported_algorithm";if("ConstraintError"===r)return"authenticator_constraints_unsupported";if("SecurityError"===r){const e=window.location.hostname;return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)?"invalid_rpid":"invalid_domain"}if(!await Oe())return"webauthn_unsupported";const s="platform"===(null===(i=null===(o=null==t?void 0:t.publicKey)||void 0===o?void 0:o.authenticatorSelection)||void 0===i?void 0:i.authenticatorAttachment);return n&&s&&!await Oe(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function Oe(e=!1){var t,n;if(!c)return Promise.resolve(!1);if(k()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const o=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return o&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():o}function xe(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=De(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=De(e.id)})),n}function je(e){return JSON.stringify({id:e.id,rawId:Ce(e.rawId),type:e.type,response:{authenticatorData:Ce(e.response.authenticatorData),clientDataJSON:Ce(e.response.clientDataJSON),signature:Ce(e.response.signature),userHandle:e.response.userHandle?Ce(e.response.userHandle):void 0}})}function De(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Ce(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Ue,Ae=(Ue=e=>({async signUp(t,n,o){const i=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await ke(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,r)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const i=await Se(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,i)},async signUpOrIn(t,n){var o;const i=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!i.ok)return i;if(null===(o=i.data)||void 0===o?void 0:o.create){const t=await ke(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await Se(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,t)}},async update(t,n,o){const i=await e.webauthn.update.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await ke(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:ke,get:Se,isSupported:Oe,conditional:Ie}}),(...e)=>{const t=Ue(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const Te={config:"/fedcm/config"},Re=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function Ee(e,t){var n;try{await $e(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function $e(e,t){var n,o;const i=await async function(e,t="google",n,o,i){const r=Re(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(i&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==i||i(n),void d()}if(o&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==o||o(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!i.credential)return null;if(null==t?void 0:t.onCodeReceived){const o=await e.oauth.verifyOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!o.ok||!o.data)throw new Error("Failed to verify OneTap client ID for provider "+i.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,o.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+i.provider);null===(o=null==t?void 0:t.onAuthenticated)||void 0===o||o.call(t,n.data)}}var Ne=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Oe(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});const Je=()=>window.location.search.includes("code")&&window.location.search.includes("state");let Pe;const qe=(e,t)=>new Promise(((n,o)=>{if(!e.length)return o(new Error("No URLs provided to loadScriptWithFallback"));const i=t();if(i)return n(i);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{qe(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)}));const Le=async(e,t,n)=>{Pe||(Pe=(async()=>{try{return require("oidc-client-ts")}catch(e){return qe([u,f],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await Pe;if(!o)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new i({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new o(d),stateUserKey:l}},Ke=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await Le(e,t,n)),{client:o,stateUserKey:i}},i=async(t="")=>{var n;const{client:i,stateUserKey:r}=await o(),s=await i.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),_(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var i;const{client:r}=await o(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(i=e.httpClient.hooks)||void 0===i?void 0:i.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:i,finishLoginIfNeed:async(e="")=>{if(Je())return await i(e)},refreshToken:async t=>{var n;const{client:i,stateUserKey:r}=await o(),s=(e=>{const t=O(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await i.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:i}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||F(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return x(i),t||window.location.replace(s),r}}},Ve=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,v=n,e(t)}),(t=>n=>{var{fpKey:o,fpLoad:i}=n,r=e(n,["fpKey","fpLoad"]);return c?(o&&i&&Z(o).catch((()=>null)),t(y(r,{beforeRequest:Y}))):t(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.51.5"},t.baseHeaders)}))),(e=>t=>{const n=ye(),i=ye(),r=ye(),s=ye(),a=e(y(t,{afterRequest:async(e,t)=>{if(S(e,t))U("Session invalidated, notifying subscribers with empty values"),i.pub(null),r.pub(null),n.pub(null),s.pub(null);else{const e=await(async e=>{const t=await b(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&r.pub(e);const{sessionJwt:o,sessionExpiration:a,claims:l}=await b(t);o&&i.pub(o),l&&s.pub(l),(a||o)&&n.pub(a||42)}}})),l=o(a,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const o=await e(...t);return i.pub(null),r.pub(null),n.pub(null),s.pub(null),o}));return Object.assign(l,{onSessionTokenChange:i.sub,onUserChange:r.sub,onClaimsChange:s.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(t=>n=>{var o;const{enableFlowNonce:i=!0,nonceStoragePrefix:r=ee}=n,s=e(n,["enableFlowNonce","nonceStoragePrefix"]);if(!i)return t(s);((e=ee)=>{try{if(!I)return;for(let i=0;i<(t=void 0,n=void 0,o=void 0,null!==(o=null!==(t=null==v?void 0:v.length)&&void 0!==t?t:c&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==o?o:0);i++){const t=j(i);if(t&&t.startsWith(e)){const e=O(t);if(e)try{JSON.parse(e).expiry<Date.now()&&x(t)}catch(e){x(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,o})(r);const a=t(y(s,{afterRequest:async(e,t)=>{var n;if(e.path!==ne&&e.path!==oe)return;const{nonce:o,seq:i,executionId:s}=await le(e,t);if(!o||!s)return;const a=e.path===ne,l=null===(n=re(s,r))||void 0===n?void 0:n.seq;if(!a&&void 0!==i&&void 0!==l&&i<=l)return;((e,t,n,o=ee,i)=>{try{const r=ie(e,o),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:i};_(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,o,a,r,null!=i?i:a?void 0:l)},beforeRequest:e=>{if(e.path===oe){const t=ce(e);if(t){const n=((e,t=ee)=>{var n,o;return null!==(o=null===(n=re(e,t))||void 0===n?void 0:n.value)&&void 0!==o?o:null})(t,r);n&&(e.headers=e.headers||{},e.headers[te]=n)}}return e}}));if(null===(o=a.flow)||void 0===o?void 0:o.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const o=e;let i;e=new Promise((e=>{i=e})),await o;try{return await t(...n)}finally{i()}}}return a}),(e=>t=>{const n=e(y(t,{afterRequest:async(e,t)=>{if(S(e,t))return void C(we);const n=await b(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,o;try{c&&(null===(o=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o||o.call(n,e,t))}catch(e){}})(we,String(n.sessionExpiration))}}));return o(n,["logout","logoutAll","oidc.logout"],me)}),(n=>i=>{var{autoRefresh:r}=i,s=e(i,["autoRefresh"]);const a=!!r,l="object"==typeof r&&(null==r?void 0:r.customActivityTracking);if(!a||k())return Object.assign(n(s),{markUserActive:()=>{A("markUserActive() called but has no effect")}});const{clearAllTimers:d,setTimer:u}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let f,p,v=null,g=!1,h=!1;l&&(U("Activity-based refresh enabled"),v=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),c&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&f&&new Date>f&&(U("Expiration time passed, refreshing session"),w.refresh(K()||p))}));const w=n(y(s,{afterRequest:async(e,n)=>{const{sessionJwt:o,refreshJwt:i,sessionExpiration:r,nextRefreshSeconds:s}=await b(n);if(S(e,n))U("Session invalidated, canceling all timers"),d();else if(o||r){if(f=((e,n)=>{if(n)return new Date(1e3*n);U("Could not extract expiration time from session token, trying to decode the token");try{const n=t(e);if(n.exp)return new Date(1e3*n.exp)}catch(e){return null}})(o,r),!f)return void U("Could not extract expiration time from session token");p=i,g=s>0;const e=T(f,s);if(d(),e<=2e4)return void U("Session is too close to expiration, not setting refresh timer");const n=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});U(`Setting refresh timer for ${n}. (${e}ms)`),v&&(v.reset(),h=!1),u((()=>{if(c&&"hidden"===document.visibilityState)U("Skipping refresh due to timer - document is hidden");else{if(v&&g&&!v.hadActivity())return U("Skipping refresh due to timer - user is idle"),void(h=!0);U("Refreshing session due to timer"),w.refresh(K()||i)}}),e)}}}));return Object.assign(o(w,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return U("Clearing all timers"),d(),n})),{markUserActive:v?()=>{U("markUserActive() called"),g||U("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),v.markActive(),h&&(U("User became active after skipped refresh, triggering refresh"),h=!1,d(),w.refresh(K()||p))}:()=>{A("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(t=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:r=!1}=n,s=e(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(t(s),{getLastUserLoginId:pe,getLastUserDisplayName:ve});const a=t(y(s,{afterRequest:async(e,t)=>{var n;const{userInfo:o,lastAuth:i}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=m((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],s=null==o?void 0:o.name;r?(fe(r),(e=>{_(ue,e)})(s)):(null==i?void 0:i.loginId)&&fe(i.loginId)}}));let l=o(a,["flow.start"],ge);return l=o(l,["logout","logoutAll"],he(r)),Object.assign(l,{getLastUserLoginId:pe,getLastUserDisplayName:ve})}),(t=>n=>{var{persistTokens:r,sessionTokenViaCookie:s,refreshTokenViaCookie:a,storagePrefix:l,refreshCookieName:d}=n,u=e(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!r||!c)return t(Object.assign({refreshCookieName:d},u));let f;const p=t(y(Object.assign({refreshCookieName:d},u),{beforeRequest:H(l,a,d),afterRequest:async(e,t)=>{if(S(e,t))U("Session invalidated, clearing persisted tokens"),M(l,s,a,f);else{const e=await b(t);e.cookieName?_(`${l||""}${N}`,e.cookieName):e.refreshJwt&&x(`${l||""}${N}`);const n=((e={},t=!1,n="",o=!1)=>{var r,s,a,l;const{sessionJwt:c,refreshJwt:d,trustedDeviceJwt:u}=e;let f;if(d)if(o){x(`${n}${E}`);const t=o.sameSite||"Strict",i=null===(r=o.secure)||void 0===r||r,a=null!==(s=o.domain)&&void 0!==s?s:e.cookieDomain,l=L(o);i&&"https:"!==window.location.protocol&&A("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:i,cookieDomain:a});J(l,d,c);const u=P(a);f=Object.assign(Object.assign({},f),{refresh:{path:c.cookiePath,domain:u?a:void 0}})}else{const e=L(o);i.remove(e),_(`${n}${E}`,d)}if(c)if(t){const n=t.sameSite||"Strict",o=null===(a=t.secure)||void 0===a||a,i=null!==(l=t.domain)&&void 0!==l?l:e.cookieDomain,r=q(t);o&&"https:"!==window.location.protocol&&A("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const s=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:o,cookieDomain:i});J(r,c,s);const d=P(i);f=Object.assign(Object.assign({},f),{session:{path:s.cookiePath,domain:d?i:void 0}})}else _(`${n}${R}`,c);return e.idToken&&_(`${n}${$}`,e.idToken),u&&_(`${n}DTD`,u),f})(e,s,l,a);n&&(f=n)}}})),v=o(p,["logout","logoutAll","oidc.logout"],be(l,s,a,(()=>f)));return Object.assign(v,{getRefreshToken:()=>K(l,a),getSessionToken:()=>V(l,s),getIdToken:()=>F(l)})}))((e=>{const t=n(e),o=Ke(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(n,i)=>{var r;if(k())return U(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await o.refreshToken(n),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(i&&c&&void 0!==window.localStorage&&!D(we)&&!O(de)&&!D("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=V(),a=K();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){U("Error getting external token while refreshing",e)}return t.refresh(n,{dcs:s?"t":"f",dcr:a?"t":"f"},l,i)},logout:async n=>{if(e.oidcConfig)try{return await o.logout({id_token_hint:n}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(n)},flow:Ne(t),webauthn:Ae(t),fedcm:(i=t,r=e.projectId,{onetap:{requestExchangeCode(e){Ee(i,e)},requestAuthentication(e){Ee(i,e)}},async oneTap(e,t,n,o,r){await $e(i,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:i.httpClient.buildUrl(r+Te.config),clientId:r}]}},o=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(o.token)},isSupported:()=>c&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(r+Te.config);try{const o={identity:{context:e||"signin",providers:[{configURL:n,clientId:r}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return!!i&&!!i.token}catch(e){return!1}}}),oidc:o});var i,r}));export{E as REFRESH_TOKEN_KEY,R as SESSION_TOKEN_KEY,Q as clearFingerprintData,Ve as createSdk,Ve as default,Z as ensureFingerprintIds,V as getSessionToken,Je as hasOidcParamsInUrl};
|
|
1
|
+
import{__rest as e}from"tslib";import{jwtDecode as t}from"jwt-decode";import n,{wrapWith as o}from"@descope/core-js-sdk";import i from"js-cookie";import{load as r,defaultEndpoint as s,defaultScriptUrlPattern as a}from"@fingerprintjs/fingerprintjs-pro";const l="3.2.0",c="undefined"!=typeof window,d=Math.pow(2,31)-1,u=`https://descopecdn.com/npm/oidc-client-ts@${l}/dist/browser/oidc-client-ts.min.js`,f=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${l}/dist/browser/oidc-client-ts.min.js`;const p=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let v;const g=e=>{try{return t(e).exp}catch(e){return null}},h=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:g(n)},w=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?g(o):void 0)},m=t=>{const{access_token:n,id_token:o,refresh_token:i,refresh_expire_in:r}=t,s=e(t,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:t.sessionJwt||n,idToken:o,refreshJwt:t.refreshJwt||i,sessionExpiration:t.sessionExpiration||w(t),cookieExpiration:t.cookieExpiration||h(t)},s)},y=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},b=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return m(n)},k=()=>c&&!!window.descopeBridge,S=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return p.includes(n)},I=void 0!==v||c&&void 0!==window.localStorage,_=(e,t)=>{var n,o;return null===(o=null===(n=v||c&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o?void 0:o.call(n,e,t)},O=e=>{var t,n;return null===(n=null===(t=v||c&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},x=e=>{var t,n;return null===(n=null===(t=v||c&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},j=e=>{var t,n,o,i,r;return null!==(r=null!==(n=null===(t=null==v?void 0:v.key)||void 0===t?void 0:t.call(v,e))&&void 0!==n?n:c&&(null===(i=null===(o=window.localStorage)||void 0===o?void 0:o.key)||void 0===i?void 0:i.call(o,e)))&&void 0!==r?r:null},D=e=>{var t,n;return c&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},C=e=>{var t,n;try{c&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},U=(...e)=>{console.debug(...e)},A=(...e)=>{console.warn(...e)},T=(e,t)=>{let n;var o;return t>0?(n=1e3*t,U(`Using provided nextRefreshSeconds: ${t}s`)):n=((o=e)?o.getTime()-(new Date).getTime():0)-2e4,n>d&&(U(`Timeout is too large (${n}ms), setting it to ${d}ms`),n=d),n},R="DS",E="DSR",$="DSI",N="DSRCN";function J(e,t,n){if(t){const{cookieDomain:o,cookiePath:r,cookieSameSite:s,cookieExpiration:a,cookieSecure:l}=n,c=new Date(1e3*a),d=P(o);i.set(e,t,{path:r,domain:d?o:void 0,expires:c,sameSite:s,secure:l})}}function P(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const q=e=>(null==e?void 0:e.cookieName)||R,L=e=>(null==e?void 0:e.cookieName)||E;function K(e="",t){return i.get(L(t))||O(`${e}${E}`)||""}function V(e="",t){return i.get(q(t))||O(`${e}${R}`)||""}function F(e=""){return O(`${e}${$}`)||""}function M(e="",t,n,o){x(`${e}${E}`),x(`${e}${R}`),x(`${e}${$}`),x(`${e}${N}`);const r=q(t);i.remove(r,null==o?void 0:o.session);const s=L(n);i.remove(s,null==o?void 0:o.refresh)}const H=(e,t,n)=>o=>{const i=Object.assign(o,{token:o.token||K(e,t)});if(!n){const t=function(e=""){return O(`${e}${N}`)}(e);t&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return O(`${e}DTD`)||""}(e);return r&&(i.headers=Object.assign(Object.assign({},i.headers||{}),{"x-descope-trusted-device-token":r})),i},B=c&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",z="vsid",G="vrid",W="fp",X=(e=!1)=>{const t=O(W);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Z=async(e,t=B)=>{try{if(X())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const l=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",c=r({apiKey:e,endpoint:[o.toString(),s],scriptUrlPattern:[l,a]}),d=await c,{requestId:u}=await d.get({linkedId:n}),f=((e,t)=>({[z]:e,[G]:t}))(n,u);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};_(W,JSON.stringify(t))})(f)}catch(e){console.warn("Could not load fingerprint",e)}},Q=()=>{x(W)},Y=e=>{const t=X(!0);return t&&e.body&&(e.body.fpData=t),e},ee="descopeFlowNonce",te="X-Descope-Flow-Nonce",ne="/v1/flow/start",oe="/v1/flow/next",ie=(e,t=ee)=>`${t}${e}`,re=(e,t=ee)=>{try{const n=ie(e,t),o=O(n);if(!o)return null;const i=JSON.parse(o);return i.expiry<Date.now()?(se(e,t),null):{value:i.value,seq:i.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},se=(e,t=ee)=>{try{const n=ie(e,t);x(n)}catch(e){console.error("Error removing flow nonce:",e)}},ae=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},le=async(e,t)=>{try{const n=t.headers.get(te),o=null===n?void 0:(e=>{const t=e.indexOf(".");if(t<=0)return;const n=e.slice(0,t);if(!/^\d+$/.test(n))return;const o=Number(n);return Number.isSafeInteger(o)?o:void 0})(n);let i=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return i||(i=ce(e)),{nonce:n,seq:o,executionId:ae(i)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}},ce=e=>{var t;return e.path===oe&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?ae(e.body.executionId):null},de="dls_last_user_login_id",ue="dls_last_user_display_name",fe=e=>_(de,e),pe=()=>O(de),ve=()=>O(ue),ge=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=pe(),r=ve();i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r);return await e(...t)},he=e=>t=>async(...n)=>{const o=await t(...n);return e||(x(de),x(ue)),o},we="DSLI",me=e=>async(...t)=>{const n=await e(...t);return C(we),n};function ye(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}const be=(e,t,n,o)=>i=>async(...r)=>{const s=await i(...r);return M(e,t,n,null==o?void 0:o()),s};async function ke(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=De(n.publicKey.challenge),n.publicKey.user.id=De(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=De(e.id)})),n}(e);try{const e=await navigator.credentials.create(t);return n=e,JSON.stringify({id:n.id,rawId:Ce(n.rawId),type:n.type,response:{attestationObject:Ce(n.response.attestationObject),clientDataJSON:Ce(n.response.clientDataJSON)}})}catch(e){throw await _e(e,t,!0)}var n}async function Se(e){const t=xe(e);try{return je(await navigator.credentials.get(t))}catch(e){throw await _e(e,t,!1)}}async function Ie(e,t){const n=xe(e);n.signal=t.signal,n.mediation="conditional";try{return je(await navigator.credentials.get(n))}catch(e){throw await _e(e,n,!1)}}async function _e(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var o,i;const r=null==e?void 0:e.name;if("AbortError"===r&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===r&&n)return"authenticator_already_registered";if("NotSupportedError"===r)return"no_supported_algorithm";if("ConstraintError"===r)return"authenticator_constraints_unsupported";if("SecurityError"===r){const e=window.location.hostname;return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)?"invalid_rpid":"invalid_domain"}if(!await Oe())return"webauthn_unsupported";const s="platform"===(null===(i=null===(o=null==t?void 0:t.publicKey)||void 0===o?void 0:o.authenticatorSelection)||void 0===i?void 0:i.authenticatorAttachment);return n&&s&&!await Oe(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function Oe(e=!1){var t,n;if(!c)return Promise.resolve(!1);if(k()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const o=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return o&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():o}function xe(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=De(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=De(e.id)})),n}function je(e){return JSON.stringify({id:e.id,rawId:Ce(e.rawId),type:e.type,response:{authenticatorData:Ce(e.response.authenticatorData),clientDataJSON:Ce(e.response.clientDataJSON),signature:Ce(e.response.signature),userHandle:e.response.userHandle?Ce(e.response.userHandle):void 0}})}function De(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Ce(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Ue,Ae=(Ue=e=>({async signUp(t,n,o){const i=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await ke(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,r)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const i=await Se(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,i)},async signUpOrIn(t,n){var o;const i=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!i.ok)return i;if(null===(o=i.data)||void 0===o?void 0:o.create){const t=await ke(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await Se(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,t)}},async update(t,n,o){const i=await e.webauthn.update.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await ke(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:ke,get:Se,isSupported:Oe,conditional:Ie}}),(...e)=>{const t=Ue(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const Te={config:"/fedcm/config"};async function Re(e,t){var n;try{await Ee(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Ee(e,t){var n,o;const i=await async function(e,t="google",n,o,i){const r=(()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)})(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(i&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==i||i(n),void d()}if(o&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==o||o(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!i.credential)return null;if(null==t?void 0:t.onCodeReceived){const o=await e.oauth.verifyOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!o.ok||!o.data)throw new Error("Failed to verify OneTap client ID for provider "+i.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,o.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+i.provider);null===(o=null==t?void 0:t.onAuthenticated)||void 0===o||o.call(t,n.data)}}var $e=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Oe(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});const Ne=()=>window.location.search.includes("code")&&window.location.search.includes("state");let Je;const Pe=(e,t)=>new Promise(((n,o)=>{if(!e.length)return o(new Error("No URLs provided to loadScriptWithFallback"));const i=t();if(i)return n(i);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{Pe(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)}));const qe=async(e,t,n)=>{Je||(Je=(async()=>{try{return require("oidc-client-ts")}catch(e){return Pe([u,f],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await Je;if(!o)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new i({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new o(d),stateUserKey:l}},Le=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await qe(e,t,n)),{client:o,stateUserKey:i}},i=async(t="")=>{var n;const{client:i,stateUserKey:r}=await o(),s=await i.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),_(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var i;const{client:r}=await o(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(i=e.httpClient.hooks)||void 0===i?void 0:i.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:i,finishLoginIfNeed:async(e="")=>{if(Ne())return await i(e)},refreshToken:async t=>{var n;const{client:i,stateUserKey:r}=await o(),s=(e=>{const t=O(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await i.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:i}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||F(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return x(i),t||window.location.replace(s),r}}},Ke=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,v=n,e(t)}),(t=>n=>{var{fpKey:o,fpLoad:i}=n,r=e(n,["fpKey","fpLoad"]);return c?(o&&i&&Z(o).catch((()=>null)),t(y(r,{beforeRequest:Y}))):t(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.52.0"},t.baseHeaders)}))),(e=>t=>{const n=ye(),i=ye(),r=ye(),s=ye(),a=e(y(t,{afterRequest:async(e,t)=>{if(S(e,t))U("Session invalidated, notifying subscribers with empty values"),i.pub(null),r.pub(null),n.pub(null),s.pub(null);else{const e=await(async e=>{const t=await b(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&r.pub(e);const{sessionJwt:o,sessionExpiration:a,claims:l}=await b(t);o&&i.pub(o),l&&s.pub(l),(a||o)&&n.pub(a||42)}}})),l=o(a,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const o=await e(...t);return i.pub(null),r.pub(null),n.pub(null),s.pub(null),o}));return Object.assign(l,{onSessionTokenChange:i.sub,onUserChange:r.sub,onClaimsChange:s.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(t=>n=>{var o;const{enableFlowNonce:i=!0,nonceStoragePrefix:r=ee}=n,s=e(n,["enableFlowNonce","nonceStoragePrefix"]);if(!i)return t(s);((e=ee)=>{try{if(!I)return;for(let i=0;i<(t=void 0,n=void 0,o=void 0,null!==(o=null!==(t=null==v?void 0:v.length)&&void 0!==t?t:c&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==o?o:0);i++){const t=j(i);if(t&&t.startsWith(e)){const e=O(t);if(e)try{JSON.parse(e).expiry<Date.now()&&x(t)}catch(e){x(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,o})(r);const a=t(y(s,{afterRequest:async(e,t)=>{var n;if(e.path!==ne&&e.path!==oe)return;const{nonce:o,seq:i,executionId:s}=await le(e,t);if(!o||!s)return;const a=e.path===ne,l=null===(n=re(s,r))||void 0===n?void 0:n.seq;if(!a&&void 0!==i&&void 0!==l&&i<=l)return;((e,t,n,o=ee,i)=>{try{const r=ie(e,o),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:i};_(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,o,a,r,null!=i?i:a?void 0:l)},beforeRequest:e=>{if(e.path===oe){const t=ce(e);if(t){const n=((e,t=ee)=>{var n,o;return null!==(o=null===(n=re(e,t))||void 0===n?void 0:n.value)&&void 0!==o?o:null})(t,r);n&&(e.headers=e.headers||{},e.headers[te]=n)}}return e}}));if(null===(o=a.flow)||void 0===o?void 0:o.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const o=e;let i;e=new Promise((e=>{i=e})),await o;try{return await t(...n)}finally{i()}}}return a}),(e=>t=>{const n=e(y(t,{afterRequest:async(e,t)=>{if(S(e,t))return void C(we);const n=await b(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,o;try{c&&(null===(o=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===o||o.call(n,e,t))}catch(e){}})(we,String(n.sessionExpiration))}}));return o(n,["logout","logoutAll","oidc.logout"],me)}),(n=>i=>{var{autoRefresh:r}=i,s=e(i,["autoRefresh"]);const a=!!r,l="object"==typeof r&&(null==r?void 0:r.customActivityTracking);if(!a||k())return Object.assign(n(s),{markUserActive:()=>{A("markUserActive() called but has no effect")}});const{clearAllTimers:d,setTimer:u}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let f,p,v=null,g=!1,h=!1;l&&(U("Activity-based refresh enabled"),v=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),c&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&f&&new Date>f&&(U("Expiration time passed, refreshing session"),w.refresh(K()||p))}));const w=n(y(s,{afterRequest:async(e,n)=>{const{sessionJwt:o,refreshJwt:i,sessionExpiration:r,nextRefreshSeconds:s}=await b(n);if(S(e,n))U("Session invalidated, canceling all timers"),d();else if(o||r){if(f=((e,n)=>{if(n)return new Date(1e3*n);U("Could not extract expiration time from session token, trying to decode the token");try{const n=t(e);if(n.exp)return new Date(1e3*n.exp)}catch(e){return null}})(o,r),!f)return void U("Could not extract expiration time from session token");p=i,g=s>0;const e=T(f,s);if(d(),e<=2e4)return void U("Session is too close to expiration, not setting refresh timer");const n=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});U(`Setting refresh timer for ${n}. (${e}ms)`),v&&(v.reset(),h=!1),u((()=>{if(c&&"hidden"===document.visibilityState)U("Skipping refresh due to timer - document is hidden");else{if(v&&g&&!v.hadActivity())return U("Skipping refresh due to timer - user is idle"),void(h=!0);U("Refreshing session due to timer"),w.refresh(K()||i)}}),e)}}}));return Object.assign(o(w,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return U("Clearing all timers"),d(),n})),{markUserActive:v?()=>{U("markUserActive() called"),g||U("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),v.markActive(),h&&(U("User became active after skipped refresh, triggering refresh"),h=!1,d(),w.refresh(K()||p))}:()=>{A("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(t=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:r=!1}=n,s=e(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(t(s),{getLastUserLoginId:pe,getLastUserDisplayName:ve});const a=t(y(s,{afterRequest:async(e,t)=>{var n;const{userInfo:o,lastAuth:i}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=m((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],s=null==o?void 0:o.name;r?(fe(r),(e=>{_(ue,e)})(s)):(null==i?void 0:i.loginId)&&fe(i.loginId)}}));let l=o(a,["flow.start"],ge);return l=o(l,["logout","logoutAll"],he(r)),Object.assign(l,{getLastUserLoginId:pe,getLastUserDisplayName:ve})}),(t=>n=>{var{persistTokens:r,sessionTokenViaCookie:s,refreshTokenViaCookie:a,storagePrefix:l,refreshCookieName:d}=n,u=e(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!r||!c)return t(Object.assign({refreshCookieName:d},u));let f;const p=t(y(Object.assign({refreshCookieName:d},u),{beforeRequest:H(l,a,d),afterRequest:async(e,t)=>{if(S(e,t))U("Session invalidated, clearing persisted tokens"),M(l,s,a,f);else{const e=await b(t);e.cookieName?_(`${l||""}${N}`,e.cookieName):e.refreshJwt&&x(`${l||""}${N}`);const n=((e={},t=!1,n="",o=!1)=>{var r,s,a,l;const{sessionJwt:c,refreshJwt:d,trustedDeviceJwt:u}=e;let f;if(d)if(o){x(`${n}${E}`);const t=o.sameSite||"Strict",i=null===(r=o.secure)||void 0===r||r,a=null!==(s=o.domain)&&void 0!==s?s:e.cookieDomain,l=L(o);i&&"https:"!==window.location.protocol&&A("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:i,cookieDomain:a});J(l,d,c);const u=P(a);f=Object.assign(Object.assign({},f),{refresh:{path:c.cookiePath,domain:u?a:void 0}})}else{const e=L(o);i.remove(e),_(`${n}${E}`,d)}if(c)if(t){const n=t.sameSite||"Strict",o=null===(a=t.secure)||void 0===a||a,i=null!==(l=t.domain)&&void 0!==l?l:e.cookieDomain,r=q(t);o&&"https:"!==window.location.protocol&&A("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const s=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:o,cookieDomain:i});J(r,c,s);const d=P(i);f=Object.assign(Object.assign({},f),{session:{path:s.cookiePath,domain:d?i:void 0}})}else _(`${n}${R}`,c);return e.idToken&&_(`${n}${$}`,e.idToken),u&&_(`${n}DTD`,u),f})(e,s,l,a);n&&(f=n)}}})),v=o(p,["logout","logoutAll","oidc.logout"],be(l,s,a,(()=>f)));return Object.assign(v,{getRefreshToken:()=>K(l,a),getSessionToken:()=>V(l,s),getIdToken:()=>F(l)})}))((e=>{const t=n(e),o=Le(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(n,i)=>{var r;if(k())return U(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await o.refreshToken(n),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(i&&c&&void 0!==window.localStorage&&!D(we)&&!O(de)&&!D("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=V(),a=K();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){U("Error getting external token while refreshing",e)}return t.refresh(n,{dcs:s?"t":"f",dcr:a?"t":"f"},l,i)},logout:async n=>{if(e.oidcConfig)try{return await o.logout({id_token_hint:n}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(n)},flow:$e(t),webauthn:Ae(t),fedcm:(i=t,r=e.projectId,{onetap:{requestExchangeCode(e){Re(i,e)},requestAuthentication(e){Re(i,e)}},async oneTap(e,t,n,o,r){await Ee(i,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:i.httpClient.buildUrl(r+Te.config),clientId:r}]}},o=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(o.token)},isSupported:()=>c&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(r+Te.config);try{const o={identity:{context:e||"signin",providers:[{configURL:n,clientId:r}]}},i=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return!!i&&!!i.token}catch(e){return!1}}}),oidc:o});var i,r}));export{E as REFRESH_TOKEN_KEY,R as SESSION_TOKEN_KEY,Q as clearFingerprintData,Ke as createSdk,Ke as default,Z as ensureFingerprintIds,V as getSessionToken,Ne as hasOidcParamsInUrl};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|