@turnkey/react-wallet-kit 1.0.0-beta.2 → 1.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.MD +2 -1
  2. package/dist/components/export/Export.d.ts +2 -2
  3. package/dist/components/export/Export.d.ts.map +1 -1
  4. package/dist/components/export/Export.js +10 -3
  5. package/dist/components/export/Export.js.map +1 -1
  6. package/dist/components/export/Export.mjs +11 -4
  7. package/dist/components/export/Export.mjs.map +1 -1
  8. package/dist/components/export/ExportWarning.d.ts +2 -2
  9. package/dist/components/export/ExportWarning.d.ts.map +1 -1
  10. package/dist/components/export/ExportWarning.js +54 -14
  11. package/dist/components/export/ExportWarning.js.map +1 -1
  12. package/dist/components/export/ExportWarning.mjs +73 -22
  13. package/dist/components/export/ExportWarning.mjs.map +1 -1
  14. package/dist/components/import/Import.d.ts +0 -4
  15. package/dist/components/import/Import.d.ts.map +1 -1
  16. package/dist/components/import/Import.js +0 -5
  17. package/dist/components/import/Import.js.map +1 -1
  18. package/dist/components/import/Import.mjs +1 -6
  19. package/dist/components/import/Import.mjs.map +1 -1
  20. package/dist/providers/client/Provider.d.ts.map +1 -1
  21. package/dist/providers/client/Provider.js +109 -23
  22. package/dist/providers/client/Provider.js.map +1 -1
  23. package/dist/providers/client/Provider.mjs +1303 -1083
  24. package/dist/providers/client/Provider.mjs.map +1 -1
  25. package/dist/providers/client/Types.d.ts +52 -10
  26. package/dist/providers/client/Types.d.ts.map +1 -1
  27. package/dist/providers/client/Types.js.map +1 -1
  28. package/dist/providers/client/Types.mjs.map +1 -1
  29. package/dist/providers/modal/Root.js +22 -10
  30. package/dist/providers/modal/Root.js.map +1 -1
  31. package/dist/providers/modal/Root.mjs +20 -10
  32. package/dist/providers/modal/Root.mjs.map +1 -1
  33. package/dist/styles.css +1 -1
  34. package/dist/types/base.d.ts +6 -1
  35. package/dist/types/base.d.ts.map +1 -1
  36. package/dist/types/base.js +1 -0
  37. package/dist/types/base.js.map +1 -1
  38. package/dist/types/base.mjs +1 -0
  39. package/dist/types/base.mjs.map +1 -1
  40. package/package.json +12 -4
@@ -4,7 +4,7 @@ import { jsx } from 'react/jsx-runtime';
4
4
  import { sha256 } from '@noble/hashes/sha2';
5
5
  import { bytesToHex } from '@noble/hashes/utils';
6
6
  import { useDebouncedCallback, isValidSession, parseOAuthRedirect, handleFacebookPKCEFlow, SESSION_WARNING_THRESHOLD_MS, withTurnkeyErrorHandling, GOOGLE_AUTH_URL, popupWidth, popupHeight, APPLE_AUTH_URL, exchangeCodeForToken, FACEBOOK_AUTH_URL, generateChallengePair } from '../../utils.mjs';
7
- import { TurnkeyClient, Chain, getAuthProxyConfig, DEFAULT_SESSION_EXPIRATION_IN_SECONDS, OtpType } from '@turnkey/core';
7
+ import { TurnkeyClient, WalletInterfaceType, Chain, getAuthProxyConfig, DEFAULT_SESSION_EXPIRATION_IN_SECONDS, OtpType } from '@turnkey/core';
8
8
  import { useState, useRef, useEffect } from 'react';
9
9
  import { TurnkeyError, TurnkeyNetworkError, TurnkeyErrorCodes, OAuthProviders } from '@turnkey/sdk-types';
10
10
  import { useModal } from '../modal/Hook.mjs';
@@ -66,36 +66,32 @@ var ClientProvider = function ClientProvider(_ref) {
66
66
  _useState4 = _slicedToArray(_useState3, 2),
67
67
  session = _useState4[0],
68
68
  setSession = _useState4[1];
69
- var _useState5 = useState(false),
69
+ var _useState5 = useState(undefined),
70
70
  _useState6 = _slicedToArray(_useState5, 2),
71
- autoRefreshSession = _useState6[0],
72
- setAutoRefreshSession = _useState6[1];
73
- var _useState7 = useState(undefined),
71
+ masterConfig = _useState6[0],
72
+ setMasterConfig = _useState6[1];
73
+ var _useState7 = useState([]),
74
74
  _useState8 = _slicedToArray(_useState7, 2),
75
- masterConfig = _useState8[0],
76
- setMasterConfig = _useState8[1];
77
- var _useState9 = useState([]),
75
+ wallets = _useState8[0],
76
+ setWallets = _useState8[1];
77
+ var _useState9 = useState(undefined),
78
78
  _useState0 = _slicedToArray(_useState9, 2),
79
- wallets = _useState0[0],
80
- setWallets = _useState0[1];
81
- var _useState1 = useState(undefined),
79
+ user = _useState0[0],
80
+ setUser = _useState0[1];
81
+ var _useState1 = useState(),
82
82
  _useState10 = _slicedToArray(_useState1, 2),
83
- user = _useState10[0],
84
- setUser = _useState10[1];
85
- var _useState11 = useState(),
83
+ clientState = _useState10[0],
84
+ setClientState = _useState10[1];
85
+ var _useState11 = useState(AuthState.Unauthenticated),
86
86
  _useState12 = _slicedToArray(_useState11, 2),
87
- clientState = _useState12[0],
88
- setClientState = _useState12[1];
89
- var _useState13 = useState(AuthState.Unauthenticated),
90
- _useState14 = _slicedToArray(_useState13, 2),
91
- authState = _useState14[0],
92
- setAuthState = _useState14[1];
87
+ authState = _useState12[0],
88
+ setAuthState = _useState12[1];
93
89
  var expiryTimeoutsRef = useRef({});
94
90
  var proxyAuthConfigRef = useRef(null);
95
- var _useState15 = useState(undefined),
96
- _useState16 = _slicedToArray(_useState15, 2),
97
- allSessions = _useState16[0],
98
- setAllSessions = _useState16[1];
91
+ var _useState13 = useState(undefined),
92
+ _useState14 = _slicedToArray(_useState13, 2),
93
+ allSessions = _useState14[0],
94
+ setAllSessions = _useState14[1];
99
95
  var _useModal = useModal(),
100
96
  pushPage = _useModal.pushPage,
101
97
  closeModal = _useModal.closeModal;
@@ -173,7 +169,7 @@ var ClientProvider = function ClientProvider(_ref) {
173
169
  useEffect(function () {
174
170
  // authState must be consistent with session state. We found during testing that there are cases where the session and authState can be out of sync in very rare edge cases.
175
171
  // This will ensure that they are always in sync and remove the need to setAuthState manually in other places.
176
- if (session) {
172
+ if (session && isValidSession(session)) {
177
173
  setAuthState(AuthState.Authenticated);
178
174
  } else {
179
175
  setAuthState(AuthState.Unauthenticated);
@@ -397,7 +393,7 @@ var ClientProvider = function ClientProvider(_ref) {
397
393
  };
398
394
  }();
399
395
  var buildConfig = function buildConfig(proxyAuthConfig) {
400
- 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$oauthOrd, _config$auth8, _config$auth$methodOr, _config$auth9, _config$auth0, _config$auth1, _config$auth1$oauthCo, _config$walletConfig, _ref4, _resolvedMethods$wall, _config$walletConfig2, _config$walletConfig3, _config$walletConfig$, _config$walletConfig4, _config$walletConfig5, _config$walletConfig6, _config$walletConfig7, _config$walletConfig8, _config$walletConfig9, _config$walletConfig0, _config$importIframeU, _config$exportIframeU;
396
+ 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$oauthOrd, _config$auth8, _config$auth$methodOr, _config$auth9, _config$auth0, _config$auth1, _config$auth1$oauthCo, _config$auth$autoRefr, _config$auth10, _config$walletConfig, _ref4, _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;
401
397
  // Juggle the local overrides with the values set in the dashboard (proxyAuthConfig).
402
398
  var resolvedMethods = {
403
399
  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"),
@@ -423,7 +419,8 @@ var ClientProvider = function ClientProvider(_ref) {
423
419
  }),
424
420
  sessionExpirationSeconds: proxyAuthConfig === null || proxyAuthConfig === void 0 ? void 0 : proxyAuthConfig.sessionExpirationSeconds,
425
421
  methodOrder: methodOrder,
426
- oauthOrder: oauthOrder
422
+ oauthOrder: oauthOrder,
423
+ autoRefreshSession: (_config$auth$autoRefr = (_config$auth10 = config.auth) === null || _config$auth10 === void 0 ? void 0 : _config$auth10.autoRefreshSession) !== null && _config$auth$autoRefr !== void 0 ? _config$auth$autoRefr : true
427
424
  }),
428
425
  walletConfig: _objectSpread2(_objectSpread2({}, config.walletConfig), {}, {
429
426
  features: _objectSpread2(_objectSpread2({}, (_config$walletConfig = config.walletConfig) === null || _config$walletConfig === void 0 ? void 0 : _config$walletConfig.features), {}, {
@@ -433,10 +430,12 @@ var ClientProvider = function ClientProvider(_ref) {
433
430
  }),
434
431
  chains: _objectSpread2(_objectSpread2({}, (_config$walletConfig6 = config.walletConfig) === null || _config$walletConfig6 === void 0 ? void 0 : _config$walletConfig6.chains), {}, {
435
432
  ethereum: _objectSpread2(_objectSpread2({}, (_config$walletConfig7 = config.walletConfig) === null || _config$walletConfig7 === void 0 ? void 0 : (_config$walletConfig8 = _config$walletConfig7.chains) === null || _config$walletConfig8 === void 0 ? void 0 : _config$walletConfig8.ethereum), {}, {
436
- "native": true // Always enable native Ethereum support
433
+ // keep user's value if provided; default only when undefined
434
+ "native": (_config$walletConfig$2 = (_config$walletConfig9 = config.walletConfig) === null || _config$walletConfig9 === void 0 ? void 0 : (_config$walletConfig0 = _config$walletConfig9.chains) === null || _config$walletConfig0 === void 0 ? void 0 : (_config$walletConfig1 = _config$walletConfig0.ethereum) === null || _config$walletConfig1 === void 0 ? void 0 : _config$walletConfig1["native"]) !== null && _config$walletConfig$2 !== void 0 ? _config$walletConfig$2 : true
437
435
  }),
438
- solana: _objectSpread2(_objectSpread2({}, (_config$walletConfig9 = config.walletConfig) === null || _config$walletConfig9 === void 0 ? void 0 : (_config$walletConfig0 = _config$walletConfig9.chains) === null || _config$walletConfig0 === void 0 ? void 0 : _config$walletConfig0.solana), {}, {
439
- "native": true // Always enable native Solana support
436
+ solana: _objectSpread2(_objectSpread2({}, (_config$walletConfig10 = config.walletConfig) === null || _config$walletConfig10 === void 0 ? void 0 : (_config$walletConfig11 = _config$walletConfig10.chains) === null || _config$walletConfig11 === void 0 ? void 0 : _config$walletConfig11.solana), {}, {
437
+ // keep user's value if provided; default only when undefined
438
+ "native": (_config$walletConfig$3 = (_config$walletConfig12 = config.walletConfig) === null || _config$walletConfig12 === void 0 ? void 0 : (_config$walletConfig13 = _config$walletConfig12.chains) === null || _config$walletConfig13 === void 0 ? void 0 : (_config$walletConfig14 = _config$walletConfig13.solana) === null || _config$walletConfig14 === void 0 ? void 0 : _config$walletConfig14["native"]) !== null && _config$walletConfig$3 !== void 0 ? _config$walletConfig$3 : true
440
439
  })
441
440
  })
442
441
  }),
@@ -453,7 +452,7 @@ var ClientProvider = function ClientProvider(_ref) {
453
452
  */
454
453
  var initializeClient = /*#__PURE__*/function () {
455
454
  var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
456
- var _masterConfig$passkey, _masterConfig$passkey2, _masterConfig$passkey3, _masterConfig$passkey4, _masterConfig$walletC, _masterConfig$walletC2, _masterConfig$walletC3, _masterConfig$auth$au, _masterConfig$auth3, turnkeyClient, _callbacks$onError, _callbacks$onError2;
455
+ var _masterConfig$passkey, _masterConfig$passkey2, _masterConfig$passkey3, _masterConfig$passkey4, _masterConfig$walletC, _masterConfig$walletC2, _masterConfig$walletC3, turnkeyClient, _callbacks$onError, _callbacks$onError2;
457
456
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
458
457
  while (1) switch (_context5.prev = _context5.next) {
459
458
  case 0:
@@ -485,16 +484,15 @@ var ClientProvider = function ClientProvider(_ref) {
485
484
  walletConnect: masterConfig.walletConfig.walletConnect
486
485
  })
487
486
  });
488
- setAutoRefreshSession((_masterConfig$auth$au = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth3 = masterConfig.auth) === null || _masterConfig$auth3 === void 0 ? void 0 : _masterConfig$auth3.autoRefreshSession) !== null && _masterConfig$auth$au !== void 0 ? _masterConfig$auth$au : false);
489
- _context5.next = 8;
487
+ _context5.next = 7;
490
488
  return turnkeyClient.init();
491
- case 8:
489
+ case 7:
492
490
  setClient(turnkeyClient);
493
491
  // Don't set clientState to ready until we fetch the proxy auth config (See other fetchProxyAuthConfig useEffect)
494
- _context5.next = 15;
492
+ _context5.next = 14;
495
493
  break;
496
- case 11:
497
- _context5.prev = 11;
494
+ case 10:
495
+ _context5.prev = 10;
498
496
  _context5.t0 = _context5["catch"](2);
499
497
  setClientState(ClientState.Error);
500
498
  if (_context5.t0 instanceof TurnkeyError || _context5.t0 instanceof TurnkeyNetworkError) {
@@ -502,11 +500,11 @@ var ClientProvider = function ClientProvider(_ref) {
502
500
  } else {
503
501
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError2 = callbacks.onError) === null || _callbacks$onError2 === void 0 ? void 0 : _callbacks$onError2.call(callbacks, new TurnkeyError("Failed to initialize Turnkey client", TurnkeyErrorCodes.INITIALIZE_CLIENT_ERROR, _context5.t0));
504
502
  }
505
- case 15:
503
+ case 14:
506
504
  case "end":
507
505
  return _context5.stop();
508
506
  }
509
- }, _callee5, null, [[2, 11]]);
507
+ }, _callee5, null, [[2, 10]]);
510
508
  }));
511
509
  return function initializeClient() {
512
510
  return _ref5.apply(this, arguments);
@@ -518,31 +516,33 @@ var ClientProvider = function ClientProvider(_ref) {
518
516
  */
519
517
  var initializeSessions = /*#__PURE__*/function () {
520
518
  var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
521
- var _allSessions, activeSessionKey, _callbacks$onError3, _callbacks$onError4;
519
+ var allLocalStorageSessions, activeSessionKey, _callbacks$onError3, _callbacks$onError4;
522
520
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
523
521
  while (1) switch (_context7.prev = _context7.next) {
524
522
  case 0:
525
- _context7.prev = 0;
526
- _context7.next = 3;
523
+ setSession(undefined);
524
+ setAllSessions(undefined);
525
+ _context7.prev = 2;
526
+ _context7.next = 5;
527
527
  return getAllSessions();
528
- case 3:
529
- _allSessions = _context7.sent;
530
- if (_allSessions) {
531
- _context7.next = 6;
528
+ case 5:
529
+ allLocalStorageSessions = _context7.sent;
530
+ if (allLocalStorageSessions) {
531
+ _context7.next = 8;
532
532
  break;
533
533
  }
534
534
  return _context7.abrupt("return");
535
- case 6:
536
- _context7.next = 8;
537
- return Promise.all(Object.keys(_allSessions).map(/*#__PURE__*/function () {
535
+ case 8:
536
+ _context7.next = 10;
537
+ return Promise.all(Object.keys(allLocalStorageSessions).map(/*#__PURE__*/function () {
538
538
  var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(sessionKey) {
539
539
  var session;
540
540
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
541
541
  while (1) switch (_context6.prev = _context6.next) {
542
542
  case 0:
543
- session = _allSessions === null || _allSessions === void 0 ? void 0 : _allSessions[sessionKey];
543
+ session = allLocalStorageSessions === null || allLocalStorageSessions === void 0 ? void 0 : allLocalStorageSessions[sessionKey];
544
544
  if (isValidSession(session)) {
545
- _context6.next = 5;
545
+ _context6.next = 12;
546
546
  break;
547
547
  }
548
548
  _context6.next = 4;
@@ -550,13 +550,25 @@ var ClientProvider = function ClientProvider(_ref) {
550
550
  sessionKey: sessionKey
551
551
  });
552
552
  case 4:
553
+ _context6.t0 = sessionKey;
554
+ _context6.next = 7;
555
+ return getActiveSessionKey();
556
+ case 7:
557
+ _context6.t1 = _context6.sent;
558
+ if (!(_context6.t0 === _context6.t1)) {
559
+ _context6.next = 10;
560
+ break;
561
+ }
562
+ setSession(undefined);
563
+ case 10:
564
+ delete allLocalStorageSessions[sessionKey];
553
565
  return _context6.abrupt("return");
554
- case 5:
566
+ case 12:
555
567
  scheduleSessionExpiration({
556
568
  sessionKey: sessionKey,
557
569
  expiry: session.expiry
558
570
  });
559
- case 6:
571
+ case 13:
560
572
  case "end":
561
573
  return _context6.stop();
562
574
  }
@@ -566,40 +578,46 @@ var ClientProvider = function ClientProvider(_ref) {
566
578
  return _ref7.apply(this, arguments);
567
579
  };
568
580
  }()));
569
- case 8:
570
- setAllSessions(_allSessions);
571
- _context7.next = 11;
581
+ case 10:
582
+ setAllSessions(allLocalStorageSessions || undefined);
583
+ _context7.next = 13;
572
584
  return client === null || client === void 0 ? void 0 : client.getActiveSessionKey();
573
- case 11:
585
+ case 13:
574
586
  activeSessionKey = _context7.sent;
575
587
  if (!activeSessionKey) {
576
- _context7.next = 19;
588
+ _context7.next = 23;
589
+ break;
590
+ }
591
+ if (allLocalStorageSessions[activeSessionKey]) {
592
+ _context7.next = 17;
577
593
  break;
578
594
  }
579
- setSession(_allSessions === null || _allSessions === void 0 ? void 0 : _allSessions[activeSessionKey]);
580
- _context7.next = 16;
595
+ return _context7.abrupt("return");
596
+ case 17:
597
+ setSession(allLocalStorageSessions[activeSessionKey]);
598
+ _context7.next = 20;
581
599
  return refreshUser();
582
- case 16:
583
- _context7.next = 18;
600
+ case 20:
601
+ _context7.next = 22;
584
602
  return refreshWallets();
585
- case 18:
603
+ case 22:
586
604
  return _context7.abrupt("return");
587
- case 19:
588
- _context7.next = 24;
605
+ case 23:
606
+ _context7.next = 28;
589
607
  break;
590
- case 21:
591
- _context7.prev = 21;
592
- _context7.t0 = _context7["catch"](0);
608
+ case 25:
609
+ _context7.prev = 25;
610
+ _context7.t0 = _context7["catch"](2);
593
611
  if (_context7.t0 instanceof TurnkeyError || _context7.t0 instanceof TurnkeyNetworkError) {
594
612
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError3 = callbacks.onError) === null || _callbacks$onError3 === void 0 ? void 0 : _callbacks$onError3.call(callbacks, _context7.t0);
595
613
  } else {
596
614
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError4 = callbacks.onError) === null || _callbacks$onError4 === void 0 ? void 0 : _callbacks$onError4.call(callbacks, new TurnkeyError("Failed to initialize sessions", TurnkeyErrorCodes.INITIALIZE_SESSION_ERROR, _context7.t0));
597
615
  }
598
- case 24:
616
+ case 28:
599
617
  case "end":
600
618
  return _context7.stop();
601
619
  }
602
- }, _callee7, null, [[0, 21]]);
620
+ }, _callee7, null, [[2, 25]]);
603
621
  }));
604
622
  return function initializeSessions() {
605
623
  return _ref6.apply(this, arguments);
@@ -630,10 +648,10 @@ var ClientProvider = function ClientProvider(_ref) {
630
648
  * @throws {TurnkeyError} If an error occurs while clearing the timeouts.
631
649
  */
632
650
  function _scheduleSessionExpiration() {
633
- _scheduleSessionExpiration = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
651
+ _scheduleSessionExpiration = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
634
652
  var sessionKey, expiry, timeUntilExpiry, _beforeExpiry, expireSession, _callbacks$onError0, _callbacks$onError1;
635
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
636
- while (1) switch (_context29.prev = _context29.next) {
653
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
654
+ while (1) switch (_context31.prev = _context31.next) {
637
655
  case 0:
638
656
  sessionKey = params.sessionKey, expiry = params.expiry;
639
657
  try {
@@ -648,97 +666,114 @@ var ClientProvider = function ClientProvider(_ref) {
648
666
  }
649
667
  timeUntilExpiry = expiry * 1000 - Date.now();
650
668
  _beforeExpiry = /*#__PURE__*/function () {
651
- var _ref33 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
652
- var _callbacks$beforeSess;
669
+ var _ref35 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
670
+ var _callbacks$beforeSess, _masterConfig$auth5;
653
671
  var activeSession, session;
654
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
655
- while (1) switch (_context27.prev = _context27.next) {
672
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
673
+ while (1) switch (_context29.prev = _context29.next) {
656
674
  case 0:
657
- _context27.next = 2;
675
+ _context29.next = 2;
658
676
  return getSession();
659
677
  case 2:
660
- activeSession = _context27.sent;
678
+ activeSession = _context29.sent;
661
679
  if (!(!activeSession && expiryTimeoutsRef.current[sessionKey])) {
662
- _context27.next = 7;
680
+ _context29.next = 7;
663
681
  break;
664
682
  }
665
683
  clearTimeout(expiryTimeoutsRef.current["".concat(sessionKey, "-warning")]);
666
684
  expiryTimeoutsRef.current["".concat(sessionKey, "-warning")] = setTimeout(_beforeExpiry, 10000);
667
- return _context27.abrupt("return");
685
+ return _context29.abrupt("return");
668
686
  case 7:
669
- _context27.next = 9;
687
+ _context29.next = 9;
670
688
  return getSession({
671
689
  sessionKey: sessionKey
672
690
  });
673
691
  case 9:
674
- session = _context27.sent;
692
+ session = _context29.sent;
675
693
  if (session) {
676
- _context27.next = 12;
694
+ _context29.next = 12;
677
695
  break;
678
696
  }
679
- return _context27.abrupt("return");
697
+ return _context29.abrupt("return");
680
698
  case 12:
681
699
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$beforeSess = callbacks.beforeSessionExpiry) === null || _callbacks$beforeSess === void 0 ? void 0 : _callbacks$beforeSess.call(callbacks, {
682
700
  sessionKey: sessionKey
683
701
  });
684
- if (!autoRefreshSession) {
685
- _context27.next = 16;
702
+ if (!(masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth5 = masterConfig.auth) !== null && _masterConfig$auth5 !== void 0 && _masterConfig$auth5.autoRefreshSession)) {
703
+ _context29.next = 16;
686
704
  break;
687
705
  }
688
- _context27.next = 16;
706
+ _context29.next = 16;
689
707
  return refreshSession({
690
708
  expirationSeconds: session.expirationSeconds,
691
709
  sessionKey: sessionKey
692
710
  });
693
711
  case 16:
694
712
  case "end":
695
- return _context27.stop();
713
+ return _context29.stop();
696
714
  }
697
- }, _callee27);
715
+ }, _callee29);
698
716
  }));
699
717
  return function beforeExpiry() {
700
- return _ref33.apply(this, arguments);
718
+ return _ref35.apply(this, arguments);
701
719
  };
702
720
  }();
703
721
  expireSession = /*#__PURE__*/function () {
704
- var _ref34 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
722
+ var _ref36 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
705
723
  var _callbacks$onSessionE;
706
724
  var expiredSession;
707
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
708
- while (1) switch (_context28.prev = _context28.next) {
725
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
726
+ while (1) switch (_context30.prev = _context30.next) {
709
727
  case 0:
710
- _context28.next = 2;
728
+ _context30.next = 2;
711
729
  return getSession({
712
730
  sessionKey: sessionKey
713
731
  });
714
732
  case 2:
715
- expiredSession = _context28.sent;
733
+ expiredSession = _context30.sent;
716
734
  if (expiredSession) {
717
- _context28.next = 5;
735
+ _context30.next = 5;
718
736
  break;
719
737
  }
720
- return _context28.abrupt("return");
738
+ return _context30.abrupt("return");
721
739
  case 5:
722
740
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onSessionE = callbacks.onSessionExpired) === null || _callbacks$onSessionE === void 0 ? void 0 : _callbacks$onSessionE.call(callbacks, {
723
741
  sessionKey: sessionKey
724
742
  });
725
- _context28.next = 8;
743
+ _context30.next = 8;
744
+ return getActiveSessionKey();
745
+ case 8:
746
+ _context30.t0 = _context30.sent;
747
+ _context30.t1 = sessionKey;
748
+ if (!(_context30.t0 === _context30.t1)) {
749
+ _context30.next = 12;
750
+ break;
751
+ }
752
+ setSession(undefined);
753
+ case 12:
754
+ setAllSessions(function (prevSessions) {
755
+ if (!prevSessions) return prevSessions;
756
+ var newSessions = _objectSpread2({}, prevSessions);
757
+ delete newSessions[sessionKey];
758
+ return newSessions;
759
+ });
760
+ _context30.next = 15;
726
761
  return clearSession({
727
762
  sessionKey: sessionKey
728
763
  });
729
- case 8:
764
+ case 15:
730
765
  delete expiryTimeoutsRef.current[sessionKey];
731
766
  delete expiryTimeoutsRef.current["".concat(sessionKey, "-warning")];
732
- _context28.next = 12;
767
+ _context30.next = 19;
733
768
  return logout();
734
- case 12:
769
+ case 19:
735
770
  case "end":
736
- return _context28.stop();
771
+ return _context30.stop();
737
772
  }
738
- }, _callee28);
773
+ }, _callee30);
739
774
  }));
740
775
  return function expireSession() {
741
- return _ref34.apply(this, arguments);
776
+ return _ref36.apply(this, arguments);
742
777
  };
743
778
  }();
744
779
  if (timeUntilExpiry <= SESSION_WARNING_THRESHOLD_MS) {
@@ -756,9 +791,9 @@ var ClientProvider = function ClientProvider(_ref) {
756
791
  }
757
792
  case 2:
758
793
  case "end":
759
- return _context29.stop();
794
+ return _context31.stop();
760
795
  }
761
- }, _callee29);
796
+ }, _callee31);
762
797
  }));
763
798
  return _scheduleSessionExpiration.apply(this, arguments);
764
799
  }
@@ -792,7 +827,7 @@ var ClientProvider = function ClientProvider(_ref) {
792
827
  */
793
828
  var handlePostAuth = /*#__PURE__*/function () {
794
829
  var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
795
- var sessionKey, _session, _allSessions2, _callbacks$onError7, _callbacks$onError8;
830
+ var sessionKey, _session, _allSessions, _callbacks$onError7, _callbacks$onError8;
796
831
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
797
832
  while (1) switch (_context8.prev = _context8.next) {
798
833
  case 0:
@@ -820,9 +855,9 @@ var ClientProvider = function ClientProvider(_ref) {
820
855
  _context8.next = 12;
821
856
  return client.getAllSessions();
822
857
  case 12:
823
- _allSessions2 = _context8.sent;
858
+ _allSessions = _context8.sent;
824
859
  setSession(_session);
825
- setAllSessions(_allSessions2);
860
+ setAllSessions(_allSessions);
826
861
  _context8.next = 17;
827
862
  return refreshWallets();
828
863
  case 17:
@@ -878,24 +913,24 @@ var ClientProvider = function ClientProvider(_ref) {
878
913
  return _createPasskey.apply(this, arguments);
879
914
  }
880
915
  function _createPasskey() {
881
- _createPasskey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
882
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
883
- while (1) switch (_context30.prev = _context30.next) {
916
+ _createPasskey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
917
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
918
+ while (1) switch (_context32.prev = _context32.next) {
884
919
  case 0:
885
920
  if (client) {
886
- _context30.next = 2;
921
+ _context32.next = 2;
887
922
  break;
888
923
  }
889
924
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
890
925
  case 2:
891
- return _context30.abrupt("return", withTurnkeyErrorHandling(function () {
926
+ return _context32.abrupt("return", withTurnkeyErrorHandling(function () {
892
927
  return client.createPasskey(_objectSpread2({}, params));
893
928
  }, callbacks, "Failed to create passkey"));
894
929
  case 3:
895
930
  case "end":
896
- return _context30.stop();
931
+ return _context32.stop();
897
932
  }
898
- }, _callee30);
933
+ }, _callee32);
899
934
  }));
900
935
  return _createPasskey.apply(this, arguments);
901
936
  }
@@ -903,12 +938,12 @@ var ClientProvider = function ClientProvider(_ref) {
903
938
  return _logout.apply(this, arguments);
904
939
  }
905
940
  function _logout() {
906
- _logout = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
907
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
908
- while (1) switch (_context31.prev = _context31.next) {
941
+ _logout = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
942
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
943
+ while (1) switch (_context33.prev = _context33.next) {
909
944
  case 0:
910
945
  if (client) {
911
- _context31.next = 2;
946
+ _context33.next = 2;
912
947
  break;
913
948
  }
914
949
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
@@ -917,12 +952,12 @@ var ClientProvider = function ClientProvider(_ref) {
917
952
  return client.logout(params);
918
953
  }, callbacks, "Failed to logout");
919
954
  handlePostLogout();
920
- return _context31.abrupt("return");
955
+ return _context33.abrupt("return");
921
956
  case 5:
922
957
  case "end":
923
- return _context31.stop();
958
+ return _context33.stop();
924
959
  }
925
- }, _callee31);
960
+ }, _callee33);
926
961
  }));
927
962
  return _logout.apply(this, arguments);
928
963
  }
@@ -930,40 +965,40 @@ var ClientProvider = function ClientProvider(_ref) {
930
965
  return _loginWithPasskey.apply(this, arguments);
931
966
  }
932
967
  function _loginWithPasskey() {
933
- _loginWithPasskey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
968
+ _loginWithPasskey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
934
969
  var _masterConfig$auth$se, _masterConfig$auth6;
935
970
  var expirationSeconds, res;
936
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
937
- while (1) switch (_context32.prev = _context32.next) {
971
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
972
+ while (1) switch (_context34.prev = _context34.next) {
938
973
  case 0:
939
974
  if (client) {
940
- _context32.next = 2;
975
+ _context34.next = 2;
941
976
  break;
942
977
  }
943
978
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
944
979
  case 2:
945
980
  expirationSeconds = (_masterConfig$auth$se = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth6 = masterConfig.auth) === null || _masterConfig$auth6 === void 0 ? void 0 : _masterConfig$auth6.sessionExpirationSeconds) !== null && _masterConfig$auth$se !== void 0 ? _masterConfig$auth$se : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
946
- _context32.next = 5;
981
+ _context34.next = 5;
947
982
  return withTurnkeyErrorHandling(function () {
948
983
  return client.loginWithPasskey(_objectSpread2(_objectSpread2({}, params), {}, {
949
984
  expirationSeconds: expirationSeconds
950
985
  }));
951
986
  }, callbacks, "Failed to login with passkey");
952
987
  case 5:
953
- res = _context32.sent;
988
+ res = _context34.sent;
954
989
  if (!res) {
955
- _context32.next = 9;
990
+ _context34.next = 9;
956
991
  break;
957
992
  }
958
- _context32.next = 9;
993
+ _context34.next = 9;
959
994
  return handlePostAuth();
960
995
  case 9:
961
- return _context32.abrupt("return", res);
996
+ return _context34.abrupt("return", res);
962
997
  case 10:
963
998
  case "end":
964
- return _context32.stop();
999
+ return _context34.stop();
965
1000
  }
966
- }, _callee32);
1001
+ }, _callee34);
967
1002
  }));
968
1003
  return _loginWithPasskey.apply(this, arguments);
969
1004
  }
@@ -971,20 +1006,20 @@ var ClientProvider = function ClientProvider(_ref) {
971
1006
  return _signUpWithPasskey.apply(this, arguments);
972
1007
  }
973
1008
  function _signUpWithPasskey() {
974
- _signUpWithPasskey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
975
- var _params$createSubOrgP, _params, _masterConfig$auth7, _masterConfig$auth7$c, _masterConfig$auth$se2, _masterConfig$auth8, _ref35, _params$passkeyDispla, _params2, _masterConfig$auth9, _masterConfig$auth9$c, _masterConfig$auth9$c2;
1009
+ _signUpWithPasskey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
1010
+ var _params$createSubOrgP, _params, _masterConfig$auth7, _masterConfig$auth7$c, _masterConfig$auth$se2, _masterConfig$auth8, _ref37, _params$passkeyDispla, _params2, _masterConfig$auth9, _masterConfig$auth9$c, _masterConfig$auth9$c2;
976
1011
  var createSubOrgParams, expirationSeconds, websiteName, timestamp, passkeyName, res;
977
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
978
- while (1) switch (_context33.prev = _context33.next) {
1012
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
1013
+ while (1) switch (_context35.prev = _context35.next) {
979
1014
  case 0:
980
1015
  if (client) {
981
- _context33.next = 2;
1016
+ _context35.next = 2;
982
1017
  break;
983
1018
  }
984
1019
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
985
1020
  case 2:
986
1021
  if (masterConfig) {
987
- _context33.next = 4;
1022
+ _context35.next = 4;
988
1023
  break;
989
1024
  }
990
1025
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
@@ -1002,8 +1037,8 @@ var ClientProvider = function ClientProvider(_ref) {
1002
1037
  }); // We allow passkeyName to be passed in thru the provider or thru the params of this function directly.
1003
1038
  // This is because signUpWithPasskey will create a new passkey using that name.
1004
1039
  // Any extra authenticators will be created after the first one. (see core implementation)
1005
- passkeyName = (_ref35 = (_params$passkeyDispla = (_params2 = params) === null || _params2 === void 0 ? void 0 : _params2.passkeyDisplayName) !== null && _params$passkeyDispla !== void 0 ? _params$passkeyDispla : (_masterConfig$auth9 = masterConfig.auth) === null || _masterConfig$auth9 === void 0 ? void 0 : (_masterConfig$auth9$c = _masterConfig$auth9.createSuborgParams) === null || _masterConfig$auth9$c === void 0 ? void 0 : (_masterConfig$auth9$c2 = _masterConfig$auth9$c.passkeyAuth) === null || _masterConfig$auth9$c2 === void 0 ? void 0 : _masterConfig$auth9$c2.passkeyName) !== null && _ref35 !== void 0 ? _ref35 : "".concat(websiteName, "-").concat(timestamp);
1006
- _context33.next = 12;
1040
+ passkeyName = (_ref37 = (_params$passkeyDispla = (_params2 = params) === null || _params2 === void 0 ? void 0 : _params2.passkeyDisplayName) !== null && _params$passkeyDispla !== void 0 ? _params$passkeyDispla : (_masterConfig$auth9 = masterConfig.auth) === null || _masterConfig$auth9 === void 0 ? void 0 : (_masterConfig$auth9$c = _masterConfig$auth9.createSuborgParams) === null || _masterConfig$auth9$c === void 0 ? void 0 : (_masterConfig$auth9$c2 = _masterConfig$auth9$c.passkeyAuth) === null || _masterConfig$auth9$c2 === void 0 ? void 0 : _masterConfig$auth9$c2.passkeyName) !== null && _ref37 !== void 0 ? _ref37 : "".concat(websiteName, "-").concat(timestamp);
1041
+ _context35.next = 12;
1007
1042
  return withTurnkeyErrorHandling(function () {
1008
1043
  return client.signUpWithPasskey(_objectSpread2(_objectSpread2({}, params), {}, {
1009
1044
  passkeyDisplayName: passkeyName,
@@ -1011,20 +1046,20 @@ var ClientProvider = function ClientProvider(_ref) {
1011
1046
  }));
1012
1047
  }, callbacks, "Failed to sign up with passkey");
1013
1048
  case 12:
1014
- res = _context33.sent;
1049
+ res = _context35.sent;
1015
1050
  if (!res) {
1016
- _context33.next = 16;
1051
+ _context35.next = 16;
1017
1052
  break;
1018
1053
  }
1019
- _context33.next = 16;
1054
+ _context35.next = 16;
1020
1055
  return handlePostAuth();
1021
1056
  case 16:
1022
- return _context33.abrupt("return", res);
1057
+ return _context35.abrupt("return", res);
1023
1058
  case 17:
1024
1059
  case "end":
1025
- return _context33.stop();
1060
+ return _context35.stop();
1026
1061
  }
1027
- }, _callee33);
1062
+ }, _callee35);
1028
1063
  }));
1029
1064
  return _signUpWithPasskey.apply(this, arguments);
1030
1065
  }
@@ -1032,25 +1067,25 @@ var ClientProvider = function ClientProvider(_ref) {
1032
1067
  return _getWalletProviders.apply(this, arguments);
1033
1068
  }
1034
1069
  function _getWalletProviders() {
1035
- _getWalletProviders = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee34(chain) {
1036
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
1037
- while (1) switch (_context34.prev = _context34.next) {
1070
+ _getWalletProviders = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee36(chain) {
1071
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
1072
+ while (1) switch (_context36.prev = _context36.next) {
1038
1073
  case 0:
1039
1074
  if (client) {
1040
- _context34.next = 2;
1075
+ _context36.next = 2;
1041
1076
  break;
1042
1077
  }
1043
1078
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1044
1079
  case 2:
1045
- _context34.next = 4;
1080
+ _context36.next = 4;
1046
1081
  return client.getWalletProviders(chain);
1047
1082
  case 4:
1048
- return _context34.abrupt("return", _context34.sent);
1083
+ return _context36.abrupt("return", _context36.sent);
1049
1084
  case 5:
1050
1085
  case "end":
1051
- return _context34.stop();
1086
+ return _context36.stop();
1052
1087
  }
1053
- }, _callee34);
1088
+ }, _callee36);
1054
1089
  }));
1055
1090
  return _getWalletProviders.apply(this, arguments);
1056
1091
  }
@@ -1058,26 +1093,26 @@ var ClientProvider = function ClientProvider(_ref) {
1058
1093
  return _connectWalletAccount.apply(this, arguments);
1059
1094
  }
1060
1095
  function _connectWalletAccount() {
1061
- _connectWalletAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee35(walletProvider) {
1062
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
1063
- while (1) switch (_context35.prev = _context35.next) {
1096
+ _connectWalletAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee37(walletProvider) {
1097
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
1098
+ while (1) switch (_context37.prev = _context37.next) {
1064
1099
  case 0:
1065
1100
  if (client) {
1066
- _context35.next = 2;
1101
+ _context37.next = 2;
1067
1102
  break;
1068
1103
  }
1069
1104
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1070
1105
  case 2:
1071
- _context35.next = 4;
1106
+ _context37.next = 4;
1072
1107
  return client.connectWalletAccount(walletProvider);
1073
1108
  case 4:
1074
- _context35.next = 6;
1109
+ _context37.next = 6;
1075
1110
  return refreshWallets();
1076
1111
  case 6:
1077
1112
  case "end":
1078
- return _context35.stop();
1113
+ return _context37.stop();
1079
1114
  }
1080
- }, _callee35);
1115
+ }, _callee37);
1081
1116
  }));
1082
1117
  return _connectWalletAccount.apply(this, arguments);
1083
1118
  }
@@ -1085,30 +1120,30 @@ var ClientProvider = function ClientProvider(_ref) {
1085
1120
  return _disconnectWalletAccount.apply(this, arguments);
1086
1121
  }
1087
1122
  function _disconnectWalletAccount() {
1088
- _disconnectWalletAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee36(walletProvider) {
1089
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
1090
- while (1) switch (_context36.prev = _context36.next) {
1123
+ _disconnectWalletAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee38(walletProvider) {
1124
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
1125
+ while (1) switch (_context38.prev = _context38.next) {
1091
1126
  case 0:
1092
1127
  if (client) {
1093
- _context36.next = 2;
1128
+ _context38.next = 2;
1094
1129
  break;
1095
1130
  }
1096
1131
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1097
1132
  case 2:
1098
- _context36.next = 4;
1133
+ _context38.next = 4;
1099
1134
  return client.disconnectWalletAccount(walletProvider);
1100
1135
  case 4:
1101
1136
  if (!session) {
1102
- _context36.next = 7;
1137
+ _context38.next = 7;
1103
1138
  break;
1104
1139
  }
1105
- _context36.next = 7;
1140
+ _context38.next = 7;
1106
1141
  return refreshWallets();
1107
1142
  case 7:
1108
1143
  case "end":
1109
- return _context36.stop();
1144
+ return _context38.stop();
1110
1145
  }
1111
- }, _callee36);
1146
+ }, _callee38);
1112
1147
  }));
1113
1148
  return _disconnectWalletAccount.apply(this, arguments);
1114
1149
  }
@@ -1116,23 +1151,23 @@ var ClientProvider = function ClientProvider(_ref) {
1116
1151
  return _switchWalletProviderChain.apply(this, arguments);
1117
1152
  } // TODO: MOE PLEASE COMMENT THESE
1118
1153
  function _switchWalletProviderChain() {
1119
- _switchWalletProviderChain = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee37(walletProvider, chainOrId) {
1120
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
1121
- while (1) switch (_context37.prev = _context37.next) {
1154
+ _switchWalletProviderChain = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee39(walletProvider, chainOrId) {
1155
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
1156
+ while (1) switch (_context39.prev = _context39.next) {
1122
1157
  case 0:
1123
1158
  if (client) {
1124
- _context37.next = 2;
1159
+ _context39.next = 2;
1125
1160
  break;
1126
1161
  }
1127
1162
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1128
1163
  case 2:
1129
- _context37.next = 4;
1164
+ _context39.next = 4;
1130
1165
  return client.switchWalletProviderChain(walletProvider, chainOrId);
1131
1166
  case 4:
1132
1167
  case "end":
1133
- return _context37.stop();
1168
+ return _context39.stop();
1134
1169
  }
1135
- }, _callee37);
1170
+ }, _callee39);
1136
1171
  }));
1137
1172
  return _switchWalletProviderChain.apply(this, arguments);
1138
1173
  }
@@ -1140,10 +1175,11 @@ var ClientProvider = function ClientProvider(_ref) {
1140
1175
  return _initializeProviders.apply(this, arguments);
1141
1176
  }
1142
1177
  function _initializeProviders() {
1143
- _initializeProviders = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee38(getWalletProviders, onWalletsChanged) {
1144
- var cleanups, _yield$Promise$all, _yield$Promise$all2, ethProviders, solProviders, attachEthereumListeners, attachSolanaListeners;
1145
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
1146
- while (1) switch (_context38.prev = _context38.next) {
1178
+ _initializeProviders = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee40(getWalletProviders, onWalletsChanged) {
1179
+ var _masterConfig$walletC6, _masterConfig$walletC7, _masterConfig$walletC8, _masterConfig$walletC9;
1180
+ var cleanups, nativeOnly, ethProviders, solProviders, attachEthereumListeners, attachSolanaListeners;
1181
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
1182
+ while (1) switch (_context40.prev = _context40.next) {
1147
1183
  case 0:
1148
1184
  attachSolanaListeners = function _attachSolanaListener(provider, onWalletsChanged) {
1149
1185
  var _provider$features;
@@ -1184,14 +1220,39 @@ var ClientProvider = function ClientProvider(_ref) {
1184
1220
  provider.removeListener("disconnect", handleDisconnect);
1185
1221
  };
1186
1222
  };
1187
- cleanups = [];
1188
- _context38.next = 5;
1189
- return Promise.all([getWalletProviders(Chain.Ethereum), getWalletProviders(Chain.Solana)]);
1190
- case 5:
1191
- _yield$Promise$all = _context38.sent;
1192
- _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
1193
- ethProviders = _yield$Promise$all2[0];
1194
- solProviders = _yield$Promise$all2[1];
1223
+ cleanups = []; // we only want to initialize these listeners for native wallet providers
1224
+ // and not WalletConnect
1225
+ nativeOnly = function nativeOnly(p) {
1226
+ return p.interfaceType !== WalletInterfaceType.WalletConnect;
1227
+ };
1228
+ if (!(masterConfig !== null && masterConfig !== void 0 && (_masterConfig$walletC6 = masterConfig.walletConfig) !== null && _masterConfig$walletC6 !== void 0 && (_masterConfig$walletC7 = _masterConfig$walletC6.chains.ethereum) !== null && _masterConfig$walletC7 !== void 0 && _masterConfig$walletC7["native"])) {
1229
+ _context40.next = 10;
1230
+ break;
1231
+ }
1232
+ _context40.next = 7;
1233
+ return getWalletProviders(Chain.Ethereum);
1234
+ case 7:
1235
+ _context40.t0 = _context40.sent.filter(nativeOnly);
1236
+ _context40.next = 11;
1237
+ break;
1238
+ case 10:
1239
+ _context40.t0 = [];
1240
+ case 11:
1241
+ ethProviders = _context40.t0;
1242
+ if (!(masterConfig !== null && masterConfig !== void 0 && (_masterConfig$walletC8 = masterConfig.walletConfig) !== null && _masterConfig$walletC8 !== void 0 && (_masterConfig$walletC9 = _masterConfig$walletC8.chains.solana) !== null && _masterConfig$walletC9 !== void 0 && _masterConfig$walletC9["native"])) {
1243
+ _context40.next = 18;
1244
+ break;
1245
+ }
1246
+ _context40.next = 15;
1247
+ return getWalletProviders(Chain.Solana);
1248
+ case 15:
1249
+ _context40.t1 = _context40.sent.filter(nativeOnly);
1250
+ _context40.next = 19;
1251
+ break;
1252
+ case 18:
1253
+ _context40.t1 = [];
1254
+ case 19:
1255
+ solProviders = _context40.t1;
1195
1256
  ethProviders.forEach(function (p) {
1196
1257
  var cleanup = attachEthereumListeners(p.provider, onWalletsChanged);
1197
1258
  if (cleanup) cleanups.push(cleanup);
@@ -1200,16 +1261,16 @@ var ClientProvider = function ClientProvider(_ref) {
1200
1261
  var cleanup = attachSolanaListeners(p.provider, onWalletsChanged);
1201
1262
  if (cleanup) cleanups.push(cleanup);
1202
1263
  });
1203
- return _context38.abrupt("return", function () {
1264
+ return _context40.abrupt("return", function () {
1204
1265
  cleanups.forEach(function (remove) {
1205
1266
  return remove();
1206
1267
  });
1207
1268
  });
1208
- case 12:
1269
+ case 23:
1209
1270
  case "end":
1210
- return _context38.stop();
1271
+ return _context40.stop();
1211
1272
  }
1212
- }, _callee38);
1273
+ }, _callee40);
1213
1274
  }));
1214
1275
  return _initializeProviders.apply(this, arguments);
1215
1276
  }
@@ -1217,40 +1278,40 @@ var ClientProvider = function ClientProvider(_ref) {
1217
1278
  return _loginWithWallet.apply(this, arguments);
1218
1279
  }
1219
1280
  function _loginWithWallet() {
1220
- _loginWithWallet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
1281
+ _loginWithWallet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
1221
1282
  var _masterConfig$auth$se3, _masterConfig$auth0;
1222
1283
  var expirationSeconds, res;
1223
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
1224
- while (1) switch (_context39.prev = _context39.next) {
1284
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
1285
+ while (1) switch (_context41.prev = _context41.next) {
1225
1286
  case 0:
1226
1287
  if (client) {
1227
- _context39.next = 2;
1288
+ _context41.next = 2;
1228
1289
  break;
1229
1290
  }
1230
1291
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1231
1292
  case 2:
1232
1293
  expirationSeconds = (_masterConfig$auth$se3 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth0 = masterConfig.auth) === null || _masterConfig$auth0 === void 0 ? void 0 : _masterConfig$auth0.sessionExpirationSeconds) !== null && _masterConfig$auth$se3 !== void 0 ? _masterConfig$auth$se3 : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
1233
- _context39.next = 5;
1294
+ _context41.next = 5;
1234
1295
  return withTurnkeyErrorHandling(function () {
1235
1296
  return client.loginWithWallet(_objectSpread2(_objectSpread2({}, params), {}, {
1236
1297
  expirationSeconds: expirationSeconds
1237
1298
  }));
1238
1299
  }, callbacks, "Failed to login with wallet");
1239
1300
  case 5:
1240
- res = _context39.sent;
1301
+ res = _context41.sent;
1241
1302
  if (!res) {
1242
- _context39.next = 9;
1303
+ _context41.next = 9;
1243
1304
  break;
1244
1305
  }
1245
- _context39.next = 9;
1306
+ _context41.next = 9;
1246
1307
  return handlePostAuth();
1247
1308
  case 9:
1248
- return _context39.abrupt("return", res);
1309
+ return _context41.abrupt("return", res);
1249
1310
  case 10:
1250
1311
  case "end":
1251
- return _context39.stop();
1312
+ return _context41.stop();
1252
1313
  }
1253
- }, _callee39);
1314
+ }, _callee41);
1254
1315
  }));
1255
1316
  return _loginWithWallet.apply(this, arguments);
1256
1317
  }
@@ -1258,20 +1319,20 @@ var ClientProvider = function ClientProvider(_ref) {
1258
1319
  return _signUpWithWallet.apply(this, arguments);
1259
1320
  }
1260
1321
  function _signUpWithWallet() {
1261
- _signUpWithWallet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
1322
+ _signUpWithWallet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
1262
1323
  var _params$createSubOrgP2, _masterConfig$auth1, _masterConfig$auth1$c, _masterConfig$auth$se4, _masterConfig$auth10;
1263
1324
  var createSubOrgParams, expirationSeconds, res;
1264
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
1265
- while (1) switch (_context40.prev = _context40.next) {
1325
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
1326
+ while (1) switch (_context42.prev = _context42.next) {
1266
1327
  case 0:
1267
1328
  if (client) {
1268
- _context40.next = 2;
1329
+ _context42.next = 2;
1269
1330
  break;
1270
1331
  }
1271
1332
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1272
1333
  case 2:
1273
1334
  if (masterConfig) {
1274
- _context40.next = 4;
1335
+ _context42.next = 4;
1275
1336
  break;
1276
1337
  }
1277
1338
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
@@ -1282,30 +1343,30 @@ var ClientProvider = function ClientProvider(_ref) {
1282
1343
  createSubOrgParams: createSubOrgParams
1283
1344
  }) : _objectSpread2({}, params);
1284
1345
  expirationSeconds = (_masterConfig$auth$se4 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth10 = masterConfig.auth) === null || _masterConfig$auth10 === void 0 ? void 0 : _masterConfig$auth10.sessionExpirationSeconds) !== null && _masterConfig$auth$se4 !== void 0 ? _masterConfig$auth$se4 : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
1285
- _context40.next = 9;
1346
+ _context42.next = 9;
1286
1347
  return withTurnkeyErrorHandling(function () {
1287
1348
  return client.signUpWithWallet(_objectSpread2(_objectSpread2({}, params), {}, {
1288
1349
  expirationSeconds: expirationSeconds
1289
1350
  }));
1290
1351
  }, callbacks, "Failed to sign up with wallet");
1291
1352
  case 9:
1292
- res = _context40.sent;
1353
+ res = _context42.sent;
1293
1354
  if (!res) {
1294
- _context40.next = 15;
1355
+ _context42.next = 15;
1295
1356
  break;
1296
1357
  }
1297
- _context40.next = 13;
1358
+ _context42.next = 13;
1298
1359
  return handlePostAuth();
1299
1360
  case 13:
1300
- _context40.next = 15;
1361
+ _context42.next = 15;
1301
1362
  break;
1302
1363
  case 15:
1303
- return _context40.abrupt("return", res);
1364
+ return _context42.abrupt("return", res);
1304
1365
  case 16:
1305
1366
  case "end":
1306
- return _context40.stop();
1367
+ return _context42.stop();
1307
1368
  }
1308
- }, _callee40);
1369
+ }, _callee42);
1309
1370
  }));
1310
1371
  return _signUpWithWallet.apply(this, arguments);
1311
1372
  }
@@ -1313,20 +1374,20 @@ var ClientProvider = function ClientProvider(_ref) {
1313
1374
  return _loginOrSignupWithWallet.apply(this, arguments);
1314
1375
  }
1315
1376
  function _loginOrSignupWithWallet() {
1316
- _loginOrSignupWithWallet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
1377
+ _loginOrSignupWithWallet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
1317
1378
  var _params$createSubOrgP3, _masterConfig$auth11, _masterConfig$auth11$, _masterConfig$auth$se5, _masterConfig$auth12;
1318
1379
  var createSubOrgParams, expirationSeconds, res;
1319
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
1320
- while (1) switch (_context41.prev = _context41.next) {
1380
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
1381
+ while (1) switch (_context43.prev = _context43.next) {
1321
1382
  case 0:
1322
1383
  if (client) {
1323
- _context41.next = 2;
1384
+ _context43.next = 2;
1324
1385
  break;
1325
1386
  }
1326
1387
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1327
1388
  case 2:
1328
1389
  if (masterConfig) {
1329
- _context41.next = 4;
1390
+ _context43.next = 4;
1330
1391
  break;
1331
1392
  }
1332
1393
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
@@ -1337,30 +1398,30 @@ var ClientProvider = function ClientProvider(_ref) {
1337
1398
  createSubOrgParams: createSubOrgParams
1338
1399
  }) : _objectSpread2({}, params);
1339
1400
  expirationSeconds = (_masterConfig$auth$se5 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth12 = masterConfig.auth) === null || _masterConfig$auth12 === void 0 ? void 0 : _masterConfig$auth12.sessionExpirationSeconds) !== null && _masterConfig$auth$se5 !== void 0 ? _masterConfig$auth$se5 : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
1340
- _context41.next = 9;
1401
+ _context43.next = 9;
1341
1402
  return withTurnkeyErrorHandling(function () {
1342
1403
  return client.loginOrSignupWithWallet(_objectSpread2(_objectSpread2({}, params), {}, {
1343
1404
  expirationSeconds: expirationSeconds
1344
1405
  }));
1345
1406
  }, callbacks, "Failed to login or sign up with wallet");
1346
1407
  case 9:
1347
- res = _context41.sent;
1408
+ res = _context43.sent;
1348
1409
  if (!res) {
1349
- _context41.next = 15;
1410
+ _context43.next = 15;
1350
1411
  break;
1351
1412
  }
1352
- _context41.next = 13;
1413
+ _context43.next = 13;
1353
1414
  return handlePostAuth();
1354
1415
  case 13:
1355
- _context41.next = 15;
1416
+ _context43.next = 15;
1356
1417
  break;
1357
1418
  case 15:
1358
- return _context41.abrupt("return", res);
1419
+ return _context43.abrupt("return", res);
1359
1420
  case 16:
1360
1421
  case "end":
1361
- return _context41.stop();
1422
+ return _context43.stop();
1362
1423
  }
1363
- }, _callee41);
1424
+ }, _callee43);
1364
1425
  }));
1365
1426
  return _loginOrSignupWithWallet.apply(this, arguments);
1366
1427
  }
@@ -1368,24 +1429,24 @@ var ClientProvider = function ClientProvider(_ref) {
1368
1429
  return _initOtp.apply(this, arguments);
1369
1430
  }
1370
1431
  function _initOtp() {
1371
- _initOtp = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
1372
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
1373
- while (1) switch (_context42.prev = _context42.next) {
1432
+ _initOtp = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
1433
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
1434
+ while (1) switch (_context44.prev = _context44.next) {
1374
1435
  case 0:
1375
1436
  if (client) {
1376
- _context42.next = 2;
1437
+ _context44.next = 2;
1377
1438
  break;
1378
1439
  }
1379
1440
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1380
1441
  case 2:
1381
- return _context42.abrupt("return", withTurnkeyErrorHandling(function () {
1442
+ return _context44.abrupt("return", withTurnkeyErrorHandling(function () {
1382
1443
  return client.initOtp(params);
1383
1444
  }, callbacks, "Failed to initialize OTP"));
1384
1445
  case 3:
1385
1446
  case "end":
1386
- return _context42.stop();
1447
+ return _context44.stop();
1387
1448
  }
1388
- }, _callee42);
1449
+ }, _callee44);
1389
1450
  }));
1390
1451
  return _initOtp.apply(this, arguments);
1391
1452
  }
@@ -1393,24 +1454,24 @@ var ClientProvider = function ClientProvider(_ref) {
1393
1454
  return _verifyOtp.apply(this, arguments);
1394
1455
  }
1395
1456
  function _verifyOtp() {
1396
- _verifyOtp = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
1397
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
1398
- while (1) switch (_context43.prev = _context43.next) {
1457
+ _verifyOtp = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
1458
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
1459
+ while (1) switch (_context45.prev = _context45.next) {
1399
1460
  case 0:
1400
1461
  if (client) {
1401
- _context43.next = 2;
1462
+ _context45.next = 2;
1402
1463
  break;
1403
1464
  }
1404
1465
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1405
1466
  case 2:
1406
- return _context43.abrupt("return", withTurnkeyErrorHandling(function () {
1467
+ return _context45.abrupt("return", withTurnkeyErrorHandling(function () {
1407
1468
  return client.verifyOtp(params);
1408
1469
  }, callbacks, "Failed to verify OTP"));
1409
1470
  case 3:
1410
1471
  case "end":
1411
- return _context43.stop();
1472
+ return _context45.stop();
1412
1473
  }
1413
- }, _callee43);
1474
+ }, _callee45);
1414
1475
  }));
1415
1476
  return _verifyOtp.apply(this, arguments);
1416
1477
  }
@@ -1418,39 +1479,39 @@ var ClientProvider = function ClientProvider(_ref) {
1418
1479
  return _loginWithOtp.apply(this, arguments);
1419
1480
  }
1420
1481
  function _loginWithOtp() {
1421
- _loginWithOtp = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
1482
+ _loginWithOtp = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
1422
1483
  var res;
1423
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
1424
- while (1) switch (_context44.prev = _context44.next) {
1484
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
1485
+ while (1) switch (_context46.prev = _context46.next) {
1425
1486
  case 0:
1426
1487
  if (client) {
1427
- _context44.next = 2;
1488
+ _context46.next = 2;
1428
1489
  break;
1429
1490
  }
1430
1491
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1431
1492
  case 2:
1432
- _context44.next = 4;
1493
+ _context46.next = 4;
1433
1494
  return withTurnkeyErrorHandling(function () {
1434
1495
  return client.loginWithOtp(params);
1435
1496
  }, callbacks, "Failed to login with OTP");
1436
1497
  case 4:
1437
- res = _context44.sent;
1498
+ res = _context46.sent;
1438
1499
  if (!res) {
1439
- _context44.next = 10;
1500
+ _context46.next = 10;
1440
1501
  break;
1441
1502
  }
1442
- _context44.next = 8;
1503
+ _context46.next = 8;
1443
1504
  return handlePostAuth();
1444
1505
  case 8:
1445
- _context44.next = 10;
1506
+ _context46.next = 10;
1446
1507
  break;
1447
1508
  case 10:
1448
- return _context44.abrupt("return", res);
1509
+ return _context46.abrupt("return", res);
1449
1510
  case 11:
1450
1511
  case "end":
1451
- return _context44.stop();
1512
+ return _context46.stop();
1452
1513
  }
1453
- }, _callee44);
1514
+ }, _callee46);
1454
1515
  }));
1455
1516
  return _loginWithOtp.apply(this, arguments);
1456
1517
  }
@@ -1458,20 +1519,20 @@ var ClientProvider = function ClientProvider(_ref) {
1458
1519
  return _signUpWithOtp.apply(this, arguments);
1459
1520
  }
1460
1521
  function _signUpWithOtp() {
1461
- _signUpWithOtp = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
1522
+ _signUpWithOtp = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
1462
1523
  var _masterConfig$auth13;
1463
1524
  var createSubOrgParams, res;
1464
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
1465
- while (1) switch (_context45.prev = _context45.next) {
1525
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
1526
+ while (1) switch (_context47.prev = _context47.next) {
1466
1527
  case 0:
1467
1528
  if (client) {
1468
- _context45.next = 2;
1529
+ _context47.next = 2;
1469
1530
  break;
1470
1531
  }
1471
1532
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1472
1533
  case 2:
1473
1534
  if (masterConfig) {
1474
- _context45.next = 4;
1535
+ _context47.next = 4;
1475
1536
  break;
1476
1537
  }
1477
1538
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
@@ -1488,28 +1549,28 @@ var ClientProvider = function ClientProvider(_ref) {
1488
1549
  params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
1489
1550
  createSubOrgParams: createSubOrgParams
1490
1551
  }) : _objectSpread2({}, params);
1491
- _context45.next = 9;
1552
+ _context47.next = 9;
1492
1553
  return withTurnkeyErrorHandling(function () {
1493
1554
  return client.signUpWithOtp(params);
1494
1555
  }, callbacks, "Failed to sign up with OTP");
1495
1556
  case 9:
1496
- res = _context45.sent;
1557
+ res = _context47.sent;
1497
1558
  if (!res) {
1498
- _context45.next = 15;
1559
+ _context47.next = 15;
1499
1560
  break;
1500
1561
  }
1501
- _context45.next = 13;
1562
+ _context47.next = 13;
1502
1563
  return handlePostAuth();
1503
1564
  case 13:
1504
- _context45.next = 15;
1565
+ _context47.next = 15;
1505
1566
  break;
1506
1567
  case 15:
1507
- return _context45.abrupt("return", res);
1568
+ return _context47.abrupt("return", res);
1508
1569
  case 16:
1509
1570
  case "end":
1510
- return _context45.stop();
1571
+ return _context47.stop();
1511
1572
  }
1512
- }, _callee45);
1573
+ }, _callee47);
1513
1574
  }));
1514
1575
  return _signUpWithOtp.apply(this, arguments);
1515
1576
  }
@@ -1517,20 +1578,20 @@ var ClientProvider = function ClientProvider(_ref) {
1517
1578
  return _completeOtp.apply(this, arguments);
1518
1579
  }
1519
1580
  function _completeOtp() {
1520
- _completeOtp = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
1581
+ _completeOtp = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
1521
1582
  var _masterConfig$auth14;
1522
1583
  var createSubOrgParams, res;
1523
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
1524
- while (1) switch (_context46.prev = _context46.next) {
1584
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
1585
+ while (1) switch (_context48.prev = _context48.next) {
1525
1586
  case 0:
1526
1587
  if (client) {
1527
- _context46.next = 2;
1588
+ _context48.next = 2;
1528
1589
  break;
1529
1590
  }
1530
1591
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1531
1592
  case 2:
1532
1593
  if (masterConfig) {
1533
- _context46.next = 4;
1594
+ _context48.next = 4;
1534
1595
  break;
1535
1596
  }
1536
1597
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
@@ -1547,28 +1608,28 @@ var ClientProvider = function ClientProvider(_ref) {
1547
1608
  params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
1548
1609
  createSubOrgParams: createSubOrgParams
1549
1610
  }) : _objectSpread2({}, params);
1550
- _context46.next = 9;
1611
+ _context48.next = 9;
1551
1612
  return withTurnkeyErrorHandling(function () {
1552
1613
  return client.completeOtp(params);
1553
1614
  }, callbacks, "Failed to complete OTP");
1554
1615
  case 9:
1555
- res = _context46.sent;
1616
+ res = _context48.sent;
1556
1617
  if (!res) {
1557
- _context46.next = 15;
1618
+ _context48.next = 15;
1558
1619
  break;
1559
1620
  }
1560
- _context46.next = 13;
1621
+ _context48.next = 13;
1561
1622
  return handlePostAuth();
1562
1623
  case 13:
1563
- _context46.next = 15;
1624
+ _context48.next = 15;
1564
1625
  break;
1565
1626
  case 15:
1566
- return _context46.abrupt("return", res);
1627
+ return _context48.abrupt("return", res);
1567
1628
  case 16:
1568
1629
  case "end":
1569
- return _context46.stop();
1630
+ return _context48.stop();
1570
1631
  }
1571
- }, _callee46);
1632
+ }, _callee48);
1572
1633
  }));
1573
1634
  return _completeOtp.apply(this, arguments);
1574
1635
  }
@@ -1576,20 +1637,20 @@ var ClientProvider = function ClientProvider(_ref) {
1576
1637
  return _completeOauth.apply(this, arguments);
1577
1638
  }
1578
1639
  function _completeOauth() {
1579
- _completeOauth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
1640
+ _completeOauth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
1580
1641
  var _params$createSubOrgP4, _masterConfig$auth15, _masterConfig$auth15$;
1581
1642
  var createSubOrgParams, res;
1582
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
1583
- while (1) switch (_context47.prev = _context47.next) {
1643
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
1644
+ while (1) switch (_context49.prev = _context49.next) {
1584
1645
  case 0:
1585
1646
  if (client) {
1586
- _context47.next = 2;
1647
+ _context49.next = 2;
1587
1648
  break;
1588
1649
  }
1589
1650
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1590
1651
  case 2:
1591
1652
  if (masterConfig) {
1592
- _context47.next = 4;
1653
+ _context49.next = 4;
1593
1654
  break;
1594
1655
  }
1595
1656
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
@@ -1599,28 +1660,28 @@ var ClientProvider = function ClientProvider(_ref) {
1599
1660
  params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
1600
1661
  createSubOrgParams: createSubOrgParams
1601
1662
  }) : _objectSpread2({}, params);
1602
- _context47.next = 8;
1663
+ _context49.next = 8;
1603
1664
  return withTurnkeyErrorHandling(function () {
1604
1665
  return client.completeOauth(params);
1605
1666
  }, callbacks, "Failed to complete OAuth");
1606
1667
  case 8:
1607
- res = _context47.sent;
1668
+ res = _context49.sent;
1608
1669
  if (!res) {
1609
- _context47.next = 14;
1670
+ _context49.next = 14;
1610
1671
  break;
1611
1672
  }
1612
- _context47.next = 12;
1673
+ _context49.next = 12;
1613
1674
  return handlePostAuth();
1614
1675
  case 12:
1615
- _context47.next = 14;
1676
+ _context49.next = 14;
1616
1677
  break;
1617
1678
  case 14:
1618
- return _context47.abrupt("return", res);
1679
+ return _context49.abrupt("return", res);
1619
1680
  case 15:
1620
1681
  case "end":
1621
- return _context47.stop();
1682
+ return _context49.stop();
1622
1683
  }
1623
- }, _callee47);
1684
+ }, _callee49);
1624
1685
  }));
1625
1686
  return _completeOauth.apply(this, arguments);
1626
1687
  }
@@ -1628,39 +1689,39 @@ var ClientProvider = function ClientProvider(_ref) {
1628
1689
  return _loginWithOauth.apply(this, arguments);
1629
1690
  }
1630
1691
  function _loginWithOauth() {
1631
- _loginWithOauth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
1692
+ _loginWithOauth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
1632
1693
  var res;
1633
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
1634
- while (1) switch (_context48.prev = _context48.next) {
1694
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
1695
+ while (1) switch (_context50.prev = _context50.next) {
1635
1696
  case 0:
1636
1697
  if (client) {
1637
- _context48.next = 2;
1698
+ _context50.next = 2;
1638
1699
  break;
1639
1700
  }
1640
1701
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1641
1702
  case 2:
1642
- _context48.next = 4;
1703
+ _context50.next = 4;
1643
1704
  return withTurnkeyErrorHandling(function () {
1644
1705
  return client.loginWithOauth(params);
1645
1706
  }, callbacks, "Failed to login with OAuth");
1646
1707
  case 4:
1647
- res = _context48.sent;
1708
+ res = _context50.sent;
1648
1709
  if (!res) {
1649
- _context48.next = 10;
1710
+ _context50.next = 10;
1650
1711
  break;
1651
1712
  }
1652
- _context48.next = 8;
1713
+ _context50.next = 8;
1653
1714
  return handlePostAuth();
1654
1715
  case 8:
1655
- _context48.next = 10;
1716
+ _context50.next = 10;
1656
1717
  break;
1657
1718
  case 10:
1658
- return _context48.abrupt("return", res);
1719
+ return _context50.abrupt("return", res);
1659
1720
  case 11:
1660
1721
  case "end":
1661
- return _context48.stop();
1722
+ return _context50.stop();
1662
1723
  }
1663
- }, _callee48);
1724
+ }, _callee50);
1664
1725
  }));
1665
1726
  return _loginWithOauth.apply(this, arguments);
1666
1727
  }
@@ -1668,20 +1729,20 @@ var ClientProvider = function ClientProvider(_ref) {
1668
1729
  return _signUpWithOauth.apply(this, arguments);
1669
1730
  }
1670
1731
  function _signUpWithOauth() {
1671
- _signUpWithOauth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
1732
+ _signUpWithOauth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
1672
1733
  var _params$createSubOrgP5, _masterConfig$auth16, _masterConfig$auth16$;
1673
1734
  var createSubOrgParams, res;
1674
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
1675
- while (1) switch (_context49.prev = _context49.next) {
1735
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
1736
+ while (1) switch (_context51.prev = _context51.next) {
1676
1737
  case 0:
1677
1738
  if (client) {
1678
- _context49.next = 2;
1739
+ _context51.next = 2;
1679
1740
  break;
1680
1741
  }
1681
1742
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1682
1743
  case 2:
1683
1744
  if (masterConfig) {
1684
- _context49.next = 4;
1745
+ _context51.next = 4;
1685
1746
  break;
1686
1747
  }
1687
1748
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
@@ -1691,25 +1752,25 @@ var ClientProvider = function ClientProvider(_ref) {
1691
1752
  params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
1692
1753
  createSubOrgParams: createSubOrgParams
1693
1754
  }) : _objectSpread2({}, params);
1694
- _context49.next = 8;
1755
+ _context51.next = 8;
1695
1756
  return withTurnkeyErrorHandling(function () {
1696
1757
  return client.signUpWithOauth(params);
1697
1758
  }, callbacks, "Failed to sign up with OAuth");
1698
1759
  case 8:
1699
- res = _context49.sent;
1760
+ res = _context51.sent;
1700
1761
  if (!res) {
1701
- _context49.next = 12;
1762
+ _context51.next = 12;
1702
1763
  break;
1703
1764
  }
1704
- _context49.next = 12;
1765
+ _context51.next = 12;
1705
1766
  return handlePostAuth();
1706
1767
  case 12:
1707
- return _context49.abrupt("return", res);
1768
+ return _context51.abrupt("return", res);
1708
1769
  case 13:
1709
1770
  case "end":
1710
- return _context49.stop();
1771
+ return _context51.stop();
1711
1772
  }
1712
- }, _callee49);
1773
+ }, _callee51);
1713
1774
  }));
1714
1775
  return _signUpWithOauth.apply(this, arguments);
1715
1776
  }
@@ -1717,24 +1778,24 @@ var ClientProvider = function ClientProvider(_ref) {
1717
1778
  return _fetchWallets.apply(this, arguments);
1718
1779
  }
1719
1780
  function _fetchWallets() {
1720
- _fetchWallets = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
1721
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
1722
- while (1) switch (_context50.prev = _context50.next) {
1781
+ _fetchWallets = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
1782
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
1783
+ while (1) switch (_context52.prev = _context52.next) {
1723
1784
  case 0:
1724
1785
  if (client) {
1725
- _context50.next = 2;
1786
+ _context52.next = 2;
1726
1787
  break;
1727
1788
  }
1728
1789
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1729
1790
  case 2:
1730
- return _context50.abrupt("return", withTurnkeyErrorHandling(function () {
1791
+ return _context52.abrupt("return", withTurnkeyErrorHandling(function () {
1731
1792
  return client.fetchWallets(params);
1732
1793
  }, callbacks, "Failed to fetch wallets"));
1733
1794
  case 3:
1734
1795
  case "end":
1735
- return _context50.stop();
1796
+ return _context52.stop();
1736
1797
  }
1737
- }, _callee50);
1798
+ }, _callee52);
1738
1799
  }));
1739
1800
  return _fetchWallets.apply(this, arguments);
1740
1801
  }
@@ -1742,24 +1803,24 @@ var ClientProvider = function ClientProvider(_ref) {
1742
1803
  return _fetchWalletAccounts.apply(this, arguments);
1743
1804
  }
1744
1805
  function _fetchWalletAccounts() {
1745
- _fetchWalletAccounts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
1746
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
1747
- while (1) switch (_context51.prev = _context51.next) {
1806
+ _fetchWalletAccounts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
1807
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
1808
+ while (1) switch (_context53.prev = _context53.next) {
1748
1809
  case 0:
1749
1810
  if (client) {
1750
- _context51.next = 2;
1811
+ _context53.next = 2;
1751
1812
  break;
1752
1813
  }
1753
1814
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1754
1815
  case 2:
1755
- return _context51.abrupt("return", withTurnkeyErrorHandling(function () {
1816
+ return _context53.abrupt("return", withTurnkeyErrorHandling(function () {
1756
1817
  return client.fetchWalletAccounts(params);
1757
1818
  }, callbacks, "Failed to fetch wallet accounts"));
1758
1819
  case 3:
1759
1820
  case "end":
1760
- return _context51.stop();
1821
+ return _context53.stop();
1761
1822
  }
1762
- }, _callee51);
1823
+ }, _callee53);
1763
1824
  }));
1764
1825
  return _fetchWalletAccounts.apply(this, arguments);
1765
1826
  }
@@ -1767,24 +1828,24 @@ var ClientProvider = function ClientProvider(_ref) {
1767
1828
  return _signMessage.apply(this, arguments);
1768
1829
  }
1769
1830
  function _signMessage() {
1770
- _signMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
1771
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
1772
- while (1) switch (_context52.prev = _context52.next) {
1831
+ _signMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
1832
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
1833
+ while (1) switch (_context54.prev = _context54.next) {
1773
1834
  case 0:
1774
1835
  if (client) {
1775
- _context52.next = 2;
1836
+ _context54.next = 2;
1776
1837
  break;
1777
1838
  }
1778
1839
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1779
1840
  case 2:
1780
- return _context52.abrupt("return", withTurnkeyErrorHandling(function () {
1841
+ return _context54.abrupt("return", withTurnkeyErrorHandling(function () {
1781
1842
  return client.signMessage(params);
1782
1843
  }, callbacks, "Failed to sign message"));
1783
1844
  case 3:
1784
1845
  case "end":
1785
- return _context52.stop();
1846
+ return _context54.stop();
1786
1847
  }
1787
- }, _callee52);
1848
+ }, _callee54);
1788
1849
  }));
1789
1850
  return _signMessage.apply(this, arguments);
1790
1851
  }
@@ -1792,19 +1853,19 @@ var ClientProvider = function ClientProvider(_ref) {
1792
1853
  return _handleSignMessage.apply(this, arguments);
1793
1854
  }
1794
1855
  function _handleSignMessage() {
1795
- _handleSignMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
1856
+ _handleSignMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
1796
1857
  var _params$successPageDu3, successPageDuration;
1797
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
1798
- while (1) switch (_context53.prev = _context53.next) {
1858
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
1859
+ while (1) switch (_context55.prev = _context55.next) {
1799
1860
  case 0:
1800
1861
  _params$successPageDu3 = params.successPageDuration, successPageDuration = _params$successPageDu3 === void 0 ? 2000 : _params$successPageDu3;
1801
1862
  if (client) {
1802
- _context53.next = 3;
1863
+ _context55.next = 3;
1803
1864
  break;
1804
1865
  }
1805
1866
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1806
1867
  case 3:
1807
- return _context53.abrupt("return", new Promise(function (resolve, reject) {
1868
+ return _context55.abrupt("return", new Promise(function (resolve, reject) {
1808
1869
  pushPage({
1809
1870
  key: "Sign Message",
1810
1871
  content: jsx(SignMessageModal, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -1830,9 +1891,9 @@ var ClientProvider = function ClientProvider(_ref) {
1830
1891
  }));
1831
1892
  case 4:
1832
1893
  case "end":
1833
- return _context53.stop();
1894
+ return _context55.stop();
1834
1895
  }
1835
- }, _callee53);
1896
+ }, _callee55);
1836
1897
  }));
1837
1898
  return _handleSignMessage.apply(this, arguments);
1838
1899
  }
@@ -1840,24 +1901,24 @@ var ClientProvider = function ClientProvider(_ref) {
1840
1901
  return _signTransaction.apply(this, arguments);
1841
1902
  }
1842
1903
  function _signTransaction() {
1843
- _signTransaction = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
1844
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
1845
- while (1) switch (_context54.prev = _context54.next) {
1904
+ _signTransaction = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
1905
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
1906
+ while (1) switch (_context56.prev = _context56.next) {
1846
1907
  case 0:
1847
1908
  if (client) {
1848
- _context54.next = 2;
1909
+ _context56.next = 2;
1849
1910
  break;
1850
1911
  }
1851
1912
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1852
1913
  case 2:
1853
- return _context54.abrupt("return", withTurnkeyErrorHandling(function () {
1914
+ return _context56.abrupt("return", withTurnkeyErrorHandling(function () {
1854
1915
  return client.signTransaction(params);
1855
1916
  }, callbacks, "Failed to sign transaction"));
1856
1917
  case 3:
1857
1918
  case "end":
1858
- return _context54.stop();
1919
+ return _context56.stop();
1859
1920
  }
1860
- }, _callee54);
1921
+ }, _callee56);
1861
1922
  }));
1862
1923
  return _signTransaction.apply(this, arguments);
1863
1924
  }
@@ -1865,24 +1926,24 @@ var ClientProvider = function ClientProvider(_ref) {
1865
1926
  return _signAndSendTransaction.apply(this, arguments);
1866
1927
  }
1867
1928
  function _signAndSendTransaction() {
1868
- _signAndSendTransaction = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
1869
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
1870
- while (1) switch (_context55.prev = _context55.next) {
1929
+ _signAndSendTransaction = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
1930
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
1931
+ while (1) switch (_context57.prev = _context57.next) {
1871
1932
  case 0:
1872
1933
  if (client) {
1873
- _context55.next = 2;
1934
+ _context57.next = 2;
1874
1935
  break;
1875
1936
  }
1876
1937
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1877
1938
  case 2:
1878
- return _context55.abrupt("return", withTurnkeyErrorHandling(function () {
1939
+ return _context57.abrupt("return", withTurnkeyErrorHandling(function () {
1879
1940
  return client.signAndSendTransaction(params);
1880
1941
  }, callbacks, "Failed to sign transaction"));
1881
1942
  case 3:
1882
1943
  case "end":
1883
- return _context55.stop();
1944
+ return _context57.stop();
1884
1945
  }
1885
- }, _callee55);
1946
+ }, _callee57);
1886
1947
  }));
1887
1948
  return _signAndSendTransaction.apply(this, arguments);
1888
1949
  }
@@ -1890,24 +1951,24 @@ var ClientProvider = function ClientProvider(_ref) {
1890
1951
  return _fetchUser.apply(this, arguments);
1891
1952
  }
1892
1953
  function _fetchUser() {
1893
- _fetchUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
1894
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
1895
- while (1) switch (_context56.prev = _context56.next) {
1954
+ _fetchUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
1955
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
1956
+ while (1) switch (_context58.prev = _context58.next) {
1896
1957
  case 0:
1897
1958
  if (client) {
1898
- _context56.next = 2;
1959
+ _context58.next = 2;
1899
1960
  break;
1900
1961
  }
1901
1962
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1902
1963
  case 2:
1903
- return _context56.abrupt("return", withTurnkeyErrorHandling(function () {
1964
+ return _context58.abrupt("return", withTurnkeyErrorHandling(function () {
1904
1965
  return client.fetchUser(params);
1905
1966
  }, callbacks, "Failed to fetch user"));
1906
1967
  case 3:
1907
1968
  case "end":
1908
- return _context56.stop();
1969
+ return _context58.stop();
1909
1970
  }
1910
- }, _callee56);
1971
+ }, _callee58);
1911
1972
  }));
1912
1973
  return _fetchUser.apply(this, arguments);
1913
1974
  }
@@ -1915,38 +1976,38 @@ var ClientProvider = function ClientProvider(_ref) {
1915
1976
  return _updateUserEmail.apply(this, arguments);
1916
1977
  }
1917
1978
  function _updateUserEmail() {
1918
- _updateUserEmail = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
1979
+ _updateUserEmail = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
1919
1980
  var res;
1920
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
1921
- while (1) switch (_context57.prev = _context57.next) {
1981
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
1982
+ while (1) switch (_context59.prev = _context59.next) {
1922
1983
  case 0:
1923
1984
  if (client) {
1924
- _context57.next = 2;
1985
+ _context59.next = 2;
1925
1986
  break;
1926
1987
  }
1927
1988
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1928
1989
  case 2:
1929
- _context57.next = 4;
1990
+ _context59.next = 4;
1930
1991
  return withTurnkeyErrorHandling(function () {
1931
1992
  return client.updateUserEmail(params);
1932
1993
  }, callbacks, "Failed to update user email");
1933
1994
  case 4:
1934
- res = _context57.sent;
1995
+ res = _context59.sent;
1935
1996
  if (!res) {
1936
- _context57.next = 8;
1997
+ _context59.next = 8;
1937
1998
  break;
1938
1999
  }
1939
- _context57.next = 8;
2000
+ _context59.next = 8;
1940
2001
  return refreshUser({
1941
2002
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
1942
2003
  });
1943
2004
  case 8:
1944
- return _context57.abrupt("return", res);
2005
+ return _context59.abrupt("return", res);
1945
2006
  case 9:
1946
2007
  case "end":
1947
- return _context57.stop();
2008
+ return _context59.stop();
1948
2009
  }
1949
- }, _callee57);
2010
+ }, _callee59);
1950
2011
  }));
1951
2012
  return _updateUserEmail.apply(this, arguments);
1952
2013
  }
@@ -1954,38 +2015,38 @@ var ClientProvider = function ClientProvider(_ref) {
1954
2015
  return _removeUserEmail.apply(this, arguments);
1955
2016
  }
1956
2017
  function _removeUserEmail() {
1957
- _removeUserEmail = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
2018
+ _removeUserEmail = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
1958
2019
  var res;
1959
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
1960
- while (1) switch (_context58.prev = _context58.next) {
2020
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
2021
+ while (1) switch (_context60.prev = _context60.next) {
1961
2022
  case 0:
1962
2023
  if (client) {
1963
- _context58.next = 2;
2024
+ _context60.next = 2;
1964
2025
  break;
1965
2026
  }
1966
2027
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1967
2028
  case 2:
1968
- _context58.next = 4;
2029
+ _context60.next = 4;
1969
2030
  return withTurnkeyErrorHandling(function () {
1970
2031
  return client.removeUserEmail(params);
1971
2032
  }, callbacks, "Failed to remove user email");
1972
2033
  case 4:
1973
- res = _context58.sent;
2034
+ res = _context60.sent;
1974
2035
  if (!res) {
1975
- _context58.next = 8;
2036
+ _context60.next = 8;
1976
2037
  break;
1977
2038
  }
1978
- _context58.next = 8;
2039
+ _context60.next = 8;
1979
2040
  return refreshUser({
1980
2041
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
1981
2042
  });
1982
2043
  case 8:
1983
- return _context58.abrupt("return", res);
2044
+ return _context60.abrupt("return", res);
1984
2045
  case 9:
1985
2046
  case "end":
1986
- return _context58.stop();
2047
+ return _context60.stop();
1987
2048
  }
1988
- }, _callee58);
2049
+ }, _callee60);
1989
2050
  }));
1990
2051
  return _removeUserEmail.apply(this, arguments);
1991
2052
  }
@@ -1993,38 +2054,38 @@ var ClientProvider = function ClientProvider(_ref) {
1993
2054
  return _updateUserPhoneNumber.apply(this, arguments);
1994
2055
  }
1995
2056
  function _updateUserPhoneNumber() {
1996
- _updateUserPhoneNumber = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
2057
+ _updateUserPhoneNumber = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
1997
2058
  var res;
1998
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
1999
- while (1) switch (_context59.prev = _context59.next) {
2059
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
2060
+ while (1) switch (_context61.prev = _context61.next) {
2000
2061
  case 0:
2001
2062
  if (client) {
2002
- _context59.next = 2;
2063
+ _context61.next = 2;
2003
2064
  break;
2004
2065
  }
2005
2066
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2006
2067
  case 2:
2007
- _context59.next = 4;
2068
+ _context61.next = 4;
2008
2069
  return withTurnkeyErrorHandling(function () {
2009
2070
  return client.updateUserPhoneNumber(params);
2010
2071
  }, callbacks, "Failed to update user phone number");
2011
2072
  case 4:
2012
- res = _context59.sent;
2073
+ res = _context61.sent;
2013
2074
  if (!res) {
2014
- _context59.next = 8;
2075
+ _context61.next = 8;
2015
2076
  break;
2016
2077
  }
2017
- _context59.next = 8;
2078
+ _context61.next = 8;
2018
2079
  return refreshUser({
2019
2080
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2020
2081
  });
2021
2082
  case 8:
2022
- return _context59.abrupt("return", res);
2083
+ return _context61.abrupt("return", res);
2023
2084
  case 9:
2024
2085
  case "end":
2025
- return _context59.stop();
2086
+ return _context61.stop();
2026
2087
  }
2027
- }, _callee59);
2088
+ }, _callee61);
2028
2089
  }));
2029
2090
  return _updateUserPhoneNumber.apply(this, arguments);
2030
2091
  }
@@ -2032,38 +2093,38 @@ var ClientProvider = function ClientProvider(_ref) {
2032
2093
  return _removeUserPhoneNumber.apply(this, arguments);
2033
2094
  }
2034
2095
  function _removeUserPhoneNumber() {
2035
- _removeUserPhoneNumber = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
2096
+ _removeUserPhoneNumber = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
2036
2097
  var res;
2037
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
2038
- while (1) switch (_context60.prev = _context60.next) {
2098
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
2099
+ while (1) switch (_context62.prev = _context62.next) {
2039
2100
  case 0:
2040
2101
  if (client) {
2041
- _context60.next = 2;
2102
+ _context62.next = 2;
2042
2103
  break;
2043
2104
  }
2044
2105
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2045
2106
  case 2:
2046
- _context60.next = 4;
2107
+ _context62.next = 4;
2047
2108
  return withTurnkeyErrorHandling(function () {
2048
2109
  return client.removeUserPhoneNumber(params);
2049
2110
  }, callbacks, "Failed to remove user phone number");
2050
2111
  case 4:
2051
- res = _context60.sent;
2112
+ res = _context62.sent;
2052
2113
  if (!res) {
2053
- _context60.next = 8;
2114
+ _context62.next = 8;
2054
2115
  break;
2055
2116
  }
2056
- _context60.next = 8;
2117
+ _context62.next = 8;
2057
2118
  return refreshUser({
2058
2119
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2059
2120
  });
2060
2121
  case 8:
2061
- return _context60.abrupt("return", res);
2122
+ return _context62.abrupt("return", res);
2062
2123
  case 9:
2063
2124
  case "end":
2064
- return _context60.stop();
2125
+ return _context62.stop();
2065
2126
  }
2066
- }, _callee60);
2127
+ }, _callee62);
2067
2128
  }));
2068
2129
  return _removeUserPhoneNumber.apply(this, arguments);
2069
2130
  }
@@ -2071,38 +2132,38 @@ var ClientProvider = function ClientProvider(_ref) {
2071
2132
  return _updateUserName.apply(this, arguments);
2072
2133
  }
2073
2134
  function _updateUserName() {
2074
- _updateUserName = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
2135
+ _updateUserName = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
2075
2136
  var res;
2076
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
2077
- while (1) switch (_context61.prev = _context61.next) {
2137
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
2138
+ while (1) switch (_context63.prev = _context63.next) {
2078
2139
  case 0:
2079
2140
  if (client) {
2080
- _context61.next = 2;
2141
+ _context63.next = 2;
2081
2142
  break;
2082
2143
  }
2083
2144
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2084
2145
  case 2:
2085
- _context61.next = 4;
2146
+ _context63.next = 4;
2086
2147
  return withTurnkeyErrorHandling(function () {
2087
2148
  return client.updateUserName(params);
2088
2149
  }, callbacks, "Failed to update user name");
2089
2150
  case 4:
2090
- res = _context61.sent;
2151
+ res = _context63.sent;
2091
2152
  if (!res) {
2092
- _context61.next = 8;
2153
+ _context63.next = 8;
2093
2154
  break;
2094
2155
  }
2095
- _context61.next = 8;
2156
+ _context63.next = 8;
2096
2157
  return refreshUser({
2097
2158
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2098
2159
  });
2099
2160
  case 8:
2100
- return _context61.abrupt("return", res);
2161
+ return _context63.abrupt("return", res);
2101
2162
  case 9:
2102
2163
  case "end":
2103
- return _context61.stop();
2164
+ return _context63.stop();
2104
2165
  }
2105
- }, _callee61);
2166
+ }, _callee63);
2106
2167
  }));
2107
2168
  return _updateUserName.apply(this, arguments);
2108
2169
  }
@@ -2110,38 +2171,38 @@ var ClientProvider = function ClientProvider(_ref) {
2110
2171
  return _addOauthProvider.apply(this, arguments);
2111
2172
  }
2112
2173
  function _addOauthProvider() {
2113
- _addOauthProvider = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
2174
+ _addOauthProvider = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
2114
2175
  var res;
2115
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
2116
- while (1) switch (_context62.prev = _context62.next) {
2176
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
2177
+ while (1) switch (_context64.prev = _context64.next) {
2117
2178
  case 0:
2118
2179
  if (client) {
2119
- _context62.next = 2;
2180
+ _context64.next = 2;
2120
2181
  break;
2121
2182
  }
2122
2183
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2123
2184
  case 2:
2124
- _context62.next = 4;
2185
+ _context64.next = 4;
2125
2186
  return withTurnkeyErrorHandling(function () {
2126
2187
  return client.addOauthProvider(params);
2127
2188
  }, callbacks, "Failed to add OAuth provider");
2128
2189
  case 4:
2129
- res = _context62.sent;
2190
+ res = _context64.sent;
2130
2191
  if (!res) {
2131
- _context62.next = 8;
2192
+ _context64.next = 8;
2132
2193
  break;
2133
2194
  }
2134
- _context62.next = 8;
2195
+ _context64.next = 8;
2135
2196
  return refreshUser({
2136
2197
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2137
2198
  });
2138
2199
  case 8:
2139
- return _context62.abrupt("return", res);
2200
+ return _context64.abrupt("return", res);
2140
2201
  case 9:
2141
2202
  case "end":
2142
- return _context62.stop();
2203
+ return _context64.stop();
2143
2204
  }
2144
- }, _callee62);
2205
+ }, _callee64);
2145
2206
  }));
2146
2207
  return _addOauthProvider.apply(this, arguments);
2147
2208
  }
@@ -2149,38 +2210,38 @@ var ClientProvider = function ClientProvider(_ref) {
2149
2210
  return _removeOauthProviders.apply(this, arguments);
2150
2211
  }
2151
2212
  function _removeOauthProviders() {
2152
- _removeOauthProviders = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
2213
+ _removeOauthProviders = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee65(params) {
2153
2214
  var res;
2154
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
2155
- while (1) switch (_context63.prev = _context63.next) {
2215
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
2216
+ while (1) switch (_context65.prev = _context65.next) {
2156
2217
  case 0:
2157
2218
  if (client) {
2158
- _context63.next = 2;
2219
+ _context65.next = 2;
2159
2220
  break;
2160
2221
  }
2161
2222
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2162
2223
  case 2:
2163
- _context63.next = 4;
2224
+ _context65.next = 4;
2164
2225
  return withTurnkeyErrorHandling(function () {
2165
2226
  return client.removeOauthProviders(params);
2166
2227
  }, callbacks, "Failed to remove OAuth providers");
2167
2228
  case 4:
2168
- res = _context63.sent;
2229
+ res = _context65.sent;
2169
2230
  if (!res) {
2170
- _context63.next = 8;
2231
+ _context65.next = 8;
2171
2232
  break;
2172
2233
  }
2173
- _context63.next = 8;
2234
+ _context65.next = 8;
2174
2235
  return refreshUser({
2175
2236
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2176
2237
  });
2177
2238
  case 8:
2178
- return _context63.abrupt("return", res);
2239
+ return _context65.abrupt("return", res);
2179
2240
  case 9:
2180
2241
  case "end":
2181
- return _context63.stop();
2242
+ return _context65.stop();
2182
2243
  }
2183
- }, _callee63);
2244
+ }, _callee65);
2184
2245
  }));
2185
2246
  return _removeOauthProviders.apply(this, arguments);
2186
2247
  }
@@ -2188,38 +2249,38 @@ var ClientProvider = function ClientProvider(_ref) {
2188
2249
  return _addPasskey.apply(this, arguments);
2189
2250
  }
2190
2251
  function _addPasskey() {
2191
- _addPasskey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
2252
+ _addPasskey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee66(params) {
2192
2253
  var res;
2193
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
2194
- while (1) switch (_context64.prev = _context64.next) {
2254
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
2255
+ while (1) switch (_context66.prev = _context66.next) {
2195
2256
  case 0:
2196
2257
  if (client) {
2197
- _context64.next = 2;
2258
+ _context66.next = 2;
2198
2259
  break;
2199
2260
  }
2200
2261
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2201
2262
  case 2:
2202
- _context64.next = 4;
2263
+ _context66.next = 4;
2203
2264
  return withTurnkeyErrorHandling(function () {
2204
2265
  return client.addPasskey(params);
2205
2266
  }, callbacks, "Failed to add passkey");
2206
2267
  case 4:
2207
- res = _context64.sent;
2268
+ res = _context66.sent;
2208
2269
  if (!res) {
2209
- _context64.next = 8;
2270
+ _context66.next = 8;
2210
2271
  break;
2211
2272
  }
2212
- _context64.next = 8;
2273
+ _context66.next = 8;
2213
2274
  return refreshUser({
2214
2275
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2215
2276
  });
2216
2277
  case 8:
2217
- return _context64.abrupt("return", res);
2278
+ return _context66.abrupt("return", res);
2218
2279
  case 9:
2219
2280
  case "end":
2220
- return _context64.stop();
2281
+ return _context66.stop();
2221
2282
  }
2222
- }, _callee64);
2283
+ }, _callee66);
2223
2284
  }));
2224
2285
  return _addPasskey.apply(this, arguments);
2225
2286
  }
@@ -2227,38 +2288,38 @@ var ClientProvider = function ClientProvider(_ref) {
2227
2288
  return _removePasskeys.apply(this, arguments);
2228
2289
  }
2229
2290
  function _removePasskeys() {
2230
- _removePasskeys = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee65(params) {
2291
+ _removePasskeys = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee67(params) {
2231
2292
  var res;
2232
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
2233
- while (1) switch (_context65.prev = _context65.next) {
2293
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
2294
+ while (1) switch (_context67.prev = _context67.next) {
2234
2295
  case 0:
2235
2296
  if (client) {
2236
- _context65.next = 2;
2297
+ _context67.next = 2;
2237
2298
  break;
2238
2299
  }
2239
2300
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2240
2301
  case 2:
2241
- _context65.next = 4;
2302
+ _context67.next = 4;
2242
2303
  return withTurnkeyErrorHandling(function () {
2243
2304
  return client.removePasskeys(params);
2244
2305
  }, callbacks, "Failed to remove passkeys");
2245
2306
  case 4:
2246
- res = _context65.sent;
2307
+ res = _context67.sent;
2247
2308
  if (!res) {
2248
- _context65.next = 8;
2309
+ _context67.next = 8;
2249
2310
  break;
2250
2311
  }
2251
- _context65.next = 8;
2312
+ _context67.next = 8;
2252
2313
  return refreshUser({
2253
2314
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2254
2315
  });
2255
2316
  case 8:
2256
- return _context65.abrupt("return", res);
2317
+ return _context67.abrupt("return", res);
2257
2318
  case 9:
2258
2319
  case "end":
2259
- return _context65.stop();
2320
+ return _context67.stop();
2260
2321
  }
2261
- }, _callee65);
2322
+ }, _callee67);
2262
2323
  }));
2263
2324
  return _removePasskeys.apply(this, arguments);
2264
2325
  }
@@ -2266,38 +2327,38 @@ var ClientProvider = function ClientProvider(_ref) {
2266
2327
  return _createWallet.apply(this, arguments);
2267
2328
  }
2268
2329
  function _createWallet() {
2269
- _createWallet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee66(params) {
2330
+ _createWallet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
2270
2331
  var res;
2271
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
2272
- while (1) switch (_context66.prev = _context66.next) {
2332
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
2333
+ while (1) switch (_context68.prev = _context68.next) {
2273
2334
  case 0:
2274
2335
  if (client) {
2275
- _context66.next = 2;
2336
+ _context68.next = 2;
2276
2337
  break;
2277
2338
  }
2278
2339
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2279
2340
  case 2:
2280
- _context66.next = 4;
2341
+ _context68.next = 4;
2281
2342
  return withTurnkeyErrorHandling(function () {
2282
2343
  return client.createWallet(params);
2283
2344
  }, callbacks, "Failed to create wallet");
2284
2345
  case 4:
2285
- res = _context66.sent;
2346
+ res = _context68.sent;
2286
2347
  if (!res) {
2287
- _context66.next = 8;
2348
+ _context68.next = 8;
2288
2349
  break;
2289
2350
  }
2290
- _context66.next = 8;
2351
+ _context68.next = 8;
2291
2352
  return refreshWallets({
2292
2353
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2293
2354
  });
2294
2355
  case 8:
2295
- return _context66.abrupt("return", res);
2356
+ return _context68.abrupt("return", res);
2296
2357
  case 9:
2297
2358
  case "end":
2298
- return _context66.stop();
2359
+ return _context68.stop();
2299
2360
  }
2300
- }, _callee66);
2361
+ }, _callee68);
2301
2362
  }));
2302
2363
  return _createWallet.apply(this, arguments);
2303
2364
  }
@@ -2305,235 +2366,334 @@ var ClientProvider = function ClientProvider(_ref) {
2305
2366
  return _createWalletAccounts.apply(this, arguments);
2306
2367
  }
2307
2368
  function _createWalletAccounts() {
2308
- _createWalletAccounts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee67(params) {
2369
+ _createWalletAccounts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee69(params) {
2309
2370
  var res;
2310
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
2311
- while (1) switch (_context67.prev = _context67.next) {
2371
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
2372
+ while (1) switch (_context69.prev = _context69.next) {
2312
2373
  case 0:
2313
2374
  if (client) {
2314
- _context67.next = 2;
2375
+ _context69.next = 2;
2315
2376
  break;
2316
2377
  }
2317
2378
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2318
2379
  case 2:
2319
- _context67.next = 4;
2380
+ _context69.next = 4;
2320
2381
  return withTurnkeyErrorHandling(function () {
2321
2382
  return client.createWalletAccounts(params);
2322
2383
  }, callbacks, "Failed to create wallet accounts");
2323
2384
  case 4:
2324
- res = _context67.sent;
2385
+ res = _context69.sent;
2325
2386
  if (!res) {
2326
- _context67.next = 8;
2387
+ _context69.next = 8;
2327
2388
  break;
2328
2389
  }
2329
- _context67.next = 8;
2390
+ _context69.next = 8;
2330
2391
  return refreshWallets({
2331
2392
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2332
2393
  });
2333
2394
  case 8:
2334
- return _context67.abrupt("return", res);
2395
+ return _context69.abrupt("return", res);
2335
2396
  case 9:
2336
2397
  case "end":
2337
- return _context67.stop();
2398
+ return _context69.stop();
2399
+ }
2400
+ }, _callee69);
2401
+ }));
2402
+ return _createWalletAccounts.apply(this, arguments);
2403
+ }
2404
+ function exportWallet(_x41) {
2405
+ return _exportWallet.apply(this, arguments);
2406
+ }
2407
+ function _exportWallet() {
2408
+ _exportWallet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
2409
+ var res;
2410
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
2411
+ while (1) switch (_context70.prev = _context70.next) {
2412
+ case 0:
2413
+ if (client) {
2414
+ _context70.next = 2;
2415
+ break;
2416
+ }
2417
+ throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2418
+ case 2:
2419
+ _context70.next = 4;
2420
+ return withTurnkeyErrorHandling(function () {
2421
+ return client.exportWallet(params);
2422
+ }, callbacks, "Failed to export wallet");
2423
+ case 4:
2424
+ res = _context70.sent;
2425
+ if (!res) {
2426
+ _context70.next = 8;
2427
+ break;
2428
+ }
2429
+ _context70.next = 8;
2430
+ return refreshWallets({
2431
+ stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2432
+ });
2433
+ case 8:
2434
+ return _context70.abrupt("return", res);
2435
+ case 9:
2436
+ case "end":
2437
+ return _context70.stop();
2438
+ }
2439
+ }, _callee70);
2440
+ }));
2441
+ return _exportWallet.apply(this, arguments);
2442
+ }
2443
+ function exportPrivateKey(_x42) {
2444
+ return _exportPrivateKey.apply(this, arguments);
2445
+ }
2446
+ function _exportPrivateKey() {
2447
+ _exportPrivateKey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
2448
+ var res;
2449
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
2450
+ while (1) switch (_context71.prev = _context71.next) {
2451
+ case 0:
2452
+ if (client) {
2453
+ _context71.next = 2;
2454
+ break;
2455
+ }
2456
+ throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2457
+ case 2:
2458
+ _context71.next = 4;
2459
+ return withTurnkeyErrorHandling(function () {
2460
+ return client.exportPrivateKey(params);
2461
+ }, callbacks, "Failed to export private key");
2462
+ case 4:
2463
+ res = _context71.sent;
2464
+ return _context71.abrupt("return", res);
2465
+ case 6:
2466
+ case "end":
2467
+ return _context71.stop();
2338
2468
  }
2339
- }, _callee67);
2469
+ }, _callee71);
2340
2470
  }));
2341
- return _createWalletAccounts.apply(this, arguments);
2471
+ return _exportPrivateKey.apply(this, arguments);
2342
2472
  }
2343
- function exportWallet(_x41) {
2344
- return _exportWallet.apply(this, arguments);
2473
+ function exportWalletAccount(_x43) {
2474
+ return _exportWalletAccount.apply(this, arguments);
2345
2475
  }
2346
- function _exportWallet() {
2347
- _exportWallet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
2476
+ function _exportWalletAccount() {
2477
+ _exportWalletAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee72(params) {
2348
2478
  var res;
2349
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
2350
- while (1) switch (_context68.prev = _context68.next) {
2479
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
2480
+ while (1) switch (_context72.prev = _context72.next) {
2351
2481
  case 0:
2352
2482
  if (client) {
2353
- _context68.next = 2;
2483
+ _context72.next = 2;
2354
2484
  break;
2355
2485
  }
2356
2486
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2357
2487
  case 2:
2358
- _context68.next = 4;
2488
+ _context72.next = 4;
2359
2489
  return withTurnkeyErrorHandling(function () {
2360
- return client.exportWallet(params);
2361
- }, callbacks, "Failed to export wallet");
2490
+ return client.exportWalletAccount(params);
2491
+ }, callbacks, "Failed to export wallet accounts");
2362
2492
  case 4:
2363
- res = _context68.sent;
2493
+ res = _context72.sent;
2364
2494
  if (!res) {
2365
- _context68.next = 8;
2495
+ _context72.next = 8;
2366
2496
  break;
2367
2497
  }
2368
- _context68.next = 8;
2498
+ _context72.next = 8;
2369
2499
  return refreshWallets({
2370
2500
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2371
2501
  });
2372
2502
  case 8:
2373
- return _context68.abrupt("return", res);
2503
+ return _context72.abrupt("return", res);
2374
2504
  case 9:
2375
2505
  case "end":
2376
- return _context68.stop();
2506
+ return _context72.stop();
2377
2507
  }
2378
- }, _callee68);
2508
+ }, _callee72);
2379
2509
  }));
2380
- return _exportWallet.apply(this, arguments);
2510
+ return _exportWalletAccount.apply(this, arguments);
2381
2511
  }
2382
- function importWallet(_x42) {
2512
+ function importWallet(_x44) {
2383
2513
  return _importWallet.apply(this, arguments);
2384
2514
  }
2385
2515
  function _importWallet() {
2386
- _importWallet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee69(params) {
2516
+ _importWallet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee73(params) {
2387
2517
  var res;
2388
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
2389
- while (1) switch (_context69.prev = _context69.next) {
2518
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
2519
+ while (1) switch (_context73.prev = _context73.next) {
2390
2520
  case 0:
2391
2521
  if (client) {
2392
- _context69.next = 2;
2522
+ _context73.next = 2;
2393
2523
  break;
2394
2524
  }
2395
2525
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2396
2526
  case 2:
2397
- _context69.next = 4;
2527
+ _context73.next = 4;
2398
2528
  return withTurnkeyErrorHandling(function () {
2399
2529
  return client.importWallet(params);
2400
2530
  }, callbacks, "Failed to import wallet");
2401
2531
  case 4:
2402
- res = _context69.sent;
2532
+ res = _context73.sent;
2403
2533
  if (!res) {
2404
- _context69.next = 8;
2534
+ _context73.next = 8;
2405
2535
  break;
2406
2536
  }
2407
- _context69.next = 8;
2537
+ _context73.next = 8;
2408
2538
  return refreshWallets({
2409
2539
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2410
2540
  });
2411
2541
  case 8:
2412
- return _context69.abrupt("return", res);
2542
+ return _context73.abrupt("return", res);
2413
2543
  case 9:
2414
2544
  case "end":
2415
- return _context69.stop();
2545
+ return _context73.stop();
2416
2546
  }
2417
- }, _callee69);
2547
+ }, _callee73);
2418
2548
  }));
2419
2549
  return _importWallet.apply(this, arguments);
2420
2550
  }
2421
- function deleteSubOrganization(_x43) {
2551
+ function importPrivateKey(_x45) {
2552
+ return _importPrivateKey.apply(this, arguments);
2553
+ }
2554
+ function _importPrivateKey() {
2555
+ _importPrivateKey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee74(params) {
2556
+ var res;
2557
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
2558
+ while (1) switch (_context74.prev = _context74.next) {
2559
+ case 0:
2560
+ if (client) {
2561
+ _context74.next = 2;
2562
+ break;
2563
+ }
2564
+ throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2565
+ case 2:
2566
+ _context74.next = 4;
2567
+ return withTurnkeyErrorHandling(function () {
2568
+ return client.importPrivateKey(params);
2569
+ }, callbacks, "Failed to import private key");
2570
+ case 4:
2571
+ res = _context74.sent;
2572
+ return _context74.abrupt("return", res);
2573
+ case 6:
2574
+ case "end":
2575
+ return _context74.stop();
2576
+ }
2577
+ }, _callee74);
2578
+ }));
2579
+ return _importPrivateKey.apply(this, arguments);
2580
+ }
2581
+ function deleteSubOrganization(_x46) {
2422
2582
  return _deleteSubOrganization.apply(this, arguments);
2423
2583
  }
2424
2584
  function _deleteSubOrganization() {
2425
- _deleteSubOrganization = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
2426
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
2427
- while (1) switch (_context70.prev = _context70.next) {
2585
+ _deleteSubOrganization = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee75(params) {
2586
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
2587
+ while (1) switch (_context75.prev = _context75.next) {
2428
2588
  case 0:
2429
2589
  if (client) {
2430
- _context70.next = 2;
2590
+ _context75.next = 2;
2431
2591
  break;
2432
2592
  }
2433
2593
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2434
2594
  case 2:
2435
- return _context70.abrupt("return", withTurnkeyErrorHandling(function () {
2595
+ return _context75.abrupt("return", withTurnkeyErrorHandling(function () {
2436
2596
  return client.deleteSubOrganization(params);
2437
2597
  }, callbacks, "Failed to delete sub-organization"));
2438
2598
  case 3:
2439
2599
  case "end":
2440
- return _context70.stop();
2600
+ return _context75.stop();
2441
2601
  }
2442
- }, _callee70);
2602
+ }, _callee75);
2443
2603
  }));
2444
2604
  return _deleteSubOrganization.apply(this, arguments);
2445
2605
  }
2446
- function storeSession(_x44) {
2606
+ function storeSession(_x47) {
2447
2607
  return _storeSession.apply(this, arguments);
2448
2608
  }
2449
2609
  function _storeSession() {
2450
- _storeSession = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
2610
+ _storeSession = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee76(params) {
2451
2611
  var sessionKey, session, allSessions;
2452
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
2453
- while (1) switch (_context71.prev = _context71.next) {
2612
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
2613
+ while (1) switch (_context76.prev = _context76.next) {
2454
2614
  case 0:
2455
2615
  if (client) {
2456
- _context71.next = 2;
2616
+ _context76.next = 2;
2457
2617
  break;
2458
2618
  }
2459
2619
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2460
2620
  case 2:
2461
- _context71.next = 4;
2621
+ _context76.next = 4;
2462
2622
  return withTurnkeyErrorHandling(function () {
2463
2623
  return client.storeSession(params);
2464
2624
  }, callbacks, "Failed to store session");
2465
2625
  case 4:
2466
- _context71.next = 6;
2626
+ _context76.next = 6;
2467
2627
  return getActiveSessionKey();
2468
2628
  case 6:
2469
- sessionKey = _context71.sent;
2470
- _context71.next = 9;
2629
+ sessionKey = _context76.sent;
2630
+ _context76.next = 9;
2471
2631
  return getSession(_objectSpread2({}, sessionKey && {
2472
2632
  sessionKey: sessionKey
2473
2633
  }));
2474
2634
  case 9:
2475
- session = _context71.sent;
2635
+ session = _context76.sent;
2476
2636
  if (!(session && sessionKey)) {
2477
- _context71.next = 13;
2637
+ _context76.next = 13;
2478
2638
  break;
2479
2639
  }
2480
- _context71.next = 13;
2640
+ _context76.next = 13;
2481
2641
  return scheduleSessionExpiration({
2482
2642
  sessionKey: sessionKey,
2483
2643
  expiry: session.expiry
2484
2644
  });
2485
2645
  case 13:
2486
- _context71.next = 15;
2646
+ _context76.next = 15;
2487
2647
  return getAllSessions();
2488
2648
  case 15:
2489
- allSessions = _context71.sent;
2649
+ allSessions = _context76.sent;
2490
2650
  setSession(session);
2491
2651
  setAllSessions(allSessions);
2492
- return _context71.abrupt("return");
2652
+ return _context76.abrupt("return");
2493
2653
  case 19:
2494
2654
  case "end":
2495
- return _context71.stop();
2655
+ return _context76.stop();
2496
2656
  }
2497
- }, _callee71);
2657
+ }, _callee76);
2498
2658
  }));
2499
2659
  return _storeSession.apply(this, arguments);
2500
2660
  }
2501
- function clearSession(_x45) {
2661
+ function clearSession(_x48) {
2502
2662
  return _clearSession.apply(this, arguments);
2503
2663
  }
2504
2664
  function _clearSession() {
2505
- _clearSession = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee72(params) {
2665
+ _clearSession = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee77(params) {
2506
2666
  var session, allSessions;
2507
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
2508
- while (1) switch (_context72.prev = _context72.next) {
2667
+ return _regeneratorRuntime().wrap(function _callee77$(_context77) {
2668
+ while (1) switch (_context77.prev = _context77.next) {
2509
2669
  case 0:
2510
2670
  if (client) {
2511
- _context72.next = 2;
2671
+ _context77.next = 2;
2512
2672
  break;
2513
2673
  }
2514
2674
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2515
2675
  case 2:
2516
- _context72.next = 4;
2676
+ _context77.next = 4;
2517
2677
  return withTurnkeyErrorHandling(function () {
2518
2678
  return client.clearSession(params);
2519
2679
  }, callbacks, "Failed to clear session");
2520
2680
  case 4:
2521
- _context72.next = 6;
2681
+ _context77.next = 6;
2522
2682
  return getSession();
2523
2683
  case 6:
2524
- session = _context72.sent;
2525
- _context72.next = 9;
2684
+ session = _context77.sent;
2685
+ _context77.next = 9;
2526
2686
  return getAllSessions();
2527
2687
  case 9:
2528
- allSessions = _context72.sent;
2688
+ allSessions = _context77.sent;
2529
2689
  setSession(session);
2530
2690
  setAllSessions(allSessions);
2531
- return _context72.abrupt("return");
2691
+ return _context77.abrupt("return");
2532
2692
  case 13:
2533
2693
  case "end":
2534
- return _context72.stop();
2694
+ return _context77.stop();
2535
2695
  }
2536
- }, _callee72);
2696
+ }, _callee77);
2537
2697
  }));
2538
2698
  return _clearSession.apply(this, arguments);
2539
2699
  }
@@ -2541,76 +2701,76 @@ var ClientProvider = function ClientProvider(_ref) {
2541
2701
  return _clearAllSessions.apply(this, arguments);
2542
2702
  }
2543
2703
  function _clearAllSessions() {
2544
- _clearAllSessions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee73() {
2545
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
2546
- while (1) switch (_context73.prev = _context73.next) {
2704
+ _clearAllSessions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
2705
+ return _regeneratorRuntime().wrap(function _callee78$(_context78) {
2706
+ while (1) switch (_context78.prev = _context78.next) {
2547
2707
  case 0:
2548
2708
  if (client) {
2549
- _context73.next = 2;
2709
+ _context78.next = 2;
2550
2710
  break;
2551
2711
  }
2552
2712
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2553
2713
  case 2:
2554
2714
  setSession(undefined);
2555
2715
  setAllSessions(undefined);
2556
- _context73.next = 6;
2716
+ _context78.next = 6;
2557
2717
  return withTurnkeyErrorHandling(function () {
2558
2718
  return client.clearAllSessions();
2559
2719
  }, callbacks, "Failed to clear all sessions");
2560
2720
  case 6:
2561
- return _context73.abrupt("return", _context73.sent);
2721
+ return _context78.abrupt("return", _context78.sent);
2562
2722
  case 7:
2563
2723
  case "end":
2564
- return _context73.stop();
2724
+ return _context78.stop();
2565
2725
  }
2566
- }, _callee73);
2726
+ }, _callee78);
2567
2727
  }));
2568
2728
  return _clearAllSessions.apply(this, arguments);
2569
2729
  }
2570
- function refreshSession(_x46) {
2730
+ function refreshSession(_x49) {
2571
2731
  return _refreshSession.apply(this, arguments);
2572
2732
  }
2573
2733
  function _refreshSession() {
2574
- _refreshSession = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee74(params) {
2734
+ _refreshSession = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee79(params) {
2575
2735
  var _params$sessionKey;
2576
2736
  var activeSessionKey, sessionKey, res, session, allSessions;
2577
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
2578
- while (1) switch (_context74.prev = _context74.next) {
2737
+ return _regeneratorRuntime().wrap(function _callee79$(_context79) {
2738
+ while (1) switch (_context79.prev = _context79.next) {
2579
2739
  case 0:
2580
2740
  if (client) {
2581
- _context74.next = 2;
2741
+ _context79.next = 2;
2582
2742
  break;
2583
2743
  }
2584
2744
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2585
2745
  case 2:
2586
- _context74.next = 4;
2746
+ _context79.next = 4;
2587
2747
  return client.getActiveSessionKey();
2588
2748
  case 4:
2589
- activeSessionKey = _context74.sent;
2749
+ activeSessionKey = _context79.sent;
2590
2750
  if (activeSessionKey) {
2591
- _context74.next = 7;
2751
+ _context79.next = 7;
2592
2752
  break;
2593
2753
  }
2594
2754
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
2595
2755
  case 7:
2596
2756
  sessionKey = (_params$sessionKey = params === null || params === void 0 ? void 0 : params.sessionKey) !== null && _params$sessionKey !== void 0 ? _params$sessionKey : activeSessionKey;
2597
- _context74.next = 10;
2757
+ _context79.next = 10;
2598
2758
  return withTurnkeyErrorHandling(function () {
2599
2759
  return client.refreshSession(_objectSpread2({}, params));
2600
2760
  }, callbacks, "Failed to refresh session");
2601
2761
  case 10:
2602
- res = _context74.sent;
2603
- _context74.next = 13;
2762
+ res = _context79.sent;
2763
+ _context79.next = 13;
2604
2764
  return getSession({
2605
2765
  sessionKey: sessionKey
2606
2766
  });
2607
2767
  case 13:
2608
- session = _context74.sent;
2768
+ session = _context79.sent;
2609
2769
  if (!(session && sessionKey)) {
2610
- _context74.next = 17;
2770
+ _context79.next = 17;
2611
2771
  break;
2612
2772
  }
2613
- _context74.next = 17;
2773
+ _context79.next = 17;
2614
2774
  return scheduleSessionExpiration(_objectSpread2({
2615
2775
  sessionKey: sessionKey,
2616
2776
  expiry: session.expiry
@@ -2618,43 +2778,43 @@ var ClientProvider = function ClientProvider(_ref) {
2618
2778
  expirationSeconds: params === null || params === void 0 ? void 0 : params.expirationSeconds
2619
2779
  }));
2620
2780
  case 17:
2621
- _context74.next = 19;
2781
+ _context79.next = 19;
2622
2782
  return getAllSessions();
2623
2783
  case 19:
2624
- allSessions = _context74.sent;
2784
+ allSessions = _context79.sent;
2625
2785
  setSession(session);
2626
2786
  setAllSessions(allSessions);
2627
- return _context74.abrupt("return", res);
2787
+ return _context79.abrupt("return", res);
2628
2788
  case 23:
2629
2789
  case "end":
2630
- return _context74.stop();
2790
+ return _context79.stop();
2631
2791
  }
2632
- }, _callee74);
2792
+ }, _callee79);
2633
2793
  }));
2634
2794
  return _refreshSession.apply(this, arguments);
2635
2795
  }
2636
- function getSession(_x47) {
2796
+ function getSession(_x50) {
2637
2797
  return _getSession.apply(this, arguments);
2638
2798
  }
2639
2799
  function _getSession() {
2640
- _getSession = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee75(params) {
2641
- return _regeneratorRuntime().wrap(function _callee75$(_context75) {
2642
- while (1) switch (_context75.prev = _context75.next) {
2800
+ _getSession = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee80(params) {
2801
+ return _regeneratorRuntime().wrap(function _callee80$(_context80) {
2802
+ while (1) switch (_context80.prev = _context80.next) {
2643
2803
  case 0:
2644
2804
  if (client) {
2645
- _context75.next = 2;
2805
+ _context80.next = 2;
2646
2806
  break;
2647
2807
  }
2648
2808
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2649
2809
  case 2:
2650
- return _context75.abrupt("return", withTurnkeyErrorHandling(function () {
2810
+ return _context80.abrupt("return", withTurnkeyErrorHandling(function () {
2651
2811
  return client.getSession(params);
2652
2812
  }, callbacks, "Failed to get session"));
2653
2813
  case 3:
2654
2814
  case "end":
2655
- return _context75.stop();
2815
+ return _context80.stop();
2656
2816
  }
2657
- }, _callee75);
2817
+ }, _callee80);
2658
2818
  }));
2659
2819
  return _getSession.apply(this, arguments);
2660
2820
  }
@@ -2662,68 +2822,68 @@ var ClientProvider = function ClientProvider(_ref) {
2662
2822
  return _getAllSessions.apply(this, arguments);
2663
2823
  }
2664
2824
  function _getAllSessions() {
2665
- _getAllSessions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee76() {
2666
- return _regeneratorRuntime().wrap(function _callee76$(_context76) {
2667
- while (1) switch (_context76.prev = _context76.next) {
2825
+ _getAllSessions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee81() {
2826
+ return _regeneratorRuntime().wrap(function _callee81$(_context81) {
2827
+ while (1) switch (_context81.prev = _context81.next) {
2668
2828
  case 0:
2669
2829
  if (client) {
2670
- _context76.next = 2;
2830
+ _context81.next = 2;
2671
2831
  break;
2672
2832
  }
2673
2833
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2674
2834
  case 2:
2675
- return _context76.abrupt("return", withTurnkeyErrorHandling(function () {
2835
+ return _context81.abrupt("return", withTurnkeyErrorHandling(function () {
2676
2836
  return client.getAllSessions();
2677
2837
  }, callbacks, "Failed to get all sessions"));
2678
2838
  case 3:
2679
2839
  case "end":
2680
- return _context76.stop();
2840
+ return _context81.stop();
2681
2841
  }
2682
- }, _callee76);
2842
+ }, _callee81);
2683
2843
  }));
2684
2844
  return _getAllSessions.apply(this, arguments);
2685
2845
  }
2686
- function setActiveSession(_x48) {
2846
+ function setActiveSession(_x51) {
2687
2847
  return _setActiveSession.apply(this, arguments);
2688
2848
  }
2689
2849
  function _setActiveSession() {
2690
- _setActiveSession = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee77(params) {
2850
+ _setActiveSession = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee82(params) {
2691
2851
  var session;
2692
- return _regeneratorRuntime().wrap(function _callee77$(_context77) {
2693
- while (1) switch (_context77.prev = _context77.next) {
2852
+ return _regeneratorRuntime().wrap(function _callee82$(_context82) {
2853
+ while (1) switch (_context82.prev = _context82.next) {
2694
2854
  case 0:
2695
2855
  if (client) {
2696
- _context77.next = 2;
2856
+ _context82.next = 2;
2697
2857
  break;
2698
2858
  }
2699
2859
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2700
2860
  case 2:
2701
- _context77.next = 4;
2861
+ _context82.next = 4;
2702
2862
  return withTurnkeyErrorHandling(function () {
2703
2863
  return client.getSession({
2704
2864
  sessionKey: params.sessionKey
2705
2865
  });
2706
2866
  }, callbacks, "Failed to get session");
2707
2867
  case 4:
2708
- session = _context77.sent;
2868
+ session = _context82.sent;
2709
2869
  if (session) {
2710
- _context77.next = 7;
2870
+ _context82.next = 7;
2711
2871
  break;
2712
2872
  }
2713
2873
  throw new TurnkeyError("Session not found.", TurnkeyErrorCodes.NOT_FOUND);
2714
2874
  case 7:
2715
- _context77.next = 9;
2875
+ _context82.next = 9;
2716
2876
  return withTurnkeyErrorHandling(function () {
2717
2877
  return client.setActiveSession(params);
2718
2878
  }, callbacks, "Failed to set active session");
2719
2879
  case 9:
2720
2880
  setSession(session);
2721
- return _context77.abrupt("return");
2881
+ return _context82.abrupt("return");
2722
2882
  case 11:
2723
2883
  case "end":
2724
- return _context77.stop();
2884
+ return _context82.stop();
2725
2885
  }
2726
- }, _callee77);
2886
+ }, _callee82);
2727
2887
  }));
2728
2888
  return _setActiveSession.apply(this, arguments);
2729
2889
  }
@@ -2731,24 +2891,24 @@ var ClientProvider = function ClientProvider(_ref) {
2731
2891
  return _getActiveSessionKey.apply(this, arguments);
2732
2892
  }
2733
2893
  function _getActiveSessionKey() {
2734
- _getActiveSessionKey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
2735
- return _regeneratorRuntime().wrap(function _callee78$(_context78) {
2736
- while (1) switch (_context78.prev = _context78.next) {
2894
+ _getActiveSessionKey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee83() {
2895
+ return _regeneratorRuntime().wrap(function _callee83$(_context83) {
2896
+ while (1) switch (_context83.prev = _context83.next) {
2737
2897
  case 0:
2738
2898
  if (client) {
2739
- _context78.next = 2;
2899
+ _context83.next = 2;
2740
2900
  break;
2741
2901
  }
2742
2902
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2743
2903
  case 2:
2744
- return _context78.abrupt("return", withTurnkeyErrorHandling(function () {
2904
+ return _context83.abrupt("return", withTurnkeyErrorHandling(function () {
2745
2905
  return client.getActiveSessionKey();
2746
2906
  }, callbacks, "Failed to get active session key"));
2747
2907
  case 3:
2748
2908
  case "end":
2749
- return _context78.stop();
2909
+ return _context83.stop();
2750
2910
  }
2751
- }, _callee78);
2911
+ }, _callee83);
2752
2912
  }));
2753
2913
  return _getActiveSessionKey.apply(this, arguments);
2754
2914
  }
@@ -2756,49 +2916,49 @@ var ClientProvider = function ClientProvider(_ref) {
2756
2916
  return _clearUnusedKeyPairs.apply(this, arguments);
2757
2917
  }
2758
2918
  function _clearUnusedKeyPairs() {
2759
- _clearUnusedKeyPairs = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee79() {
2760
- return _regeneratorRuntime().wrap(function _callee79$(_context79) {
2761
- while (1) switch (_context79.prev = _context79.next) {
2919
+ _clearUnusedKeyPairs = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee84() {
2920
+ return _regeneratorRuntime().wrap(function _callee84$(_context84) {
2921
+ while (1) switch (_context84.prev = _context84.next) {
2762
2922
  case 0:
2763
2923
  if (client) {
2764
- _context79.next = 2;
2924
+ _context84.next = 2;
2765
2925
  break;
2766
2926
  }
2767
2927
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2768
2928
  case 2:
2769
- return _context79.abrupt("return", withTurnkeyErrorHandling(function () {
2929
+ return _context84.abrupt("return", withTurnkeyErrorHandling(function () {
2770
2930
  return client.clearUnusedKeyPairs();
2771
2931
  }, callbacks, "Failed to clear unused key pairs"));
2772
2932
  case 3:
2773
2933
  case "end":
2774
- return _context79.stop();
2934
+ return _context84.stop();
2775
2935
  }
2776
- }, _callee79);
2936
+ }, _callee84);
2777
2937
  }));
2778
2938
  return _clearUnusedKeyPairs.apply(this, arguments);
2779
2939
  }
2780
- function createApiKeyPair(_x49) {
2940
+ function createApiKeyPair(_x52) {
2781
2941
  return _createApiKeyPair.apply(this, arguments);
2782
2942
  }
2783
2943
  function _createApiKeyPair() {
2784
- _createApiKeyPair = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee80(params) {
2785
- return _regeneratorRuntime().wrap(function _callee80$(_context80) {
2786
- while (1) switch (_context80.prev = _context80.next) {
2944
+ _createApiKeyPair = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee85(params) {
2945
+ return _regeneratorRuntime().wrap(function _callee85$(_context85) {
2946
+ while (1) switch (_context85.prev = _context85.next) {
2787
2947
  case 0:
2788
2948
  if (client) {
2789
- _context80.next = 2;
2949
+ _context85.next = 2;
2790
2950
  break;
2791
2951
  }
2792
2952
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2793
2953
  case 2:
2794
- return _context80.abrupt("return", withTurnkeyErrorHandling(function () {
2954
+ return _context85.abrupt("return", withTurnkeyErrorHandling(function () {
2795
2955
  return client.createApiKeyPair(params);
2796
2956
  }, callbacks, "Failed to create API key pair"));
2797
2957
  case 3:
2798
2958
  case "end":
2799
- return _context80.stop();
2959
+ return _context85.stop();
2800
2960
  }
2801
- }, _callee80);
2961
+ }, _callee85);
2802
2962
  }));
2803
2963
  return _createApiKeyPair.apply(this, arguments);
2804
2964
  }
@@ -2806,135 +2966,135 @@ var ClientProvider = function ClientProvider(_ref) {
2806
2966
  return _getProxyAuthConfig.apply(this, arguments);
2807
2967
  }
2808
2968
  function _getProxyAuthConfig() {
2809
- _getProxyAuthConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee81() {
2810
- return _regeneratorRuntime().wrap(function _callee81$(_context81) {
2811
- while (1) switch (_context81.prev = _context81.next) {
2969
+ _getProxyAuthConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee86() {
2970
+ return _regeneratorRuntime().wrap(function _callee86$(_context86) {
2971
+ while (1) switch (_context86.prev = _context86.next) {
2812
2972
  case 0:
2813
2973
  if (client) {
2814
- _context81.next = 2;
2974
+ _context86.next = 2;
2815
2975
  break;
2816
2976
  }
2817
2977
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2818
2978
  case 2:
2819
- return _context81.abrupt("return", withTurnkeyErrorHandling(function () {
2979
+ return _context86.abrupt("return", withTurnkeyErrorHandling(function () {
2820
2980
  return client.getProxyAuthConfig();
2821
2981
  }, callbacks, "Failed to get proxy auth config"));
2822
2982
  case 3:
2823
2983
  case "end":
2824
- return _context81.stop();
2984
+ return _context86.stop();
2825
2985
  }
2826
- }, _callee81);
2986
+ }, _callee86);
2827
2987
  }));
2828
2988
  return _getProxyAuthConfig.apply(this, arguments);
2829
2989
  }
2830
- function refreshUser(_x50) {
2990
+ function refreshUser(_x53) {
2831
2991
  return _refreshUser.apply(this, arguments);
2832
2992
  }
2833
2993
  function _refreshUser() {
2834
- _refreshUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee82(params) {
2835
- var _ref36, stampWith, user;
2836
- return _regeneratorRuntime().wrap(function _callee82$(_context82) {
2837
- while (1) switch (_context82.prev = _context82.next) {
2994
+ _refreshUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee87(params) {
2995
+ var _ref38, stampWith, user;
2996
+ return _regeneratorRuntime().wrap(function _callee87$(_context87) {
2997
+ while (1) switch (_context87.prev = _context87.next) {
2838
2998
  case 0:
2839
- _ref36 = params || {}, stampWith = _ref36.stampWith;
2999
+ _ref38 = params || {}, stampWith = _ref38.stampWith;
2840
3000
  if (client) {
2841
- _context82.next = 3;
3001
+ _context87.next = 3;
2842
3002
  break;
2843
3003
  }
2844
3004
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2845
3005
  case 3:
2846
- _context82.next = 5;
3006
+ _context87.next = 5;
2847
3007
  return withTurnkeyErrorHandling(function () {
2848
3008
  return fetchUser({
2849
3009
  stampWith: stampWith
2850
3010
  });
2851
3011
  }, callbacks, "Failed to refresh user");
2852
3012
  case 5:
2853
- user = _context82.sent;
3013
+ user = _context87.sent;
2854
3014
  if (user) {
2855
3015
  setUser(user);
2856
3016
  }
2857
3017
  case 7:
2858
3018
  case "end":
2859
- return _context82.stop();
3019
+ return _context87.stop();
2860
3020
  }
2861
- }, _callee82);
3021
+ }, _callee87);
2862
3022
  }));
2863
3023
  return _refreshUser.apply(this, arguments);
2864
3024
  }
2865
- function refreshWallets(_x51) {
3025
+ function refreshWallets(_x54) {
2866
3026
  return _refreshWallets.apply(this, arguments);
2867
3027
  }
2868
3028
  function _refreshWallets() {
2869
- _refreshWallets = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee83(params) {
2870
- var _ref37, stampWith, wallets;
2871
- return _regeneratorRuntime().wrap(function _callee83$(_context83) {
2872
- while (1) switch (_context83.prev = _context83.next) {
3029
+ _refreshWallets = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee88(params) {
3030
+ var _ref39, stampWith, wallets;
3031
+ return _regeneratorRuntime().wrap(function _callee88$(_context88) {
3032
+ while (1) switch (_context88.prev = _context88.next) {
2873
3033
  case 0:
2874
- _ref37 = params || {}, stampWith = _ref37.stampWith;
3034
+ _ref39 = params || {}, stampWith = _ref39.stampWith;
2875
3035
  if (client) {
2876
- _context83.next = 3;
3036
+ _context88.next = 3;
2877
3037
  break;
2878
3038
  }
2879
3039
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2880
3040
  case 3:
2881
- _context83.next = 5;
3041
+ _context88.next = 5;
2882
3042
  return withTurnkeyErrorHandling(function () {
2883
3043
  return fetchWallets({
2884
3044
  stampWith: stampWith
2885
3045
  });
2886
3046
  }, callbacks, "Failed to refresh wallets");
2887
3047
  case 5:
2888
- wallets = _context83.sent;
3048
+ wallets = _context88.sent;
2889
3049
  if (wallets) {
2890
3050
  setWallets(wallets);
2891
3051
  }
2892
3052
  case 7:
2893
3053
  case "end":
2894
- return _context83.stop();
3054
+ return _context88.stop();
2895
3055
  }
2896
- }, _callee83);
3056
+ }, _callee88);
2897
3057
  }));
2898
3058
  return _refreshWallets.apply(this, arguments);
2899
3059
  }
2900
- function handleGoogleOauth(_x52) {
3060
+ function handleGoogleOauth(_x55) {
2901
3061
  return _handleGoogleOauth.apply(this, arguments);
2902
3062
  }
2903
3063
  function _handleGoogleOauth() {
2904
- _handleGoogleOauth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee84(params) {
3064
+ _handleGoogleOauth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee89(params) {
2905
3065
  var _masterConfig$auth17, _masterConfig$auth17$, _masterConfig$auth$oa2, _masterConfig$auth18, _masterConfig$auth18$;
2906
- var _ref38, _ref38$clientId, clientId, _ref38$openInPage, openInPage, additionalParameters, _masterConfig$auth19, _masterConfig$auth19$, _masterConfig$auth20, flow, redirectURI, publicKey, nonce, googleAuthUrl, state, additionalState, width, height, left, top, authWindow;
2907
- return _regeneratorRuntime().wrap(function _callee84$(_context84) {
2908
- while (1) switch (_context84.prev = _context84.next) {
3066
+ var _ref40, _ref40$clientId, clientId, _ref40$openInPage, openInPage, additionalParameters, _masterConfig$auth19, _masterConfig$auth19$, _masterConfig$auth20, flow, redirectURI, publicKey, nonce, googleAuthUrl, state, additionalState, width, height, left, top, authWindow;
3067
+ return _regeneratorRuntime().wrap(function _callee89$(_context89) {
3068
+ while (1) switch (_context89.prev = _context89.next) {
2909
3069
  case 0:
2910
- _ref38 = params || {}, _ref38$clientId = _ref38.clientId, clientId = _ref38$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth17 = masterConfig.auth) === null || _masterConfig$auth17 === void 0 ? void 0 : (_masterConfig$auth17$ = _masterConfig$auth17.oauthConfig) === null || _masterConfig$auth17$ === void 0 ? void 0 : _masterConfig$auth17$.googleClientId : _ref38$clientId, _ref38$openInPage = _ref38.openInPage, openInPage = _ref38$openInPage === void 0 ? (_masterConfig$auth$oa2 = 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$.openOauthInPage) !== null && _masterConfig$auth$oa2 !== void 0 ? _masterConfig$auth$oa2 : false : _ref38$openInPage, additionalParameters = _ref38.additionalState;
2911
- _context84.prev = 1;
3070
+ _ref40 = params || {}, _ref40$clientId = _ref40.clientId, clientId = _ref40$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth17 = masterConfig.auth) === null || _masterConfig$auth17 === void 0 ? void 0 : (_masterConfig$auth17$ = _masterConfig$auth17.oauthConfig) === null || _masterConfig$auth17$ === void 0 ? void 0 : _masterConfig$auth17$.googleClientId : _ref40$clientId, _ref40$openInPage = _ref40.openInPage, openInPage = _ref40$openInPage === void 0 ? (_masterConfig$auth$oa2 = 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$.openOauthInPage) !== null && _masterConfig$auth$oa2 !== void 0 ? _masterConfig$auth$oa2 : false : _ref40$openInPage, additionalParameters = _ref40.additionalState;
3071
+ _context89.prev = 1;
2912
3072
  if (masterConfig) {
2913
- _context84.next = 4;
3073
+ _context89.next = 4;
2914
3074
  break;
2915
3075
  }
2916
3076
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
2917
3077
  case 4:
2918
3078
  if (clientId) {
2919
- _context84.next = 6;
3079
+ _context89.next = 6;
2920
3080
  break;
2921
3081
  }
2922
3082
  throw new TurnkeyError("Google Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
2923
3083
  case 6:
2924
3084
  if ((_masterConfig$auth19 = masterConfig.auth) !== null && _masterConfig$auth19 !== void 0 && (_masterConfig$auth19$ = _masterConfig$auth19.oauthConfig) !== null && _masterConfig$auth19$ !== void 0 && _masterConfig$auth19$.oauthRedirectUri) {
2925
- _context84.next = 8;
3085
+ _context89.next = 8;
2926
3086
  break;
2927
3087
  }
2928
3088
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
2929
3089
  case 8:
2930
3090
  flow = openInPage ? "redirect" : "popup";
2931
3091
  redirectURI = (_masterConfig$auth20 = masterConfig.auth) === null || _masterConfig$auth20 === void 0 ? void 0 : _masterConfig$auth20.oauthConfig.oauthRedirectUri.replace(/\/$/, ""); // Create key pair and generate nonce
2932
- _context84.next = 12;
3092
+ _context89.next = 12;
2933
3093
  return createApiKeyPair();
2934
3094
  case 12:
2935
- publicKey = _context84.sent;
3095
+ publicKey = _context89.sent;
2936
3096
  if (publicKey) {
2937
- _context84.next = 15;
3097
+ _context89.next = 15;
2938
3098
  break;
2939
3099
  }
2940
3100
  throw new Error("Failed to create public key for OAuth.");
@@ -2950,10 +3110,10 @@ var ClientProvider = function ClientProvider(_ref) {
2950
3110
  // Create state parameter
2951
3111
  state = "provider=google&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
2952
3112
  if (additionalParameters) {
2953
- additionalState = Object.entries(additionalParameters).map(function (_ref39) {
2954
- var _ref40 = _slicedToArray(_ref39, 2),
2955
- key = _ref40[0],
2956
- value = _ref40[1];
3113
+ additionalState = Object.entries(additionalParameters).map(function (_ref41) {
3114
+ var _ref42 = _slicedToArray(_ref41, 2),
3115
+ key = _ref42[0],
3116
+ value = _ref42[1];
2957
3117
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
2958
3118
  }).join("&");
2959
3119
  if (additionalState) {
@@ -2962,12 +3122,12 @@ var ClientProvider = function ClientProvider(_ref) {
2962
3122
  }
2963
3123
  googleAuthUrl.searchParams.set("state", state);
2964
3124
  if (!openInPage) {
2965
- _context84.next = 31;
3125
+ _context89.next = 31;
2966
3126
  break;
2967
3127
  }
2968
3128
  // Redirect current page to Google Auth
2969
3129
  window.location.href = googleAuthUrl.toString();
2970
- return _context84.abrupt("return", new Promise(function (_, reject) {
3130
+ return _context89.abrupt("return", new Promise(function (_, reject) {
2971
3131
  // By here, the page should have already redirected. We wait here since the function is async.
2972
3132
  // We want any function that runs this to simply wait until the page redirects.
2973
3133
  // A 5 min timeout is set just in case, idk
@@ -2987,7 +3147,7 @@ var ClientProvider = function ClientProvider(_ref) {
2987
3147
  top = window.screenY + (window.innerHeight - height) / 2;
2988
3148
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
2989
3149
  if (authWindow) {
2990
- _context84.next = 38;
3150
+ _context89.next = 38;
2991
3151
  break;
2992
3152
  }
2993
3153
  throw new Error("Failed to open Google login window.");
@@ -2995,7 +3155,7 @@ var ClientProvider = function ClientProvider(_ref) {
2995
3155
  authWindow.location.href = googleAuthUrl.toString();
2996
3156
  // Return a promise that resolves when the OAuth flow completes
2997
3157
  // This following code will only run for the popup flow
2998
- return _context84.abrupt("return", new Promise(function (resolve, reject) {
3158
+ return _context89.abrupt("return", new Promise(function (resolve, reject) {
2999
3159
  var interval = setInterval(function () {
3000
3160
  try {
3001
3161
  // Check if window was closed without completing auth
@@ -3043,46 +3203,46 @@ var ClientProvider = function ClientProvider(_ref) {
3043
3203
  }
3044
3204
  }));
3045
3205
  case 40:
3046
- _context84.next = 45;
3206
+ _context89.next = 45;
3047
3207
  break;
3048
3208
  case 42:
3049
- _context84.prev = 42;
3050
- _context84.t0 = _context84["catch"](1);
3051
- throw _context84.t0;
3209
+ _context89.prev = 42;
3210
+ _context89.t0 = _context89["catch"](1);
3211
+ throw _context89.t0;
3052
3212
  case 45:
3053
3213
  case "end":
3054
- return _context84.stop();
3214
+ return _context89.stop();
3055
3215
  }
3056
- }, _callee84, null, [[1, 42]]);
3216
+ }, _callee89, null, [[1, 42]]);
3057
3217
  }));
3058
3218
  return _handleGoogleOauth.apply(this, arguments);
3059
3219
  }
3060
- function handleAppleOauth(_x53) {
3220
+ function handleAppleOauth(_x56) {
3061
3221
  return _handleAppleOauth.apply(this, arguments);
3062
3222
  }
3063
3223
  function _handleAppleOauth() {
3064
- _handleAppleOauth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee85(params) {
3224
+ _handleAppleOauth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee90(params) {
3065
3225
  var _masterConfig$auth21, _masterConfig$auth21$, _masterConfig$auth$oa3, _masterConfig$auth22, _masterConfig$auth22$;
3066
- var _ref41, _ref41$clientId, clientId, _ref41$openInPage, openInPage, additionalParameters, _masterConfig$auth23, _masterConfig$auth23$, _masterConfig$auth24, flow, redirectURI, publicKey, nonce, appleAuthUrl, state, additionalState, width, height, left, top, authWindow;
3067
- return _regeneratorRuntime().wrap(function _callee85$(_context85) {
3068
- while (1) switch (_context85.prev = _context85.next) {
3226
+ var _ref43, _ref43$clientId, clientId, _ref43$openInPage, openInPage, additionalParameters, _masterConfig$auth23, _masterConfig$auth23$, _masterConfig$auth24, flow, redirectURI, publicKey, nonce, appleAuthUrl, state, additionalState, width, height, left, top, authWindow;
3227
+ return _regeneratorRuntime().wrap(function _callee90$(_context90) {
3228
+ while (1) switch (_context90.prev = _context90.next) {
3069
3229
  case 0:
3070
- _ref41 = params || {}, _ref41$clientId = _ref41.clientId, clientId = _ref41$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth21 = masterConfig.auth) === null || _masterConfig$auth21 === void 0 ? void 0 : (_masterConfig$auth21$ = _masterConfig$auth21.oauthConfig) === null || _masterConfig$auth21$ === void 0 ? void 0 : _masterConfig$auth21$.appleClientId : _ref41$clientId, _ref41$openInPage = _ref41.openInPage, openInPage = _ref41$openInPage === void 0 ? (_masterConfig$auth$oa3 = 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$.openOauthInPage) !== null && _masterConfig$auth$oa3 !== void 0 ? _masterConfig$auth$oa3 : false : _ref41$openInPage, additionalParameters = _ref41.additionalState;
3071
- _context85.prev = 1;
3230
+ _ref43 = params || {}, _ref43$clientId = _ref43.clientId, clientId = _ref43$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth21 = masterConfig.auth) === null || _masterConfig$auth21 === void 0 ? void 0 : (_masterConfig$auth21$ = _masterConfig$auth21.oauthConfig) === null || _masterConfig$auth21$ === void 0 ? void 0 : _masterConfig$auth21$.appleClientId : _ref43$clientId, _ref43$openInPage = _ref43.openInPage, openInPage = _ref43$openInPage === void 0 ? (_masterConfig$auth$oa3 = 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$.openOauthInPage) !== null && _masterConfig$auth$oa3 !== void 0 ? _masterConfig$auth$oa3 : false : _ref43$openInPage, additionalParameters = _ref43.additionalState;
3231
+ _context90.prev = 1;
3072
3232
  if (masterConfig) {
3073
- _context85.next = 4;
3233
+ _context90.next = 4;
3074
3234
  break;
3075
3235
  }
3076
3236
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3077
3237
  case 4:
3078
3238
  if (clientId) {
3079
- _context85.next = 6;
3239
+ _context90.next = 6;
3080
3240
  break;
3081
3241
  }
3082
3242
  throw new TurnkeyError("Apple Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3083
3243
  case 6:
3084
3244
  if ((_masterConfig$auth23 = masterConfig.auth) !== null && _masterConfig$auth23 !== void 0 && (_masterConfig$auth23$ = _masterConfig$auth23.oauthConfig) !== null && _masterConfig$auth23$ !== void 0 && _masterConfig$auth23$.oauthRedirectUri) {
3085
- _context85.next = 8;
3245
+ _context90.next = 8;
3086
3246
  break;
3087
3247
  }
3088
3248
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
@@ -3090,12 +3250,12 @@ var ClientProvider = function ClientProvider(_ref) {
3090
3250
  flow = openInPage ? "redirect" : "popup";
3091
3251
  redirectURI = (_masterConfig$auth24 = masterConfig.auth) === null || _masterConfig$auth24 === void 0 ? void 0 : _masterConfig$auth24.oauthConfig.oauthRedirectUri; // TODO (Amir): Apple needs the '/' at the end. Maybe we should add it if not there?
3092
3252
  // Create key pair and generate nonce
3093
- _context85.next = 12;
3253
+ _context90.next = 12;
3094
3254
  return createApiKeyPair();
3095
3255
  case 12:
3096
- publicKey = _context85.sent;
3256
+ publicKey = _context90.sent;
3097
3257
  if (publicKey) {
3098
- _context85.next = 15;
3258
+ _context90.next = 15;
3099
3259
  break;
3100
3260
  }
3101
3261
  throw new Error("Failed to create public key for OAuth.");
@@ -3110,10 +3270,10 @@ var ClientProvider = function ClientProvider(_ref) {
3110
3270
  // Create state parameter
3111
3271
  state = "provider=apple&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
3112
3272
  if (additionalParameters) {
3113
- additionalState = Object.entries(additionalParameters).map(function (_ref42) {
3114
- var _ref43 = _slicedToArray(_ref42, 2),
3115
- key = _ref43[0],
3116
- value = _ref43[1];
3273
+ additionalState = Object.entries(additionalParameters).map(function (_ref44) {
3274
+ var _ref45 = _slicedToArray(_ref44, 2),
3275
+ key = _ref45[0],
3276
+ value = _ref45[1];
3117
3277
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
3118
3278
  }).join("&");
3119
3279
  if (additionalState) {
@@ -3122,12 +3282,12 @@ var ClientProvider = function ClientProvider(_ref) {
3122
3282
  }
3123
3283
  appleAuthUrl.searchParams.set("state", state);
3124
3284
  if (!openInPage) {
3125
- _context85.next = 30;
3285
+ _context90.next = 30;
3126
3286
  break;
3127
3287
  }
3128
3288
  // Redirect current page to Apple Auth
3129
3289
  window.location.href = appleAuthUrl.toString();
3130
- return _context85.abrupt("return", new Promise(function (_, reject) {
3290
+ return _context90.abrupt("return", new Promise(function (_, reject) {
3131
3291
  // Set a timeout just in case the redirect doesn't happen
3132
3292
  var timeout = setTimeout(function () {
3133
3293
  reject(new Error("Authentication timed out."));
@@ -3145,14 +3305,14 @@ var ClientProvider = function ClientProvider(_ref) {
3145
3305
  top = window.screenY + (window.innerHeight - height) / 2;
3146
3306
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3147
3307
  if (authWindow) {
3148
- _context85.next = 37;
3308
+ _context90.next = 37;
3149
3309
  break;
3150
3310
  }
3151
3311
  throw new Error("Failed to open Apple login window.");
3152
3312
  case 37:
3153
3313
  authWindow.location.href = appleAuthUrl.toString();
3154
3314
  // Return a promise that resolves when the OAuth flow completes
3155
- return _context85.abrupt("return", new Promise(function (resolve, reject) {
3315
+ return _context90.abrupt("return", new Promise(function (resolve, reject) {
3156
3316
  var interval = setInterval(function () {
3157
3317
  try {
3158
3318
  // Check if window was closed without completing auth
@@ -3200,67 +3360,67 @@ var ClientProvider = function ClientProvider(_ref) {
3200
3360
  }
3201
3361
  }));
3202
3362
  case 39:
3203
- _context85.next = 44;
3363
+ _context90.next = 44;
3204
3364
  break;
3205
3365
  case 41:
3206
- _context85.prev = 41;
3207
- _context85.t0 = _context85["catch"](1);
3208
- throw _context85.t0;
3366
+ _context90.prev = 41;
3367
+ _context90.t0 = _context90["catch"](1);
3368
+ throw _context90.t0;
3209
3369
  case 44:
3210
3370
  case "end":
3211
- return _context85.stop();
3371
+ return _context90.stop();
3212
3372
  }
3213
- }, _callee85, null, [[1, 41]]);
3373
+ }, _callee90, null, [[1, 41]]);
3214
3374
  }));
3215
3375
  return _handleAppleOauth.apply(this, arguments);
3216
3376
  }
3217
- function handleFacebookOauth(_x54) {
3377
+ function handleFacebookOauth(_x57) {
3218
3378
  return _handleFacebookOauth.apply(this, arguments);
3219
3379
  }
3220
3380
  function _handleFacebookOauth() {
3221
- _handleFacebookOauth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee86(params) {
3381
+ _handleFacebookOauth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee91(params) {
3222
3382
  var _masterConfig$auth25, _masterConfig$auth25$, _masterConfig$auth$oa4, _masterConfig$auth26, _masterConfig$auth26$;
3223
- var _ref44, _ref44$clientId, clientId, _ref44$openInPage, openInPage, additionalParameters, _masterConfig$auth27, _masterConfig$auth27$, _masterConfig$auth28, flow, redirectURI, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, facebookAuthUrl, state, additionalState, width, height, left, top, authWindow;
3224
- return _regeneratorRuntime().wrap(function _callee86$(_context86) {
3225
- while (1) switch (_context86.prev = _context86.next) {
3383
+ var _ref46, _ref46$clientId, clientId, _ref46$openInPage, openInPage, additionalParameters, _masterConfig$auth27, _masterConfig$auth27$, _masterConfig$auth28, flow, redirectURI, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, facebookAuthUrl, state, additionalState, width, height, left, top, authWindow;
3384
+ return _regeneratorRuntime().wrap(function _callee91$(_context91) {
3385
+ while (1) switch (_context91.prev = _context91.next) {
3226
3386
  case 0:
3227
- _ref44 = params || {}, _ref44$clientId = _ref44.clientId, clientId = _ref44$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth25 = masterConfig.auth) === null || _masterConfig$auth25 === void 0 ? void 0 : (_masterConfig$auth25$ = _masterConfig$auth25.oauthConfig) === null || _masterConfig$auth25$ === void 0 ? void 0 : _masterConfig$auth25$.facebookClientId : _ref44$clientId, _ref44$openInPage = _ref44.openInPage, openInPage = _ref44$openInPage === void 0 ? (_masterConfig$auth$oa4 = 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$.openOauthInPage) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : false : _ref44$openInPage, additionalParameters = _ref44.additionalState;
3228
- _context86.prev = 1;
3387
+ _ref46 = params || {}, _ref46$clientId = _ref46.clientId, clientId = _ref46$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth25 = masterConfig.auth) === null || _masterConfig$auth25 === void 0 ? void 0 : (_masterConfig$auth25$ = _masterConfig$auth25.oauthConfig) === null || _masterConfig$auth25$ === void 0 ? void 0 : _masterConfig$auth25$.facebookClientId : _ref46$clientId, _ref46$openInPage = _ref46.openInPage, openInPage = _ref46$openInPage === void 0 ? (_masterConfig$auth$oa4 = 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$.openOauthInPage) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : false : _ref46$openInPage, additionalParameters = _ref46.additionalState;
3388
+ _context91.prev = 1;
3229
3389
  if (masterConfig) {
3230
- _context86.next = 4;
3390
+ _context91.next = 4;
3231
3391
  break;
3232
3392
  }
3233
3393
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3234
3394
  case 4:
3235
3395
  if (clientId) {
3236
- _context86.next = 6;
3396
+ _context91.next = 6;
3237
3397
  break;
3238
3398
  }
3239
3399
  throw new TurnkeyError("Facebook Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3240
3400
  case 6:
3241
3401
  if ((_masterConfig$auth27 = masterConfig.auth) !== null && _masterConfig$auth27 !== void 0 && (_masterConfig$auth27$ = _masterConfig$auth27.oauthConfig) !== null && _masterConfig$auth27$ !== void 0 && _masterConfig$auth27$.oauthRedirectUri) {
3242
- _context86.next = 8;
3402
+ _context91.next = 8;
3243
3403
  break;
3244
3404
  }
3245
3405
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3246
3406
  case 8:
3247
3407
  flow = openInPage ? "redirect" : "popup";
3248
3408
  redirectURI = (_masterConfig$auth28 = masterConfig.auth) === null || _masterConfig$auth28 === void 0 ? void 0 : _masterConfig$auth28.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3249
- _context86.next = 12;
3409
+ _context91.next = 12;
3250
3410
  return createApiKeyPair();
3251
3411
  case 12:
3252
- publicKey = _context86.sent;
3412
+ publicKey = _context91.sent;
3253
3413
  if (publicKey) {
3254
- _context86.next = 15;
3414
+ _context91.next = 15;
3255
3415
  break;
3256
3416
  }
3257
3417
  throw new Error("Failed to create public key for OAuth.");
3258
3418
  case 15:
3259
3419
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
3260
- _context86.next = 18;
3420
+ _context91.next = 18;
3261
3421
  return generateChallengePair();
3262
3422
  case 18:
3263
- _yield$generateChalle = _context86.sent;
3423
+ _yield$generateChalle = _context91.sent;
3264
3424
  verifier = _yield$generateChalle.verifier;
3265
3425
  codeChallenge = _yield$generateChalle.codeChallenge;
3266
3426
  // Store verifier for later token exchange
@@ -3277,10 +3437,10 @@ var ClientProvider = function ClientProvider(_ref) {
3277
3437
  // Create state parameter
3278
3438
  state = "provider=facebook&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
3279
3439
  if (additionalParameters) {
3280
- additionalState = Object.entries(additionalParameters).map(function (_ref45) {
3281
- var _ref46 = _slicedToArray(_ref45, 2),
3282
- key = _ref46[0],
3283
- value = _ref46[1];
3440
+ additionalState = Object.entries(additionalParameters).map(function (_ref47) {
3441
+ var _ref48 = _slicedToArray(_ref47, 2),
3442
+ key = _ref48[0],
3443
+ value = _ref48[1];
3284
3444
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
3285
3445
  }).join("&");
3286
3446
  if (additionalState) {
@@ -3289,12 +3449,12 @@ var ClientProvider = function ClientProvider(_ref) {
3289
3449
  }
3290
3450
  facebookAuthUrl.searchParams.set("state", state);
3291
3451
  if (!openInPage) {
3292
- _context86.next = 38;
3452
+ _context91.next = 38;
3293
3453
  break;
3294
3454
  }
3295
3455
  // Redirect current page to Facebook Auth
3296
3456
  window.location.href = facebookAuthUrl.toString();
3297
- return _context86.abrupt("return", new Promise(function (_, reject) {
3457
+ return _context91.abrupt("return", new Promise(function (_, reject) {
3298
3458
  // Set a timeout just in case the redirect doesn't happen
3299
3459
  var timeout = setTimeout(function () {
3300
3460
  reject(new Error("Authentication timed out."));
@@ -3312,14 +3472,14 @@ var ClientProvider = function ClientProvider(_ref) {
3312
3472
  top = window.screenY + (window.innerHeight - height) / 2;
3313
3473
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3314
3474
  if (authWindow) {
3315
- _context86.next = 45;
3475
+ _context91.next = 45;
3316
3476
  break;
3317
3477
  }
3318
3478
  throw new Error("Failed to open Facebook login window.");
3319
3479
  case 45:
3320
3480
  authWindow.location.href = facebookAuthUrl.toString();
3321
3481
  // Return a promise that resolves when the OAuth flow completes
3322
- return _context86.abrupt("return", new Promise(function (resolve, reject) {
3482
+ return _context91.abrupt("return", new Promise(function (resolve, reject) {
3323
3483
  var interval = setInterval(function () {
3324
3484
  try {
3325
3485
  // Check if window was closed without completing auth
@@ -3377,17 +3537,17 @@ var ClientProvider = function ClientProvider(_ref) {
3377
3537
  }
3378
3538
  }));
3379
3539
  case 47:
3380
- _context86.next = 52;
3540
+ _context91.next = 52;
3381
3541
  break;
3382
3542
  case 49:
3383
- _context86.prev = 49;
3384
- _context86.t0 = _context86["catch"](1);
3385
- throw _context86.t0;
3543
+ _context91.prev = 49;
3544
+ _context91.t0 = _context91["catch"](1);
3545
+ throw _context91.t0;
3386
3546
  case 52:
3387
3547
  case "end":
3388
- return _context86.stop();
3548
+ return _context91.stop();
3389
3549
  }
3390
- }, _callee86, null, [[1, 49]]);
3550
+ }, _callee91, null, [[1, 49]]);
3391
3551
  }));
3392
3552
  return _handleFacebookOauth.apply(this, arguments);
3393
3553
  }
@@ -3410,19 +3570,18 @@ var ClientProvider = function ClientProvider(_ref) {
3410
3570
  return _ref9.apply(this, arguments);
3411
3571
  };
3412
3572
  }();
3413
- var handleExport = /*#__PURE__*/function () {
3573
+ var handleExportWallet = /*#__PURE__*/function () {
3414
3574
  var _ref0 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0(params) {
3415
- var _wallets$;
3416
- var walletId, exportType, targetPublicKey, stampWith;
3575
+ var walletId, targetPublicKey, stampWith;
3417
3576
  return _regeneratorRuntime().wrap(function _callee0$(_context0) {
3418
3577
  while (1) switch (_context0.prev = _context0.next) {
3419
3578
  case 0:
3420
- walletId = params.walletId, exportType = params.exportType, targetPublicKey = params.targetPublicKey, stampWith = params.stampWith;
3579
+ walletId = params.walletId, targetPublicKey = params.targetPublicKey, stampWith = params.stampWith;
3421
3580
  pushPage({
3422
3581
  key: "Export Wallet",
3423
3582
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2({
3424
- walletId: walletId !== null && walletId !== void 0 ? walletId : (_wallets$ = wallets[0]) === null || _wallets$ === void 0 ? void 0 : _wallets$.walletId,
3425
- exportType: exportType !== null && exportType !== void 0 ? exportType : ExportType.Wallet
3583
+ target: walletId,
3584
+ exportType: ExportType.Wallet
3426
3585
  }, targetPublicKey !== undefined ? {
3427
3586
  targetPublicKey: targetPublicKey
3428
3587
  } : {}), stampWith !== undefined ? {
@@ -3435,19 +3594,75 @@ var ClientProvider = function ClientProvider(_ref) {
3435
3594
  }
3436
3595
  }, _callee0);
3437
3596
  }));
3438
- return function handleExport(_x55) {
3597
+ return function handleExportWallet(_x58) {
3439
3598
  return _ref0.apply(this, arguments);
3440
3599
  };
3441
3600
  }();
3442
- var handleImport = /*#__PURE__*/function () {
3601
+ var handleExportPrivateKey = /*#__PURE__*/function () {
3443
3602
  var _ref1 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee1(params) {
3444
- var _ref10, defaultWalletAccounts, _ref10$successPageDur, successPageDuration, stampWith;
3603
+ var privateKeyId, targetPublicKey, stampWith;
3445
3604
  return _regeneratorRuntime().wrap(function _callee1$(_context1) {
3446
3605
  while (1) switch (_context1.prev = _context1.next) {
3447
3606
  case 0:
3448
- _ref10 = params || {}, defaultWalletAccounts = _ref10.defaultWalletAccounts, _ref10$successPageDur = _ref10.successPageDuration, successPageDuration = _ref10$successPageDur === void 0 ? 2000 : _ref10$successPageDur, stampWith = _ref10.stampWith;
3449
- _context1.prev = 1;
3450
- return _context1.abrupt("return", withTurnkeyErrorHandling(function () {
3607
+ privateKeyId = params.privateKeyId, targetPublicKey = params.targetPublicKey, stampWith = params.stampWith;
3608
+ pushPage({
3609
+ key: "Export Private Key",
3610
+ content: jsx(ExportComponent, _objectSpread2(_objectSpread2({
3611
+ target: privateKeyId,
3612
+ exportType: ExportType.PrivateKey
3613
+ }, targetPublicKey !== undefined ? {
3614
+ targetPublicKey: targetPublicKey
3615
+ } : {}), stampWith !== undefined ? {
3616
+ stampWith: stampWith
3617
+ } : {}))
3618
+ });
3619
+ case 2:
3620
+ case "end":
3621
+ return _context1.stop();
3622
+ }
3623
+ }, _callee1);
3624
+ }));
3625
+ return function handleExportPrivateKey(_x59) {
3626
+ return _ref1.apply(this, arguments);
3627
+ };
3628
+ }();
3629
+ var handleExportWalletAccount = /*#__PURE__*/function () {
3630
+ var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
3631
+ var address, targetPublicKey, stampWith;
3632
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
3633
+ while (1) switch (_context10.prev = _context10.next) {
3634
+ case 0:
3635
+ address = params.address, targetPublicKey = params.targetPublicKey, stampWith = params.stampWith;
3636
+ pushPage({
3637
+ key: "Export Wallet Account",
3638
+ content: jsx(ExportComponent, _objectSpread2(_objectSpread2({
3639
+ target: address,
3640
+ exportType: ExportType.WalletAccount
3641
+ }, targetPublicKey !== undefined ? {
3642
+ targetPublicKey: targetPublicKey
3643
+ } : {}), stampWith !== undefined ? {
3644
+ stampWith: stampWith
3645
+ } : {}))
3646
+ });
3647
+ case 2:
3648
+ case "end":
3649
+ return _context10.stop();
3650
+ }
3651
+ }, _callee10);
3652
+ }));
3653
+ return function handleExportWalletAccount(_x60) {
3654
+ return _ref10.apply(this, arguments);
3655
+ };
3656
+ }();
3657
+ var handleImportWallet = /*#__PURE__*/function () {
3658
+ var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
3659
+ var _ref12, defaultWalletAccounts, _ref12$successPageDur, successPageDuration, stampWith;
3660
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
3661
+ while (1) switch (_context11.prev = _context11.next) {
3662
+ case 0:
3663
+ _ref12 = params || {}, defaultWalletAccounts = _ref12.defaultWalletAccounts, _ref12$successPageDur = _ref12.successPageDuration, successPageDuration = _ref12$successPageDur === void 0 ? 2000 : _ref12$successPageDur, stampWith = _ref12.stampWith;
3664
+ _context11.prev = 1;
3665
+ return _context11.abrupt("return", withTurnkeyErrorHandling(function () {
3451
3666
  return new Promise(function (resolve, reject) {
3452
3667
  return pushPage({
3453
3668
  key: "Import Wallet",
@@ -3469,40 +3684,40 @@ var ClientProvider = function ClientProvider(_ref) {
3469
3684
  });
3470
3685
  }));
3471
3686
  case 5:
3472
- _context1.prev = 5;
3473
- _context1.t0 = _context1["catch"](1);
3474
- if (!(_context1.t0 instanceof TurnkeyError)) {
3475
- _context1.next = 9;
3687
+ _context11.prev = 5;
3688
+ _context11.t0 = _context11["catch"](1);
3689
+ if (!(_context11.t0 instanceof TurnkeyError)) {
3690
+ _context11.next = 9;
3476
3691
  break;
3477
3692
  }
3478
- throw _context1.t0;
3693
+ throw _context11.t0;
3479
3694
  case 9:
3480
- throw new TurnkeyError("Failed to import wallet.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _context1.t0);
3695
+ throw new TurnkeyError("Failed to import wallet.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _context11.t0);
3481
3696
  case 10:
3482
3697
  case "end":
3483
- return _context1.stop();
3698
+ return _context11.stop();
3484
3699
  }
3485
- }, _callee1, null, [[1, 5]]);
3700
+ }, _callee11, null, [[1, 5]]);
3486
3701
  }));
3487
- return function handleImport(_x56) {
3488
- return _ref1.apply(this, arguments);
3702
+ return function handleImportWallet(_x61) {
3703
+ return _ref11.apply(this, arguments);
3489
3704
  };
3490
3705
  }();
3491
3706
  var handleUpdateUserName = /*#__PURE__*/function () {
3492
- var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
3493
- var _ref12, _ref12$successPageDur, successPageDuration, subTitle, title, stampWith, onSuccess, res;
3494
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
3495
- while (1) switch (_context10.prev = _context10.next) {
3707
+ var _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
3708
+ var _ref14, _ref14$successPageDur, successPageDuration, subTitle, title, stampWith, onSuccess, res;
3709
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
3710
+ while (1) switch (_context12.prev = _context12.next) {
3496
3711
  case 0:
3497
- _ref12 = params || {}, _ref12$successPageDur = _ref12.successPageDuration, successPageDuration = _ref12$successPageDur === void 0 ? 2000 : _ref12$successPageDur, subTitle = _ref12.subTitle, title = _ref12.title, stampWith = _ref12.stampWith;
3712
+ _ref14 = params || {}, _ref14$successPageDur = _ref14.successPageDuration, successPageDuration = _ref14$successPageDur === void 0 ? 2000 : _ref14$successPageDur, subTitle = _ref14.subTitle, title = _ref14.title, stampWith = _ref14.stampWith;
3498
3713
  if (client) {
3499
- _context10.next = 3;
3714
+ _context12.next = 3;
3500
3715
  break;
3501
3716
  }
3502
3717
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3503
3718
  case 3:
3504
3719
  if (session) {
3505
- _context10.next = 5;
3720
+ _context12.next = 5;
3506
3721
  break;
3507
3722
  }
3508
3723
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
@@ -3522,12 +3737,12 @@ var ClientProvider = function ClientProvider(_ref) {
3522
3737
  showTitle: false
3523
3738
  });
3524
3739
  };
3525
- _context10.prev = 6;
3740
+ _context12.prev = 6;
3526
3741
  if (!(!(params !== null && params !== void 0 && params.userName) && (params === null || params === void 0 ? void 0 : params.userName) !== "")) {
3527
- _context10.next = 11;
3742
+ _context12.next = 11;
3528
3743
  break;
3529
3744
  }
3530
- return _context10.abrupt("return", withTurnkeyErrorHandling(function () {
3745
+ return _context12.abrupt("return", withTurnkeyErrorHandling(function () {
3531
3746
  return new Promise(function (resolve, reject) {
3532
3747
  pushPage({
3533
3748
  key: "Update User Name",
@@ -3550,67 +3765,67 @@ var ClientProvider = function ClientProvider(_ref) {
3550
3765
  });
3551
3766
  }));
3552
3767
  case 11:
3553
- _context10.next = 13;
3768
+ _context12.next = 13;
3554
3769
  return updateUserName({
3555
3770
  userName: params.userName,
3556
3771
  userId: user.userId,
3557
3772
  stampWith: stampWith
3558
3773
  });
3559
3774
  case 13:
3560
- res = _context10.sent;
3775
+ res = _context12.sent;
3561
3776
  onSuccess();
3562
- return _context10.abrupt("return", res);
3777
+ return _context12.abrupt("return", res);
3563
3778
  case 16:
3564
- _context10.next = 23;
3779
+ _context12.next = 23;
3565
3780
  break;
3566
3781
  case 18:
3567
- _context10.prev = 18;
3568
- _context10.t0 = _context10["catch"](6);
3569
- if (!(_context10.t0 instanceof TurnkeyError)) {
3570
- _context10.next = 22;
3782
+ _context12.prev = 18;
3783
+ _context12.t0 = _context12["catch"](6);
3784
+ if (!(_context12.t0 instanceof TurnkeyError)) {
3785
+ _context12.next = 22;
3571
3786
  break;
3572
3787
  }
3573
- throw _context10.t0;
3788
+ throw _context12.t0;
3574
3789
  case 22:
3575
- throw new TurnkeyError("Failed to update user name.", TurnkeyErrorCodes.UPDATE_USER_NAME_ERROR, _context10.t0);
3790
+ throw new TurnkeyError("Failed to update user name.", TurnkeyErrorCodes.UPDATE_USER_NAME_ERROR, _context12.t0);
3576
3791
  case 23:
3577
3792
  case "end":
3578
- return _context10.stop();
3793
+ return _context12.stop();
3579
3794
  }
3580
- }, _callee10, null, [[6, 18]]);
3795
+ }, _callee12, null, [[6, 18]]);
3581
3796
  }));
3582
- return function handleUpdateUserName(_x57) {
3583
- return _ref11.apply(this, arguments);
3797
+ return function handleUpdateUserName(_x62) {
3798
+ return _ref13.apply(this, arguments);
3584
3799
  };
3585
3800
  }();
3586
3801
  var handleUpdateUserPhoneNumber = /*#__PURE__*/function () {
3587
- var _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
3588
- var _masterConfig$auth4, _masterConfig$auth4$m;
3589
- var _ref14, _ref14$successPageDur, successPageDuration, subTitle, title, onSuccess, otpId;
3590
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
3591
- while (1) switch (_context12.prev = _context12.next) {
3802
+ var _ref15 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
3803
+ var _masterConfig$auth3, _masterConfig$auth3$m;
3804
+ var _ref16, _ref16$successPageDur, successPageDuration, subTitle, title, onSuccess, otpId;
3805
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
3806
+ while (1) switch (_context14.prev = _context14.next) {
3592
3807
  case 0:
3593
- _ref14 = params || {}, _ref14$successPageDur = _ref14.successPageDuration, successPageDuration = _ref14$successPageDur === void 0 ? 2000 : _ref14$successPageDur, subTitle = _ref14.subTitle, title = _ref14.title;
3808
+ _ref16 = params || {}, _ref16$successPageDur = _ref16.successPageDuration, successPageDuration = _ref16$successPageDur === void 0 ? 2000 : _ref16$successPageDur, subTitle = _ref16.subTitle, title = _ref16.title;
3594
3809
  if (client) {
3595
- _context12.next = 3;
3810
+ _context14.next = 3;
3596
3811
  break;
3597
3812
  }
3598
3813
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3599
3814
  case 3:
3600
3815
  if (session) {
3601
- _context12.next = 5;
3816
+ _context14.next = 5;
3602
3817
  break;
3603
3818
  }
3604
3819
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
3605
3820
  case 5:
3606
3821
  if (masterConfig) {
3607
- _context12.next = 7;
3822
+ _context14.next = 7;
3608
3823
  break;
3609
3824
  }
3610
3825
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
3611
3826
  case 7:
3612
- if ((_masterConfig$auth4 = masterConfig.auth) !== null && _masterConfig$auth4 !== void 0 && (_masterConfig$auth4$m = _masterConfig$auth4.methods) !== null && _masterConfig$auth4$m !== void 0 && _masterConfig$auth4$m.smsOtpAuthEnabled) {
3613
- _context12.next = 9;
3827
+ if ((_masterConfig$auth3 = masterConfig.auth) !== null && _masterConfig$auth3 !== void 0 && (_masterConfig$auth3$m = _masterConfig$auth3.methods) !== null && _masterConfig$auth3$m !== void 0 && _masterConfig$auth3$m.smsOtpAuthEnabled) {
3828
+ _context14.next = 9;
3614
3829
  break;
3615
3830
  }
3616
3831
  throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
@@ -3630,12 +3845,12 @@ var ClientProvider = function ClientProvider(_ref) {
3630
3845
  showTitle: false
3631
3846
  });
3632
3847
  };
3633
- _context12.prev = 10;
3848
+ _context14.prev = 10;
3634
3849
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
3635
- _context12.next = 15;
3850
+ _context14.next = 15;
3636
3851
  break;
3637
3852
  }
3638
- return _context12.abrupt("return", withTurnkeyErrorHandling(function () {
3853
+ return _context14.abrupt("return", withTurnkeyErrorHandling(function () {
3639
3854
  return new Promise(function (resolve, reject) {
3640
3855
  pushPage({
3641
3856
  key: "Update Phone Number",
@@ -3657,14 +3872,14 @@ var ClientProvider = function ClientProvider(_ref) {
3657
3872
  });
3658
3873
  }));
3659
3874
  case 15:
3660
- _context12.next = 17;
3875
+ _context14.next = 17;
3661
3876
  return initOtp({
3662
3877
  otpType: OtpType.Sms,
3663
3878
  contact: params.phoneNumber
3664
3879
  });
3665
3880
  case 17:
3666
- otpId = _context12.sent;
3667
- return _context12.abrupt("return", withTurnkeyErrorHandling(function () {
3881
+ otpId = _context14.sent;
3882
+ return _context14.abrupt("return", withTurnkeyErrorHandling(function () {
3668
3883
  return new Promise(function (resolve, reject) {
3669
3884
  pushPage({
3670
3885
  key: "Update Phone Number",
@@ -3673,13 +3888,13 @@ var ClientProvider = function ClientProvider(_ref) {
3673
3888
  contact: params.phoneNumber,
3674
3889
  otpId: otpId,
3675
3890
  onContinue: function () {
3676
- var _onContinue = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(otpCode) {
3891
+ var _onContinue = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(otpCode) {
3677
3892
  var _yield$verifyOtp, verificationToken, res;
3678
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
3679
- while (1) switch (_context11.prev = _context11.next) {
3893
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
3894
+ while (1) switch (_context13.prev = _context13.next) {
3680
3895
  case 0:
3681
- _context11.prev = 0;
3682
- _context11.next = 3;
3896
+ _context13.prev = 0;
3897
+ _context13.next = 3;
3683
3898
  return verifyOtp({
3684
3899
  otpId: otpId,
3685
3900
  otpCode: otpCode,
@@ -3687,31 +3902,31 @@ var ClientProvider = function ClientProvider(_ref) {
3687
3902
  otpType: OtpType.Sms
3688
3903
  });
3689
3904
  case 3:
3690
- _yield$verifyOtp = _context11.sent;
3905
+ _yield$verifyOtp = _context13.sent;
3691
3906
  verificationToken = _yield$verifyOtp.verificationToken;
3692
- _context11.next = 7;
3907
+ _context13.next = 7;
3693
3908
  return updateUserPhoneNumber({
3694
3909
  phoneNumber: params.phoneNumber,
3695
3910
  verificationToken: verificationToken,
3696
3911
  userId: user.userId
3697
3912
  });
3698
3913
  case 7:
3699
- res = _context11.sent;
3914
+ res = _context13.sent;
3700
3915
  onSuccess();
3701
3916
  resolve(res);
3702
- _context11.next = 15;
3917
+ _context13.next = 15;
3703
3918
  break;
3704
3919
  case 12:
3705
- _context11.prev = 12;
3706
- _context11.t0 = _context11["catch"](0);
3707
- reject(_context11.t0);
3920
+ _context13.prev = 12;
3921
+ _context13.t0 = _context13["catch"](0);
3922
+ reject(_context13.t0);
3708
3923
  case 15:
3709
3924
  case "end":
3710
- return _context11.stop();
3925
+ return _context13.stop();
3711
3926
  }
3712
- }, _callee11, null, [[0, 12]]);
3927
+ }, _callee13, null, [[0, 12]]);
3713
3928
  }));
3714
- function onContinue(_x59) {
3929
+ function onContinue(_x64) {
3715
3930
  return _onContinue.apply(this, arguments);
3716
3931
  }
3717
3932
  return onContinue;
@@ -3728,43 +3943,43 @@ var ClientProvider = function ClientProvider(_ref) {
3728
3943
  });
3729
3944
  }, callbacks, "Failed to update phone number"));
3730
3945
  case 19:
3731
- _context12.next = 26;
3946
+ _context14.next = 26;
3732
3947
  break;
3733
3948
  case 21:
3734
- _context12.prev = 21;
3735
- _context12.t0 = _context12["catch"](10);
3736
- if (!(_context12.t0 instanceof TurnkeyError)) {
3737
- _context12.next = 25;
3949
+ _context14.prev = 21;
3950
+ _context14.t0 = _context14["catch"](10);
3951
+ if (!(_context14.t0 instanceof TurnkeyError)) {
3952
+ _context14.next = 25;
3738
3953
  break;
3739
3954
  }
3740
- throw _context12.t0;
3955
+ throw _context14.t0;
3741
3956
  case 25:
3742
- throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context12.t0);
3957
+ throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context14.t0);
3743
3958
  case 26:
3744
3959
  case "end":
3745
- return _context12.stop();
3960
+ return _context14.stop();
3746
3961
  }
3747
- }, _callee12, null, [[10, 21]]);
3962
+ }, _callee14, null, [[10, 21]]);
3748
3963
  }));
3749
- return function handleUpdateUserPhoneNumber(_x58) {
3750
- return _ref13.apply(this, arguments);
3964
+ return function handleUpdateUserPhoneNumber(_x63) {
3965
+ return _ref15.apply(this, arguments);
3751
3966
  };
3752
3967
  }();
3753
3968
  var handleUpdateUserEmail = /*#__PURE__*/function () {
3754
- var _ref15 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
3755
- var _ref16, _ref16$successPageDur, successPageDuration, subTitle, title, onSuccess, otpId;
3756
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
3757
- while (1) switch (_context14.prev = _context14.next) {
3969
+ var _ref17 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
3970
+ var _ref18, _ref18$successPageDur, successPageDuration, subTitle, title, onSuccess, otpId;
3971
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
3972
+ while (1) switch (_context16.prev = _context16.next) {
3758
3973
  case 0:
3759
- _ref16 = params || {}, _ref16$successPageDur = _ref16.successPageDuration, successPageDuration = _ref16$successPageDur === void 0 ? 2000 : _ref16$successPageDur, subTitle = _ref16.subTitle, title = _ref16.title;
3974
+ _ref18 = params || {}, _ref18$successPageDur = _ref18.successPageDuration, successPageDuration = _ref18$successPageDur === void 0 ? 2000 : _ref18$successPageDur, subTitle = _ref18.subTitle, title = _ref18.title;
3760
3975
  if (client) {
3761
- _context14.next = 3;
3976
+ _context16.next = 3;
3762
3977
  break;
3763
3978
  }
3764
3979
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3765
3980
  case 3:
3766
3981
  if (session) {
3767
- _context14.next = 5;
3982
+ _context16.next = 5;
3768
3983
  break;
3769
3984
  }
3770
3985
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
@@ -3784,12 +3999,12 @@ var ClientProvider = function ClientProvider(_ref) {
3784
3999
  showTitle: false
3785
4000
  });
3786
4001
  };
3787
- _context14.prev = 6;
4002
+ _context16.prev = 6;
3788
4003
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
3789
- _context14.next = 11;
4004
+ _context16.next = 11;
3790
4005
  break;
3791
4006
  }
3792
- return _context14.abrupt("return", withTurnkeyErrorHandling(function () {
4007
+ return _context16.abrupt("return", withTurnkeyErrorHandling(function () {
3793
4008
  return new Promise(function (resolve, reject) {
3794
4009
  pushPage({
3795
4010
  key: "Update Email",
@@ -3811,14 +4026,14 @@ var ClientProvider = function ClientProvider(_ref) {
3811
4026
  });
3812
4027
  }));
3813
4028
  case 11:
3814
- _context14.next = 13;
4029
+ _context16.next = 13;
3815
4030
  return initOtp({
3816
4031
  otpType: OtpType.Email,
3817
4032
  contact: params.email
3818
4033
  });
3819
4034
  case 13:
3820
- otpId = _context14.sent;
3821
- return _context14.abrupt("return", withTurnkeyErrorHandling(function () {
4035
+ otpId = _context16.sent;
4036
+ return _context16.abrupt("return", withTurnkeyErrorHandling(function () {
3822
4037
  return new Promise(function (resolve, reject) {
3823
4038
  pushPage({
3824
4039
  key: "Update Email",
@@ -3827,13 +4042,13 @@ var ClientProvider = function ClientProvider(_ref) {
3827
4042
  contact: params.email,
3828
4043
  otpId: otpId,
3829
4044
  onContinue: function () {
3830
- var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(otpCode) {
4045
+ var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(otpCode) {
3831
4046
  var _yield$verifyOtp2, verificationToken, res;
3832
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
3833
- while (1) switch (_context13.prev = _context13.next) {
4047
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
4048
+ while (1) switch (_context15.prev = _context15.next) {
3834
4049
  case 0:
3835
- _context13.prev = 0;
3836
- _context13.next = 3;
4050
+ _context15.prev = 0;
4051
+ _context15.next = 3;
3837
4052
  return verifyOtp({
3838
4053
  otpId: otpId,
3839
4054
  otpCode: otpCode,
@@ -3841,31 +4056,31 @@ var ClientProvider = function ClientProvider(_ref) {
3841
4056
  otpType: OtpType.Email
3842
4057
  });
3843
4058
  case 3:
3844
- _yield$verifyOtp2 = _context13.sent;
4059
+ _yield$verifyOtp2 = _context15.sent;
3845
4060
  verificationToken = _yield$verifyOtp2.verificationToken;
3846
- _context13.next = 7;
4061
+ _context15.next = 7;
3847
4062
  return updateUserEmail({
3848
4063
  email: params.email,
3849
4064
  verificationToken: verificationToken,
3850
4065
  userId: user.userId
3851
4066
  });
3852
4067
  case 7:
3853
- res = _context13.sent;
4068
+ res = _context15.sent;
3854
4069
  onSuccess();
3855
4070
  resolve(res);
3856
- _context13.next = 15;
4071
+ _context15.next = 15;
3857
4072
  break;
3858
4073
  case 12:
3859
- _context13.prev = 12;
3860
- _context13.t0 = _context13["catch"](0);
3861
- reject(_context13.t0);
4074
+ _context15.prev = 12;
4075
+ _context15.t0 = _context15["catch"](0);
4076
+ reject(_context15.t0);
3862
4077
  case 15:
3863
4078
  case "end":
3864
- return _context13.stop();
4079
+ return _context15.stop();
3865
4080
  }
3866
- }, _callee13, null, [[0, 12]]);
4081
+ }, _callee15, null, [[0, 12]]);
3867
4082
  }));
3868
- function onContinue(_x61) {
4083
+ function onContinue(_x66) {
3869
4084
  return _onContinue2.apply(this, arguments);
3870
4085
  }
3871
4086
  return onContinue;
@@ -3880,43 +4095,43 @@ var ClientProvider = function ClientProvider(_ref) {
3880
4095
  });
3881
4096
  }, callbacks, "Failed to update email"));
3882
4097
  case 15:
3883
- _context14.next = 22;
4098
+ _context16.next = 22;
3884
4099
  break;
3885
4100
  case 17:
3886
- _context14.prev = 17;
3887
- _context14.t0 = _context14["catch"](6);
3888
- if (!(_context14.t0 instanceof TurnkeyError)) {
3889
- _context14.next = 21;
4101
+ _context16.prev = 17;
4102
+ _context16.t0 = _context16["catch"](6);
4103
+ if (!(_context16.t0 instanceof TurnkeyError)) {
4104
+ _context16.next = 21;
3890
4105
  break;
3891
4106
  }
3892
- throw _context14.t0;
4107
+ throw _context16.t0;
3893
4108
  case 21:
3894
- throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context14.t0);
4109
+ throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context16.t0);
3895
4110
  case 22:
3896
4111
  case "end":
3897
- return _context14.stop();
4112
+ return _context16.stop();
3898
4113
  }
3899
- }, _callee14, null, [[6, 17]]);
4114
+ }, _callee16, null, [[6, 17]]);
3900
4115
  }));
3901
- return function handleUpdateUserEmail(_x60) {
3902
- return _ref15.apply(this, arguments);
4116
+ return function handleUpdateUserEmail(_x65) {
4117
+ return _ref17.apply(this, arguments);
3903
4118
  };
3904
4119
  }();
3905
4120
  var handleAddEmail = /*#__PURE__*/function () {
3906
- var _ref17 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
3907
- var _ref18, _ref18$successPageDur, successPageDuration, subTitle, title, onSuccess, otpId;
3908
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
3909
- while (1) switch (_context16.prev = _context16.next) {
4121
+ var _ref19 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
4122
+ var _ref20, _ref20$successPageDur, successPageDuration, subTitle, title, onSuccess, otpId;
4123
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
4124
+ while (1) switch (_context18.prev = _context18.next) {
3910
4125
  case 0:
3911
- _ref18 = params || {}, _ref18$successPageDur = _ref18.successPageDuration, successPageDuration = _ref18$successPageDur === void 0 ? 2000 : _ref18$successPageDur, subTitle = _ref18.subTitle, title = _ref18.title;
4126
+ _ref20 = params || {}, _ref20$successPageDur = _ref20.successPageDuration, successPageDuration = _ref20$successPageDur === void 0 ? 2000 : _ref20$successPageDur, subTitle = _ref20.subTitle, title = _ref20.title;
3912
4127
  if (client) {
3913
- _context16.next = 3;
4128
+ _context18.next = 3;
3914
4129
  break;
3915
4130
  }
3916
4131
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3917
4132
  case 3:
3918
4133
  if (session) {
3919
- _context16.next = 5;
4134
+ _context18.next = 5;
3920
4135
  break;
3921
4136
  }
3922
4137
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
@@ -3936,12 +4151,12 @@ var ClientProvider = function ClientProvider(_ref) {
3936
4151
  showTitle: false
3937
4152
  });
3938
4153
  };
3939
- _context16.prev = 6;
4154
+ _context18.prev = 6;
3940
4155
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
3941
- _context16.next = 11;
4156
+ _context18.next = 11;
3942
4157
  break;
3943
4158
  }
3944
- return _context16.abrupt("return", withTurnkeyErrorHandling(function () {
4159
+ return _context18.abrupt("return", withTurnkeyErrorHandling(function () {
3945
4160
  return new Promise(function (resolve, reject) {
3946
4161
  pushPage({
3947
4162
  key: "Add Email",
@@ -3963,14 +4178,14 @@ var ClientProvider = function ClientProvider(_ref) {
3963
4178
  });
3964
4179
  }));
3965
4180
  case 11:
3966
- _context16.next = 13;
4181
+ _context18.next = 13;
3967
4182
  return initOtp({
3968
4183
  otpType: OtpType.Email,
3969
4184
  contact: params.email
3970
4185
  });
3971
4186
  case 13:
3972
- otpId = _context16.sent;
3973
- return _context16.abrupt("return", withTurnkeyErrorHandling(function () {
4187
+ otpId = _context18.sent;
4188
+ return _context18.abrupt("return", withTurnkeyErrorHandling(function () {
3974
4189
  return new Promise(function (resolve, reject) {
3975
4190
  pushPage({
3976
4191
  key: "Add Email",
@@ -3979,13 +4194,13 @@ var ClientProvider = function ClientProvider(_ref) {
3979
4194
  contact: params.email,
3980
4195
  otpId: otpId,
3981
4196
  onContinue: function () {
3982
- var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(otpCode) {
4197
+ var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(otpCode) {
3983
4198
  var _yield$verifyOtp3, verificationToken, res;
3984
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
3985
- while (1) switch (_context15.prev = _context15.next) {
4199
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
4200
+ while (1) switch (_context17.prev = _context17.next) {
3986
4201
  case 0:
3987
- _context15.prev = 0;
3988
- _context15.next = 3;
4202
+ _context17.prev = 0;
4203
+ _context17.next = 3;
3989
4204
  return verifyOtp({
3990
4205
  otpId: otpId,
3991
4206
  otpCode: otpCode,
@@ -3993,31 +4208,31 @@ var ClientProvider = function ClientProvider(_ref) {
3993
4208
  otpType: OtpType.Email
3994
4209
  });
3995
4210
  case 3:
3996
- _yield$verifyOtp3 = _context15.sent;
4211
+ _yield$verifyOtp3 = _context17.sent;
3997
4212
  verificationToken = _yield$verifyOtp3.verificationToken;
3998
- _context15.next = 7;
4213
+ _context17.next = 7;
3999
4214
  return updateUserEmail({
4000
4215
  email: params.email,
4001
4216
  verificationToken: verificationToken,
4002
4217
  userId: user.userId
4003
4218
  });
4004
4219
  case 7:
4005
- res = _context15.sent;
4220
+ res = _context17.sent;
4006
4221
  onSuccess();
4007
4222
  resolve(res);
4008
- _context15.next = 15;
4223
+ _context17.next = 15;
4009
4224
  break;
4010
4225
  case 12:
4011
- _context15.prev = 12;
4012
- _context15.t0 = _context15["catch"](0);
4013
- reject(_context15.t0);
4226
+ _context17.prev = 12;
4227
+ _context17.t0 = _context17["catch"](0);
4228
+ reject(_context17.t0);
4014
4229
  case 15:
4015
4230
  case "end":
4016
- return _context15.stop();
4231
+ return _context17.stop();
4017
4232
  }
4018
- }, _callee15, null, [[0, 12]]);
4233
+ }, _callee17, null, [[0, 12]]);
4019
4234
  }));
4020
- function onContinue(_x63) {
4235
+ function onContinue(_x68) {
4021
4236
  return _onContinue3.apply(this, arguments);
4022
4237
  }
4023
4238
  return onContinue;
@@ -4032,56 +4247,56 @@ var ClientProvider = function ClientProvider(_ref) {
4032
4247
  });
4033
4248
  }, callbacks, "Failed to add email"));
4034
4249
  case 15:
4035
- _context16.next = 22;
4250
+ _context18.next = 22;
4036
4251
  break;
4037
4252
  case 17:
4038
- _context16.prev = 17;
4039
- _context16.t0 = _context16["catch"](6);
4040
- if (!(_context16.t0 instanceof TurnkeyError)) {
4041
- _context16.next = 21;
4253
+ _context18.prev = 17;
4254
+ _context18.t0 = _context18["catch"](6);
4255
+ if (!(_context18.t0 instanceof TurnkeyError)) {
4256
+ _context18.next = 21;
4042
4257
  break;
4043
4258
  }
4044
- throw _context16.t0;
4259
+ throw _context18.t0;
4045
4260
  case 21:
4046
- throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context16.t0);
4261
+ throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context18.t0);
4047
4262
  case 22:
4048
4263
  case "end":
4049
- return _context16.stop();
4264
+ return _context18.stop();
4050
4265
  }
4051
- }, _callee16, null, [[6, 17]]);
4266
+ }, _callee18, null, [[6, 17]]);
4052
4267
  }));
4053
- return function handleAddEmail(_x62) {
4054
- return _ref17.apply(this, arguments);
4268
+ return function handleAddEmail(_x67) {
4269
+ return _ref19.apply(this, arguments);
4055
4270
  };
4056
4271
  }();
4057
4272
  var handleAddPhoneNumber = /*#__PURE__*/function () {
4058
- var _ref19 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
4059
- var _masterConfig$auth5, _masterConfig$auth5$m;
4060
- var _ref20, _ref20$successPageDur, successPageDuration, subTitle, title, onSuccess, otpId;
4061
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
4062
- while (1) switch (_context18.prev = _context18.next) {
4273
+ var _ref21 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
4274
+ var _masterConfig$auth4, _masterConfig$auth4$m;
4275
+ var _ref22, _ref22$successPageDur, successPageDuration, subTitle, title, onSuccess, otpId;
4276
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
4277
+ while (1) switch (_context20.prev = _context20.next) {
4063
4278
  case 0:
4064
- _ref20 = params || {}, _ref20$successPageDur = _ref20.successPageDuration, successPageDuration = _ref20$successPageDur === void 0 ? 2000 : _ref20$successPageDur, subTitle = _ref20.subTitle, title = _ref20.title;
4279
+ _ref22 = params || {}, _ref22$successPageDur = _ref22.successPageDuration, successPageDuration = _ref22$successPageDur === void 0 ? 2000 : _ref22$successPageDur, subTitle = _ref22.subTitle, title = _ref22.title;
4065
4280
  if (client) {
4066
- _context18.next = 3;
4281
+ _context20.next = 3;
4067
4282
  break;
4068
4283
  }
4069
4284
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4070
4285
  case 3:
4071
4286
  if (session) {
4072
- _context18.next = 5;
4287
+ _context20.next = 5;
4073
4288
  break;
4074
4289
  }
4075
4290
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
4076
4291
  case 5:
4077
4292
  if (masterConfig) {
4078
- _context18.next = 7;
4293
+ _context20.next = 7;
4079
4294
  break;
4080
4295
  }
4081
4296
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
4082
4297
  case 7:
4083
- if ((_masterConfig$auth5 = masterConfig.auth) !== null && _masterConfig$auth5 !== void 0 && (_masterConfig$auth5$m = _masterConfig$auth5.methods) !== null && _masterConfig$auth5$m !== void 0 && _masterConfig$auth5$m.smsOtpAuthEnabled) {
4084
- _context18.next = 9;
4298
+ if ((_masterConfig$auth4 = masterConfig.auth) !== null && _masterConfig$auth4 !== void 0 && (_masterConfig$auth4$m = _masterConfig$auth4.methods) !== null && _masterConfig$auth4$m !== void 0 && _masterConfig$auth4$m.smsOtpAuthEnabled) {
4299
+ _context20.next = 9;
4085
4300
  break;
4086
4301
  }
4087
4302
  throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
@@ -4101,12 +4316,12 @@ var ClientProvider = function ClientProvider(_ref) {
4101
4316
  showTitle: false
4102
4317
  });
4103
4318
  };
4104
- _context18.prev = 10;
4319
+ _context20.prev = 10;
4105
4320
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
4106
- _context18.next = 15;
4321
+ _context20.next = 15;
4107
4322
  break;
4108
4323
  }
4109
- return _context18.abrupt("return", withTurnkeyErrorHandling(function () {
4324
+ return _context20.abrupt("return", withTurnkeyErrorHandling(function () {
4110
4325
  return new Promise(function (resolve, reject) {
4111
4326
  pushPage({
4112
4327
  key: "Add Phone Number",
@@ -4128,14 +4343,14 @@ var ClientProvider = function ClientProvider(_ref) {
4128
4343
  });
4129
4344
  }, callbacks, "Failed to add phone number"));
4130
4345
  case 15:
4131
- _context18.next = 17;
4346
+ _context20.next = 17;
4132
4347
  return initOtp({
4133
4348
  otpType: OtpType.Sms,
4134
4349
  contact: params.phoneNumber
4135
4350
  });
4136
4351
  case 17:
4137
- otpId = _context18.sent;
4138
- return _context18.abrupt("return", withTurnkeyErrorHandling(function () {
4352
+ otpId = _context20.sent;
4353
+ return _context20.abrupt("return", withTurnkeyErrorHandling(function () {
4139
4354
  return new Promise(function (resolve, reject) {
4140
4355
  pushPage({
4141
4356
  key: "Add Phone Number",
@@ -4144,13 +4359,13 @@ var ClientProvider = function ClientProvider(_ref) {
4144
4359
  contact: params.phoneNumber,
4145
4360
  otpId: otpId,
4146
4361
  onContinue: function () {
4147
- var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(otpCode) {
4362
+ var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(otpCode) {
4148
4363
  var _yield$verifyOtp4, verificationToken, res;
4149
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
4150
- while (1) switch (_context17.prev = _context17.next) {
4364
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
4365
+ while (1) switch (_context19.prev = _context19.next) {
4151
4366
  case 0:
4152
- _context17.prev = 0;
4153
- _context17.next = 3;
4367
+ _context19.prev = 0;
4368
+ _context19.next = 3;
4154
4369
  return verifyOtp({
4155
4370
  otpId: otpId,
4156
4371
  otpCode: otpCode,
@@ -4158,31 +4373,31 @@ var ClientProvider = function ClientProvider(_ref) {
4158
4373
  otpType: OtpType.Sms
4159
4374
  });
4160
4375
  case 3:
4161
- _yield$verifyOtp4 = _context17.sent;
4376
+ _yield$verifyOtp4 = _context19.sent;
4162
4377
  verificationToken = _yield$verifyOtp4.verificationToken;
4163
- _context17.next = 7;
4378
+ _context19.next = 7;
4164
4379
  return updateUserPhoneNumber({
4165
4380
  phoneNumber: params.phoneNumber,
4166
4381
  verificationToken: verificationToken,
4167
4382
  userId: user.userId
4168
4383
  });
4169
4384
  case 7:
4170
- res = _context17.sent;
4385
+ res = _context19.sent;
4171
4386
  onSuccess();
4172
4387
  resolve(res);
4173
- _context17.next = 15;
4388
+ _context19.next = 15;
4174
4389
  break;
4175
4390
  case 12:
4176
- _context17.prev = 12;
4177
- _context17.t0 = _context17["catch"](0);
4178
- reject(_context17.t0);
4391
+ _context19.prev = 12;
4392
+ _context19.t0 = _context19["catch"](0);
4393
+ reject(_context19.t0);
4179
4394
  case 15:
4180
4395
  case "end":
4181
- return _context17.stop();
4396
+ return _context19.stop();
4182
4397
  }
4183
- }, _callee17, null, [[0, 12]]);
4398
+ }, _callee19, null, [[0, 12]]);
4184
4399
  }));
4185
- function onContinue(_x65) {
4400
+ function onContinue(_x70) {
4186
4401
  return _onContinue4.apply(this, arguments);
4187
4402
  }
4188
4403
  return onContinue;
@@ -4199,48 +4414,48 @@ var ClientProvider = function ClientProvider(_ref) {
4199
4414
  });
4200
4415
  }, callbacks, "Failed to add phone number"));
4201
4416
  case 19:
4202
- _context18.next = 26;
4417
+ _context20.next = 26;
4203
4418
  break;
4204
4419
  case 21:
4205
- _context18.prev = 21;
4206
- _context18.t0 = _context18["catch"](10);
4207
- if (!(_context18.t0 instanceof TurnkeyError)) {
4208
- _context18.next = 25;
4420
+ _context20.prev = 21;
4421
+ _context20.t0 = _context20["catch"](10);
4422
+ if (!(_context20.t0 instanceof TurnkeyError)) {
4423
+ _context20.next = 25;
4209
4424
  break;
4210
4425
  }
4211
- throw _context18.t0;
4426
+ throw _context20.t0;
4212
4427
  case 25:
4213
- throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context18.t0);
4428
+ throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _context20.t0);
4214
4429
  case 26:
4215
4430
  case "end":
4216
- return _context18.stop();
4431
+ return _context20.stop();
4217
4432
  }
4218
- }, _callee18, null, [[10, 21]]);
4433
+ }, _callee20, null, [[10, 21]]);
4219
4434
  }));
4220
- return function handleAddPhoneNumber(_x64) {
4221
- return _ref19.apply(this, arguments);
4435
+ return function handleAddPhoneNumber(_x69) {
4436
+ return _ref21.apply(this, arguments);
4222
4437
  };
4223
4438
  }();
4224
4439
  var handleRemovePasskey = /*#__PURE__*/function () {
4225
- var _ref21 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
4440
+ var _ref23 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
4226
4441
  var authenticatorId, _params$successPageDu, successPageDuration, subTitle, title, stampWith, userId;
4227
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
4228
- while (1) switch (_context19.prev = _context19.next) {
4442
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
4443
+ while (1) switch (_context21.prev = _context21.next) {
4229
4444
  case 0:
4230
4445
  authenticatorId = params.authenticatorId, _params$successPageDu = params.successPageDuration, successPageDuration = _params$successPageDu === void 0 ? 2000 : _params$successPageDu, subTitle = params.subTitle, title = params.title, stampWith = params.stampWith, userId = params.userId;
4231
4446
  if (client) {
4232
- _context19.next = 3;
4447
+ _context21.next = 3;
4233
4448
  break;
4234
4449
  }
4235
4450
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4236
4451
  case 3:
4237
4452
  if (session) {
4238
- _context19.next = 5;
4453
+ _context21.next = 5;
4239
4454
  break;
4240
4455
  }
4241
4456
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
4242
4457
  case 5:
4243
- return _context19.abrupt("return", withTurnkeyErrorHandling(function () {
4458
+ return _context21.abrupt("return", withTurnkeyErrorHandling(function () {
4244
4459
  return new Promise(function (resolve, reject) {
4245
4460
  pushPage({
4246
4461
  key: "Remove Passkey",
@@ -4268,35 +4483,35 @@ var ClientProvider = function ClientProvider(_ref) {
4268
4483
  }, callbacks, "Failed to remove passkey"));
4269
4484
  case 6:
4270
4485
  case "end":
4271
- return _context19.stop();
4486
+ return _context21.stop();
4272
4487
  }
4273
- }, _callee19);
4488
+ }, _callee21);
4274
4489
  }));
4275
- return function handleRemovePasskey(_x66) {
4276
- return _ref21.apply(this, arguments);
4490
+ return function handleRemovePasskey(_x71) {
4491
+ return _ref23.apply(this, arguments);
4277
4492
  };
4278
4493
  }();
4279
4494
  var handleAddPasskey = /*#__PURE__*/function () {
4280
- var _ref22 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
4281
- var _ref23, name, displayName, _ref23$successPageDur, successPageDuration, stampWith, userId, resPromise;
4282
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
4283
- while (1) switch (_context20.prev = _context20.next) {
4495
+ var _ref24 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
4496
+ var _ref25, name, displayName, _ref25$successPageDur, successPageDuration, stampWith, userId, resPromise;
4497
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
4498
+ while (1) switch (_context22.prev = _context22.next) {
4284
4499
  case 0:
4285
- _ref23 = params || {}, name = _ref23.name, displayName = _ref23.displayName, _ref23$successPageDur = _ref23.successPageDuration, successPageDuration = _ref23$successPageDur === void 0 ? 2000 : _ref23$successPageDur, stampWith = _ref23.stampWith;
4500
+ _ref25 = params || {}, name = _ref25.name, displayName = _ref25.displayName, _ref25$successPageDur = _ref25.successPageDuration, successPageDuration = _ref25$successPageDur === void 0 ? 2000 : _ref25$successPageDur, stampWith = _ref25.stampWith;
4286
4501
  if (client) {
4287
- _context20.next = 3;
4502
+ _context22.next = 3;
4288
4503
  break;
4289
4504
  }
4290
4505
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4291
4506
  case 3:
4292
4507
  if (session) {
4293
- _context20.next = 5;
4508
+ _context22.next = 5;
4294
4509
  break;
4295
4510
  }
4296
4511
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
4297
4512
  case 5:
4298
4513
  userId = (params === null || params === void 0 ? void 0 : params.userId) || session.userId;
4299
- _context20.prev = 6;
4514
+ _context22.prev = 6;
4300
4515
  resPromise = addPasskey(_objectSpread2(_objectSpread2(_objectSpread2({}, name && {
4301
4516
  name: name
4302
4517
  }), displayName && {
@@ -4319,51 +4534,51 @@ var ClientProvider = function ClientProvider(_ref) {
4319
4534
  showTitle: false
4320
4535
  });
4321
4536
  });
4322
- _context20.next = 11;
4537
+ _context22.next = 11;
4323
4538
  return resPromise;
4324
4539
  case 11:
4325
- return _context20.abrupt("return", _context20.sent);
4540
+ return _context22.abrupt("return", _context22.sent);
4326
4541
  case 14:
4327
- _context20.prev = 14;
4328
- _context20.t0 = _context20["catch"](6);
4329
- if (!(_context20.t0 instanceof TurnkeyError)) {
4330
- _context20.next = 18;
4542
+ _context22.prev = 14;
4543
+ _context22.t0 = _context22["catch"](6);
4544
+ if (!(_context22.t0 instanceof TurnkeyError)) {
4545
+ _context22.next = 18;
4331
4546
  break;
4332
4547
  }
4333
- throw _context20.t0;
4548
+ throw _context22.t0;
4334
4549
  case 18:
4335
- throw new TurnkeyError("Failed to add passkey in handler.", TurnkeyErrorCodes.ADD_PASSKEY_ERROR, _context20.t0);
4550
+ throw new TurnkeyError("Failed to add passkey in handler.", TurnkeyErrorCodes.ADD_PASSKEY_ERROR, _context22.t0);
4336
4551
  case 19:
4337
4552
  case "end":
4338
- return _context20.stop();
4553
+ return _context22.stop();
4339
4554
  }
4340
- }, _callee20, null, [[6, 14]]);
4555
+ }, _callee22, null, [[6, 14]]);
4341
4556
  }));
4342
- return function handleAddPasskey(_x67) {
4343
- return _ref22.apply(this, arguments);
4557
+ return function handleAddPasskey(_x72) {
4558
+ return _ref24.apply(this, arguments);
4344
4559
  };
4345
4560
  }();
4346
4561
  var handleRemoveOauthProvider = /*#__PURE__*/function () {
4347
- var _ref24 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
4562
+ var _ref26 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
4348
4563
  var providerId, _params$successPageDu2, successPageDuration, subTitle, title, stampWith;
4349
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
4350
- while (1) switch (_context21.prev = _context21.next) {
4564
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
4565
+ while (1) switch (_context23.prev = _context23.next) {
4351
4566
  case 0:
4352
4567
  providerId = params.providerId, _params$successPageDu2 = params.successPageDuration, successPageDuration = _params$successPageDu2 === void 0 ? 2000 : _params$successPageDu2, subTitle = params.subTitle, title = params.title, stampWith = params.stampWith;
4353
4568
  if (client) {
4354
- _context21.next = 3;
4569
+ _context23.next = 3;
4355
4570
  break;
4356
4571
  }
4357
4572
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4358
4573
  case 3:
4359
4574
  if (session) {
4360
- _context21.next = 5;
4575
+ _context23.next = 5;
4361
4576
  break;
4362
4577
  }
4363
4578
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
4364
4579
  case 5:
4365
- _context21.prev = 5;
4366
- return _context21.abrupt("return", new Promise(function (resolve, reject) {
4580
+ _context23.prev = 5;
4581
+ return _context23.abrupt("return", new Promise(function (resolve, reject) {
4367
4582
  pushPage({
4368
4583
  key: "Remove OAuth Provider",
4369
4584
  content: jsx(RemoveOAuthProvider, _objectSpread2(_objectSpread2({
@@ -4386,50 +4601,50 @@ var ClientProvider = function ClientProvider(_ref) {
4386
4601
  });
4387
4602
  }));
4388
4603
  case 9:
4389
- _context21.prev = 9;
4390
- _context21.t0 = _context21["catch"](5);
4391
- if (!(_context21.t0 instanceof TurnkeyError)) {
4392
- _context21.next = 13;
4604
+ _context23.prev = 9;
4605
+ _context23.t0 = _context23["catch"](5);
4606
+ if (!(_context23.t0 instanceof TurnkeyError)) {
4607
+ _context23.next = 13;
4393
4608
  break;
4394
4609
  }
4395
- throw _context21.t0;
4610
+ throw _context23.t0;
4396
4611
  case 13:
4397
- throw new TurnkeyError("Failed to remove OAuth provider in handler.", TurnkeyErrorCodes.REMOVE_OAUTH_PROVIDER_ERROR, _context21.t0);
4612
+ throw new TurnkeyError("Failed to remove OAuth provider in handler.", TurnkeyErrorCodes.REMOVE_OAUTH_PROVIDER_ERROR, _context23.t0);
4398
4613
  case 14:
4399
4614
  case "end":
4400
- return _context21.stop();
4615
+ return _context23.stop();
4401
4616
  }
4402
- }, _callee21, null, [[5, 9]]);
4617
+ }, _callee23, null, [[5, 9]]);
4403
4618
  }));
4404
- return function handleRemoveOauthProvider(_x68) {
4405
- return _ref24.apply(this, arguments);
4619
+ return function handleRemoveOauthProvider(_x73) {
4620
+ return _ref26.apply(this, arguments);
4406
4621
  };
4407
4622
  }();
4408
4623
  var handleAddOauthProvider = /*#__PURE__*/function () {
4409
- var _ref25 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
4624
+ var _ref27 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
4410
4625
  var providerName, stampWith, onOauthSuccess;
4411
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
4412
- while (1) switch (_context23.prev = _context23.next) {
4626
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
4627
+ while (1) switch (_context25.prev = _context25.next) {
4413
4628
  case 0:
4414
4629
  if (client) {
4415
- _context23.next = 2;
4630
+ _context25.next = 2;
4416
4631
  break;
4417
4632
  }
4418
4633
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4419
4634
  case 2:
4420
4635
  if (session) {
4421
- _context23.next = 4;
4636
+ _context25.next = 4;
4422
4637
  break;
4423
4638
  }
4424
4639
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
4425
4640
  case 4:
4426
4641
  providerName = params.providerName, stampWith = params.stampWith;
4427
4642
  onOauthSuccess = /*#__PURE__*/function () {
4428
- var _ref26 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
4429
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
4430
- while (1) switch (_context22.prev = _context22.next) {
4643
+ var _ref28 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
4644
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
4645
+ while (1) switch (_context24.prev = _context24.next) {
4431
4646
  case 0:
4432
- _context22.next = 2;
4647
+ _context24.next = 2;
4433
4648
  return addOauthProvider({
4434
4649
  providerName: params.providerName,
4435
4650
  oidcToken: params.oidcToken,
@@ -4450,83 +4665,83 @@ var ClientProvider = function ClientProvider(_ref) {
4450
4665
  });
4451
4666
  case 3:
4452
4667
  case "end":
4453
- return _context22.stop();
4668
+ return _context24.stop();
4454
4669
  }
4455
- }, _callee22);
4670
+ }, _callee24);
4456
4671
  }));
4457
- return function onOauthSuccess(_x70) {
4458
- return _ref26.apply(this, arguments);
4672
+ return function onOauthSuccess(_x75) {
4673
+ return _ref28.apply(this, arguments);
4459
4674
  };
4460
4675
  }();
4461
- _context23.t0 = providerName;
4462
- _context23.next = _context23.t0 === OAuthProviders.GOOGLE ? 9 : _context23.t0 === OAuthProviders.APPLE ? 12 : _context23.t0 === OAuthProviders.FACEBOOK ? 15 : 18;
4676
+ _context25.t0 = providerName;
4677
+ _context25.next = _context25.t0 === OAuthProviders.GOOGLE ? 9 : _context25.t0 === OAuthProviders.APPLE ? 12 : _context25.t0 === OAuthProviders.FACEBOOK ? 15 : 18;
4463
4678
  break;
4464
4679
  case 9:
4465
- _context23.next = 11;
4680
+ _context25.next = 11;
4466
4681
  return handleGoogleOauth({
4467
4682
  openInPage: false,
4468
4683
  onOauthSuccess: onOauthSuccess
4469
4684
  });
4470
4685
  case 11:
4471
- return _context23.abrupt("break", 19);
4686
+ return _context25.abrupt("break", 19);
4472
4687
  case 12:
4473
- _context23.next = 14;
4688
+ _context25.next = 14;
4474
4689
  return handleAppleOauth({
4475
4690
  openInPage: false,
4476
4691
  onOauthSuccess: onOauthSuccess
4477
4692
  });
4478
4693
  case 14:
4479
- return _context23.abrupt("break", 19);
4694
+ return _context25.abrupt("break", 19);
4480
4695
  case 15:
4481
- _context23.next = 17;
4696
+ _context25.next = 17;
4482
4697
  return handleFacebookOauth({
4483
4698
  openInPage: false,
4484
4699
  onOauthSuccess: onOauthSuccess
4485
4700
  });
4486
4701
  case 17:
4487
- return _context23.abrupt("break", 19);
4702
+ return _context25.abrupt("break", 19);
4488
4703
  case 18:
4489
4704
  throw new TurnkeyError("Unsupported OAuth provider: ".concat(providerName), TurnkeyErrorCodes.NOT_FOUND);
4490
4705
  case 19:
4491
4706
  case "end":
4492
- return _context23.stop();
4707
+ return _context25.stop();
4493
4708
  }
4494
- }, _callee23);
4709
+ }, _callee25);
4495
4710
  }));
4496
- return function handleAddOauthProvider(_x69) {
4497
- return _ref25.apply(this, arguments);
4711
+ return function handleAddOauthProvider(_x74) {
4712
+ return _ref27.apply(this, arguments);
4498
4713
  };
4499
4714
  }();
4500
4715
  var handleLinkExternalWallet = /*#__PURE__*/function () {
4501
- var _ref27 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
4716
+ var _ref29 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
4502
4717
  var _masterConfig$walletC4, _masterConfig$walletC5;
4503
- var _ref28, _ref28$successPageDur, successPageDuration, providers;
4504
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
4505
- while (1) switch (_context24.prev = _context24.next) {
4718
+ var _ref30, _ref30$successPageDur, successPageDuration, providers;
4719
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
4720
+ while (1) switch (_context26.prev = _context26.next) {
4506
4721
  case 0:
4507
- _ref28 = params || {}, _ref28$successPageDur = _ref28.successPageDuration, successPageDuration = _ref28$successPageDur === void 0 ? 2000 : _ref28$successPageDur;
4722
+ _ref30 = params || {}, _ref30$successPageDur = _ref30.successPageDuration, successPageDuration = _ref30$successPageDur === void 0 ? 2000 : _ref30$successPageDur;
4508
4723
  if (client) {
4509
- _context24.next = 3;
4724
+ _context26.next = 3;
4510
4725
  break;
4511
4726
  }
4512
4727
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4513
4728
  case 3:
4514
4729
  if (session) {
4515
- _context24.next = 5;
4730
+ _context26.next = 5;
4516
4731
  break;
4517
4732
  }
4518
4733
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
4519
4734
  case 5:
4520
4735
  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) {
4521
- _context24.next = 7;
4736
+ _context26.next = 7;
4522
4737
  break;
4523
4738
  }
4524
4739
  throw new TurnkeyError("Wallet connecting is not enabled.", TurnkeyErrorCodes.FEATURE_NOT_ENABLED);
4525
4740
  case 7:
4526
- _context24.next = 9;
4741
+ _context26.next = 9;
4527
4742
  return getWalletProviders();
4528
4743
  case 9:
4529
- providers = _context24.sent;
4744
+ providers = _context26.sent;
4530
4745
  pushPage({
4531
4746
  key: "Link Wallet",
4532
4747
  content: jsx(LinkWalletModal, {
@@ -4536,29 +4751,29 @@ var ClientProvider = function ClientProvider(_ref) {
4536
4751
  });
4537
4752
  case 11:
4538
4753
  case "end":
4539
- return _context24.stop();
4754
+ return _context26.stop();
4540
4755
  }
4541
- }, _callee24);
4756
+ }, _callee26);
4542
4757
  }));
4543
- return function handleLinkExternalWallet(_x71) {
4544
- return _ref27.apply(this, arguments);
4758
+ return function handleLinkExternalWallet(_x76) {
4759
+ return _ref29.apply(this, arguments);
4545
4760
  };
4546
4761
  }();
4547
4762
  var handleRemoveUserEmail = /*#__PURE__*/function () {
4548
- var _ref29 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
4549
- var _ref30, _ref30$successPageDur, successPageDuration, stampWith, userId;
4550
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
4551
- while (1) switch (_context25.prev = _context25.next) {
4763
+ var _ref31 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
4764
+ var _ref32, _ref32$successPageDur, successPageDuration, stampWith, userId;
4765
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
4766
+ while (1) switch (_context27.prev = _context27.next) {
4552
4767
  case 0:
4553
- _ref30 = params || {}, _ref30$successPageDur = _ref30.successPageDuration, successPageDuration = _ref30$successPageDur === void 0 ? 2000 : _ref30$successPageDur, stampWith = _ref30.stampWith, userId = _ref30.userId;
4768
+ _ref32 = params || {}, _ref32$successPageDur = _ref32.successPageDuration, successPageDuration = _ref32$successPageDur === void 0 ? 2000 : _ref32$successPageDur, stampWith = _ref32.stampWith, userId = _ref32.userId;
4554
4769
  if (session) {
4555
- _context25.next = 3;
4770
+ _context27.next = 3;
4556
4771
  break;
4557
4772
  }
4558
4773
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
4559
4774
  case 3:
4560
- _context25.prev = 3;
4561
- return _context25.abrupt("return", new Promise(function (resolve, reject) {
4775
+ _context27.prev = 3;
4776
+ return _context27.abrupt("return", new Promise(function (resolve, reject) {
4562
4777
  pushPage({
4563
4778
  key: "Remove Email",
4564
4779
  content: jsx(RemoveEmail, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -4580,40 +4795,40 @@ var ClientProvider = function ClientProvider(_ref) {
4580
4795
  });
4581
4796
  }));
4582
4797
  case 7:
4583
- _context25.prev = 7;
4584
- _context25.t0 = _context25["catch"](3);
4585
- if (!(_context25.t0 instanceof TurnkeyError)) {
4586
- _context25.next = 11;
4798
+ _context27.prev = 7;
4799
+ _context27.t0 = _context27["catch"](3);
4800
+ if (!(_context27.t0 instanceof TurnkeyError)) {
4801
+ _context27.next = 11;
4587
4802
  break;
4588
4803
  }
4589
- throw _context25.t0;
4804
+ throw _context27.t0;
4590
4805
  case 11:
4591
- throw new TurnkeyError("Failed to remove user email.", TurnkeyErrorCodes.UPDATE_USER_EMAIL_ERROR, _context25.t0);
4806
+ throw new TurnkeyError("Failed to remove user email.", TurnkeyErrorCodes.UPDATE_USER_EMAIL_ERROR, _context27.t0);
4592
4807
  case 12:
4593
4808
  case "end":
4594
- return _context25.stop();
4809
+ return _context27.stop();
4595
4810
  }
4596
- }, _callee25, null, [[3, 7]]);
4811
+ }, _callee27, null, [[3, 7]]);
4597
4812
  }));
4598
- return function handleRemoveUserEmail(_x72) {
4599
- return _ref29.apply(this, arguments);
4813
+ return function handleRemoveUserEmail(_x77) {
4814
+ return _ref31.apply(this, arguments);
4600
4815
  };
4601
4816
  }();
4602
4817
  var handleRemoveUserPhoneNumber = /*#__PURE__*/function () {
4603
- var _ref31 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
4604
- var _ref32, _ref32$successPageDur, successPageDuration, stampWith, userId;
4605
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
4606
- while (1) switch (_context26.prev = _context26.next) {
4818
+ var _ref33 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4819
+ var _ref34, _ref34$successPageDur, successPageDuration, stampWith, userId;
4820
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
4821
+ while (1) switch (_context28.prev = _context28.next) {
4607
4822
  case 0:
4608
- _ref32 = params || {}, _ref32$successPageDur = _ref32.successPageDuration, successPageDuration = _ref32$successPageDur === void 0 ? 2000 : _ref32$successPageDur, stampWith = _ref32.stampWith, userId = _ref32.userId;
4823
+ _ref34 = params || {}, _ref34$successPageDur = _ref34.successPageDuration, successPageDuration = _ref34$successPageDur === void 0 ? 2000 : _ref34$successPageDur, stampWith = _ref34.stampWith, userId = _ref34.userId;
4609
4824
  if (session) {
4610
- _context26.next = 3;
4825
+ _context28.next = 3;
4611
4826
  break;
4612
4827
  }
4613
4828
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
4614
4829
  case 3:
4615
- _context26.prev = 3;
4616
- return _context26.abrupt("return", new Promise(function (resolve, reject) {
4830
+ _context28.prev = 3;
4831
+ return _context28.abrupt("return", new Promise(function (resolve, reject) {
4617
4832
  pushPage({
4618
4833
  key: "Remove Phone Number",
4619
4834
  content: jsx(RemovePhoneNumber, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -4635,23 +4850,23 @@ var ClientProvider = function ClientProvider(_ref) {
4635
4850
  });
4636
4851
  }));
4637
4852
  case 7:
4638
- _context26.prev = 7;
4639
- _context26.t0 = _context26["catch"](3);
4640
- if (!(_context26.t0 instanceof TurnkeyError)) {
4641
- _context26.next = 11;
4853
+ _context28.prev = 7;
4854
+ _context28.t0 = _context28["catch"](3);
4855
+ if (!(_context28.t0 instanceof TurnkeyError)) {
4856
+ _context28.next = 11;
4642
4857
  break;
4643
4858
  }
4644
- throw _context26.t0;
4859
+ throw _context28.t0;
4645
4860
  case 11:
4646
- throw new TurnkeyError("Failed to remove user phone number.", TurnkeyErrorCodes.UPDATE_USER_PHONE_NUMBER_ERROR, _context26.t0);
4861
+ throw new TurnkeyError("Failed to remove user phone number.", TurnkeyErrorCodes.UPDATE_USER_PHONE_NUMBER_ERROR, _context28.t0);
4647
4862
  case 12:
4648
4863
  case "end":
4649
- return _context26.stop();
4864
+ return _context28.stop();
4650
4865
  }
4651
- }, _callee26, null, [[3, 7]]);
4866
+ }, _callee28, null, [[3, 7]]);
4652
4867
  }));
4653
- return function handleRemoveUserPhoneNumber(_x73) {
4654
- return _ref31.apply(this, arguments);
4868
+ return function handleRemoveUserPhoneNumber(_x78) {
4869
+ return _ref33.apply(this, arguments);
4655
4870
  };
4656
4871
  }();
4657
4872
  return jsx(ClientContext.Provider, {
@@ -4703,7 +4918,10 @@ var ClientProvider = function ClientProvider(_ref) {
4703
4918
  createWallet: createWallet,
4704
4919
  createWalletAccounts: createWalletAccounts,
4705
4920
  exportWallet: exportWallet,
4921
+ exportPrivateKey: exportPrivateKey,
4922
+ exportWalletAccount: exportWalletAccount,
4706
4923
  importWallet: importWallet,
4924
+ importPrivateKey: importPrivateKey,
4707
4925
  deleteSubOrganization: deleteSubOrganization,
4708
4926
  storeSession: storeSession,
4709
4927
  clearSession: clearSession,
@@ -4720,8 +4938,10 @@ var ClientProvider = function ClientProvider(_ref) {
4720
4938
  handleGoogleOauth: handleGoogleOauth,
4721
4939
  handleAppleOauth: handleAppleOauth,
4722
4940
  handleFacebookOauth: handleFacebookOauth,
4723
- handleExport: handleExport,
4724
- handleImport: handleImport,
4941
+ handleExportWallet: handleExportWallet,
4942
+ handleExportPrivateKey: handleExportPrivateKey,
4943
+ handleExportWalletAccount: handleExportWalletAccount,
4944
+ handleImportWallet: handleImportWallet,
4725
4945
  handleUpdateUserEmail: handleUpdateUserEmail,
4726
4946
  handleUpdateUserPhoneNumber: handleUpdateUserPhoneNumber,
4727
4947
  handleUpdateUserName: handleUpdateUserName,