@stytch/vanilla-js 5.6.1 → 5.7.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.
@@ -30,9 +30,9 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
30
30
  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
31
  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); }
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 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-DK-YyUyE.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-DB9djgAd.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-DB9djgAd.js';
36
36
  var DEFAULT_MFA_STATE = {
37
37
  primaryInfo: null,
38
38
  isEnrolling: false,
@@ -458,6 +458,7 @@ var ErrorType;
458
458
  ErrorType[ErrorType["EmailMagicLink"] = 1] = "EmailMagicLink";
459
459
  ErrorType[ErrorType["Organization"] = 2] = "Organization";
460
460
  ErrorType[ErrorType["CannotJoinOrgDueToAuthPolicy"] = 3] = "CannotJoinOrgDueToAuthPolicy";
461
+ ErrorType[ErrorType["AdBlockerDetected"] = 4] = "AdBlockerDetected";
461
462
  })(ErrorType || (ErrorType = {}));
462
463
  var DEFAULT_STATE = {
463
464
  screen: AppScreens$1.Main,
@@ -1500,7 +1501,7 @@ var ErrorScreen = function ErrorScreen() {
1500
1501
  _useGlobalReducer2 = _slicedToArray(_useGlobalReducer, 1),
1501
1502
  state = _useGlobalReducer2[0];
1502
1503
  var currentErrorType = state.errorType;
1503
- var ErrorTypeMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ErrorType.Default, 'Something went wrong. Try again later or contact your admin for help.'), ErrorType.EmailMagicLink, 'Something went wrong. Your login link may have expired, been revoked, or been used more than once. Request a new login link to try again, or contact your admin for help.'), ErrorType.Organization, 'The organization you are looking for could not be found. If you think this is a mistake, contact your admin.'), ErrorType.CannotJoinOrgDueToAuthPolicy, "Unable to join due to ".concat((_b = (_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.organization_name) !== null && _b !== void 0 ? _b : 'the organization', "'s authentication policy. Please contact your admin for more information."));
1504
+ var ErrorTypeMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ErrorType.Default, 'Something went wrong. Try again later or contact your admin for help.'), ErrorType.EmailMagicLink, 'Something went wrong. Your login link may have expired, been revoked, or been used more than once. Request a new login link to try again, or contact your admin for help.'), ErrorType.Organization, 'The organization you are looking for could not be found. If you think this is a mistake, contact your admin.'), ErrorType.CannotJoinOrgDueToAuthPolicy, "Unable to join due to ".concat((_b = (_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.organization_name) !== null && _b !== void 0 ? _b : 'the organization', "'s authentication policy. Please contact your admin for more information.")), ErrorType.AdBlockerDetected, 'The request was blocked by an Ad Blocker. Please disable your ad blocker, refresh the page, and try again.');
1504
1505
  return /*#__PURE__*/wn.createElement(Flex, {
1505
1506
  direction: "column",
1506
1507
  gap: 24,
@@ -1791,6 +1792,34 @@ var usePasswordInput = function usePasswordInput() {
1791
1792
  setErrorMessage('Invalid email or password. Please try again or use the link below to get help.');
1792
1793
  });
1793
1794
  };
1795
+ var submitDiscoveryPassword = function submitDiscoveryPassword() {
1796
+ setErrorMessage('');
1797
+ setIsSubmitting(true);
1798
+ stytch.passwords.discovery.authenticate({
1799
+ email_address: email,
1800
+ password: password
1801
+ }).then(function (data) {
1802
+ setIsSubmitting(false);
1803
+ onEvent({
1804
+ type: StytchEventType.B2BPasswordDiscoveryAuthenticate,
1805
+ data: data
1806
+ });
1807
+ dispatch({
1808
+ type: 'transition',
1809
+ screen: AppScreens$1.Discovery
1810
+ });
1811
+ dispatch({
1812
+ type: 'set_discovery_state',
1813
+ email: data.email_address,
1814
+ discoveredOrganizations: data.discovered_organizations,
1815
+ intermediateSessionToken: data.intermediate_session_token
1816
+ });
1817
+ })["catch"](function (err) {
1818
+ setIsSubmitting(false);
1819
+ onError(err);
1820
+ setErrorMessage('Invalid email or password. Please try again or use the link below to get help.');
1821
+ });
1822
+ };
1794
1823
  var emailEligibleForJITProvisioning = function emailEligibleForJITProvisioning(organization, email) {
1795
1824
  var emailDomain = email.split('@').pop();
1796
1825
  return organization.email_jit_provisioning == 'NOT_ALLOWED' || organization.email_jit_provisioning == 'RESTRICTED' && emailDomain && organization.email_allowed_domains.includes(emailDomain);
@@ -1843,6 +1872,7 @@ var usePasswordInput = function usePasswordInput() {
1843
1872
  isSubmitting: isSubmitting,
1844
1873
  setIsSubmitting: setIsSubmitting,
1845
1874
  submitPassword: submitPassword,
1875
+ submitDiscoveryPassword: submitDiscoveryPassword,
1846
1876
  handleNonMemberReset: handleNonMemberReset
1847
1877
  };
1848
1878
  };
@@ -2352,27 +2382,25 @@ var PasswordsAuthenticate = function PasswordsAuthenticate() {
2352
2382
  errorMessage = _usePasswordInput.errorMessage,
2353
2383
  setErrorMessage = _usePasswordInput.setErrorMessage,
2354
2384
  isSubmitting = _usePasswordInput.isSubmitting,
2355
- submitPassword = _usePasswordInput.submitPassword;
2385
+ submitPassword = _usePasswordInput.submitPassword,
2386
+ submitDiscoveryPassword = _usePasswordInput.submitDiscoveryPassword;
2356
2387
  if (!passwordOptions) return /*#__PURE__*/wn.createElement(wn.Fragment, null);
2357
- if (!organization) return /*#__PURE__*/wn.createElement(wn.Fragment, null);
2358
2388
  var handleSubmit = function handleSubmit(e) {
2359
2389
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
2360
2390
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
2361
2391
  while (1) switch (_context4.prev = _context4.next) {
2362
2392
  case 0:
2363
2393
  e.preventDefault();
2364
- if (organization) {
2365
- _context4.next = 3;
2366
- break;
2367
- }
2368
- return _context4.abrupt("return");
2369
- case 3:
2370
2394
  if (!email.match(EMAIL_REGEX)) {
2371
2395
  setErrorMessage('Invalid email address');
2372
2396
  } else {
2373
- submitPassword(organization.organization_id);
2397
+ if (!organization) {
2398
+ submitDiscoveryPassword();
2399
+ } else {
2400
+ submitPassword(organization.organization_id);
2401
+ }
2374
2402
  }
2375
- case 4:
2403
+ case 2:
2376
2404
  case "end":
2377
2405
  return _context4.stop();
2378
2406
  }
@@ -2430,14 +2458,19 @@ var PasswordsAuthenticate = function PasswordsAuthenticate() {
2430
2458
  })), /*#__PURE__*/wn.createElement(SubmitButton, {
2431
2459
  isSubmitting: isSubmitting,
2432
2460
  text: "Continue"
2433
- }), /*#__PURE__*/wn.createElement(Flex, {
2461
+ }), organization != null ? ( /*#__PURE__*/wn.createElement(Flex, {
2434
2462
  onClick: onGetHelp,
2435
2463
  direction: "row"
2436
2464
  }, /*#__PURE__*/wn.createElement(Text, {
2437
2465
  color: "secondary"
2438
2466
  }, "Having trouble signing in?"), "\xA0", /*#__PURE__*/wn.createElement(GetHelpText, {
2439
2467
  color: "secondary"
2440
- }, "Get help")))));
2468
+ }, "Get help"))) : ( /*#__PURE__*/wn.createElement(Flex, {
2469
+ onClick: onGetHelp,
2470
+ justifyContent: "center"
2471
+ }, /*#__PURE__*/wn.createElement(GetHelpText, {
2472
+ color: "secondary"
2473
+ }, "Sign up or reset password"))))));
2441
2474
  };
2442
2475
  var PasswordsEmailForm = function PasswordsEmailForm() {
2443
2476
  var _useGlobalReducer15 = useGlobalReducer(),
@@ -2457,13 +2490,13 @@ var PasswordsEmailForm = function PasswordsEmailForm() {
2457
2490
  isSubmitting = _usePasswordInput2.isSubmitting,
2458
2491
  setIsSubmitting = _usePasswordInput2.setIsSubmitting,
2459
2492
  submitPassword = _usePasswordInput2.submitPassword,
2493
+ submitDiscoveryPassword = _usePasswordInput2.submitDiscoveryPassword,
2460
2494
  handleNonMemberReset = _usePasswordInput2.handleNonMemberReset;
2461
- var _h$21 = h$2(!email),
2495
+ var _h$21 = h$2(!!organization && !email),
2462
2496
  _h$22 = _slicedToArray(_h$21, 2),
2463
2497
  hideInput = _h$22[0],
2464
2498
  setHideInput = _h$22[1];
2465
2499
  if (!passwordOptions) return /*#__PURE__*/wn.createElement(wn.Fragment, null);
2466
- if (!organization) return /*#__PURE__*/wn.createElement(wn.Fragment, null);
2467
2500
  var handleSubmit = function handleSubmit(e) {
2468
2501
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
2469
2502
  var organization_id;
@@ -2471,21 +2504,25 @@ var PasswordsEmailForm = function PasswordsEmailForm() {
2471
2504
  while (1) switch (_context5.prev = _context5.next) {
2472
2505
  case 0:
2473
2506
  e.preventDefault();
2507
+ if (!organization) {
2508
+ _context5.next = 14;
2509
+ break;
2510
+ }
2474
2511
  organization_id = organization.organization_id;
2475
2512
  if (hideInput) {
2476
- _context5.next = 5;
2513
+ _context5.next = 6;
2477
2514
  break;
2478
2515
  }
2479
2516
  submitPassword(organization_id);
2480
2517
  return _context5.abrupt("return");
2481
- case 5:
2518
+ case 6:
2482
2519
  if (email.match(EMAIL_REGEX)) {
2483
- _context5.next = 8;
2520
+ _context5.next = 9;
2484
2521
  break;
2485
2522
  }
2486
2523
  setErrorMessage('Invalid email address');
2487
2524
  return _context5.abrupt("return");
2488
- case 8:
2525
+ case 9:
2489
2526
  setErrorMessage('');
2490
2527
  setIsSubmitting(true);
2491
2528
  readB2BInternals(stytch).searchManager.searchMember(email, organization.organization_id).then(function (_ref54) {
@@ -2508,7 +2545,11 @@ var PasswordsEmailForm = function PasswordsEmailForm() {
2508
2545
  }
2509
2546
  setErrorMessage(message);
2510
2547
  });
2511
- case 11:
2548
+ _context5.next = 15;
2549
+ break;
2550
+ case 14:
2551
+ submitDiscoveryPassword();
2552
+ case 15:
2512
2553
  case "end":
2513
2554
  return _context5.stop();
2514
2555
  }
@@ -3204,6 +3245,7 @@ var Component;
3204
3245
  Component["SSOButtons"] = "SSOButtons";
3205
3246
  Component["PasswordsEmailForm"] = "PasswordsEmailForm";
3206
3247
  Component["PasswordEMLCombined"] = "PasswordEMLCombined";
3248
+ Component["PasswordEMLCombinedDiscovery"] = "PasswordEMLCombinedDiscovery";
3207
3249
  Component["Divider"] = "Divider";
3208
3250
  })(Component || (Component = {}));
3209
3251
  var generateProductComponentsOrdering = function generateProductComponentsOrdering(products, flowState) {
@@ -3231,7 +3273,7 @@ var generateProductComponentsOrdering = function generateProductComponentsOrderi
3231
3273
  var passwordIndex = products.indexOf(B2BProducts.passwords);
3232
3274
  var emlIndex = products.indexOf(B2BProducts.emailMagicLinks);
3233
3275
  var firstProductIndex = Math.min(passwordIndex, emlIndex);
3234
- var combinedComponent = flowStateType === AuthFlowType.Organization ? Component.PasswordEMLCombined : Component.MagicLinkEmailDiscoveryForm;
3276
+ var combinedComponent = flowStateType === AuthFlowType.Organization ? Component.PasswordEMLCombined : Component.PasswordEMLCombinedDiscovery;
3235
3277
  ProductComponents.splice(firstProductIndex, 0, combinedComponent);
3236
3278
  }
3237
3279
  var hasButtons = ProductComponents.includes(Component.OAuthButtons) || ProductComponents.includes(Component.SSOButtons);
@@ -3292,6 +3334,16 @@ var ProductComponents = function ProductComponents(_ref63) {
3292
3334
  }), /*#__PURE__*/wn.createElement(PasswordUseButton, {
3293
3335
  key: "password"
3294
3336
  }));
3337
+ case Component.PasswordEMLCombinedDiscovery:
3338
+ return /*#__PURE__*/wn.createElement(Flex, {
3339
+ key: "eml_password_discovery",
3340
+ direction: "column",
3341
+ gap: 12
3342
+ }, /*#__PURE__*/wn.createElement(MagicLinkEmailDiscoveryForm, {
3343
+ key: "magic_link"
3344
+ }), /*#__PURE__*/wn.createElement(PasswordUseButton, {
3345
+ key: "password"
3346
+ }));
3295
3347
  case Component.Divider:
3296
3348
  return /*#__PURE__*/wn.createElement(Divider, {
3297
3349
  key: "divider"
@@ -4411,6 +4463,35 @@ var PasswordResetForm = function PasswordResetForm() {
4411
4463
  setErrorMessage(message);
4412
4464
  setIsSubmitting(false);
4413
4465
  });
4466
+ } else if (resetTokenType == 'discovery') {
4467
+ stytchClient.passwords.discovery.resetByEmail({
4468
+ password_reset_token: resetToken,
4469
+ password: password
4470
+ }).then(function (data) {
4471
+ setIsSubmitting(false);
4472
+ onEvent({
4473
+ type: StytchEventType.B2BDiscoveryPasswordReset,
4474
+ data: data
4475
+ });
4476
+ dispatch({
4477
+ type: 'transition',
4478
+ screen: AppScreens$1.Discovery
4479
+ });
4480
+ dispatch({
4481
+ type: 'set_discovery_state',
4482
+ email: data.email_address,
4483
+ discoveredOrganizations: data.discovered_organizations,
4484
+ intermediateSessionToken: data.intermediate_session_token
4485
+ });
4486
+ })["catch"](function (e) {
4487
+ onError(e);
4488
+ var message = e.message;
4489
+ if (e instanceof StytchAPIError) {
4490
+ message = e.error_message;
4491
+ }
4492
+ setErrorMessage(message);
4493
+ setIsSubmitting(false);
4494
+ });
4414
4495
  } else {
4415
4496
  stytchClient.passwords.resetBySession({
4416
4497
  password: password
@@ -4493,28 +4574,42 @@ var PasswordSetNew = function PasswordSetNew() {
4493
4574
  email = _usePasswordInput3.email,
4494
4575
  organization = _usePasswordInput3.organization,
4495
4576
  setIsSubmitting = _usePasswordInput3.setIsSubmitting;
4496
- if (!organization) {
4497
- return /*#__PURE__*/wn.createElement(wn.Fragment, null);
4498
- }
4499
4577
  var resendResetPassword = function resendResetPassword() {
4500
- var _a, _b, _c, _d;
4501
- stytch.passwords.resetByEmailStart({
4502
- email_address: email,
4503
- organization_id: organization.organization_id,
4504
- login_redirect_url: (_a = config.emailMagicLinksOptions) === null || _a === void 0 ? void 0 : _a.loginTemplateId,
4505
- reset_password_redirect_url: (_b = config.passwordOptions) === null || _b === void 0 ? void 0 : _b.resetPasswordRedirectURL,
4506
- reset_password_expiration_minutes: (_c = config.passwordOptions) === null || _c === void 0 ? void 0 : _c.resetPasswordExpirationMinutes,
4507
- reset_password_template_id: (_d = config.passwordOptions) === null || _d === void 0 ? void 0 : _d.resetPasswordTemplateId
4508
- }).then(function (data) {
4509
- _t.success('Email resent');
4510
- setIsSubmitting(false);
4511
- onEvent({
4512
- type: StytchEventType.B2BPasswordResetByEmailStart,
4513
- data: data
4578
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4579
+ if (!organization) {
4580
+ stytch.passwords.discovery.resetByEmailStart({
4581
+ email_address: email,
4582
+ discovery_redirect_url: (_a = config.emailMagicLinksOptions) === null || _a === void 0 ? void 0 : _a.loginRedirectURL,
4583
+ reset_password_redirect_url: (_b = config.passwordOptions) === null || _b === void 0 ? void 0 : _b.resetPasswordRedirectURL,
4584
+ reset_password_expiration_minutes: (_c = config.passwordOptions) === null || _c === void 0 ? void 0 : _c.resetPasswordExpirationMinutes,
4585
+ reset_password_template_id: (_d = config.passwordOptions) === null || _d === void 0 ? void 0 : _d.resetPasswordTemplateId
4586
+ }).then(function (data) {
4587
+ _t.success('Email resent');
4588
+ setIsSubmitting(false);
4589
+ onEvent({
4590
+ type: StytchEventType.B2BPasswordDiscoveryResetStart,
4591
+ data: data
4592
+ });
4514
4593
  });
4515
- })["catch"](function (e) {
4516
- onError(e);
4517
- });
4594
+ } else {
4595
+ stytch.passwords.resetByEmailStart({
4596
+ email_address: email,
4597
+ organization_id: organization.organization_id,
4598
+ login_redirect_url: (_e = config.emailMagicLinksOptions) === null || _e === void 0 ? void 0 : _e.loginTemplateId,
4599
+ reset_password_redirect_url: (_f = config.passwordOptions) === null || _f === void 0 ? void 0 : _f.resetPasswordRedirectURL,
4600
+ reset_password_expiration_minutes: (_g = config.passwordOptions) === null || _g === void 0 ? void 0 : _g.resetPasswordExpirationMinutes,
4601
+ reset_password_template_id: (_h = config.passwordOptions) === null || _h === void 0 ? void 0 : _h.resetPasswordTemplateId
4602
+ }).then(function (data) {
4603
+ _t.success('Email resent');
4604
+ setIsSubmitting(false);
4605
+ onEvent({
4606
+ type: StytchEventType.B2BPasswordResetByEmailStart,
4607
+ data: data
4608
+ });
4609
+ })["catch"](function (e) {
4610
+ onError(e);
4611
+ });
4612
+ }
4518
4613
  };
4519
4614
  return /*#__PURE__*/wn.createElement(Flex, {
4520
4615
  direction: "column",
@@ -4557,9 +4652,9 @@ var PasswordsForgotForm = function PasswordsForgotForm() {
4557
4652
  setIsSubmitting = _usePasswordInput4.setIsSubmitting,
4558
4653
  handleNonMemberReset = _usePasswordInput4.handleNonMemberReset;
4559
4654
  if (!passwordOptions) return /*#__PURE__*/wn.createElement(wn.Fragment, null);
4560
- if (!organization) return /*#__PURE__*/wn.createElement(wn.Fragment, null);
4561
4655
  var handleSubmit = function handleSubmit(e) {
4562
4656
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
4657
+ var _a, _b, _c, _d;
4563
4658
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
4564
4659
  while (1) switch (_context7.prev = _context7.next) {
4565
4660
  case 0:
@@ -4573,26 +4668,56 @@ var PasswordsForgotForm = function PasswordsForgotForm() {
4573
4668
  case 4:
4574
4669
  setErrorMessage('');
4575
4670
  setIsSubmitting(true);
4576
- readB2BInternals(stytch).searchManager.searchMember(email, organization.organization_id).then(function (_ref82) {
4577
- var member = _ref82.member;
4578
- var _a, _b, _c, _d;
4579
- if (!(member === null || member === void 0 ? void 0 : member.member_password_id)) {
4580
- handleNonMemberReset();
4581
- return;
4582
- }
4583
- stytch.passwords.resetByEmailStart({
4671
+ if (organization) {
4672
+ readB2BInternals(stytch).searchManager.searchMember(email, organization.organization_id).then(function (_ref82) {
4673
+ var member = _ref82.member;
4674
+ var _a, _b, _c, _d;
4675
+ if (!(member === null || member === void 0 ? void 0 : member.member_password_id)) {
4676
+ handleNonMemberReset();
4677
+ return;
4678
+ }
4679
+ stytch.passwords.resetByEmailStart({
4680
+ email_address: email,
4681
+ organization_id: organization.organization_id,
4682
+ login_redirect_url: (_a = config.emailMagicLinksOptions) === null || _a === void 0 ? void 0 : _a.loginRedirectURL,
4683
+ reset_password_redirect_url: (_b = config.passwordOptions) === null || _b === void 0 ? void 0 : _b.resetPasswordRedirectURL,
4684
+ reset_password_expiration_minutes: (_c = config.passwordOptions) === null || _c === void 0 ? void 0 : _c.resetPasswordExpirationMinutes,
4685
+ reset_password_template_id: (_d = config.passwordOptions) === null || _d === void 0 ? void 0 : _d.resetPasswordTemplateId
4686
+ }).then(function (data) {
4687
+ setIsSubmitting(false);
4688
+ onEvent({
4689
+ type: StytchEventType.B2BPasswordResetByEmailStart,
4690
+ data: data
4691
+ });
4692
+ dispatch({
4693
+ type: 'set_password_state',
4694
+ email: email
4695
+ });
4696
+ dispatch({
4697
+ type: 'transition',
4698
+ screen: AppScreens$1.PasswordSetNewConfirmation
4699
+ });
4700
+ })["catch"](function (err) {
4701
+ setIsSubmitting(false);
4702
+ setErrorMessage(err.error_message);
4703
+ });
4704
+ })["catch"](function (err) {
4705
+ setIsSubmitting(false);
4706
+ var message = err.message;
4707
+ if (err instanceof StytchAPIError) {
4708
+ message = err.error_message;
4709
+ }
4710
+ setErrorMessage(message);
4711
+ });
4712
+ } else {
4713
+ stytch.passwords.discovery.resetByEmailStart({
4584
4714
  email_address: email,
4585
- organization_id: organization.organization_id,
4586
- login_redirect_url: (_a = config.emailMagicLinksOptions) === null || _a === void 0 ? void 0 : _a.loginRedirectURL,
4715
+ discovery_redirect_url: (_a = config.emailMagicLinksOptions) === null || _a === void 0 ? void 0 : _a.loginRedirectURL,
4587
4716
  reset_password_redirect_url: (_b = config.passwordOptions) === null || _b === void 0 ? void 0 : _b.resetPasswordRedirectURL,
4588
4717
  reset_password_expiration_minutes: (_c = config.passwordOptions) === null || _c === void 0 ? void 0 : _c.resetPasswordExpirationMinutes,
4589
4718
  reset_password_template_id: (_d = config.passwordOptions) === null || _d === void 0 ? void 0 : _d.resetPasswordTemplateId
4590
- }).then(function (data) {
4719
+ }).then(function () {
4591
4720
  setIsSubmitting(false);
4592
- onEvent({
4593
- type: StytchEventType.B2BPasswordResetByEmailStart,
4594
- data: data
4595
- });
4596
4721
  dispatch({
4597
4722
  type: 'set_password_state',
4598
4723
  email: email
@@ -4605,14 +4730,7 @@ var PasswordsForgotForm = function PasswordsForgotForm() {
4605
4730
  setIsSubmitting(false);
4606
4731
  setErrorMessage(err.error_message);
4607
4732
  });
4608
- })["catch"](function (err) {
4609
- setIsSubmitting(false);
4610
- var message = err.message;
4611
- if (err instanceof StytchAPIError) {
4612
- message = err.error_message;
4613
- }
4614
- setErrorMessage(message);
4615
- });
4733
+ }
4616
4734
  case 7:
4617
4735
  case "end":
4618
4736
  return _context7.stop();
@@ -4634,7 +4752,7 @@ var PasswordsForgotForm = function PasswordsForgotForm() {
4634
4752
  }
4635
4753
  }), /*#__PURE__*/wn.createElement(Text, {
4636
4754
  size: "header"
4637
- }, "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, {
4755
+ }, "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, {
4638
4756
  direction: "column",
4639
4757
  gap: 4
4640
4758
  }, /*#__PURE__*/wn.createElement(Text, {
@@ -5827,81 +5945,75 @@ var AppContainer$1 = function AppContainer$1() {
5827
5945
  intermediateSessionToken: data.intermediate_session_token
5828
5946
  });
5829
5947
  };
5830
- var onError = function onError(_ref123) {
5831
- var errorType = _ref123.errorType;
5832
- return function () {
5948
+ var handleStytchAPIError = function handleStytchAPIError(defaultErrorType) {
5949
+ return function (error) {
5950
+ var error_type = extractErrorType(error);
5951
+ var errorTypeMap = {
5952
+ ad_blocker_detected: ErrorType.AdBlockerDetected
5953
+ };
5954
+ var errorType = error_type && errorTypeMap[error_type] ? errorTypeMap[error_type] : defaultErrorType !== null && defaultErrorType !== void 0 ? defaultErrorType : ErrorType.Default;
5833
5955
  clearStytchSearchParams();
5834
5956
  dispatch({
5835
5957
  type: 'set_error_message_and_transition',
5836
- errorType: errorType !== null && errorType !== void 0 ? errorType : ErrorType.Default
5958
+ errorType: errorType
5837
5959
  });
5838
5960
  };
5839
5961
  };
5840
- var _useMutate13 = useMutate("stytch.magicLinks.authenticate", function (_, _ref124) {
5841
- var token = _ref124.arg.token;
5962
+ var _useMutate13 = useMutate("stytch.magicLinks.authenticate", function (_, _ref123) {
5963
+ var token = _ref123.arg.token;
5842
5964
  return stytchClient.magicLinks.authenticate({
5843
5965
  magic_links_token: token,
5844
5966
  session_duration_minutes: config.sessionOptions.sessionDurationMinutes
5845
5967
  });
5846
5968
  }, {
5847
5969
  onSuccess: onSuccess,
5848
- onError: onError({
5849
- errorType: ErrorType.EmailMagicLink
5850
- })
5970
+ onError: handleStytchAPIError(ErrorType.EmailMagicLink)
5851
5971
  }),
5852
5972
  stytchMagicLinkAuthenticate = _useMutate13.trigger,
5853
5973
  isMagicLinkLoading = _useMutate13.isMutating;
5854
- var _useMutate14 = useMutate("stytch.oauth.authenticate", function (_, _ref125) {
5855
- var token = _ref125.arg.token;
5974
+ var _useMutate14 = useMutate("stytch.oauth.authenticate", function (_, _ref124) {
5975
+ var token = _ref124.arg.token;
5856
5976
  return stytchClient.oauth.authenticate({
5857
5977
  oauth_token: token,
5858
5978
  session_duration_minutes: config.sessionOptions.sessionDurationMinutes
5859
5979
  });
5860
5980
  }, {
5861
5981
  onSuccess: onSuccess,
5862
- onError: onError({
5863
- errorType: null
5864
- })
5982
+ onError: handleStytchAPIError()
5865
5983
  }),
5866
5984
  stytchOAuthAuthenticate = _useMutate14.trigger,
5867
5985
  isOAuthLoading = _useMutate14.isMutating;
5868
- var _useMutate15 = useMutate("stytch.oauth.discovery.authenticate", function (_, _ref126) {
5869
- var token = _ref126.arg.token;
5986
+ var _useMutate15 = useMutate("stytch.oauth.discovery.authenticate", function (_, _ref125) {
5987
+ var token = _ref125.arg.token;
5870
5988
  return stytchClient.oauth.discovery.authenticate({
5871
5989
  discovery_oauth_token: token
5872
5990
  });
5873
5991
  }, {
5874
5992
  onSuccess: onDiscoverySuccess,
5875
- onError: onError({
5876
- errorType: null
5877
- })
5993
+ onError: handleStytchAPIError()
5878
5994
  }),
5879
5995
  stytchOAuthDiscoveryAuthenticate = _useMutate15.trigger,
5880
5996
  isDiscoveryOAuthLoading = _useMutate15.isMutating;
5881
- var _useMutate16 = useMutate("stytch.sso.authenticate", function (_, _ref127) {
5882
- var token = _ref127.arg.token;
5997
+ var _useMutate16 = useMutate("stytch.sso.authenticate", function (_, _ref126) {
5998
+ var token = _ref126.arg.token;
5883
5999
  return stytchClient.sso.authenticate({
5884
6000
  sso_token: token,
5885
6001
  session_duration_minutes: config.sessionOptions.sessionDurationMinutes
5886
6002
  });
5887
6003
  }, {
5888
6004
  onSuccess: onSuccess,
5889
- onError: onError({
5890
- errorType: null
5891
- })
6005
+ onError: handleStytchAPIError()
5892
6006
  }),
5893
6007
  stytchSSOAuthenticate = _useMutate16.trigger,
5894
6008
  isSSOLoading = _useMutate16.isMutating;
5895
- var _useMutate17 = useMutate("stytch.magicLinks.discovery.authenticate", function (_, _ref128) {
5896
- var token = _ref128.arg.token;
6009
+ var _useMutate17 = useMutate("stytch.magicLinks.discovery.authenticate", function (_, _ref127) {
6010
+ var token = _ref127.arg.token;
5897
6011
  return stytchClient.magicLinks.discovery.authenticate({
5898
6012
  discovery_magic_links_token: token
5899
6013
  });
5900
6014
  }, {
5901
6015
  onSuccess: onDiscoverySuccess,
5902
- onError: onError({
5903
- errorType: ErrorType.Default
5904
- })
6016
+ onError: handleStytchAPIError()
5905
6017
  }),
5906
6018
  stytchDiscoveryAuthenticate = _useMutate17.trigger,
5907
6019
  isDiscoveryLoading = _useMutate17.isMutating;
@@ -6004,11 +6116,11 @@ var AppContainer$1 = function AppContainer$1() {
6004
6116
  src: POWERED_BY_STYTCH_IMG_URL
6005
6117
  }))))));
6006
6118
  };
6007
- var AppContainer = function AppContainer(_ref129) {
6008
- var client = _ref129.client,
6009
- styles = _ref129.styles,
6010
- callbacks = _ref129.callbacks,
6011
- config = _ref129.config;
6119
+ var AppContainer = function AppContainer(_ref128) {
6120
+ var client = _ref128.client,
6121
+ styles = _ref128.styles,
6122
+ callbacks = _ref128.callbacks,
6123
+ config = _ref128.config;
6012
6124
  var _h$59 = h$2(function () {
6013
6125
  var _readB2BInternals$boo3 = readB2BInternals(client).bootstrap.getSync(),
6014
6126
  displayWatermark = _readB2BInternals$boo3.displayWatermark;
@@ -6024,8 +6136,8 @@ var AppContainer = function AppContainer(_ref129) {
6024
6136
  options: config
6025
6137
  }
6026
6138
  });
6027
- readB2BInternals(client).bootstrap.getAsync().then(function (_ref130) {
6028
- var displayWatermark = _ref130.displayWatermark;
6139
+ readB2BInternals(client).bootstrap.getAsync().then(function (_ref129) {
6140
+ var displayWatermark = _ref129.displayWatermark;
6029
6141
  setDisplayWatermark(displayWatermark);
6030
6142
  });
6031
6143
  }, [client]);
@@ -6062,11 +6174,11 @@ var StytchB2BUIClient = /*#__PURE__*/function (_StytchB2BHeadlessCli) {
6062
6174
  }
6063
6175
  _createClass(StytchB2BUIClient, [{
6064
6176
  key: "mount",
6065
- value: function mount(_ref131) {
6066
- var elementId = _ref131.elementId,
6067
- styles = _ref131.styles,
6068
- callbacks = _ref131.callbacks,
6069
- config = _ref131.config;
6177
+ value: function mount(_ref130) {
6178
+ var elementId = _ref130.elementId,
6179
+ styles = _ref130.styles,
6180
+ callbacks = _ref130.callbacks,
6181
+ config = _ref130.config;
6070
6182
  var _a;
6071
6183
  var targetParentDomNode = document.querySelector(elementId);
6072
6184
  if (!targetParentDomNode) {