@descope/web-js-sdk 1.31.2 → 1.31.4

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/index.d.ts CHANGED
@@ -234,7 +234,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
234
234
  onAuthenticated?: (response: _descope_core_js_sdk.JWTResponse) => void;
235
235
  }): void;
236
236
  };
237
- oneTap(provider?: string, oneTapConfig?: OneTapConfig, loginOptions?: _descope_core_js_sdk.LoginOptions, onSkipped?: (reason?: string) => void, onDismissed?: (reason?: string) => void): void;
237
+ oneTap(provider?: string, oneTapConfig?: OneTapConfig, loginOptions?: _descope_core_js_sdk.LoginOptions, onSkipped?: (reason?: string) => void, onDismissed?: (reason?: string) => void): Promise<void>;
238
238
  launch(context?: "signin" | "signup" | "use" | "continue"): Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
239
239
  isSupported(): boolean;
240
240
  isLoggedIn(context?: "signin" | "signup" | "use" | "continue"): Promise<boolean>;
@@ -357,6 +357,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
357
357
  templateOptions?: {
358
358
  [x: string]: string;
359
359
  };
360
+ templateId?: string;
361
+ providerId?: string;
360
362
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
361
363
  maskedEmail: string;
362
364
  }>>;
@@ -367,6 +369,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
367
369
  templateOptions?: {
368
370
  [x: string]: string;
369
371
  };
372
+ templateId?: string;
373
+ providerId?: string;
370
374
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
371
375
  maskedPhone: string;
372
376
  }>>;
@@ -376,6 +380,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
376
380
  templateOptions?: {
377
381
  [x: string]: string;
378
382
  };
383
+ templateId?: string;
384
+ providerId?: string;
379
385
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
380
386
  maskedPhone: string;
381
387
  }>>;
@@ -385,6 +391,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
385
391
  templateOptions?: {
386
392
  [x: string]: string;
387
393
  };
394
+ templateId?: string;
395
+ providerId?: string;
388
396
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
389
397
  maskedPhone: string;
390
398
  }>>;
@@ -518,6 +526,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
518
526
  templateOptions?: {
519
527
  [x: string]: string;
520
528
  };
529
+ templateId?: string;
530
+ providerId?: string;
521
531
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
522
532
  maskedEmail: string;
523
533
  }>>;
@@ -528,6 +538,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
528
538
  templateOptions?: {
529
539
  [x: string]: string;
530
540
  };
541
+ templateId?: string;
542
+ providerId?: string;
531
543
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
532
544
  maskedPhone: string;
533
545
  }>>;
@@ -537,6 +549,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
537
549
  templateOptions?: {
538
550
  [x: string]: string;
539
551
  };
552
+ templateId?: string;
553
+ providerId?: string;
540
554
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
541
555
  maskedPhone: string;
542
556
  }>>;
@@ -546,6 +560,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
546
560
  templateOptions?: {
547
561
  [x: string]: string;
548
562
  };
563
+ templateId?: string;
564
+ providerId?: string;
549
565
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
550
566
  maskedPhone: string;
551
567
  }>>;
@@ -587,6 +603,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
587
603
  templateOptions?: {
588
604
  [x: string]: string;
589
605
  };
606
+ templateId?: string;
607
+ providerId?: string;
590
608
  }) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
591
609
  };
592
610
  };
@@ -887,7 +905,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
887
905
  onAuthenticated?: (response: _descope_core_js_sdk.JWTResponse) => void;
888
906
  }): void;
889
907
  };
890
- oneTap(provider?: string, oneTapConfig?: OneTapConfig, loginOptions?: _descope_core_js_sdk.LoginOptions, onSkipped?: (reason?: string) => void, onDismissed?: (reason?: string) => void): void;
908
+ oneTap(provider?: string, oneTapConfig?: OneTapConfig, loginOptions?: _descope_core_js_sdk.LoginOptions, onSkipped?: (reason?: string) => void, onDismissed?: (reason?: string) => void): Promise<void>;
891
909
  launch(context?: "signin" | "signup" | "use" | "continue"): Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
892
910
  isSupported(): boolean;
893
911
  isLoggedIn(context?: "signin" | "signup" | "use" | "continue"): Promise<boolean>;
@@ -1010,6 +1028,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1010
1028
  templateOptions?: {
1011
1029
  [x: string]: string;
1012
1030
  };
1031
+ templateId?: string;
1032
+ providerId?: string;
1013
1033
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1014
1034
  maskedEmail: string;
1015
1035
  }>>;
@@ -1020,6 +1040,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1020
1040
  templateOptions?: {
1021
1041
  [x: string]: string;
1022
1042
  };
1043
+ templateId?: string;
1044
+ providerId?: string;
1023
1045
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1024
1046
  maskedPhone: string;
1025
1047
  }>>;
@@ -1029,6 +1051,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1029
1051
  templateOptions?: {
1030
1052
  [x: string]: string;
1031
1053
  };
1054
+ templateId?: string;
1055
+ providerId?: string;
1032
1056
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1033
1057
  maskedPhone: string;
1034
1058
  }>>;
@@ -1038,6 +1062,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1038
1062
  templateOptions?: {
1039
1063
  [x: string]: string;
1040
1064
  };
1065
+ templateId?: string;
1066
+ providerId?: string;
1041
1067
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1042
1068
  maskedPhone: string;
1043
1069
  }>>;
@@ -1171,6 +1197,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1171
1197
  templateOptions?: {
1172
1198
  [x: string]: string;
1173
1199
  };
1200
+ templateId?: string;
1201
+ providerId?: string;
1174
1202
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1175
1203
  maskedEmail: string;
1176
1204
  }>>;
@@ -1181,6 +1209,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1181
1209
  templateOptions?: {
1182
1210
  [x: string]: string;
1183
1211
  };
1212
+ templateId?: string;
1213
+ providerId?: string;
1184
1214
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1185
1215
  maskedPhone: string;
1186
1216
  }>>;
@@ -1190,6 +1220,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1190
1220
  templateOptions?: {
1191
1221
  [x: string]: string;
1192
1222
  };
1223
+ templateId?: string;
1224
+ providerId?: string;
1193
1225
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1194
1226
  maskedPhone: string;
1195
1227
  }>>;
@@ -1199,6 +1231,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1199
1231
  templateOptions?: {
1200
1232
  [x: string]: string;
1201
1233
  };
1234
+ templateId?: string;
1235
+ providerId?: string;
1202
1236
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1203
1237
  maskedPhone: string;
1204
1238
  }>>;
@@ -1240,6 +1274,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1240
1274
  templateOptions?: {
1241
1275
  [x: string]: string;
1242
1276
  };
1277
+ templateId?: string;
1278
+ providerId?: string;
1243
1279
  }) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
1244
1280
  };
1245
1281
  };
@@ -1540,7 +1576,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1540
1576
  onAuthenticated?: (response: _descope_core_js_sdk.JWTResponse) => void;
1541
1577
  }): void;
1542
1578
  };
1543
- oneTap(provider?: string, oneTapConfig?: OneTapConfig, loginOptions?: _descope_core_js_sdk.LoginOptions, onSkipped?: (reason?: string) => void, onDismissed?: (reason?: string) => void): void;
1579
+ oneTap(provider?: string, oneTapConfig?: OneTapConfig, loginOptions?: _descope_core_js_sdk.LoginOptions, onSkipped?: (reason?: string) => void, onDismissed?: (reason?: string) => void): Promise<void>;
1544
1580
  launch(context?: "signin" | "signup" | "use" | "continue"): Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
1545
1581
  isSupported(): boolean;
1546
1582
  isLoggedIn(context?: "signin" | "signup" | "use" | "continue"): Promise<boolean>;
@@ -1663,6 +1699,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1663
1699
  templateOptions?: {
1664
1700
  [x: string]: string;
1665
1701
  };
1702
+ templateId?: string;
1703
+ providerId?: string;
1666
1704
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1667
1705
  maskedEmail: string;
1668
1706
  }>>;
@@ -1673,6 +1711,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1673
1711
  templateOptions?: {
1674
1712
  [x: string]: string;
1675
1713
  };
1714
+ templateId?: string;
1715
+ providerId?: string;
1676
1716
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1677
1717
  maskedPhone: string;
1678
1718
  }>>;
@@ -1682,6 +1722,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1682
1722
  templateOptions?: {
1683
1723
  [x: string]: string;
1684
1724
  };
1725
+ templateId?: string;
1726
+ providerId?: string;
1685
1727
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1686
1728
  maskedPhone: string;
1687
1729
  }>>;
@@ -1691,6 +1733,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1691
1733
  templateOptions?: {
1692
1734
  [x: string]: string;
1693
1735
  };
1736
+ templateId?: string;
1737
+ providerId?: string;
1694
1738
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1695
1739
  maskedPhone: string;
1696
1740
  }>>;
@@ -1824,6 +1868,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1824
1868
  templateOptions?: {
1825
1869
  [x: string]: string;
1826
1870
  };
1871
+ templateId?: string;
1872
+ providerId?: string;
1827
1873
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1828
1874
  maskedEmail: string;
1829
1875
  }>>;
@@ -1834,6 +1880,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1834
1880
  templateOptions?: {
1835
1881
  [x: string]: string;
1836
1882
  };
1883
+ templateId?: string;
1884
+ providerId?: string;
1837
1885
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1838
1886
  maskedPhone: string;
1839
1887
  }>>;
@@ -1843,6 +1891,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1843
1891
  templateOptions?: {
1844
1892
  [x: string]: string;
1845
1893
  };
1894
+ templateId?: string;
1895
+ providerId?: string;
1846
1896
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1847
1897
  maskedPhone: string;
1848
1898
  }>>;
@@ -1852,6 +1902,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1852
1902
  templateOptions?: {
1853
1903
  [x: string]: string;
1854
1904
  };
1905
+ templateId?: string;
1906
+ providerId?: string;
1855
1907
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
1856
1908
  maskedPhone: string;
1857
1909
  }>>;
@@ -1893,6 +1945,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
1893
1945
  templateOptions?: {
1894
1946
  [x: string]: string;
1895
1947
  };
1948
+ templateId?: string;
1949
+ providerId?: string;
1896
1950
  }) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
1897
1951
  };
1898
1952
  };
@@ -2200,7 +2254,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
2200
2254
  onAuthenticated?: (response: _descope_core_js_sdk.JWTResponse) => void;
2201
2255
  }): void;
2202
2256
  };
2203
- oneTap(provider?: string, oneTapConfig?: OneTapConfig, loginOptions?: _descope_core_js_sdk.LoginOptions, onSkipped?: (reason?: string) => void, onDismissed?: (reason?: string) => void): void;
2257
+ oneTap(provider?: string, oneTapConfig?: OneTapConfig, loginOptions?: _descope_core_js_sdk.LoginOptions, onSkipped?: (reason?: string) => void, onDismissed?: (reason?: string) => void): Promise<void>;
2204
2258
  launch(context?: "signin" | "signup" | "use" | "continue"): Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
2205
2259
  isSupported(): boolean;
2206
2260
  isLoggedIn(context?: "signin" | "signup" | "use" | "continue"): Promise<boolean>;
@@ -2323,6 +2377,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
2323
2377
  templateOptions?: {
2324
2378
  [x: string]: string;
2325
2379
  };
2380
+ templateId?: string;
2381
+ providerId?: string;
2326
2382
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
2327
2383
  maskedEmail: string;
2328
2384
  }>>;
@@ -2333,6 +2389,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
2333
2389
  templateOptions?: {
2334
2390
  [x: string]: string;
2335
2391
  };
2392
+ templateId?: string;
2393
+ providerId?: string;
2336
2394
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
2337
2395
  maskedPhone: string;
2338
2396
  }>>;
@@ -2342,6 +2400,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
2342
2400
  templateOptions?: {
2343
2401
  [x: string]: string;
2344
2402
  };
2403
+ templateId?: string;
2404
+ providerId?: string;
2345
2405
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
2346
2406
  maskedPhone: string;
2347
2407
  }>>;
@@ -2351,6 +2411,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
2351
2411
  templateOptions?: {
2352
2412
  [x: string]: string;
2353
2413
  };
2414
+ templateId?: string;
2415
+ providerId?: string;
2354
2416
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
2355
2417
  maskedPhone: string;
2356
2418
  }>>;
@@ -2484,6 +2546,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
2484
2546
  templateOptions?: {
2485
2547
  [x: string]: string;
2486
2548
  };
2549
+ templateId?: string;
2550
+ providerId?: string;
2487
2551
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
2488
2552
  maskedEmail: string;
2489
2553
  }>>;
@@ -2494,6 +2558,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
2494
2558
  templateOptions?: {
2495
2559
  [x: string]: string;
2496
2560
  };
2561
+ templateId?: string;
2562
+ providerId?: string;
2497
2563
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
2498
2564
  maskedPhone: string;
2499
2565
  }>>;
@@ -2503,6 +2569,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
2503
2569
  templateOptions?: {
2504
2570
  [x: string]: string;
2505
2571
  };
2572
+ templateId?: string;
2573
+ providerId?: string;
2506
2574
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
2507
2575
  maskedPhone: string;
2508
2576
  }>>;
@@ -2512,6 +2580,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
2512
2580
  templateOptions?: {
2513
2581
  [x: string]: string;
2514
2582
  };
2583
+ templateId?: string;
2584
+ providerId?: string;
2515
2585
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
2516
2586
  maskedPhone: string;
2517
2587
  }>>;
@@ -2553,6 +2623,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
2553
2623
  templateOptions?: {
2554
2624
  [x: string]: string;
2555
2625
  };
2626
+ templateId?: string;
2627
+ providerId?: string;
2556
2628
  }) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
2557
2629
  };
2558
2630
  };
@@ -2853,7 +2925,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
2853
2925
  onAuthenticated?: (response: _descope_core_js_sdk.JWTResponse) => void;
2854
2926
  }): void;
2855
2927
  };
2856
- oneTap(provider?: string, oneTapConfig?: OneTapConfig, loginOptions?: _descope_core_js_sdk.LoginOptions, onSkipped?: (reason?: string) => void, onDismissed?: (reason?: string) => void): void;
2928
+ oneTap(provider?: string, oneTapConfig?: OneTapConfig, loginOptions?: _descope_core_js_sdk.LoginOptions, onSkipped?: (reason?: string) => void, onDismissed?: (reason?: string) => void): Promise<void>;
2857
2929
  launch(context?: "signin" | "signup" | "use" | "continue"): Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
2858
2930
  isSupported(): boolean;
2859
2931
  isLoggedIn(context?: "signin" | "signup" | "use" | "continue"): Promise<boolean>;
@@ -2976,6 +3048,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
2976
3048
  templateOptions?: {
2977
3049
  [x: string]: string;
2978
3050
  };
3051
+ templateId?: string;
3052
+ providerId?: string;
2979
3053
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
2980
3054
  maskedEmail: string;
2981
3055
  }>>;
@@ -2986,6 +3060,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
2986
3060
  templateOptions?: {
2987
3061
  [x: string]: string;
2988
3062
  };
3063
+ templateId?: string;
3064
+ providerId?: string;
2989
3065
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
2990
3066
  maskedPhone: string;
2991
3067
  }>>;
@@ -2995,6 +3071,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
2995
3071
  templateOptions?: {
2996
3072
  [x: string]: string;
2997
3073
  };
3074
+ templateId?: string;
3075
+ providerId?: string;
2998
3076
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
2999
3077
  maskedPhone: string;
3000
3078
  }>>;
@@ -3004,6 +3082,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3004
3082
  templateOptions?: {
3005
3083
  [x: string]: string;
3006
3084
  };
3085
+ templateId?: string;
3086
+ providerId?: string;
3007
3087
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
3008
3088
  maskedPhone: string;
3009
3089
  }>>;
@@ -3137,6 +3217,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3137
3217
  templateOptions?: {
3138
3218
  [x: string]: string;
3139
3219
  };
3220
+ templateId?: string;
3221
+ providerId?: string;
3140
3222
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
3141
3223
  maskedEmail: string;
3142
3224
  }>>;
@@ -3147,6 +3229,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3147
3229
  templateOptions?: {
3148
3230
  [x: string]: string;
3149
3231
  };
3232
+ templateId?: string;
3233
+ providerId?: string;
3150
3234
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
3151
3235
  maskedPhone: string;
3152
3236
  }>>;
@@ -3156,6 +3240,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3156
3240
  templateOptions?: {
3157
3241
  [x: string]: string;
3158
3242
  };
3243
+ templateId?: string;
3244
+ providerId?: string;
3159
3245
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
3160
3246
  maskedPhone: string;
3161
3247
  }>>;
@@ -3165,6 +3251,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3165
3251
  templateOptions?: {
3166
3252
  [x: string]: string;
3167
3253
  };
3254
+ templateId?: string;
3255
+ providerId?: string;
3168
3256
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
3169
3257
  maskedPhone: string;
3170
3258
  }>>;
@@ -3206,6 +3294,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3206
3294
  templateOptions?: {
3207
3295
  [x: string]: string;
3208
3296
  };
3297
+ templateId?: string;
3298
+ providerId?: string;
3209
3299
  }) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
3210
3300
  };
3211
3301
  };
@@ -3506,7 +3596,7 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3506
3596
  onAuthenticated?: (response: _descope_core_js_sdk.JWTResponse) => void;
3507
3597
  }): void;
3508
3598
  };
3509
- oneTap(provider?: string, oneTapConfig?: OneTapConfig, loginOptions?: _descope_core_js_sdk.LoginOptions, onSkipped?: (reason?: string) => void, onDismissed?: (reason?: string) => void): void;
3599
+ oneTap(provider?: string, oneTapConfig?: OneTapConfig, loginOptions?: _descope_core_js_sdk.LoginOptions, onSkipped?: (reason?: string) => void, onDismissed?: (reason?: string) => void): Promise<void>;
3510
3600
  launch(context?: "signin" | "signup" | "use" | "continue"): Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>;
3511
3601
  isSupported(): boolean;
3512
3602
  isLoggedIn(context?: "signin" | "signup" | "use" | "continue"): Promise<boolean>;
@@ -3629,6 +3719,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3629
3719
  templateOptions?: {
3630
3720
  [x: string]: string;
3631
3721
  };
3722
+ templateId?: string;
3723
+ providerId?: string;
3632
3724
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
3633
3725
  maskedEmail: string;
3634
3726
  }>>;
@@ -3639,6 +3731,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3639
3731
  templateOptions?: {
3640
3732
  [x: string]: string;
3641
3733
  };
3734
+ templateId?: string;
3735
+ providerId?: string;
3642
3736
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
3643
3737
  maskedPhone: string;
3644
3738
  }>>;
@@ -3648,6 +3742,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3648
3742
  templateOptions?: {
3649
3743
  [x: string]: string;
3650
3744
  };
3745
+ templateId?: string;
3746
+ providerId?: string;
3651
3747
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
3652
3748
  maskedPhone: string;
3653
3749
  }>>;
@@ -3657,6 +3753,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3657
3753
  templateOptions?: {
3658
3754
  [x: string]: string;
3659
3755
  };
3756
+ templateId?: string;
3757
+ providerId?: string;
3660
3758
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
3661
3759
  maskedPhone: string;
3662
3760
  }>>;
@@ -3790,6 +3888,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3790
3888
  templateOptions?: {
3791
3889
  [x: string]: string;
3792
3890
  };
3891
+ templateId?: string;
3892
+ providerId?: string;
3793
3893
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
3794
3894
  maskedEmail: string;
3795
3895
  }>>;
@@ -3800,6 +3900,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3800
3900
  templateOptions?: {
3801
3901
  [x: string]: string;
3802
3902
  };
3903
+ templateId?: string;
3904
+ providerId?: string;
3803
3905
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
3804
3906
  maskedPhone: string;
3805
3907
  }>>;
@@ -3809,6 +3911,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3809
3911
  templateOptions?: {
3810
3912
  [x: string]: string;
3811
3913
  };
3914
+ templateId?: string;
3915
+ providerId?: string;
3812
3916
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
3813
3917
  maskedPhone: string;
3814
3918
  }>>;
@@ -3818,6 +3922,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3818
3922
  templateOptions?: {
3819
3923
  [x: string]: string;
3820
3924
  };
3925
+ templateId?: string;
3926
+ providerId?: string;
3821
3927
  }) => Promise<_descope_core_js_sdk.SdkResponse<{
3822
3928
  maskedPhone: string;
3823
3929
  }>>;
@@ -3859,6 +3965,8 @@ declare const decoratedCreateSdk: <A extends CookieConfig>({ persistTokens: isPe
3859
3965
  templateOptions?: {
3860
3966
  [x: string]: string;
3861
3967
  };
3968
+ templateId?: string;
3969
+ providerId?: string;
3862
3970
  }) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
3863
3971
  };
3864
3972
  };
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 a,defaultScriptUrlPattern as s}from"@fingerprintjs/fingerprintjs-pro";const c=e=>{try{return t(e).exp}catch(e){return null}},l=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:c(n)},d=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?c(o):void 0)},u=(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},p=async t=>{if(!(null==t?void 0:t.ok))return{};const n=await(null==t?void 0:t.clone().json());return(t=>{const{access_token:n,id_token:o,refresh_token:i,refresh_expire_in:r}=t,a=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||d(t),cookieExpiration:t.cookieExpiration||l(t)},a)})((null==n?void 0:n.authInfo)||n||{})},g=async e=>{const t=await p(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},f="undefined"!=typeof localStorage,w=(e,t)=>f&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),h=e=>f&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),v=e=>f&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),m=(...e)=>{console.debug(...e)},y="3.2.0",b="undefined"!=typeof window,k=Math.pow(2,31)-1,S=`https://descopecdn.com/npm/oidc-client-ts@${y}/dist/browser/oidc-client-ts.min.js`,I=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${y}/dist/browser/oidc-client-ts.min.js`,_=e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>k&&(m(`Timeout is too large (${t}ms), setting it to ${k}ms`),t=k),t},O="DS",U="DSR",x="DSI";function j(e,t,n){if(t){const{cookieDomain:o,cookiePath:r,cookieSameSite:a,cookieExpiration:s,cookieSecure:c}=n,l=new Date(1e3*s),d=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);i.set(e,t,{path:r,domain:d?o:void 0,expires:l,sameSite:a,secure:c})}}function C(e=""){return h(`${e}${U}`)||""}function R(e=""){return i.get(O)||h(`${e}${O}`)||""}function T(e=""){return h(`${e}${x}`)||""}function D(e=""){v(`${e}${U}`),v(`${e}${O}`),v(`${e}${x}`),i.remove(O)}const A=b&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",E="vsid",J="vrid",L="fp",$=(e=!1)=>{const t=localStorage.getItem(L);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},K=async(e,t=A)=>{try{if($())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 c=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",l=r({apiKey:e,endpoint:[o.toString(),a],scriptUrlPattern:[c,s]}),d=await l,{requestId:u}=await d.get({linkedId:n}),p=((e,t)=>({[E]:e,[J]:t}))(n,u);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(L,JSON.stringify(t))})(p)}catch(e){console.warn("Could not load fingerprint",e)}},P=()=>{localStorage.removeItem(L)},q=e=>{const t=$(!0);return t&&e.body&&(e.body.fpData=t),e},N="dls_last_user_login_id",V="dls_last_user_display_name",M=()=>h(N),F=()=>h(V),H=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=M(),r=F();i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r);return await e(...t)},B=e=>t=>async(...n)=>{const o=await t(...n);return e||(v(N),v(V)),o};function G(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}const W=e=>t=>async(...n)=>{const o=await t(...n);return D(e),o};async function Z(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=te(n.publicKey.challenge),n.publicKey.user.id=te(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=te(e.id)})),n}(e),n=await navigator.credentials.create(t);return o=n,JSON.stringify({id:o.id,rawId:ne(o.rawId),type:o.type,response:{attestationObject:ne(o.response.attestationObject),clientDataJSON:ne(o.response.clientDataJSON)}});var o}async function X(e){const t=Y(e);return ee(await navigator.credentials.get(t))}async function z(e,t){const n=Y(e);n.signal=t.signal,n.mediation="conditional";return ee(await navigator.credentials.get(n))}async function Q(e=!1){if(!b)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Y(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=te(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=te(e.id)})),n}function ee(e){return JSON.stringify({id:e.id,rawId:ne(e.rawId),type:e.type,response:{authenticatorData:ne(e.response.authenticatorData),clientDataJSON:ne(e.response.clientDataJSON),signature:ne(e.response.signature),userHandle:e.response.userHandle?ne(e.response.userHandle):void 0}})}function te(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function ne(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var oe,ie=(oe=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 Z(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 X(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 Z(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await X(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 Z(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:Z,get:X,isSupported:Q,conditional:z}}),(...e)=>{const t=oe(...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 re={config:"/fedcm/config"},ae=()=>{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 se(e,t){var n,o,i;try{const i=await async function(e,t="google",n,o,i){const r=ae(),a=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")}}))}(),s=await e.oauth.getOneTapClientId(t);if(!s.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const c=s.data.clientId;return new Promise((e=>{var s,l;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};a.initialize(Object.assign(Object.assign({},n),{itp_support:null===(s=null==n?void 0:n.itp_support)||void 0===s||s,use_fedcm_for_prompt:null===(l=null==n?void 0:n.use_fedcm_for_prompt)||void 0===l||l,client_id:c,callback:d,nonce:r})),a.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)}}catch(e){null===(i=null==t?void 0:t.onFailed)||void 0===i||i.call(t,e)}}var ce=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Q(),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 le=()=>window.location.search.includes("code")&&window.location.search.includes("state");let de;const ue=(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(),a=document.createElement("script");a.src=r,a.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),a.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},a.addEventListener("error",(()=>{ue(e,t),a.setAttribute("data-error","true")})),document.body.appendChild(a)}));const pe=async(e,t,n)=>{de||(de=(async()=>{try{return require("oidc-client-ts")}catch(e){return ue([S,I],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await de;if(!o)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=t,a=(null==n?void 0:n.redirectUri)||window.location.href,s=(null==n?void 0:n.scope)||"openid email roles descope.custom_claims offline_access",c=`${r}_user`;let l=e.httpClient.buildUrl(t);(null==n?void 0:n.applicationId)&&(l=`${l}/${n.applicationId}`);const d={authority:l,client_id:t,redirect_uri:a,response_type:"code",scope:s,stateStore:new i({store:window.localStorage,prefix:r}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),(null==n?void 0:n.scope)&&(d.scope=n.scope),{client:new o(d),stateUserKey:c}},ge=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await pe(e,t,n)),{client:o,stateUserKey:i}},i=async(t="")=>{var n;const{client:i,stateUserKey:r}=await o(),a=await i.processSigninResponse(t||window.location.href);var s;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(a)))),window.localStorage.setItem(r,JSON.stringify({id_token:(s=a).id_token,session_state:s.session_state,profile:s.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),a};return{loginWithRedirect:async(e={},t=!1)=>{const{client:n}=await o(),i=await n.createSigninRequest(e),{url:r}=i;return t||(window.location.href=r),{ok:!0,data:i}},finishLogin:i,finishLoginIfNeed:async(e="")=>{if(le())return await i(e)},refreshToken:async t=>{var n;const{client:i,stateUserKey:r}=await o(),a=(e=>{const t=window.localStorage.getItem(e);return t?JSON.parse(t):null})(r);if(!a)throw new Error("User not found in storage to refresh token");let s=t;if(!s){const t={};e.httpClient.hooks.beforeRequest(t),s=t.token}const c=await i.useRefreshToken({state:{refresh_token:s,session_state:a.session_state,profile:a.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(c)))),c},logout:async(e,t=!1)=>{const{client:n,stateUserKey:i}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||T(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:a}=r;return window.localStorage.removeItem(i),t||window.location.replace(a),r}}},fe=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((t=>n=>{var{fpKey:o,fpLoad:i}=n,r=e(n,["fpKey","fpLoad"]);return b?(o&&i&&K(o).catch((()=>null)),t(u(r,{beforeRequest:q}))):t(r)}),(n=>i=>{var{autoRefresh:r}=i,a=e(i,["autoRefresh"]);if(!r||"undefined"!=typeof window&&window.descopeBridge)return n(a);const{clearAllTimers:s,setTimer:c}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let l,d;b&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&l&&new Date>l&&(m("Expiration time passed, refreshing session"),g.refresh(C()||d))}));const g=n(u(a,{afterRequest:async(e,n)=>{const{sessionJwt:o,refreshJwt:i,sessionExpiration:r}=await p(n);if(401===(null==n?void 0:n.status))m("Received 401, canceling all timers"),s();else if(o||r){if(l=((e,n)=>{if(n)return new Date(1e3*n);m("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),!l)return void m("Could not extract expiration time from session token");d=i;const e=_(l);if(s(),e<=2e4)return void m("Session is too close to expiration, not setting refresh timer");const n=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});m(`Setting refresh timer for ${n}. (${e}ms)`),c((()=>{m("Refreshing session due to timer"),g.refresh(C()||i)}),e)}}}));return o(g,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return m("Clearing all timers"),s(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.31.2"},t.baseHeaders)}))),(e=>t=>{const n=G(),i=G(),r=G(),a=e(u(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))i.pub(null),r.pub(null),n.pub(null);else{const e=await g(t);e&&r.pub(e);const{sessionJwt:o,sessionExpiration:a}=await p(t);o&&i.pub(o),(a||o)&&n.pub(a||42)}}})),s=o(a,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const o=await e(...t);return i.pub(null),r.pub(null),n.pub(null),o}));return Object.assign(s,{onSessionTokenChange:i.sub,onUserChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(t=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:r=!1}=n,a=e(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(t(a),{getLastUserLoginId:M,getLastUserDisplayName:F});const s=t(u(a,{afterRequest:async(e,t)=>{var n;const o=await g(t),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((e=>{w(N,e)})(i),(e=>{w(V,e)})(r))}}));let c=o(s,["flow.start"],H);return c=o(c,["logout","logoutAll"],B(r)),Object.assign(c,{getLastUserLoginId:M,getLastUserDisplayName:F})}),(t=>n=>{var{persistTokens:i,sessionTokenViaCookie:r,storagePrefix:a}=n,s=e(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!i||!b)return t(s);const c=t(u(s,{beforeRequest:(l=a,e=>Object.assign(e,{token:e.token||C(l)})),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);401===(null==t?void 0:t.status)?n||D(a):((e={},t=!1,n="")=>{var o;const{sessionJwt:i,refreshJwt:r}=e;if(r&&w(`${n}${U}`,r),i)if(t){const n=t.sameSite||"Strict",r=null===(o=t.secure)||void 0===o||o;j(O,i,Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:r}))}else w(`${n}${O}`,i);e.idToken&&w(`${n}${x}`,e.idToken)})(await p(t),r,a)}}));var l;const d=o(c,["logout","logoutAll","oidc.logout"],W(a));return Object.assign(d,{getRefreshToken:()=>C(a),getSessionToken:()=>R(a),getIdToken:()=>T(a)})}))((e=>{const t=n(e),o=ge(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async n=>{var i;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()}})}const r=R(),a=C();let s="";if(e.getExternalToken)try{s=await(null===(i=e.getExternalToken)||void 0===i?void 0:i.call(e))}catch(e){m("Error getting external token while refreshing",e)}return t.refresh(n,{dcs:r?"t":"f",dcr:a?"t":"f"},s)},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:ce(t),webauthn:ie(t),fedcm:(i=t,r=e.projectId,{onetap:{requestExchangeCode(e){se(i,e)},requestAuthentication(e){se(i,e)}},oneTap(e,t,n,o,r){se(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+re.config),clientId:r}]}},o=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(o.token)},isSupported:()=>b&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(r+re.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{U as REFRESH_TOKEN_KEY,O as SESSION_TOKEN_KEY,P as clearFingerprintData,fe as default,K as ensureFingerprintIds,le 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 a,defaultScriptUrlPattern as s}from"@fingerprintjs/fingerprintjs-pro";const c=e=>{try{return t(e).exp}catch(e){return null}},l=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:c(n)},d=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?c(o):void 0)},u=(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},p=async t=>{if(!(null==t?void 0:t.ok))return{};const n=await(null==t?void 0:t.clone().json());return(t=>{const{access_token:n,id_token:o,refresh_token:i,refresh_expire_in:r}=t,a=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||d(t),cookieExpiration:t.cookieExpiration||l(t)},a)})((null==n?void 0:n.authInfo)||n||{})},g=async e=>{const t=await p(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},f="undefined"!=typeof localStorage,w=(e,t)=>f&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),h=e=>f&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),v=e=>f&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),m=(...e)=>{console.debug(...e)},y="3.2.0",b="undefined"!=typeof window,k=Math.pow(2,31)-1,S=`https://descopecdn.com/npm/oidc-client-ts@${y}/dist/browser/oidc-client-ts.min.js`,I=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${y}/dist/browser/oidc-client-ts.min.js`,_=e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>k&&(m(`Timeout is too large (${t}ms), setting it to ${k}ms`),t=k),t},O="DS",U="DSR",x="DSI";function j(e,t,n){if(t){const{cookieDomain:o,cookiePath:r,cookieSameSite:a,cookieExpiration:s,cookieSecure:c}=n,l=new Date(1e3*s),d=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);i.set(e,t,{path:r,domain:d?o:void 0,expires:l,sameSite:a,secure:c})}}function C(e=""){return h(`${e}${U}`)||""}function R(e=""){return i.get(O)||h(`${e}${O}`)||""}function T(e=""){return h(`${e}${x}`)||""}function D(e=""){v(`${e}${U}`),v(`${e}${O}`),v(`${e}${x}`),i.remove(O)}const A=b&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",E="vsid",J="vrid",L="fp",$=(e=!1)=>{const t=localStorage.getItem(L);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},K=async(e,t=A)=>{try{if($())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 c=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",l=r({apiKey:e,endpoint:[o.toString(),a],scriptUrlPattern:[c,s]}),d=await l,{requestId:u}=await d.get({linkedId:n}),p=((e,t)=>({[E]:e,[J]:t}))(n,u);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(L,JSON.stringify(t))})(p)}catch(e){console.warn("Could not load fingerprint",e)}},P=()=>{localStorage.removeItem(L)},q=e=>{const t=$(!0);return t&&e.body&&(e.body.fpData=t),e},N="dls_last_user_login_id",V="dls_last_user_display_name",M=()=>h(N),F=()=>h(V),H=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=M(),r=F();i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r);return await e(...t)},B=e=>t=>async(...n)=>{const o=await t(...n);return e||(v(N),v(V)),o};function G(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}const W=e=>t=>async(...n)=>{const o=await t(...n);return D(e),o};async function Z(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=te(n.publicKey.challenge),n.publicKey.user.id=te(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=te(e.id)})),n}(e),n=await navigator.credentials.create(t);return o=n,JSON.stringify({id:o.id,rawId:ne(o.rawId),type:o.type,response:{attestationObject:ne(o.response.attestationObject),clientDataJSON:ne(o.response.clientDataJSON)}});var o}async function X(e){const t=Y(e);return ee(await navigator.credentials.get(t))}async function z(e,t){const n=Y(e);n.signal=t.signal,n.mediation="conditional";return ee(await navigator.credentials.get(n))}async function Q(e=!1){if(!b)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Y(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=te(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=te(e.id)})),n}function ee(e){return JSON.stringify({id:e.id,rawId:ne(e.rawId),type:e.type,response:{authenticatorData:ne(e.response.authenticatorData),clientDataJSON:ne(e.response.clientDataJSON),signature:ne(e.response.signature),userHandle:e.response.userHandle?ne(e.response.userHandle):void 0}})}function te(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function ne(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var oe,ie=(oe=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 Z(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 X(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 Z(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await X(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 Z(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:Z,get:X,isSupported:Q,conditional:z}}),(...e)=>{const t=oe(...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 re={config:"/fedcm/config"},ae=()=>{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 se(e,t){var n;try{await ce(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function ce(e,t){var n,o;const i=await async function(e,t="google",n,o,i){const r=ae(),a=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")}}))}(),s=await e.oauth.getOneTapClientId(t);if(!s.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const c=s.data.clientId;return new Promise((e=>{var s,l;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};a.initialize(Object.assign(Object.assign({},n),{itp_support:null===(s=null==n?void 0:n.itp_support)||void 0===s||s,use_fedcm_for_prompt:null===(l=null==n?void 0:n.use_fedcm_for_prompt)||void 0===l||l,client_id:c,callback:d,nonce:r})),a.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 le=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Q(),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 de=()=>window.location.search.includes("code")&&window.location.search.includes("state");let ue;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(),a=document.createElement("script");a.src=r,a.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),a.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},a.addEventListener("error",(()=>{pe(e,t),a.setAttribute("data-error","true")})),document.body.appendChild(a)}));const ge=async(e,t,n)=>{ue||(ue=(async()=>{try{return require("oidc-client-ts")}catch(e){return pe([S,I],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await ue;if(!o)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=t,a=(null==n?void 0:n.redirectUri)||window.location.href,s=(null==n?void 0:n.scope)||"openid email roles descope.custom_claims offline_access",c=`${r}_user`;let l=e.httpClient.buildUrl(t);(null==n?void 0:n.applicationId)&&(l=`${l}/${n.applicationId}`);const d={authority:l,client_id:t,redirect_uri:a,response_type:"code",scope:s,stateStore:new i({store:window.localStorage,prefix:r}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),(null==n?void 0:n.scope)&&(d.scope=n.scope),{client:new o(d),stateUserKey:c}},fe=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await ge(e,t,n)),{client:o,stateUserKey:i}},i=async(t="")=>{var n;const{client:i,stateUserKey:r}=await o(),a=await i.processSigninResponse(t||window.location.href);var s;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(a)))),window.localStorage.setItem(r,JSON.stringify({id_token:(s=a).id_token,session_state:s.session_state,profile:s.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),a};return{loginWithRedirect:async(e={},t=!1)=>{const{client:n}=await o(),i=await n.createSigninRequest(e),{url:r}=i;return t||(window.location.href=r),{ok:!0,data:i}},finishLogin:i,finishLoginIfNeed:async(e="")=>{if(de())return await i(e)},refreshToken:async t=>{var n;const{client:i,stateUserKey:r}=await o(),a=(e=>{const t=window.localStorage.getItem(e);return t?JSON.parse(t):null})(r);if(!a)throw new Error("User not found in storage to refresh token");let s=t;if(!s){const t={};e.httpClient.hooks.beforeRequest(t),s=t.token}const c=await i.useRefreshToken({state:{refresh_token:s,session_state:a.session_state,profile:a.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(c)))),c},logout:async(e,t=!1)=>{const{client:n,stateUserKey:i}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||T(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:a}=r;return window.localStorage.removeItem(i),t||window.location.replace(a),r}}},we=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((t=>n=>{var{fpKey:o,fpLoad:i}=n,r=e(n,["fpKey","fpLoad"]);return b?(o&&i&&K(o).catch((()=>null)),t(u(r,{beforeRequest:q}))):t(r)}),(n=>i=>{var{autoRefresh:r}=i,a=e(i,["autoRefresh"]);if(!r||"undefined"!=typeof window&&window.descopeBridge)return n(a);const{clearAllTimers:s,setTimer:c}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let l,d;b&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&l&&new Date>l&&(m("Expiration time passed, refreshing session"),g.refresh(C()||d))}));const g=n(u(a,{afterRequest:async(e,n)=>{const{sessionJwt:o,refreshJwt:i,sessionExpiration:r}=await p(n);if(401===(null==n?void 0:n.status))m("Received 401, canceling all timers"),s();else if(o||r){if(l=((e,n)=>{if(n)return new Date(1e3*n);m("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),!l)return void m("Could not extract expiration time from session token");d=i;const e=_(l);if(s(),e<=2e4)return void m("Session is too close to expiration, not setting refresh timer");const n=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});m(`Setting refresh timer for ${n}. (${e}ms)`),c((()=>{m("Refreshing session due to timer"),g.refresh(C()||i)}),e)}}}));return o(g,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return m("Clearing all timers"),s(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.31.4"},t.baseHeaders)}))),(e=>t=>{const n=G(),i=G(),r=G(),a=e(u(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))i.pub(null),r.pub(null),n.pub(null);else{const e=await g(t);e&&r.pub(e);const{sessionJwt:o,sessionExpiration:a}=await p(t);o&&i.pub(o),(a||o)&&n.pub(a||42)}}})),s=o(a,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const o=await e(...t);return i.pub(null),r.pub(null),n.pub(null),o}));return Object.assign(s,{onSessionTokenChange:i.sub,onUserChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(t=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:r=!1}=n,a=e(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(t(a),{getLastUserLoginId:M,getLastUserDisplayName:F});const s=t(u(a,{afterRequest:async(e,t)=>{var n;const o=await g(t),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((e=>{w(N,e)})(i),(e=>{w(V,e)})(r))}}));let c=o(s,["flow.start"],H);return c=o(c,["logout","logoutAll"],B(r)),Object.assign(c,{getLastUserLoginId:M,getLastUserDisplayName:F})}),(t=>n=>{var{persistTokens:i,sessionTokenViaCookie:r,storagePrefix:a}=n,s=e(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!i||!b)return t(s);const c=t(u(s,{beforeRequest:(l=a,e=>Object.assign(e,{token:e.token||C(l)})),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);401===(null==t?void 0:t.status)?n||D(a):((e={},t=!1,n="")=>{var o;const{sessionJwt:i,refreshJwt:r}=e;if(r&&w(`${n}${U}`,r),i)if(t){const n=t.sameSite||"Strict",r=null===(o=t.secure)||void 0===o||o;j(O,i,Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:r}))}else w(`${n}${O}`,i);e.idToken&&w(`${n}${x}`,e.idToken)})(await p(t),r,a)}}));var l;const d=o(c,["logout","logoutAll","oidc.logout"],W(a));return Object.assign(d,{getRefreshToken:()=>C(a),getSessionToken:()=>R(a),getIdToken:()=>T(a)})}))((e=>{const t=n(e),o=fe(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async n=>{var i;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()}})}const r=R(),a=C();let s="";if(e.getExternalToken)try{s=await(null===(i=e.getExternalToken)||void 0===i?void 0:i.call(e))}catch(e){m("Error getting external token while refreshing",e)}return t.refresh(n,{dcs:r?"t":"f",dcr:a?"t":"f"},s)},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:le(t),webauthn:ie(t),fedcm:(i=t,r=e.projectId,{onetap:{requestExchangeCode(e){se(i,e)},requestAuthentication(e){se(i,e)}},async oneTap(e,t,n,o,r){await ce(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+re.config),clientId:r}]}},o=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(o.token)},isSupported:()=>b&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(r+re.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{U as REFRESH_TOKEN_KEY,O as SESSION_TOKEN_KEY,P as clearFingerprintData,we as default,K as ensureFingerprintIds,de as hasOidcParamsInUrl};
2
2
  //# sourceMappingURL=index.esm.js.map