@descope/web-js-sdk 1.19.0 → 1.19.2

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
@@ -142,12 +142,8 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
142
142
  name?: string;
143
143
  loginId?: string;
144
144
  }, "loginId" | "name">;
145
- }, conditionInteractionId?: string, interactionId?: string, componentsVersion?: string, flowVersions?: Record<string, number>, input?: {
146
- [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)[])[])[])[])[])[])[])[])[])[])[];
147
- }) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
148
- next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: {
149
- [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)[])[])[])[])[])[])[])[])[])[])[];
150
- }) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
145
+ }, conditionInteractionId?: string, interactionId?: string, componentsVersion?: string, flowVersions?: Record<string, number>, input?: FlowInput) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
146
+ next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: FlowInput) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
151
147
  };
152
148
  webauthn: {
153
149
  signUp: ((identifier: string, name: string, passkeyOptions?: _descope_core_js_sdk.PasskeyOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>) & {
@@ -227,6 +223,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
227
223
  phone?: string;
228
224
  }, signUpOptions?: {
229
225
  customClaims?: Record<string, any>;
226
+ templateId?: string;
230
227
  templateOptions?: {
231
228
  [x: string]: string;
232
229
  };
@@ -242,6 +239,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
242
239
  phone?: string;
243
240
  }, signUpOptions?: {
244
241
  customClaims?: Record<string, any>;
242
+ templateId?: string;
245
243
  templateOptions?: {
246
244
  [x: string]: string;
247
245
  };
@@ -257,6 +255,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
257
255
  phone?: string;
258
256
  }, signUpOptions?: {
259
257
  customClaims?: Record<string, any>;
258
+ templateId?: string;
260
259
  templateOptions?: {
261
260
  [x: string]: string;
262
261
  };
@@ -272,6 +271,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
272
271
  phone?: string;
273
272
  }, signUpOptions?: {
274
273
  customClaims?: Record<string, any>;
274
+ templateId?: string;
275
275
  templateOptions?: {
276
276
  [x: string]: string;
277
277
  };
@@ -360,6 +360,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
360
360
  phone?: string;
361
361
  }, signUpOptions?: {
362
362
  customClaims?: Record<string, any>;
363
+ templateId?: string;
363
364
  templateOptions?: {
364
365
  [x: string]: string;
365
366
  };
@@ -375,6 +376,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
375
376
  phone?: string;
376
377
  }, signUpOptions?: {
377
378
  customClaims?: Record<string, any>;
379
+ templateId?: string;
378
380
  templateOptions?: {
379
381
  [x: string]: string;
380
382
  };
@@ -390,6 +392,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
390
392
  phone?: string;
391
393
  }, signUpOptions?: {
392
394
  customClaims?: Record<string, any>;
395
+ templateId?: string;
393
396
  templateOptions?: {
394
397
  [x: string]: string;
395
398
  };
@@ -405,6 +408,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
405
408
  phone?: string;
406
409
  }, signUpOptions?: {
407
410
  customClaims?: Record<string, any>;
411
+ templateId?: string;
408
412
  templateOptions?: {
409
413
  [x: string]: string;
410
414
  };
@@ -415,6 +419,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
415
419
  signUpOrIn: {
416
420
  sms: (loginId: string, URI?: string, signUpOptions?: {
417
421
  customClaims?: Record<string, any>;
422
+ templateId?: string;
418
423
  templateOptions?: {
419
424
  [x: string]: string;
420
425
  };
@@ -423,6 +428,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
423
428
  }>>;
424
429
  voice: (loginId: string, URI?: string, signUpOptions?: {
425
430
  customClaims?: Record<string, any>;
431
+ templateId?: string;
426
432
  templateOptions?: {
427
433
  [x: string]: string;
428
434
  };
@@ -431,6 +437,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
431
437
  }>>;
432
438
  whatsapp: (loginId: string, URI?: string, signUpOptions?: {
433
439
  customClaims?: Record<string, any>;
440
+ templateId?: string;
434
441
  templateOptions?: {
435
442
  [x: string]: string;
436
443
  };
@@ -439,6 +446,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
439
446
  }>>;
440
447
  email: (loginId: string, URI?: string, signUpOptions?: {
441
448
  customClaims?: Record<string, any>;
449
+ templateId?: string;
442
450
  templateOptions?: {
443
451
  [x: string]: string;
444
452
  };
@@ -492,6 +500,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
492
500
  signIn: (loginId: string, URI?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
493
501
  signUpOrIn: (loginId: string, URI?: string, signUpOptions?: {
494
502
  customClaims?: Record<string, any>;
503
+ templateId?: string;
495
504
  templateOptions?: {
496
505
  [x: string]: string;
497
506
  };
@@ -505,6 +514,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
505
514
  phone?: string;
506
515
  }, signUpOptions?: {
507
516
  customClaims?: Record<string, any>;
517
+ templateId?: string;
508
518
  templateOptions?: {
509
519
  [x: string]: string;
510
520
  };
@@ -558,6 +568,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
558
568
  notp: {
559
569
  signUpOrIn: (loginId?: string, signUpOptions?: {
560
570
  customClaims?: Record<string, any>;
571
+ templateId?: string;
561
572
  templateOptions?: {
562
573
  [x: string]: string;
563
574
  };
@@ -575,6 +586,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
575
586
  phone?: string;
576
587
  }, signUpOptions?: {
577
588
  customClaims?: Record<string, any>;
589
+ templateId?: string;
578
590
  templateOptions?: {
579
591
  [x: string]: string;
580
592
  };
@@ -603,6 +615,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
603
615
  phone?: string;
604
616
  }, signUpOptions?: {
605
617
  customClaims?: Record<string, any>;
618
+ templateId?: string;
606
619
  templateOptions?: {
607
620
  [x: string]: string;
608
621
  };
@@ -731,12 +744,8 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
731
744
  name?: string;
732
745
  loginId?: string;
733
746
  }, "loginId" | "name">;
734
- }, conditionInteractionId?: string, interactionId?: string, componentsVersion?: string, flowVersions?: Record<string, number>, input?: {
735
- [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)[])[])[])[])[])[])[])[])[])[])[];
736
- }) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
737
- next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: {
738
- [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)[])[])[])[])[])[])[])[])[])[])[];
739
- }) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
747
+ }, conditionInteractionId?: string, interactionId?: string, componentsVersion?: string, flowVersions?: Record<string, number>, input?: FlowInput) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
748
+ next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: FlowInput) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
740
749
  };
741
750
  webauthn: {
742
751
  signUp: ((identifier: string, name: string, passkeyOptions?: _descope_core_js_sdk.PasskeyOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>) & {
@@ -816,6 +825,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
816
825
  phone?: string;
817
826
  }, signUpOptions?: {
818
827
  customClaims?: Record<string, any>;
828
+ templateId?: string;
819
829
  templateOptions?: {
820
830
  [x: string]: string;
821
831
  };
@@ -831,6 +841,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
831
841
  phone?: string;
832
842
  }, signUpOptions?: {
833
843
  customClaims?: Record<string, any>;
844
+ templateId?: string;
834
845
  templateOptions?: {
835
846
  [x: string]: string;
836
847
  };
@@ -846,6 +857,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
846
857
  phone?: string;
847
858
  }, signUpOptions?: {
848
859
  customClaims?: Record<string, any>;
860
+ templateId?: string;
849
861
  templateOptions?: {
850
862
  [x: string]: string;
851
863
  };
@@ -861,6 +873,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
861
873
  phone?: string;
862
874
  }, signUpOptions?: {
863
875
  customClaims?: Record<string, any>;
876
+ templateId?: string;
864
877
  templateOptions?: {
865
878
  [x: string]: string;
866
879
  };
@@ -949,6 +962,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
949
962
  phone?: string;
950
963
  }, signUpOptions?: {
951
964
  customClaims?: Record<string, any>;
965
+ templateId?: string;
952
966
  templateOptions?: {
953
967
  [x: string]: string;
954
968
  };
@@ -964,6 +978,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
964
978
  phone?: string;
965
979
  }, signUpOptions?: {
966
980
  customClaims?: Record<string, any>;
981
+ templateId?: string;
967
982
  templateOptions?: {
968
983
  [x: string]: string;
969
984
  };
@@ -979,6 +994,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
979
994
  phone?: string;
980
995
  }, signUpOptions?: {
981
996
  customClaims?: Record<string, any>;
997
+ templateId?: string;
982
998
  templateOptions?: {
983
999
  [x: string]: string;
984
1000
  };
@@ -994,6 +1010,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
994
1010
  phone?: string;
995
1011
  }, signUpOptions?: {
996
1012
  customClaims?: Record<string, any>;
1013
+ templateId?: string;
997
1014
  templateOptions?: {
998
1015
  [x: string]: string;
999
1016
  };
@@ -1004,6 +1021,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1004
1021
  signUpOrIn: {
1005
1022
  sms: (loginId: string, URI?: string, signUpOptions?: {
1006
1023
  customClaims?: Record<string, any>;
1024
+ templateId?: string;
1007
1025
  templateOptions?: {
1008
1026
  [x: string]: string;
1009
1027
  };
@@ -1012,6 +1030,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1012
1030
  }>>;
1013
1031
  voice: (loginId: string, URI?: string, signUpOptions?: {
1014
1032
  customClaims?: Record<string, any>;
1033
+ templateId?: string;
1015
1034
  templateOptions?: {
1016
1035
  [x: string]: string;
1017
1036
  };
@@ -1020,6 +1039,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1020
1039
  }>>;
1021
1040
  whatsapp: (loginId: string, URI?: string, signUpOptions?: {
1022
1041
  customClaims?: Record<string, any>;
1042
+ templateId?: string;
1023
1043
  templateOptions?: {
1024
1044
  [x: string]: string;
1025
1045
  };
@@ -1028,6 +1048,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1028
1048
  }>>;
1029
1049
  email: (loginId: string, URI?: string, signUpOptions?: {
1030
1050
  customClaims?: Record<string, any>;
1051
+ templateId?: string;
1031
1052
  templateOptions?: {
1032
1053
  [x: string]: string;
1033
1054
  };
@@ -1081,6 +1102,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1081
1102
  signIn: (loginId: string, URI?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
1082
1103
  signUpOrIn: (loginId: string, URI?: string, signUpOptions?: {
1083
1104
  customClaims?: Record<string, any>;
1105
+ templateId?: string;
1084
1106
  templateOptions?: {
1085
1107
  [x: string]: string;
1086
1108
  };
@@ -1094,6 +1116,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1094
1116
  phone?: string;
1095
1117
  }, signUpOptions?: {
1096
1118
  customClaims?: Record<string, any>;
1119
+ templateId?: string;
1097
1120
  templateOptions?: {
1098
1121
  [x: string]: string;
1099
1122
  };
@@ -1147,6 +1170,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1147
1170
  notp: {
1148
1171
  signUpOrIn: (loginId?: string, signUpOptions?: {
1149
1172
  customClaims?: Record<string, any>;
1173
+ templateId?: string;
1150
1174
  templateOptions?: {
1151
1175
  [x: string]: string;
1152
1176
  };
@@ -1164,6 +1188,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1164
1188
  phone?: string;
1165
1189
  }, signUpOptions?: {
1166
1190
  customClaims?: Record<string, any>;
1191
+ templateId?: string;
1167
1192
  templateOptions?: {
1168
1193
  [x: string]: string;
1169
1194
  };
@@ -1192,6 +1217,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1192
1217
  phone?: string;
1193
1218
  }, signUpOptions?: {
1194
1219
  customClaims?: Record<string, any>;
1220
+ templateId?: string;
1195
1221
  templateOptions?: {
1196
1222
  [x: string]: string;
1197
1223
  };
@@ -1329,12 +1355,8 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1329
1355
  name?: string;
1330
1356
  loginId?: string;
1331
1357
  }, "loginId" | "name">;
1332
- }, conditionInteractionId?: string, interactionId?: string, componentsVersion?: string, flowVersions?: Record<string, number>, input?: {
1333
- [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)[])[])[])[])[])[])[])[])[])[])[];
1334
- }) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
1335
- next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: {
1336
- [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)[])[])[])[])[])[])[])[])[])[])[];
1337
- }) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
1358
+ }, conditionInteractionId?: string, interactionId?: string, componentsVersion?: string, flowVersions?: Record<string, number>, input?: FlowInput) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
1359
+ next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: FlowInput) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
1338
1360
  };
1339
1361
  webauthn: {
1340
1362
  signUp: ((identifier: string, name: string, passkeyOptions?: _descope_core_js_sdk.PasskeyOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>) & {
@@ -1414,6 +1436,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1414
1436
  phone?: string;
1415
1437
  }, signUpOptions?: {
1416
1438
  customClaims?: Record<string, any>;
1439
+ templateId?: string;
1417
1440
  templateOptions?: {
1418
1441
  [x: string]: string;
1419
1442
  };
@@ -1429,6 +1452,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1429
1452
  phone?: string;
1430
1453
  }, signUpOptions?: {
1431
1454
  customClaims?: Record<string, any>;
1455
+ templateId?: string;
1432
1456
  templateOptions?: {
1433
1457
  [x: string]: string;
1434
1458
  };
@@ -1444,6 +1468,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1444
1468
  phone?: string;
1445
1469
  }, signUpOptions?: {
1446
1470
  customClaims?: Record<string, any>;
1471
+ templateId?: string;
1447
1472
  templateOptions?: {
1448
1473
  [x: string]: string;
1449
1474
  };
@@ -1459,6 +1484,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1459
1484
  phone?: string;
1460
1485
  }, signUpOptions?: {
1461
1486
  customClaims?: Record<string, any>;
1487
+ templateId?: string;
1462
1488
  templateOptions?: {
1463
1489
  [x: string]: string;
1464
1490
  };
@@ -1547,6 +1573,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1547
1573
  phone?: string;
1548
1574
  }, signUpOptions?: {
1549
1575
  customClaims?: Record<string, any>;
1576
+ templateId?: string;
1550
1577
  templateOptions?: {
1551
1578
  [x: string]: string;
1552
1579
  };
@@ -1562,6 +1589,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1562
1589
  phone?: string;
1563
1590
  }, signUpOptions?: {
1564
1591
  customClaims?: Record<string, any>;
1592
+ templateId?: string;
1565
1593
  templateOptions?: {
1566
1594
  [x: string]: string;
1567
1595
  };
@@ -1577,6 +1605,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1577
1605
  phone?: string;
1578
1606
  }, signUpOptions?: {
1579
1607
  customClaims?: Record<string, any>;
1608
+ templateId?: string;
1580
1609
  templateOptions?: {
1581
1610
  [x: string]: string;
1582
1611
  };
@@ -1592,6 +1621,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1592
1621
  phone?: string;
1593
1622
  }, signUpOptions?: {
1594
1623
  customClaims?: Record<string, any>;
1624
+ templateId?: string;
1595
1625
  templateOptions?: {
1596
1626
  [x: string]: string;
1597
1627
  };
@@ -1602,6 +1632,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1602
1632
  signUpOrIn: {
1603
1633
  sms: (loginId: string, URI?: string, signUpOptions?: {
1604
1634
  customClaims?: Record<string, any>;
1635
+ templateId?: string;
1605
1636
  templateOptions?: {
1606
1637
  [x: string]: string;
1607
1638
  };
@@ -1610,6 +1641,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1610
1641
  }>>;
1611
1642
  voice: (loginId: string, URI?: string, signUpOptions?: {
1612
1643
  customClaims?: Record<string, any>;
1644
+ templateId?: string;
1613
1645
  templateOptions?: {
1614
1646
  [x: string]: string;
1615
1647
  };
@@ -1618,6 +1650,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1618
1650
  }>>;
1619
1651
  whatsapp: (loginId: string, URI?: string, signUpOptions?: {
1620
1652
  customClaims?: Record<string, any>;
1653
+ templateId?: string;
1621
1654
  templateOptions?: {
1622
1655
  [x: string]: string;
1623
1656
  };
@@ -1626,6 +1659,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1626
1659
  }>>;
1627
1660
  email: (loginId: string, URI?: string, signUpOptions?: {
1628
1661
  customClaims?: Record<string, any>;
1662
+ templateId?: string;
1629
1663
  templateOptions?: {
1630
1664
  [x: string]: string;
1631
1665
  };
@@ -1679,6 +1713,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1679
1713
  signIn: (loginId: string, URI?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
1680
1714
  signUpOrIn: (loginId: string, URI?: string, signUpOptions?: {
1681
1715
  customClaims?: Record<string, any>;
1716
+ templateId?: string;
1682
1717
  templateOptions?: {
1683
1718
  [x: string]: string;
1684
1719
  };
@@ -1692,6 +1727,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1692
1727
  phone?: string;
1693
1728
  }, signUpOptions?: {
1694
1729
  customClaims?: Record<string, any>;
1730
+ templateId?: string;
1695
1731
  templateOptions?: {
1696
1732
  [x: string]: string;
1697
1733
  };
@@ -1745,6 +1781,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1745
1781
  notp: {
1746
1782
  signUpOrIn: (loginId?: string, signUpOptions?: {
1747
1783
  customClaims?: Record<string, any>;
1784
+ templateId?: string;
1748
1785
  templateOptions?: {
1749
1786
  [x: string]: string;
1750
1787
  };
@@ -1762,6 +1799,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1762
1799
  phone?: string;
1763
1800
  }, signUpOptions?: {
1764
1801
  customClaims?: Record<string, any>;
1802
+ templateId?: string;
1765
1803
  templateOptions?: {
1766
1804
  [x: string]: string;
1767
1805
  };
@@ -1790,6 +1828,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1790
1828
  phone?: string;
1791
1829
  }, signUpOptions?: {
1792
1830
  customClaims?: Record<string, any>;
1831
+ templateId?: string;
1793
1832
  templateOptions?: {
1794
1833
  [x: string]: string;
1795
1834
  };
@@ -1918,12 +1957,8 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
1918
1957
  name?: string;
1919
1958
  loginId?: string;
1920
1959
  }, "loginId" | "name">;
1921
- }, conditionInteractionId?: string, interactionId?: string, componentsVersion?: string, flowVersions?: Record<string, number>, input?: {
1922
- [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)[])[])[])[])[])[])[])[])[])[])[];
1923
- }) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
1924
- next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: {
1925
- [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)[])[])[])[])[])[])[])[])[])[])[];
1926
- }) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
1960
+ }, conditionInteractionId?: string, interactionId?: string, componentsVersion?: string, flowVersions?: Record<string, number>, input?: FlowInput) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
1961
+ next: (executionId: string, stepId: string, interactionId: string, version?: number, componentsVersion?: string, input?: FlowInput) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.FlowResponse>>;
1927
1962
  };
1928
1963
  webauthn: {
1929
1964
  signUp: ((identifier: string, name: string, passkeyOptions?: _descope_core_js_sdk.PasskeyOptions) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.JWTResponse>>) & {
@@ -2003,6 +2038,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2003
2038
  phone?: string;
2004
2039
  }, signUpOptions?: {
2005
2040
  customClaims?: Record<string, any>;
2041
+ templateId?: string;
2006
2042
  templateOptions?: {
2007
2043
  [x: string]: string;
2008
2044
  };
@@ -2018,6 +2054,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2018
2054
  phone?: string;
2019
2055
  }, signUpOptions?: {
2020
2056
  customClaims?: Record<string, any>;
2057
+ templateId?: string;
2021
2058
  templateOptions?: {
2022
2059
  [x: string]: string;
2023
2060
  };
@@ -2033,6 +2070,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2033
2070
  phone?: string;
2034
2071
  }, signUpOptions?: {
2035
2072
  customClaims?: Record<string, any>;
2073
+ templateId?: string;
2036
2074
  templateOptions?: {
2037
2075
  [x: string]: string;
2038
2076
  };
@@ -2048,6 +2086,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2048
2086
  phone?: string;
2049
2087
  }, signUpOptions?: {
2050
2088
  customClaims?: Record<string, any>;
2089
+ templateId?: string;
2051
2090
  templateOptions?: {
2052
2091
  [x: string]: string;
2053
2092
  };
@@ -2136,6 +2175,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2136
2175
  phone?: string;
2137
2176
  }, signUpOptions?: {
2138
2177
  customClaims?: Record<string, any>;
2178
+ templateId?: string;
2139
2179
  templateOptions?: {
2140
2180
  [x: string]: string;
2141
2181
  };
@@ -2151,6 +2191,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2151
2191
  phone?: string;
2152
2192
  }, signUpOptions?: {
2153
2193
  customClaims?: Record<string, any>;
2194
+ templateId?: string;
2154
2195
  templateOptions?: {
2155
2196
  [x: string]: string;
2156
2197
  };
@@ -2166,6 +2207,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2166
2207
  phone?: string;
2167
2208
  }, signUpOptions?: {
2168
2209
  customClaims?: Record<string, any>;
2210
+ templateId?: string;
2169
2211
  templateOptions?: {
2170
2212
  [x: string]: string;
2171
2213
  };
@@ -2181,6 +2223,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2181
2223
  phone?: string;
2182
2224
  }, signUpOptions?: {
2183
2225
  customClaims?: Record<string, any>;
2226
+ templateId?: string;
2184
2227
  templateOptions?: {
2185
2228
  [x: string]: string;
2186
2229
  };
@@ -2191,6 +2234,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2191
2234
  signUpOrIn: {
2192
2235
  sms: (loginId: string, URI?: string, signUpOptions?: {
2193
2236
  customClaims?: Record<string, any>;
2237
+ templateId?: string;
2194
2238
  templateOptions?: {
2195
2239
  [x: string]: string;
2196
2240
  };
@@ -2199,6 +2243,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2199
2243
  }>>;
2200
2244
  voice: (loginId: string, URI?: string, signUpOptions?: {
2201
2245
  customClaims?: Record<string, any>;
2246
+ templateId?: string;
2202
2247
  templateOptions?: {
2203
2248
  [x: string]: string;
2204
2249
  };
@@ -2207,6 +2252,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2207
2252
  }>>;
2208
2253
  whatsapp: (loginId: string, URI?: string, signUpOptions?: {
2209
2254
  customClaims?: Record<string, any>;
2255
+ templateId?: string;
2210
2256
  templateOptions?: {
2211
2257
  [x: string]: string;
2212
2258
  };
@@ -2215,6 +2261,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2215
2261
  }>>;
2216
2262
  email: (loginId: string, URI?: string, signUpOptions?: {
2217
2263
  customClaims?: Record<string, any>;
2264
+ templateId?: string;
2218
2265
  templateOptions?: {
2219
2266
  [x: string]: string;
2220
2267
  };
@@ -2268,6 +2315,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2268
2315
  signIn: (loginId: string, URI?: string, loginOptions?: _descope_core_js_sdk.LoginOptions, token?: string) => Promise<_descope_core_js_sdk.SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
2269
2316
  signUpOrIn: (loginId: string, URI?: string, signUpOptions?: {
2270
2317
  customClaims?: Record<string, any>;
2318
+ templateId?: string;
2271
2319
  templateOptions?: {
2272
2320
  [x: string]: string;
2273
2321
  };
@@ -2281,6 +2329,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2281
2329
  phone?: string;
2282
2330
  }, signUpOptions?: {
2283
2331
  customClaims?: Record<string, any>;
2332
+ templateId?: string;
2284
2333
  templateOptions?: {
2285
2334
  [x: string]: string;
2286
2335
  };
@@ -2334,6 +2383,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2334
2383
  notp: {
2335
2384
  signUpOrIn: (loginId?: string, signUpOptions?: {
2336
2385
  customClaims?: Record<string, any>;
2386
+ templateId?: string;
2337
2387
  templateOptions?: {
2338
2388
  [x: string]: string;
2339
2389
  };
@@ -2351,6 +2401,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2351
2401
  phone?: string;
2352
2402
  }, signUpOptions?: {
2353
2403
  customClaims?: Record<string, any>;
2404
+ templateId?: string;
2354
2405
  templateOptions?: {
2355
2406
  [x: string]: string;
2356
2407
  };
@@ -2379,6 +2430,7 @@ declare const decoratedCreateSdk: <A extends boolean>({ persistTokens: isPersist
2379
2430
  phone?: string;
2380
2431
  }, signUpOptions?: {
2381
2432
  customClaims?: Record<string, any>;
2433
+ templateId?: string;
2382
2434
  templateOptions?: {
2383
2435
  [x: string]: string;
2384
2436
  };
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import{__rest as t}from"tslib";import e,{wrapWith as n}from"@descope/core-js-sdk";import{jwtDecode as o}from"jwt-decode";import a from"js-cookie";import{load as i,defaultEndpoint as r,defaultScriptUrlPattern as s}from"@fingerprintjs/fingerprintjs-pro";const l=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var a;return n[o]=[].concat((null===(a=t.hooks)||void 0===a?void 0:a[o])||[]).concat((null==e?void 0:e[o])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},c=async t=>{if(!(null==t?void 0:t.ok))return{};const e=await(null==t?void 0:t.clone().json());return(null==e?void 0:e.authInfo)||e||{}},u=async t=>{const e=await c(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},d="undefined"!=typeof localStorage,g=(t,e)=>d&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),p=t=>d&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),f=t=>d&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),w=(...t)=>{console.debug(...t)},v="undefined"!=typeof window,h=Math.pow(2,31)-1,m="DS",b="DSR";function y(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(e){const r=new Date(1e3*i),s=function(t){const e=window.location.hostname.split("."),n=t.split(".");return e.slice(-n.length).join(".")===t}(o);a.set(t,e,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}function S(t=""){return p(`${t}${b}`)||""}function I(t=""){return a.get(m)||p(`${t}${m}`)||""}function O(t=""){f(`${t}${b}`),f(`${t}${m}`),a.remove(m)}const k=v&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",j="fp",U=(t=!1)=>{const e=localStorage.getItem(j);if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},A=async(t,e=k)=>{try{if(U())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(e);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const a=new URL(e);a.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const l=a.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",c=i({apiKey:t,endpoint:[o.toString(),r],scriptUrlPattern:[l,s]}),u=await c,{requestId:d}=await u.get({linkedId:n}),g=((t,e)=>({vsid:t,vrid:e}))(n,d);(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem(j,JSON.stringify(e))})(g)}catch(t){console.warn("Could not load fingerprint",t)}},D=()=>{localStorage.removeItem(j)},T=t=>{const e=U(!0);return e&&t.body&&(t.body.fpData=e),t},x="dls_last_user_login_id",J="dls_last_user_display_name",L=()=>p(x),_=()=>p(J),C=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,a=L(),i=_();a&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=a,o.lastAuth.name=i);return await t(...e)},R=t=>e=>async(...n)=>{const o=await e(...n);return t||(f(x),f(J)),o};function K(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}const $=t=>e=>async(...n)=>{const o=await e(...n);return O(t),o};async function N(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=G(n.publicKey.challenge),n.publicKey.user.id=G(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=G(t.id)})),n}(t),n=await navigator.credentials.create(e);return o=n,JSON.stringify({id:o.id,rawId:M(o.rawId),type:o.type,response:{attestationObject:M(o.response.attestationObject),clientDataJSON:M(o.response.clientDataJSON)}});var o}async function P(t){const e=V(t);return H(await navigator.credentials.get(e))}async function q(t,e){const n=V(t);n.signal=e.signal,n.mediation="conditional";return H(await navigator.credentials.get(n))}async function E(t=!1){if(!v)return Promise.resolve(!1);const e=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function V(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=G(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=G(t.id)})),n}function H(t){return JSON.stringify({id:t.id,rawId:M(t.rawId),type:t.type,response:{authenticatorData:M(t.response.authenticatorData),clientDataJSON:M(t.response.clientDataJSON),signature:M(t.response.signature),userHandle:t.response.userHandle?M(t.response.userHandle):void 0}})}function G(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function M(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var B,Z=(B=t=>({async signUp(e,n,o){const a=await t.webauthn.signUp.start(e,window.location.origin,n,o);if(!a.ok)return a;const i=await N(a.data.options);return await t.webauthn.signUp.finish(a.data.transactionId,i)},async signIn(e,n){const o=await t.webauthn.signIn.start(e,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const a=await P(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,a)},async signUpOrIn(e,n){var o;const a=await t.webauthn.signUpOrIn.start(e,window.location.origin,n);if(!a.ok)return a;if(null===(o=a.data)||void 0===o?void 0:o.create){const e=await N(a.data.options);return await t.webauthn.signUp.finish(a.data.transactionId,e)}{const e=await P(a.data.options);return await t.webauthn.signIn.finish(a.data.transactionId,e)}},async update(e,n,o){const a=await t.webauthn.update.start(e,window.location.origin,n,o);if(!a.ok)return a;const i=await N(a.data.options);return await t.webauthn.update.finish(a.data.transactionId,i)},helpers:{create:N,get:P,isSupported:E,conditional:q}}),(...t)=>{const e=B(...t);return Object.assign(e.signUp,t[0].webauthn.signUp),Object.assign(e.signIn,t[0].webauthn.signIn),Object.assign(e.signUpOrIn,t[0].webauthn.signUpOrIn),Object.assign(e.update,t[0].webauthn.update),e});const F={config:"/fedcm/config"},X=(t,e)=>({async oneTap(e,n,o,a){const i=null!=e?e:"google",r=await t.oauth.startNative(i,o,!0);if(!r.ok)return r;const{clientId:s,stateId:l,nonce:c}=r.data,u=await async function(){return new Promise(((t,e)=>{if(window.google)return void t(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?t(window.google.accounts.id):e("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){e("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((e=>{var o,r;u.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,use_fedcm_for_prompt:null===(r=null==n?void 0:n.use_fedcm_for_prompt)||void 0===r||r,client_id:s,callback:n=>{e(t.oauth.finishNative(i,l,"","",n.credential))},nonce:c})),u.prompt((t=>{(null==t?void 0:t.isSkippedMoment())&&(null==a||a())}))}))},async launch(n){var o;const a={identity:{context:n||"signin",providers:[{configURL:t.httpClient.buildUrl(e+F.config),clientId:e}]}},i=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(a));return t.refresh(i.token)},isSupported:()=>v&&"IdentityCredential"in window});var z=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await E(),o=Object.assign(Object.assign({location:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return e[1]=o,t.flow.start(...e)}});const Q=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((e=>n=>{var{fpKey:o,fpLoad:a}=n,i=t(n,["fpKey","fpLoad"]);return v?(o&&a&&A(o).catch((()=>null)),e(l(i,{beforeRequest:T}))):e(i)}),(e=>a=>{var{autoRefresh:i}=a,r=t(a,["autoRefresh"]);if(!i)return e(r);const{clearAllTimers:s,setTimer:u}=(()=>{const t=[];return{clearAllTimers:()=>{for(;t.length;)clearTimeout(t.pop())},setTimer:(e,n)=>{t.push(setTimeout(e,n))}}})();let d,g;v&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>d&&(w("Expiration time passed, refreshing session"),p.refresh(S()||g))}));const p=e(l(r,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:a}=await c(e);if(401===(null==e?void 0:e.status))w("Received 401, canceling all timers"),s();else if(a){if(d=(t=>{try{const e=o(t);if(e.exp)return new Date(1e3*e.exp)}catch(t){return null}})(a),!d)return void w("Could not extract expiration time from session token");g=n;let t=((i=d)?i.getTime()-(new Date).getTime():0)-2e4;t>h&&(w(`Timeout is too large (${t}ms), setting it to ${h}ms`),t=h),s();const e=new Date(Date.now()+t).toLocaleTimeString("en-US",{hour12:!1});w(`Setting refresh timer for ${e}. (${t}ms)`),u((()=>{w("Refreshing session due to timer"),p.refresh(S()||n)}),t)}var i}}));return n(p,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return w("Clearing all timers"),s(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.19.0"},e.baseHeaders)}))),(t=>e=>{const o=K(),a=K(),i=t(l(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))o.pub(null),a.pub(null);else{const t=await u(e);t&&a.pub(t);const{sessionJwt:n}=await c(e);n&&o.pub(n)}}})),r=n(i,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return o.pub(null),a.pub(null),n}));return Object.assign(r,{onSessionTokenChange:o.sub,onUserChange:a.sub})}),(e=>o=>{var{storeLastAuthenticatedUser:a=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=o,r=t(o,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!a)return Object.assign(e(r),{getLastUserLoginId:L,getLastUserDisplayName:_});const s=e(l(r,{afterRequest:async(t,e)=>{var n;const o=await u(e),a=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],i=null==o?void 0:o.name;a&&((t=>{g(x,t)})(a),(t=>{g(J,t)})(i))}}));let c=n(s,["flow.start"],C);return c=n(c,["logout","logoutAll"],R(i)),Object.assign(c,{getLastUserLoginId:L,getLastUserDisplayName:_})}),(e=>o=>{var{persistTokens:a,sessionTokenViaCookie:i,storagePrefix:r}=o,s=t(o,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!a||!v)return e(s);const u=e(l(s,{beforeRequest:(d=r,t=>Object.assign(t,{token:t.token||S(d)})),afterRequest:async(e,n)=>{const o=/^\/v\d+\/mgmt\//.test(e.path);401===(null==n?void 0:n.status)?o||O(r):((e={},n,o)=>{var{refreshJwt:a,sessionJwt:i}=e,r=t(e,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),a&&g(`${o}${b}`,a),i&&(n?y(m,i,r):g(`${o}${m}`,i))})(await c(n),i,r)}}));var d;const p=n(u,["logout","logoutAll"],$(r));return Object.assign(p,{getRefreshToken:()=>S(r),getSessionToken:()=>I(r)})}))(((...t)=>{const n=e(...t);return Object.assign(Object.assign({},n),{refresh:t=>{const e=I();return n.refresh(t,{dcs:e?"t":"f"})},flow:z(n),webauthn:Z(n),fedcm:X(n,t[0].projectId)})}));export{b as REFRESH_TOKEN_KEY,m as SESSION_TOKEN_KEY,D as clearFingerprintData,Q as default,A as ensureFingerprintIds};
1
+ import{__rest as t}from"tslib";import e,{wrapWith as n}from"@descope/core-js-sdk";import{jwtDecode as o}from"jwt-decode";import a from"js-cookie";import{load as i,defaultEndpoint as r,defaultScriptUrlPattern as s}from"@fingerprintjs/fingerprintjs-pro";const l=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var a;return n[o]=[].concat((null===(a=t.hooks)||void 0===a?void 0:a[o])||[]).concat((null==e?void 0:e[o])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},c=async t=>{if(!(null==t?void 0:t.ok))return{};const e=await(null==t?void 0:t.clone().json());return(null==e?void 0:e.authInfo)||e||{}},u=async t=>{const e=await c(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},d="undefined"!=typeof localStorage,g=(t,e)=>d&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),p=t=>d&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),f=t=>d&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),w=(...t)=>{console.debug(...t)},v="undefined"!=typeof window,h=Math.pow(2,31)-1,m="DS",b="DSR";function y(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(e){const r=new Date(1e3*i),s=function(t){const e=window.location.hostname.split("."),n=t.split(".");return e.slice(-n.length).join(".")===t}(o);a.set(t,e,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}function S(t=""){return p(`${t}${b}`)||""}function I(t=""){return a.get(m)||p(`${t}${m}`)||""}function O(t=""){f(`${t}${b}`),f(`${t}${m}`),a.remove(m)}const k=v&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",j="vsid",U="vrid",A="fp",D=(t=!1)=>{const e=localStorage.getItem(A);if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},T=async(t,e=k)=>{try{if(D())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(e);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const a=new URL(e);a.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const l=a.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",c=i({apiKey:t,endpoint:[o.toString(),r],scriptUrlPattern:[l,s]}),u=await c,{requestId:d}=await u.get({linkedId:n}),g=((t,e)=>({[j]:t,[U]:e}))(n,d);(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem(A,JSON.stringify(e))})(g)}catch(t){console.warn("Could not load fingerprint",t)}},x=()=>{localStorage.removeItem(A)},J=t=>{const e=D(!0);return e&&t.body&&(t.body.fpData=e),t},L="dls_last_user_login_id",_="dls_last_user_display_name",C=()=>p(L),R=()=>p(_),K=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,a=C(),i=R();a&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=a,o.lastAuth.name=i);return await t(...e)},$=t=>e=>async(...n)=>{const o=await e(...n);return t||(f(L),f(_)),o};function N(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}const P=t=>e=>async(...n)=>{const o=await e(...n);return O(t),o};async function q(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=B(n.publicKey.challenge),n.publicKey.user.id=B(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=B(t.id)})),n}(t),n=await navigator.credentials.create(e);return o=n,JSON.stringify({id:o.id,rawId:Z(o.rawId),type:o.type,response:{attestationObject:Z(o.response.attestationObject),clientDataJSON:Z(o.response.clientDataJSON)}});var o}async function E(t){const e=G(t);return M(await navigator.credentials.get(e))}async function V(t,e){const n=G(t);n.signal=e.signal,n.mediation="conditional";return M(await navigator.credentials.get(n))}async function H(t=!1){if(!v)return Promise.resolve(!1);const e=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function G(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=B(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=B(t.id)})),n}function M(t){return JSON.stringify({id:t.id,rawId:Z(t.rawId),type:t.type,response:{authenticatorData:Z(t.response.authenticatorData),clientDataJSON:Z(t.response.clientDataJSON),signature:Z(t.response.signature),userHandle:t.response.userHandle?Z(t.response.userHandle):void 0}})}function B(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Z(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var F,X=(F=t=>({async signUp(e,n,o){const a=await t.webauthn.signUp.start(e,window.location.origin,n,o);if(!a.ok)return a;const i=await q(a.data.options);return await t.webauthn.signUp.finish(a.data.transactionId,i)},async signIn(e,n){const o=await t.webauthn.signIn.start(e,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const a=await E(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,a)},async signUpOrIn(e,n){var o;const a=await t.webauthn.signUpOrIn.start(e,window.location.origin,n);if(!a.ok)return a;if(null===(o=a.data)||void 0===o?void 0:o.create){const e=await q(a.data.options);return await t.webauthn.signUp.finish(a.data.transactionId,e)}{const e=await E(a.data.options);return await t.webauthn.signIn.finish(a.data.transactionId,e)}},async update(e,n,o){const a=await t.webauthn.update.start(e,window.location.origin,n,o);if(!a.ok)return a;const i=await q(a.data.options);return await t.webauthn.update.finish(a.data.transactionId,i)},helpers:{create:q,get:E,isSupported:H,conditional:V}}),(...t)=>{const e=F(...t);return Object.assign(e.signUp,t[0].webauthn.signUp),Object.assign(e.signIn,t[0].webauthn.signIn),Object.assign(e.signUpOrIn,t[0].webauthn.signUpOrIn),Object.assign(e.update,t[0].webauthn.update),e});const z={config:"/fedcm/config"},Q=(t,e)=>({async oneTap(e,n,o,a){const i=null!=e?e:"google",r=await t.oauth.startNative(i,o,!0);if(!r.ok)return r;const{clientId:s,stateId:l,nonce:c}=r.data,u=await async function(){return new Promise(((t,e)=>{if(window.google)return void t(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?t(window.google.accounts.id):e("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){e("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((e=>{var o,r;u.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,use_fedcm_for_prompt:null===(r=null==n?void 0:n.use_fedcm_for_prompt)||void 0===r||r,client_id:s,callback:n=>{e(t.oauth.finishNative(i,l,"","",n.credential))},nonce:c})),u.prompt((t=>{(null==t?void 0:t.isSkippedMoment())&&(null==a||a())}))}))},async launch(n){var o;const a={identity:{context:n||"signin",providers:[{configURL:t.httpClient.buildUrl(e+z.config),clientId:e}]}},i=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(a));return t.refresh(i.token)},isSupported:()=>v&&"IdentityCredential"in window});var W=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await H(),o=Object.assign(Object.assign({location:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return e[1]=o,t.flow.start(...e)}});const Y=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((e=>n=>{var{fpKey:o,fpLoad:a}=n,i=t(n,["fpKey","fpLoad"]);return v?(o&&a&&T(o).catch((()=>null)),e(l(i,{beforeRequest:J}))):e(i)}),(e=>a=>{var{autoRefresh:i}=a,r=t(a,["autoRefresh"]);if(!i)return e(r);const{clearAllTimers:s,setTimer:u}=(()=>{const t=[];return{clearAllTimers:()=>{for(;t.length;)clearTimeout(t.pop())},setTimer:(e,n)=>{t.push(setTimeout(e,n))}}})();let d,g;v&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>d&&(w("Expiration time passed, refreshing session"),p.refresh(S()||g))}));const p=e(l(r,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:a}=await c(e);if(401===(null==e?void 0:e.status))w("Received 401, canceling all timers"),s();else if(a){if(d=(t=>{try{const e=o(t);if(e.exp)return new Date(1e3*e.exp)}catch(t){return null}})(a),!d)return void w("Could not extract expiration time from session token");g=n;let t=((i=d)?i.getTime()-(new Date).getTime():0)-2e4;t>h&&(w(`Timeout is too large (${t}ms), setting it to ${h}ms`),t=h),s();const e=new Date(Date.now()+t).toLocaleTimeString("en-US",{hour12:!1});w(`Setting refresh timer for ${e}. (${t}ms)`),u((()=>{w("Refreshing session due to timer"),p.refresh(S()||n)}),t)}var i}}));return n(p,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return w("Clearing all timers"),s(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.19.2"},e.baseHeaders)}))),(t=>e=>{const o=N(),a=N(),i=t(l(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))o.pub(null),a.pub(null);else{const t=await u(e);t&&a.pub(t);const{sessionJwt:n}=await c(e);n&&o.pub(n)}}})),r=n(i,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return o.pub(null),a.pub(null),n}));return Object.assign(r,{onSessionTokenChange:o.sub,onUserChange:a.sub})}),(e=>o=>{var{storeLastAuthenticatedUser:a=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=o,r=t(o,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!a)return Object.assign(e(r),{getLastUserLoginId:C,getLastUserDisplayName:R});const s=e(l(r,{afterRequest:async(t,e)=>{var n;const o=await u(e),a=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],i=null==o?void 0:o.name;a&&((t=>{g(L,t)})(a),(t=>{g(_,t)})(i))}}));let c=n(s,["flow.start"],K);return c=n(c,["logout","logoutAll"],$(i)),Object.assign(c,{getLastUserLoginId:C,getLastUserDisplayName:R})}),(e=>o=>{var{persistTokens:a,sessionTokenViaCookie:i,storagePrefix:r}=o,s=t(o,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!a||!v)return e(s);const u=e(l(s,{beforeRequest:(d=r,t=>Object.assign(t,{token:t.token||S(d)})),afterRequest:async(e,n)=>{const o=/^\/v\d+\/mgmt\//.test(e.path);401===(null==n?void 0:n.status)?o||O(r):((e={},n,o)=>{var{refreshJwt:a,sessionJwt:i}=e,r=t(e,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),a&&g(`${o}${b}`,a),i&&(n?y(m,i,r):g(`${o}${m}`,i))})(await c(n),i,r)}}));var d;const p=n(u,["logout","logoutAll"],P(r));return Object.assign(p,{getRefreshToken:()=>S(r),getSessionToken:()=>I(r)})}))(((...t)=>{const n=e(...t);return Object.assign(Object.assign({},n),{refresh:t=>{const e=I();return n.refresh(t,{dcs:e?"t":"f"})},flow:W(n),webauthn:X(n),fedcm:Q(n,t[0].projectId)})}));export{b as REFRESH_TOKEN_KEY,m as SESSION_TOKEN_KEY,x as clearFingerprintData,Y as default,T as ensureFingerprintIds};
2
2
  //# sourceMappingURL=index.esm.js.map