@stytch/vanilla-js 5.24.2 → 5.24.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/CHANGELOG.md +14 -0
- package/dist/adminPortal/index.esm.js +1 -1
- package/dist/adminPortal/index.js +1 -1
- package/dist/b2b/index.esm.js +10 -9
- package/dist/b2b/index.headless.esm.js +3 -3
- package/dist/b2b/index.headless.js +2 -2
- package/dist/b2b/index.js +9 -8
- package/dist/{extractErrorMessage-srtVp7Jv.js → extractErrorMessage-CFBC76C1.js} +1 -1
- package/dist/{extractErrorMessage-DiCva4gS.js → extractErrorMessage-DS3D8CPf.js} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.headless.esm.js +567 -529
- package/dist/index.headless.js +567 -529
- package/dist/index.js +1 -1
- package/dist/{internal-64venB4k.js → internal-B5ow3XSB.js} +1162 -1066
- package/dist/{internal-Bd3Djulx.js → internal-BArKrHsQ.js} +1162 -1066
- package/package.json +2 -2
|
@@ -2455,6 +2455,44 @@ var HeadlessUserClient = /*#__PURE__*/_createClass(function HeadlessUserClient(_
|
|
|
2455
2455
|
};
|
|
2456
2456
|
return _this3._subscriptionService.subscribeToState(listener);
|
|
2457
2457
|
};
|
|
2458
|
+
this.getConnectedApps = function () {
|
|
2459
|
+
return __awaiter$1(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
2460
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2461
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2462
|
+
case 0:
|
|
2463
|
+
_context24.next = 2;
|
|
2464
|
+
return this._networkClient.fetchSDK({
|
|
2465
|
+
url: '/users/connected_apps',
|
|
2466
|
+
method: 'GET'
|
|
2467
|
+
});
|
|
2468
|
+
case 2:
|
|
2469
|
+
return _context24.abrupt("return", _context24.sent);
|
|
2470
|
+
case 3:
|
|
2471
|
+
case "end":
|
|
2472
|
+
return _context24.stop();
|
|
2473
|
+
}
|
|
2474
|
+
}, _callee24, this);
|
|
2475
|
+
}));
|
|
2476
|
+
};
|
|
2477
|
+
this.revokedConnectedApp = function (connectedAppId) {
|
|
2478
|
+
return __awaiter$1(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
2479
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2480
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2481
|
+
case 0:
|
|
2482
|
+
_context25.next = 2;
|
|
2483
|
+
return this._networkClient.fetchSDK({
|
|
2484
|
+
url: "/users/connected_apps/".concat(connectedAppId, "/revoke"),
|
|
2485
|
+
method: 'POST'
|
|
2486
|
+
});
|
|
2487
|
+
case 2:
|
|
2488
|
+
return _context25.abrupt("return", _context25.sent);
|
|
2489
|
+
case 3:
|
|
2490
|
+
case "end":
|
|
2491
|
+
return _context25.stop();
|
|
2492
|
+
}
|
|
2493
|
+
}, _callee25, this);
|
|
2494
|
+
}));
|
|
2495
|
+
};
|
|
2458
2496
|
});
|
|
2459
2497
|
var HeadlessSessionClient = /*#__PURE__*/function () {
|
|
2460
2498
|
function HeadlessSessionClient(_networkClient, _subscriptionService) {
|
|
@@ -2485,111 +2523,111 @@ var HeadlessSessionClient = /*#__PURE__*/function () {
|
|
|
2485
2523
|
return _this4._subscriptionService.subscribeToState(listener);
|
|
2486
2524
|
};
|
|
2487
2525
|
this.revoke = function (options) {
|
|
2488
|
-
return __awaiter$1(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2526
|
+
return __awaiter$1(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
2489
2527
|
var resp;
|
|
2490
|
-
return _regeneratorRuntime().wrap(function
|
|
2491
|
-
while (1) switch (
|
|
2528
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2529
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2492
2530
|
case 0:
|
|
2493
|
-
|
|
2494
|
-
|
|
2531
|
+
_context26.prev = 0;
|
|
2532
|
+
_context26.next = 3;
|
|
2495
2533
|
return this._networkClient.fetchSDK({
|
|
2496
2534
|
url: "/sessions/revoke",
|
|
2497
2535
|
method: 'POST'
|
|
2498
2536
|
});
|
|
2499
2537
|
case 3:
|
|
2500
|
-
resp =
|
|
2538
|
+
resp = _context26.sent;
|
|
2501
2539
|
this._subscriptionService.destroyState();
|
|
2502
|
-
return
|
|
2540
|
+
return _context26.abrupt("return", resp);
|
|
2503
2541
|
case 8:
|
|
2504
|
-
|
|
2505
|
-
|
|
2542
|
+
_context26.prev = 8;
|
|
2543
|
+
_context26.t0 = _context26["catch"](0);
|
|
2506
2544
|
if (!!(options === null || options === void 0 ? void 0 : options.forceClear)) {
|
|
2507
2545
|
this._subscriptionService.destroyState();
|
|
2508
|
-
} else if (UNRECOVERABLE_ERROR_TYPES.includes(
|
|
2546
|
+
} else if (UNRECOVERABLE_ERROR_TYPES.includes(_context26.t0.error_type)) {
|
|
2509
2547
|
this._subscriptionService.destroyState();
|
|
2510
2548
|
}
|
|
2511
|
-
throw
|
|
2549
|
+
throw _context26.t0;
|
|
2512
2550
|
case 12:
|
|
2513
2551
|
case "end":
|
|
2514
|
-
return
|
|
2552
|
+
return _context26.stop();
|
|
2515
2553
|
}
|
|
2516
|
-
},
|
|
2554
|
+
}, _callee26, this, [[0, 8]]);
|
|
2517
2555
|
}));
|
|
2518
2556
|
};
|
|
2519
2557
|
this.authenticate = function (options) {
|
|
2520
|
-
return __awaiter$1(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2558
|
+
return __awaiter$1(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
2521
2559
|
var _this5 = this;
|
|
2522
2560
|
var initialSession, isSessionStale, requestBody, resp;
|
|
2523
|
-
return _regeneratorRuntime().wrap(function
|
|
2524
|
-
while (1) switch (
|
|
2561
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2562
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2525
2563
|
case 0:
|
|
2526
2564
|
initialSession = this._subscriptionService.getSession();
|
|
2527
2565
|
isSessionStale = function isSessionStale() {
|
|
2528
2566
|
var _a;
|
|
2529
2567
|
return (initialSession === null || initialSession === void 0 ? void 0 : initialSession.session_id) !== ((_a = _this5._subscriptionService.getSession()) === null || _a === void 0 ? void 0 : _a.session_id);
|
|
2530
2568
|
};
|
|
2531
|
-
|
|
2569
|
+
_context27.prev = 2;
|
|
2532
2570
|
requestBody = {
|
|
2533
2571
|
session_duration_minutes: options === null || options === void 0 ? void 0 : options.session_duration_minutes
|
|
2534
2572
|
};
|
|
2535
|
-
|
|
2573
|
+
_context27.next = 6;
|
|
2536
2574
|
return this._networkClient.fetchSDK({
|
|
2537
2575
|
url: '/sessions/authenticate',
|
|
2538
2576
|
body: requestBody,
|
|
2539
2577
|
method: 'POST'
|
|
2540
2578
|
});
|
|
2541
2579
|
case 6:
|
|
2542
|
-
resp =
|
|
2580
|
+
resp = _context27.sent;
|
|
2543
2581
|
if (!isSessionStale()) {
|
|
2544
|
-
|
|
2582
|
+
_context27.next = 9;
|
|
2545
2583
|
break;
|
|
2546
2584
|
}
|
|
2547
|
-
return
|
|
2585
|
+
return _context27.abrupt("return", this.authenticate(options));
|
|
2548
2586
|
case 9:
|
|
2549
2587
|
this._subscriptionService.updateSession(resp);
|
|
2550
|
-
return
|
|
2588
|
+
return _context27.abrupt("return", omitUser(resp));
|
|
2551
2589
|
case 13:
|
|
2552
|
-
|
|
2553
|
-
|
|
2590
|
+
_context27.prev = 13;
|
|
2591
|
+
_context27.t0 = _context27["catch"](2);
|
|
2554
2592
|
if (!isSessionStale()) {
|
|
2555
|
-
|
|
2593
|
+
_context27.next = 17;
|
|
2556
2594
|
break;
|
|
2557
2595
|
}
|
|
2558
|
-
return
|
|
2596
|
+
return _context27.abrupt("return", this.authenticate(options));
|
|
2559
2597
|
case 17:
|
|
2560
|
-
if (UNRECOVERABLE_ERROR_TYPES.includes(
|
|
2598
|
+
if (UNRECOVERABLE_ERROR_TYPES.includes(_context27.t0.error_type)) {
|
|
2561
2599
|
this._subscriptionService.destroySession();
|
|
2562
2600
|
}
|
|
2563
|
-
throw
|
|
2601
|
+
throw _context27.t0;
|
|
2564
2602
|
case 19:
|
|
2565
2603
|
case "end":
|
|
2566
|
-
return
|
|
2604
|
+
return _context27.stop();
|
|
2567
2605
|
}
|
|
2568
|
-
},
|
|
2606
|
+
}, _callee27, this, [[2, 13]]);
|
|
2569
2607
|
}));
|
|
2570
2608
|
};
|
|
2571
2609
|
this.exchangeAccessToken = function (data) {
|
|
2572
|
-
return __awaiter$1(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2610
|
+
return __awaiter$1(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
2573
2611
|
var resp;
|
|
2574
|
-
return _regeneratorRuntime().wrap(function
|
|
2575
|
-
while (1) switch (
|
|
2612
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2613
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2576
2614
|
case 0:
|
|
2577
2615
|
validate('stytch.session.exchangeAccessToken').isString('access_token', data.access_token).isNumber('session_duration_minutes', data.session_duration_minutes);
|
|
2578
|
-
|
|
2616
|
+
_context28.next = 3;
|
|
2579
2617
|
return this._networkClient.fetchSDK({
|
|
2580
2618
|
url: '/sessions/exchange_access_token',
|
|
2581
2619
|
body: data,
|
|
2582
2620
|
method: 'POST'
|
|
2583
2621
|
});
|
|
2584
2622
|
case 3:
|
|
2585
|
-
resp =
|
|
2623
|
+
resp = _context28.sent;
|
|
2586
2624
|
this._subscriptionService.updateSession(resp);
|
|
2587
|
-
return
|
|
2625
|
+
return _context28.abrupt("return", omitUser(resp));
|
|
2588
2626
|
case 6:
|
|
2589
2627
|
case "end":
|
|
2590
|
-
return
|
|
2628
|
+
return _context28.stop();
|
|
2591
2629
|
}
|
|
2592
|
-
},
|
|
2630
|
+
}, _callee28, this);
|
|
2593
2631
|
}));
|
|
2594
2632
|
};
|
|
2595
2633
|
}
|
|
@@ -2625,30 +2663,30 @@ var HeadlessMagicLinksClient = /*#__PURE__*/function () {
|
|
|
2625
2663
|
this.email = {
|
|
2626
2664
|
loginOrCreate: function loginOrCreate(email) {
|
|
2627
2665
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2628
|
-
return __awaiter$1(_this6, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2666
|
+
return __awaiter$1(_this6, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
2629
2667
|
var _yield$this$_config, pkceRequiredForEmailMagicLinks, code_challenge, _yield$this$dfpProtec, dfp_telemetry_id, captcha_token, requestBody;
|
|
2630
|
-
return _regeneratorRuntime().wrap(function
|
|
2631
|
-
while (1) switch (
|
|
2668
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2669
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2632
2670
|
case 0:
|
|
2633
|
-
|
|
2671
|
+
_context29.next = 2;
|
|
2634
2672
|
return this._config;
|
|
2635
2673
|
case 2:
|
|
2636
|
-
_yield$this$_config =
|
|
2674
|
+
_yield$this$_config = _context29.sent;
|
|
2637
2675
|
pkceRequiredForEmailMagicLinks = _yield$this$_config.pkceRequiredForEmailMagicLinks;
|
|
2638
2676
|
code_challenge = undefined;
|
|
2639
2677
|
if (!pkceRequiredForEmailMagicLinks) {
|
|
2640
|
-
|
|
2678
|
+
_context29.next = 9;
|
|
2641
2679
|
break;
|
|
2642
2680
|
}
|
|
2643
|
-
|
|
2681
|
+
_context29.next = 8;
|
|
2644
2682
|
return this.getCodeChallenge();
|
|
2645
2683
|
case 8:
|
|
2646
|
-
code_challenge =
|
|
2684
|
+
code_challenge = _context29.sent;
|
|
2647
2685
|
case 9:
|
|
2648
|
-
|
|
2686
|
+
_context29.next = 11;
|
|
2649
2687
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
2650
2688
|
case 11:
|
|
2651
|
-
_yield$this$dfpProtec =
|
|
2689
|
+
_yield$this$dfpProtec = _context29.sent;
|
|
2652
2690
|
dfp_telemetry_id = _yield$this$dfpProtec.dfp_telemetry_id;
|
|
2653
2691
|
captcha_token = _yield$this$dfpProtec.captcha_token;
|
|
2654
2692
|
requestBody = Object.assign(Object.assign({}, options), {
|
|
@@ -2657,7 +2695,7 @@ var HeadlessMagicLinksClient = /*#__PURE__*/function () {
|
|
|
2657
2695
|
captcha_token: captcha_token,
|
|
2658
2696
|
dfp_telemetry_id: dfp_telemetry_id
|
|
2659
2697
|
});
|
|
2660
|
-
return
|
|
2698
|
+
return _context29.abrupt("return", this._networkClient.retriableFetchSDK({
|
|
2661
2699
|
url: '/magic_links/email/login_or_create',
|
|
2662
2700
|
body: requestBody,
|
|
2663
2701
|
method: 'POST',
|
|
@@ -2665,37 +2703,37 @@ var HeadlessMagicLinksClient = /*#__PURE__*/function () {
|
|
|
2665
2703
|
}));
|
|
2666
2704
|
case 16:
|
|
2667
2705
|
case "end":
|
|
2668
|
-
return
|
|
2706
|
+
return _context29.stop();
|
|
2669
2707
|
}
|
|
2670
|
-
},
|
|
2708
|
+
}, _callee29, this);
|
|
2671
2709
|
}));
|
|
2672
2710
|
},
|
|
2673
2711
|
send: function send(email) {
|
|
2674
2712
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2675
|
-
return __awaiter$1(_this6, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2713
|
+
return __awaiter$1(_this6, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2676
2714
|
var _yield$this$_config2, pkceRequiredForEmailMagicLinks, code_challenge, _yield$this$dfpProtec2, dfp_telemetry_id, captcha_token, requestBody, isLoggedIn, endpoint;
|
|
2677
|
-
return _regeneratorRuntime().wrap(function
|
|
2678
|
-
while (1) switch (
|
|
2715
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2716
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2679
2717
|
case 0:
|
|
2680
|
-
|
|
2718
|
+
_context30.next = 2;
|
|
2681
2719
|
return this._config;
|
|
2682
2720
|
case 2:
|
|
2683
|
-
_yield$this$_config2 =
|
|
2721
|
+
_yield$this$_config2 = _context30.sent;
|
|
2684
2722
|
pkceRequiredForEmailMagicLinks = _yield$this$_config2.pkceRequiredForEmailMagicLinks;
|
|
2685
2723
|
code_challenge = undefined;
|
|
2686
2724
|
if (!pkceRequiredForEmailMagicLinks) {
|
|
2687
|
-
|
|
2725
|
+
_context30.next = 9;
|
|
2688
2726
|
break;
|
|
2689
2727
|
}
|
|
2690
|
-
|
|
2728
|
+
_context30.next = 8;
|
|
2691
2729
|
return this.getCodeChallenge();
|
|
2692
2730
|
case 8:
|
|
2693
|
-
code_challenge =
|
|
2731
|
+
code_challenge = _context30.sent;
|
|
2694
2732
|
case 9:
|
|
2695
|
-
|
|
2733
|
+
_context30.next = 11;
|
|
2696
2734
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
2697
2735
|
case 11:
|
|
2698
|
-
_yield$this$dfpProtec2 =
|
|
2736
|
+
_yield$this$dfpProtec2 = _context30.sent;
|
|
2699
2737
|
dfp_telemetry_id = _yield$this$dfpProtec2.dfp_telemetry_id;
|
|
2700
2738
|
captcha_token = _yield$this$dfpProtec2.captcha_token;
|
|
2701
2739
|
requestBody = Object.assign(Object.assign({}, options), {
|
|
@@ -2706,7 +2744,7 @@ var HeadlessMagicLinksClient = /*#__PURE__*/function () {
|
|
|
2706
2744
|
});
|
|
2707
2745
|
isLoggedIn = !!this._subscriptionService.getSession();
|
|
2708
2746
|
endpoint = isLoggedIn ? '/magic_links/email/send/secondary' : '/magic_links/email/send/primary';
|
|
2709
|
-
return
|
|
2747
|
+
return _context30.abrupt("return", this._networkClient.retriableFetchSDK({
|
|
2710
2748
|
url: endpoint,
|
|
2711
2749
|
body: requestBody,
|
|
2712
2750
|
method: 'POST',
|
|
@@ -2714,131 +2752,131 @@ var HeadlessMagicLinksClient = /*#__PURE__*/function () {
|
|
|
2714
2752
|
}));
|
|
2715
2753
|
case 18:
|
|
2716
2754
|
case "end":
|
|
2717
|
-
return
|
|
2755
|
+
return _context30.stop();
|
|
2718
2756
|
}
|
|
2719
|
-
},
|
|
2757
|
+
}, _callee30, this);
|
|
2720
2758
|
}));
|
|
2721
2759
|
}
|
|
2722
2760
|
};
|
|
2723
2761
|
this.authenticate = function (token, options) {
|
|
2724
|
-
return __awaiter$1(_this6, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2762
|
+
return __awaiter$1(_this6, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
2725
2763
|
var passwordResetPKPair, resp;
|
|
2726
|
-
return _regeneratorRuntime().wrap(function
|
|
2727
|
-
while (1) switch (
|
|
2764
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2765
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2728
2766
|
case 0:
|
|
2729
2767
|
validate('stytch.magicLinks.authenticate').isString('Token', token).isNumber('session_duration_minutes', options.session_duration_minutes);
|
|
2730
|
-
|
|
2768
|
+
_context31.next = 3;
|
|
2731
2769
|
return this._passwordResetPKCEManager.getPKPair();
|
|
2732
2770
|
case 3:
|
|
2733
|
-
passwordResetPKPair =
|
|
2771
|
+
passwordResetPKPair = _context31.sent;
|
|
2734
2772
|
resp = null;
|
|
2735
2773
|
if (!(passwordResetPKPair === null || passwordResetPKPair === void 0 ? void 0 : passwordResetPKPair.code_verifier)) {
|
|
2736
|
-
|
|
2774
|
+
_context31.next = 19;
|
|
2737
2775
|
break;
|
|
2738
2776
|
}
|
|
2739
|
-
|
|
2740
|
-
|
|
2777
|
+
_context31.prev = 6;
|
|
2778
|
+
_context31.next = 9;
|
|
2741
2779
|
return this.handlePKCEForAuthenticate(this._passwordResetPKCEManager, Object.assign(Object.assign({}, options), {
|
|
2742
2780
|
token: token
|
|
2743
2781
|
}));
|
|
2744
2782
|
case 9:
|
|
2745
|
-
resp =
|
|
2746
|
-
|
|
2783
|
+
resp = _context31.sent;
|
|
2784
|
+
_context31.next = 19;
|
|
2747
2785
|
break;
|
|
2748
2786
|
case 12:
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
if (!
|
|
2752
|
-
|
|
2787
|
+
_context31.prev = 12;
|
|
2788
|
+
_context31.t0 = _context31["catch"](6);
|
|
2789
|
+
if (!_context31.t0.message.includes('pkce')) {
|
|
2790
|
+
_context31.next = 18;
|
|
2753
2791
|
break;
|
|
2754
2792
|
}
|
|
2755
2793
|
console.log('Authenticate with passwords pkce namespace failed. Falling back to authenticate with magic_links namespace.');
|
|
2756
|
-
|
|
2794
|
+
_context31.next = 19;
|
|
2757
2795
|
break;
|
|
2758
2796
|
case 18:
|
|
2759
|
-
throw
|
|
2797
|
+
throw _context31.t0;
|
|
2760
2798
|
case 19:
|
|
2761
2799
|
if (resp) {
|
|
2762
|
-
|
|
2800
|
+
_context31.next = 23;
|
|
2763
2801
|
break;
|
|
2764
2802
|
}
|
|
2765
|
-
|
|
2803
|
+
_context31.next = 22;
|
|
2766
2804
|
return this.handlePKCEForAuthenticate(this._pkceManager, Object.assign(Object.assign({}, options), {
|
|
2767
2805
|
token: token
|
|
2768
2806
|
}));
|
|
2769
2807
|
case 22:
|
|
2770
|
-
resp =
|
|
2808
|
+
resp = _context31.sent;
|
|
2771
2809
|
case 23:
|
|
2772
2810
|
this._subscriptionService.updateSession(resp);
|
|
2773
|
-
return
|
|
2811
|
+
return _context31.abrupt("return", omitUser(resp));
|
|
2774
2812
|
case 25:
|
|
2775
2813
|
case "end":
|
|
2776
|
-
return
|
|
2814
|
+
return _context31.stop();
|
|
2777
2815
|
}
|
|
2778
|
-
},
|
|
2816
|
+
}, _callee31, this, [[6, 12]]);
|
|
2779
2817
|
}));
|
|
2780
2818
|
};
|
|
2781
2819
|
}
|
|
2782
2820
|
return _createClass(HeadlessMagicLinksClient, [{
|
|
2783
2821
|
key: "getCodeChallenge",
|
|
2784
2822
|
value: function getCodeChallenge() {
|
|
2785
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2823
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
2786
2824
|
var keyPair;
|
|
2787
|
-
return _regeneratorRuntime().wrap(function
|
|
2788
|
-
while (1) switch (
|
|
2825
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2826
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2789
2827
|
case 0:
|
|
2790
|
-
|
|
2828
|
+
_context32.next = 2;
|
|
2791
2829
|
return this._pkceManager.getPKPair();
|
|
2792
2830
|
case 2:
|
|
2793
|
-
keyPair =
|
|
2831
|
+
keyPair = _context32.sent;
|
|
2794
2832
|
if (!keyPair) {
|
|
2795
|
-
|
|
2833
|
+
_context32.next = 5;
|
|
2796
2834
|
break;
|
|
2797
2835
|
}
|
|
2798
|
-
return
|
|
2836
|
+
return _context32.abrupt("return", keyPair.code_challenge);
|
|
2799
2837
|
case 5:
|
|
2800
|
-
|
|
2838
|
+
_context32.next = 7;
|
|
2801
2839
|
return this._pkceManager.startPKCETransaction();
|
|
2802
2840
|
case 7:
|
|
2803
|
-
keyPair =
|
|
2804
|
-
return
|
|
2841
|
+
keyPair = _context32.sent;
|
|
2842
|
+
return _context32.abrupt("return", keyPair.code_challenge);
|
|
2805
2843
|
case 9:
|
|
2806
2844
|
case "end":
|
|
2807
|
-
return
|
|
2845
|
+
return _context32.stop();
|
|
2808
2846
|
}
|
|
2809
|
-
},
|
|
2847
|
+
}, _callee32, this);
|
|
2810
2848
|
}));
|
|
2811
2849
|
}
|
|
2812
2850
|
}, {
|
|
2813
2851
|
key: "handlePKCEForAuthenticate",
|
|
2814
2852
|
value: function handlePKCEForAuthenticate(pkceManager, data) {
|
|
2815
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2853
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2816
2854
|
var pkPair, requestBody, resp;
|
|
2817
|
-
return _regeneratorRuntime().wrap(function
|
|
2818
|
-
while (1) switch (
|
|
2855
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2856
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2819
2857
|
case 0:
|
|
2820
|
-
|
|
2858
|
+
_context33.next = 2;
|
|
2821
2859
|
return pkceManager.getPKPair();
|
|
2822
2860
|
case 2:
|
|
2823
|
-
pkPair =
|
|
2861
|
+
pkPair = _context33.sent;
|
|
2824
2862
|
requestBody = Object.assign({
|
|
2825
2863
|
code_verifier: pkPair === null || pkPair === void 0 ? void 0 : pkPair.code_verifier
|
|
2826
2864
|
}, data);
|
|
2827
|
-
|
|
2865
|
+
_context33.next = 6;
|
|
2828
2866
|
return this._networkClient.fetchSDK({
|
|
2829
2867
|
url: '/magic_links/authenticate',
|
|
2830
2868
|
body: requestBody,
|
|
2831
2869
|
method: 'POST'
|
|
2832
2870
|
});
|
|
2833
2871
|
case 6:
|
|
2834
|
-
resp =
|
|
2872
|
+
resp = _context33.sent;
|
|
2835
2873
|
pkceManager.clearPKPair();
|
|
2836
|
-
return
|
|
2874
|
+
return _context33.abrupt("return", resp);
|
|
2837
2875
|
case 9:
|
|
2838
2876
|
case "end":
|
|
2839
|
-
return
|
|
2877
|
+
return _context33.stop();
|
|
2840
2878
|
}
|
|
2841
|
-
},
|
|
2879
|
+
}, _callee33, this);
|
|
2842
2880
|
}));
|
|
2843
2881
|
}
|
|
2844
2882
|
}]);
|
|
@@ -2856,15 +2894,15 @@ var HeadlessOTPClient = /*#__PURE__*/_createClass(function HeadlessOTPClient(_ne
|
|
|
2856
2894
|
this.dfpProtectedAuth = dfpProtectedAuth;
|
|
2857
2895
|
this.sms = {
|
|
2858
2896
|
loginOrCreate: function loginOrCreate(phone_number, options) {
|
|
2859
|
-
return __awaiter$1(_this7, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2897
|
+
return __awaiter$1(_this7, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
2860
2898
|
var _yield$this$dfpProtec3, dfp_telemetry_id, captcha_token, requestBody;
|
|
2861
|
-
return _regeneratorRuntime().wrap(function
|
|
2862
|
-
while (1) switch (
|
|
2899
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2900
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
2863
2901
|
case 0:
|
|
2864
|
-
|
|
2902
|
+
_context34.next = 2;
|
|
2865
2903
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
2866
2904
|
case 2:
|
|
2867
|
-
_yield$this$dfpProtec3 =
|
|
2905
|
+
_yield$this$dfpProtec3 = _context34.sent;
|
|
2868
2906
|
dfp_telemetry_id = _yield$this$dfpProtec3.dfp_telemetry_id;
|
|
2869
2907
|
captcha_token = _yield$this$dfpProtec3.captcha_token;
|
|
2870
2908
|
requestBody = Object.assign(Object.assign({}, options), {
|
|
@@ -2872,7 +2910,7 @@ var HeadlessOTPClient = /*#__PURE__*/_createClass(function HeadlessOTPClient(_ne
|
|
|
2872
2910
|
captcha_token: captcha_token,
|
|
2873
2911
|
dfp_telemetry_id: dfp_telemetry_id
|
|
2874
2912
|
});
|
|
2875
|
-
return
|
|
2913
|
+
return _context34.abrupt("return", this._networkClient.retriableFetchSDK({
|
|
2876
2914
|
url: '/otps/sms/login_or_create',
|
|
2877
2915
|
body: requestBody,
|
|
2878
2916
|
method: 'POST',
|
|
@@ -2880,21 +2918,21 @@ var HeadlessOTPClient = /*#__PURE__*/_createClass(function HeadlessOTPClient(_ne
|
|
|
2880
2918
|
}));
|
|
2881
2919
|
case 7:
|
|
2882
2920
|
case "end":
|
|
2883
|
-
return
|
|
2921
|
+
return _context34.stop();
|
|
2884
2922
|
}
|
|
2885
|
-
},
|
|
2923
|
+
}, _callee34, this);
|
|
2886
2924
|
}));
|
|
2887
2925
|
},
|
|
2888
2926
|
send: function send(phone_number, options) {
|
|
2889
|
-
return __awaiter$1(_this7, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2927
|
+
return __awaiter$1(_this7, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
|
|
2890
2928
|
var _yield$this$dfpProtec4, dfp_telemetry_id, captcha_token, requestBody, isLoggedIn, endpoint;
|
|
2891
|
-
return _regeneratorRuntime().wrap(function
|
|
2892
|
-
while (1) switch (
|
|
2929
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2930
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
2893
2931
|
case 0:
|
|
2894
|
-
|
|
2932
|
+
_context35.next = 2;
|
|
2895
2933
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
2896
2934
|
case 2:
|
|
2897
|
-
_yield$this$dfpProtec4 =
|
|
2935
|
+
_yield$this$dfpProtec4 = _context35.sent;
|
|
2898
2936
|
dfp_telemetry_id = _yield$this$dfpProtec4.dfp_telemetry_id;
|
|
2899
2937
|
captcha_token = _yield$this$dfpProtec4.captcha_token;
|
|
2900
2938
|
requestBody = Object.assign(Object.assign({}, options), {
|
|
@@ -2904,7 +2942,7 @@ var HeadlessOTPClient = /*#__PURE__*/_createClass(function HeadlessOTPClient(_ne
|
|
|
2904
2942
|
});
|
|
2905
2943
|
isLoggedIn = !!this._subscriptionService.getSession();
|
|
2906
2944
|
endpoint = isLoggedIn ? '/otps/sms/send/secondary' : '/otps/sms/send/primary';
|
|
2907
|
-
return
|
|
2945
|
+
return _context35.abrupt("return", this._networkClient.retriableFetchSDK({
|
|
2908
2946
|
url: endpoint,
|
|
2909
2947
|
body: requestBody,
|
|
2910
2948
|
method: 'POST',
|
|
@@ -2912,23 +2950,23 @@ var HeadlessOTPClient = /*#__PURE__*/_createClass(function HeadlessOTPClient(_ne
|
|
|
2912
2950
|
}));
|
|
2913
2951
|
case 9:
|
|
2914
2952
|
case "end":
|
|
2915
|
-
return
|
|
2953
|
+
return _context35.stop();
|
|
2916
2954
|
}
|
|
2917
|
-
},
|
|
2955
|
+
}, _callee35, this);
|
|
2918
2956
|
}));
|
|
2919
2957
|
}
|
|
2920
2958
|
};
|
|
2921
2959
|
this.whatsapp = {
|
|
2922
2960
|
loginOrCreate: function loginOrCreate(phone_number, options) {
|
|
2923
|
-
return __awaiter$1(_this7, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2961
|
+
return __awaiter$1(_this7, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
|
|
2924
2962
|
var _yield$this$dfpProtec5, dfp_telemetry_id, captcha_token, requestBody;
|
|
2925
|
-
return _regeneratorRuntime().wrap(function
|
|
2926
|
-
while (1) switch (
|
|
2963
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2964
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
2927
2965
|
case 0:
|
|
2928
|
-
|
|
2966
|
+
_context36.next = 2;
|
|
2929
2967
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
2930
2968
|
case 2:
|
|
2931
|
-
_yield$this$dfpProtec5 =
|
|
2969
|
+
_yield$this$dfpProtec5 = _context36.sent;
|
|
2932
2970
|
dfp_telemetry_id = _yield$this$dfpProtec5.dfp_telemetry_id;
|
|
2933
2971
|
captcha_token = _yield$this$dfpProtec5.captcha_token;
|
|
2934
2972
|
requestBody = Object.assign(Object.assign({}, options), {
|
|
@@ -2936,7 +2974,7 @@ var HeadlessOTPClient = /*#__PURE__*/_createClass(function HeadlessOTPClient(_ne
|
|
|
2936
2974
|
dfp_telemetry_id: dfp_telemetry_id,
|
|
2937
2975
|
captcha_token: captcha_token
|
|
2938
2976
|
});
|
|
2939
|
-
return
|
|
2977
|
+
return _context36.abrupt("return", this._networkClient.retriableFetchSDK({
|
|
2940
2978
|
url: '/otps/whatsapp/login_or_create',
|
|
2941
2979
|
body: requestBody,
|
|
2942
2980
|
method: 'POST',
|
|
@@ -2944,21 +2982,21 @@ var HeadlessOTPClient = /*#__PURE__*/_createClass(function HeadlessOTPClient(_ne
|
|
|
2944
2982
|
}));
|
|
2945
2983
|
case 7:
|
|
2946
2984
|
case "end":
|
|
2947
|
-
return
|
|
2985
|
+
return _context36.stop();
|
|
2948
2986
|
}
|
|
2949
|
-
},
|
|
2987
|
+
}, _callee36, this);
|
|
2950
2988
|
}));
|
|
2951
2989
|
},
|
|
2952
2990
|
send: function send(phone_number, options) {
|
|
2953
|
-
return __awaiter$1(_this7, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2991
|
+
return __awaiter$1(_this7, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
|
|
2954
2992
|
var _yield$this$dfpProtec6, dfp_telemetry_id, captcha_token, requestBody, isLoggedIn, endpoint;
|
|
2955
|
-
return _regeneratorRuntime().wrap(function
|
|
2956
|
-
while (1) switch (
|
|
2993
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
2994
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
2957
2995
|
case 0:
|
|
2958
|
-
|
|
2996
|
+
_context37.next = 2;
|
|
2959
2997
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
2960
2998
|
case 2:
|
|
2961
|
-
_yield$this$dfpProtec6 =
|
|
2999
|
+
_yield$this$dfpProtec6 = _context37.sent;
|
|
2962
3000
|
dfp_telemetry_id = _yield$this$dfpProtec6.dfp_telemetry_id;
|
|
2963
3001
|
captcha_token = _yield$this$dfpProtec6.captcha_token;
|
|
2964
3002
|
requestBody = Object.assign(Object.assign({}, options), {
|
|
@@ -2968,7 +3006,7 @@ var HeadlessOTPClient = /*#__PURE__*/_createClass(function HeadlessOTPClient(_ne
|
|
|
2968
3006
|
});
|
|
2969
3007
|
isLoggedIn = !!this._subscriptionService.getSession();
|
|
2970
3008
|
endpoint = isLoggedIn ? '/otps/whatsapp/send/secondary' : '/otps/whatsapp/send/primary';
|
|
2971
|
-
return
|
|
3009
|
+
return _context37.abrupt("return", this._networkClient.retriableFetchSDK({
|
|
2972
3010
|
url: endpoint,
|
|
2973
3011
|
body: requestBody,
|
|
2974
3012
|
method: 'POST',
|
|
@@ -2976,23 +3014,23 @@ var HeadlessOTPClient = /*#__PURE__*/_createClass(function HeadlessOTPClient(_ne
|
|
|
2976
3014
|
}));
|
|
2977
3015
|
case 9:
|
|
2978
3016
|
case "end":
|
|
2979
|
-
return
|
|
3017
|
+
return _context37.stop();
|
|
2980
3018
|
}
|
|
2981
|
-
},
|
|
3019
|
+
}, _callee37, this);
|
|
2982
3020
|
}));
|
|
2983
3021
|
}
|
|
2984
3022
|
};
|
|
2985
3023
|
this.email = {
|
|
2986
3024
|
loginOrCreate: function loginOrCreate(email, options) {
|
|
2987
|
-
return __awaiter$1(_this7, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3025
|
+
return __awaiter$1(_this7, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
|
|
2988
3026
|
var _yield$this$dfpProtec7, dfp_telemetry_id, captcha_token, requestBody;
|
|
2989
|
-
return _regeneratorRuntime().wrap(function
|
|
2990
|
-
while (1) switch (
|
|
3027
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3028
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
2991
3029
|
case 0:
|
|
2992
|
-
|
|
3030
|
+
_context38.next = 2;
|
|
2993
3031
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
2994
3032
|
case 2:
|
|
2995
|
-
_yield$this$dfpProtec7 =
|
|
3033
|
+
_yield$this$dfpProtec7 = _context38.sent;
|
|
2996
3034
|
dfp_telemetry_id = _yield$this$dfpProtec7.dfp_telemetry_id;
|
|
2997
3035
|
captcha_token = _yield$this$dfpProtec7.captcha_token;
|
|
2998
3036
|
requestBody = Object.assign(Object.assign({}, options), {
|
|
@@ -3000,7 +3038,7 @@ var HeadlessOTPClient = /*#__PURE__*/_createClass(function HeadlessOTPClient(_ne
|
|
|
3000
3038
|
captcha_token: captcha_token,
|
|
3001
3039
|
dfp_telemetry_id: dfp_telemetry_id
|
|
3002
3040
|
});
|
|
3003
|
-
return
|
|
3041
|
+
return _context38.abrupt("return", this._networkClient.retriableFetchSDK({
|
|
3004
3042
|
url: '/otps/email/login_or_create',
|
|
3005
3043
|
body: requestBody,
|
|
3006
3044
|
method: 'POST',
|
|
@@ -3008,51 +3046,51 @@ var HeadlessOTPClient = /*#__PURE__*/_createClass(function HeadlessOTPClient(_ne
|
|
|
3008
3046
|
}));
|
|
3009
3047
|
case 7:
|
|
3010
3048
|
case "end":
|
|
3011
|
-
return
|
|
3049
|
+
return _context38.stop();
|
|
3012
3050
|
}
|
|
3013
|
-
},
|
|
3051
|
+
}, _callee38, this);
|
|
3014
3052
|
}));
|
|
3015
3053
|
},
|
|
3016
3054
|
send: function send(email, options) {
|
|
3017
|
-
return __awaiter$1(_this7, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3055
|
+
return __awaiter$1(_this7, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
|
|
3018
3056
|
var captcha_token, requestBody, isLoggedIn, endpoint;
|
|
3019
|
-
return _regeneratorRuntime().wrap(function
|
|
3020
|
-
while (1) switch (
|
|
3057
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3058
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3021
3059
|
case 0:
|
|
3022
|
-
|
|
3060
|
+
_context39.next = 2;
|
|
3023
3061
|
return this.executeRecaptcha();
|
|
3024
3062
|
case 2:
|
|
3025
|
-
captcha_token =
|
|
3063
|
+
captcha_token = _context39.sent;
|
|
3026
3064
|
requestBody = Object.assign(Object.assign({}, options), {
|
|
3027
3065
|
email: email,
|
|
3028
3066
|
captcha_token: captcha_token
|
|
3029
3067
|
});
|
|
3030
3068
|
isLoggedIn = !!this._subscriptionService.getSession();
|
|
3031
3069
|
endpoint = isLoggedIn ? '/otps/email/send/secondary' : '/otps/email/send/primary';
|
|
3032
|
-
return
|
|
3070
|
+
return _context39.abrupt("return", this._networkClient.fetchSDK({
|
|
3033
3071
|
url: endpoint,
|
|
3034
3072
|
body: requestBody,
|
|
3035
3073
|
method: 'POST'
|
|
3036
3074
|
}));
|
|
3037
3075
|
case 7:
|
|
3038
3076
|
case "end":
|
|
3039
|
-
return
|
|
3077
|
+
return _context39.stop();
|
|
3040
3078
|
}
|
|
3041
|
-
},
|
|
3079
|
+
}, _callee39, this);
|
|
3042
3080
|
}));
|
|
3043
3081
|
}
|
|
3044
3082
|
};
|
|
3045
3083
|
this.authenticate = function (code, method_id, options) {
|
|
3046
|
-
return __awaiter$1(_this7, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3084
|
+
return __awaiter$1(_this7, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
|
|
3047
3085
|
var _yield$this$dfpProtec8, dfp_telemetry_id, captcha_token, requestBody, resp;
|
|
3048
|
-
return _regeneratorRuntime().wrap(function
|
|
3049
|
-
while (1) switch (
|
|
3086
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3087
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3050
3088
|
case 0:
|
|
3051
3089
|
validate('stytch.otps.authenticate').isString('Code', code).isNumber('session_duration_minutes', options.session_duration_minutes);
|
|
3052
|
-
|
|
3090
|
+
_context40.next = 3;
|
|
3053
3091
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
3054
3092
|
case 3:
|
|
3055
|
-
_yield$this$dfpProtec8 =
|
|
3093
|
+
_yield$this$dfpProtec8 = _context40.sent;
|
|
3056
3094
|
dfp_telemetry_id = _yield$this$dfpProtec8.dfp_telemetry_id;
|
|
3057
3095
|
captcha_token = _yield$this$dfpProtec8.captcha_token;
|
|
3058
3096
|
requestBody = Object.assign({
|
|
@@ -3061,7 +3099,7 @@ var HeadlessOTPClient = /*#__PURE__*/_createClass(function HeadlessOTPClient(_ne
|
|
|
3061
3099
|
dfp_telemetry_id: dfp_telemetry_id,
|
|
3062
3100
|
captcha_token: captcha_token
|
|
3063
3101
|
}, options);
|
|
3064
|
-
|
|
3102
|
+
_context40.next = 9;
|
|
3065
3103
|
return this._networkClient.retriableFetchSDK({
|
|
3066
3104
|
url: '/otps/authenticate',
|
|
3067
3105
|
body: requestBody,
|
|
@@ -3069,14 +3107,14 @@ var HeadlessOTPClient = /*#__PURE__*/_createClass(function HeadlessOTPClient(_ne
|
|
|
3069
3107
|
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
3070
3108
|
});
|
|
3071
3109
|
case 9:
|
|
3072
|
-
resp =
|
|
3110
|
+
resp = _context40.sent;
|
|
3073
3111
|
this._subscriptionService.updateSession(resp);
|
|
3074
|
-
return
|
|
3112
|
+
return _context40.abrupt("return", omitUser(resp));
|
|
3075
3113
|
case 12:
|
|
3076
3114
|
case "end":
|
|
3077
|
-
return
|
|
3115
|
+
return _context40.stop();
|
|
3078
3116
|
}
|
|
3079
|
-
},
|
|
3117
|
+
}, _callee40, this);
|
|
3080
3118
|
}));
|
|
3081
3119
|
};
|
|
3082
3120
|
});
|
|
@@ -3149,20 +3187,20 @@ var HeadlessOAuthClient$1 = /*#__PURE__*/function () {
|
|
|
3149
3187
|
return _createClass(HeadlessOAuthClient, [{
|
|
3150
3188
|
key: "authenticate",
|
|
3151
3189
|
value: function authenticate(token, options) {
|
|
3152
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3190
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
|
|
3153
3191
|
var keyPair, resp;
|
|
3154
|
-
return _regeneratorRuntime().wrap(function
|
|
3155
|
-
while (1) switch (
|
|
3192
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3193
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3156
3194
|
case 0:
|
|
3157
3195
|
validate('stytch.oauth.authenticate').isString('Token', token).isNumber('session_duration_minutes', options.session_duration_minutes);
|
|
3158
|
-
|
|
3196
|
+
_context41.next = 3;
|
|
3159
3197
|
return this._pkceManager.getPKPair();
|
|
3160
3198
|
case 3:
|
|
3161
|
-
keyPair =
|
|
3199
|
+
keyPair = _context41.sent;
|
|
3162
3200
|
if (!keyPair) {
|
|
3163
3201
|
logger.warn('No code verifier found in local storage for OAuth flow.\n' + 'Consider using stytch.oauth.$provider.start() to add PKCE to your OAuth flows for added security.\n' + 'See https://stytch.com/docs/oauth#guides_pkce for more information.');
|
|
3164
3202
|
}
|
|
3165
|
-
|
|
3203
|
+
_context41.next = 7;
|
|
3166
3204
|
return this._networkClient.fetchSDK({
|
|
3167
3205
|
url: '/oauth/authenticate',
|
|
3168
3206
|
method: 'POST',
|
|
@@ -3172,48 +3210,48 @@ var HeadlessOAuthClient$1 = /*#__PURE__*/function () {
|
|
|
3172
3210
|
}, options)
|
|
3173
3211
|
});
|
|
3174
3212
|
case 7:
|
|
3175
|
-
resp =
|
|
3213
|
+
resp = _context41.sent;
|
|
3176
3214
|
this._pkceManager.clearPKPair();
|
|
3177
3215
|
this._subscriptionService.updateSession(resp);
|
|
3178
|
-
return
|
|
3216
|
+
return _context41.abrupt("return", omitUser(resp));
|
|
3179
3217
|
case 11:
|
|
3180
3218
|
case "end":
|
|
3181
|
-
return
|
|
3219
|
+
return _context41.stop();
|
|
3182
3220
|
}
|
|
3183
|
-
},
|
|
3221
|
+
}, _callee41, this);
|
|
3184
3222
|
}));
|
|
3185
3223
|
}
|
|
3186
3224
|
}, {
|
|
3187
3225
|
key: "getBaseApiUrl",
|
|
3188
3226
|
value: function getBaseApiUrl() {
|
|
3189
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3227
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
|
|
3190
3228
|
var _yield$this$_dynamicC, cnameDomain;
|
|
3191
|
-
return _regeneratorRuntime().wrap(function
|
|
3192
|
-
while (1) switch (
|
|
3229
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3230
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3193
3231
|
case 0:
|
|
3194
|
-
|
|
3232
|
+
_context42.next = 2;
|
|
3195
3233
|
return this._dynamicConfig;
|
|
3196
3234
|
case 2:
|
|
3197
|
-
_yield$this$_dynamicC =
|
|
3235
|
+
_yield$this$_dynamicC = _context42.sent;
|
|
3198
3236
|
cnameDomain = _yield$this$_dynamicC.cnameDomain;
|
|
3199
3237
|
if (!cnameDomain) {
|
|
3200
|
-
|
|
3238
|
+
_context42.next = 6;
|
|
3201
3239
|
break;
|
|
3202
3240
|
}
|
|
3203
|
-
return
|
|
3241
|
+
return _context42.abrupt("return", "https://".concat(cnameDomain));
|
|
3204
3242
|
case 6:
|
|
3205
3243
|
if (!isTestPublicToken(this._config.publicToken)) {
|
|
3206
|
-
|
|
3244
|
+
_context42.next = 8;
|
|
3207
3245
|
break;
|
|
3208
3246
|
}
|
|
3209
|
-
return
|
|
3247
|
+
return _context42.abrupt("return", this._config.testAPIURL);
|
|
3210
3248
|
case 8:
|
|
3211
|
-
return
|
|
3249
|
+
return _context42.abrupt("return", this._config.liveAPIURL);
|
|
3212
3250
|
case 9:
|
|
3213
3251
|
case "end":
|
|
3214
|
-
return
|
|
3252
|
+
return _context42.stop();
|
|
3215
3253
|
}
|
|
3216
|
-
},
|
|
3254
|
+
}, _callee42, this);
|
|
3217
3255
|
}));
|
|
3218
3256
|
}
|
|
3219
3257
|
}, {
|
|
@@ -3226,21 +3264,21 @@ var HeadlessOAuthClient$1 = /*#__PURE__*/function () {
|
|
|
3226
3264
|
signup_redirect_url = _ref6.signup_redirect_url,
|
|
3227
3265
|
custom_scopes = _ref6.custom_scopes,
|
|
3228
3266
|
provider_params = _ref6.provider_params;
|
|
3229
|
-
return __awaiter$1(_this8, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3267
|
+
return __awaiter$1(_this8, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
|
|
3230
3268
|
var _yield$this$_dynamicC2, cnameDomain, pkceRequiredForOAuth, baseURL, oauthUrl, keyPair, key;
|
|
3231
|
-
return _regeneratorRuntime().wrap(function
|
|
3232
|
-
while (1) switch (
|
|
3269
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3270
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
3233
3271
|
case 0:
|
|
3234
|
-
|
|
3272
|
+
_context43.next = 2;
|
|
3235
3273
|
return this._dynamicConfig;
|
|
3236
3274
|
case 2:
|
|
3237
|
-
_yield$this$_dynamicC2 =
|
|
3275
|
+
_yield$this$_dynamicC2 = _context43.sent;
|
|
3238
3276
|
cnameDomain = _yield$this$_dynamicC2.cnameDomain;
|
|
3239
3277
|
pkceRequiredForOAuth = _yield$this$_dynamicC2.pkceRequiredForOAuth;
|
|
3240
|
-
|
|
3278
|
+
_context43.next = 7;
|
|
3241
3279
|
return this.getBaseApiUrl();
|
|
3242
3280
|
case 7:
|
|
3243
|
-
baseURL =
|
|
3281
|
+
baseURL = _context43.sent;
|
|
3244
3282
|
this._networkClient.logEvent({
|
|
3245
3283
|
name: 'start_oauth_flow',
|
|
3246
3284
|
details: {
|
|
@@ -3254,15 +3292,15 @@ var HeadlessOAuthClient$1 = /*#__PURE__*/function () {
|
|
|
3254
3292
|
oauthUrl = new URL("".concat(baseURL, "/v1/public/oauth/").concat(providerType, "/start"));
|
|
3255
3293
|
oauthUrl.searchParams.set('public_token', this._config.publicToken);
|
|
3256
3294
|
if (!pkceRequiredForOAuth) {
|
|
3257
|
-
|
|
3295
|
+
_context43.next = 18;
|
|
3258
3296
|
break;
|
|
3259
3297
|
}
|
|
3260
|
-
|
|
3298
|
+
_context43.next = 14;
|
|
3261
3299
|
return this._pkceManager.startPKCETransaction();
|
|
3262
3300
|
case 14:
|
|
3263
|
-
keyPair =
|
|
3301
|
+
keyPair = _context43.sent;
|
|
3264
3302
|
oauthUrl.searchParams.set('code_challenge', keyPair.code_challenge);
|
|
3265
|
-
|
|
3303
|
+
_context43.next = 19;
|
|
3266
3304
|
break;
|
|
3267
3305
|
case 18:
|
|
3268
3306
|
this._pkceManager.clearPKPair();
|
|
@@ -3282,9 +3320,9 @@ var HeadlessOAuthClient$1 = /*#__PURE__*/function () {
|
|
|
3282
3320
|
window.location.href = oauthUrl.toString();
|
|
3283
3321
|
case 24:
|
|
3284
3322
|
case "end":
|
|
3285
|
-
return
|
|
3323
|
+
return _context43.stop();
|
|
3286
3324
|
}
|
|
3287
|
-
},
|
|
3325
|
+
}, _callee43, this);
|
|
3288
3326
|
}));
|
|
3289
3327
|
};
|
|
3290
3328
|
}
|
|
@@ -3312,24 +3350,24 @@ var HeadlessCryptoWalletClient = /*#__PURE__*/function () {
|
|
|
3312
3350
|
key: "authenticateStart",
|
|
3313
3351
|
value: function authenticateStart(options) {
|
|
3314
3352
|
var _a;
|
|
3315
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3353
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
|
|
3316
3354
|
var isLoggedIn, captcha_token, _yield$this$_config3, siweRequiredForCryptoWallets, body, endpoint, requestBody;
|
|
3317
|
-
return _regeneratorRuntime().wrap(function
|
|
3318
|
-
while (1) switch (
|
|
3355
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
3356
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
3319
3357
|
case 0:
|
|
3320
3358
|
validate('stytch.cryptoWallets.authenticateStart').isString('crypto_wallet_address', options.crypto_wallet_address).isString('crypto_wallet_type', options.crypto_wallet_type);
|
|
3321
3359
|
if (options.siwe_params) {
|
|
3322
3360
|
validate('stytch.cryptoWallets.authenticateStart').isOptionalString('uri', options.siwe_params.uri).isOptionalString('chain_id', options.siwe_params.chain_id).isOptionalString('issued_at', options.siwe_params.issued_at).isOptionalString('statement', options.siwe_params.statement).isOptionalString('not_before', options.siwe_params.not_before).isOptionalString('message_request_id', options.siwe_params.message_request_id).isOptionalStringArray('resources', options.siwe_params.resources);
|
|
3323
3361
|
}
|
|
3324
3362
|
isLoggedIn = !!this._subscriptionService.getSession();
|
|
3325
|
-
|
|
3363
|
+
_context44.next = 5;
|
|
3326
3364
|
return this.executeRecaptcha();
|
|
3327
3365
|
case 5:
|
|
3328
|
-
captcha_token =
|
|
3329
|
-
|
|
3366
|
+
captcha_token = _context44.sent;
|
|
3367
|
+
_context44.next = 8;
|
|
3330
3368
|
return this._config;
|
|
3331
3369
|
case 8:
|
|
3332
|
-
_yield$this$_config3 =
|
|
3370
|
+
_yield$this$_config3 = _context44.sent;
|
|
3333
3371
|
siweRequiredForCryptoWallets = _yield$this$_config3.siweRequiredForCryptoWallets;
|
|
3334
3372
|
body = {
|
|
3335
3373
|
crypto_wallet_address: options.crypto_wallet_address,
|
|
@@ -3344,34 +3382,34 @@ var HeadlessCryptoWalletClient = /*#__PURE__*/function () {
|
|
|
3344
3382
|
requestBody = Object.assign(Object.assign({}, body), {
|
|
3345
3383
|
captcha_token: captcha_token
|
|
3346
3384
|
});
|
|
3347
|
-
return
|
|
3385
|
+
return _context44.abrupt("return", this._apiNetworkClient.fetchSDK({
|
|
3348
3386
|
url: endpoint,
|
|
3349
3387
|
method: 'POST',
|
|
3350
3388
|
body: requestBody
|
|
3351
3389
|
}));
|
|
3352
3390
|
case 15:
|
|
3353
3391
|
case "end":
|
|
3354
|
-
return
|
|
3392
|
+
return _context44.stop();
|
|
3355
3393
|
}
|
|
3356
|
-
},
|
|
3394
|
+
}, _callee44, this);
|
|
3357
3395
|
}));
|
|
3358
3396
|
}
|
|
3359
3397
|
}, {
|
|
3360
3398
|
key: "authenticate",
|
|
3361
3399
|
value: function authenticate(options) {
|
|
3362
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3400
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
|
|
3363
3401
|
var _yield$this$dfpProtec9, dfp_telemetry_id, captcha_token, resp;
|
|
3364
|
-
return _regeneratorRuntime().wrap(function
|
|
3365
|
-
while (1) switch (
|
|
3402
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
3403
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
3366
3404
|
case 0:
|
|
3367
3405
|
validate('stytch.cryptoWallets.authenticate').isString('signature', options.signature).isString('crypto_wallet_address', options.crypto_wallet_address).isString('crypto_wallet_type', options.crypto_wallet_type).isNumber('session_duration_minutes', options.session_duration_minutes);
|
|
3368
|
-
|
|
3406
|
+
_context45.next = 3;
|
|
3369
3407
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
3370
3408
|
case 3:
|
|
3371
|
-
_yield$this$dfpProtec9 =
|
|
3409
|
+
_yield$this$dfpProtec9 = _context45.sent;
|
|
3372
3410
|
dfp_telemetry_id = _yield$this$dfpProtec9.dfp_telemetry_id;
|
|
3373
3411
|
captcha_token = _yield$this$dfpProtec9.captcha_token;
|
|
3374
|
-
|
|
3412
|
+
_context45.next = 8;
|
|
3375
3413
|
return this._apiNetworkClient.retriableFetchSDK({
|
|
3376
3414
|
url: '/crypto_wallets/authenticate',
|
|
3377
3415
|
method: 'POST',
|
|
@@ -3386,14 +3424,14 @@ var HeadlessCryptoWalletClient = /*#__PURE__*/function () {
|
|
|
3386
3424
|
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
3387
3425
|
});
|
|
3388
3426
|
case 8:
|
|
3389
|
-
resp =
|
|
3427
|
+
resp = _context45.sent;
|
|
3390
3428
|
this._subscriptionService.updateSession(resp);
|
|
3391
|
-
return
|
|
3429
|
+
return _context45.abrupt("return", omitUser(resp));
|
|
3392
3430
|
case 11:
|
|
3393
3431
|
case "end":
|
|
3394
|
-
return
|
|
3432
|
+
return _context45.stop();
|
|
3395
3433
|
}
|
|
3396
|
-
},
|
|
3434
|
+
}, _callee45, this);
|
|
3397
3435
|
}));
|
|
3398
3436
|
}
|
|
3399
3437
|
}]);
|
|
@@ -3408,13 +3446,13 @@ var HeadlessTOTPClient = /*#__PURE__*/function () {
|
|
|
3408
3446
|
return _createClass(HeadlessTOTPClient, [{
|
|
3409
3447
|
key: "create",
|
|
3410
3448
|
value: function create(options) {
|
|
3411
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3449
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
3412
3450
|
var resp;
|
|
3413
|
-
return _regeneratorRuntime().wrap(function
|
|
3414
|
-
while (1) switch (
|
|
3451
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
3452
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
3415
3453
|
case 0:
|
|
3416
3454
|
validate('stytch.totps.create').isNumber('expiration_minutes', options.expiration_minutes);
|
|
3417
|
-
|
|
3455
|
+
_context46.next = 3;
|
|
3418
3456
|
return this._networkClient.fetchSDK({
|
|
3419
3457
|
url: '/totps',
|
|
3420
3458
|
method: 'POST',
|
|
@@ -3423,32 +3461,32 @@ var HeadlessTOTPClient = /*#__PURE__*/function () {
|
|
|
3423
3461
|
}
|
|
3424
3462
|
});
|
|
3425
3463
|
case 3:
|
|
3426
|
-
resp =
|
|
3464
|
+
resp = _context46.sent;
|
|
3427
3465
|
this._subscriptionService.updateUser(resp.__user);
|
|
3428
|
-
return
|
|
3466
|
+
return _context46.abrupt("return", omitUser(resp));
|
|
3429
3467
|
case 6:
|
|
3430
3468
|
case "end":
|
|
3431
|
-
return
|
|
3469
|
+
return _context46.stop();
|
|
3432
3470
|
}
|
|
3433
|
-
},
|
|
3471
|
+
}, _callee46, this);
|
|
3434
3472
|
}));
|
|
3435
3473
|
}
|
|
3436
3474
|
}, {
|
|
3437
3475
|
key: "authenticate",
|
|
3438
3476
|
value: function authenticate(options) {
|
|
3439
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3477
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
|
|
3440
3478
|
var _yield$this$dfpProtec10, dfp_telemetry_id, captcha_token, resp;
|
|
3441
|
-
return _regeneratorRuntime().wrap(function
|
|
3442
|
-
while (1) switch (
|
|
3479
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
3480
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
3443
3481
|
case 0:
|
|
3444
3482
|
validate('stytch.totps.authenticate').isNumber('session_duration_minutes', options.session_duration_minutes).isString('totp_code', options.totp_code);
|
|
3445
|
-
|
|
3483
|
+
_context47.next = 3;
|
|
3446
3484
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
3447
3485
|
case 3:
|
|
3448
|
-
_yield$this$dfpProtec10 =
|
|
3486
|
+
_yield$this$dfpProtec10 = _context47.sent;
|
|
3449
3487
|
dfp_telemetry_id = _yield$this$dfpProtec10.dfp_telemetry_id;
|
|
3450
3488
|
captcha_token = _yield$this$dfpProtec10.captcha_token;
|
|
3451
|
-
|
|
3489
|
+
_context47.next = 8;
|
|
3452
3490
|
return this._networkClient.retriableFetchSDK({
|
|
3453
3491
|
url: '/totps/authenticate',
|
|
3454
3492
|
method: 'POST',
|
|
@@ -3461,50 +3499,50 @@ var HeadlessTOTPClient = /*#__PURE__*/function () {
|
|
|
3461
3499
|
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
3462
3500
|
});
|
|
3463
3501
|
case 8:
|
|
3464
|
-
resp =
|
|
3502
|
+
resp = _context47.sent;
|
|
3465
3503
|
this._subscriptionService.updateSession(resp);
|
|
3466
|
-
return
|
|
3504
|
+
return _context47.abrupt("return", omitUser(resp));
|
|
3467
3505
|
case 11:
|
|
3468
3506
|
case "end":
|
|
3469
|
-
return
|
|
3507
|
+
return _context47.stop();
|
|
3470
3508
|
}
|
|
3471
|
-
},
|
|
3509
|
+
}, _callee47, this);
|
|
3472
3510
|
}));
|
|
3473
3511
|
}
|
|
3474
3512
|
}, {
|
|
3475
3513
|
key: "recoveryCodes",
|
|
3476
3514
|
value: function recoveryCodes() {
|
|
3477
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3478
|
-
return _regeneratorRuntime().wrap(function
|
|
3479
|
-
while (1) switch (
|
|
3515
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
|
|
3516
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
3517
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
3480
3518
|
case 0:
|
|
3481
|
-
return
|
|
3519
|
+
return _context48.abrupt("return", this._networkClient.fetchSDK({
|
|
3482
3520
|
url: '/totps/recovery_codes',
|
|
3483
3521
|
method: 'POST'
|
|
3484
3522
|
}));
|
|
3485
3523
|
case 1:
|
|
3486
3524
|
case "end":
|
|
3487
|
-
return
|
|
3525
|
+
return _context48.stop();
|
|
3488
3526
|
}
|
|
3489
|
-
},
|
|
3527
|
+
}, _callee48, this);
|
|
3490
3528
|
}));
|
|
3491
3529
|
}
|
|
3492
3530
|
}, {
|
|
3493
3531
|
key: "recover",
|
|
3494
3532
|
value: function recover(options) {
|
|
3495
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3533
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
|
|
3496
3534
|
var _yield$this$dfpProtec11, dfp_telemetry_id, captcha_token, resp;
|
|
3497
|
-
return _regeneratorRuntime().wrap(function
|
|
3498
|
-
while (1) switch (
|
|
3535
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
3536
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
3499
3537
|
case 0:
|
|
3500
3538
|
validate('stytch.totps.recover').isNumber('session_duration_minutes', options.session_duration_minutes).isString('recovery_code', options.recovery_code);
|
|
3501
|
-
|
|
3539
|
+
_context49.next = 3;
|
|
3502
3540
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
3503
3541
|
case 3:
|
|
3504
|
-
_yield$this$dfpProtec11 =
|
|
3542
|
+
_yield$this$dfpProtec11 = _context49.sent;
|
|
3505
3543
|
dfp_telemetry_id = _yield$this$dfpProtec11.dfp_telemetry_id;
|
|
3506
3544
|
captcha_token = _yield$this$dfpProtec11.captcha_token;
|
|
3507
|
-
|
|
3545
|
+
_context49.next = 8;
|
|
3508
3546
|
return this._networkClient.retriableFetchSDK({
|
|
3509
3547
|
url: '/totps/recover',
|
|
3510
3548
|
method: 'POST',
|
|
@@ -3517,14 +3555,14 @@ var HeadlessTOTPClient = /*#__PURE__*/function () {
|
|
|
3517
3555
|
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
3518
3556
|
});
|
|
3519
3557
|
case 8:
|
|
3520
|
-
resp =
|
|
3558
|
+
resp = _context49.sent;
|
|
3521
3559
|
this._subscriptionService.updateSession(resp);
|
|
3522
|
-
return
|
|
3560
|
+
return _context49.abrupt("return", omitUser(resp));
|
|
3523
3561
|
case 11:
|
|
3524
3562
|
case "end":
|
|
3525
|
-
return
|
|
3563
|
+
return _context49.stop();
|
|
3526
3564
|
}
|
|
3527
|
-
},
|
|
3565
|
+
}, _callee49, this);
|
|
3528
3566
|
}));
|
|
3529
3567
|
}
|
|
3530
3568
|
}]);
|
|
@@ -3703,21 +3741,21 @@ function createResponseToJSON(credential) {
|
|
|
3703
3741
|
return convert(bufferToBase64url, publicKeyCredentialWithAttestation, credential);
|
|
3704
3742
|
}
|
|
3705
3743
|
function create(requestJSON) {
|
|
3706
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3744
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
|
|
3707
3745
|
var credential;
|
|
3708
|
-
return _regeneratorRuntime().wrap(function
|
|
3709
|
-
while (1) switch (
|
|
3746
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
3747
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
3710
3748
|
case 0:
|
|
3711
|
-
|
|
3749
|
+
_context50.next = 2;
|
|
3712
3750
|
return navigator.credentials.create(createRequestFromJSON(requestJSON));
|
|
3713
3751
|
case 2:
|
|
3714
|
-
credential =
|
|
3715
|
-
return
|
|
3752
|
+
credential = _context50.sent;
|
|
3753
|
+
return _context50.abrupt("return", createResponseToJSON(credential));
|
|
3716
3754
|
case 4:
|
|
3717
3755
|
case "end":
|
|
3718
|
-
return
|
|
3756
|
+
return _context50.stop();
|
|
3719
3757
|
}
|
|
3720
|
-
},
|
|
3758
|
+
}, _callee50);
|
|
3721
3759
|
}));
|
|
3722
3760
|
}
|
|
3723
3761
|
function getRequestFromJSON(requestJSON) {
|
|
@@ -3727,21 +3765,21 @@ function getResponseToJSON(credential) {
|
|
|
3727
3765
|
return convert(bufferToBase64url, publicKeyCredentialWithAssertion, credential);
|
|
3728
3766
|
}
|
|
3729
3767
|
function get(requestJSON) {
|
|
3730
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3768
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee51() {
|
|
3731
3769
|
var credential;
|
|
3732
|
-
return _regeneratorRuntime().wrap(function
|
|
3733
|
-
while (1) switch (
|
|
3770
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
3771
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
3734
3772
|
case 0:
|
|
3735
|
-
|
|
3773
|
+
_context51.next = 2;
|
|
3736
3774
|
return navigator.credentials.get(getRequestFromJSON(requestJSON));
|
|
3737
3775
|
case 2:
|
|
3738
|
-
credential =
|
|
3739
|
-
return
|
|
3776
|
+
credential = _context51.sent;
|
|
3777
|
+
return _context51.abrupt("return", getResponseToJSON(credential));
|
|
3740
3778
|
case 4:
|
|
3741
3779
|
case "end":
|
|
3742
|
-
return
|
|
3780
|
+
return _context51.stop();
|
|
3743
3781
|
}
|
|
3744
|
-
},
|
|
3782
|
+
}, _callee51);
|
|
3745
3783
|
}));
|
|
3746
3784
|
}
|
|
3747
3785
|
var HeadlessWebAuthnClient = /*#__PURE__*/function () {
|
|
@@ -3763,13 +3801,13 @@ var HeadlessWebAuthnClient = /*#__PURE__*/function () {
|
|
|
3763
3801
|
key: "register",
|
|
3764
3802
|
value: function register(options) {
|
|
3765
3803
|
var _a, _b;
|
|
3766
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3804
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee52() {
|
|
3767
3805
|
var startResp, publicKeyCredentialCreationOptions, publicKey, credential, resp;
|
|
3768
|
-
return _regeneratorRuntime().wrap(function
|
|
3769
|
-
while (1) switch (
|
|
3806
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
3807
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
3770
3808
|
case 0:
|
|
3771
3809
|
validate('stytch.webauthn.register').isOptionalString('domain', options === null || options === void 0 ? void 0 : options.domain).isOptionalString('authenticator_type', options === null || options === void 0 ? void 0 : options.authenticator_type).isOptionalBoolean('is_passkey', options === null || options === void 0 ? void 0 : options.is_passkey).isOptionalNumber('session_duration_minutes', options === null || options === void 0 ? void 0 : options.session_duration_minutes).isOptionalString('override_id', options === null || options === void 0 ? void 0 : options.override_id).isOptionalString('override_name', options === null || options === void 0 ? void 0 : options.override_name).isOptionalString('override_display_name', options === null || options === void 0 ? void 0 : options.override_display_name);
|
|
3772
|
-
|
|
3810
|
+
_context52.next = 3;
|
|
3773
3811
|
return this._networkClient.fetchSDK({
|
|
3774
3812
|
url: '/webauthn/register/start',
|
|
3775
3813
|
method: 'POST',
|
|
@@ -3784,16 +3822,16 @@ var HeadlessWebAuthnClient = /*#__PURE__*/function () {
|
|
|
3784
3822
|
}
|
|
3785
3823
|
});
|
|
3786
3824
|
case 3:
|
|
3787
|
-
startResp =
|
|
3825
|
+
startResp = _context52.sent;
|
|
3788
3826
|
publicKeyCredentialCreationOptions = startResp.public_key_credential_creation_options;
|
|
3789
3827
|
publicKey = JSON.parse(publicKeyCredentialCreationOptions);
|
|
3790
|
-
|
|
3828
|
+
_context52.next = 8;
|
|
3791
3829
|
return create({
|
|
3792
3830
|
publicKey: publicKey
|
|
3793
3831
|
});
|
|
3794
3832
|
case 8:
|
|
3795
|
-
credential =
|
|
3796
|
-
|
|
3833
|
+
credential = _context52.sent;
|
|
3834
|
+
_context52.next = 11;
|
|
3797
3835
|
return this._networkClient.fetchSDK({
|
|
3798
3836
|
url: '/webauthn/register',
|
|
3799
3837
|
method: 'POST',
|
|
@@ -3803,55 +3841,55 @@ var HeadlessWebAuthnClient = /*#__PURE__*/function () {
|
|
|
3803
3841
|
}
|
|
3804
3842
|
});
|
|
3805
3843
|
case 11:
|
|
3806
|
-
resp =
|
|
3844
|
+
resp = _context52.sent;
|
|
3807
3845
|
this._subscriptionService.updateSession(resp);
|
|
3808
|
-
return
|
|
3846
|
+
return _context52.abrupt("return", omitUser(resp));
|
|
3809
3847
|
case 14:
|
|
3810
3848
|
case "end":
|
|
3811
|
-
return
|
|
3849
|
+
return _context52.stop();
|
|
3812
3850
|
}
|
|
3813
|
-
},
|
|
3851
|
+
}, _callee52, this);
|
|
3814
3852
|
}));
|
|
3815
3853
|
}
|
|
3816
3854
|
}, {
|
|
3817
3855
|
key: "authenticate",
|
|
3818
3856
|
value: function authenticate(options) {
|
|
3819
3857
|
var _a, _b;
|
|
3820
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3858
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
|
|
3821
3859
|
var _yield$this$dfpProtec12, dfp_telemetry_id, captcha_token, isLoggedIn, endpoint, startResp, publicKeyCredentialRequestOptions, abortController, credReqOptions, conditionalMediationCredReqOption, credential, authenticationData;
|
|
3822
|
-
return _regeneratorRuntime().wrap(function
|
|
3823
|
-
while (1) switch (
|
|
3860
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
3861
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
3824
3862
|
case 0:
|
|
3825
3863
|
validate('stytch.webauthn.authenticate').isOptionalString('domain', options.domain).isNumber('session_duration_minutes', options.session_duration_minutes).isOptionalBoolean('is_passkey', options.is_passkey).isOptionalObject('signal', options.signal);
|
|
3826
|
-
|
|
3864
|
+
_context53.next = 3;
|
|
3827
3865
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
3828
3866
|
case 3:
|
|
3829
|
-
_yield$this$dfpProtec12 =
|
|
3867
|
+
_yield$this$dfpProtec12 = _context53.sent;
|
|
3830
3868
|
dfp_telemetry_id = _yield$this$dfpProtec12.dfp_telemetry_id;
|
|
3831
3869
|
captcha_token = _yield$this$dfpProtec12.captcha_token;
|
|
3832
3870
|
if (!options.conditional_mediation) {
|
|
3833
|
-
|
|
3871
|
+
_context53.next = 14;
|
|
3834
3872
|
break;
|
|
3835
3873
|
}
|
|
3836
|
-
|
|
3874
|
+
_context53.next = 9;
|
|
3837
3875
|
return this.browserSupportsAutofill();
|
|
3838
3876
|
case 9:
|
|
3839
|
-
if (
|
|
3840
|
-
|
|
3877
|
+
if (_context53.sent) {
|
|
3878
|
+
_context53.next = 12;
|
|
3841
3879
|
break;
|
|
3842
3880
|
}
|
|
3843
3881
|
console.error('Browser does not support WebAuthn autofill');
|
|
3844
|
-
return
|
|
3882
|
+
return _context53.abrupt("return", null);
|
|
3845
3883
|
case 12:
|
|
3846
3884
|
if (this.checkEligibleInputs()) {
|
|
3847
|
-
|
|
3885
|
+
_context53.next = 14;
|
|
3848
3886
|
break;
|
|
3849
3887
|
}
|
|
3850
|
-
return
|
|
3888
|
+
return _context53.abrupt("return", null);
|
|
3851
3889
|
case 14:
|
|
3852
3890
|
isLoggedIn = !!this._subscriptionService.getSession();
|
|
3853
3891
|
endpoint = isLoggedIn ? '/webauthn/authenticate/start/secondary' : '/webauthn/authenticate/start/primary';
|
|
3854
|
-
|
|
3892
|
+
_context53.next = 18;
|
|
3855
3893
|
return this._networkClient.fetchSDK({
|
|
3856
3894
|
url: endpoint,
|
|
3857
3895
|
method: 'POST',
|
|
@@ -3861,7 +3899,7 @@ var HeadlessWebAuthnClient = /*#__PURE__*/function () {
|
|
|
3861
3899
|
}
|
|
3862
3900
|
});
|
|
3863
3901
|
case 18:
|
|
3864
|
-
startResp =
|
|
3902
|
+
startResp = _context53.sent;
|
|
3865
3903
|
publicKeyCredentialRequestOptions = startResp.public_key_credential_request_options;
|
|
3866
3904
|
abortController = new AbortController();
|
|
3867
3905
|
credReqOptions = {
|
|
@@ -3871,11 +3909,11 @@ var HeadlessWebAuthnClient = /*#__PURE__*/function () {
|
|
|
3871
3909
|
conditionalMediationCredReqOption = Object.assign(Object.assign({}, credReqOptions), {
|
|
3872
3910
|
mediation: 'conditional'
|
|
3873
3911
|
});
|
|
3874
|
-
|
|
3912
|
+
_context53.next = 25;
|
|
3875
3913
|
return get(options.conditional_mediation ? conditionalMediationCredReqOption : credReqOptions);
|
|
3876
3914
|
case 25:
|
|
3877
|
-
credential =
|
|
3878
|
-
|
|
3915
|
+
credential = _context53.sent;
|
|
3916
|
+
_context53.next = 28;
|
|
3879
3917
|
return this._networkClient.retriableFetchSDK({
|
|
3880
3918
|
url: '/webauthn/authenticate',
|
|
3881
3919
|
method: 'POST',
|
|
@@ -3888,26 +3926,26 @@ var HeadlessWebAuthnClient = /*#__PURE__*/function () {
|
|
|
3888
3926
|
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
3889
3927
|
});
|
|
3890
3928
|
case 28:
|
|
3891
|
-
authenticationData =
|
|
3929
|
+
authenticationData = _context53.sent;
|
|
3892
3930
|
this._subscriptionService.updateSession(authenticationData);
|
|
3893
|
-
return
|
|
3931
|
+
return _context53.abrupt("return", omitUser(authenticationData));
|
|
3894
3932
|
case 31:
|
|
3895
3933
|
case "end":
|
|
3896
|
-
return
|
|
3934
|
+
return _context53.stop();
|
|
3897
3935
|
}
|
|
3898
|
-
},
|
|
3936
|
+
}, _callee53, this);
|
|
3899
3937
|
}));
|
|
3900
3938
|
}
|
|
3901
3939
|
}, {
|
|
3902
3940
|
key: "update",
|
|
3903
3941
|
value: function update(options) {
|
|
3904
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3942
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
|
|
3905
3943
|
var url;
|
|
3906
|
-
return _regeneratorRuntime().wrap(function
|
|
3907
|
-
while (1) switch (
|
|
3944
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
3945
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
3908
3946
|
case 0:
|
|
3909
3947
|
url = '/webauthn/update/' + options.webauthn_registration_id;
|
|
3910
|
-
|
|
3948
|
+
_context54.next = 3;
|
|
3911
3949
|
return this._networkClient.fetchSDK({
|
|
3912
3950
|
url: url,
|
|
3913
3951
|
method: 'PUT',
|
|
@@ -3916,36 +3954,36 @@ var HeadlessWebAuthnClient = /*#__PURE__*/function () {
|
|
|
3916
3954
|
}
|
|
3917
3955
|
});
|
|
3918
3956
|
case 3:
|
|
3919
|
-
return
|
|
3957
|
+
return _context54.abrupt("return", _context54.sent);
|
|
3920
3958
|
case 4:
|
|
3921
3959
|
case "end":
|
|
3922
|
-
return
|
|
3960
|
+
return _context54.stop();
|
|
3923
3961
|
}
|
|
3924
|
-
},
|
|
3962
|
+
}, _callee54, this);
|
|
3925
3963
|
}));
|
|
3926
3964
|
}
|
|
3927
3965
|
}, {
|
|
3928
3966
|
key: "browserSupportsAutofill",
|
|
3929
3967
|
value: function browserSupportsAutofill() {
|
|
3930
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3931
|
-
return _regeneratorRuntime().wrap(function
|
|
3932
|
-
while (1) switch (
|
|
3968
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
|
|
3969
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
3970
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
3933
3971
|
case 0:
|
|
3934
3972
|
if (!(window.PublicKeyCredential && window.PublicKeyCredential.isConditionalMediationAvailable)) {
|
|
3935
|
-
|
|
3973
|
+
_context55.next = 4;
|
|
3936
3974
|
break;
|
|
3937
3975
|
}
|
|
3938
|
-
|
|
3976
|
+
_context55.next = 3;
|
|
3939
3977
|
return window.PublicKeyCredential.isConditionalMediationAvailable();
|
|
3940
3978
|
case 3:
|
|
3941
|
-
return
|
|
3979
|
+
return _context55.abrupt("return", _context55.sent);
|
|
3942
3980
|
case 4:
|
|
3943
|
-
return
|
|
3981
|
+
return _context55.abrupt("return", false);
|
|
3944
3982
|
case 5:
|
|
3945
3983
|
case "end":
|
|
3946
|
-
return
|
|
3984
|
+
return _context55.stop();
|
|
3947
3985
|
}
|
|
3948
|
-
},
|
|
3986
|
+
}, _callee55);
|
|
3949
3987
|
}));
|
|
3950
3988
|
}
|
|
3951
3989
|
}]);
|
|
@@ -3967,60 +4005,60 @@ var HeadlessPasswordClient = /*#__PURE__*/function () {
|
|
|
3967
4005
|
return _createClass(HeadlessPasswordClient, [{
|
|
3968
4006
|
key: "getCodeChallenge",
|
|
3969
4007
|
value: function getCodeChallenge() {
|
|
3970
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4008
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee56() {
|
|
3971
4009
|
var _yield$this$_config4, pkceRequiredForPasswordResets, keyPair;
|
|
3972
|
-
return _regeneratorRuntime().wrap(function
|
|
3973
|
-
while (1) switch (
|
|
4010
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
4011
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
3974
4012
|
case 0:
|
|
3975
|
-
|
|
4013
|
+
_context56.next = 2;
|
|
3976
4014
|
return this._config;
|
|
3977
4015
|
case 2:
|
|
3978
|
-
_yield$this$_config4 =
|
|
4016
|
+
_yield$this$_config4 = _context56.sent;
|
|
3979
4017
|
pkceRequiredForPasswordResets = _yield$this$_config4.pkceRequiredForPasswordResets;
|
|
3980
4018
|
if (pkceRequiredForPasswordResets) {
|
|
3981
|
-
|
|
4019
|
+
_context56.next = 6;
|
|
3982
4020
|
break;
|
|
3983
4021
|
}
|
|
3984
|
-
return
|
|
4022
|
+
return _context56.abrupt("return", undefined);
|
|
3985
4023
|
case 6:
|
|
3986
|
-
|
|
4024
|
+
_context56.next = 8;
|
|
3987
4025
|
return this._pkceManager.getPKPair();
|
|
3988
4026
|
case 8:
|
|
3989
|
-
keyPair =
|
|
4027
|
+
keyPair = _context56.sent;
|
|
3990
4028
|
if (!keyPair) {
|
|
3991
|
-
|
|
4029
|
+
_context56.next = 11;
|
|
3992
4030
|
break;
|
|
3993
4031
|
}
|
|
3994
|
-
return
|
|
4032
|
+
return _context56.abrupt("return", keyPair.code_challenge);
|
|
3995
4033
|
case 11:
|
|
3996
|
-
|
|
4034
|
+
_context56.next = 13;
|
|
3997
4035
|
return this._pkceManager.startPKCETransaction();
|
|
3998
4036
|
case 13:
|
|
3999
|
-
keyPair =
|
|
4000
|
-
return
|
|
4037
|
+
keyPair = _context56.sent;
|
|
4038
|
+
return _context56.abrupt("return", keyPair.code_challenge);
|
|
4001
4039
|
case 15:
|
|
4002
4040
|
case "end":
|
|
4003
|
-
return
|
|
4041
|
+
return _context56.stop();
|
|
4004
4042
|
}
|
|
4005
|
-
},
|
|
4043
|
+
}, _callee56, this);
|
|
4006
4044
|
}));
|
|
4007
4045
|
}
|
|
4008
4046
|
}, {
|
|
4009
4047
|
key: "create",
|
|
4010
4048
|
value: function create(options) {
|
|
4011
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4049
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee57() {
|
|
4012
4050
|
var _yield$this$dfpProtec13, dfp_telemetry_id, captcha_token, resp;
|
|
4013
|
-
return _regeneratorRuntime().wrap(function
|
|
4014
|
-
while (1) switch (
|
|
4051
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
4052
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
4015
4053
|
case 0:
|
|
4016
4054
|
validate('stytch.passwords.create').isString('password', options.password).isString('email', options.email).isNumber('session_duration_minutes', options.session_duration_minutes);
|
|
4017
|
-
|
|
4055
|
+
_context57.next = 3;
|
|
4018
4056
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
4019
4057
|
case 3:
|
|
4020
|
-
_yield$this$dfpProtec13 =
|
|
4058
|
+
_yield$this$dfpProtec13 = _context57.sent;
|
|
4021
4059
|
dfp_telemetry_id = _yield$this$dfpProtec13.dfp_telemetry_id;
|
|
4022
4060
|
captcha_token = _yield$this$dfpProtec13.captcha_token;
|
|
4023
|
-
|
|
4061
|
+
_context57.next = 8;
|
|
4024
4062
|
return this._networkClient.retriableFetchSDK({
|
|
4025
4063
|
url: '/passwords',
|
|
4026
4064
|
method: 'POST',
|
|
@@ -4034,32 +4072,32 @@ var HeadlessPasswordClient = /*#__PURE__*/function () {
|
|
|
4034
4072
|
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
4035
4073
|
});
|
|
4036
4074
|
case 8:
|
|
4037
|
-
resp =
|
|
4075
|
+
resp = _context57.sent;
|
|
4038
4076
|
this._subscriptionService.updateSession(resp);
|
|
4039
|
-
return
|
|
4077
|
+
return _context57.abrupt("return", omitUser(resp));
|
|
4040
4078
|
case 11:
|
|
4041
4079
|
case "end":
|
|
4042
|
-
return
|
|
4080
|
+
return _context57.stop();
|
|
4043
4081
|
}
|
|
4044
|
-
},
|
|
4082
|
+
}, _callee57, this);
|
|
4045
4083
|
}));
|
|
4046
4084
|
}
|
|
4047
4085
|
}, {
|
|
4048
4086
|
key: "authenticate",
|
|
4049
4087
|
value: function authenticate(options) {
|
|
4050
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4088
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee58() {
|
|
4051
4089
|
var _yield$this$dfpProtec14, dfp_telemetry_id, captcha_token, resp;
|
|
4052
|
-
return _regeneratorRuntime().wrap(function
|
|
4053
|
-
while (1) switch (
|
|
4090
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
4091
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
4054
4092
|
case 0:
|
|
4055
4093
|
validate('stytch.passwords.authenticate').isString('password', options.password).isString('email', options.email).isNumber('session_duration_minutes', options.session_duration_minutes);
|
|
4056
|
-
|
|
4094
|
+
_context58.next = 3;
|
|
4057
4095
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
4058
4096
|
case 3:
|
|
4059
|
-
_yield$this$dfpProtec14 =
|
|
4097
|
+
_yield$this$dfpProtec14 = _context58.sent;
|
|
4060
4098
|
dfp_telemetry_id = _yield$this$dfpProtec14.dfp_telemetry_id;
|
|
4061
4099
|
captcha_token = _yield$this$dfpProtec14.captcha_token;
|
|
4062
|
-
|
|
4100
|
+
_context58.next = 8;
|
|
4063
4101
|
return this._networkClient.retriableFetchSDK({
|
|
4064
4102
|
url: '/passwords/authenticate',
|
|
4065
4103
|
method: 'POST',
|
|
@@ -4073,36 +4111,36 @@ var HeadlessPasswordClient = /*#__PURE__*/function () {
|
|
|
4073
4111
|
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
4074
4112
|
});
|
|
4075
4113
|
case 8:
|
|
4076
|
-
resp =
|
|
4114
|
+
resp = _context58.sent;
|
|
4077
4115
|
this._subscriptionService.updateSession(resp);
|
|
4078
|
-
return
|
|
4116
|
+
return _context58.abrupt("return", omitUser(resp));
|
|
4079
4117
|
case 11:
|
|
4080
4118
|
case "end":
|
|
4081
|
-
return
|
|
4119
|
+
return _context58.stop();
|
|
4082
4120
|
}
|
|
4083
|
-
},
|
|
4121
|
+
}, _callee58, this);
|
|
4084
4122
|
}));
|
|
4085
4123
|
}
|
|
4086
4124
|
}, {
|
|
4087
4125
|
key: "resetByEmailStart",
|
|
4088
4126
|
value: function resetByEmailStart(options) {
|
|
4089
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4127
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee59() {
|
|
4090
4128
|
var code_challenge, _yield$this$dfpProtec15, dfp_telemetry_id, captcha_token;
|
|
4091
|
-
return _regeneratorRuntime().wrap(function
|
|
4092
|
-
while (1) switch (
|
|
4129
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
4130
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
4093
4131
|
case 0:
|
|
4094
4132
|
validate('stytch.passwords.resetByEmailStart').isString('email', options.email).isOptionalString('login_redirect_url', options.login_redirect_url).isOptionalString('reset_password_redirect_url', options.reset_password_redirect_url).isOptionalString('reset_password_template_id', options.reset_password_template_id).isOptionalNumber('reset_password_expiration_minutes', options.reset_password_expiration_minutes);
|
|
4095
|
-
|
|
4133
|
+
_context59.next = 3;
|
|
4096
4134
|
return this.getCodeChallenge();
|
|
4097
4135
|
case 3:
|
|
4098
|
-
code_challenge =
|
|
4099
|
-
|
|
4136
|
+
code_challenge = _context59.sent;
|
|
4137
|
+
_context59.next = 6;
|
|
4100
4138
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
4101
4139
|
case 6:
|
|
4102
|
-
_yield$this$dfpProtec15 =
|
|
4140
|
+
_yield$this$dfpProtec15 = _context59.sent;
|
|
4103
4141
|
dfp_telemetry_id = _yield$this$dfpProtec15.dfp_telemetry_id;
|
|
4104
4142
|
captcha_token = _yield$this$dfpProtec15.captcha_token;
|
|
4105
|
-
return
|
|
4143
|
+
return _context59.abrupt("return", this._networkClient.retriableFetchSDK({
|
|
4106
4144
|
url: '/passwords/email/reset/start',
|
|
4107
4145
|
method: 'POST',
|
|
4108
4146
|
body: {
|
|
@@ -4119,32 +4157,32 @@ var HeadlessPasswordClient = /*#__PURE__*/function () {
|
|
|
4119
4157
|
}));
|
|
4120
4158
|
case 10:
|
|
4121
4159
|
case "end":
|
|
4122
|
-
return
|
|
4160
|
+
return _context59.stop();
|
|
4123
4161
|
}
|
|
4124
|
-
},
|
|
4162
|
+
}, _callee59, this);
|
|
4125
4163
|
}));
|
|
4126
4164
|
}
|
|
4127
4165
|
}, {
|
|
4128
4166
|
key: "resetByEmail",
|
|
4129
4167
|
value: function resetByEmail(options) {
|
|
4130
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4168
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee60() {
|
|
4131
4169
|
var _yield$this$dfpProtec16, dfp_telemetry_id, captcha_token, pkPair, code_verifier, resp;
|
|
4132
|
-
return _regeneratorRuntime().wrap(function
|
|
4133
|
-
while (1) switch (
|
|
4170
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
4171
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
4134
4172
|
case 0:
|
|
4135
4173
|
validate('stytch.passwords.resetByEmail').isString('token', options.token).isString('password', options.password).isNumber('session_duration_minutes', options.session_duration_minutes);
|
|
4136
|
-
|
|
4174
|
+
_context60.next = 3;
|
|
4137
4175
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
4138
4176
|
case 3:
|
|
4139
|
-
_yield$this$dfpProtec16 =
|
|
4177
|
+
_yield$this$dfpProtec16 = _context60.sent;
|
|
4140
4178
|
dfp_telemetry_id = _yield$this$dfpProtec16.dfp_telemetry_id;
|
|
4141
4179
|
captcha_token = _yield$this$dfpProtec16.captcha_token;
|
|
4142
|
-
|
|
4180
|
+
_context60.next = 8;
|
|
4143
4181
|
return this._pkceManager.getPKPair();
|
|
4144
4182
|
case 8:
|
|
4145
|
-
pkPair =
|
|
4183
|
+
pkPair = _context60.sent;
|
|
4146
4184
|
code_verifier = pkPair === null || pkPair === void 0 ? void 0 : pkPair.code_verifier;
|
|
4147
|
-
|
|
4185
|
+
_context60.next = 12;
|
|
4148
4186
|
return this._networkClient.retriableFetchSDK({
|
|
4149
4187
|
url: '/passwords/email/reset',
|
|
4150
4188
|
method: 'POST',
|
|
@@ -4159,33 +4197,33 @@ var HeadlessPasswordClient = /*#__PURE__*/function () {
|
|
|
4159
4197
|
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
4160
4198
|
});
|
|
4161
4199
|
case 12:
|
|
4162
|
-
resp =
|
|
4200
|
+
resp = _context60.sent;
|
|
4163
4201
|
this._pkceManager.clearPKPair();
|
|
4164
4202
|
this._subscriptionService.updateSession(resp);
|
|
4165
|
-
return
|
|
4203
|
+
return _context60.abrupt("return", omitUser(resp));
|
|
4166
4204
|
case 16:
|
|
4167
4205
|
case "end":
|
|
4168
|
-
return
|
|
4206
|
+
return _context60.stop();
|
|
4169
4207
|
}
|
|
4170
|
-
},
|
|
4208
|
+
}, _callee60, this);
|
|
4171
4209
|
}));
|
|
4172
4210
|
}
|
|
4173
4211
|
}, {
|
|
4174
4212
|
key: "resetByExistingPassword",
|
|
4175
4213
|
value: function resetByExistingPassword(options) {
|
|
4176
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4214
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee61() {
|
|
4177
4215
|
var _yield$this$dfpProtec17, dfp_telemetry_id, captcha_token, resp;
|
|
4178
|
-
return _regeneratorRuntime().wrap(function
|
|
4179
|
-
while (1) switch (
|
|
4216
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
4217
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
4180
4218
|
case 0:
|
|
4181
4219
|
validate('stytch.passwords.resetByExistingPassword').isString('email', options.email).isString('existing_password', options.existing_password).isString('new_password', options.new_password).isNumber('session_duration_minutes', options.session_duration_minutes);
|
|
4182
|
-
|
|
4220
|
+
_context61.next = 3;
|
|
4183
4221
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
4184
4222
|
case 3:
|
|
4185
|
-
_yield$this$dfpProtec17 =
|
|
4223
|
+
_yield$this$dfpProtec17 = _context61.sent;
|
|
4186
4224
|
dfp_telemetry_id = _yield$this$dfpProtec17.dfp_telemetry_id;
|
|
4187
4225
|
captcha_token = _yield$this$dfpProtec17.captcha_token;
|
|
4188
|
-
|
|
4226
|
+
_context61.next = 8;
|
|
4189
4227
|
return this._networkClient.retriableFetchSDK({
|
|
4190
4228
|
url: '/passwords/existing_password/reset',
|
|
4191
4229
|
method: 'POST',
|
|
@@ -4200,32 +4238,32 @@ var HeadlessPasswordClient = /*#__PURE__*/function () {
|
|
|
4200
4238
|
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
4201
4239
|
});
|
|
4202
4240
|
case 8:
|
|
4203
|
-
resp =
|
|
4241
|
+
resp = _context61.sent;
|
|
4204
4242
|
this._subscriptionService.updateSession(resp);
|
|
4205
|
-
return
|
|
4243
|
+
return _context61.abrupt("return", omitUser(resp));
|
|
4206
4244
|
case 11:
|
|
4207
4245
|
case "end":
|
|
4208
|
-
return
|
|
4246
|
+
return _context61.stop();
|
|
4209
4247
|
}
|
|
4210
|
-
},
|
|
4248
|
+
}, _callee61, this);
|
|
4211
4249
|
}));
|
|
4212
4250
|
}
|
|
4213
4251
|
}, {
|
|
4214
4252
|
key: "resetBySession",
|
|
4215
4253
|
value: function resetBySession(options) {
|
|
4216
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4254
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee62() {
|
|
4217
4255
|
var _yield$this$dfpProtec18, dfp_telemetry_id, captcha_token, resp;
|
|
4218
|
-
return _regeneratorRuntime().wrap(function
|
|
4219
|
-
while (1) switch (
|
|
4256
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
4257
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
4220
4258
|
case 0:
|
|
4221
4259
|
validate('stytch.passwords.resetBySession').isString('password', options.password);
|
|
4222
|
-
|
|
4260
|
+
_context62.next = 3;
|
|
4223
4261
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
4224
4262
|
case 3:
|
|
4225
|
-
_yield$this$dfpProtec18 =
|
|
4263
|
+
_yield$this$dfpProtec18 = _context62.sent;
|
|
4226
4264
|
dfp_telemetry_id = _yield$this$dfpProtec18.dfp_telemetry_id;
|
|
4227
4265
|
captcha_token = _yield$this$dfpProtec18.captcha_token;
|
|
4228
|
-
|
|
4266
|
+
_context62.next = 8;
|
|
4229
4267
|
return this._networkClient.retriableFetchSDK({
|
|
4230
4268
|
url: '/passwords/session/reset',
|
|
4231
4269
|
method: 'POST',
|
|
@@ -4238,25 +4276,25 @@ var HeadlessPasswordClient = /*#__PURE__*/function () {
|
|
|
4238
4276
|
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
4239
4277
|
});
|
|
4240
4278
|
case 8:
|
|
4241
|
-
resp =
|
|
4279
|
+
resp = _context62.sent;
|
|
4242
4280
|
this._subscriptionService.updateSession(resp);
|
|
4243
|
-
return
|
|
4281
|
+
return _context62.abrupt("return", resp);
|
|
4244
4282
|
case 11:
|
|
4245
4283
|
case "end":
|
|
4246
|
-
return
|
|
4284
|
+
return _context62.stop();
|
|
4247
4285
|
}
|
|
4248
|
-
},
|
|
4286
|
+
}, _callee62, this);
|
|
4249
4287
|
}));
|
|
4250
4288
|
}
|
|
4251
4289
|
}, {
|
|
4252
4290
|
key: "strengthCheck",
|
|
4253
4291
|
value: function strengthCheck(options) {
|
|
4254
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4255
|
-
return _regeneratorRuntime().wrap(function
|
|
4256
|
-
while (1) switch (
|
|
4292
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee63() {
|
|
4293
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
4294
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
4257
4295
|
case 0:
|
|
4258
4296
|
validate('stytch.passwords.strengthCheck').isOptionalString('email', options.email).isString('password', options.password);
|
|
4259
|
-
return
|
|
4297
|
+
return _context63.abrupt("return", this._networkClient.fetchSDK({
|
|
4260
4298
|
url: '/passwords/strength_check',
|
|
4261
4299
|
method: 'POST',
|
|
4262
4300
|
body: {
|
|
@@ -4266,9 +4304,9 @@ var HeadlessPasswordClient = /*#__PURE__*/function () {
|
|
|
4266
4304
|
}));
|
|
4267
4305
|
case 2:
|
|
4268
4306
|
case "end":
|
|
4269
|
-
return
|
|
4307
|
+
return _context63.stop();
|
|
4270
4308
|
}
|
|
4271
|
-
},
|
|
4309
|
+
}, _callee63, this);
|
|
4272
4310
|
}));
|
|
4273
4311
|
}
|
|
4274
4312
|
}]);
|
|
@@ -4280,19 +4318,19 @@ var HeadlessImpersonationClient = /*#__PURE__*/_createClass(function HeadlessImp
|
|
|
4280
4318
|
this._subscriptionService = _subscriptionService;
|
|
4281
4319
|
this.dfpProtectedAuth = dfpProtectedAuth;
|
|
4282
4320
|
this.authenticate = function (data) {
|
|
4283
|
-
return __awaiter$1(_this9, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4321
|
+
return __awaiter$1(_this9, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee64() {
|
|
4284
4322
|
var _yield$this$dfpProtec19, dfp_telemetry_id, captcha_token, resp;
|
|
4285
|
-
return _regeneratorRuntime().wrap(function
|
|
4286
|
-
while (1) switch (
|
|
4323
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
4324
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
4287
4325
|
case 0:
|
|
4288
4326
|
validate('stytch.impersonation.authenticate').isString('impersonation_token', data.impersonation_token);
|
|
4289
|
-
|
|
4327
|
+
_context64.next = 3;
|
|
4290
4328
|
return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
|
|
4291
4329
|
case 3:
|
|
4292
|
-
_yield$this$dfpProtec19 =
|
|
4330
|
+
_yield$this$dfpProtec19 = _context64.sent;
|
|
4293
4331
|
dfp_telemetry_id = _yield$this$dfpProtec19.dfp_telemetry_id;
|
|
4294
4332
|
captcha_token = _yield$this$dfpProtec19.captcha_token;
|
|
4295
|
-
|
|
4333
|
+
_context64.next = 8;
|
|
4296
4334
|
return this._networkClient.retriableFetchSDK({
|
|
4297
4335
|
url: '/impersonation/authenticate',
|
|
4298
4336
|
body: Object.assign(Object.assign({}, data), {
|
|
@@ -4303,14 +4341,14 @@ var HeadlessImpersonationClient = /*#__PURE__*/_createClass(function HeadlessImp
|
|
|
4303
4341
|
retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
|
|
4304
4342
|
});
|
|
4305
4343
|
case 8:
|
|
4306
|
-
resp =
|
|
4344
|
+
resp = _context64.sent;
|
|
4307
4345
|
this._subscriptionService.updateSession(resp);
|
|
4308
|
-
return
|
|
4346
|
+
return _context64.abrupt("return", resp);
|
|
4309
4347
|
case 11:
|
|
4310
4348
|
case "end":
|
|
4311
|
-
return
|
|
4349
|
+
return _context64.stop();
|
|
4312
4350
|
}
|
|
4313
|
-
},
|
|
4351
|
+
}, _callee64, this);
|
|
4314
4352
|
}));
|
|
4315
4353
|
};
|
|
4316
4354
|
});
|
|
@@ -4357,18 +4395,18 @@ var IframeHostClient = /*#__PURE__*/function () {
|
|
|
4357
4395
|
}, {
|
|
4358
4396
|
key: "call",
|
|
4359
4397
|
value: function call(method, args) {
|
|
4360
|
-
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4398
|
+
return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee154() {
|
|
4361
4399
|
var _this28 = this;
|
|
4362
4400
|
var frame, channel;
|
|
4363
|
-
return _regeneratorRuntime().wrap(function
|
|
4364
|
-
while (1) switch (
|
|
4401
|
+
return _regeneratorRuntime().wrap(function _callee154$(_context154) {
|
|
4402
|
+
while (1) switch (_context154.prev = _context154.next) {
|
|
4365
4403
|
case 0:
|
|
4366
|
-
|
|
4404
|
+
_context154.next = 2;
|
|
4367
4405
|
return this.frame;
|
|
4368
4406
|
case 2:
|
|
4369
|
-
frame =
|
|
4407
|
+
frame = _context154.sent;
|
|
4370
4408
|
channel = new MessageChannel();
|
|
4371
|
-
return
|
|
4409
|
+
return _context154.abrupt("return", new Promise(function (resolve, reject) {
|
|
4372
4410
|
var _a;
|
|
4373
4411
|
channel.port1.onmessage = function (event) {
|
|
4374
4412
|
var resp = event.data;
|
|
@@ -4387,9 +4425,9 @@ var IframeHostClient = /*#__PURE__*/function () {
|
|
|
4387
4425
|
}));
|
|
4388
4426
|
case 5:
|
|
4389
4427
|
case "end":
|
|
4390
|
-
return
|
|
4428
|
+
return _context154.stop();
|
|
4391
4429
|
}
|
|
4392
|
-
},
|
|
4430
|
+
}, _callee154, this);
|
|
4393
4431
|
}));
|
|
4394
4432
|
}
|
|
4395
4433
|
}]);
|
|
@@ -4479,40 +4517,40 @@ var SessionManager = /*#__PURE__*/function () {
|
|
|
4479
4517
|
}
|
|
4480
4518
|
};
|
|
4481
4519
|
this._reauthenticateWithBackoff = function () {
|
|
4482
|
-
return __awaiter$1(_this30, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4520
|
+
return __awaiter$1(_this30, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee155() {
|
|
4483
4521
|
var count;
|
|
4484
|
-
return _regeneratorRuntime().wrap(function
|
|
4485
|
-
while (1) switch (
|
|
4522
|
+
return _regeneratorRuntime().wrap(function _callee155$(_context155) {
|
|
4523
|
+
while (1) switch (_context155.prev = _context155.next) {
|
|
4486
4524
|
case 0:
|
|
4487
4525
|
count = 0;
|
|
4488
4526
|
case 1:
|
|
4489
|
-
|
|
4490
|
-
|
|
4527
|
+
_context155.prev = 2;
|
|
4528
|
+
_context155.next = 5;
|
|
4491
4529
|
return this._headlessSessionClient.authenticate();
|
|
4492
4530
|
case 5:
|
|
4493
|
-
return
|
|
4531
|
+
return _context155.abrupt("return", _context155.sent);
|
|
4494
4532
|
case 8:
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
if (!SessionManager.isUnrecoverableError(
|
|
4498
|
-
|
|
4533
|
+
_context155.prev = 8;
|
|
4534
|
+
_context155.t0 = _context155["catch"](2);
|
|
4535
|
+
if (!SessionManager.isUnrecoverableError(_context155.t0)) {
|
|
4536
|
+
_context155.next = 12;
|
|
4499
4537
|
break;
|
|
4500
4538
|
}
|
|
4501
|
-
return
|
|
4539
|
+
return _context155.abrupt("return", Promise.reject(_context155.t0));
|
|
4502
4540
|
case 12:
|
|
4503
4541
|
count++;
|
|
4504
|
-
|
|
4542
|
+
_context155.next = 15;
|
|
4505
4543
|
return new Promise(function (done) {
|
|
4506
4544
|
return setTimeout(done, SessionManager.timeoutForAttempt(count));
|
|
4507
4545
|
});
|
|
4508
4546
|
case 15:
|
|
4509
|
-
|
|
4547
|
+
_context155.next = 1;
|
|
4510
4548
|
break;
|
|
4511
4549
|
case 17:
|
|
4512
4550
|
case "end":
|
|
4513
|
-
return
|
|
4551
|
+
return _context155.stop();
|
|
4514
4552
|
}
|
|
4515
|
-
},
|
|
4553
|
+
}, _callee155, this, [[2, 8]]);
|
|
4516
4554
|
}));
|
|
4517
4555
|
};
|
|
4518
4556
|
this.timeout = null;
|
|
@@ -4863,7 +4901,7 @@ var HeadlessOAuthClient = /*#__PURE__*/function (_HeadlessOAuthClient$) {
|
|
|
4863
4901
|
_inherits2(HeadlessOAuthClient, _HeadlessOAuthClient$);
|
|
4864
4902
|
return _createClass2(HeadlessOAuthClient);
|
|
4865
4903
|
}(HeadlessOAuthClient$1);
|
|
4866
|
-
var version = "5.24.
|
|
4904
|
+
var version = "5.24.4";
|
|
4867
4905
|
var NetworkClient = /*#__PURE__*/function () {
|
|
4868
4906
|
function NetworkClient(_publicToken, _subscriptionDataLayer, _liveAPIURL, _testAPIURL, additionalTelemetryDataFn) {
|
|
4869
4907
|
_classCallCheck2(this, NetworkClient);
|
|
@@ -4954,16 +4992,16 @@ var NetworkClient = /*#__PURE__*/function () {
|
|
|
4954
4992
|
var url = _ref9.url,
|
|
4955
4993
|
body = _ref9.body,
|
|
4956
4994
|
method = _ref9.method;
|
|
4957
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function
|
|
4995
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function _callee65() {
|
|
4958
4996
|
var sessionToken, basicAuthHeader, xSDKClientHeader, xSDKParentHostHeader;
|
|
4959
|
-
return _regeneratorRuntime2().wrap(function
|
|
4960
|
-
while (1) switch (
|
|
4997
|
+
return _regeneratorRuntime2().wrap(function _callee65$(_context65) {
|
|
4998
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
4961
4999
|
case 0:
|
|
4962
5000
|
sessionToken = this._subscriptionDataLayer.readSessionCookie().session_token;
|
|
4963
5001
|
basicAuthHeader = 'Basic ' + window.btoa(this._publicToken + ':' + (sessionToken || this._publicToken));
|
|
4964
5002
|
xSDKClientHeader = window.btoa(JSON.stringify(this.createTelemetryBlob()));
|
|
4965
5003
|
xSDKParentHostHeader = window.location.origin;
|
|
4966
|
-
return
|
|
5004
|
+
return _context65.abrupt("return", baseSubmitFormSDK({
|
|
4967
5005
|
basicAuthHeader: basicAuthHeader,
|
|
4968
5006
|
body: body,
|
|
4969
5007
|
finalURL: this.buildSDKUrl(url),
|
|
@@ -4973,9 +5011,9 @@ var NetworkClient = /*#__PURE__*/function () {
|
|
|
4973
5011
|
}));
|
|
4974
5012
|
case 5:
|
|
4975
5013
|
case "end":
|
|
4976
|
-
return
|
|
5014
|
+
return _context65.stop();
|
|
4977
5015
|
}
|
|
4978
|
-
},
|
|
5016
|
+
}, _callee65, this);
|
|
4979
5017
|
}));
|
|
4980
5018
|
}
|
|
4981
5019
|
}, {
|
|
@@ -4985,16 +5023,16 @@ var NetworkClient = /*#__PURE__*/function () {
|
|
|
4985
5023
|
body = _ref11.body,
|
|
4986
5024
|
method = _ref11.method,
|
|
4987
5025
|
retryCallback = _ref11.retryCallback;
|
|
4988
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function
|
|
5026
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function _callee66() {
|
|
4989
5027
|
var sessionToken, basicAuthHeader, xSDKClientHeader, xSDKParentHostHeader;
|
|
4990
|
-
return _regeneratorRuntime2().wrap(function
|
|
4991
|
-
while (1) switch (
|
|
5028
|
+
return _regeneratorRuntime2().wrap(function _callee66$(_context66) {
|
|
5029
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
4992
5030
|
case 0:
|
|
4993
5031
|
sessionToken = this._subscriptionDataLayer.readSessionCookie().session_token;
|
|
4994
5032
|
basicAuthHeader = 'Basic ' + window.btoa(this._publicToken + ':' + (sessionToken || this._publicToken));
|
|
4995
5033
|
xSDKClientHeader = window.btoa(JSON.stringify(this.createTelemetryBlob()));
|
|
4996
5034
|
xSDKParentHostHeader = window.location.origin;
|
|
4997
|
-
return
|
|
5035
|
+
return _context66.abrupt("return", _retriableFetchSDK({
|
|
4998
5036
|
basicAuthHeader: basicAuthHeader,
|
|
4999
5037
|
body: body,
|
|
5000
5038
|
finalURL: this.buildSDKUrl(url),
|
|
@@ -5005,9 +5043,9 @@ var NetworkClient = /*#__PURE__*/function () {
|
|
|
5005
5043
|
}));
|
|
5006
5044
|
case 5:
|
|
5007
5045
|
case "end":
|
|
5008
|
-
return
|
|
5046
|
+
return _context66.stop();
|
|
5009
5047
|
}
|
|
5010
|
-
},
|
|
5048
|
+
}, _callee66, this);
|
|
5011
5049
|
}));
|
|
5012
5050
|
}
|
|
5013
5051
|
}, {
|
|
@@ -5050,11 +5088,11 @@ var GoogleOneTapClient = /*#__PURE__*/function () {
|
|
|
5050
5088
|
style = _ref12.style,
|
|
5051
5089
|
_ref12$cancelOnTapOut = _ref12.cancelOnTapOutside,
|
|
5052
5090
|
cancelOnTapOutside = _ref12$cancelOnTapOut === void 0 ? true : _ref12$cancelOnTapOut;
|
|
5053
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function
|
|
5091
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function _callee67() {
|
|
5054
5092
|
var _this14 = this;
|
|
5055
5093
|
var embeddedMode, shouldRenderEmbeddedOneTap, config;
|
|
5056
|
-
return _regeneratorRuntime2().wrap(function
|
|
5057
|
-
while (1) switch (
|
|
5094
|
+
return _regeneratorRuntime2().wrap(function _callee67$(_context67) {
|
|
5095
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
5058
5096
|
case 0:
|
|
5059
5097
|
embeddedMode = getConfiguredEmbeddedMode(style.position);
|
|
5060
5098
|
shouldRenderEmbeddedOneTap = getShouldRenderEmbeddedOneTap(style.position);
|
|
@@ -5072,7 +5110,7 @@ var GoogleOneTapClient = /*#__PURE__*/function () {
|
|
|
5072
5110
|
config.cancel_on_tap_outside = false;
|
|
5073
5111
|
}
|
|
5074
5112
|
this._googleClient.initialize(config);
|
|
5075
|
-
return
|
|
5113
|
+
return _context67.abrupt("return", new Promise(function (resolve) {
|
|
5076
5114
|
_this14._googleClient.prompt(function (notification) {
|
|
5077
5115
|
var _a, _b, _c, _d, _e;
|
|
5078
5116
|
if (notification.isSkippedMoment()) {
|
|
@@ -5101,9 +5139,9 @@ var GoogleOneTapClient = /*#__PURE__*/function () {
|
|
|
5101
5139
|
}));
|
|
5102
5140
|
case 6:
|
|
5103
5141
|
case "end":
|
|
5104
|
-
return
|
|
5142
|
+
return _context67.stop();
|
|
5105
5143
|
}
|
|
5106
|
-
},
|
|
5144
|
+
}, _callee67, this);
|
|
5107
5145
|
}));
|
|
5108
5146
|
}
|
|
5109
5147
|
}, {
|
|
@@ -5136,27 +5174,27 @@ var OneTapProvider = /*#__PURE__*/function () {
|
|
|
5136
5174
|
signupRedirectUrl = _ref13.signupRedirectUrl,
|
|
5137
5175
|
onSuccess = _ref13.onSuccess;
|
|
5138
5176
|
return function (response) {
|
|
5139
|
-
return __awaiter(_this15, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function
|
|
5177
|
+
return __awaiter(_this15, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function _callee68() {
|
|
5140
5178
|
var credential, _yield$this$submitGoo, redirect_url;
|
|
5141
|
-
return _regeneratorRuntime2().wrap(function
|
|
5142
|
-
while (1) switch (
|
|
5179
|
+
return _regeneratorRuntime2().wrap(function _callee68$(_context68) {
|
|
5180
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
5143
5181
|
case 0:
|
|
5144
5182
|
credential = response.credential;
|
|
5145
|
-
|
|
5183
|
+
_context68.next = 3;
|
|
5146
5184
|
return this.submitGoogleOneTapToken({
|
|
5147
5185
|
credential: credential,
|
|
5148
5186
|
loginRedirectUrl: loginRedirectUrl,
|
|
5149
5187
|
signupRedirectUrl: signupRedirectUrl
|
|
5150
5188
|
});
|
|
5151
5189
|
case 3:
|
|
5152
|
-
_yield$this$submitGoo =
|
|
5190
|
+
_yield$this$submitGoo = _context68.sent;
|
|
5153
5191
|
redirect_url = _yield$this$submitGoo.redirect_url;
|
|
5154
5192
|
onSuccess(redirect_url);
|
|
5155
5193
|
case 6:
|
|
5156
5194
|
case "end":
|
|
5157
|
-
return
|
|
5195
|
+
return _context68.stop();
|
|
5158
5196
|
}
|
|
5159
|
-
},
|
|
5197
|
+
}, _callee68, this);
|
|
5160
5198
|
}));
|
|
5161
5199
|
};
|
|
5162
5200
|
};
|
|
@@ -5167,53 +5205,53 @@ var OneTapProvider = /*#__PURE__*/function () {
|
|
|
5167
5205
|
return _createClass2(OneTapProvider, [{
|
|
5168
5206
|
key: "createOneTapClient",
|
|
5169
5207
|
value: function createOneTapClient() {
|
|
5170
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function
|
|
5208
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function _callee69() {
|
|
5171
5209
|
var googleClientId, _yield$this$fetchGoog, err, client;
|
|
5172
|
-
return _regeneratorRuntime2().wrap(function
|
|
5173
|
-
while (1) switch (
|
|
5210
|
+
return _regeneratorRuntime2().wrap(function _callee69$(_context69) {
|
|
5211
|
+
while (1) switch (_context69.prev = _context69.next) {
|
|
5174
5212
|
case 0:
|
|
5175
|
-
|
|
5176
|
-
|
|
5213
|
+
_context69.prev = 0;
|
|
5214
|
+
_context69.next = 3;
|
|
5177
5215
|
return this.fetchGoogleStart();
|
|
5178
5216
|
case 3:
|
|
5179
|
-
_yield$this$fetchGoog =
|
|
5217
|
+
_yield$this$fetchGoog = _context69.sent;
|
|
5180
5218
|
googleClientId = _yield$this$fetchGoog.googleClientId;
|
|
5181
|
-
|
|
5219
|
+
_context69.next = 11;
|
|
5182
5220
|
break;
|
|
5183
5221
|
case 7:
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
err = StytchAPIError.from(
|
|
5187
|
-
return
|
|
5222
|
+
_context69.prev = 7;
|
|
5223
|
+
_context69.t0 = _context69["catch"](0);
|
|
5224
|
+
err = StytchAPIError.from(_context69.t0);
|
|
5225
|
+
return _context69.abrupt("return", {
|
|
5188
5226
|
success: false,
|
|
5189
5227
|
reason: err.error_type
|
|
5190
5228
|
});
|
|
5191
5229
|
case 11:
|
|
5192
5230
|
if (!(googleClientId === '')) {
|
|
5193
|
-
|
|
5231
|
+
_context69.next = 13;
|
|
5194
5232
|
break;
|
|
5195
5233
|
}
|
|
5196
|
-
return
|
|
5234
|
+
return _context69.abrupt("return", {
|
|
5197
5235
|
success: false,
|
|
5198
5236
|
reason: 'oauth_config_not_found'
|
|
5199
5237
|
});
|
|
5200
5238
|
case 13:
|
|
5201
|
-
|
|
5202
|
-
|
|
5239
|
+
_context69.t1 = GoogleOneTapClient;
|
|
5240
|
+
_context69.next = 16;
|
|
5203
5241
|
return loadGoogleOneTapClient();
|
|
5204
5242
|
case 16:
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
client = new
|
|
5208
|
-
return
|
|
5243
|
+
_context69.t2 = _context69.sent;
|
|
5244
|
+
_context69.t3 = googleClientId;
|
|
5245
|
+
client = new _context69.t1(_context69.t2, _context69.t3);
|
|
5246
|
+
return _context69.abrupt("return", {
|
|
5209
5247
|
success: true,
|
|
5210
5248
|
client: client
|
|
5211
5249
|
});
|
|
5212
5250
|
case 20:
|
|
5213
5251
|
case "end":
|
|
5214
|
-
return
|
|
5252
|
+
return _context69.stop();
|
|
5215
5253
|
}
|
|
5216
|
-
},
|
|
5254
|
+
}, _callee69, this, [[0, 7]]);
|
|
5217
5255
|
}));
|
|
5218
5256
|
}
|
|
5219
5257
|
}, {
|
|
@@ -5233,17 +5271,17 @@ var OneTapProvider = /*#__PURE__*/function () {
|
|
|
5233
5271
|
var credential = _ref14.credential,
|
|
5234
5272
|
loginRedirectUrl = _ref14.loginRedirectUrl,
|
|
5235
5273
|
signupRedirectUrl = _ref14.signupRedirectUrl;
|
|
5236
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function
|
|
5274
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function _callee70() {
|
|
5237
5275
|
var _yield$this$fetchGoog2, oauthCallbackId;
|
|
5238
|
-
return _regeneratorRuntime2().wrap(function
|
|
5239
|
-
while (1) switch (
|
|
5276
|
+
return _regeneratorRuntime2().wrap(function _callee70$(_context70) {
|
|
5277
|
+
while (1) switch (_context70.prev = _context70.next) {
|
|
5240
5278
|
case 0:
|
|
5241
|
-
|
|
5279
|
+
_context70.next = 2;
|
|
5242
5280
|
return this.fetchGoogleStart();
|
|
5243
5281
|
case 2:
|
|
5244
|
-
_yield$this$fetchGoog2 =
|
|
5282
|
+
_yield$this$fetchGoog2 = _context70.sent;
|
|
5245
5283
|
oauthCallbackId = _yield$this$fetchGoog2.oauthCallbackId;
|
|
5246
|
-
return
|
|
5284
|
+
return _context70.abrupt("return", this.clientsideServices.oneTapSubmit({
|
|
5247
5285
|
publicToken: this._publicToken,
|
|
5248
5286
|
idToken: credential,
|
|
5249
5287
|
loginRedirectURL: loginRedirectUrl,
|
|
@@ -5252,9 +5290,9 @@ var OneTapProvider = /*#__PURE__*/function () {
|
|
|
5252
5290
|
}));
|
|
5253
5291
|
case 5:
|
|
5254
5292
|
case "end":
|
|
5255
|
-
return
|
|
5293
|
+
return _context70.stop();
|
|
5256
5294
|
}
|
|
5257
|
-
},
|
|
5295
|
+
}, _callee70, this);
|
|
5258
5296
|
}));
|
|
5259
5297
|
}
|
|
5260
5298
|
}], [{
|
|
@@ -5300,22 +5338,22 @@ var PKCEManager = /*#__PURE__*/function () {
|
|
|
5300
5338
|
}, {
|
|
5301
5339
|
key: "startPKCETransaction",
|
|
5302
5340
|
value: function startPKCETransaction() {
|
|
5303
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function
|
|
5341
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function _callee71() {
|
|
5304
5342
|
var keyPair;
|
|
5305
|
-
return _regeneratorRuntime2().wrap(function
|
|
5306
|
-
while (1) switch (
|
|
5343
|
+
return _regeneratorRuntime2().wrap(function _callee71$(_context71) {
|
|
5344
|
+
while (1) switch (_context71.prev = _context71.next) {
|
|
5307
5345
|
case 0:
|
|
5308
|
-
|
|
5346
|
+
_context71.next = 2;
|
|
5309
5347
|
return PKCEManager.createProofkeyPair();
|
|
5310
5348
|
case 2:
|
|
5311
|
-
keyPair =
|
|
5349
|
+
keyPair = _context71.sent;
|
|
5312
5350
|
this._dataLayer.setItem(this.key(), JSON.stringify(keyPair));
|
|
5313
|
-
return
|
|
5351
|
+
return _context71.abrupt("return", keyPair);
|
|
5314
5352
|
case 5:
|
|
5315
5353
|
case "end":
|
|
5316
|
-
return
|
|
5354
|
+
return _context71.stop();
|
|
5317
5355
|
}
|
|
5318
|
-
},
|
|
5356
|
+
}, _callee71, this);
|
|
5319
5357
|
}));
|
|
5320
5358
|
}
|
|
5321
5359
|
}, {
|
|
@@ -5340,27 +5378,27 @@ var PKCEManager = /*#__PURE__*/function () {
|
|
|
5340
5378
|
}], [{
|
|
5341
5379
|
key: "createProofkeyPair",
|
|
5342
5380
|
value: function createProofkeyPair() {
|
|
5343
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function
|
|
5381
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function _callee72() {
|
|
5344
5382
|
var bytes, codeVerifier, digest;
|
|
5345
|
-
return _regeneratorRuntime2().wrap(function
|
|
5346
|
-
while (1) switch (
|
|
5383
|
+
return _regeneratorRuntime2().wrap(function _callee72$(_context72) {
|
|
5384
|
+
while (1) switch (_context72.prev = _context72.next) {
|
|
5347
5385
|
case 0:
|
|
5348
5386
|
bytes = new Uint32Array(16);
|
|
5349
5387
|
window.crypto.getRandomValues(bytes);
|
|
5350
5388
|
codeVerifier = Array.from(bytes).map(toHex).join('');
|
|
5351
|
-
|
|
5389
|
+
_context72.next = 5;
|
|
5352
5390
|
return window.crypto.subtle.digest('SHA-256', new TextEncoder().encode(codeVerifier));
|
|
5353
5391
|
case 5:
|
|
5354
|
-
digest =
|
|
5355
|
-
return
|
|
5392
|
+
digest = _context72.sent;
|
|
5393
|
+
return _context72.abrupt("return", {
|
|
5356
5394
|
code_challenge: base64URLEncode(digest),
|
|
5357
5395
|
code_verifier: codeVerifier
|
|
5358
5396
|
});
|
|
5359
5397
|
case 7:
|
|
5360
5398
|
case "end":
|
|
5361
|
-
return
|
|
5399
|
+
return _context72.stop();
|
|
5362
5400
|
}
|
|
5363
|
-
},
|
|
5401
|
+
}, _callee72);
|
|
5364
5402
|
}));
|
|
5365
5403
|
}
|
|
5366
5404
|
}]);
|
|
@@ -6031,63 +6069,63 @@ var IDPClient = /*#__PURE__*/_createClass2(function IDPClient(_networkClient) {
|
|
|
6031
6069
|
_classCallCheck2(this, IDPClient);
|
|
6032
6070
|
this._networkClient = _networkClient;
|
|
6033
6071
|
this.oauthAuthorizeStart = function (data) {
|
|
6034
|
-
return __awaiter(_this20, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function
|
|
6035
|
-
return _regeneratorRuntime2().wrap(function
|
|
6036
|
-
while (1) switch (
|
|
6072
|
+
return __awaiter(_this20, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function _callee73() {
|
|
6073
|
+
return _regeneratorRuntime2().wrap(function _callee73$(_context73) {
|
|
6074
|
+
while (1) switch (_context73.prev = _context73.next) {
|
|
6037
6075
|
case 0:
|
|
6038
|
-
|
|
6076
|
+
_context73.next = 2;
|
|
6039
6077
|
return this._networkClient.fetchSDK({
|
|
6040
6078
|
url: "/oauth/authorize/start",
|
|
6041
6079
|
method: 'POST',
|
|
6042
6080
|
body: data
|
|
6043
6081
|
});
|
|
6044
6082
|
case 2:
|
|
6045
|
-
return
|
|
6083
|
+
return _context73.abrupt("return", _context73.sent);
|
|
6046
6084
|
case 3:
|
|
6047
6085
|
case "end":
|
|
6048
|
-
return
|
|
6086
|
+
return _context73.stop();
|
|
6049
6087
|
}
|
|
6050
|
-
},
|
|
6088
|
+
}, _callee73, this);
|
|
6051
6089
|
}));
|
|
6052
6090
|
};
|
|
6053
6091
|
this.oauthAuthorizeSubmit = function (data) {
|
|
6054
|
-
return __awaiter(_this20, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function
|
|
6055
|
-
return _regeneratorRuntime2().wrap(function
|
|
6056
|
-
while (1) switch (
|
|
6092
|
+
return __awaiter(_this20, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function _callee74() {
|
|
6093
|
+
return _regeneratorRuntime2().wrap(function _callee74$(_context74) {
|
|
6094
|
+
while (1) switch (_context74.prev = _context74.next) {
|
|
6057
6095
|
case 0:
|
|
6058
|
-
|
|
6096
|
+
_context74.next = 2;
|
|
6059
6097
|
return this._networkClient.submitFormSDK({
|
|
6060
6098
|
url: "/oauth/authorize",
|
|
6061
6099
|
method: 'POST',
|
|
6062
6100
|
body: data
|
|
6063
6101
|
});
|
|
6064
6102
|
case 2:
|
|
6065
|
-
return
|
|
6103
|
+
return _context74.abrupt("return", _context74.sent);
|
|
6066
6104
|
case 3:
|
|
6067
6105
|
case "end":
|
|
6068
|
-
return
|
|
6106
|
+
return _context74.stop();
|
|
6069
6107
|
}
|
|
6070
|
-
},
|
|
6108
|
+
}, _callee74, this);
|
|
6071
6109
|
}));
|
|
6072
6110
|
};
|
|
6073
6111
|
this.oauthLogoutStart = function (data) {
|
|
6074
|
-
return __awaiter(_this20, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function
|
|
6075
|
-
return _regeneratorRuntime2().wrap(function
|
|
6076
|
-
while (1) switch (
|
|
6112
|
+
return __awaiter(_this20, void 0, void 0, /*#__PURE__*/_regeneratorRuntime2().mark(function _callee75() {
|
|
6113
|
+
return _regeneratorRuntime2().wrap(function _callee75$(_context75) {
|
|
6114
|
+
while (1) switch (_context75.prev = _context75.next) {
|
|
6077
6115
|
case 0:
|
|
6078
|
-
|
|
6116
|
+
_context75.next = 2;
|
|
6079
6117
|
return this._networkClient.fetchSDK({
|
|
6080
6118
|
url: "/oauth/logout/start",
|
|
6081
6119
|
method: 'POST',
|
|
6082
6120
|
body: data
|
|
6083
6121
|
});
|
|
6084
6122
|
case 2:
|
|
6085
|
-
return
|
|
6123
|
+
return _context75.abrupt("return", _context75.sent);
|
|
6086
6124
|
case 3:
|
|
6087
6125
|
case "end":
|
|
6088
|
-
return
|
|
6126
|
+
return _context75.stop();
|
|
6089
6127
|
}
|
|
6090
|
-
},
|
|
6128
|
+
}, _callee75, this);
|
|
6091
6129
|
}));
|
|
6092
6130
|
};
|
|
6093
6131
|
});
|