@stytch/vanilla-js 5.6.2 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +1 -1
  3. package/dist/adminPortal/index.esm.js +2 -2
  4. package/dist/adminPortal/index.js +2 -2
  5. package/dist/adminPortal/settings/AdminPortalOrgSettings.d.ts +1 -0
  6. package/dist/b2b/index.esm.js +1866 -1307
  7. package/dist/b2b/index.headless.esm.js +3 -3
  8. package/dist/b2b/index.headless.js +2 -2
  9. package/dist/b2b/index.js +1869 -1310
  10. package/dist/{extractErrorMessage-DqI8LnhU.js → extractErrorMessage-C0TeBTBa.js} +4 -4
  11. package/dist/{extractErrorMessage-Ddemk2Gq.js → extractErrorMessage-CYXucHbA.js} +5 -5
  12. package/dist/index.esm.js +1 -1
  13. package/dist/index.headless.esm.js +43 -39
  14. package/dist/index.headless.js +43 -39
  15. package/dist/index.js +1 -1
  16. package/dist/{internal-8PFEtDRF.js → internal-BeiYVaO7.js} +597 -435
  17. package/dist/{internal-B_3PRrIX.js → internal-HC6WhS3G.js} +598 -436
  18. package/dist/ui/b2b/GlobalContextProvider.d.ts +11 -4
  19. package/dist/ui/b2b/generateProductComponentsOrdering.d.ts +4 -3
  20. package/dist/ui/b2b/getOtpCodeExpiration.d.ts +1 -0
  21. package/dist/ui/b2b/hooks/useEmailOtpDiscoverySend.d.ts +5 -0
  22. package/dist/ui/b2b/hooks/useEmailOtpLoginOrSignup.d.ts +6 -0
  23. package/dist/ui/b2b/hooks/useEmlDiscoverySend.d.ts +5 -0
  24. package/dist/ui/b2b/hooks/useEmlLoginOrSignup.d.ts +6 -0
  25. package/dist/ui/b2b/reducer.d.ts +7 -1
  26. package/dist/ui/b2b/screens/EmailForm.d.ts +3 -0
  27. package/dist/ui/b2b/screens/EmailMethodSelectionScreen.d.ts +2 -0
  28. package/dist/ui/b2b/screens/EmailOTPEntryScreen.d.ts +2 -0
  29. package/dist/ui/b2b/utils.d.ts +3 -1
  30. package/dist/ui/components/LoadingButton.d.ts +8 -0
  31. package/dist/ui/components/MenuButton.d.ts +6 -0
  32. package/dist/ui/components/SubmitButton.d.ts +1 -1
  33. package/dist/utils/StyledComponentProps.d.ts +2 -0
  34. package/package.json +2 -2
  35. package/dist/ui/b2b/screens/MagicLinkForm.d.ts +0 -3
@@ -17,22 +17,22 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
17
17
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
18
18
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
19
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
21
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
23
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
24
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
25
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
26
20
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
27
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
28
22
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
29
23
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
30
24
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
31
25
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
26
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
27
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
28
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
29
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
30
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
31
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
32
32
  import { StytchB2BHeadlessClient } from './index.headless.esm.js';
33
- import { i as isTruthy, w as wn, q, F as F$1, m as merge, a as w$1, y, g as g$1, p as p$1, T as T$1, h as h$2, H as He, b as withMiddleware, u as useSWR, c as useSWRConfig, _ as _$1, d as useStateWithDeps, s as serialize, e as mergeObjects, f as getTimestamp, U as UNDEFINED, j as useIsomorphicLayoutEffect, k as Ue, l as passwordManagerDisableAutofillProps, Z as Ze, n as extractErrorMessage, C as CreateSSRSafeWebComponent, o as Fe } from '../extractErrorMessage-Ddemk2Gq.js';
34
- import { B as B2BMFAProducts, A as AuthFlowType, a as B2BProducts, b as OTPMethods, W as Wallets, P as Products, S as StytchEventType, r as readB2BInternals, D as DEFAULT_SESSION_DURATION_MINUTES, _ as __awaiter, E as EMAIL_REGEX, c as StytchAPIError, d as B2BOAuthProviders, l as logger, e as OneTapPositions, i as isTestPublicToken, f as debounce, C as COUNTRIES_LIST, g as StytchSDKError, h as checkNotSSR } from '../internal-B_3PRrIX.js';
35
- export { j as BiometricsFailedError, k as BiometricsUnavailableError, m as ChallengeSigningFailedError, n as DeviceCredentialsNotAllowedError, F as FailedCodeChallengeError, o as FailedToDecryptDataError, I as InternalError, p as InvalidAuthorizationCredentialError, q as InvalidCredentialTypeError, s as InvalidRedirectSchemeError, t as InvalidStartUrlError, J as JSONDataNotConvertibleToStringError, K as KeyInvalidatedError, u as KeystoreUnavailableError, M as MissingAttestationObjectError, v as MissingAuthorizationCredentialIDTokenError, w as MissingGoogleClientIDError, x as MissingPKCEError, y as MissingPublicKeyError, z as MissingUrlError, N as NoBiometricsEnrolledError, G as NoBiometricsRegistrationError, H as NoCredentialsPresentError, L as NoCurrentSessionError, O as OAuthProviders, Q as PasskeysInvalidEncoding, R as PasskeysMisconfigured, T as PasskeysUnsupportedError, U as RNUIProducts, V as RandomNumberGenerationFailed, X as SDKAPIUnreachableError, Y as SDKNotConfiguredError, Z as SignInWithAppleMisconfigured, $ as StytchAPISchemaError, a0 as StytchAPIUnreachableError, a1 as StytchError, a2 as StytchSDKAPIError, a3 as StytchSDKSchemaError, a4 as StytchSDKUsageError, a5 as UNRECOVERABLE_ERROR_TYPES, a6 as UserCancellationError, a7 as UserLockedOutError, a8 as errorToStytchError } from '../internal-B_3PRrIX.js';
33
+ import { i as isTruthy, w as wn, q, F as F$1, m as merge, a as w$1, y, g as g$1, p as p$1, T as T$1, h as h$2, H as He, b as passwordManagerDisableAutofillProps, U as Ue, c as withMiddleware, u as useSWR, d as useSWRConfig, _ as _$1, e as useStateWithDeps, s as serialize, f as mergeObjects, j as getTimestamp, k as UNDEFINED, l as useIsomorphicLayoutEffect, Z as Ze, n as extractErrorMessage, C as CreateSSRSafeWebComponent, o as Fe } from '../extractErrorMessage-CYXucHbA.js';
34
+ import { B as B2BMFAProducts, A as AuthFlowType, a as B2BProducts, b as OTPMethods, W as Wallets, P as Products, _ as __rest, c as B2BOAuthProviders, S as StytchEventType, r as readB2BInternals, D as DEFAULT_SESSION_DURATION_MINUTES, d as __awaiter, E as EMAIL_REGEX, e as StytchAPIError, l as logger, f as OneTapPositions, i as isTestPublicToken, g as debounce, C as COUNTRIES_LIST, h as StytchSDKError, j as checkNotSSR } from '../internal-HC6WhS3G.js';
35
+ export { k as BiometricsFailedError, m as BiometricsUnavailableError, n as ChallengeSigningFailedError, o as DeviceCredentialsNotAllowedError, F as FailedCodeChallengeError, p as FailedToDecryptDataError, I as InternalError, q as InvalidAuthorizationCredentialError, s as InvalidCredentialTypeError, t as InvalidRedirectSchemeError, u as InvalidStartUrlError, J as JSONDataNotConvertibleToStringError, K as KeyInvalidatedError, v as KeystoreUnavailableError, M as MissingAttestationObjectError, w as MissingAuthorizationCredentialIDTokenError, x as MissingGoogleClientIDError, y as MissingPKCEError, z as MissingPublicKeyError, G as MissingUrlError, N as NoBiometricsEnrolledError, H as NoBiometricsRegistrationError, L as NoCredentialsPresentError, Q as NoCurrentSessionError, O as OAuthProviders, R as PasskeysInvalidEncoding, T as PasskeysMisconfigured, U as PasskeysUnsupportedError, V as RNUIProducts, X as RandomNumberGenerationFailed, Y as SDKAPIUnreachableError, Z as SDKNotConfiguredError, $ as SignInWithAppleMisconfigured, a0 as StytchAPISchemaError, a1 as StytchAPIUnreachableError, a2 as StytchError, a3 as StytchSDKAPIError, a4 as StytchSDKSchemaError, a5 as StytchSDKUsageError, a6 as UNRECOVERABLE_ERROR_TYPES, a7 as UserCancellationError, a8 as UserLockedOutError, a9 as errorToStytchError } from '../internal-HC6WhS3G.js';
36
36
  var DEFAULT_MFA_STATE = {
37
37
  primaryInfo: null,
38
38
  isEnrolling: false,
@@ -342,20 +342,36 @@ var reducer = function reducer(state, action) {
342
342
  var _a, _b, _c;
343
343
  switch (action.type) {
344
344
  case 'transition':
345
- return Object.assign(Object.assign({}, state), {
346
- screen: action.screen
347
- });
345
+ {
346
+ var screenHistory = action.history === 'push' ? [].concat(_toConsumableArray(state.screenHistory), [state.screen]) : [];
347
+ return Object.assign(Object.assign({}, state), {
348
+ screen: action.screen,
349
+ screenHistory: screenHistory
350
+ });
351
+ }
352
+ case 'navigate_back':
353
+ {
354
+ var screen = state.screenHistory.at(-1);
355
+ if (!screen) {
356
+ return state;
357
+ }
358
+ var _screenHistory = state.screenHistory.slice(0, -1);
359
+ return Object.assign(Object.assign({}, state), {
360
+ screen: screen,
361
+ screenHistory: _screenHistory
362
+ });
363
+ }
348
364
  case 'set_error_message_and_transition':
349
365
  return Object.assign(Object.assign({}, state), {
350
366
  screen: AppScreens$1.Error,
351
367
  errorType: action.errorType
352
368
  });
353
- case 'set_magic_link_email':
369
+ case 'set_user_supplied_email':
354
370
  {
355
371
  return Object.assign(Object.assign({}, state), {
356
372
  formState: Object.assign(Object.assign({}, state.formState), {
357
- magicLinkState: {
358
- email: action.email
373
+ emailState: {
374
+ userSuppliedEmail: action.email
359
375
  }
360
376
  })
361
377
  });
@@ -426,6 +442,18 @@ var reducer = function reducer(state, action) {
426
442
  })
427
443
  });
428
444
  }
445
+ case 'send_email_otp':
446
+ {
447
+ return Object.assign(Object.assign({}, state), {
448
+ formState: Object.assign(Object.assign({}, state.formState), {
449
+ otpState: {
450
+ codeExpiration: action.codeExpiration
451
+ }
452
+ }),
453
+ screen: AppScreens$1.EmailOTPEntry,
454
+ screenHistory: [].concat(_toConsumableArray(state.screenHistory), [state.screen])
455
+ });
456
+ }
429
457
  default:
430
458
  return mfaReducer(state, action);
431
459
  }
@@ -451,6 +479,8 @@ var AppScreens$1;
451
479
  AppScreens["TOTPEnrollmentManual"] = "TOTP Enrollment Manual";
452
480
  AppScreens["TOTPEnrollmentQRCode"] = "TOTP Enrollment QR Code";
453
481
  AppScreens["TOTPEntry"] = "TOTP Entry";
482
+ AppScreens["EmailMethodSelection"] = "Email Method Selection";
483
+ AppScreens["EmailOTPEntry"] = "Email OTP Entry";
454
484
  })(AppScreens$1 || (AppScreens$1 = {}));
455
485
  var ErrorType;
456
486
  (function (ErrorType) {
@@ -462,9 +492,13 @@ var ErrorType;
462
492
  })(ErrorType || (ErrorType = {}));
463
493
  var DEFAULT_STATE = {
464
494
  screen: AppScreens$1.Main,
495
+ screenHistory: [],
465
496
  formState: {
466
- magicLinkState: {
467
- email: ''
497
+ emailState: {
498
+ userSuppliedEmail: ''
499
+ },
500
+ otpState: {
501
+ codeExpiration: null
468
502
  },
469
503
  discoveryState: {
470
504
  email: '',
@@ -1510,186 +1544,495 @@ var ErrorScreen = function ErrorScreen() {
1510
1544
  size: "header"
1511
1545
  }, "Looks like there was an error!"), /*#__PURE__*/wn.createElement(ErrorSVG, null), /*#__PURE__*/wn.createElement(Text, null, ErrorTypeMap[currentErrorType]));
1512
1546
  };
1513
- var mutation = function mutation() {
1514
- return function (key, fetcher) {
1515
- var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1516
- var _useSWRConfig = useSWRConfig(),
1517
- mutate = _useSWRConfig.mutate;
1518
- var keyRef = _$1(key);
1519
- var fetcherRef = _$1(fetcher);
1520
- var configRef = _$1(config);
1521
- var ditchMutationsUntilRef = _$1(0);
1522
- var _useStateWithDeps = useStateWithDeps({
1523
- data: UNDEFINED,
1524
- error: UNDEFINED,
1525
- isMutating: false
1526
- }),
1527
- _useStateWithDeps2 = _slicedToArray(_useStateWithDeps, 3),
1528
- stateRef = _useStateWithDeps2[0],
1529
- stateDependencies = _useStateWithDeps2[1],
1530
- setState = _useStateWithDeps2[2];
1531
- var currentState = stateRef.current;
1532
- var trigger = T$1( /*#__PURE__*/function () {
1533
- var _ref39 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(arg, opts) {
1534
- var _serialize, _serialize2, serializedKey, resolvedKey, options, mutationStartedAt, data;
1535
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1536
- while (1) switch (_context.prev = _context.next) {
1537
- case 0:
1538
- _serialize = serialize(keyRef.current), _serialize2 = _slicedToArray(_serialize, 2), serializedKey = _serialize2[0], resolvedKey = _serialize2[1];
1539
- if (fetcherRef.current) {
1540
- _context.next = 3;
1541
- break;
1542
- }
1543
- throw new Error('Can’t trigger the mutation: missing fetcher.');
1544
- case 3:
1545
- if (serializedKey) {
1546
- _context.next = 5;
1547
- break;
1548
- }
1549
- throw new Error('Can’t trigger the mutation: missing key.');
1550
- case 5:
1551
- options = mergeObjects(mergeObjects({
1552
- populateCache: false,
1553
- throwOnError: true
1554
- }, configRef.current), opts);
1555
- mutationStartedAt = getTimestamp();
1556
- ditchMutationsUntilRef.current = mutationStartedAt;
1557
- setState({
1558
- isMutating: true
1559
- });
1560
- _context.prev = 9;
1561
- _context.next = 12;
1562
- return mutate(serializedKey, fetcherRef.current(resolvedKey, {
1563
- arg: arg
1564
- }), mergeObjects(options, {
1565
- throwOnError: true
1566
- }));
1567
- case 12:
1568
- data = _context.sent;
1569
- if (ditchMutationsUntilRef.current <= mutationStartedAt) {
1570
- setState({
1571
- data: data,
1572
- isMutating: false,
1573
- error: undefined
1574
- });
1575
- options.onSuccess == null ? void 0 : options.onSuccess(data, serializedKey, options);
1576
- }
1577
- return _context.abrupt("return", data);
1578
- case 17:
1579
- _context.prev = 17;
1580
- _context.t0 = _context["catch"](9);
1581
- if (!(ditchMutationsUntilRef.current <= mutationStartedAt)) {
1582
- _context.next = 24;
1583
- break;
1584
- }
1585
- setState({
1586
- error: _context.t0,
1587
- isMutating: false
1588
- });
1589
- options.onError == null ? void 0 : options.onError(_context.t0, serializedKey, options);
1590
- if (!options.throwOnError) {
1591
- _context.next = 24;
1592
- break;
1593
- }
1594
- throw _context.t0;
1595
- case 24:
1596
- case "end":
1597
- return _context.stop();
1598
- }
1599
- }, _callee, null, [[9, 17]]);
1600
- }));
1601
- return function (_x, _x2) {
1602
- return _ref39.apply(this, arguments);
1603
- };
1604
- }(), []);
1605
- var reset = T$1(function () {
1606
- ditchMutationsUntilRef.current = getTimestamp();
1607
- setState({
1608
- data: UNDEFINED,
1609
- error: UNDEFINED,
1610
- isMutating: false
1611
- });
1612
- }, []);
1613
- useIsomorphicLayoutEffect(function () {
1614
- keyRef.current = key;
1615
- fetcherRef.current = fetcher;
1616
- configRef.current = config;
1617
- });
1618
- return {
1619
- trigger: trigger,
1620
- reset: reset,
1621
- get data() {
1622
- stateDependencies.data = true;
1623
- return currentState.data;
1624
- },
1625
- get error() {
1626
- stateDependencies.error = true;
1627
- return currentState.error;
1628
- },
1629
- get isMutating() {
1630
- stateDependencies.isMutating = true;
1631
- return currentState.isMutating;
1632
- }
1633
- };
1634
- };
1635
- };
1636
- var index = withMiddleware(useSWR, mutation);
1637
- var KeyToStytchEventMap = {
1638
- 'stytch.magicLinks.authenticate': StytchEventType.B2BMagicLinkAuthenticate,
1639
- 'stytch.sso.authenticate': StytchEventType.B2BSSOAuthenticate,
1640
- 'stytch.magicLinks.discovery.authenticate': StytchEventType.B2BMagicLinkDiscoveryAuthenticate,
1641
- 'stytch.discovery.organization.create': StytchEventType.B2BDiscoveryOrganizationsCreate,
1642
- 'stytch.discovery.intermediateSessions.exchange': StytchEventType.B2BDiscoveryIntermediateSessionExchange,
1643
- 'stytch.magicLinks.email.loginOrSignup': StytchEventType.B2BMagicLinkEmailLoginOrSignup,
1644
- 'stytch.magicLinks.discovery.send': StytchEventType.B2BMagicLinkEmailDiscoverySend,
1645
- 'stytch.oauth.authenticate': StytchEventType.B2BOAuthAuthenticate,
1646
- 'stytch.oauth.discovery.authenticate': StytchEventType.B2BOAuthDiscoveryAuthenticate,
1647
- 'stytch.otps.sms.send': StytchEventType.B2BSMSOTPSend,
1648
- 'stytch.otps.sms.authenticate': StytchEventType.B2BSMSOTPAuthenticate,
1649
- 'stytch.totp.create': StytchEventType.B2BTOTPCreate,
1650
- 'stytch.totp.authenticate': StytchEventType.B2BTOTPAuthenticate,
1651
- 'stytch.recoveryCodes.recover': StytchEventType.B2BRecoveryCodesRecover
1652
- };
1653
- var useMutate = function useMutate(key, fetcher, options) {
1654
- var onEvent = useEventCallback();
1655
- var _onError = useErrorCallback();
1656
- return index(key, fetcher, Object.assign(Object.assign({
1657
- throwOnError: false
1658
- }, options), {
1659
- onSuccess: function onSuccess(data, key, config) {
1660
- if (KeyToStytchEventMap[key]) {
1661
- onEvent({
1662
- type: KeyToStytchEventMap[key],
1663
- data: data
1664
- });
1665
- }
1666
- (options === null || options === void 0 ? void 0 : options.onSuccess) && options.onSuccess(data, key, config);
1547
+ var Input = He.input(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["\n background-color: ", ";\n height: 47px;\n padding: 0 8px;\n box-sizing: border-box;\n border: 1px solid ", ";\n border-radius: ", ";\n color: ", ";\n font-family: ", ";\n font-size: 18px;\n &::placeholder {\n color: ", ";\n }\n\n &:disabled {\n border: 1px solid ", ";\n color: ", ";\n background-color: ", ";\n }\n"])), function (props) {
1548
+ return props.theme.inputs.backgroundColor;
1549
+ }, function (props) {
1550
+ return props.theme.inputs.borderColor;
1551
+ }, function (props) {
1552
+ return props.theme.inputs.borderRadius;
1553
+ }, function (props) {
1554
+ return props.theme.inputs.textColor;
1555
+ }, function (props) {
1556
+ return props.theme.typography.fontFamily;
1557
+ }, function (props) {
1558
+ return props.theme.inputs.placeholderColor;
1559
+ }, function (props) {
1560
+ return props.theme.colors.disabledText;
1561
+ }, function (props) {
1562
+ return props.theme.colors.disabledText;
1563
+ }, function (props) {
1564
+ return props.theme.colors.disabled;
1565
+ });
1566
+ var EmailInput = function EmailInput(_ref39) {
1567
+ var email = _ref39.email,
1568
+ setEmail = _ref39.setEmail,
1569
+ _ref39$disableInput = _ref39.disableInput,
1570
+ disableInput = _ref39$disableInput === void 0 ? false : _ref39$disableInput,
1571
+ _ref39$hasPasskeys = _ref39.hasPasskeys,
1572
+ hasPasskeys = _ref39$hasPasskeys === void 0 ? false : _ref39$hasPasskeys;
1573
+ return /*#__PURE__*/wn.createElement(Input, Object.assign({
1574
+ placeholder: "example@email.com",
1575
+ name: "email",
1576
+ type: "email",
1577
+ autoComplete: hasPasskeys ? 'email webauthn' : 'email',
1578
+ disabled: disableInput,
1579
+ id: "email-input",
1580
+ value: email,
1581
+ onChange: function onChange(e) {
1582
+ return setEmail(e.target.value);
1667
1583
  },
1668
- onError: function onError(error, key, config) {
1669
- _onError(error);
1670
- (options === null || options === void 0 ? void 0 : options.onError) && options.onError(error, key, config);
1584
+ required: true
1585
+ }, hasPasskeys ? passwordManagerDisableAutofillProps : {}));
1586
+ };
1587
+ var DASHBOARD_REGEX = /https:\/\/stytch\.com\/[#a-zA-Z0-9/-]+/g;
1588
+ var mapURLsToLinks = function mapURLsToLinks(str) {
1589
+ var nonLinkChunks = str.split(DASHBOARD_REGEX);
1590
+ var linkChunks = Array.from(str.matchAll(DASHBOARD_REGEX)).map(function (el) {
1591
+ return el[0];
1592
+ });
1593
+ var chunkResults = [];
1594
+ while (nonLinkChunks.length || linkChunks.length) {
1595
+ if (nonLinkChunks.length) {
1596
+ chunkResults.push(nonLinkChunks.shift());
1671
1597
  }
1672
- }));
1598
+ if (linkChunks.length) {
1599
+ var chunk = linkChunks.shift();
1600
+ chunkResults.push( /*#__PURE__*/wn.createElement("a", {
1601
+ key: chunk + '__' + String(linkChunks.length),
1602
+ href: chunk,
1603
+ target: "_blank",
1604
+ rel: "noreferrer"
1605
+ }, chunk));
1606
+ }
1607
+ }
1608
+ return chunkResults;
1673
1609
  };
1674
- var useExtractSlug = function useExtractSlug() {
1675
- var _useGlobalReducer3 = useGlobalReducer(),
1676
- _useGlobalReducer4 = _slicedToArray(_useGlobalReducer3, 2),
1677
- state = _useGlobalReducer4[0],
1678
- dispatch = _useGlobalReducer4[1];
1679
- var _h$3 = h$2(),
1680
- _h$4 = _slicedToArray(_h$3, 2),
1681
- pattern = _h$4[0],
1682
- setPattern = _h$4[1];
1683
- var stytchClient = useStytch();
1684
- var slug = extractFromPattern(pattern || null);
1685
- var _useMutate = useMutate('stytchClient.organization.getBySlug', function (_, _ref40) {
1686
- var slug = _ref40.arg.slug;
1687
- return stytchClient.organization.getBySlug({
1688
- organization_slug: slug
1689
- });
1690
- }, {
1691
- onSuccess: function onSuccess(_ref41) {
1692
- var organization = _ref41.organization;
1610
+ var ErrorText = function ErrorText(_ref40) {
1611
+ var errorMessage = _ref40.errorMessage;
1612
+ var tokens = F$1(function () {
1613
+ return mapURLsToLinks(errorMessage);
1614
+ }, [errorMessage]);
1615
+ return /*#__PURE__*/wn.createElement(Text, {
1616
+ size: "helper",
1617
+ color: "error"
1618
+ }, tokens);
1619
+ };
1620
+ var Button = He.button(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["\n all: unset;\n width: 100%;\n height: 45px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 18px;\n text-transform: none;\n font-family: ", ";\n box-shadow: none;\n text-align: center;\n\n ", "\n\n &:disabled {\n background-color: ", ";\n color: ", ";\n border: ", ";\n border-radius: ", ";\n cursor: not-allowed;\n }\n"])), function (props) {
1621
+ return props.theme.typography.fontFamily;
1622
+ }, function (props) {
1623
+ switch (props.variant) {
1624
+ case 'primary':
1625
+ return "\n border: ".concat(props.theme.buttons.primary.border, ";\n border-radius: ").concat(props.theme.buttons.primary.borderRadius, ";\n color: ").concat(props.theme.buttons.primary.textColor, ";\n background-color: ").concat(props.theme.buttons.primary.backgroundColor, ";\n ");
1626
+ case 'outlined':
1627
+ return "\n border: ".concat(props.theme.buttons.secondary.border, ";\n border-radius: ").concat(props.theme.buttons.secondary.borderRadius, ";\n color: ").concat(props.theme.buttons.secondary.textColor, ";\n background-color: ").concat(props.theme.buttons.secondary.backgroundColor, ";\n ");
1628
+ case 'text':
1629
+ return "\n color: ".concat(props.theme.colors.primary, ";\n background-color: transparent;\n font-weight: 600;\n ");
1630
+ }
1631
+ }, function (props) {
1632
+ return props.theme.buttons.disabled.backgroundColor;
1633
+ }, function (props) {
1634
+ return props.theme.buttons.disabled.textColor;
1635
+ }, function (props) {
1636
+ return props.theme.buttons.disabled.border;
1637
+ }, function (props) {
1638
+ return props.theme.buttons.disabled.borderRadius;
1639
+ });
1640
+ Button.defaultProps = {
1641
+ variant: 'primary'
1642
+ };
1643
+ var circularRotateKeyframe = Ue(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n"])));
1644
+ var circularDashKeyframe = Ue(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["\n 0% {\n stroke-dasharray: 1px, 200px;\n stroke-dashoffset: 0;\n }\n 50% {\n stroke-dasharray: 100px, 200px;\n stroke-dashoffset: -15px;\n }\n 100% {\n stroke-dasharray: 100px, 200px;\n stroke-dashoffset: -125px;\n }\n"])));
1645
+ var AnimatedCircle = He.circle(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["\n stroke-dasharray: 80px, 200px;\n stroke-dashoffset: 0;\n animation: ", " 1.4s ease-in-out infinite;\n stroke: ", ";\n fill: none;\n"])), circularDashKeyframe, function (props) {
1646
+ return props.theme.colors.primary;
1647
+ });
1648
+ var CircularProgressRoot = He.div(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["\n width: ", "px;\n height: ", "px;\n animation: ", " 1.4s ease-in-out infinite;\n"])), function (props) {
1649
+ return props.size;
1650
+ }, function (props) {
1651
+ return props.size;
1652
+ }, circularRotateKeyframe);
1653
+ var CircularProgressSVG = He.svg(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["\n display: block;\n"])));
1654
+ var CircularProgress = function CircularProgress(_ref41) {
1655
+ var size = _ref41.size,
1656
+ thickness = _ref41.thickness;
1657
+ return /*#__PURE__*/wn.createElement(CircularProgressRoot, {
1658
+ size: size
1659
+ }, /*#__PURE__*/wn.createElement(CircularProgressSVG, {
1660
+ viewBox: "".concat(size / 2, " ").concat(size / 2, " ").concat(size, " ").concat(size)
1661
+ }, /*#__PURE__*/wn.createElement(AnimatedCircle, {
1662
+ cx: size,
1663
+ cy: size,
1664
+ r: (size - thickness) / 2,
1665
+ fill: "none",
1666
+ strokeWidth: thickness
1667
+ })));
1668
+ };
1669
+ var LoadingButton = function LoadingButton(_a) {
1670
+ var children = _a.children,
1671
+ isLoading = _a.isLoading,
1672
+ buttonProps = __rest(_a, ["children", "isLoading"]);
1673
+ return /*#__PURE__*/wn.createElement(Button, Object.assign({}, buttonProps), isLoading ? ( /*#__PURE__*/wn.createElement(Flex, {
1674
+ justifyContent: "center"
1675
+ }, /*#__PURE__*/wn.createElement(CircularProgress, {
1676
+ size: 18,
1677
+ thickness: 1,
1678
+ "data-testid": "loading-icon"
1679
+ }))) : children);
1680
+ };
1681
+ var SubmitButton = function SubmitButton(_ref42) {
1682
+ var isSubmitting = _ref42.isSubmitting,
1683
+ disabled = _ref42.disabled,
1684
+ text = _ref42.text,
1685
+ variant = _ref42.variant;
1686
+ var buttonDisabled = isSubmitting || disabled;
1687
+ return /*#__PURE__*/wn.createElement(LoadingButton, {
1688
+ isLoading: isSubmitting,
1689
+ type: "submit",
1690
+ disabled: buttonDisabled,
1691
+ variant: variant
1692
+ }, text);
1693
+ };
1694
+ var getParamsFromB2BOAuthProviderConfig = function getParamsFromB2BOAuthProviderConfig(provider) {
1695
+ var providerType = '';
1696
+ var oneTap = false;
1697
+ var customScopes = [];
1698
+ var providerParams = {};
1699
+ if (typeof provider === 'string') {
1700
+ providerType = provider;
1701
+ } else {
1702
+ providerType = provider.type;
1703
+ if (provider.type === B2BOAuthProviders.Google && 'one_tap' in provider) {
1704
+ oneTap = provider.one_tap;
1705
+ }
1706
+ customScopes = provider.customScopes || [];
1707
+ providerParams = provider.providerParams || {};
1708
+ }
1709
+ var oauthProvider = providerType;
1710
+ return {
1711
+ type: oauthProvider,
1712
+ one_tap: oneTap,
1713
+ customScopes: customScopes,
1714
+ providerParams: providerParams
1715
+ };
1716
+ };
1717
+ var productsToAuthMethods = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, B2BProducts.oauth, undefined), B2BProducts.sso, 'sso'), B2BProducts.emailMagicLinks, 'magic_link'), B2BProducts.emailOtp, 'email_otp'), B2BProducts.passwords, 'password');
1718
+ var oauthProvidersToAuthMethods = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, B2BOAuthProviders.Google, 'google_oauth'), B2BOAuthProviders.Microsoft, 'microsoft_oauth'), B2BOAuthProviders.HubSpot, 'hubspot_oauth'), B2BOAuthProviders.Slack, 'slack_oauth'), B2BOAuthProviders.GitHub, 'github_oauth');
1719
+ var authMethodsToProducts = Object.entries(productsToAuthMethods).reduce(function (acc, _ref43) {
1720
+ var _ref44 = _slicedToArray(_ref43, 2),
1721
+ product = _ref44[0],
1722
+ method = _ref44[1];
1723
+ if (method) {
1724
+ acc[method] = product;
1725
+ }
1726
+ return acc;
1727
+ }, {});
1728
+ var oauthMethodsToOauthProviders = Object.entries(oauthProvidersToAuthMethods).reduce(function (acc, _ref45) {
1729
+ var _ref46 = _slicedToArray(_ref45, 2),
1730
+ provider = _ref46[0],
1731
+ method = _ref46[1];
1732
+ acc[method] = provider;
1733
+ return acc;
1734
+ }, {});
1735
+ var oauthProviderToAuthMethod = function oauthProviderToAuthMethod(provider) {
1736
+ return oauthProvidersToAuthMethods[provider];
1737
+ };
1738
+ var oauthMethodToOauthProvider = function oauthMethodToOauthProvider(authMethod) {
1739
+ return oauthMethodsToOauthProviders[authMethod];
1740
+ };
1741
+ var productToAuthMethod = function productToAuthMethod(product) {
1742
+ return productsToAuthMethods[product];
1743
+ };
1744
+ var authMethodToProduct = function authMethodToProduct(authMethod) {
1745
+ if (authMethod in oauthMethodsToOauthProviders) {
1746
+ return B2BProducts.oauth;
1747
+ }
1748
+ return authMethodsToProducts[authMethod];
1749
+ };
1750
+ var allProducts = Object.keys(productsToAuthMethods);
1751
+ var allOauthProviders = Object.values(B2BOAuthProviders);
1752
+ var flattenConfigToAuthMethods = function flattenConfigToAuthMethods(products, oauthProviders) {
1753
+ return products.reduce(function (acc, product) {
1754
+ if (product === B2BProducts.oauth) {
1755
+ oauthProviders.forEach(function (provider) {
1756
+ var authMethod = oauthProviderToAuthMethod(typeof provider === 'string' ? provider : provider.type);
1757
+ if (authMethod) {
1758
+ acc.push(authMethod);
1759
+ }
1760
+ });
1761
+ } else {
1762
+ var authMethod = productToAuthMethod(product);
1763
+ if (authMethod) {
1764
+ acc.push(authMethod);
1765
+ }
1766
+ }
1767
+ return acc;
1768
+ }, []);
1769
+ };
1770
+ var useOAuthProviderConfigs = function useOAuthProviderConfigs() {
1771
+ var _a;
1772
+ var config = useConfig();
1773
+ return F$1(function () {
1774
+ var _a;
1775
+ if (!((_a = config.oauthOptions) === null || _a === void 0 ? void 0 : _a.providers)) {
1776
+ return [];
1777
+ }
1778
+ return config.oauthOptions.providers.map(getParamsFromB2BOAuthProviderConfig);
1779
+ }, [(_a = config.oauthOptions) === null || _a === void 0 ? void 0 : _a.providers]);
1780
+ };
1781
+ var useRestrictedAuthMethods = function useRestrictedAuthMethods() {
1782
+ var _a, _b;
1783
+ var _useGlobalReducer3 = useGlobalReducer(),
1784
+ _useGlobalReducer4 = _slicedToArray(_useGlobalReducer3, 1),
1785
+ state = _useGlobalReducer4[0];
1786
+ var primaryAuthMethods = state.primary.primaryAuthMethods;
1787
+ var hasPrimaryAuthMethods = !!primaryAuthMethods;
1788
+ var restrictedAuthMethods = F$1(function () {
1789
+ var _a, _b, _c;
1790
+ if (state.primary.primaryAuthMethods) {
1791
+ return new Set(state.primary.primaryAuthMethods);
1792
+ }
1793
+ if (((_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.auth_methods) === 'RESTRICTED') {
1794
+ return new Set((_c = (_b = state.flowState.organization) === null || _b === void 0 ? void 0 : _b.allowed_auth_methods) !== null && _c !== void 0 ? _c : []);
1795
+ }
1796
+ }, [(_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.allowed_auth_methods, (_b = state.flowState.organization) === null || _b === void 0 ? void 0 : _b.auth_methods, state.primary.primaryAuthMethods]);
1797
+ return {
1798
+ restrictedAuthMethods: restrictedAuthMethods,
1799
+ hasPrimaryAuthMethods: hasPrimaryAuthMethods
1800
+ };
1801
+ };
1802
+ var useEffectiveAuthConfig = function useEffectiveAuthConfig() {
1803
+ var _a;
1804
+ var _useGlobalReducer5 = useGlobalReducer(),
1805
+ _useGlobalReducer6 = _slicedToArray(_useGlobalReducer5, 1),
1806
+ state = _useGlobalReducer6[0];
1807
+ var config = useConfig();
1808
+ var _useRestrictedAuthMet = useRestrictedAuthMethods(),
1809
+ restrictedAuthMethods = _useRestrictedAuthMet.restrictedAuthMethods,
1810
+ hasPrimaryAuthMethods = _useRestrictedAuthMet.hasPrimaryAuthMethods;
1811
+ var oauthProviderConfigs = useOAuthProviderConfigs();
1812
+ var flattenedConfiguredAuthMethods = F$1(function () {
1813
+ return flattenConfigToAuthMethods(config.products, oauthProviderConfigs);
1814
+ }, [config.products, oauthProviderConfigs]);
1815
+ var authMethodsToShow = F$1(function () {
1816
+ var _a;
1817
+ if (!restrictedAuthMethods) {
1818
+ return flattenedConfiguredAuthMethods;
1819
+ }
1820
+ var restrictedAuthMethodsInUiConfig = flattenedConfiguredAuthMethods.filter(function (authMethod) {
1821
+ return restrictedAuthMethods.has(authMethod);
1822
+ });
1823
+ if (restrictedAuthMethodsInUiConfig.length > 0 || !hasPrimaryAuthMethods) {
1824
+ return restrictedAuthMethodsInUiConfig;
1825
+ }
1826
+ if (((_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.auth_methods) === 'RESTRICTED') {
1827
+ return flattenConfigToAuthMethods(allProducts, allOauthProviders).filter(function (authMethod) {
1828
+ return restrictedAuthMethods.has(authMethod);
1829
+ });
1830
+ }
1831
+ return ['magic_link'];
1832
+ }, [flattenedConfiguredAuthMethods, hasPrimaryAuthMethods, restrictedAuthMethods, (_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.auth_methods]);
1833
+ var products = F$1(function () {
1834
+ return _toConsumableArray(new Set(authMethodsToShow.map(authMethodToProduct).filter(isTruthy)));
1835
+ }, [authMethodsToShow]);
1836
+ var oauthProviderSettings = F$1(function () {
1837
+ return authMethodsToShow.map(function (authMethod) {
1838
+ var _a;
1839
+ var provider = oauthMethodToOauthProvider(authMethod);
1840
+ if (provider) {
1841
+ return (_a = oauthProviderConfigs.find(function (oauthProvider) {
1842
+ return oauthProvider.type === provider;
1843
+ })) !== null && _a !== void 0 ? _a : getParamsFromB2BOAuthProviderConfig(provider);
1844
+ }
1845
+ }).filter(isTruthy);
1846
+ }, [authMethodsToShow, oauthProviderConfigs]);
1847
+ return {
1848
+ products: products,
1849
+ oauthProviderSettings: oauthProviderSettings
1850
+ };
1851
+ };
1852
+ var DEFAULT_OTP_EXPIRATION_MS = 1000 * 60 * 10;
1853
+ var getOtpCodeExpiration = function getOtpCodeExpiration() {
1854
+ return new Date(Date.now() + DEFAULT_OTP_EXPIRATION_MS);
1855
+ };
1856
+ var mutation = function mutation() {
1857
+ return function (key, fetcher) {
1858
+ var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1859
+ var _useSWRConfig = useSWRConfig(),
1860
+ mutate = _useSWRConfig.mutate;
1861
+ var keyRef = _$1(key);
1862
+ var fetcherRef = _$1(fetcher);
1863
+ var configRef = _$1(config);
1864
+ var ditchMutationsUntilRef = _$1(0);
1865
+ var _useStateWithDeps = useStateWithDeps({
1866
+ data: UNDEFINED,
1867
+ error: UNDEFINED,
1868
+ isMutating: false
1869
+ }),
1870
+ _useStateWithDeps2 = _slicedToArray(_useStateWithDeps, 3),
1871
+ stateRef = _useStateWithDeps2[0],
1872
+ stateDependencies = _useStateWithDeps2[1],
1873
+ setState = _useStateWithDeps2[2];
1874
+ var currentState = stateRef.current;
1875
+ var trigger = T$1( /*#__PURE__*/function () {
1876
+ var _ref47 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(arg, opts) {
1877
+ var _serialize, _serialize2, serializedKey, resolvedKey, options, mutationStartedAt, data;
1878
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1879
+ while (1) switch (_context.prev = _context.next) {
1880
+ case 0:
1881
+ _serialize = serialize(keyRef.current), _serialize2 = _slicedToArray(_serialize, 2), serializedKey = _serialize2[0], resolvedKey = _serialize2[1];
1882
+ if (fetcherRef.current) {
1883
+ _context.next = 3;
1884
+ break;
1885
+ }
1886
+ throw new Error('Can’t trigger the mutation: missing fetcher.');
1887
+ case 3:
1888
+ if (serializedKey) {
1889
+ _context.next = 5;
1890
+ break;
1891
+ }
1892
+ throw new Error('Can’t trigger the mutation: missing key.');
1893
+ case 5:
1894
+ options = mergeObjects(mergeObjects({
1895
+ populateCache: false,
1896
+ throwOnError: true
1897
+ }, configRef.current), opts);
1898
+ mutationStartedAt = getTimestamp();
1899
+ ditchMutationsUntilRef.current = mutationStartedAt;
1900
+ setState({
1901
+ isMutating: true
1902
+ });
1903
+ _context.prev = 9;
1904
+ _context.next = 12;
1905
+ return mutate(serializedKey, fetcherRef.current(resolvedKey, {
1906
+ arg: arg
1907
+ }), mergeObjects(options, {
1908
+ throwOnError: true
1909
+ }));
1910
+ case 12:
1911
+ data = _context.sent;
1912
+ if (ditchMutationsUntilRef.current <= mutationStartedAt) {
1913
+ setState({
1914
+ data: data,
1915
+ isMutating: false,
1916
+ error: undefined
1917
+ });
1918
+ options.onSuccess == null ? void 0 : options.onSuccess(data, serializedKey, options);
1919
+ }
1920
+ return _context.abrupt("return", data);
1921
+ case 17:
1922
+ _context.prev = 17;
1923
+ _context.t0 = _context["catch"](9);
1924
+ if (!(ditchMutationsUntilRef.current <= mutationStartedAt)) {
1925
+ _context.next = 24;
1926
+ break;
1927
+ }
1928
+ setState({
1929
+ error: _context.t0,
1930
+ isMutating: false
1931
+ });
1932
+ options.onError == null ? void 0 : options.onError(_context.t0, serializedKey, options);
1933
+ if (!options.throwOnError) {
1934
+ _context.next = 24;
1935
+ break;
1936
+ }
1937
+ throw _context.t0;
1938
+ case 24:
1939
+ case "end":
1940
+ return _context.stop();
1941
+ }
1942
+ }, _callee, null, [[9, 17]]);
1943
+ }));
1944
+ return function (_x, _x2) {
1945
+ return _ref47.apply(this, arguments);
1946
+ };
1947
+ }(), []);
1948
+ var reset = T$1(function () {
1949
+ ditchMutationsUntilRef.current = getTimestamp();
1950
+ setState({
1951
+ data: UNDEFINED,
1952
+ error: UNDEFINED,
1953
+ isMutating: false
1954
+ });
1955
+ }, []);
1956
+ useIsomorphicLayoutEffect(function () {
1957
+ keyRef.current = key;
1958
+ fetcherRef.current = fetcher;
1959
+ configRef.current = config;
1960
+ });
1961
+ return {
1962
+ trigger: trigger,
1963
+ reset: reset,
1964
+ get data() {
1965
+ stateDependencies.data = true;
1966
+ return currentState.data;
1967
+ },
1968
+ get error() {
1969
+ stateDependencies.error = true;
1970
+ return currentState.error;
1971
+ },
1972
+ get isMutating() {
1973
+ stateDependencies.isMutating = true;
1974
+ return currentState.isMutating;
1975
+ }
1976
+ };
1977
+ };
1978
+ };
1979
+ var index = withMiddleware(useSWR, mutation);
1980
+ var KeyToStytchEventMap = {
1981
+ 'stytch.magicLinks.authenticate': StytchEventType.B2BMagicLinkAuthenticate,
1982
+ 'stytch.sso.authenticate': StytchEventType.B2BSSOAuthenticate,
1983
+ 'stytch.magicLinks.discovery.authenticate': StytchEventType.B2BMagicLinkDiscoveryAuthenticate,
1984
+ 'stytch.discovery.organization.create': StytchEventType.B2BDiscoveryOrganizationsCreate,
1985
+ 'stytch.discovery.intermediateSessions.exchange': StytchEventType.B2BDiscoveryIntermediateSessionExchange,
1986
+ 'stytch.magicLinks.email.loginOrSignup': StytchEventType.B2BMagicLinkEmailLoginOrSignup,
1987
+ 'stytch.magicLinks.discovery.send': StytchEventType.B2BMagicLinkEmailDiscoverySend,
1988
+ 'stytch.oauth.authenticate': StytchEventType.B2BOAuthAuthenticate,
1989
+ 'stytch.oauth.discovery.authenticate': StytchEventType.B2BOAuthDiscoveryAuthenticate,
1990
+ 'stytch.otps.sms.send': StytchEventType.B2BSMSOTPSend,
1991
+ 'stytch.otps.sms.authenticate': StytchEventType.B2BSMSOTPAuthenticate,
1992
+ 'stytch.totp.create': StytchEventType.B2BTOTPCreate,
1993
+ 'stytch.totp.authenticate': StytchEventType.B2BTOTPAuthenticate,
1994
+ 'stytch.recoveryCodes.recover': StytchEventType.B2BRecoveryCodesRecover
1995
+ };
1996
+ var useMutate = function useMutate(key, fetcher, options) {
1997
+ var onEvent = useEventCallback();
1998
+ var _onError = useErrorCallback();
1999
+ return index(key, fetcher, Object.assign(Object.assign({
2000
+ throwOnError: false
2001
+ }, options), {
2002
+ onSuccess: function onSuccess(data, key, config) {
2003
+ if (KeyToStytchEventMap[key]) {
2004
+ onEvent({
2005
+ type: KeyToStytchEventMap[key],
2006
+ data: data
2007
+ });
2008
+ }
2009
+ (options === null || options === void 0 ? void 0 : options.onSuccess) && options.onSuccess(data, key, config);
2010
+ },
2011
+ onError: function onError(error, key, config) {
2012
+ _onError(error);
2013
+ (options === null || options === void 0 ? void 0 : options.onError) && options.onError(error, key, config);
2014
+ }
2015
+ }));
2016
+ };
2017
+ var useExtractSlug = function useExtractSlug() {
2018
+ var _useGlobalReducer7 = useGlobalReducer(),
2019
+ _useGlobalReducer8 = _slicedToArray(_useGlobalReducer7, 2),
2020
+ state = _useGlobalReducer8[0],
2021
+ dispatch = _useGlobalReducer8[1];
2022
+ var _h$3 = h$2(),
2023
+ _h$4 = _slicedToArray(_h$3, 2),
2024
+ pattern = _h$4[0],
2025
+ setPattern = _h$4[1];
2026
+ var stytchClient = useStytch();
2027
+ var slug = extractFromPattern(pattern || null);
2028
+ var _useMutate = useMutate('stytchClient.organization.getBySlug', function (_, _ref48) {
2029
+ var slug = _ref48.arg.slug;
2030
+ return stytchClient.organization.getBySlug({
2031
+ organization_slug: slug
2032
+ });
2033
+ }, {
2034
+ onSuccess: function onSuccess(_ref49) {
2035
+ var organization = _ref49.organization;
1693
2036
  if (organization === null) {
1694
2037
  dispatch({
1695
2038
  type: 'set_error_message_and_transition',
@@ -1706,8 +2049,8 @@ var useExtractSlug = function useExtractSlug() {
1706
2049
  trigger = _useMutate.trigger,
1707
2050
  isSearching = _useMutate.isMutating;
1708
2051
  p$1(function () {
1709
- readB2BInternals(stytchClient).bootstrap.getAsync().then(function (_ref42) {
1710
- var slugPattern = _ref42.slugPattern;
2052
+ readB2BInternals(stytchClient).bootstrap.getAsync().then(function (_ref50) {
2053
+ var slugPattern = _ref50.slugPattern;
1711
2054
  setPattern(slugPattern);
1712
2055
  });
1713
2056
  }, [stytchClient]);
@@ -1744,11 +2087,19 @@ var onAuthenticateSuccess = function onAuthenticateSuccess(data, dispatch, confi
1744
2087
  includedMfaMethods: config.mfaProductInclude
1745
2088
  });
1746
2089
  };
2090
+ var onDiscoveryAuthenticateSuccess = function onDiscoveryAuthenticateSuccess(data, dispatch) {
2091
+ dispatch({
2092
+ type: 'set_discovery_state',
2093
+ email: data.email_address,
2094
+ discoveredOrganizations: data.discovered_organizations,
2095
+ intermediateSessionToken: data.intermediate_session_token
2096
+ });
2097
+ };
1747
2098
  var usePasswordInput = function usePasswordInput() {
1748
- var _useGlobalReducer5 = useGlobalReducer(),
1749
- _useGlobalReducer6 = _slicedToArray(_useGlobalReducer5, 2),
1750
- state = _useGlobalReducer6[0],
1751
- dispatch = _useGlobalReducer6[1];
2099
+ var _useGlobalReducer9 = useGlobalReducer(),
2100
+ _useGlobalReducer10 = _slicedToArray(_useGlobalReducer9, 2),
2101
+ state = _useGlobalReducer10[0],
2102
+ dispatch = _useGlobalReducer10[1];
1752
2103
  var config = useConfig();
1753
2104
  var stytch = useStytch();
1754
2105
  var onEvent = useEventCallback();
@@ -1792,6 +2143,34 @@ var usePasswordInput = function usePasswordInput() {
1792
2143
  setErrorMessage('Invalid email or password. Please try again or use the link below to get help.');
1793
2144
  });
1794
2145
  };
2146
+ var submitDiscoveryPassword = function submitDiscoveryPassword() {
2147
+ setErrorMessage('');
2148
+ setIsSubmitting(true);
2149
+ stytch.passwords.discovery.authenticate({
2150
+ email_address: email,
2151
+ password: password
2152
+ }).then(function (data) {
2153
+ setIsSubmitting(false);
2154
+ onEvent({
2155
+ type: StytchEventType.B2BPasswordDiscoveryAuthenticate,
2156
+ data: data
2157
+ });
2158
+ dispatch({
2159
+ type: 'transition',
2160
+ screen: AppScreens$1.Discovery
2161
+ });
2162
+ dispatch({
2163
+ type: 'set_discovery_state',
2164
+ email: data.email_address,
2165
+ discoveredOrganizations: data.discovered_organizations,
2166
+ intermediateSessionToken: data.intermediate_session_token
2167
+ });
2168
+ })["catch"](function (err) {
2169
+ setIsSubmitting(false);
2170
+ onError(err);
2171
+ setErrorMessage('Invalid email or password. Please try again or use the link below to get help.');
2172
+ });
2173
+ };
1795
2174
  var emailEligibleForJITProvisioning = function emailEligibleForJITProvisioning(organization, email) {
1796
2175
  var emailDomain = email.split('@').pop();
1797
2176
  return organization.email_jit_provisioning == 'NOT_ALLOWED' || organization.email_jit_provisioning == 'RESTRICTED' && emailDomain && organization.email_allowed_domains.includes(emailDomain);
@@ -1844,6 +2223,7 @@ var usePasswordInput = function usePasswordInput() {
1844
2223
  isSubmitting: isSubmitting,
1845
2224
  setIsSubmitting: setIsSubmitting,
1846
2225
  submitPassword: submitPassword,
2226
+ submitDiscoveryPassword: submitDiscoveryPassword,
1847
2227
  handleNonMemberReset: handleNonMemberReset
1848
2228
  };
1849
2229
  };
@@ -1858,192 +2238,138 @@ var extractFromPattern = function extractFromPattern(pattern) {
1858
2238
  }
1859
2239
  return null;
1860
2240
  };
1861
- var Button = He.button(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["\n all: unset;\n width: 100%;\n height: 45px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 18px;\n text-transform: none;\n font-family: ", ";\n box-shadow: none;\n text-align: center;\n\n ", "\n\n &:disabled {\n background-color: ", ";\n color: ", ";\n border: ", ";\n border-radius: ", ";\n cursor: not-allowed;\n }\n"])), function (props) {
1862
- return props.theme.typography.fontFamily;
1863
- }, function (props) {
1864
- switch (props.variant) {
1865
- case 'primary':
1866
- return "\n border: ".concat(props.theme.buttons.primary.border, ";\n border-radius: ").concat(props.theme.buttons.primary.borderRadius, ";\n color: ").concat(props.theme.buttons.primary.textColor, ";\n background-color: ").concat(props.theme.buttons.primary.backgroundColor, ";\n ");
1867
- case 'outlined':
1868
- return "\n border: ".concat(props.theme.buttons.secondary.border, ";\n border-radius: ").concat(props.theme.buttons.secondary.borderRadius, ";\n color: ").concat(props.theme.buttons.secondary.textColor, ";\n background-color: ").concat(props.theme.buttons.secondary.backgroundColor, ";\n ");
1869
- case 'text':
1870
- return "\n color: ".concat(props.theme.colors.primary, ";\n background-color: transparent;\n font-weight: 600;\n ");
1871
- }
1872
- }, function (props) {
1873
- return props.theme.buttons.disabled.backgroundColor;
1874
- }, function (props) {
1875
- return props.theme.buttons.disabled.textColor;
1876
- }, function (props) {
1877
- return props.theme.buttons.disabled.border;
1878
- }, function (props) {
1879
- return props.theme.buttons.disabled.borderRadius;
1880
- });
1881
- Button.defaultProps = {
1882
- variant: 'primary'
1883
- };
1884
- var circularRotateKeyframe = Ue(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n"])));
1885
- var circularDashKeyframe = Ue(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["\n 0% {\n stroke-dasharray: 1px, 200px;\n stroke-dashoffset: 0;\n }\n 50% {\n stroke-dasharray: 100px, 200px;\n stroke-dashoffset: -15px;\n }\n 100% {\n stroke-dasharray: 100px, 200px;\n stroke-dashoffset: -125px;\n }\n"])));
1886
- var AnimatedCircle = He.circle(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["\n stroke-dasharray: 80px, 200px;\n stroke-dashoffset: 0;\n animation: ", " 1.4s ease-in-out infinite;\n stroke: ", ";\n fill: none;\n"])), circularDashKeyframe, function (props) {
1887
- return props.theme.colors.primary;
1888
- });
1889
- var CircularProgressRoot = He.div(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["\n width: ", "px;\n height: ", "px;\n animation: ", " 1.4s ease-in-out infinite;\n"])), function (props) {
1890
- return props.size;
1891
- }, function (props) {
1892
- return props.size;
1893
- }, circularRotateKeyframe);
1894
- var CircularProgressSVG = He.svg(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["\n display: block;\n"])));
1895
- var CircularProgress = function CircularProgress(_ref43) {
1896
- var size = _ref43.size,
1897
- thickness = _ref43.thickness;
1898
- return /*#__PURE__*/wn.createElement(CircularProgressRoot, {
1899
- size: size
1900
- }, /*#__PURE__*/wn.createElement(CircularProgressSVG, {
1901
- viewBox: "".concat(size / 2, " ").concat(size / 2, " ").concat(size, " ").concat(size)
1902
- }, /*#__PURE__*/wn.createElement(AnimatedCircle, {
1903
- cx: size,
1904
- cy: size,
1905
- r: (size - thickness) / 2,
1906
- fill: "none",
1907
- strokeWidth: thickness
1908
- })));
1909
- };
1910
- var SubmitButton = function SubmitButton(props) {
1911
- var buttonDisabled = props.isSubmitting || props.disabled;
1912
- return /*#__PURE__*/wn.createElement(Button, {
1913
- id: 'submit',
1914
- type: "submit",
1915
- disabled: buttonDisabled,
1916
- variant: props.variant
1917
- }, props.isSubmitting ? ( /*#__PURE__*/wn.createElement(Flex, {
1918
- justifyContent: "center"
1919
- }, /*#__PURE__*/wn.createElement(CircularProgress, {
1920
- size: 18,
1921
- thickness: 1,
1922
- "data-testid": "loading-icon"
1923
- }))) : props.text);
1924
- };
1925
- var Input = He.input(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["\n background-color: ", ";\n height: 47px;\n padding: 0 8px;\n box-sizing: border-box;\n border: 1px solid ", ";\n border-radius: ", ";\n color: ", ";\n font-family: ", ";\n font-size: 18px;\n &::placeholder {\n color: ", ";\n }\n\n &:disabled {\n border: 1px solid ", ";\n color: ", ";\n background-color: ", ";\n }\n"])), function (props) {
1926
- return props.theme.inputs.backgroundColor;
1927
- }, function (props) {
1928
- return props.theme.inputs.borderColor;
1929
- }, function (props) {
1930
- return props.theme.inputs.borderRadius;
1931
- }, function (props) {
1932
- return props.theme.inputs.textColor;
1933
- }, function (props) {
1934
- return props.theme.typography.fontFamily;
1935
- }, function (props) {
1936
- return props.theme.inputs.placeholderColor;
1937
- }, function (props) {
1938
- return props.theme.colors.disabledText;
1939
- }, function (props) {
1940
- return props.theme.colors.disabledText;
1941
- }, function (props) {
1942
- return props.theme.colors.disabled;
1943
- });
1944
- var EmailInput = function EmailInput(_ref44) {
1945
- var email = _ref44.email,
1946
- setEmail = _ref44.setEmail,
1947
- _ref44$disableInput = _ref44.disableInput,
1948
- disableInput = _ref44$disableInput === void 0 ? false : _ref44$disableInput,
1949
- _ref44$hasPasskeys = _ref44.hasPasskeys,
1950
- hasPasskeys = _ref44$hasPasskeys === void 0 ? false : _ref44$hasPasskeys;
1951
- return /*#__PURE__*/wn.createElement(Input, Object.assign({
1952
- placeholder: "example@email.com",
1953
- name: "email",
1954
- type: "email",
1955
- autoComplete: hasPasskeys ? 'email webauthn' : 'email',
1956
- disabled: disableInput,
1957
- id: "email-input",
1958
- value: email,
1959
- onChange: function onChange(e) {
1960
- return setEmail(e.target.value);
1961
- },
1962
- required: true
1963
- }, hasPasskeys ? passwordManagerDisableAutofillProps : {}));
1964
- };
1965
- var DASHBOARD_REGEX = /https:\/\/stytch\.com\/[#a-zA-Z0-9/-]+/g;
1966
- var mapURLsToLinks = function mapURLsToLinks(str) {
1967
- var nonLinkChunks = str.split(DASHBOARD_REGEX);
1968
- var linkChunks = Array.from(str.matchAll(DASHBOARD_REGEX)).map(function (el) {
1969
- return el[0];
2241
+ var useEmailOtpDiscoverySend = function useEmailOtpDiscoverySend() {
2242
+ var _useGlobalReducer11 = useGlobalReducer(),
2243
+ _useGlobalReducer12 = _slicedToArray(_useGlobalReducer11, 2),
2244
+ dispatch = _useGlobalReducer12[1];
2245
+ var stytchClient = useStytch();
2246
+ var config = useConfig();
2247
+ return useMutate('stytch.otps.email.discovery.send', function (_key, _ref51) {
2248
+ var email = _ref51.arg.email;
2249
+ var _a;
2250
+ return stytchClient.otps.email.discovery.send({
2251
+ email_address: email,
2252
+ login_template_id: (_a = config.emailOtpOptions) === null || _a === void 0 ? void 0 : _a.loginTemplateId
2253
+ });
2254
+ }, {
2255
+ onSuccess: function onSuccess() {
2256
+ dispatch({
2257
+ type: 'send_email_otp',
2258
+ codeExpiration: getOtpCodeExpiration()
2259
+ });
2260
+ }
1970
2261
  });
1971
- var chunkResults = [];
1972
- while (nonLinkChunks.length || linkChunks.length) {
1973
- if (nonLinkChunks.length) {
1974
- chunkResults.push(nonLinkChunks.shift());
2262
+ };
2263
+ var useEmailOtpLoginOrSignup = function useEmailOtpLoginOrSignup() {
2264
+ var _useGlobalReducer13 = useGlobalReducer(),
2265
+ _useGlobalReducer14 = _slicedToArray(_useGlobalReducer13, 2),
2266
+ dispatch = _useGlobalReducer14[1];
2267
+ var stytchClient = useStytch();
2268
+ var config = useConfig();
2269
+ return useMutate('stytch.otps.email.loginOrSignup', function (_key, _ref52) {
2270
+ var _ref52$arg = _ref52.arg,
2271
+ email = _ref52$arg.email,
2272
+ organization_id = _ref52$arg.organization_id;
2273
+ var _a, _b;
2274
+ return stytchClient.otps.email.loginOrSignup({
2275
+ email_address: email,
2276
+ organization_id: organization_id,
2277
+ login_template_id: (_a = config.emailOtpOptions) === null || _a === void 0 ? void 0 : _a.loginTemplateId,
2278
+ signup_template_id: (_b = config.emailOtpOptions) === null || _b === void 0 ? void 0 : _b.signupTemplateId
2279
+ });
2280
+ }, {
2281
+ onSuccess: function onSuccess() {
2282
+ dispatch({
2283
+ type: 'send_email_otp',
2284
+ codeExpiration: getOtpCodeExpiration()
2285
+ });
1975
2286
  }
1976
- if (linkChunks.length) {
1977
- var chunk = linkChunks.shift();
1978
- chunkResults.push( /*#__PURE__*/wn.createElement("a", {
1979
- key: chunk + '__' + String(linkChunks.length),
1980
- href: chunk,
1981
- target: "_blank",
1982
- rel: "noreferrer"
1983
- }, chunk));
2287
+ });
2288
+ };
2289
+ var useEmlDiscoverySend = function useEmlDiscoverySend() {
2290
+ var _useGlobalReducer15 = useGlobalReducer(),
2291
+ _useGlobalReducer16 = _slicedToArray(_useGlobalReducer15, 2),
2292
+ dispatch = _useGlobalReducer16[1];
2293
+ var stytchClient = useStytch();
2294
+ var config = useConfig();
2295
+ return useMutate('stytch.magicLinks.discovery.send', function (_, _ref53) {
2296
+ var email = _ref53.arg.email;
2297
+ var _a, _b;
2298
+ return stytchClient.magicLinks.email.discovery.send({
2299
+ email_address: email,
2300
+ discovery_redirect_url: (_a = config.emailMagicLinksOptions) === null || _a === void 0 ? void 0 : _a.discoveryRedirectURL,
2301
+ login_template_id: (_b = config.emailMagicLinksOptions) === null || _b === void 0 ? void 0 : _b.loginTemplateId
2302
+ });
2303
+ }, {
2304
+ onSuccess: function onSuccess() {
2305
+ dispatch({
2306
+ type: 'transition',
2307
+ screen: AppScreens$1.EmailConfirmation
2308
+ });
1984
2309
  }
1985
- }
1986
- return chunkResults;
2310
+ });
1987
2311
  };
1988
- var ErrorText = function ErrorText(_ref45) {
1989
- var errorMessage = _ref45.errorMessage;
1990
- var tokens = F$1(function () {
1991
- return mapURLsToLinks(errorMessage);
1992
- }, [errorMessage]);
1993
- return /*#__PURE__*/wn.createElement(Text, {
1994
- size: "helper",
1995
- color: "error"
1996
- }, tokens);
2312
+ var useEmlLoginOrSignup = function useEmlLoginOrSignup() {
2313
+ var _useGlobalReducer17 = useGlobalReducer(),
2314
+ _useGlobalReducer18 = _slicedToArray(_useGlobalReducer17, 2),
2315
+ dispatch = _useGlobalReducer18[1];
2316
+ var stytchClient = useStytch();
2317
+ var config = useConfig();
2318
+ return useMutate('stytch.magicLinks.email.loginOrSignup', function (_, _ref54) {
2319
+ var _ref54$arg = _ref54.arg,
2320
+ email = _ref54$arg.email,
2321
+ organization_id = _ref54$arg.organization_id;
2322
+ var _a, _b, _c, _d;
2323
+ return stytchClient.magicLinks.email.loginOrSignup({
2324
+ email_address: email,
2325
+ organization_id: organization_id,
2326
+ login_redirect_url: (_a = config.emailMagicLinksOptions) === null || _a === void 0 ? void 0 : _a.loginRedirectURL,
2327
+ signup_redirect_url: (_b = config.emailMagicLinksOptions) === null || _b === void 0 ? void 0 : _b.signupRedirectURL,
2328
+ login_template_id: (_c = config.emailMagicLinksOptions) === null || _c === void 0 ? void 0 : _c.loginTemplateId,
2329
+ signup_template_id: (_d = config.emailMagicLinksOptions) === null || _d === void 0 ? void 0 : _d.signupTemplateId
2330
+ });
2331
+ }, {
2332
+ onSuccess: function onSuccess() {
2333
+ dispatch({
2334
+ type: 'transition',
2335
+ screen: AppScreens$1.EmailConfirmation
2336
+ });
2337
+ }
2338
+ });
1997
2339
  };
1998
2340
  var JIT_PROVISIONING_ERRORS = ['email_jit_provisioning_not_allowed', 'invalid_email_for_jit_provisioning'];
1999
- var parseErrorMessage = function parseErrorMessage(error, _ref46) {
2000
- var email = _ref46.email,
2001
- org = _ref46.org;
2341
+ var parseErrorMessage = function parseErrorMessage(error, _ref55) {
2342
+ var email = _ref55.email,
2343
+ org = _ref55.org;
2002
2344
  if (JIT_PROVISIONING_ERRORS.includes(error.error_type)) {
2003
2345
  return "".concat(email, " does not have access to ").concat(org, ". If you think this is a mistake, contact your admin");
2004
2346
  } else {
2005
2347
  return error.error_message;
2006
2348
  }
2007
2349
  };
2008
- var MagicLinkEmailForm = function MagicLinkEmailForm() {
2009
- var _useGlobalReducer7 = useGlobalReducer(),
2010
- _useGlobalReducer8 = _slicedToArray(_useGlobalReducer7, 2),
2011
- state = _useGlobalReducer8[0],
2012
- dispatch = _useGlobalReducer8[1];
2013
- var stytchClient = useStytch();
2014
- var config = useConfig();
2350
+ var EmailForm = function EmailForm() {
2351
+ var _useGlobalReducer19 = useGlobalReducer(),
2352
+ _useGlobalReducer20 = _slicedToArray(_useGlobalReducer19, 2),
2353
+ state = _useGlobalReducer20[0],
2354
+ dispatch = _useGlobalReducer20[1];
2015
2355
  var _h$15 = h$2(''),
2016
2356
  _h$16 = _slicedToArray(_h$15, 2),
2017
2357
  emailInput = _h$16[0],
2018
2358
  setEmailInput = _h$16[1];
2359
+ var _useEffectiveAuthConf = useEffectiveAuthConfig(),
2360
+ products = _useEffectiveAuthConf.products;
2361
+ var enableEml = products.includes(B2BProducts.emailMagicLinks);
2362
+ var enableOtp = products.includes(B2BProducts.emailOtp);
2019
2363
  var providedEmail = state.primary.email;
2020
2364
  var email = providedEmail || emailInput;
2021
- var _useMutate2 = useMutate('stytch.magicLinks.email.loginOrSignup', function (_, _ref47) {
2022
- var organization_id = _ref47.arg.organization_id;
2023
- var _a, _b, _c, _d;
2024
- return stytchClient.magicLinks.email.loginOrSignup({
2025
- email_address: email,
2026
- organization_id: organization_id,
2027
- login_redirect_url: (_a = config.emailMagicLinksOptions) === null || _a === void 0 ? void 0 : _a.loginRedirectURL,
2028
- signup_redirect_url: (_b = config.emailMagicLinksOptions) === null || _b === void 0 ? void 0 : _b.signupRedirectURL,
2029
- login_template_id: (_c = config.emailMagicLinksOptions) === null || _c === void 0 ? void 0 : _c.loginTemplateId,
2030
- signup_template_id: (_d = config.emailMagicLinksOptions) === null || _d === void 0 ? void 0 : _d.signupTemplateId
2031
- });
2032
- }, {
2033
- onSuccess: function onSuccess() {
2034
- dispatch({
2035
- type: 'set_magic_link_email',
2036
- email: email
2037
- });
2038
- dispatch({
2039
- type: 'transition',
2040
- screen: AppScreens$1.EmailConfirmation
2041
- });
2042
- }
2043
- }),
2044
- stytchLoginOrSignup = _useMutate2.trigger,
2045
- error = _useMutate2.error,
2046
- isMutating = _useMutate2.isMutating;
2365
+ var _useEmlLoginOrSignup = useEmlLoginOrSignup(),
2366
+ stytchEmlLoginOrSignup = _useEmlLoginOrSignup.trigger,
2367
+ emlError = _useEmlLoginOrSignup.error,
2368
+ emlIsMutating = _useEmlLoginOrSignup.isMutating;
2369
+ var _useEmailOtpLoginOrSi = useEmailOtpLoginOrSignup(),
2370
+ stytchOtpLoginOrSignup = _useEmailOtpLoginOrSi.trigger,
2371
+ otpError = _useEmailOtpLoginOrSi.error,
2372
+ otpIsMutating = _useEmailOtpLoginOrSi.isMutating;
2047
2373
  var organization = state.flowState.organization;
2048
2374
  if (!organization) return /*#__PURE__*/wn.createElement(wn.Fragment, null);
2049
2375
  var handleSubmit = function handleSubmit(e) {
@@ -2052,23 +2378,92 @@ var MagicLinkEmailForm = function MagicLinkEmailForm() {
2052
2378
  while (1) switch (_context2.prev = _context2.next) {
2053
2379
  case 0:
2054
2380
  e.preventDefault();
2055
- stytchLoginOrSignup({
2056
- organization_id: organization.organization_id
2381
+ dispatch({
2382
+ type: 'set_user_supplied_email',
2383
+ email: email
2057
2384
  });
2058
- case 2:
2385
+ if (enableEml && enableOtp) {
2386
+ dispatch({
2387
+ type: 'transition',
2388
+ screen: AppScreens$1.EmailMethodSelection,
2389
+ history: 'push'
2390
+ });
2391
+ } else if (enableEml) {
2392
+ stytchEmlLoginOrSignup({
2393
+ email: email,
2394
+ organization_id: organization.organization_id
2395
+ });
2396
+ } else if (enableOtp) {
2397
+ stytchOtpLoginOrSignup({
2398
+ email: email,
2399
+ organization_id: organization.organization_id
2400
+ });
2401
+ }
2402
+ case 3:
2059
2403
  case "end":
2060
2404
  return _context2.stop();
2061
2405
  }
2062
2406
  }, _callee2);
2063
2407
  }));
2064
2408
  };
2409
+ var isMutating = emlIsMutating || otpIsMutating;
2410
+ var error = emlError || otpError;
2411
+ var errorText = error && ( /*#__PURE__*/wn.createElement(ErrorText, {
2412
+ errorMessage: parseErrorMessage(error, {
2413
+ email: email,
2414
+ org: organization.organization_name
2415
+ })
2416
+ }));
2417
+ if (providedEmail) {
2418
+ return /*#__PURE__*/wn.createElement(Flex, {
2419
+ direction: "column",
2420
+ gap: 8
2421
+ }, products.filter(function (product) {
2422
+ return product === B2BProducts.emailMagicLinks || product === B2BProducts.emailOtp;
2423
+ }).map(function (product) {
2424
+ switch (product) {
2425
+ case B2BProducts.emailMagicLinks:
2426
+ return /*#__PURE__*/wn.createElement(LoadingButton, {
2427
+ key: product,
2428
+ type: "button",
2429
+ onClick: function onClick() {
2430
+ dispatch({
2431
+ type: 'set_user_supplied_email',
2432
+ email: email
2433
+ });
2434
+ stytchEmlLoginOrSignup({
2435
+ email: email,
2436
+ organization_id: organization.organization_id
2437
+ });
2438
+ },
2439
+ isLoading: emlIsMutating,
2440
+ disabled: isMutating,
2441
+ variant: "text"
2442
+ }, "Email me a link");
2443
+ case B2BProducts.emailOtp:
2444
+ return /*#__PURE__*/wn.createElement(LoadingButton, {
2445
+ key: product,
2446
+ type: "button",
2447
+ onClick: function onClick() {
2448
+ dispatch({
2449
+ type: 'set_user_supplied_email',
2450
+ email: email
2451
+ });
2452
+ stytchOtpLoginOrSignup({
2453
+ email: email,
2454
+ organization_id: organization.organization_id
2455
+ });
2456
+ },
2457
+ isLoading: otpIsMutating,
2458
+ disabled: isMutating,
2459
+ variant: "text"
2460
+ }, "Email me a code");
2461
+ }
2462
+ }));
2463
+ }
2065
2464
  return /*#__PURE__*/wn.createElement("form", {
2066
2465
  onSubmit: handleSubmit
2067
- }, providedEmail ? ( /*#__PURE__*/wn.createElement(SubmitButton, {
2068
- isSubmitting: isMutating,
2069
- text: 'Email me a link',
2070
- variant: "text"
2071
- })) : ( /*#__PURE__*/wn.createElement(Flex, {
2466
+ }, /*#__PURE__*/wn.createElement(Flex, {
2072
2467
  direction: "column",
2073
2468
  gap: 8
2074
2469
  }, /*#__PURE__*/wn.createElement(Flex, {
@@ -2077,62 +2472,65 @@ var MagicLinkEmailForm = function MagicLinkEmailForm() {
2077
2472
  }, /*#__PURE__*/wn.createElement(EmailInput, {
2078
2473
  email: email,
2079
2474
  setEmail: setEmailInput
2080
- }), error && ( /*#__PURE__*/wn.createElement(ErrorText, {
2081
- errorMessage: parseErrorMessage(error, {
2082
- email: email,
2083
- org: organization.organization_name
2084
- })
2085
- }))), /*#__PURE__*/wn.createElement(SubmitButton, {
2475
+ }), errorText), /*#__PURE__*/wn.createElement(SubmitButton, {
2086
2476
  isSubmitting: isMutating,
2087
2477
  text: 'Continue with email'
2088
- }))));
2478
+ })));
2089
2479
  };
2090
- var MagicLinkEmailDiscoveryForm = function MagicLinkEmailDiscoveryForm() {
2091
- var _useGlobalReducer9 = useGlobalReducer(),
2092
- _useGlobalReducer10 = _slicedToArray(_useGlobalReducer9, 2),
2093
- dispatch = _useGlobalReducer10[1];
2094
- var stytchClient = useStytch();
2095
- var config = useConfig();
2480
+ var EmailDiscoveryForm = function EmailDiscoveryForm() {
2481
+ var _useGlobalReducer21 = useGlobalReducer(),
2482
+ _useGlobalReducer22 = _slicedToArray(_useGlobalReducer21, 2),
2483
+ dispatch = _useGlobalReducer22[1];
2096
2484
  var _h$17 = h$2(''),
2097
2485
  _h$18 = _slicedToArray(_h$17, 2),
2098
2486
  email = _h$18[0],
2099
2487
  setEmail = _h$18[1];
2100
- var _useMutate3 = useMutate('stytch.magicLinks.discovery.send', function () {
2101
- var _a, _b;
2102
- return stytchClient.magicLinks.email.discovery.send({
2103
- email_address: email,
2104
- discovery_redirect_url: (_a = config.emailMagicLinksOptions) === null || _a === void 0 ? void 0 : _a.discoveryRedirectURL,
2105
- login_template_id: (_b = config.emailMagicLinksOptions) === null || _b === void 0 ? void 0 : _b.loginTemplateId
2106
- });
2107
- }, {
2108
- onSuccess: function onSuccess() {
2109
- dispatch({
2110
- type: 'set_magic_link_email',
2111
- email: email
2112
- });
2113
- dispatch({
2114
- type: 'transition',
2115
- screen: AppScreens$1.EmailConfirmation
2116
- });
2117
- }
2118
- }),
2119
- stytchDiscoverySend = _useMutate3.trigger,
2120
- error = _useMutate3.error,
2121
- isMutating = _useMutate3.isMutating;
2488
+ var _useEffectiveAuthConf2 = useEffectiveAuthConfig(),
2489
+ products = _useEffectiveAuthConf2.products;
2490
+ var enableEml = products.includes(B2BProducts.emailMagicLinks);
2491
+ var enableOtp = products.includes(B2BProducts.emailOtp);
2492
+ var _useEmlDiscoverySend = useEmlDiscoverySend(),
2493
+ stytchEmlDiscoverySend = _useEmlDiscoverySend.trigger,
2494
+ emlError = _useEmlDiscoverySend.error,
2495
+ emlIsMutating = _useEmlDiscoverySend.isMutating;
2496
+ var _useEmailOtpDiscovery = useEmailOtpDiscoverySend(),
2497
+ stytchOtpDiscoverySend = _useEmailOtpDiscovery.trigger,
2498
+ otpError = _useEmailOtpDiscovery.error,
2499
+ otpIsMutating = _useEmailOtpDiscovery.isMutating;
2122
2500
  var handleSubmit = function handleSubmit(e) {
2123
2501
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
2124
2502
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
2125
2503
  while (1) switch (_context3.prev = _context3.next) {
2126
2504
  case 0:
2127
2505
  e.preventDefault();
2128
- stytchDiscoverySend();
2129
- case 2:
2506
+ dispatch({
2507
+ type: 'set_user_supplied_email',
2508
+ email: email
2509
+ });
2510
+ if (enableEml && enableOtp) {
2511
+ dispatch({
2512
+ type: 'transition',
2513
+ screen: AppScreens$1.EmailMethodSelection,
2514
+ history: 'push'
2515
+ });
2516
+ } else if (enableEml) {
2517
+ stytchEmlDiscoverySend({
2518
+ email: email
2519
+ });
2520
+ } else if (enableOtp) {
2521
+ stytchOtpDiscoverySend({
2522
+ email: email
2523
+ });
2524
+ }
2525
+ case 3:
2130
2526
  case "end":
2131
2527
  return _context3.stop();
2132
2528
  }
2133
2529
  }, _callee3);
2134
2530
  }));
2135
2531
  };
2532
+ var isMutating = emlIsMutating || otpIsMutating;
2533
+ var error = emlError || otpError;
2136
2534
  return /*#__PURE__*/wn.createElement("form", {
2137
2535
  onSubmit: handleSubmit
2138
2536
  }, /*#__PURE__*/wn.createElement(Flex, {
@@ -2151,9 +2549,9 @@ var MagicLinkEmailDiscoveryForm = function MagicLinkEmailDiscoveryForm() {
2151
2549
  text: 'Continue with email'
2152
2550
  })));
2153
2551
  };
2154
- var SSOButton = function SSOButton(_ref48) {
2155
- var display_name = _ref48.display_name,
2156
- connection_id = _ref48.connection_id;
2552
+ var SSOButton = function SSOButton(_ref56) {
2553
+ var display_name = _ref56.display_name,
2554
+ connection_id = _ref56.connection_id;
2157
2555
  var stytchClient = useStytch();
2158
2556
  var config = useConfig();
2159
2557
  var onButtonClick = function onButtonClick() {
@@ -2180,9 +2578,9 @@ var SSOButton = function SSOButton(_ref48) {
2180
2578
  }, "Continue with ".concat(display_name))));
2181
2579
  };
2182
2580
  var SSOButtons = function SSOButtons() {
2183
- var _useGlobalReducer11 = useGlobalReducer(),
2184
- _useGlobalReducer12 = _slicedToArray(_useGlobalReducer11, 1),
2185
- state = _useGlobalReducer12[0];
2581
+ var _useGlobalReducer23 = useGlobalReducer(),
2582
+ _useGlobalReducer24 = _slicedToArray(_useGlobalReducer23, 1),
2583
+ state = _useGlobalReducer24[0];
2186
2584
  if (!state.flowState.organization) return /*#__PURE__*/y(g$1, null);
2187
2585
  return /*#__PURE__*/y(Flex, {
2188
2586
  direction: "column",
@@ -2218,9 +2616,9 @@ var Divider = function Divider() {
2218
2616
  "$placement": "right"
2219
2617
  }));
2220
2618
  };
2221
- var PasswordIconSvg = function PasswordIconSvg(_ref49) {
2222
- var _ref49$enabled = _ref49.enabled,
2223
- enabled = _ref49$enabled === void 0 ? false : _ref49$enabled;
2619
+ var PasswordIconSvg = function PasswordIconSvg(_ref57) {
2620
+ var _ref57$enabled = _ref57.enabled,
2621
+ enabled = _ref57$enabled === void 0 ? false : _ref57$enabled;
2224
2622
  return /*#__PURE__*/wn.createElement("svg", {
2225
2623
  width: "20",
2226
2624
  height: "14",
@@ -2269,10 +2667,10 @@ var InputContainer = He(Flex)(_templateObject31 || (_templateObject31 = _taggedT
2269
2667
  return props.theme.inputs.placeholderColor;
2270
2668
  });
2271
2669
  var PasswordIconButton = He.button(_templateObject32 || (_templateObject32 = _taggedTemplateLiteral(["\n all: unset;\n cursor: pointer;\n"])));
2272
- var PasswordIcon = function PasswordIcon(_ref50) {
2273
- var onClick = _ref50.onClick,
2274
- enabled = _ref50.enabled,
2275
- visible = _ref50.visible;
2670
+ var PasswordIcon = function PasswordIcon(_ref58) {
2671
+ var onClick = _ref58.onClick,
2672
+ enabled = _ref58.enabled,
2673
+ visible = _ref58.visible;
2276
2674
  return /*#__PURE__*/wn.createElement(PasswordIconButton, {
2277
2675
  onClick: onClick,
2278
2676
  type: "button"
@@ -2280,10 +2678,10 @@ var PasswordIcon = function PasswordIcon(_ref50) {
2280
2678
  enabled: enabled
2281
2679
  }));
2282
2680
  };
2283
- var PasswordInput = function PasswordInput(_ref51) {
2284
- var password = _ref51.password,
2285
- setPassword = _ref51.setPassword,
2286
- type = _ref51.type;
2681
+ var PasswordInput = function PasswordInput(_ref59) {
2682
+ var password = _ref59.password,
2683
+ setPassword = _ref59.setPassword,
2684
+ type = _ref59.type;
2287
2685
  var _h$19 = h$2(false),
2288
2686
  _h$20 = _slicedToArray(_h$19, 2),
2289
2687
  visible = _h$20[0],
@@ -2313,8 +2711,8 @@ var PasswordInput = function PasswordInput(_ref51) {
2313
2711
  }));
2314
2712
  };
2315
2713
  var BackButton = He.button(_templateObject33 || (_templateObject33 = _taggedTemplateLiteral(["\n all: unset;\n cursor: pointer;\n"])));
2316
- var BackArrowSvg = function BackArrowSvg(_ref52) {
2317
- var color = _ref52.color;
2714
+ var BackArrowSvg = function BackArrowSvg(_ref60) {
2715
+ var color = _ref60.color;
2318
2716
  return /*#__PURE__*/wn.createElement("svg", {
2319
2717
  width: "24",
2320
2718
  height: "24",
@@ -2326,8 +2724,8 @@ var BackArrowSvg = function BackArrowSvg(_ref52) {
2326
2724
  fill: color
2327
2725
  }));
2328
2726
  };
2329
- var BackArrow = function BackArrow(_ref53) {
2330
- var onClick = _ref53.onClick;
2727
+ var BackArrow = function BackArrow(_ref61) {
2728
+ var onClick = _ref61.onClick;
2331
2729
  var theme = Ze();
2332
2730
  return /*#__PURE__*/wn.createElement(BackButton, {
2333
2731
  type: "button",
@@ -2339,9 +2737,9 @@ var BackArrow = function BackArrow(_ref53) {
2339
2737
  };
2340
2738
  var GetHelpText = He(Text)(_templateObject34 || (_templateObject34 = _taggedTemplateLiteral(["\n font-weight: bold !important;\n cursor: pointer;\n"])));
2341
2739
  var PasswordsAuthenticate = function PasswordsAuthenticate() {
2342
- var _useGlobalReducer13 = useGlobalReducer(),
2343
- _useGlobalReducer14 = _slicedToArray(_useGlobalReducer13, 2),
2344
- dispatch = _useGlobalReducer14[1];
2740
+ var _useGlobalReducer25 = useGlobalReducer(),
2741
+ _useGlobalReducer26 = _slicedToArray(_useGlobalReducer25, 2),
2742
+ dispatch = _useGlobalReducer26[1];
2345
2743
  var config = useConfig();
2346
2744
  var passwordOptions = config.passwordOptions;
2347
2745
  var _usePasswordInput = usePasswordInput(),
@@ -2353,27 +2751,25 @@ var PasswordsAuthenticate = function PasswordsAuthenticate() {
2353
2751
  errorMessage = _usePasswordInput.errorMessage,
2354
2752
  setErrorMessage = _usePasswordInput.setErrorMessage,
2355
2753
  isSubmitting = _usePasswordInput.isSubmitting,
2356
- submitPassword = _usePasswordInput.submitPassword;
2754
+ submitPassword = _usePasswordInput.submitPassword,
2755
+ submitDiscoveryPassword = _usePasswordInput.submitDiscoveryPassword;
2357
2756
  if (!passwordOptions) return /*#__PURE__*/wn.createElement(wn.Fragment, null);
2358
- if (!organization) return /*#__PURE__*/wn.createElement(wn.Fragment, null);
2359
2757
  var handleSubmit = function handleSubmit(e) {
2360
2758
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
2361
2759
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
2362
2760
  while (1) switch (_context4.prev = _context4.next) {
2363
2761
  case 0:
2364
2762
  e.preventDefault();
2365
- if (organization) {
2366
- _context4.next = 3;
2367
- break;
2368
- }
2369
- return _context4.abrupt("return");
2370
- case 3:
2371
2763
  if (!email.match(EMAIL_REGEX)) {
2372
2764
  setErrorMessage('Invalid email address');
2373
2765
  } else {
2374
- submitPassword(organization.organization_id);
2766
+ if (!organization) {
2767
+ submitDiscoveryPassword();
2768
+ } else {
2769
+ submitPassword(organization.organization_id);
2770
+ }
2375
2771
  }
2376
- case 4:
2772
+ case 2:
2377
2773
  case "end":
2378
2774
  return _context4.stop();
2379
2775
  }
@@ -2431,19 +2827,24 @@ var PasswordsAuthenticate = function PasswordsAuthenticate() {
2431
2827
  })), /*#__PURE__*/wn.createElement(SubmitButton, {
2432
2828
  isSubmitting: isSubmitting,
2433
2829
  text: "Continue"
2434
- }), /*#__PURE__*/wn.createElement(Flex, {
2830
+ }), organization != null ? ( /*#__PURE__*/wn.createElement(Flex, {
2435
2831
  onClick: onGetHelp,
2436
2832
  direction: "row"
2437
2833
  }, /*#__PURE__*/wn.createElement(Text, {
2438
2834
  color: "secondary"
2439
2835
  }, "Having trouble signing in?"), "\xA0", /*#__PURE__*/wn.createElement(GetHelpText, {
2440
2836
  color: "secondary"
2441
- }, "Get help")))));
2837
+ }, "Get help"))) : ( /*#__PURE__*/wn.createElement(Flex, {
2838
+ onClick: onGetHelp,
2839
+ justifyContent: "center"
2840
+ }, /*#__PURE__*/wn.createElement(GetHelpText, {
2841
+ color: "secondary"
2842
+ }, "Sign up or reset password"))))));
2442
2843
  };
2443
2844
  var PasswordsEmailForm = function PasswordsEmailForm() {
2444
- var _useGlobalReducer15 = useGlobalReducer(),
2445
- _useGlobalReducer16 = _slicedToArray(_useGlobalReducer15, 2),
2446
- dispatch = _useGlobalReducer16[1];
2845
+ var _useGlobalReducer27 = useGlobalReducer(),
2846
+ _useGlobalReducer28 = _slicedToArray(_useGlobalReducer27, 2),
2847
+ dispatch = _useGlobalReducer28[1];
2447
2848
  var config = useConfig();
2448
2849
  var passwordOptions = config.passwordOptions;
2449
2850
  var _usePasswordInput2 = usePasswordInput(),
@@ -2458,13 +2859,13 @@ var PasswordsEmailForm = function PasswordsEmailForm() {
2458
2859
  isSubmitting = _usePasswordInput2.isSubmitting,
2459
2860
  setIsSubmitting = _usePasswordInput2.setIsSubmitting,
2460
2861
  submitPassword = _usePasswordInput2.submitPassword,
2862
+ submitDiscoveryPassword = _usePasswordInput2.submitDiscoveryPassword,
2461
2863
  handleNonMemberReset = _usePasswordInput2.handleNonMemberReset;
2462
- var _h$21 = h$2(!email),
2864
+ var _h$21 = h$2(!!organization && !email),
2463
2865
  _h$22 = _slicedToArray(_h$21, 2),
2464
2866
  hideInput = _h$22[0],
2465
2867
  setHideInput = _h$22[1];
2466
2868
  if (!passwordOptions) return /*#__PURE__*/wn.createElement(wn.Fragment, null);
2467
- if (!organization) return /*#__PURE__*/wn.createElement(wn.Fragment, null);
2468
2869
  var handleSubmit = function handleSubmit(e) {
2469
2870
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
2470
2871
  var organization_id;
@@ -2472,25 +2873,29 @@ var PasswordsEmailForm = function PasswordsEmailForm() {
2472
2873
  while (1) switch (_context5.prev = _context5.next) {
2473
2874
  case 0:
2474
2875
  e.preventDefault();
2876
+ if (!organization) {
2877
+ _context5.next = 14;
2878
+ break;
2879
+ }
2475
2880
  organization_id = organization.organization_id;
2476
2881
  if (hideInput) {
2477
- _context5.next = 5;
2882
+ _context5.next = 6;
2478
2883
  break;
2479
2884
  }
2480
2885
  submitPassword(organization_id);
2481
2886
  return _context5.abrupt("return");
2482
- case 5:
2887
+ case 6:
2483
2888
  if (email.match(EMAIL_REGEX)) {
2484
- _context5.next = 8;
2889
+ _context5.next = 9;
2485
2890
  break;
2486
2891
  }
2487
2892
  setErrorMessage('Invalid email address');
2488
2893
  return _context5.abrupt("return");
2489
- case 8:
2894
+ case 9:
2490
2895
  setErrorMessage('');
2491
2896
  setIsSubmitting(true);
2492
- readB2BInternals(stytch).searchManager.searchMember(email, organization.organization_id).then(function (_ref54) {
2493
- var member = _ref54.member;
2897
+ readB2BInternals(stytch).searchManager.searchMember(email, organization.organization_id).then(function (_ref62) {
2898
+ var member = _ref62.member;
2494
2899
  if (member === null || member === void 0 ? void 0 : member.member_password_id) {
2495
2900
  setHideInput(false);
2496
2901
  setIsSubmitting(false);
@@ -2509,7 +2914,11 @@ var PasswordsEmailForm = function PasswordsEmailForm() {
2509
2914
  }
2510
2915
  setErrorMessage(message);
2511
2916
  });
2512
- case 11:
2917
+ _context5.next = 15;
2918
+ break;
2919
+ case 14:
2920
+ submitDiscoveryPassword();
2921
+ case 15:
2513
2922
  case "end":
2514
2923
  return _context5.stop();
2515
2924
  }
@@ -2675,29 +3084,6 @@ var GithubIconSvg = function GithubIconSvg() {
2675
3084
  }));
2676
3085
  };
2677
3086
  var GitHubIcon = CreateIcon(GithubIconSvg);
2678
- var getParamsFromB2BOAuthProviderConfig = function getParamsFromB2BOAuthProviderConfig(provider) {
2679
- var providerType = '';
2680
- var oneTap = false;
2681
- var customScopes = [];
2682
- var providerParams = {};
2683
- if (typeof provider === 'string') {
2684
- providerType = provider;
2685
- } else {
2686
- providerType = provider.type;
2687
- if (provider.type === B2BOAuthProviders.Google && 'one_tap' in provider) {
2688
- oneTap = provider.one_tap;
2689
- }
2690
- customScopes = provider.customScopes || [];
2691
- providerParams = provider.providerParams || {};
2692
- }
2693
- var oauthProvider = providerType;
2694
- return {
2695
- type: oauthProvider,
2696
- one_tap: oneTap,
2697
- customScopes: customScopes,
2698
- providerParams: providerParams
2699
- };
2700
- };
2701
3087
  var useIsOnlyFloatingOneTap = function useIsOnlyFloatingOneTap() {
2702
3088
  var config = useConfig();
2703
3089
  var isOnlyFloatingOneTap = F$1(function () {
@@ -2719,9 +3105,9 @@ var useIsUnmounted = function useIsUnmounted() {
2719
3105
  };
2720
3106
  var OAuthB2BButton = function OAuthB2BButton(props) {
2721
3107
  var stytchClient = useStytch();
2722
- var _useGlobalReducer17 = useGlobalReducer(),
2723
- _useGlobalReducer18 = _slicedToArray(_useGlobalReducer17, 1),
2724
- state = _useGlobalReducer18[0];
3108
+ var _useGlobalReducer29 = useGlobalReducer(),
3109
+ _useGlobalReducer30 = _slicedToArray(_useGlobalReducer29, 1),
3110
+ state = _useGlobalReducer30[0];
2725
3111
  var onButtonClick = function onButtonClick() {
2726
3112
  if (state.flowState.organization) {
2727
3113
  return stytchClient.oauth[props.providerType].start({
@@ -2753,8 +3139,8 @@ var OAuthB2BButton = function OAuthB2BButton(props) {
2753
3139
  }
2754
3140
  }, "Continue with ", props.providerTypeTitle)));
2755
3141
  };
2756
- var OAuthErrorMessage = function OAuthErrorMessage(_ref55) {
2757
- var children = _ref55.children;
3142
+ var OAuthErrorMessage = function OAuthErrorMessage(_ref63) {
3143
+ var children = _ref63.children;
2758
3144
  return /*#__PURE__*/wn.createElement("div", {
2759
3145
  key: "oauth-error-message"
2760
3146
  }, /*#__PURE__*/wn.createElement(Text, {
@@ -2766,9 +3152,9 @@ var OneTapNoConfiguredClientsErrorMessage = function OneTapNoConfiguredClientsEr
2766
3152
  href: "https://stytch.com/dashboard/oauth"
2767
3153
  }, "dashboard."));
2768
3154
  };
2769
- var RedirectUrlsErrorMessage = function RedirectUrlsErrorMessage(_ref56) {
2770
- var niceName = _ref56.niceName,
2771
- variableName = _ref56.variableName;
3155
+ var RedirectUrlsErrorMessage = function RedirectUrlsErrorMessage(_ref64) {
3156
+ var niceName = _ref64.niceName,
3157
+ variableName = _ref64.variableName;
2772
3158
  return /*#__PURE__*/wn.createElement(OAuthErrorMessage, null, "One Tap cannot render because there are no ", niceName, " set for this project so we are unable to verify the", ' ', /*#__PURE__*/wn.createElement("code", null, variableName), "\xA0 provided in the configuration. To set ", niceName, " for this project please visit\xA0", /*#__PURE__*/wn.createElement("a", {
2773
3159
  href: "https://stytch.com/docs/javascript-sdk"
2774
3160
  }, "the Stytch dashboard."), "\xA0 For more information on why this validation is necessary please visit\xA0", /*#__PURE__*/wn.createElement("a", {
@@ -2828,10 +3214,10 @@ var B2BGoogleOneTap = function B2BGoogleOneTap() {
2828
3214
  oneTapError = _h$24[0],
2829
3215
  setOneTapError = _h$24[1];
2830
3216
  var isUnmounted = useIsUnmounted();
2831
- var _useGlobalReducer19 = useGlobalReducer(),
2832
- _useGlobalReducer20 = _slicedToArray(_useGlobalReducer19, 2),
2833
- state = _useGlobalReducer20[0],
2834
- dispatch = _useGlobalReducer20[1];
3217
+ var _useGlobalReducer31 = useGlobalReducer(),
3218
+ _useGlobalReducer32 = _slicedToArray(_useGlobalReducer31, 2),
3219
+ state = _useGlobalReducer32[0],
3220
+ dispatch = _useGlobalReducer32[1];
2835
3221
  var attemptToLoadOneTap = T$1(function () {
2836
3222
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
2837
3223
  var _g, _h, _j, _readB2BInternals, oneTap, clientResult, client, oneTapCallback, renderResult;
@@ -2942,149 +3328,14 @@ var B2BGoogleOneTap = function B2BGoogleOneTap() {
2942
3328
  providerTypeTitle: "Google",
2943
3329
  loginRedirectUrl: (_d = config.oauthOptions) === null || _d === void 0 ? void 0 : _d.loginRedirectURL,
2944
3330
  signupRedirectUrl: (_e = config.oauthOptions) === null || _e === void 0 ? void 0 : _e.signupRedirectURL,
2945
- discoveryRedirectUrl: (_f = config.oauthOptions) === null || _f === void 0 ? void 0 : _f.discoveryRedirectURL
2946
- });
2947
- var _readB2BInternals2 = readB2BInternals(stytch),
2948
- publicToken = _readB2BInternals2.publicToken;
2949
- if (oneTapError !== OneTapErrors.None) {
2950
- return /*#__PURE__*/wn.createElement(wn.Fragment, null, isTestPublicToken(publicToken) ? ErrorMessages[oneTapError] : null, googleAuthButton);
2951
- }
2952
- return googleAuthButton;
2953
- };
2954
- var productsToAuthMethods = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, B2BProducts.oauth, undefined), B2BProducts.sso, 'sso'), B2BProducts.emailMagicLinks, 'magic_link'), B2BProducts.passwords, 'password');
2955
- var oauthProvidersToAuthMethods = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, B2BOAuthProviders.Google, 'google_oauth'), B2BOAuthProviders.Microsoft, 'microsoft_oauth'), B2BOAuthProviders.HubSpot, 'hubspot_oauth'), B2BOAuthProviders.Slack, 'slack_oauth'), B2BOAuthProviders.GitHub, 'github_oauth');
2956
- var authMethodsToProducts = Object.entries(productsToAuthMethods).reduce(function (acc, _ref57) {
2957
- var _ref58 = _slicedToArray(_ref57, 2),
2958
- product = _ref58[0],
2959
- method = _ref58[1];
2960
- if (method) {
2961
- acc[method] = product;
2962
- }
2963
- return acc;
2964
- }, {});
2965
- var oauthMethodsToOauthProviders = Object.entries(oauthProvidersToAuthMethods).reduce(function (acc, _ref59) {
2966
- var _ref60 = _slicedToArray(_ref59, 2),
2967
- provider = _ref60[0],
2968
- method = _ref60[1];
2969
- acc[method] = provider;
2970
- return acc;
2971
- }, {});
2972
- var oauthProviderToAuthMethod = function oauthProviderToAuthMethod(provider) {
2973
- return oauthProvidersToAuthMethods[provider];
2974
- };
2975
- var oauthMethodToOauthProvider = function oauthMethodToOauthProvider(authMethod) {
2976
- return oauthMethodsToOauthProviders[authMethod];
2977
- };
2978
- var productToAuthMethod = function productToAuthMethod(product) {
2979
- return productsToAuthMethods[product];
2980
- };
2981
- var authMethodToProduct = function authMethodToProduct(authMethod) {
2982
- if (authMethod in oauthMethodsToOauthProviders) {
2983
- return B2BProducts.oauth;
2984
- }
2985
- return authMethodsToProducts[authMethod];
2986
- };
2987
- var allProducts = Object.keys(productsToAuthMethods);
2988
- var allOauthProviders = Object.values(B2BOAuthProviders);
2989
- var flattenConfigToAuthMethods = function flattenConfigToAuthMethods(products, oauthProviders) {
2990
- return products.reduce(function (acc, product) {
2991
- if (product === B2BProducts.oauth) {
2992
- oauthProviders.forEach(function (provider) {
2993
- var authMethod = oauthProviderToAuthMethod(typeof provider === 'string' ? provider : provider.type);
2994
- if (authMethod) {
2995
- acc.push(authMethod);
2996
- }
2997
- });
2998
- } else {
2999
- var authMethod = productToAuthMethod(product);
3000
- if (authMethod) {
3001
- acc.push(authMethod);
3002
- }
3003
- }
3004
- return acc;
3005
- }, []);
3006
- };
3007
- var useOAuthProviderConfigs = function useOAuthProviderConfigs() {
3008
- var _a;
3009
- var config = useConfig();
3010
- return F$1(function () {
3011
- var _a;
3012
- if (!((_a = config.oauthOptions) === null || _a === void 0 ? void 0 : _a.providers)) {
3013
- return [];
3014
- }
3015
- return config.oauthOptions.providers.map(getParamsFromB2BOAuthProviderConfig);
3016
- }, [(_a = config.oauthOptions) === null || _a === void 0 ? void 0 : _a.providers]);
3017
- };
3018
- var useRestrictedAuthMethods = function useRestrictedAuthMethods() {
3019
- var _a, _b;
3020
- var _useGlobalReducer21 = useGlobalReducer(),
3021
- _useGlobalReducer22 = _slicedToArray(_useGlobalReducer21, 1),
3022
- state = _useGlobalReducer22[0];
3023
- var primaryAuthMethods = state.primary.primaryAuthMethods;
3024
- var hasPrimaryAuthMethods = !!primaryAuthMethods;
3025
- var restrictedAuthMethods = F$1(function () {
3026
- var _a, _b, _c;
3027
- if (state.primary.primaryAuthMethods) {
3028
- return new Set(state.primary.primaryAuthMethods);
3029
- }
3030
- if (((_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.auth_methods) === 'RESTRICTED') {
3031
- return new Set((_c = (_b = state.flowState.organization) === null || _b === void 0 ? void 0 : _b.allowed_auth_methods) !== null && _c !== void 0 ? _c : []);
3032
- }
3033
- }, [(_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.allowed_auth_methods, (_b = state.flowState.organization) === null || _b === void 0 ? void 0 : _b.auth_methods, state.primary.primaryAuthMethods]);
3034
- return {
3035
- restrictedAuthMethods: restrictedAuthMethods,
3036
- hasPrimaryAuthMethods: hasPrimaryAuthMethods
3037
- };
3038
- };
3039
- var useEffectiveAuthConfig = function useEffectiveAuthConfig() {
3040
- var _a;
3041
- var _useGlobalReducer23 = useGlobalReducer(),
3042
- _useGlobalReducer24 = _slicedToArray(_useGlobalReducer23, 1),
3043
- state = _useGlobalReducer24[0];
3044
- var config = useConfig();
3045
- var _useRestrictedAuthMet = useRestrictedAuthMethods(),
3046
- restrictedAuthMethods = _useRestrictedAuthMet.restrictedAuthMethods,
3047
- hasPrimaryAuthMethods = _useRestrictedAuthMet.hasPrimaryAuthMethods;
3048
- var oauthProviderConfigs = useOAuthProviderConfigs();
3049
- var flattenedConfiguredAuthMethods = F$1(function () {
3050
- return flattenConfigToAuthMethods(config.products, oauthProviderConfigs);
3051
- }, [config.products, oauthProviderConfigs]);
3052
- var authMethodsToShow = F$1(function () {
3053
- var _a;
3054
- if (!restrictedAuthMethods) {
3055
- return flattenedConfiguredAuthMethods;
3056
- }
3057
- var restrictedAuthMethodsInUiConfig = flattenedConfiguredAuthMethods.filter(function (authMethod) {
3058
- return restrictedAuthMethods.has(authMethod);
3059
- });
3060
- if (restrictedAuthMethodsInUiConfig.length > 0 || !hasPrimaryAuthMethods) {
3061
- return restrictedAuthMethodsInUiConfig;
3062
- }
3063
- if (((_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.auth_methods) === 'RESTRICTED') {
3064
- return flattenConfigToAuthMethods(allProducts, allOauthProviders).filter(function (authMethod) {
3065
- return restrictedAuthMethods.has(authMethod);
3066
- });
3067
- }
3068
- return ['magic_link'];
3069
- }, [flattenedConfiguredAuthMethods, hasPrimaryAuthMethods, restrictedAuthMethods, (_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.auth_methods]);
3070
- var products = F$1(function () {
3071
- return _toConsumableArray(new Set(authMethodsToShow.map(authMethodToProduct).filter(isTruthy)));
3072
- }, [authMethodsToShow]);
3073
- var oauthProviderSettings = F$1(function () {
3074
- return authMethodsToShow.map(function (authMethod) {
3075
- var _a;
3076
- var provider = oauthMethodToOauthProvider(authMethod);
3077
- if (provider) {
3078
- return (_a = oauthProviderConfigs.find(function (oauthProvider) {
3079
- return oauthProvider.type === provider;
3080
- })) !== null && _a !== void 0 ? _a : getParamsFromB2BOAuthProviderConfig(provider);
3081
- }
3082
- }).filter(isTruthy);
3083
- }, [authMethodsToShow, oauthProviderConfigs]);
3084
- return {
3085
- products: products,
3086
- oauthProviderSettings: oauthProviderSettings
3087
- };
3331
+ discoveryRedirectUrl: (_f = config.oauthOptions) === null || _f === void 0 ? void 0 : _f.discoveryRedirectURL
3332
+ });
3333
+ var _readB2BInternals2 = readB2BInternals(stytch),
3334
+ publicToken = _readB2BInternals2.publicToken;
3335
+ if (oneTapError !== OneTapErrors.None) {
3336
+ return /*#__PURE__*/wn.createElement(wn.Fragment, null, isTestPublicToken(publicToken) ? ErrorMessages[oneTapError] : null, googleAuthButton);
3337
+ }
3338
+ return googleAuthButton;
3088
3339
  };
3089
3340
  var getProviderInfo = function getProviderInfo(provider) {
3090
3341
  switch (provider) {
@@ -3141,18 +3392,18 @@ var getProviderParamsForProvider = function getProviderParamsForProvider(oauthPr
3141
3392
  };
3142
3393
  var OAuthButtons = function OAuthButtons() {
3143
3394
  var _a;
3144
- var _useGlobalReducer25 = useGlobalReducer(),
3145
- _useGlobalReducer26 = _slicedToArray(_useGlobalReducer25, 1),
3146
- state = _useGlobalReducer26[0];
3147
- var _useEffectiveAuthConf = useEffectiveAuthConfig(),
3148
- oauthProviderSettings = _useEffectiveAuthConf.oauthProviderSettings;
3395
+ var _useGlobalReducer33 = useGlobalReducer(),
3396
+ _useGlobalReducer34 = _slicedToArray(_useGlobalReducer33, 1),
3397
+ state = _useGlobalReducer34[0];
3398
+ var _useEffectiveAuthConf3 = useEffectiveAuthConfig(),
3399
+ oauthProviderSettings = _useEffectiveAuthConf3.oauthProviderSettings;
3149
3400
  var config = useConfig();
3150
- var _ref61 = (_a = config.oauthOptions) !== null && _a !== void 0 ? _a : {},
3151
- loginRedirectURL = _ref61.loginRedirectURL,
3152
- signupRedirectURL = _ref61.signupRedirectURL,
3153
- discoveryRedirectURL = _ref61.discoveryRedirectURL,
3154
- customScopes = _ref61.customScopes,
3155
- providerParams = _ref61.providerParams;
3401
+ var _ref65 = (_a = config.oauthOptions) !== null && _a !== void 0 ? _a : {},
3402
+ loginRedirectURL = _ref65.loginRedirectURL,
3403
+ signupRedirectURL = _ref65.signupRedirectURL,
3404
+ discoveryRedirectURL = _ref65.discoveryRedirectURL,
3405
+ customScopes = _ref65.customScopes,
3406
+ providerParams = _ref65.providerParams;
3156
3407
  var mappedProviders = oauthProviderSettings.map(function (oauthProvider) {
3157
3408
  var _getProviderInfo = getProviderInfo(oauthProvider.type),
3158
3409
  icon = _getProviderInfo.icon,
@@ -3182,9 +3433,9 @@ var OAuthButtons = function OAuthButtons() {
3182
3433
  };
3183
3434
  var UsePasswordText = He(Text)(_templateObject36 || (_templateObject36 = _taggedTemplateLiteral(["\n font-weight: bold !important;\n cursor: pointer;\n"])));
3184
3435
  var PasswordUseButton = function PasswordUseButton() {
3185
- var _useGlobalReducer27 = useGlobalReducer(),
3186
- _useGlobalReducer28 = _slicedToArray(_useGlobalReducer27, 2),
3187
- dispatch = _useGlobalReducer28[1];
3436
+ var _useGlobalReducer35 = useGlobalReducer(),
3437
+ _useGlobalReducer36 = _slicedToArray(_useGlobalReducer35, 2),
3438
+ dispatch = _useGlobalReducer36[1];
3188
3439
  var handleUsePassword = function handleUsePassword() {
3189
3440
  dispatch({
3190
3441
  type: 'transition',
@@ -3199,56 +3450,68 @@ var PasswordUseButton = function PasswordUseButton() {
3199
3450
  };
3200
3451
  var Component;
3201
3452
  (function (Component) {
3202
- Component["MagicLinkEmailForm"] = "MagicLinkEmailForm";
3203
- Component["MagicLinkEmailDiscoveryForm"] = "MagicLinkEmailDiscoveryForm";
3453
+ Component["EmailForm"] = "EmailForm";
3454
+ Component["EmailDiscoveryForm"] = "EmailDiscoveryForm";
3204
3455
  Component["OAuthButtons"] = "OAuthButtons";
3205
3456
  Component["SSOButtons"] = "SSOButtons";
3206
3457
  Component["PasswordsEmailForm"] = "PasswordsEmailForm";
3207
- Component["PasswordEMLCombined"] = "PasswordEMLCombined";
3458
+ Component["PasswordEmailCombined"] = "PasswordEmailCombined";
3459
+ Component["PasswordEmailCombinedDiscovery"] = "PasswordEmailCombinedDiscovery";
3208
3460
  Component["Divider"] = "Divider";
3209
3461
  })(Component || (Component = {}));
3210
3462
  var generateProductComponentsOrdering = function generateProductComponentsOrdering(products, flowState) {
3211
3463
  var flowStateType = flowState.type;
3212
- var displayEmlAndPasswordsTogether = products.includes(B2BProducts.emailMagicLinks) && products.includes(B2BProducts.passwords);
3213
- var ProductComponents = products.map(function (product) {
3464
+ var productsSet = new Set(products);
3465
+ var displayEmailAndPasswordsTogether = (productsSet.has(B2BProducts.emailMagicLinks) || productsSet.has(B2BProducts.emailOtp)) && productsSet.has(B2BProducts.passwords);
3466
+ var productComponentsSet = products.reduce(function (components, product) {
3214
3467
  var _a, _b, _c;
3215
3468
  switch (product) {
3216
3469
  case B2BProducts.emailMagicLinks:
3217
- if (displayEmlAndPasswordsTogether) return null;
3218
- return flowStateType === AuthFlowType.Organization ? Component.MagicLinkEmailForm : Component.MagicLinkEmailDiscoveryForm;
3470
+ case B2BProducts.emailOtp:
3471
+ if (!displayEmailAndPasswordsTogether) {
3472
+ components.add(flowStateType === AuthFlowType.Organization ? Component.EmailForm : Component.EmailDiscoveryForm);
3473
+ }
3474
+ break;
3219
3475
  case B2BProducts.oauth:
3220
- return Component.OAuthButtons;
3476
+ components.add(Component.OAuthButtons);
3477
+ break;
3221
3478
  case B2BProducts.sso:
3222
3479
  var isSsoValid = ((_c = (_b = (_a = flowState.organization) === null || _a === void 0 ? void 0 : _a.sso_active_connections) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 0;
3223
- return flowStateType === AuthFlowType.Organization && isSsoValid ? Component.SSOButtons : null;
3480
+ if (flowStateType === AuthFlowType.Organization && isSsoValid) {
3481
+ components.add(Component.SSOButtons);
3482
+ }
3483
+ break;
3224
3484
  case B2BProducts.passwords:
3225
- if (displayEmlAndPasswordsTogether) return null;
3226
- return Component.PasswordsEmailForm;
3485
+ if (!displayEmailAndPasswordsTogether) {
3486
+ components.add(Component.PasswordsEmailForm);
3487
+ }
3488
+ break;
3227
3489
  }
3228
- }).filter(function (component) {
3229
- return component !== null;
3230
- });
3231
- if (displayEmlAndPasswordsTogether) {
3490
+ return components;
3491
+ }, new Set());
3492
+ var productComponents = Array.from(productComponentsSet);
3493
+ if (displayEmailAndPasswordsTogether) {
3232
3494
  var passwordIndex = products.indexOf(B2BProducts.passwords);
3233
3495
  var emlIndex = products.indexOf(B2BProducts.emailMagicLinks);
3234
- var firstProductIndex = Math.min(passwordIndex, emlIndex);
3235
- var combinedComponent = flowStateType === AuthFlowType.Organization ? Component.PasswordEMLCombined : Component.MagicLinkEmailDiscoveryForm;
3236
- ProductComponents.splice(firstProductIndex, 0, combinedComponent);
3496
+ var otpIndex = products.indexOf(B2BProducts.emailOtp);
3497
+ var firstProductIndex = Math.min(passwordIndex, emlIndex, otpIndex);
3498
+ var combinedComponent = flowStateType === AuthFlowType.Organization ? Component.PasswordEmailCombined : Component.PasswordEmailCombinedDiscovery;
3499
+ productComponents.splice(firstProductIndex, 0, combinedComponent);
3237
3500
  }
3238
- var hasButtons = ProductComponents.includes(Component.OAuthButtons) || ProductComponents.includes(Component.SSOButtons);
3239
- var hasInput = products.includes(B2BProducts.emailMagicLinks) || products.includes(B2BProducts.passwords);
3501
+ var hasButtons = productComponentsSet.has(Component.OAuthButtons) || productComponentsSet.has(Component.SSOButtons);
3502
+ var hasInput = productsSet.has(B2BProducts.emailMagicLinks) || productsSet.has(B2BProducts.passwords);
3240
3503
  var showDivider = hasButtons && hasInput;
3241
- if (ProductComponents.length > 1 && showDivider) {
3242
- ProductComponents.splice(ProductComponents.length - 1, 0, Component.Divider);
3504
+ if (productComponents.length > 1 && showDivider) {
3505
+ productComponents.splice(productComponents.length - 1, 0, Component.Divider);
3243
3506
  }
3244
- return ProductComponents;
3507
+ return productComponents;
3245
3508
  };
3246
3509
  var Container$1 = He(Flex)(_templateObject37 || (_templateObject37 = _taggedTemplateLiteral(["\n > * + * {\n margin-top: 24px;\n }\n"])));
3247
3510
  var LogoImage$1 = He.img(_templateObject38 || (_templateObject38 = _taggedTemplateLiteral(["\n max-height: 50px;\n max-width: 100px;\n"])));
3248
3511
  var Header = He(Text)(_templateObject39 || (_templateObject39 = _taggedTemplateLiteral(["\n text-align: center;\n"])));
3249
- var Logo$1 = function Logo$1(_ref62) {
3250
- var orgLogo = _ref62.orgLogo,
3251
- appLogo = _ref62.appLogo;
3512
+ var Logo$1 = function Logo$1(_ref66) {
3513
+ var orgLogo = _ref66.orgLogo,
3514
+ appLogo = _ref66.appLogo;
3252
3515
  if (orgLogo !== '' && appLogo !== '') return /*#__PURE__*/wn.createElement(wn.Fragment, null);
3253
3516
  return /*#__PURE__*/wn.createElement(Flex, {
3254
3517
  justifyContent: "center",
@@ -3259,16 +3522,16 @@ var Logo$1 = function Logo$1(_ref62) {
3259
3522
  src: appLogo
3260
3523
  }));
3261
3524
  };
3262
- var ProductComponents = function ProductComponents(_ref63) {
3263
- var components = _ref63.components;
3525
+ var ProductComponents = function ProductComponents(_ref67) {
3526
+ var components = _ref67.components;
3264
3527
  var renderedComponents = components.map(function (component) {
3265
3528
  switch (component) {
3266
- case Component.MagicLinkEmailForm:
3267
- return /*#__PURE__*/wn.createElement(MagicLinkEmailForm, {
3529
+ case Component.EmailForm:
3530
+ return /*#__PURE__*/wn.createElement(EmailForm, {
3268
3531
  key: component
3269
3532
  });
3270
- case Component.MagicLinkEmailDiscoveryForm:
3271
- return /*#__PURE__*/wn.createElement(MagicLinkEmailDiscoveryForm, {
3533
+ case Component.EmailDiscoveryForm:
3534
+ return /*#__PURE__*/wn.createElement(EmailDiscoveryForm, {
3272
3535
  key: component
3273
3536
  });
3274
3537
  case Component.OAuthButtons:
@@ -3283,13 +3546,23 @@ var ProductComponents = function ProductComponents(_ref63) {
3283
3546
  return /*#__PURE__*/wn.createElement(PasswordsEmailForm, {
3284
3547
  key: component
3285
3548
  });
3286
- case Component.PasswordEMLCombined:
3549
+ case Component.PasswordEmailCombined:
3550
+ return /*#__PURE__*/wn.createElement(Flex, {
3551
+ key: "email_password",
3552
+ direction: "column",
3553
+ gap: 12
3554
+ }, /*#__PURE__*/wn.createElement(EmailForm, {
3555
+ key: "email"
3556
+ }), /*#__PURE__*/wn.createElement(PasswordUseButton, {
3557
+ key: "password"
3558
+ }));
3559
+ case Component.PasswordEmailCombinedDiscovery:
3287
3560
  return /*#__PURE__*/wn.createElement(Flex, {
3288
- key: "eml_password",
3561
+ key: "email_password_discovery",
3289
3562
  direction: "column",
3290
3563
  gap: 12
3291
- }, /*#__PURE__*/wn.createElement(MagicLinkEmailForm, {
3292
- key: "magic_link"
3564
+ }, /*#__PURE__*/wn.createElement(EmailDiscoveryForm, {
3565
+ key: "email"
3293
3566
  }), /*#__PURE__*/wn.createElement(PasswordUseButton, {
3294
3567
  key: "password"
3295
3568
  }));
@@ -3306,15 +3579,15 @@ var MainScreen = function MainScreen() {
3306
3579
  var _Ze = Ze(),
3307
3580
  displayHeader = _Ze.displayHeader,
3308
3581
  logo = _Ze.logo;
3309
- var _useGlobalReducer29 = useGlobalReducer(),
3310
- _useGlobalReducer30 = _slicedToArray(_useGlobalReducer29, 1),
3311
- state = _useGlobalReducer30[0];
3582
+ var _useGlobalReducer37 = useGlobalReducer(),
3583
+ _useGlobalReducer38 = _slicedToArray(_useGlobalReducer37, 1),
3584
+ state = _useGlobalReducer38[0];
3312
3585
  var _state$primary = state.primary,
3313
3586
  primaryAuthMethods = _state$primary.primaryAuthMethods,
3314
3587
  email = _state$primary.email,
3315
3588
  emailVerified = _state$primary.emailVerified;
3316
- var _useEffectiveAuthConf2 = useEffectiveAuthConfig(),
3317
- products = _useEffectiveAuthConf2.products;
3589
+ var _useEffectiveAuthConf4 = useEffectiveAuthConfig(),
3590
+ products = _useEffectiveAuthConf4.products;
3318
3591
  var ProductComponentsOrdering = generateProductComponentsOrdering(products, state.flowState);
3319
3592
  var title;
3320
3593
  switch (state.flowState.type) {
@@ -3451,10 +3724,10 @@ var inboxLinks$1 = function inboxLinks$1(emailDomain) {
3451
3724
  var Link$1 = He.a(_templateObject40 || (_templateObject40 = _taggedTemplateLiteral(["\n all: unset;\n cursor: pointer;\n\n &:hover {\n text-decoration: underline;\n text-decoration-color: ", ";\n }\n"])), function (props) {
3452
3725
  return props.theme.colors.primary;
3453
3726
  });
3454
- var EmailProviderLink$1 = function EmailProviderLink$1(_ref64) {
3455
- var label = _ref64.label,
3456
- href = _ref64.href,
3457
- Icon = _ref64.Icon;
3727
+ var EmailProviderLink$1 = function EmailProviderLink$1(_ref68) {
3728
+ var label = _ref68.label,
3729
+ href = _ref68.href,
3730
+ Icon = _ref68.Icon;
3458
3731
  return /*#__PURE__*/wn.createElement(Flex, {
3459
3732
  gap: 4
3460
3733
  }, Icon, /*#__PURE__*/wn.createElement(Link$1, {
@@ -3463,10 +3736,10 @@ var EmailProviderLink$1 = function EmailProviderLink$1(_ref64) {
3463
3736
  rel: "noopener noreferrer"
3464
3737
  }, /*#__PURE__*/wn.createElement(Text, null, "Open in ", label)));
3465
3738
  };
3466
- var EmailConfirmation$1 = function EmailConfirmation$1(_ref65) {
3467
- var emailDomain = _ref65.emailDomain,
3468
- reset = _ref65.reset,
3469
- email = _ref65.email;
3739
+ var EmailConfirmation$1 = function EmailConfirmation$1(_ref69) {
3740
+ var emailDomain = _ref69.emailDomain,
3741
+ reset = _ref69.reset,
3742
+ email = _ref69.email;
3470
3743
  var _inboxLinks$ = inboxLinks$1(emailDomain),
3471
3744
  GMAIL = _inboxLinks$.GMAIL,
3472
3745
  YAHOO = _inboxLinks$.YAHOO,
@@ -3512,8 +3785,8 @@ var useEmailDomain$1 = function useEmailDomain$1() {
3512
3785
  emailDomains = _h$26[0],
3513
3786
  setEmailDomains = _h$26[1];
3514
3787
  p$1(function () {
3515
- readB2BInternals(stytch).bootstrap.getAsync().then(function (_ref66) {
3516
- var emailDomains = _ref66.emailDomains;
3788
+ readB2BInternals(stytch).bootstrap.getAsync().then(function (_ref70) {
3789
+ var emailDomains = _ref70.emailDomains;
3517
3790
  setEmailDomains(emailDomains);
3518
3791
  });
3519
3792
  }, [stytch]);
@@ -3526,14 +3799,14 @@ var useEmailDomain$1 = function useEmailDomain$1() {
3526
3799
  return null;
3527
3800
  };
3528
3801
  var EmailConfirmation = function EmailConfirmation() {
3529
- var _useGlobalReducer31 = useGlobalReducer(),
3530
- _useGlobalReducer32 = _slicedToArray(_useGlobalReducer31, 2),
3531
- state = _useGlobalReducer32[0],
3532
- dispatch = _useGlobalReducer32[1];
3802
+ var _useGlobalReducer39 = useGlobalReducer(),
3803
+ _useGlobalReducer40 = _slicedToArray(_useGlobalReducer39, 2),
3804
+ state = _useGlobalReducer40[0],
3805
+ dispatch = _useGlobalReducer40[1];
3533
3806
  var emailDomain = useEmailDomain$1();
3534
3807
  var reset = function reset() {
3535
3808
  dispatch({
3536
- type: 'set_magic_link_email',
3809
+ type: 'set_user_supplied_email',
3537
3810
  email: ''
3538
3811
  });
3539
3812
  dispatch({
@@ -3544,7 +3817,7 @@ var EmailConfirmation = function EmailConfirmation() {
3544
3817
  return /*#__PURE__*/wn.createElement(EmailConfirmation$1, {
3545
3818
  emailDomain: emailDomain,
3546
3819
  reset: reset,
3547
- email: state.formState.magicLinkState.email
3820
+ email: state.formState.emailState.userSuppliedEmail
3548
3821
  });
3549
3822
  };
3550
3823
  var LoggingInScreen = function LoggingInScreen() {
@@ -3572,23 +3845,23 @@ var LoadingScreen = function LoadingScreen() {
3572
3845
  var isJoinViaJitType = function isJoinViaJitType(type) {
3573
3846
  return type === 'eligible_to_join_by_email_domain' || type === 'eligible_to_join_by_oauth_tenant';
3574
3847
  };
3575
- var OrganizationsContainer = He(Flex)(_templateObject41 || (_templateObject41 = _taggedTemplateLiteral(["\n border: ", ";\n border-radius: ", ";\n > div + div {\n border-top: ", ";\n }\n"])), function (_ref67) {
3576
- var theme = _ref67.theme;
3848
+ var OrganizationsContainer = He(Flex)(_templateObject41 || (_templateObject41 = _taggedTemplateLiteral(["\n border: ", ";\n border-radius: ", ";\n > div + div {\n border-top: ", ";\n }\n"])), function (_ref71) {
3849
+ var theme = _ref71.theme;
3577
3850
  return theme.container.border;
3578
- }, function (_ref68) {
3579
- var theme = _ref68.theme;
3851
+ }, function (_ref72) {
3852
+ var theme = _ref72.theme;
3580
3853
  return theme.container.borderRadius;
3581
- }, function (_ref69) {
3582
- var theme = _ref69.theme;
3854
+ }, function (_ref73) {
3855
+ var theme = _ref73.theme;
3583
3856
  return theme.container.border;
3584
3857
  });
3585
3858
  var OrganizationsRow = He(Flex)(_templateObject42 || (_templateObject42 = _taggedTemplateLiteral(["\n cursor: pointer;\n gap: 8px;\n"])));
3586
3859
  var LogoImage = He.img(_templateObject43 || (_templateObject43 = _taggedTemplateLiteral(["\n height: 40px;\n width: 40px;\n flex-shrink: 0;\n border-radius: 4px;\n"])));
3587
- var LogoText = He(Flex)(_templateObject44 || (_templateObject44 = _taggedTemplateLiteral(["\n height: 40px;\n width: 40px;\n flex-shrink: 0;\n background-color: ", ";\n color: ", ";\n border-radius: 4px;\n\n font-style: normal;\n font-weight: 400;\n font-size: 18px;\n line-height: 25px;\n"])), function (_ref70) {
3588
- var theme = _ref70.theme;
3860
+ var LogoText = He(Flex)(_templateObject44 || (_templateObject44 = _taggedTemplateLiteral(["\n height: 40px;\n width: 40px;\n flex-shrink: 0;\n background-color: ", ";\n color: ", ";\n border-radius: 4px;\n\n font-style: normal;\n font-weight: 400;\n font-size: 18px;\n line-height: 25px;\n"])), function (_ref74) {
3861
+ var theme = _ref74.theme;
3589
3862
  return theme.buttons.primary.backgroundColor;
3590
- }, function (_ref71) {
3591
- var theme = _ref71.theme;
3863
+ }, function (_ref75) {
3864
+ var theme = _ref75.theme;
3592
3865
  return theme.buttons.primary.textColor;
3593
3866
  });
3594
3867
  var SvgNoShrink = He.svg(_templateObject45 || (_templateObject45 = _taggedTemplateLiteral(["\n flex-shrink: 0;\n"])));
@@ -3604,9 +3877,9 @@ var RightArrowSVG = function RightArrowSVG() {
3604
3877
  fill: "#19303D"
3605
3878
  }));
3606
3879
  };
3607
- var Logo = function Logo(_ref72) {
3608
- var name = _ref72.name,
3609
- logo = _ref72.logo;
3880
+ var Logo = function Logo(_ref76) {
3881
+ var name = _ref76.name,
3882
+ logo = _ref76.logo;
3610
3883
  if (logo !== '') {
3611
3884
  return /*#__PURE__*/y(LogoImage, {
3612
3885
  src: logo
@@ -3617,8 +3890,8 @@ var Logo = function Logo(_ref72) {
3617
3890
  justifyContent: "center"
3618
3891
  }, name[0]);
3619
3892
  };
3620
- var ArrowText = function ArrowText(_ref73) {
3621
- var type = _ref73.type;
3893
+ var ArrowText = function ArrowText(_ref77) {
3894
+ var type = _ref77.type;
3622
3895
  if (isJoinViaJitType(type) || type === 'pending_member') return /*#__PURE__*/y(Text, {
3623
3896
  align: "right"
3624
3897
  }, "Join");
@@ -3628,10 +3901,10 @@ var ArrowText = function ArrowText(_ref73) {
3628
3901
  return /*#__PURE__*/y(g$1, null);
3629
3902
  };
3630
3903
  var DiscoverNoOrganizations = function DiscoverNoOrganizations() {
3631
- var _useGlobalReducer33 = useGlobalReducer(),
3632
- _useGlobalReducer34 = _slicedToArray(_useGlobalReducer33, 2),
3633
- state = _useGlobalReducer34[0],
3634
- dispatch = _useGlobalReducer34[1];
3904
+ var _useGlobalReducer41 = useGlobalReducer(),
3905
+ _useGlobalReducer42 = _slicedToArray(_useGlobalReducer41, 2),
3906
+ state = _useGlobalReducer42[0],
3907
+ dispatch = _useGlobalReducer42[1];
3635
3908
  var stytchClient = useStytch();
3636
3909
  var config = useConfig();
3637
3910
  var _useBootstrap = useBootstrap(),
@@ -3642,7 +3915,7 @@ var DiscoverNoOrganizations = function DiscoverNoOrganizations() {
3642
3915
  screen: AppScreens$1.Main
3643
3916
  });
3644
3917
  };
3645
- var _useMutate4 = useMutate("stytch.discovery.organization.create", function () {
3918
+ var _useMutate2 = useMutate("stytch.discovery.organization.create", function () {
3646
3919
  return stytchClient.discovery.organizations.create({
3647
3920
  session_duration_minutes: config.sessionOptions.sessionDurationMinutes
3648
3921
  });
@@ -3657,8 +3930,8 @@ var DiscoverNoOrganizations = function DiscoverNoOrganizations() {
3657
3930
  });
3658
3931
  }
3659
3932
  }),
3660
- stytchCreateOrganization = _useMutate4.trigger,
3661
- isCreateLoading = _useMutate4.isMutating;
3933
+ stytchCreateOrganization = _useMutate2.trigger,
3934
+ isCreateLoading = _useMutate2.isMutating;
3662
3935
  if (isCreateLoading) {
3663
3936
  return /*#__PURE__*/y(LoadingScreen, null);
3664
3937
  }
@@ -3704,10 +3977,10 @@ var shouldAllowDirectLoginToOrganization = function shouldAllowDirectLoginToOrga
3704
3977
  };
3705
3978
  var Discovery = function Discovery() {
3706
3979
  var _a;
3707
- var _useGlobalReducer35 = useGlobalReducer(),
3708
- _useGlobalReducer36 = _slicedToArray(_useGlobalReducer35, 2),
3709
- state = _useGlobalReducer36[0],
3710
- dispatch = _useGlobalReducer36[1];
3980
+ var _useGlobalReducer43 = useGlobalReducer(),
3981
+ _useGlobalReducer44 = _slicedToArray(_useGlobalReducer43, 2),
3982
+ state = _useGlobalReducer44[0],
3983
+ dispatch = _useGlobalReducer44[1];
3711
3984
  var stytchClient = useStytch();
3712
3985
  var config = useConfig();
3713
3986
  var shouldDirectLoginConfigEnabled = !!((_a = config.directLoginForSingleMembership) === null || _a === void 0 ? void 0 : _a.status);
@@ -3742,8 +4015,8 @@ var Discovery = function Discovery() {
3742
4015
  connection_id: connectionId
3743
4016
  });
3744
4017
  }, [stytchClient]);
3745
- var _useMutate5 = useMutate("stytch.discovery.intermediateSessions.exchange", function (_, _ref74) {
3746
- var organizationId = _ref74.arg.organizationId;
4018
+ var _useMutate3 = useMutate("stytch.discovery.intermediateSessions.exchange", function (_, _ref78) {
4019
+ var organizationId = _ref78.arg.organizationId;
3747
4020
  return stytchClient.discovery.intermediateSessions.exchange({
3748
4021
  organization_id: organizationId,
3749
4022
  session_duration_minutes: config.sessionOptions.sessionDurationMinutes
@@ -3753,9 +4026,9 @@ var Discovery = function Discovery() {
3753
4026
  onAuthenticateSuccess(data, dispatch, config);
3754
4027
  }
3755
4028
  }),
3756
- stytchDiscoveryExchange = _useMutate5.trigger,
3757
- isExchangeLoading = _useMutate5.isMutating;
3758
- var _useMutate6 = useMutate("stytch.discovery.organization.create", function () {
4029
+ stytchDiscoveryExchange = _useMutate3.trigger,
4030
+ isExchangeLoading = _useMutate3.isMutating;
4031
+ var _useMutate4 = useMutate("stytch.discovery.organization.create", function () {
3759
4032
  return stytchClient.discovery.organizations.create({
3760
4033
  session_duration_minutes: config.sessionOptions.sessionDurationMinutes
3761
4034
  });
@@ -3770,8 +4043,8 @@ var Discovery = function Discovery() {
3770
4043
  });
3771
4044
  }
3772
4045
  }),
3773
- stytchCreateOrganization = _useMutate6.trigger,
3774
- isCreateLoading = _useMutate6.isMutating;
4046
+ stytchCreateOrganization = _useMutate4.trigger,
4047
+ isCreateLoading = _useMutate4.isMutating;
3775
4048
  if (isExchangeLoading) {
3776
4049
  return /*#__PURE__*/y(LoggingInScreen, null);
3777
4050
  }
@@ -3924,59 +4197,521 @@ var ConfirmationSVG = function ConfirmationSVG() {
3924
4197
  stopOpacity: "0.26"
3925
4198
  }))));
3926
4199
  };
3927
- var Confirmation = function Confirmation() {
3928
- return /*#__PURE__*/y(Flex, {
4200
+ var Confirmation = function Confirmation() {
4201
+ return /*#__PURE__*/y(Flex, {
4202
+ direction: "column",
4203
+ gap: 24,
4204
+ alignItems: "center"
4205
+ }, /*#__PURE__*/y(Text, {
4206
+ size: "header"
4207
+ }, "Success!"), /*#__PURE__*/y(Text, null, "You have successfully logged in."), /*#__PURE__*/y(ConfirmationSVG, null));
4208
+ };
4209
+ var useMountEffect = function useMountEffect(effect) {
4210
+ var effectRef = _$1(effect);
4211
+ p$1(function () {
4212
+ return effectRef.current();
4213
+ }, []);
4214
+ };
4215
+ var ConfirmationScreen = function ConfirmationScreen() {
4216
+ var onEvent = useEventCallback();
4217
+ useMountEffect(function () {
4218
+ onEvent({
4219
+ type: StytchEventType.AuthenticateFlowComplete,
4220
+ data: {}
4221
+ });
4222
+ });
4223
+ return /*#__PURE__*/y(Confirmation, null);
4224
+ };
4225
+ var assertUnreachable = function assertUnreachable() {
4226
+ throw new Error('Assertion failure');
4227
+ };
4228
+ var Chevron = function Chevron() {
4229
+ return /*#__PURE__*/wn.createElement("svg", {
4230
+ viewBox: "0 0 25 25",
4231
+ fill: "none",
4232
+ xmlns: "http://www.w3.org/2000/svg"
4233
+ }, /*#__PURE__*/wn.createElement("path", {
4234
+ d: "M9.09 7.91L13.67 12.5L9.09 17.09L10.5 18.5L16.5 12.5L10.5 6.5L9.09 7.91Z",
4235
+ fill: "currentColor"
4236
+ }));
4237
+ };
4238
+ var Chevron$1 = CreateIcon(Chevron);
4239
+ var StyledButton = He.button(_templateObject46 || (_templateObject46 = _taggedTemplateLiteral(["\n all: unset;\n color: ", ";\n cursor: pointer;\n padding: 20px 0;\n border-bottom: 1px solid #e5e8eb;\n font-weight: 500;\n display: flex;\n align-items: center;\n justify-content: space-between;\n"])), function (props) {
4240
+ return props.theme.colors.primary;
4241
+ });
4242
+ var MenuText = He.div(_templateObject47 || (_templateObject47 = _taggedTemplateLiteral(["\n flex: 1 1 auto;\n"])));
4243
+ var ChevronContainer = He.span(_templateObject48 || (_templateObject48 = _taggedTemplateLiteral(["\n flex: 0 0 auto;\n"])));
4244
+ var MenuButton = function MenuButton(_ref79) {
4245
+ var children = _ref79.children,
4246
+ disabled = _ref79.disabled,
4247
+ onClick = _ref79.onClick;
4248
+ return /*#__PURE__*/wn.createElement(StyledButton, {
4249
+ type: "button",
4250
+ onClick: onClick,
4251
+ disabled: disabled
4252
+ }, /*#__PURE__*/wn.createElement(MenuText, null, children), /*#__PURE__*/wn.createElement(ChevronContainer, {
4253
+ "aria-hidden": true
4254
+ }, /*#__PURE__*/wn.createElement(Chevron$1, null)));
4255
+ };
4256
+ var options = _defineProperty(_defineProperty({}, B2BProducts.emailMagicLinks, {
4257
+ label: 'Email me a log in link'
4258
+ }), B2BProducts.emailOtp, {
4259
+ label: 'Email me a log in code'
4260
+ });
4261
+ var EmailMethodSelectionScreen = function EmailMethodSelectionScreen() {
4262
+ var _useEffectiveAuthConf5 = useEffectiveAuthConfig(),
4263
+ products = _useEffectiveAuthConf5.products;
4264
+ var _useGlobalReducer45 = useGlobalReducer(),
4265
+ _useGlobalReducer46 = _slicedToArray(_useGlobalReducer45, 2),
4266
+ state = _useGlobalReducer46[0],
4267
+ dispatch = _useGlobalReducer46[1];
4268
+ var _useEmlDiscoverySend2 = useEmlDiscoverySend(),
4269
+ sendDiscoveryEml = _useEmlDiscoverySend2.trigger,
4270
+ isSendingDiscoveryEml = _useEmlDiscoverySend2.isMutating,
4271
+ sendDiscoveryEmlError = _useEmlDiscoverySend2.error,
4272
+ resetSendDiscoveryEml = _useEmlDiscoverySend2.reset;
4273
+ var _useEmailOtpDiscovery2 = useEmailOtpDiscoverySend(),
4274
+ sendDiscoveryOtp = _useEmailOtpDiscovery2.trigger,
4275
+ isSendingDiscoveryOtp = _useEmailOtpDiscovery2.isMutating,
4276
+ sendDiscoveryOtpError = _useEmailOtpDiscovery2.error,
4277
+ resetSendDiscoveryOtp = _useEmailOtpDiscovery2.reset;
4278
+ var _useEmlLoginOrSignup2 = useEmlLoginOrSignup(),
4279
+ sendLoginOrSignupEml = _useEmlLoginOrSignup2.trigger,
4280
+ isSendingLoginOrSignupEml = _useEmlLoginOrSignup2.isMutating,
4281
+ sendLoginOrSignupEmlError = _useEmlLoginOrSignup2.error,
4282
+ resetSendLoginOrSignupEml = _useEmlLoginOrSignup2.reset;
4283
+ var _useEmailOtpLoginOrSi2 = useEmailOtpLoginOrSignup(),
4284
+ sendLoginOrSignupOtp = _useEmailOtpLoginOrSi2.trigger,
4285
+ isSendingLoginOrSignupOtp = _useEmailOtpLoginOrSi2.isMutating,
4286
+ sendLoginOrSignupOtpError = _useEmailOtpLoginOrSi2.error,
4287
+ resetSendLoginOrSignupOtp = _useEmailOtpLoginOrSi2.reset;
4288
+ var isSending = isSendingDiscoveryEml || isSendingDiscoveryOtp || isSendingLoginOrSignupEml || isSendingLoginOrSignupOtp;
4289
+ var error = sendDiscoveryEmlError || sendDiscoveryOtpError || sendLoginOrSignupEmlError || sendLoginOrSignupOtpError;
4290
+ var errorMessage = extractErrorMessage(error);
4291
+ var handleChooseMethod = function handleChooseMethod(method) {
4292
+ resetSendDiscoveryEml();
4293
+ resetSendDiscoveryOtp();
4294
+ resetSendLoginOrSignupEml();
4295
+ resetSendLoginOrSignupOtp();
4296
+ switch (method) {
4297
+ case B2BProducts.emailMagicLinks:
4298
+ if (state.flowState.type === AuthFlowType.Discovery) {
4299
+ sendDiscoveryEml({
4300
+ email: state.formState.emailState.userSuppliedEmail
4301
+ });
4302
+ } else if (state.flowState.type === AuthFlowType.Organization && state.flowState.organization) {
4303
+ sendLoginOrSignupEml({
4304
+ email: state.formState.emailState.userSuppliedEmail,
4305
+ organization_id: state.flowState.organization.organization_id
4306
+ });
4307
+ }
4308
+ break;
4309
+ case B2BProducts.emailOtp:
4310
+ if (state.flowState.type === AuthFlowType.Discovery) {
4311
+ sendDiscoveryOtp({
4312
+ email: state.formState.emailState.userSuppliedEmail
4313
+ });
4314
+ } else if (state.flowState.type === AuthFlowType.Organization && state.flowState.organization) {
4315
+ sendLoginOrSignupOtp({
4316
+ email: state.formState.emailState.userSuppliedEmail,
4317
+ organization_id: state.flowState.organization.organization_id
4318
+ });
4319
+ }
4320
+ break;
4321
+ }
4322
+ };
4323
+ var displayOptions = F$1(function () {
4324
+ return products.filter(function (product) {
4325
+ return product in options;
4326
+ }).map(function (product) {
4327
+ var option = options[product];
4328
+ return {
4329
+ option: product,
4330
+ label: option.label
4331
+ };
4332
+ });
4333
+ }, [products]);
4334
+ var handleBack = function handleBack() {
4335
+ dispatch({
4336
+ type: 'navigate_back'
4337
+ });
4338
+ };
4339
+ return /*#__PURE__*/wn.createElement(Flex, {
4340
+ direction: "column",
4341
+ gap: 24
4342
+ }, /*#__PURE__*/wn.createElement(BackArrow, {
4343
+ onClick: handleBack
4344
+ }), /*#__PURE__*/wn.createElement(Text, {
4345
+ size: "header"
4346
+ }, "Select how you\u2019d like to continue."), /*#__PURE__*/wn.createElement(Flex, {
4347
+ direction: "column"
4348
+ }, displayOptions.map(function (_ref80) {
4349
+ var option = _ref80.option,
4350
+ label = _ref80.label;
4351
+ return /*#__PURE__*/wn.createElement(MenuButton, {
4352
+ key: option,
4353
+ disabled: isSending,
4354
+ onClick: function onClick() {
4355
+ handleChooseMethod(option);
4356
+ }
4357
+ }, label);
4358
+ })), errorMessage && /*#__PURE__*/wn.createElement(ErrorText, {
4359
+ errorMessage: errorMessage
4360
+ }));
4361
+ };
4362
+ var InlineButton = function InlineButton(_ref81) {
4363
+ var onClick = _ref81.onClick,
4364
+ children = _ref81.children;
4365
+ return /*#__PURE__*/wn.createElement("button", {
4366
+ onClick: onClick,
4367
+ style: {
4368
+ all: 'unset'
4369
+ }
4370
+ }, /*#__PURE__*/wn.createElement("b", {
4371
+ style: {
4372
+ cursor: 'pointer'
4373
+ }
4374
+ }, children));
4375
+ };
4376
+ var Wrapper = He.div(_templateObject49 || (_templateObject49 = _taggedTemplateLiteral(["\n display: grid;\n grid-template-rows: ", ";\n transition: grid-template-rows 0.15s ease-out;\n"])), function (_ref82) {
4377
+ var isOpen = _ref82.isOpen;
4378
+ return isOpen ? '1fr' : '0fr';
4379
+ });
4380
+ var Inner = He.div(_templateObject50 || (_templateObject50 = _taggedTemplateLiteral(["\n overflow: hidden;\n"])));
4381
+ var AnimatedContainer = function AnimatedContainer(_ref83) {
4382
+ var isOpen = _ref83.isOpen,
4383
+ children = _ref83.children;
4384
+ return /*#__PURE__*/wn.createElement(Wrapper, {
4385
+ isOpen: isOpen
4386
+ }, /*#__PURE__*/wn.createElement(Inner, null, children));
4387
+ };
4388
+ var Container = He.div(_templateObject51 || (_templateObject51 = _taggedTemplateLiteral(["\n height: 4px;\n background-color: ", ";\n border-radius: 3px;\n overflow: hidden;\n"])), function (_ref84) {
4389
+ var theme = _ref84.theme;
4390
+ return theme.colors.disabled;
4391
+ });
4392
+ var loading = Ue(_templateObject52 || (_templateObject52 = _taggedTemplateLiteral(["\n 0% {\n transform: translateX(-100%);\n }\n 100% {\n transform: translateX(-1%);\n }\n"])));
4393
+ var Progress = He.div(_templateObject53 || (_templateObject53 = _taggedTemplateLiteral(["\n height: 100%;\n width: 100%;\n background-color: ", ";\n animation: ", " 10s cubic-bezier(0.22, 1, 0.36, 1);\n"])), function (_ref85) {
4394
+ var theme = _ref85.theme;
4395
+ return theme.colors.primary;
4396
+ }, loading);
4397
+ var LoadingBar = function LoadingBar(_ref86) {
4398
+ var isLoading = _ref86.isLoading;
4399
+ return /*#__PURE__*/wn.createElement(Container, null, isLoading && /*#__PURE__*/wn.createElement(Progress, null));
4400
+ };
4401
+ var GAP = '8px';
4402
+ var WIDTH = '46px';
4403
+ var INPUT_HEIGHT = '46px';
4404
+ var Digit = He.div(_templateObject54 || (_templateObject54 = _taggedTemplateLiteral(["\n border: 1px solid ", ";\n border-radius: 4px;\n align-items: center;\n display: flex;\n font-size: 18px;\n justify-content: center;\n height: ", ";\n width: ", ";\n background: ", ";\n color: ", ";\n"])), function (_ref87) {
4405
+ var disabled = _ref87.disabled,
4406
+ theme = _ref87.theme;
4407
+ return disabled ? theme.colors.disabled : '#ADBCC5';
4408
+ }, INPUT_HEIGHT, WIDTH, function (_ref88) {
4409
+ var disabled = _ref88.disabled,
4410
+ theme = _ref88.theme;
4411
+ return disabled ? theme.colors.disabled : theme.inputs.backgroundColor;
4412
+ }, function (_ref89) {
4413
+ var disabled = _ref89.disabled,
4414
+ theme = _ref89.theme;
4415
+ return disabled ? theme.colors.disabledText : theme.inputs.textColor;
4416
+ });
4417
+ var digitsContainerStyles = {
4418
+ display: 'flex',
4419
+ justifyContent: 'space-between',
4420
+ gap: GAP,
4421
+ position: 'relative',
4422
+ zIndex: -1
4423
+ };
4424
+ var otpContainerStyles = {
4425
+ overflow: 'hidden',
4426
+ position: 'relative',
4427
+ textAlign: 'initial',
4428
+ zIndex: 1
4429
+ };
4430
+ var invisibleInputStyles = {
4431
+ background: 'transparent',
4432
+ border: 'none',
4433
+ color: 'transparent',
4434
+ height: INPUT_HEIGHT,
4435
+ margin: 0,
4436
+ outline: 'none',
4437
+ position: 'absolute',
4438
+ width: "calc(100% - (0.5 * ".concat(WIDTH, "))"),
4439
+ caretColor: '#ADBCC5',
4440
+ letterSpacing: "calc(".concat(WIDTH, " - 1ch + ").concat(GAP, ")"),
4441
+ paddingLeft: "calc(0.5 * ".concat(WIDTH, ")"),
4442
+ zIndex: 10
4443
+ };
4444
+ var DigitAtIndex = function DigitAtIndex(_ref90) {
4445
+ var index = _ref90.index,
4446
+ disabled = _ref90.disabled,
4447
+ otp = _ref90.otp;
4448
+ var fill = otp ? otp[index] : '';
4449
+ return /*#__PURE__*/wn.createElement(Digit, {
4450
+ disabled: disabled,
4451
+ "data-testid": "otp-".concat(index)
4452
+ }, fill);
4453
+ };
4454
+ var OTPInput = function OTPInput(_ref91) {
4455
+ var otp = _ref91.otp,
4456
+ setOtp = _ref91.setOtp,
4457
+ disabled = _ref91.disabled;
4458
+ var onPasscodeChange = function onPasscodeChange(e) {
4459
+ if (!/^\d*$/.test(e.target.value)) {
4460
+ return;
4461
+ }
4462
+ setOtp(e.target.value);
4463
+ };
4464
+ return /*#__PURE__*/wn.createElement("div", {
4465
+ style: otpContainerStyles
4466
+ }, /*#__PURE__*/wn.createElement("input", Object.assign({
4467
+ "aria-label": "One-time passcode",
4468
+ autoComplete: "one-time-code",
4469
+ autoFocus: true,
4470
+ disabled: disabled,
4471
+ style: invisibleInputStyles,
4472
+ maxLength: 6,
4473
+ onChange: onPasscodeChange,
4474
+ type: "text",
4475
+ inputMode: "numeric",
4476
+ value: otp
4477
+ }, passwordManagerDisableAutofillProps)), /*#__PURE__*/wn.createElement("div", {
4478
+ style: digitsContainerStyles
4479
+ }, _toConsumableArray(Array(6).keys()).map(function (i) {
4480
+ return /*#__PURE__*/wn.createElement(DigitAtIndex, {
4481
+ key: "digit-".concat(i),
4482
+ index: i,
4483
+ otp: otp,
4484
+ disabled: !!disabled
4485
+ });
4486
+ })));
4487
+ };
4488
+ var OTP_CODE_LENGTH = 6;
4489
+ var OTPControl = function OTPControl(_ref92) {
4490
+ var isSubmitting = _ref92.isSubmitting,
4491
+ onSubmit = _ref92.onSubmit,
4492
+ errorMessage = _ref92.errorMessage;
4493
+ var _h$27 = h$2(''),
4494
+ _h$28 = _slicedToArray(_h$27, 2),
4495
+ otp = _h$28[0],
4496
+ setOtp = _h$28[1];
4497
+ var handleOtpChange = function handleOtpChange(otp) {
4498
+ setOtp(otp);
4499
+ if (otp.length === OTP_CODE_LENGTH) {
4500
+ onSubmit(otp);
4501
+ }
4502
+ };
4503
+ return /*#__PURE__*/wn.createElement(Flex, {
4504
+ direction: "column",
4505
+ maxWidth: 316
4506
+ }, /*#__PURE__*/wn.createElement(OTPInput, {
4507
+ otp: otp,
4508
+ setOtp: handleOtpChange,
4509
+ disabled: isSubmitting
4510
+ }), /*#__PURE__*/wn.createElement(AnimatedContainer, {
4511
+ isOpen: isSubmitting
4512
+ }, /*#__PURE__*/wn.createElement(Flex, {
4513
+ direction: "column",
4514
+ gap: 8,
4515
+ marginTop: 8
4516
+ }, /*#__PURE__*/wn.createElement(Text, {
4517
+ color: "secondary",
4518
+ size: "helper"
4519
+ }, "Verifying passcode..."), /*#__PURE__*/wn.createElement(LoadingBar, {
4520
+ isLoading: isSubmitting
4521
+ }))), !isSubmitting && /*#__PURE__*/wn.createElement(ErrorText, {
4522
+ errorMessage: errorMessage !== null && errorMessage !== void 0 ? errorMessage : ''
4523
+ }));
4524
+ };
4525
+ var OTPEntry = function OTPEntry(_ref93) {
4526
+ var header = _ref93.header,
4527
+ helperContent = _ref93.helperContent,
4528
+ instruction = _ref93.instruction,
4529
+ isSubmitting = _ref93.isSubmitting,
4530
+ onSubmit = _ref93.onSubmit,
4531
+ errorMessage = _ref93.errorMessage;
4532
+ return /*#__PURE__*/wn.createElement(Flex, {
3929
4533
  direction: "column",
3930
- gap: 24,
3931
- alignItems: "center"
3932
- }, /*#__PURE__*/y(Text, {
4534
+ gap: 24
4535
+ }, /*#__PURE__*/wn.createElement(Text, {
3933
4536
  size: "header"
3934
- }, "Success!"), /*#__PURE__*/y(Text, null, "You have successfully logged in."), /*#__PURE__*/y(ConfirmationSVG, null));
4537
+ }, header), /*#__PURE__*/wn.createElement(Text, null, instruction), /*#__PURE__*/wn.createElement(OTPControl, {
4538
+ isSubmitting: isSubmitting,
4539
+ onSubmit: onSubmit,
4540
+ errorMessage: errorMessage
4541
+ }), /*#__PURE__*/wn.createElement(Text, {
4542
+ size: "helper",
4543
+ color: "secondary"
4544
+ }, helperContent));
3935
4545
  };
3936
- var useMountEffect = function useMountEffect(effect) {
3937
- var effectRef = _$1(effect);
4546
+ var getSecondsRemaining = function getSecondsRemaining(expiration) {
4547
+ var now = new Date();
4548
+ return Math.ceil((expiration.getTime() - now.getTime()) / 1000);
4549
+ };
4550
+ var ExpirationMessage = function ExpirationMessage(_ref94) {
4551
+ var expiration = _ref94.expiration,
4552
+ resendOTP = _ref94.resendOTP;
4553
+ var _h$29 = h$2(function () {
4554
+ return getSecondsRemaining(expiration);
4555
+ }),
4556
+ _h$30 = _slicedToArray(_h$29, 2),
4557
+ seconds = _h$30[0],
4558
+ setSeconds = _h$30[1];
4559
+ var codeExpired = seconds <= 0;
3938
4560
  p$1(function () {
3939
- return effectRef.current();
3940
- }, []);
4561
+ if (!codeExpired) {
4562
+ var updateSeconds = function updateSeconds() {
4563
+ return setSeconds(getSecondsRemaining(expiration));
4564
+ };
4565
+ var interval = setInterval(updateSeconds, 1000);
4566
+ updateSeconds();
4567
+ return function () {
4568
+ return clearInterval(interval);
4569
+ };
4570
+ }
4571
+ }, [codeExpired, expiration]);
4572
+ var displayMinutes = Math.floor(Number(seconds / 60));
4573
+ var displaySeconds = seconds - displayMinutes * 60;
4574
+ var formattedTime = "".concat(displayMinutes, ":").concat(displaySeconds < 10 ? "0".concat(displaySeconds) : displaySeconds);
4575
+ var formattedText = seconds > 0 ? "Your code expires in ".concat(formattedTime, ". Didn't get it? ") : 'Your code has expired. ';
4576
+ return /*#__PURE__*/wn.createElement(wn.Fragment, null, formattedText, /*#__PURE__*/wn.createElement(InlineButton, {
4577
+ onClick: resendOTP
4578
+ }, "Resend code"));
3941
4579
  };
3942
- var ConfirmationScreen = function ConfirmationScreen() {
3943
- var onEvent = useEventCallback();
3944
- useMountEffect(function () {
3945
- onEvent({
3946
- type: StytchEventType.AuthenticateFlowComplete,
3947
- data: {}
3948
- });
4580
+ var SentOTPEntry = function SentOTPEntry(_ref95) {
4581
+ var expiration = _ref95.expiration,
4582
+ formattedDestination = _ref95.formattedDestination,
4583
+ isSubmitting = _ref95.isSubmitting,
4584
+ onSubmit = _ref95.onSubmit,
4585
+ errorMessage = _ref95.errorMessage,
4586
+ resendOTP = _ref95.resendOTP;
4587
+ return /*#__PURE__*/wn.createElement(OTPEntry, {
4588
+ header: "Enter passcode",
4589
+ helperContent: /*#__PURE__*/wn.createElement(ExpirationMessage, {
4590
+ expiration: expiration,
4591
+ resendOTP: resendOTP
4592
+ }),
4593
+ instruction: /*#__PURE__*/wn.createElement(wn.Fragment, null, "A 6-digit passcode was sent to you at ", /*#__PURE__*/wn.createElement("b", null, formattedDestination), "."),
4594
+ isSubmitting: isSubmitting,
4595
+ onSubmit: onSubmit,
4596
+ errorMessage: errorMessage
3949
4597
  });
3950
- return /*#__PURE__*/y(Confirmation, null);
3951
- };
3952
- var assertUnreachable = function assertUnreachable() {
3953
- throw new Error('Assertion failure');
3954
- };
3955
- var Chevron = function Chevron() {
3956
- return /*#__PURE__*/wn.createElement("svg", {
3957
- viewBox: "0 0 25 25",
3958
- fill: "none",
3959
- xmlns: "http://www.w3.org/2000/svg"
3960
- }, /*#__PURE__*/wn.createElement("path", {
3961
- d: "M9.09 7.91L13.67 12.5L9.09 17.09L10.5 18.5L16.5 12.5L10.5 6.5L9.09 7.91Z",
3962
- fill: "currentColor"
3963
- }));
3964
4598
  };
3965
- var Chevron$1 = CreateIcon(Chevron);
3966
- var StyledButton = He.button(_templateObject46 || (_templateObject46 = _taggedTemplateLiteral(["\n all: unset;\n color: ", ";\n cursor: pointer;\n padding: 20px 0;\n border-bottom: 1px solid #e5e8eb;\n font-weight: 500;\n display: flex;\n align-items: center;\n justify-content: space-between;\n"])), function (props) {
3967
- return props.theme.colors.primary;
3968
- });
3969
- var MenuText = He.div(_templateObject47 || (_templateObject47 = _taggedTemplateLiteral(["\n flex: 1 1 auto;\n"])));
3970
- var ChevronContainer = He.span(_templateObject48 || (_templateObject48 = _taggedTemplateLiteral(["\n flex: 0 0 auto;\n"])));
3971
- var MenuButton = function MenuButton(_ref75) {
3972
- var children = _ref75.children,
3973
- onClick = _ref75.onClick;
3974
- return /*#__PURE__*/wn.createElement(StyledButton, {
3975
- type: "button",
3976
- onClick: onClick
3977
- }, /*#__PURE__*/wn.createElement(MenuText, null, children), /*#__PURE__*/wn.createElement(ChevronContainer, {
3978
- "aria-hidden": true
3979
- }, /*#__PURE__*/wn.createElement(Chevron$1, null)));
4599
+ var EmailOTPEntryScreen = function EmailOTPEntryScreen() {
4600
+ var stytchClient = useStytch();
4601
+ var config = useConfig();
4602
+ var _useGlobalReducer47 = useGlobalReducer(),
4603
+ _useGlobalReducer48 = _slicedToArray(_useGlobalReducer47, 2),
4604
+ state = _useGlobalReducer48[0],
4605
+ dispatch = _useGlobalReducer48[1];
4606
+ var codeExpiration = state.formState.otpState.codeExpiration;
4607
+ var userSuppliedEmail = state.formState.emailState.userSuppliedEmail;
4608
+ var _useEmailOtpLoginOrSi3 = useEmailOtpLoginOrSignup(),
4609
+ sendOtp = _useEmailOtpLoginOrSi3.trigger,
4610
+ isSendingOtp = _useEmailOtpLoginOrSi3.isMutating,
4611
+ sendOtpError = _useEmailOtpLoginOrSi3.error;
4612
+ var _useEmailOtpDiscovery3 = useEmailOtpDiscoverySend(),
4613
+ sendOtpDiscovery = _useEmailOtpDiscovery3.trigger,
4614
+ isSendingDiscovery = _useEmailOtpDiscovery3.isMutating,
4615
+ sendDiscoveryError = _useEmailOtpDiscovery3.error,
4616
+ resetSendDiscovery = _useEmailOtpDiscovery3.reset;
4617
+ var isSending = isSendingDiscovery || isSendingOtp;
4618
+ var sendError = sendDiscoveryError || sendOtpError;
4619
+ var _useMutate5 = useMutate('stytch.otps.email.discovery.authenticate', function (_, _ref96) {
4620
+ var _ref96$arg = _ref96.arg,
4621
+ otp = _ref96$arg.otp,
4622
+ email = _ref96$arg.email;
4623
+ return stytchClient.otps.email.discovery.authenticate({
4624
+ code: otp,
4625
+ email_address: email
4626
+ });
4627
+ }, {
4628
+ onSuccess: function onSuccess(data) {
4629
+ onDiscoveryAuthenticateSuccess(data, dispatch);
4630
+ }
4631
+ }),
4632
+ discoveryAuthenticate = _useMutate5.trigger,
4633
+ isDiscoveryAuthenticating = _useMutate5.isMutating,
4634
+ discoveryAuthenticateError = _useMutate5.error,
4635
+ resetDiscoveryAuthenticate = _useMutate5.reset;
4636
+ var _useMutate6 = useMutate('stytch.otps.email.authenticate', function (_, _ref97) {
4637
+ var _ref97$arg = _ref97.arg,
4638
+ otp = _ref97$arg.otp,
4639
+ emailAddress = _ref97$arg.emailAddress,
4640
+ organizationId = _ref97$arg.organizationId,
4641
+ sessionDurationMinutes = _ref97$arg.sessionDurationMinutes;
4642
+ return stytchClient.otps.email.authenticate({
4643
+ code: otp,
4644
+ email_address: emailAddress,
4645
+ organization_id: organizationId,
4646
+ session_duration_minutes: sessionDurationMinutes
4647
+ });
4648
+ }, {
4649
+ onSuccess: function onSuccess(data) {
4650
+ onAuthenticateSuccess(data, dispatch, config);
4651
+ }
4652
+ }),
4653
+ authenticate = _useMutate6.trigger,
4654
+ isAuthenticating = _useMutate6.isMutating,
4655
+ authenticateError = _useMutate6.error,
4656
+ resetAuthenticate = _useMutate6.reset;
4657
+ var isAuthenticatingAny = isDiscoveryAuthenticating || isAuthenticating;
4658
+ var authenticateAnyError = discoveryAuthenticateError || authenticateError;
4659
+ var errorAny = authenticateAnyError || sendError;
4660
+ var errorMessage = errorAny ? 'Invalid passcode, please try again.' : undefined;
4661
+ var resetAll = function resetAll() {
4662
+ resetDiscoveryAuthenticate();
4663
+ resetAuthenticate();
4664
+ resetSendDiscovery();
4665
+ };
4666
+ var handleSubmit = function handleSubmit(otp) {
4667
+ resetAll();
4668
+ if (state.flowState.type === AuthFlowType.Discovery) {
4669
+ discoveryAuthenticate({
4670
+ otp: otp,
4671
+ email: userSuppliedEmail
4672
+ });
4673
+ } else if (state.flowState.type === AuthFlowType.Organization && state.flowState.organization && state.formState.emailState.userSuppliedEmail) {
4674
+ authenticate({
4675
+ otp: otp,
4676
+ emailAddress: state.formState.emailState.userSuppliedEmail,
4677
+ organizationId: state.flowState.organization.organization_id,
4678
+ sessionDurationMinutes: config.sessionOptions.sessionDurationMinutes
4679
+ });
4680
+ }
4681
+ };
4682
+ var handleResendOTP = function handleResendOTP() {
4683
+ resetAll();
4684
+ if (!isSending) {
4685
+ if (state.flowState.type === AuthFlowType.Discovery) {
4686
+ sendOtpDiscovery({
4687
+ email: userSuppliedEmail
4688
+ });
4689
+ } else if (state.flowState.type === AuthFlowType.Organization && state.flowState.organization) {
4690
+ sendOtp({
4691
+ email: userSuppliedEmail,
4692
+ organization_id: state.flowState.organization.organization_id
4693
+ });
4694
+ }
4695
+ }
4696
+ };
4697
+ var handleBack = function handleBack() {
4698
+ dispatch({
4699
+ type: 'navigate_back'
4700
+ });
4701
+ };
4702
+ return /*#__PURE__*/wn.createElement(Flex, {
4703
+ direction: "column",
4704
+ gap: 24
4705
+ }, /*#__PURE__*/wn.createElement(BackArrow, {
4706
+ onClick: handleBack
4707
+ }), codeExpiration !== null ? ( /*#__PURE__*/wn.createElement(SentOTPEntry, {
4708
+ isSubmitting: isAuthenticatingAny,
4709
+ onSubmit: handleSubmit,
4710
+ errorMessage: errorMessage,
4711
+ expiration: codeExpiration,
4712
+ formattedDestination: userSuppliedEmail,
4713
+ resendOTP: handleResendOTP
4714
+ })) : ( /*#__PURE__*/wn.createElement(LoadingScreen, null)));
3980
4715
  };
3981
4716
  var mfaOptions = _defineProperty(_defineProperty({}, B2BMFAProducts.totp, {
3982
4717
  label: 'Use an authenticator app'
@@ -3987,10 +4722,10 @@ var MFAEnrollmentSelectionScreen = function MFAEnrollmentSelectionScreen() {
3987
4722
  var _useConfig = useConfig(),
3988
4723
  mfaProductInclude = _useConfig.mfaProductInclude,
3989
4724
  mfaProductOrder = _useConfig.mfaProductOrder;
3990
- var _useGlobalReducer37 = useGlobalReducer(),
3991
- _useGlobalReducer38 = _slicedToArray(_useGlobalReducer37, 2),
3992
- state = _useGlobalReducer38[0],
3993
- dispatch = _useGlobalReducer38[1];
4725
+ var _useGlobalReducer49 = useGlobalReducer(),
4726
+ _useGlobalReducer50 = _slicedToArray(_useGlobalReducer49, 2),
4727
+ state = _useGlobalReducer50[0],
4728
+ dispatch = _useGlobalReducer50[1];
3994
4729
  var organizationMfaOptionsSupported = state.mfa.primaryInfo.organizationMfaOptionsSupported;
3995
4730
  var handleChooseMethod = function handleChooseMethod(method) {
3996
4731
  dispatch({
@@ -4029,9 +4764,9 @@ var MFAEnrollmentSelectionScreen = function MFAEnrollmentSelectionScreen() {
4029
4764
  size: "header"
4030
4765
  }, "Set up Multi-Factor Authentication"), /*#__PURE__*/wn.createElement(Text, null, "Your organization requires an additional form of verification to make your account more secure."), /*#__PURE__*/wn.createElement(Flex, {
4031
4766
  direction: "column"
4032
- }, displayOptions.map(function (_ref76) {
4033
- var option = _ref76.option,
4034
- label = _ref76.label;
4767
+ }, displayOptions.map(function (_ref98) {
4768
+ var option = _ref98.option,
4769
+ label = _ref98.label;
4035
4770
  return /*#__PURE__*/wn.createElement(MenuButton, {
4036
4771
  key: option,
4037
4772
  onClick: function onClick() {
@@ -4053,13 +4788,13 @@ var inboxLinks = function inboxLinks(emailDomain) {
4053
4788
  OUTLOOK: 'https://outlook.office.com/mail/0/inbox'
4054
4789
  };
4055
4790
  };
4056
- var Link = He.a(_templateObject49 || (_templateObject49 = _taggedTemplateLiteral(["\n all: unset;\n cursor: pointer;\n\n &:hover {\n text-decoration: underline;\n text-decoration-color: ", ";\n }\n"])), function (props) {
4791
+ var Link = He.a(_templateObject55 || (_templateObject55 = _taggedTemplateLiteral(["\n all: unset;\n cursor: pointer;\n\n &:hover {\n text-decoration: underline;\n text-decoration-color: ", ";\n }\n"])), function (props) {
4057
4792
  return props.theme.colors.primary;
4058
4793
  });
4059
- var EmailProviderLink = function EmailProviderLink(_ref77) {
4060
- var label = _ref77.label,
4061
- href = _ref77.href,
4062
- Icon = _ref77.Icon;
4794
+ var EmailProviderLink = function EmailProviderLink(_ref99) {
4795
+ var label = _ref99.label,
4796
+ href = _ref99.href,
4797
+ Icon = _ref99.Icon;
4063
4798
  return /*#__PURE__*/wn.createElement(Flex, {
4064
4799
  gap: 4
4065
4800
  }, Icon, /*#__PURE__*/wn.createElement(Link, {
@@ -4068,16 +4803,16 @@ var EmailProviderLink = function EmailProviderLink(_ref77) {
4068
4803
  rel: "noopener noreferrer"
4069
4804
  }, /*#__PURE__*/wn.createElement(Text, null, "Open in ", label)));
4070
4805
  };
4071
- var VerifyEmailConfirmation = function VerifyEmailConfirmation(_ref78) {
4072
- var emailDomain = _ref78.emailDomain,
4073
- reset = _ref78.reset,
4074
- email = _ref78.email;
4806
+ var VerifyEmailConfirmation = function VerifyEmailConfirmation(_ref100) {
4807
+ var emailDomain = _ref100.emailDomain,
4808
+ reset = _ref100.reset,
4809
+ email = _ref100.email;
4075
4810
  var _inboxLinks = inboxLinks(emailDomain),
4076
4811
  GMAIL = _inboxLinks.GMAIL,
4077
4812
  OUTLOOK = _inboxLinks.OUTLOOK;
4078
- var _useGlobalReducer39 = useGlobalReducer(),
4079
- _useGlobalReducer40 = _slicedToArray(_useGlobalReducer39, 2),
4080
- dispatch = _useGlobalReducer40[1];
4813
+ var _useGlobalReducer51 = useGlobalReducer(),
4814
+ _useGlobalReducer52 = _slicedToArray(_useGlobalReducer51, 2),
4815
+ dispatch = _useGlobalReducer52[1];
4081
4816
  return /*#__PURE__*/wn.createElement(Flex, {
4082
4817
  direction: "column",
4083
4818
  gap: 24
@@ -4117,17 +4852,17 @@ var useEmailDomain = function useEmailDomain() {
4117
4852
  var _a, _b;
4118
4853
  var stytch = useStytch();
4119
4854
  var config = useConfig();
4120
- var _h$27 = h$2(function () {
4855
+ var _h$31 = h$2(function () {
4121
4856
  var _readB2BInternals$boo2 = readB2BInternals(stytch).bootstrap.getSync(),
4122
4857
  emailDomains = _readB2BInternals$boo2.emailDomains;
4123
4858
  return emailDomains;
4124
4859
  }),
4125
- _h$28 = _slicedToArray(_h$27, 2),
4126
- emailDomains = _h$28[0],
4127
- setEmailDomains = _h$28[1];
4860
+ _h$32 = _slicedToArray(_h$31, 2),
4861
+ emailDomains = _h$32[0],
4862
+ setEmailDomains = _h$32[1];
4128
4863
  p$1(function () {
4129
- readB2BInternals(stytch).bootstrap.getAsync().then(function (_ref79) {
4130
- var emailDomains = _ref79.emailDomains;
4864
+ readB2BInternals(stytch).bootstrap.getAsync().then(function (_ref101) {
4865
+ var emailDomains = _ref101.emailDomains;
4131
4866
  setEmailDomains(emailDomains);
4132
4867
  });
4133
4868
  }, [stytch]);
@@ -4140,14 +4875,14 @@ var useEmailDomain = function useEmailDomain() {
4140
4875
  return null;
4141
4876
  };
4142
4877
  var PasswordResetConfirmation = function PasswordResetConfirmation() {
4143
- var _useGlobalReducer41 = useGlobalReducer(),
4144
- _useGlobalReducer42 = _slicedToArray(_useGlobalReducer41, 2),
4145
- state = _useGlobalReducer42[0],
4146
- dispatch = _useGlobalReducer42[1];
4878
+ var _useGlobalReducer53 = useGlobalReducer(),
4879
+ _useGlobalReducer54 = _slicedToArray(_useGlobalReducer53, 2),
4880
+ state = _useGlobalReducer54[0],
4881
+ dispatch = _useGlobalReducer54[1];
4147
4882
  var emailDomain = useEmailDomain();
4148
4883
  var reset = function reset() {
4149
4884
  dispatch({
4150
- type: 'set_magic_link_email',
4885
+ type: 'set_user_supplied_email',
4151
4886
  email: ''
4152
4887
  });
4153
4888
  dispatch({
@@ -4161,11 +4896,11 @@ var PasswordResetConfirmation = function PasswordResetConfirmation() {
4161
4896
  email: state.formState.passwordState.email
4162
4897
  });
4163
4898
  };
4164
- var Block = He.div(_templateObject50 || (_templateObject50 = _taggedTemplateLiteral(["\n height: 4px;\n width: 25%;\n background-color: ", ";\n"])), function (props) {
4899
+ var Block = He.div(_templateObject56 || (_templateObject56 = _taggedTemplateLiteral(["\n height: 4px;\n width: 25%;\n background-color: ", ";\n"])), function (props) {
4165
4900
  return props.$bgColor;
4166
4901
  });
4167
- var PasswordStrengthCheck = function PasswordStrengthCheck(_ref80) {
4168
- var score = _ref80.score;
4902
+ var PasswordStrengthCheck = function PasswordStrengthCheck(_ref102) {
4903
+ var score = _ref102.score;
4169
4904
  var blocks = [];
4170
4905
  switch (score) {
4171
4906
  case 0:
@@ -4270,76 +5005,76 @@ var removeStytchParams = function removeStytchParams(value) {
4270
5005
  params["delete"]('stytch_token_type');
4271
5006
  return url;
4272
5007
  };
4273
- var Form = He.form(_templateObject51 || (_templateObject51 = _taggedTemplateLiteral(["\n width: 100%;\n"])));
5008
+ var Form = He.form(_templateObject57 || (_templateObject57 = _taggedTemplateLiteral(["\n width: 100%;\n"])));
4274
5009
  var PasswordResetForm = function PasswordResetForm() {
4275
5010
  var stytchClient = useStytch();
4276
5011
  var config = useConfig();
4277
- var _useGlobalReducer43 = useGlobalReducer(),
4278
- _useGlobalReducer44 = _slicedToArray(_useGlobalReducer43, 2),
4279
- dispatch = _useGlobalReducer44[1];
5012
+ var _useGlobalReducer55 = useGlobalReducer(),
5013
+ _useGlobalReducer56 = _slicedToArray(_useGlobalReducer55, 2),
5014
+ dispatch = _useGlobalReducer56[1];
4280
5015
  var onEvent = useEventCallback();
4281
5016
  var onError = useErrorCallback();
4282
- var _h$29 = h$2(''),
4283
- _h$30 = _slicedToArray(_h$29, 2),
4284
- resetTokenType = _h$30[0],
4285
- setResetTokenType = _h$30[1];
4286
- var _h$31 = h$2(''),
4287
- _h$32 = _slicedToArray(_h$31, 2),
4288
- resetToken = _h$32[0],
4289
- setResetToken = _h$32[1];
4290
- var dataLayer = readB2BInternals(stytchClient).dataLayer;
4291
- var email = dataLayer.getItem('reset-email-value');
4292
5017
  var _h$33 = h$2(''),
4293
5018
  _h$34 = _slicedToArray(_h$33, 2),
4294
- password = _h$34[0],
4295
- setPassword = _h$34[1];
5019
+ resetTokenType = _h$34[0],
5020
+ setResetTokenType = _h$34[1];
4296
5021
  var _h$35 = h$2(''),
4297
5022
  _h$36 = _slicedToArray(_h$35, 2),
4298
- errorMessage = _h$36[0],
4299
- setErrorMessage = _h$36[1];
4300
- var _h$37 = h$2(0),
5023
+ resetToken = _h$36[0],
5024
+ setResetToken = _h$36[1];
5025
+ var dataLayer = readB2BInternals(stytchClient).dataLayer;
5026
+ var email = dataLayer.getItem('reset-email-value');
5027
+ var _h$37 = h$2(''),
4301
5028
  _h$38 = _slicedToArray(_h$37, 2),
4302
- passwordScore = _h$38[0],
4303
- setPasswordScore = _h$38[1];
5029
+ password = _h$38[0],
5030
+ setPassword = _h$38[1];
4304
5031
  var _h$39 = h$2(''),
4305
5032
  _h$40 = _slicedToArray(_h$39, 2),
4306
- passwordFeedback = _h$40[0],
4307
- setPasswordFeedback = _h$40[1];
4308
- var _h$41 = h$2(true),
5033
+ errorMessage = _h$40[0],
5034
+ setErrorMessage = _h$40[1];
5035
+ var _h$41 = h$2(0),
4309
5036
  _h$42 = _slicedToArray(_h$41, 2),
4310
- invalidPassword = _h$42[0],
4311
- setInvalidPassword = _h$42[1];
4312
- var _h$43 = h$2(false),
5037
+ passwordScore = _h$42[0],
5038
+ setPasswordScore = _h$42[1];
5039
+ var _h$43 = h$2(''),
4313
5040
  _h$44 = _slicedToArray(_h$43, 2),
4314
- isSubmitting = _h$44[0],
4315
- setIsSubmitting = _h$44[1];
4316
- var _h$45 = h$2('none'),
5041
+ passwordFeedback = _h$44[0],
5042
+ setPasswordFeedback = _h$44[1];
5043
+ var _h$45 = h$2(true),
4317
5044
  _h$46 = _slicedToArray(_h$45, 2),
4318
- strengthPolicy = _h$46[0],
4319
- setStrengthPolicy = _h$46[1];
4320
- var _h$47 = h$2(0),
5045
+ invalidPassword = _h$46[0],
5046
+ setInvalidPassword = _h$46[1];
5047
+ var _h$47 = h$2(false),
4321
5048
  _h$48 = _slicedToArray(_h$47, 2),
4322
- missingCharacters = _h$48[0],
4323
- setMissingCharacters = _h$48[1];
4324
- var _h$49 = h$2(0),
5049
+ isSubmitting = _h$48[0],
5050
+ setIsSubmitting = _h$48[1];
5051
+ var _h$49 = h$2('none'),
4325
5052
  _h$50 = _slicedToArray(_h$49, 2),
4326
- missingComplexity = _h$50[0],
4327
- setMissingComplexity = _h$50[1];
4328
- var _h$51 = h$2(false),
5053
+ strengthPolicy = _h$50[0],
5054
+ setStrengthPolicy = _h$50[1];
5055
+ var _h$51 = h$2(0),
4329
5056
  _h$52 = _slicedToArray(_h$51, 2),
4330
- isPasswordBreached = _h$52[0],
4331
- setIsPasswordBreached = _h$52[1];
5057
+ missingCharacters = _h$52[0],
5058
+ setMissingCharacters = _h$52[1];
5059
+ var _h$53 = h$2(0),
5060
+ _h$54 = _slicedToArray(_h$53, 2),
5061
+ missingComplexity = _h$54[0],
5062
+ setMissingComplexity = _h$54[1];
5063
+ var _h$55 = h$2(false),
5064
+ _h$56 = _slicedToArray(_h$55, 2),
5065
+ isPasswordBreached = _h$56[0],
5066
+ setIsPasswordBreached = _h$56[1];
4332
5067
  var updateStrengthCheck = F$1(function () {
4333
5068
  return debounce(function (password) {
4334
5069
  return stytchClient.passwords.strengthCheck({
4335
5070
  password: password
4336
- }).then(function (_ref81) {
4337
- var score = _ref81.score,
4338
- valid_password = _ref81.valid_password,
4339
- zxcvbn_feedback = _ref81.zxcvbn_feedback,
4340
- luds_feedback = _ref81.luds_feedback,
4341
- strength_policy = _ref81.strength_policy,
4342
- breached_password = _ref81.breached_password;
5071
+ }).then(function (_ref103) {
5072
+ var score = _ref103.score,
5073
+ valid_password = _ref103.valid_password,
5074
+ zxcvbn_feedback = _ref103.zxcvbn_feedback,
5075
+ luds_feedback = _ref103.luds_feedback,
5076
+ strength_policy = _ref103.strength_policy,
5077
+ breached_password = _ref103.breached_password;
4343
5078
  setStrengthPolicy(strength_policy);
4344
5079
  setInvalidPassword(!valid_password);
4345
5080
  if (strength_policy === 'zxcvbn') {
@@ -4412,6 +5147,35 @@ var PasswordResetForm = function PasswordResetForm() {
4412
5147
  setErrorMessage(message);
4413
5148
  setIsSubmitting(false);
4414
5149
  });
5150
+ } else if (resetTokenType == 'discovery') {
5151
+ stytchClient.passwords.discovery.resetByEmail({
5152
+ password_reset_token: resetToken,
5153
+ password: password
5154
+ }).then(function (data) {
5155
+ setIsSubmitting(false);
5156
+ onEvent({
5157
+ type: StytchEventType.B2BDiscoveryPasswordReset,
5158
+ data: data
5159
+ });
5160
+ dispatch({
5161
+ type: 'transition',
5162
+ screen: AppScreens$1.Discovery
5163
+ });
5164
+ dispatch({
5165
+ type: 'set_discovery_state',
5166
+ email: data.email_address,
5167
+ discoveredOrganizations: data.discovered_organizations,
5168
+ intermediateSessionToken: data.intermediate_session_token
5169
+ });
5170
+ })["catch"](function (e) {
5171
+ onError(e);
5172
+ var message = e.message;
5173
+ if (e instanceof StytchAPIError) {
5174
+ message = e.error_message;
5175
+ }
5176
+ setErrorMessage(message);
5177
+ setIsSubmitting(false);
5178
+ });
4415
5179
  } else {
4416
5180
  stytchClient.passwords.resetBySession({
4417
5181
  password: password
@@ -4483,9 +5247,9 @@ var PasswordResetForm = function PasswordResetForm() {
4483
5247
  }))));
4484
5248
  };
4485
5249
  var PasswordSetNew = function PasswordSetNew() {
4486
- var _useGlobalReducer45 = useGlobalReducer(),
4487
- _useGlobalReducer46 = _slicedToArray(_useGlobalReducer45, 2),
4488
- dispatch = _useGlobalReducer46[1];
5250
+ var _useGlobalReducer57 = useGlobalReducer(),
5251
+ _useGlobalReducer58 = _slicedToArray(_useGlobalReducer57, 2),
5252
+ dispatch = _useGlobalReducer58[1];
4489
5253
  var onEvent = useEventCallback();
4490
5254
  var config = useConfig();
4491
5255
  var _usePasswordInput3 = usePasswordInput(),
@@ -4494,28 +5258,42 @@ var PasswordSetNew = function PasswordSetNew() {
4494
5258
  email = _usePasswordInput3.email,
4495
5259
  organization = _usePasswordInput3.organization,
4496
5260
  setIsSubmitting = _usePasswordInput3.setIsSubmitting;
4497
- if (!organization) {
4498
- return /*#__PURE__*/wn.createElement(wn.Fragment, null);
4499
- }
4500
5261
  var resendResetPassword = function resendResetPassword() {
4501
- var _a, _b, _c, _d;
4502
- stytch.passwords.resetByEmailStart({
4503
- email_address: email,
4504
- organization_id: organization.organization_id,
4505
- login_redirect_url: (_a = config.emailMagicLinksOptions) === null || _a === void 0 ? void 0 : _a.loginTemplateId,
4506
- reset_password_redirect_url: (_b = config.passwordOptions) === null || _b === void 0 ? void 0 : _b.resetPasswordRedirectURL,
4507
- reset_password_expiration_minutes: (_c = config.passwordOptions) === null || _c === void 0 ? void 0 : _c.resetPasswordExpirationMinutes,
4508
- reset_password_template_id: (_d = config.passwordOptions) === null || _d === void 0 ? void 0 : _d.resetPasswordTemplateId
4509
- }).then(function (data) {
4510
- _t.success('Email resent');
4511
- setIsSubmitting(false);
4512
- onEvent({
4513
- type: StytchEventType.B2BPasswordResetByEmailStart,
4514
- data: data
5262
+ var _a, _b, _c, _d, _e, _f, _g, _h;
5263
+ if (!organization) {
5264
+ stytch.passwords.discovery.resetByEmailStart({
5265
+ email_address: email,
5266
+ discovery_redirect_url: (_a = config.emailMagicLinksOptions) === null || _a === void 0 ? void 0 : _a.loginRedirectURL,
5267
+ reset_password_redirect_url: (_b = config.passwordOptions) === null || _b === void 0 ? void 0 : _b.resetPasswordRedirectURL,
5268
+ reset_password_expiration_minutes: (_c = config.passwordOptions) === null || _c === void 0 ? void 0 : _c.resetPasswordExpirationMinutes,
5269
+ reset_password_template_id: (_d = config.passwordOptions) === null || _d === void 0 ? void 0 : _d.resetPasswordTemplateId
5270
+ }).then(function (data) {
5271
+ _t.success('Email resent');
5272
+ setIsSubmitting(false);
5273
+ onEvent({
5274
+ type: StytchEventType.B2BPasswordDiscoveryResetStart,
5275
+ data: data
5276
+ });
4515
5277
  });
4516
- })["catch"](function (e) {
4517
- onError(e);
4518
- });
5278
+ } else {
5279
+ stytch.passwords.resetByEmailStart({
5280
+ email_address: email,
5281
+ organization_id: organization.organization_id,
5282
+ login_redirect_url: (_e = config.emailMagicLinksOptions) === null || _e === void 0 ? void 0 : _e.loginTemplateId,
5283
+ reset_password_redirect_url: (_f = config.passwordOptions) === null || _f === void 0 ? void 0 : _f.resetPasswordRedirectURL,
5284
+ reset_password_expiration_minutes: (_g = config.passwordOptions) === null || _g === void 0 ? void 0 : _g.resetPasswordExpirationMinutes,
5285
+ reset_password_template_id: (_h = config.passwordOptions) === null || _h === void 0 ? void 0 : _h.resetPasswordTemplateId
5286
+ }).then(function (data) {
5287
+ _t.success('Email resent');
5288
+ setIsSubmitting(false);
5289
+ onEvent({
5290
+ type: StytchEventType.B2BPasswordResetByEmailStart,
5291
+ data: data
5292
+ });
5293
+ })["catch"](function (e) {
5294
+ onError(e);
5295
+ });
5296
+ }
4519
5297
  };
4520
5298
  return /*#__PURE__*/wn.createElement(Flex, {
4521
5299
  direction: "column",
@@ -4541,9 +5319,9 @@ var PasswordSetNew = function PasswordSetNew() {
4541
5319
  }, "Resend email"))));
4542
5320
  };
4543
5321
  var PasswordsForgotForm = function PasswordsForgotForm() {
4544
- var _useGlobalReducer47 = useGlobalReducer(),
4545
- _useGlobalReducer48 = _slicedToArray(_useGlobalReducer47, 2),
4546
- dispatch = _useGlobalReducer48[1];
5322
+ var _useGlobalReducer59 = useGlobalReducer(),
5323
+ _useGlobalReducer60 = _slicedToArray(_useGlobalReducer59, 2),
5324
+ dispatch = _useGlobalReducer60[1];
4547
5325
  var config = useConfig();
4548
5326
  var onEvent = useEventCallback();
4549
5327
  var passwordOptions = config.passwordOptions;
@@ -4558,9 +5336,9 @@ var PasswordsForgotForm = function PasswordsForgotForm() {
4558
5336
  setIsSubmitting = _usePasswordInput4.setIsSubmitting,
4559
5337
  handleNonMemberReset = _usePasswordInput4.handleNonMemberReset;
4560
5338
  if (!passwordOptions) return /*#__PURE__*/wn.createElement(wn.Fragment, null);
4561
- if (!organization) return /*#__PURE__*/wn.createElement(wn.Fragment, null);
4562
5339
  var handleSubmit = function handleSubmit(e) {
4563
5340
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
5341
+ var _a, _b, _c, _d;
4564
5342
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
4565
5343
  while (1) switch (_context7.prev = _context7.next) {
4566
5344
  case 0:
@@ -4574,26 +5352,56 @@ var PasswordsForgotForm = function PasswordsForgotForm() {
4574
5352
  case 4:
4575
5353
  setErrorMessage('');
4576
5354
  setIsSubmitting(true);
4577
- readB2BInternals(stytch).searchManager.searchMember(email, organization.organization_id).then(function (_ref82) {
4578
- var member = _ref82.member;
4579
- var _a, _b, _c, _d;
4580
- if (!(member === null || member === void 0 ? void 0 : member.member_password_id)) {
4581
- handleNonMemberReset();
4582
- return;
4583
- }
4584
- stytch.passwords.resetByEmailStart({
5355
+ if (organization) {
5356
+ readB2BInternals(stytch).searchManager.searchMember(email, organization.organization_id).then(function (_ref104) {
5357
+ var member = _ref104.member;
5358
+ var _a, _b, _c, _d;
5359
+ if (!(member === null || member === void 0 ? void 0 : member.member_password_id)) {
5360
+ handleNonMemberReset();
5361
+ return;
5362
+ }
5363
+ stytch.passwords.resetByEmailStart({
5364
+ email_address: email,
5365
+ organization_id: organization.organization_id,
5366
+ login_redirect_url: (_a = config.emailMagicLinksOptions) === null || _a === void 0 ? void 0 : _a.loginRedirectURL,
5367
+ reset_password_redirect_url: (_b = config.passwordOptions) === null || _b === void 0 ? void 0 : _b.resetPasswordRedirectURL,
5368
+ reset_password_expiration_minutes: (_c = config.passwordOptions) === null || _c === void 0 ? void 0 : _c.resetPasswordExpirationMinutes,
5369
+ reset_password_template_id: (_d = config.passwordOptions) === null || _d === void 0 ? void 0 : _d.resetPasswordTemplateId
5370
+ }).then(function (data) {
5371
+ setIsSubmitting(false);
5372
+ onEvent({
5373
+ type: StytchEventType.B2BPasswordResetByEmailStart,
5374
+ data: data
5375
+ });
5376
+ dispatch({
5377
+ type: 'set_password_state',
5378
+ email: email
5379
+ });
5380
+ dispatch({
5381
+ type: 'transition',
5382
+ screen: AppScreens$1.PasswordSetNewConfirmation
5383
+ });
5384
+ })["catch"](function (err) {
5385
+ setIsSubmitting(false);
5386
+ setErrorMessage(err.error_message);
5387
+ });
5388
+ })["catch"](function (err) {
5389
+ setIsSubmitting(false);
5390
+ var message = err.message;
5391
+ if (err instanceof StytchAPIError) {
5392
+ message = err.error_message;
5393
+ }
5394
+ setErrorMessage(message);
5395
+ });
5396
+ } else {
5397
+ stytch.passwords.discovery.resetByEmailStart({
4585
5398
  email_address: email,
4586
- organization_id: organization.organization_id,
4587
- login_redirect_url: (_a = config.emailMagicLinksOptions) === null || _a === void 0 ? void 0 : _a.loginRedirectURL,
5399
+ discovery_redirect_url: (_a = config.emailMagicLinksOptions) === null || _a === void 0 ? void 0 : _a.loginRedirectURL,
4588
5400
  reset_password_redirect_url: (_b = config.passwordOptions) === null || _b === void 0 ? void 0 : _b.resetPasswordRedirectURL,
4589
5401
  reset_password_expiration_minutes: (_c = config.passwordOptions) === null || _c === void 0 ? void 0 : _c.resetPasswordExpirationMinutes,
4590
5402
  reset_password_template_id: (_d = config.passwordOptions) === null || _d === void 0 ? void 0 : _d.resetPasswordTemplateId
4591
- }).then(function (data) {
5403
+ }).then(function () {
4592
5404
  setIsSubmitting(false);
4593
- onEvent({
4594
- type: StytchEventType.B2BPasswordResetByEmailStart,
4595
- data: data
4596
- });
4597
5405
  dispatch({
4598
5406
  type: 'set_password_state',
4599
5407
  email: email
@@ -4606,14 +5414,7 @@ var PasswordsForgotForm = function PasswordsForgotForm() {
4606
5414
  setIsSubmitting(false);
4607
5415
  setErrorMessage(err.error_message);
4608
5416
  });
4609
- })["catch"](function (err) {
4610
- setIsSubmitting(false);
4611
- var message = err.message;
4612
- if (err instanceof StytchAPIError) {
4613
- message = err.error_message;
4614
- }
4615
- setErrorMessage(message);
4616
- });
5417
+ }
4617
5418
  case 7:
4618
5419
  case "end":
4619
5420
  return _context7.stop();
@@ -4635,7 +5436,7 @@ var PasswordsForgotForm = function PasswordsForgotForm() {
4635
5436
  }
4636
5437
  }), /*#__PURE__*/wn.createElement(Text, {
4637
5438
  size: "header"
4638
- }, "Check your email for help signing in!"), /*#__PURE__*/wn.createElement(Text, null, "We'll email you a login link to sign in to your account directly or reset your password if you have one."), /*#__PURE__*/wn.createElement(Flex, {
5439
+ }, "Check your email for help signing in!"), /*#__PURE__*/wn.createElement(Text, null, !organization ? "We'll email you a login link to sign up for an account or reset your password if you have one." : "We'll email you a login link to sign in to your account directly or reset your password if you have one."), /*#__PURE__*/wn.createElement(Flex, {
4639
5440
  direction: "column",
4640
5441
  gap: 4
4641
5442
  }, /*#__PURE__*/wn.createElement(Text, {
@@ -4655,23 +5456,23 @@ var RecoveryCodeEntryScreen = function RecoveryCodeEntryScreen() {
4655
5456
  var stytchClient = useStytch();
4656
5457
  var _useConfig2 = useConfig(),
4657
5458
  sessionDurationMinutes = _useConfig2.sessionOptions.sessionDurationMinutes;
4658
- var _useGlobalReducer49 = useGlobalReducer(),
4659
- _useGlobalReducer50 = _slicedToArray(_useGlobalReducer49, 2),
4660
- state = _useGlobalReducer50[0],
4661
- dispatch = _useGlobalReducer50[1];
5459
+ var _useGlobalReducer61 = useGlobalReducer(),
5460
+ _useGlobalReducer62 = _slicedToArray(_useGlobalReducer61, 2),
5461
+ state = _useGlobalReducer62[0],
5462
+ dispatch = _useGlobalReducer62[1];
4662
5463
  var _state$mfa$primaryInf = state.mfa.primaryInfo,
4663
5464
  memberId = _state$mfa$primaryInf.memberId,
4664
5465
  organizationId = _state$mfa$primaryInf.organizationId;
4665
- var _h$53 = h$2(''),
4666
- _h$54 = _slicedToArray(_h$53, 2),
4667
- recoveryCode = _h$54[0],
4668
- setRecoveryCode = _h$54[1];
4669
- var _useMutate7 = useMutate('stytch.recoveryCodes.recover', function (_, _ref83) {
4670
- var _ref83$arg = _ref83.arg,
4671
- recoveryCode = _ref83$arg.recoveryCode,
4672
- memberId = _ref83$arg.memberId,
4673
- organizationId = _ref83$arg.organizationId,
4674
- sessionDurationMinutes = _ref83$arg.sessionDurationMinutes;
5466
+ var _h$57 = h$2(''),
5467
+ _h$58 = _slicedToArray(_h$57, 2),
5468
+ recoveryCode = _h$58[0],
5469
+ setRecoveryCode = _h$58[1];
5470
+ var _useMutate7 = useMutate('stytch.recoveryCodes.recover', function (_, _ref105) {
5471
+ var _ref105$arg = _ref105.arg,
5472
+ recoveryCode = _ref105$arg.recoveryCode,
5473
+ memberId = _ref105$arg.memberId,
5474
+ organizationId = _ref105$arg.organizationId,
5475
+ sessionDurationMinutes = _ref105$arg.sessionDurationMinutes;
4675
5476
  return stytchClient.recoveryCodes.recover({
4676
5477
  recovery_code: recoveryCode,
4677
5478
  member_id: memberId,
@@ -4741,8 +5542,8 @@ var RecoveryCodeEntryScreen = function RecoveryCodeEntryScreen() {
4741
5542
  isSubmitting: isSubmitting
4742
5543
  })));
4743
5544
  };
4744
- var InsetContainer = He.div(_templateObject52 || (_templateObject52 = _taggedTemplateLiteral(["\n background-color: #f3f5f6;\n color: #000;\n font-size: 16px;\n line-height: 28px;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n gap: 8px;\n padding: 16px 8px;\n"])));
4745
- var CodeList = He.ul(_templateObject53 || (_templateObject53 = _taggedTemplateLiteral(["\n list-style: none;\n padding: 0;\n margin: 0;\n"])));
5545
+ var InsetContainer = He.div(_templateObject58 || (_templateObject58 = _taggedTemplateLiteral(["\n background-color: #f3f5f6;\n color: #000;\n font-size: 16px;\n line-height: 28px;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n gap: 8px;\n padding: 16px 8px;\n"])));
5546
+ var CodeList = He.ul(_templateObject59 || (_templateObject59 = _taggedTemplateLiteral(["\n list-style: none;\n padding: 0;\n margin: 0;\n"])));
4746
5547
  var downloadFile = function downloadFile(content, filename) {
4747
5548
  var blob = new Blob([content], {
4748
5549
  type: 'text/plain'
@@ -4755,10 +5556,10 @@ var downloadFile = function downloadFile(content, filename) {
4755
5556
  URL.revokeObjectURL(url);
4756
5557
  };
4757
5558
  var RecoveryCodeSaveScreen = function RecoveryCodeSaveScreen() {
4758
- var _useGlobalReducer51 = useGlobalReducer(),
4759
- _useGlobalReducer52 = _slicedToArray(_useGlobalReducer51, 2),
4760
- state = _useGlobalReducer52[0],
4761
- dispatch = _useGlobalReducer52[1];
5559
+ var _useGlobalReducer63 = useGlobalReducer(),
5560
+ _useGlobalReducer64 = _slicedToArray(_useGlobalReducer63, 2),
5561
+ state = _useGlobalReducer64[0],
5562
+ dispatch = _useGlobalReducer64[1];
4762
5563
  var recoveryCodes = state.mfa.totp.enrollment.recoveryCodes;
4763
5564
  var handleContinue = function handleContinue() {
4764
5565
  dispatch({
@@ -4816,7 +5617,7 @@ var RecoveryCodeSaveScreen = function RecoveryCodeSaveScreen() {
4816
5617
  onClick: handleContinue
4817
5618
  }, "Done"));
4818
5619
  };
4819
- var Select = He.select(_templateObject54 || (_templateObject54 = _taggedTemplateLiteral(["\n background-color: ", ";\n border: 1px solid ", ";\n border-radius: ", ";\n height: 47px;\n box-sizing: border-box;\n padding: 0 8px;\n color: ", ";\n font-family: ", ";\n width: 80px;\n font-size: 18px;\n"])), function (props) {
5620
+ var Select = He.select(_templateObject60 || (_templateObject60 = _taggedTemplateLiteral(["\n background-color: ", ";\n border: 1px solid ", ";\n border-radius: ", ";\n height: 47px;\n box-sizing: border-box;\n padding: 0 8px;\n color: ", ";\n font-family: ", ";\n width: 80px;\n font-size: 18px;\n"])), function (props) {
4820
5621
  return props.theme.inputs.backgroundColor;
4821
5622
  }, function (props) {
4822
5623
  return props.theme.inputs.borderColor;
@@ -4827,9 +5628,9 @@ var Select = He.select(_templateObject54 || (_templateObject54 = _taggedTemplate
4827
5628
  }, function (props) {
4828
5629
  return props.theme.typography.fontFamily;
4829
5630
  });
4830
- var CountrySelector = function CountrySelector(_ref84) {
4831
- var country = _ref84.country,
4832
- setCountry = _ref84.setCountry;
5631
+ var CountrySelector = function CountrySelector(_ref106) {
5632
+ var country = _ref106.country,
5633
+ setCountry = _ref106.setCountry;
4833
5634
  var countryFormatter = new Intl.DisplayNames(['en'], {
4834
5635
  type: 'region'
4835
5636
  });
@@ -4840,24 +5641,24 @@ var CountrySelector = function CountrySelector(_ref84) {
4840
5641
  onChange: function onChange(e) {
4841
5642
  setCountry(e.target.value);
4842
5643
  }
4843
- }, Object.entries(COUNTRIES_LIST).map(function (_ref85) {
4844
- var _ref86 = _slicedToArray(_ref85, 2),
4845
- countryCode = _ref86[0],
4846
- countryNumber = _ref86[1];
5644
+ }, Object.entries(COUNTRIES_LIST).map(function (_ref107) {
5645
+ var _ref108 = _slicedToArray(_ref107, 2),
5646
+ countryCode = _ref108[0],
5647
+ countryNumber = _ref108[1];
4847
5648
  return /*#__PURE__*/wn.createElement("option", {
4848
5649
  key: countryCode,
4849
5650
  value: countryCode
4850
5651
  }, countryCode !== country ? "+".concat(countryNumber, " ").concat(countryFormatter.of(countryCode)) : "+".concat(countryNumber));
4851
5652
  }));
4852
5653
  };
4853
- var PhoneStyledInput = He(Input)(_templateObject55 || (_templateObject55 = _taggedTemplateLiteral(["\n flex-grow: 1;\n min-width: 100px;\n"])));
4854
- var PhoneInput = function PhoneInput(_ref87) {
4855
- var phone = _ref87.phone,
4856
- setPhone = _ref87.setPhone,
4857
- country = _ref87.country,
4858
- setCountry = _ref87.setCountry,
4859
- parsePhoneNumber = _ref87.parsePhoneNumber,
4860
- hasPasskeys = _ref87.hasPasskeys;
5654
+ var PhoneStyledInput = He(Input)(_templateObject61 || (_templateObject61 = _taggedTemplateLiteral(["\n flex-grow: 1;\n min-width: 100px;\n"])));
5655
+ var PhoneInput = function PhoneInput(_ref109) {
5656
+ var phone = _ref109.phone,
5657
+ setPhone = _ref109.setPhone,
5658
+ country = _ref109.country,
5659
+ setCountry = _ref109.setCountry,
5660
+ parsePhoneNumber = _ref109.parsePhoneNumber,
5661
+ hasPasskeys = _ref109.hasPasskeys;
4861
5662
  return /*#__PURE__*/wn.createElement(Flex, {
4862
5663
  direction: "row",
4863
5664
  wrap: "nowrap",
@@ -4919,8 +5720,8 @@ var InvalidPhoneNumberError = /*#__PURE__*/function (_StytchSDKError) {
4919
5720
  }
4920
5721
  return _createClass(InvalidPhoneNumberError);
4921
5722
  }(StytchSDKError);
4922
- var findErrorTypeFrom = function findErrorTypeFrom(_ref88) {
4923
- var error = _ref88.error;
5723
+ var findErrorTypeFrom = function findErrorTypeFrom(_ref110) {
5724
+ var error = _ref110.error;
4924
5725
  var errorType = extractErrorType(error);
4925
5726
  return !!errorType && errorType in supportedErrorTypeMap ? errorType : 'default';
4926
5727
  };
@@ -4931,10 +5732,10 @@ var supportedErrorTypeMap = {
4931
5732
  var SMSOTPEnrollScreen = function SMSOTPEnrollScreen() {
4932
5733
  var _a, _b;
4933
5734
  var stytchClient = useStytch();
4934
- var _useGlobalReducer53 = useGlobalReducer(),
4935
- _useGlobalReducer54 = _slicedToArray(_useGlobalReducer53, 2),
4936
- state = _useGlobalReducer54[0],
4937
- dispatch = _useGlobalReducer54[1];
5735
+ var _useGlobalReducer65 = useGlobalReducer(),
5736
+ _useGlobalReducer66 = _slicedToArray(_useGlobalReducer65, 2),
5737
+ state = _useGlobalReducer66[0],
5738
+ dispatch = _useGlobalReducer66[1];
4938
5739
  var _state$mfa$smsOtp = state.mfa.smsOtp,
4939
5740
  isSending = _state$mfa$smsOtp.isSending,
4940
5741
  sendError = _state$mfa$smsOtp.sendError,
@@ -4960,8 +5761,8 @@ var SMSOTPEnrollScreen = function SMSOTPEnrollScreen() {
4960
5761
  regionCode: countryCode
4961
5762
  });
4962
5763
  };
4963
- var _useMutate8 = useMutate('stytch.otps.sms.send', function (_, _ref89) {
4964
- var parsedNumber = _ref89.arg.parsedNumber;
5764
+ var _useMutate8 = useMutate('stytch.otps.sms.send', function (_, _ref111) {
5765
+ var parsedNumber = _ref111.arg.parsedNumber;
4965
5766
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
4966
5767
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
4967
5768
  while (1) switch (_context11.prev = _context11.next) {
@@ -5060,252 +5861,15 @@ var SMSOTPEnrollScreen = function SMSOTPEnrollScreen() {
5060
5861
  disabled: !phoneNumber
5061
5862
  })));
5062
5863
  };
5063
- var InlineButton = function InlineButton(_ref90) {
5064
- var onClick = _ref90.onClick,
5065
- children = _ref90.children;
5066
- return /*#__PURE__*/wn.createElement("button", {
5067
- onClick: onClick,
5068
- style: {
5069
- all: 'unset'
5070
- }
5071
- }, /*#__PURE__*/wn.createElement("b", {
5072
- style: {
5073
- cursor: 'pointer'
5074
- }
5075
- }, children));
5076
- };
5077
- var Wrapper = He.div(_templateObject56 || (_templateObject56 = _taggedTemplateLiteral(["\n display: grid;\n grid-template-rows: ", ";\n transition: grid-template-rows 0.15s ease-out;\n"])), function (_ref91) {
5078
- var isOpen = _ref91.isOpen;
5079
- return isOpen ? '1fr' : '0fr';
5080
- });
5081
- var Inner = He.div(_templateObject57 || (_templateObject57 = _taggedTemplateLiteral(["\n overflow: hidden;\n"])));
5082
- var AnimatedContainer = function AnimatedContainer(_ref92) {
5083
- var isOpen = _ref92.isOpen,
5084
- children = _ref92.children;
5085
- return /*#__PURE__*/wn.createElement(Wrapper, {
5086
- isOpen: isOpen
5087
- }, /*#__PURE__*/wn.createElement(Inner, null, children));
5088
- };
5089
- var Container = He.div(_templateObject58 || (_templateObject58 = _taggedTemplateLiteral(["\n height: 4px;\n background-color: ", ";\n border-radius: 3px;\n overflow: hidden;\n"])), function (_ref93) {
5090
- var theme = _ref93.theme;
5091
- return theme.colors.disabled;
5092
- });
5093
- var loading = Ue(_templateObject59 || (_templateObject59 = _taggedTemplateLiteral(["\n 0% {\n transform: translateX(-100%);\n }\n 100% {\n transform: translateX(-1%);\n }\n"])));
5094
- var Progress = He.div(_templateObject60 || (_templateObject60 = _taggedTemplateLiteral(["\n height: 100%;\n width: 100%;\n background-color: ", ";\n animation: ", " 10s cubic-bezier(0.22, 1, 0.36, 1);\n"])), function (_ref94) {
5095
- var theme = _ref94.theme;
5096
- return theme.colors.primary;
5097
- }, loading);
5098
- var LoadingBar = function LoadingBar(_ref95) {
5099
- var isLoading = _ref95.isLoading;
5100
- return /*#__PURE__*/wn.createElement(Container, null, isLoading && /*#__PURE__*/wn.createElement(Progress, null));
5101
- };
5102
- var GAP = '8px';
5103
- var WIDTH = '46px';
5104
- var INPUT_HEIGHT = '46px';
5105
- var Digit = He.div(_templateObject61 || (_templateObject61 = _taggedTemplateLiteral(["\n border: 1px solid ", ";\n border-radius: 4px;\n align-items: center;\n display: flex;\n font-size: 18px;\n justify-content: center;\n height: ", ";\n width: ", ";\n background: ", ";\n color: ", ";\n"])), function (_ref96) {
5106
- var disabled = _ref96.disabled,
5107
- theme = _ref96.theme;
5108
- return disabled ? theme.colors.disabled : '#ADBCC5';
5109
- }, INPUT_HEIGHT, WIDTH, function (_ref97) {
5110
- var disabled = _ref97.disabled,
5111
- theme = _ref97.theme;
5112
- return disabled ? theme.colors.disabled : theme.inputs.backgroundColor;
5113
- }, function (_ref98) {
5114
- var disabled = _ref98.disabled,
5115
- theme = _ref98.theme;
5116
- return disabled ? theme.colors.disabledText : theme.inputs.textColor;
5117
- });
5118
- var digitsContainerStyles = {
5119
- display: 'flex',
5120
- justifyContent: 'space-between',
5121
- gap: GAP,
5122
- position: 'relative',
5123
- zIndex: -1
5124
- };
5125
- var otpContainerStyles = {
5126
- overflow: 'hidden',
5127
- position: 'relative',
5128
- textAlign: 'initial',
5129
- zIndex: 1
5130
- };
5131
- var invisibleInputStyles = {
5132
- background: 'transparent',
5133
- border: 'none',
5134
- color: 'transparent',
5135
- height: INPUT_HEIGHT,
5136
- margin: 0,
5137
- outline: 'none',
5138
- position: 'absolute',
5139
- width: "calc(100% - (0.5 * ".concat(WIDTH, "))"),
5140
- caretColor: '#ADBCC5',
5141
- letterSpacing: "calc(".concat(WIDTH, " - 1ch + ").concat(GAP, ")"),
5142
- paddingLeft: "calc(0.5 * ".concat(WIDTH, ")"),
5143
- zIndex: 10
5144
- };
5145
- var DigitAtIndex = function DigitAtIndex(_ref99) {
5146
- var index = _ref99.index,
5147
- disabled = _ref99.disabled,
5148
- otp = _ref99.otp;
5149
- var fill = otp ? otp[index] : '';
5150
- return /*#__PURE__*/wn.createElement(Digit, {
5151
- disabled: disabled,
5152
- "data-testid": "otp-".concat(index)
5153
- }, fill);
5154
- };
5155
- var OTPInput = function OTPInput(_ref100) {
5156
- var otp = _ref100.otp,
5157
- setOtp = _ref100.setOtp,
5158
- disabled = _ref100.disabled;
5159
- var onPasscodeChange = function onPasscodeChange(e) {
5160
- if (!/^\d*$/.test(e.target.value)) {
5161
- return;
5162
- }
5163
- setOtp(e.target.value);
5164
- };
5165
- return /*#__PURE__*/wn.createElement("div", {
5166
- style: otpContainerStyles
5167
- }, /*#__PURE__*/wn.createElement("input", Object.assign({
5168
- "aria-label": "One-time passcode",
5169
- autoComplete: "one-time-code",
5170
- autoFocus: true,
5171
- disabled: disabled,
5172
- style: invisibleInputStyles,
5173
- maxLength: 6,
5174
- onChange: onPasscodeChange,
5175
- type: "text",
5176
- inputMode: "numeric",
5177
- value: otp
5178
- }, passwordManagerDisableAutofillProps)), /*#__PURE__*/wn.createElement("div", {
5179
- style: digitsContainerStyles
5180
- }, _toConsumableArray(Array(6).keys()).map(function (i) {
5181
- return /*#__PURE__*/wn.createElement(DigitAtIndex, {
5182
- key: "digit-".concat(i),
5183
- index: i,
5184
- otp: otp,
5185
- disabled: !!disabled
5186
- });
5187
- })));
5188
- };
5189
- var OTP_CODE_LENGTH = 6;
5190
- var OTPControl = function OTPControl(_ref101) {
5191
- var isSubmitting = _ref101.isSubmitting,
5192
- onSubmit = _ref101.onSubmit,
5193
- errorMessage = _ref101.errorMessage;
5194
- var _h$55 = h$2(''),
5195
- _h$56 = _slicedToArray(_h$55, 2),
5196
- otp = _h$56[0],
5197
- setOtp = _h$56[1];
5198
- var handleOtpChange = function handleOtpChange(otp) {
5199
- setOtp(otp);
5200
- if (otp.length === OTP_CODE_LENGTH) {
5201
- onSubmit(otp);
5202
- }
5203
- };
5204
- return /*#__PURE__*/wn.createElement(Flex, {
5205
- direction: "column",
5206
- maxWidth: 316
5207
- }, /*#__PURE__*/wn.createElement(OTPInput, {
5208
- otp: otp,
5209
- setOtp: handleOtpChange,
5210
- disabled: isSubmitting
5211
- }), /*#__PURE__*/wn.createElement(AnimatedContainer, {
5212
- isOpen: isSubmitting
5213
- }, /*#__PURE__*/wn.createElement(Flex, {
5214
- direction: "column",
5215
- gap: 8,
5216
- marginTop: 8
5217
- }, /*#__PURE__*/wn.createElement(Text, {
5218
- color: "secondary",
5219
- size: "helper"
5220
- }, "Verifying passcode..."), /*#__PURE__*/wn.createElement(LoadingBar, {
5221
- isLoading: isSubmitting
5222
- }))), !isSubmitting && /*#__PURE__*/wn.createElement(ErrorText, {
5223
- errorMessage: errorMessage !== null && errorMessage !== void 0 ? errorMessage : ''
5224
- }));
5225
- };
5226
- var OTPEntry = function OTPEntry(_ref102) {
5227
- var header = _ref102.header,
5228
- helperContent = _ref102.helperContent,
5229
- instruction = _ref102.instruction,
5230
- isSubmitting = _ref102.isSubmitting,
5231
- onSubmit = _ref102.onSubmit,
5232
- errorMessage = _ref102.errorMessage;
5233
- return /*#__PURE__*/wn.createElement(Flex, {
5234
- direction: "column",
5235
- gap: 24
5236
- }, /*#__PURE__*/wn.createElement(Text, {
5237
- size: "header"
5238
- }, header), /*#__PURE__*/wn.createElement(Text, null, instruction), /*#__PURE__*/wn.createElement(OTPControl, {
5239
- isSubmitting: isSubmitting,
5240
- onSubmit: onSubmit,
5241
- errorMessage: errorMessage
5242
- }), /*#__PURE__*/wn.createElement(Text, {
5243
- size: "helper",
5244
- color: "secondary"
5245
- }, helperContent));
5246
- };
5247
- var getSecondsRemaining = function getSecondsRemaining(expiration) {
5248
- var now = new Date();
5249
- return Math.ceil((expiration.getTime() - now.getTime()) / 1000);
5250
- };
5251
- var ExpirationMessage = function ExpirationMessage(_ref103) {
5252
- var expiration = _ref103.expiration,
5253
- resendOTP = _ref103.resendOTP;
5254
- var _h$57 = h$2(function () {
5255
- return getSecondsRemaining(expiration);
5256
- }),
5257
- _h$58 = _slicedToArray(_h$57, 2),
5258
- seconds = _h$58[0],
5259
- setSeconds = _h$58[1];
5260
- var codeExpired = seconds <= 0;
5261
- p$1(function () {
5262
- if (!codeExpired) {
5263
- var updateSeconds = function updateSeconds() {
5264
- return setSeconds(getSecondsRemaining(expiration));
5265
- };
5266
- var interval = setInterval(updateSeconds, 1000);
5267
- updateSeconds();
5268
- return function () {
5269
- return clearInterval(interval);
5270
- };
5271
- }
5272
- }, [codeExpired, expiration]);
5273
- var displayMinutes = Math.floor(Number(seconds / 60));
5274
- var displaySeconds = seconds - displayMinutes * 60;
5275
- var formattedTime = "".concat(displayMinutes, ":").concat(displaySeconds < 10 ? "0".concat(displaySeconds) : displaySeconds);
5276
- var formattedText = seconds > 0 ? "Your code expires in ".concat(formattedTime, ". Didn't get it? ") : 'Your code has expired. ';
5277
- return /*#__PURE__*/wn.createElement(wn.Fragment, null, formattedText, /*#__PURE__*/wn.createElement(InlineButton, {
5278
- onClick: resendOTP
5279
- }, "Resend code"));
5280
- };
5281
- var SentOTPEntry = function SentOTPEntry(_ref104) {
5282
- var expiration = _ref104.expiration,
5283
- formattedDestination = _ref104.formattedDestination,
5284
- isSubmitting = _ref104.isSubmitting,
5285
- onSubmit = _ref104.onSubmit,
5286
- errorMessage = _ref104.errorMessage,
5287
- resendOTP = _ref104.resendOTP;
5288
- return /*#__PURE__*/wn.createElement(OTPEntry, {
5289
- header: "Enter passcode",
5290
- helperContent: /*#__PURE__*/wn.createElement(ExpirationMessage, {
5291
- expiration: expiration,
5292
- resendOTP: resendOTP
5293
- }),
5294
- instruction: /*#__PURE__*/wn.createElement(wn.Fragment, null, "A 6-digit passcode was sent to you at ", /*#__PURE__*/wn.createElement("b", null, formattedDestination), "."),
5295
- isSubmitting: isSubmitting,
5296
- onSubmit: onSubmit,
5297
- errorMessage: errorMessage
5298
- });
5299
- };
5300
5864
  var SMSOTPEntryScreen = function SMSOTPEntryScreen() {
5301
5865
  var _a;
5302
5866
  var stytchClient = useStytch();
5303
5867
  var _useConfig3 = useConfig(),
5304
5868
  sessionDurationMinutes = _useConfig3.sessionOptions.sessionDurationMinutes;
5305
- var _useGlobalReducer55 = useGlobalReducer(),
5306
- _useGlobalReducer56 = _slicedToArray(_useGlobalReducer55, 2),
5307
- state = _useGlobalReducer56[0],
5308
- dispatch = _useGlobalReducer56[1];
5869
+ var _useGlobalReducer67 = useGlobalReducer(),
5870
+ _useGlobalReducer68 = _slicedToArray(_useGlobalReducer67, 2),
5871
+ state = _useGlobalReducer68[0],
5872
+ dispatch = _useGlobalReducer68[1];
5309
5873
  var _state$mfa = state.mfa,
5310
5874
  isEnrolling = _state$mfa.isEnrolling,
5311
5875
  _state$mfa$smsOtp2 = _state$mfa.smsOtp,
@@ -5317,10 +5881,10 @@ var SMSOTPEntryScreen = function SMSOTPEntryScreen() {
5317
5881
  memberPhoneNumber = _state$mfa$primaryInf3.memberPhoneNumber,
5318
5882
  organizationId = _state$mfa$primaryInf3.organizationId,
5319
5883
  organizationMfaOptionsSupported = _state$mfa$primaryInf3.organizationMfaOptionsSupported;
5320
- var _useMutate9 = useMutate('stytch.otps.sms.send', function (_, _ref105) {
5321
- var _ref105$arg = _ref105.arg,
5322
- memberId = _ref105$arg.memberId,
5323
- organizationId = _ref105$arg.organizationId;
5884
+ var _useMutate9 = useMutate('stytch.otps.sms.send', function (_, _ref112) {
5885
+ var _ref112$arg = _ref112.arg,
5886
+ memberId = _ref112$arg.memberId,
5887
+ organizationId = _ref112$arg.organizationId;
5324
5888
  dispatch({
5325
5889
  type: 'sms_otp/send'
5326
5890
  });
@@ -5349,12 +5913,12 @@ var SMSOTPEntryScreen = function SMSOTPEntryScreen() {
5349
5913
  sendSms = _useMutate9.trigger,
5350
5914
  isSending = _useMutate9.isMutating,
5351
5915
  sendError = _useMutate9.error;
5352
- var _useMutate10 = useMutate('stytch.otps.sms.authenticate', function (_, _ref106) {
5353
- var _ref106$arg = _ref106.arg,
5354
- otp = _ref106$arg.otp,
5355
- memberId = _ref106$arg.memberId,
5356
- organizationId = _ref106$arg.organizationId,
5357
- sessionDurationMinutes = _ref106$arg.sessionDurationMinutes;
5916
+ var _useMutate10 = useMutate('stytch.otps.sms.authenticate', function (_, _ref113) {
5917
+ var _ref113$arg = _ref113.arg,
5918
+ otp = _ref113$arg.otp,
5919
+ memberId = _ref113$arg.memberId,
5920
+ organizationId = _ref113$arg.organizationId,
5921
+ sessionDurationMinutes = _ref113$arg.sessionDurationMinutes;
5358
5922
  return stytchClient.otps.sms.authenticate({
5359
5923
  code: otp,
5360
5924
  member_id: memberId,
@@ -5483,10 +6047,10 @@ var CodeContainer = He(InsetContainer)(_templateObject63 || (_templateObject63 =
5483
6047
  var Spacer = He.div(_templateObject64 || (_templateObject64 = _taggedTemplateLiteral(["\n flex: 0 1 24px;\n"])));
5484
6048
  var Code = He.code(_templateObject65 || (_templateObject65 = _taggedTemplateLiteral(["\n white-space: pre-wrap;\n align-self: center;\n text-align: center;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-wrap: wrap;\n gap: 1ch;\n"])));
5485
6049
  var TOTPEnrollManualScreen = function TOTPEnrollManualScreen() {
5486
- var _useGlobalReducer57 = useGlobalReducer(),
5487
- _useGlobalReducer58 = _slicedToArray(_useGlobalReducer57, 2),
5488
- state = _useGlobalReducer58[0],
5489
- dispatch = _useGlobalReducer58[1];
6050
+ var _useGlobalReducer69 = useGlobalReducer(),
6051
+ _useGlobalReducer70 = _slicedToArray(_useGlobalReducer69, 2),
6052
+ state = _useGlobalReducer70[0],
6053
+ dispatch = _useGlobalReducer70[1];
5490
6054
  var secret = state.mfa.totp.enrollment.secret;
5491
6055
  var displaySecret = secret.toLowerCase();
5492
6056
  var secretChunked = displaySecret.split(/(.{4})/g).filter(Boolean);
@@ -5554,10 +6118,10 @@ var TOTPEnrollManualScreen = function TOTPEnrollManualScreen() {
5554
6118
  var QRCodeImg = He.img(_templateObject66 || (_templateObject66 = _taggedTemplateLiteral(["\n margin: 0 auto;\n"])));
5555
6119
  var TOTPEnrollQRScreen = function TOTPEnrollQRScreen() {
5556
6120
  var stytchClient = useStytch();
5557
- var _useGlobalReducer59 = useGlobalReducer(),
5558
- _useGlobalReducer60 = _slicedToArray(_useGlobalReducer59, 2),
5559
- state = _useGlobalReducer60[0],
5560
- dispatch = _useGlobalReducer60[1];
6121
+ var _useGlobalReducer71 = useGlobalReducer(),
6122
+ _useGlobalReducer72 = _slicedToArray(_useGlobalReducer71, 2),
6123
+ state = _useGlobalReducer72[0],
6124
+ dispatch = _useGlobalReducer72[1];
5561
6125
  var _state$mfa$totp = state.mfa.totp,
5562
6126
  createError = _state$mfa$totp.createError,
5563
6127
  enrollment = _state$mfa$totp.enrollment,
@@ -5565,10 +6129,10 @@ var TOTPEnrollQRScreen = function TOTPEnrollQRScreen() {
5565
6129
  var _state$mfa$primaryInf4 = state.mfa.primaryInfo,
5566
6130
  memberId = _state$mfa$primaryInf4.memberId,
5567
6131
  organizationId = _state$mfa$primaryInf4.organizationId;
5568
- var _useMutate11 = useMutate('stytch.totp.create', function (_, _ref107) {
5569
- var _ref107$arg = _ref107.arg,
5570
- memberId = _ref107$arg.memberId,
5571
- organizationId = _ref107$arg.organizationId;
6132
+ var _useMutate11 = useMutate('stytch.totp.create', function (_, _ref114) {
6133
+ var _ref114$arg = _ref114.arg,
6134
+ memberId = _ref114$arg.memberId,
6135
+ organizationId = _ref114$arg.organizationId;
5572
6136
  dispatch({
5573
6137
  type: 'totp/create'
5574
6138
  });
@@ -5634,11 +6198,11 @@ var TOTPEnrollQRScreen = function TOTPEnrollQRScreen() {
5634
6198
  onClick: handleContinue
5635
6199
  }, "Continue"))) : ( /*#__PURE__*/wn.createElement(LoadingScreen, null)));
5636
6200
  };
5637
- var TOTPEntry = function TOTPEntry(_ref108) {
5638
- var helperContent = _ref108.helperContent,
5639
- isSubmitting = _ref108.isSubmitting,
5640
- onSubmit = _ref108.onSubmit,
5641
- errorMessage = _ref108.errorMessage;
6201
+ var TOTPEntry = function TOTPEntry(_ref115) {
6202
+ var helperContent = _ref115.helperContent,
6203
+ isSubmitting = _ref115.isSubmitting,
6204
+ onSubmit = _ref115.onSubmit,
6205
+ errorMessage = _ref115.errorMessage;
5642
6206
  return /*#__PURE__*/wn.createElement(OTPEntry, {
5643
6207
  header: "Enter verification code",
5644
6208
  instruction: "Enter the 6-digit code from your authenticator app.",
@@ -5652,22 +6216,22 @@ var TOTPEntryScreen = function TOTPEntryScreen() {
5652
6216
  var stytchClient = useStytch();
5653
6217
  var _useConfig4 = useConfig(),
5654
6218
  sessionDurationMinutes = _useConfig4.sessionOptions.sessionDurationMinutes;
5655
- var _useGlobalReducer61 = useGlobalReducer(),
5656
- _useGlobalReducer62 = _slicedToArray(_useGlobalReducer61, 2),
5657
- state = _useGlobalReducer62[0],
5658
- dispatch = _useGlobalReducer62[1];
6219
+ var _useGlobalReducer73 = useGlobalReducer(),
6220
+ _useGlobalReducer74 = _slicedToArray(_useGlobalReducer73, 2),
6221
+ state = _useGlobalReducer74[0],
6222
+ dispatch = _useGlobalReducer74[1];
5659
6223
  var isEnrolling = state.mfa.isEnrolling;
5660
6224
  var _state$mfa$primaryInf5 = state.mfa.primaryInfo,
5661
6225
  enrolledMfaMethods = _state$mfa$primaryInf5.enrolledMfaMethods,
5662
6226
  memberId = _state$mfa$primaryInf5.memberId,
5663
6227
  organizationId = _state$mfa$primaryInf5.organizationId,
5664
6228
  organizationMfaOptionsSupported = _state$mfa$primaryInf5.organizationMfaOptionsSupported;
5665
- var _useMutate12 = useMutate('stytch.totp.authenticate', function (_, _ref109) {
5666
- var _ref109$arg = _ref109.arg,
5667
- memberId = _ref109$arg.memberId,
5668
- organizationId = _ref109$arg.organizationId,
5669
- otp = _ref109$arg.otp,
5670
- sessionDurationMinutes = _ref109$arg.sessionDurationMinutes;
6229
+ var _useMutate12 = useMutate('stytch.totp.authenticate', function (_, _ref116) {
6230
+ var _ref116$arg = _ref116.arg,
6231
+ memberId = _ref116$arg.memberId,
6232
+ organizationId = _ref116$arg.organizationId,
6233
+ otp = _ref116$arg.otp,
6234
+ sessionDurationMinutes = _ref116$arg.sessionDurationMinutes;
5671
6235
  return stytchClient.totp.authenticate({
5672
6236
  code: otp,
5673
6237
  member_id: memberId,
@@ -5740,49 +6304,49 @@ var TOTPEntryScreen = function TOTPEntryScreen() {
5740
6304
  onClick: handleSwitchToSms
5741
6305
  }, "Text me a code instead"))));
5742
6306
  };
5743
- var MainContainer = He.div(_templateObject67 || (_templateObject67 = _taggedTemplateLiteral(["\n width: ", ";\n font-family: ", ";\n box-sizing: border-box;\n * {\n box-sizing: content-box;\n }\n background-color: ", ";\n border: ", ";\n border-radius: ", ";\n border-bottom-left-radius: ", ";\n border-bottom-right-radius: ", ";\n border-bottom: ", ";\n"])), function (_ref110) {
5744
- var theme = _ref110.theme;
6307
+ var MainContainer = He.div(_templateObject67 || (_templateObject67 = _taggedTemplateLiteral(["\n width: ", ";\n font-family: ", ";\n box-sizing: border-box;\n * {\n box-sizing: content-box;\n }\n background-color: ", ";\n border: ", ";\n border-radius: ", ";\n border-bottom-left-radius: ", ";\n border-bottom-right-radius: ", ";\n border-bottom: ", ";\n"])), function (_ref117) {
6308
+ var theme = _ref117.theme;
5745
6309
  return theme.container.width;
5746
- }, function (_ref111) {
5747
- var theme = _ref111.theme;
6310
+ }, function (_ref118) {
6311
+ var theme = _ref118.theme;
5748
6312
  return theme.typography.fontFamily;
5749
- }, function (_ref112) {
5750
- var theme = _ref112.theme;
6313
+ }, function (_ref119) {
6314
+ var theme = _ref119.theme;
5751
6315
  return theme.container.backgroundColor;
5752
- }, function (_ref113) {
5753
- var theme = _ref113.theme;
6316
+ }, function (_ref120) {
6317
+ var theme = _ref120.theme;
5754
6318
  return theme.container.border;
5755
- }, function (_ref114) {
5756
- var theme = _ref114.theme;
6319
+ }, function (_ref121) {
6320
+ var theme = _ref121.theme;
5757
6321
  return theme.container.borderRadius;
5758
- }, function (_ref115) {
5759
- var theme = _ref115.theme,
5760
- displayWatermark = _ref115.displayWatermark;
6322
+ }, function (_ref122) {
6323
+ var theme = _ref122.theme,
6324
+ displayWatermark = _ref122.displayWatermark;
5761
6325
  return displayWatermark ? '0' : theme.container.borderRadius;
5762
- }, function (_ref116) {
5763
- var theme = _ref116.theme,
5764
- displayWatermark = _ref116.displayWatermark;
6326
+ }, function (_ref123) {
6327
+ var theme = _ref123.theme,
6328
+ displayWatermark = _ref123.displayWatermark;
5765
6329
  return displayWatermark ? '0' : theme.container.borderRadius;
5766
- }, function (_ref117) {
5767
- var theme = _ref117.theme,
5768
- displayWatermark = _ref117.displayWatermark;
6330
+ }, function (_ref124) {
6331
+ var theme = _ref124.theme,
6332
+ displayWatermark = _ref124.displayWatermark;
5769
6333
  return displayWatermark ? 'none' : theme.container.border;
5770
6334
  });
5771
6335
  var ChildrenContainer = He.div(_templateObject68 || (_templateObject68 = _taggedTemplateLiteral(["\n padding: 24px 32px;\n"])));
5772
- var WatermarkContainer = He.div(_templateObject69 || (_templateObject69 = _taggedTemplateLiteral(["\n box-sizing: border-box;\n width: ", ";\n background-color: ", ";\n border: ", ";\n border-top: none;\n border-bottom-left-radius: ", ";\n border-bottom-right-radius: ", ";\n overflow: hidden;\n"])), function (_ref118) {
5773
- var theme = _ref118.theme;
6336
+ var WatermarkContainer = He.div(_templateObject69 || (_templateObject69 = _taggedTemplateLiteral(["\n box-sizing: border-box;\n width: ", ";\n background-color: ", ";\n border: ", ";\n border-top: none;\n border-bottom-left-radius: ", ";\n border-bottom-right-radius: ", ";\n overflow: hidden;\n"])), function (_ref125) {
6337
+ var theme = _ref125.theme;
5774
6338
  return theme.container.width;
5775
- }, function (_ref119) {
5776
- var theme = _ref119.theme;
6339
+ }, function (_ref126) {
6340
+ var theme = _ref126.theme;
5777
6341
  return theme.container.backgroundColor;
5778
- }, function (_ref120) {
5779
- var theme = _ref120.theme;
6342
+ }, function (_ref127) {
6343
+ var theme = _ref127.theme;
5780
6344
  return theme.container.border;
5781
- }, function (_ref121) {
5782
- var theme = _ref121.theme;
6345
+ }, function (_ref128) {
6346
+ var theme = _ref128.theme;
5783
6347
  return theme.container.borderRadius;
5784
- }, function (_ref122) {
5785
- var theme = _ref122.theme;
6348
+ }, function (_ref129) {
6349
+ var theme = _ref129.theme;
5786
6350
  return theme.container.borderRadius;
5787
6351
  });
5788
6352
  var InnerContainer = He.div(_templateObject70 || (_templateObject70 = _taggedTemplateLiteral(["\n background-color: #19303d;\n display: flex;\n justify-content: center;\n align-items: center;\n opacity: 0.5;\n"])));
@@ -5804,29 +6368,24 @@ var isSupportedTokenType = function isSupportedTokenType(tokenType) {
5804
6368
  };
5805
6369
  var AppContainer$1 = function AppContainer$1() {
5806
6370
  var _ScreenComponentMap;
5807
- var _useGlobalReducer63 = useGlobalReducer(),
5808
- _useGlobalReducer64 = _slicedToArray(_useGlobalReducer63, 2),
5809
- state = _useGlobalReducer64[0],
5810
- dispatch = _useGlobalReducer64[1];
6371
+ var _useGlobalReducer75 = useGlobalReducer(),
6372
+ _useGlobalReducer76 = _slicedToArray(_useGlobalReducer75, 2),
6373
+ state = _useGlobalReducer76[0],
6374
+ dispatch = _useGlobalReducer76[1];
5811
6375
  var stytchClient = useStytch();
5812
6376
  var config = useConfig();
5813
6377
  var _Ze2 = Ze(),
5814
6378
  displayWatermark = _Ze2.displayWatermark;
5815
6379
  var isOnlyFloatingOneTap = useIsOnlyFloatingOneTap();
5816
6380
  var currentScreen = state.screen;
5817
- var ScreenComponentMap = (_ScreenComponentMap = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ScreenComponentMap, AppScreens$1.Main, /*#__PURE__*/wn.createElement(MainScreen, null)), AppScreens$1.EmailConfirmation, /*#__PURE__*/wn.createElement(EmailConfirmation, null)), AppScreens$1.LoggedIn, /*#__PURE__*/wn.createElement(ConfirmationScreen, null)), AppScreens$1.Discovery, /*#__PURE__*/wn.createElement(Discovery, null)), AppScreens$1.Error, /*#__PURE__*/wn.createElement(ErrorScreen, null)), AppScreens$1.PasswordEmailForm, /*#__PURE__*/wn.createElement(PasswordsEmailForm, null)), AppScreens$1.PasswordAuthenticate, /*#__PURE__*/wn.createElement(PasswordsAuthenticate, null)), AppScreens$1.PasswordResetForm, /*#__PURE__*/wn.createElement(PasswordResetForm, null)), AppScreens$1.PasswordResetVerifyConfirmation, /*#__PURE__*/wn.createElement(PasswordResetConfirmation, null)), AppScreens$1.PasswordForgotForm, /*#__PURE__*/wn.createElement(PasswordsForgotForm, null)), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ScreenComponentMap, AppScreens$1.PasswordSetNewConfirmation, /*#__PURE__*/wn.createElement(PasswordSetNew, null)), AppScreens$1.MFAEnrollmentSelection, /*#__PURE__*/wn.createElement(MFAEnrollmentSelectionScreen, null)), AppScreens$1.SMSOTPEnrollment, /*#__PURE__*/wn.createElement(SMSOTPEnrollScreen, null)), AppScreens$1.SMSOTPEntry, /*#__PURE__*/wn.createElement(SMSOTPEntryScreen, null)), AppScreens$1.RecoveryCodeEntry, /*#__PURE__*/wn.createElement(RecoveryCodeEntryScreen, null)), AppScreens$1.RecoveryCodeSave, /*#__PURE__*/wn.createElement(RecoveryCodeSaveScreen, null)), AppScreens$1.TOTPEnrollmentQRCode, /*#__PURE__*/wn.createElement(TOTPEnrollQRScreen, null)), AppScreens$1.TOTPEnrollmentManual, /*#__PURE__*/wn.createElement(TOTPEnrollManualScreen, null)), AppScreens$1.TOTPEntry, /*#__PURE__*/wn.createElement(TOTPEntryScreen, null)));
6381
+ var ScreenComponentMap = (_ScreenComponentMap = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ScreenComponentMap, AppScreens$1.Main, /*#__PURE__*/wn.createElement(MainScreen, null)), AppScreens$1.EmailConfirmation, /*#__PURE__*/wn.createElement(EmailConfirmation, null)), AppScreens$1.LoggedIn, /*#__PURE__*/wn.createElement(ConfirmationScreen, null)), AppScreens$1.Discovery, /*#__PURE__*/wn.createElement(Discovery, null)), AppScreens$1.Error, /*#__PURE__*/wn.createElement(ErrorScreen, null)), AppScreens$1.PasswordEmailForm, /*#__PURE__*/wn.createElement(PasswordsEmailForm, null)), AppScreens$1.PasswordAuthenticate, /*#__PURE__*/wn.createElement(PasswordsAuthenticate, null)), AppScreens$1.PasswordResetForm, /*#__PURE__*/wn.createElement(PasswordResetForm, null)), AppScreens$1.PasswordResetVerifyConfirmation, /*#__PURE__*/wn.createElement(PasswordResetConfirmation, null)), AppScreens$1.PasswordForgotForm, /*#__PURE__*/wn.createElement(PasswordsForgotForm, null)), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ScreenComponentMap, AppScreens$1.PasswordSetNewConfirmation, /*#__PURE__*/wn.createElement(PasswordSetNew, null)), AppScreens$1.MFAEnrollmentSelection, /*#__PURE__*/wn.createElement(MFAEnrollmentSelectionScreen, null)), AppScreens$1.SMSOTPEnrollment, /*#__PURE__*/wn.createElement(SMSOTPEnrollScreen, null)), AppScreens$1.SMSOTPEntry, /*#__PURE__*/wn.createElement(SMSOTPEntryScreen, null)), AppScreens$1.RecoveryCodeEntry, /*#__PURE__*/wn.createElement(RecoveryCodeEntryScreen, null)), AppScreens$1.RecoveryCodeSave, /*#__PURE__*/wn.createElement(RecoveryCodeSaveScreen, null)), AppScreens$1.TOTPEnrollmentQRCode, /*#__PURE__*/wn.createElement(TOTPEnrollQRScreen, null)), AppScreens$1.TOTPEnrollmentManual, /*#__PURE__*/wn.createElement(TOTPEnrollManualScreen, null)), AppScreens$1.TOTPEntry, /*#__PURE__*/wn.createElement(TOTPEntryScreen, null)), AppScreens$1.EmailMethodSelection, /*#__PURE__*/wn.createElement(EmailMethodSelectionScreen, null)), _defineProperty(_ScreenComponentMap, AppScreens$1.EmailOTPEntry, /*#__PURE__*/wn.createElement(EmailOTPEntryScreen, null)));
5818
6382
  var onSuccess = function onSuccess(data) {
5819
6383
  clearStytchSearchParams();
5820
6384
  onAuthenticateSuccess(data, dispatch, config);
5821
6385
  };
5822
6386
  var onDiscoverySuccess = function onDiscoverySuccess(data) {
5823
6387
  clearStytchSearchParams();
5824
- dispatch({
5825
- type: 'set_discovery_state',
5826
- email: data.email_address,
5827
- discoveredOrganizations: data.discovered_organizations,
5828
- intermediateSessionToken: data.intermediate_session_token
5829
- });
6388
+ onDiscoveryAuthenticateSuccess(data, dispatch);
5830
6389
  };
5831
6390
  var handleStytchAPIError = function handleStytchAPIError(defaultErrorType) {
5832
6391
  return function (error) {
@@ -5842,8 +6401,8 @@ var AppContainer$1 = function AppContainer$1() {
5842
6401
  });
5843
6402
  };
5844
6403
  };
5845
- var _useMutate13 = useMutate("stytch.magicLinks.authenticate", function (_, _ref123) {
5846
- var token = _ref123.arg.token;
6404
+ var _useMutate13 = useMutate("stytch.magicLinks.authenticate", function (_, _ref130) {
6405
+ var token = _ref130.arg.token;
5847
6406
  return stytchClient.magicLinks.authenticate({
5848
6407
  magic_links_token: token,
5849
6408
  session_duration_minutes: config.sessionOptions.sessionDurationMinutes
@@ -5854,8 +6413,8 @@ var AppContainer$1 = function AppContainer$1() {
5854
6413
  }),
5855
6414
  stytchMagicLinkAuthenticate = _useMutate13.trigger,
5856
6415
  isMagicLinkLoading = _useMutate13.isMutating;
5857
- var _useMutate14 = useMutate("stytch.oauth.authenticate", function (_, _ref124) {
5858
- var token = _ref124.arg.token;
6416
+ var _useMutate14 = useMutate("stytch.oauth.authenticate", function (_, _ref131) {
6417
+ var token = _ref131.arg.token;
5859
6418
  return stytchClient.oauth.authenticate({
5860
6419
  oauth_token: token,
5861
6420
  session_duration_minutes: config.sessionOptions.sessionDurationMinutes
@@ -5866,8 +6425,8 @@ var AppContainer$1 = function AppContainer$1() {
5866
6425
  }),
5867
6426
  stytchOAuthAuthenticate = _useMutate14.trigger,
5868
6427
  isOAuthLoading = _useMutate14.isMutating;
5869
- var _useMutate15 = useMutate("stytch.oauth.discovery.authenticate", function (_, _ref125) {
5870
- var token = _ref125.arg.token;
6428
+ var _useMutate15 = useMutate("stytch.oauth.discovery.authenticate", function (_, _ref132) {
6429
+ var token = _ref132.arg.token;
5871
6430
  return stytchClient.oauth.discovery.authenticate({
5872
6431
  discovery_oauth_token: token
5873
6432
  });
@@ -5877,8 +6436,8 @@ var AppContainer$1 = function AppContainer$1() {
5877
6436
  }),
5878
6437
  stytchOAuthDiscoveryAuthenticate = _useMutate15.trigger,
5879
6438
  isDiscoveryOAuthLoading = _useMutate15.isMutating;
5880
- var _useMutate16 = useMutate("stytch.sso.authenticate", function (_, _ref126) {
5881
- var token = _ref126.arg.token;
6439
+ var _useMutate16 = useMutate("stytch.sso.authenticate", function (_, _ref133) {
6440
+ var token = _ref133.arg.token;
5882
6441
  return stytchClient.sso.authenticate({
5883
6442
  sso_token: token,
5884
6443
  session_duration_minutes: config.sessionOptions.sessionDurationMinutes
@@ -5889,8 +6448,8 @@ var AppContainer$1 = function AppContainer$1() {
5889
6448
  }),
5890
6449
  stytchSSOAuthenticate = _useMutate16.trigger,
5891
6450
  isSSOLoading = _useMutate16.isMutating;
5892
- var _useMutate17 = useMutate("stytch.magicLinks.discovery.authenticate", function (_, _ref127) {
5893
- var token = _ref127.arg.token;
6451
+ var _useMutate17 = useMutate("stytch.magicLinks.discovery.authenticate", function (_, _ref134) {
6452
+ var token = _ref134.arg.token;
5894
6453
  return stytchClient.magicLinks.discovery.authenticate({
5895
6454
  discovery_magic_links_token: token
5896
6455
  });
@@ -5999,11 +6558,11 @@ var AppContainer$1 = function AppContainer$1() {
5999
6558
  src: POWERED_BY_STYTCH_IMG_URL
6000
6559
  }))))));
6001
6560
  };
6002
- var AppContainer = function AppContainer(_ref128) {
6003
- var client = _ref128.client,
6004
- styles = _ref128.styles,
6005
- callbacks = _ref128.callbacks,
6006
- config = _ref128.config;
6561
+ var AppContainer = function AppContainer(_ref135) {
6562
+ var client = _ref135.client,
6563
+ styles = _ref135.styles,
6564
+ callbacks = _ref135.callbacks,
6565
+ config = _ref135.config;
6007
6566
  var _h$59 = h$2(function () {
6008
6567
  var _readB2BInternals$boo3 = readB2BInternals(client).bootstrap.getSync(),
6009
6568
  displayWatermark = _readB2BInternals$boo3.displayWatermark;
@@ -6019,8 +6578,8 @@ var AppContainer = function AppContainer(_ref128) {
6019
6578
  options: config
6020
6579
  }
6021
6580
  });
6022
- readB2BInternals(client).bootstrap.getAsync().then(function (_ref129) {
6023
- var displayWatermark = _ref129.displayWatermark;
6581
+ readB2BInternals(client).bootstrap.getAsync().then(function (_ref136) {
6582
+ var displayWatermark = _ref136.displayWatermark;
6024
6583
  setDisplayWatermark(displayWatermark);
6025
6584
  });
6026
6585
  }, [client]);
@@ -6050,18 +6609,18 @@ var StytchB2BUIClient = /*#__PURE__*/function (_StytchB2BHeadlessCli) {
6050
6609
  function StytchB2BUIClient() {
6051
6610
  _classCallCheck(this, StytchB2BUIClient);
6052
6611
  checkNotSSR('StytchUIClient');
6053
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6054
- args[_key] = arguments[_key];
6612
+ for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
6613
+ args[_key2] = arguments[_key2];
6055
6614
  }
6056
6615
  return _callSuper(this, StytchB2BUIClient, [].concat(args));
6057
6616
  }
6058
6617
  _createClass(StytchB2BUIClient, [{
6059
6618
  key: "mount",
6060
- value: function mount(_ref130) {
6061
- var elementId = _ref130.elementId,
6062
- styles = _ref130.styles,
6063
- callbacks = _ref130.callbacks,
6064
- config = _ref130.config;
6619
+ value: function mount(_ref137) {
6620
+ var elementId = _ref137.elementId,
6621
+ styles = _ref137.styles,
6622
+ callbacks = _ref137.callbacks,
6623
+ config = _ref137.config;
6065
6624
  var _a;
6066
6625
  var targetParentDomNode = document.querySelector(elementId);
6067
6626
  if (!targetParentDomNode) {