@turnkey/react-wallet-kit 1.0.0-beta.6 → 1.0.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 (70) hide show
  1. package/README.MD +5 -2
  2. package/dist/components/auth/Email.d.ts.map +1 -1
  3. package/dist/components/auth/Email.js +3 -0
  4. package/dist/components/auth/Email.js.map +1 -1
  5. package/dist/components/auth/Email.mjs +3 -0
  6. package/dist/components/auth/Email.mjs.map +1 -1
  7. package/dist/components/auth/OAuth.d.ts.map +1 -1
  8. package/dist/components/auth/OAuth.js +1 -0
  9. package/dist/components/auth/OAuth.js.map +1 -1
  10. package/dist/components/auth/OAuth.mjs +1 -0
  11. package/dist/components/auth/OAuth.mjs.map +1 -1
  12. package/dist/components/auth/Passkey.d.ts.map +1 -1
  13. package/dist/components/auth/Passkey.js +2 -0
  14. package/dist/components/auth/Passkey.js.map +1 -1
  15. package/dist/components/auth/Passkey.mjs +2 -0
  16. package/dist/components/auth/Passkey.mjs.map +1 -1
  17. package/dist/components/auth/Wallet.d.ts.map +1 -1
  18. package/dist/components/auth/Wallet.js +3 -2
  19. package/dist/components/auth/Wallet.js.map +1 -1
  20. package/dist/components/auth/Wallet.mjs +3 -2
  21. package/dist/components/auth/Wallet.mjs.map +1 -1
  22. package/dist/components/auth/index.js +2 -2
  23. package/dist/components/auth/index.js.map +1 -1
  24. package/dist/components/auth/index.mjs +2 -2
  25. package/dist/components/auth/index.mjs.map +1 -1
  26. package/dist/components/design/Buttons.d.ts +2 -0
  27. package/dist/components/design/Buttons.d.ts.map +1 -1
  28. package/dist/components/design/Buttons.js +8 -2
  29. package/dist/components/design/Buttons.js.map +1 -1
  30. package/dist/components/design/Buttons.mjs +9 -3
  31. package/dist/components/design/Buttons.mjs.map +1 -1
  32. package/dist/components/export/Export.d.ts.map +1 -1
  33. package/dist/components/export/Export.js +1 -0
  34. package/dist/components/export/Export.js.map +1 -1
  35. package/dist/components/export/Export.mjs +1 -0
  36. package/dist/components/export/Export.mjs.map +1 -1
  37. package/dist/components/export/ExportWarning.d.ts.map +1 -1
  38. package/dist/components/export/ExportWarning.js +1 -0
  39. package/dist/components/export/ExportWarning.js.map +1 -1
  40. package/dist/components/export/ExportWarning.mjs +1 -0
  41. package/dist/components/export/ExportWarning.mjs.map +1 -1
  42. package/dist/components/import/Import.d.ts.map +1 -1
  43. package/dist/components/import/Import.js +4 -1
  44. package/dist/components/import/Import.js.map +1 -1
  45. package/dist/components/import/Import.mjs +5 -2
  46. package/dist/components/import/Import.mjs.map +1 -1
  47. package/dist/components/sign/Message.d.ts.map +1 -1
  48. package/dist/components/sign/Message.js +1 -0
  49. package/dist/components/sign/Message.js.map +1 -1
  50. package/dist/components/sign/Message.mjs +1 -0
  51. package/dist/components/sign/Message.mjs.map +1 -1
  52. package/dist/components/user/RemovePasskey.d.ts.map +1 -1
  53. package/dist/components/user/RemovePasskey.js +1 -0
  54. package/dist/components/user/RemovePasskey.js.map +1 -1
  55. package/dist/components/user/RemovePasskey.mjs +1 -0
  56. package/dist/components/user/RemovePasskey.mjs.map +1 -1
  57. package/dist/providers/client/Provider.d.ts.map +1 -1
  58. package/dist/providers/client/Provider.js +79 -47
  59. package/dist/providers/client/Provider.js.map +1 -1
  60. package/dist/providers/client/Provider.mjs +979 -900
  61. package/dist/providers/client/Provider.mjs.map +1 -1
  62. package/dist/tests/timers-test.d.ts +2 -0
  63. package/dist/tests/timers-test.d.ts.map +1 -0
  64. package/dist/tests/utils-test.d.ts +2 -0
  65. package/dist/tests/utils-test.d.ts.map +1 -0
  66. package/dist/types/base.d.ts +3 -1
  67. package/dist/types/base.d.ts.map +1 -1
  68. package/dist/types/base.js.map +1 -1
  69. package/dist/types/base.mjs.map +1 -1
  70. package/package.json +6 -5
@@ -100,6 +100,7 @@ var ClientProvider = function ClientProvider(_ref) {
100
100
  allSessions = _useState14[0],
101
101
  setAllSessions = _useState14[1];
102
102
  var _useModal = useModal(),
103
+ isMobile = _useModal.isMobile,
103
104
  pushPage = _useModal.pushPage,
104
105
  closeModal = _useModal.closeModal;
105
106
  var completeRedirectOauth = /*#__PURE__*/function () {
@@ -238,6 +239,7 @@ var ClientProvider = function ClientProvider(_ref) {
238
239
  authCode: code,
239
240
  redirectUri: _redirectURI,
240
241
  codeVerifier: verifier,
242
+ clientId: _clientId,
241
243
  nonce: nonce
242
244
  });
243
245
  case 3:
@@ -323,6 +325,7 @@ var ClientProvider = function ClientProvider(_ref) {
323
325
  authCode: code,
324
326
  redirectUri: _redirectURI2,
325
327
  codeVerifier: _verifier,
328
+ clientId: _clientId2,
326
329
  nonce: _nonce
327
330
  });
328
331
  case 3:
@@ -483,7 +486,7 @@ var ClientProvider = function ClientProvider(_ref) {
483
486
  };
484
487
  }();
485
488
  var buildConfig = function buildConfig(proxyAuthConfig) {
486
- var _config$auth$methods$, _config$auth, _config$auth$methods, _config$auth$methods$2, _config$auth2, _config$auth2$methods, _config$auth$methods$3, _config$auth3, _config$auth3$methods, _config$auth$methods$4, _config$auth4, _config$auth4$methods, _config$auth$methods$5, _config$auth5, _config$auth5$methods, _config$auth$methods$6, _config$auth6, _config$auth6$methods, _config$auth$methods$7, _config$auth7, _config$auth7$methods, _config$auth$methods$8, _config$auth8, _config$auth8$methods, _config$auth$methods$9, _config$auth9, _config$auth9$methods, _config$auth$oauthOrd, _config$auth0, _config$auth$methodOr, _config$auth1, _config$auth10, _config$auth11, _config$auth11$oauthC, _config$auth$autoRefr, _config$auth12, _config$walletConfig, _ref3, _resolvedMethods$wall, _config$walletConfig2, _config$walletConfig3, _config$walletConfig$, _config$walletConfig4, _config$walletConfig5, _config$walletConfig6, _config$walletConfig7, _config$walletConfig8, _config$walletConfig$2, _config$walletConfig9, _config$walletConfig0, _config$walletConfig1, _config$walletConfig10, _config$walletConfig11, _config$walletConfig$3, _config$walletConfig12, _config$walletConfig13, _config$walletConfig14, _config$importIframeU, _config$exportIframeU;
489
+ var _config$auth$methods$, _config$auth, _config$auth$methods, _config$auth$methods$2, _config$auth2, _config$auth2$methods, _config$auth$methods$3, _config$auth3, _config$auth3$methods, _config$auth$methods$4, _config$auth4, _config$auth4$methods, _config$auth$methods$5, _config$auth5, _config$auth5$methods, _config$auth$methods$6, _config$auth6, _config$auth6$methods, _config$auth$methods$7, _config$auth7, _config$auth7$methods, _config$auth$methods$8, _config$auth8, _config$auth8$methods, _config$auth$methods$9, _config$auth9, _config$auth9$methods, _config$auth$oauthCon, _config$auth0, _config$auth0$oauthCo, _proxyAuthConfig$oaut, _config$auth$oauthCon2, _config$auth1, _config$auth1$oauthCo, _proxyAuthConfig$oaut2, _config$auth$oauthCon3, _config$auth10, _config$auth10$oauthC, _proxyAuthConfig$oaut3, _config$auth$oauthCon4, _config$auth11, _config$auth11$oauthC, _proxyAuthConfig$oaut4, _config$auth$oauthCon5, _config$auth12, _config$auth12$oauthC, _proxyAuthConfig$oaut5, _config$auth$oauthCon6, _config$auth13, _config$auth13$oauthC, _config$auth$oauthOrd, _config$auth14, _config$auth$methodOr, _config$auth15, _config$auth16, _config$auth17, _config$auth17$oauthC, _config$auth$autoRefr, _config$auth18, _config$autoRefreshMa, _config$walletConfig, _ref3, _resolvedMethods$wall, _config$walletConfig2, _config$walletConfig3, _config$walletConfig$, _config$walletConfig4, _config$walletConfig5, _config$walletConfig6, _config$walletConfig7, _config$walletConfig8, _config$walletConfig$2, _config$walletConfig9, _config$walletConfig0, _config$walletConfig1, _config$walletConfig10, _config$walletConfig11, _config$walletConfig$3, _config$walletConfig12, _config$walletConfig13, _config$walletConfig14, _config$importIframeU, _config$exportIframeU;
487
490
  // Juggle the local overrides with the values set in the dashboard (proxyAuthConfig).
488
491
  var resolvedMethods = {
489
492
  emailOtpAuthEnabled: (_config$auth$methods$ = (_config$auth = config.auth) === null || _config$auth === void 0 ? void 0 : (_config$auth$methods = _config$auth.methods) === null || _config$auth$methods === void 0 ? void 0 : _config$auth$methods.emailOtpAuthEnabled) !== null && _config$auth$methods$ !== void 0 ? _config$auth$methods$ : proxyAuthConfig === null || proxyAuthConfig === void 0 ? void 0 : proxyAuthConfig.enabledProviders.includes("email"),
@@ -496,24 +499,36 @@ var ClientProvider = function ClientProvider(_ref) {
496
499
  appleOauthEnabled: (_config$auth$methods$8 = (_config$auth8 = config.auth) === null || _config$auth8 === void 0 ? void 0 : (_config$auth8$methods = _config$auth8.methods) === null || _config$auth8$methods === void 0 ? void 0 : _config$auth8$methods.appleOauthEnabled) !== null && _config$auth$methods$8 !== void 0 ? _config$auth$methods$8 : proxyAuthConfig === null || proxyAuthConfig === void 0 ? void 0 : proxyAuthConfig.enabledProviders.includes("apple"),
497
500
  facebookOauthEnabled: (_config$auth$methods$9 = (_config$auth9 = config.auth) === null || _config$auth9 === void 0 ? void 0 : (_config$auth9$methods = _config$auth9.methods) === null || _config$auth9$methods === void 0 ? void 0 : _config$auth9$methods.facebookOauthEnabled) !== null && _config$auth$methods$9 !== void 0 ? _config$auth$methods$9 : proxyAuthConfig === null || proxyAuthConfig === void 0 ? void 0 : proxyAuthConfig.enabledProviders.includes("facebook")
498
501
  };
502
+ var resolvedClientIds = {
503
+ googleClientId: (_config$auth$oauthCon = (_config$auth0 = config.auth) === null || _config$auth0 === void 0 ? void 0 : (_config$auth0$oauthCo = _config$auth0.oauthConfig) === null || _config$auth0$oauthCo === void 0 ? void 0 : _config$auth0$oauthCo.googleClientId) !== null && _config$auth$oauthCon !== void 0 ? _config$auth$oauthCon : proxyAuthConfig === null || proxyAuthConfig === void 0 ? void 0 : (_proxyAuthConfig$oaut = proxyAuthConfig.oauthClientIds) === null || _proxyAuthConfig$oaut === void 0 ? void 0 : _proxyAuthConfig$oaut.google,
504
+ appleClientId: (_config$auth$oauthCon2 = (_config$auth1 = config.auth) === null || _config$auth1 === void 0 ? void 0 : (_config$auth1$oauthCo = _config$auth1.oauthConfig) === null || _config$auth1$oauthCo === void 0 ? void 0 : _config$auth1$oauthCo.appleClientId) !== null && _config$auth$oauthCon2 !== void 0 ? _config$auth$oauthCon2 : proxyAuthConfig === null || proxyAuthConfig === void 0 ? void 0 : (_proxyAuthConfig$oaut2 = proxyAuthConfig.oauthClientIds) === null || _proxyAuthConfig$oaut2 === void 0 ? void 0 : _proxyAuthConfig$oaut2.apple,
505
+ facebookClientId: (_config$auth$oauthCon3 = (_config$auth10 = config.auth) === null || _config$auth10 === void 0 ? void 0 : (_config$auth10$oauthC = _config$auth10.oauthConfig) === null || _config$auth10$oauthC === void 0 ? void 0 : _config$auth10$oauthC.facebookClientId) !== null && _config$auth$oauthCon3 !== void 0 ? _config$auth$oauthCon3 : proxyAuthConfig === null || proxyAuthConfig === void 0 ? void 0 : (_proxyAuthConfig$oaut3 = proxyAuthConfig.oauthClientIds) === null || _proxyAuthConfig$oaut3 === void 0 ? void 0 : _proxyAuthConfig$oaut3.facebook,
506
+ xClientId: (_config$auth$oauthCon4 = (_config$auth11 = config.auth) === null || _config$auth11 === void 0 ? void 0 : (_config$auth11$oauthC = _config$auth11.oauthConfig) === null || _config$auth11$oauthC === void 0 ? void 0 : _config$auth11$oauthC.xClientId) !== null && _config$auth$oauthCon4 !== void 0 ? _config$auth$oauthCon4 : proxyAuthConfig === null || proxyAuthConfig === void 0 ? void 0 : (_proxyAuthConfig$oaut4 = proxyAuthConfig.oauthClientIds) === null || _proxyAuthConfig$oaut4 === void 0 ? void 0 : _proxyAuthConfig$oaut4.x,
507
+ discordClientId: (_config$auth$oauthCon5 = (_config$auth12 = config.auth) === null || _config$auth12 === void 0 ? void 0 : (_config$auth12$oauthC = _config$auth12.oauthConfig) === null || _config$auth12$oauthC === void 0 ? void 0 : _config$auth12$oauthC.discordClientId) !== null && _config$auth$oauthCon5 !== void 0 ? _config$auth$oauthCon5 : proxyAuthConfig === null || proxyAuthConfig === void 0 ? void 0 : (_proxyAuthConfig$oaut5 = proxyAuthConfig.oauthClientIds) === null || _proxyAuthConfig$oaut5 === void 0 ? void 0 : _proxyAuthConfig$oaut5.discord
508
+ };
509
+ var redirectUrl = (_config$auth$oauthCon6 = (_config$auth13 = config.auth) === null || _config$auth13 === void 0 ? void 0 : (_config$auth13$oauthC = _config$auth13.oauthConfig) === null || _config$auth13$oauthC === void 0 ? void 0 : _config$auth13$oauthC.oauthRedirectUri) !== null && _config$auth$oauthCon6 !== void 0 ? _config$auth$oauthCon6 : proxyAuthConfig === null || proxyAuthConfig === void 0 ? void 0 : proxyAuthConfig.oauthRedirectUrl;
499
510
  // Set a default ordering for the oAuth methods
500
- var oauthOrder = (_config$auth$oauthOrd = (_config$auth0 = config.auth) === null || _config$auth0 === void 0 ? void 0 : _config$auth0.oauthOrder) !== null && _config$auth$oauthOrd !== void 0 ? _config$auth$oauthOrd : ["google", "apple", "x", "discord", "facebook"].filter(function (provider) {
511
+ var oauthOrder = (_config$auth$oauthOrd = (_config$auth14 = config.auth) === null || _config$auth14 === void 0 ? void 0 : _config$auth14.oauthOrder) !== null && _config$auth$oauthOrd !== void 0 ? _config$auth$oauthOrd : ["google", "apple", "x", "discord", "facebook"].filter(function (provider) {
501
512
  return resolvedMethods["".concat(provider, "OauthEnabled")];
502
513
  });
503
514
  // Set a default ordering for the overall auth methods
504
- var methodOrder = (_config$auth$methodOr = (_config$auth1 = config.auth) === null || _config$auth1 === void 0 ? void 0 : _config$auth1.methodOrder) !== null && _config$auth$methodOr !== void 0 ? _config$auth$methodOr : [oauthOrder.length > 0 ? "socials" : null, resolvedMethods.emailOtpAuthEnabled ? "email" : null, resolvedMethods.smsOtpAuthEnabled ? "sms" : null, resolvedMethods.passkeyAuthEnabled ? "passkey" : null, resolvedMethods.walletAuthEnabled ? "wallet" : null].filter(Boolean);
515
+ var methodOrder = (_config$auth$methodOr = (_config$auth15 = config.auth) === null || _config$auth15 === void 0 ? void 0 : _config$auth15.methodOrder) !== null && _config$auth$methodOr !== void 0 ? _config$auth$methodOr : [oauthOrder.length > 0 ? "socials" : null, resolvedMethods.emailOtpAuthEnabled ? "email" : null, resolvedMethods.smsOtpAuthEnabled ? "sms" : null, resolvedMethods.passkeyAuthEnabled ? "passkey" : null, resolvedMethods.walletAuthEnabled ? "wallet" : null].filter(Boolean);
505
516
  return _objectSpread2(_objectSpread2({}, config), {}, {
506
517
  // Overrides:
507
518
  auth: _objectSpread2(_objectSpread2({}, config.auth), {}, {
508
519
  methods: resolvedMethods,
509
- oauthConfig: _objectSpread2(_objectSpread2({}, (_config$auth10 = config.auth) === null || _config$auth10 === void 0 ? void 0 : _config$auth10.oauthConfig), {}, {
510
- openOauthInPage: (_config$auth11 = config.auth) === null || _config$auth11 === void 0 ? void 0 : (_config$auth11$oauthC = _config$auth11.oauthConfig) === null || _config$auth11$oauthC === void 0 ? void 0 : _config$auth11$oauthC.openOauthInPage
520
+ oauthConfig: _objectSpread2(_objectSpread2(_objectSpread2({}, (_config$auth16 = config.auth) === null || _config$auth16 === void 0 ? void 0 : _config$auth16.oauthConfig), resolvedClientIds), {}, {
521
+ oauthRedirectUri: redirectUrl,
522
+ // on mobile we default to true since many mobile browsers
523
+ // (e.g. Safari) block popups
524
+ openOauthInPage: isMobile ? true : (_config$auth17 = config.auth) === null || _config$auth17 === void 0 ? void 0 : (_config$auth17$oauthC = _config$auth17.oauthConfig) === null || _config$auth17$oauthC === void 0 ? void 0 : _config$auth17$oauthC.openOauthInPage
511
525
  }),
512
526
  sessionExpirationSeconds: proxyAuthConfig === null || proxyAuthConfig === void 0 ? void 0 : proxyAuthConfig.sessionExpirationSeconds,
513
527
  methodOrder: methodOrder,
514
528
  oauthOrder: oauthOrder,
515
- autoRefreshSession: (_config$auth$autoRefr = (_config$auth12 = config.auth) === null || _config$auth12 === void 0 ? void 0 : _config$auth12.autoRefreshSession) !== null && _config$auth$autoRefr !== void 0 ? _config$auth$autoRefr : true
529
+ autoRefreshSession: (_config$auth$autoRefr = (_config$auth18 = config.auth) === null || _config$auth18 === void 0 ? void 0 : _config$auth18.autoRefreshSession) !== null && _config$auth$autoRefr !== void 0 ? _config$auth$autoRefr : true
516
530
  }),
531
+ autoRefreshManagedState: (_config$autoRefreshMa = config.autoRefreshManagedState) !== null && _config$autoRefreshMa !== void 0 ? _config$autoRefreshMa : true,
517
532
  walletConfig: _objectSpread2(_objectSpread2({}, config.walletConfig), {}, {
518
533
  features: _objectSpread2(_objectSpread2({}, (_config$walletConfig = config.walletConfig) === null || _config$walletConfig === void 0 ? void 0 : _config$walletConfig.features), {}, {
519
534
  auth: // If walletAuthEnabled is not set, default to true. Wallet auth can be enabled/disabled in the dashboard or by explicitly changing the walletAuthEnabled / walletConfig auth feature.
@@ -746,11 +761,11 @@ var ClientProvider = function ClientProvider(_ref) {
746
761
  * @throws {TurnkeyError} If an error occurs while scheduling the session expiration.
747
762
  */
748
763
  function _initializeWalletProviderListeners() {
749
- _initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee97(walletProviders, onWalletsChanged) {
764
+ _initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee99(walletProviders, onWalletsChanged) {
750
765
  var _masterConfig$walletC6, _masterConfig$walletC7, _masterConfig$walletC8, _masterConfig$walletC9;
751
766
  var cleanups, nativeOnly, ethProviders, solProviders, wcProviders, attachEthereumListeners, attachSolanaListeners;
752
- return _regeneratorRuntime().wrap(function _callee97$(_context97) {
753
- while (1) switch (_context97.prev = _context97.next) {
767
+ return _regeneratorRuntime().wrap(function _callee99$(_context99) {
768
+ while (1) switch (_context99.prev = _context99.next) {
754
769
  case 0:
755
770
  attachSolanaListeners = function _attachSolanaListener(provider, onWalletsChanged) {
756
771
  var _provider$features;
@@ -789,10 +804,10 @@ var ClientProvider = function ClientProvider(_ref) {
789
804
  };
790
805
  };
791
806
  if (!(walletProviders.length === 0)) {
792
- _context97.next = 4;
807
+ _context99.next = 4;
793
808
  break;
794
809
  }
795
- return _context97.abrupt("return", function () {});
810
+ return _context99.abrupt("return", function () {});
796
811
  case 4:
797
812
  cleanups = []; // we only want to initialize these listeners for connected walletProviders
798
813
  nativeOnly = function nativeOnly(provider) {
@@ -825,16 +840,16 @@ var ClientProvider = function ClientProvider(_ref) {
825
840
  cleanups.push(unsubscribe);
826
841
  }
827
842
  });
828
- return _context97.abrupt("return", function () {
843
+ return _context99.abrupt("return", function () {
829
844
  cleanups.forEach(function (remove) {
830
845
  return remove();
831
846
  });
832
847
  });
833
848
  case 13:
834
849
  case "end":
835
- return _context97.stop();
850
+ return _context99.stop();
836
851
  }
837
- }, _callee97);
852
+ }, _callee99);
838
853
  }));
839
854
  return _initializeWalletProviderListeners.apply(this, arguments);
840
855
  }
@@ -850,13 +865,13 @@ var ClientProvider = function ClientProvider(_ref) {
850
865
  * @throws {TurnkeyError} If an error occurs while clearing the timers.
851
866
  */
852
867
  function _scheduleSessionExpiration() {
853
- _scheduleSessionExpiration = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee100(params) {
868
+ _scheduleSessionExpiration = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee102(params) {
854
869
  var sessionKey, expiry, warnKey, now, expiryMs, timeUntilExpiry, _beforeExpiry, expireSession, warnAt, _callbacks$onError0, _callbacks$onError1;
855
- return _regeneratorRuntime().wrap(function _callee100$(_context100) {
856
- while (1) switch (_context100.prev = _context100.next) {
870
+ return _regeneratorRuntime().wrap(function _callee102$(_context102) {
871
+ while (1) switch (_context102.prev = _context102.next) {
857
872
  case 0:
858
873
  sessionKey = params.sessionKey, expiry = params.expiry;
859
- _context100.prev = 1;
874
+ _context102.prev = 1;
860
875
  warnKey = "".concat(sessionKey, "-warning"); // Replace any prior timers for this session
861
876
  clearKey(expiryTimeoutsRef.current, sessionKey);
862
877
  clearKey(expiryTimeoutsRef.current, warnKey);
@@ -864,87 +879,87 @@ var ClientProvider = function ClientProvider(_ref) {
864
879
  expiryMs = expiry * 1000;
865
880
  timeUntilExpiry = expiryMs - now;
866
881
  _beforeExpiry = /*#__PURE__*/function () {
867
- var _ref120 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee98() {
882
+ var _ref122 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee100() {
868
883
  var _callbacks$beforeSess, _masterConfig$auth40;
869
884
  var activeSession, session;
870
- return _regeneratorRuntime().wrap(function _callee98$(_context98) {
871
- while (1) switch (_context98.prev = _context98.next) {
885
+ return _regeneratorRuntime().wrap(function _callee100$(_context100) {
886
+ while (1) switch (_context100.prev = _context100.next) {
872
887
  case 0:
873
- _context98.next = 2;
888
+ _context100.next = 2;
874
889
  return getSession();
875
890
  case 2:
876
- activeSession = _context98.sent;
891
+ activeSession = _context100.sent;
877
892
  if (!(!activeSession && expiryTimeoutsRef.current[warnKey])) {
878
- _context98.next = 6;
893
+ _context100.next = 6;
879
894
  break;
880
895
  }
881
896
  // Keep nudging until session materializes (short 10s timer is fine)
882
897
  setTimeoutInMap(expiryTimeoutsRef.current, warnKey, _beforeExpiry, 10000);
883
- return _context98.abrupt("return");
898
+ return _context100.abrupt("return");
884
899
  case 6:
885
- _context98.next = 8;
900
+ _context100.next = 8;
886
901
  return getSession({
887
902
  sessionKey: sessionKey
888
903
  });
889
904
  case 8:
890
- session = _context98.sent;
905
+ session = _context100.sent;
891
906
  if (session) {
892
- _context98.next = 11;
907
+ _context100.next = 11;
893
908
  break;
894
909
  }
895
- return _context98.abrupt("return");
910
+ return _context100.abrupt("return");
896
911
  case 11:
897
912
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$beforeSess = callbacks.beforeSessionExpiry) === null || _callbacks$beforeSess === void 0 ? void 0 : _callbacks$beforeSess.call(callbacks, {
898
913
  sessionKey: sessionKey
899
914
  });
900
915
  if (!(masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth40 = masterConfig.auth) !== null && _masterConfig$auth40 !== void 0 && _masterConfig$auth40.autoRefreshSession)) {
901
- _context98.next = 15;
916
+ _context100.next = 15;
902
917
  break;
903
918
  }
904
- _context98.next = 15;
919
+ _context100.next = 15;
905
920
  return refreshSession({
906
921
  expirationSeconds: session.expirationSeconds,
907
922
  sessionKey: sessionKey
908
923
  });
909
924
  case 15:
910
925
  case "end":
911
- return _context98.stop();
926
+ return _context100.stop();
912
927
  }
913
- }, _callee98);
928
+ }, _callee100);
914
929
  }));
915
930
  return function beforeExpiry() {
916
- return _ref120.apply(this, arguments);
931
+ return _ref122.apply(this, arguments);
917
932
  };
918
933
  }();
919
934
  expireSession = /*#__PURE__*/function () {
920
- var _ref121 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee99() {
935
+ var _ref123 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee101() {
921
936
  var _callbacks$onSessionE;
922
937
  var expiredSession;
923
- return _regeneratorRuntime().wrap(function _callee99$(_context99) {
924
- while (1) switch (_context99.prev = _context99.next) {
938
+ return _regeneratorRuntime().wrap(function _callee101$(_context101) {
939
+ while (1) switch (_context101.prev = _context101.next) {
925
940
  case 0:
926
- _context99.next = 2;
941
+ _context101.next = 2;
927
942
  return getSession({
928
943
  sessionKey: sessionKey
929
944
  });
930
945
  case 2:
931
- expiredSession = _context99.sent;
946
+ expiredSession = _context101.sent;
932
947
  if (expiredSession) {
933
- _context99.next = 5;
948
+ _context101.next = 5;
934
949
  break;
935
950
  }
936
- return _context99.abrupt("return");
951
+ return _context101.abrupt("return");
937
952
  case 5:
938
953
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onSessionE = callbacks.onSessionExpired) === null || _callbacks$onSessionE === void 0 ? void 0 : _callbacks$onSessionE.call(callbacks, {
939
954
  sessionKey: sessionKey
940
955
  });
941
- _context99.next = 8;
956
+ _context101.next = 8;
942
957
  return getActiveSessionKey();
943
958
  case 8:
944
- _context99.t0 = _context99.sent;
945
- _context99.t1 = sessionKey;
946
- if (!(_context99.t0 === _context99.t1)) {
947
- _context99.next = 12;
959
+ _context101.t0 = _context101.sent;
960
+ _context101.t1 = sessionKey;
961
+ if (!(_context101.t0 === _context101.t1)) {
962
+ _context101.next = 12;
948
963
  break;
949
964
  }
950
965
  setSession(undefined);
@@ -955,7 +970,7 @@ var ClientProvider = function ClientProvider(_ref) {
955
970
  delete next[sessionKey];
956
971
  return next;
957
972
  });
958
- _context99.next = 15;
973
+ _context101.next = 15;
959
974
  return clearSession({
960
975
  sessionKey: sessionKey
961
976
  });
@@ -963,26 +978,26 @@ var ClientProvider = function ClientProvider(_ref) {
963
978
  // Remove timers for this session
964
979
  clearKey(expiryTimeoutsRef.current, sessionKey);
965
980
  clearKey(expiryTimeoutsRef.current, warnKey);
966
- _context99.next = 19;
981
+ _context101.next = 19;
967
982
  return logout();
968
983
  case 19:
969
984
  case "end":
970
- return _context99.stop();
985
+ return _context101.stop();
971
986
  }
972
- }, _callee99);
987
+ }, _callee101);
973
988
  }));
974
989
  return function expireSession() {
975
- return _ref121.apply(this, arguments);
990
+ return _ref123.apply(this, arguments);
976
991
  };
977
992
  }(); // Already expired → expire immediately
978
993
  if (!(timeUntilExpiry <= 0)) {
979
- _context100.next = 14;
994
+ _context102.next = 14;
980
995
  break;
981
996
  }
982
- _context100.next = 13;
997
+ _context102.next = 13;
983
998
  return expireSession();
984
999
  case 13:
985
- return _context100.abrupt("return");
1000
+ return _context102.abrupt("return");
986
1001
  case 14:
987
1002
  // Warning timer (if threshold is in the future)
988
1003
  warnAt = expiryMs - SESSION_WARNING_THRESHOLD_MS;
@@ -993,21 +1008,21 @@ var ClientProvider = function ClientProvider(_ref) {
993
1008
  }
994
1009
  // Actual expiry timer (safe for long delays)
995
1010
  setCappedTimeoutInMap(expiryTimeoutsRef.current, sessionKey, expireSession, timeUntilExpiry);
996
- _context100.next = 22;
1011
+ _context102.next = 22;
997
1012
  break;
998
1013
  case 19:
999
- _context100.prev = 19;
1000
- _context100.t0 = _context100["catch"](1);
1001
- if (_context100.t0 instanceof TurnkeyError || _context100.t0 instanceof TurnkeyNetworkError) {
1002
- callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError0 = callbacks.onError) === null || _callbacks$onError0 === void 0 ? void 0 : _callbacks$onError0.call(callbacks, _context100.t0);
1014
+ _context102.prev = 19;
1015
+ _context102.t0 = _context102["catch"](1);
1016
+ if (_context102.t0 instanceof TurnkeyError || _context102.t0 instanceof TurnkeyNetworkError) {
1017
+ callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError0 = callbacks.onError) === null || _callbacks$onError0 === void 0 ? void 0 : _callbacks$onError0.call(callbacks, _context102.t0);
1003
1018
  } else {
1004
- callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError1 = callbacks.onError) === null || _callbacks$onError1 === void 0 ? void 0 : _callbacks$onError1.call(callbacks, new TurnkeyError("Failed to schedule session expiration for ".concat(sessionKey), TurnkeyErrorCodes.SCHEDULE_SESSION_EXPIRY_ERROR, _context100.t0));
1019
+ callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError1 = callbacks.onError) === null || _callbacks$onError1 === void 0 ? void 0 : _callbacks$onError1.call(callbacks, new TurnkeyError("Failed to schedule session expiration for ".concat(sessionKey), TurnkeyErrorCodes.SCHEDULE_SESSION_EXPIRY_ERROR, _context102.t0));
1005
1020
  }
1006
1021
  case 22:
1007
1022
  case "end":
1008
- return _context100.stop();
1023
+ return _context102.stop();
1009
1024
  }
1010
- }, _callee100, null, [[1, 19]]);
1025
+ }, _callee102, null, [[1, 19]]);
1011
1026
  }));
1012
1027
  return _scheduleSessionExpiration.apply(this, arguments);
1013
1028
  }
@@ -1322,7 +1337,7 @@ var ClientProvider = function ClientProvider(_ref) {
1322
1337
  return _ref10.apply(this, arguments);
1323
1338
  };
1324
1339
  }(), [client, callbacks]);
1325
- var getWalletProviders = useCallback(/*#__PURE__*/function () {
1340
+ var fetchWalletProviders = useCallback(/*#__PURE__*/function () {
1326
1341
  var _ref12 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(chain) {
1327
1342
  var newProviders;
1328
1343
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
@@ -1335,7 +1350,7 @@ var ClientProvider = function ClientProvider(_ref) {
1335
1350
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1336
1351
  case 2:
1337
1352
  _context13.next = 4;
1338
- return client.getWalletProviders(chain);
1353
+ return client.fetchWalletProviders(chain);
1339
1354
  case 4:
1340
1355
  newProviders = _context13.sent;
1341
1356
  // we update state with the latest providers
@@ -2154,9 +2169,8 @@ var ClientProvider = function ClientProvider(_ref) {
2154
2169
  return _ref34.apply(this, arguments);
2155
2170
  };
2156
2171
  }(), [client, callbacks]);
2157
- var updateUserEmail = useCallback(/*#__PURE__*/function () {
2172
+ var fetchOrCreateP256ApiKeyUser = useCallback(/*#__PURE__*/function () {
2158
2173
  var _ref35 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
2159
- var res;
2160
2174
  return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2161
2175
  while (1) switch (_context36.prev = _context36.next) {
2162
2176
  case 0:
@@ -2166,23 +2180,10 @@ var ClientProvider = function ClientProvider(_ref) {
2166
2180
  }
2167
2181
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2168
2182
  case 2:
2169
- _context36.next = 4;
2170
- return withTurnkeyErrorHandling(function () {
2171
- return client.updateUserEmail(params);
2172
- }, callbacks, "Failed to update user email");
2173
- case 4:
2174
- res = _context36.sent;
2175
- if (!res) {
2176
- _context36.next = 8;
2177
- break;
2178
- }
2179
- _context36.next = 8;
2180
- return refreshUser({
2181
- stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2182
- });
2183
- case 8:
2184
- return _context36.abrupt("return", res);
2185
- case 9:
2183
+ return _context36.abrupt("return", withTurnkeyErrorHandling(function () {
2184
+ return client.fetchOrCreateP256ApiKeyUser(params);
2185
+ }, callbacks, "Failed to fetch or create delegated access user"));
2186
+ case 3:
2186
2187
  case "end":
2187
2188
  return _context36.stop();
2188
2189
  }
@@ -2192,9 +2193,8 @@ var ClientProvider = function ClientProvider(_ref) {
2192
2193
  return _ref35.apply(this, arguments);
2193
2194
  };
2194
2195
  }(), [client, callbacks]);
2195
- var removeUserEmail = useCallback(/*#__PURE__*/function () {
2196
+ var fetchOrCreatePolicies = useCallback(/*#__PURE__*/function () {
2196
2197
  var _ref36 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
2197
- var res;
2198
2198
  return _regeneratorRuntime().wrap(function _callee37$(_context37) {
2199
2199
  while (1) switch (_context37.prev = _context37.next) {
2200
2200
  case 0:
@@ -2204,23 +2204,10 @@ var ClientProvider = function ClientProvider(_ref) {
2204
2204
  }
2205
2205
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2206
2206
  case 2:
2207
- _context37.next = 4;
2208
- return withTurnkeyErrorHandling(function () {
2209
- return client.removeUserEmail(params);
2210
- }, callbacks, "Failed to remove user email");
2211
- case 4:
2212
- res = _context37.sent;
2213
- if (!res) {
2214
- _context37.next = 8;
2215
- break;
2216
- }
2217
- _context37.next = 8;
2218
- return refreshUser({
2219
- stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2220
- });
2221
- case 8:
2222
- return _context37.abrupt("return", res);
2223
- case 9:
2207
+ return _context37.abrupt("return", withTurnkeyErrorHandling(function () {
2208
+ return client.fetchOrCreatePolicies(params);
2209
+ }, callbacks, "Failed to fetch or create delegated access user"));
2210
+ case 3:
2224
2211
  case "end":
2225
2212
  return _context37.stop();
2226
2213
  }
@@ -2230,7 +2217,7 @@ var ClientProvider = function ClientProvider(_ref) {
2230
2217
  return _ref36.apply(this, arguments);
2231
2218
  };
2232
2219
  }(), [client, callbacks]);
2233
- var updateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
2220
+ var updateUserEmail = useCallback(/*#__PURE__*/function () {
2234
2221
  var _ref37 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
2235
2222
  var res;
2236
2223
  return _regeneratorRuntime().wrap(function _callee38$(_context38) {
@@ -2244,8 +2231,8 @@ var ClientProvider = function ClientProvider(_ref) {
2244
2231
  case 2:
2245
2232
  _context38.next = 4;
2246
2233
  return withTurnkeyErrorHandling(function () {
2247
- return client.updateUserPhoneNumber(params);
2248
- }, callbacks, "Failed to update user phone number");
2234
+ return client.updateUserEmail(params);
2235
+ }, callbacks, "Failed to update user email");
2249
2236
  case 4:
2250
2237
  res = _context38.sent;
2251
2238
  if (!res) {
@@ -2268,7 +2255,7 @@ var ClientProvider = function ClientProvider(_ref) {
2268
2255
  return _ref37.apply(this, arguments);
2269
2256
  };
2270
2257
  }(), [client, callbacks]);
2271
- var removeUserPhoneNumber = useCallback(/*#__PURE__*/function () {
2258
+ var removeUserEmail = useCallback(/*#__PURE__*/function () {
2272
2259
  var _ref38 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
2273
2260
  var res;
2274
2261
  return _regeneratorRuntime().wrap(function _callee39$(_context39) {
@@ -2282,8 +2269,8 @@ var ClientProvider = function ClientProvider(_ref) {
2282
2269
  case 2:
2283
2270
  _context39.next = 4;
2284
2271
  return withTurnkeyErrorHandling(function () {
2285
- return client.removeUserPhoneNumber(params);
2286
- }, callbacks, "Failed to remove user phone number");
2272
+ return client.removeUserEmail(params);
2273
+ }, callbacks, "Failed to remove user email");
2287
2274
  case 4:
2288
2275
  res = _context39.sent;
2289
2276
  if (!res) {
@@ -2306,7 +2293,7 @@ var ClientProvider = function ClientProvider(_ref) {
2306
2293
  return _ref38.apply(this, arguments);
2307
2294
  };
2308
2295
  }(), [client, callbacks]);
2309
- var updateUserName = useCallback(/*#__PURE__*/function () {
2296
+ var updateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
2310
2297
  var _ref39 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
2311
2298
  var res;
2312
2299
  return _regeneratorRuntime().wrap(function _callee40$(_context40) {
@@ -2320,8 +2307,8 @@ var ClientProvider = function ClientProvider(_ref) {
2320
2307
  case 2:
2321
2308
  _context40.next = 4;
2322
2309
  return withTurnkeyErrorHandling(function () {
2323
- return client.updateUserName(params);
2324
- }, callbacks, "Failed to update user name");
2310
+ return client.updateUserPhoneNumber(params);
2311
+ }, callbacks, "Failed to update user phone number");
2325
2312
  case 4:
2326
2313
  res = _context40.sent;
2327
2314
  if (!res) {
@@ -2344,7 +2331,7 @@ var ClientProvider = function ClientProvider(_ref) {
2344
2331
  return _ref39.apply(this, arguments);
2345
2332
  };
2346
2333
  }(), [client, callbacks]);
2347
- var addOauthProvider = useCallback(/*#__PURE__*/function () {
2334
+ var removeUserPhoneNumber = useCallback(/*#__PURE__*/function () {
2348
2335
  var _ref40 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
2349
2336
  var res;
2350
2337
  return _regeneratorRuntime().wrap(function _callee41$(_context41) {
@@ -2358,8 +2345,8 @@ var ClientProvider = function ClientProvider(_ref) {
2358
2345
  case 2:
2359
2346
  _context41.next = 4;
2360
2347
  return withTurnkeyErrorHandling(function () {
2361
- return client.addOauthProvider(params);
2362
- }, callbacks, "Failed to add OAuth provider");
2348
+ return client.removeUserPhoneNumber(params);
2349
+ }, callbacks, "Failed to remove user phone number");
2363
2350
  case 4:
2364
2351
  res = _context41.sent;
2365
2352
  if (!res) {
@@ -2382,7 +2369,7 @@ var ClientProvider = function ClientProvider(_ref) {
2382
2369
  return _ref40.apply(this, arguments);
2383
2370
  };
2384
2371
  }(), [client, callbacks]);
2385
- var removeOauthProviders = useCallback(/*#__PURE__*/function () {
2372
+ var updateUserName = useCallback(/*#__PURE__*/function () {
2386
2373
  var _ref41 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
2387
2374
  var res;
2388
2375
  return _regeneratorRuntime().wrap(function _callee42$(_context42) {
@@ -2396,8 +2383,8 @@ var ClientProvider = function ClientProvider(_ref) {
2396
2383
  case 2:
2397
2384
  _context42.next = 4;
2398
2385
  return withTurnkeyErrorHandling(function () {
2399
- return client.removeOauthProviders(params);
2400
- }, callbacks, "Failed to remove OAuth providers");
2386
+ return client.updateUserName(params);
2387
+ }, callbacks, "Failed to update user name");
2401
2388
  case 4:
2402
2389
  res = _context42.sent;
2403
2390
  if (!res) {
@@ -2420,7 +2407,7 @@ var ClientProvider = function ClientProvider(_ref) {
2420
2407
  return _ref41.apply(this, arguments);
2421
2408
  };
2422
2409
  }(), [client, callbacks]);
2423
- var addPasskey = useCallback(/*#__PURE__*/function () {
2410
+ var addOauthProvider = useCallback(/*#__PURE__*/function () {
2424
2411
  var _ref42 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
2425
2412
  var res;
2426
2413
  return _regeneratorRuntime().wrap(function _callee43$(_context43) {
@@ -2434,8 +2421,8 @@ var ClientProvider = function ClientProvider(_ref) {
2434
2421
  case 2:
2435
2422
  _context43.next = 4;
2436
2423
  return withTurnkeyErrorHandling(function () {
2437
- return client.addPasskey(params);
2438
- }, callbacks, "Failed to add passkey");
2424
+ return client.addOauthProvider(params);
2425
+ }, callbacks, "Failed to add OAuth provider");
2439
2426
  case 4:
2440
2427
  res = _context43.sent;
2441
2428
  if (!res) {
@@ -2458,7 +2445,7 @@ var ClientProvider = function ClientProvider(_ref) {
2458
2445
  return _ref42.apply(this, arguments);
2459
2446
  };
2460
2447
  }(), [client, callbacks]);
2461
- var removePasskeys = useCallback(/*#__PURE__*/function () {
2448
+ var removeOauthProviders = useCallback(/*#__PURE__*/function () {
2462
2449
  var _ref43 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
2463
2450
  var res;
2464
2451
  return _regeneratorRuntime().wrap(function _callee44$(_context44) {
@@ -2472,8 +2459,8 @@ var ClientProvider = function ClientProvider(_ref) {
2472
2459
  case 2:
2473
2460
  _context44.next = 4;
2474
2461
  return withTurnkeyErrorHandling(function () {
2475
- return client.removePasskeys(params);
2476
- }, callbacks, "Failed to remove passkeys");
2462
+ return client.removeOauthProviders(params);
2463
+ }, callbacks, "Failed to remove OAuth providers");
2477
2464
  case 4:
2478
2465
  res = _context44.sent;
2479
2466
  if (!res) {
@@ -2496,7 +2483,7 @@ var ClientProvider = function ClientProvider(_ref) {
2496
2483
  return _ref43.apply(this, arguments);
2497
2484
  };
2498
2485
  }(), [client, callbacks]);
2499
- var createWallet = useCallback(/*#__PURE__*/function () {
2486
+ var addPasskey = useCallback(/*#__PURE__*/function () {
2500
2487
  var _ref44 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
2501
2488
  var res;
2502
2489
  return _regeneratorRuntime().wrap(function _callee45$(_context45) {
@@ -2510,8 +2497,8 @@ var ClientProvider = function ClientProvider(_ref) {
2510
2497
  case 2:
2511
2498
  _context45.next = 4;
2512
2499
  return withTurnkeyErrorHandling(function () {
2513
- return client.createWallet(params);
2514
- }, callbacks, "Failed to create wallet");
2500
+ return client.addPasskey(params);
2501
+ }, callbacks, "Failed to add passkey");
2515
2502
  case 4:
2516
2503
  res = _context45.sent;
2517
2504
  if (!res) {
@@ -2519,7 +2506,7 @@ var ClientProvider = function ClientProvider(_ref) {
2519
2506
  break;
2520
2507
  }
2521
2508
  _context45.next = 8;
2522
- return refreshWallets({
2509
+ return refreshUser({
2523
2510
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2524
2511
  });
2525
2512
  case 8:
@@ -2534,7 +2521,7 @@ var ClientProvider = function ClientProvider(_ref) {
2534
2521
  return _ref44.apply(this, arguments);
2535
2522
  };
2536
2523
  }(), [client, callbacks]);
2537
- var createWalletAccounts = useCallback(/*#__PURE__*/function () {
2524
+ var removePasskeys = useCallback(/*#__PURE__*/function () {
2538
2525
  var _ref45 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
2539
2526
  var res;
2540
2527
  return _regeneratorRuntime().wrap(function _callee46$(_context46) {
@@ -2548,8 +2535,8 @@ var ClientProvider = function ClientProvider(_ref) {
2548
2535
  case 2:
2549
2536
  _context46.next = 4;
2550
2537
  return withTurnkeyErrorHandling(function () {
2551
- return client.createWalletAccounts(params);
2552
- }, callbacks, "Failed to create wallet accounts");
2538
+ return client.removePasskeys(params);
2539
+ }, callbacks, "Failed to remove passkeys");
2553
2540
  case 4:
2554
2541
  res = _context46.sent;
2555
2542
  if (!res) {
@@ -2557,7 +2544,7 @@ var ClientProvider = function ClientProvider(_ref) {
2557
2544
  break;
2558
2545
  }
2559
2546
  _context46.next = 8;
2560
- return refreshWallets({
2547
+ return refreshUser({
2561
2548
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2562
2549
  });
2563
2550
  case 8:
@@ -2572,7 +2559,7 @@ var ClientProvider = function ClientProvider(_ref) {
2572
2559
  return _ref45.apply(this, arguments);
2573
2560
  };
2574
2561
  }(), [client, callbacks]);
2575
- var exportWallet = useCallback(/*#__PURE__*/function () {
2562
+ var createWallet = useCallback(/*#__PURE__*/function () {
2576
2563
  var _ref46 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
2577
2564
  var res;
2578
2565
  return _regeneratorRuntime().wrap(function _callee47$(_context47) {
@@ -2586,8 +2573,8 @@ var ClientProvider = function ClientProvider(_ref) {
2586
2573
  case 2:
2587
2574
  _context47.next = 4;
2588
2575
  return withTurnkeyErrorHandling(function () {
2589
- return client.exportWallet(params);
2590
- }, callbacks, "Failed to export wallet");
2576
+ return client.createWallet(params);
2577
+ }, callbacks, "Failed to create wallet");
2591
2578
  case 4:
2592
2579
  res = _context47.sent;
2593
2580
  if (!res) {
@@ -2610,7 +2597,7 @@ var ClientProvider = function ClientProvider(_ref) {
2610
2597
  return _ref46.apply(this, arguments);
2611
2598
  };
2612
2599
  }(), [client, callbacks]);
2613
- var exportPrivateKey = useCallback(/*#__PURE__*/function () {
2600
+ var createWalletAccounts = useCallback(/*#__PURE__*/function () {
2614
2601
  var _ref47 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
2615
2602
  var res;
2616
2603
  return _regeneratorRuntime().wrap(function _callee48$(_context48) {
@@ -2624,12 +2611,21 @@ var ClientProvider = function ClientProvider(_ref) {
2624
2611
  case 2:
2625
2612
  _context48.next = 4;
2626
2613
  return withTurnkeyErrorHandling(function () {
2627
- return client.exportPrivateKey(params);
2628
- }, callbacks, "Failed to export private key");
2614
+ return client.createWalletAccounts(params);
2615
+ }, callbacks, "Failed to create wallet accounts");
2629
2616
  case 4:
2630
2617
  res = _context48.sent;
2618
+ if (!res) {
2619
+ _context48.next = 8;
2620
+ break;
2621
+ }
2622
+ _context48.next = 8;
2623
+ return refreshWallets({
2624
+ stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2625
+ });
2626
+ case 8:
2631
2627
  return _context48.abrupt("return", res);
2632
- case 6:
2628
+ case 9:
2633
2629
  case "end":
2634
2630
  return _context48.stop();
2635
2631
  }
@@ -2639,7 +2635,7 @@ var ClientProvider = function ClientProvider(_ref) {
2639
2635
  return _ref47.apply(this, arguments);
2640
2636
  };
2641
2637
  }(), [client, callbacks]);
2642
- var exportWalletAccount = useCallback(/*#__PURE__*/function () {
2638
+ var exportWallet = useCallback(/*#__PURE__*/function () {
2643
2639
  var _ref48 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
2644
2640
  var res;
2645
2641
  return _regeneratorRuntime().wrap(function _callee49$(_context49) {
@@ -2653,8 +2649,8 @@ var ClientProvider = function ClientProvider(_ref) {
2653
2649
  case 2:
2654
2650
  _context49.next = 4;
2655
2651
  return withTurnkeyErrorHandling(function () {
2656
- return client.exportWalletAccount(params);
2657
- }, callbacks, "Failed to export wallet accounts");
2652
+ return client.exportWallet(params);
2653
+ }, callbacks, "Failed to export wallet");
2658
2654
  case 4:
2659
2655
  res = _context49.sent;
2660
2656
  if (!res) {
@@ -2677,7 +2673,7 @@ var ClientProvider = function ClientProvider(_ref) {
2677
2673
  return _ref48.apply(this, arguments);
2678
2674
  };
2679
2675
  }(), [client, callbacks]);
2680
- var importWallet = useCallback(/*#__PURE__*/function () {
2676
+ var exportPrivateKey = useCallback(/*#__PURE__*/function () {
2681
2677
  var _ref49 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
2682
2678
  var res;
2683
2679
  return _regeneratorRuntime().wrap(function _callee50$(_context50) {
@@ -2691,21 +2687,12 @@ var ClientProvider = function ClientProvider(_ref) {
2691
2687
  case 2:
2692
2688
  _context50.next = 4;
2693
2689
  return withTurnkeyErrorHandling(function () {
2694
- return client.importWallet(params);
2695
- }, callbacks, "Failed to import wallet");
2690
+ return client.exportPrivateKey(params);
2691
+ }, callbacks, "Failed to export private key");
2696
2692
  case 4:
2697
2693
  res = _context50.sent;
2698
- if (!res) {
2699
- _context50.next = 8;
2700
- break;
2701
- }
2702
- _context50.next = 8;
2703
- return refreshWallets({
2704
- stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2705
- });
2706
- case 8:
2707
2694
  return _context50.abrupt("return", res);
2708
- case 9:
2695
+ case 6:
2709
2696
  case "end":
2710
2697
  return _context50.stop();
2711
2698
  }
@@ -2715,7 +2702,7 @@ var ClientProvider = function ClientProvider(_ref) {
2715
2702
  return _ref49.apply(this, arguments);
2716
2703
  };
2717
2704
  }(), [client, callbacks]);
2718
- var importPrivateKey = useCallback(/*#__PURE__*/function () {
2705
+ var exportWalletAccount = useCallback(/*#__PURE__*/function () {
2719
2706
  var _ref50 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
2720
2707
  var res;
2721
2708
  return _regeneratorRuntime().wrap(function _callee51$(_context51) {
@@ -2729,12 +2716,21 @@ var ClientProvider = function ClientProvider(_ref) {
2729
2716
  case 2:
2730
2717
  _context51.next = 4;
2731
2718
  return withTurnkeyErrorHandling(function () {
2732
- return client.importPrivateKey(params);
2733
- }, callbacks, "Failed to import private key");
2719
+ return client.exportWalletAccount(params);
2720
+ }, callbacks, "Failed to export wallet accounts");
2734
2721
  case 4:
2735
2722
  res = _context51.sent;
2723
+ if (!res) {
2724
+ _context51.next = 8;
2725
+ break;
2726
+ }
2727
+ _context51.next = 8;
2728
+ return refreshWallets({
2729
+ stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2730
+ });
2731
+ case 8:
2736
2732
  return _context51.abrupt("return", res);
2737
- case 6:
2733
+ case 9:
2738
2734
  case "end":
2739
2735
  return _context51.stop();
2740
2736
  }
@@ -2743,9 +2739,10 @@ var ClientProvider = function ClientProvider(_ref) {
2743
2739
  return function (_x46) {
2744
2740
  return _ref50.apply(this, arguments);
2745
2741
  };
2746
- }(), [client, callbacks]);
2747
- var deleteSubOrganization = useCallback(/*#__PURE__*/function () {
2742
+ }(), [client, callbacks, masterConfig, session, user]);
2743
+ var importWallet = useCallback(/*#__PURE__*/function () {
2748
2744
  var _ref51 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
2745
+ var res;
2749
2746
  return _regeneratorRuntime().wrap(function _callee52$(_context52) {
2750
2747
  while (1) switch (_context52.prev = _context52.next) {
2751
2748
  case 0:
@@ -2755,10 +2752,23 @@ var ClientProvider = function ClientProvider(_ref) {
2755
2752
  }
2756
2753
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2757
2754
  case 2:
2758
- return _context52.abrupt("return", withTurnkeyErrorHandling(function () {
2759
- return client.deleteSubOrganization(params);
2760
- }, callbacks, "Failed to delete sub-organization"));
2761
- case 3:
2755
+ _context52.next = 4;
2756
+ return withTurnkeyErrorHandling(function () {
2757
+ return client.importWallet(params);
2758
+ }, callbacks, "Failed to import wallet");
2759
+ case 4:
2760
+ res = _context52.sent;
2761
+ if (!res) {
2762
+ _context52.next = 8;
2763
+ break;
2764
+ }
2765
+ _context52.next = 8;
2766
+ return refreshWallets({
2767
+ stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2768
+ });
2769
+ case 8:
2770
+ return _context52.abrupt("return", res);
2771
+ case 9:
2762
2772
  case "end":
2763
2773
  return _context52.stop();
2764
2774
  }
@@ -2767,10 +2777,10 @@ var ClientProvider = function ClientProvider(_ref) {
2767
2777
  return function (_x47) {
2768
2778
  return _ref51.apply(this, arguments);
2769
2779
  };
2770
- }(), [client, callbacks]);
2771
- var storeSession = useCallback(/*#__PURE__*/function () {
2780
+ }(), [client, callbacks, masterConfig, session, user]);
2781
+ var importPrivateKey = useCallback(/*#__PURE__*/function () {
2772
2782
  var _ref52 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
2773
- var sessionKey, session, allSessions;
2783
+ var res;
2774
2784
  return _regeneratorRuntime().wrap(function _callee53$(_context53) {
2775
2785
  while (1) switch (_context53.prev = _context53.next) {
2776
2786
  case 0:
@@ -2781,150 +2791,203 @@ var ClientProvider = function ClientProvider(_ref) {
2781
2791
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2782
2792
  case 2:
2783
2793
  _context53.next = 4;
2794
+ return withTurnkeyErrorHandling(function () {
2795
+ return client.importPrivateKey(params);
2796
+ }, callbacks, "Failed to import private key");
2797
+ case 4:
2798
+ res = _context53.sent;
2799
+ return _context53.abrupt("return", res);
2800
+ case 6:
2801
+ case "end":
2802
+ return _context53.stop();
2803
+ }
2804
+ }, _callee53);
2805
+ }));
2806
+ return function (_x48) {
2807
+ return _ref52.apply(this, arguments);
2808
+ };
2809
+ }(), [client, callbacks, masterConfig, session, user]);
2810
+ var deleteSubOrganization = useCallback(/*#__PURE__*/function () {
2811
+ var _ref53 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
2812
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
2813
+ while (1) switch (_context54.prev = _context54.next) {
2814
+ case 0:
2815
+ if (client) {
2816
+ _context54.next = 2;
2817
+ break;
2818
+ }
2819
+ throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2820
+ case 2:
2821
+ return _context54.abrupt("return", withTurnkeyErrorHandling(function () {
2822
+ return client.deleteSubOrganization(params);
2823
+ }, callbacks, "Failed to delete sub-organization"));
2824
+ case 3:
2825
+ case "end":
2826
+ return _context54.stop();
2827
+ }
2828
+ }, _callee54);
2829
+ }));
2830
+ return function (_x49) {
2831
+ return _ref53.apply(this, arguments);
2832
+ };
2833
+ }(), [client, callbacks, masterConfig, session, user]);
2834
+ var storeSession = useCallback(/*#__PURE__*/function () {
2835
+ var _ref54 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
2836
+ var sessionKey, session, allSessions;
2837
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
2838
+ while (1) switch (_context55.prev = _context55.next) {
2839
+ case 0:
2840
+ if (client) {
2841
+ _context55.next = 2;
2842
+ break;
2843
+ }
2844
+ throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2845
+ case 2:
2846
+ _context55.next = 4;
2784
2847
  return withTurnkeyErrorHandling(function () {
2785
2848
  return client.storeSession(params);
2786
2849
  }, callbacks, "Failed to store session");
2787
2850
  case 4:
2788
- _context53.next = 6;
2851
+ _context55.next = 6;
2789
2852
  return getActiveSessionKey();
2790
2853
  case 6:
2791
- sessionKey = _context53.sent;
2792
- _context53.next = 9;
2854
+ sessionKey = _context55.sent;
2855
+ _context55.next = 9;
2793
2856
  return getSession(_objectSpread2({}, sessionKey && {
2794
2857
  sessionKey: sessionKey
2795
2858
  }));
2796
2859
  case 9:
2797
- session = _context53.sent;
2860
+ session = _context55.sent;
2798
2861
  if (!(session && sessionKey)) {
2799
- _context53.next = 13;
2862
+ _context55.next = 13;
2800
2863
  break;
2801
2864
  }
2802
- _context53.next = 13;
2865
+ _context55.next = 13;
2803
2866
  return scheduleSessionExpiration({
2804
2867
  sessionKey: sessionKey,
2805
2868
  expiry: session.expiry
2806
2869
  });
2807
2870
  case 13:
2808
- _context53.next = 15;
2871
+ _context55.next = 15;
2809
2872
  return getAllSessions();
2810
2873
  case 15:
2811
- allSessions = _context53.sent;
2874
+ allSessions = _context55.sent;
2812
2875
  setSession(session);
2813
2876
  setAllSessions(allSessions);
2814
- return _context53.abrupt("return");
2877
+ return _context55.abrupt("return");
2815
2878
  case 19:
2816
2879
  case "end":
2817
- return _context53.stop();
2880
+ return _context55.stop();
2818
2881
  }
2819
- }, _callee53);
2882
+ }, _callee55);
2820
2883
  }));
2821
- return function (_x48) {
2822
- return _ref52.apply(this, arguments);
2884
+ return function (_x50) {
2885
+ return _ref54.apply(this, arguments);
2823
2886
  };
2824
- }(), [client, callbacks]);
2887
+ }(), [client, callbacks, masterConfig, session, user]);
2825
2888
  var clearSession = useCallback(/*#__PURE__*/function () {
2826
- var _ref53 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
2889
+ var _ref55 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
2827
2890
  var session, allSessions;
2828
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
2829
- while (1) switch (_context54.prev = _context54.next) {
2891
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
2892
+ while (1) switch (_context56.prev = _context56.next) {
2830
2893
  case 0:
2831
2894
  if (client) {
2832
- _context54.next = 2;
2895
+ _context56.next = 2;
2833
2896
  break;
2834
2897
  }
2835
2898
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2836
2899
  case 2:
2837
- _context54.next = 4;
2900
+ _context56.next = 4;
2838
2901
  return withTurnkeyErrorHandling(function () {
2839
2902
  return client.clearSession(params);
2840
2903
  }, callbacks, "Failed to clear session");
2841
2904
  case 4:
2842
- _context54.next = 6;
2905
+ _context56.next = 6;
2843
2906
  return getSession();
2844
2907
  case 6:
2845
- session = _context54.sent;
2846
- _context54.next = 9;
2908
+ session = _context56.sent;
2909
+ _context56.next = 9;
2847
2910
  return getAllSessions();
2848
2911
  case 9:
2849
- allSessions = _context54.sent;
2912
+ allSessions = _context56.sent;
2850
2913
  setSession(session);
2851
2914
  setAllSessions(allSessions);
2852
- return _context54.abrupt("return");
2915
+ return _context56.abrupt("return");
2853
2916
  case 13:
2854
2917
  case "end":
2855
- return _context54.stop();
2918
+ return _context56.stop();
2856
2919
  }
2857
- }, _callee54);
2920
+ }, _callee56);
2858
2921
  }));
2859
- return function (_x49) {
2860
- return _ref53.apply(this, arguments);
2922
+ return function (_x51) {
2923
+ return _ref55.apply(this, arguments);
2861
2924
  };
2862
- }(), [client, callbacks]);
2863
- var clearAllSessions = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
2864
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
2865
- while (1) switch (_context55.prev = _context55.next) {
2925
+ }(), [client, callbacks, session, user, masterConfig]);
2926
+ var clearAllSessions = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee57() {
2927
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
2928
+ while (1) switch (_context57.prev = _context57.next) {
2866
2929
  case 0:
2867
2930
  if (client) {
2868
- _context55.next = 2;
2931
+ _context57.next = 2;
2869
2932
  break;
2870
2933
  }
2871
2934
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2872
2935
  case 2:
2873
2936
  setSession(undefined);
2874
2937
  setAllSessions(undefined);
2875
- _context55.next = 6;
2938
+ _context57.next = 6;
2876
2939
  return withTurnkeyErrorHandling(function () {
2877
2940
  return client.clearAllSessions();
2878
2941
  }, callbacks, "Failed to clear all sessions");
2879
2942
  case 6:
2880
- return _context55.abrupt("return", _context55.sent);
2943
+ return _context57.abrupt("return", _context57.sent);
2881
2944
  case 7:
2882
2945
  case "end":
2883
- return _context55.stop();
2946
+ return _context57.stop();
2884
2947
  }
2885
- }, _callee55);
2886
- })), [client, callbacks]);
2948
+ }, _callee57);
2949
+ })), [client, callbacks, session, user, masterConfig]);
2887
2950
  var refreshSession = useCallback(/*#__PURE__*/function () {
2888
- var _ref55 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
2951
+ var _ref57 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
2889
2952
  var _params$sessionKey;
2890
2953
  var activeSessionKey, sessionKey, res, session, allSessions;
2891
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
2892
- while (1) switch (_context56.prev = _context56.next) {
2954
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
2955
+ while (1) switch (_context58.prev = _context58.next) {
2893
2956
  case 0:
2894
2957
  if (client) {
2895
- _context56.next = 2;
2958
+ _context58.next = 2;
2896
2959
  break;
2897
2960
  }
2898
2961
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2899
2962
  case 2:
2900
- _context56.next = 4;
2963
+ _context58.next = 4;
2901
2964
  return client.getActiveSessionKey();
2902
2965
  case 4:
2903
- activeSessionKey = _context56.sent;
2966
+ activeSessionKey = _context58.sent;
2904
2967
  if (activeSessionKey) {
2905
- _context56.next = 7;
2968
+ _context58.next = 7;
2906
2969
  break;
2907
2970
  }
2908
2971
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
2909
2972
  case 7:
2910
2973
  sessionKey = (_params$sessionKey = params === null || params === void 0 ? void 0 : params.sessionKey) !== null && _params$sessionKey !== void 0 ? _params$sessionKey : activeSessionKey;
2911
- _context56.next = 10;
2974
+ _context58.next = 10;
2912
2975
  return withTurnkeyErrorHandling(function () {
2913
2976
  return client.refreshSession(_objectSpread2({}, params));
2914
2977
  }, callbacks, "Failed to refresh session");
2915
2978
  case 10:
2916
- res = _context56.sent;
2917
- _context56.next = 13;
2979
+ res = _context58.sent;
2980
+ _context58.next = 13;
2918
2981
  return getSession({
2919
2982
  sessionKey: sessionKey
2920
2983
  });
2921
2984
  case 13:
2922
- session = _context56.sent;
2985
+ session = _context58.sent;
2923
2986
  if (!(session && sessionKey)) {
2924
- _context56.next = 17;
2987
+ _context58.next = 17;
2925
2988
  break;
2926
2989
  }
2927
- _context56.next = 17;
2990
+ _context58.next = 17;
2928
2991
  return scheduleSessionExpiration(_objectSpread2({
2929
2992
  sessionKey: sessionKey,
2930
2993
  expiry: session.expiry
@@ -2932,326 +2995,338 @@ var ClientProvider = function ClientProvider(_ref) {
2932
2995
  expirationSeconds: params === null || params === void 0 ? void 0 : params.expirationSeconds
2933
2996
  }));
2934
2997
  case 17:
2935
- _context56.next = 19;
2998
+ _context58.next = 19;
2936
2999
  return getAllSessions();
2937
3000
  case 19:
2938
- allSessions = _context56.sent;
3001
+ allSessions = _context58.sent;
2939
3002
  setSession(session);
2940
3003
  setAllSessions(allSessions);
2941
- return _context56.abrupt("return", res);
3004
+ return _context58.abrupt("return", res);
2942
3005
  case 23:
2943
3006
  case "end":
2944
- return _context56.stop();
3007
+ return _context58.stop();
2945
3008
  }
2946
- }, _callee56);
3009
+ }, _callee58);
2947
3010
  }));
2948
- return function (_x50) {
2949
- return _ref55.apply(this, arguments);
3011
+ return function (_x52) {
3012
+ return _ref57.apply(this, arguments);
2950
3013
  };
2951
- }(), [client, callbacks]);
3014
+ }(), [client, callbacks, scheduleSessionExpiration, session, user, masterConfig]);
2952
3015
  var getSession = useCallback(/*#__PURE__*/function () {
2953
- var _ref56 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
2954
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
2955
- while (1) switch (_context57.prev = _context57.next) {
3016
+ var _ref58 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
3017
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
3018
+ while (1) switch (_context59.prev = _context59.next) {
2956
3019
  case 0:
2957
3020
  if (client) {
2958
- _context57.next = 2;
3021
+ _context59.next = 2;
2959
3022
  break;
2960
3023
  }
2961
3024
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2962
3025
  case 2:
2963
- return _context57.abrupt("return", withTurnkeyErrorHandling(function () {
3026
+ return _context59.abrupt("return", withTurnkeyErrorHandling(function () {
2964
3027
  return client.getSession(params);
2965
3028
  }, callbacks, "Failed to get session"));
2966
3029
  case 3:
2967
3030
  case "end":
2968
- return _context57.stop();
3031
+ return _context59.stop();
2969
3032
  }
2970
- }, _callee57);
3033
+ }, _callee59);
2971
3034
  }));
2972
- return function (_x51) {
2973
- return _ref56.apply(this, arguments);
3035
+ return function (_x53) {
3036
+ return _ref58.apply(this, arguments);
2974
3037
  };
2975
- }(), [client, callbacks]);
2976
- var getAllSessions = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee58() {
2977
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
2978
- while (1) switch (_context58.prev = _context58.next) {
3038
+ }(), [client, callbacks, masterConfig, session, user]);
3039
+ var getAllSessions = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee60() {
3040
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
3041
+ while (1) switch (_context60.prev = _context60.next) {
2979
3042
  case 0:
2980
3043
  if (client) {
2981
- _context58.next = 2;
3044
+ _context60.next = 2;
2982
3045
  break;
2983
3046
  }
2984
3047
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2985
3048
  case 2:
2986
- return _context58.abrupt("return", withTurnkeyErrorHandling(function () {
3049
+ return _context60.abrupt("return", withTurnkeyErrorHandling(function () {
2987
3050
  return client.getAllSessions();
2988
3051
  }, callbacks, "Failed to get all sessions"));
2989
3052
  case 3:
2990
3053
  case "end":
2991
- return _context58.stop();
3054
+ return _context60.stop();
2992
3055
  }
2993
- }, _callee58);
2994
- })), [client, callbacks]);
3056
+ }, _callee60);
3057
+ })), [client, callbacks, masterConfig, session, user]);
2995
3058
  var setActiveSession = useCallback(/*#__PURE__*/function () {
2996
- var _ref58 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
3059
+ var _ref60 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
2997
3060
  var session;
2998
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
2999
- while (1) switch (_context60.prev = _context60.next) {
3061
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
3062
+ while (1) switch (_context62.prev = _context62.next) {
3000
3063
  case 0:
3001
3064
  if (client) {
3002
- _context60.next = 2;
3065
+ _context62.next = 2;
3003
3066
  break;
3004
3067
  }
3005
3068
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3006
3069
  case 2:
3007
- _context60.next = 4;
3070
+ _context62.next = 4;
3008
3071
  return withTurnkeyErrorHandling(function () {
3009
3072
  return client.getSession({
3010
3073
  sessionKey: params.sessionKey
3011
3074
  });
3012
3075
  }, callbacks, "Failed to get session");
3013
3076
  case 4:
3014
- session = _context60.sent;
3077
+ session = _context62.sent;
3015
3078
  if (session) {
3016
- _context60.next = 7;
3079
+ _context62.next = 7;
3017
3080
  break;
3018
3081
  }
3019
3082
  throw new TurnkeyError("Session not found.", TurnkeyErrorCodes.NOT_FOUND);
3020
3083
  case 7:
3021
- _context60.next = 9;
3084
+ _context62.next = 9;
3022
3085
  return withTurnkeyErrorHandling(function () {
3023
3086
  return client.setActiveSession(params);
3024
3087
  }, callbacks, "Failed to set active session");
3025
3088
  case 9:
3026
3089
  setSession(session);
3027
- _context60.next = 12;
3028
- return withTurnkeyErrorHandling(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee59() {
3029
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
3030
- while (1) switch (_context59.prev = _context59.next) {
3090
+ _context62.next = 12;
3091
+ return withTurnkeyErrorHandling(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee61() {
3092
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
3093
+ while (1) switch (_context61.prev = _context61.next) {
3031
3094
  case 0:
3032
- _context59.next = 2;
3095
+ _context61.next = 2;
3033
3096
  return refreshWallets();
3034
3097
  case 2:
3035
- _context59.next = 4;
3098
+ _context61.next = 4;
3036
3099
  return refreshUser();
3037
3100
  case 4:
3038
3101
  case "end":
3039
- return _context59.stop();
3102
+ return _context61.stop();
3040
3103
  }
3041
- }, _callee59);
3104
+ }, _callee61);
3042
3105
  })), callbacks, "Failed to refresh data after setting active session");
3043
3106
  case 12:
3044
- return _context60.abrupt("return");
3107
+ return _context62.abrupt("return");
3045
3108
  case 13:
3046
3109
  case "end":
3047
- return _context60.stop();
3110
+ return _context62.stop();
3048
3111
  }
3049
- }, _callee60);
3112
+ }, _callee62);
3050
3113
  }));
3051
- return function (_x52) {
3052
- return _ref58.apply(this, arguments);
3114
+ return function (_x54) {
3115
+ return _ref60.apply(this, arguments);
3053
3116
  };
3054
- }(), [client, callbacks]);
3055
- var getActiveSessionKey = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee61() {
3056
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
3057
- while (1) switch (_context61.prev = _context61.next) {
3117
+ }(), [client, callbacks, session, user, masterConfig]);
3118
+ var getActiveSessionKey = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee63() {
3119
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
3120
+ while (1) switch (_context63.prev = _context63.next) {
3058
3121
  case 0:
3059
3122
  if (client) {
3060
- _context61.next = 2;
3123
+ _context63.next = 2;
3061
3124
  break;
3062
3125
  }
3063
3126
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3064
3127
  case 2:
3065
- return _context61.abrupt("return", withTurnkeyErrorHandling(function () {
3128
+ return _context63.abrupt("return", withTurnkeyErrorHandling(function () {
3066
3129
  return client.getActiveSessionKey();
3067
3130
  }, callbacks, "Failed to get active session key"));
3068
3131
  case 3:
3069
3132
  case "end":
3070
- return _context61.stop();
3133
+ return _context63.stop();
3071
3134
  }
3072
- }, _callee61);
3073
- })), [client, callbacks]);
3074
- var clearUnusedKeyPairs = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee62() {
3075
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
3076
- while (1) switch (_context62.prev = _context62.next) {
3135
+ }, _callee63);
3136
+ })), [client, callbacks, masterConfig, session, user]);
3137
+ var clearUnusedKeyPairs = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee64() {
3138
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
3139
+ while (1) switch (_context64.prev = _context64.next) {
3077
3140
  case 0:
3078
3141
  if (client) {
3079
- _context62.next = 2;
3142
+ _context64.next = 2;
3080
3143
  break;
3081
3144
  }
3082
3145
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3083
3146
  case 2:
3084
- return _context62.abrupt("return", withTurnkeyErrorHandling(function () {
3147
+ return _context64.abrupt("return", withTurnkeyErrorHandling(function () {
3085
3148
  return client.clearUnusedKeyPairs();
3086
3149
  }, callbacks, "Failed to clear unused key pairs"));
3087
3150
  case 3:
3088
3151
  case "end":
3089
- return _context62.stop();
3152
+ return _context64.stop();
3090
3153
  }
3091
- }, _callee62);
3092
- })), [client, callbacks]);
3154
+ }, _callee64);
3155
+ })), [client, callbacks, masterConfig, session, user]);
3093
3156
  var createApiKeyPair = useCallback(/*#__PURE__*/function () {
3094
- var _ref62 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
3095
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
3096
- while (1) switch (_context63.prev = _context63.next) {
3157
+ var _ref64 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee65(params) {
3158
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
3159
+ while (1) switch (_context65.prev = _context65.next) {
3097
3160
  case 0:
3098
3161
  if (client) {
3099
- _context63.next = 2;
3162
+ _context65.next = 2;
3100
3163
  break;
3101
3164
  }
3102
3165
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3103
3166
  case 2:
3104
- return _context63.abrupt("return", withTurnkeyErrorHandling(function () {
3167
+ return _context65.abrupt("return", withTurnkeyErrorHandling(function () {
3105
3168
  return client.createApiKeyPair(params);
3106
3169
  }, callbacks, "Failed to create API key pair"));
3107
3170
  case 3:
3108
3171
  case "end":
3109
- return _context63.stop();
3172
+ return _context65.stop();
3110
3173
  }
3111
- }, _callee63);
3174
+ }, _callee65);
3112
3175
  }));
3113
- return function (_x53) {
3114
- return _ref62.apply(this, arguments);
3176
+ return function (_x55) {
3177
+ return _ref64.apply(this, arguments);
3115
3178
  };
3116
- }(), [client, callbacks]);
3117
- var getProxyAuthConfig = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee64() {
3118
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
3119
- while (1) switch (_context64.prev = _context64.next) {
3179
+ }(), [client, callbacks, session, user, masterConfig]);
3180
+ var getProxyAuthConfig = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee66() {
3181
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
3182
+ while (1) switch (_context66.prev = _context66.next) {
3120
3183
  case 0:
3121
3184
  if (client) {
3122
- _context64.next = 2;
3185
+ _context66.next = 2;
3123
3186
  break;
3124
3187
  }
3125
3188
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3126
3189
  case 2:
3127
- return _context64.abrupt("return", withTurnkeyErrorHandling(function () {
3190
+ return _context66.abrupt("return", withTurnkeyErrorHandling(function () {
3128
3191
  return client.getProxyAuthConfig();
3129
3192
  }, callbacks, "Failed to get proxy auth config"));
3130
3193
  case 3:
3131
3194
  case "end":
3132
- return _context64.stop();
3195
+ return _context66.stop();
3133
3196
  }
3134
- }, _callee64);
3135
- })), [client, callbacks]);
3197
+ }, _callee66);
3198
+ })), [client, callbacks, masterConfig, session, user]);
3136
3199
  var refreshUser = useCallback(/*#__PURE__*/function () {
3137
- var _ref64 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee65(params) {
3138
- var _ref65, stampWith, user;
3139
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
3140
- while (1) switch (_context65.prev = _context65.next) {
3200
+ var _ref66 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee67(params) {
3201
+ var _ref67, stampWith, user;
3202
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
3203
+ while (1) switch (_context67.prev = _context67.next) {
3141
3204
  case 0:
3142
- _ref65 = params || {}, stampWith = _ref65.stampWith;
3205
+ if (masterConfig !== null && masterConfig !== void 0 && masterConfig.autoRefreshManagedState) {
3206
+ _context67.next = 2;
3207
+ break;
3208
+ }
3209
+ return _context67.abrupt("return");
3210
+ case 2:
3211
+ _ref67 = params || {}, stampWith = _ref67.stampWith;
3143
3212
  if (client) {
3144
- _context65.next = 3;
3213
+ _context67.next = 5;
3145
3214
  break;
3146
3215
  }
3147
3216
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3148
- case 3:
3149
- _context65.next = 5;
3217
+ case 5:
3218
+ _context67.next = 7;
3150
3219
  return withTurnkeyErrorHandling(function () {
3151
3220
  return fetchUser({
3152
3221
  stampWith: stampWith
3153
3222
  });
3154
3223
  }, callbacks, "Failed to refresh user");
3155
- case 5:
3156
- user = _context65.sent;
3224
+ case 7:
3225
+ user = _context67.sent;
3157
3226
  if (user) {
3158
3227
  setUser(user);
3159
3228
  }
3160
- case 7:
3229
+ case 9:
3161
3230
  case "end":
3162
- return _context65.stop();
3231
+ return _context67.stop();
3163
3232
  }
3164
- }, _callee65);
3233
+ }, _callee67);
3165
3234
  }));
3166
- return function (_x54) {
3167
- return _ref64.apply(this, arguments);
3235
+ return function (_x56) {
3236
+ return _ref66.apply(this, arguments);
3168
3237
  };
3169
- }(), [client, callbacks]);
3238
+ }(), [client, callbacks, fetchUser, masterConfig, session, user]);
3170
3239
  var refreshWallets = useCallback(/*#__PURE__*/function () {
3171
- var _ref66 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee66(params) {
3172
- var _ref67, stampWith, walletProviders, wallets;
3173
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
3174
- while (1) switch (_context66.prev = _context66.next) {
3240
+ var _ref68 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
3241
+ var _ref69, stampWith, walletProviders, wallets;
3242
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
3243
+ while (1) switch (_context68.prev = _context68.next) {
3175
3244
  case 0:
3176
- _ref67 = params || {}, stampWith = _ref67.stampWith;
3245
+ if (masterConfig !== null && masterConfig !== void 0 && masterConfig.autoRefreshManagedState) {
3246
+ _context68.next = 2;
3247
+ break;
3248
+ }
3249
+ return _context68.abrupt("return");
3250
+ case 2:
3251
+ _ref69 = params || {}, stampWith = _ref69.stampWith;
3177
3252
  if (client) {
3178
- _context66.next = 3;
3253
+ _context68.next = 5;
3179
3254
  break;
3180
3255
  }
3181
3256
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3182
- case 3:
3183
- _context66.next = 5;
3257
+ case 5:
3258
+ _context68.next = 7;
3184
3259
  return withTurnkeyErrorHandling(function () {
3185
- return getWalletProviders();
3260
+ return fetchWalletProviders();
3186
3261
  }, callbacks, "Failed to refresh wallets");
3187
- case 5:
3188
- walletProviders = _context66.sent;
3189
- _context66.next = 8;
3262
+ case 7:
3263
+ walletProviders = _context68.sent;
3264
+ _context68.next = 10;
3190
3265
  return withTurnkeyErrorHandling(function () {
3191
3266
  return fetchWallets({
3192
3267
  stampWith: stampWith,
3193
3268
  walletProviders: walletProviders
3194
3269
  });
3195
3270
  }, callbacks, "Failed to refresh wallets");
3196
- case 8:
3197
- wallets = _context66.sent;
3271
+ case 10:
3272
+ wallets = _context68.sent;
3198
3273
  if (wallets) {
3199
3274
  setWallets(wallets);
3200
3275
  }
3201
- case 10:
3276
+ case 12:
3202
3277
  case "end":
3203
- return _context66.stop();
3278
+ return _context68.stop();
3204
3279
  }
3205
- }, _callee66);
3280
+ }, _callee68);
3206
3281
  }));
3207
- return function (_x55) {
3208
- return _ref66.apply(this, arguments);
3282
+ return function (_x57) {
3283
+ return _ref68.apply(this, arguments);
3209
3284
  };
3210
- }(), [client, callbacks, getWalletProviders, fetchWallets]);
3285
+ }(), [client, callbacks, fetchWalletProviders, fetchWallets, masterConfig, session, user]);
3211
3286
  var handleDiscordOauth = useCallback(/*#__PURE__*/function () {
3212
- var _ref68 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee67(params) {
3287
+ var _ref70 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee69(params) {
3213
3288
  var _masterConfig$auth18, _masterConfig$auth18$, _masterConfig$auth$oa2, _masterConfig$auth19, _masterConfig$auth19$;
3214
- var _ref69, _ref69$clientId, clientId, _ref69$openInPage, openInPage, additionalParameters, _masterConfig$auth20, _masterConfig$auth20$, _masterConfig$auth21, flow, redirectURI, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, discordAuthUrl, extra, width, height, left, top, authWindow;
3215
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
3216
- while (1) switch (_context67.prev = _context67.next) {
3289
+ var _ref71, _ref71$clientId, clientId, _ref71$openInPage, openInPage, additionalParameters, _masterConfig$auth20, _masterConfig$auth20$, _masterConfig$auth21, flow, redirectURI, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, discordAuthUrl, extra, width, height, left, top, authWindow;
3290
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
3291
+ while (1) switch (_context69.prev = _context69.next) {
3217
3292
  case 0:
3218
- _ref69 = params || {}, _ref69$clientId = _ref69.clientId, clientId = _ref69$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth18 = masterConfig.auth) === null || _masterConfig$auth18 === void 0 ? void 0 : (_masterConfig$auth18$ = _masterConfig$auth18.oauthConfig) === null || _masterConfig$auth18$ === void 0 ? void 0 : _masterConfig$auth18$.discordClientId : _ref69$clientId, _ref69$openInPage = _ref69.openInPage, openInPage = _ref69$openInPage === void 0 ? (_masterConfig$auth$oa2 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth19 = masterConfig.auth) === null || _masterConfig$auth19 === void 0 ? void 0 : (_masterConfig$auth19$ = _masterConfig$auth19.oauthConfig) === null || _masterConfig$auth19$ === void 0 ? void 0 : _masterConfig$auth19$.openOauthInPage) !== null && _masterConfig$auth$oa2 !== void 0 ? _masterConfig$auth$oa2 : false : _ref69$openInPage, additionalParameters = _ref69.additionalState;
3219
- _context67.prev = 1;
3293
+ _ref71 = params || {}, _ref71$clientId = _ref71.clientId, clientId = _ref71$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth18 = masterConfig.auth) === null || _masterConfig$auth18 === void 0 ? void 0 : (_masterConfig$auth18$ = _masterConfig$auth18.oauthConfig) === null || _masterConfig$auth18$ === void 0 ? void 0 : _masterConfig$auth18$.discordClientId : _ref71$clientId, _ref71$openInPage = _ref71.openInPage, openInPage = _ref71$openInPage === void 0 ? (_masterConfig$auth$oa2 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth19 = masterConfig.auth) === null || _masterConfig$auth19 === void 0 ? void 0 : (_masterConfig$auth19$ = _masterConfig$auth19.oauthConfig) === null || _masterConfig$auth19$ === void 0 ? void 0 : _masterConfig$auth19$.openOauthInPage) !== null && _masterConfig$auth$oa2 !== void 0 ? _masterConfig$auth$oa2 : false : _ref71$openInPage, additionalParameters = _ref71.additionalState;
3294
+ _context69.prev = 1;
3220
3295
  if (masterConfig) {
3221
- _context67.next = 4;
3296
+ _context69.next = 4;
3222
3297
  break;
3223
3298
  }
3224
3299
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3225
3300
  case 4:
3226
3301
  if (clientId) {
3227
- _context67.next = 6;
3302
+ _context69.next = 6;
3228
3303
  break;
3229
3304
  }
3230
3305
  throw new TurnkeyError("Discord Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3231
3306
  case 6:
3232
3307
  if ((_masterConfig$auth20 = masterConfig.auth) !== null && _masterConfig$auth20 !== void 0 && (_masterConfig$auth20$ = _masterConfig$auth20.oauthConfig) !== null && _masterConfig$auth20$ !== void 0 && _masterConfig$auth20$.oauthRedirectUri) {
3233
- _context67.next = 8;
3308
+ _context69.next = 8;
3234
3309
  break;
3235
3310
  }
3236
3311
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3237
3312
  case 8:
3238
3313
  flow = openInPage ? "redirect" : "popup";
3239
3314
  redirectURI = (_masterConfig$auth21 = masterConfig.auth) === null || _masterConfig$auth21 === void 0 ? void 0 : _masterConfig$auth21.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3240
- _context67.next = 12;
3315
+ _context69.next = 12;
3241
3316
  return createApiKeyPair();
3242
3317
  case 12:
3243
- publicKey = _context67.sent;
3318
+ publicKey = _context69.sent;
3244
3319
  if (publicKey) {
3245
- _context67.next = 15;
3320
+ _context69.next = 15;
3246
3321
  break;
3247
3322
  }
3248
3323
  throw new Error("Failed to create public key for OAuth.");
3249
3324
  case 15:
3250
3325
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
3251
- _context67.next = 18;
3326
+ _context69.next = 18;
3252
3327
  return generateChallengePair();
3253
3328
  case 18:
3254
- _yield$generateChalle = _context67.sent;
3329
+ _yield$generateChalle = _context69.sent;
3255
3330
  verifier = _yield$generateChalle.verifier;
3256
3331
  codeChallenge = _yield$generateChalle.codeChallenge;
3257
3332
  sessionStorage.setItem("discord_verifier", verifier);
@@ -3265,10 +3340,10 @@ var ClientProvider = function ClientProvider(_ref) {
3265
3340
  discordAuthUrl.searchParams.set("scope", "identify email");
3266
3341
  discordAuthUrl.searchParams.set("state", "provider=discord&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey), "&nonce=").concat(nonce));
3267
3342
  if (additionalParameters) {
3268
- extra = Object.entries(additionalParameters).map(function (_ref70) {
3269
- var _ref71 = _slicedToArray(_ref70, 2),
3270
- k = _ref71[0],
3271
- v = _ref71[1];
3343
+ extra = Object.entries(additionalParameters).map(function (_ref72) {
3344
+ var _ref73 = _slicedToArray(_ref72, 2),
3345
+ k = _ref73[0],
3346
+ v = _ref73[1];
3272
3347
  return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(v));
3273
3348
  }).join("&");
3274
3349
  if (extra) {
@@ -3276,11 +3351,11 @@ var ClientProvider = function ClientProvider(_ref) {
3276
3351
  }
3277
3352
  }
3278
3353
  if (!openInPage) {
3279
- _context67.next = 36;
3354
+ _context69.next = 36;
3280
3355
  break;
3281
3356
  }
3282
3357
  window.location.href = discordAuthUrl.toString();
3283
- return _context67.abrupt("return", new Promise(function (_, reject) {
3358
+ return _context69.abrupt("return", new Promise(function (_, reject) {
3284
3359
  var timeout = setTimeout(function () {
3285
3360
  reject(new Error("Authentication timed out."));
3286
3361
  }, 300000);
@@ -3295,13 +3370,13 @@ var ClientProvider = function ClientProvider(_ref) {
3295
3370
  top = window.screenY + (window.innerHeight - height) / 2;
3296
3371
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3297
3372
  if (authWindow) {
3298
- _context67.next = 43;
3373
+ _context69.next = 43;
3299
3374
  break;
3300
3375
  }
3301
3376
  throw new Error("Failed to open Discord login window.");
3302
3377
  case 43:
3303
3378
  authWindow.location.href = discordAuthUrl.toString();
3304
- return _context67.abrupt("return", new Promise(function (resolve, reject) {
3379
+ return _context69.abrupt("return", new Promise(function (resolve, reject) {
3305
3380
  var interval = setInterval(function () {
3306
3381
  try {
3307
3382
  if (authWindow.closed) {
@@ -3331,6 +3406,7 @@ var ClientProvider = function ClientProvider(_ref) {
3331
3406
  authCode: authCode,
3332
3407
  redirectUri: redirectURI,
3333
3408
  codeVerifier: _verifier2,
3409
+ clientId: clientId,
3334
3410
  nonce: nonce
3335
3411
  }).then(function (resp) {
3336
3412
  sessionStorage.removeItem("discord_verifier");
@@ -3374,66 +3450,66 @@ var ClientProvider = function ClientProvider(_ref) {
3374
3450
  }
3375
3451
  }));
3376
3452
  case 45:
3377
- _context67.next = 50;
3453
+ _context69.next = 50;
3378
3454
  break;
3379
3455
  case 47:
3380
- _context67.prev = 47;
3381
- _context67.t0 = _context67["catch"](1);
3382
- throw _context67.t0;
3456
+ _context69.prev = 47;
3457
+ _context69.t0 = _context69["catch"](1);
3458
+ throw _context69.t0;
3383
3459
  case 50:
3384
3460
  case "end":
3385
- return _context67.stop();
3461
+ return _context69.stop();
3386
3462
  }
3387
- }, _callee67, null, [[1, 47]]);
3463
+ }, _callee69, null, [[1, 47]]);
3388
3464
  }));
3389
- return function (_x56) {
3390
- return _ref68.apply(this, arguments);
3465
+ return function (_x58) {
3466
+ return _ref70.apply(this, arguments);
3391
3467
  };
3392
- }(), [client, callbacks]);
3468
+ }(), [client, callbacks, completeOauth, createApiKeyPair, masterConfig, session, user]);
3393
3469
  var handleXOauth = useCallback(/*#__PURE__*/function () {
3394
- var _ref72 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
3470
+ var _ref74 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
3395
3471
  var _masterConfig$auth22, _masterConfig$auth22$, _masterConfig$auth$oa3, _masterConfig$auth23, _masterConfig$auth23$;
3396
- var _ref73, _ref73$clientId, clientId, _ref73$openInPage, openInPage, additionalParameters, _masterConfig$auth24, _masterConfig$auth24$, _masterConfig$auth25, flow, redirectURI, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, twitterAuthUrl, extra, width, height, left, top, authWindow;
3397
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
3398
- while (1) switch (_context68.prev = _context68.next) {
3472
+ var _ref75, _ref75$clientId, clientId, _ref75$openInPage, openInPage, additionalParameters, _masterConfig$auth24, _masterConfig$auth24$, _masterConfig$auth25, flow, redirectURI, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, twitterAuthUrl, extra, width, height, left, top, authWindow;
3473
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
3474
+ while (1) switch (_context70.prev = _context70.next) {
3399
3475
  case 0:
3400
- _ref73 = params || {}, _ref73$clientId = _ref73.clientId, clientId = _ref73$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth22 = masterConfig.auth) === null || _masterConfig$auth22 === void 0 ? void 0 : (_masterConfig$auth22$ = _masterConfig$auth22.oauthConfig) === null || _masterConfig$auth22$ === void 0 ? void 0 : _masterConfig$auth22$.xClientId : _ref73$clientId, _ref73$openInPage = _ref73.openInPage, openInPage = _ref73$openInPage === void 0 ? (_masterConfig$auth$oa3 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth23 = masterConfig.auth) === null || _masterConfig$auth23 === void 0 ? void 0 : (_masterConfig$auth23$ = _masterConfig$auth23.oauthConfig) === null || _masterConfig$auth23$ === void 0 ? void 0 : _masterConfig$auth23$.openOauthInPage) !== null && _masterConfig$auth$oa3 !== void 0 ? _masterConfig$auth$oa3 : false : _ref73$openInPage, additionalParameters = _ref73.additionalState;
3401
- _context68.prev = 1;
3476
+ _ref75 = params || {}, _ref75$clientId = _ref75.clientId, clientId = _ref75$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth22 = masterConfig.auth) === null || _masterConfig$auth22 === void 0 ? void 0 : (_masterConfig$auth22$ = _masterConfig$auth22.oauthConfig) === null || _masterConfig$auth22$ === void 0 ? void 0 : _masterConfig$auth22$.xClientId : _ref75$clientId, _ref75$openInPage = _ref75.openInPage, openInPage = _ref75$openInPage === void 0 ? (_masterConfig$auth$oa3 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth23 = masterConfig.auth) === null || _masterConfig$auth23 === void 0 ? void 0 : (_masterConfig$auth23$ = _masterConfig$auth23.oauthConfig) === null || _masterConfig$auth23$ === void 0 ? void 0 : _masterConfig$auth23$.openOauthInPage) !== null && _masterConfig$auth$oa3 !== void 0 ? _masterConfig$auth$oa3 : false : _ref75$openInPage, additionalParameters = _ref75.additionalState;
3477
+ _context70.prev = 1;
3402
3478
  if (masterConfig) {
3403
- _context68.next = 4;
3479
+ _context70.next = 4;
3404
3480
  break;
3405
3481
  }
3406
3482
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3407
3483
  case 4:
3408
3484
  if (clientId) {
3409
- _context68.next = 6;
3485
+ _context70.next = 6;
3410
3486
  break;
3411
3487
  }
3412
3488
  throw new TurnkeyError("Twitter Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3413
3489
  case 6:
3414
3490
  if ((_masterConfig$auth24 = masterConfig.auth) !== null && _masterConfig$auth24 !== void 0 && (_masterConfig$auth24$ = _masterConfig$auth24.oauthConfig) !== null && _masterConfig$auth24$ !== void 0 && _masterConfig$auth24$.oauthRedirectUri) {
3415
- _context68.next = 8;
3491
+ _context70.next = 8;
3416
3492
  break;
3417
3493
  }
3418
3494
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3419
3495
  case 8:
3420
3496
  flow = openInPage ? "redirect" : "popup";
3421
3497
  redirectURI = (_masterConfig$auth25 = masterConfig.auth) === null || _masterConfig$auth25 === void 0 ? void 0 : _masterConfig$auth25.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3422
- _context68.next = 12;
3498
+ _context70.next = 12;
3423
3499
  return createApiKeyPair();
3424
3500
  case 12:
3425
- publicKey = _context68.sent;
3501
+ publicKey = _context70.sent;
3426
3502
  if (publicKey) {
3427
- _context68.next = 15;
3503
+ _context70.next = 15;
3428
3504
  break;
3429
3505
  }
3430
3506
  throw new Error("Failed to create public key for OAuth.");
3431
3507
  case 15:
3432
3508
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
3433
- _context68.next = 18;
3509
+ _context70.next = 18;
3434
3510
  return generateChallengePair();
3435
3511
  case 18:
3436
- _yield$generateChalle2 = _context68.sent;
3512
+ _yield$generateChalle2 = _context70.sent;
3437
3513
  verifier = _yield$generateChalle2.verifier;
3438
3514
  codeChallenge = _yield$generateChalle2.codeChallenge;
3439
3515
  sessionStorage.setItem("twitter_verifier", verifier);
@@ -3447,10 +3523,10 @@ var ClientProvider = function ClientProvider(_ref) {
3447
3523
  twitterAuthUrl.searchParams.set("scope", "tweet.read users.read");
3448
3524
  twitterAuthUrl.searchParams.set("state", "provider=twitter&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey), "&nonce=").concat(nonce));
3449
3525
  if (additionalParameters) {
3450
- extra = Object.entries(additionalParameters).map(function (_ref74) {
3451
- var _ref75 = _slicedToArray(_ref74, 2),
3452
- k = _ref75[0],
3453
- v = _ref75[1];
3526
+ extra = Object.entries(additionalParameters).map(function (_ref76) {
3527
+ var _ref77 = _slicedToArray(_ref76, 2),
3528
+ k = _ref77[0],
3529
+ v = _ref77[1];
3454
3530
  return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(v));
3455
3531
  }).join("&");
3456
3532
  if (extra) {
@@ -3458,11 +3534,11 @@ var ClientProvider = function ClientProvider(_ref) {
3458
3534
  }
3459
3535
  }
3460
3536
  if (!openInPage) {
3461
- _context68.next = 36;
3537
+ _context70.next = 36;
3462
3538
  break;
3463
3539
  }
3464
3540
  window.location.href = twitterAuthUrl.toString();
3465
- return _context68.abrupt("return", new Promise(function (_, reject) {
3541
+ return _context70.abrupt("return", new Promise(function (_, reject) {
3466
3542
  var timeout = setTimeout(function () {
3467
3543
  reject(new Error("Authentication timed out."));
3468
3544
  }, 300000);
@@ -3477,13 +3553,13 @@ var ClientProvider = function ClientProvider(_ref) {
3477
3553
  top = window.screenY + (window.innerHeight - height) / 2;
3478
3554
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3479
3555
  if (authWindow) {
3480
- _context68.next = 43;
3556
+ _context70.next = 43;
3481
3557
  break;
3482
3558
  }
3483
3559
  throw new Error("Failed to open Twitter login window.");
3484
3560
  case 43:
3485
3561
  authWindow.location.href = twitterAuthUrl.toString();
3486
- return _context68.abrupt("return", new Promise(function (resolve, reject) {
3562
+ return _context70.abrupt("return", new Promise(function (resolve, reject) {
3487
3563
  var interval = setInterval(function () {
3488
3564
  try {
3489
3565
  if (authWindow.closed) {
@@ -3513,6 +3589,7 @@ var ClientProvider = function ClientProvider(_ref) {
3513
3589
  authCode: authCode,
3514
3590
  redirectUri: redirectURI,
3515
3591
  codeVerifier: _verifier3,
3592
+ clientId: clientId,
3516
3593
  nonce: nonce
3517
3594
  }).then(function (resp) {
3518
3595
  sessionStorage.removeItem("twitter_verifier");
@@ -3556,57 +3633,57 @@ var ClientProvider = function ClientProvider(_ref) {
3556
3633
  }
3557
3634
  }));
3558
3635
  case 45:
3559
- _context68.next = 50;
3636
+ _context70.next = 50;
3560
3637
  break;
3561
3638
  case 47:
3562
- _context68.prev = 47;
3563
- _context68.t0 = _context68["catch"](1);
3564
- throw _context68.t0;
3639
+ _context70.prev = 47;
3640
+ _context70.t0 = _context70["catch"](1);
3641
+ throw _context70.t0;
3565
3642
  case 50:
3566
3643
  case "end":
3567
- return _context68.stop();
3644
+ return _context70.stop();
3568
3645
  }
3569
- }, _callee68, null, [[1, 47]]);
3646
+ }, _callee70, null, [[1, 47]]);
3570
3647
  }));
3571
- return function (_x57) {
3572
- return _ref72.apply(this, arguments);
3648
+ return function (_x59) {
3649
+ return _ref74.apply(this, arguments);
3573
3650
  };
3574
- }(), [client, callbacks]);
3651
+ }(), [client, callbacks, masterConfig, session, user]);
3575
3652
  var handleGoogleOauth = useCallback(/*#__PURE__*/function () {
3576
- var _ref76 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee69(params) {
3653
+ var _ref78 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
3577
3654
  var _masterConfig$auth26, _masterConfig$auth26$, _masterConfig$auth$oa4, _masterConfig$auth27, _masterConfig$auth27$;
3578
- var _ref77, _ref77$clientId, clientId, _ref77$openInPage, openInPage, additionalParameters, _masterConfig$auth28, _masterConfig$auth28$, _masterConfig$auth29, flow, redirectURI, publicKey, nonce, googleAuthUrl, state, additionalState, width, height, left, top, authWindow;
3579
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
3580
- while (1) switch (_context69.prev = _context69.next) {
3655
+ var _ref79, _ref79$clientId, clientId, _ref79$openInPage, openInPage, additionalParameters, _masterConfig$auth28, _masterConfig$auth28$, _masterConfig$auth29, flow, redirectURI, publicKey, nonce, googleAuthUrl, state, additionalState, width, height, left, top, authWindow;
3656
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
3657
+ while (1) switch (_context71.prev = _context71.next) {
3581
3658
  case 0:
3582
- _ref77 = params || {}, _ref77$clientId = _ref77.clientId, clientId = _ref77$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth26 = masterConfig.auth) === null || _masterConfig$auth26 === void 0 ? void 0 : (_masterConfig$auth26$ = _masterConfig$auth26.oauthConfig) === null || _masterConfig$auth26$ === void 0 ? void 0 : _masterConfig$auth26$.googleClientId : _ref77$clientId, _ref77$openInPage = _ref77.openInPage, openInPage = _ref77$openInPage === void 0 ? (_masterConfig$auth$oa4 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth27 = masterConfig.auth) === null || _masterConfig$auth27 === void 0 ? void 0 : (_masterConfig$auth27$ = _masterConfig$auth27.oauthConfig) === null || _masterConfig$auth27$ === void 0 ? void 0 : _masterConfig$auth27$.openOauthInPage) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : false : _ref77$openInPage, additionalParameters = _ref77.additionalState;
3583
- _context69.prev = 1;
3659
+ _ref79 = params || {}, _ref79$clientId = _ref79.clientId, clientId = _ref79$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth26 = masterConfig.auth) === null || _masterConfig$auth26 === void 0 ? void 0 : (_masterConfig$auth26$ = _masterConfig$auth26.oauthConfig) === null || _masterConfig$auth26$ === void 0 ? void 0 : _masterConfig$auth26$.googleClientId : _ref79$clientId, _ref79$openInPage = _ref79.openInPage, openInPage = _ref79$openInPage === void 0 ? (_masterConfig$auth$oa4 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth27 = masterConfig.auth) === null || _masterConfig$auth27 === void 0 ? void 0 : (_masterConfig$auth27$ = _masterConfig$auth27.oauthConfig) === null || _masterConfig$auth27$ === void 0 ? void 0 : _masterConfig$auth27$.openOauthInPage) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : false : _ref79$openInPage, additionalParameters = _ref79.additionalState;
3660
+ _context71.prev = 1;
3584
3661
  if (masterConfig) {
3585
- _context69.next = 4;
3662
+ _context71.next = 4;
3586
3663
  break;
3587
3664
  }
3588
3665
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3589
3666
  case 4:
3590
3667
  if (clientId) {
3591
- _context69.next = 6;
3668
+ _context71.next = 6;
3592
3669
  break;
3593
3670
  }
3594
3671
  throw new TurnkeyError("Google Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3595
3672
  case 6:
3596
3673
  if ((_masterConfig$auth28 = masterConfig.auth) !== null && _masterConfig$auth28 !== void 0 && (_masterConfig$auth28$ = _masterConfig$auth28.oauthConfig) !== null && _masterConfig$auth28$ !== void 0 && _masterConfig$auth28$.oauthRedirectUri) {
3597
- _context69.next = 8;
3674
+ _context71.next = 8;
3598
3675
  break;
3599
3676
  }
3600
3677
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3601
3678
  case 8:
3602
3679
  flow = openInPage ? "redirect" : "popup";
3603
3680
  redirectURI = (_masterConfig$auth29 = masterConfig.auth) === null || _masterConfig$auth29 === void 0 ? void 0 : _masterConfig$auth29.oauthConfig.oauthRedirectUri.replace(/\/$/, ""); // Create key pair and generate nonce
3604
- _context69.next = 12;
3681
+ _context71.next = 12;
3605
3682
  return createApiKeyPair();
3606
3683
  case 12:
3607
- publicKey = _context69.sent;
3684
+ publicKey = _context71.sent;
3608
3685
  if (publicKey) {
3609
- _context69.next = 15;
3686
+ _context71.next = 15;
3610
3687
  break;
3611
3688
  }
3612
3689
  throw new Error("Failed to create public key for OAuth.");
@@ -3622,10 +3699,10 @@ var ClientProvider = function ClientProvider(_ref) {
3622
3699
  // Create state parameter
3623
3700
  state = "provider=google&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
3624
3701
  if (additionalParameters) {
3625
- additionalState = Object.entries(additionalParameters).map(function (_ref78) {
3626
- var _ref79 = _slicedToArray(_ref78, 2),
3627
- key = _ref79[0],
3628
- value = _ref79[1];
3702
+ additionalState = Object.entries(additionalParameters).map(function (_ref80) {
3703
+ var _ref81 = _slicedToArray(_ref80, 2),
3704
+ key = _ref81[0],
3705
+ value = _ref81[1];
3629
3706
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
3630
3707
  }).join("&");
3631
3708
  if (additionalState) {
@@ -3634,12 +3711,12 @@ var ClientProvider = function ClientProvider(_ref) {
3634
3711
  }
3635
3712
  googleAuthUrl.searchParams.set("state", state);
3636
3713
  if (!openInPage) {
3637
- _context69.next = 31;
3714
+ _context71.next = 31;
3638
3715
  break;
3639
3716
  }
3640
3717
  // Redirect current page to Google Auth
3641
3718
  window.location.href = googleAuthUrl.toString();
3642
- return _context69.abrupt("return", new Promise(function (_, reject) {
3719
+ return _context71.abrupt("return", new Promise(function (_, reject) {
3643
3720
  // By here, the page should have already redirected. We wait here since the function is async.
3644
3721
  // We want any function that runs this to simply wait until the page redirects.
3645
3722
  // A 5 min timeout is set just in case, idk
@@ -3659,7 +3736,7 @@ var ClientProvider = function ClientProvider(_ref) {
3659
3736
  top = window.screenY + (window.innerHeight - height) / 2;
3660
3737
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3661
3738
  if (authWindow) {
3662
- _context69.next = 38;
3739
+ _context71.next = 38;
3663
3740
  break;
3664
3741
  }
3665
3742
  throw new Error("Failed to open Google login window.");
@@ -3667,7 +3744,7 @@ var ClientProvider = function ClientProvider(_ref) {
3667
3744
  authWindow.location.href = googleAuthUrl.toString();
3668
3745
  // Return a promise that resolves when the OAuth flow completes
3669
3746
  // This following code will only run for the popup flow
3670
- return _context69.abrupt("return", new Promise(function (resolve, reject) {
3747
+ return _context71.abrupt("return", new Promise(function (resolve, reject) {
3671
3748
  var interval = setInterval(function () {
3672
3749
  try {
3673
3750
  // Check if window was closed without completing auth
@@ -3726,45 +3803,45 @@ var ClientProvider = function ClientProvider(_ref) {
3726
3803
  }
3727
3804
  }));
3728
3805
  case 40:
3729
- _context69.next = 45;
3806
+ _context71.next = 45;
3730
3807
  break;
3731
3808
  case 42:
3732
- _context69.prev = 42;
3733
- _context69.t0 = _context69["catch"](1);
3734
- throw _context69.t0;
3809
+ _context71.prev = 42;
3810
+ _context71.t0 = _context71["catch"](1);
3811
+ throw _context71.t0;
3735
3812
  case 45:
3736
3813
  case "end":
3737
- return _context69.stop();
3814
+ return _context71.stop();
3738
3815
  }
3739
- }, _callee69, null, [[1, 42]]);
3816
+ }, _callee71, null, [[1, 42]]);
3740
3817
  }));
3741
- return function (_x58) {
3742
- return _ref76.apply(this, arguments);
3818
+ return function (_x60) {
3819
+ return _ref78.apply(this, arguments);
3743
3820
  };
3744
- }(), [client, callbacks]);
3821
+ }(), [client, callbacks, masterConfig, session, user]);
3745
3822
  var handleAppleOauth = useCallback(/*#__PURE__*/function () {
3746
- var _ref80 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
3823
+ var _ref82 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee72(params) {
3747
3824
  var _masterConfig$auth30, _masterConfig$auth30$, _masterConfig$auth$oa5, _masterConfig$auth31, _masterConfig$auth31$;
3748
- var _ref81, _ref81$clientId, clientId, _ref81$openInPage, openInPage, additionalParameters, _masterConfig$auth32, _masterConfig$auth32$, _masterConfig$auth33, flow, redirectURI, publicKey, nonce, appleAuthUrl, state, additionalState, width, height, left, top, authWindow;
3749
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
3750
- while (1) switch (_context70.prev = _context70.next) {
3825
+ var _ref83, _ref83$clientId, clientId, _ref83$openInPage, openInPage, additionalParameters, _masterConfig$auth32, _masterConfig$auth32$, _masterConfig$auth33, flow, redirectURI, publicKey, nonce, appleAuthUrl, state, additionalState, width, height, left, top, authWindow;
3826
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
3827
+ while (1) switch (_context72.prev = _context72.next) {
3751
3828
  case 0:
3752
- _ref81 = params || {}, _ref81$clientId = _ref81.clientId, clientId = _ref81$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth30 = masterConfig.auth) === null || _masterConfig$auth30 === void 0 ? void 0 : (_masterConfig$auth30$ = _masterConfig$auth30.oauthConfig) === null || _masterConfig$auth30$ === void 0 ? void 0 : _masterConfig$auth30$.appleClientId : _ref81$clientId, _ref81$openInPage = _ref81.openInPage, openInPage = _ref81$openInPage === void 0 ? (_masterConfig$auth$oa5 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth31 = masterConfig.auth) === null || _masterConfig$auth31 === void 0 ? void 0 : (_masterConfig$auth31$ = _masterConfig$auth31.oauthConfig) === null || _masterConfig$auth31$ === void 0 ? void 0 : _masterConfig$auth31$.openOauthInPage) !== null && _masterConfig$auth$oa5 !== void 0 ? _masterConfig$auth$oa5 : false : _ref81$openInPage, additionalParameters = _ref81.additionalState;
3753
- _context70.prev = 1;
3829
+ _ref83 = params || {}, _ref83$clientId = _ref83.clientId, clientId = _ref83$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth30 = masterConfig.auth) === null || _masterConfig$auth30 === void 0 ? void 0 : (_masterConfig$auth30$ = _masterConfig$auth30.oauthConfig) === null || _masterConfig$auth30$ === void 0 ? void 0 : _masterConfig$auth30$.appleClientId : _ref83$clientId, _ref83$openInPage = _ref83.openInPage, openInPage = _ref83$openInPage === void 0 ? (_masterConfig$auth$oa5 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth31 = masterConfig.auth) === null || _masterConfig$auth31 === void 0 ? void 0 : (_masterConfig$auth31$ = _masterConfig$auth31.oauthConfig) === null || _masterConfig$auth31$ === void 0 ? void 0 : _masterConfig$auth31$.openOauthInPage) !== null && _masterConfig$auth$oa5 !== void 0 ? _masterConfig$auth$oa5 : false : _ref83$openInPage, additionalParameters = _ref83.additionalState;
3830
+ _context72.prev = 1;
3754
3831
  if (masterConfig) {
3755
- _context70.next = 4;
3832
+ _context72.next = 4;
3756
3833
  break;
3757
3834
  }
3758
3835
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3759
3836
  case 4:
3760
3837
  if (clientId) {
3761
- _context70.next = 6;
3838
+ _context72.next = 6;
3762
3839
  break;
3763
3840
  }
3764
3841
  throw new TurnkeyError("Apple Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3765
3842
  case 6:
3766
3843
  if ((_masterConfig$auth32 = masterConfig.auth) !== null && _masterConfig$auth32 !== void 0 && (_masterConfig$auth32$ = _masterConfig$auth32.oauthConfig) !== null && _masterConfig$auth32$ !== void 0 && _masterConfig$auth32$.oauthRedirectUri) {
3767
- _context70.next = 8;
3844
+ _context72.next = 8;
3768
3845
  break;
3769
3846
  }
3770
3847
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
@@ -3772,12 +3849,12 @@ var ClientProvider = function ClientProvider(_ref) {
3772
3849
  flow = openInPage ? "redirect" : "popup";
3773
3850
  redirectURI = (_masterConfig$auth33 = masterConfig.auth) === null || _masterConfig$auth33 === void 0 ? void 0 : _masterConfig$auth33.oauthConfig.oauthRedirectUri; // TODO (Amir): Apple needs the '/' at the end. Maybe we should add it if not there?
3774
3851
  // Create key pair and generate nonce
3775
- _context70.next = 12;
3852
+ _context72.next = 12;
3776
3853
  return createApiKeyPair();
3777
3854
  case 12:
3778
- publicKey = _context70.sent;
3855
+ publicKey = _context72.sent;
3779
3856
  if (publicKey) {
3780
- _context70.next = 15;
3857
+ _context72.next = 15;
3781
3858
  break;
3782
3859
  }
3783
3860
  throw new Error("Failed to create public key for OAuth.");
@@ -3792,10 +3869,10 @@ var ClientProvider = function ClientProvider(_ref) {
3792
3869
  // Create state parameter
3793
3870
  state = "provider=apple&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
3794
3871
  if (additionalParameters) {
3795
- additionalState = Object.entries(additionalParameters).map(function (_ref82) {
3796
- var _ref83 = _slicedToArray(_ref82, 2),
3797
- key = _ref83[0],
3798
- value = _ref83[1];
3872
+ additionalState = Object.entries(additionalParameters).map(function (_ref84) {
3873
+ var _ref85 = _slicedToArray(_ref84, 2),
3874
+ key = _ref85[0],
3875
+ value = _ref85[1];
3799
3876
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
3800
3877
  }).join("&");
3801
3878
  if (additionalState) {
@@ -3804,12 +3881,12 @@ var ClientProvider = function ClientProvider(_ref) {
3804
3881
  }
3805
3882
  appleAuthUrl.searchParams.set("state", state);
3806
3883
  if (!openInPage) {
3807
- _context70.next = 30;
3884
+ _context72.next = 30;
3808
3885
  break;
3809
3886
  }
3810
3887
  // Redirect current page to Apple Auth
3811
3888
  window.location.href = appleAuthUrl.toString();
3812
- return _context70.abrupt("return", new Promise(function (_, reject) {
3889
+ return _context72.abrupt("return", new Promise(function (_, reject) {
3813
3890
  // Set a timeout just in case the redirect doesn't happen
3814
3891
  var timeout = setTimeout(function () {
3815
3892
  reject(new Error("Authentication timed out."));
@@ -3827,14 +3904,14 @@ var ClientProvider = function ClientProvider(_ref) {
3827
3904
  top = window.screenY + (window.innerHeight - height) / 2;
3828
3905
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3829
3906
  if (authWindow) {
3830
- _context70.next = 37;
3907
+ _context72.next = 37;
3831
3908
  break;
3832
3909
  }
3833
3910
  throw new Error("Failed to open Apple login window.");
3834
3911
  case 37:
3835
3912
  authWindow.location.href = appleAuthUrl.toString();
3836
3913
  // Return a promise that resolves when the OAuth flow completes
3837
- return _context70.abrupt("return", new Promise(function (resolve, reject) {
3914
+ return _context72.abrupt("return", new Promise(function (resolve, reject) {
3838
3915
  var interval = setInterval(function () {
3839
3916
  try {
3840
3917
  // Check if window was closed without completing auth
@@ -3893,66 +3970,66 @@ var ClientProvider = function ClientProvider(_ref) {
3893
3970
  }
3894
3971
  }));
3895
3972
  case 39:
3896
- _context70.next = 44;
3973
+ _context72.next = 44;
3897
3974
  break;
3898
3975
  case 41:
3899
- _context70.prev = 41;
3900
- _context70.t0 = _context70["catch"](1);
3901
- throw _context70.t0;
3976
+ _context72.prev = 41;
3977
+ _context72.t0 = _context72["catch"](1);
3978
+ throw _context72.t0;
3902
3979
  case 44:
3903
3980
  case "end":
3904
- return _context70.stop();
3981
+ return _context72.stop();
3905
3982
  }
3906
- }, _callee70, null, [[1, 41]]);
3983
+ }, _callee72, null, [[1, 41]]);
3907
3984
  }));
3908
- return function (_x59) {
3909
- return _ref80.apply(this, arguments);
3985
+ return function (_x61) {
3986
+ return _ref82.apply(this, arguments);
3910
3987
  };
3911
- }(), [client, callbacks]);
3988
+ }(), [client, callbacks, masterConfig, session, user]);
3912
3989
  var handleFacebookOauth = useCallback(/*#__PURE__*/function () {
3913
- var _ref84 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
3990
+ var _ref86 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee73(params) {
3914
3991
  var _masterConfig$auth34, _masterConfig$auth34$, _masterConfig$auth$oa6, _masterConfig$auth35, _masterConfig$auth35$;
3915
- var _ref85, _ref85$clientId, clientId, _ref85$openInPage, openInPage, additionalParameters, _masterConfig$auth36, _masterConfig$auth36$, _masterConfig$auth37, flow, redirectURI, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, facebookAuthUrl, state, additionalState, width, height, left, top, authWindow;
3916
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
3917
- while (1) switch (_context71.prev = _context71.next) {
3992
+ var _ref87, _ref87$clientId, clientId, _ref87$openInPage, openInPage, additionalParameters, _masterConfig$auth36, _masterConfig$auth36$, _masterConfig$auth37, flow, redirectURI, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, facebookAuthUrl, state, additionalState, width, height, left, top, authWindow;
3993
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
3994
+ while (1) switch (_context73.prev = _context73.next) {
3918
3995
  case 0:
3919
- _ref85 = params || {}, _ref85$clientId = _ref85.clientId, clientId = _ref85$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth34 = masterConfig.auth) === null || _masterConfig$auth34 === void 0 ? void 0 : (_masterConfig$auth34$ = _masterConfig$auth34.oauthConfig) === null || _masterConfig$auth34$ === void 0 ? void 0 : _masterConfig$auth34$.facebookClientId : _ref85$clientId, _ref85$openInPage = _ref85.openInPage, openInPage = _ref85$openInPage === void 0 ? (_masterConfig$auth$oa6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth35 = masterConfig.auth) === null || _masterConfig$auth35 === void 0 ? void 0 : (_masterConfig$auth35$ = _masterConfig$auth35.oauthConfig) === null || _masterConfig$auth35$ === void 0 ? void 0 : _masterConfig$auth35$.openOauthInPage) !== null && _masterConfig$auth$oa6 !== void 0 ? _masterConfig$auth$oa6 : false : _ref85$openInPage, additionalParameters = _ref85.additionalState;
3920
- _context71.prev = 1;
3996
+ _ref87 = params || {}, _ref87$clientId = _ref87.clientId, clientId = _ref87$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth34 = masterConfig.auth) === null || _masterConfig$auth34 === void 0 ? void 0 : (_masterConfig$auth34$ = _masterConfig$auth34.oauthConfig) === null || _masterConfig$auth34$ === void 0 ? void 0 : _masterConfig$auth34$.facebookClientId : _ref87$clientId, _ref87$openInPage = _ref87.openInPage, openInPage = _ref87$openInPage === void 0 ? (_masterConfig$auth$oa6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth35 = masterConfig.auth) === null || _masterConfig$auth35 === void 0 ? void 0 : (_masterConfig$auth35$ = _masterConfig$auth35.oauthConfig) === null || _masterConfig$auth35$ === void 0 ? void 0 : _masterConfig$auth35$.openOauthInPage) !== null && _masterConfig$auth$oa6 !== void 0 ? _masterConfig$auth$oa6 : false : _ref87$openInPage, additionalParameters = _ref87.additionalState;
3997
+ _context73.prev = 1;
3921
3998
  if (masterConfig) {
3922
- _context71.next = 4;
3999
+ _context73.next = 4;
3923
4000
  break;
3924
4001
  }
3925
4002
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3926
4003
  case 4:
3927
4004
  if (clientId) {
3928
- _context71.next = 6;
4005
+ _context73.next = 6;
3929
4006
  break;
3930
4007
  }
3931
4008
  throw new TurnkeyError("Facebook Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3932
4009
  case 6:
3933
4010
  if ((_masterConfig$auth36 = masterConfig.auth) !== null && _masterConfig$auth36 !== void 0 && (_masterConfig$auth36$ = _masterConfig$auth36.oauthConfig) !== null && _masterConfig$auth36$ !== void 0 && _masterConfig$auth36$.oauthRedirectUri) {
3934
- _context71.next = 8;
4011
+ _context73.next = 8;
3935
4012
  break;
3936
4013
  }
3937
4014
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3938
4015
  case 8:
3939
4016
  flow = openInPage ? "redirect" : "popup";
3940
4017
  redirectURI = (_masterConfig$auth37 = masterConfig.auth) === null || _masterConfig$auth37 === void 0 ? void 0 : _masterConfig$auth37.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3941
- _context71.next = 12;
4018
+ _context73.next = 12;
3942
4019
  return createApiKeyPair();
3943
4020
  case 12:
3944
- publicKey = _context71.sent;
4021
+ publicKey = _context73.sent;
3945
4022
  if (publicKey) {
3946
- _context71.next = 15;
4023
+ _context73.next = 15;
3947
4024
  break;
3948
4025
  }
3949
4026
  throw new Error("Failed to create public key for OAuth.");
3950
4027
  case 15:
3951
4028
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
3952
- _context71.next = 18;
4029
+ _context73.next = 18;
3953
4030
  return generateChallengePair();
3954
4031
  case 18:
3955
- _yield$generateChalle3 = _context71.sent;
4032
+ _yield$generateChalle3 = _context73.sent;
3956
4033
  verifier = _yield$generateChalle3.verifier;
3957
4034
  codeChallenge = _yield$generateChalle3.codeChallenge;
3958
4035
  // Store verifier for later token exchange
@@ -3969,10 +4046,10 @@ var ClientProvider = function ClientProvider(_ref) {
3969
4046
  // Create state parameter
3970
4047
  state = "provider=facebook&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
3971
4048
  if (additionalParameters) {
3972
- additionalState = Object.entries(additionalParameters).map(function (_ref86) {
3973
- var _ref87 = _slicedToArray(_ref86, 2),
3974
- key = _ref87[0],
3975
- value = _ref87[1];
4049
+ additionalState = Object.entries(additionalParameters).map(function (_ref88) {
4050
+ var _ref89 = _slicedToArray(_ref88, 2),
4051
+ key = _ref89[0],
4052
+ value = _ref89[1];
3976
4053
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
3977
4054
  }).join("&");
3978
4055
  if (additionalState) {
@@ -3981,12 +4058,12 @@ var ClientProvider = function ClientProvider(_ref) {
3981
4058
  }
3982
4059
  facebookAuthUrl.searchParams.set("state", state);
3983
4060
  if (!openInPage) {
3984
- _context71.next = 38;
4061
+ _context73.next = 38;
3985
4062
  break;
3986
4063
  }
3987
4064
  // Redirect current page to Facebook Auth
3988
4065
  window.location.href = facebookAuthUrl.toString();
3989
- return _context71.abrupt("return", new Promise(function (_, reject) {
4066
+ return _context73.abrupt("return", new Promise(function (_, reject) {
3990
4067
  // Set a timeout just in case the redirect doesn't happen
3991
4068
  var timeout = setTimeout(function () {
3992
4069
  reject(new Error("Authentication timed out."));
@@ -4004,14 +4081,14 @@ var ClientProvider = function ClientProvider(_ref) {
4004
4081
  top = window.screenY + (window.innerHeight - height) / 2;
4005
4082
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
4006
4083
  if (authWindow) {
4007
- _context71.next = 45;
4084
+ _context73.next = 45;
4008
4085
  break;
4009
4086
  }
4010
4087
  throw new Error("Failed to open Facebook login window.");
4011
4088
  case 45:
4012
4089
  authWindow.location.href = facebookAuthUrl.toString();
4013
4090
  // Return a promise that resolves when the OAuth flow completes
4014
- return _context71.abrupt("return", new Promise(function (resolve, reject) {
4091
+ return _context73.abrupt("return", new Promise(function (resolve, reject) {
4015
4092
  var interval = setInterval(function () {
4016
4093
  try {
4017
4094
  // Check if window was closed without completing auth
@@ -4079,26 +4156,26 @@ var ClientProvider = function ClientProvider(_ref) {
4079
4156
  }
4080
4157
  }));
4081
4158
  case 47:
4082
- _context71.next = 52;
4159
+ _context73.next = 52;
4083
4160
  break;
4084
4161
  case 49:
4085
- _context71.prev = 49;
4086
- _context71.t0 = _context71["catch"](1);
4087
- throw _context71.t0;
4162
+ _context73.prev = 49;
4163
+ _context73.t0 = _context73["catch"](1);
4164
+ throw _context73.t0;
4088
4165
  case 52:
4089
4166
  case "end":
4090
- return _context71.stop();
4167
+ return _context73.stop();
4091
4168
  }
4092
- }, _callee71, null, [[1, 49]]);
4169
+ }, _callee73, null, [[1, 49]]);
4093
4170
  }));
4094
- return function (_x60) {
4095
- return _ref84.apply(this, arguments);
4171
+ return function (_x62) {
4172
+ return _ref86.apply(this, arguments);
4096
4173
  };
4097
- }(), [client, callbacks]);
4174
+ }(), [client, callbacks, masterConfig, client, session, user]);
4098
4175
  var handleLogin = useCallback(/*#__PURE__*/function () {
4099
- var _ref88 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee72(params) {
4100
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
4101
- while (1) switch (_context72.prev = _context72.next) {
4176
+ var _ref90 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee74(params) {
4177
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
4178
+ while (1) switch (_context74.prev = _context74.next) {
4102
4179
  case 0:
4103
4180
  pushPage({
4104
4181
  key: "Log in or sign up",
@@ -4108,19 +4185,19 @@ var ClientProvider = function ClientProvider(_ref) {
4108
4185
  });
4109
4186
  case 1:
4110
4187
  case "end":
4111
- return _context72.stop();
4188
+ return _context74.stop();
4112
4189
  }
4113
- }, _callee72);
4190
+ }, _callee74);
4114
4191
  }));
4115
- return function (_x61) {
4116
- return _ref88.apply(this, arguments);
4192
+ return function (_x63) {
4193
+ return _ref90.apply(this, arguments);
4117
4194
  };
4118
- }(), [pushPage]);
4195
+ }(), [pushPage, masterConfig, client, session, user]);
4119
4196
  var handleExportWallet = useCallback(/*#__PURE__*/function () {
4120
- var _ref89 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee73(params) {
4197
+ var _ref91 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee75(params) {
4121
4198
  var walletId, targetPublicKey, stampWith;
4122
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
4123
- while (1) switch (_context73.prev = _context73.next) {
4199
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
4200
+ while (1) switch (_context75.prev = _context75.next) {
4124
4201
  case 0:
4125
4202
  walletId = params.walletId, targetPublicKey = params.targetPublicKey, stampWith = params.stampWith;
4126
4203
  pushPage({
@@ -4136,19 +4213,19 @@ var ClientProvider = function ClientProvider(_ref) {
4136
4213
  });
4137
4214
  case 2:
4138
4215
  case "end":
4139
- return _context73.stop();
4216
+ return _context75.stop();
4140
4217
  }
4141
- }, _callee73);
4218
+ }, _callee75);
4142
4219
  }));
4143
- return function (_x62) {
4144
- return _ref89.apply(this, arguments);
4220
+ return function (_x64) {
4221
+ return _ref91.apply(this, arguments);
4145
4222
  };
4146
- }(), [pushPage]);
4223
+ }(), [pushPage, masterConfig, client, session, user]);
4147
4224
  var handleExportPrivateKey = useCallback(/*#__PURE__*/function () {
4148
- var _ref90 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee74(params) {
4225
+ var _ref92 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee76(params) {
4149
4226
  var privateKeyId, targetPublicKey, keyFormat, stampWith;
4150
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
4151
- while (1) switch (_context74.prev = _context74.next) {
4227
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
4228
+ while (1) switch (_context76.prev = _context76.next) {
4152
4229
  case 0:
4153
4230
  privateKeyId = params.privateKeyId, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith;
4154
4231
  pushPage({
@@ -4166,19 +4243,19 @@ var ClientProvider = function ClientProvider(_ref) {
4166
4243
  });
4167
4244
  case 2:
4168
4245
  case "end":
4169
- return _context74.stop();
4246
+ return _context76.stop();
4170
4247
  }
4171
- }, _callee74);
4248
+ }, _callee76);
4172
4249
  }));
4173
- return function (_x63) {
4174
- return _ref90.apply(this, arguments);
4250
+ return function (_x65) {
4251
+ return _ref92.apply(this, arguments);
4175
4252
  };
4176
- }(), [pushPage]);
4253
+ }(), [pushPage, masterConfig, client, session, user]);
4177
4254
  var handleExportWalletAccount = useCallback(/*#__PURE__*/function () {
4178
- var _ref91 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee75(params) {
4255
+ var _ref93 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee77(params) {
4179
4256
  var address, targetPublicKey, keyFormat, stampWith;
4180
- return _regeneratorRuntime().wrap(function _callee75$(_context75) {
4181
- while (1) switch (_context75.prev = _context75.next) {
4257
+ return _regeneratorRuntime().wrap(function _callee77$(_context77) {
4258
+ while (1) switch (_context77.prev = _context77.next) {
4182
4259
  case 0:
4183
4260
  address = params.address, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith;
4184
4261
  pushPage({
@@ -4196,23 +4273,23 @@ var ClientProvider = function ClientProvider(_ref) {
4196
4273
  });
4197
4274
  case 2:
4198
4275
  case "end":
4199
- return _context75.stop();
4276
+ return _context77.stop();
4200
4277
  }
4201
- }, _callee75);
4278
+ }, _callee77);
4202
4279
  }));
4203
- return function (_x64) {
4204
- return _ref91.apply(this, arguments);
4280
+ return function (_x66) {
4281
+ return _ref93.apply(this, arguments);
4205
4282
  };
4206
- }(), [pushPage]);
4283
+ }(), [pushPage, masterConfig, client, session, user]);
4207
4284
  var handleImportWallet = useCallback(/*#__PURE__*/function () {
4208
- var _ref92 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee76(params) {
4209
- var _ref93, defaultWalletAccounts, _ref93$successPageDur, successPageDuration, stampWith;
4210
- return _regeneratorRuntime().wrap(function _callee76$(_context76) {
4211
- while (1) switch (_context76.prev = _context76.next) {
4285
+ var _ref94 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee78(params) {
4286
+ var _ref95, defaultWalletAccounts, _ref95$successPageDur, successPageDuration, stampWith;
4287
+ return _regeneratorRuntime().wrap(function _callee78$(_context78) {
4288
+ while (1) switch (_context78.prev = _context78.next) {
4212
4289
  case 0:
4213
- _ref93 = params || {}, defaultWalletAccounts = _ref93.defaultWalletAccounts, _ref93$successPageDur = _ref93.successPageDuration, successPageDuration = _ref93$successPageDur === void 0 ? 2000 : _ref93$successPageDur, stampWith = _ref93.stampWith;
4214
- _context76.prev = 1;
4215
- return _context76.abrupt("return", withTurnkeyErrorHandling(function () {
4290
+ _ref95 = params || {}, defaultWalletAccounts = _ref95.defaultWalletAccounts, _ref95$successPageDur = _ref95.successPageDuration, successPageDuration = _ref95$successPageDur === void 0 ? 2000 : _ref95$successPageDur, stampWith = _ref95.stampWith;
4291
+ _context78.prev = 1;
4292
+ return _context78.abrupt("return", withTurnkeyErrorHandling(function () {
4216
4293
  return new Promise(function (resolve, reject) {
4217
4294
  return pushPage({
4218
4295
  key: "Import wallet",
@@ -4235,34 +4312,34 @@ var ClientProvider = function ClientProvider(_ref) {
4235
4312
  });
4236
4313
  }));
4237
4314
  case 5:
4238
- _context76.prev = 5;
4239
- _context76.t0 = _context76["catch"](1);
4240
- if (!(_context76.t0 instanceof TurnkeyError)) {
4241
- _context76.next = 9;
4315
+ _context78.prev = 5;
4316
+ _context78.t0 = _context78["catch"](1);
4317
+ if (!(_context78.t0 instanceof TurnkeyError)) {
4318
+ _context78.next = 9;
4242
4319
  break;
4243
4320
  }
4244
- throw _context76.t0;
4321
+ throw _context78.t0;
4245
4322
  case 9:
4246
- throw new TurnkeyError("Failed to import wallet.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _context76.t0);
4323
+ throw new TurnkeyError("Failed to import wallet.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _context78.t0);
4247
4324
  case 10:
4248
4325
  case "end":
4249
- return _context76.stop();
4326
+ return _context78.stop();
4250
4327
  }
4251
- }, _callee76, null, [[1, 5]]);
4328
+ }, _callee78, null, [[1, 5]]);
4252
4329
  }));
4253
- return function (_x65) {
4254
- return _ref92.apply(this, arguments);
4330
+ return function (_x67) {
4331
+ return _ref94.apply(this, arguments);
4255
4332
  };
4256
- }(), [pushPage]);
4333
+ }(), [pushPage, masterConfig, client, session, user]);
4257
4334
  var handleImportPrivateKey = useCallback(/*#__PURE__*/function () {
4258
- var _ref94 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee77(params) {
4259
- var _ref95, curve, addressFormats, _ref95$successPageDur, successPageDuration, stampWith;
4260
- return _regeneratorRuntime().wrap(function _callee77$(_context77) {
4261
- while (1) switch (_context77.prev = _context77.next) {
4335
+ var _ref96 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee79(params) {
4336
+ var _ref97, curve, addressFormats, _ref97$successPageDur, successPageDuration, stampWith;
4337
+ return _regeneratorRuntime().wrap(function _callee79$(_context79) {
4338
+ while (1) switch (_context79.prev = _context79.next) {
4262
4339
  case 0:
4263
- _ref95 = params || {}, curve = _ref95.curve, addressFormats = _ref95.addressFormats, _ref95$successPageDur = _ref95.successPageDuration, successPageDuration = _ref95$successPageDur === void 0 ? 2000 : _ref95$successPageDur, stampWith = _ref95.stampWith;
4264
- _context77.prev = 1;
4265
- return _context77.abrupt("return", withTurnkeyErrorHandling(function () {
4340
+ _ref97 = params || {}, curve = _ref97.curve, addressFormats = _ref97.addressFormats, _ref97$successPageDur = _ref97.successPageDuration, successPageDuration = _ref97$successPageDur === void 0 ? 2000 : _ref97$successPageDur, stampWith = _ref97.stampWith;
4341
+ _context79.prev = 1;
4342
+ return _context79.abrupt("return", withTurnkeyErrorHandling(function () {
4266
4343
  return new Promise(function (resolve, reject) {
4267
4344
  return pushPage({
4268
4345
  key: "Import private key",
@@ -4285,40 +4362,40 @@ var ClientProvider = function ClientProvider(_ref) {
4285
4362
  });
4286
4363
  }));
4287
4364
  case 5:
4288
- _context77.prev = 5;
4289
- _context77.t0 = _context77["catch"](1);
4290
- if (!(_context77.t0 instanceof TurnkeyError)) {
4291
- _context77.next = 9;
4365
+ _context79.prev = 5;
4366
+ _context79.t0 = _context79["catch"](1);
4367
+ if (!(_context79.t0 instanceof TurnkeyError)) {
4368
+ _context79.next = 9;
4292
4369
  break;
4293
4370
  }
4294
- throw _context77.t0;
4371
+ throw _context79.t0;
4295
4372
  case 9:
4296
- throw new TurnkeyError("Failed to import private key.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _context77.t0);
4373
+ throw new TurnkeyError("Failed to import private key.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _context79.t0);
4297
4374
  case 10:
4298
4375
  case "end":
4299
- return _context77.stop();
4376
+ return _context79.stop();
4300
4377
  }
4301
- }, _callee77, null, [[1, 5]]);
4378
+ }, _callee79, null, [[1, 5]]);
4302
4379
  }));
4303
- return function (_x66) {
4304
- return _ref94.apply(this, arguments);
4380
+ return function (_x68) {
4381
+ return _ref96.apply(this, arguments);
4305
4382
  };
4306
- }(), [pushPage]);
4383
+ }(), [pushPage, masterConfig, client, session, user]);
4307
4384
  var handleUpdateUserName = useCallback(/*#__PURE__*/function () {
4308
- var _ref96 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee78(params) {
4309
- var _ref97, _ref97$successPageDur, successPageDuration, subTitle, title, stampWith, onSuccess, res;
4310
- return _regeneratorRuntime().wrap(function _callee78$(_context78) {
4311
- while (1) switch (_context78.prev = _context78.next) {
4385
+ var _ref98 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee80(params) {
4386
+ var _ref99, _ref99$successPageDur, successPageDuration, subTitle, title, stampWith, onSuccess, res;
4387
+ return _regeneratorRuntime().wrap(function _callee80$(_context80) {
4388
+ while (1) switch (_context80.prev = _context80.next) {
4312
4389
  case 0:
4313
- _ref97 = params || {}, _ref97$successPageDur = _ref97.successPageDuration, successPageDuration = _ref97$successPageDur === void 0 ? 2000 : _ref97$successPageDur, subTitle = _ref97.subTitle, title = _ref97.title, stampWith = _ref97.stampWith;
4390
+ _ref99 = params || {}, _ref99$successPageDur = _ref99.successPageDuration, successPageDuration = _ref99$successPageDur === void 0 ? 2000 : _ref99$successPageDur, subTitle = _ref99.subTitle, title = _ref99.title, stampWith = _ref99.stampWith;
4314
4391
  if (client) {
4315
- _context78.next = 3;
4392
+ _context80.next = 3;
4316
4393
  break;
4317
4394
  }
4318
4395
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4319
4396
  case 3:
4320
4397
  if (session) {
4321
- _context78.next = 5;
4398
+ _context80.next = 5;
4322
4399
  break;
4323
4400
  }
4324
4401
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
@@ -4338,12 +4415,12 @@ var ClientProvider = function ClientProvider(_ref) {
4338
4415
  showTitle: false
4339
4416
  });
4340
4417
  };
4341
- _context78.prev = 6;
4418
+ _context80.prev = 6;
4342
4419
  if (!(!(params !== null && params !== void 0 && params.userName) && (params === null || params === void 0 ? void 0 : params.userName) !== "")) {
4343
- _context78.next = 11;
4420
+ _context80.next = 11;
4344
4421
  break;
4345
4422
  }
4346
- return _context78.abrupt("return", withTurnkeyErrorHandling(function () {
4423
+ return _context80.abrupt("return", withTurnkeyErrorHandling(function () {
4347
4424
  return new Promise(function (resolve, reject) {
4348
4425
  pushPage({
4349
4426
  key: "Update User Name",
@@ -4366,67 +4443,67 @@ var ClientProvider = function ClientProvider(_ref) {
4366
4443
  });
4367
4444
  }));
4368
4445
  case 11:
4369
- _context78.next = 13;
4446
+ _context80.next = 13;
4370
4447
  return updateUserName({
4371
4448
  userName: params.userName,
4372
4449
  userId: user.userId,
4373
4450
  stampWith: stampWith
4374
4451
  });
4375
4452
  case 13:
4376
- res = _context78.sent;
4453
+ res = _context80.sent;
4377
4454
  onSuccess();
4378
- return _context78.abrupt("return", res);
4455
+ return _context80.abrupt("return", res);
4379
4456
  case 16:
4380
- _context78.next = 23;
4457
+ _context80.next = 23;
4381
4458
  break;
4382
4459
  case 18:
4383
- _context78.prev = 18;
4384
- _context78.t0 = _context78["catch"](6);
4385
- if (!(_context78.t0 instanceof TurnkeyError)) {
4386
- _context78.next = 22;
4460
+ _context80.prev = 18;
4461
+ _context80.t0 = _context80["catch"](6);
4462
+ if (!(_context80.t0 instanceof TurnkeyError)) {
4463
+ _context80.next = 22;
4387
4464
  break;
4388
4465
  }
4389
- throw _context78.t0;
4466
+ throw _context80.t0;
4390
4467
  case 22:
4391
- throw new TurnkeyError("Failed to update user name.", TurnkeyErrorCodes.UPDATE_USER_NAME_ERROR, _context78.t0);
4468
+ throw new TurnkeyError("Failed to update user name.", TurnkeyErrorCodes.UPDATE_USER_NAME_ERROR, _context80.t0);
4392
4469
  case 23:
4393
4470
  case "end":
4394
- return _context78.stop();
4471
+ return _context80.stop();
4395
4472
  }
4396
- }, _callee78, null, [[6, 18]]);
4473
+ }, _callee80, null, [[6, 18]]);
4397
4474
  }));
4398
- return function (_x67) {
4399
- return _ref96.apply(this, arguments);
4475
+ return function (_x69) {
4476
+ return _ref98.apply(this, arguments);
4400
4477
  };
4401
- }(), [pushPage]);
4478
+ }(), [pushPage, masterConfig, client, session, user]);
4402
4479
  var handleUpdateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
4403
- var _ref98 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee80(params) {
4480
+ var _ref100 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee82(params) {
4404
4481
  var _masterConfig$auth38, _masterConfig$auth38$;
4405
- var _ref99, _ref99$successPageDur, successPageDuration, subTitle, title, onSuccess, otpId;
4406
- return _regeneratorRuntime().wrap(function _callee80$(_context80) {
4407
- while (1) switch (_context80.prev = _context80.next) {
4482
+ var _ref101, _ref101$successPageDu, successPageDuration, subTitle, title, onSuccess, otpId;
4483
+ return _regeneratorRuntime().wrap(function _callee82$(_context82) {
4484
+ while (1) switch (_context82.prev = _context82.next) {
4408
4485
  case 0:
4409
- _ref99 = params || {}, _ref99$successPageDur = _ref99.successPageDuration, successPageDuration = _ref99$successPageDur === void 0 ? 2000 : _ref99$successPageDur, subTitle = _ref99.subTitle, title = _ref99.title;
4486
+ _ref101 = params || {}, _ref101$successPageDu = _ref101.successPageDuration, successPageDuration = _ref101$successPageDu === void 0 ? 2000 : _ref101$successPageDu, subTitle = _ref101.subTitle, title = _ref101.title;
4410
4487
  if (client) {
4411
- _context80.next = 3;
4488
+ _context82.next = 3;
4412
4489
  break;
4413
4490
  }
4414
4491
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4415
4492
  case 3:
4416
4493
  if (session) {
4417
- _context80.next = 5;
4494
+ _context82.next = 5;
4418
4495
  break;
4419
4496
  }
4420
4497
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
4421
4498
  case 5:
4422
4499
  if (masterConfig) {
4423
- _context80.next = 7;
4500
+ _context82.next = 7;
4424
4501
  break;
4425
4502
  }
4426
4503
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
4427
4504
  case 7:
4428
4505
  if ((_masterConfig$auth38 = masterConfig.auth) !== null && _masterConfig$auth38 !== void 0 && (_masterConfig$auth38$ = _masterConfig$auth38.methods) !== null && _masterConfig$auth38$ !== void 0 && _masterConfig$auth38$.smsOtpAuthEnabled) {
4429
- _context80.next = 9;
4506
+ _context82.next = 9;
4430
4507
  break;
4431
4508
  }
4432
4509
  throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
@@ -4446,12 +4523,12 @@ var ClientProvider = function ClientProvider(_ref) {
4446
4523
  showTitle: false
4447
4524
  });
4448
4525
  };
4449
- _context80.prev = 10;
4526
+ _context82.prev = 10;
4450
4527
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
4451
- _context80.next = 15;
4528
+ _context82.next = 15;
4452
4529
  break;
4453
4530
  }
4454
- return _context80.abrupt("return", withTurnkeyErrorHandling(function () {
4531
+ return _context82.abrupt("return", withTurnkeyErrorHandling(function () {
4455
4532
  return new Promise(function (resolve, reject) {
4456
4533
  pushPage({
4457
4534
  key: "Update Phone Number",
@@ -4473,14 +4550,14 @@ var ClientProvider = function ClientProvider(_ref) {
4473
4550
  });
4474
4551
  }));
4475
4552
  case 15:
4476
- _context80.next = 17;
4553
+ _context82.next = 17;
4477
4554
  return initOtp({
4478
4555
  otpType: OtpType.Sms,
4479
4556
  contact: params.phoneNumber
4480
4557
  });
4481
4558
  case 17:
4482
- otpId = _context80.sent;
4483
- return _context80.abrupt("return", withTurnkeyErrorHandling(function () {
4559
+ otpId = _context82.sent;
4560
+ return _context82.abrupt("return", withTurnkeyErrorHandling(function () {
4484
4561
  return new Promise(function (resolve, reject) {
4485
4562
  pushPage({
4486
4563
  key: "Update Phone Number",
@@ -4489,13 +4566,13 @@ var ClientProvider = function ClientProvider(_ref) {
4489
4566
  contact: params.phoneNumber,
4490
4567
  otpId: otpId,
4491
4568
  onContinue: function () {
4492
- var _onContinue = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee79(otpCode) {
4569
+ var _onContinue = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee81(otpCode) {
4493
4570
  var _yield$verifyOtp, verificationToken, res;
4494
- return _regeneratorRuntime().wrap(function _callee79$(_context79) {
4495
- while (1) switch (_context79.prev = _context79.next) {
4571
+ return _regeneratorRuntime().wrap(function _callee81$(_context81) {
4572
+ while (1) switch (_context81.prev = _context81.next) {
4496
4573
  case 0:
4497
- _context79.prev = 0;
4498
- _context79.next = 3;
4574
+ _context81.prev = 0;
4575
+ _context81.next = 3;
4499
4576
  return verifyOtp({
4500
4577
  otpId: otpId,
4501
4578
  otpCode: otpCode,
@@ -4503,31 +4580,31 @@ var ClientProvider = function ClientProvider(_ref) {
4503
4580
  otpType: OtpType.Sms
4504
4581
  });
4505
4582
  case 3:
4506
- _yield$verifyOtp = _context79.sent;
4583
+ _yield$verifyOtp = _context81.sent;
4507
4584
  verificationToken = _yield$verifyOtp.verificationToken;
4508
- _context79.next = 7;
4585
+ _context81.next = 7;
4509
4586
  return updateUserPhoneNumber({
4510
4587
  phoneNumber: params.phoneNumber,
4511
4588
  verificationToken: verificationToken,
4512
4589
  userId: user.userId
4513
4590
  });
4514
4591
  case 7:
4515
- res = _context79.sent;
4592
+ res = _context81.sent;
4516
4593
  onSuccess();
4517
4594
  resolve(res);
4518
- _context79.next = 15;
4595
+ _context81.next = 15;
4519
4596
  break;
4520
4597
  case 12:
4521
- _context79.prev = 12;
4522
- _context79.t0 = _context79["catch"](0);
4523
- reject(_context79.t0);
4598
+ _context81.prev = 12;
4599
+ _context81.t0 = _context81["catch"](0);
4600
+ reject(_context81.t0);
4524
4601
  case 15:
4525
4602
  case "end":
4526
- return _context79.stop();
4603
+ return _context81.stop();
4527
4604
  }
4528
- }, _callee79, null, [[0, 12]]);
4605
+ }, _callee81, null, [[0, 12]]);
4529
4606
  }));
4530
- function onContinue(_x69) {
4607
+ function onContinue(_x71) {
4531
4608
  return _onContinue.apply(this, arguments);
4532
4609
  }
4533
4610
  return onContinue;
@@ -4544,43 +4621,43 @@ var ClientProvider = function ClientProvider(_ref) {
4544
4621
  });
4545
4622
  }, callbacks, "Failed to update phone number"));
4546
4623
  case 19:
4547
- _context80.next = 26;
4624
+ _context82.next = 26;
4548
4625
  break;
4549
4626
  case 21:
4550
- _context80.prev = 21;
4551
- _context80.t0 = _context80["catch"](10);
4552
- if (!(_context80.t0 instanceof TurnkeyError)) {
4553
- _context80.next = 25;
4627
+ _context82.prev = 21;
4628
+ _context82.t0 = _context82["catch"](10);
4629
+ if (!(_context82.t0 instanceof TurnkeyError)) {
4630
+ _context82.next = 25;
4554
4631
  break;
4555
4632
  }
4556
- throw _context80.t0;
4633
+ throw _context82.t0;
4557
4634
  case 25:
4558
- throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context80.t0);
4635
+ throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context82.t0);
4559
4636
  case 26:
4560
4637
  case "end":
4561
- return _context80.stop();
4638
+ return _context82.stop();
4562
4639
  }
4563
- }, _callee80, null, [[10, 21]]);
4640
+ }, _callee82, null, [[10, 21]]);
4564
4641
  }));
4565
- return function (_x68) {
4566
- return _ref98.apply(this, arguments);
4642
+ return function (_x70) {
4643
+ return _ref100.apply(this, arguments);
4567
4644
  };
4568
- }(), [pushPage]);
4645
+ }(), [pushPage, masterConfig, client, session, user]);
4569
4646
  var handleUpdateUserEmail = useCallback(/*#__PURE__*/function () {
4570
- var _ref100 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee82(params) {
4571
- var _ref101, _ref101$successPageDu, successPageDuration, subTitle, title, onSuccess, otpId;
4572
- return _regeneratorRuntime().wrap(function _callee82$(_context82) {
4573
- while (1) switch (_context82.prev = _context82.next) {
4647
+ var _ref102 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee84(params) {
4648
+ var _ref103, _ref103$successPageDu, successPageDuration, subTitle, title, onSuccess, otpId;
4649
+ return _regeneratorRuntime().wrap(function _callee84$(_context84) {
4650
+ while (1) switch (_context84.prev = _context84.next) {
4574
4651
  case 0:
4575
- _ref101 = params || {}, _ref101$successPageDu = _ref101.successPageDuration, successPageDuration = _ref101$successPageDu === void 0 ? 2000 : _ref101$successPageDu, subTitle = _ref101.subTitle, title = _ref101.title;
4652
+ _ref103 = params || {}, _ref103$successPageDu = _ref103.successPageDuration, successPageDuration = _ref103$successPageDu === void 0 ? 2000 : _ref103$successPageDu, subTitle = _ref103.subTitle, title = _ref103.title;
4576
4653
  if (client) {
4577
- _context82.next = 3;
4654
+ _context84.next = 3;
4578
4655
  break;
4579
4656
  }
4580
4657
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4581
4658
  case 3:
4582
4659
  if (session) {
4583
- _context82.next = 5;
4660
+ _context84.next = 5;
4584
4661
  break;
4585
4662
  }
4586
4663
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
@@ -4600,12 +4677,12 @@ var ClientProvider = function ClientProvider(_ref) {
4600
4677
  showTitle: false
4601
4678
  });
4602
4679
  };
4603
- _context82.prev = 6;
4680
+ _context84.prev = 6;
4604
4681
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
4605
- _context82.next = 11;
4682
+ _context84.next = 11;
4606
4683
  break;
4607
4684
  }
4608
- return _context82.abrupt("return", withTurnkeyErrorHandling(function () {
4685
+ return _context84.abrupt("return", withTurnkeyErrorHandling(function () {
4609
4686
  return new Promise(function (resolve, reject) {
4610
4687
  pushPage({
4611
4688
  key: "Update Email",
@@ -4627,14 +4704,14 @@ var ClientProvider = function ClientProvider(_ref) {
4627
4704
  });
4628
4705
  }));
4629
4706
  case 11:
4630
- _context82.next = 13;
4707
+ _context84.next = 13;
4631
4708
  return initOtp({
4632
4709
  otpType: OtpType.Email,
4633
4710
  contact: params.email
4634
4711
  });
4635
4712
  case 13:
4636
- otpId = _context82.sent;
4637
- return _context82.abrupt("return", withTurnkeyErrorHandling(function () {
4713
+ otpId = _context84.sent;
4714
+ return _context84.abrupt("return", withTurnkeyErrorHandling(function () {
4638
4715
  return new Promise(function (resolve, reject) {
4639
4716
  pushPage({
4640
4717
  key: "Update Email",
@@ -4643,13 +4720,13 @@ var ClientProvider = function ClientProvider(_ref) {
4643
4720
  contact: params.email,
4644
4721
  otpId: otpId,
4645
4722
  onContinue: function () {
4646
- var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee81(otpCode) {
4723
+ var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee83(otpCode) {
4647
4724
  var _yield$verifyOtp2, verificationToken, res;
4648
- return _regeneratorRuntime().wrap(function _callee81$(_context81) {
4649
- while (1) switch (_context81.prev = _context81.next) {
4725
+ return _regeneratorRuntime().wrap(function _callee83$(_context83) {
4726
+ while (1) switch (_context83.prev = _context83.next) {
4650
4727
  case 0:
4651
- _context81.prev = 0;
4652
- _context81.next = 3;
4728
+ _context83.prev = 0;
4729
+ _context83.next = 3;
4653
4730
  return verifyOtp({
4654
4731
  otpId: otpId,
4655
4732
  otpCode: otpCode,
@@ -4657,31 +4734,31 @@ var ClientProvider = function ClientProvider(_ref) {
4657
4734
  otpType: OtpType.Email
4658
4735
  });
4659
4736
  case 3:
4660
- _yield$verifyOtp2 = _context81.sent;
4737
+ _yield$verifyOtp2 = _context83.sent;
4661
4738
  verificationToken = _yield$verifyOtp2.verificationToken;
4662
- _context81.next = 7;
4739
+ _context83.next = 7;
4663
4740
  return updateUserEmail({
4664
4741
  email: params.email,
4665
4742
  verificationToken: verificationToken,
4666
4743
  userId: user.userId
4667
4744
  });
4668
4745
  case 7:
4669
- res = _context81.sent;
4746
+ res = _context83.sent;
4670
4747
  onSuccess();
4671
4748
  resolve(res);
4672
- _context81.next = 15;
4749
+ _context83.next = 15;
4673
4750
  break;
4674
4751
  case 12:
4675
- _context81.prev = 12;
4676
- _context81.t0 = _context81["catch"](0);
4677
- reject(_context81.t0);
4752
+ _context83.prev = 12;
4753
+ _context83.t0 = _context83["catch"](0);
4754
+ reject(_context83.t0);
4678
4755
  case 15:
4679
4756
  case "end":
4680
- return _context81.stop();
4757
+ return _context83.stop();
4681
4758
  }
4682
- }, _callee81, null, [[0, 12]]);
4759
+ }, _callee83, null, [[0, 12]]);
4683
4760
  }));
4684
- function onContinue(_x71) {
4761
+ function onContinue(_x73) {
4685
4762
  return _onContinue2.apply(this, arguments);
4686
4763
  }
4687
4764
  return onContinue;
@@ -4696,43 +4773,43 @@ var ClientProvider = function ClientProvider(_ref) {
4696
4773
  });
4697
4774
  }, callbacks, "Failed to update email"));
4698
4775
  case 15:
4699
- _context82.next = 22;
4776
+ _context84.next = 22;
4700
4777
  break;
4701
4778
  case 17:
4702
- _context82.prev = 17;
4703
- _context82.t0 = _context82["catch"](6);
4704
- if (!(_context82.t0 instanceof TurnkeyError)) {
4705
- _context82.next = 21;
4779
+ _context84.prev = 17;
4780
+ _context84.t0 = _context84["catch"](6);
4781
+ if (!(_context84.t0 instanceof TurnkeyError)) {
4782
+ _context84.next = 21;
4706
4783
  break;
4707
4784
  }
4708
- throw _context82.t0;
4785
+ throw _context84.t0;
4709
4786
  case 21:
4710
- throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context82.t0);
4787
+ throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context84.t0);
4711
4788
  case 22:
4712
4789
  case "end":
4713
- return _context82.stop();
4790
+ return _context84.stop();
4714
4791
  }
4715
- }, _callee82, null, [[6, 17]]);
4792
+ }, _callee84, null, [[6, 17]]);
4716
4793
  }));
4717
- return function (_x70) {
4718
- return _ref100.apply(this, arguments);
4794
+ return function (_x72) {
4795
+ return _ref102.apply(this, arguments);
4719
4796
  };
4720
- }(), [pushPage]);
4797
+ }(), [pushPage, masterConfig, client, session, user]);
4721
4798
  var handleAddEmail = useCallback(/*#__PURE__*/function () {
4722
- var _ref102 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee84(params) {
4723
- var _ref103, _ref103$successPageDu, successPageDuration, subTitle, title, onSuccess, otpId;
4724
- return _regeneratorRuntime().wrap(function _callee84$(_context84) {
4725
- while (1) switch (_context84.prev = _context84.next) {
4799
+ var _ref104 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee86(params) {
4800
+ var _ref105, _ref105$successPageDu, successPageDuration, subTitle, title, onSuccess, otpId;
4801
+ return _regeneratorRuntime().wrap(function _callee86$(_context86) {
4802
+ while (1) switch (_context86.prev = _context86.next) {
4726
4803
  case 0:
4727
- _ref103 = params || {}, _ref103$successPageDu = _ref103.successPageDuration, successPageDuration = _ref103$successPageDu === void 0 ? 2000 : _ref103$successPageDu, subTitle = _ref103.subTitle, title = _ref103.title;
4804
+ _ref105 = params || {}, _ref105$successPageDu = _ref105.successPageDuration, successPageDuration = _ref105$successPageDu === void 0 ? 2000 : _ref105$successPageDu, subTitle = _ref105.subTitle, title = _ref105.title;
4728
4805
  if (client) {
4729
- _context84.next = 3;
4806
+ _context86.next = 3;
4730
4807
  break;
4731
4808
  }
4732
4809
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4733
4810
  case 3:
4734
4811
  if (session) {
4735
- _context84.next = 5;
4812
+ _context86.next = 5;
4736
4813
  break;
4737
4814
  }
4738
4815
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
@@ -4752,12 +4829,12 @@ var ClientProvider = function ClientProvider(_ref) {
4752
4829
  showTitle: false
4753
4830
  });
4754
4831
  };
4755
- _context84.prev = 6;
4832
+ _context86.prev = 6;
4756
4833
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
4757
- _context84.next = 11;
4834
+ _context86.next = 11;
4758
4835
  break;
4759
4836
  }
4760
- return _context84.abrupt("return", withTurnkeyErrorHandling(function () {
4837
+ return _context86.abrupt("return", withTurnkeyErrorHandling(function () {
4761
4838
  return new Promise(function (resolve, reject) {
4762
4839
  pushPage({
4763
4840
  key: "Add Email",
@@ -4779,14 +4856,14 @@ var ClientProvider = function ClientProvider(_ref) {
4779
4856
  });
4780
4857
  }));
4781
4858
  case 11:
4782
- _context84.next = 13;
4859
+ _context86.next = 13;
4783
4860
  return initOtp({
4784
4861
  otpType: OtpType.Email,
4785
4862
  contact: params.email
4786
4863
  });
4787
4864
  case 13:
4788
- otpId = _context84.sent;
4789
- return _context84.abrupt("return", withTurnkeyErrorHandling(function () {
4865
+ otpId = _context86.sent;
4866
+ return _context86.abrupt("return", withTurnkeyErrorHandling(function () {
4790
4867
  return new Promise(function (resolve, reject) {
4791
4868
  pushPage({
4792
4869
  key: "Add Email",
@@ -4795,13 +4872,13 @@ var ClientProvider = function ClientProvider(_ref) {
4795
4872
  contact: params.email,
4796
4873
  otpId: otpId,
4797
4874
  onContinue: function () {
4798
- var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee83(otpCode) {
4875
+ var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee85(otpCode) {
4799
4876
  var _yield$verifyOtp3, verificationToken, res;
4800
- return _regeneratorRuntime().wrap(function _callee83$(_context83) {
4801
- while (1) switch (_context83.prev = _context83.next) {
4877
+ return _regeneratorRuntime().wrap(function _callee85$(_context85) {
4878
+ while (1) switch (_context85.prev = _context85.next) {
4802
4879
  case 0:
4803
- _context83.prev = 0;
4804
- _context83.next = 3;
4880
+ _context85.prev = 0;
4881
+ _context85.next = 3;
4805
4882
  return verifyOtp({
4806
4883
  otpId: otpId,
4807
4884
  otpCode: otpCode,
@@ -4809,31 +4886,31 @@ var ClientProvider = function ClientProvider(_ref) {
4809
4886
  otpType: OtpType.Email
4810
4887
  });
4811
4888
  case 3:
4812
- _yield$verifyOtp3 = _context83.sent;
4889
+ _yield$verifyOtp3 = _context85.sent;
4813
4890
  verificationToken = _yield$verifyOtp3.verificationToken;
4814
- _context83.next = 7;
4891
+ _context85.next = 7;
4815
4892
  return updateUserEmail({
4816
4893
  email: params.email,
4817
4894
  verificationToken: verificationToken,
4818
4895
  userId: user.userId
4819
4896
  });
4820
4897
  case 7:
4821
- res = _context83.sent;
4898
+ res = _context85.sent;
4822
4899
  onSuccess();
4823
4900
  resolve(res);
4824
- _context83.next = 15;
4901
+ _context85.next = 15;
4825
4902
  break;
4826
4903
  case 12:
4827
- _context83.prev = 12;
4828
- _context83.t0 = _context83["catch"](0);
4829
- reject(_context83.t0);
4904
+ _context85.prev = 12;
4905
+ _context85.t0 = _context85["catch"](0);
4906
+ reject(_context85.t0);
4830
4907
  case 15:
4831
4908
  case "end":
4832
- return _context83.stop();
4909
+ return _context85.stop();
4833
4910
  }
4834
- }, _callee83, null, [[0, 12]]);
4911
+ }, _callee85, null, [[0, 12]]);
4835
4912
  }));
4836
- function onContinue(_x73) {
4913
+ function onContinue(_x75) {
4837
4914
  return _onContinue3.apply(this, arguments);
4838
4915
  }
4839
4916
  return onContinue;
@@ -4848,56 +4925,56 @@ var ClientProvider = function ClientProvider(_ref) {
4848
4925
  });
4849
4926
  }, callbacks, "Failed to add email"));
4850
4927
  case 15:
4851
- _context84.next = 22;
4928
+ _context86.next = 22;
4852
4929
  break;
4853
4930
  case 17:
4854
- _context84.prev = 17;
4855
- _context84.t0 = _context84["catch"](6);
4856
- if (!(_context84.t0 instanceof TurnkeyError)) {
4857
- _context84.next = 21;
4931
+ _context86.prev = 17;
4932
+ _context86.t0 = _context86["catch"](6);
4933
+ if (!(_context86.t0 instanceof TurnkeyError)) {
4934
+ _context86.next = 21;
4858
4935
  break;
4859
4936
  }
4860
- throw _context84.t0;
4937
+ throw _context86.t0;
4861
4938
  case 21:
4862
- throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context84.t0);
4939
+ throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context86.t0);
4863
4940
  case 22:
4864
4941
  case "end":
4865
- return _context84.stop();
4942
+ return _context86.stop();
4866
4943
  }
4867
- }, _callee84, null, [[6, 17]]);
4944
+ }, _callee86, null, [[6, 17]]);
4868
4945
  }));
4869
- return function (_x72) {
4870
- return _ref102.apply(this, arguments);
4946
+ return function (_x74) {
4947
+ return _ref104.apply(this, arguments);
4871
4948
  };
4872
- }(), [pushPage]);
4949
+ }(), [pushPage, client, session, user]);
4873
4950
  var handleAddPhoneNumber = useCallback(/*#__PURE__*/function () {
4874
- var _ref104 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee86(params) {
4951
+ var _ref106 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee88(params) {
4875
4952
  var _masterConfig$auth39, _masterConfig$auth39$;
4876
- var _ref105, _ref105$successPageDu, successPageDuration, subTitle, title, onSuccess, otpId;
4877
- return _regeneratorRuntime().wrap(function _callee86$(_context86) {
4878
- while (1) switch (_context86.prev = _context86.next) {
4953
+ var _ref107, _ref107$successPageDu, successPageDuration, subTitle, title, onSuccess, otpId;
4954
+ return _regeneratorRuntime().wrap(function _callee88$(_context88) {
4955
+ while (1) switch (_context88.prev = _context88.next) {
4879
4956
  case 0:
4880
- _ref105 = params || {}, _ref105$successPageDu = _ref105.successPageDuration, successPageDuration = _ref105$successPageDu === void 0 ? 2000 : _ref105$successPageDu, subTitle = _ref105.subTitle, title = _ref105.title;
4957
+ _ref107 = params || {}, _ref107$successPageDu = _ref107.successPageDuration, successPageDuration = _ref107$successPageDu === void 0 ? 2000 : _ref107$successPageDu, subTitle = _ref107.subTitle, title = _ref107.title;
4881
4958
  if (client) {
4882
- _context86.next = 3;
4959
+ _context88.next = 3;
4883
4960
  break;
4884
4961
  }
4885
4962
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4886
4963
  case 3:
4887
4964
  if (session) {
4888
- _context86.next = 5;
4965
+ _context88.next = 5;
4889
4966
  break;
4890
4967
  }
4891
4968
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
4892
4969
  case 5:
4893
4970
  if (masterConfig) {
4894
- _context86.next = 7;
4971
+ _context88.next = 7;
4895
4972
  break;
4896
4973
  }
4897
4974
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
4898
4975
  case 7:
4899
4976
  if ((_masterConfig$auth39 = masterConfig.auth) !== null && _masterConfig$auth39 !== void 0 && (_masterConfig$auth39$ = _masterConfig$auth39.methods) !== null && _masterConfig$auth39$ !== void 0 && _masterConfig$auth39$.smsOtpAuthEnabled) {
4900
- _context86.next = 9;
4977
+ _context88.next = 9;
4901
4978
  break;
4902
4979
  }
4903
4980
  throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
@@ -4917,12 +4994,12 @@ var ClientProvider = function ClientProvider(_ref) {
4917
4994
  showTitle: false
4918
4995
  });
4919
4996
  };
4920
- _context86.prev = 10;
4997
+ _context88.prev = 10;
4921
4998
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
4922
- _context86.next = 15;
4999
+ _context88.next = 15;
4923
5000
  break;
4924
5001
  }
4925
- return _context86.abrupt("return", withTurnkeyErrorHandling(function () {
5002
+ return _context88.abrupt("return", withTurnkeyErrorHandling(function () {
4926
5003
  return new Promise(function (resolve, reject) {
4927
5004
  pushPage({
4928
5005
  key: "Add Phone Number",
@@ -4944,14 +5021,14 @@ var ClientProvider = function ClientProvider(_ref) {
4944
5021
  });
4945
5022
  }, callbacks, "Failed to add phone number"));
4946
5023
  case 15:
4947
- _context86.next = 17;
5024
+ _context88.next = 17;
4948
5025
  return initOtp({
4949
5026
  otpType: OtpType.Sms,
4950
5027
  contact: params.phoneNumber
4951
5028
  });
4952
5029
  case 17:
4953
- otpId = _context86.sent;
4954
- return _context86.abrupt("return", withTurnkeyErrorHandling(function () {
5030
+ otpId = _context88.sent;
5031
+ return _context88.abrupt("return", withTurnkeyErrorHandling(function () {
4955
5032
  return new Promise(function (resolve, reject) {
4956
5033
  pushPage({
4957
5034
  key: "Add Phone Number",
@@ -4960,13 +5037,13 @@ var ClientProvider = function ClientProvider(_ref) {
4960
5037
  contact: params.phoneNumber,
4961
5038
  otpId: otpId,
4962
5039
  onContinue: function () {
4963
- var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee85(otpCode) {
5040
+ var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee87(otpCode) {
4964
5041
  var _yield$verifyOtp4, verificationToken, res;
4965
- return _regeneratorRuntime().wrap(function _callee85$(_context85) {
4966
- while (1) switch (_context85.prev = _context85.next) {
5042
+ return _regeneratorRuntime().wrap(function _callee87$(_context87) {
5043
+ while (1) switch (_context87.prev = _context87.next) {
4967
5044
  case 0:
4968
- _context85.prev = 0;
4969
- _context85.next = 3;
5045
+ _context87.prev = 0;
5046
+ _context87.next = 3;
4970
5047
  return verifyOtp({
4971
5048
  otpId: otpId,
4972
5049
  otpCode: otpCode,
@@ -4974,31 +5051,31 @@ var ClientProvider = function ClientProvider(_ref) {
4974
5051
  otpType: OtpType.Sms
4975
5052
  });
4976
5053
  case 3:
4977
- _yield$verifyOtp4 = _context85.sent;
5054
+ _yield$verifyOtp4 = _context87.sent;
4978
5055
  verificationToken = _yield$verifyOtp4.verificationToken;
4979
- _context85.next = 7;
5056
+ _context87.next = 7;
4980
5057
  return updateUserPhoneNumber({
4981
5058
  phoneNumber: params.phoneNumber,
4982
5059
  verificationToken: verificationToken,
4983
5060
  userId: user.userId
4984
5061
  });
4985
5062
  case 7:
4986
- res = _context85.sent;
5063
+ res = _context87.sent;
4987
5064
  onSuccess();
4988
5065
  resolve(res);
4989
- _context85.next = 15;
5066
+ _context87.next = 15;
4990
5067
  break;
4991
5068
  case 12:
4992
- _context85.prev = 12;
4993
- _context85.t0 = _context85["catch"](0);
4994
- reject(_context85.t0);
5069
+ _context87.prev = 12;
5070
+ _context87.t0 = _context87["catch"](0);
5071
+ reject(_context87.t0);
4995
5072
  case 15:
4996
5073
  case "end":
4997
- return _context85.stop();
5074
+ return _context87.stop();
4998
5075
  }
4999
- }, _callee85, null, [[0, 12]]);
5076
+ }, _callee87, null, [[0, 12]]);
5000
5077
  }));
5001
- function onContinue(_x75) {
5078
+ function onContinue(_x77) {
5002
5079
  return _onContinue4.apply(this, arguments);
5003
5080
  }
5004
5081
  return onContinue;
@@ -5015,48 +5092,48 @@ var ClientProvider = function ClientProvider(_ref) {
5015
5092
  });
5016
5093
  }, callbacks, "Failed to add phone number"));
5017
5094
  case 19:
5018
- _context86.next = 26;
5095
+ _context88.next = 26;
5019
5096
  break;
5020
5097
  case 21:
5021
- _context86.prev = 21;
5022
- _context86.t0 = _context86["catch"](10);
5023
- if (!(_context86.t0 instanceof TurnkeyError)) {
5024
- _context86.next = 25;
5098
+ _context88.prev = 21;
5099
+ _context88.t0 = _context88["catch"](10);
5100
+ if (!(_context88.t0 instanceof TurnkeyError)) {
5101
+ _context88.next = 25;
5025
5102
  break;
5026
5103
  }
5027
- throw _context86.t0;
5104
+ throw _context88.t0;
5028
5105
  case 25:
5029
- throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context86.t0);
5106
+ throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context88.t0);
5030
5107
  case 26:
5031
5108
  case "end":
5032
- return _context86.stop();
5109
+ return _context88.stop();
5033
5110
  }
5034
- }, _callee86, null, [[10, 21]]);
5111
+ }, _callee88, null, [[10, 21]]);
5035
5112
  }));
5036
- return function (_x74) {
5037
- return _ref104.apply(this, arguments);
5113
+ return function (_x76) {
5114
+ return _ref106.apply(this, arguments);
5038
5115
  };
5039
- }(), [pushPage]);
5116
+ }(), [pushPage, masterConfig, client, session, user]);
5040
5117
  var handleRemovePasskey = useCallback(/*#__PURE__*/function () {
5041
- var _ref106 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee87(params) {
5118
+ var _ref108 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee89(params) {
5042
5119
  var authenticatorId, _params$successPageDu2, successPageDuration, subTitle, title, stampWith, userId;
5043
- return _regeneratorRuntime().wrap(function _callee87$(_context87) {
5044
- while (1) switch (_context87.prev = _context87.next) {
5120
+ return _regeneratorRuntime().wrap(function _callee89$(_context89) {
5121
+ while (1) switch (_context89.prev = _context89.next) {
5045
5122
  case 0:
5046
5123
  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;
5047
5124
  if (client) {
5048
- _context87.next = 3;
5125
+ _context89.next = 3;
5049
5126
  break;
5050
5127
  }
5051
5128
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5052
5129
  case 3:
5053
5130
  if (session) {
5054
- _context87.next = 5;
5131
+ _context89.next = 5;
5055
5132
  break;
5056
5133
  }
5057
5134
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
5058
5135
  case 5:
5059
- return _context87.abrupt("return", withTurnkeyErrorHandling(function () {
5136
+ return _context89.abrupt("return", withTurnkeyErrorHandling(function () {
5060
5137
  return new Promise(function (resolve, reject) {
5061
5138
  pushPage({
5062
5139
  key: "Remove Passkey",
@@ -5084,35 +5161,35 @@ var ClientProvider = function ClientProvider(_ref) {
5084
5161
  }, callbacks, "Failed to remove passkey"));
5085
5162
  case 6:
5086
5163
  case "end":
5087
- return _context87.stop();
5164
+ return _context89.stop();
5088
5165
  }
5089
- }, _callee87);
5166
+ }, _callee89);
5090
5167
  }));
5091
- return function (_x76) {
5092
- return _ref106.apply(this, arguments);
5168
+ return function (_x78) {
5169
+ return _ref108.apply(this, arguments);
5093
5170
  };
5094
- }(), [pushPage]);
5171
+ }(), [pushPage, masterConfig, client, session, user]);
5095
5172
  var handleAddPasskey = useCallback(/*#__PURE__*/function () {
5096
- var _ref107 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee88(params) {
5097
- var _ref108, name, displayName, _ref108$successPageDu, successPageDuration, stampWith, userId, resPromise;
5098
- return _regeneratorRuntime().wrap(function _callee88$(_context88) {
5099
- while (1) switch (_context88.prev = _context88.next) {
5173
+ var _ref109 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee90(params) {
5174
+ var _ref110, name, displayName, _ref110$successPageDu, successPageDuration, stampWith, userId, resPromise;
5175
+ return _regeneratorRuntime().wrap(function _callee90$(_context90) {
5176
+ while (1) switch (_context90.prev = _context90.next) {
5100
5177
  case 0:
5101
- _ref108 = params || {}, name = _ref108.name, displayName = _ref108.displayName, _ref108$successPageDu = _ref108.successPageDuration, successPageDuration = _ref108$successPageDu === void 0 ? 2000 : _ref108$successPageDu, stampWith = _ref108.stampWith;
5178
+ _ref110 = params || {}, name = _ref110.name, displayName = _ref110.displayName, _ref110$successPageDu = _ref110.successPageDuration, successPageDuration = _ref110$successPageDu === void 0 ? 2000 : _ref110$successPageDu, stampWith = _ref110.stampWith;
5102
5179
  if (client) {
5103
- _context88.next = 3;
5180
+ _context90.next = 3;
5104
5181
  break;
5105
5182
  }
5106
5183
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5107
5184
  case 3:
5108
5185
  if (session) {
5109
- _context88.next = 5;
5186
+ _context90.next = 5;
5110
5187
  break;
5111
5188
  }
5112
5189
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
5113
5190
  case 5:
5114
5191
  userId = (params === null || params === void 0 ? void 0 : params.userId) || session.userId;
5115
- _context88.prev = 6;
5192
+ _context90.prev = 6;
5116
5193
  resPromise = addPasskey(_objectSpread2(_objectSpread2(_objectSpread2({}, name && {
5117
5194
  name: name
5118
5195
  }), displayName && {
@@ -5135,51 +5212,51 @@ var ClientProvider = function ClientProvider(_ref) {
5135
5212
  showTitle: false
5136
5213
  });
5137
5214
  });
5138
- _context88.next = 11;
5215
+ _context90.next = 11;
5139
5216
  return resPromise;
5140
5217
  case 11:
5141
- return _context88.abrupt("return", _context88.sent);
5218
+ return _context90.abrupt("return", _context90.sent);
5142
5219
  case 14:
5143
- _context88.prev = 14;
5144
- _context88.t0 = _context88["catch"](6);
5145
- if (!(_context88.t0 instanceof TurnkeyError)) {
5146
- _context88.next = 18;
5220
+ _context90.prev = 14;
5221
+ _context90.t0 = _context90["catch"](6);
5222
+ if (!(_context90.t0 instanceof TurnkeyError)) {
5223
+ _context90.next = 18;
5147
5224
  break;
5148
5225
  }
5149
- throw _context88.t0;
5226
+ throw _context90.t0;
5150
5227
  case 18:
5151
- throw new TurnkeyError("Failed to add passkey in handler.", TurnkeyErrorCodes.ADD_PASSKEY_ERROR, _context88.t0);
5228
+ throw new TurnkeyError("Failed to add passkey in handler.", TurnkeyErrorCodes.ADD_PASSKEY_ERROR, _context90.t0);
5152
5229
  case 19:
5153
5230
  case "end":
5154
- return _context88.stop();
5231
+ return _context90.stop();
5155
5232
  }
5156
- }, _callee88, null, [[6, 14]]);
5233
+ }, _callee90, null, [[6, 14]]);
5157
5234
  }));
5158
- return function (_x77) {
5159
- return _ref107.apply(this, arguments);
5235
+ return function (_x79) {
5236
+ return _ref109.apply(this, arguments);
5160
5237
  };
5161
- }(), [pushPage]);
5238
+ }(), [pushPage, masterConfig, client, session, user]);
5162
5239
  var handleRemoveOauthProvider = useCallback(/*#__PURE__*/function () {
5163
- var _ref109 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee89(params) {
5240
+ var _ref111 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee91(params) {
5164
5241
  var providerId, _params$successPageDu3, successPageDuration, subTitle, title, stampWith;
5165
- return _regeneratorRuntime().wrap(function _callee89$(_context89) {
5166
- while (1) switch (_context89.prev = _context89.next) {
5242
+ return _regeneratorRuntime().wrap(function _callee91$(_context91) {
5243
+ while (1) switch (_context91.prev = _context91.next) {
5167
5244
  case 0:
5168
5245
  providerId = params.providerId, _params$successPageDu3 = params.successPageDuration, successPageDuration = _params$successPageDu3 === void 0 ? 2000 : _params$successPageDu3, subTitle = params.subTitle, title = params.title, stampWith = params.stampWith;
5169
5246
  if (client) {
5170
- _context89.next = 3;
5247
+ _context91.next = 3;
5171
5248
  break;
5172
5249
  }
5173
5250
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5174
5251
  case 3:
5175
5252
  if (session) {
5176
- _context89.next = 5;
5253
+ _context91.next = 5;
5177
5254
  break;
5178
5255
  }
5179
5256
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
5180
5257
  case 5:
5181
- _context89.prev = 5;
5182
- return _context89.abrupt("return", new Promise(function (resolve, reject) {
5258
+ _context91.prev = 5;
5259
+ return _context91.abrupt("return", new Promise(function (resolve, reject) {
5183
5260
  pushPage({
5184
5261
  key: "Remove OAuth Provider",
5185
5262
  content: jsx(RemoveOAuthProvider, _objectSpread2(_objectSpread2({
@@ -5202,50 +5279,50 @@ var ClientProvider = function ClientProvider(_ref) {
5202
5279
  });
5203
5280
  }));
5204
5281
  case 9:
5205
- _context89.prev = 9;
5206
- _context89.t0 = _context89["catch"](5);
5207
- if (!(_context89.t0 instanceof TurnkeyError)) {
5208
- _context89.next = 13;
5282
+ _context91.prev = 9;
5283
+ _context91.t0 = _context91["catch"](5);
5284
+ if (!(_context91.t0 instanceof TurnkeyError)) {
5285
+ _context91.next = 13;
5209
5286
  break;
5210
5287
  }
5211
- throw _context89.t0;
5288
+ throw _context91.t0;
5212
5289
  case 13:
5213
- throw new TurnkeyError("Failed to remove OAuth provider in handler.", TurnkeyErrorCodes.REMOVE_OAUTH_PROVIDER_ERROR, _context89.t0);
5290
+ throw new TurnkeyError("Failed to remove OAuth provider in handler.", TurnkeyErrorCodes.REMOVE_OAUTH_PROVIDER_ERROR, _context91.t0);
5214
5291
  case 14:
5215
5292
  case "end":
5216
- return _context89.stop();
5293
+ return _context91.stop();
5217
5294
  }
5218
- }, _callee89, null, [[5, 9]]);
5295
+ }, _callee91, null, [[5, 9]]);
5219
5296
  }));
5220
- return function (_x78) {
5221
- return _ref109.apply(this, arguments);
5297
+ return function (_x80) {
5298
+ return _ref111.apply(this, arguments);
5222
5299
  };
5223
- }(), [pushPage]);
5300
+ }(), [pushPage, masterConfig, client, session, user]);
5224
5301
  var handleAddOauthProvider = useCallback(/*#__PURE__*/function () {
5225
- var _ref110 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee91(params) {
5302
+ var _ref112 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee93(params) {
5226
5303
  var providerName, stampWith, onOauthSuccess;
5227
- return _regeneratorRuntime().wrap(function _callee91$(_context91) {
5228
- while (1) switch (_context91.prev = _context91.next) {
5304
+ return _regeneratorRuntime().wrap(function _callee93$(_context93) {
5305
+ while (1) switch (_context93.prev = _context93.next) {
5229
5306
  case 0:
5230
5307
  if (client) {
5231
- _context91.next = 2;
5308
+ _context93.next = 2;
5232
5309
  break;
5233
5310
  }
5234
5311
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5235
5312
  case 2:
5236
5313
  if (session) {
5237
- _context91.next = 4;
5314
+ _context93.next = 4;
5238
5315
  break;
5239
5316
  }
5240
5317
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
5241
5318
  case 4:
5242
5319
  providerName = params.providerName, stampWith = params.stampWith;
5243
5320
  onOauthSuccess = /*#__PURE__*/function () {
5244
- var _ref111 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee90(params) {
5245
- return _regeneratorRuntime().wrap(function _callee90$(_context90) {
5246
- while (1) switch (_context90.prev = _context90.next) {
5321
+ var _ref113 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee92(params) {
5322
+ return _regeneratorRuntime().wrap(function _callee92$(_context92) {
5323
+ while (1) switch (_context92.prev = _context92.next) {
5247
5324
  case 0:
5248
- _context90.next = 2;
5325
+ _context92.next = 2;
5249
5326
  return addOauthProvider({
5250
5327
  providerName: params.providerName,
5251
5328
  oidcToken: params.oidcToken,
@@ -5266,99 +5343,99 @@ var ClientProvider = function ClientProvider(_ref) {
5266
5343
  });
5267
5344
  case 3:
5268
5345
  case "end":
5269
- return _context90.stop();
5346
+ return _context92.stop();
5270
5347
  }
5271
- }, _callee90);
5348
+ }, _callee92);
5272
5349
  }));
5273
- return function onOauthSuccess(_x80) {
5274
- return _ref111.apply(this, arguments);
5350
+ return function onOauthSuccess(_x82) {
5351
+ return _ref113.apply(this, arguments);
5275
5352
  };
5276
5353
  }();
5277
- _context91.t0 = providerName;
5278
- _context91.next = _context91.t0 === OAuthProviders.DISCORD ? 9 : _context91.t0 === OAuthProviders.X ? 12 : _context91.t0 === OAuthProviders.GOOGLE ? 15 : _context91.t0 === OAuthProviders.APPLE ? 18 : _context91.t0 === OAuthProviders.FACEBOOK ? 21 : 24;
5354
+ _context93.t0 = providerName;
5355
+ _context93.next = _context93.t0 === OAuthProviders.DISCORD ? 9 : _context93.t0 === OAuthProviders.X ? 12 : _context93.t0 === OAuthProviders.GOOGLE ? 15 : _context93.t0 === OAuthProviders.APPLE ? 18 : _context93.t0 === OAuthProviders.FACEBOOK ? 21 : 24;
5279
5356
  break;
5280
5357
  case 9:
5281
- _context91.next = 11;
5358
+ _context93.next = 11;
5282
5359
  return handleDiscordOauth({
5283
5360
  openInPage: false,
5284
5361
  onOauthSuccess: onOauthSuccess
5285
5362
  });
5286
5363
  case 11:
5287
- return _context91.abrupt("break", 25);
5364
+ return _context93.abrupt("break", 25);
5288
5365
  case 12:
5289
- _context91.next = 14;
5366
+ _context93.next = 14;
5290
5367
  return handleXOauth({
5291
5368
  openInPage: false,
5292
5369
  onOauthSuccess: onOauthSuccess
5293
5370
  });
5294
5371
  case 14:
5295
- return _context91.abrupt("break", 25);
5372
+ return _context93.abrupt("break", 25);
5296
5373
  case 15:
5297
- _context91.next = 17;
5374
+ _context93.next = 17;
5298
5375
  return handleGoogleOauth({
5299
5376
  openInPage: false,
5300
5377
  onOauthSuccess: onOauthSuccess
5301
5378
  });
5302
5379
  case 17:
5303
- return _context91.abrupt("break", 25);
5380
+ return _context93.abrupt("break", 25);
5304
5381
  case 18:
5305
- _context91.next = 20;
5382
+ _context93.next = 20;
5306
5383
  return handleAppleOauth({
5307
5384
  openInPage: false,
5308
5385
  onOauthSuccess: onOauthSuccess
5309
5386
  });
5310
5387
  case 20:
5311
- return _context91.abrupt("break", 25);
5388
+ return _context93.abrupt("break", 25);
5312
5389
  case 21:
5313
- _context91.next = 23;
5390
+ _context93.next = 23;
5314
5391
  return handleFacebookOauth({
5315
5392
  openInPage: false,
5316
5393
  onOauthSuccess: onOauthSuccess
5317
5394
  });
5318
5395
  case 23:
5319
- return _context91.abrupt("break", 25);
5396
+ return _context93.abrupt("break", 25);
5320
5397
  case 24:
5321
5398
  throw new TurnkeyError("Unsupported OAuth provider: ".concat(providerName), TurnkeyErrorCodes.NOT_FOUND);
5322
5399
  case 25:
5323
5400
  case "end":
5324
- return _context91.stop();
5401
+ return _context93.stop();
5325
5402
  }
5326
- }, _callee91);
5403
+ }, _callee93);
5327
5404
  }));
5328
- return function (_x79) {
5329
- return _ref110.apply(this, arguments);
5405
+ return function (_x81) {
5406
+ return _ref112.apply(this, arguments);
5330
5407
  };
5331
- }(), [pushPage]);
5408
+ }(), [pushPage, masterConfig, client, session, user]);
5332
5409
  var handleConnectExternalWallet = useCallback(/*#__PURE__*/function () {
5333
- var _ref112 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee92(params) {
5410
+ var _ref114 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee94(params) {
5334
5411
  var _masterConfig$walletC4, _masterConfig$walletC5;
5335
- var _ref113, _ref113$successPageDu, successPageDuration, providers;
5336
- return _regeneratorRuntime().wrap(function _callee92$(_context92) {
5337
- while (1) switch (_context92.prev = _context92.next) {
5412
+ var _ref115, _ref115$successPageDu, successPageDuration, providers;
5413
+ return _regeneratorRuntime().wrap(function _callee94$(_context94) {
5414
+ while (1) switch (_context94.prev = _context94.next) {
5338
5415
  case 0:
5339
- _ref113 = params || {}, _ref113$successPageDu = _ref113.successPageDuration, successPageDuration = _ref113$successPageDu === void 0 ? 2000 : _ref113$successPageDu;
5416
+ _ref115 = params || {}, _ref115$successPageDu = _ref115.successPageDuration, successPageDuration = _ref115$successPageDu === void 0 ? 2000 : _ref115$successPageDu;
5340
5417
  if (client) {
5341
- _context92.next = 3;
5418
+ _context94.next = 3;
5342
5419
  break;
5343
5420
  }
5344
5421
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5345
5422
  case 3:
5346
5423
  if (session) {
5347
- _context92.next = 5;
5424
+ _context94.next = 5;
5348
5425
  break;
5349
5426
  }
5350
5427
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
5351
5428
  case 5:
5352
5429
  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) {
5353
- _context92.next = 7;
5430
+ _context94.next = 7;
5354
5431
  break;
5355
5432
  }
5356
5433
  throw new TurnkeyError("Wallet connecting is not enabled.", TurnkeyErrorCodes.FEATURE_NOT_ENABLED);
5357
5434
  case 7:
5358
- _context92.next = 9;
5359
- return getWalletProviders();
5435
+ _context94.next = 9;
5436
+ return fetchWalletProviders();
5360
5437
  case 9:
5361
- providers = _context92.sent;
5438
+ providers = _context94.sent;
5362
5439
  pushPage({
5363
5440
  key: "Connect wallet",
5364
5441
  content: jsx(ConnectWalletModal, {
@@ -5368,29 +5445,29 @@ var ClientProvider = function ClientProvider(_ref) {
5368
5445
  });
5369
5446
  case 11:
5370
5447
  case "end":
5371
- return _context92.stop();
5448
+ return _context94.stop();
5372
5449
  }
5373
- }, _callee92);
5450
+ }, _callee94);
5374
5451
  }));
5375
- return function (_x81) {
5376
- return _ref112.apply(this, arguments);
5452
+ return function (_x83) {
5453
+ return _ref114.apply(this, arguments);
5377
5454
  };
5378
- }(), [pushPage]);
5455
+ }(), [pushPage, masterConfig, client, session, user]);
5379
5456
  var handleRemoveUserEmail = useCallback(/*#__PURE__*/function () {
5380
- var _ref114 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee93(params) {
5381
- var _ref115, _ref115$successPageDu, successPageDuration, stampWith, userId;
5382
- return _regeneratorRuntime().wrap(function _callee93$(_context93) {
5383
- while (1) switch (_context93.prev = _context93.next) {
5457
+ var _ref116 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee95(params) {
5458
+ var _ref117, _ref117$successPageDu, successPageDuration, stampWith, userId;
5459
+ return _regeneratorRuntime().wrap(function _callee95$(_context95) {
5460
+ while (1) switch (_context95.prev = _context95.next) {
5384
5461
  case 0:
5385
- _ref115 = params || {}, _ref115$successPageDu = _ref115.successPageDuration, successPageDuration = _ref115$successPageDu === void 0 ? 2000 : _ref115$successPageDu, stampWith = _ref115.stampWith, userId = _ref115.userId;
5462
+ _ref117 = params || {}, _ref117$successPageDu = _ref117.successPageDuration, successPageDuration = _ref117$successPageDu === void 0 ? 2000 : _ref117$successPageDu, stampWith = _ref117.stampWith, userId = _ref117.userId;
5386
5463
  if (session) {
5387
- _context93.next = 3;
5464
+ _context95.next = 3;
5388
5465
  break;
5389
5466
  }
5390
5467
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
5391
5468
  case 3:
5392
- _context93.prev = 3;
5393
- return _context93.abrupt("return", new Promise(function (resolve, reject) {
5469
+ _context95.prev = 3;
5470
+ return _context95.abrupt("return", new Promise(function (resolve, reject) {
5394
5471
  pushPage({
5395
5472
  key: "Remove Email",
5396
5473
  content: jsx(RemoveEmail, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5412,40 +5489,40 @@ var ClientProvider = function ClientProvider(_ref) {
5412
5489
  });
5413
5490
  }));
5414
5491
  case 7:
5415
- _context93.prev = 7;
5416
- _context93.t0 = _context93["catch"](3);
5417
- if (!(_context93.t0 instanceof TurnkeyError)) {
5418
- _context93.next = 11;
5492
+ _context95.prev = 7;
5493
+ _context95.t0 = _context95["catch"](3);
5494
+ if (!(_context95.t0 instanceof TurnkeyError)) {
5495
+ _context95.next = 11;
5419
5496
  break;
5420
5497
  }
5421
- throw _context93.t0;
5498
+ throw _context95.t0;
5422
5499
  case 11:
5423
- throw new TurnkeyError("Failed to remove user email.", TurnkeyErrorCodes.UPDATE_USER_EMAIL_ERROR, _context93.t0);
5500
+ throw new TurnkeyError("Failed to remove user email.", TurnkeyErrorCodes.UPDATE_USER_EMAIL_ERROR, _context95.t0);
5424
5501
  case 12:
5425
5502
  case "end":
5426
- return _context93.stop();
5503
+ return _context95.stop();
5427
5504
  }
5428
- }, _callee93, null, [[3, 7]]);
5505
+ }, _callee95, null, [[3, 7]]);
5429
5506
  }));
5430
- return function (_x82) {
5431
- return _ref114.apply(this, arguments);
5507
+ return function (_x84) {
5508
+ return _ref116.apply(this, arguments);
5432
5509
  };
5433
- }(), [pushPage]);
5510
+ }(), [pushPage, masterConfig, client, session, user]);
5434
5511
  var handleRemoveUserPhoneNumber = useCallback(/*#__PURE__*/function () {
5435
- var _ref116 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee94(params) {
5436
- var _ref117, _ref117$successPageDu, successPageDuration, stampWith, userId;
5437
- return _regeneratorRuntime().wrap(function _callee94$(_context94) {
5438
- while (1) switch (_context94.prev = _context94.next) {
5512
+ var _ref118 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee96(params) {
5513
+ var _ref119, _ref119$successPageDu, successPageDuration, stampWith, userId;
5514
+ return _regeneratorRuntime().wrap(function _callee96$(_context96) {
5515
+ while (1) switch (_context96.prev = _context96.next) {
5439
5516
  case 0:
5440
- _ref117 = params || {}, _ref117$successPageDu = _ref117.successPageDuration, successPageDuration = _ref117$successPageDu === void 0 ? 2000 : _ref117$successPageDu, stampWith = _ref117.stampWith, userId = _ref117.userId;
5517
+ _ref119 = params || {}, _ref119$successPageDu = _ref119.successPageDuration, successPageDuration = _ref119$successPageDu === void 0 ? 2000 : _ref119$successPageDu, stampWith = _ref119.stampWith, userId = _ref119.userId;
5441
5518
  if (session) {
5442
- _context94.next = 3;
5519
+ _context96.next = 3;
5443
5520
  break;
5444
5521
  }
5445
5522
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
5446
5523
  case 3:
5447
- _context94.prev = 3;
5448
- return _context94.abrupt("return", new Promise(function (resolve, reject) {
5524
+ _context96.prev = 3;
5525
+ return _context96.abrupt("return", new Promise(function (resolve, reject) {
5449
5526
  pushPage({
5450
5527
  key: "Remove Phone Number",
5451
5528
  content: jsx(RemovePhoneNumber, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5467,60 +5544,60 @@ var ClientProvider = function ClientProvider(_ref) {
5467
5544
  });
5468
5545
  }));
5469
5546
  case 7:
5470
- _context94.prev = 7;
5471
- _context94.t0 = _context94["catch"](3);
5472
- if (!(_context94.t0 instanceof TurnkeyError)) {
5473
- _context94.next = 11;
5547
+ _context96.prev = 7;
5548
+ _context96.t0 = _context96["catch"](3);
5549
+ if (!(_context96.t0 instanceof TurnkeyError)) {
5550
+ _context96.next = 11;
5474
5551
  break;
5475
5552
  }
5476
- throw _context94.t0;
5553
+ throw _context96.t0;
5477
5554
  case 11:
5478
- throw new TurnkeyError("Failed to remove user phone number.", TurnkeyErrorCodes.UPDATE_USER_PHONE_NUMBER_ERROR, _context94.t0);
5555
+ throw new TurnkeyError("Failed to remove user phone number.", TurnkeyErrorCodes.UPDATE_USER_PHONE_NUMBER_ERROR, _context96.t0);
5479
5556
  case 12:
5480
5557
  case "end":
5481
- return _context94.stop();
5558
+ return _context96.stop();
5482
5559
  }
5483
- }, _callee94, null, [[3, 7]]);
5560
+ }, _callee96, null, [[3, 7]]);
5484
5561
  }));
5485
- return function (_x83) {
5486
- return _ref116.apply(this, arguments);
5562
+ return function (_x85) {
5563
+ return _ref118.apply(this, arguments);
5487
5564
  };
5488
- }(), [pushPage]);
5565
+ }(), [pushPage, masterConfig, client, session, user]);
5489
5566
  useEffect(function () {
5490
5567
  if (proxyAuthConfigRef.current) return;
5491
5568
  // Only fetch the proxy auth config once. Use that to build the master config.
5492
5569
  var fetchProxyAuthConfig = /*#__PURE__*/function () {
5493
- var _ref118 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee95() {
5570
+ var _ref120 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee97() {
5494
5571
  var proxyAuthConfig;
5495
- return _regeneratorRuntime().wrap(function _callee95$(_context95) {
5496
- while (1) switch (_context95.prev = _context95.next) {
5572
+ return _regeneratorRuntime().wrap(function _callee97$(_context97) {
5573
+ while (1) switch (_context97.prev = _context97.next) {
5497
5574
  case 0:
5498
- _context95.prev = 0;
5575
+ _context97.prev = 0;
5499
5576
  if (!config.authProxyConfigId) {
5500
- _context95.next = 6;
5577
+ _context97.next = 6;
5501
5578
  break;
5502
5579
  }
5503
- _context95.next = 4;
5580
+ _context97.next = 4;
5504
5581
  return getAuthProxyConfig(config.authProxyConfigId, config.authProxyUrl);
5505
5582
  case 4:
5506
- proxyAuthConfig = _context95.sent;
5583
+ proxyAuthConfig = _context97.sent;
5507
5584
  proxyAuthConfigRef.current = proxyAuthConfig;
5508
5585
  case 6:
5509
5586
  setMasterConfig(buildConfig(proxyAuthConfig));
5510
- _context95.next = 12;
5587
+ _context97.next = 12;
5511
5588
  break;
5512
5589
  case 9:
5513
- _context95.prev = 9;
5514
- _context95.t0 = _context95["catch"](0);
5590
+ _context97.prev = 9;
5591
+ _context97.t0 = _context97["catch"](0);
5515
5592
  setClientState(ClientState.Error);
5516
5593
  case 12:
5517
5594
  case "end":
5518
- return _context95.stop();
5595
+ return _context97.stop();
5519
5596
  }
5520
- }, _callee95, null, [[0, 9]]);
5597
+ }, _callee97, null, [[0, 9]]);
5521
5598
  }));
5522
5599
  return function fetchProxyAuthConfig() {
5523
- return _ref118.apply(this, arguments);
5600
+ return _ref120.apply(this, arguments);
5524
5601
  };
5525
5602
  }();
5526
5603
  fetchProxyAuthConfig();
@@ -5551,24 +5628,24 @@ var ClientProvider = function ClientProvider(_ref) {
5551
5628
  useEffect(function () {
5552
5629
  if (!client) return;
5553
5630
  var handleRefreshWallets = /*#__PURE__*/function () {
5554
- var _ref119 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee96() {
5555
- return _regeneratorRuntime().wrap(function _callee96$(_context96) {
5556
- while (1) switch (_context96.prev = _context96.next) {
5631
+ var _ref121 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee98() {
5632
+ return _regeneratorRuntime().wrap(function _callee98$(_context98) {
5633
+ while (1) switch (_context98.prev = _context98.next) {
5557
5634
  case 0:
5558
5635
  if (!session) {
5559
- _context96.next = 3;
5636
+ _context98.next = 3;
5560
5637
  break;
5561
5638
  }
5562
- _context96.next = 3;
5639
+ _context98.next = 3;
5563
5640
  return debouncedRefreshWallets();
5564
5641
  case 3:
5565
5642
  case "end":
5566
- return _context96.stop();
5643
+ return _context98.stop();
5567
5644
  }
5568
- }, _callee96);
5645
+ }, _callee98);
5569
5646
  }));
5570
5647
  return function handleRefreshWallets() {
5571
- return _ref119.apply(this, arguments);
5648
+ return _ref121.apply(this, arguments);
5572
5649
  };
5573
5650
  }();
5574
5651
  var cleanup = function cleanup() {};
@@ -5618,7 +5695,7 @@ var ClientProvider = function ClientProvider(_ref) {
5618
5695
  logout: logout,
5619
5696
  loginWithPasskey: loginWithPasskey,
5620
5697
  signUpWithPasskey: signUpWithPasskey,
5621
- getWalletProviders: getWalletProviders,
5698
+ fetchWalletProviders: fetchWalletProviders,
5622
5699
  connectWalletAccount: connectWalletAccount,
5623
5700
  disconnectWalletAccount: disconnectWalletAccount,
5624
5701
  switchWalletAccountChain: switchWalletAccountChain,
@@ -5641,6 +5718,8 @@ var ClientProvider = function ClientProvider(_ref) {
5641
5718
  signTransaction: signTransaction,
5642
5719
  signAndSendTransaction: signAndSendTransaction,
5643
5720
  fetchUser: fetchUser,
5721
+ fetchOrCreateP256ApiKeyUser: fetchOrCreateP256ApiKeyUser,
5722
+ fetchOrCreatePolicies: fetchOrCreatePolicies,
5644
5723
  refreshUser: refreshUser,
5645
5724
  updateUserEmail: updateUserEmail,
5646
5725
  removeUserEmail: removeUserEmail,