@turnkey/react-wallet-kit 2.3.1 → 2.4.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 (33) hide show
  1. package/dist/components/auth/OTP.d.ts.map +1 -1
  2. package/dist/components/auth/OTP.js +12 -8
  3. package/dist/components/auth/OTP.js.map +1 -1
  4. package/dist/components/auth/OTP.mjs +12 -8
  5. package/dist/components/auth/OTP.mjs.map +1 -1
  6. package/dist/components/auth/TurnstileWidget.d.ts +6 -0
  7. package/dist/components/auth/TurnstileWidget.d.ts.map +1 -1
  8. package/dist/components/auth/TurnstileWidget.js +44 -2
  9. package/dist/components/auth/TurnstileWidget.js.map +1 -1
  10. package/dist/components/auth/TurnstileWidget.mjs +73 -2
  11. package/dist/components/auth/TurnstileWidget.mjs.map +1 -1
  12. package/dist/providers/client/Provider.d.ts.map +1 -1
  13. package/dist/providers/client/Provider.js +157 -77
  14. package/dist/providers/client/Provider.js.map +1 -1
  15. package/dist/providers/client/Provider.mjs +1303 -1107
  16. package/dist/providers/client/Provider.mjs.map +1 -1
  17. package/dist/providers/client/Types.d.ts +15 -1
  18. package/dist/providers/client/Types.d.ts.map +1 -1
  19. package/dist/providers/client/Types.js.map +1 -1
  20. package/dist/providers/client/Types.mjs.map +1 -1
  21. package/dist/utils/oauth/config.d.ts +7 -1
  22. package/dist/utils/oauth/config.d.ts.map +1 -1
  23. package/dist/utils/oauth/config.js +11 -1
  24. package/dist/utils/oauth/config.js.map +1 -1
  25. package/dist/utils/oauth/config.mjs +12 -2
  26. package/dist/utils/oauth/config.mjs.map +1 -1
  27. package/dist/utils/oauth/url.d.ts +3 -0
  28. package/dist/utils/oauth/url.d.ts.map +1 -1
  29. package/dist/utils/oauth/url.js +47 -0
  30. package/dist/utils/oauth/url.js.map +1 -1
  31. package/dist/utils/oauth/url.mjs +65 -3
  32. package/dist/utils/oauth/url.mjs.map +1 -1
  33. package/package.json +4 -4
@@ -4,14 +4,14 @@ import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import { sha256 } from '@noble/hashes/sha2';
5
5
  import { bytesToHex } from '@noble/hashes/utils';
6
6
  import { storePKCEVerifier, storeOAuthCaptchaToken, storeOAuthAddProviderMetadata, clearAllOAuthData, getOAuthAddProviderMetadata, hasPKCEVerifier, OAUTH_INTENT_ADD_PROVIDER } from '../../utils/oauth/storage.mjs';
7
- import '../../utils/oauth/config.mjs';
8
- import { parseOAuthResponse, openOAuthPopup, buildOAuthUrl, redirectToOAuthProvider, cleanupOAuthUrlPreserveSearch, cleanupOAuthUrl } from '../../utils/oauth/url.mjs';
7
+ import { OAUTH_PROVIDER_CONFIGS } from '../../utils/oauth/config.mjs';
8
+ import { isExpectedOAuthRedirectUrl, parseOAuthResponse, openOAuthPopup, buildOAuthUrl, redirectToOAuthProvider, cleanupOAuthUrlPreserveSearch, cleanupOAuthUrl } from '../../utils/oauth/url.mjs';
9
9
  import { completeOAuthPopup, completeOAuthFlow, completePKCEFlow } from '../../utils/oauth/completion.mjs';
10
10
  import { generateChallengePair, exchangeFacebookCodeForToken } from '../../utils/oauth/pkce.mjs';
11
11
  import { capitalizeProviderName, getProviderIcon } from '../../utils/oauth/helpers.mjs';
12
12
  import { useWalletProviderState, useDebouncedCallback, isValidSession, withTurnkeyErrorHandling, SESSION_WARNING_THRESHOLD_MS, mergeWalletsWithoutDuplicates } from '../../utils/utils.mjs';
13
13
  import { clearKeys, clearAll, setCappedTimeoutInMap, clearKey, setTimeoutInMap } from '../../utils/timers.mjs';
14
- import { resetPasskeyScope, DEFAULT_SESSION_EXPIRATION_IN_SECONDS, OtpType, applyPasskeyScope, buildSecondaryOauthProviders, TurnkeyClient, Chain, WalletInterfaceType, getAuthProxyConfig, getClientParams, WalletSource, buildSecondaryOidcClaims } from '@turnkey/core';
14
+ import { resetPasskeyScope, DEFAULT_SESSION_EXPIRATION_IN_SECONDS, OtpType, applyPasskeyScope, TurnkeyClient, Chain, WalletInterfaceType, getAuthProxyConfig, getClientParams, WalletSource, buildSecondaryOauthProviders, buildSecondaryOidcClaims } from '@turnkey/core';
15
15
  import { useState, useRef, useCallback, useEffect } from 'react';
16
16
  import { TurnkeyError, TurnkeyErrorCodes, TurnkeyNetworkError, AuthAction, OAuthProviders, FiatOnRampCryptoCurrency, FiatOnRampBlockchainNetwork } from '@turnkey/sdk-types';
17
17
  import { useModal } from '../modal/Hook.mjs';
@@ -68,7 +68,7 @@ import { Turnstile } from '../../components/auth/Turnstile.mjs';
68
68
  * @returns A React context provider exposing authentication, wallet, and user management methods and state.
69
69
  */
70
70
  var ClientProvider = function ClientProvider(_ref) {
71
- var _config$autoFetchWall, _masterConfig$auth31, _masterConfig$auth33, _masterConfig$auth35;
71
+ var _config$autoFetchWall, _masterConfig$auth33, _masterConfig$auth35, _masterConfig$auth37;
72
72
  var config = _ref.config,
73
73
  children = _ref.children,
74
74
  callbacks = _ref.callbacks;
@@ -120,6 +120,9 @@ var ClientProvider = function ClientProvider(_ref) {
120
120
  var expiryTimeoutsRef = useRef({});
121
121
  var proxyAuthConfigRef = useRef(null);
122
122
  var clientParamsRef = useRef(null);
123
+ // Stores the developer's custom MFA handler set via setMfaHandler.
124
+ // When unset, the default httpClient MFA behavior is used (no onMfaRequired callback).
125
+ var mfaHandlerRef = useRef(undefined);
123
126
  var _useState13 = useState(undefined),
124
127
  _useState14 = _slicedToArray(_useState13, 2),
125
128
  allSessions = _useState14[0],
@@ -942,11 +945,11 @@ var ClientProvider = function ClientProvider(_ref) {
942
945
  * @throws {TurnkeyError} If an error occurs while clearing the timers.
943
946
  */
944
947
  function _initializeWalletProviderListeners() {
945
- _initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee142(walletProviders, onUpdateState) {
948
+ _initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee149(walletProviders, onUpdateState) {
946
949
  var _masterConfig$walletC0, _masterConfig$walletC1, _masterConfig$walletC10, _masterConfig$walletC11;
947
950
  var cleanups, nativeOnly, ethProviders, solProviders, wcProviders, wcProvider, attachEthereumListeners, attachSolanaListeners, _wcProvider$provider, _wcProvider$provider$, standardEvents, unsubscribe;
948
- return _regenerator().w(function (_context142) {
949
- while (1) switch (_context142.n) {
951
+ return _regenerator().w(function (_context149) {
952
+ while (1) switch (_context149.n) {
950
953
  case 0:
951
954
  attachSolanaListeners = function _attachSolanaListener(provider, onUpdateState) {
952
955
  var _provider$features;
@@ -954,19 +957,19 @@ var ClientProvider = function ClientProvider(_ref) {
954
957
  var walletEvents = provider === null || provider === void 0 ? void 0 : (_provider$features = provider.features) === null || _provider$features === void 0 ? void 0 : _provider$features["standard:events"];
955
958
  if (walletEvents !== null && walletEvents !== void 0 && walletEvents.on) {
956
959
  var offChange = walletEvents.on("change", /*#__PURE__*/function () {
957
- var _ref166 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee140(_evt) {
958
- return _regenerator().w(function (_context140) {
959
- while (1) switch (_context140.n) {
960
+ var _ref175 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee147(_evt) {
961
+ return _regenerator().w(function (_context147) {
962
+ while (1) switch (_context147.n) {
960
963
  case 0:
961
- _context140.n = 1;
964
+ _context147.n = 1;
962
965
  return onUpdateState();
963
966
  case 1:
964
- return _context140.a(2);
967
+ return _context147.a(2);
965
968
  }
966
- }, _callee140);
969
+ }, _callee147);
967
970
  }));
968
- return function (_x118) {
969
- return _ref166.apply(this, arguments);
971
+ return function (_x120) {
972
+ return _ref175.apply(this, arguments);
970
973
  };
971
974
  }());
972
975
  cleanups.push(offChange);
@@ -980,31 +983,31 @@ var ClientProvider = function ClientProvider(_ref) {
980
983
  attachEthereumListeners = function _attachEthereumListen(provider, onUpdateState) {
981
984
  if (typeof provider.on !== "function") return;
982
985
  var handleChainChanged = /*#__PURE__*/function () {
983
- var _ref164 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee138(_chainId) {
984
- return _regenerator().w(function (_context138) {
985
- while (1) switch (_context138.n) {
986
+ var _ref173 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee145(_chainId) {
987
+ return _regenerator().w(function (_context145) {
988
+ while (1) switch (_context145.n) {
986
989
  case 0:
987
- return _context138.a(2, onUpdateState());
990
+ return _context145.a(2, onUpdateState());
988
991
  }
989
- }, _callee138);
992
+ }, _callee145);
990
993
  }));
991
- return function handleChainChanged(_x116) {
992
- return _ref164.apply(this, arguments);
994
+ return function handleChainChanged(_x118) {
995
+ return _ref173.apply(this, arguments);
993
996
  };
994
997
  }();
995
998
  var handleAccountsChanged = /*#__PURE__*/function () {
996
- var _ref165 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee139(accounts) {
997
- return _regenerator().w(function (_context139) {
998
- while (1) switch (_context139.n) {
999
+ var _ref174 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee146(accounts) {
1000
+ return _regenerator().w(function (_context146) {
1001
+ while (1) switch (_context146.n) {
999
1002
  case 0:
1000
1003
  if (accounts.length === 0) onUpdateState();
1001
1004
  case 1:
1002
- return _context139.a(2);
1005
+ return _context146.a(2);
1003
1006
  }
1004
- }, _callee139);
1007
+ }, _callee146);
1005
1008
  }));
1006
- return function handleAccountsChanged(_x117) {
1007
- return _ref165.apply(this, arguments);
1009
+ return function handleAccountsChanged(_x119) {
1010
+ return _ref174.apply(this, arguments);
1008
1011
  };
1009
1012
  }();
1010
1013
  var handleDisconnect = function handleDisconnect() {
@@ -1020,10 +1023,10 @@ var ClientProvider = function ClientProvider(_ref) {
1020
1023
  };
1021
1024
  };
1022
1025
  if (!(walletProviders.length === 0)) {
1023
- _context142.n = 1;
1026
+ _context149.n = 1;
1024
1027
  break;
1025
1028
  }
1026
- return _context142.a(2, function () {});
1029
+ return _context149.a(2, function () {});
1027
1030
  case 1:
1028
1031
  cleanups = []; // we only want to initialize these listeners for connected walletProviders
1029
1032
  nativeOnly = function nativeOnly(provider) {
@@ -1061,82 +1064,82 @@ var ClientProvider = function ClientProvider(_ref) {
1061
1064
  if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
1062
1065
  if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
1063
1066
  unsubscribe = standardEvents.on("change", /*#__PURE__*/function () {
1064
- var _ref167 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee141(evt) {
1067
+ var _ref176 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee148(evt) {
1065
1068
  var _callbacks$onError10, providers, currentSession, _wcProviders, wcWallets;
1066
- return _regenerator().w(function (_context141) {
1067
- while (1) switch (_context141.n) {
1069
+ return _regenerator().w(function (_context148) {
1070
+ while (1) switch (_context148.n) {
1068
1071
  case 0:
1069
1072
  if (!((evt === null || evt === void 0 ? void 0 : evt.type) === "pairingExpired")) {
1070
- _context141.n = 1;
1073
+ _context148.n = 1;
1071
1074
  break;
1072
1075
  }
1073
1076
  debouncedFetchWalletProviders();
1074
- return _context141.a(2);
1077
+ return _context148.a(2);
1075
1078
  case 1:
1076
1079
  if (!((evt === null || evt === void 0 ? void 0 : evt.type) === "failed")) {
1077
- _context141.n = 2;
1080
+ _context148.n = 2;
1078
1081
  break;
1079
1082
  }
1080
1083
  debouncedFetchWalletProviders();
1081
1084
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError10 = callbacks.onError) === null || _callbacks$onError10 === void 0 ? void 0 : _callbacks$onError10.call(callbacks, new TurnkeyError("WalletConnect initialization failed: ".concat(evt.error || "Unknown error"), TurnkeyErrorCodes.WALLET_CONNECT_INITIALIZATION_ERROR, evt.error));
1082
- return _context141.a(2);
1085
+ return _context148.a(2);
1083
1086
  case 2:
1084
1087
  if (!((evt === null || evt === void 0 ? void 0 : evt.type) === "initialized")) {
1085
- _context141.n = 7;
1088
+ _context148.n = 7;
1086
1089
  break;
1087
1090
  }
1088
- _context141.n = 3;
1091
+ _context148.n = 3;
1089
1092
  return debouncedFetchWalletProviders();
1090
1093
  case 3:
1091
- providers = _context141.v;
1092
- _context141.n = 4;
1094
+ providers = _context148.v;
1095
+ _context148.n = 4;
1093
1096
  return getSession();
1094
1097
  case 4:
1095
- currentSession = _context141.v;
1098
+ currentSession = _context148.v;
1096
1099
  if (!currentSession) {
1097
- _context141.n = 6;
1100
+ _context148.n = 6;
1098
1101
  break;
1099
1102
  }
1100
1103
  _wcProviders = providers === null || providers === void 0 ? void 0 : providers.filter(function (p) {
1101
1104
  return p.interfaceType === WalletInterfaceType.WalletConnect;
1102
1105
  });
1103
- _context141.n = 5;
1106
+ _context148.n = 5;
1104
1107
  return fetchWallets({
1105
1108
  walletProviders: _wcProviders,
1106
1109
  connectedOnly: true
1107
1110
  });
1108
1111
  case 5:
1109
- wcWallets = _context141.v;
1112
+ wcWallets = _context148.v;
1110
1113
  if (wcWallets.length > 0) {
1111
1114
  setWallets(function (prev) {
1112
1115
  return mergeWalletsWithoutDuplicates(prev, wcWallets);
1113
1116
  });
1114
1117
  }
1115
1118
  case 6:
1116
- return _context141.a(2);
1119
+ return _context148.a(2);
1117
1120
  case 7:
1118
- _context141.n = 8;
1121
+ _context148.n = 8;
1119
1122
  return onUpdateState();
1120
1123
  case 8:
1121
- return _context141.a(2);
1124
+ return _context148.a(2);
1122
1125
  }
1123
- }, _callee141);
1126
+ }, _callee148);
1124
1127
  }));
1125
- return function (_x119) {
1126
- return _ref167.apply(this, arguments);
1128
+ return function (_x121) {
1129
+ return _ref176.apply(this, arguments);
1127
1130
  };
1128
1131
  }());
1129
1132
  cleanups.push(unsubscribe);
1130
1133
  }
1131
1134
  }
1132
1135
  }
1133
- return _context142.a(2, function () {
1136
+ return _context149.a(2, function () {
1134
1137
  cleanups.forEach(function (remove) {
1135
1138
  return remove();
1136
1139
  });
1137
1140
  });
1138
1141
  }
1139
- }, _callee142);
1142
+ }, _callee149);
1140
1143
  }));
1141
1144
  return _initializeWalletProviderListeners.apply(this, arguments);
1142
1145
  }
@@ -1324,6 +1327,12 @@ var ClientProvider = function ClientProvider(_ref) {
1324
1327
  }
1325
1328
  return client.overridePasskeyStamper(params);
1326
1329
  }, [client]);
1330
+ var overrideAttestedStamper = useCallback(function (params) {
1331
+ if (!client) {
1332
+ throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1333
+ }
1334
+ return client.overrideAttestedStamper(params);
1335
+ }, [client]);
1327
1336
  var getActiveSessionKey = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
1328
1337
  return _regenerator().w(function (_context15) {
1329
1338
  while (1) switch (_context15.n) {
@@ -2419,6 +2428,7 @@ var ClientProvider = function ClientProvider(_ref) {
2419
2428
  }(), [client, callbacks]);
2420
2429
  var verifyOtp = useCallback(/*#__PURE__*/function () {
2421
2430
  var _ref61 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee48(params) {
2431
+ var res;
2422
2432
  return _regenerator().w(function (_context48) {
2423
2433
  while (1) switch (_context48.n) {
2424
2434
  case 0:
@@ -2428,9 +2438,19 @@ var ClientProvider = function ClientProvider(_ref) {
2428
2438
  }
2429
2439
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2430
2440
  case 1:
2431
- return _context48.a(2, withTurnkeyErrorHandling(function () {
2441
+ _context48.n = 2;
2442
+ return withTurnkeyErrorHandling(function () {
2432
2443
  return client.verifyOtp(params);
2433
- }, undefined, callbacks, "Failed to verify OTP"));
2444
+ }, undefined, callbacks, "Failed to verify OTP");
2445
+ case 2:
2446
+ res = _context48.v;
2447
+ _context48.n = 3;
2448
+ return client.overrideAttestedStamper({
2449
+ verificationToken: res.verificationToken,
2450
+ publicKey: res.publicKey
2451
+ });
2452
+ case 3:
2453
+ return _context48.a(2, res);
2434
2454
  }
2435
2455
  }, _callee48);
2436
2456
  }));
@@ -2440,7 +2460,8 @@ var ClientProvider = function ClientProvider(_ref) {
2440
2460
  }(), [client, callbacks]);
2441
2461
  var loginWithOtp = useCallback(/*#__PURE__*/function () {
2442
2462
  var _ref62 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee49(params) {
2443
- var res;
2463
+ var _ref63, _params$expirationSec7, _masterConfig$auth26;
2464
+ var expirationSeconds, res;
2444
2465
  return _regenerator().w(function (_context49) {
2445
2466
  while (1) switch (_context49.n) {
2446
2467
  case 0:
@@ -2450,9 +2471,12 @@ var ClientProvider = function ClientProvider(_ref) {
2450
2471
  }
2451
2472
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2452
2473
  case 1:
2474
+ expirationSeconds = (_ref63 = (_params$expirationSec7 = params === null || params === void 0 ? void 0 : params.expirationSeconds) !== null && _params$expirationSec7 !== void 0 ? _params$expirationSec7 : masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth26 = masterConfig.auth) === null || _masterConfig$auth26 === void 0 ? void 0 : _masterConfig$auth26.sessionExpirationSeconds) !== null && _ref63 !== void 0 ? _ref63 : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
2453
2475
  _context49.n = 2;
2454
2476
  return withTurnkeyErrorHandling(function () {
2455
- return client.loginWithOtp(params);
2477
+ return client.loginWithOtp(_objectSpread2(_objectSpread2({}, params), {}, {
2478
+ expirationSeconds: expirationSeconds
2479
+ }));
2456
2480
  }, undefined, callbacks, "Failed to login with OTP");
2457
2481
  case 2:
2458
2482
  res = _context49.v;
@@ -2475,10 +2499,10 @@ var ClientProvider = function ClientProvider(_ref) {
2475
2499
  return function (_x37) {
2476
2500
  return _ref62.apply(this, arguments);
2477
2501
  };
2478
- }(), [client, callbacks, handlePostAuth]);
2502
+ }(), [client, callbacks, masterConfig, handlePostAuth]);
2479
2503
  var signUpWithOtp = useCallback(/*#__PURE__*/function () {
2480
- var _ref63 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee50(params) {
2481
- var _masterConfig$auth26;
2504
+ var _ref64 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee50(params) {
2505
+ var _masterConfig$auth27;
2482
2506
  var createSubOrgParams, res;
2483
2507
  return _regenerator().w(function (_context50) {
2484
2508
  while (1) switch (_context50.n) {
@@ -2497,7 +2521,7 @@ var ClientProvider = function ClientProvider(_ref) {
2497
2521
  case 2:
2498
2522
  // If createSubOrgParams is not provided, use the default from masterConfig
2499
2523
  createSubOrgParams = params.createSubOrgParams;
2500
- if (!createSubOrgParams && masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth26 = masterConfig.auth) !== null && _masterConfig$auth26 !== void 0 && _masterConfig$auth26.createSuborgParams) {
2524
+ if (!createSubOrgParams && masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth27 = masterConfig.auth) !== null && _masterConfig$auth27 !== void 0 && _masterConfig$auth27.createSuborgParams) {
2501
2525
  if (params.otpType === OtpType.Email) {
2502
2526
  createSubOrgParams = masterConfig.auth.createSuborgParams.emailOtpAuth;
2503
2527
  } else if (params.otpType === OtpType.Sms) {
@@ -2530,12 +2554,12 @@ var ClientProvider = function ClientProvider(_ref) {
2530
2554
  }, _callee50);
2531
2555
  }));
2532
2556
  return function (_x38) {
2533
- return _ref63.apply(this, arguments);
2557
+ return _ref64.apply(this, arguments);
2534
2558
  };
2535
2559
  }(), [client, callbacks, masterConfig, handlePostAuth]);
2536
2560
  var completeOtp = useCallback(/*#__PURE__*/function () {
2537
- var _ref64 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee51(params) {
2538
- var _masterConfig$auth27;
2561
+ var _ref65 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee51(params) {
2562
+ var _masterConfig$auth28;
2539
2563
  var createSubOrgParams, res;
2540
2564
  return _regenerator().w(function (_context51) {
2541
2565
  while (1) switch (_context51.n) {
@@ -2554,7 +2578,7 @@ var ClientProvider = function ClientProvider(_ref) {
2554
2578
  case 2:
2555
2579
  // If createSubOrgParams is not provided, use the default from masterConfig
2556
2580
  createSubOrgParams = params.createSubOrgParams;
2557
- if (!createSubOrgParams && masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth27 = masterConfig.auth) !== null && _masterConfig$auth27 !== void 0 && _masterConfig$auth27.createSuborgParams) {
2581
+ if (!createSubOrgParams && masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth28 = masterConfig.auth) !== null && _masterConfig$auth28 !== void 0 && _masterConfig$auth28.createSuborgParams) {
2558
2582
  if (params.otpType === OtpType.Email) {
2559
2583
  createSubOrgParams = masterConfig.auth.createSuborgParams.emailOtpAuth;
2560
2584
  } else if (params.otpType === OtpType.Sms) {
@@ -2587,12 +2611,13 @@ var ClientProvider = function ClientProvider(_ref) {
2587
2611
  }, _callee51);
2588
2612
  }));
2589
2613
  return function (_x39) {
2590
- return _ref64.apply(this, arguments);
2614
+ return _ref65.apply(this, arguments);
2591
2615
  };
2592
2616
  }(), [client, callbacks, handlePostAuth, masterConfig]);
2593
2617
  var loginWithOauth = useCallback(/*#__PURE__*/function () {
2594
- var _ref65 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee52(params) {
2595
- var res;
2618
+ var _ref66 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee52(params) {
2619
+ var _ref67, _params$expirationSec8, _masterConfig$auth29;
2620
+ var expirationSeconds, res;
2596
2621
  return _regenerator().w(function (_context52) {
2597
2622
  while (1) switch (_context52.n) {
2598
2623
  case 0:
@@ -2602,9 +2627,12 @@ var ClientProvider = function ClientProvider(_ref) {
2602
2627
  }
2603
2628
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2604
2629
  case 1:
2630
+ expirationSeconds = (_ref67 = (_params$expirationSec8 = params === null || params === void 0 ? void 0 : params.expirationSeconds) !== null && _params$expirationSec8 !== void 0 ? _params$expirationSec8 : masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth29 = masterConfig.auth) === null || _masterConfig$auth29 === void 0 ? void 0 : _masterConfig$auth29.sessionExpirationSeconds) !== null && _ref67 !== void 0 ? _ref67 : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
2605
2631
  _context52.n = 2;
2606
2632
  return withTurnkeyErrorHandling(function () {
2607
- return client.loginWithOauth(params);
2633
+ return client.loginWithOauth(_objectSpread2(_objectSpread2({}, params), {}, {
2634
+ expirationSeconds: expirationSeconds
2635
+ }));
2608
2636
  }, undefined, callbacks, "Failed to login with OAuth");
2609
2637
  case 2:
2610
2638
  res = _context52.v;
@@ -2625,12 +2653,12 @@ var ClientProvider = function ClientProvider(_ref) {
2625
2653
  }, _callee52);
2626
2654
  }));
2627
2655
  return function (_x40) {
2628
- return _ref65.apply(this, arguments);
2656
+ return _ref66.apply(this, arguments);
2629
2657
  };
2630
- }(), [client, callbacks, handlePostAuth]);
2658
+ }(), [client, callbacks, masterConfig, handlePostAuth]);
2631
2659
  var signUpWithOauth = useCallback(/*#__PURE__*/function () {
2632
- var _ref66 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee53(params) {
2633
- var _params$createSubOrgP4, _masterConfig$auth28, _masterConfig$auth28$;
2660
+ var _ref68 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee53(params) {
2661
+ var _params$createSubOrgP4, _masterConfig$auth30, _masterConfig$auth30$;
2634
2662
  var createSubOrgParams, res;
2635
2663
  return _regenerator().w(function (_context53) {
2636
2664
  while (1) switch (_context53.n) {
@@ -2648,7 +2676,7 @@ var ClientProvider = function ClientProvider(_ref) {
2648
2676
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
2649
2677
  case 2:
2650
2678
  // If createSubOrgParams is not provided, use the default from masterConfig
2651
- createSubOrgParams = (_params$createSubOrgP4 = params.createSubOrgParams) !== null && _params$createSubOrgP4 !== void 0 ? _params$createSubOrgP4 : (_masterConfig$auth28 = masterConfig.auth) === null || _masterConfig$auth28 === void 0 ? void 0 : (_masterConfig$auth28$ = _masterConfig$auth28.createSuborgParams) === null || _masterConfig$auth28$ === void 0 ? void 0 : _masterConfig$auth28$.oauth;
2679
+ createSubOrgParams = (_params$createSubOrgP4 = params.createSubOrgParams) !== null && _params$createSubOrgP4 !== void 0 ? _params$createSubOrgP4 : (_masterConfig$auth30 = masterConfig.auth) === null || _masterConfig$auth30 === void 0 ? void 0 : (_masterConfig$auth30$ = _masterConfig$auth30.createSuborgParams) === null || _masterConfig$auth30$ === void 0 ? void 0 : _masterConfig$auth30$.oauth;
2652
2680
  params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
2653
2681
  createSubOrgParams: createSubOrgParams
2654
2682
  }) : _objectSpread2({}, params);
@@ -2675,12 +2703,12 @@ var ClientProvider = function ClientProvider(_ref) {
2675
2703
  }, _callee53);
2676
2704
  }));
2677
2705
  return function (_x41) {
2678
- return _ref66.apply(this, arguments);
2706
+ return _ref68.apply(this, arguments);
2679
2707
  };
2680
2708
  }(), [client, callbacks, handlePostAuth, masterConfig]);
2681
2709
  var _completeOauth = useCallback(/*#__PURE__*/function () {
2682
- var _ref67 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee54(params) {
2683
- var _params$createSubOrgP5, _masterConfig$auth29, _masterConfig$auth29$;
2710
+ var _ref69 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee54(params) {
2711
+ var _params$createSubOrgP5, _masterConfig$auth31, _masterConfig$auth31$;
2684
2712
  var createSubOrgParams, res;
2685
2713
  return _regenerator().w(function (_context54) {
2686
2714
  while (1) switch (_context54.n) {
@@ -2698,7 +2726,7 @@ var ClientProvider = function ClientProvider(_ref) {
2698
2726
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
2699
2727
  case 2:
2700
2728
  // If createSubOrgParams is not provided, use the default from masterConfig
2701
- createSubOrgParams = (_params$createSubOrgP5 = params.createSubOrgParams) !== null && _params$createSubOrgP5 !== void 0 ? _params$createSubOrgP5 : (_masterConfig$auth29 = masterConfig.auth) === null || _masterConfig$auth29 === void 0 ? void 0 : (_masterConfig$auth29$ = _masterConfig$auth29.createSuborgParams) === null || _masterConfig$auth29$ === void 0 ? void 0 : _masterConfig$auth29$.oauth;
2729
+ createSubOrgParams = (_params$createSubOrgP5 = params.createSubOrgParams) !== null && _params$createSubOrgP5 !== void 0 ? _params$createSubOrgP5 : (_masterConfig$auth31 = masterConfig.auth) === null || _masterConfig$auth31 === void 0 ? void 0 : (_masterConfig$auth31$ = _masterConfig$auth31.createSuborgParams) === null || _masterConfig$auth31$ === void 0 ? void 0 : _masterConfig$auth31$.oauth;
2702
2730
  params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
2703
2731
  createSubOrgParams: createSubOrgParams
2704
2732
  }) : _objectSpread2({}, params);
@@ -2725,11 +2753,11 @@ var ClientProvider = function ClientProvider(_ref) {
2725
2753
  }, _callee54);
2726
2754
  }));
2727
2755
  return function (_x42) {
2728
- return _ref67.apply(this, arguments);
2756
+ return _ref69.apply(this, arguments);
2729
2757
  };
2730
2758
  }(), [client, callbacks, masterConfig, handlePostAuth]);
2731
2759
  var fetchWalletAccounts = useCallback(/*#__PURE__*/function () {
2732
- var _ref68 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee55(params) {
2760
+ var _ref70 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee55(params) {
2733
2761
  return _regenerator().w(function (_context55) {
2734
2762
  while (1) switch (_context55.n) {
2735
2763
  case 0:
@@ -2748,11 +2776,11 @@ var ClientProvider = function ClientProvider(_ref) {
2748
2776
  }, _callee55);
2749
2777
  }));
2750
2778
  return function (_x43) {
2751
- return _ref68.apply(this, arguments);
2779
+ return _ref70.apply(this, arguments);
2752
2780
  };
2753
2781
  }(), [client, callbacks, logout]);
2754
2782
  var fetchPrivateKeys = useCallback(/*#__PURE__*/function () {
2755
- var _ref69 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee56(params) {
2783
+ var _ref71 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee56(params) {
2756
2784
  return _regenerator().w(function (_context56) {
2757
2785
  while (1) switch (_context56.n) {
2758
2786
  case 0:
@@ -2771,11 +2799,11 @@ var ClientProvider = function ClientProvider(_ref) {
2771
2799
  }, _callee56);
2772
2800
  }));
2773
2801
  return function (_x44) {
2774
- return _ref69.apply(this, arguments);
2802
+ return _ref71.apply(this, arguments);
2775
2803
  };
2776
2804
  }(), [client, callbacks, logout]);
2777
2805
  var signMessage = useCallback(/*#__PURE__*/function () {
2778
- var _ref70 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee57(params) {
2806
+ var _ref72 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee57(params) {
2779
2807
  return _regenerator().w(function (_context57) {
2780
2808
  while (1) switch (_context57.n) {
2781
2809
  case 0:
@@ -2794,11 +2822,11 @@ var ClientProvider = function ClientProvider(_ref) {
2794
2822
  }, _callee57);
2795
2823
  }));
2796
2824
  return function (_x45) {
2797
- return _ref70.apply(this, arguments);
2825
+ return _ref72.apply(this, arguments);
2798
2826
  };
2799
2827
  }(), [client, callbacks, logout]);
2800
2828
  var handleSignMessage = useCallback(/*#__PURE__*/function () {
2801
- var _ref71 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee58(params) {
2829
+ var _ref73 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee58(params) {
2802
2830
  var _params$successPageDu, successPageDuration;
2803
2831
  return _regenerator().w(function (_context58) {
2804
2832
  while (1) switch (_context58.n) {
@@ -2843,11 +2871,11 @@ var ClientProvider = function ClientProvider(_ref) {
2843
2871
  }, _callee58);
2844
2872
  }));
2845
2873
  return function (_x46) {
2846
- return _ref71.apply(this, arguments);
2874
+ return _ref73.apply(this, arguments);
2847
2875
  };
2848
2876
  }(), [client, callbacks, pushPage]);
2849
2877
  var signTransaction = useCallback(/*#__PURE__*/function () {
2850
- var _ref72 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee59(params) {
2878
+ var _ref74 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee59(params) {
2851
2879
  return _regenerator().w(function (_context59) {
2852
2880
  while (1) switch (_context59.n) {
2853
2881
  case 0:
@@ -2866,11 +2894,11 @@ var ClientProvider = function ClientProvider(_ref) {
2866
2894
  }, _callee59);
2867
2895
  }));
2868
2896
  return function (_x47) {
2869
- return _ref72.apply(this, arguments);
2897
+ return _ref74.apply(this, arguments);
2870
2898
  };
2871
2899
  }(), [client, callbacks, logout]);
2872
2900
  var ethSendTransaction = useCallback(/*#__PURE__*/function () {
2873
- var _ref73 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee60(params) {
2901
+ var _ref75 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee60(params) {
2874
2902
  return _regenerator().w(function (_context60) {
2875
2903
  while (1) switch (_context60.n) {
2876
2904
  case 0:
@@ -2889,11 +2917,11 @@ var ClientProvider = function ClientProvider(_ref) {
2889
2917
  }, _callee60);
2890
2918
  }));
2891
2919
  return function (_x48) {
2892
- return _ref73.apply(this, arguments);
2920
+ return _ref75.apply(this, arguments);
2893
2921
  };
2894
2922
  }(), [client, callbacks, logout]);
2895
2923
  var ethSendErc20Transfer = useCallback(/*#__PURE__*/function () {
2896
- var _ref74 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee61(params) {
2924
+ var _ref76 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee61(params) {
2897
2925
  return _regenerator().w(function (_context61) {
2898
2926
  while (1) switch (_context61.n) {
2899
2927
  case 0:
@@ -2912,11 +2940,11 @@ var ClientProvider = function ClientProvider(_ref) {
2912
2940
  }, _callee61);
2913
2941
  }));
2914
2942
  return function (_x49) {
2915
- return _ref74.apply(this, arguments);
2943
+ return _ref76.apply(this, arguments);
2916
2944
  };
2917
2945
  }(), [client, callbacks, logout]);
2918
2946
  var solSendTransaction = useCallback(/*#__PURE__*/function () {
2919
- var _ref75 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee62(params) {
2947
+ var _ref77 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee62(params) {
2920
2948
  return _regenerator().w(function (_context62) {
2921
2949
  while (1) switch (_context62.n) {
2922
2950
  case 0:
@@ -2935,11 +2963,11 @@ var ClientProvider = function ClientProvider(_ref) {
2935
2963
  }, _callee62);
2936
2964
  }));
2937
2965
  return function (_x50) {
2938
- return _ref75.apply(this, arguments);
2966
+ return _ref77.apply(this, arguments);
2939
2967
  };
2940
2968
  }(), [client, callbacks, logout]);
2941
2969
  var signAndSendTransaction = useCallback(/*#__PURE__*/function () {
2942
- var _ref76 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee63(params) {
2970
+ var _ref78 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee63(params) {
2943
2971
  return _regenerator().w(function (_context63) {
2944
2972
  while (1) switch (_context63.n) {
2945
2973
  case 0:
@@ -2958,11 +2986,11 @@ var ClientProvider = function ClientProvider(_ref) {
2958
2986
  }, _callee63);
2959
2987
  }));
2960
2988
  return function (_x51) {
2961
- return _ref76.apply(this, arguments);
2989
+ return _ref78.apply(this, arguments);
2962
2990
  };
2963
2991
  }(), [client, callbacks, logout]);
2964
2992
  var pollTransactionStatus = useCallback(/*#__PURE__*/function () {
2965
- var _ref77 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee64(params) {
2993
+ var _ref79 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee64(params) {
2966
2994
  return _regenerator().w(function (_context64) {
2967
2995
  while (1) switch (_context64.n) {
2968
2996
  case 0:
@@ -2981,11 +3009,11 @@ var ClientProvider = function ClientProvider(_ref) {
2981
3009
  }, _callee64);
2982
3010
  }));
2983
3011
  return function (_x52) {
2984
- return _ref77.apply(this, arguments);
3012
+ return _ref79.apply(this, arguments);
2985
3013
  };
2986
3014
  }(), [client, callbacks]);
2987
3015
  var fetchOrCreateP256ApiKeyUser = useCallback(/*#__PURE__*/function () {
2988
- var _ref78 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee65(params) {
3016
+ var _ref80 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee65(params) {
2989
3017
  return _regenerator().w(function (_context65) {
2990
3018
  while (1) switch (_context65.n) {
2991
3019
  case 0:
@@ -3004,11 +3032,11 @@ var ClientProvider = function ClientProvider(_ref) {
3004
3032
  }, _callee65);
3005
3033
  }));
3006
3034
  return function (_x53) {
3007
- return _ref78.apply(this, arguments);
3035
+ return _ref80.apply(this, arguments);
3008
3036
  };
3009
3037
  }(), [client, callbacks, logout]);
3010
3038
  var fetchOrCreatePolicies = useCallback(/*#__PURE__*/function () {
3011
- var _ref79 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee66(params) {
3039
+ var _ref81 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee66(params) {
3012
3040
  return _regenerator().w(function (_context66) {
3013
3041
  while (1) switch (_context66.n) {
3014
3042
  case 0:
@@ -3027,11 +3055,11 @@ var ClientProvider = function ClientProvider(_ref) {
3027
3055
  }, _callee66);
3028
3056
  }));
3029
3057
  return function (_x54) {
3030
- return _ref79.apply(this, arguments);
3058
+ return _ref81.apply(this, arguments);
3031
3059
  };
3032
3060
  }(), [client, callbacks, logout]);
3033
3061
  var updateUserEmail = useCallback(/*#__PURE__*/function () {
3034
- var _ref80 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee67(params) {
3062
+ var _ref82 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee67(params) {
3035
3063
  var res;
3036
3064
  return _regenerator().w(function (_context67) {
3037
3065
  while (1) switch (_context67.n) {
@@ -3068,11 +3096,11 @@ var ClientProvider = function ClientProvider(_ref) {
3068
3096
  }, _callee67);
3069
3097
  }));
3070
3098
  return function (_x55) {
3071
- return _ref80.apply(this, arguments);
3099
+ return _ref82.apply(this, arguments);
3072
3100
  };
3073
3101
  }(), [client, callbacks, logout, maybeRefreshUser]);
3074
3102
  var removeUserEmail = useCallback(/*#__PURE__*/function () {
3075
- var _ref81 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee68(params) {
3103
+ var _ref83 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee68(params) {
3076
3104
  var res;
3077
3105
  return _regenerator().w(function (_context68) {
3078
3106
  while (1) switch (_context68.n) {
@@ -3109,11 +3137,11 @@ var ClientProvider = function ClientProvider(_ref) {
3109
3137
  }, _callee68);
3110
3138
  }));
3111
3139
  return function (_x56) {
3112
- return _ref81.apply(this, arguments);
3140
+ return _ref83.apply(this, arguments);
3113
3141
  };
3114
3142
  }(), [client, callbacks, logout, maybeRefreshUser]);
3115
3143
  var updateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
3116
- var _ref82 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee69(params) {
3144
+ var _ref84 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee69(params) {
3117
3145
  var res;
3118
3146
  return _regenerator().w(function (_context69) {
3119
3147
  while (1) switch (_context69.n) {
@@ -3150,11 +3178,11 @@ var ClientProvider = function ClientProvider(_ref) {
3150
3178
  }, _callee69);
3151
3179
  }));
3152
3180
  return function (_x57) {
3153
- return _ref82.apply(this, arguments);
3181
+ return _ref84.apply(this, arguments);
3154
3182
  };
3155
3183
  }(), [client, callbacks, logout, maybeRefreshUser]);
3156
3184
  var removeUserPhoneNumber = useCallback(/*#__PURE__*/function () {
3157
- var _ref83 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee70(params) {
3185
+ var _ref85 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee70(params) {
3158
3186
  var res;
3159
3187
  return _regenerator().w(function (_context70) {
3160
3188
  while (1) switch (_context70.n) {
@@ -3191,11 +3219,11 @@ var ClientProvider = function ClientProvider(_ref) {
3191
3219
  }, _callee70);
3192
3220
  }));
3193
3221
  return function (_x58) {
3194
- return _ref83.apply(this, arguments);
3222
+ return _ref85.apply(this, arguments);
3195
3223
  };
3196
3224
  }(), [client, callbacks, logout, maybeRefreshUser]);
3197
3225
  var updateUserName = useCallback(/*#__PURE__*/function () {
3198
- var _ref84 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee71(params) {
3226
+ var _ref86 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee71(params) {
3199
3227
  var res;
3200
3228
  return _regenerator().w(function (_context71) {
3201
3229
  while (1) switch (_context71.n) {
@@ -3232,11 +3260,11 @@ var ClientProvider = function ClientProvider(_ref) {
3232
3260
  }, _callee71);
3233
3261
  }));
3234
3262
  return function (_x59) {
3235
- return _ref84.apply(this, arguments);
3263
+ return _ref86.apply(this, arguments);
3236
3264
  };
3237
3265
  }(), [client, callbacks, logout, maybeRefreshUser]);
3238
3266
  var addOauthProvider = useCallback(/*#__PURE__*/function () {
3239
- var _ref85 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee72(params) {
3267
+ var _ref87 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee72(params) {
3240
3268
  var res;
3241
3269
  return _regenerator().w(function (_context72) {
3242
3270
  while (1) switch (_context72.n) {
@@ -3273,11 +3301,11 @@ var ClientProvider = function ClientProvider(_ref) {
3273
3301
  }, _callee72);
3274
3302
  }));
3275
3303
  return function (_x60) {
3276
- return _ref85.apply(this, arguments);
3304
+ return _ref87.apply(this, arguments);
3277
3305
  };
3278
3306
  }(), [client, callbacks, logout, maybeRefreshUser]);
3279
3307
  var removeOauthProviders = useCallback(/*#__PURE__*/function () {
3280
- var _ref86 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee73(params) {
3308
+ var _ref88 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee73(params) {
3281
3309
  var res;
3282
3310
  return _regenerator().w(function (_context73) {
3283
3311
  while (1) switch (_context73.n) {
@@ -3314,12 +3342,12 @@ var ClientProvider = function ClientProvider(_ref) {
3314
3342
  }, _callee73);
3315
3343
  }));
3316
3344
  return function (_x61) {
3317
- return _ref86.apply(this, arguments);
3345
+ return _ref88.apply(this, arguments);
3318
3346
  };
3319
3347
  }(), [client, callbacks, logout, maybeRefreshUser]);
3320
3348
  var addPasskey = useCallback(/*#__PURE__*/function () {
3321
- var _ref87 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee74(params) {
3322
- var res, _masterConfig$auth30, updatedUser;
3349
+ var _ref89 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee74(params) {
3350
+ var res, _masterConfig$auth32, updatedUser;
3323
3351
  return _regenerator().w(function (_context74) {
3324
3352
  while (1) switch (_context74.n) {
3325
3353
  case 0:
@@ -3352,18 +3380,18 @@ var ClientProvider = function ClientProvider(_ref) {
3352
3380
  case 3:
3353
3381
  updatedUser = _context74.v;
3354
3382
  _context74.n = 4;
3355
- return applyPasskeyScope(client, client.config.passkeyConfig, updatedUser, masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth30 = masterConfig.auth) === null || _masterConfig$auth30 === void 0 ? void 0 : _masterConfig$auth30.scopePasskeyToUser);
3383
+ return applyPasskeyScope(client, client.config.passkeyConfig, updatedUser, masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth32 = masterConfig.auth) === null || _masterConfig$auth32 === void 0 ? void 0 : _masterConfig$auth32.scopePasskeyToUser);
3356
3384
  case 4:
3357
3385
  return _context74.a(2, res);
3358
3386
  }
3359
3387
  }, _callee74);
3360
3388
  }));
3361
3389
  return function (_x62) {
3362
- return _ref87.apply(this, arguments);
3390
+ return _ref89.apply(this, arguments);
3363
3391
  };
3364
- }(), [client, callbacks, logout, maybeRefreshUser, masterConfig === null || masterConfig === void 0 ? void 0 : masterConfig.passkeyConfig, masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth31 = masterConfig.auth) === null || _masterConfig$auth31 === void 0 ? void 0 : _masterConfig$auth31.scopePasskeyToUser]);
3392
+ }(), [client, callbacks, logout, maybeRefreshUser, masterConfig === null || masterConfig === void 0 ? void 0 : masterConfig.passkeyConfig, masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth33 = masterConfig.auth) === null || _masterConfig$auth33 === void 0 ? void 0 : _masterConfig$auth33.scopePasskeyToUser]);
3365
3393
  var removePasskeys = useCallback(/*#__PURE__*/function () {
3366
- var _ref88 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee75(params) {
3394
+ var _ref90 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee75(params) {
3367
3395
  var res;
3368
3396
  return _regenerator().w(function (_context75) {
3369
3397
  while (1) switch (_context75.n) {
@@ -3400,11 +3428,11 @@ var ClientProvider = function ClientProvider(_ref) {
3400
3428
  }, _callee75);
3401
3429
  }));
3402
3430
  return function (_x63) {
3403
- return _ref88.apply(this, arguments);
3431
+ return _ref90.apply(this, arguments);
3404
3432
  };
3405
3433
  }(), [client, callbacks, logout, maybeRefreshUser]);
3406
3434
  var createWallet = useCallback(/*#__PURE__*/function () {
3407
- var _ref89 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee76(params) {
3435
+ var _ref91 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee76(params) {
3408
3436
  var res, s;
3409
3437
  return _regenerator().w(function (_context76) {
3410
3438
  while (1) switch (_context76.n) {
@@ -3443,11 +3471,11 @@ var ClientProvider = function ClientProvider(_ref) {
3443
3471
  }, _callee76);
3444
3472
  }));
3445
3473
  return function (_x64) {
3446
- return _ref89.apply(this, arguments);
3474
+ return _ref91.apply(this, arguments);
3447
3475
  };
3448
3476
  }(), [client, session, callbacks, logout, maybeRefreshWallets, getSession]);
3449
3477
  var createWalletAccounts = useCallback(/*#__PURE__*/function () {
3450
- var _ref90 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee77(params) {
3478
+ var _ref92 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee77(params) {
3451
3479
  var res, s;
3452
3480
  return _regenerator().w(function (_context77) {
3453
3481
  while (1) switch (_context77.n) {
@@ -3486,11 +3514,11 @@ var ClientProvider = function ClientProvider(_ref) {
3486
3514
  }, _callee77);
3487
3515
  }));
3488
3516
  return function (_x65) {
3489
- return _ref90.apply(this, arguments);
3517
+ return _ref92.apply(this, arguments);
3490
3518
  };
3491
3519
  }(), [client, session, callbacks, logout, getSession, maybeRefreshWallets]);
3492
3520
  var exportWallet = useCallback(/*#__PURE__*/function () {
3493
- var _ref91 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee78(params) {
3521
+ var _ref93 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee78(params) {
3494
3522
  var res, s;
3495
3523
  return _regenerator().w(function (_context78) {
3496
3524
  while (1) switch (_context78.n) {
@@ -3529,11 +3557,11 @@ var ClientProvider = function ClientProvider(_ref) {
3529
3557
  }, _callee78);
3530
3558
  }));
3531
3559
  return function (_x66) {
3532
- return _ref91.apply(this, arguments);
3560
+ return _ref93.apply(this, arguments);
3533
3561
  };
3534
3562
  }(), [client, session, callbacks, logout, getSession, maybeRefreshWallets]);
3535
3563
  var exportPrivateKey = useCallback(/*#__PURE__*/function () {
3536
- var _ref92 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee79(params) {
3564
+ var _ref94 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee79(params) {
3537
3565
  var res;
3538
3566
  return _regenerator().w(function (_context79) {
3539
3567
  while (1) switch (_context79.n) {
@@ -3557,11 +3585,11 @@ var ClientProvider = function ClientProvider(_ref) {
3557
3585
  }, _callee79);
3558
3586
  }));
3559
3587
  return function (_x67) {
3560
- return _ref92.apply(this, arguments);
3588
+ return _ref94.apply(this, arguments);
3561
3589
  };
3562
3590
  }(), [client, callbacks, logout]);
3563
3591
  var exportWalletAccount = useCallback(/*#__PURE__*/function () {
3564
- var _ref93 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee80(params) {
3592
+ var _ref95 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee80(params) {
3565
3593
  var res, s;
3566
3594
  return _regenerator().w(function (_context80) {
3567
3595
  while (1) switch (_context80.n) {
@@ -3600,11 +3628,11 @@ var ClientProvider = function ClientProvider(_ref) {
3600
3628
  }, _callee80);
3601
3629
  }));
3602
3630
  return function (_x68) {
3603
- return _ref93.apply(this, arguments);
3631
+ return _ref95.apply(this, arguments);
3604
3632
  };
3605
3633
  }(), [client, callbacks, logout, getSession, maybeRefreshWallets]);
3606
3634
  var importWallet = useCallback(/*#__PURE__*/function () {
3607
- var _ref94 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee81(params) {
3635
+ var _ref96 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee81(params) {
3608
3636
  var res, s;
3609
3637
  return _regenerator().w(function (_context81) {
3610
3638
  while (1) switch (_context81.n) {
@@ -3645,11 +3673,11 @@ var ClientProvider = function ClientProvider(_ref) {
3645
3673
  }, _callee81);
3646
3674
  }));
3647
3675
  return function (_x69) {
3648
- return _ref94.apply(this, arguments);
3676
+ return _ref96.apply(this, arguments);
3649
3677
  };
3650
3678
  }(), [client, callbacks, logout, getSession, maybeRefreshWallets]);
3651
3679
  var importPrivateKey = useCallback(/*#__PURE__*/function () {
3652
- var _ref95 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee82(params) {
3680
+ var _ref97 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee82(params) {
3653
3681
  var res;
3654
3682
  return _regenerator().w(function (_context82) {
3655
3683
  while (1) switch (_context82.n) {
@@ -3673,11 +3701,11 @@ var ClientProvider = function ClientProvider(_ref) {
3673
3701
  }, _callee82);
3674
3702
  }));
3675
3703
  return function (_x70) {
3676
- return _ref95.apply(this, arguments);
3704
+ return _ref97.apply(this, arguments);
3677
3705
  };
3678
3706
  }(), [client, callbacks, logout]);
3679
3707
  var deleteSubOrganization = useCallback(/*#__PURE__*/function () {
3680
- var _ref96 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee83(params) {
3708
+ var _ref98 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee83(params) {
3681
3709
  return _regenerator().w(function (_context83) {
3682
3710
  while (1) switch (_context83.n) {
3683
3711
  case 0:
@@ -3696,12 +3724,12 @@ var ClientProvider = function ClientProvider(_ref) {
3696
3724
  }, _callee83);
3697
3725
  }));
3698
3726
  return function (_x71) {
3699
- return _ref96.apply(this, arguments);
3727
+ return _ref98.apply(this, arguments);
3700
3728
  };
3701
3729
  }(), [client, callbacks, logout]);
3702
3730
  var storeSession = useCallback(/*#__PURE__*/function () {
3703
- var _ref97 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee84(params) {
3704
- var _masterConfig$auth32;
3731
+ var _ref99 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee84(params) {
3732
+ var _masterConfig$auth34;
3705
3733
  var sessionKey, session, allSessions, nextUser;
3706
3734
  return _regenerator().w(function (_context84) {
3707
3735
  while (1) switch (_context84.n) {
@@ -3757,16 +3785,16 @@ var ClientProvider = function ClientProvider(_ref) {
3757
3785
  break;
3758
3786
  }
3759
3787
  _context84.n = 9;
3760
- return applyPasskeyScope(client, client.config.passkeyConfig, nextUser, masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth32 = masterConfig.auth) === null || _masterConfig$auth32 === void 0 ? void 0 : _masterConfig$auth32.scopePasskeyToUser);
3788
+ return applyPasskeyScope(client, client.config.passkeyConfig, nextUser, masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth34 = masterConfig.auth) === null || _masterConfig$auth34 === void 0 ? void 0 : _masterConfig$auth34.scopePasskeyToUser);
3761
3789
  case 9:
3762
3790
  return _context84.a(2);
3763
3791
  }
3764
3792
  }, _callee84);
3765
3793
  }));
3766
3794
  return function (_x72) {
3767
- return _ref97.apply(this, arguments);
3795
+ return _ref99.apply(this, arguments);
3768
3796
  };
3769
- }(), [client, callbacks, logout, getActiveSessionKey, getSession, scheduleSessionExpiration, getAllSessions, masterConfig === null || masterConfig === void 0 ? void 0 : masterConfig.passkeyConfig, masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth33 = masterConfig.auth) === null || _masterConfig$auth33 === void 0 ? void 0 : _masterConfig$auth33.scopePasskeyToUser, maybeRefreshWallets, maybeRefreshUser]);
3797
+ }(), [client, callbacks, logout, getActiveSessionKey, getSession, scheduleSessionExpiration, getAllSessions, masterConfig === null || masterConfig === void 0 ? void 0 : masterConfig.passkeyConfig, masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth35 = masterConfig.auth) === null || _masterConfig$auth35 === void 0 ? void 0 : _masterConfig$auth35.scopePasskeyToUser, maybeRefreshWallets, maybeRefreshUser]);
3770
3798
  var clearAllSessions = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee85() {
3771
3799
  return _regenerator().w(function (_context85) {
3772
3800
  while (1) switch (_context85.n) {
@@ -3797,8 +3825,8 @@ var ClientProvider = function ClientProvider(_ref) {
3797
3825
  }, _callee85);
3798
3826
  })), [client, callbacks, logout, clearSessionTimeouts, masterConfig === null || masterConfig === void 0 ? void 0 : masterConfig.passkeyConfig]);
3799
3827
  var setActiveSession = useCallback(/*#__PURE__*/function () {
3800
- var _ref99 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee87(params) {
3801
- var session, s;
3828
+ var _ref101 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee87(params) {
3829
+ var s;
3802
3830
  return _regenerator().w(function (_context87) {
3803
3831
  while (1) switch (_context87.n) {
3804
3832
  case 0:
@@ -3809,36 +3837,28 @@ var ClientProvider = function ClientProvider(_ref) {
3809
3837
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3810
3838
  case 1:
3811
3839
  _context87.n = 2;
3812
- return withTurnkeyErrorHandling(function () {
3813
- return client.getSession({
3814
- sessionKey: params.sessionKey
3815
- });
3816
- }, function () {
3817
- return logout();
3818
- }, callbacks, "Failed to get session");
3840
+ return getSession({
3841
+ sessionKey: params.sessionKey
3842
+ });
3819
3843
  case 2:
3820
- session = _context87.v;
3821
- _context87.n = 3;
3822
- return getSession();
3823
- case 3:
3824
3844
  s = _context87.v;
3825
3845
  if (s) {
3826
- _context87.n = 4;
3846
+ _context87.n = 3;
3827
3847
  break;
3828
3848
  }
3829
3849
  throw new TurnkeyError("Session not found.", TurnkeyErrorCodes.NOT_FOUND);
3830
- case 4:
3831
- _context87.n = 5;
3850
+ case 3:
3851
+ _context87.n = 4;
3832
3852
  return withTurnkeyErrorHandling(function () {
3833
3853
  return client.setActiveSession(params);
3834
3854
  }, function () {
3835
3855
  return logout();
3836
3856
  }, callbacks, "Failed to set active session");
3837
- case 5:
3857
+ case 4:
3838
3858
  setSession(session);
3839
- _context87.n = 6;
3859
+ _context87.n = 5;
3840
3860
  return withTurnkeyErrorHandling(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee86() {
3841
- var _masterConfig$auth34;
3861
+ var _masterConfig$auth36;
3842
3862
  var nextUser;
3843
3863
  return _regenerator().w(function (_context86) {
3844
3864
  while (1) switch (_context86.n) {
@@ -3855,7 +3875,7 @@ var ClientProvider = function ClientProvider(_ref) {
3855
3875
  break;
3856
3876
  }
3857
3877
  _context86.n = 3;
3858
- return applyPasskeyScope(client, client.config.passkeyConfig, nextUser, masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth34 = masterConfig.auth) === null || _masterConfig$auth34 === void 0 ? void 0 : _masterConfig$auth34.scopePasskeyToUser);
3878
+ return applyPasskeyScope(client, client.config.passkeyConfig, nextUser, masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth36 = masterConfig.auth) === null || _masterConfig$auth36 === void 0 ? void 0 : _masterConfig$auth36.scopePasskeyToUser);
3859
3879
  case 3:
3860
3880
  return _context86.a(2);
3861
3881
  }
@@ -3863,15 +3883,15 @@ var ClientProvider = function ClientProvider(_ref) {
3863
3883
  })), function () {
3864
3884
  return logout();
3865
3885
  }, callbacks, "Failed to refresh data after setting active session");
3866
- case 6:
3886
+ case 5:
3867
3887
  return _context87.a(2);
3868
3888
  }
3869
3889
  }, _callee87);
3870
3890
  }));
3871
3891
  return function (_x73) {
3872
- return _ref99.apply(this, arguments);
3892
+ return _ref101.apply(this, arguments);
3873
3893
  };
3874
- }(), [client, callbacks, logout, getSession, masterConfig === null || masterConfig === void 0 ? void 0 : masterConfig.passkeyConfig, masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth35 = masterConfig.auth) === null || _masterConfig$auth35 === void 0 ? void 0 : _masterConfig$auth35.scopePasskeyToUser, maybeRefreshWallets, maybeRefreshUser]);
3894
+ }(), [client, callbacks, logout, getSession, masterConfig === null || masterConfig === void 0 ? void 0 : masterConfig.passkeyConfig, masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth37 = masterConfig.auth) === null || _masterConfig$auth37 === void 0 ? void 0 : _masterConfig$auth37.scopePasskeyToUser, maybeRefreshWallets, maybeRefreshUser]);
3875
3895
  var clearUnusedKeyPairs = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee88() {
3876
3896
  return _regenerator().w(function (_context88) {
3877
3897
  while (1) switch (_context88.n) {
@@ -3889,7 +3909,7 @@ var ClientProvider = function ClientProvider(_ref) {
3889
3909
  }, _callee88);
3890
3910
  })), [client, callbacks]);
3891
3911
  var createApiKeyPair = useCallback(/*#__PURE__*/function () {
3892
- var _ref102 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee89(params) {
3912
+ var _ref104 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee89(params) {
3893
3913
  return _regenerator().w(function (_context89) {
3894
3914
  while (1) switch (_context89.n) {
3895
3915
  case 0:
@@ -3906,11 +3926,11 @@ var ClientProvider = function ClientProvider(_ref) {
3906
3926
  }, _callee89);
3907
3927
  }));
3908
3928
  return function (_x74) {
3909
- return _ref102.apply(this, arguments);
3929
+ return _ref104.apply(this, arguments);
3910
3930
  };
3911
3931
  }(), [client, callbacks]);
3912
3932
  var deleteApiKeyPair = useCallback(/*#__PURE__*/function () {
3913
- var _ref103 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee90(params) {
3933
+ var _ref105 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee90(params) {
3914
3934
  return _regenerator().w(function (_context90) {
3915
3935
  while (1) switch (_context90.n) {
3916
3936
  case 0:
@@ -3927,11 +3947,11 @@ var ClientProvider = function ClientProvider(_ref) {
3927
3947
  }, _callee90);
3928
3948
  }));
3929
3949
  return function (_x75) {
3930
- return _ref103.apply(this, arguments);
3950
+ return _ref105.apply(this, arguments);
3931
3951
  };
3932
3952
  }(), [client, callbacks]);
3933
3953
  var signWithApiKey = useCallback(/*#__PURE__*/function () {
3934
- var _ref104 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(params) {
3954
+ var _ref106 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(params) {
3935
3955
  return _regenerator().w(function (_context91) {
3936
3956
  while (1) switch (_context91.n) {
3937
3957
  case 0:
@@ -3948,7 +3968,7 @@ var ClientProvider = function ClientProvider(_ref) {
3948
3968
  }, _callee91);
3949
3969
  }));
3950
3970
  return function (_x76) {
3951
- return _ref104.apply(this, arguments);
3971
+ return _ref106.apply(this, arguments);
3952
3972
  };
3953
3973
  }(), [client, callbacks]);
3954
3974
  var getProxyAuthConfig = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee92() {
@@ -3968,7 +3988,7 @@ var ClientProvider = function ClientProvider(_ref) {
3968
3988
  }, _callee92);
3969
3989
  })), [client, callbacks]);
3970
3990
  var fetchBootProofForAppProof = useCallback(/*#__PURE__*/function () {
3971
- var _ref106 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(params) {
3991
+ var _ref108 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(params) {
3972
3992
  return _regenerator().w(function (_context93) {
3973
3993
  while (1) switch (_context93.n) {
3974
3994
  case 0:
@@ -3987,11 +4007,11 @@ var ClientProvider = function ClientProvider(_ref) {
3987
4007
  }, _callee93);
3988
4008
  }));
3989
4009
  return function (_x77) {
3990
- return _ref106.apply(this, arguments);
4010
+ return _ref108.apply(this, arguments);
3991
4011
  };
3992
4012
  }(), [client, callbacks, logout]);
3993
4013
  var verifyAppProofs = useCallback(/*#__PURE__*/function () {
3994
- var _ref107 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(params) {
4014
+ var _ref109 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(params) {
3995
4015
  return _regenerator().w(function (_context94) {
3996
4016
  while (1) switch (_context94.n) {
3997
4017
  case 0:
@@ -4010,54 +4030,78 @@ var ClientProvider = function ClientProvider(_ref) {
4010
4030
  }, _callee94);
4011
4031
  }));
4012
4032
  return function (_x78) {
4013
- return _ref107.apply(this, arguments);
4033
+ return _ref109.apply(this, arguments);
4014
4034
  };
4015
4035
  }(), [client, callbacks, logout]);
4036
+ var setMfaHandler = useCallback(function (handler) {
4037
+ mfaHandlerRef.current = handler;
4038
+ // Apply immediately if the client is ready.
4039
+ // When a custom handler is set, route the httpClient's MFA callback to it.
4040
+ // When cleared, restore the default httpClient behavior (no onMfaRequired callback).
4041
+ if (client) {
4042
+ client.httpClient.config.onMfaRequired = handler ? (/*#__PURE__*/function () {
4043
+ var _ref110 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(ctx) {
4044
+ return _regenerator().w(function (_context95) {
4045
+ while (1) switch (_context95.n) {
4046
+ case 0:
4047
+ _context95.n = 1;
4048
+ return handler(ctx);
4049
+ case 1:
4050
+ return _context95.a(2);
4051
+ }
4052
+ }, _callee95);
4053
+ }));
4054
+ return function (_x79) {
4055
+ return _ref110.apply(this, arguments);
4056
+ };
4057
+ }()) : undefined;
4058
+ }
4059
+ }, [client]);
4016
4060
  var handleDiscordOauth = useCallback(/*#__PURE__*/function () {
4017
- var _ref108 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(params) {
4018
- var _masterConfig$auth36, _masterConfig$auth36$, _masterConfig$auth36$2, _masterConfig$auth$oa4, _masterConfig$auth37, _masterConfig$auth37$, _masterConfig$auth37$2, _masterConfig$auth$oa5, _masterConfig$auth38, _masterConfig$auth38$, _masterConfig$auth39, _masterConfig$auth39$, _masterConfig$auth40;
4019
- var _ref109, _ref109$primaryClient, primaryClientId, _ref109$secondaryClie, secondaryClientIds, _ref109$openInPage, openInPage, additionalParameters, captchaToken, clientId, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, authUrl, authWindow;
4020
- return _regenerator().w(function (_context96) {
4021
- while (1) switch (_context96.n) {
4061
+ var _ref111 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(params) {
4062
+ var _masterConfig$auth38, _masterConfig$auth38$, _masterConfig$auth38$2, _masterConfig$auth$oa4, _masterConfig$auth39, _masterConfig$auth39$, _masterConfig$auth39$2, _masterConfig$auth$oa5, _masterConfig$auth40, _masterConfig$auth40$, _masterConfig$auth41, _masterConfig$auth41$, _masterConfig$auth42;
4063
+ var _ref112, _ref112$primaryClient, primaryClientId, _ref112$secondaryClie, secondaryClientIds, _ref112$openInPage, openInPage, additionalParameters, captchaToken, clientId, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, authUrl, authWindow;
4064
+ return _regenerator().w(function (_context98) {
4065
+ while (1) switch (_context98.n) {
4022
4066
  case 0:
4023
- _ref109 = params || {}, _ref109$primaryClient = _ref109.primaryClientId, primaryClientId = _ref109$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth36 = masterConfig.auth) === null || _masterConfig$auth36 === void 0 ? void 0 : (_masterConfig$auth36$ = _masterConfig$auth36.oauthConfig) === null || _masterConfig$auth36$ === void 0 ? void 0 : (_masterConfig$auth36$2 = _masterConfig$auth36$.discord) === null || _masterConfig$auth36$2 === void 0 ? void 0 : _masterConfig$auth36$2.primaryClientId : _ref109$primaryClient, _ref109$secondaryClie = _ref109.secondaryClientIds, secondaryClientIds = _ref109$secondaryClie === void 0 ? (_masterConfig$auth$oa4 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth37 = masterConfig.auth) === null || _masterConfig$auth37 === void 0 ? void 0 : (_masterConfig$auth37$ = _masterConfig$auth37.oauthConfig) === null || _masterConfig$auth37$ === void 0 ? void 0 : (_masterConfig$auth37$2 = _masterConfig$auth37$.discord) === null || _masterConfig$auth37$2 === void 0 ? void 0 : _masterConfig$auth37$2.secondaryClientIds) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : [] : _ref109$secondaryClie, _ref109$openInPage = _ref109.openInPage, openInPage = _ref109$openInPage === void 0 ? (_masterConfig$auth$oa5 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth38 = masterConfig.auth) === null || _masterConfig$auth38 === void 0 ? void 0 : (_masterConfig$auth38$ = _masterConfig$auth38.oauthConfig) === null || _masterConfig$auth38$ === void 0 ? void 0 : _masterConfig$auth38$.openOauthInPage) !== null && _masterConfig$auth$oa5 !== void 0 ? _masterConfig$auth$oa5 : false : _ref109$openInPage, additionalParameters = _ref109.additionalState, captchaToken = _ref109.captchaToken;
4067
+ _ref112 = params || {}, _ref112$primaryClient = _ref112.primaryClientId, primaryClientId = _ref112$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth38 = masterConfig.auth) === null || _masterConfig$auth38 === void 0 ? void 0 : (_masterConfig$auth38$ = _masterConfig$auth38.oauthConfig) === null || _masterConfig$auth38$ === void 0 ? void 0 : (_masterConfig$auth38$2 = _masterConfig$auth38$.discord) === null || _masterConfig$auth38$2 === void 0 ? void 0 : _masterConfig$auth38$2.primaryClientId : _ref112$primaryClient, _ref112$secondaryClie = _ref112.secondaryClientIds, secondaryClientIds = _ref112$secondaryClie === void 0 ? (_masterConfig$auth$oa4 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth39 = masterConfig.auth) === null || _masterConfig$auth39 === void 0 ? void 0 : (_masterConfig$auth39$ = _masterConfig$auth39.oauthConfig) === null || _masterConfig$auth39$ === void 0 ? void 0 : (_masterConfig$auth39$2 = _masterConfig$auth39$.discord) === null || _masterConfig$auth39$2 === void 0 ? void 0 : _masterConfig$auth39$2.secondaryClientIds) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : [] : _ref112$secondaryClie, _ref112$openInPage = _ref112.openInPage, openInPage = _ref112$openInPage === void 0 ? (_masterConfig$auth$oa5 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth40 = masterConfig.auth) === null || _masterConfig$auth40 === void 0 ? void 0 : (_masterConfig$auth40$ = _masterConfig$auth40.oauthConfig) === null || _masterConfig$auth40$ === void 0 ? void 0 : _masterConfig$auth40$.openOauthInPage) !== null && _masterConfig$auth$oa5 !== void 0 ? _masterConfig$auth$oa5 : false : _ref112$openInPage, additionalParameters = _ref112.additionalState, captchaToken = _ref112.captchaToken;
4024
4068
  clientId = primaryClientId;
4025
4069
  provider = OAuthProviders.DISCORD;
4026
4070
  if (masterConfig) {
4027
- _context96.n = 1;
4071
+ _context98.n = 1;
4028
4072
  break;
4029
4073
  }
4030
4074
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4031
4075
  case 1:
4032
4076
  if (clientId) {
4033
- _context96.n = 2;
4077
+ _context98.n = 2;
4034
4078
  break;
4035
4079
  }
4036
4080
  throw new TurnkeyError("Discord Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4037
4081
  case 2:
4038
- if ((_masterConfig$auth39 = masterConfig.auth) !== null && _masterConfig$auth39 !== void 0 && (_masterConfig$auth39$ = _masterConfig$auth39.oauthConfig) !== null && _masterConfig$auth39$ !== void 0 && _masterConfig$auth39$.oauthRedirectUri) {
4039
- _context96.n = 3;
4082
+ if ((_masterConfig$auth41 = masterConfig.auth) !== null && _masterConfig$auth41 !== void 0 && (_masterConfig$auth41$ = _masterConfig$auth41.oauthConfig) !== null && _masterConfig$auth41$ !== void 0 && _masterConfig$auth41$.oauthRedirectUri) {
4083
+ _context98.n = 3;
4040
4084
  break;
4041
4085
  }
4042
4086
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4043
4087
  case 3:
4044
4088
  flow = openInPage ? "redirect" : "popup";
4045
- redirectUri = (_masterConfig$auth40 = masterConfig.auth) === null || _masterConfig$auth40 === void 0 ? void 0 : _masterConfig$auth40.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4046
- _context96.n = 4;
4089
+ redirectUri = (_masterConfig$auth42 = masterConfig.auth) === null || _masterConfig$auth42 === void 0 ? void 0 : _masterConfig$auth42.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4090
+ _context98.n = 4;
4047
4091
  return createApiKeyPair();
4048
4092
  case 4:
4049
- publicKey = _context96.v;
4093
+ publicKey = _context98.v;
4050
4094
  if (publicKey) {
4051
- _context96.n = 5;
4095
+ _context98.n = 5;
4052
4096
  break;
4053
4097
  }
4054
4098
  throw new Error("Failed to create public key for OAuth.");
4055
4099
  case 5:
4056
4100
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair and store verifier
4057
- _context96.n = 6;
4101
+ _context98.n = 6;
4058
4102
  return generateChallengePair();
4059
4103
  case 6:
4060
- _yield$generateChalle = _context96.v;
4104
+ _yield$generateChalle = _context98.v;
4061
4105
  verifier = _yield$generateChalle.verifier;
4062
4106
  codeChallenge = _yield$generateChalle.codeChallenge;
4063
4107
  storePKCEVerifier(provider, verifier);
@@ -4077,143 +4121,167 @@ var ClientProvider = function ClientProvider(_ref) {
4077
4121
  additionalState: _objectSpread2({}, additionalParameters)
4078
4122
  });
4079
4123
  if (!openInPage) {
4080
- _context96.n = 7;
4124
+ _context98.n = 7;
4081
4125
  break;
4082
4126
  }
4083
- return _context96.a(2, redirectToOAuthProvider(authUrl));
4127
+ return _context98.a(2, redirectToOAuthProvider(authUrl));
4084
4128
  case 7:
4085
4129
  // Popup flow
4086
4130
  authWindow = openOAuthPopup();
4087
4131
  if (authWindow) {
4088
- _context96.n = 8;
4132
+ _context98.n = 8;
4089
4133
  break;
4090
4134
  }
4091
4135
  throw new Error("Failed to open ".concat(capitalizeProviderName(provider), " login window."));
4092
4136
  case 8:
4093
4137
  authWindow.location.href = authUrl;
4094
- return _context96.a(2, new Promise(function (resolve, reject) {
4095
- var interval = setInterval(function () {
4096
- try {
4097
- if (authWindow.closed) {
4098
- clearInterval(interval);
4099
- reject(new Error("Authentication window was closed."));
4100
- return;
4101
- }
4102
- var url = authWindow.location.href || "";
4103
- if (url.startsWith(window.location.origin)) {
4104
- var result = parseOAuthResponse(url, provider);
4105
- if (result) {
4106
- authWindow.close();
4138
+ return _context98.a(2, new Promise(function (resolve, reject) {
4139
+ var interval = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97() {
4140
+ var url, result;
4141
+ return _regenerator().w(function (_context97) {
4142
+ while (1) switch (_context97.p = _context97.n) {
4143
+ case 0:
4144
+ _context97.p = 0;
4145
+ if (!authWindow.closed) {
4146
+ _context97.n = 1;
4147
+ break;
4148
+ }
4107
4149
  clearInterval(interval);
4108
- completeOAuthPopup({
4109
- provider: provider,
4110
- publicKey: publicKey,
4111
- result: result,
4112
- callbacks: callbacks,
4113
- completeOauth: function completeOauth(completionParams) {
4114
- var _masterConfig$auth41, _masterConfig$auth41$, _completionParams$pro3, _existingCreateSubOrg3;
4115
- var existingCreateSubOrgParams = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth41 = masterConfig.auth) === null || _masterConfig$auth41 === void 0 ? void 0 : (_masterConfig$auth41$ = _masterConfig$auth41.createSuborgParams) === null || _masterConfig$auth41$ === void 0 ? void 0 : _masterConfig$auth41$.oauth;
4116
- var secondaryProviders = buildSecondaryOauthProviders(completionParams.oidcToken, (_completionParams$pro3 = completionParams.providerName) !== null && _completionParams$pro3 !== void 0 ? _completionParams$pro3 : provider, secondaryClientIds);
4117
- return _completeOauth(_objectSpread2(_objectSpread2({}, completionParams), secondaryProviders.length > 0 && {
4118
- createSubOrgParams: _objectSpread2(_objectSpread2({}, existingCreateSubOrgParams), {}, {
4119
- oauthProviders: [].concat(_toConsumableArray((_existingCreateSubOrg3 = existingCreateSubOrgParams === null || existingCreateSubOrgParams === void 0 ? void 0 : existingCreateSubOrgParams.oauthProviders) !== null && _existingCreateSubOrg3 !== void 0 ? _existingCreateSubOrg3 : []), _toConsumableArray(secondaryProviders))
4120
- })
4121
- }));
4122
- },
4123
- captchaToken: captchaToken,
4124
- onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess,
4125
- exchangeCodeForToken: function () {
4126
- var _exchangeCodeForToken = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(codeVerifier) {
4127
- var _resp$oidcToken;
4128
- var resp;
4129
- return _regenerator().w(function (_context95) {
4130
- while (1) switch (_context95.n) {
4131
- case 0:
4132
- _context95.n = 1;
4133
- return client === null || client === void 0 ? void 0 : client.httpClient.proxyOAuth2Authenticate({
4134
- provider: "OAUTH2_PROVIDER_DISCORD",
4135
- authCode: result.authCode,
4136
- redirectUri: redirectUri,
4137
- codeVerifier: codeVerifier,
4138
- clientId: clientId,
4139
- nonce: nonce
4140
- });
4141
- case 1:
4142
- resp = _context95.v;
4143
- return _context95.a(2, (_resp$oidcToken = resp === null || resp === void 0 ? void 0 : resp.oidcToken) !== null && _resp$oidcToken !== void 0 ? _resp$oidcToken : "");
4150
+ reject(new Error("Authentication window was closed."));
4151
+ return _context97.a(2);
4152
+ case 1:
4153
+ url = authWindow.location.href || "";
4154
+ if (isExpectedOAuthRedirectUrl(url, redirectUri, OAUTH_PROVIDER_CONFIGS[provider].expectedResponseMode)) {
4155
+ result = parseOAuthResponse(url, provider);
4156
+ if (result) {
4157
+ authWindow.close();
4158
+ clearInterval(interval);
4159
+ completeOAuthPopup({
4160
+ provider: provider,
4161
+ publicKey: publicKey,
4162
+ result: result,
4163
+ callbacks: callbacks,
4164
+ completeOauth: function completeOauth(completionParams) {
4165
+ var _masterConfig$auth43, _masterConfig$auth43$, _completionParams$pro3, _existingCreateSubOrg3;
4166
+ var existingCreateSubOrgParams = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth43 = masterConfig.auth) === null || _masterConfig$auth43 === void 0 ? void 0 : (_masterConfig$auth43$ = _masterConfig$auth43.createSuborgParams) === null || _masterConfig$auth43$ === void 0 ? void 0 : _masterConfig$auth43$.oauth;
4167
+ var secondaryProviders = buildSecondaryOauthProviders(completionParams.oidcToken, (_completionParams$pro3 = completionParams.providerName) !== null && _completionParams$pro3 !== void 0 ? _completionParams$pro3 : provider, secondaryClientIds);
4168
+ return _completeOauth(_objectSpread2(_objectSpread2({}, completionParams), secondaryProviders.length > 0 && {
4169
+ createSubOrgParams: _objectSpread2(_objectSpread2({}, existingCreateSubOrgParams), {}, {
4170
+ oauthProviders: [].concat(_toConsumableArray((_existingCreateSubOrg3 = existingCreateSubOrgParams === null || existingCreateSubOrgParams === void 0 ? void 0 : existingCreateSubOrgParams.oauthProviders) !== null && _existingCreateSubOrg3 !== void 0 ? _existingCreateSubOrg3 : []), _toConsumableArray(secondaryProviders))
4171
+ })
4172
+ }));
4173
+ },
4174
+ captchaToken: captchaToken,
4175
+ onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess,
4176
+ exchangeCodeForToken: function () {
4177
+ var _exchangeCodeForToken = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(codeVerifier) {
4178
+ var _resp$oidcToken;
4179
+ var resp, oidcToken;
4180
+ return _regenerator().w(function (_context96) {
4181
+ while (1) switch (_context96.n) {
4182
+ case 0:
4183
+ _context96.n = 1;
4184
+ return client === null || client === void 0 ? void 0 : client.httpClient.proxyOAuth2Authenticate({
4185
+ provider: "OAUTH2_PROVIDER_DISCORD",
4186
+ authCode: result.authCode,
4187
+ redirectUri: redirectUri,
4188
+ codeVerifier: codeVerifier,
4189
+ clientId: clientId,
4190
+ nonce: nonce
4191
+ });
4192
+ case 1:
4193
+ resp = _context96.v;
4194
+ oidcToken = (_resp$oidcToken = resp === null || resp === void 0 ? void 0 : resp.oidcToken) !== null && _resp$oidcToken !== void 0 ? _resp$oidcToken : ""; // Set the attested stamper with the oidcToken
4195
+ if (!oidcToken) {
4196
+ _context96.n = 2;
4197
+ break;
4198
+ }
4199
+ _context96.n = 2;
4200
+ return client === null || client === void 0 ? void 0 : client.overrideAttestedStamper({
4201
+ oidcToken: oidcToken,
4202
+ publicKey: publicKey
4203
+ });
4204
+ case 2:
4205
+ return _context96.a(2, oidcToken);
4206
+ }
4207
+ }, _callee96);
4208
+ }));
4209
+ function exchangeCodeForToken(_x81) {
4210
+ return _exchangeCodeForToken.apply(this, arguments);
4144
4211
  }
4145
- }, _callee95);
4146
- }));
4147
- function exchangeCodeForToken(_x80) {
4148
- return _exchangeCodeForToken.apply(this, arguments);
4149
- }
4150
- return exchangeCodeForToken;
4151
- }()
4152
- }).then(function () {
4153
- return resolve();
4154
- })["catch"](reject);
4155
- }
4212
+ return exchangeCodeForToken;
4213
+ }()
4214
+ }).then(function () {
4215
+ return resolve();
4216
+ })["catch"](reject);
4217
+ }
4218
+ }
4219
+ _context97.n = 3;
4220
+ break;
4221
+ case 2:
4222
+ _context97.p = 2;
4223
+ _context97.v;
4224
+ case 3:
4225
+ return _context97.a(2);
4156
4226
  }
4157
- } catch (_unused) {
4158
- // ignore cross-origin
4159
- }
4160
- }, 500);
4227
+ }, _callee97, null, [[0, 2]]);
4228
+ })), 500);
4161
4229
  if (authWindow.closed) {
4162
4230
  clearInterval(interval);
4163
4231
  }
4164
4232
  }));
4165
4233
  }
4166
- }, _callee96);
4234
+ }, _callee98);
4167
4235
  }));
4168
- return function (_x79) {
4169
- return _ref108.apply(this, arguments);
4236
+ return function (_x80) {
4237
+ return _ref111.apply(this, arguments);
4170
4238
  };
4171
4239
  }(), [client, callbacks, _completeOauth, createApiKeyPair, masterConfig]);
4172
4240
  var handleXOauth = useCallback(/*#__PURE__*/function () {
4173
- var _ref110 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(params) {
4174
- var _masterConfig$auth42, _masterConfig$auth42$, _masterConfig$auth42$2, _masterConfig$auth$oa6, _masterConfig$auth43, _masterConfig$auth43$, _masterConfig$auth43$2, _masterConfig$auth$oa7, _masterConfig$auth44, _masterConfig$auth44$, _masterConfig$auth45, _masterConfig$auth45$, _masterConfig$auth46;
4175
- var _ref111, _ref111$primaryClient, primaryClientId, _ref111$secondaryClie, secondaryClientIds, _ref111$openInPage, openInPage, additionalParameters, captchaToken, clientId, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, authUrl, authWindow;
4176
- return _regenerator().w(function (_context98) {
4177
- while (1) switch (_context98.n) {
4241
+ var _ref114 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101(params) {
4242
+ var _masterConfig$auth44, _masterConfig$auth44$, _masterConfig$auth44$2, _masterConfig$auth$oa6, _masterConfig$auth45, _masterConfig$auth45$, _masterConfig$auth45$2, _masterConfig$auth$oa7, _masterConfig$auth46, _masterConfig$auth46$, _masterConfig$auth47, _masterConfig$auth47$, _masterConfig$auth48;
4243
+ var _ref115, _ref115$primaryClient, primaryClientId, _ref115$secondaryClie, secondaryClientIds, _ref115$openInPage, openInPage, additionalParameters, captchaToken, clientId, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, authUrl, authWindow;
4244
+ return _regenerator().w(function (_context101) {
4245
+ while (1) switch (_context101.n) {
4178
4246
  case 0:
4179
- _ref111 = params || {}, _ref111$primaryClient = _ref111.primaryClientId, primaryClientId = _ref111$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth42 = masterConfig.auth) === null || _masterConfig$auth42 === void 0 ? void 0 : (_masterConfig$auth42$ = _masterConfig$auth42.oauthConfig) === null || _masterConfig$auth42$ === void 0 ? void 0 : (_masterConfig$auth42$2 = _masterConfig$auth42$.x) === null || _masterConfig$auth42$2 === void 0 ? void 0 : _masterConfig$auth42$2.primaryClientId : _ref111$primaryClient, _ref111$secondaryClie = _ref111.secondaryClientIds, secondaryClientIds = _ref111$secondaryClie === void 0 ? (_masterConfig$auth$oa6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth43 = masterConfig.auth) === null || _masterConfig$auth43 === void 0 ? void 0 : (_masterConfig$auth43$ = _masterConfig$auth43.oauthConfig) === null || _masterConfig$auth43$ === void 0 ? void 0 : (_masterConfig$auth43$2 = _masterConfig$auth43$.x) === null || _masterConfig$auth43$2 === void 0 ? void 0 : _masterConfig$auth43$2.secondaryClientIds) !== null && _masterConfig$auth$oa6 !== void 0 ? _masterConfig$auth$oa6 : [] : _ref111$secondaryClie, _ref111$openInPage = _ref111.openInPage, openInPage = _ref111$openInPage === void 0 ? (_masterConfig$auth$oa7 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth44 = masterConfig.auth) === null || _masterConfig$auth44 === void 0 ? void 0 : (_masterConfig$auth44$ = _masterConfig$auth44.oauthConfig) === null || _masterConfig$auth44$ === void 0 ? void 0 : _masterConfig$auth44$.openOauthInPage) !== null && _masterConfig$auth$oa7 !== void 0 ? _masterConfig$auth$oa7 : false : _ref111$openInPage, additionalParameters = _ref111.additionalState, captchaToken = _ref111.captchaToken;
4247
+ _ref115 = params || {}, _ref115$primaryClient = _ref115.primaryClientId, primaryClientId = _ref115$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth44 = masterConfig.auth) === null || _masterConfig$auth44 === void 0 ? void 0 : (_masterConfig$auth44$ = _masterConfig$auth44.oauthConfig) === null || _masterConfig$auth44$ === void 0 ? void 0 : (_masterConfig$auth44$2 = _masterConfig$auth44$.x) === null || _masterConfig$auth44$2 === void 0 ? void 0 : _masterConfig$auth44$2.primaryClientId : _ref115$primaryClient, _ref115$secondaryClie = _ref115.secondaryClientIds, secondaryClientIds = _ref115$secondaryClie === void 0 ? (_masterConfig$auth$oa6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth45 = masterConfig.auth) === null || _masterConfig$auth45 === void 0 ? void 0 : (_masterConfig$auth45$ = _masterConfig$auth45.oauthConfig) === null || _masterConfig$auth45$ === void 0 ? void 0 : (_masterConfig$auth45$2 = _masterConfig$auth45$.x) === null || _masterConfig$auth45$2 === void 0 ? void 0 : _masterConfig$auth45$2.secondaryClientIds) !== null && _masterConfig$auth$oa6 !== void 0 ? _masterConfig$auth$oa6 : [] : _ref115$secondaryClie, _ref115$openInPage = _ref115.openInPage, openInPage = _ref115$openInPage === void 0 ? (_masterConfig$auth$oa7 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth46 = masterConfig.auth) === null || _masterConfig$auth46 === void 0 ? void 0 : (_masterConfig$auth46$ = _masterConfig$auth46.oauthConfig) === null || _masterConfig$auth46$ === void 0 ? void 0 : _masterConfig$auth46$.openOauthInPage) !== null && _masterConfig$auth$oa7 !== void 0 ? _masterConfig$auth$oa7 : false : _ref115$openInPage, additionalParameters = _ref115.additionalState, captchaToken = _ref115.captchaToken;
4180
4248
  clientId = primaryClientId;
4181
4249
  provider = OAuthProviders.X;
4182
4250
  if (masterConfig) {
4183
- _context98.n = 1;
4251
+ _context101.n = 1;
4184
4252
  break;
4185
4253
  }
4186
4254
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4187
4255
  case 1:
4188
4256
  if (clientId) {
4189
- _context98.n = 2;
4257
+ _context101.n = 2;
4190
4258
  break;
4191
4259
  }
4192
4260
  throw new TurnkeyError("Twitter Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4193
4261
  case 2:
4194
- if ((_masterConfig$auth45 = masterConfig.auth) !== null && _masterConfig$auth45 !== void 0 && (_masterConfig$auth45$ = _masterConfig$auth45.oauthConfig) !== null && _masterConfig$auth45$ !== void 0 && _masterConfig$auth45$.oauthRedirectUri) {
4195
- _context98.n = 3;
4262
+ if ((_masterConfig$auth47 = masterConfig.auth) !== null && _masterConfig$auth47 !== void 0 && (_masterConfig$auth47$ = _masterConfig$auth47.oauthConfig) !== null && _masterConfig$auth47$ !== void 0 && _masterConfig$auth47$.oauthRedirectUri) {
4263
+ _context101.n = 3;
4196
4264
  break;
4197
4265
  }
4198
4266
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4199
4267
  case 3:
4200
4268
  flow = openInPage ? "redirect" : "popup";
4201
- redirectUri = (_masterConfig$auth46 = masterConfig.auth) === null || _masterConfig$auth46 === void 0 ? void 0 : _masterConfig$auth46.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4202
- _context98.n = 4;
4269
+ redirectUri = (_masterConfig$auth48 = masterConfig.auth) === null || _masterConfig$auth48 === void 0 ? void 0 : _masterConfig$auth48.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4270
+ _context101.n = 4;
4203
4271
  return createApiKeyPair();
4204
4272
  case 4:
4205
- publicKey = _context98.v;
4273
+ publicKey = _context101.v;
4206
4274
  if (publicKey) {
4207
- _context98.n = 5;
4275
+ _context101.n = 5;
4208
4276
  break;
4209
4277
  }
4210
4278
  throw new Error("Failed to create public key for OAuth.");
4211
4279
  case 5:
4212
4280
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair and store verifier
4213
- _context98.n = 6;
4281
+ _context101.n = 6;
4214
4282
  return generateChallengePair();
4215
4283
  case 6:
4216
- _yield$generateChalle2 = _context98.v;
4284
+ _yield$generateChalle2 = _context101.v;
4217
4285
  verifier = _yield$generateChalle2.verifier;
4218
4286
  codeChallenge = _yield$generateChalle2.codeChallenge;
4219
4287
  storePKCEVerifier(provider, verifier);
@@ -4233,134 +4301,158 @@ var ClientProvider = function ClientProvider(_ref) {
4233
4301
  additionalState: _objectSpread2({}, additionalParameters)
4234
4302
  });
4235
4303
  if (!openInPage) {
4236
- _context98.n = 7;
4304
+ _context101.n = 7;
4237
4305
  break;
4238
4306
  }
4239
- return _context98.a(2, redirectToOAuthProvider(authUrl));
4307
+ return _context101.a(2, redirectToOAuthProvider(authUrl));
4240
4308
  case 7:
4241
4309
  // Popup flow
4242
4310
  authWindow = openOAuthPopup();
4243
4311
  if (authWindow) {
4244
- _context98.n = 8;
4312
+ _context101.n = 8;
4245
4313
  break;
4246
4314
  }
4247
4315
  throw new Error("Failed to open ".concat(capitalizeProviderName(provider), " login window."));
4248
4316
  case 8:
4249
4317
  authWindow.location.href = authUrl;
4250
- return _context98.a(2, new Promise(function (resolve, reject) {
4251
- var interval = setInterval(function () {
4252
- try {
4253
- if (authWindow.closed) {
4254
- clearInterval(interval);
4255
- reject(new Error("Authentication window was closed."));
4256
- return;
4257
- }
4258
- var url = authWindow.location.href || "";
4259
- if (url.startsWith(window.location.origin)) {
4260
- var result = parseOAuthResponse(url, provider);
4261
- if (result) {
4262
- authWindow.close();
4318
+ return _context101.a(2, new Promise(function (resolve, reject) {
4319
+ var interval = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100() {
4320
+ var url, result;
4321
+ return _regenerator().w(function (_context100) {
4322
+ while (1) switch (_context100.p = _context100.n) {
4323
+ case 0:
4324
+ _context100.p = 0;
4325
+ if (!authWindow.closed) {
4326
+ _context100.n = 1;
4327
+ break;
4328
+ }
4263
4329
  clearInterval(interval);
4264
- completeOAuthPopup({
4265
- provider: provider,
4266
- publicKey: publicKey,
4267
- result: result,
4268
- callbacks: callbacks,
4269
- completeOauth: function completeOauth(completionParams) {
4270
- var _masterConfig$auth47, _masterConfig$auth47$, _completionParams$pro4, _existingCreateSubOrg4;
4271
- var existingCreateSubOrgParams = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth47 = masterConfig.auth) === null || _masterConfig$auth47 === void 0 ? void 0 : (_masterConfig$auth47$ = _masterConfig$auth47.createSuborgParams) === null || _masterConfig$auth47$ === void 0 ? void 0 : _masterConfig$auth47$.oauth;
4272
- var secondaryProviders = buildSecondaryOauthProviders(completionParams.oidcToken, (_completionParams$pro4 = completionParams.providerName) !== null && _completionParams$pro4 !== void 0 ? _completionParams$pro4 : provider, secondaryClientIds);
4273
- return _completeOauth(_objectSpread2(_objectSpread2({}, completionParams), secondaryProviders.length > 0 && {
4274
- createSubOrgParams: _objectSpread2(_objectSpread2({}, existingCreateSubOrgParams), {}, {
4275
- oauthProviders: [].concat(_toConsumableArray((_existingCreateSubOrg4 = existingCreateSubOrgParams === null || existingCreateSubOrgParams === void 0 ? void 0 : existingCreateSubOrgParams.oauthProviders) !== null && _existingCreateSubOrg4 !== void 0 ? _existingCreateSubOrg4 : []), _toConsumableArray(secondaryProviders))
4276
- })
4277
- }));
4278
- },
4279
- captchaToken: captchaToken,
4280
- onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess,
4281
- exchangeCodeForToken: function () {
4282
- var _exchangeCodeForToken2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(codeVerifier) {
4283
- var _resp$oidcToken2;
4284
- var resp;
4285
- return _regenerator().w(function (_context97) {
4286
- while (1) switch (_context97.n) {
4287
- case 0:
4288
- _context97.n = 1;
4289
- return client === null || client === void 0 ? void 0 : client.httpClient.proxyOAuth2Authenticate({
4290
- provider: "OAUTH2_PROVIDER_X",
4291
- authCode: result.authCode,
4292
- redirectUri: redirectUri,
4293
- codeVerifier: codeVerifier,
4294
- clientId: clientId,
4295
- nonce: nonce
4296
- });
4297
- case 1:
4298
- resp = _context97.v;
4299
- return _context97.a(2, (_resp$oidcToken2 = resp === null || resp === void 0 ? void 0 : resp.oidcToken) !== null && _resp$oidcToken2 !== void 0 ? _resp$oidcToken2 : "");
4330
+ reject(new Error("Authentication window was closed."));
4331
+ return _context100.a(2);
4332
+ case 1:
4333
+ url = authWindow.location.href || "";
4334
+ if (isExpectedOAuthRedirectUrl(url, redirectUri, OAUTH_PROVIDER_CONFIGS[provider].expectedResponseMode)) {
4335
+ result = parseOAuthResponse(url, provider);
4336
+ if (result) {
4337
+ authWindow.close();
4338
+ clearInterval(interval);
4339
+ completeOAuthPopup({
4340
+ provider: provider,
4341
+ publicKey: publicKey,
4342
+ result: result,
4343
+ callbacks: callbacks,
4344
+ completeOauth: function completeOauth(completionParams) {
4345
+ var _masterConfig$auth49, _masterConfig$auth49$, _completionParams$pro4, _existingCreateSubOrg4;
4346
+ var existingCreateSubOrgParams = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth49 = masterConfig.auth) === null || _masterConfig$auth49 === void 0 ? void 0 : (_masterConfig$auth49$ = _masterConfig$auth49.createSuborgParams) === null || _masterConfig$auth49$ === void 0 ? void 0 : _masterConfig$auth49$.oauth;
4347
+ var secondaryProviders = buildSecondaryOauthProviders(completionParams.oidcToken, (_completionParams$pro4 = completionParams.providerName) !== null && _completionParams$pro4 !== void 0 ? _completionParams$pro4 : provider, secondaryClientIds);
4348
+ return _completeOauth(_objectSpread2(_objectSpread2({}, completionParams), secondaryProviders.length > 0 && {
4349
+ createSubOrgParams: _objectSpread2(_objectSpread2({}, existingCreateSubOrgParams), {}, {
4350
+ oauthProviders: [].concat(_toConsumableArray((_existingCreateSubOrg4 = existingCreateSubOrgParams === null || existingCreateSubOrgParams === void 0 ? void 0 : existingCreateSubOrgParams.oauthProviders) !== null && _existingCreateSubOrg4 !== void 0 ? _existingCreateSubOrg4 : []), _toConsumableArray(secondaryProviders))
4351
+ })
4352
+ }));
4353
+ },
4354
+ captchaToken: captchaToken,
4355
+ onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess,
4356
+ exchangeCodeForToken: function () {
4357
+ var _exchangeCodeForToken2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99(codeVerifier) {
4358
+ var _resp$oidcToken2;
4359
+ var resp, oidcToken;
4360
+ return _regenerator().w(function (_context99) {
4361
+ while (1) switch (_context99.n) {
4362
+ case 0:
4363
+ _context99.n = 1;
4364
+ return client === null || client === void 0 ? void 0 : client.httpClient.proxyOAuth2Authenticate({
4365
+ provider: "OAUTH2_PROVIDER_X",
4366
+ authCode: result.authCode,
4367
+ redirectUri: redirectUri,
4368
+ codeVerifier: codeVerifier,
4369
+ clientId: clientId,
4370
+ nonce: nonce
4371
+ });
4372
+ case 1:
4373
+ resp = _context99.v;
4374
+ oidcToken = (_resp$oidcToken2 = resp === null || resp === void 0 ? void 0 : resp.oidcToken) !== null && _resp$oidcToken2 !== void 0 ? _resp$oidcToken2 : ""; // Set the attested stamper with the oidcToken
4375
+ if (!oidcToken) {
4376
+ _context99.n = 2;
4377
+ break;
4378
+ }
4379
+ _context99.n = 2;
4380
+ return client === null || client === void 0 ? void 0 : client.overrideAttestedStamper({
4381
+ oidcToken: oidcToken,
4382
+ publicKey: publicKey
4383
+ });
4384
+ case 2:
4385
+ return _context99.a(2, oidcToken);
4386
+ }
4387
+ }, _callee99);
4388
+ }));
4389
+ function exchangeCodeForToken(_x83) {
4390
+ return _exchangeCodeForToken2.apply(this, arguments);
4300
4391
  }
4301
- }, _callee97);
4302
- }));
4303
- function exchangeCodeForToken(_x82) {
4304
- return _exchangeCodeForToken2.apply(this, arguments);
4305
- }
4306
- return exchangeCodeForToken;
4307
- }()
4308
- }).then(function () {
4309
- return resolve();
4310
- })["catch"](reject);
4311
- }
4392
+ return exchangeCodeForToken;
4393
+ }()
4394
+ }).then(function () {
4395
+ return resolve();
4396
+ })["catch"](reject);
4397
+ }
4398
+ }
4399
+ _context100.n = 3;
4400
+ break;
4401
+ case 2:
4402
+ _context100.p = 2;
4403
+ _context100.v;
4404
+ case 3:
4405
+ return _context100.a(2);
4312
4406
  }
4313
- } catch (_unused2) {
4314
- // ignore cross-origin
4315
- }
4316
- }, 500);
4407
+ }, _callee100, null, [[0, 2]]);
4408
+ })), 500);
4317
4409
  if (authWindow.closed) {
4318
4410
  clearInterval(interval);
4319
4411
  }
4320
4412
  }));
4321
4413
  }
4322
- }, _callee98);
4414
+ }, _callee101);
4323
4415
  }));
4324
- return function (_x81) {
4325
- return _ref110.apply(this, arguments);
4416
+ return function (_x82) {
4417
+ return _ref114.apply(this, arguments);
4326
4418
  };
4327
4419
  }(), [client, callbacks, _completeOauth, createApiKeyPair, masterConfig]);
4328
4420
  var handleGoogleOauth = useCallback(/*#__PURE__*/function () {
4329
- var _ref112 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99(params) {
4330
- var _masterConfig$auth48, _masterConfig$auth48$, _masterConfig$auth48$2, _masterConfig$auth$oa8, _masterConfig$auth49, _masterConfig$auth49$, _masterConfig$auth49$2, _masterConfig$auth$oa9, _masterConfig$auth50, _masterConfig$auth50$, _masterConfig$auth51, _masterConfig$auth51$, _masterConfig$auth52;
4331
- var _ref113, _ref113$primaryClient, primaryClientId, _ref113$secondaryClie, secondaryClientIds, _ref113$openInPage, openInPage, additionalParameters, captchaToken, clientId, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4332
- return _regenerator().w(function (_context99) {
4333
- while (1) switch (_context99.n) {
4421
+ var _ref117 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee103(params) {
4422
+ var _masterConfig$auth50, _masterConfig$auth50$, _masterConfig$auth50$2, _masterConfig$auth$oa8, _masterConfig$auth51, _masterConfig$auth51$, _masterConfig$auth51$2, _masterConfig$auth$oa9, _masterConfig$auth52, _masterConfig$auth52$, _masterConfig$auth53, _masterConfig$auth53$, _masterConfig$auth54;
4423
+ var _ref118, _ref118$primaryClient, primaryClientId, _ref118$secondaryClie, secondaryClientIds, _ref118$openInPage, openInPage, additionalParameters, captchaToken, clientId, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4424
+ return _regenerator().w(function (_context103) {
4425
+ while (1) switch (_context103.n) {
4334
4426
  case 0:
4335
- _ref113 = params || {}, _ref113$primaryClient = _ref113.primaryClientId, primaryClientId = _ref113$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth48 = masterConfig.auth) === null || _masterConfig$auth48 === void 0 ? void 0 : (_masterConfig$auth48$ = _masterConfig$auth48.oauthConfig) === null || _masterConfig$auth48$ === void 0 ? void 0 : (_masterConfig$auth48$2 = _masterConfig$auth48$.google) === null || _masterConfig$auth48$2 === void 0 ? void 0 : _masterConfig$auth48$2.primaryClientId : _ref113$primaryClient, _ref113$secondaryClie = _ref113.secondaryClientIds, secondaryClientIds = _ref113$secondaryClie === void 0 ? (_masterConfig$auth$oa8 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth49 = masterConfig.auth) === null || _masterConfig$auth49 === void 0 ? void 0 : (_masterConfig$auth49$ = _masterConfig$auth49.oauthConfig) === null || _masterConfig$auth49$ === void 0 ? void 0 : (_masterConfig$auth49$2 = _masterConfig$auth49$.google) === null || _masterConfig$auth49$2 === void 0 ? void 0 : _masterConfig$auth49$2.secondaryClientIds) !== null && _masterConfig$auth$oa8 !== void 0 ? _masterConfig$auth$oa8 : [] : _ref113$secondaryClie, _ref113$openInPage = _ref113.openInPage, openInPage = _ref113$openInPage === void 0 ? (_masterConfig$auth$oa9 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth50 = masterConfig.auth) === null || _masterConfig$auth50 === void 0 ? void 0 : (_masterConfig$auth50$ = _masterConfig$auth50.oauthConfig) === null || _masterConfig$auth50$ === void 0 ? void 0 : _masterConfig$auth50$.openOauthInPage) !== null && _masterConfig$auth$oa9 !== void 0 ? _masterConfig$auth$oa9 : false : _ref113$openInPage, additionalParameters = _ref113.additionalState, captchaToken = _ref113.captchaToken;
4427
+ _ref118 = params || {}, _ref118$primaryClient = _ref118.primaryClientId, primaryClientId = _ref118$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth50 = masterConfig.auth) === null || _masterConfig$auth50 === void 0 ? void 0 : (_masterConfig$auth50$ = _masterConfig$auth50.oauthConfig) === null || _masterConfig$auth50$ === void 0 ? void 0 : (_masterConfig$auth50$2 = _masterConfig$auth50$.google) === null || _masterConfig$auth50$2 === void 0 ? void 0 : _masterConfig$auth50$2.primaryClientId : _ref118$primaryClient, _ref118$secondaryClie = _ref118.secondaryClientIds, secondaryClientIds = _ref118$secondaryClie === void 0 ? (_masterConfig$auth$oa8 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth51 = masterConfig.auth) === null || _masterConfig$auth51 === void 0 ? void 0 : (_masterConfig$auth51$ = _masterConfig$auth51.oauthConfig) === null || _masterConfig$auth51$ === void 0 ? void 0 : (_masterConfig$auth51$2 = _masterConfig$auth51$.google) === null || _masterConfig$auth51$2 === void 0 ? void 0 : _masterConfig$auth51$2.secondaryClientIds) !== null && _masterConfig$auth$oa8 !== void 0 ? _masterConfig$auth$oa8 : [] : _ref118$secondaryClie, _ref118$openInPage = _ref118.openInPage, openInPage = _ref118$openInPage === void 0 ? (_masterConfig$auth$oa9 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth52 = masterConfig.auth) === null || _masterConfig$auth52 === void 0 ? void 0 : (_masterConfig$auth52$ = _masterConfig$auth52.oauthConfig) === null || _masterConfig$auth52$ === void 0 ? void 0 : _masterConfig$auth52$.openOauthInPage) !== null && _masterConfig$auth$oa9 !== void 0 ? _masterConfig$auth$oa9 : false : _ref118$openInPage, additionalParameters = _ref118.additionalState, captchaToken = _ref118.captchaToken;
4336
4428
  clientId = primaryClientId;
4337
4429
  provider = OAuthProviders.GOOGLE;
4338
4430
  if (masterConfig) {
4339
- _context99.n = 1;
4431
+ _context103.n = 1;
4340
4432
  break;
4341
4433
  }
4342
4434
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4343
4435
  case 1:
4344
4436
  if (clientId) {
4345
- _context99.n = 2;
4437
+ _context103.n = 2;
4346
4438
  break;
4347
4439
  }
4348
4440
  throw new TurnkeyError("Google Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4349
4441
  case 2:
4350
- if ((_masterConfig$auth51 = masterConfig.auth) !== null && _masterConfig$auth51 !== void 0 && (_masterConfig$auth51$ = _masterConfig$auth51.oauthConfig) !== null && _masterConfig$auth51$ !== void 0 && _masterConfig$auth51$.oauthRedirectUri) {
4351
- _context99.n = 3;
4442
+ if ((_masterConfig$auth53 = masterConfig.auth) !== null && _masterConfig$auth53 !== void 0 && (_masterConfig$auth53$ = _masterConfig$auth53.oauthConfig) !== null && _masterConfig$auth53$ !== void 0 && _masterConfig$auth53$.oauthRedirectUri) {
4443
+ _context103.n = 3;
4352
4444
  break;
4353
4445
  }
4354
4446
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4355
4447
  case 3:
4356
4448
  flow = openInPage ? "redirect" : "popup"; // Google requires no trailing slash
4357
- redirectUri = (_masterConfig$auth52 = masterConfig.auth) === null || _masterConfig$auth52 === void 0 ? void 0 : _masterConfig$auth52.oauthConfig.oauthRedirectUri.replace(/\/$/, ""); // Create key pair and generate nonce
4358
- _context99.n = 4;
4449
+ redirectUri = (_masterConfig$auth54 = masterConfig.auth) === null || _masterConfig$auth54 === void 0 ? void 0 : _masterConfig$auth54.oauthConfig.oauthRedirectUri.replace(/\/$/, ""); // Create key pair and generate nonce
4450
+ _context103.n = 4;
4359
4451
  return createApiKeyPair();
4360
4452
  case 4:
4361
- publicKey = _context99.v;
4453
+ publicKey = _context103.v;
4362
4454
  if (publicKey) {
4363
- _context99.n = 5;
4455
+ _context103.n = 5;
4364
4456
  break;
4365
4457
  }
4366
4458
  throw new Error("Failed to create public key for OAuth.");
@@ -4380,42 +4472,66 @@ var ClientProvider = function ClientProvider(_ref) {
4380
4472
  additionalState: _objectSpread2({}, additionalParameters)
4381
4473
  });
4382
4474
  if (!openInPage) {
4383
- _context99.n = 6;
4475
+ _context103.n = 6;
4384
4476
  break;
4385
4477
  }
4386
- return _context99.a(2, redirectToOAuthProvider(authUrl));
4478
+ return _context103.a(2, redirectToOAuthProvider(authUrl));
4387
4479
  case 6:
4388
4480
  // Popup flow
4389
4481
  authWindow = openOAuthPopup();
4390
4482
  if (authWindow) {
4391
- _context99.n = 7;
4483
+ _context103.n = 7;
4392
4484
  break;
4393
4485
  }
4394
4486
  throw new Error("Failed to open ".concat(capitalizeProviderName(provider), " login window."));
4395
4487
  case 7:
4396
4488
  authWindow.location.href = authUrl;
4397
- return _context99.a(2, new Promise(function (resolve, reject) {
4398
- var interval = setInterval(function () {
4399
- try {
4400
- if (authWindow.closed) {
4401
- clearInterval(interval);
4402
- reject(new Error("Authentication window was closed."));
4403
- return;
4404
- }
4405
- var url = authWindow.location.href || "";
4406
- if (url.startsWith(window.location.origin)) {
4407
- var result = parseOAuthResponse(url, provider);
4408
- if (result) {
4489
+ return _context103.a(2, new Promise(function (resolve, reject) {
4490
+ var interval = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102() {
4491
+ var url, result;
4492
+ return _regenerator().w(function (_context102) {
4493
+ while (1) switch (_context102.p = _context102.n) {
4494
+ case 0:
4495
+ _context102.p = 0;
4496
+ if (!authWindow.closed) {
4497
+ _context102.n = 1;
4498
+ break;
4499
+ }
4500
+ clearInterval(interval);
4501
+ reject(new Error("Authentication window was closed."));
4502
+ return _context102.a(2);
4503
+ case 1:
4504
+ url = authWindow.location.href || "";
4505
+ if (!isExpectedOAuthRedirectUrl(url, redirectUri, OAUTH_PROVIDER_CONFIGS[provider].expectedResponseMode)) {
4506
+ _context102.n = 3;
4507
+ break;
4508
+ }
4509
+ result = parseOAuthResponse(url, provider);
4510
+ if (!result) {
4511
+ _context102.n = 3;
4512
+ break;
4513
+ }
4409
4514
  authWindow.close();
4410
4515
  clearInterval(interval);
4516
+ // Set the attested stamper with the oidcToken
4517
+ if (!result.idToken) {
4518
+ _context102.n = 2;
4519
+ break;
4520
+ }
4521
+ _context102.n = 2;
4522
+ return client === null || client === void 0 ? void 0 : client.overrideAttestedStamper({
4523
+ oidcToken: result.idToken,
4524
+ publicKey: publicKey
4525
+ });
4526
+ case 2:
4411
4527
  completeOAuthPopup({
4412
4528
  provider: provider,
4413
4529
  publicKey: publicKey,
4414
4530
  result: result,
4415
4531
  callbacks: callbacks,
4416
4532
  completeOauth: function completeOauth(completionParams) {
4417
- var _masterConfig$auth53, _masterConfig$auth53$, _completionParams$pro5, _existingCreateSubOrg5;
4418
- var existingCreateSubOrgParams = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth53 = masterConfig.auth) === null || _masterConfig$auth53 === void 0 ? void 0 : (_masterConfig$auth53$ = _masterConfig$auth53.createSuborgParams) === null || _masterConfig$auth53$ === void 0 ? void 0 : _masterConfig$auth53$.oauth;
4533
+ var _masterConfig$auth55, _masterConfig$auth55$, _completionParams$pro5, _existingCreateSubOrg5;
4534
+ var existingCreateSubOrgParams = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth55 = masterConfig.auth) === null || _masterConfig$auth55 === void 0 ? void 0 : (_masterConfig$auth55$ = _masterConfig$auth55.createSuborgParams) === null || _masterConfig$auth55$ === void 0 ? void 0 : _masterConfig$auth55$.oauth;
4419
4535
  var secondaryProviders = buildSecondaryOauthProviders(completionParams.oidcToken, (_completionParams$pro5 = completionParams.providerName) !== null && _completionParams$pro5 !== void 0 ? _completionParams$pro5 : provider, secondaryClientIds);
4420
4536
  return _completeOauth(_objectSpread2(_objectSpread2({}, completionParams), secondaryProviders.length > 0 && {
4421
4537
  createSubOrgParams: _objectSpread2(_objectSpread2({}, existingCreateSubOrgParams), {}, {
@@ -4428,59 +4544,64 @@ var ClientProvider = function ClientProvider(_ref) {
4428
4544
  }).then(function () {
4429
4545
  return resolve();
4430
4546
  })["catch"](reject);
4431
- }
4547
+ case 3:
4548
+ _context102.n = 5;
4549
+ break;
4550
+ case 4:
4551
+ _context102.p = 4;
4552
+ _context102.v;
4553
+ case 5:
4554
+ return _context102.a(2);
4432
4555
  }
4433
- } catch (_unused3) {
4434
- // Ignore cross-origin errors
4435
- }
4436
- }, 500);
4556
+ }, _callee102, null, [[0, 4]]);
4557
+ })), 500);
4437
4558
  if (authWindow.closed) {
4438
4559
  clearInterval(interval);
4439
4560
  }
4440
4561
  }));
4441
4562
  }
4442
- }, _callee99);
4563
+ }, _callee103);
4443
4564
  }));
4444
- return function (_x83) {
4445
- return _ref112.apply(this, arguments);
4565
+ return function (_x84) {
4566
+ return _ref117.apply(this, arguments);
4446
4567
  };
4447
4568
  }(), [callbacks, _completeOauth, createApiKeyPair, masterConfig]);
4448
4569
  var handleAppleOauth = useCallback(/*#__PURE__*/function () {
4449
- var _ref114 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100(params) {
4450
- var _masterConfig$auth54, _masterConfig$auth54$, _masterConfig$auth54$2, _masterConfig$auth$oa0, _masterConfig$auth55, _masterConfig$auth55$, _masterConfig$auth55$2, _masterConfig$auth$oa1, _masterConfig$auth56, _masterConfig$auth56$, _masterConfig$auth57, _masterConfig$auth57$, _masterConfig$auth58;
4451
- var _ref115, _ref115$primaryClient, primaryClientId, _ref115$secondaryClie, secondaryClientIds, _ref115$openInPage, openInPage, additionalParameters, captchaToken, clientId, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4452
- return _regenerator().w(function (_context100) {
4453
- while (1) switch (_context100.n) {
4570
+ var _ref120 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee105(params) {
4571
+ var _masterConfig$auth56, _masterConfig$auth56$, _masterConfig$auth56$2, _masterConfig$auth$oa0, _masterConfig$auth57, _masterConfig$auth57$, _masterConfig$auth57$2, _masterConfig$auth$oa1, _masterConfig$auth58, _masterConfig$auth58$, _masterConfig$auth59, _masterConfig$auth59$, _masterConfig$auth60;
4572
+ var _ref121, _ref121$primaryClient, primaryClientId, _ref121$secondaryClie, secondaryClientIds, _ref121$openInPage, openInPage, additionalParameters, captchaToken, clientId, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4573
+ return _regenerator().w(function (_context105) {
4574
+ while (1) switch (_context105.n) {
4454
4575
  case 0:
4455
- _ref115 = params || {}, _ref115$primaryClient = _ref115.primaryClientId, primaryClientId = _ref115$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth54 = masterConfig.auth) === null || _masterConfig$auth54 === void 0 ? void 0 : (_masterConfig$auth54$ = _masterConfig$auth54.oauthConfig) === null || _masterConfig$auth54$ === void 0 ? void 0 : (_masterConfig$auth54$2 = _masterConfig$auth54$.apple) === null || _masterConfig$auth54$2 === void 0 ? void 0 : _masterConfig$auth54$2.primaryClientId : _ref115$primaryClient, _ref115$secondaryClie = _ref115.secondaryClientIds, secondaryClientIds = _ref115$secondaryClie === void 0 ? (_masterConfig$auth$oa0 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth55 = masterConfig.auth) === null || _masterConfig$auth55 === void 0 ? void 0 : (_masterConfig$auth55$ = _masterConfig$auth55.oauthConfig) === null || _masterConfig$auth55$ === void 0 ? void 0 : (_masterConfig$auth55$2 = _masterConfig$auth55$.apple) === null || _masterConfig$auth55$2 === void 0 ? void 0 : _masterConfig$auth55$2.secondaryClientIds) !== null && _masterConfig$auth$oa0 !== void 0 ? _masterConfig$auth$oa0 : [] : _ref115$secondaryClie, _ref115$openInPage = _ref115.openInPage, openInPage = _ref115$openInPage === void 0 ? (_masterConfig$auth$oa1 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth56 = masterConfig.auth) === null || _masterConfig$auth56 === void 0 ? void 0 : (_masterConfig$auth56$ = _masterConfig$auth56.oauthConfig) === null || _masterConfig$auth56$ === void 0 ? void 0 : _masterConfig$auth56$.openOauthInPage) !== null && _masterConfig$auth$oa1 !== void 0 ? _masterConfig$auth$oa1 : false : _ref115$openInPage, additionalParameters = _ref115.additionalState, captchaToken = _ref115.captchaToken;
4576
+ _ref121 = params || {}, _ref121$primaryClient = _ref121.primaryClientId, primaryClientId = _ref121$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth56 = masterConfig.auth) === null || _masterConfig$auth56 === void 0 ? void 0 : (_masterConfig$auth56$ = _masterConfig$auth56.oauthConfig) === null || _masterConfig$auth56$ === void 0 ? void 0 : (_masterConfig$auth56$2 = _masterConfig$auth56$.apple) === null || _masterConfig$auth56$2 === void 0 ? void 0 : _masterConfig$auth56$2.primaryClientId : _ref121$primaryClient, _ref121$secondaryClie = _ref121.secondaryClientIds, secondaryClientIds = _ref121$secondaryClie === void 0 ? (_masterConfig$auth$oa0 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth57 = masterConfig.auth) === null || _masterConfig$auth57 === void 0 ? void 0 : (_masterConfig$auth57$ = _masterConfig$auth57.oauthConfig) === null || _masterConfig$auth57$ === void 0 ? void 0 : (_masterConfig$auth57$2 = _masterConfig$auth57$.apple) === null || _masterConfig$auth57$2 === void 0 ? void 0 : _masterConfig$auth57$2.secondaryClientIds) !== null && _masterConfig$auth$oa0 !== void 0 ? _masterConfig$auth$oa0 : [] : _ref121$secondaryClie, _ref121$openInPage = _ref121.openInPage, openInPage = _ref121$openInPage === void 0 ? (_masterConfig$auth$oa1 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth58 = masterConfig.auth) === null || _masterConfig$auth58 === void 0 ? void 0 : (_masterConfig$auth58$ = _masterConfig$auth58.oauthConfig) === null || _masterConfig$auth58$ === void 0 ? void 0 : _masterConfig$auth58$.openOauthInPage) !== null && _masterConfig$auth$oa1 !== void 0 ? _masterConfig$auth$oa1 : false : _ref121$openInPage, additionalParameters = _ref121.additionalState, captchaToken = _ref121.captchaToken;
4456
4577
  clientId = primaryClientId;
4457
4578
  provider = OAuthProviders.APPLE;
4458
4579
  if (masterConfig) {
4459
- _context100.n = 1;
4580
+ _context105.n = 1;
4460
4581
  break;
4461
4582
  }
4462
4583
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4463
4584
  case 1:
4464
4585
  if (clientId) {
4465
- _context100.n = 2;
4586
+ _context105.n = 2;
4466
4587
  break;
4467
4588
  }
4468
4589
  throw new TurnkeyError("Apple Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4469
4590
  case 2:
4470
- if ((_masterConfig$auth57 = masterConfig.auth) !== null && _masterConfig$auth57 !== void 0 && (_masterConfig$auth57$ = _masterConfig$auth57.oauthConfig) !== null && _masterConfig$auth57$ !== void 0 && _masterConfig$auth57$.oauthRedirectUri) {
4471
- _context100.n = 3;
4591
+ if ((_masterConfig$auth59 = masterConfig.auth) !== null && _masterConfig$auth59 !== void 0 && (_masterConfig$auth59$ = _masterConfig$auth59.oauthConfig) !== null && _masterConfig$auth59$ !== void 0 && _masterConfig$auth59$.oauthRedirectUri) {
4592
+ _context105.n = 3;
4472
4593
  break;
4473
4594
  }
4474
4595
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4475
4596
  case 3:
4476
4597
  flow = openInPage ? "redirect" : "popup"; // TODO (Amir): Apple needs the '/' at the end. Maybe we should add it if not there?
4477
- redirectUri = (_masterConfig$auth58 = masterConfig.auth) === null || _masterConfig$auth58 === void 0 ? void 0 : _masterConfig$auth58.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4478
- _context100.n = 4;
4598
+ redirectUri = (_masterConfig$auth60 = masterConfig.auth) === null || _masterConfig$auth60 === void 0 ? void 0 : _masterConfig$auth60.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4599
+ _context105.n = 4;
4479
4600
  return createApiKeyPair();
4480
4601
  case 4:
4481
- publicKey = _context100.v;
4602
+ publicKey = _context105.v;
4482
4603
  if (publicKey) {
4483
- _context100.n = 5;
4604
+ _context105.n = 5;
4484
4605
  break;
4485
4606
  }
4486
4607
  throw new Error("Failed to create public key for OAuth.");
@@ -4500,42 +4621,66 @@ var ClientProvider = function ClientProvider(_ref) {
4500
4621
  additionalState: _objectSpread2({}, additionalParameters)
4501
4622
  });
4502
4623
  if (!openInPage) {
4503
- _context100.n = 6;
4624
+ _context105.n = 6;
4504
4625
  break;
4505
4626
  }
4506
- return _context100.a(2, redirectToOAuthProvider(authUrl));
4627
+ return _context105.a(2, redirectToOAuthProvider(authUrl));
4507
4628
  case 6:
4508
4629
  // Popup flow
4509
4630
  authWindow = openOAuthPopup();
4510
4631
  if (authWindow) {
4511
- _context100.n = 7;
4632
+ _context105.n = 7;
4512
4633
  break;
4513
4634
  }
4514
4635
  throw new Error("Failed to open ".concat(capitalizeProviderName(provider), " login window."));
4515
4636
  case 7:
4516
4637
  authWindow.location.href = authUrl;
4517
- return _context100.a(2, new Promise(function (resolve, reject) {
4518
- var interval = setInterval(function () {
4519
- try {
4520
- if (authWindow.closed) {
4521
- clearInterval(interval);
4522
- reject(new Error("Authentication window was closed."));
4523
- return;
4524
- }
4525
- var url = authWindow.location.href || "";
4526
- if (url.startsWith(window.location.origin)) {
4527
- var result = parseOAuthResponse(url, provider);
4528
- if (result) {
4529
- authWindow.close();
4638
+ return _context105.a(2, new Promise(function (resolve, reject) {
4639
+ var interval = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee104() {
4640
+ var url, result;
4641
+ return _regenerator().w(function (_context104) {
4642
+ while (1) switch (_context104.p = _context104.n) {
4643
+ case 0:
4644
+ _context104.p = 0;
4645
+ if (!authWindow.closed) {
4646
+ _context104.n = 1;
4647
+ break;
4648
+ }
4649
+ clearInterval(interval);
4650
+ reject(new Error("Authentication window was closed."));
4651
+ return _context104.a(2);
4652
+ case 1:
4653
+ url = authWindow.location.href || "";
4654
+ if (!isExpectedOAuthRedirectUrl(url, redirectUri, OAUTH_PROVIDER_CONFIGS[provider].expectedResponseMode)) {
4655
+ _context104.n = 3;
4656
+ break;
4657
+ }
4658
+ result = parseOAuthResponse(url, provider);
4659
+ if (!result) {
4660
+ _context104.n = 3;
4661
+ break;
4662
+ }
4663
+ authWindow.close();
4530
4664
  clearInterval(interval);
4665
+ // Set the attested stamper with the oidcToken
4666
+ if (!result.idToken) {
4667
+ _context104.n = 2;
4668
+ break;
4669
+ }
4670
+ _context104.n = 2;
4671
+ return client === null || client === void 0 ? void 0 : client.overrideAttestedStamper({
4672
+ oidcToken: result.idToken,
4673
+ publicKey: publicKey
4674
+ });
4675
+ case 2:
4531
4676
  completeOAuthPopup({
4532
4677
  provider: provider,
4533
4678
  publicKey: publicKey,
4534
4679
  result: result,
4535
4680
  callbacks: callbacks,
4536
4681
  completeOauth: function completeOauth(completionParams) {
4537
- var _masterConfig$auth59, _masterConfig$auth59$, _completionParams$pro6, _existingCreateSubOrg6;
4538
- var existingCreateSubOrgParams = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth59 = masterConfig.auth) === null || _masterConfig$auth59 === void 0 ? void 0 : (_masterConfig$auth59$ = _masterConfig$auth59.createSuborgParams) === null || _masterConfig$auth59$ === void 0 ? void 0 : _masterConfig$auth59$.oauth;
4682
+ var _masterConfig$auth61, _masterConfig$auth61$, _completionParams$pro6, _existingCreateSubOrg6;
4683
+ var existingCreateSubOrgParams = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth61 = masterConfig.auth) === null || _masterConfig$auth61 === void 0 ? void 0 : (_masterConfig$auth61$ = _masterConfig$auth61.createSuborgParams) === null || _masterConfig$auth61$ === void 0 ? void 0 : _masterConfig$auth61$.oauth;
4539
4684
  var secondaryProviders = buildSecondaryOauthProviders(completionParams.oidcToken, (_completionParams$pro6 = completionParams.providerName) !== null && _completionParams$pro6 !== void 0 ? _completionParams$pro6 : provider, secondaryClientIds);
4540
4685
  return _completeOauth(_objectSpread2(_objectSpread2({}, completionParams), secondaryProviders.length > 0 && {
4541
4686
  createSubOrgParams: _objectSpread2(_objectSpread2({}, existingCreateSubOrgParams), {}, {
@@ -4548,68 +4693,73 @@ var ClientProvider = function ClientProvider(_ref) {
4548
4693
  }).then(function () {
4549
4694
  return resolve();
4550
4695
  })["catch"](reject);
4551
- }
4696
+ case 3:
4697
+ _context104.n = 5;
4698
+ break;
4699
+ case 4:
4700
+ _context104.p = 4;
4701
+ _context104.v;
4702
+ case 5:
4703
+ return _context104.a(2);
4552
4704
  }
4553
- } catch (_unused4) {
4554
- // Ignore cross-origin errors
4555
- }
4556
- }, 500);
4705
+ }, _callee104, null, [[0, 4]]);
4706
+ })), 500);
4557
4707
  if (authWindow.closed) {
4558
4708
  clearInterval(interval);
4559
4709
  }
4560
4710
  }));
4561
4711
  }
4562
- }, _callee100);
4712
+ }, _callee105);
4563
4713
  }));
4564
- return function (_x84) {
4565
- return _ref114.apply(this, arguments);
4714
+ return function (_x85) {
4715
+ return _ref120.apply(this, arguments);
4566
4716
  };
4567
4717
  }(), [callbacks, _completeOauth, createApiKeyPair, masterConfig]);
4568
4718
  var handleFacebookOauth = useCallback(/*#__PURE__*/function () {
4569
- var _ref116 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102(params) {
4570
- var _masterConfig$auth60, _masterConfig$auth60$, _masterConfig$auth60$2, _masterConfig$auth$oa10, _masterConfig$auth61, _masterConfig$auth61$, _masterConfig$auth61$2, _masterConfig$auth$oa11, _masterConfig$auth62, _masterConfig$auth62$, _masterConfig$auth63, _masterConfig$auth63$, _masterConfig$auth64;
4571
- var _ref117, _ref117$primaryClient, primaryClientId, _ref117$secondaryClie, secondaryClientIds, _ref117$openInPage, openInPage, additionalParameters, captchaToken, clientId, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, authUrl, authWindow;
4572
- return _regenerator().w(function (_context102) {
4573
- while (1) switch (_context102.n) {
4719
+ var _ref123 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee108(params) {
4720
+ var _masterConfig$auth62, _masterConfig$auth62$, _masterConfig$auth62$2, _masterConfig$auth$oa10, _masterConfig$auth63, _masterConfig$auth63$, _masterConfig$auth63$2, _masterConfig$auth$oa11, _masterConfig$auth64, _masterConfig$auth64$, _masterConfig$auth65, _masterConfig$auth65$, _masterConfig$auth66;
4721
+ var _ref124, _ref124$primaryClient, primaryClientId, _ref124$secondaryClie, secondaryClientIds, _ref124$openInPage, openInPage, additionalParameters, captchaToken, clientId, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, authUrl, authWindow;
4722
+ return _regenerator().w(function (_context108) {
4723
+ while (1) switch (_context108.n) {
4574
4724
  case 0:
4575
- _ref117 = params || {}, _ref117$primaryClient = _ref117.primaryClientId, primaryClientId = _ref117$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth60 = masterConfig.auth) === null || _masterConfig$auth60 === void 0 ? void 0 : (_masterConfig$auth60$ = _masterConfig$auth60.oauthConfig) === null || _masterConfig$auth60$ === void 0 ? void 0 : (_masterConfig$auth60$2 = _masterConfig$auth60$.facebook) === null || _masterConfig$auth60$2 === void 0 ? void 0 : _masterConfig$auth60$2.primaryClientId : _ref117$primaryClient, _ref117$secondaryClie = _ref117.secondaryClientIds, secondaryClientIds = _ref117$secondaryClie === void 0 ? (_masterConfig$auth$oa10 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth61 = masterConfig.auth) === null || _masterConfig$auth61 === void 0 ? void 0 : (_masterConfig$auth61$ = _masterConfig$auth61.oauthConfig) === null || _masterConfig$auth61$ === void 0 ? void 0 : (_masterConfig$auth61$2 = _masterConfig$auth61$.facebook) === null || _masterConfig$auth61$2 === void 0 ? void 0 : _masterConfig$auth61$2.secondaryClientIds) !== null && _masterConfig$auth$oa10 !== void 0 ? _masterConfig$auth$oa10 : [] : _ref117$secondaryClie, _ref117$openInPage = _ref117.openInPage, openInPage = _ref117$openInPage === void 0 ? (_masterConfig$auth$oa11 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth62 = masterConfig.auth) === null || _masterConfig$auth62 === void 0 ? void 0 : (_masterConfig$auth62$ = _masterConfig$auth62.oauthConfig) === null || _masterConfig$auth62$ === void 0 ? void 0 : _masterConfig$auth62$.openOauthInPage) !== null && _masterConfig$auth$oa11 !== void 0 ? _masterConfig$auth$oa11 : false : _ref117$openInPage, additionalParameters = _ref117.additionalState, captchaToken = _ref117.captchaToken;
4725
+ _ref124 = params || {}, _ref124$primaryClient = _ref124.primaryClientId, primaryClientId = _ref124$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth62 = masterConfig.auth) === null || _masterConfig$auth62 === void 0 ? void 0 : (_masterConfig$auth62$ = _masterConfig$auth62.oauthConfig) === null || _masterConfig$auth62$ === void 0 ? void 0 : (_masterConfig$auth62$2 = _masterConfig$auth62$.facebook) === null || _masterConfig$auth62$2 === void 0 ? void 0 : _masterConfig$auth62$2.primaryClientId : _ref124$primaryClient, _ref124$secondaryClie = _ref124.secondaryClientIds, secondaryClientIds = _ref124$secondaryClie === void 0 ? (_masterConfig$auth$oa10 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth63 = masterConfig.auth) === null || _masterConfig$auth63 === void 0 ? void 0 : (_masterConfig$auth63$ = _masterConfig$auth63.oauthConfig) === null || _masterConfig$auth63$ === void 0 ? void 0 : (_masterConfig$auth63$2 = _masterConfig$auth63$.facebook) === null || _masterConfig$auth63$2 === void 0 ? void 0 : _masterConfig$auth63$2.secondaryClientIds) !== null && _masterConfig$auth$oa10 !== void 0 ? _masterConfig$auth$oa10 : [] : _ref124$secondaryClie, _ref124$openInPage = _ref124.openInPage, openInPage = _ref124$openInPage === void 0 ? (_masterConfig$auth$oa11 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth64 = masterConfig.auth) === null || _masterConfig$auth64 === void 0 ? void 0 : (_masterConfig$auth64$ = _masterConfig$auth64.oauthConfig) === null || _masterConfig$auth64$ === void 0 ? void 0 : _masterConfig$auth64$.openOauthInPage) !== null && _masterConfig$auth$oa11 !== void 0 ? _masterConfig$auth$oa11 : false : _ref124$openInPage, additionalParameters = _ref124.additionalState, captchaToken = _ref124.captchaToken;
4576
4726
  clientId = primaryClientId;
4577
4727
  provider = OAuthProviders.FACEBOOK;
4578
4728
  if (masterConfig) {
4579
- _context102.n = 1;
4729
+ _context108.n = 1;
4580
4730
  break;
4581
4731
  }
4582
4732
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4583
4733
  case 1:
4584
4734
  if (clientId) {
4585
- _context102.n = 2;
4735
+ _context108.n = 2;
4586
4736
  break;
4587
4737
  }
4588
4738
  throw new TurnkeyError("Facebook Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4589
4739
  case 2:
4590
- if ((_masterConfig$auth63 = masterConfig.auth) !== null && _masterConfig$auth63 !== void 0 && (_masterConfig$auth63$ = _masterConfig$auth63.oauthConfig) !== null && _masterConfig$auth63$ !== void 0 && _masterConfig$auth63$.oauthRedirectUri) {
4591
- _context102.n = 3;
4740
+ if ((_masterConfig$auth65 = masterConfig.auth) !== null && _masterConfig$auth65 !== void 0 && (_masterConfig$auth65$ = _masterConfig$auth65.oauthConfig) !== null && _masterConfig$auth65$ !== void 0 && _masterConfig$auth65$.oauthRedirectUri) {
4741
+ _context108.n = 3;
4592
4742
  break;
4593
4743
  }
4594
4744
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4595
4745
  case 3:
4596
4746
  flow = openInPage ? "redirect" : "popup";
4597
- redirectUri = (_masterConfig$auth64 = masterConfig.auth) === null || _masterConfig$auth64 === void 0 ? void 0 : _masterConfig$auth64.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4598
- _context102.n = 4;
4747
+ redirectUri = (_masterConfig$auth66 = masterConfig.auth) === null || _masterConfig$auth66 === void 0 ? void 0 : _masterConfig$auth66.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4748
+ _context108.n = 4;
4599
4749
  return createApiKeyPair();
4600
4750
  case 4:
4601
- publicKey = _context102.v;
4751
+ publicKey = _context108.v;
4602
4752
  if (publicKey) {
4603
- _context102.n = 5;
4753
+ _context108.n = 5;
4604
4754
  break;
4605
4755
  }
4606
4756
  throw new Error("Failed to create public key for OAuth.");
4607
4757
  case 5:
4608
4758
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair and store verifier
4609
- _context102.n = 6;
4759
+ _context108.n = 6;
4610
4760
  return generateChallengePair();
4611
4761
  case 6:
4612
- _yield$generateChalle3 = _context102.v;
4762
+ _yield$generateChalle3 = _context108.v;
4613
4763
  verifier = _yield$generateChalle3.verifier;
4614
4764
  codeChallenge = _yield$generateChalle3.codeChallenge;
4615
4765
  storePKCEVerifier(provider, verifier);
@@ -4629,96 +4779,120 @@ var ClientProvider = function ClientProvider(_ref) {
4629
4779
  additionalState: _objectSpread2({}, additionalParameters)
4630
4780
  });
4631
4781
  if (!openInPage) {
4632
- _context102.n = 7;
4782
+ _context108.n = 7;
4633
4783
  break;
4634
4784
  }
4635
- return _context102.a(2, redirectToOAuthProvider(authUrl));
4785
+ return _context108.a(2, redirectToOAuthProvider(authUrl));
4636
4786
  case 7:
4637
4787
  // Popup flow
4638
4788
  authWindow = openOAuthPopup();
4639
4789
  if (authWindow) {
4640
- _context102.n = 8;
4790
+ _context108.n = 8;
4641
4791
  break;
4642
4792
  }
4643
4793
  throw new Error("Failed to open ".concat(capitalizeProviderName(provider), " login window."));
4644
4794
  case 8:
4645
4795
  authWindow.location.href = authUrl;
4646
- return _context102.a(2, new Promise(function (resolve, reject) {
4647
- var interval = setInterval(function () {
4648
- try {
4649
- if (authWindow.closed) {
4650
- clearInterval(interval);
4651
- reject(new Error("Authentication window was closed."));
4652
- return;
4653
- }
4654
- var url = authWindow.location.href || "";
4655
- if (url.startsWith(window.location.origin)) {
4656
- var result = parseOAuthResponse(url, provider);
4657
- if (result) {
4658
- authWindow.close();
4796
+ return _context108.a(2, new Promise(function (resolve, reject) {
4797
+ var interval = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee107() {
4798
+ var url, result;
4799
+ return _regenerator().w(function (_context107) {
4800
+ while (1) switch (_context107.p = _context107.n) {
4801
+ case 0:
4802
+ _context107.p = 0;
4803
+ if (!authWindow.closed) {
4804
+ _context107.n = 1;
4805
+ break;
4806
+ }
4659
4807
  clearInterval(interval);
4660
- completeOAuthPopup({
4661
- provider: provider,
4662
- publicKey: publicKey,
4663
- result: result,
4664
- callbacks: callbacks,
4665
- completeOauth: function completeOauth(completionParams) {
4666
- var _masterConfig$auth65, _masterConfig$auth65$, _completionParams$pro7, _existingCreateSubOrg7;
4667
- var existingCreateSubOrgParams = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth65 = masterConfig.auth) === null || _masterConfig$auth65 === void 0 ? void 0 : (_masterConfig$auth65$ = _masterConfig$auth65.createSuborgParams) === null || _masterConfig$auth65$ === void 0 ? void 0 : _masterConfig$auth65$.oauth;
4668
- var secondaryProviders = buildSecondaryOauthProviders(completionParams.oidcToken, (_completionParams$pro7 = completionParams.providerName) !== null && _completionParams$pro7 !== void 0 ? _completionParams$pro7 : provider, secondaryClientIds);
4669
- return _completeOauth(_objectSpread2(_objectSpread2({}, completionParams), secondaryProviders.length > 0 && {
4670
- createSubOrgParams: _objectSpread2(_objectSpread2({}, existingCreateSubOrgParams), {}, {
4671
- oauthProviders: [].concat(_toConsumableArray((_existingCreateSubOrg7 = existingCreateSubOrgParams === null || existingCreateSubOrgParams === void 0 ? void 0 : existingCreateSubOrgParams.oauthProviders) !== null && _existingCreateSubOrg7 !== void 0 ? _existingCreateSubOrg7 : []), _toConsumableArray(secondaryProviders))
4672
- })
4673
- }));
4674
- },
4675
- captchaToken: captchaToken,
4676
- onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess,
4677
- exchangeCodeForToken: function () {
4678
- var _exchangeCodeForToken3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101(codeVerifier) {
4679
- var tokenData;
4680
- return _regenerator().w(function (_context101) {
4681
- while (1) switch (_context101.n) {
4682
- case 0:
4683
- _context101.n = 1;
4684
- return exchangeFacebookCodeForToken(clientId, redirectUri, result.authCode, codeVerifier);
4685
- case 1:
4686
- tokenData = _context101.v;
4687
- return _context101.a(2, tokenData.id_token);
4808
+ reject(new Error("Authentication window was closed."));
4809
+ return _context107.a(2);
4810
+ case 1:
4811
+ url = authWindow.location.href || "";
4812
+ if (isExpectedOAuthRedirectUrl(url, redirectUri, OAUTH_PROVIDER_CONFIGS[provider].expectedResponseMode)) {
4813
+ result = parseOAuthResponse(url, provider);
4814
+ if (result) {
4815
+ authWindow.close();
4816
+ clearInterval(interval);
4817
+ completeOAuthPopup({
4818
+ provider: provider,
4819
+ publicKey: publicKey,
4820
+ result: result,
4821
+ callbacks: callbacks,
4822
+ completeOauth: function completeOauth(completionParams) {
4823
+ var _masterConfig$auth67, _masterConfig$auth67$, _completionParams$pro7, _existingCreateSubOrg7;
4824
+ var existingCreateSubOrgParams = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth67 = masterConfig.auth) === null || _masterConfig$auth67 === void 0 ? void 0 : (_masterConfig$auth67$ = _masterConfig$auth67.createSuborgParams) === null || _masterConfig$auth67$ === void 0 ? void 0 : _masterConfig$auth67$.oauth;
4825
+ var secondaryProviders = buildSecondaryOauthProviders(completionParams.oidcToken, (_completionParams$pro7 = completionParams.providerName) !== null && _completionParams$pro7 !== void 0 ? _completionParams$pro7 : provider, secondaryClientIds);
4826
+ return _completeOauth(_objectSpread2(_objectSpread2({}, completionParams), secondaryProviders.length > 0 && {
4827
+ createSubOrgParams: _objectSpread2(_objectSpread2({}, existingCreateSubOrgParams), {}, {
4828
+ oauthProviders: [].concat(_toConsumableArray((_existingCreateSubOrg7 = existingCreateSubOrgParams === null || existingCreateSubOrgParams === void 0 ? void 0 : existingCreateSubOrgParams.oauthProviders) !== null && _existingCreateSubOrg7 !== void 0 ? _existingCreateSubOrg7 : []), _toConsumableArray(secondaryProviders))
4829
+ })
4830
+ }));
4831
+ },
4832
+ captchaToken: captchaToken,
4833
+ onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess,
4834
+ exchangeCodeForToken: function () {
4835
+ var _exchangeCodeForToken3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee106(codeVerifier) {
4836
+ var tokenData, oidcToken;
4837
+ return _regenerator().w(function (_context106) {
4838
+ while (1) switch (_context106.n) {
4839
+ case 0:
4840
+ _context106.n = 1;
4841
+ return exchangeFacebookCodeForToken(clientId, redirectUri, result.authCode, codeVerifier);
4842
+ case 1:
4843
+ tokenData = _context106.v;
4844
+ oidcToken = tokenData.id_token; // Set the attested stamper with the oidcToken
4845
+ if (!oidcToken) {
4846
+ _context106.n = 2;
4847
+ break;
4848
+ }
4849
+ _context106.n = 2;
4850
+ return client === null || client === void 0 ? void 0 : client.overrideAttestedStamper({
4851
+ oidcToken: oidcToken,
4852
+ publicKey: publicKey
4853
+ });
4854
+ case 2:
4855
+ return _context106.a(2, oidcToken);
4856
+ }
4857
+ }, _callee106);
4858
+ }));
4859
+ function exchangeCodeForToken(_x87) {
4860
+ return _exchangeCodeForToken3.apply(this, arguments);
4688
4861
  }
4689
- }, _callee101);
4690
- }));
4691
- function exchangeCodeForToken(_x86) {
4692
- return _exchangeCodeForToken3.apply(this, arguments);
4693
- }
4694
- return exchangeCodeForToken;
4695
- }()
4696
- }).then(function () {
4697
- return resolve();
4698
- })["catch"](reject);
4699
- }
4862
+ return exchangeCodeForToken;
4863
+ }()
4864
+ }).then(function () {
4865
+ return resolve();
4866
+ })["catch"](reject);
4867
+ }
4868
+ }
4869
+ _context107.n = 3;
4870
+ break;
4871
+ case 2:
4872
+ _context107.p = 2;
4873
+ _context107.v;
4874
+ case 3:
4875
+ return _context107.a(2);
4700
4876
  }
4701
- } catch (_unused5) {
4702
- // Ignore cross-origin errors
4703
- }
4704
- }, 500);
4877
+ }, _callee107, null, [[0, 2]]);
4878
+ })), 500);
4705
4879
  if (authWindow.closed) {
4706
4880
  clearInterval(interval);
4707
4881
  }
4708
4882
  }));
4709
4883
  }
4710
- }, _callee102);
4884
+ }, _callee108);
4711
4885
  }));
4712
- return function (_x85) {
4713
- return _ref116.apply(this, arguments);
4886
+ return function (_x86) {
4887
+ return _ref123.apply(this, arguments);
4714
4888
  };
4715
4889
  }(), [callbacks, _completeOauth, createApiKeyPair, masterConfig]);
4716
4890
  var handleLogin = useCallback(/*#__PURE__*/function () {
4717
- var _ref118 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee103(params) {
4891
+ var _ref126 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee109(params) {
4718
4892
  var _masterConfig$ui, _params$logoDark, _masterConfig$ui2, _params$logoLight, _masterConfig$ui3, _params$title;
4719
4893
  var logo;
4720
- return _regenerator().w(function (_context103) {
4721
- while (1) switch (_context103.n) {
4894
+ return _regenerator().w(function (_context109) {
4895
+ while (1) switch (_context109.n) {
4722
4896
  case 0:
4723
4897
  logo = masterConfig !== null && masterConfig !== void 0 && (_masterConfig$ui = masterConfig.ui) !== null && _masterConfig$ui !== void 0 && _masterConfig$ui.darkMode ? (_params$logoDark = params === null || params === void 0 ? void 0 : params.logoDark) !== null && _params$logoDark !== void 0 ? _params$logoDark : masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$ui2 = masterConfig.ui) === null || _masterConfig$ui2 === void 0 ? void 0 : _masterConfig$ui2.logoDark : (_params$logoLight = params === null || params === void 0 ? void 0 : params.logoLight) !== null && _params$logoLight !== void 0 ? _params$logoLight : masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$ui3 = masterConfig.ui) === null || _masterConfig$ui3 === void 0 ? void 0 : _masterConfig$ui3.logoLight;
4724
4898
  pushPage({
@@ -4733,22 +4907,22 @@ var ClientProvider = function ClientProvider(_ref) {
4733
4907
  contextProvider: WalletConnectProvider
4734
4908
  });
4735
4909
  case 1:
4736
- return _context103.a(2);
4910
+ return _context109.a(2);
4737
4911
  }
4738
- }, _callee103);
4912
+ }, _callee109);
4739
4913
  }));
4740
- return function (_x87) {
4741
- return _ref118.apply(this, arguments);
4914
+ return function (_x88) {
4915
+ return _ref126.apply(this, arguments);
4742
4916
  };
4743
4917
  }(), [pushPage, masterConfig]);
4744
4918
  var handleExportWallet = useCallback(/*#__PURE__*/function () {
4745
- var _ref119 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee104(params) {
4919
+ var _ref127 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee110(params) {
4746
4920
  var walletId, targetPublicKey, stampWith, organizationId;
4747
- return _regenerator().w(function (_context104) {
4748
- while (1) switch (_context104.n) {
4921
+ return _regenerator().w(function (_context110) {
4922
+ while (1) switch (_context110.n) {
4749
4923
  case 0:
4750
4924
  walletId = params.walletId, targetPublicKey = params.targetPublicKey, stampWith = params.stampWith, organizationId = params.organizationId;
4751
- return _context104.a(2, new Promise(function (resolve, reject) {
4925
+ return _context110.a(2, new Promise(function (resolve, reject) {
4752
4926
  return pushPage({
4753
4927
  key: "Export wallet",
4754
4928
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4774,20 +4948,20 @@ var ClientProvider = function ClientProvider(_ref) {
4774
4948
  });
4775
4949
  }));
4776
4950
  }
4777
- }, _callee104);
4951
+ }, _callee110);
4778
4952
  }));
4779
- return function (_x88) {
4780
- return _ref119.apply(this, arguments);
4953
+ return function (_x89) {
4954
+ return _ref127.apply(this, arguments);
4781
4955
  };
4782
4956
  }(), [pushPage]);
4783
4957
  var handleExportPrivateKey = useCallback(/*#__PURE__*/function () {
4784
- var _ref120 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee105(params) {
4958
+ var _ref128 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee111(params) {
4785
4959
  var privateKeyId, targetPublicKey, keyFormat, stampWith, organizationId;
4786
- return _regenerator().w(function (_context105) {
4787
- while (1) switch (_context105.n) {
4960
+ return _regenerator().w(function (_context111) {
4961
+ while (1) switch (_context111.n) {
4788
4962
  case 0:
4789
4963
  privateKeyId = params.privateKeyId, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith, organizationId = params.organizationId;
4790
- return _context105.a(2, new Promise(function (resolve, reject) {
4964
+ return _context111.a(2, new Promise(function (resolve, reject) {
4791
4965
  return pushPage({
4792
4966
  key: "Export private key",
4793
4967
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4815,20 +4989,20 @@ var ClientProvider = function ClientProvider(_ref) {
4815
4989
  });
4816
4990
  }));
4817
4991
  }
4818
- }, _callee105);
4992
+ }, _callee111);
4819
4993
  }));
4820
- return function (_x89) {
4821
- return _ref120.apply(this, arguments);
4994
+ return function (_x90) {
4995
+ return _ref128.apply(this, arguments);
4822
4996
  };
4823
4997
  }(), [pushPage]);
4824
4998
  var handleExportWalletAccount = useCallback(/*#__PURE__*/function () {
4825
- var _ref121 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee106(params) {
4999
+ var _ref129 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee112(params) {
4826
5000
  var address, targetPublicKey, keyFormat, stampWith, organizationId;
4827
- return _regenerator().w(function (_context106) {
4828
- while (1) switch (_context106.n) {
5001
+ return _regenerator().w(function (_context112) {
5002
+ while (1) switch (_context112.n) {
4829
5003
  case 0:
4830
5004
  address = params.address, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith, organizationId = params.organizationId;
4831
- return _context106.a(2, new Promise(function (resolve, reject) {
5005
+ return _context112.a(2, new Promise(function (resolve, reject) {
4832
5006
  return pushPage({
4833
5007
  key: "Export wallet account",
4834
5008
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4856,21 +5030,21 @@ var ClientProvider = function ClientProvider(_ref) {
4856
5030
  });
4857
5031
  }));
4858
5032
  }
4859
- }, _callee106);
5033
+ }, _callee112);
4860
5034
  }));
4861
- return function (_x90) {
4862
- return _ref121.apply(this, arguments);
5035
+ return function (_x91) {
5036
+ return _ref129.apply(this, arguments);
4863
5037
  };
4864
5038
  }(), [pushPage]);
4865
5039
  var handleImportWallet = useCallback(/*#__PURE__*/function () {
4866
- var _ref122 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee107(params) {
4867
- var _ref123, defaultWalletAccounts, _ref123$successPageDu, successPageDuration, stampWith, walletName, clearClipboardOnPaste, organizationId, userId, _t10;
4868
- return _regenerator().w(function (_context107) {
4869
- while (1) switch (_context107.p = _context107.n) {
5040
+ var _ref130 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee113(params) {
5041
+ var _ref131, defaultWalletAccounts, _ref131$successPageDu, successPageDuration, stampWith, walletName, clearClipboardOnPaste, organizationId, userId, _t15;
5042
+ return _regenerator().w(function (_context113) {
5043
+ while (1) switch (_context113.p = _context113.n) {
4870
5044
  case 0:
4871
- _ref123 = params || {}, defaultWalletAccounts = _ref123.defaultWalletAccounts, _ref123$successPageDu = _ref123.successPageDuration, successPageDuration = _ref123$successPageDu === void 0 ? 2000 : _ref123$successPageDu, stampWith = _ref123.stampWith, walletName = _ref123.walletName, clearClipboardOnPaste = _ref123.clearClipboardOnPaste, organizationId = _ref123.organizationId, userId = _ref123.userId;
4872
- _context107.p = 1;
4873
- return _context107.a(2, withTurnkeyErrorHandling(function () {
5045
+ _ref131 = params || {}, defaultWalletAccounts = _ref131.defaultWalletAccounts, _ref131$successPageDu = _ref131.successPageDuration, successPageDuration = _ref131$successPageDu === void 0 ? 2000 : _ref131$successPageDu, stampWith = _ref131.stampWith, walletName = _ref131.walletName, clearClipboardOnPaste = _ref131.clearClipboardOnPaste, organizationId = _ref131.organizationId, userId = _ref131.userId;
5046
+ _context113.p = 1;
5047
+ return _context113.a(2, withTurnkeyErrorHandling(function () {
4874
5048
  return new Promise(function (resolve, reject) {
4875
5049
  return pushPage({
4876
5050
  key: "Import wallet",
@@ -4903,33 +5077,33 @@ var ClientProvider = function ClientProvider(_ref) {
4903
5077
  return logout();
4904
5078
  }));
4905
5079
  case 2:
4906
- _context107.p = 2;
4907
- _t10 = _context107.v;
4908
- if (!(_t10 instanceof TurnkeyError)) {
4909
- _context107.n = 3;
5080
+ _context113.p = 2;
5081
+ _t15 = _context113.v;
5082
+ if (!(_t15 instanceof TurnkeyError)) {
5083
+ _context113.n = 3;
4910
5084
  break;
4911
5085
  }
4912
- throw _t10;
5086
+ throw _t15;
4913
5087
  case 3:
4914
- throw new TurnkeyError("Failed to import wallet.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t10);
5088
+ throw new TurnkeyError("Failed to import wallet.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t15);
4915
5089
  case 4:
4916
- return _context107.a(2);
5090
+ return _context113.a(2);
4917
5091
  }
4918
- }, _callee107, null, [[1, 2]]);
5092
+ }, _callee113, null, [[1, 2]]);
4919
5093
  }));
4920
- return function (_x91) {
4921
- return _ref122.apply(this, arguments);
5094
+ return function (_x92) {
5095
+ return _ref130.apply(this, arguments);
4922
5096
  };
4923
5097
  }(), [pushPage, logout]);
4924
5098
  var handleImportPrivateKey = useCallback(/*#__PURE__*/function () {
4925
- var _ref124 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee108(params) {
4926
- var _ref125, curve, addressFormats, _ref125$successPageDu, successPageDuration, stampWith, keyName, keyFormat, clearClipboardOnPaste, organizationId, _t11;
4927
- return _regenerator().w(function (_context108) {
4928
- while (1) switch (_context108.p = _context108.n) {
5099
+ var _ref132 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee114(params) {
5100
+ var _ref133, curve, addressFormats, _ref133$successPageDu, successPageDuration, stampWith, keyName, keyFormat, clearClipboardOnPaste, organizationId, _t16;
5101
+ return _regenerator().w(function (_context114) {
5102
+ while (1) switch (_context114.p = _context114.n) {
4929
5103
  case 0:
4930
- _ref125 = params || {}, curve = _ref125.curve, addressFormats = _ref125.addressFormats, _ref125$successPageDu = _ref125.successPageDuration, successPageDuration = _ref125$successPageDu === void 0 ? 2000 : _ref125$successPageDu, stampWith = _ref125.stampWith, keyName = _ref125.keyName, keyFormat = _ref125.keyFormat, clearClipboardOnPaste = _ref125.clearClipboardOnPaste, organizationId = _ref125.organizationId;
4931
- _context108.p = 1;
4932
- return _context108.a(2, withTurnkeyErrorHandling(function () {
5104
+ _ref133 = params || {}, curve = _ref133.curve, addressFormats = _ref133.addressFormats, _ref133$successPageDu = _ref133.successPageDuration, successPageDuration = _ref133$successPageDu === void 0 ? 2000 : _ref133$successPageDu, stampWith = _ref133.stampWith, keyName = _ref133.keyName, keyFormat = _ref133.keyFormat, clearClipboardOnPaste = _ref133.clearClipboardOnPaste, organizationId = _ref133.organizationId;
5105
+ _context114.p = 1;
5106
+ return _context114.a(2, withTurnkeyErrorHandling(function () {
4933
5107
  return new Promise(function (resolve, reject) {
4934
5108
  return pushPage({
4935
5109
  key: "Import private key",
@@ -4961,51 +5135,51 @@ var ClientProvider = function ClientProvider(_ref) {
4961
5135
  return logout();
4962
5136
  }));
4963
5137
  case 2:
4964
- _context108.p = 2;
4965
- _t11 = _context108.v;
4966
- if (!(_t11 instanceof TurnkeyError)) {
4967
- _context108.n = 3;
5138
+ _context114.p = 2;
5139
+ _t16 = _context114.v;
5140
+ if (!(_t16 instanceof TurnkeyError)) {
5141
+ _context114.n = 3;
4968
5142
  break;
4969
5143
  }
4970
- throw _t11;
5144
+ throw _t16;
4971
5145
  case 3:
4972
- throw new TurnkeyError("Failed to import private key.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t11);
5146
+ throw new TurnkeyError("Failed to import private key.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t16);
4973
5147
  case 4:
4974
- return _context108.a(2);
5148
+ return _context114.a(2);
4975
5149
  }
4976
- }, _callee108, null, [[1, 2]]);
5150
+ }, _callee114, null, [[1, 2]]);
4977
5151
  }));
4978
- return function (_x92) {
4979
- return _ref124.apply(this, arguments);
5152
+ return function (_x93) {
5153
+ return _ref132.apply(this, arguments);
4980
5154
  };
4981
5155
  }(), [pushPage, logout]);
4982
5156
  var handleUpdateUserName = useCallback(/*#__PURE__*/function () {
4983
- var _ref126 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee109(params) {
4984
- var _ref127, _ref127$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _params$userId, res, _t12;
4985
- return _regenerator().w(function (_context109) {
4986
- while (1) switch (_context109.p = _context109.n) {
5157
+ var _ref134 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee115(params) {
5158
+ var _ref135, _ref135$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _params$userId, res, _t17;
5159
+ return _regenerator().w(function (_context115) {
5160
+ while (1) switch (_context115.p = _context115.n) {
4987
5161
  case 0:
4988
- _ref127 = params || {}, _ref127$successPageDu = _ref127.successPageDuration, successPageDuration = _ref127$successPageDu === void 0 ? 2000 : _ref127$successPageDu, subTitle = _ref127.subTitle, title = _ref127.title, stampWith = _ref127.stampWith;
5162
+ _ref135 = params || {}, _ref135$successPageDu = _ref135.successPageDuration, successPageDuration = _ref135$successPageDu === void 0 ? 2000 : _ref135$successPageDu, subTitle = _ref135.subTitle, title = _ref135.title, stampWith = _ref135.stampWith;
4989
5163
  if (client) {
4990
- _context109.n = 1;
5164
+ _context115.n = 1;
4991
5165
  break;
4992
5166
  }
4993
5167
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4994
5168
  case 1:
4995
- _context109.n = 2;
5169
+ _context115.n = 2;
4996
5170
  return getSession();
4997
5171
  case 2:
4998
- s = _context109.v;
5172
+ s = _context115.v;
4999
5173
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5000
5174
  if (organizationId) {
5001
- _context109.n = 3;
5175
+ _context115.n = 3;
5002
5176
  break;
5003
5177
  }
5004
5178
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5005
5179
  case 3:
5006
5180
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (user === null || user === void 0 ? void 0 : user.userId);
5007
5181
  if (userId) {
5008
- _context109.n = 4;
5182
+ _context115.n = 4;
5009
5183
  break;
5010
5184
  }
5011
5185
  throw new TurnkeyError("A user ID is required to update a user name.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5025,12 +5199,12 @@ var ClientProvider = function ClientProvider(_ref) {
5025
5199
  showTitle: false
5026
5200
  });
5027
5201
  };
5028
- _context109.p = 5;
5202
+ _context115.p = 5;
5029
5203
  if (!(!(params !== null && params !== void 0 && params.userName) && (params === null || params === void 0 ? void 0 : params.userName) !== "")) {
5030
- _context109.n = 6;
5204
+ _context115.n = 6;
5031
5205
  break;
5032
5206
  }
5033
- return _context109.a(2, withTurnkeyErrorHandling(function () {
5207
+ return _context115.a(2, withTurnkeyErrorHandling(function () {
5034
5208
  return new Promise(function (resolve, reject) {
5035
5209
  pushPage({
5036
5210
  key: "Update User Name",
@@ -5058,7 +5232,7 @@ var ClientProvider = function ClientProvider(_ref) {
5058
5232
  return logout();
5059
5233
  }));
5060
5234
  case 6:
5061
- _context109.n = 7;
5235
+ _context115.n = 7;
5062
5236
  return updateUserName(_objectSpread2({
5063
5237
  userName: params.userName,
5064
5238
  userId: (_params$userId = params.userId) !== null && _params$userId !== void 0 ? _params$userId : user.userId,
@@ -5067,64 +5241,64 @@ var ClientProvider = function ClientProvider(_ref) {
5067
5241
  organizationId: organizationId
5068
5242
  }));
5069
5243
  case 7:
5070
- res = _context109.v;
5244
+ res = _context115.v;
5071
5245
  onSuccess();
5072
- return _context109.a(2, res);
5246
+ return _context115.a(2, res);
5073
5247
  case 8:
5074
- _context109.n = 11;
5248
+ _context115.n = 11;
5075
5249
  break;
5076
5250
  case 9:
5077
- _context109.p = 9;
5078
- _t12 = _context109.v;
5079
- if (!(_t12 instanceof TurnkeyError)) {
5080
- _context109.n = 10;
5251
+ _context115.p = 9;
5252
+ _t17 = _context115.v;
5253
+ if (!(_t17 instanceof TurnkeyError)) {
5254
+ _context115.n = 10;
5081
5255
  break;
5082
5256
  }
5083
- throw _t12;
5257
+ throw _t17;
5084
5258
  case 10:
5085
- throw new TurnkeyError("Failed to update user name.", TurnkeyErrorCodes.UPDATE_USER_NAME_ERROR, _t12);
5259
+ throw new TurnkeyError("Failed to update user name.", TurnkeyErrorCodes.UPDATE_USER_NAME_ERROR, _t17);
5086
5260
  case 11:
5087
- return _context109.a(2);
5261
+ return _context115.a(2);
5088
5262
  }
5089
- }, _callee109, null, [[5, 9]]);
5263
+ }, _callee115, null, [[5, 9]]);
5090
5264
  }));
5091
- return function (_x93) {
5092
- return _ref126.apply(this, arguments);
5265
+ return function (_x94) {
5266
+ return _ref134.apply(this, arguments);
5093
5267
  };
5094
5268
  }(), [client, getSession, user, pushPage, closeModal, updateUserName, logout]);
5095
5269
  var handleUpdateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
5096
- var _ref128 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee111(params) {
5097
- var _ref129, _ref129$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp, otpId, otpEncryptionTargetBundle, _t14;
5098
- return _regenerator().w(function (_context111) {
5099
- while (1) switch (_context111.p = _context111.n) {
5270
+ var _ref136 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee117(params) {
5271
+ var _ref137, _ref137$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp, otpId, otpEncryptionTargetBundle, _t19;
5272
+ return _regenerator().w(function (_context117) {
5273
+ while (1) switch (_context117.p = _context117.n) {
5100
5274
  case 0:
5101
- _ref129 = params || {}, _ref129$successPageDu = _ref129.successPageDuration, successPageDuration = _ref129$successPageDu === void 0 ? 2000 : _ref129$successPageDu, subTitle = _ref129.subTitle, title = _ref129.title, stampWith = _ref129.stampWith;
5275
+ _ref137 = params || {}, _ref137$successPageDu = _ref137.successPageDuration, successPageDuration = _ref137$successPageDu === void 0 ? 2000 : _ref137$successPageDu, subTitle = _ref137.subTitle, title = _ref137.title, stampWith = _ref137.stampWith;
5102
5276
  if (client) {
5103
- _context111.n = 1;
5277
+ _context117.n = 1;
5104
5278
  break;
5105
5279
  }
5106
5280
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5107
5281
  case 1:
5108
5282
  if (masterConfig) {
5109
- _context111.n = 2;
5283
+ _context117.n = 2;
5110
5284
  break;
5111
5285
  }
5112
5286
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
5113
5287
  case 2:
5114
- _context111.n = 3;
5288
+ _context117.n = 3;
5115
5289
  return getSession();
5116
5290
  case 3:
5117
- s = _context111.v;
5291
+ s = _context117.v;
5118
5292
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5119
5293
  if (organizationId) {
5120
- _context111.n = 4;
5294
+ _context117.n = 4;
5121
5295
  break;
5122
5296
  }
5123
5297
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5124
5298
  case 4:
5125
5299
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5126
5300
  if (userId) {
5127
- _context111.n = 5;
5301
+ _context117.n = 5;
5128
5302
  break;
5129
5303
  }
5130
5304
  throw new TurnkeyError("A user ID is required to update a phone number.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5144,12 +5318,12 @@ var ClientProvider = function ClientProvider(_ref) {
5144
5318
  showTitle: false
5145
5319
  });
5146
5320
  };
5147
- _context111.p = 6;
5321
+ _context117.p = 6;
5148
5322
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
5149
- _context111.n = 7;
5323
+ _context117.n = 7;
5150
5324
  break;
5151
5325
  }
5152
- return _context111.a(2, withTurnkeyErrorHandling(function () {
5326
+ return _context117.a(2, withTurnkeyErrorHandling(function () {
5153
5327
  return new Promise(function (resolve, reject) {
5154
5328
  pushPage({
5155
5329
  key: "Update Phone Number",
@@ -5177,18 +5351,18 @@ var ClientProvider = function ClientProvider(_ref) {
5177
5351
  return logout();
5178
5352
  }));
5179
5353
  case 7:
5180
- _context111.n = 8;
5354
+ _context117.n = 8;
5181
5355
  return initOtp({
5182
5356
  otpType: OtpType.Sms,
5183
5357
  contact: params.phoneNumber
5184
5358
  });
5185
5359
  case 8:
5186
- _yield$initOtp = _context111.v;
5360
+ _yield$initOtp = _context117.v;
5187
5361
  otpId = _yield$initOtp.otpId;
5188
5362
  otpEncryptionTargetBundle = _yield$initOtp.otpEncryptionTargetBundle;
5189
- return _context111.a(2, withTurnkeyErrorHandling(function () {
5363
+ return _context117.a(2, withTurnkeyErrorHandling(function () {
5190
5364
  return new Promise(function (resolve, reject) {
5191
- var _masterConfig$auth66, _masterConfig$auth67;
5365
+ var _masterConfig$auth68, _masterConfig$auth69;
5192
5366
  pushPage({
5193
5367
  key: "Update Phone Number",
5194
5368
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5196,25 +5370,25 @@ var ClientProvider = function ClientProvider(_ref) {
5196
5370
  contact: params.phoneNumber,
5197
5371
  otpId: otpId,
5198
5372
  otpEncryptionTargetBundle: otpEncryptionTargetBundle,
5199
- otpLength: ((_masterConfig$auth66 = masterConfig.auth) === null || _masterConfig$auth66 === void 0 ? void 0 : _masterConfig$auth66.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5200
- alphanumeric: (_masterConfig$auth67 = masterConfig.auth) === null || _masterConfig$auth67 === void 0 ? void 0 : _masterConfig$auth67.otpAlphanumeric,
5373
+ otpLength: ((_masterConfig$auth68 = masterConfig.auth) === null || _masterConfig$auth68 === void 0 ? void 0 : _masterConfig$auth68.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5374
+ alphanumeric: (_masterConfig$auth69 = masterConfig.auth) === null || _masterConfig$auth69 === void 0 ? void 0 : _masterConfig$auth69.otpAlphanumeric,
5201
5375
  onContinue: function () {
5202
- var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee110(otpCode) {
5203
- var _yield$verifyOtp, verificationToken, res, _t13;
5204
- return _regenerator().w(function (_context110) {
5205
- while (1) switch (_context110.p = _context110.n) {
5376
+ var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee116(otpCode) {
5377
+ var _yield$verifyOtp, verificationToken, res, _t18;
5378
+ return _regenerator().w(function (_context116) {
5379
+ while (1) switch (_context116.p = _context116.n) {
5206
5380
  case 0:
5207
- _context110.p = 0;
5208
- _context110.n = 1;
5381
+ _context116.p = 0;
5382
+ _context116.n = 1;
5209
5383
  return verifyOtp({
5210
5384
  otpId: otpId,
5211
5385
  otpCode: otpCode,
5212
5386
  otpEncryptionTargetBundle: otpEncryptionTargetBundle
5213
5387
  });
5214
5388
  case 1:
5215
- _yield$verifyOtp = _context110.v;
5389
+ _yield$verifyOtp = _context116.v;
5216
5390
  verificationToken = _yield$verifyOtp.verificationToken;
5217
- _context110.n = 2;
5391
+ _context116.n = 2;
5218
5392
  return updateUserPhoneNumber(_objectSpread2({
5219
5393
  phoneNumber: params.phoneNumber,
5220
5394
  verificationToken: verificationToken,
@@ -5224,21 +5398,21 @@ var ClientProvider = function ClientProvider(_ref) {
5224
5398
  stampWith: stampWith
5225
5399
  }));
5226
5400
  case 2:
5227
- res = _context110.v;
5401
+ res = _context116.v;
5228
5402
  onSuccess();
5229
5403
  resolve(res);
5230
- _context110.n = 4;
5404
+ _context116.n = 4;
5231
5405
  break;
5232
5406
  case 3:
5233
- _context110.p = 3;
5234
- _t13 = _context110.v;
5235
- reject(_t13);
5407
+ _context116.p = 3;
5408
+ _t18 = _context116.v;
5409
+ reject(_t18);
5236
5410
  case 4:
5237
- return _context110.a(2);
5411
+ return _context116.a(2);
5238
5412
  }
5239
- }, _callee110, null, [[0, 3]]);
5413
+ }, _callee116, null, [[0, 3]]);
5240
5414
  }));
5241
- function onContinue(_x95) {
5415
+ function onContinue(_x96) {
5242
5416
  return _onContinue.apply(this, arguments);
5243
5417
  }
5244
5418
  return onContinue;
@@ -5257,54 +5431,54 @@ var ClientProvider = function ClientProvider(_ref) {
5257
5431
  return logout();
5258
5432
  }, callbacks, "Failed to update phone number"));
5259
5433
  case 9:
5260
- _context111.n = 12;
5434
+ _context117.n = 12;
5261
5435
  break;
5262
5436
  case 10:
5263
- _context111.p = 10;
5264
- _t14 = _context111.v;
5265
- if (!(_t14 instanceof TurnkeyError)) {
5266
- _context111.n = 11;
5437
+ _context117.p = 10;
5438
+ _t19 = _context117.v;
5439
+ if (!(_t19 instanceof TurnkeyError)) {
5440
+ _context117.n = 11;
5267
5441
  break;
5268
5442
  }
5269
- throw _t14;
5443
+ throw _t19;
5270
5444
  case 11:
5271
- throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t14);
5445
+ throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t19);
5272
5446
  case 12:
5273
- return _context111.a(2);
5447
+ return _context117.a(2);
5274
5448
  }
5275
- }, _callee111, null, [[6, 10]]);
5449
+ }, _callee117, null, [[6, 10]]);
5276
5450
  }));
5277
- return function (_x94) {
5278
- return _ref128.apply(this, arguments);
5451
+ return function (_x95) {
5452
+ return _ref136.apply(this, arguments);
5279
5453
  };
5280
5454
  }(), [client, masterConfig, getSession, pushPage, closeModal, logout, initOtp, verifyOtp, updateUserPhoneNumber, user, callbacks]);
5281
5455
  var handleUpdateUserEmail = useCallback(/*#__PURE__*/function () {
5282
- var _ref130 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee113(params) {
5283
- var _ref131, _ref131$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp2, otpId, otpEncryptionTargetBundle, _t16;
5284
- return _regenerator().w(function (_context113) {
5285
- while (1) switch (_context113.p = _context113.n) {
5456
+ var _ref138 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee119(params) {
5457
+ var _ref139, _ref139$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp2, otpId, otpEncryptionTargetBundle, _t21;
5458
+ return _regenerator().w(function (_context119) {
5459
+ while (1) switch (_context119.p = _context119.n) {
5286
5460
  case 0:
5287
- _ref131 = params || {}, _ref131$successPageDu = _ref131.successPageDuration, successPageDuration = _ref131$successPageDu === void 0 ? 2000 : _ref131$successPageDu, subTitle = _ref131.subTitle, title = _ref131.title, stampWith = _ref131.stampWith;
5461
+ _ref139 = params || {}, _ref139$successPageDu = _ref139.successPageDuration, successPageDuration = _ref139$successPageDu === void 0 ? 2000 : _ref139$successPageDu, subTitle = _ref139.subTitle, title = _ref139.title, stampWith = _ref139.stampWith;
5288
5462
  if (client) {
5289
- _context113.n = 1;
5463
+ _context119.n = 1;
5290
5464
  break;
5291
5465
  }
5292
5466
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5293
5467
  case 1:
5294
- _context113.n = 2;
5468
+ _context119.n = 2;
5295
5469
  return getSession();
5296
5470
  case 2:
5297
- s = _context113.v;
5471
+ s = _context119.v;
5298
5472
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5299
5473
  if (organizationId) {
5300
- _context113.n = 3;
5474
+ _context119.n = 3;
5301
5475
  break;
5302
5476
  }
5303
5477
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5304
5478
  case 3:
5305
5479
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5306
5480
  if (userId) {
5307
- _context113.n = 4;
5481
+ _context119.n = 4;
5308
5482
  break;
5309
5483
  }
5310
5484
  throw new TurnkeyError("A user ID is required to update an email.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5324,12 +5498,12 @@ var ClientProvider = function ClientProvider(_ref) {
5324
5498
  showTitle: false
5325
5499
  });
5326
5500
  };
5327
- _context113.p = 5;
5501
+ _context119.p = 5;
5328
5502
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
5329
- _context113.n = 6;
5503
+ _context119.n = 6;
5330
5504
  break;
5331
5505
  }
5332
- return _context113.a(2, withTurnkeyErrorHandling(function () {
5506
+ return _context119.a(2, withTurnkeyErrorHandling(function () {
5333
5507
  return new Promise(function (resolve, reject) {
5334
5508
  pushPage({
5335
5509
  key: "Update Email",
@@ -5357,18 +5531,18 @@ var ClientProvider = function ClientProvider(_ref) {
5357
5531
  return logout();
5358
5532
  }));
5359
5533
  case 6:
5360
- _context113.n = 7;
5534
+ _context119.n = 7;
5361
5535
  return initOtp({
5362
5536
  otpType: OtpType.Email,
5363
5537
  contact: params.email
5364
5538
  });
5365
5539
  case 7:
5366
- _yield$initOtp2 = _context113.v;
5540
+ _yield$initOtp2 = _context119.v;
5367
5541
  otpId = _yield$initOtp2.otpId;
5368
5542
  otpEncryptionTargetBundle = _yield$initOtp2.otpEncryptionTargetBundle;
5369
- return _context113.a(2, withTurnkeyErrorHandling(function () {
5543
+ return _context119.a(2, withTurnkeyErrorHandling(function () {
5370
5544
  return new Promise(function (resolve, reject) {
5371
- var _masterConfig$auth68, _masterConfig$auth69;
5545
+ var _masterConfig$auth70, _masterConfig$auth71;
5372
5546
  pushPage({
5373
5547
  key: "Update Email",
5374
5548
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2({
@@ -5376,25 +5550,25 @@ var ClientProvider = function ClientProvider(_ref) {
5376
5550
  contact: params.email,
5377
5551
  otpId: otpId,
5378
5552
  otpEncryptionTargetBundle: otpEncryptionTargetBundle,
5379
- otpLength: (masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth68 = masterConfig.auth) === null || _masterConfig$auth68 === void 0 ? void 0 : _masterConfig$auth68.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5380
- alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth69 = masterConfig.auth) === null || _masterConfig$auth69 === void 0 ? void 0 : _masterConfig$auth69.otpAlphanumeric,
5553
+ otpLength: (masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth70 = masterConfig.auth) === null || _masterConfig$auth70 === void 0 ? void 0 : _masterConfig$auth70.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5554
+ alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth71 = masterConfig.auth) === null || _masterConfig$auth71 === void 0 ? void 0 : _masterConfig$auth71.otpAlphanumeric,
5381
5555
  onContinue: function () {
5382
- var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee112(otpCode) {
5383
- var _yield$verifyOtp2, verificationToken, res, _t15;
5384
- return _regenerator().w(function (_context112) {
5385
- while (1) switch (_context112.p = _context112.n) {
5556
+ var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee118(otpCode) {
5557
+ var _yield$verifyOtp2, verificationToken, res, _t20;
5558
+ return _regenerator().w(function (_context118) {
5559
+ while (1) switch (_context118.p = _context118.n) {
5386
5560
  case 0:
5387
- _context112.p = 0;
5388
- _context112.n = 1;
5561
+ _context118.p = 0;
5562
+ _context118.n = 1;
5389
5563
  return verifyOtp({
5390
5564
  otpId: otpId,
5391
5565
  otpCode: otpCode,
5392
5566
  otpEncryptionTargetBundle: otpEncryptionTargetBundle
5393
5567
  });
5394
5568
  case 1:
5395
- _yield$verifyOtp2 = _context112.v;
5569
+ _yield$verifyOtp2 = _context118.v;
5396
5570
  verificationToken = _yield$verifyOtp2.verificationToken;
5397
- _context112.n = 2;
5571
+ _context118.n = 2;
5398
5572
  return updateUserEmail(_objectSpread2({
5399
5573
  email: params.email,
5400
5574
  verificationToken: verificationToken,
@@ -5404,21 +5578,21 @@ var ClientProvider = function ClientProvider(_ref) {
5404
5578
  stampWith: stampWith
5405
5579
  }));
5406
5580
  case 2:
5407
- res = _context112.v;
5581
+ res = _context118.v;
5408
5582
  onSuccess();
5409
5583
  resolve(res);
5410
- _context112.n = 4;
5584
+ _context118.n = 4;
5411
5585
  break;
5412
5586
  case 3:
5413
- _context112.p = 3;
5414
- _t15 = _context112.v;
5415
- reject(_t15);
5587
+ _context118.p = 3;
5588
+ _t20 = _context118.v;
5589
+ reject(_t20);
5416
5590
  case 4:
5417
- return _context112.a(2);
5591
+ return _context118.a(2);
5418
5592
  }
5419
- }, _callee112, null, [[0, 3]]);
5593
+ }, _callee118, null, [[0, 3]]);
5420
5594
  }));
5421
- function onContinue(_x97) {
5595
+ function onContinue(_x98) {
5422
5596
  return _onContinue2.apply(this, arguments);
5423
5597
  }
5424
5598
  return onContinue;
@@ -5435,54 +5609,54 @@ var ClientProvider = function ClientProvider(_ref) {
5435
5609
  return logout();
5436
5610
  }, callbacks, "Failed to update email"));
5437
5611
  case 8:
5438
- _context113.n = 11;
5612
+ _context119.n = 11;
5439
5613
  break;
5440
5614
  case 9:
5441
- _context113.p = 9;
5442
- _t16 = _context113.v;
5443
- if (!(_t16 instanceof TurnkeyError)) {
5444
- _context113.n = 10;
5615
+ _context119.p = 9;
5616
+ _t21 = _context119.v;
5617
+ if (!(_t21 instanceof TurnkeyError)) {
5618
+ _context119.n = 10;
5445
5619
  break;
5446
5620
  }
5447
- throw _t16;
5621
+ throw _t21;
5448
5622
  case 10:
5449
- throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t16);
5623
+ throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t21);
5450
5624
  case 11:
5451
- return _context113.a(2);
5625
+ return _context119.a(2);
5452
5626
  }
5453
- }, _callee113, null, [[5, 9]]);
5627
+ }, _callee119, null, [[5, 9]]);
5454
5628
  }));
5455
- return function (_x96) {
5456
- return _ref130.apply(this, arguments);
5629
+ return function (_x97) {
5630
+ return _ref138.apply(this, arguments);
5457
5631
  };
5458
5632
  }(), [client, getSession, pushPage, closeModal, logout, initOtp, masterConfig, verifyOtp, updateUserEmail, user, callbacks]);
5459
5633
  var handleAddEmail = useCallback(/*#__PURE__*/function () {
5460
- var _ref132 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee115(params) {
5461
- var _ref133, _ref133$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp3, otpId, otpEncryptionTargetBundle, _t18;
5462
- return _regenerator().w(function (_context115) {
5463
- while (1) switch (_context115.p = _context115.n) {
5634
+ var _ref140 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee121(params) {
5635
+ var _ref141, _ref141$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp3, otpId, otpEncryptionTargetBundle, _t23;
5636
+ return _regenerator().w(function (_context121) {
5637
+ while (1) switch (_context121.p = _context121.n) {
5464
5638
  case 0:
5465
- _ref133 = params || {}, _ref133$successPageDu = _ref133.successPageDuration, successPageDuration = _ref133$successPageDu === void 0 ? 2000 : _ref133$successPageDu, subTitle = _ref133.subTitle, title = _ref133.title, stampWith = _ref133.stampWith;
5639
+ _ref141 = params || {}, _ref141$successPageDu = _ref141.successPageDuration, successPageDuration = _ref141$successPageDu === void 0 ? 2000 : _ref141$successPageDu, subTitle = _ref141.subTitle, title = _ref141.title, stampWith = _ref141.stampWith;
5466
5640
  if (client) {
5467
- _context115.n = 1;
5641
+ _context121.n = 1;
5468
5642
  break;
5469
5643
  }
5470
5644
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5471
5645
  case 1:
5472
- _context115.n = 2;
5646
+ _context121.n = 2;
5473
5647
  return getSession();
5474
5648
  case 2:
5475
- s = _context115.v;
5649
+ s = _context121.v;
5476
5650
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5477
5651
  if (organizationId) {
5478
- _context115.n = 3;
5652
+ _context121.n = 3;
5479
5653
  break;
5480
5654
  }
5481
5655
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5482
5656
  case 3:
5483
5657
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5484
5658
  if (userId) {
5485
- _context115.n = 4;
5659
+ _context121.n = 4;
5486
5660
  break;
5487
5661
  }
5488
5662
  throw new TurnkeyError("A user ID is required to add an email.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5502,12 +5676,12 @@ var ClientProvider = function ClientProvider(_ref) {
5502
5676
  showTitle: false
5503
5677
  });
5504
5678
  };
5505
- _context115.p = 5;
5679
+ _context121.p = 5;
5506
5680
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
5507
- _context115.n = 6;
5681
+ _context121.n = 6;
5508
5682
  break;
5509
5683
  }
5510
- return _context115.a(2, withTurnkeyErrorHandling(function () {
5684
+ return _context121.a(2, withTurnkeyErrorHandling(function () {
5511
5685
  return new Promise(function (resolve, reject) {
5512
5686
  pushPage({
5513
5687
  key: "Add Email",
@@ -5535,18 +5709,18 @@ var ClientProvider = function ClientProvider(_ref) {
5535
5709
  return logout();
5536
5710
  }));
5537
5711
  case 6:
5538
- _context115.n = 7;
5712
+ _context121.n = 7;
5539
5713
  return initOtp({
5540
5714
  otpType: OtpType.Email,
5541
5715
  contact: params.email
5542
5716
  });
5543
5717
  case 7:
5544
- _yield$initOtp3 = _context115.v;
5718
+ _yield$initOtp3 = _context121.v;
5545
5719
  otpId = _yield$initOtp3.otpId;
5546
5720
  otpEncryptionTargetBundle = _yield$initOtp3.otpEncryptionTargetBundle;
5547
- return _context115.a(2, withTurnkeyErrorHandling(function () {
5721
+ return _context121.a(2, withTurnkeyErrorHandling(function () {
5548
5722
  return new Promise(function (resolve, reject) {
5549
- var _masterConfig$auth70, _masterConfig$auth71;
5723
+ var _masterConfig$auth72, _masterConfig$auth73;
5550
5724
  pushPage({
5551
5725
  key: "Add Email",
5552
5726
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2({
@@ -5554,25 +5728,25 @@ var ClientProvider = function ClientProvider(_ref) {
5554
5728
  contact: params.email,
5555
5729
  otpId: otpId,
5556
5730
  otpEncryptionTargetBundle: otpEncryptionTargetBundle,
5557
- otpLength: (masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth70 = masterConfig.auth) === null || _masterConfig$auth70 === void 0 ? void 0 : _masterConfig$auth70.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5558
- alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth71 = masterConfig.auth) === null || _masterConfig$auth71 === void 0 ? void 0 : _masterConfig$auth71.otpAlphanumeric,
5731
+ otpLength: (masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth72 = masterConfig.auth) === null || _masterConfig$auth72 === void 0 ? void 0 : _masterConfig$auth72.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5732
+ alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth73 = masterConfig.auth) === null || _masterConfig$auth73 === void 0 ? void 0 : _masterConfig$auth73.otpAlphanumeric,
5559
5733
  onContinue: function () {
5560
- var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee114(otpCode) {
5561
- var _yield$verifyOtp3, verificationToken, res, _t17;
5562
- return _regenerator().w(function (_context114) {
5563
- while (1) switch (_context114.p = _context114.n) {
5734
+ var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee120(otpCode) {
5735
+ var _yield$verifyOtp3, verificationToken, res, _t22;
5736
+ return _regenerator().w(function (_context120) {
5737
+ while (1) switch (_context120.p = _context120.n) {
5564
5738
  case 0:
5565
- _context114.p = 0;
5566
- _context114.n = 1;
5739
+ _context120.p = 0;
5740
+ _context120.n = 1;
5567
5741
  return verifyOtp({
5568
5742
  otpId: otpId,
5569
5743
  otpCode: otpCode,
5570
5744
  otpEncryptionTargetBundle: otpEncryptionTargetBundle
5571
5745
  });
5572
5746
  case 1:
5573
- _yield$verifyOtp3 = _context114.v;
5747
+ _yield$verifyOtp3 = _context120.v;
5574
5748
  verificationToken = _yield$verifyOtp3.verificationToken;
5575
- _context114.n = 2;
5749
+ _context120.n = 2;
5576
5750
  return updateUserEmail({
5577
5751
  email: params.email,
5578
5752
  verificationToken: verificationToken,
@@ -5581,21 +5755,21 @@ var ClientProvider = function ClientProvider(_ref) {
5581
5755
  stampWith: stampWith
5582
5756
  });
5583
5757
  case 2:
5584
- res = _context114.v;
5758
+ res = _context120.v;
5585
5759
  onSuccess();
5586
5760
  resolve(res);
5587
- _context114.n = 4;
5761
+ _context120.n = 4;
5588
5762
  break;
5589
5763
  case 3:
5590
- _context114.p = 3;
5591
- _t17 = _context114.v;
5592
- reject(_t17);
5764
+ _context120.p = 3;
5765
+ _t22 = _context120.v;
5766
+ reject(_t22);
5593
5767
  case 4:
5594
- return _context114.a(2);
5768
+ return _context120.a(2);
5595
5769
  }
5596
- }, _callee114, null, [[0, 3]]);
5770
+ }, _callee120, null, [[0, 3]]);
5597
5771
  }));
5598
- function onContinue(_x99) {
5772
+ function onContinue(_x100) {
5599
5773
  return _onContinue3.apply(this, arguments);
5600
5774
  }
5601
5775
  return onContinue;
@@ -5612,60 +5786,60 @@ var ClientProvider = function ClientProvider(_ref) {
5612
5786
  return logout();
5613
5787
  }, callbacks, "Failed to add email"));
5614
5788
  case 8:
5615
- _context115.n = 11;
5789
+ _context121.n = 11;
5616
5790
  break;
5617
5791
  case 9:
5618
- _context115.p = 9;
5619
- _t18 = _context115.v;
5620
- if (!(_t18 instanceof TurnkeyError)) {
5621
- _context115.n = 10;
5792
+ _context121.p = 9;
5793
+ _t23 = _context121.v;
5794
+ if (!(_t23 instanceof TurnkeyError)) {
5795
+ _context121.n = 10;
5622
5796
  break;
5623
5797
  }
5624
- throw _t18;
5798
+ throw _t23;
5625
5799
  case 10:
5626
- throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t18);
5800
+ throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t23);
5627
5801
  case 11:
5628
- return _context115.a(2);
5802
+ return _context121.a(2);
5629
5803
  }
5630
- }, _callee115, null, [[5, 9]]);
5804
+ }, _callee121, null, [[5, 9]]);
5631
5805
  }));
5632
- return function (_x98) {
5633
- return _ref132.apply(this, arguments);
5806
+ return function (_x99) {
5807
+ return _ref140.apply(this, arguments);
5634
5808
  };
5635
5809
  }(), [client, getSession, pushPage, closeModal, user, logout, initOtp, masterConfig, verifyOtp, updateUserEmail, callbacks]);
5636
5810
  var handleAddPhoneNumber = useCallback(/*#__PURE__*/function () {
5637
- var _ref134 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee117(params) {
5638
- var _ref135, _ref135$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp4, otpId, otpEncryptionTargetBundle, _t20;
5639
- return _regenerator().w(function (_context117) {
5640
- while (1) switch (_context117.p = _context117.n) {
5811
+ var _ref142 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee123(params) {
5812
+ var _ref143, _ref143$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp4, otpId, otpEncryptionTargetBundle, _t25;
5813
+ return _regenerator().w(function (_context123) {
5814
+ while (1) switch (_context123.p = _context123.n) {
5641
5815
  case 0:
5642
- _ref135 = params || {}, _ref135$successPageDu = _ref135.successPageDuration, successPageDuration = _ref135$successPageDu === void 0 ? 2000 : _ref135$successPageDu, subTitle = _ref135.subTitle, title = _ref135.title, stampWith = _ref135.stampWith;
5816
+ _ref143 = params || {}, _ref143$successPageDu = _ref143.successPageDuration, successPageDuration = _ref143$successPageDu === void 0 ? 2000 : _ref143$successPageDu, subTitle = _ref143.subTitle, title = _ref143.title, stampWith = _ref143.stampWith;
5643
5817
  if (client) {
5644
- _context117.n = 1;
5818
+ _context123.n = 1;
5645
5819
  break;
5646
5820
  }
5647
5821
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5648
5822
  case 1:
5649
5823
  if (masterConfig) {
5650
- _context117.n = 2;
5824
+ _context123.n = 2;
5651
5825
  break;
5652
5826
  }
5653
5827
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
5654
5828
  case 2:
5655
- _context117.n = 3;
5829
+ _context123.n = 3;
5656
5830
  return getSession();
5657
5831
  case 3:
5658
- s = _context117.v;
5832
+ s = _context123.v;
5659
5833
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5660
5834
  if (organizationId) {
5661
- _context117.n = 4;
5835
+ _context123.n = 4;
5662
5836
  break;
5663
5837
  }
5664
5838
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5665
5839
  case 4:
5666
5840
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5667
5841
  if (userId) {
5668
- _context117.n = 5;
5842
+ _context123.n = 5;
5669
5843
  break;
5670
5844
  }
5671
5845
  throw new TurnkeyError("A user ID is required to add a phone number.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5685,12 +5859,12 @@ var ClientProvider = function ClientProvider(_ref) {
5685
5859
  showTitle: false
5686
5860
  });
5687
5861
  };
5688
- _context117.p = 6;
5862
+ _context123.p = 6;
5689
5863
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
5690
- _context117.n = 7;
5864
+ _context123.n = 7;
5691
5865
  break;
5692
5866
  }
5693
- return _context117.a(2, withTurnkeyErrorHandling(function () {
5867
+ return _context123.a(2, withTurnkeyErrorHandling(function () {
5694
5868
  return new Promise(function (resolve, reject) {
5695
5869
  pushPage({
5696
5870
  key: "Add Phone Number",
@@ -5718,18 +5892,18 @@ var ClientProvider = function ClientProvider(_ref) {
5718
5892
  return logout();
5719
5893
  }, callbacks, "Failed to add phone number"));
5720
5894
  case 7:
5721
- _context117.n = 8;
5895
+ _context123.n = 8;
5722
5896
  return initOtp({
5723
5897
  otpType: OtpType.Sms,
5724
5898
  contact: params.phoneNumber
5725
5899
  });
5726
5900
  case 8:
5727
- _yield$initOtp4 = _context117.v;
5901
+ _yield$initOtp4 = _context123.v;
5728
5902
  otpId = _yield$initOtp4.otpId;
5729
5903
  otpEncryptionTargetBundle = _yield$initOtp4.otpEncryptionTargetBundle;
5730
- return _context117.a(2, withTurnkeyErrorHandling(function () {
5904
+ return _context123.a(2, withTurnkeyErrorHandling(function () {
5731
5905
  return new Promise(function (resolve, reject) {
5732
- var _masterConfig$auth72, _masterConfig$auth73;
5906
+ var _masterConfig$auth74, _masterConfig$auth75;
5733
5907
  pushPage({
5734
5908
  key: "Add Phone Number",
5735
5909
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5737,25 +5911,25 @@ var ClientProvider = function ClientProvider(_ref) {
5737
5911
  contact: params.phoneNumber,
5738
5912
  otpId: otpId,
5739
5913
  otpEncryptionTargetBundle: otpEncryptionTargetBundle,
5740
- otpLength: ((_masterConfig$auth72 = masterConfig.auth) === null || _masterConfig$auth72 === void 0 ? void 0 : _masterConfig$auth72.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5741
- alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth73 = masterConfig.auth) === null || _masterConfig$auth73 === void 0 ? void 0 : _masterConfig$auth73.otpAlphanumeric,
5914
+ otpLength: ((_masterConfig$auth74 = masterConfig.auth) === null || _masterConfig$auth74 === void 0 ? void 0 : _masterConfig$auth74.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5915
+ alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth75 = masterConfig.auth) === null || _masterConfig$auth75 === void 0 ? void 0 : _masterConfig$auth75.otpAlphanumeric,
5742
5916
  onContinue: function () {
5743
- var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee116(otpCode) {
5744
- var _yield$verifyOtp4, verificationToken, res, _t19;
5745
- return _regenerator().w(function (_context116) {
5746
- while (1) switch (_context116.p = _context116.n) {
5917
+ var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee122(otpCode) {
5918
+ var _yield$verifyOtp4, verificationToken, res, _t24;
5919
+ return _regenerator().w(function (_context122) {
5920
+ while (1) switch (_context122.p = _context122.n) {
5747
5921
  case 0:
5748
- _context116.p = 0;
5749
- _context116.n = 1;
5922
+ _context122.p = 0;
5923
+ _context122.n = 1;
5750
5924
  return verifyOtp({
5751
5925
  otpId: otpId,
5752
5926
  otpCode: otpCode,
5753
5927
  otpEncryptionTargetBundle: otpEncryptionTargetBundle
5754
5928
  });
5755
5929
  case 1:
5756
- _yield$verifyOtp4 = _context116.v;
5930
+ _yield$verifyOtp4 = _context122.v;
5757
5931
  verificationToken = _yield$verifyOtp4.verificationToken;
5758
- _context116.n = 2;
5932
+ _context122.n = 2;
5759
5933
  return updateUserPhoneNumber({
5760
5934
  phoneNumber: params.phoneNumber,
5761
5935
  verificationToken: verificationToken,
@@ -5764,21 +5938,21 @@ var ClientProvider = function ClientProvider(_ref) {
5764
5938
  stampWith: stampWith
5765
5939
  });
5766
5940
  case 2:
5767
- res = _context116.v;
5941
+ res = _context122.v;
5768
5942
  onSuccess();
5769
5943
  resolve(res);
5770
- _context116.n = 4;
5944
+ _context122.n = 4;
5771
5945
  break;
5772
5946
  case 3:
5773
- _context116.p = 3;
5774
- _t19 = _context116.v;
5775
- reject(_t19);
5947
+ _context122.p = 3;
5948
+ _t24 = _context122.v;
5949
+ reject(_t24);
5776
5950
  case 4:
5777
- return _context116.a(2);
5951
+ return _context122.a(2);
5778
5952
  }
5779
- }, _callee116, null, [[0, 3]]);
5953
+ }, _callee122, null, [[0, 3]]);
5780
5954
  }));
5781
- function onContinue(_x101) {
5955
+ function onContinue(_x102) {
5782
5956
  return _onContinue4.apply(this, arguments);
5783
5957
  }
5784
5958
  return onContinue;
@@ -5797,52 +5971,52 @@ var ClientProvider = function ClientProvider(_ref) {
5797
5971
  return logout();
5798
5972
  }, callbacks, "Failed to add phone number"));
5799
5973
  case 9:
5800
- _context117.n = 12;
5974
+ _context123.n = 12;
5801
5975
  break;
5802
5976
  case 10:
5803
- _context117.p = 10;
5804
- _t20 = _context117.v;
5805
- if (!(_t20 instanceof TurnkeyError)) {
5806
- _context117.n = 11;
5977
+ _context123.p = 10;
5978
+ _t25 = _context123.v;
5979
+ if (!(_t25 instanceof TurnkeyError)) {
5980
+ _context123.n = 11;
5807
5981
  break;
5808
5982
  }
5809
- throw _t20;
5983
+ throw _t25;
5810
5984
  case 11:
5811
- throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t20);
5985
+ throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t25);
5812
5986
  case 12:
5813
- return _context117.a(2);
5987
+ return _context123.a(2);
5814
5988
  }
5815
- }, _callee117, null, [[6, 10]]);
5989
+ }, _callee123, null, [[6, 10]]);
5816
5990
  }));
5817
- return function (_x100) {
5818
- return _ref134.apply(this, arguments);
5991
+ return function (_x101) {
5992
+ return _ref142.apply(this, arguments);
5819
5993
  };
5820
5994
  }(), [client, masterConfig, getSession, pushPage, closeModal, user, logout, callbacks, initOtp, verifyOtp, updateUserPhoneNumber]);
5821
5995
  var handleRemovePasskey = useCallback(/*#__PURE__*/function () {
5822
- var _ref136 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee118(params) {
5996
+ var _ref144 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee124(params) {
5823
5997
  var authenticatorId, _params$successPageDu2, successPageDuration, subTitle, title, stampWith, userId, s, organizationId;
5824
- return _regenerator().w(function (_context118) {
5825
- while (1) switch (_context118.n) {
5998
+ return _regenerator().w(function (_context124) {
5999
+ while (1) switch (_context124.n) {
5826
6000
  case 0:
5827
6001
  authenticatorId = params.authenticatorId, _params$successPageDu2 = params.successPageDuration, successPageDuration = _params$successPageDu2 === void 0 ? 2000 : _params$successPageDu2, subTitle = params.subTitle, title = params.title, stampWith = params.stampWith, userId = params.userId;
5828
6002
  if (client) {
5829
- _context118.n = 1;
6003
+ _context124.n = 1;
5830
6004
  break;
5831
6005
  }
5832
6006
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5833
6007
  case 1:
5834
- _context118.n = 2;
6008
+ _context124.n = 2;
5835
6009
  return getSession();
5836
6010
  case 2:
5837
- s = _context118.v;
6011
+ s = _context124.v;
5838
6012
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5839
6013
  if (organizationId) {
5840
- _context118.n = 3;
6014
+ _context124.n = 3;
5841
6015
  break;
5842
6016
  }
5843
6017
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5844
6018
  case 3:
5845
- return _context118.a(2, withTurnkeyErrorHandling(function () {
6019
+ return _context124.a(2, withTurnkeyErrorHandling(function () {
5846
6020
  return new Promise(function (resolve, reject) {
5847
6021
  pushPage({
5848
6022
  key: "Remove Passkey",
@@ -5873,44 +6047,44 @@ var ClientProvider = function ClientProvider(_ref) {
5873
6047
  return logout();
5874
6048
  }, callbacks, "Failed to remove passkey"));
5875
6049
  }
5876
- }, _callee118);
6050
+ }, _callee124);
5877
6051
  }));
5878
- return function (_x102) {
5879
- return _ref136.apply(this, arguments);
6052
+ return function (_x103) {
6053
+ return _ref144.apply(this, arguments);
5880
6054
  };
5881
6055
  }(), [client, getSession, pushPage, logout, callbacks]);
5882
6056
  var handleAddPasskey = useCallback(/*#__PURE__*/function () {
5883
- var _ref137 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee119(params) {
5884
- var _ref138, name, displayName, _ref138$successPageDu, successPageDuration, stampWith, s, organizationId, userId, resPromise, _t21;
5885
- return _regenerator().w(function (_context119) {
5886
- while (1) switch (_context119.p = _context119.n) {
6057
+ var _ref145 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee125(params) {
6058
+ var _ref146, name, displayName, _ref146$successPageDu, successPageDuration, stampWith, s, organizationId, userId, resPromise, _t26;
6059
+ return _regenerator().w(function (_context125) {
6060
+ while (1) switch (_context125.p = _context125.n) {
5887
6061
  case 0:
5888
- _ref138 = params || {}, name = _ref138.name, displayName = _ref138.displayName, _ref138$successPageDu = _ref138.successPageDuration, successPageDuration = _ref138$successPageDu === void 0 ? 2000 : _ref138$successPageDu, stampWith = _ref138.stampWith;
6062
+ _ref146 = params || {}, name = _ref146.name, displayName = _ref146.displayName, _ref146$successPageDu = _ref146.successPageDuration, successPageDuration = _ref146$successPageDu === void 0 ? 2000 : _ref146$successPageDu, stampWith = _ref146.stampWith;
5889
6063
  if (client) {
5890
- _context119.n = 1;
6064
+ _context125.n = 1;
5891
6065
  break;
5892
6066
  }
5893
6067
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5894
6068
  case 1:
5895
- _context119.n = 2;
6069
+ _context125.n = 2;
5896
6070
  return getSession();
5897
6071
  case 2:
5898
- s = _context119.v;
6072
+ s = _context125.v;
5899
6073
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5900
6074
  if (organizationId) {
5901
- _context119.n = 3;
6075
+ _context125.n = 3;
5902
6076
  break;
5903
6077
  }
5904
6078
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5905
6079
  case 3:
5906
6080
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5907
6081
  if (userId) {
5908
- _context119.n = 4;
6082
+ _context125.n = 4;
5909
6083
  break;
5910
6084
  }
5911
6085
  throw new TurnkeyError("A user ID or a valid session is required to add a passkey.", TurnkeyErrorCodes.INVALID_REQUEST);
5912
6086
  case 4:
5913
- _context119.p = 4;
6087
+ _context125.p = 4;
5914
6088
  resPromise = addPasskey(_objectSpread2(_objectSpread2(_objectSpread2({}, name && {
5915
6089
  name: name
5916
6090
  }), displayName && {
@@ -5935,55 +6109,55 @@ var ClientProvider = function ClientProvider(_ref) {
5935
6109
  showTitle: false
5936
6110
  });
5937
6111
  });
5938
- _context119.n = 5;
6112
+ _context125.n = 5;
5939
6113
  return resPromise;
5940
6114
  case 5:
5941
- return _context119.a(2, _context119.v);
6115
+ return _context125.a(2, _context125.v);
5942
6116
  case 6:
5943
- _context119.p = 6;
5944
- _t21 = _context119.v;
5945
- if (!(_t21 instanceof TurnkeyError)) {
5946
- _context119.n = 7;
6117
+ _context125.p = 6;
6118
+ _t26 = _context125.v;
6119
+ if (!(_t26 instanceof TurnkeyError)) {
6120
+ _context125.n = 7;
5947
6121
  break;
5948
6122
  }
5949
- throw _t21;
6123
+ throw _t26;
5950
6124
  case 7:
5951
- throw new TurnkeyError("Failed to add passkey in handler.", TurnkeyErrorCodes.ADD_PASSKEY_ERROR, _t21);
6125
+ throw new TurnkeyError("Failed to add passkey in handler.", TurnkeyErrorCodes.ADD_PASSKEY_ERROR, _t26);
5952
6126
  case 8:
5953
- return _context119.a(2);
6127
+ return _context125.a(2);
5954
6128
  }
5955
- }, _callee119, null, [[4, 6]]);
6129
+ }, _callee125, null, [[4, 6]]);
5956
6130
  }));
5957
- return function (_x103) {
5958
- return _ref137.apply(this, arguments);
6131
+ return function (_x104) {
6132
+ return _ref145.apply(this, arguments);
5959
6133
  };
5960
6134
  }(), [client, getSession, addPasskey, pushPage, closeModal]);
5961
6135
  var handleRemoveOauthProvider = useCallback(/*#__PURE__*/function () {
5962
- var _ref139 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee120(params) {
5963
- var providerId, _params$successPageDu3, successPageDuration, subTitle, title, stampWith, s, organizationId, _t22;
5964
- return _regenerator().w(function (_context120) {
5965
- while (1) switch (_context120.p = _context120.n) {
6136
+ var _ref147 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee126(params) {
6137
+ var providerId, _params$successPageDu3, successPageDuration, subTitle, title, stampWith, s, organizationId, _t27;
6138
+ return _regenerator().w(function (_context126) {
6139
+ while (1) switch (_context126.p = _context126.n) {
5966
6140
  case 0:
5967
6141
  providerId = params.providerId, _params$successPageDu3 = params.successPageDuration, successPageDuration = _params$successPageDu3 === void 0 ? 2000 : _params$successPageDu3, subTitle = params.subTitle, title = params.title, stampWith = params.stampWith;
5968
6142
  if (client) {
5969
- _context120.n = 1;
6143
+ _context126.n = 1;
5970
6144
  break;
5971
6145
  }
5972
6146
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5973
6147
  case 1:
5974
- _context120.n = 2;
6148
+ _context126.n = 2;
5975
6149
  return getSession();
5976
6150
  case 2:
5977
- s = _context120.v;
6151
+ s = _context126.v;
5978
6152
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5979
6153
  if (organizationId) {
5980
- _context120.n = 3;
6154
+ _context126.n = 3;
5981
6155
  break;
5982
6156
  }
5983
6157
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5984
6158
  case 3:
5985
- _context120.p = 3;
5986
- return _context120.a(2, new Promise(function (resolve, reject) {
6159
+ _context126.p = 3;
6160
+ return _context126.a(2, new Promise(function (resolve, reject) {
5987
6161
  pushPage({
5988
6162
  key: "Remove OAuth Provider",
5989
6163
  content: jsx(RemoveOAuthProvider, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -6011,94 +6185,94 @@ var ClientProvider = function ClientProvider(_ref) {
6011
6185
  });
6012
6186
  }));
6013
6187
  case 4:
6014
- _context120.p = 4;
6015
- _t22 = _context120.v;
6016
- if (!(_t22 instanceof TurnkeyError)) {
6017
- _context120.n = 5;
6188
+ _context126.p = 4;
6189
+ _t27 = _context126.v;
6190
+ if (!(_t27 instanceof TurnkeyError)) {
6191
+ _context126.n = 5;
6018
6192
  break;
6019
6193
  }
6020
- throw _t22;
6194
+ throw _t27;
6021
6195
  case 5:
6022
- throw new TurnkeyError("Failed to remove OAuth provider in handler.", TurnkeyErrorCodes.REMOVE_OAUTH_PROVIDER_ERROR, _t22);
6196
+ throw new TurnkeyError("Failed to remove OAuth provider in handler.", TurnkeyErrorCodes.REMOVE_OAUTH_PROVIDER_ERROR, _t27);
6023
6197
  case 6:
6024
- return _context120.a(2);
6198
+ return _context126.a(2);
6025
6199
  }
6026
- }, _callee120, null, [[3, 4]]);
6200
+ }, _callee126, null, [[3, 4]]);
6027
6201
  }));
6028
- return function (_x104) {
6029
- return _ref139.apply(this, arguments);
6202
+ return function (_x105) {
6203
+ return _ref147.apply(this, arguments);
6030
6204
  };
6031
6205
  }(), [client, getSession, pushPage]);
6032
6206
  var handleAddOauthProvider = useCallback(/*#__PURE__*/function () {
6033
- var _ref140 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee123(params) {
6034
- var _masterConfig$auth$oa12, _masterConfig$auth74, _masterConfig$auth74$, _masterConfig$auth75, _masterConfig$auth75$, _masterConfig$auth76, _masterConfig$auth76$, _masterConfig$auth77, _masterConfig$auth77$, _masterConfig$auth78, _masterConfig$auth78$, _masterConfig$auth79, _masterConfig$auth79$, _params$primaryClient, _providerConfig, _ref141, _params$secondaryClie, _providerConfig2;
6035
- var providerName, stampWith, _params$successPageDu4, successPageDuration, _params$openInPage, openInPage, providerConfig, primaryClientId, secondaryClientIds, s, organizationId, userId, _t25;
6036
- return _regenerator().w(function (_context123) {
6037
- while (1) switch (_context123.n) {
6207
+ var _ref148 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee129(params) {
6208
+ var _masterConfig$auth$oa12, _masterConfig$auth76, _masterConfig$auth76$, _masterConfig$auth77, _masterConfig$auth77$, _masterConfig$auth78, _masterConfig$auth78$, _masterConfig$auth79, _masterConfig$auth79$, _masterConfig$auth80, _masterConfig$auth80$, _masterConfig$auth81, _masterConfig$auth81$, _params$primaryClient, _providerConfig, _ref149, _params$secondaryClie, _providerConfig2;
6209
+ var providerName, stampWith, _params$successPageDu4, successPageDuration, _params$openInPage, openInPage, providerConfig, primaryClientId, secondaryClientIds, s, organizationId, userId, _t30;
6210
+ return _regenerator().w(function (_context129) {
6211
+ while (1) switch (_context129.n) {
6038
6212
  case 0:
6039
6213
  if (client) {
6040
- _context123.n = 1;
6214
+ _context129.n = 1;
6041
6215
  break;
6042
6216
  }
6043
6217
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
6044
6218
  case 1:
6045
- providerName = params.providerName, stampWith = params.stampWith, _params$successPageDu4 = params.successPageDuration, successPageDuration = _params$successPageDu4 === void 0 ? 2000 : _params$successPageDu4, _params$openInPage = params.openInPage, openInPage = _params$openInPage === void 0 ? (_masterConfig$auth$oa12 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth74 = masterConfig.auth) === null || _masterConfig$auth74 === void 0 ? void 0 : (_masterConfig$auth74$ = _masterConfig$auth74.oauthConfig) === null || _masterConfig$auth74$ === void 0 ? void 0 : _masterConfig$auth74$.openOauthInPage) !== null && _masterConfig$auth$oa12 !== void 0 ? _masterConfig$auth$oa12 : false : _params$openInPage; // Resolve the provider's per-provider config, then apply per-call overrides.
6046
- _t25 = providerName;
6047
- _context123.n = _t25 === OAuthProviders.DISCORD ? 2 : _t25 === OAuthProviders.X ? 3 : _t25 === OAuthProviders.GOOGLE ? 4 : _t25 === OAuthProviders.APPLE ? 5 : _t25 === OAuthProviders.FACEBOOK ? 6 : 7;
6219
+ providerName = params.providerName, stampWith = params.stampWith, _params$successPageDu4 = params.successPageDuration, successPageDuration = _params$successPageDu4 === void 0 ? 2000 : _params$successPageDu4, _params$openInPage = params.openInPage, openInPage = _params$openInPage === void 0 ? (_masterConfig$auth$oa12 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth76 = masterConfig.auth) === null || _masterConfig$auth76 === void 0 ? void 0 : (_masterConfig$auth76$ = _masterConfig$auth76.oauthConfig) === null || _masterConfig$auth76$ === void 0 ? void 0 : _masterConfig$auth76$.openOauthInPage) !== null && _masterConfig$auth$oa12 !== void 0 ? _masterConfig$auth$oa12 : false : _params$openInPage; // Resolve the provider's per-provider config, then apply per-call overrides.
6220
+ _t30 = providerName;
6221
+ _context129.n = _t30 === OAuthProviders.DISCORD ? 2 : _t30 === OAuthProviders.X ? 3 : _t30 === OAuthProviders.GOOGLE ? 4 : _t30 === OAuthProviders.APPLE ? 5 : _t30 === OAuthProviders.FACEBOOK ? 6 : 7;
6048
6222
  break;
6049
6223
  case 2:
6050
- providerConfig = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth75 = masterConfig.auth) === null || _masterConfig$auth75 === void 0 ? void 0 : (_masterConfig$auth75$ = _masterConfig$auth75.oauthConfig) === null || _masterConfig$auth75$ === void 0 ? void 0 : _masterConfig$auth75$.discord;
6051
- return _context123.a(3, 8);
6224
+ providerConfig = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth77 = masterConfig.auth) === null || _masterConfig$auth77 === void 0 ? void 0 : (_masterConfig$auth77$ = _masterConfig$auth77.oauthConfig) === null || _masterConfig$auth77$ === void 0 ? void 0 : _masterConfig$auth77$.discord;
6225
+ return _context129.a(3, 8);
6052
6226
  case 3:
6053
- providerConfig = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth76 = masterConfig.auth) === null || _masterConfig$auth76 === void 0 ? void 0 : (_masterConfig$auth76$ = _masterConfig$auth76.oauthConfig) === null || _masterConfig$auth76$ === void 0 ? void 0 : _masterConfig$auth76$.x;
6054
- return _context123.a(3, 8);
6227
+ providerConfig = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth78 = masterConfig.auth) === null || _masterConfig$auth78 === void 0 ? void 0 : (_masterConfig$auth78$ = _masterConfig$auth78.oauthConfig) === null || _masterConfig$auth78$ === void 0 ? void 0 : _masterConfig$auth78$.x;
6228
+ return _context129.a(3, 8);
6055
6229
  case 4:
6056
- providerConfig = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth77 = masterConfig.auth) === null || _masterConfig$auth77 === void 0 ? void 0 : (_masterConfig$auth77$ = _masterConfig$auth77.oauthConfig) === null || _masterConfig$auth77$ === void 0 ? void 0 : _masterConfig$auth77$.google;
6057
- return _context123.a(3, 8);
6230
+ providerConfig = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth79 = masterConfig.auth) === null || _masterConfig$auth79 === void 0 ? void 0 : (_masterConfig$auth79$ = _masterConfig$auth79.oauthConfig) === null || _masterConfig$auth79$ === void 0 ? void 0 : _masterConfig$auth79$.google;
6231
+ return _context129.a(3, 8);
6058
6232
  case 5:
6059
- providerConfig = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth78 = masterConfig.auth) === null || _masterConfig$auth78 === void 0 ? void 0 : (_masterConfig$auth78$ = _masterConfig$auth78.oauthConfig) === null || _masterConfig$auth78$ === void 0 ? void 0 : _masterConfig$auth78$.apple;
6060
- return _context123.a(3, 8);
6233
+ providerConfig = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth80 = masterConfig.auth) === null || _masterConfig$auth80 === void 0 ? void 0 : (_masterConfig$auth80$ = _masterConfig$auth80.oauthConfig) === null || _masterConfig$auth80$ === void 0 ? void 0 : _masterConfig$auth80$.apple;
6234
+ return _context129.a(3, 8);
6061
6235
  case 6:
6062
- providerConfig = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth79 = masterConfig.auth) === null || _masterConfig$auth79 === void 0 ? void 0 : (_masterConfig$auth79$ = _masterConfig$auth79.oauthConfig) === null || _masterConfig$auth79$ === void 0 ? void 0 : _masterConfig$auth79$.facebook;
6063
- return _context123.a(3, 8);
6236
+ providerConfig = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth81 = masterConfig.auth) === null || _masterConfig$auth81 === void 0 ? void 0 : (_masterConfig$auth81$ = _masterConfig$auth81.oauthConfig) === null || _masterConfig$auth81$ === void 0 ? void 0 : _masterConfig$auth81$.facebook;
6237
+ return _context129.a(3, 8);
6064
6238
  case 7:
6065
6239
  providerConfig = undefined;
6066
6240
  case 8:
6067
6241
  primaryClientId = (_params$primaryClient = params.primaryClientId) !== null && _params$primaryClient !== void 0 ? _params$primaryClient : (_providerConfig = providerConfig) === null || _providerConfig === void 0 ? void 0 : _providerConfig.primaryClientId;
6068
- secondaryClientIds = (_ref141 = (_params$secondaryClie = params.secondaryClientIds) !== null && _params$secondaryClie !== void 0 ? _params$secondaryClie : (_providerConfig2 = providerConfig) === null || _providerConfig2 === void 0 ? void 0 : _providerConfig2.secondaryClientIds) !== null && _ref141 !== void 0 ? _ref141 : [];
6069
- _context123.n = 9;
6242
+ secondaryClientIds = (_ref149 = (_params$secondaryClie = params.secondaryClientIds) !== null && _params$secondaryClie !== void 0 ? _params$secondaryClie : (_providerConfig2 = providerConfig) === null || _providerConfig2 === void 0 ? void 0 : _providerConfig2.secondaryClientIds) !== null && _ref149 !== void 0 ? _ref149 : [];
6243
+ _context129.n = 9;
6070
6244
  return getSession();
6071
6245
  case 9:
6072
- s = _context123.v;
6246
+ s = _context129.v;
6073
6247
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
6074
6248
  if (organizationId) {
6075
- _context123.n = 10;
6249
+ _context129.n = 10;
6076
6250
  break;
6077
6251
  }
6078
6252
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
6079
6253
  case 10:
6080
6254
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
6081
6255
  if (userId) {
6082
- _context123.n = 11;
6256
+ _context129.n = 11;
6083
6257
  break;
6084
6258
  }
6085
6259
  throw new TurnkeyError("A user ID is required to add an OAuth provider.", TurnkeyErrorCodes.INVALID_REQUEST);
6086
6260
  case 11:
6087
- return _context123.a(2, new Promise(/*#__PURE__*/function () {
6088
- var _ref142 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee122(resolve, reject) {
6089
- var onOauthSuccess, additionalState, sharedOauthParams, _t23, _t24;
6090
- return _regenerator().w(function (_context122) {
6091
- while (1) switch (_context122.p = _context122.n) {
6261
+ return _context129.a(2, new Promise(/*#__PURE__*/function () {
6262
+ var _ref150 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee128(resolve, reject) {
6263
+ var onOauthSuccess, additionalState, sharedOauthParams, _t28, _t29;
6264
+ return _regenerator().w(function (_context128) {
6265
+ while (1) switch (_context128.p = _context128.n) {
6092
6266
  case 0:
6093
- _context122.p = 0;
6267
+ _context128.p = 0;
6094
6268
  onOauthSuccess = /*#__PURE__*/function () {
6095
- var _ref143 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee121(params) {
6269
+ var _ref151 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee127(params) {
6096
6270
  var oidcClaims;
6097
- return _regenerator().w(function (_context121) {
6098
- while (1) switch (_context121.n) {
6271
+ return _regenerator().w(function (_context127) {
6272
+ while (1) switch (_context127.n) {
6099
6273
  case 0:
6100
6274
  oidcClaims = buildSecondaryOidcClaims(params.oidcToken, secondaryClientIds);
6101
- _context121.n = 1;
6275
+ _context127.n = 1;
6102
6276
  return addOauthProvider(_objectSpread2(_objectSpread2({
6103
6277
  providerName: params.providerName,
6104
6278
  oidcToken: params.oidcToken
@@ -6124,12 +6298,12 @@ var ClientProvider = function ClientProvider(_ref) {
6124
6298
  showTitle: false
6125
6299
  });
6126
6300
  case 2:
6127
- return _context121.a(2);
6301
+ return _context127.a(2);
6128
6302
  }
6129
- }, _callee121);
6303
+ }, _callee127);
6130
6304
  }));
6131
- return function onOauthSuccess(_x108) {
6132
- return _ref143.apply(this, arguments);
6305
+ return function onOauthSuccess(_x109) {
6306
+ return _ref151.apply(this, arguments);
6133
6307
  };
6134
6308
  }();
6135
6309
  if (openInPage) {
@@ -6158,80 +6332,80 @@ var ClientProvider = function ClientProvider(_ref) {
6158
6332
  }), !openInPage && {
6159
6333
  onOauthSuccess: onOauthSuccess
6160
6334
  });
6161
- _t23 = providerName;
6162
- _context122.n = _t23 === OAuthProviders.DISCORD ? 1 : _t23 === OAuthProviders.X ? 3 : _t23 === OAuthProviders.GOOGLE ? 5 : _t23 === OAuthProviders.APPLE ? 7 : _t23 === OAuthProviders.FACEBOOK ? 9 : 11;
6335
+ _t28 = providerName;
6336
+ _context128.n = _t28 === OAuthProviders.DISCORD ? 1 : _t28 === OAuthProviders.X ? 3 : _t28 === OAuthProviders.GOOGLE ? 5 : _t28 === OAuthProviders.APPLE ? 7 : _t28 === OAuthProviders.FACEBOOK ? 9 : 11;
6163
6337
  break;
6164
6338
  case 1:
6165
- _context122.n = 2;
6339
+ _context128.n = 2;
6166
6340
  return handleDiscordOauth(sharedOauthParams);
6167
6341
  case 2:
6168
- return _context122.a(2, _context122.v);
6342
+ return _context128.a(2, _context128.v);
6169
6343
  case 3:
6170
- _context122.n = 4;
6344
+ _context128.n = 4;
6171
6345
  return handleXOauth(sharedOauthParams);
6172
6346
  case 4:
6173
- return _context122.a(2, _context122.v);
6347
+ return _context128.a(2, _context128.v);
6174
6348
  case 5:
6175
- _context122.n = 6;
6349
+ _context128.n = 6;
6176
6350
  return handleGoogleOauth(sharedOauthParams);
6177
6351
  case 6:
6178
- return _context122.a(2, _context122.v);
6352
+ return _context128.a(2, _context128.v);
6179
6353
  case 7:
6180
- _context122.n = 8;
6354
+ _context128.n = 8;
6181
6355
  return handleAppleOauth(sharedOauthParams);
6182
6356
  case 8:
6183
- return _context122.a(2, _context122.v);
6357
+ return _context128.a(2, _context128.v);
6184
6358
  case 9:
6185
- _context122.n = 10;
6359
+ _context128.n = 10;
6186
6360
  return handleFacebookOauth(sharedOauthParams);
6187
6361
  case 10:
6188
- return _context122.a(2, _context122.v);
6362
+ return _context128.a(2, _context128.v);
6189
6363
  case 11:
6190
6364
  throw new TurnkeyError("Unsupported OAuth provider: ".concat(providerName), TurnkeyErrorCodes.NOT_FOUND);
6191
6365
  case 12:
6192
- _context122.n = 14;
6366
+ _context128.n = 14;
6193
6367
  break;
6194
6368
  case 13:
6195
- _context122.p = 13;
6196
- _t24 = _context122.v;
6197
- reject(_t24);
6369
+ _context128.p = 13;
6370
+ _t29 = _context128.v;
6371
+ reject(_t29);
6198
6372
  case 14:
6199
- return _context122.a(2);
6373
+ return _context128.a(2);
6200
6374
  }
6201
- }, _callee122, null, [[0, 13]]);
6375
+ }, _callee128, null, [[0, 13]]);
6202
6376
  }));
6203
- return function (_x106, _x107) {
6204
- return _ref142.apply(this, arguments);
6377
+ return function (_x107, _x108) {
6378
+ return _ref150.apply(this, arguments);
6205
6379
  };
6206
6380
  }()));
6207
6381
  }
6208
- }, _callee123);
6382
+ }, _callee129);
6209
6383
  }));
6210
- return function (_x105) {
6211
- return _ref140.apply(this, arguments);
6384
+ return function (_x106) {
6385
+ return _ref148.apply(this, arguments);
6212
6386
  };
6213
6387
  }(), [client, getSession, addOauthProvider, pushPage, closeModal, handleDiscordOauth, handleXOauth, handleGoogleOauth, handleAppleOauth, handleFacebookOauth]);
6214
6388
  var handleConnectExternalWallet = useCallback(/*#__PURE__*/function () {
6215
- var _ref144 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee124(params) {
6389
+ var _ref152 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee130(params) {
6216
6390
  var _masterConfig$walletC4, _masterConfig$walletC5;
6217
- var _ref145, _ref145$successPageDu, successPageDuration;
6218
- return _regenerator().w(function (_context124) {
6219
- while (1) switch (_context124.n) {
6391
+ var _ref153, _ref153$successPageDu, successPageDuration;
6392
+ return _regenerator().w(function (_context130) {
6393
+ while (1) switch (_context130.n) {
6220
6394
  case 0:
6221
- _ref145 = params || {}, _ref145$successPageDu = _ref145.successPageDuration, successPageDuration = _ref145$successPageDu === void 0 ? 2000 : _ref145$successPageDu;
6395
+ _ref153 = params || {}, _ref153$successPageDu = _ref153.successPageDuration, successPageDuration = _ref153$successPageDu === void 0 ? 2000 : _ref153$successPageDu;
6222
6396
  if (client) {
6223
- _context124.n = 1;
6397
+ _context130.n = 1;
6224
6398
  break;
6225
6399
  }
6226
6400
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
6227
6401
  case 1:
6228
6402
  if (masterConfig !== null && masterConfig !== void 0 && (_masterConfig$walletC4 = masterConfig.walletConfig) !== null && _masterConfig$walletC4 !== void 0 && (_masterConfig$walletC5 = _masterConfig$walletC4.features) !== null && _masterConfig$walletC5 !== void 0 && _masterConfig$walletC5.connecting) {
6229
- _context124.n = 2;
6403
+ _context130.n = 2;
6230
6404
  break;
6231
6405
  }
6232
6406
  throw new TurnkeyError("Wallet connecting is not enabled.", TurnkeyErrorCodes.FEATURE_NOT_ENABLED);
6233
6407
  case 2:
6234
- return _context124.a(2, new Promise(function (resolve, reject) {
6408
+ return _context130.a(2, new Promise(function (resolve, reject) {
6235
6409
  pushPage({
6236
6410
  key: "Connect wallet",
6237
6411
  content: jsx(ConnectWalletModal, {
@@ -6250,32 +6424,32 @@ var ClientProvider = function ClientProvider(_ref) {
6250
6424
  });
6251
6425
  }));
6252
6426
  }
6253
- }, _callee124);
6427
+ }, _callee130);
6254
6428
  }));
6255
- return function (_x109) {
6256
- return _ref144.apply(this, arguments);
6429
+ return function (_x110) {
6430
+ return _ref152.apply(this, arguments);
6257
6431
  };
6258
6432
  }(), [client, masterConfig, fetchWalletProviders, pushPage]);
6259
6433
  var handleRemoveUserEmail = useCallback(/*#__PURE__*/function () {
6260
- var _ref146 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee125(params) {
6261
- var _ref147, _ref147$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t26;
6262
- return _regenerator().w(function (_context125) {
6263
- while (1) switch (_context125.p = _context125.n) {
6434
+ var _ref154 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee131(params) {
6435
+ var _ref155, _ref155$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t31;
6436
+ return _regenerator().w(function (_context131) {
6437
+ while (1) switch (_context131.p = _context131.n) {
6264
6438
  case 0:
6265
- _ref147 = params || {}, _ref147$successPageDu = _ref147.successPageDuration, successPageDuration = _ref147$successPageDu === void 0 ? 2000 : _ref147$successPageDu, stampWith = _ref147.stampWith, userId = _ref147.userId;
6266
- _context125.n = 1;
6439
+ _ref155 = params || {}, _ref155$successPageDu = _ref155.successPageDuration, successPageDuration = _ref155$successPageDu === void 0 ? 2000 : _ref155$successPageDu, stampWith = _ref155.stampWith, userId = _ref155.userId;
6440
+ _context131.n = 1;
6267
6441
  return getSession();
6268
6442
  case 1:
6269
- s = _context125.v;
6443
+ s = _context131.v;
6270
6444
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
6271
6445
  if (organizationId) {
6272
- _context125.n = 2;
6446
+ _context131.n = 2;
6273
6447
  break;
6274
6448
  }
6275
6449
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
6276
6450
  case 2:
6277
- _context125.p = 2;
6278
- return _context125.a(2, new Promise(function (resolve, reject) {
6451
+ _context131.p = 2;
6452
+ return _context131.a(2, new Promise(function (resolve, reject) {
6279
6453
  pushPage({
6280
6454
  key: "Remove Email",
6281
6455
  content: jsx(RemoveEmail, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -6302,44 +6476,44 @@ var ClientProvider = function ClientProvider(_ref) {
6302
6476
  });
6303
6477
  }));
6304
6478
  case 3:
6305
- _context125.p = 3;
6306
- _t26 = _context125.v;
6307
- if (!(_t26 instanceof TurnkeyError)) {
6308
- _context125.n = 4;
6479
+ _context131.p = 3;
6480
+ _t31 = _context131.v;
6481
+ if (!(_t31 instanceof TurnkeyError)) {
6482
+ _context131.n = 4;
6309
6483
  break;
6310
6484
  }
6311
- throw _t26;
6485
+ throw _t31;
6312
6486
  case 4:
6313
- throw new TurnkeyError("Failed to remove user email.", TurnkeyErrorCodes.UPDATE_USER_EMAIL_ERROR, _t26);
6487
+ throw new TurnkeyError("Failed to remove user email.", TurnkeyErrorCodes.UPDATE_USER_EMAIL_ERROR, _t31);
6314
6488
  case 5:
6315
- return _context125.a(2);
6489
+ return _context131.a(2);
6316
6490
  }
6317
- }, _callee125, null, [[2, 3]]);
6491
+ }, _callee131, null, [[2, 3]]);
6318
6492
  }));
6319
- return function (_x110) {
6320
- return _ref146.apply(this, arguments);
6493
+ return function (_x111) {
6494
+ return _ref154.apply(this, arguments);
6321
6495
  };
6322
6496
  }(), [getSession, pushPage]);
6323
6497
  var handleRemoveUserPhoneNumber = useCallback(/*#__PURE__*/function () {
6324
- var _ref148 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee126(params) {
6325
- var _ref149, _ref149$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t27;
6326
- return _regenerator().w(function (_context126) {
6327
- while (1) switch (_context126.p = _context126.n) {
6498
+ var _ref156 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee132(params) {
6499
+ var _ref157, _ref157$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t32;
6500
+ return _regenerator().w(function (_context132) {
6501
+ while (1) switch (_context132.p = _context132.n) {
6328
6502
  case 0:
6329
- _ref149 = params || {}, _ref149$successPageDu = _ref149.successPageDuration, successPageDuration = _ref149$successPageDu === void 0 ? 2000 : _ref149$successPageDu, stampWith = _ref149.stampWith, userId = _ref149.userId;
6330
- _context126.n = 1;
6503
+ _ref157 = params || {}, _ref157$successPageDu = _ref157.successPageDuration, successPageDuration = _ref157$successPageDu === void 0 ? 2000 : _ref157$successPageDu, stampWith = _ref157.stampWith, userId = _ref157.userId;
6504
+ _context132.n = 1;
6331
6505
  return getSession();
6332
6506
  case 1:
6333
- s = _context126.v;
6507
+ s = _context132.v;
6334
6508
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
6335
6509
  if (organizationId) {
6336
- _context126.n = 2;
6510
+ _context132.n = 2;
6337
6511
  break;
6338
6512
  }
6339
6513
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
6340
6514
  case 2:
6341
- _context126.p = 2;
6342
- return _context126.a(2, new Promise(function (resolve, reject) {
6515
+ _context132.p = 2;
6516
+ return _context132.a(2, new Promise(function (resolve, reject) {
6343
6517
  pushPage({
6344
6518
  key: "Remove Phone Number",
6345
6519
  content: jsx(RemovePhoneNumber, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -6366,37 +6540,37 @@ var ClientProvider = function ClientProvider(_ref) {
6366
6540
  });
6367
6541
  }));
6368
6542
  case 3:
6369
- _context126.p = 3;
6370
- _t27 = _context126.v;
6371
- if (!(_t27 instanceof TurnkeyError)) {
6372
- _context126.n = 4;
6543
+ _context132.p = 3;
6544
+ _t32 = _context132.v;
6545
+ if (!(_t32 instanceof TurnkeyError)) {
6546
+ _context132.n = 4;
6373
6547
  break;
6374
6548
  }
6375
- throw _t27;
6549
+ throw _t32;
6376
6550
  case 4:
6377
- throw new TurnkeyError("Failed to remove user phone number.", TurnkeyErrorCodes.UPDATE_USER_PHONE_NUMBER_ERROR, _t27);
6551
+ throw new TurnkeyError("Failed to remove user phone number.", TurnkeyErrorCodes.UPDATE_USER_PHONE_NUMBER_ERROR, _t32);
6378
6552
  case 5:
6379
- return _context126.a(2);
6553
+ return _context132.a(2);
6380
6554
  }
6381
- }, _callee126, null, [[2, 3]]);
6555
+ }, _callee132, null, [[2, 3]]);
6382
6556
  }));
6383
- return function (_x111) {
6384
- return _ref148.apply(this, arguments);
6557
+ return function (_x112) {
6558
+ return _ref156.apply(this, arguments);
6385
6559
  };
6386
6560
  }(), [getSession, pushPage]);
6387
6561
  var handleSendTransaction = useCallback(/*#__PURE__*/function () {
6388
- var _ref150 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee129(params) {
6562
+ var _ref158 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee135(params) {
6389
6563
  var session, organizationId, transaction, icon, stampWith, _params$successPageDu5, successPageDuration, caip2, isSolanaTransaction;
6390
- return _regenerator().w(function (_context129) {
6391
- while (1) switch (_context129.n) {
6564
+ return _regenerator().w(function (_context135) {
6565
+ while (1) switch (_context135.n) {
6392
6566
  case 0:
6393
- _context129.n = 1;
6567
+ _context135.n = 1;
6394
6568
  return getSession();
6395
6569
  case 1:
6396
- session = _context129.v;
6570
+ session = _context135.v;
6397
6571
  organizationId = params.organizationId || (session === null || session === void 0 ? void 0 : session.organizationId);
6398
6572
  if (organizationId) {
6399
- _context129.n = 2;
6573
+ _context135.n = 2;
6400
6574
  break;
6401
6575
  }
6402
6576
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -6404,34 +6578,34 @@ var ClientProvider = function ClientProvider(_ref) {
6404
6578
  transaction = params.transaction, icon = params.icon, stampWith = params.stampWith, _params$successPageDu5 = params.successPageDuration, successPageDuration = _params$successPageDu5 === void 0 ? 2000 : _params$successPageDu5;
6405
6579
  caip2 = transaction.caip2;
6406
6580
  isSolanaTransaction = caip2.startsWith("solana:");
6407
- return _context129.a(2, new Promise(function (resolve, reject) {
6581
+ return _context135.a(2, new Promise(function (resolve, reject) {
6408
6582
  var action = /*#__PURE__*/function () {
6409
- var _ref151 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee128() {
6410
- var _ref154, _txDetails$eth$txHash, _txDetails$eth, _txDetails$solana;
6411
- var sendTransactionStatusId, pollResult, txDetails, txHash, _t28;
6412
- return _regenerator().w(function (_context128) {
6413
- while (1) switch (_context128.n) {
6583
+ var _ref159 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee134() {
6584
+ var _ref162, _txDetails$eth$txHash, _txDetails$eth, _txDetails$solana;
6585
+ var sendTransactionStatusId, pollResult, txDetails, txHash, _t33;
6586
+ return _regenerator().w(function (_context134) {
6587
+ while (1) switch (_context134.n) {
6414
6588
  case 0:
6415
6589
  if (!isSolanaTransaction) {
6416
- _context128.n = 2;
6590
+ _context134.n = 2;
6417
6591
  break;
6418
6592
  }
6419
- _context128.n = 1;
6593
+ _context134.n = 1;
6420
6594
  return solSendTransaction({
6421
6595
  organizationId: organizationId,
6422
6596
  transaction: transaction,
6423
6597
  stampWith: stampWith
6424
6598
  });
6425
6599
  case 1:
6426
- _t28 = _context128.v;
6427
- _context128.n = 4;
6600
+ _t33 = _context134.v;
6601
+ _context134.n = 4;
6428
6602
  break;
6429
6603
  case 2:
6430
- _context128.n = 3;
6431
- return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee127() {
6604
+ _context134.n = 3;
6605
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee133() {
6432
6606
  var ethTx, cleanData, from, sponsor, nonce, gasLimit, maxFeePerGas, maxPriorityFeePerGas, commonFields, tx, cleanedData;
6433
- return _regenerator().w(function (_context127) {
6434
- while (1) switch (_context127.n) {
6607
+ return _regenerator().w(function (_context133) {
6608
+ while (1) switch (_context133.n) {
6435
6609
  case 0:
6436
6610
  ethTx = transaction; // Drop empty/no-op calldata ("0x" or "") so it isn't sent.
6437
6611
  cleanData = function cleanData(data) {
@@ -6454,10 +6628,10 @@ var ClientProvider = function ClientProvider(_ref) {
6454
6628
  // TODO (breaking change): eventually, we wont generate the v1 activity at all, remove this check and update the intent.
6455
6629
  if ("calls" in ethTx) {
6456
6630
  tx = _objectSpread2(_objectSpread2({}, commonFields), {}, {
6457
- calls: ethTx.calls.map(function (_ref153) {
6458
- var to = _ref153.to,
6459
- value = _ref153.value,
6460
- data = _ref153.data;
6631
+ calls: ethTx.calls.map(function (_ref161) {
6632
+ var to = _ref161.to,
6633
+ value = _ref161.value,
6634
+ data = _ref161.data;
6461
6635
  var cleanedData = cleanData(data);
6462
6636
  return _objectSpread2(_objectSpread2({
6463
6637
  to: to
@@ -6478,41 +6652,41 @@ var ClientProvider = function ClientProvider(_ref) {
6478
6652
  data: cleanedData
6479
6653
  } : {});
6480
6654
  }
6481
- return _context127.a(2, ethSendTransaction({
6655
+ return _context133.a(2, ethSendTransaction({
6482
6656
  organizationId: organizationId,
6483
6657
  transaction: tx,
6484
6658
  stampWith: stampWith
6485
6659
  }));
6486
6660
  }
6487
- }, _callee127);
6661
+ }, _callee133);
6488
6662
  }))();
6489
6663
  case 3:
6490
- _t28 = _context128.v;
6664
+ _t33 = _context134.v;
6491
6665
  case 4:
6492
- sendTransactionStatusId = _t28;
6666
+ sendTransactionStatusId = _t33;
6493
6667
  if (sendTransactionStatusId) {
6494
- _context128.n = 5;
6668
+ _context134.n = 5;
6495
6669
  break;
6496
6670
  }
6497
6671
  throw new TurnkeyError("Missing sendTransactionStatusId", TurnkeyErrorCodes.BAD_RESPONSE);
6498
6672
  case 5:
6499
- _context128.n = 6;
6673
+ _context134.n = 6;
6500
6674
  return pollTransactionStatus({
6501
6675
  organizationId: organizationId,
6502
6676
  sendTransactionStatusId: sendTransactionStatusId
6503
6677
  });
6504
6678
  case 6:
6505
- pollResult = _context128.v;
6679
+ pollResult = _context134.v;
6506
6680
  txDetails = pollResult;
6507
- txHash = (_ref154 = (_txDetails$eth$txHash = (_txDetails$eth = txDetails.eth) === null || _txDetails$eth === void 0 ? void 0 : _txDetails$eth.txHash) !== null && _txDetails$eth$txHash !== void 0 ? _txDetails$eth$txHash : (_txDetails$solana = txDetails.solana) === null || _txDetails$solana === void 0 ? void 0 : _txDetails$solana.signature) !== null && _ref154 !== void 0 ? _ref154 : txDetails.txHash;
6508
- return _context128.a(2, txHash ? {
6681
+ txHash = (_ref162 = (_txDetails$eth$txHash = (_txDetails$eth = txDetails.eth) === null || _txDetails$eth === void 0 ? void 0 : _txDetails$eth.txHash) !== null && _txDetails$eth$txHash !== void 0 ? _txDetails$eth$txHash : (_txDetails$solana = txDetails.solana) === null || _txDetails$solana === void 0 ? void 0 : _txDetails$solana.signature) !== null && _ref162 !== void 0 ? _ref162 : txDetails.txHash;
6682
+ return _context134.a(2, txHash ? {
6509
6683
  txHash: txHash
6510
6684
  } : {});
6511
6685
  }
6512
- }, _callee128);
6686
+ }, _callee134);
6513
6687
  }));
6514
6688
  return function action() {
6515
- return _ref151.apply(this, arguments);
6689
+ return _ref159.apply(this, arguments);
6516
6690
  };
6517
6691
  }();
6518
6692
  pushPage({
@@ -6537,69 +6711,69 @@ var ClientProvider = function ClientProvider(_ref) {
6537
6711
  });
6538
6712
  }));
6539
6713
  }
6540
- }, _callee129);
6714
+ }, _callee135);
6541
6715
  }));
6542
- return function (_x112) {
6543
- return _ref150.apply(this, arguments);
6716
+ return function (_x113) {
6717
+ return _ref158.apply(this, arguments);
6544
6718
  };
6545
6719
  }(), [ethSendTransaction, getSession, pollTransactionStatus, pushPage, solSendTransaction]);
6546
6720
  var handleSendErc20Transfer = useCallback(/*#__PURE__*/function () {
6547
- var _ref155 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee131(params) {
6721
+ var _ref163 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee137(params) {
6548
6722
  var session, organizationId, transfer, icon, stampWith, _params$successPageDu6, successPageDuration, caip2;
6549
- return _regenerator().w(function (_context131) {
6550
- while (1) switch (_context131.n) {
6723
+ return _regenerator().w(function (_context137) {
6724
+ while (1) switch (_context137.n) {
6551
6725
  case 0:
6552
- _context131.n = 1;
6726
+ _context137.n = 1;
6553
6727
  return getSession();
6554
6728
  case 1:
6555
- session = _context131.v;
6729
+ session = _context137.v;
6556
6730
  organizationId = params.organizationId || (session === null || session === void 0 ? void 0 : session.organizationId);
6557
6731
  if (organizationId) {
6558
- _context131.n = 2;
6732
+ _context137.n = 2;
6559
6733
  break;
6560
6734
  }
6561
6735
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
6562
6736
  case 2:
6563
6737
  transfer = params.transfer, icon = params.icon, stampWith = params.stampWith, _params$successPageDu6 = params.successPageDuration, successPageDuration = _params$successPageDu6 === void 0 ? 2000 : _params$successPageDu6;
6564
6738
  caip2 = transfer.caip2;
6565
- return _context131.a(2, new Promise(function (resolve, reject) {
6739
+ return _context137.a(2, new Promise(function (resolve, reject) {
6566
6740
  var action = /*#__PURE__*/function () {
6567
- var _ref156 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee130() {
6741
+ var _ref164 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee136() {
6568
6742
  var _pollResult$eth$txHas, _pollResult$eth;
6569
6743
  var sendTransactionStatusId, pollResult, txHash;
6570
- return _regenerator().w(function (_context130) {
6571
- while (1) switch (_context130.n) {
6744
+ return _regenerator().w(function (_context136) {
6745
+ while (1) switch (_context136.n) {
6572
6746
  case 0:
6573
- _context130.n = 1;
6747
+ _context136.n = 1;
6574
6748
  return ethSendErc20Transfer({
6575
6749
  organizationId: organizationId,
6576
6750
  transfer: transfer,
6577
6751
  stampWith: stampWith
6578
6752
  });
6579
6753
  case 1:
6580
- sendTransactionStatusId = _context130.v;
6754
+ sendTransactionStatusId = _context136.v;
6581
6755
  if (sendTransactionStatusId) {
6582
- _context130.n = 2;
6756
+ _context136.n = 2;
6583
6757
  break;
6584
6758
  }
6585
6759
  throw new TurnkeyError("Missing sendTransactionStatusId", TurnkeyErrorCodes.BAD_RESPONSE);
6586
6760
  case 2:
6587
- _context130.n = 3;
6761
+ _context136.n = 3;
6588
6762
  return pollTransactionStatus({
6589
6763
  organizationId: organizationId,
6590
6764
  sendTransactionStatusId: sendTransactionStatusId
6591
6765
  });
6592
6766
  case 3:
6593
- pollResult = _context130.v;
6767
+ pollResult = _context136.v;
6594
6768
  txHash = (_pollResult$eth$txHas = pollResult === null || pollResult === void 0 ? void 0 : (_pollResult$eth = pollResult.eth) === null || _pollResult$eth === void 0 ? void 0 : _pollResult$eth.txHash) !== null && _pollResult$eth$txHas !== void 0 ? _pollResult$eth$txHas : pollResult === null || pollResult === void 0 ? void 0 : pollResult.txHash;
6595
- return _context130.a(2, txHash ? {
6769
+ return _context136.a(2, txHash ? {
6596
6770
  txHash: txHash
6597
6771
  } : {});
6598
6772
  }
6599
- }, _callee130);
6773
+ }, _callee136);
6600
6774
  }));
6601
6775
  return function action() {
6602
- return _ref156.apply(this, arguments);
6776
+ return _ref164.apply(this, arguments);
6603
6777
  };
6604
6778
  }();
6605
6779
  pushPage({
@@ -6624,55 +6798,55 @@ var ClientProvider = function ClientProvider(_ref) {
6624
6798
  });
6625
6799
  }));
6626
6800
  }
6627
- }, _callee131);
6801
+ }, _callee137);
6628
6802
  }));
6629
- return function (_x113) {
6630
- return _ref155.apply(this, arguments);
6803
+ return function (_x114) {
6804
+ return _ref163.apply(this, arguments);
6631
6805
  };
6632
6806
  }(), [ethSendErc20Transfer, getSession, pollTransactionStatus, pushPage]);
6633
6807
  var handleOnRamp = useCallback(/*#__PURE__*/function () {
6634
- var _ref157 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee134(params) {
6808
+ var _ref165 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee140(params) {
6635
6809
  var _walletAccount$addres;
6636
- var walletAccount, fiatCurrencyAmount, fiatCurrencyCode, paymentMethod, countrySubdivisionCode, urlForSignature, countryCode, _params$onrampProvide, onrampProvider, _params$sandboxMode, sandboxMode, _params$successPageDu7, successPageDuration, _params$openInNewTab, openInNewTab, s, organizationId, cryptoCurrencyCode, network, openNewTab, _t31;
6637
- return _regenerator().w(function (_context134) {
6638
- while (1) switch (_context134.n) {
6810
+ var walletAccount, fiatCurrencyAmount, fiatCurrencyCode, paymentMethod, countrySubdivisionCode, urlForSignature, countryCode, _params$onrampProvide, onrampProvider, _params$sandboxMode, sandboxMode, _params$successPageDu7, successPageDuration, _params$openInNewTab, openInNewTab, s, organizationId, cryptoCurrencyCode, network, openNewTab, _t36;
6811
+ return _regenerator().w(function (_context140) {
6812
+ while (1) switch (_context140.n) {
6639
6813
  case 0:
6640
6814
  walletAccount = params.walletAccount, fiatCurrencyAmount = params.fiatCurrencyAmount, fiatCurrencyCode = params.fiatCurrencyCode, paymentMethod = params.paymentMethod, countrySubdivisionCode = params.countrySubdivisionCode, urlForSignature = params.urlForSignature, countryCode = params.countryCode, _params$onrampProvide = params.onrampProvider, onrampProvider = _params$onrampProvide === void 0 ? "FIAT_ON_RAMP_PROVIDER_MOONPAY" : _params$onrampProvide, _params$sandboxMode = params.sandboxMode, sandboxMode = _params$sandboxMode === void 0 ? true : _params$sandboxMode, _params$successPageDu7 = params.successPageDuration, successPageDuration = _params$successPageDu7 === void 0 ? 2000 : _params$successPageDu7, _params$openInNewTab = params.openInNewTab, openInNewTab = _params$openInNewTab === void 0 ? false : _params$openInNewTab;
6641
- _context134.n = 1;
6815
+ _context140.n = 1;
6642
6816
  return getSession();
6643
6817
  case 1:
6644
- s = _context134.v;
6818
+ s = _context140.v;
6645
6819
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
6646
6820
  if (organizationId) {
6647
- _context134.n = 2;
6821
+ _context140.n = 2;
6648
6822
  break;
6649
6823
  }
6650
6824
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
6651
6825
  case 2:
6652
- _t31 = true;
6653
- _context134.n = _t31 === (walletAccount.addressFormat === "ADDRESS_FORMAT_ETHEREUM") ? 3 : _t31 === ((_walletAccount$addres = walletAccount.addressFormat) === null || _walletAccount$addres === void 0 ? void 0 : _walletAccount$addres.includes("ADDRESS_FORMAT_BITCOIN")) ? 4 : _t31 === (walletAccount.addressFormat === "ADDRESS_FORMAT_SOLANA") ? 5 : 6;
6826
+ _t36 = true;
6827
+ _context140.n = _t36 === (walletAccount.addressFormat === "ADDRESS_FORMAT_ETHEREUM") ? 3 : _t36 === ((_walletAccount$addres = walletAccount.addressFormat) === null || _walletAccount$addres === void 0 ? void 0 : _walletAccount$addres.includes("ADDRESS_FORMAT_BITCOIN")) ? 4 : _t36 === (walletAccount.addressFormat === "ADDRESS_FORMAT_SOLANA") ? 5 : 6;
6654
6828
  break;
6655
6829
  case 3:
6656
6830
  cryptoCurrencyCode = FiatOnRampCryptoCurrency.ETHEREUM;
6657
6831
  network = FiatOnRampBlockchainNetwork.ETHEREUM;
6658
- return _context134.a(3, 7);
6832
+ return _context140.a(3, 7);
6659
6833
  case 4:
6660
6834
  cryptoCurrencyCode = FiatOnRampCryptoCurrency.BITCOIN;
6661
6835
  network = FiatOnRampBlockchainNetwork.BITCOIN;
6662
- return _context134.a(3, 7);
6836
+ return _context140.a(3, 7);
6663
6837
  case 5:
6664
6838
  cryptoCurrencyCode = FiatOnRampCryptoCurrency.SOLANA;
6665
6839
  network = FiatOnRampBlockchainNetwork.SOLANA;
6666
- return _context134.a(3, 7);
6840
+ return _context140.a(3, 7);
6667
6841
  case 6:
6668
6842
  cryptoCurrencyCode = FiatOnRampCryptoCurrency.ETHEREUM;
6669
6843
  network = FiatOnRampBlockchainNetwork.ETHEREUM;
6670
- return _context134.a(3, 7);
6844
+ return _context140.a(3, 7);
6671
6845
  case 7:
6672
6846
  openNewTab = openInNewTab || isMobile;
6673
6847
  cryptoCurrencyCode = params.cryptoCurrencyCode || cryptoCurrencyCode;
6674
6848
  network = params.network || network;
6675
- return _context134.a(2, new Promise(function (resolve, reject) {
6849
+ return _context140.a(2, new Promise(function (resolve, reject) {
6676
6850
  var OnRampContainer = function OnRampContainer() {
6677
6851
  var _useState15 = useState(false),
6678
6852
  _useState16 = _slicedToArray(_useState15, 2),
@@ -6691,25 +6865,25 @@ var ClientProvider = function ClientProvider(_ref) {
6691
6865
  };
6692
6866
  }, []);
6693
6867
  var action = /*#__PURE__*/function () {
6694
- var _ref158 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee133() {
6695
- var _client$httpClient, onRampWindow, result, popupWidth, popupHeight, left, top, onRampTransactionId, _t30;
6696
- return _regenerator().w(function (_context133) {
6697
- while (1) switch (_context133.p = _context133.n) {
6868
+ var _ref166 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee139() {
6869
+ var _client$httpClient, onRampWindow, result, popupWidth, popupHeight, left, top, onRampTransactionId, _t35;
6870
+ return _regenerator().w(function (_context139) {
6871
+ while (1) switch (_context139.p = _context139.n) {
6698
6872
  case 0:
6699
- _context133.p = 0;
6873
+ _context139.p = 0;
6700
6874
  onRampWindow = null;
6701
6875
  if (!openNewTab) {
6702
- _context133.n = 1;
6876
+ _context139.n = 1;
6703
6877
  break;
6704
6878
  }
6705
6879
  onRampWindow = window.open("", "_blank");
6706
6880
  if (onRampWindow) {
6707
- _context133.n = 1;
6881
+ _context139.n = 1;
6708
6882
  break;
6709
6883
  }
6710
6884
  throw new Error("Failed to open On Ramp tab.");
6711
6885
  case 1:
6712
- _context133.n = 2;
6886
+ _context139.n = 2;
6713
6887
  return client === null || client === void 0 ? void 0 : (_client$httpClient = client.httpClient) === null || _client$httpClient === void 0 ? void 0 : _client$httpClient.initFiatOnRamp(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
6714
6888
  onrampProvider: onrampProvider,
6715
6889
  walletAddress: walletAccount.address,
@@ -6733,19 +6907,19 @@ var ClientProvider = function ClientProvider(_ref) {
6733
6907
  urlForSignature: urlForSignature
6734
6908
  } : {}));
6735
6909
  case 2:
6736
- result = _context133.v;
6910
+ result = _context139.v;
6737
6911
  if (result !== null && result !== void 0 && result.onRampUrl) {
6738
- _context133.n = 3;
6912
+ _context139.n = 3;
6739
6913
  break;
6740
6914
  }
6741
6915
  throw new Error("Missing onRampUrl");
6742
6916
  case 3:
6743
6917
  if (!(openNewTab && onRampWindow)) {
6744
- _context133.n = 4;
6918
+ _context139.n = 4;
6745
6919
  break;
6746
6920
  }
6747
6921
  onRampWindow.location.href = result.onRampUrl.toString();
6748
- _context133.n = 5;
6922
+ _context139.n = 5;
6749
6923
  break;
6750
6924
  case 4:
6751
6925
  popupWidth = 500;
@@ -6754,54 +6928,54 @@ var ClientProvider = function ClientProvider(_ref) {
6754
6928
  top = window.screenY + (window.innerHeight - popupHeight) / 2;
6755
6929
  onRampWindow = window.open(result.onRampUrl.toString(), "_blank", "width=".concat(popupWidth, ",height=").concat(popupHeight, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
6756
6930
  if (onRampWindow) {
6757
- _context133.n = 5;
6931
+ _context139.n = 5;
6758
6932
  break;
6759
6933
  }
6760
6934
  throw new Error("Failed to open On Ramp window.");
6761
6935
  case 5:
6762
6936
  onRampTransactionId = result.onRampTransactionId;
6763
6937
  if (onRampTransactionId) {
6764
- _context133.n = 6;
6938
+ _context139.n = 6;
6765
6939
  break;
6766
6940
  }
6767
6941
  throw new Error("No onRampTransactionId returned");
6768
6942
  case 6:
6769
- return _context133.a(2, new Promise(function (resolveAction, rejectAction) {
6770
- pollingRef.current = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee132() {
6771
- var _onRampWindow, _client$httpClient2, currentUrl, _onRampWindow2, _onRampWindow3, resp, status, _onRampWindow4, _t29;
6772
- return _regenerator().w(function (_context132) {
6773
- while (1) switch (_context132.p = _context132.n) {
6943
+ return _context139.a(2, new Promise(function (resolveAction, rejectAction) {
6944
+ pollingRef.current = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee138() {
6945
+ var _onRampWindow, _client$httpClient2, currentUrl, _onRampWindow2, _onRampWindow3, resp, status, _onRampWindow4, _t34;
6946
+ return _regenerator().w(function (_context138) {
6947
+ while (1) switch (_context138.p = _context138.n) {
6774
6948
  case 0:
6775
- _context132.p = 0;
6949
+ _context138.p = 0;
6776
6950
  if (!(onrampProvider === "FIAT_ON_RAMP_PROVIDER_COINBASE" && (_onRampWindow = onRampWindow) !== null && _onRampWindow !== void 0 && _onRampWindow.closed)) {
6777
- _context132.n = 1;
6951
+ _context138.n = 1;
6778
6952
  break;
6779
6953
  }
6780
6954
  cleanup();
6781
6955
  rejectAction(new Error("On-ramp popup closed by user"));
6782
- return _context132.a(2);
6956
+ return _context138.a(2);
6783
6957
  case 1:
6784
6958
  currentUrl = "";
6785
6959
  try {
6786
6960
  currentUrl = ((_onRampWindow2 = onRampWindow) === null || _onRampWindow2 === void 0 ? void 0 : _onRampWindow2.location.href) || "";
6787
6961
  } catch (_unused6) {}
6788
6962
  if (!(currentUrl && currentUrl.startsWith(window.location.origin))) {
6789
- _context132.n = 2;
6963
+ _context138.n = 2;
6790
6964
  break;
6791
6965
  }
6792
6966
  cleanup();
6793
6967
  (_onRampWindow3 = onRampWindow) === null || _onRampWindow3 === void 0 ? void 0 : _onRampWindow3.close();
6794
6968
  setCompleted(true);
6795
6969
  resolveAction();
6796
- return _context132.a(2);
6970
+ return _context138.a(2);
6797
6971
  case 2:
6798
- _context132.n = 3;
6972
+ _context138.n = 3;
6799
6973
  return client === null || client === void 0 ? void 0 : (_client$httpClient2 = client.httpClient) === null || _client$httpClient2 === void 0 ? void 0 : _client$httpClient2.getOnRampTransactionStatus({
6800
6974
  transactionId: onRampTransactionId,
6801
6975
  refresh: true
6802
6976
  });
6803
6977
  case 3:
6804
- resp = _context132.v;
6978
+ resp = _context138.v;
6805
6979
  status = resp === null || resp === void 0 ? void 0 : resp.transactionStatus;
6806
6980
  if (["COMPLETED", "FAILED", "CANCELLED"].includes(status !== null && status !== void 0 ? status : "")) {
6807
6981
  cleanup();
@@ -6811,30 +6985,30 @@ var ClientProvider = function ClientProvider(_ref) {
6811
6985
  setCompleted(true);
6812
6986
  resolveAction();
6813
6987
  }
6814
- _context132.n = 5;
6988
+ _context138.n = 5;
6815
6989
  break;
6816
6990
  case 4:
6817
- _context132.p = 4;
6818
- _t29 = _context132.v;
6819
- console.warn("Polling error (ignored):", _t29);
6991
+ _context138.p = 4;
6992
+ _t34 = _context138.v;
6993
+ console.warn("Polling error (ignored):", _t34);
6820
6994
  case 5:
6821
- return _context132.a(2);
6995
+ return _context138.a(2);
6822
6996
  }
6823
- }, _callee132, null, [[0, 4]]);
6997
+ }, _callee138, null, [[0, 4]]);
6824
6998
  })), 3000);
6825
6999
  }));
6826
7000
  case 7:
6827
- _context133.p = 7;
6828
- _t30 = _context133.v;
7001
+ _context139.p = 7;
7002
+ _t35 = _context139.v;
6829
7003
  cleanup();
6830
- throw _t30;
7004
+ throw _t35;
6831
7005
  case 8:
6832
- return _context133.a(2);
7006
+ return _context139.a(2);
6833
7007
  }
6834
- }, _callee133, null, [[0, 7]]);
7008
+ }, _callee139, null, [[0, 7]]);
6835
7009
  }));
6836
7010
  return function action() {
6837
- return _ref158.apply(this, arguments);
7011
+ return _ref166.apply(this, arguments);
6838
7012
  };
6839
7013
  }();
6840
7014
  return jsx(OnRampPage, {
@@ -6867,32 +7041,32 @@ var ClientProvider = function ClientProvider(_ref) {
6867
7041
  });
6868
7042
  }));
6869
7043
  }
6870
- }, _callee134);
7044
+ }, _callee140);
6871
7045
  }));
6872
- return function (_x114) {
6873
- return _ref157.apply(this, arguments);
7046
+ return function (_x115) {
7047
+ return _ref165.apply(this, arguments);
6874
7048
  };
6875
7049
  }(), [getSession, client, pushPage]);
6876
7050
  var handleVerifyAppProofs = useCallback(/*#__PURE__*/function () {
6877
- var _ref160 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee135(params) {
6878
- var _ref161, appProofs, _ref161$successPageDu, successPageDuration, stampWith, s, organizationId, _t32;
6879
- return _regenerator().w(function (_context135) {
6880
- while (1) switch (_context135.p = _context135.n) {
7051
+ var _ref168 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee141(params) {
7052
+ var _ref169, appProofs, _ref169$successPageDu, successPageDuration, stampWith, s, organizationId, _t37;
7053
+ return _regenerator().w(function (_context141) {
7054
+ while (1) switch (_context141.p = _context141.n) {
6881
7055
  case 0:
6882
- _ref161 = params || {}, appProofs = _ref161.appProofs, _ref161$successPageDu = _ref161.successPageDuration, successPageDuration = _ref161$successPageDu === void 0 ? 3000 : _ref161$successPageDu, stampWith = _ref161.stampWith;
6883
- _context135.n = 1;
7056
+ _ref169 = params || {}, appProofs = _ref169.appProofs, _ref169$successPageDu = _ref169.successPageDuration, successPageDuration = _ref169$successPageDu === void 0 ? 3000 : _ref169$successPageDu, stampWith = _ref169.stampWith;
7057
+ _context141.n = 1;
6884
7058
  return getSession();
6885
7059
  case 1:
6886
- s = _context135.v;
7060
+ s = _context141.v;
6887
7061
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
6888
7062
  if (organizationId) {
6889
- _context135.n = 2;
7063
+ _context141.n = 2;
6890
7064
  break;
6891
7065
  }
6892
7066
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
6893
7067
  case 2:
6894
- _context135.p = 2;
6895
- return _context135.a(2, new Promise(function (resolve, reject) {
7068
+ _context141.p = 2;
7069
+ return _context141.a(2, new Promise(function (resolve, reject) {
6896
7070
  pushPage({
6897
7071
  key: "Verify app proofs",
6898
7072
  showTurnkeyBranding: false,
@@ -6918,34 +7092,34 @@ var ClientProvider = function ClientProvider(_ref) {
6918
7092
  });
6919
7093
  }));
6920
7094
  case 3:
6921
- _context135.p = 3;
6922
- _t32 = _context135.v;
6923
- if (!(_t32 instanceof TurnkeyError)) {
6924
- _context135.n = 4;
7095
+ _context141.p = 3;
7096
+ _t37 = _context141.v;
7097
+ if (!(_t37 instanceof TurnkeyError)) {
7098
+ _context141.n = 4;
6925
7099
  break;
6926
7100
  }
6927
- throw _t32;
7101
+ throw _t37;
6928
7102
  case 4:
6929
- throw new TurnkeyError("Failed to verify app proofs.", TurnkeyErrorCodes.VERIFY_APP_PROOFS_ERROR, _t32);
7103
+ throw new TurnkeyError("Failed to verify app proofs.", TurnkeyErrorCodes.VERIFY_APP_PROOFS_ERROR, _t37);
6930
7104
  case 5:
6931
- return _context135.a(2);
7105
+ return _context141.a(2);
6932
7106
  }
6933
- }, _callee135, null, [[2, 3]]);
7107
+ }, _callee141, null, [[2, 3]]);
6934
7108
  }));
6935
- return function (_x115) {
6936
- return _ref160.apply(this, arguments);
7109
+ return function (_x116) {
7110
+ return _ref168.apply(this, arguments);
6937
7111
  };
6938
7112
  }(), [getSession, pushPage]);
6939
7113
  useEffect(function () {
6940
7114
  if (proxyAuthConfigRef.current) return;
6941
7115
  // Fetch proxy auth config and client params once. Use both to build the master config.
6942
7116
  var fetchProxyAuthConfig = /*#__PURE__*/function () {
6943
- var _ref162 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee136() {
7117
+ var _ref170 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee142() {
6944
7118
  var proxyAuthConfig, clientParams, promises;
6945
- return _regenerator().w(function (_context136) {
6946
- while (1) switch (_context136.p = _context136.n) {
7119
+ return _regenerator().w(function (_context142) {
7120
+ while (1) switch (_context142.p = _context142.n) {
6947
7121
  case 0:
6948
- _context136.p = 0;
7122
+ _context142.p = 0;
6949
7123
  promises = [];
6950
7124
  if (shouldFetchWalletKitConfig) {
6951
7125
  promises.push(getAuthProxyConfig(config.authProxyConfigId, config.authProxyUrl).then(function (result) {
@@ -6957,7 +7131,7 @@ var ClientProvider = function ClientProvider(_ref) {
6957
7131
  clientParams = result;
6958
7132
  }));
6959
7133
  }
6960
- _context136.n = 1;
7134
+ _context142.n = 1;
6961
7135
  return Promise.all(promises);
6962
7136
  case 1:
6963
7137
  if (proxyAuthConfig) {
@@ -6967,19 +7141,19 @@ var ClientProvider = function ClientProvider(_ref) {
6967
7141
  clientParamsRef.current = clientParams;
6968
7142
  }
6969
7143
  setMasterConfig(buildConfig(proxyAuthConfig, clientParams));
6970
- _context136.n = 3;
7144
+ _context142.n = 3;
6971
7145
  break;
6972
7146
  case 2:
6973
- _context136.p = 2;
6974
- _context136.v;
7147
+ _context142.p = 2;
7148
+ _context142.v;
6975
7149
  setClientState(ClientState.Error);
6976
7150
  case 3:
6977
- return _context136.a(2);
7151
+ return _context142.a(2);
6978
7152
  }
6979
- }, _callee136, null, [[0, 2]]);
7153
+ }, _callee142, null, [[0, 2]]);
6980
7154
  }));
6981
7155
  return function fetchProxyAuthConfig() {
6982
- return _ref162.apply(this, arguments);
7156
+ return _ref170.apply(this, arguments);
6983
7157
  };
6984
7158
  }();
6985
7159
  fetchProxyAuthConfig();
@@ -7012,34 +7186,34 @@ var ClientProvider = function ClientProvider(_ref) {
7012
7186
  var debouncedFetchWalletProviders = useDebouncedCallback(fetchWalletProviders, 100);
7013
7187
  useEffect(function () {
7014
7188
  var handleUpdateState = /*#__PURE__*/function () {
7015
- var _ref163 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee137() {
7189
+ var _ref171 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee143() {
7016
7190
  var currentSession;
7017
- return _regenerator().w(function (_context137) {
7018
- while (1) switch (_context137.n) {
7191
+ return _regenerator().w(function (_context143) {
7192
+ while (1) switch (_context143.n) {
7019
7193
  case 0:
7020
- _context137.n = 1;
7194
+ _context143.n = 1;
7021
7195
  return getSession();
7022
7196
  case 1:
7023
- currentSession = _context137.v;
7197
+ currentSession = _context143.v;
7024
7198
  if (!currentSession) {
7025
- _context137.n = 3;
7199
+ _context143.n = 3;
7026
7200
  break;
7027
7201
  }
7028
- _context137.n = 2;
7202
+ _context143.n = 2;
7029
7203
  return debouncedRefreshWallets();
7030
7204
  case 2:
7031
- _context137.n = 4;
7205
+ _context143.n = 4;
7032
7206
  break;
7033
7207
  case 3:
7034
- _context137.n = 4;
7208
+ _context143.n = 4;
7035
7209
  return debouncedFetchWalletProviders();
7036
7210
  case 4:
7037
- return _context137.a(2);
7211
+ return _context143.a(2);
7038
7212
  }
7039
- }, _callee137);
7213
+ }, _callee143);
7040
7214
  }));
7041
7215
  return function handleUpdateState() {
7042
- return _ref163.apply(this, arguments);
7216
+ return _ref171.apply(this, arguments);
7043
7217
  };
7044
7218
  }();
7045
7219
  var cleanup = function cleanup() {};
@@ -7062,8 +7236,8 @@ var ClientProvider = function ClientProvider(_ref) {
7062
7236
  }
7063
7237
  }, [session]);
7064
7238
  useEffect(function () {
7065
- // This will handle any redirect based oAuth. It then initializes the session. This is the last step before client is considered "ready"
7066
7239
  if (!client || !masterConfig) return;
7240
+ // This will handle any redirect based oAuth. It then initializes the session. This is the last step before client is considered "ready"
7067
7241
  completeRedirectOauth()["finally"](function () {
7068
7242
  var _masterConfig$walletC6, _masterConfig$walletC7, _masterConfig$walletC8, _masterConfig$walletC9;
7069
7243
  clearSessionTimeouts();
@@ -7077,6 +7251,26 @@ var ClientProvider = function ClientProvider(_ref) {
7077
7251
  setClientState(ClientState.Ready);
7078
7252
  });
7079
7253
  });
7254
+ // Only set the onMfaRequired handler if we have a mfaHandler set.
7255
+ var mfaHandler = mfaHandlerRef.current;
7256
+ if (mfaHandler) {
7257
+ client.httpClient.config.onMfaRequired = /*#__PURE__*/function () {
7258
+ var _ref172 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee144(ctx) {
7259
+ return _regenerator().w(function (_context144) {
7260
+ while (1) switch (_context144.n) {
7261
+ case 0:
7262
+ _context144.n = 1;
7263
+ return mfaHandler(ctx);
7264
+ case 1:
7265
+ return _context144.a(2);
7266
+ }
7267
+ }, _callee144);
7268
+ }));
7269
+ return function (_x117) {
7270
+ return _ref172.apply(this, arguments);
7271
+ };
7272
+ }();
7273
+ }
7080
7274
  return function () {
7081
7275
  clearSessionTimeouts();
7082
7276
  };
@@ -7095,6 +7289,7 @@ var ClientProvider = function ClientProvider(_ref) {
7095
7289
  createHttpClient: createHttpClient,
7096
7290
  overrideApiKeyStamper: overrideApiKeyStamper,
7097
7291
  overridePasskeyStamper: overridePasskeyStamper,
7292
+ overrideAttestedStamper: overrideAttestedStamper,
7098
7293
  createPasskey: createPasskey,
7099
7294
  logout: logout,
7100
7295
  loginWithPasskey: loginWithPasskey,
@@ -7190,6 +7385,7 @@ var ClientProvider = function ClientProvider(_ref) {
7190
7385
  handleOnRamp: handleOnRamp,
7191
7386
  handleSendTransaction: handleSendTransaction,
7192
7387
  handleSendErc20Transfer: handleSendErc20Transfer,
7388
+ setMfaHandler: setMfaHandler,
7193
7389
  getTurnstileToken: getTurnstileToken,
7194
7390
  setTurnstileToken: setTurnstileToken
7195
7391
  },