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