@turnkey/react-wallet-kit 1.2.0 → 1.3.1

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.
@@ -614,7 +614,8 @@ var ClientProvider = function ClientProvider(_ref) {
614
614
  chains: _objectSpread2({}, (_masterConfig$walletC2 = masterConfig.walletConfig) === null || _masterConfig$walletC2 === void 0 ? void 0 : _masterConfig$walletC2.chains)
615
615
  }, ((_masterConfig$walletC3 = masterConfig.walletConfig) === null || _masterConfig$walletC3 === void 0 ? void 0 : _masterConfig$walletC3.walletConnect) && {
616
616
  walletConnect: masterConfig.walletConfig.walletConnect
617
- })
617
+ }),
618
+ defaultStamperType: masterConfig.defaultStamperType
618
619
  });
619
620
  _context6.n = 2;
620
621
  return turnkeyClient.init();
@@ -787,11 +788,11 @@ var ClientProvider = function ClientProvider(_ref) {
787
788
  * @throws {TurnkeyError} If an error occurs while scheduling the session expiration.
788
789
  */
789
790
  function _initializeWalletProviderListeners() {
790
- _initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee106(walletProviders, onUpdateState) {
791
+ _initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee107(walletProviders, onUpdateState) {
791
792
  var _masterConfig$walletC0, _masterConfig$walletC1, _masterConfig$walletC10, _masterConfig$walletC11;
792
793
  var cleanups, nativeOnly, ethProviders, solProviders, wcProviders, wcProvider, attachEthereumListeners, attachSolanaListeners, _wcProvider$provider, _wcProvider$provider$, standardEvents, unsubscribe;
793
- return _regenerator().w(function (_context106) {
794
- while (1) switch (_context106.n) {
794
+ return _regenerator().w(function (_context107) {
795
+ while (1) switch (_context107.n) {
795
796
  case 0:
796
797
  attachSolanaListeners = function _attachSolanaListener(provider, onUpdateState) {
797
798
  var _provider$features;
@@ -799,19 +800,19 @@ var ClientProvider = function ClientProvider(_ref) {
799
800
  var walletEvents = provider === null || provider === void 0 ? void 0 : (_provider$features = provider.features) === null || _provider$features === void 0 ? void 0 : _provider$features["standard:events"];
800
801
  if (walletEvents !== null && walletEvents !== void 0 && walletEvents.on) {
801
802
  var offChange = walletEvents.on("change", /*#__PURE__*/function () {
802
- var _ref127 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee104(_evt) {
803
- return _regenerator().w(function (_context104) {
804
- while (1) switch (_context104.n) {
803
+ var _ref128 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee105(_evt) {
804
+ return _regenerator().w(function (_context105) {
805
+ while (1) switch (_context105.n) {
805
806
  case 0:
806
- _context104.n = 1;
807
+ _context105.n = 1;
807
808
  return onUpdateState();
808
809
  case 1:
809
- return _context104.a(2);
810
+ return _context105.a(2);
810
811
  }
811
- }, _callee104);
812
+ }, _callee105);
812
813
  }));
813
- return function (_x91) {
814
- return _ref127.apply(this, arguments);
814
+ return function (_x92) {
815
+ return _ref128.apply(this, arguments);
815
816
  };
816
817
  }());
817
818
  cleanups.push(offChange);
@@ -825,31 +826,31 @@ var ClientProvider = function ClientProvider(_ref) {
825
826
  attachEthereumListeners = function _attachEthereumListen(provider, onUpdateState) {
826
827
  if (typeof provider.on !== "function") return;
827
828
  var handleChainChanged = /*#__PURE__*/function () {
828
- var _ref125 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102(_chainId) {
829
- return _regenerator().w(function (_context102) {
830
- while (1) switch (_context102.n) {
829
+ var _ref126 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee103(_chainId) {
830
+ return _regenerator().w(function (_context103) {
831
+ while (1) switch (_context103.n) {
831
832
  case 0:
832
- return _context102.a(2, onUpdateState());
833
+ return _context103.a(2, onUpdateState());
833
834
  }
834
- }, _callee102);
835
+ }, _callee103);
835
836
  }));
836
- return function handleChainChanged(_x89) {
837
- return _ref125.apply(this, arguments);
837
+ return function handleChainChanged(_x90) {
838
+ return _ref126.apply(this, arguments);
838
839
  };
839
840
  }();
840
841
  var handleAccountsChanged = /*#__PURE__*/function () {
841
- var _ref126 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee103(accounts) {
842
- return _regenerator().w(function (_context103) {
843
- while (1) switch (_context103.n) {
842
+ var _ref127 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee104(accounts) {
843
+ return _regenerator().w(function (_context104) {
844
+ while (1) switch (_context104.n) {
844
845
  case 0:
845
846
  if (accounts.length === 0) onUpdateState();
846
847
  case 1:
847
- return _context103.a(2);
848
+ return _context104.a(2);
848
849
  }
849
- }, _callee103);
850
+ }, _callee104);
850
851
  }));
851
- return function handleAccountsChanged(_x90) {
852
- return _ref126.apply(this, arguments);
852
+ return function handleAccountsChanged(_x91) {
853
+ return _ref127.apply(this, arguments);
853
854
  };
854
855
  }();
855
856
  var handleDisconnect = function handleDisconnect() {
@@ -865,10 +866,10 @@ var ClientProvider = function ClientProvider(_ref) {
865
866
  };
866
867
  };
867
868
  if (!(walletProviders.length === 0)) {
868
- _context106.n = 1;
869
+ _context107.n = 1;
869
870
  break;
870
871
  }
871
- return _context106.a(2, function () {});
872
+ return _context107.a(2, function () {});
872
873
  case 1:
873
874
  cleanups = []; // we only want to initialize these listeners for connected walletProviders
874
875
  nativeOnly = function nativeOnly(provider) {
@@ -906,9 +907,9 @@ var ClientProvider = function ClientProvider(_ref) {
906
907
  if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
907
908
  if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
908
909
  unsubscribe = standardEvents.on("change", /*#__PURE__*/function () {
909
- var _ref128 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee105(evt) {
910
- return _regenerator().w(function (_context105) {
911
- while (1) switch (_context105.n) {
910
+ var _ref129 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee106(evt) {
911
+ return _regenerator().w(function (_context106) {
912
+ while (1) switch (_context106.n) {
912
913
  case 0:
913
914
  // if the event is a proposalExpired, we want to re-fetch the providers
914
915
  // to refresh the uri, there is no need to refresh the wallets state
@@ -917,28 +918,28 @@ var ClientProvider = function ClientProvider(_ref) {
917
918
  }
918
919
  // any other event (disconnect, chain switch, accounts changed)
919
920
  // we refresh the wallets state
920
- _context105.n = 1;
921
+ _context106.n = 1;
921
922
  return onUpdateState();
922
923
  case 1:
923
- return _context105.a(2);
924
+ return _context106.a(2);
924
925
  }
925
- }, _callee105);
926
+ }, _callee106);
926
927
  }));
927
- return function (_x92) {
928
- return _ref128.apply(this, arguments);
928
+ return function (_x93) {
929
+ return _ref129.apply(this, arguments);
929
930
  };
930
931
  }());
931
932
  cleanups.push(unsubscribe);
932
933
  }
933
934
  }
934
935
  }
935
- return _context106.a(2, function () {
936
+ return _context107.a(2, function () {
936
937
  cleanups.forEach(function (remove) {
937
938
  return remove();
938
939
  });
939
940
  });
940
941
  }
941
- }, _callee106);
942
+ }, _callee107);
942
943
  }));
943
944
  return _initializeWalletProviderListeners.apply(this, arguments);
944
945
  }
@@ -954,13 +955,13 @@ var ClientProvider = function ClientProvider(_ref) {
954
955
  * @throws {TurnkeyError} If an error occurs while clearing the timers.
955
956
  */
956
957
  function _scheduleSessionExpiration() {
957
- _scheduleSessionExpiration = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee109(params) {
958
+ _scheduleSessionExpiration = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee110(params) {
958
959
  var sessionKey, expiry, warnKey, now, expiryMs, timeUntilExpiry, _beforeExpiry, expireSession, warnAt, _callbacks$onError0, _callbacks$onError1, _t34;
959
- return _regenerator().w(function (_context109) {
960
- while (1) switch (_context109.p = _context109.n) {
960
+ return _regenerator().w(function (_context110) {
961
+ while (1) switch (_context110.p = _context110.n) {
961
962
  case 0:
962
963
  sessionKey = params.sessionKey, expiry = params.expiry;
963
- _context109.p = 1;
964
+ _context110.p = 1;
964
965
  warnKey = "".concat(sessionKey, "-warning"); // Replace any prior timers for this session
965
966
  clearKey(expiryTimeoutsRef.current, sessionKey);
966
967
  clearKey(expiryTimeoutsRef.current, warnKey);
@@ -968,86 +969,86 @@ var ClientProvider = function ClientProvider(_ref) {
968
969
  expiryMs = expiry * 1000;
969
970
  timeUntilExpiry = expiryMs - now;
970
971
  _beforeExpiry = /*#__PURE__*/function () {
971
- var _ref129 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee107() {
972
- var _callbacks$beforeSess, _masterConfig$auth48;
972
+ var _ref130 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee108() {
973
+ var _callbacks$beforeSess, _masterConfig$auth49;
973
974
  var activeSession, session;
974
- return _regenerator().w(function (_context107) {
975
- while (1) switch (_context107.n) {
975
+ return _regenerator().w(function (_context108) {
976
+ while (1) switch (_context108.n) {
976
977
  case 0:
977
- _context107.n = 1;
978
+ _context108.n = 1;
978
979
  return getSession();
979
980
  case 1:
980
- activeSession = _context107.v;
981
+ activeSession = _context108.v;
981
982
  if (!(!activeSession && expiryTimeoutsRef.current[warnKey])) {
982
- _context107.n = 2;
983
+ _context108.n = 2;
983
984
  break;
984
985
  }
985
986
  // Keep nudging until session materializes (short 10s timer is fine)
986
987
  setTimeoutInMap(expiryTimeoutsRef.current, warnKey, _beforeExpiry, 10000);
987
- return _context107.a(2);
988
+ return _context108.a(2);
988
989
  case 2:
989
- _context107.n = 3;
990
+ _context108.n = 3;
990
991
  return getSession({
991
992
  sessionKey: sessionKey
992
993
  });
993
994
  case 3:
994
- session = _context107.v;
995
+ session = _context108.v;
995
996
  if (session) {
996
- _context107.n = 4;
997
+ _context108.n = 4;
997
998
  break;
998
999
  }
999
- return _context107.a(2);
1000
+ return _context108.a(2);
1000
1001
  case 4:
1001
1002
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$beforeSess = callbacks.beforeSessionExpiry) === null || _callbacks$beforeSess === void 0 ? void 0 : _callbacks$beforeSess.call(callbacks, {
1002
1003
  sessionKey: sessionKey
1003
1004
  });
1004
- if (!(masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth48 = masterConfig.auth) !== null && _masterConfig$auth48 !== void 0 && _masterConfig$auth48.autoRefreshSession)) {
1005
- _context107.n = 5;
1005
+ if (!(masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth49 = masterConfig.auth) !== null && _masterConfig$auth49 !== void 0 && _masterConfig$auth49.autoRefreshSession)) {
1006
+ _context108.n = 5;
1006
1007
  break;
1007
1008
  }
1008
- _context107.n = 5;
1009
+ _context108.n = 5;
1009
1010
  return refreshSession({
1010
1011
  expirationSeconds: session.expirationSeconds,
1011
1012
  sessionKey: sessionKey
1012
1013
  });
1013
1014
  case 5:
1014
- return _context107.a(2);
1015
+ return _context108.a(2);
1015
1016
  }
1016
- }, _callee107);
1017
+ }, _callee108);
1017
1018
  }));
1018
1019
  return function beforeExpiry() {
1019
- return _ref129.apply(this, arguments);
1020
+ return _ref130.apply(this, arguments);
1020
1021
  };
1021
1022
  }();
1022
1023
  expireSession = /*#__PURE__*/function () {
1023
- var _ref130 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee108() {
1024
+ var _ref131 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee109() {
1024
1025
  var _callbacks$onSessionE;
1025
1026
  var expiredSession, _t32, _t33;
1026
- return _regenerator().w(function (_context108) {
1027
- while (1) switch (_context108.n) {
1027
+ return _regenerator().w(function (_context109) {
1028
+ while (1) switch (_context109.n) {
1028
1029
  case 0:
1029
- _context108.n = 1;
1030
+ _context109.n = 1;
1030
1031
  return getSession({
1031
1032
  sessionKey: sessionKey
1032
1033
  });
1033
1034
  case 1:
1034
- expiredSession = _context108.v;
1035
+ expiredSession = _context109.v;
1035
1036
  if (expiredSession) {
1036
- _context108.n = 2;
1037
+ _context109.n = 2;
1037
1038
  break;
1038
1039
  }
1039
- return _context108.a(2);
1040
+ return _context109.a(2);
1040
1041
  case 2:
1041
1042
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onSessionE = callbacks.onSessionExpired) === null || _callbacks$onSessionE === void 0 ? void 0 : _callbacks$onSessionE.call(callbacks, {
1042
1043
  sessionKey: sessionKey
1043
1044
  });
1044
- _context108.n = 3;
1045
+ _context109.n = 3;
1045
1046
  return getActiveSessionKey();
1046
1047
  case 3:
1047
- _t32 = _context108.v;
1048
+ _t32 = _context109.v;
1048
1049
  _t33 = sessionKey;
1049
1050
  if (!(_t32 === _t33)) {
1050
- _context108.n = 4;
1051
+ _context109.n = 4;
1051
1052
  break;
1052
1053
  }
1053
1054
  setSession(undefined);
@@ -1058,7 +1059,7 @@ var ClientProvider = function ClientProvider(_ref) {
1058
1059
  delete next[sessionKey];
1059
1060
  return next;
1060
1061
  });
1061
- _context108.n = 5;
1062
+ _context109.n = 5;
1062
1063
  return clearSession({
1063
1064
  sessionKey: sessionKey
1064
1065
  });
@@ -1066,25 +1067,25 @@ var ClientProvider = function ClientProvider(_ref) {
1066
1067
  // Remove timers for this session
1067
1068
  clearKey(expiryTimeoutsRef.current, sessionKey);
1068
1069
  clearKey(expiryTimeoutsRef.current, warnKey);
1069
- _context108.n = 6;
1070
+ _context109.n = 6;
1070
1071
  return logout();
1071
1072
  case 6:
1072
- return _context108.a(2);
1073
+ return _context109.a(2);
1073
1074
  }
1074
- }, _callee108);
1075
+ }, _callee109);
1075
1076
  }));
1076
1077
  return function expireSession() {
1077
- return _ref130.apply(this, arguments);
1078
+ return _ref131.apply(this, arguments);
1078
1079
  };
1079
1080
  }(); // Already expired → expire immediately
1080
1081
  if (!(timeUntilExpiry <= 0)) {
1081
- _context109.n = 3;
1082
+ _context110.n = 3;
1082
1083
  break;
1083
1084
  }
1084
- _context109.n = 2;
1085
+ _context110.n = 2;
1085
1086
  return expireSession();
1086
1087
  case 2:
1087
- return _context109.a(2);
1088
+ return _context110.a(2);
1088
1089
  case 3:
1089
1090
  // Warning timer (if threshold is in the future)
1090
1091
  warnAt = expiryMs - SESSION_WARNING_THRESHOLD_MS;
@@ -1095,20 +1096,20 @@ var ClientProvider = function ClientProvider(_ref) {
1095
1096
  }
1096
1097
  // Actual expiry timer (safe for long delays)
1097
1098
  setCappedTimeoutInMap(expiryTimeoutsRef.current, sessionKey, expireSession, timeUntilExpiry);
1098
- _context109.n = 5;
1099
+ _context110.n = 5;
1099
1100
  break;
1100
1101
  case 4:
1101
- _context109.p = 4;
1102
- _t34 = _context109.v;
1102
+ _context110.p = 4;
1103
+ _t34 = _context110.v;
1103
1104
  if (_t34 instanceof TurnkeyError || _t34 instanceof TurnkeyNetworkError) {
1104
1105
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError0 = callbacks.onError) === null || _callbacks$onError0 === void 0 ? void 0 : _callbacks$onError0.call(callbacks, _t34);
1105
1106
  } else {
1106
1107
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError1 = callbacks.onError) === null || _callbacks$onError1 === void 0 ? void 0 : _callbacks$onError1.call(callbacks, new TurnkeyError("Failed to schedule session expiration for ".concat(sessionKey), TurnkeyErrorCodes.SCHEDULE_SESSION_EXPIRY_ERROR, _t34));
1107
1108
  }
1108
1109
  case 5:
1109
- return _context109.a(2);
1110
+ return _context110.a(2);
1110
1111
  }
1111
- }, _callee109, null, [[1, 4]]);
1112
+ }, _callee110, null, [[1, 4]]);
1112
1113
  }));
1113
1114
  return _scheduleSessionExpiration.apply(this, arguments);
1114
1115
  }
@@ -1239,6 +1240,12 @@ var ClientProvider = function ClientProvider(_ref) {
1239
1240
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError9 = callbacks.onError) === null || _callbacks$onError9 === void 0 ? void 0 : _callbacks$onError9.call(callbacks, new TurnkeyError("Failed to initialize sessions", TurnkeyErrorCodes.HANDLE_POST_LOGOUT_ERROR, error));
1240
1241
  }
1241
1242
  };
1243
+ var createHttpClient = useCallback(function (params) {
1244
+ if (!client) {
1245
+ throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1246
+ }
1247
+ return client.createHttpClient(params);
1248
+ }, [client]);
1242
1249
  var createPasskey = useCallback(/*#__PURE__*/function () {
1243
1250
  var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(params) {
1244
1251
  return _regenerator().w(function (_context0) {
@@ -1554,10 +1561,10 @@ var ClientProvider = function ClientProvider(_ref) {
1554
1561
  return _ref15.apply(this, arguments);
1555
1562
  };
1556
1563
  }(), [client, callbacks]);
1557
- var loginWithWallet = useCallback(/*#__PURE__*/function () {
1564
+ var buildWalletLoginRequest = useCallback(/*#__PURE__*/function () {
1558
1565
  var _ref16 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(params) {
1559
1566
  var _masterConfig$auth$se3, _masterConfig$auth1;
1560
- var expirationSeconds, res;
1567
+ var expirationSeconds;
1561
1568
  return _regenerator().w(function (_context17) {
1562
1569
  while (1) switch (_context17.n) {
1563
1570
  case 0:
@@ -1570,26 +1577,14 @@ var ClientProvider = function ClientProvider(_ref) {
1570
1577
  expirationSeconds = (_masterConfig$auth$se3 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth1 = masterConfig.auth) === null || _masterConfig$auth1 === void 0 ? void 0 : _masterConfig$auth1.sessionExpirationSeconds) !== null && _masterConfig$auth$se3 !== void 0 ? _masterConfig$auth$se3 : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
1571
1578
  _context17.n = 2;
1572
1579
  return withTurnkeyErrorHandling(function () {
1573
- return client.loginWithWallet(_objectSpread2(_objectSpread2({}, params), {}, {
1580
+ return client.buildWalletLoginRequest(_objectSpread2(_objectSpread2({}, params), {}, {
1574
1581
  expirationSeconds: expirationSeconds
1575
1582
  }));
1576
1583
  }, function () {
1577
1584
  return logout();
1578
1585
  }, callbacks, "Failed to login with wallet");
1579
1586
  case 2:
1580
- res = _context17.v;
1581
- if (!res) {
1582
- _context17.n = 3;
1583
- break;
1584
- }
1585
- _context17.n = 3;
1586
- return handlePostAuth({
1587
- method: AuthMethod.Wallet,
1588
- action: AuthAction.LOGIN,
1589
- identifier: res.address
1590
- });
1591
- case 3:
1592
- return _context17.a(2, res);
1587
+ return _context17.a(2, _context17.v);
1593
1588
  }
1594
1589
  }, _callee17);
1595
1590
  }));
@@ -1597,10 +1592,10 @@ var ClientProvider = function ClientProvider(_ref) {
1597
1592
  return _ref16.apply(this, arguments);
1598
1593
  };
1599
1594
  }(), [client, callbacks]);
1600
- var signUpWithWallet = useCallback(/*#__PURE__*/function () {
1595
+ var loginWithWallet = useCallback(/*#__PURE__*/function () {
1601
1596
  var _ref17 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(params) {
1602
- var _params$createSubOrgP2, _masterConfig$auth10, _masterConfig$auth10$, _masterConfig$auth$se4, _masterConfig$auth11;
1603
- var createSubOrgParams, expirationSeconds, res;
1597
+ var _masterConfig$auth$se4, _masterConfig$auth10;
1598
+ var expirationSeconds, res;
1604
1599
  return _regenerator().w(function (_context18) {
1605
1600
  while (1) switch (_context18.n) {
1606
1601
  case 0:
@@ -1610,39 +1605,28 @@ var ClientProvider = function ClientProvider(_ref) {
1610
1605
  }
1611
1606
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1612
1607
  case 1:
1613
- if (masterConfig) {
1614
- _context18.n = 2;
1615
- break;
1616
- }
1617
- throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
1618
- case 2:
1619
- // If createSubOrgParams is not provided, use the default from masterConfig
1620
- createSubOrgParams = (_params$createSubOrgP2 = params.createSubOrgParams) !== null && _params$createSubOrgP2 !== void 0 ? _params$createSubOrgP2 : (_masterConfig$auth10 = masterConfig.auth) === null || _masterConfig$auth10 === void 0 ? void 0 : (_masterConfig$auth10$ = _masterConfig$auth10.createSuborgParams) === null || _masterConfig$auth10$ === void 0 ? void 0 : _masterConfig$auth10$.walletAuth;
1621
- params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
1622
- createSubOrgParams: createSubOrgParams
1623
- }) : _objectSpread2({}, params);
1624
- expirationSeconds = (_masterConfig$auth$se4 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth11 = masterConfig.auth) === null || _masterConfig$auth11 === void 0 ? void 0 : _masterConfig$auth11.sessionExpirationSeconds) !== null && _masterConfig$auth$se4 !== void 0 ? _masterConfig$auth$se4 : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
1625
- _context18.n = 3;
1608
+ 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;
1609
+ _context18.n = 2;
1626
1610
  return withTurnkeyErrorHandling(function () {
1627
- return client.signUpWithWallet(_objectSpread2(_objectSpread2({}, params), {}, {
1611
+ return client.loginWithWallet(_objectSpread2(_objectSpread2({}, params), {}, {
1628
1612
  expirationSeconds: expirationSeconds
1629
1613
  }));
1630
1614
  }, function () {
1631
1615
  return logout();
1632
- }, callbacks, "Failed to sign up with wallet");
1633
- case 3:
1616
+ }, callbacks, "Failed to login with wallet");
1617
+ case 2:
1634
1618
  res = _context18.v;
1635
1619
  if (!res) {
1636
- _context18.n = 4;
1620
+ _context18.n = 3;
1637
1621
  break;
1638
1622
  }
1639
- _context18.n = 4;
1623
+ _context18.n = 3;
1640
1624
  return handlePostAuth({
1641
1625
  method: AuthMethod.Wallet,
1642
- action: AuthAction.SIGNUP,
1626
+ action: AuthAction.LOGIN,
1643
1627
  identifier: res.address
1644
1628
  });
1645
- case 4:
1629
+ case 3:
1646
1630
  return _context18.a(2, res);
1647
1631
  }
1648
1632
  }, _callee18);
@@ -1650,10 +1634,10 @@ var ClientProvider = function ClientProvider(_ref) {
1650
1634
  return function (_x13) {
1651
1635
  return _ref17.apply(this, arguments);
1652
1636
  };
1653
- }(), [client, callbacks, masterConfig]);
1654
- var loginOrSignupWithWallet = useCallback(/*#__PURE__*/function () {
1637
+ }(), [client, callbacks]);
1638
+ var signUpWithWallet = useCallback(/*#__PURE__*/function () {
1655
1639
  var _ref18 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(params) {
1656
- var _params$createSubOrgP3, _masterConfig$auth12, _masterConfig$auth12$, _masterConfig$auth$se5, _masterConfig$auth13;
1640
+ var _params$createSubOrgP2, _masterConfig$auth11, _masterConfig$auth11$, _masterConfig$auth$se5, _masterConfig$auth12;
1657
1641
  var createSubOrgParams, expirationSeconds, res;
1658
1642
  return _regenerator().w(function (_context19) {
1659
1643
  while (1) switch (_context19.n) {
@@ -1671,19 +1655,19 @@ var ClientProvider = function ClientProvider(_ref) {
1671
1655
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
1672
1656
  case 2:
1673
1657
  // If createSubOrgParams is not provided, use the default from masterConfig
1674
- createSubOrgParams = (_params$createSubOrgP3 = params.createSubOrgParams) !== null && _params$createSubOrgP3 !== void 0 ? _params$createSubOrgP3 : (_masterConfig$auth12 = masterConfig.auth) === null || _masterConfig$auth12 === void 0 ? void 0 : (_masterConfig$auth12$ = _masterConfig$auth12.createSuborgParams) === null || _masterConfig$auth12$ === void 0 ? void 0 : _masterConfig$auth12$.walletAuth;
1658
+ createSubOrgParams = (_params$createSubOrgP2 = params.createSubOrgParams) !== null && _params$createSubOrgP2 !== void 0 ? _params$createSubOrgP2 : (_masterConfig$auth11 = masterConfig.auth) === null || _masterConfig$auth11 === void 0 ? void 0 : (_masterConfig$auth11$ = _masterConfig$auth11.createSuborgParams) === null || _masterConfig$auth11$ === void 0 ? void 0 : _masterConfig$auth11$.walletAuth;
1675
1659
  params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
1676
1660
  createSubOrgParams: createSubOrgParams
1677
1661
  }) : _objectSpread2({}, params);
1678
- expirationSeconds = (_masterConfig$auth$se5 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth13 = masterConfig.auth) === null || _masterConfig$auth13 === void 0 ? void 0 : _masterConfig$auth13.sessionExpirationSeconds) !== null && _masterConfig$auth$se5 !== void 0 ? _masterConfig$auth$se5 : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
1662
+ 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;
1679
1663
  _context19.n = 3;
1680
1664
  return withTurnkeyErrorHandling(function () {
1681
- return client.loginOrSignupWithWallet(_objectSpread2(_objectSpread2({}, params), {}, {
1665
+ return client.signUpWithWallet(_objectSpread2(_objectSpread2({}, params), {}, {
1682
1666
  expirationSeconds: expirationSeconds
1683
1667
  }));
1684
1668
  }, function () {
1685
1669
  return logout();
1686
- }, callbacks, "Failed to login or sign up with wallet");
1670
+ }, callbacks, "Failed to sign up with wallet");
1687
1671
  case 3:
1688
1672
  res = _context19.v;
1689
1673
  if (!res) {
@@ -1693,7 +1677,7 @@ var ClientProvider = function ClientProvider(_ref) {
1693
1677
  _context19.n = 4;
1694
1678
  return handlePostAuth({
1695
1679
  method: AuthMethod.Wallet,
1696
- action: res.action,
1680
+ action: AuthAction.SIGNUP,
1697
1681
  identifier: res.address
1698
1682
  });
1699
1683
  case 4:
@@ -1705,8 +1689,10 @@ var ClientProvider = function ClientProvider(_ref) {
1705
1689
  return _ref18.apply(this, arguments);
1706
1690
  };
1707
1691
  }(), [client, callbacks, masterConfig]);
1708
- var initOtp = useCallback(/*#__PURE__*/function () {
1692
+ var loginOrSignupWithWallet = useCallback(/*#__PURE__*/function () {
1709
1693
  var _ref19 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(params) {
1694
+ var _params$createSubOrgP3, _masterConfig$auth13, _masterConfig$auth13$, _masterConfig$auth$se6, _masterConfig$auth14;
1695
+ var createSubOrgParams, expirationSeconds, res;
1710
1696
  return _regenerator().w(function (_context20) {
1711
1697
  while (1) switch (_context20.n) {
1712
1698
  case 0:
@@ -1716,19 +1702,48 @@ var ClientProvider = function ClientProvider(_ref) {
1716
1702
  }
1717
1703
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1718
1704
  case 1:
1719
- return _context20.a(2, withTurnkeyErrorHandling(function () {
1720
- return client.initOtp(params);
1705
+ if (masterConfig) {
1706
+ _context20.n = 2;
1707
+ break;
1708
+ }
1709
+ throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
1710
+ case 2:
1711
+ // If createSubOrgParams is not provided, use the default from masterConfig
1712
+ createSubOrgParams = (_params$createSubOrgP3 = params.createSubOrgParams) !== null && _params$createSubOrgP3 !== void 0 ? _params$createSubOrgP3 : (_masterConfig$auth13 = masterConfig.auth) === null || _masterConfig$auth13 === void 0 ? void 0 : (_masterConfig$auth13$ = _masterConfig$auth13.createSuborgParams) === null || _masterConfig$auth13$ === void 0 ? void 0 : _masterConfig$auth13$.walletAuth;
1713
+ params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
1714
+ createSubOrgParams: createSubOrgParams
1715
+ }) : _objectSpread2({}, params);
1716
+ expirationSeconds = (_masterConfig$auth$se6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth14 = masterConfig.auth) === null || _masterConfig$auth14 === void 0 ? void 0 : _masterConfig$auth14.sessionExpirationSeconds) !== null && _masterConfig$auth$se6 !== void 0 ? _masterConfig$auth$se6 : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
1717
+ _context20.n = 3;
1718
+ return withTurnkeyErrorHandling(function () {
1719
+ return client.loginOrSignupWithWallet(_objectSpread2(_objectSpread2({}, params), {}, {
1720
+ expirationSeconds: expirationSeconds
1721
+ }));
1721
1722
  }, function () {
1722
1723
  return logout();
1723
- }, callbacks, "Failed to initialize OTP"));
1724
+ }, callbacks, "Failed to login or sign up with wallet");
1725
+ case 3:
1726
+ res = _context20.v;
1727
+ if (!res) {
1728
+ _context20.n = 4;
1729
+ break;
1730
+ }
1731
+ _context20.n = 4;
1732
+ return handlePostAuth({
1733
+ method: AuthMethod.Wallet,
1734
+ action: res.action,
1735
+ identifier: res.address
1736
+ });
1737
+ case 4:
1738
+ return _context20.a(2, res);
1724
1739
  }
1725
1740
  }, _callee20);
1726
1741
  }));
1727
1742
  return function (_x15) {
1728
1743
  return _ref19.apply(this, arguments);
1729
1744
  };
1730
- }(), [client, callbacks]);
1731
- var verifyOtp = useCallback(/*#__PURE__*/function () {
1745
+ }(), [client, callbacks, masterConfig]);
1746
+ var initOtp = useCallback(/*#__PURE__*/function () {
1732
1747
  var _ref20 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(params) {
1733
1748
  return _regenerator().w(function (_context21) {
1734
1749
  while (1) switch (_context21.n) {
@@ -1740,10 +1755,10 @@ var ClientProvider = function ClientProvider(_ref) {
1740
1755
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1741
1756
  case 1:
1742
1757
  return _context21.a(2, withTurnkeyErrorHandling(function () {
1743
- return client.verifyOtp(params);
1758
+ return client.initOtp(params);
1744
1759
  }, function () {
1745
1760
  return logout();
1746
- }, callbacks, "Failed to verify OTP"));
1761
+ }, callbacks, "Failed to initialize OTP"));
1747
1762
  }
1748
1763
  }, _callee21);
1749
1764
  }));
@@ -1751,9 +1766,8 @@ var ClientProvider = function ClientProvider(_ref) {
1751
1766
  return _ref20.apply(this, arguments);
1752
1767
  };
1753
1768
  }(), [client, callbacks]);
1754
- var loginWithOtp = useCallback(/*#__PURE__*/function () {
1769
+ var verifyOtp = useCallback(/*#__PURE__*/function () {
1755
1770
  var _ref21 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(params) {
1756
- var res;
1757
1771
  return _regenerator().w(function (_context22) {
1758
1772
  while (1) switch (_context22.n) {
1759
1773
  case 0:
@@ -1763,26 +1777,11 @@ var ClientProvider = function ClientProvider(_ref) {
1763
1777
  }
1764
1778
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1765
1779
  case 1:
1766
- _context22.n = 2;
1767
- return withTurnkeyErrorHandling(function () {
1768
- return client.loginWithOtp(params);
1780
+ return _context22.a(2, withTurnkeyErrorHandling(function () {
1781
+ return client.verifyOtp(params);
1769
1782
  }, function () {
1770
1783
  return logout();
1771
- }, callbacks, "Failed to login with OTP");
1772
- case 2:
1773
- res = _context22.v;
1774
- if (!res) {
1775
- _context22.n = 3;
1776
- break;
1777
- }
1778
- _context22.n = 3;
1779
- return handlePostAuth({
1780
- method: AuthMethod.Otp,
1781
- action: AuthAction.LOGIN,
1782
- identifier: params.verificationToken
1783
- });
1784
- case 3:
1785
- return _context22.a(2, res);
1784
+ }, callbacks, "Failed to verify OTP"));
1786
1785
  }
1787
1786
  }, _callee22);
1788
1787
  }));
@@ -1790,10 +1789,9 @@ var ClientProvider = function ClientProvider(_ref) {
1790
1789
  return _ref21.apply(this, arguments);
1791
1790
  };
1792
1791
  }(), [client, callbacks]);
1793
- var signUpWithOtp = useCallback(/*#__PURE__*/function () {
1792
+ var loginWithOtp = useCallback(/*#__PURE__*/function () {
1794
1793
  var _ref22 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23(params) {
1795
- var _masterConfig$auth14;
1796
- var createSubOrgParams, res;
1794
+ var res;
1797
1795
  return _regenerator().w(function (_context23) {
1798
1796
  while (1) switch (_context23.n) {
1799
1797
  case 0:
@@ -1803,43 +1801,25 @@ var ClientProvider = function ClientProvider(_ref) {
1803
1801
  }
1804
1802
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1805
1803
  case 1:
1806
- if (masterConfig) {
1807
- _context23.n = 2;
1808
- break;
1809
- }
1810
- throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
1811
- case 2:
1812
- // If createSubOrgParams is not provided, use the default from masterConfig
1813
- createSubOrgParams = params.createSubOrgParams;
1814
- if (!createSubOrgParams && masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth14 = masterConfig.auth) !== null && _masterConfig$auth14 !== void 0 && _masterConfig$auth14.createSuborgParams) {
1815
- if (params.otpType === OtpType.Email) {
1816
- createSubOrgParams = masterConfig.auth.createSuborgParams.emailOtpAuth;
1817
- } else if (params.otpType === OtpType.Sms) {
1818
- createSubOrgParams = masterConfig.auth.createSuborgParams.smsOtpAuth;
1819
- }
1820
- }
1821
- params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
1822
- createSubOrgParams: createSubOrgParams
1823
- }) : _objectSpread2({}, params);
1824
- _context23.n = 3;
1804
+ _context23.n = 2;
1825
1805
  return withTurnkeyErrorHandling(function () {
1826
- return client.signUpWithOtp(params);
1806
+ return client.loginWithOtp(params);
1827
1807
  }, function () {
1828
1808
  return logout();
1829
- }, callbacks, "Failed to sign up with OTP");
1830
- case 3:
1809
+ }, callbacks, "Failed to login with OTP");
1810
+ case 2:
1831
1811
  res = _context23.v;
1832
1812
  if (!res) {
1833
- _context23.n = 4;
1813
+ _context23.n = 3;
1834
1814
  break;
1835
1815
  }
1836
- _context23.n = 4;
1816
+ _context23.n = 3;
1837
1817
  return handlePostAuth({
1838
1818
  method: AuthMethod.Otp,
1839
- action: AuthAction.SIGNUP,
1819
+ action: AuthAction.LOGIN,
1840
1820
  identifier: params.verificationToken
1841
1821
  });
1842
- case 4:
1822
+ case 3:
1843
1823
  return _context23.a(2, res);
1844
1824
  }
1845
1825
  }, _callee23);
@@ -1847,8 +1827,8 @@ var ClientProvider = function ClientProvider(_ref) {
1847
1827
  return function (_x18) {
1848
1828
  return _ref22.apply(this, arguments);
1849
1829
  };
1850
- }(), [client, callbacks, masterConfig]);
1851
- var completeOtp = useCallback(/*#__PURE__*/function () {
1830
+ }(), [client, callbacks]);
1831
+ var signUpWithOtp = useCallback(/*#__PURE__*/function () {
1852
1832
  var _ref23 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24(params) {
1853
1833
  var _masterConfig$auth15;
1854
1834
  var createSubOrgParams, res;
@@ -1881,10 +1861,10 @@ var ClientProvider = function ClientProvider(_ref) {
1881
1861
  }) : _objectSpread2({}, params);
1882
1862
  _context24.n = 3;
1883
1863
  return withTurnkeyErrorHandling(function () {
1884
- return client.completeOtp(params);
1864
+ return client.signUpWithOtp(params);
1885
1865
  }, function () {
1886
1866
  return logout();
1887
- }, callbacks, "Failed to complete OTP");
1867
+ }, callbacks, "Failed to sign up with OTP");
1888
1868
  case 3:
1889
1869
  res = _context24.v;
1890
1870
  if (!res) {
@@ -1894,8 +1874,8 @@ var ClientProvider = function ClientProvider(_ref) {
1894
1874
  _context24.n = 4;
1895
1875
  return handlePostAuth({
1896
1876
  method: AuthMethod.Otp,
1897
- action: res.action,
1898
- identifier: res.verificationToken
1877
+ action: AuthAction.SIGNUP,
1878
+ identifier: params.verificationToken
1899
1879
  });
1900
1880
  case 4:
1901
1881
  return _context24.a(2, res);
@@ -1906,9 +1886,10 @@ var ClientProvider = function ClientProvider(_ref) {
1906
1886
  return _ref23.apply(this, arguments);
1907
1887
  };
1908
1888
  }(), [client, callbacks, masterConfig]);
1909
- var loginWithOauth = useCallback(/*#__PURE__*/function () {
1889
+ var completeOtp = useCallback(/*#__PURE__*/function () {
1910
1890
  var _ref24 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25(params) {
1911
- var res;
1891
+ var _masterConfig$auth16;
1892
+ var createSubOrgParams, res;
1912
1893
  return _regenerator().w(function (_context25) {
1913
1894
  while (1) switch (_context25.n) {
1914
1895
  case 0:
@@ -1918,25 +1899,43 @@ var ClientProvider = function ClientProvider(_ref) {
1918
1899
  }
1919
1900
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1920
1901
  case 1:
1921
- _context25.n = 2;
1902
+ if (masterConfig) {
1903
+ _context25.n = 2;
1904
+ break;
1905
+ }
1906
+ throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
1907
+ case 2:
1908
+ // If createSubOrgParams is not provided, use the default from masterConfig
1909
+ createSubOrgParams = params.createSubOrgParams;
1910
+ if (!createSubOrgParams && masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth16 = masterConfig.auth) !== null && _masterConfig$auth16 !== void 0 && _masterConfig$auth16.createSuborgParams) {
1911
+ if (params.otpType === OtpType.Email) {
1912
+ createSubOrgParams = masterConfig.auth.createSuborgParams.emailOtpAuth;
1913
+ } else if (params.otpType === OtpType.Sms) {
1914
+ createSubOrgParams = masterConfig.auth.createSuborgParams.smsOtpAuth;
1915
+ }
1916
+ }
1917
+ params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
1918
+ createSubOrgParams: createSubOrgParams
1919
+ }) : _objectSpread2({}, params);
1920
+ _context25.n = 3;
1922
1921
  return withTurnkeyErrorHandling(function () {
1923
- return client.loginWithOauth(params);
1922
+ return client.completeOtp(params);
1924
1923
  }, function () {
1925
1924
  return logout();
1926
- }, callbacks, "Failed to login with OAuth");
1927
- case 2:
1925
+ }, callbacks, "Failed to complete OTP");
1926
+ case 3:
1928
1927
  res = _context25.v;
1929
1928
  if (!res) {
1930
- _context25.n = 3;
1929
+ _context25.n = 4;
1931
1930
  break;
1932
1931
  }
1933
- _context25.n = 3;
1932
+ _context25.n = 4;
1934
1933
  return handlePostAuth({
1935
- method: AuthMethod.Oauth,
1936
- action: AuthAction.LOGIN,
1937
- identifier: params.oidcToken
1934
+ method: AuthMethod.Otp,
1935
+ action: res.action,
1936
+ identifier: res.verificationToken
1938
1937
  });
1939
- case 3:
1938
+ case 4:
1940
1939
  return _context25.a(2, res);
1941
1940
  }
1942
1941
  }, _callee25);
@@ -1944,11 +1943,10 @@ var ClientProvider = function ClientProvider(_ref) {
1944
1943
  return function (_x20) {
1945
1944
  return _ref24.apply(this, arguments);
1946
1945
  };
1947
- }(), [client, callbacks]);
1948
- var signUpWithOauth = useCallback(/*#__PURE__*/function () {
1946
+ }(), [client, callbacks, masterConfig]);
1947
+ var loginWithOauth = useCallback(/*#__PURE__*/function () {
1949
1948
  var _ref25 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26(params) {
1950
- var _params$createSubOrgP4, _masterConfig$auth16, _masterConfig$auth16$;
1951
- var createSubOrgParams, res;
1949
+ var res;
1952
1950
  return _regenerator().w(function (_context26) {
1953
1951
  while (1) switch (_context26.n) {
1954
1952
  case 0:
@@ -1958,36 +1956,25 @@ var ClientProvider = function ClientProvider(_ref) {
1958
1956
  }
1959
1957
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1960
1958
  case 1:
1961
- if (masterConfig) {
1962
- _context26.n = 2;
1963
- break;
1964
- }
1965
- throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
1966
- case 2:
1967
- // If createSubOrgParams is not provided, use the default from masterConfig
1968
- createSubOrgParams = (_params$createSubOrgP4 = params.createSubOrgParams) !== null && _params$createSubOrgP4 !== void 0 ? _params$createSubOrgP4 : (_masterConfig$auth16 = masterConfig.auth) === null || _masterConfig$auth16 === void 0 ? void 0 : (_masterConfig$auth16$ = _masterConfig$auth16.createSuborgParams) === null || _masterConfig$auth16$ === void 0 ? void 0 : _masterConfig$auth16$.oauth;
1969
- params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
1970
- createSubOrgParams: createSubOrgParams
1971
- }) : _objectSpread2({}, params);
1972
- _context26.n = 3;
1959
+ _context26.n = 2;
1973
1960
  return withTurnkeyErrorHandling(function () {
1974
- return client.signUpWithOauth(params);
1961
+ return client.loginWithOauth(params);
1975
1962
  }, function () {
1976
1963
  return logout();
1977
- }, callbacks, "Failed to sign up with OAuth");
1978
- case 3:
1964
+ }, callbacks, "Failed to login with OAuth");
1965
+ case 2:
1979
1966
  res = _context26.v;
1980
1967
  if (!res) {
1981
- _context26.n = 4;
1968
+ _context26.n = 3;
1982
1969
  break;
1983
1970
  }
1984
- _context26.n = 4;
1971
+ _context26.n = 3;
1985
1972
  return handlePostAuth({
1986
1973
  method: AuthMethod.Oauth,
1987
- action: AuthAction.SIGNUP,
1974
+ action: AuthAction.LOGIN,
1988
1975
  identifier: params.oidcToken
1989
1976
  });
1990
- case 4:
1977
+ case 3:
1991
1978
  return _context26.a(2, res);
1992
1979
  }
1993
1980
  }, _callee26);
@@ -1995,10 +1982,10 @@ var ClientProvider = function ClientProvider(_ref) {
1995
1982
  return function (_x21) {
1996
1983
  return _ref25.apply(this, arguments);
1997
1984
  };
1998
- }(), [client, callbacks, masterConfig]);
1999
- var completeOauth = useCallback(/*#__PURE__*/function () {
1985
+ }(), [client, callbacks]);
1986
+ var signUpWithOauth = useCallback(/*#__PURE__*/function () {
2000
1987
  var _ref26 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee27(params) {
2001
- var _params$createSubOrgP5, _masterConfig$auth17, _masterConfig$auth17$;
1988
+ var _params$createSubOrgP4, _masterConfig$auth17, _masterConfig$auth17$;
2002
1989
  var createSubOrgParams, res;
2003
1990
  return _regenerator().w(function (_context27) {
2004
1991
  while (1) switch (_context27.n) {
@@ -2016,16 +2003,16 @@ var ClientProvider = function ClientProvider(_ref) {
2016
2003
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
2017
2004
  case 2:
2018
2005
  // If createSubOrgParams is not provided, use the default from masterConfig
2019
- createSubOrgParams = (_params$createSubOrgP5 = params.createSubOrgParams) !== null && _params$createSubOrgP5 !== void 0 ? _params$createSubOrgP5 : (_masterConfig$auth17 = masterConfig.auth) === null || _masterConfig$auth17 === void 0 ? void 0 : (_masterConfig$auth17$ = _masterConfig$auth17.createSuborgParams) === null || _masterConfig$auth17$ === void 0 ? void 0 : _masterConfig$auth17$.oauth;
2006
+ createSubOrgParams = (_params$createSubOrgP4 = params.createSubOrgParams) !== null && _params$createSubOrgP4 !== void 0 ? _params$createSubOrgP4 : (_masterConfig$auth17 = masterConfig.auth) === null || _masterConfig$auth17 === void 0 ? void 0 : (_masterConfig$auth17$ = _masterConfig$auth17.createSuborgParams) === null || _masterConfig$auth17$ === void 0 ? void 0 : _masterConfig$auth17$.oauth;
2020
2007
  params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
2021
2008
  createSubOrgParams: createSubOrgParams
2022
2009
  }) : _objectSpread2({}, params);
2023
2010
  _context27.n = 3;
2024
2011
  return withTurnkeyErrorHandling(function () {
2025
- return client.completeOauth(params);
2012
+ return client.signUpWithOauth(params);
2026
2013
  }, function () {
2027
2014
  return logout();
2028
- }, callbacks, "Failed to complete OAuth");
2015
+ }, callbacks, "Failed to sign up with OAuth");
2029
2016
  case 3:
2030
2017
  res = _context27.v;
2031
2018
  if (!res) {
@@ -2035,7 +2022,7 @@ var ClientProvider = function ClientProvider(_ref) {
2035
2022
  _context27.n = 4;
2036
2023
  return handlePostAuth({
2037
2024
  method: AuthMethod.Oauth,
2038
- action: res.action,
2025
+ action: AuthAction.SIGNUP,
2039
2026
  identifier: params.oidcToken
2040
2027
  });
2041
2028
  case 4:
@@ -2047,8 +2034,10 @@ var ClientProvider = function ClientProvider(_ref) {
2047
2034
  return _ref26.apply(this, arguments);
2048
2035
  };
2049
2036
  }(), [client, callbacks, masterConfig]);
2050
- var fetchWallets = useCallback(/*#__PURE__*/function () {
2037
+ var completeOauth = useCallback(/*#__PURE__*/function () {
2051
2038
  var _ref27 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee28(params) {
2039
+ var _params$createSubOrgP5, _masterConfig$auth18, _masterConfig$auth18$;
2040
+ var createSubOrgParams, res;
2052
2041
  return _regenerator().w(function (_context28) {
2053
2042
  while (1) switch (_context28.n) {
2054
2043
  case 0:
@@ -2058,19 +2047,45 @@ var ClientProvider = function ClientProvider(_ref) {
2058
2047
  }
2059
2048
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2060
2049
  case 1:
2061
- return _context28.a(2, withTurnkeyErrorHandling(function () {
2062
- return client.fetchWallets(params);
2050
+ if (masterConfig) {
2051
+ _context28.n = 2;
2052
+ break;
2053
+ }
2054
+ throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
2055
+ case 2:
2056
+ // If createSubOrgParams is not provided, use the default from masterConfig
2057
+ createSubOrgParams = (_params$createSubOrgP5 = params.createSubOrgParams) !== null && _params$createSubOrgP5 !== void 0 ? _params$createSubOrgP5 : (_masterConfig$auth18 = masterConfig.auth) === null || _masterConfig$auth18 === void 0 ? void 0 : (_masterConfig$auth18$ = _masterConfig$auth18.createSuborgParams) === null || _masterConfig$auth18$ === void 0 ? void 0 : _masterConfig$auth18$.oauth;
2058
+ params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
2059
+ createSubOrgParams: createSubOrgParams
2060
+ }) : _objectSpread2({}, params);
2061
+ _context28.n = 3;
2062
+ return withTurnkeyErrorHandling(function () {
2063
+ return client.completeOauth(params);
2063
2064
  }, function () {
2064
2065
  return logout();
2065
- }, callbacks, "Failed to fetch wallets"));
2066
+ }, callbacks, "Failed to complete OAuth");
2067
+ case 3:
2068
+ res = _context28.v;
2069
+ if (!res) {
2070
+ _context28.n = 4;
2071
+ break;
2072
+ }
2073
+ _context28.n = 4;
2074
+ return handlePostAuth({
2075
+ method: AuthMethod.Oauth,
2076
+ action: res.action,
2077
+ identifier: params.oidcToken
2078
+ });
2079
+ case 4:
2080
+ return _context28.a(2, res);
2066
2081
  }
2067
2082
  }, _callee28);
2068
2083
  }));
2069
2084
  return function (_x23) {
2070
2085
  return _ref27.apply(this, arguments);
2071
2086
  };
2072
- }(), [client, callbacks]);
2073
- var fetchWalletAccounts = useCallback(/*#__PURE__*/function () {
2087
+ }(), [client, callbacks, masterConfig]);
2088
+ var fetchWallets = useCallback(/*#__PURE__*/function () {
2074
2089
  var _ref28 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee29(params) {
2075
2090
  return _regenerator().w(function (_context29) {
2076
2091
  while (1) switch (_context29.n) {
@@ -2082,10 +2097,10 @@ var ClientProvider = function ClientProvider(_ref) {
2082
2097
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2083
2098
  case 1:
2084
2099
  return _context29.a(2, withTurnkeyErrorHandling(function () {
2085
- return client.fetchWalletAccounts(params);
2100
+ return client.fetchWallets(params);
2086
2101
  }, function () {
2087
2102
  return logout();
2088
- }, callbacks, "Failed to fetch wallet accounts"));
2103
+ }, callbacks, "Failed to fetch wallets"));
2089
2104
  }
2090
2105
  }, _callee29);
2091
2106
  }));
@@ -2093,7 +2108,7 @@ var ClientProvider = function ClientProvider(_ref) {
2093
2108
  return _ref28.apply(this, arguments);
2094
2109
  };
2095
2110
  }(), [client, callbacks]);
2096
- var fetchPrivateKeys = useCallback(/*#__PURE__*/function () {
2111
+ var fetchWalletAccounts = useCallback(/*#__PURE__*/function () {
2097
2112
  var _ref29 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee30(params) {
2098
2113
  return _regenerator().w(function (_context30) {
2099
2114
  while (1) switch (_context30.n) {
@@ -2105,10 +2120,10 @@ var ClientProvider = function ClientProvider(_ref) {
2105
2120
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2106
2121
  case 1:
2107
2122
  return _context30.a(2, withTurnkeyErrorHandling(function () {
2108
- return client.fetchPrivateKeys(params);
2123
+ return client.fetchWalletAccounts(params);
2109
2124
  }, function () {
2110
2125
  return logout();
2111
- }, callbacks, "Failed to fetch private keys"));
2126
+ }, callbacks, "Failed to fetch wallet accounts"));
2112
2127
  }
2113
2128
  }, _callee30);
2114
2129
  }));
@@ -2116,7 +2131,7 @@ var ClientProvider = function ClientProvider(_ref) {
2116
2131
  return _ref29.apply(this, arguments);
2117
2132
  };
2118
2133
  }(), [client, callbacks]);
2119
- var signMessage = useCallback(/*#__PURE__*/function () {
2134
+ var fetchPrivateKeys = useCallback(/*#__PURE__*/function () {
2120
2135
  var _ref30 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee31(params) {
2121
2136
  return _regenerator().w(function (_context31) {
2122
2137
  while (1) switch (_context31.n) {
@@ -2128,10 +2143,10 @@ var ClientProvider = function ClientProvider(_ref) {
2128
2143
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2129
2144
  case 1:
2130
2145
  return _context31.a(2, withTurnkeyErrorHandling(function () {
2131
- return client.signMessage(params);
2146
+ return client.fetchPrivateKeys(params);
2132
2147
  }, function () {
2133
2148
  return logout();
2134
- }, callbacks, "Failed to sign message"));
2149
+ }, callbacks, "Failed to fetch private keys"));
2135
2150
  }
2136
2151
  }, _callee31);
2137
2152
  }));
@@ -2139,20 +2154,43 @@ var ClientProvider = function ClientProvider(_ref) {
2139
2154
  return _ref30.apply(this, arguments);
2140
2155
  };
2141
2156
  }(), [client, callbacks]);
2142
- var handleSignMessage = useCallback(/*#__PURE__*/function () {
2157
+ var signMessage = useCallback(/*#__PURE__*/function () {
2143
2158
  var _ref31 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee32(params) {
2144
- var _params$successPageDu, successPageDuration;
2145
2159
  return _regenerator().w(function (_context32) {
2146
2160
  while (1) switch (_context32.n) {
2147
2161
  case 0:
2148
- _params$successPageDu = params.successPageDuration, successPageDuration = _params$successPageDu === void 0 ? 2000 : _params$successPageDu;
2149
2162
  if (client) {
2150
2163
  _context32.n = 1;
2151
2164
  break;
2152
2165
  }
2153
2166
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2154
2167
  case 1:
2155
- return _context32.a(2, new Promise(function (resolve, reject) {
2168
+ return _context32.a(2, withTurnkeyErrorHandling(function () {
2169
+ return client.signMessage(params);
2170
+ }, function () {
2171
+ return logout();
2172
+ }, callbacks, "Failed to sign message"));
2173
+ }
2174
+ }, _callee32);
2175
+ }));
2176
+ return function (_x27) {
2177
+ return _ref31.apply(this, arguments);
2178
+ };
2179
+ }(), [client, callbacks]);
2180
+ var handleSignMessage = useCallback(/*#__PURE__*/function () {
2181
+ var _ref32 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee33(params) {
2182
+ var _params$successPageDu, successPageDuration;
2183
+ return _regenerator().w(function (_context33) {
2184
+ while (1) switch (_context33.n) {
2185
+ case 0:
2186
+ _params$successPageDu = params.successPageDuration, successPageDuration = _params$successPageDu === void 0 ? 2000 : _params$successPageDu;
2187
+ if (client) {
2188
+ _context33.n = 1;
2189
+ break;
2190
+ }
2191
+ throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2192
+ case 1:
2193
+ return _context33.a(2, new Promise(function (resolve, reject) {
2156
2194
  pushPage({
2157
2195
  key: "Sign message",
2158
2196
  content: jsx(SignMessageModal, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -2182,36 +2220,13 @@ var ClientProvider = function ClientProvider(_ref) {
2182
2220
  });
2183
2221
  }));
2184
2222
  }
2185
- }, _callee32);
2186
- }));
2187
- return function (_x27) {
2188
- return _ref31.apply(this, arguments);
2189
- };
2190
- }(), [client, callbacks]);
2191
- var signTransaction = useCallback(/*#__PURE__*/function () {
2192
- var _ref32 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee33(params) {
2193
- return _regenerator().w(function (_context33) {
2194
- while (1) switch (_context33.n) {
2195
- case 0:
2196
- if (client) {
2197
- _context33.n = 1;
2198
- break;
2199
- }
2200
- throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2201
- case 1:
2202
- return _context33.a(2, withTurnkeyErrorHandling(function () {
2203
- return client.signTransaction(params);
2204
- }, function () {
2205
- return logout();
2206
- }, callbacks, "Failed to sign transaction"));
2207
- }
2208
2223
  }, _callee33);
2209
2224
  }));
2210
2225
  return function (_x28) {
2211
2226
  return _ref32.apply(this, arguments);
2212
2227
  };
2213
2228
  }(), [client, callbacks]);
2214
- var signAndSendTransaction = useCallback(/*#__PURE__*/function () {
2229
+ var signTransaction = useCallback(/*#__PURE__*/function () {
2215
2230
  var _ref33 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee34(params) {
2216
2231
  return _regenerator().w(function (_context34) {
2217
2232
  while (1) switch (_context34.n) {
@@ -2223,7 +2238,7 @@ var ClientProvider = function ClientProvider(_ref) {
2223
2238
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2224
2239
  case 1:
2225
2240
  return _context34.a(2, withTurnkeyErrorHandling(function () {
2226
- return client.signAndSendTransaction(params);
2241
+ return client.signTransaction(params);
2227
2242
  }, function () {
2228
2243
  return logout();
2229
2244
  }, callbacks, "Failed to sign transaction"));
@@ -2234,7 +2249,7 @@ var ClientProvider = function ClientProvider(_ref) {
2234
2249
  return _ref33.apply(this, arguments);
2235
2250
  };
2236
2251
  }(), [client, callbacks]);
2237
- var fetchUser = useCallback(/*#__PURE__*/function () {
2252
+ var signAndSendTransaction = useCallback(/*#__PURE__*/function () {
2238
2253
  var _ref34 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee35(params) {
2239
2254
  return _regenerator().w(function (_context35) {
2240
2255
  while (1) switch (_context35.n) {
@@ -2246,10 +2261,10 @@ var ClientProvider = function ClientProvider(_ref) {
2246
2261
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2247
2262
  case 1:
2248
2263
  return _context35.a(2, withTurnkeyErrorHandling(function () {
2249
- return client.fetchUser(params);
2264
+ return client.signAndSendTransaction(params);
2250
2265
  }, function () {
2251
2266
  return logout();
2252
- }, callbacks, "Failed to fetch user"));
2267
+ }, callbacks, "Failed to sign transaction"));
2253
2268
  }
2254
2269
  }, _callee35);
2255
2270
  }));
@@ -2257,7 +2272,7 @@ var ClientProvider = function ClientProvider(_ref) {
2257
2272
  return _ref34.apply(this, arguments);
2258
2273
  };
2259
2274
  }(), [client, callbacks]);
2260
- var fetchOrCreateP256ApiKeyUser = useCallback(/*#__PURE__*/function () {
2275
+ var fetchUser = useCallback(/*#__PURE__*/function () {
2261
2276
  var _ref35 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee36(params) {
2262
2277
  return _regenerator().w(function (_context36) {
2263
2278
  while (1) switch (_context36.n) {
@@ -2269,10 +2284,10 @@ var ClientProvider = function ClientProvider(_ref) {
2269
2284
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2270
2285
  case 1:
2271
2286
  return _context36.a(2, withTurnkeyErrorHandling(function () {
2272
- return client.fetchOrCreateP256ApiKeyUser(params);
2287
+ return client.fetchUser(params);
2273
2288
  }, function () {
2274
2289
  return logout();
2275
- }, callbacks, "Failed to fetch or create delegated access user"));
2290
+ }, callbacks, "Failed to fetch user"));
2276
2291
  }
2277
2292
  }, _callee36);
2278
2293
  }));
@@ -2280,7 +2295,7 @@ var ClientProvider = function ClientProvider(_ref) {
2280
2295
  return _ref35.apply(this, arguments);
2281
2296
  };
2282
2297
  }(), [client, callbacks]);
2283
- var fetchOrCreatePolicies = useCallback(/*#__PURE__*/function () {
2298
+ var fetchOrCreateP256ApiKeyUser = useCallback(/*#__PURE__*/function () {
2284
2299
  var _ref36 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee37(params) {
2285
2300
  return _regenerator().w(function (_context37) {
2286
2301
  while (1) switch (_context37.n) {
@@ -2292,7 +2307,7 @@ var ClientProvider = function ClientProvider(_ref) {
2292
2307
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2293
2308
  case 1:
2294
2309
  return _context37.a(2, withTurnkeyErrorHandling(function () {
2295
- return client.fetchOrCreatePolicies(params);
2310
+ return client.fetchOrCreateP256ApiKeyUser(params);
2296
2311
  }, function () {
2297
2312
  return logout();
2298
2313
  }, callbacks, "Failed to fetch or create delegated access user"));
@@ -2303,9 +2318,8 @@ var ClientProvider = function ClientProvider(_ref) {
2303
2318
  return _ref36.apply(this, arguments);
2304
2319
  };
2305
2320
  }(), [client, callbacks]);
2306
- var updateUserEmail = useCallback(/*#__PURE__*/function () {
2321
+ var fetchOrCreatePolicies = useCallback(/*#__PURE__*/function () {
2307
2322
  var _ref37 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee38(params) {
2308
- var res;
2309
2323
  return _regenerator().w(function (_context38) {
2310
2324
  while (1) switch (_context38.n) {
2311
2325
  case 0:
@@ -2315,28 +2329,11 @@ var ClientProvider = function ClientProvider(_ref) {
2315
2329
  }
2316
2330
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2317
2331
  case 1:
2318
- _context38.n = 2;
2319
- return withTurnkeyErrorHandling(function () {
2320
- return client.updateUserEmail(params);
2332
+ return _context38.a(2, withTurnkeyErrorHandling(function () {
2333
+ return client.fetchOrCreatePolicies(params);
2321
2334
  }, function () {
2322
2335
  return logout();
2323
- }, callbacks, "Failed to update user email");
2324
- case 2:
2325
- res = _context38.v;
2326
- if (!res) {
2327
- _context38.n = 3;
2328
- break;
2329
- }
2330
- _context38.n = 3;
2331
- return refreshUser(_objectSpread2(_objectSpread2({
2332
- stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2333
- }, (params === null || params === void 0 ? void 0 : params.organizationId) && {
2334
- organizationId: params.organizationId
2335
- }), (params === null || params === void 0 ? void 0 : params.userId) && {
2336
- userId: params.userId
2337
- }));
2338
- case 3:
2339
- return _context38.a(2, res);
2336
+ }, callbacks, "Failed to fetch or create delegated access user"));
2340
2337
  }
2341
2338
  }, _callee38);
2342
2339
  }));
@@ -2344,7 +2341,7 @@ var ClientProvider = function ClientProvider(_ref) {
2344
2341
  return _ref37.apply(this, arguments);
2345
2342
  };
2346
2343
  }(), [client, callbacks]);
2347
- var removeUserEmail = useCallback(/*#__PURE__*/function () {
2344
+ var updateUserEmail = useCallback(/*#__PURE__*/function () {
2348
2345
  var _ref38 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee39(params) {
2349
2346
  var res;
2350
2347
  return _regenerator().w(function (_context39) {
@@ -2358,10 +2355,10 @@ var ClientProvider = function ClientProvider(_ref) {
2358
2355
  case 1:
2359
2356
  _context39.n = 2;
2360
2357
  return withTurnkeyErrorHandling(function () {
2361
- return client.removeUserEmail(params);
2358
+ return client.updateUserEmail(params);
2362
2359
  }, function () {
2363
2360
  return logout();
2364
- }, callbacks, "Failed to remove user email");
2361
+ }, callbacks, "Failed to update user email");
2365
2362
  case 2:
2366
2363
  res = _context39.v;
2367
2364
  if (!res) {
@@ -2385,7 +2382,7 @@ var ClientProvider = function ClientProvider(_ref) {
2385
2382
  return _ref38.apply(this, arguments);
2386
2383
  };
2387
2384
  }(), [client, callbacks]);
2388
- var updateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
2385
+ var removeUserEmail = useCallback(/*#__PURE__*/function () {
2389
2386
  var _ref39 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee40(params) {
2390
2387
  var res;
2391
2388
  return _regenerator().w(function (_context40) {
@@ -2399,10 +2396,10 @@ var ClientProvider = function ClientProvider(_ref) {
2399
2396
  case 1:
2400
2397
  _context40.n = 2;
2401
2398
  return withTurnkeyErrorHandling(function () {
2402
- return client.updateUserPhoneNumber(params);
2399
+ return client.removeUserEmail(params);
2403
2400
  }, function () {
2404
2401
  return logout();
2405
- }, callbacks, "Failed to update user phone number");
2402
+ }, callbacks, "Failed to remove user email");
2406
2403
  case 2:
2407
2404
  res = _context40.v;
2408
2405
  if (!res) {
@@ -2426,7 +2423,7 @@ var ClientProvider = function ClientProvider(_ref) {
2426
2423
  return _ref39.apply(this, arguments);
2427
2424
  };
2428
2425
  }(), [client, callbacks]);
2429
- var removeUserPhoneNumber = useCallback(/*#__PURE__*/function () {
2426
+ var updateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
2430
2427
  var _ref40 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee41(params) {
2431
2428
  var res;
2432
2429
  return _regenerator().w(function (_context41) {
@@ -2440,10 +2437,10 @@ var ClientProvider = function ClientProvider(_ref) {
2440
2437
  case 1:
2441
2438
  _context41.n = 2;
2442
2439
  return withTurnkeyErrorHandling(function () {
2443
- return client.removeUserPhoneNumber(params);
2440
+ return client.updateUserPhoneNumber(params);
2444
2441
  }, function () {
2445
2442
  return logout();
2446
- }, callbacks, "Failed to remove user phone number");
2443
+ }, callbacks, "Failed to update user phone number");
2447
2444
  case 2:
2448
2445
  res = _context41.v;
2449
2446
  if (!res) {
@@ -2467,7 +2464,7 @@ var ClientProvider = function ClientProvider(_ref) {
2467
2464
  return _ref40.apply(this, arguments);
2468
2465
  };
2469
2466
  }(), [client, callbacks]);
2470
- var updateUserName = useCallback(/*#__PURE__*/function () {
2467
+ var removeUserPhoneNumber = useCallback(/*#__PURE__*/function () {
2471
2468
  var _ref41 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee42(params) {
2472
2469
  var res;
2473
2470
  return _regenerator().w(function (_context42) {
@@ -2481,10 +2478,10 @@ var ClientProvider = function ClientProvider(_ref) {
2481
2478
  case 1:
2482
2479
  _context42.n = 2;
2483
2480
  return withTurnkeyErrorHandling(function () {
2484
- return client.updateUserName(params);
2481
+ return client.removeUserPhoneNumber(params);
2485
2482
  }, function () {
2486
2483
  return logout();
2487
- }, callbacks, "Failed to update user name");
2484
+ }, callbacks, "Failed to remove user phone number");
2488
2485
  case 2:
2489
2486
  res = _context42.v;
2490
2487
  if (!res) {
@@ -2508,7 +2505,7 @@ var ClientProvider = function ClientProvider(_ref) {
2508
2505
  return _ref41.apply(this, arguments);
2509
2506
  };
2510
2507
  }(), [client, callbacks]);
2511
- var addOauthProvider = useCallback(/*#__PURE__*/function () {
2508
+ var updateUserName = useCallback(/*#__PURE__*/function () {
2512
2509
  var _ref42 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee43(params) {
2513
2510
  var res;
2514
2511
  return _regenerator().w(function (_context43) {
@@ -2522,10 +2519,10 @@ var ClientProvider = function ClientProvider(_ref) {
2522
2519
  case 1:
2523
2520
  _context43.n = 2;
2524
2521
  return withTurnkeyErrorHandling(function () {
2525
- return client.addOauthProvider(params);
2522
+ return client.updateUserName(params);
2526
2523
  }, function () {
2527
2524
  return logout();
2528
- }, callbacks, "Failed to add OAuth provider");
2525
+ }, callbacks, "Failed to update user name");
2529
2526
  case 2:
2530
2527
  res = _context43.v;
2531
2528
  if (!res) {
@@ -2549,7 +2546,7 @@ var ClientProvider = function ClientProvider(_ref) {
2549
2546
  return _ref42.apply(this, arguments);
2550
2547
  };
2551
2548
  }(), [client, callbacks]);
2552
- var removeOauthProviders = useCallback(/*#__PURE__*/function () {
2549
+ var addOauthProvider = useCallback(/*#__PURE__*/function () {
2553
2550
  var _ref43 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee44(params) {
2554
2551
  var res;
2555
2552
  return _regenerator().w(function (_context44) {
@@ -2563,10 +2560,10 @@ var ClientProvider = function ClientProvider(_ref) {
2563
2560
  case 1:
2564
2561
  _context44.n = 2;
2565
2562
  return withTurnkeyErrorHandling(function () {
2566
- return client.removeOauthProviders(params);
2563
+ return client.addOauthProvider(params);
2567
2564
  }, function () {
2568
2565
  return logout();
2569
- }, callbacks, "Failed to remove OAuth providers");
2566
+ }, callbacks, "Failed to add OAuth provider");
2570
2567
  case 2:
2571
2568
  res = _context44.v;
2572
2569
  if (!res) {
@@ -2590,7 +2587,7 @@ var ClientProvider = function ClientProvider(_ref) {
2590
2587
  return _ref43.apply(this, arguments);
2591
2588
  };
2592
2589
  }(), [client, callbacks]);
2593
- var addPasskey = useCallback(/*#__PURE__*/function () {
2590
+ var removeOauthProviders = useCallback(/*#__PURE__*/function () {
2594
2591
  var _ref44 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee45(params) {
2595
2592
  var res;
2596
2593
  return _regenerator().w(function (_context45) {
@@ -2604,10 +2601,10 @@ var ClientProvider = function ClientProvider(_ref) {
2604
2601
  case 1:
2605
2602
  _context45.n = 2;
2606
2603
  return withTurnkeyErrorHandling(function () {
2607
- return client.addPasskey(params);
2604
+ return client.removeOauthProviders(params);
2608
2605
  }, function () {
2609
2606
  return logout();
2610
- }, callbacks, "Failed to add passkey");
2607
+ }, callbacks, "Failed to remove OAuth providers");
2611
2608
  case 2:
2612
2609
  res = _context45.v;
2613
2610
  if (!res) {
@@ -2631,7 +2628,7 @@ var ClientProvider = function ClientProvider(_ref) {
2631
2628
  return _ref44.apply(this, arguments);
2632
2629
  };
2633
2630
  }(), [client, callbacks]);
2634
- var removePasskeys = useCallback(/*#__PURE__*/function () {
2631
+ var addPasskey = useCallback(/*#__PURE__*/function () {
2635
2632
  var _ref45 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee46(params) {
2636
2633
  var res;
2637
2634
  return _regenerator().w(function (_context46) {
@@ -2645,10 +2642,10 @@ var ClientProvider = function ClientProvider(_ref) {
2645
2642
  case 1:
2646
2643
  _context46.n = 2;
2647
2644
  return withTurnkeyErrorHandling(function () {
2648
- return client.removePasskeys(params);
2645
+ return client.addPasskey(params);
2649
2646
  }, function () {
2650
2647
  return logout();
2651
- }, callbacks, "Failed to remove passkeys");
2648
+ }, callbacks, "Failed to add passkey");
2652
2649
  case 2:
2653
2650
  res = _context46.v;
2654
2651
  if (!res) {
@@ -2672,9 +2669,9 @@ var ClientProvider = function ClientProvider(_ref) {
2672
2669
  return _ref45.apply(this, arguments);
2673
2670
  };
2674
2671
  }(), [client, callbacks]);
2675
- var createWallet = useCallback(/*#__PURE__*/function () {
2672
+ var removePasskeys = useCallback(/*#__PURE__*/function () {
2676
2673
  var _ref46 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee47(params) {
2677
- var res, s;
2674
+ var res;
2678
2675
  return _regenerator().w(function (_context47) {
2679
2676
  while (1) switch (_context47.n) {
2680
2677
  case 0:
@@ -2686,27 +2683,25 @@ var ClientProvider = function ClientProvider(_ref) {
2686
2683
  case 1:
2687
2684
  _context47.n = 2;
2688
2685
  return withTurnkeyErrorHandling(function () {
2689
- return client.createWallet(params);
2686
+ return client.removePasskeys(params);
2690
2687
  }, function () {
2691
2688
  return logout();
2692
- }, callbacks, "Failed to create wallet");
2689
+ }, callbacks, "Failed to remove passkeys");
2693
2690
  case 2:
2694
2691
  res = _context47.v;
2695
- _context47.n = 3;
2696
- return getSession();
2697
- case 3:
2698
- s = _context47.v;
2699
- if (!(res && s)) {
2700
- _context47.n = 4;
2692
+ if (!res) {
2693
+ _context47.n = 3;
2701
2694
  break;
2702
2695
  }
2703
- _context47.n = 4;
2704
- return refreshWallets(_objectSpread2({
2696
+ _context47.n = 3;
2697
+ return refreshUser(_objectSpread2(_objectSpread2({
2705
2698
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2706
2699
  }, (params === null || params === void 0 ? void 0 : params.organizationId) && {
2707
2700
  organizationId: params.organizationId
2701
+ }), (params === null || params === void 0 ? void 0 : params.userId) && {
2702
+ userId: params.userId
2708
2703
  }));
2709
- case 4:
2704
+ case 3:
2710
2705
  return _context47.a(2, res);
2711
2706
  }
2712
2707
  }, _callee47);
@@ -2714,8 +2709,8 @@ var ClientProvider = function ClientProvider(_ref) {
2714
2709
  return function (_x42) {
2715
2710
  return _ref46.apply(this, arguments);
2716
2711
  };
2717
- }(), [client, session, callbacks]);
2718
- var createWalletAccounts = useCallback(/*#__PURE__*/function () {
2712
+ }(), [client, callbacks]);
2713
+ var createWallet = useCallback(/*#__PURE__*/function () {
2719
2714
  var _ref47 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee48(params) {
2720
2715
  var res, s;
2721
2716
  return _regenerator().w(function (_context48) {
@@ -2729,10 +2724,10 @@ var ClientProvider = function ClientProvider(_ref) {
2729
2724
  case 1:
2730
2725
  _context48.n = 2;
2731
2726
  return withTurnkeyErrorHandling(function () {
2732
- return client.createWalletAccounts(params);
2727
+ return client.createWallet(params);
2733
2728
  }, function () {
2734
2729
  return logout();
2735
- }, callbacks, "Failed to create wallet accounts");
2730
+ }, callbacks, "Failed to create wallet");
2736
2731
  case 2:
2737
2732
  res = _context48.v;
2738
2733
  _context48.n = 3;
@@ -2758,7 +2753,7 @@ var ClientProvider = function ClientProvider(_ref) {
2758
2753
  return _ref47.apply(this, arguments);
2759
2754
  };
2760
2755
  }(), [client, session, callbacks]);
2761
- var exportWallet = useCallback(/*#__PURE__*/function () {
2756
+ var createWalletAccounts = useCallback(/*#__PURE__*/function () {
2762
2757
  var _ref48 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee49(params) {
2763
2758
  var res, s;
2764
2759
  return _regenerator().w(function (_context49) {
@@ -2772,10 +2767,10 @@ var ClientProvider = function ClientProvider(_ref) {
2772
2767
  case 1:
2773
2768
  _context49.n = 2;
2774
2769
  return withTurnkeyErrorHandling(function () {
2775
- return client.exportWallet(params);
2770
+ return client.createWalletAccounts(params);
2776
2771
  }, function () {
2777
2772
  return logout();
2778
- }, callbacks, "Failed to export wallet");
2773
+ }, callbacks, "Failed to create wallet accounts");
2779
2774
  case 2:
2780
2775
  res = _context49.v;
2781
2776
  _context49.n = 3;
@@ -2801,9 +2796,9 @@ var ClientProvider = function ClientProvider(_ref) {
2801
2796
  return _ref48.apply(this, arguments);
2802
2797
  };
2803
2798
  }(), [client, session, callbacks]);
2804
- var exportPrivateKey = useCallback(/*#__PURE__*/function () {
2799
+ var exportWallet = useCallback(/*#__PURE__*/function () {
2805
2800
  var _ref49 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee50(params) {
2806
- var res;
2801
+ var res, s;
2807
2802
  return _regenerator().w(function (_context50) {
2808
2803
  while (1) switch (_context50.n) {
2809
2804
  case 0:
@@ -2815,12 +2810,27 @@ var ClientProvider = function ClientProvider(_ref) {
2815
2810
  case 1:
2816
2811
  _context50.n = 2;
2817
2812
  return withTurnkeyErrorHandling(function () {
2818
- return client.exportPrivateKey(params);
2813
+ return client.exportWallet(params);
2819
2814
  }, function () {
2820
2815
  return logout();
2821
- }, callbacks, "Failed to export private key");
2816
+ }, callbacks, "Failed to export wallet");
2822
2817
  case 2:
2823
2818
  res = _context50.v;
2819
+ _context50.n = 3;
2820
+ return getSession();
2821
+ case 3:
2822
+ s = _context50.v;
2823
+ if (!(res && s)) {
2824
+ _context50.n = 4;
2825
+ break;
2826
+ }
2827
+ _context50.n = 4;
2828
+ return refreshWallets(_objectSpread2({
2829
+ stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2830
+ }, (params === null || params === void 0 ? void 0 : params.organizationId) && {
2831
+ organizationId: params.organizationId
2832
+ }));
2833
+ case 4:
2824
2834
  return _context50.a(2, res);
2825
2835
  }
2826
2836
  }, _callee50);
@@ -2828,10 +2838,10 @@ var ClientProvider = function ClientProvider(_ref) {
2828
2838
  return function (_x45) {
2829
2839
  return _ref49.apply(this, arguments);
2830
2840
  };
2831
- }(), [client, callbacks]);
2832
- var exportWalletAccount = useCallback(/*#__PURE__*/function () {
2841
+ }(), [client, session, callbacks]);
2842
+ var exportPrivateKey = useCallback(/*#__PURE__*/function () {
2833
2843
  var _ref50 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee51(params) {
2834
- var res, s;
2844
+ var res;
2835
2845
  return _regenerator().w(function (_context51) {
2836
2846
  while (1) switch (_context51.n) {
2837
2847
  case 0:
@@ -2843,27 +2853,12 @@ var ClientProvider = function ClientProvider(_ref) {
2843
2853
  case 1:
2844
2854
  _context51.n = 2;
2845
2855
  return withTurnkeyErrorHandling(function () {
2846
- return client.exportWalletAccount(params);
2856
+ return client.exportPrivateKey(params);
2847
2857
  }, function () {
2848
2858
  return logout();
2849
- }, callbacks, "Failed to export wallet accounts");
2859
+ }, callbacks, "Failed to export private key");
2850
2860
  case 2:
2851
2861
  res = _context51.v;
2852
- _context51.n = 3;
2853
- return getSession();
2854
- case 3:
2855
- s = _context51.v;
2856
- if (!(res && s)) {
2857
- _context51.n = 4;
2858
- break;
2859
- }
2860
- _context51.n = 4;
2861
- return refreshWallets(_objectSpread2({
2862
- stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2863
- }, (params === null || params === void 0 ? void 0 : params.organizationId) && {
2864
- organizationId: params.organizationId
2865
- }));
2866
- case 4:
2867
2862
  return _context51.a(2, res);
2868
2863
  }
2869
2864
  }, _callee51);
@@ -2871,8 +2866,8 @@ var ClientProvider = function ClientProvider(_ref) {
2871
2866
  return function (_x46) {
2872
2867
  return _ref50.apply(this, arguments);
2873
2868
  };
2874
- }(), [client, callbacks, masterConfig, session, user]);
2875
- var importWallet = useCallback(/*#__PURE__*/function () {
2869
+ }(), [client, callbacks]);
2870
+ var exportWalletAccount = useCallback(/*#__PURE__*/function () {
2876
2871
  var _ref51 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee52(params) {
2877
2872
  var res, s;
2878
2873
  return _regenerator().w(function (_context52) {
@@ -2886,10 +2881,10 @@ var ClientProvider = function ClientProvider(_ref) {
2886
2881
  case 1:
2887
2882
  _context52.n = 2;
2888
2883
  return withTurnkeyErrorHandling(function () {
2889
- return client.importWallet(params);
2884
+ return client.exportWalletAccount(params);
2890
2885
  }, function () {
2891
2886
  return logout();
2892
- }, callbacks, "Failed to import wallet");
2887
+ }, callbacks, "Failed to export wallet accounts");
2893
2888
  case 2:
2894
2889
  res = _context52.v;
2895
2890
  _context52.n = 3;
@@ -2901,12 +2896,10 @@ var ClientProvider = function ClientProvider(_ref) {
2901
2896
  break;
2902
2897
  }
2903
2898
  _context52.n = 4;
2904
- return refreshWallets(_objectSpread2(_objectSpread2({
2899
+ return refreshWallets(_objectSpread2({
2905
2900
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2906
2901
  }, (params === null || params === void 0 ? void 0 : params.organizationId) && {
2907
2902
  organizationId: params.organizationId
2908
- }), (params === null || params === void 0 ? void 0 : params.userId) && {
2909
- userId: params.userId
2910
2903
  }));
2911
2904
  case 4:
2912
2905
  return _context52.a(2, res);
@@ -2917,9 +2910,9 @@ var ClientProvider = function ClientProvider(_ref) {
2917
2910
  return _ref51.apply(this, arguments);
2918
2911
  };
2919
2912
  }(), [client, callbacks, masterConfig, session, user]);
2920
- var importPrivateKey = useCallback(/*#__PURE__*/function () {
2913
+ var importWallet = useCallback(/*#__PURE__*/function () {
2921
2914
  var _ref52 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee53(params) {
2922
- var res;
2915
+ var res, s;
2923
2916
  return _regenerator().w(function (_context53) {
2924
2917
  while (1) switch (_context53.n) {
2925
2918
  case 0:
@@ -2931,12 +2924,29 @@ var ClientProvider = function ClientProvider(_ref) {
2931
2924
  case 1:
2932
2925
  _context53.n = 2;
2933
2926
  return withTurnkeyErrorHandling(function () {
2934
- return client.importPrivateKey(params);
2927
+ return client.importWallet(params);
2935
2928
  }, function () {
2936
2929
  return logout();
2937
- }, callbacks, "Failed to import private key");
2930
+ }, callbacks, "Failed to import wallet");
2938
2931
  case 2:
2939
2932
  res = _context53.v;
2933
+ _context53.n = 3;
2934
+ return getSession();
2935
+ case 3:
2936
+ s = _context53.v;
2937
+ if (!(res && s)) {
2938
+ _context53.n = 4;
2939
+ break;
2940
+ }
2941
+ _context53.n = 4;
2942
+ return refreshWallets(_objectSpread2(_objectSpread2({
2943
+ stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2944
+ }, (params === null || params === void 0 ? void 0 : params.organizationId) && {
2945
+ organizationId: params.organizationId
2946
+ }), (params === null || params === void 0 ? void 0 : params.userId) && {
2947
+ userId: params.userId
2948
+ }));
2949
+ case 4:
2940
2950
  return _context53.a(2, res);
2941
2951
  }
2942
2952
  }, _callee53);
@@ -2945,8 +2955,9 @@ var ClientProvider = function ClientProvider(_ref) {
2945
2955
  return _ref52.apply(this, arguments);
2946
2956
  };
2947
2957
  }(), [client, callbacks, masterConfig, session, user]);
2948
- var deleteSubOrganization = useCallback(/*#__PURE__*/function () {
2958
+ var importPrivateKey = useCallback(/*#__PURE__*/function () {
2949
2959
  var _ref53 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee54(params) {
2960
+ var res;
2950
2961
  return _regenerator().w(function (_context54) {
2951
2962
  while (1) switch (_context54.n) {
2952
2963
  case 0:
@@ -2956,11 +2967,15 @@ var ClientProvider = function ClientProvider(_ref) {
2956
2967
  }
2957
2968
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2958
2969
  case 1:
2959
- return _context54.a(2, withTurnkeyErrorHandling(function () {
2960
- return client.deleteSubOrganization(params);
2970
+ _context54.n = 2;
2971
+ return withTurnkeyErrorHandling(function () {
2972
+ return client.importPrivateKey(params);
2961
2973
  }, function () {
2962
2974
  return logout();
2963
- }, callbacks, "Failed to delete sub-organization"));
2975
+ }, callbacks, "Failed to import private key");
2976
+ case 2:
2977
+ res = _context54.v;
2978
+ return _context54.a(2, res);
2964
2979
  }
2965
2980
  }, _callee54);
2966
2981
  }));
@@ -2968,9 +2983,8 @@ var ClientProvider = function ClientProvider(_ref) {
2968
2983
  return _ref53.apply(this, arguments);
2969
2984
  };
2970
2985
  }(), [client, callbacks, masterConfig, session, user]);
2971
- var storeSession = useCallback(/*#__PURE__*/function () {
2986
+ var deleteSubOrganization = useCallback(/*#__PURE__*/function () {
2972
2987
  var _ref54 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee55(params) {
2973
- var sessionKey, session, allSessions;
2974
2988
  return _regenerator().w(function (_context55) {
2975
2989
  while (1) switch (_context55.n) {
2976
2990
  case 0:
@@ -2980,91 +2994,115 @@ var ClientProvider = function ClientProvider(_ref) {
2980
2994
  }
2981
2995
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2982
2996
  case 1:
2983
- _context55.n = 2;
2997
+ return _context55.a(2, withTurnkeyErrorHandling(function () {
2998
+ return client.deleteSubOrganization(params);
2999
+ }, function () {
3000
+ return logout();
3001
+ }, callbacks, "Failed to delete sub-organization"));
3002
+ }
3003
+ }, _callee55);
3004
+ }));
3005
+ return function (_x50) {
3006
+ return _ref54.apply(this, arguments);
3007
+ };
3008
+ }(), [client, callbacks, masterConfig, session, user]);
3009
+ var storeSession = useCallback(/*#__PURE__*/function () {
3010
+ var _ref55 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee56(params) {
3011
+ var sessionKey, session, allSessions;
3012
+ return _regenerator().w(function (_context56) {
3013
+ while (1) switch (_context56.n) {
3014
+ case 0:
3015
+ if (client) {
3016
+ _context56.n = 1;
3017
+ break;
3018
+ }
3019
+ throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3020
+ case 1:
3021
+ _context56.n = 2;
2984
3022
  return withTurnkeyErrorHandling(function () {
2985
3023
  return client.storeSession(params);
2986
3024
  }, function () {
2987
3025
  return logout();
2988
3026
  }, callbacks, "Failed to store session");
2989
3027
  case 2:
2990
- _context55.n = 3;
3028
+ _context56.n = 3;
2991
3029
  return getActiveSessionKey();
2992
3030
  case 3:
2993
- sessionKey = _context55.v;
2994
- _context55.n = 4;
3031
+ sessionKey = _context56.v;
3032
+ _context56.n = 4;
2995
3033
  return getSession(_objectSpread2({}, sessionKey && {
2996
3034
  sessionKey: sessionKey
2997
3035
  }));
2998
3036
  case 4:
2999
- session = _context55.v;
3037
+ session = _context56.v;
3000
3038
  if (!(session && sessionKey)) {
3001
- _context55.n = 5;
3039
+ _context56.n = 5;
3002
3040
  break;
3003
3041
  }
3004
- _context55.n = 5;
3042
+ _context56.n = 5;
3005
3043
  return scheduleSessionExpiration({
3006
3044
  sessionKey: sessionKey,
3007
3045
  expiry: session.expiry
3008
3046
  });
3009
3047
  case 5:
3010
- _context55.n = 6;
3048
+ _context56.n = 6;
3011
3049
  return getAllSessions();
3012
3050
  case 6:
3013
- allSessions = _context55.v;
3051
+ allSessions = _context56.v;
3014
3052
  setSession(session);
3015
3053
  setAllSessions(allSessions);
3016
- return _context55.a(2);
3054
+ return _context56.a(2);
3017
3055
  }
3018
- }, _callee55);
3056
+ }, _callee56);
3019
3057
  }));
3020
- return function (_x50) {
3021
- return _ref54.apply(this, arguments);
3058
+ return function (_x51) {
3059
+ return _ref55.apply(this, arguments);
3022
3060
  };
3023
3061
  }(), [client, callbacks, masterConfig, session, user]);
3024
3062
  var clearSession = useCallback(/*#__PURE__*/function () {
3025
- var _ref55 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee57(params) {
3063
+ var _ref56 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee58(params) {
3026
3064
  var _params$sessionKey;
3027
3065
  var sessionKey, newAllSessions, _t0;
3028
- return _regenerator().w(function (_context57) {
3029
- while (1) switch (_context57.n) {
3066
+ return _regenerator().w(function (_context58) {
3067
+ while (1) switch (_context58.n) {
3030
3068
  case 0:
3031
3069
  if (client) {
3032
- _context57.n = 1;
3070
+ _context58.n = 1;
3033
3071
  break;
3034
3072
  }
3035
3073
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3036
3074
  case 1:
3037
- _context57.n = 2;
3038
- return withTurnkeyErrorHandling(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee56() {
3039
- return _regenerator().w(function (_context56) {
3040
- while (1) switch (_context56.n) {
3075
+ _context58.n = 2;
3076
+ return withTurnkeyErrorHandling(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee57() {
3077
+ return _regenerator().w(function (_context57) {
3078
+ while (1) switch (_context57.n) {
3041
3079
  case 0:
3042
- return _context56.a(2, client.clearSession(params));
3080
+ return _context57.a(2, client.clearSession(params));
3043
3081
  }
3044
- }, _callee56);
3082
+ }, _callee57);
3045
3083
  })), function () {
3046
3084
  return logout();
3047
3085
  }, callbacks, "Failed to clear session");
3048
3086
  case 2:
3049
3087
  if (!((_params$sessionKey = params === null || params === void 0 ? void 0 : params.sessionKey) !== null && _params$sessionKey !== void 0)) {
3050
- _context57.n = 3;
3088
+ _context58.n = 3;
3051
3089
  break;
3052
3090
  }
3053
3091
  _t0 = _params$sessionKey;
3054
- _context57.n = 5;
3092
+ _context58.n = 5;
3055
3093
  break;
3056
3094
  case 3:
3057
- _context57.n = 4;
3095
+ _context58.n = 4;
3058
3096
  return getActiveSessionKey();
3059
3097
  case 4:
3060
- _t0 = _context57.v;
3098
+ _t0 = _context58.v;
3061
3099
  case 5:
3062
3100
  sessionKey = _t0;
3063
3101
  if (sessionKey) {
3064
- _context57.n = 6;
3102
+ _context58.n = 6;
3065
3103
  break;
3066
3104
  }
3067
- return _context57.a(2);
3105
+ return _context58.a(2);
3068
3106
  case 6:
3069
3107
  if (!(params !== null && params !== void 0 && params.sessionKey)) {
3070
3108
  setSession(undefined);
@@ -3076,20 +3114,20 @@ var ClientProvider = function ClientProvider(_ref) {
3076
3114
  delete newAllSessions[sessionKey];
3077
3115
  }
3078
3116
  setAllSessions(newAllSessions);
3079
- return _context57.a(2);
3117
+ return _context58.a(2);
3080
3118
  }
3081
- }, _callee57);
3119
+ }, _callee58);
3082
3120
  }));
3083
- return function (_x51) {
3084
- return _ref55.apply(this, arguments);
3121
+ return function (_x52) {
3122
+ return _ref56.apply(this, arguments);
3085
3123
  };
3086
3124
  }(), [client, callbacks, session, user, masterConfig]);
3087
- var clearAllSessions = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee58() {
3088
- return _regenerator().w(function (_context58) {
3089
- while (1) switch (_context58.n) {
3125
+ var clearAllSessions = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee59() {
3126
+ return _regenerator().w(function (_context59) {
3127
+ while (1) switch (_context59.n) {
3090
3128
  case 0:
3091
3129
  if (client) {
3092
- _context58.n = 1;
3130
+ _context59.n = 1;
3093
3131
  break;
3094
3132
  }
3095
3133
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
@@ -3097,60 +3135,60 @@ var ClientProvider = function ClientProvider(_ref) {
3097
3135
  setSession(undefined);
3098
3136
  setAllSessions(undefined);
3099
3137
  clearSessionTimeouts();
3100
- _context58.n = 2;
3138
+ _context59.n = 2;
3101
3139
  return withTurnkeyErrorHandling(function () {
3102
3140
  return client.clearAllSessions();
3103
3141
  }, function () {
3104
3142
  return logout();
3105
3143
  }, callbacks, "Failed to clear all sessions");
3106
3144
  case 2:
3107
- return _context58.a(2, _context58.v);
3145
+ return _context59.a(2, _context59.v);
3108
3146
  }
3109
- }, _callee58);
3147
+ }, _callee59);
3110
3148
  })), [client, callbacks, session, user, masterConfig]);
3111
3149
  var refreshSession = useCallback(/*#__PURE__*/function () {
3112
- var _ref58 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee59(params) {
3150
+ var _ref59 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee60(params) {
3113
3151
  var _params$sessionKey2;
3114
3152
  var activeSessionKey, sessionKey, res, session, allSessions;
3115
- return _regenerator().w(function (_context59) {
3116
- while (1) switch (_context59.n) {
3153
+ return _regenerator().w(function (_context60) {
3154
+ while (1) switch (_context60.n) {
3117
3155
  case 0:
3118
3156
  if (client) {
3119
- _context59.n = 1;
3157
+ _context60.n = 1;
3120
3158
  break;
3121
3159
  }
3122
3160
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3123
3161
  case 1:
3124
- _context59.n = 2;
3162
+ _context60.n = 2;
3125
3163
  return client.getActiveSessionKey();
3126
3164
  case 2:
3127
- activeSessionKey = _context59.v;
3165
+ activeSessionKey = _context60.v;
3128
3166
  if (activeSessionKey) {
3129
- _context59.n = 3;
3167
+ _context60.n = 3;
3130
3168
  break;
3131
3169
  }
3132
3170
  throw new TurnkeyError("No active session found.", TurnkeyErrorCodes.NO_SESSION_FOUND);
3133
3171
  case 3:
3134
3172
  sessionKey = (_params$sessionKey2 = params === null || params === void 0 ? void 0 : params.sessionKey) !== null && _params$sessionKey2 !== void 0 ? _params$sessionKey2 : activeSessionKey;
3135
- _context59.n = 4;
3173
+ _context60.n = 4;
3136
3174
  return withTurnkeyErrorHandling(function () {
3137
3175
  return client.refreshSession(_objectSpread2({}, params));
3138
3176
  }, function () {
3139
3177
  return logout();
3140
3178
  }, callbacks, "Failed to refresh session");
3141
3179
  case 4:
3142
- res = _context59.v;
3143
- _context59.n = 5;
3180
+ res = _context60.v;
3181
+ _context60.n = 5;
3144
3182
  return getSession({
3145
3183
  sessionKey: sessionKey
3146
3184
  });
3147
3185
  case 5:
3148
- session = _context59.v;
3186
+ session = _context60.v;
3149
3187
  if (!(session && sessionKey)) {
3150
- _context59.n = 6;
3188
+ _context60.n = 6;
3151
3189
  break;
3152
3190
  }
3153
- _context59.n = 6;
3191
+ _context60.n = 6;
3154
3192
  return scheduleSessionExpiration(_objectSpread2({
3155
3193
  sessionKey: sessionKey,
3156
3194
  expiry: session.expiry
@@ -3158,74 +3196,74 @@ var ClientProvider = function ClientProvider(_ref) {
3158
3196
  expirationSeconds: params === null || params === void 0 ? void 0 : params.expirationSeconds
3159
3197
  }));
3160
3198
  case 6:
3161
- _context59.n = 7;
3199
+ _context60.n = 7;
3162
3200
  return getAllSessions();
3163
3201
  case 7:
3164
- allSessions = _context59.v;
3202
+ allSessions = _context60.v;
3165
3203
  setSession(session);
3166
3204
  setAllSessions(allSessions);
3167
- return _context59.a(2, res);
3205
+ return _context60.a(2, res);
3168
3206
  }
3169
- }, _callee59);
3207
+ }, _callee60);
3170
3208
  }));
3171
- return function (_x52) {
3172
- return _ref58.apply(this, arguments);
3209
+ return function (_x53) {
3210
+ return _ref59.apply(this, arguments);
3173
3211
  };
3174
3212
  }(), [client, callbacks, scheduleSessionExpiration, session, user, masterConfig]);
3175
3213
  var getSession = useCallback(/*#__PURE__*/function () {
3176
- var _ref59 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee60(params) {
3177
- return _regenerator().w(function (_context60) {
3178
- while (1) switch (_context60.n) {
3214
+ var _ref60 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee61(params) {
3215
+ return _regenerator().w(function (_context61) {
3216
+ while (1) switch (_context61.n) {
3179
3217
  case 0:
3180
3218
  if (client) {
3181
- _context60.n = 1;
3219
+ _context61.n = 1;
3182
3220
  break;
3183
3221
  }
3184
3222
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3185
3223
  case 1:
3186
- return _context60.a(2, withTurnkeyErrorHandling(function () {
3224
+ return _context61.a(2, withTurnkeyErrorHandling(function () {
3187
3225
  return client.getSession(params);
3188
3226
  }, function () {
3189
3227
  return logout();
3190
3228
  }, callbacks, "Failed to get session"));
3191
3229
  }
3192
- }, _callee60);
3230
+ }, _callee61);
3193
3231
  }));
3194
- return function (_x53) {
3195
- return _ref59.apply(this, arguments);
3232
+ return function (_x54) {
3233
+ return _ref60.apply(this, arguments);
3196
3234
  };
3197
3235
  }(), [client, callbacks, masterConfig, session, user]);
3198
- var getAllSessions = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee61() {
3199
- return _regenerator().w(function (_context61) {
3200
- while (1) switch (_context61.n) {
3236
+ var getAllSessions = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee62() {
3237
+ return _regenerator().w(function (_context62) {
3238
+ while (1) switch (_context62.n) {
3201
3239
  case 0:
3202
3240
  if (client) {
3203
- _context61.n = 1;
3241
+ _context62.n = 1;
3204
3242
  break;
3205
3243
  }
3206
3244
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3207
3245
  case 1:
3208
- return _context61.a(2, withTurnkeyErrorHandling(function () {
3246
+ return _context62.a(2, withTurnkeyErrorHandling(function () {
3209
3247
  return client.getAllSessions();
3210
3248
  }, function () {
3211
3249
  return logout();
3212
3250
  }, callbacks, "Failed to get all sessions"));
3213
3251
  }
3214
- }, _callee61);
3252
+ }, _callee62);
3215
3253
  })), [client, callbacks, masterConfig, session, user]);
3216
3254
  var setActiveSession = useCallback(/*#__PURE__*/function () {
3217
- var _ref61 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee63(params) {
3255
+ var _ref62 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee64(params) {
3218
3256
  var session, s;
3219
- return _regenerator().w(function (_context63) {
3220
- while (1) switch (_context63.n) {
3257
+ return _regenerator().w(function (_context64) {
3258
+ while (1) switch (_context64.n) {
3221
3259
  case 0:
3222
3260
  if (client) {
3223
- _context63.n = 1;
3261
+ _context64.n = 1;
3224
3262
  break;
3225
3263
  }
3226
3264
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3227
3265
  case 1:
3228
- _context63.n = 2;
3266
+ _context64.n = 2;
3229
3267
  return withTurnkeyErrorHandling(function () {
3230
3268
  return client.getSession({
3231
3269
  sessionKey: params.sessionKey
@@ -3234,18 +3272,18 @@ var ClientProvider = function ClientProvider(_ref) {
3234
3272
  return logout();
3235
3273
  }, callbacks, "Failed to get session");
3236
3274
  case 2:
3237
- session = _context63.v;
3238
- _context63.n = 3;
3275
+ session = _context64.v;
3276
+ _context64.n = 3;
3239
3277
  return getSession();
3240
3278
  case 3:
3241
- s = _context63.v;
3279
+ s = _context64.v;
3242
3280
  if (s) {
3243
- _context63.n = 4;
3281
+ _context64.n = 4;
3244
3282
  break;
3245
3283
  }
3246
3284
  throw new TurnkeyError("Session not found.", TurnkeyErrorCodes.NOT_FOUND);
3247
3285
  case 4:
3248
- _context63.n = 5;
3286
+ _context64.n = 5;
3249
3287
  return withTurnkeyErrorHandling(function () {
3250
3288
  return client.setActiveSession(params);
3251
3289
  }, function () {
@@ -3253,129 +3291,129 @@ var ClientProvider = function ClientProvider(_ref) {
3253
3291
  }, callbacks, "Failed to set active session");
3254
3292
  case 5:
3255
3293
  setSession(session);
3256
- _context63.n = 6;
3257
- return withTurnkeyErrorHandling(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee62() {
3258
- return _regenerator().w(function (_context62) {
3259
- while (1) switch (_context62.n) {
3294
+ _context64.n = 6;
3295
+ return withTurnkeyErrorHandling(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee63() {
3296
+ return _regenerator().w(function (_context63) {
3297
+ while (1) switch (_context63.n) {
3260
3298
  case 0:
3261
- _context62.n = 1;
3299
+ _context63.n = 1;
3262
3300
  return refreshWallets();
3263
3301
  case 1:
3264
- _context62.n = 2;
3302
+ _context63.n = 2;
3265
3303
  return refreshUser();
3266
3304
  case 2:
3267
- return _context62.a(2);
3305
+ return _context63.a(2);
3268
3306
  }
3269
- }, _callee62);
3307
+ }, _callee63);
3270
3308
  })), function () {
3271
3309
  return logout();
3272
3310
  }, callbacks, "Failed to refresh data after setting active session");
3273
3311
  case 6:
3274
- return _context63.a(2);
3312
+ return _context64.a(2);
3275
3313
  }
3276
- }, _callee63);
3314
+ }, _callee64);
3277
3315
  }));
3278
- return function (_x54) {
3279
- return _ref61.apply(this, arguments);
3316
+ return function (_x55) {
3317
+ return _ref62.apply(this, arguments);
3280
3318
  };
3281
3319
  }(), [client, callbacks, session, user, masterConfig]);
3282
- var getActiveSessionKey = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee64() {
3283
- return _regenerator().w(function (_context64) {
3284
- while (1) switch (_context64.n) {
3320
+ var getActiveSessionKey = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee65() {
3321
+ return _regenerator().w(function (_context65) {
3322
+ while (1) switch (_context65.n) {
3285
3323
  case 0:
3286
3324
  if (client) {
3287
- _context64.n = 1;
3325
+ _context65.n = 1;
3288
3326
  break;
3289
3327
  }
3290
3328
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3291
3329
  case 1:
3292
- return _context64.a(2, withTurnkeyErrorHandling(function () {
3330
+ return _context65.a(2, withTurnkeyErrorHandling(function () {
3293
3331
  return client.getActiveSessionKey();
3294
3332
  }, function () {
3295
3333
  return logout();
3296
3334
  }, callbacks, "Failed to get active session key"));
3297
3335
  }
3298
- }, _callee64);
3336
+ }, _callee65);
3299
3337
  })), [client, callbacks, masterConfig, session, user]);
3300
- var clearUnusedKeyPairs = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee65() {
3301
- return _regenerator().w(function (_context65) {
3302
- while (1) switch (_context65.n) {
3338
+ var clearUnusedKeyPairs = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee66() {
3339
+ return _regenerator().w(function (_context66) {
3340
+ while (1) switch (_context66.n) {
3303
3341
  case 0:
3304
3342
  if (client) {
3305
- _context65.n = 1;
3343
+ _context66.n = 1;
3306
3344
  break;
3307
3345
  }
3308
3346
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3309
3347
  case 1:
3310
- return _context65.a(2, withTurnkeyErrorHandling(function () {
3348
+ return _context66.a(2, withTurnkeyErrorHandling(function () {
3311
3349
  return client.clearUnusedKeyPairs();
3312
3350
  }, function () {
3313
3351
  return logout();
3314
3352
  }, callbacks, "Failed to clear unused key pairs"));
3315
3353
  }
3316
- }, _callee65);
3354
+ }, _callee66);
3317
3355
  })), [client, callbacks, masterConfig, session, user]);
3318
3356
  var createApiKeyPair = useCallback(/*#__PURE__*/function () {
3319
- var _ref65 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee66(params) {
3320
- return _regenerator().w(function (_context66) {
3321
- while (1) switch (_context66.n) {
3357
+ var _ref66 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee67(params) {
3358
+ return _regenerator().w(function (_context67) {
3359
+ while (1) switch (_context67.n) {
3322
3360
  case 0:
3323
3361
  if (client) {
3324
- _context66.n = 1;
3362
+ _context67.n = 1;
3325
3363
  break;
3326
3364
  }
3327
3365
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3328
3366
  case 1:
3329
- return _context66.a(2, withTurnkeyErrorHandling(function () {
3367
+ return _context67.a(2, withTurnkeyErrorHandling(function () {
3330
3368
  return client.createApiKeyPair(params);
3331
3369
  }, function () {
3332
3370
  return logout();
3333
3371
  }, callbacks, "Failed to create API key pair"));
3334
3372
  }
3335
- }, _callee66);
3373
+ }, _callee67);
3336
3374
  }));
3337
- return function (_x55) {
3338
- return _ref65.apply(this, arguments);
3375
+ return function (_x56) {
3376
+ return _ref66.apply(this, arguments);
3339
3377
  };
3340
3378
  }(), [client, callbacks, session, user, masterConfig]);
3341
- var getProxyAuthConfig = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee67() {
3342
- return _regenerator().w(function (_context67) {
3343
- while (1) switch (_context67.n) {
3379
+ var getProxyAuthConfig = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee68() {
3380
+ return _regenerator().w(function (_context68) {
3381
+ while (1) switch (_context68.n) {
3344
3382
  case 0:
3345
3383
  if (client) {
3346
- _context67.n = 1;
3384
+ _context68.n = 1;
3347
3385
  break;
3348
3386
  }
3349
3387
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3350
3388
  case 1:
3351
- return _context67.a(2, withTurnkeyErrorHandling(function () {
3389
+ return _context68.a(2, withTurnkeyErrorHandling(function () {
3352
3390
  return client.getProxyAuthConfig();
3353
3391
  }, function () {
3354
3392
  return logout();
3355
3393
  }, callbacks, "Failed to get proxy auth config"));
3356
3394
  }
3357
- }, _callee67);
3395
+ }, _callee68);
3358
3396
  })), [client, callbacks, masterConfig, session, user]);
3359
3397
  var refreshUser = useCallback(/*#__PURE__*/function () {
3360
- var _ref67 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee68(params) {
3361
- var _ref68, stampWith, organizationId, userId, user;
3362
- return _regenerator().w(function (_context68) {
3363
- while (1) switch (_context68.n) {
3398
+ var _ref68 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee69(params) {
3399
+ var _ref69, stampWith, organizationId, userId, user;
3400
+ return _regenerator().w(function (_context69) {
3401
+ while (1) switch (_context69.n) {
3364
3402
  case 0:
3365
3403
  if (masterConfig !== null && masterConfig !== void 0 && masterConfig.autoRefreshManagedState) {
3366
- _context68.n = 1;
3404
+ _context69.n = 1;
3367
3405
  break;
3368
3406
  }
3369
- return _context68.a(2);
3407
+ return _context69.a(2);
3370
3408
  case 1:
3371
- _ref68 = params || {}, stampWith = _ref68.stampWith, organizationId = _ref68.organizationId, userId = _ref68.userId;
3409
+ _ref69 = params || {}, stampWith = _ref69.stampWith, organizationId = _ref69.organizationId, userId = _ref69.userId;
3372
3410
  if (client) {
3373
- _context68.n = 2;
3411
+ _context69.n = 2;
3374
3412
  break;
3375
3413
  }
3376
3414
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3377
3415
  case 2:
3378
- _context68.n = 3;
3416
+ _context69.n = 3;
3379
3417
  return withTurnkeyErrorHandling(function () {
3380
3418
  return fetchUser(_objectSpread2(_objectSpread2({
3381
3419
  stampWith: stampWith
@@ -3388,70 +3426,70 @@ var ClientProvider = function ClientProvider(_ref) {
3388
3426
  return logout();
3389
3427
  }, callbacks, "Failed to refresh user");
3390
3428
  case 3:
3391
- user = _context68.v;
3429
+ user = _context69.v;
3392
3430
  if (user) {
3393
3431
  setUser(user);
3394
3432
  }
3395
3433
  case 4:
3396
- return _context68.a(2);
3434
+ return _context69.a(2);
3397
3435
  }
3398
- }, _callee68);
3436
+ }, _callee69);
3399
3437
  }));
3400
- return function (_x56) {
3401
- return _ref67.apply(this, arguments);
3438
+ return function (_x57) {
3439
+ return _ref68.apply(this, arguments);
3402
3440
  };
3403
3441
  }(), [client, callbacks, fetchUser, masterConfig, session, user]);
3404
3442
  var fetchBootProofForAppProof = useCallback(/*#__PURE__*/function () {
3405
- var _ref69 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee69(params) {
3406
- return _regenerator().w(function (_context69) {
3407
- while (1) switch (_context69.n) {
3443
+ var _ref70 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee70(params) {
3444
+ return _regenerator().w(function (_context70) {
3445
+ while (1) switch (_context70.n) {
3408
3446
  case 0:
3409
3447
  if (client) {
3410
- _context69.n = 1;
3448
+ _context70.n = 1;
3411
3449
  break;
3412
3450
  }
3413
3451
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3414
3452
  case 1:
3415
- return _context69.a(2, withTurnkeyErrorHandling(function () {
3453
+ return _context70.a(2, withTurnkeyErrorHandling(function () {
3416
3454
  return client.fetchBootProofForAppProof(params);
3417
3455
  }, function () {
3418
3456
  return logout();
3419
3457
  }, callbacks, "Failed to fetch or create delegated access user"));
3420
3458
  }
3421
- }, _callee69);
3459
+ }, _callee70);
3422
3460
  }));
3423
- return function (_x57) {
3424
- return _ref69.apply(this, arguments);
3461
+ return function (_x58) {
3462
+ return _ref70.apply(this, arguments);
3425
3463
  };
3426
3464
  }(), [client, callbacks]);
3427
3465
  var refreshWallets = useCallback(/*#__PURE__*/function () {
3428
- var _ref70 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee70(params) {
3429
- var _ref71, stampWith, organizationId, userId, walletProviders, wallets;
3430
- return _regenerator().w(function (_context70) {
3431
- while (1) switch (_context70.n) {
3466
+ var _ref71 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee71(params) {
3467
+ var _ref72, stampWith, organizationId, userId, walletProviders, wallets;
3468
+ return _regenerator().w(function (_context71) {
3469
+ while (1) switch (_context71.n) {
3432
3470
  case 0:
3433
3471
  if (masterConfig !== null && masterConfig !== void 0 && masterConfig.autoRefreshManagedState) {
3434
- _context70.n = 1;
3472
+ _context71.n = 1;
3435
3473
  break;
3436
3474
  }
3437
- return _context70.a(2, []);
3475
+ return _context71.a(2, []);
3438
3476
  case 1:
3439
- _ref71 = params || {}, stampWith = _ref71.stampWith, organizationId = _ref71.organizationId, userId = _ref71.userId;
3477
+ _ref72 = params || {}, stampWith = _ref72.stampWith, organizationId = _ref72.organizationId, userId = _ref72.userId;
3440
3478
  if (client) {
3441
- _context70.n = 2;
3479
+ _context71.n = 2;
3442
3480
  break;
3443
3481
  }
3444
3482
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3445
3483
  case 2:
3446
- _context70.n = 3;
3484
+ _context71.n = 3;
3447
3485
  return withTurnkeyErrorHandling(function () {
3448
3486
  return fetchWalletProviders();
3449
3487
  }, function () {
3450
3488
  return logout();
3451
3489
  }, callbacks, "Failed to refresh wallets");
3452
3490
  case 3:
3453
- walletProviders = _context70.v;
3454
- _context70.n = 4;
3491
+ walletProviders = _context71.v;
3492
+ _context71.n = 4;
3455
3493
  return withTurnkeyErrorHandling(function () {
3456
3494
  return fetchWallets(_objectSpread2(_objectSpread2({
3457
3495
  stampWith: stampWith,
@@ -3465,62 +3503,62 @@ var ClientProvider = function ClientProvider(_ref) {
3465
3503
  return logout();
3466
3504
  }, callbacks, "Failed to refresh wallets");
3467
3505
  case 4:
3468
- wallets = _context70.v;
3506
+ wallets = _context71.v;
3469
3507
  if (wallets) {
3470
3508
  setWallets(wallets);
3471
3509
  }
3472
- return _context70.a(2, wallets);
3510
+ return _context71.a(2, wallets);
3473
3511
  }
3474
- }, _callee70);
3512
+ }, _callee71);
3475
3513
  }));
3476
- return function (_x58) {
3477
- return _ref70.apply(this, arguments);
3514
+ return function (_x59) {
3515
+ return _ref71.apply(this, arguments);
3478
3516
  };
3479
3517
  }(), [client, callbacks, fetchWalletProviders, fetchWallets, masterConfig, session, user]);
3480
3518
  var handleDiscordOauth = useCallback(/*#__PURE__*/function () {
3481
- var _ref72 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee71(params) {
3482
- var _masterConfig$auth18, _masterConfig$auth18$, _masterConfig$auth$oa2, _masterConfig$auth19, _masterConfig$auth19$;
3483
- var _ref73, _ref73$clientId, clientId, _ref73$openInPage, openInPage, additionalParameters, _masterConfig$auth20, _masterConfig$auth20$, _masterConfig$auth21, flow, redirectURI, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, discordAuthUrl, extra, width, height, left, top, authWindow, _t1;
3484
- return _regenerator().w(function (_context71) {
3485
- while (1) switch (_context71.p = _context71.n) {
3519
+ var _ref73 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee72(params) {
3520
+ var _masterConfig$auth19, _masterConfig$auth19$, _masterConfig$auth$oa2, _masterConfig$auth20, _masterConfig$auth20$;
3521
+ var _ref74, _ref74$clientId, clientId, _ref74$openInPage, openInPage, additionalParameters, _masterConfig$auth21, _masterConfig$auth21$, _masterConfig$auth22, flow, redirectURI, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, discordAuthUrl, extra, width, height, left, top, authWindow, _t1;
3522
+ return _regenerator().w(function (_context72) {
3523
+ while (1) switch (_context72.p = _context72.n) {
3486
3524
  case 0:
3487
- _ref73 = params || {}, _ref73$clientId = _ref73.clientId, clientId = _ref73$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth18 = masterConfig.auth) === null || _masterConfig$auth18 === void 0 ? void 0 : (_masterConfig$auth18$ = _masterConfig$auth18.oauthConfig) === null || _masterConfig$auth18$ === void 0 ? void 0 : _masterConfig$auth18$.discordClientId : _ref73$clientId, _ref73$openInPage = _ref73.openInPage, openInPage = _ref73$openInPage === void 0 ? (_masterConfig$auth$oa2 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth19 = masterConfig.auth) === null || _masterConfig$auth19 === void 0 ? void 0 : (_masterConfig$auth19$ = _masterConfig$auth19.oauthConfig) === null || _masterConfig$auth19$ === void 0 ? void 0 : _masterConfig$auth19$.openOauthInPage) !== null && _masterConfig$auth$oa2 !== void 0 ? _masterConfig$auth$oa2 : false : _ref73$openInPage, additionalParameters = _ref73.additionalState;
3488
- _context71.p = 1;
3525
+ _ref74 = params || {}, _ref74$clientId = _ref74.clientId, clientId = _ref74$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth19 = masterConfig.auth) === null || _masterConfig$auth19 === void 0 ? void 0 : (_masterConfig$auth19$ = _masterConfig$auth19.oauthConfig) === null || _masterConfig$auth19$ === void 0 ? void 0 : _masterConfig$auth19$.discordClientId : _ref74$clientId, _ref74$openInPage = _ref74.openInPage, openInPage = _ref74$openInPage === void 0 ? (_masterConfig$auth$oa2 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth20 = masterConfig.auth) === null || _masterConfig$auth20 === void 0 ? void 0 : (_masterConfig$auth20$ = _masterConfig$auth20.oauthConfig) === null || _masterConfig$auth20$ === void 0 ? void 0 : _masterConfig$auth20$.openOauthInPage) !== null && _masterConfig$auth$oa2 !== void 0 ? _masterConfig$auth$oa2 : false : _ref74$openInPage, additionalParameters = _ref74.additionalState;
3526
+ _context72.p = 1;
3489
3527
  if (masterConfig) {
3490
- _context71.n = 2;
3528
+ _context72.n = 2;
3491
3529
  break;
3492
3530
  }
3493
3531
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3494
3532
  case 2:
3495
3533
  if (clientId) {
3496
- _context71.n = 3;
3534
+ _context72.n = 3;
3497
3535
  break;
3498
3536
  }
3499
3537
  throw new TurnkeyError("Discord Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3500
3538
  case 3:
3501
- if ((_masterConfig$auth20 = masterConfig.auth) !== null && _masterConfig$auth20 !== void 0 && (_masterConfig$auth20$ = _masterConfig$auth20.oauthConfig) !== null && _masterConfig$auth20$ !== void 0 && _masterConfig$auth20$.oauthRedirectUri) {
3502
- _context71.n = 4;
3539
+ if ((_masterConfig$auth21 = masterConfig.auth) !== null && _masterConfig$auth21 !== void 0 && (_masterConfig$auth21$ = _masterConfig$auth21.oauthConfig) !== null && _masterConfig$auth21$ !== void 0 && _masterConfig$auth21$.oauthRedirectUri) {
3540
+ _context72.n = 4;
3503
3541
  break;
3504
3542
  }
3505
3543
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3506
3544
  case 4:
3507
3545
  flow = openInPage ? "redirect" : "popup";
3508
- redirectURI = (_masterConfig$auth21 = masterConfig.auth) === null || _masterConfig$auth21 === void 0 ? void 0 : _masterConfig$auth21.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3509
- _context71.n = 5;
3546
+ redirectURI = (_masterConfig$auth22 = masterConfig.auth) === null || _masterConfig$auth22 === void 0 ? void 0 : _masterConfig$auth22.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3547
+ _context72.n = 5;
3510
3548
  return createApiKeyPair();
3511
3549
  case 5:
3512
- publicKey = _context71.v;
3550
+ publicKey = _context72.v;
3513
3551
  if (publicKey) {
3514
- _context71.n = 6;
3552
+ _context72.n = 6;
3515
3553
  break;
3516
3554
  }
3517
3555
  throw new Error("Failed to create public key for OAuth.");
3518
3556
  case 6:
3519
3557
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
3520
- _context71.n = 7;
3558
+ _context72.n = 7;
3521
3559
  return generateChallengePair();
3522
3560
  case 7:
3523
- _yield$generateChalle = _context71.v;
3561
+ _yield$generateChalle = _context72.v;
3524
3562
  verifier = _yield$generateChalle.verifier;
3525
3563
  codeChallenge = _yield$generateChalle.codeChallenge;
3526
3564
  sessionStorage.setItem("discord_verifier", verifier);
@@ -3534,10 +3572,10 @@ var ClientProvider = function ClientProvider(_ref) {
3534
3572
  discordAuthUrl.searchParams.set("scope", "identify email");
3535
3573
  discordAuthUrl.searchParams.set("state", "provider=discord&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey), "&nonce=").concat(nonce));
3536
3574
  if (additionalParameters) {
3537
- extra = Object.entries(additionalParameters).map(function (_ref74) {
3538
- var _ref75 = _slicedToArray(_ref74, 2),
3539
- k = _ref75[0],
3540
- v = _ref75[1];
3575
+ extra = Object.entries(additionalParameters).map(function (_ref75) {
3576
+ var _ref76 = _slicedToArray(_ref75, 2),
3577
+ k = _ref76[0],
3578
+ v = _ref76[1];
3541
3579
  return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(v));
3542
3580
  }).join("&");
3543
3581
  if (extra) {
@@ -3545,11 +3583,11 @@ var ClientProvider = function ClientProvider(_ref) {
3545
3583
  }
3546
3584
  }
3547
3585
  if (!openInPage) {
3548
- _context71.n = 8;
3586
+ _context72.n = 8;
3549
3587
  break;
3550
3588
  }
3551
3589
  window.location.href = discordAuthUrl.toString();
3552
- return _context71.a(2, new Promise(function (_, reject) {
3590
+ return _context72.a(2, new Promise(function (_, reject) {
3553
3591
  var timeout = setTimeout(function () {
3554
3592
  reject(new Error("Authentication timed out."));
3555
3593
  }, 300000);
@@ -3564,13 +3602,13 @@ var ClientProvider = function ClientProvider(_ref) {
3564
3602
  top = window.screenY + (window.innerHeight - height) / 2;
3565
3603
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3566
3604
  if (authWindow) {
3567
- _context71.n = 9;
3605
+ _context72.n = 9;
3568
3606
  break;
3569
3607
  }
3570
3608
  throw new Error("Failed to open Discord login window.");
3571
3609
  case 9:
3572
3610
  authWindow.location.href = discordAuthUrl.toString();
3573
- return _context71.a(2, new Promise(function (resolve, reject) {
3611
+ return _context72.a(2, new Promise(function (resolve, reject) {
3574
3612
  var interval = setInterval(function () {
3575
3613
  try {
3576
3614
  if (authWindow.closed) {
@@ -3607,6 +3645,7 @@ var ClientProvider = function ClientProvider(_ref) {
3607
3645
  var oidcToken = resp.oidcToken;
3608
3646
  if (params !== null && params !== void 0 && params.onOauthSuccess) {
3609
3647
  params.onOauthSuccess(_objectSpread2({
3648
+ publicKey: publicKey,
3610
3649
  oidcToken: oidcToken,
3611
3650
  providerName: "discord"
3612
3651
  }, sessionKey && {
@@ -3644,65 +3683,65 @@ var ClientProvider = function ClientProvider(_ref) {
3644
3683
  }
3645
3684
  }));
3646
3685
  case 10:
3647
- _context71.n = 12;
3686
+ _context72.n = 12;
3648
3687
  break;
3649
3688
  case 11:
3650
- _context71.p = 11;
3651
- _t1 = _context71.v;
3689
+ _context72.p = 11;
3690
+ _t1 = _context72.v;
3652
3691
  throw _t1;
3653
3692
  case 12:
3654
- return _context71.a(2);
3693
+ return _context72.a(2);
3655
3694
  }
3656
- }, _callee71, null, [[1, 11]]);
3695
+ }, _callee72, null, [[1, 11]]);
3657
3696
  }));
3658
- return function (_x59) {
3659
- return _ref72.apply(this, arguments);
3697
+ return function (_x60) {
3698
+ return _ref73.apply(this, arguments);
3660
3699
  };
3661
3700
  }(), [client, callbacks, completeOauth, createApiKeyPair, masterConfig, session, user]);
3662
3701
  var handleXOauth = useCallback(/*#__PURE__*/function () {
3663
- var _ref76 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee72(params) {
3664
- var _masterConfig$auth22, _masterConfig$auth22$, _masterConfig$auth$oa3, _masterConfig$auth23, _masterConfig$auth23$;
3665
- var _ref77, _ref77$clientId, clientId, _ref77$openInPage, openInPage, additionalParameters, _masterConfig$auth24, _masterConfig$auth24$, _masterConfig$auth25, flow, redirectURI, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, twitterAuthUrl, extra, width, height, left, top, authWindow, _t10;
3666
- return _regenerator().w(function (_context72) {
3667
- while (1) switch (_context72.p = _context72.n) {
3702
+ var _ref77 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee73(params) {
3703
+ var _masterConfig$auth23, _masterConfig$auth23$, _masterConfig$auth$oa3, _masterConfig$auth24, _masterConfig$auth24$;
3704
+ var _ref78, _ref78$clientId, clientId, _ref78$openInPage, openInPage, additionalParameters, _masterConfig$auth25, _masterConfig$auth25$, _masterConfig$auth26, flow, redirectURI, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, twitterAuthUrl, extra, width, height, left, top, authWindow, _t10;
3705
+ return _regenerator().w(function (_context73) {
3706
+ while (1) switch (_context73.p = _context73.n) {
3668
3707
  case 0:
3669
- _ref77 = params || {}, _ref77$clientId = _ref77.clientId, clientId = _ref77$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth22 = masterConfig.auth) === null || _masterConfig$auth22 === void 0 ? void 0 : (_masterConfig$auth22$ = _masterConfig$auth22.oauthConfig) === null || _masterConfig$auth22$ === void 0 ? void 0 : _masterConfig$auth22$.xClientId : _ref77$clientId, _ref77$openInPage = _ref77.openInPage, openInPage = _ref77$openInPage === void 0 ? (_masterConfig$auth$oa3 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth23 = masterConfig.auth) === null || _masterConfig$auth23 === void 0 ? void 0 : (_masterConfig$auth23$ = _masterConfig$auth23.oauthConfig) === null || _masterConfig$auth23$ === void 0 ? void 0 : _masterConfig$auth23$.openOauthInPage) !== null && _masterConfig$auth$oa3 !== void 0 ? _masterConfig$auth$oa3 : false : _ref77$openInPage, additionalParameters = _ref77.additionalState;
3670
- _context72.p = 1;
3708
+ _ref78 = params || {}, _ref78$clientId = _ref78.clientId, clientId = _ref78$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth23 = masterConfig.auth) === null || _masterConfig$auth23 === void 0 ? void 0 : (_masterConfig$auth23$ = _masterConfig$auth23.oauthConfig) === null || _masterConfig$auth23$ === void 0 ? void 0 : _masterConfig$auth23$.xClientId : _ref78$clientId, _ref78$openInPage = _ref78.openInPage, openInPage = _ref78$openInPage === void 0 ? (_masterConfig$auth$oa3 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth24 = masterConfig.auth) === null || _masterConfig$auth24 === void 0 ? void 0 : (_masterConfig$auth24$ = _masterConfig$auth24.oauthConfig) === null || _masterConfig$auth24$ === void 0 ? void 0 : _masterConfig$auth24$.openOauthInPage) !== null && _masterConfig$auth$oa3 !== void 0 ? _masterConfig$auth$oa3 : false : _ref78$openInPage, additionalParameters = _ref78.additionalState;
3709
+ _context73.p = 1;
3671
3710
  if (masterConfig) {
3672
- _context72.n = 2;
3711
+ _context73.n = 2;
3673
3712
  break;
3674
3713
  }
3675
3714
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3676
3715
  case 2:
3677
3716
  if (clientId) {
3678
- _context72.n = 3;
3717
+ _context73.n = 3;
3679
3718
  break;
3680
3719
  }
3681
3720
  throw new TurnkeyError("Twitter Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3682
3721
  case 3:
3683
- if ((_masterConfig$auth24 = masterConfig.auth) !== null && _masterConfig$auth24 !== void 0 && (_masterConfig$auth24$ = _masterConfig$auth24.oauthConfig) !== null && _masterConfig$auth24$ !== void 0 && _masterConfig$auth24$.oauthRedirectUri) {
3684
- _context72.n = 4;
3722
+ if ((_masterConfig$auth25 = masterConfig.auth) !== null && _masterConfig$auth25 !== void 0 && (_masterConfig$auth25$ = _masterConfig$auth25.oauthConfig) !== null && _masterConfig$auth25$ !== void 0 && _masterConfig$auth25$.oauthRedirectUri) {
3723
+ _context73.n = 4;
3685
3724
  break;
3686
3725
  }
3687
3726
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3688
3727
  case 4:
3689
3728
  flow = openInPage ? "redirect" : "popup";
3690
- redirectURI = (_masterConfig$auth25 = masterConfig.auth) === null || _masterConfig$auth25 === void 0 ? void 0 : _masterConfig$auth25.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3691
- _context72.n = 5;
3729
+ redirectURI = (_masterConfig$auth26 = masterConfig.auth) === null || _masterConfig$auth26 === void 0 ? void 0 : _masterConfig$auth26.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3730
+ _context73.n = 5;
3692
3731
  return createApiKeyPair();
3693
3732
  case 5:
3694
- publicKey = _context72.v;
3733
+ publicKey = _context73.v;
3695
3734
  if (publicKey) {
3696
- _context72.n = 6;
3735
+ _context73.n = 6;
3697
3736
  break;
3698
3737
  }
3699
3738
  throw new Error("Failed to create public key for OAuth.");
3700
3739
  case 6:
3701
3740
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
3702
- _context72.n = 7;
3741
+ _context73.n = 7;
3703
3742
  return generateChallengePair();
3704
3743
  case 7:
3705
- _yield$generateChalle2 = _context72.v;
3744
+ _yield$generateChalle2 = _context73.v;
3706
3745
  verifier = _yield$generateChalle2.verifier;
3707
3746
  codeChallenge = _yield$generateChalle2.codeChallenge;
3708
3747
  sessionStorage.setItem("twitter_verifier", verifier);
@@ -3716,10 +3755,10 @@ var ClientProvider = function ClientProvider(_ref) {
3716
3755
  twitterAuthUrl.searchParams.set("scope", "tweet.read users.read");
3717
3756
  twitterAuthUrl.searchParams.set("state", "provider=twitter&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey), "&nonce=").concat(nonce));
3718
3757
  if (additionalParameters) {
3719
- extra = Object.entries(additionalParameters).map(function (_ref78) {
3720
- var _ref79 = _slicedToArray(_ref78, 2),
3721
- k = _ref79[0],
3722
- v = _ref79[1];
3758
+ extra = Object.entries(additionalParameters).map(function (_ref79) {
3759
+ var _ref80 = _slicedToArray(_ref79, 2),
3760
+ k = _ref80[0],
3761
+ v = _ref80[1];
3723
3762
  return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(v));
3724
3763
  }).join("&");
3725
3764
  if (extra) {
@@ -3727,11 +3766,11 @@ var ClientProvider = function ClientProvider(_ref) {
3727
3766
  }
3728
3767
  }
3729
3768
  if (!openInPage) {
3730
- _context72.n = 8;
3769
+ _context73.n = 8;
3731
3770
  break;
3732
3771
  }
3733
3772
  window.location.href = twitterAuthUrl.toString();
3734
- return _context72.a(2, new Promise(function (_, reject) {
3773
+ return _context73.a(2, new Promise(function (_, reject) {
3735
3774
  var timeout = setTimeout(function () {
3736
3775
  reject(new Error("Authentication timed out."));
3737
3776
  }, 300000);
@@ -3746,13 +3785,13 @@ var ClientProvider = function ClientProvider(_ref) {
3746
3785
  top = window.screenY + (window.innerHeight - height) / 2;
3747
3786
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3748
3787
  if (authWindow) {
3749
- _context72.n = 9;
3788
+ _context73.n = 9;
3750
3789
  break;
3751
3790
  }
3752
3791
  throw new Error("Failed to open Twitter login window.");
3753
3792
  case 9:
3754
3793
  authWindow.location.href = twitterAuthUrl.toString();
3755
- return _context72.a(2, new Promise(function (resolve, reject) {
3794
+ return _context73.a(2, new Promise(function (resolve, reject) {
3756
3795
  var interval = setInterval(function () {
3757
3796
  try {
3758
3797
  if (authWindow.closed) {
@@ -3789,6 +3828,7 @@ var ClientProvider = function ClientProvider(_ref) {
3789
3828
  var oidcToken = resp.oidcToken;
3790
3829
  if (params !== null && params !== void 0 && params.onOauthSuccess) {
3791
3830
  params.onOauthSuccess(_objectSpread2({
3831
+ publicKey: publicKey,
3792
3832
  oidcToken: oidcToken,
3793
3833
  providerName: "twitter"
3794
3834
  }, sessionKey && {
@@ -3826,56 +3866,56 @@ var ClientProvider = function ClientProvider(_ref) {
3826
3866
  }
3827
3867
  }));
3828
3868
  case 10:
3829
- _context72.n = 12;
3869
+ _context73.n = 12;
3830
3870
  break;
3831
3871
  case 11:
3832
- _context72.p = 11;
3833
- _t10 = _context72.v;
3872
+ _context73.p = 11;
3873
+ _t10 = _context73.v;
3834
3874
  throw _t10;
3835
3875
  case 12:
3836
- return _context72.a(2);
3876
+ return _context73.a(2);
3837
3877
  }
3838
- }, _callee72, null, [[1, 11]]);
3878
+ }, _callee73, null, [[1, 11]]);
3839
3879
  }));
3840
- return function (_x60) {
3841
- return _ref76.apply(this, arguments);
3880
+ return function (_x61) {
3881
+ return _ref77.apply(this, arguments);
3842
3882
  };
3843
3883
  }(), [client, callbacks, masterConfig, session, user]);
3844
3884
  var handleGoogleOauth = useCallback(/*#__PURE__*/function () {
3845
- var _ref80 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee73(params) {
3846
- var _masterConfig$auth26, _masterConfig$auth26$, _masterConfig$auth$oa4, _masterConfig$auth27, _masterConfig$auth27$;
3847
- var _ref81, _ref81$clientId, clientId, _ref81$openInPage, openInPage, additionalParameters, _masterConfig$auth28, _masterConfig$auth28$, _masterConfig$auth29, flow, redirectURI, publicKey, nonce, googleAuthUrl, state, additionalState, width, height, left, top, authWindow, _t11;
3848
- return _regenerator().w(function (_context73) {
3849
- while (1) switch (_context73.p = _context73.n) {
3885
+ var _ref81 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee74(params) {
3886
+ var _masterConfig$auth27, _masterConfig$auth27$, _masterConfig$auth$oa4, _masterConfig$auth28, _masterConfig$auth28$;
3887
+ var _ref82, _ref82$clientId, clientId, _ref82$openInPage, openInPage, additionalParameters, _masterConfig$auth29, _masterConfig$auth29$, _masterConfig$auth30, flow, redirectURI, publicKey, nonce, googleAuthUrl, state, additionalState, width, height, left, top, authWindow, _t11;
3888
+ return _regenerator().w(function (_context74) {
3889
+ while (1) switch (_context74.p = _context74.n) {
3850
3890
  case 0:
3851
- _ref81 = params || {}, _ref81$clientId = _ref81.clientId, clientId = _ref81$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth26 = masterConfig.auth) === null || _masterConfig$auth26 === void 0 ? void 0 : (_masterConfig$auth26$ = _masterConfig$auth26.oauthConfig) === null || _masterConfig$auth26$ === void 0 ? void 0 : _masterConfig$auth26$.googleClientId : _ref81$clientId, _ref81$openInPage = _ref81.openInPage, openInPage = _ref81$openInPage === void 0 ? (_masterConfig$auth$oa4 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth27 = masterConfig.auth) === null || _masterConfig$auth27 === void 0 ? void 0 : (_masterConfig$auth27$ = _masterConfig$auth27.oauthConfig) === null || _masterConfig$auth27$ === void 0 ? void 0 : _masterConfig$auth27$.openOauthInPage) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : false : _ref81$openInPage, additionalParameters = _ref81.additionalState;
3852
- _context73.p = 1;
3891
+ _ref82 = params || {}, _ref82$clientId = _ref82.clientId, clientId = _ref82$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth27 = masterConfig.auth) === null || _masterConfig$auth27 === void 0 ? void 0 : (_masterConfig$auth27$ = _masterConfig$auth27.oauthConfig) === null || _masterConfig$auth27$ === void 0 ? void 0 : _masterConfig$auth27$.googleClientId : _ref82$clientId, _ref82$openInPage = _ref82.openInPage, openInPage = _ref82$openInPage === void 0 ? (_masterConfig$auth$oa4 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth28 = masterConfig.auth) === null || _masterConfig$auth28 === void 0 ? void 0 : (_masterConfig$auth28$ = _masterConfig$auth28.oauthConfig) === null || _masterConfig$auth28$ === void 0 ? void 0 : _masterConfig$auth28$.openOauthInPage) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : false : _ref82$openInPage, additionalParameters = _ref82.additionalState;
3892
+ _context74.p = 1;
3853
3893
  if (masterConfig) {
3854
- _context73.n = 2;
3894
+ _context74.n = 2;
3855
3895
  break;
3856
3896
  }
3857
3897
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3858
3898
  case 2:
3859
3899
  if (clientId) {
3860
- _context73.n = 3;
3900
+ _context74.n = 3;
3861
3901
  break;
3862
3902
  }
3863
3903
  throw new TurnkeyError("Google Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3864
3904
  case 3:
3865
- if ((_masterConfig$auth28 = masterConfig.auth) !== null && _masterConfig$auth28 !== void 0 && (_masterConfig$auth28$ = _masterConfig$auth28.oauthConfig) !== null && _masterConfig$auth28$ !== void 0 && _masterConfig$auth28$.oauthRedirectUri) {
3866
- _context73.n = 4;
3905
+ if ((_masterConfig$auth29 = masterConfig.auth) !== null && _masterConfig$auth29 !== void 0 && (_masterConfig$auth29$ = _masterConfig$auth29.oauthConfig) !== null && _masterConfig$auth29$ !== void 0 && _masterConfig$auth29$.oauthRedirectUri) {
3906
+ _context74.n = 4;
3867
3907
  break;
3868
3908
  }
3869
3909
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3870
3910
  case 4:
3871
3911
  flow = openInPage ? "redirect" : "popup";
3872
- redirectURI = (_masterConfig$auth29 = masterConfig.auth) === null || _masterConfig$auth29 === void 0 ? void 0 : _masterConfig$auth29.oauthConfig.oauthRedirectUri.replace(/\/$/, ""); // Create key pair and generate nonce
3873
- _context73.n = 5;
3912
+ redirectURI = (_masterConfig$auth30 = masterConfig.auth) === null || _masterConfig$auth30 === void 0 ? void 0 : _masterConfig$auth30.oauthConfig.oauthRedirectUri.replace(/\/$/, ""); // Create key pair and generate nonce
3913
+ _context74.n = 5;
3874
3914
  return createApiKeyPair();
3875
3915
  case 5:
3876
- publicKey = _context73.v;
3916
+ publicKey = _context74.v;
3877
3917
  if (publicKey) {
3878
- _context73.n = 6;
3918
+ _context74.n = 6;
3879
3919
  break;
3880
3920
  }
3881
3921
  throw new Error("Failed to create public key for OAuth.");
@@ -3891,10 +3931,10 @@ var ClientProvider = function ClientProvider(_ref) {
3891
3931
  // Create state parameter
3892
3932
  state = "provider=google&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
3893
3933
  if (additionalParameters) {
3894
- additionalState = Object.entries(additionalParameters).map(function (_ref82) {
3895
- var _ref83 = _slicedToArray(_ref82, 2),
3896
- key = _ref83[0],
3897
- value = _ref83[1];
3934
+ additionalState = Object.entries(additionalParameters).map(function (_ref83) {
3935
+ var _ref84 = _slicedToArray(_ref83, 2),
3936
+ key = _ref84[0],
3937
+ value = _ref84[1];
3898
3938
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
3899
3939
  }).join("&");
3900
3940
  if (additionalState) {
@@ -3903,12 +3943,12 @@ var ClientProvider = function ClientProvider(_ref) {
3903
3943
  }
3904
3944
  googleAuthUrl.searchParams.set("state", state);
3905
3945
  if (!openInPage) {
3906
- _context73.n = 7;
3946
+ _context74.n = 7;
3907
3947
  break;
3908
3948
  }
3909
3949
  // Redirect current page to Google Auth
3910
3950
  window.location.href = googleAuthUrl.toString();
3911
- return _context73.a(2, new Promise(function (_, reject) {
3951
+ return _context74.a(2, new Promise(function (_, reject) {
3912
3952
  // By here, the page should have already redirected. We wait here since the function is async.
3913
3953
  // We want any function that runs this to simply wait until the page redirects.
3914
3954
  // A 5 min timeout is set just in case, idk
@@ -3928,7 +3968,7 @@ var ClientProvider = function ClientProvider(_ref) {
3928
3968
  top = window.screenY + (window.innerHeight - height) / 2;
3929
3969
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3930
3970
  if (authWindow) {
3931
- _context73.n = 8;
3971
+ _context74.n = 8;
3932
3972
  break;
3933
3973
  }
3934
3974
  throw new Error("Failed to open Google login window.");
@@ -3936,7 +3976,7 @@ var ClientProvider = function ClientProvider(_ref) {
3936
3976
  authWindow.location.href = googleAuthUrl.toString();
3937
3977
  // Return a promise that resolves when the OAuth flow completes
3938
3978
  // This following code will only run for the popup flow
3939
- return _context73.a(2, new Promise(function (resolve, reject) {
3979
+ return _context74.a(2, new Promise(function (resolve, reject) {
3940
3980
  var interval = setInterval(function () {
3941
3981
  try {
3942
3982
  // Check if window was closed without completing auth
@@ -3959,6 +3999,7 @@ var ClientProvider = function ClientProvider(_ref) {
3959
3999
  clearInterval(interval);
3960
4000
  if (params !== null && params !== void 0 && params.onOauthSuccess) {
3961
4001
  params.onOauthSuccess(_objectSpread2({
4002
+ publicKey: publicKey,
3962
4003
  oidcToken: idToken,
3963
4004
  providerName: "google"
3964
4005
  }, sessionKey && {
@@ -3995,57 +4036,57 @@ var ClientProvider = function ClientProvider(_ref) {
3995
4036
  }
3996
4037
  }));
3997
4038
  case 9:
3998
- _context73.n = 11;
4039
+ _context74.n = 11;
3999
4040
  break;
4000
4041
  case 10:
4001
- _context73.p = 10;
4002
- _t11 = _context73.v;
4042
+ _context74.p = 10;
4043
+ _t11 = _context74.v;
4003
4044
  throw _t11;
4004
4045
  case 11:
4005
- return _context73.a(2);
4046
+ return _context74.a(2);
4006
4047
  }
4007
- }, _callee73, null, [[1, 10]]);
4048
+ }, _callee74, null, [[1, 10]]);
4008
4049
  }));
4009
- return function (_x61) {
4010
- return _ref80.apply(this, arguments);
4050
+ return function (_x62) {
4051
+ return _ref81.apply(this, arguments);
4011
4052
  };
4012
4053
  }(), [client, callbacks, masterConfig, session, user]);
4013
4054
  var handleAppleOauth = useCallback(/*#__PURE__*/function () {
4014
- var _ref84 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee74(params) {
4015
- var _masterConfig$auth30, _masterConfig$auth30$, _masterConfig$auth$oa5, _masterConfig$auth31, _masterConfig$auth31$;
4016
- var _ref85, _ref85$clientId, clientId, _ref85$openInPage, openInPage, additionalParameters, _masterConfig$auth32, _masterConfig$auth32$, _masterConfig$auth33, flow, redirectURI, publicKey, nonce, appleAuthUrl, state, additionalState, width, height, left, top, authWindow, _t12;
4017
- return _regenerator().w(function (_context74) {
4018
- while (1) switch (_context74.p = _context74.n) {
4055
+ var _ref85 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee75(params) {
4056
+ var _masterConfig$auth31, _masterConfig$auth31$, _masterConfig$auth$oa5, _masterConfig$auth32, _masterConfig$auth32$;
4057
+ var _ref86, _ref86$clientId, clientId, _ref86$openInPage, openInPage, additionalParameters, _masterConfig$auth33, _masterConfig$auth33$, _masterConfig$auth34, flow, redirectURI, publicKey, nonce, appleAuthUrl, state, additionalState, width, height, left, top, authWindow, _t12;
4058
+ return _regenerator().w(function (_context75) {
4059
+ while (1) switch (_context75.p = _context75.n) {
4019
4060
  case 0:
4020
- _ref85 = params || {}, _ref85$clientId = _ref85.clientId, clientId = _ref85$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth30 = masterConfig.auth) === null || _masterConfig$auth30 === void 0 ? void 0 : (_masterConfig$auth30$ = _masterConfig$auth30.oauthConfig) === null || _masterConfig$auth30$ === void 0 ? void 0 : _masterConfig$auth30$.appleClientId : _ref85$clientId, _ref85$openInPage = _ref85.openInPage, openInPage = _ref85$openInPage === void 0 ? (_masterConfig$auth$oa5 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth31 = masterConfig.auth) === null || _masterConfig$auth31 === void 0 ? void 0 : (_masterConfig$auth31$ = _masterConfig$auth31.oauthConfig) === null || _masterConfig$auth31$ === void 0 ? void 0 : _masterConfig$auth31$.openOauthInPage) !== null && _masterConfig$auth$oa5 !== void 0 ? _masterConfig$auth$oa5 : false : _ref85$openInPage, additionalParameters = _ref85.additionalState;
4021
- _context74.p = 1;
4061
+ _ref86 = params || {}, _ref86$clientId = _ref86.clientId, clientId = _ref86$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth31 = masterConfig.auth) === null || _masterConfig$auth31 === void 0 ? void 0 : (_masterConfig$auth31$ = _masterConfig$auth31.oauthConfig) === null || _masterConfig$auth31$ === void 0 ? void 0 : _masterConfig$auth31$.appleClientId : _ref86$clientId, _ref86$openInPage = _ref86.openInPage, openInPage = _ref86$openInPage === void 0 ? (_masterConfig$auth$oa5 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth32 = masterConfig.auth) === null || _masterConfig$auth32 === void 0 ? void 0 : (_masterConfig$auth32$ = _masterConfig$auth32.oauthConfig) === null || _masterConfig$auth32$ === void 0 ? void 0 : _masterConfig$auth32$.openOauthInPage) !== null && _masterConfig$auth$oa5 !== void 0 ? _masterConfig$auth$oa5 : false : _ref86$openInPage, additionalParameters = _ref86.additionalState;
4062
+ _context75.p = 1;
4022
4063
  if (masterConfig) {
4023
- _context74.n = 2;
4064
+ _context75.n = 2;
4024
4065
  break;
4025
4066
  }
4026
4067
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4027
4068
  case 2:
4028
4069
  if (clientId) {
4029
- _context74.n = 3;
4070
+ _context75.n = 3;
4030
4071
  break;
4031
4072
  }
4032
4073
  throw new TurnkeyError("Apple Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4033
4074
  case 3:
4034
- if ((_masterConfig$auth32 = masterConfig.auth) !== null && _masterConfig$auth32 !== void 0 && (_masterConfig$auth32$ = _masterConfig$auth32.oauthConfig) !== null && _masterConfig$auth32$ !== void 0 && _masterConfig$auth32$.oauthRedirectUri) {
4035
- _context74.n = 4;
4075
+ if ((_masterConfig$auth33 = masterConfig.auth) !== null && _masterConfig$auth33 !== void 0 && (_masterConfig$auth33$ = _masterConfig$auth33.oauthConfig) !== null && _masterConfig$auth33$ !== void 0 && _masterConfig$auth33$.oauthRedirectUri) {
4076
+ _context75.n = 4;
4036
4077
  break;
4037
4078
  }
4038
4079
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4039
4080
  case 4:
4040
4081
  flow = openInPage ? "redirect" : "popup";
4041
- redirectURI = (_masterConfig$auth33 = masterConfig.auth) === null || _masterConfig$auth33 === void 0 ? void 0 : _masterConfig$auth33.oauthConfig.oauthRedirectUri; // TODO (Amir): Apple needs the '/' at the end. Maybe we should add it if not there?
4082
+ redirectURI = (_masterConfig$auth34 = masterConfig.auth) === null || _masterConfig$auth34 === void 0 ? void 0 : _masterConfig$auth34.oauthConfig.oauthRedirectUri; // TODO (Amir): Apple needs the '/' at the end. Maybe we should add it if not there?
4042
4083
  // Create key pair and generate nonce
4043
- _context74.n = 5;
4084
+ _context75.n = 5;
4044
4085
  return createApiKeyPair();
4045
4086
  case 5:
4046
- publicKey = _context74.v;
4087
+ publicKey = _context75.v;
4047
4088
  if (publicKey) {
4048
- _context74.n = 6;
4089
+ _context75.n = 6;
4049
4090
  break;
4050
4091
  }
4051
4092
  throw new Error("Failed to create public key for OAuth.");
@@ -4060,10 +4101,10 @@ var ClientProvider = function ClientProvider(_ref) {
4060
4101
  // Create state parameter
4061
4102
  state = "provider=apple&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
4062
4103
  if (additionalParameters) {
4063
- additionalState = Object.entries(additionalParameters).map(function (_ref86) {
4064
- var _ref87 = _slicedToArray(_ref86, 2),
4065
- key = _ref87[0],
4066
- value = _ref87[1];
4104
+ additionalState = Object.entries(additionalParameters).map(function (_ref87) {
4105
+ var _ref88 = _slicedToArray(_ref87, 2),
4106
+ key = _ref88[0],
4107
+ value = _ref88[1];
4067
4108
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
4068
4109
  }).join("&");
4069
4110
  if (additionalState) {
@@ -4072,12 +4113,12 @@ var ClientProvider = function ClientProvider(_ref) {
4072
4113
  }
4073
4114
  appleAuthUrl.searchParams.set("state", state);
4074
4115
  if (!openInPage) {
4075
- _context74.n = 7;
4116
+ _context75.n = 7;
4076
4117
  break;
4077
4118
  }
4078
4119
  // Redirect current page to Apple Auth
4079
4120
  window.location.href = appleAuthUrl.toString();
4080
- return _context74.a(2, new Promise(function (_, reject) {
4121
+ return _context75.a(2, new Promise(function (_, reject) {
4081
4122
  // Set a timeout just in case the redirect doesn't happen
4082
4123
  var timeout = setTimeout(function () {
4083
4124
  reject(new Error("Authentication timed out."));
@@ -4095,14 +4136,14 @@ var ClientProvider = function ClientProvider(_ref) {
4095
4136
  top = window.screenY + (window.innerHeight - height) / 2;
4096
4137
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
4097
4138
  if (authWindow) {
4098
- _context74.n = 8;
4139
+ _context75.n = 8;
4099
4140
  break;
4100
4141
  }
4101
4142
  throw new Error("Failed to open Apple login window.");
4102
4143
  case 8:
4103
4144
  authWindow.location.href = appleAuthUrl.toString();
4104
4145
  // Return a promise that resolves when the OAuth flow completes
4105
- return _context74.a(2, new Promise(function (resolve, reject) {
4146
+ return _context75.a(2, new Promise(function (resolve, reject) {
4106
4147
  var interval = setInterval(function () {
4107
4148
  try {
4108
4149
  // Check if window was closed without completing auth
@@ -4125,6 +4166,7 @@ var ClientProvider = function ClientProvider(_ref) {
4125
4166
  clearInterval(interval);
4126
4167
  if (params !== null && params !== void 0 && params.onOauthSuccess) {
4127
4168
  params.onOauthSuccess(_objectSpread2({
4169
+ publicKey: publicKey,
4128
4170
  oidcToken: idToken,
4129
4171
  providerName: "apple"
4130
4172
  }, sessionKey && {
@@ -4161,65 +4203,65 @@ var ClientProvider = function ClientProvider(_ref) {
4161
4203
  }
4162
4204
  }));
4163
4205
  case 9:
4164
- _context74.n = 11;
4206
+ _context75.n = 11;
4165
4207
  break;
4166
4208
  case 10:
4167
- _context74.p = 10;
4168
- _t12 = _context74.v;
4209
+ _context75.p = 10;
4210
+ _t12 = _context75.v;
4169
4211
  throw _t12;
4170
4212
  case 11:
4171
- return _context74.a(2);
4213
+ return _context75.a(2);
4172
4214
  }
4173
- }, _callee74, null, [[1, 10]]);
4215
+ }, _callee75, null, [[1, 10]]);
4174
4216
  }));
4175
- return function (_x62) {
4176
- return _ref84.apply(this, arguments);
4217
+ return function (_x63) {
4218
+ return _ref85.apply(this, arguments);
4177
4219
  };
4178
4220
  }(), [client, callbacks, masterConfig, session, user]);
4179
4221
  var handleFacebookOauth = useCallback(/*#__PURE__*/function () {
4180
- var _ref88 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee75(params) {
4181
- var _masterConfig$auth34, _masterConfig$auth34$, _masterConfig$auth$oa6, _masterConfig$auth35, _masterConfig$auth35$;
4182
- var _ref89, _ref89$clientId, clientId, _ref89$openInPage, openInPage, additionalParameters, _masterConfig$auth36, _masterConfig$auth36$, _masterConfig$auth37, flow, redirectURI, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, facebookAuthUrl, state, additionalState, width, height, left, top, authWindow, _t13;
4183
- return _regenerator().w(function (_context75) {
4184
- while (1) switch (_context75.p = _context75.n) {
4222
+ var _ref89 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee76(params) {
4223
+ var _masterConfig$auth35, _masterConfig$auth35$, _masterConfig$auth$oa6, _masterConfig$auth36, _masterConfig$auth36$;
4224
+ var _ref90, _ref90$clientId, clientId, _ref90$openInPage, openInPage, additionalParameters, _masterConfig$auth37, _masterConfig$auth37$, _masterConfig$auth38, flow, redirectURI, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, facebookAuthUrl, state, additionalState, width, height, left, top, authWindow, _t13;
4225
+ return _regenerator().w(function (_context76) {
4226
+ while (1) switch (_context76.p = _context76.n) {
4185
4227
  case 0:
4186
- _ref89 = params || {}, _ref89$clientId = _ref89.clientId, clientId = _ref89$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth34 = masterConfig.auth) === null || _masterConfig$auth34 === void 0 ? void 0 : (_masterConfig$auth34$ = _masterConfig$auth34.oauthConfig) === null || _masterConfig$auth34$ === void 0 ? void 0 : _masterConfig$auth34$.facebookClientId : _ref89$clientId, _ref89$openInPage = _ref89.openInPage, openInPage = _ref89$openInPage === void 0 ? (_masterConfig$auth$oa6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth35 = masterConfig.auth) === null || _masterConfig$auth35 === void 0 ? void 0 : (_masterConfig$auth35$ = _masterConfig$auth35.oauthConfig) === null || _masterConfig$auth35$ === void 0 ? void 0 : _masterConfig$auth35$.openOauthInPage) !== null && _masterConfig$auth$oa6 !== void 0 ? _masterConfig$auth$oa6 : false : _ref89$openInPage, additionalParameters = _ref89.additionalState;
4187
- _context75.p = 1;
4228
+ _ref90 = params || {}, _ref90$clientId = _ref90.clientId, clientId = _ref90$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth35 = masterConfig.auth) === null || _masterConfig$auth35 === void 0 ? void 0 : (_masterConfig$auth35$ = _masterConfig$auth35.oauthConfig) === null || _masterConfig$auth35$ === void 0 ? void 0 : _masterConfig$auth35$.facebookClientId : _ref90$clientId, _ref90$openInPage = _ref90.openInPage, openInPage = _ref90$openInPage === void 0 ? (_masterConfig$auth$oa6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth36 = masterConfig.auth) === null || _masterConfig$auth36 === void 0 ? void 0 : (_masterConfig$auth36$ = _masterConfig$auth36.oauthConfig) === null || _masterConfig$auth36$ === void 0 ? void 0 : _masterConfig$auth36$.openOauthInPage) !== null && _masterConfig$auth$oa6 !== void 0 ? _masterConfig$auth$oa6 : false : _ref90$openInPage, additionalParameters = _ref90.additionalState;
4229
+ _context76.p = 1;
4188
4230
  if (masterConfig) {
4189
- _context75.n = 2;
4231
+ _context76.n = 2;
4190
4232
  break;
4191
4233
  }
4192
4234
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4193
4235
  case 2:
4194
4236
  if (clientId) {
4195
- _context75.n = 3;
4237
+ _context76.n = 3;
4196
4238
  break;
4197
4239
  }
4198
4240
  throw new TurnkeyError("Facebook Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4199
4241
  case 3:
4200
- if ((_masterConfig$auth36 = masterConfig.auth) !== null && _masterConfig$auth36 !== void 0 && (_masterConfig$auth36$ = _masterConfig$auth36.oauthConfig) !== null && _masterConfig$auth36$ !== void 0 && _masterConfig$auth36$.oauthRedirectUri) {
4201
- _context75.n = 4;
4242
+ if ((_masterConfig$auth37 = masterConfig.auth) !== null && _masterConfig$auth37 !== void 0 && (_masterConfig$auth37$ = _masterConfig$auth37.oauthConfig) !== null && _masterConfig$auth37$ !== void 0 && _masterConfig$auth37$.oauthRedirectUri) {
4243
+ _context76.n = 4;
4202
4244
  break;
4203
4245
  }
4204
4246
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4205
4247
  case 4:
4206
4248
  flow = openInPage ? "redirect" : "popup";
4207
- redirectURI = (_masterConfig$auth37 = masterConfig.auth) === null || _masterConfig$auth37 === void 0 ? void 0 : _masterConfig$auth37.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4208
- _context75.n = 5;
4249
+ redirectURI = (_masterConfig$auth38 = masterConfig.auth) === null || _masterConfig$auth38 === void 0 ? void 0 : _masterConfig$auth38.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4250
+ _context76.n = 5;
4209
4251
  return createApiKeyPair();
4210
4252
  case 5:
4211
- publicKey = _context75.v;
4253
+ publicKey = _context76.v;
4212
4254
  if (publicKey) {
4213
- _context75.n = 6;
4255
+ _context76.n = 6;
4214
4256
  break;
4215
4257
  }
4216
4258
  throw new Error("Failed to create public key for OAuth.");
4217
4259
  case 6:
4218
4260
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
4219
- _context75.n = 7;
4261
+ _context76.n = 7;
4220
4262
  return generateChallengePair();
4221
4263
  case 7:
4222
- _yield$generateChalle3 = _context75.v;
4264
+ _yield$generateChalle3 = _context76.v;
4223
4265
  verifier = _yield$generateChalle3.verifier;
4224
4266
  codeChallenge = _yield$generateChalle3.codeChallenge;
4225
4267
  // Store verifier for later token exchange
@@ -4236,10 +4278,10 @@ var ClientProvider = function ClientProvider(_ref) {
4236
4278
  // Create state parameter
4237
4279
  state = "provider=facebook&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
4238
4280
  if (additionalParameters) {
4239
- additionalState = Object.entries(additionalParameters).map(function (_ref90) {
4240
- var _ref91 = _slicedToArray(_ref90, 2),
4241
- key = _ref91[0],
4242
- value = _ref91[1];
4281
+ additionalState = Object.entries(additionalParameters).map(function (_ref91) {
4282
+ var _ref92 = _slicedToArray(_ref91, 2),
4283
+ key = _ref92[0],
4284
+ value = _ref92[1];
4243
4285
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
4244
4286
  }).join("&");
4245
4287
  if (additionalState) {
@@ -4248,12 +4290,12 @@ var ClientProvider = function ClientProvider(_ref) {
4248
4290
  }
4249
4291
  facebookAuthUrl.searchParams.set("state", state);
4250
4292
  if (!openInPage) {
4251
- _context75.n = 8;
4293
+ _context76.n = 8;
4252
4294
  break;
4253
4295
  }
4254
4296
  // Redirect current page to Facebook Auth
4255
4297
  window.location.href = facebookAuthUrl.toString();
4256
- return _context75.a(2, new Promise(function (_, reject) {
4298
+ return _context76.a(2, new Promise(function (_, reject) {
4257
4299
  // Set a timeout just in case the redirect doesn't happen
4258
4300
  var timeout = setTimeout(function () {
4259
4301
  reject(new Error("Authentication timed out."));
@@ -4271,14 +4313,14 @@ var ClientProvider = function ClientProvider(_ref) {
4271
4313
  top = window.screenY + (window.innerHeight - height) / 2;
4272
4314
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
4273
4315
  if (authWindow) {
4274
- _context75.n = 9;
4316
+ _context76.n = 9;
4275
4317
  break;
4276
4318
  }
4277
4319
  throw new Error("Failed to open Facebook login window.");
4278
4320
  case 9:
4279
4321
  authWindow.location.href = facebookAuthUrl.toString();
4280
4322
  // Return a promise that resolves when the OAuth flow completes
4281
- return _context75.a(2, new Promise(function (resolve, reject) {
4323
+ return _context76.a(2, new Promise(function (resolve, reject) {
4282
4324
  var interval = setInterval(function () {
4283
4325
  try {
4284
4326
  // Check if window was closed without completing auth
@@ -4309,6 +4351,7 @@ var ClientProvider = function ClientProvider(_ref) {
4309
4351
  sessionStorage.removeItem("facebook_verifier");
4310
4352
  if (params !== null && params !== void 0 && params.onOauthSuccess) {
4311
4353
  params.onOauthSuccess(_objectSpread2({
4354
+ publicKey: publicKey,
4312
4355
  oidcToken: tokenData.id_token,
4313
4356
  providerName: "facebook"
4314
4357
  }, sessionKey && {
@@ -4346,27 +4389,27 @@ var ClientProvider = function ClientProvider(_ref) {
4346
4389
  }
4347
4390
  }));
4348
4391
  case 10:
4349
- _context75.n = 12;
4392
+ _context76.n = 12;
4350
4393
  break;
4351
4394
  case 11:
4352
- _context75.p = 11;
4353
- _t13 = _context75.v;
4395
+ _context76.p = 11;
4396
+ _t13 = _context76.v;
4354
4397
  throw _t13;
4355
4398
  case 12:
4356
- return _context75.a(2);
4399
+ return _context76.a(2);
4357
4400
  }
4358
- }, _callee75, null, [[1, 11]]);
4401
+ }, _callee76, null, [[1, 11]]);
4359
4402
  }));
4360
- return function (_x63) {
4361
- return _ref88.apply(this, arguments);
4403
+ return function (_x64) {
4404
+ return _ref89.apply(this, arguments);
4362
4405
  };
4363
4406
  }(), [client, callbacks, masterConfig, client, session, user]);
4364
4407
  var handleLogin = useCallback(/*#__PURE__*/function () {
4365
- var _ref92 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee76(params) {
4408
+ var _ref93 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee77(params) {
4366
4409
  var _masterConfig$ui, _params$logoDark, _masterConfig$ui2, _params$logoLight, _masterConfig$ui3, _params$title;
4367
4410
  var logo;
4368
- return _regenerator().w(function (_context76) {
4369
- while (1) switch (_context76.n) {
4411
+ return _regenerator().w(function (_context77) {
4412
+ while (1) switch (_context77.n) {
4370
4413
  case 0:
4371
4414
  logo = masterConfig !== null && masterConfig !== void 0 && (_masterConfig$ui = masterConfig.ui) !== null && _masterConfig$ui !== void 0 && _masterConfig$ui.darkMode ? (_params$logoDark = params === null || params === void 0 ? void 0 : params.logoDark) !== null && _params$logoDark !== void 0 ? _params$logoDark : masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$ui2 = masterConfig.ui) === null || _masterConfig$ui2 === void 0 ? void 0 : _masterConfig$ui2.logoDark : (_params$logoLight = params === null || params === void 0 ? void 0 : params.logoLight) !== null && _params$logoLight !== void 0 ? _params$logoLight : masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$ui3 = masterConfig.ui) === null || _masterConfig$ui3 === void 0 ? void 0 : _masterConfig$ui3.logoLight;
4372
4415
  pushPage({
@@ -4380,22 +4423,22 @@ var ClientProvider = function ClientProvider(_ref) {
4380
4423
  showTitle: logo ? false : true
4381
4424
  });
4382
4425
  case 1:
4383
- return _context76.a(2);
4426
+ return _context77.a(2);
4384
4427
  }
4385
- }, _callee76);
4428
+ }, _callee77);
4386
4429
  }));
4387
- return function (_x64) {
4388
- return _ref92.apply(this, arguments);
4430
+ return function (_x65) {
4431
+ return _ref93.apply(this, arguments);
4389
4432
  };
4390
4433
  }(), [pushPage, masterConfig, client, session, user]);
4391
4434
  var handleExportWallet = useCallback(/*#__PURE__*/function () {
4392
- var _ref93 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee77(params) {
4435
+ var _ref94 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee78(params) {
4393
4436
  var walletId, targetPublicKey, stampWith, organizationId;
4394
- return _regenerator().w(function (_context77) {
4395
- while (1) switch (_context77.n) {
4437
+ return _regenerator().w(function (_context78) {
4438
+ while (1) switch (_context78.n) {
4396
4439
  case 0:
4397
4440
  walletId = params.walletId, targetPublicKey = params.targetPublicKey, stampWith = params.stampWith, organizationId = params.organizationId;
4398
- return _context77.a(2, new Promise(function (resolve, reject) {
4441
+ return _context78.a(2, new Promise(function (resolve, reject) {
4399
4442
  return pushPage({
4400
4443
  key: "Export wallet",
4401
4444
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4421,20 +4464,20 @@ var ClientProvider = function ClientProvider(_ref) {
4421
4464
  });
4422
4465
  }));
4423
4466
  }
4424
- }, _callee77);
4467
+ }, _callee78);
4425
4468
  }));
4426
- return function (_x65) {
4427
- return _ref93.apply(this, arguments);
4469
+ return function (_x66) {
4470
+ return _ref94.apply(this, arguments);
4428
4471
  };
4429
4472
  }(), [pushPage, masterConfig, client, session, user]);
4430
4473
  var handleExportPrivateKey = useCallback(/*#__PURE__*/function () {
4431
- var _ref94 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee78(params) {
4474
+ var _ref95 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee79(params) {
4432
4475
  var privateKeyId, targetPublicKey, keyFormat, stampWith, organizationId;
4433
- return _regenerator().w(function (_context78) {
4434
- while (1) switch (_context78.n) {
4476
+ return _regenerator().w(function (_context79) {
4477
+ while (1) switch (_context79.n) {
4435
4478
  case 0:
4436
4479
  privateKeyId = params.privateKeyId, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith, organizationId = params.organizationId;
4437
- return _context78.a(2, new Promise(function (resolve, reject) {
4480
+ return _context79.a(2, new Promise(function (resolve, reject) {
4438
4481
  return pushPage({
4439
4482
  key: "Export private key",
4440
4483
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4462,20 +4505,20 @@ var ClientProvider = function ClientProvider(_ref) {
4462
4505
  });
4463
4506
  }));
4464
4507
  }
4465
- }, _callee78);
4508
+ }, _callee79);
4466
4509
  }));
4467
- return function (_x66) {
4468
- return _ref94.apply(this, arguments);
4510
+ return function (_x67) {
4511
+ return _ref95.apply(this, arguments);
4469
4512
  };
4470
4513
  }(), [pushPage, masterConfig, client, session, user]);
4471
4514
  var handleExportWalletAccount = useCallback(/*#__PURE__*/function () {
4472
- var _ref95 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee79(params) {
4515
+ var _ref96 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee80(params) {
4473
4516
  var address, targetPublicKey, keyFormat, stampWith, organizationId;
4474
- return _regenerator().w(function (_context79) {
4475
- while (1) switch (_context79.n) {
4517
+ return _regenerator().w(function (_context80) {
4518
+ while (1) switch (_context80.n) {
4476
4519
  case 0:
4477
4520
  address = params.address, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith, organizationId = params.organizationId;
4478
- return _context79.a(2, new Promise(function (resolve, reject) {
4521
+ return _context80.a(2, new Promise(function (resolve, reject) {
4479
4522
  return pushPage({
4480
4523
  key: "Export wallet account",
4481
4524
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4503,21 +4546,21 @@ var ClientProvider = function ClientProvider(_ref) {
4503
4546
  });
4504
4547
  }));
4505
4548
  }
4506
- }, _callee79);
4549
+ }, _callee80);
4507
4550
  }));
4508
- return function (_x67) {
4509
- return _ref95.apply(this, arguments);
4551
+ return function (_x68) {
4552
+ return _ref96.apply(this, arguments);
4510
4553
  };
4511
4554
  }(), [pushPage, masterConfig, client, session, user]);
4512
4555
  var handleImportWallet = useCallback(/*#__PURE__*/function () {
4513
- var _ref96 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee80(params) {
4514
- var _ref97, defaultWalletAccounts, _ref97$successPageDur, successPageDuration, stampWith, walletName, organizationId, userId, _t14;
4515
- return _regenerator().w(function (_context80) {
4516
- while (1) switch (_context80.p = _context80.n) {
4556
+ var _ref97 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee81(params) {
4557
+ var _ref98, defaultWalletAccounts, _ref98$successPageDur, successPageDuration, stampWith, walletName, organizationId, userId, _t14;
4558
+ return _regenerator().w(function (_context81) {
4559
+ while (1) switch (_context81.p = _context81.n) {
4517
4560
  case 0:
4518
- _ref97 = params || {}, defaultWalletAccounts = _ref97.defaultWalletAccounts, _ref97$successPageDur = _ref97.successPageDuration, successPageDuration = _ref97$successPageDur === void 0 ? 2000 : _ref97$successPageDur, stampWith = _ref97.stampWith, walletName = _ref97.walletName, organizationId = _ref97.organizationId, userId = _ref97.userId;
4519
- _context80.p = 1;
4520
- return _context80.a(2, withTurnkeyErrorHandling(function () {
4561
+ _ref98 = params || {}, defaultWalletAccounts = _ref98.defaultWalletAccounts, _ref98$successPageDur = _ref98.successPageDuration, successPageDuration = _ref98$successPageDur === void 0 ? 2000 : _ref98$successPageDur, stampWith = _ref98.stampWith, walletName = _ref98.walletName, organizationId = _ref98.organizationId, userId = _ref98.userId;
4562
+ _context81.p = 1;
4563
+ return _context81.a(2, withTurnkeyErrorHandling(function () {
4521
4564
  return new Promise(function (resolve, reject) {
4522
4565
  return pushPage({
4523
4566
  key: "Import wallet",
@@ -4548,33 +4591,33 @@ var ClientProvider = function ClientProvider(_ref) {
4548
4591
  return logout();
4549
4592
  }));
4550
4593
  case 2:
4551
- _context80.p = 2;
4552
- _t14 = _context80.v;
4594
+ _context81.p = 2;
4595
+ _t14 = _context81.v;
4553
4596
  if (!(_t14 instanceof TurnkeyError)) {
4554
- _context80.n = 3;
4597
+ _context81.n = 3;
4555
4598
  break;
4556
4599
  }
4557
4600
  throw _t14;
4558
4601
  case 3:
4559
4602
  throw new TurnkeyError("Failed to import wallet.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t14);
4560
4603
  case 4:
4561
- return _context80.a(2);
4604
+ return _context81.a(2);
4562
4605
  }
4563
- }, _callee80, null, [[1, 2]]);
4606
+ }, _callee81, null, [[1, 2]]);
4564
4607
  }));
4565
- return function (_x68) {
4566
- return _ref96.apply(this, arguments);
4608
+ return function (_x69) {
4609
+ return _ref97.apply(this, arguments);
4567
4610
  };
4568
4611
  }(), [pushPage, masterConfig, client, session, user]);
4569
4612
  var handleImportPrivateKey = useCallback(/*#__PURE__*/function () {
4570
- var _ref98 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee81(params) {
4571
- var _ref99, curve, addressFormats, _ref99$successPageDur, successPageDuration, stampWith, keyName, organizationId, _t15;
4572
- return _regenerator().w(function (_context81) {
4573
- while (1) switch (_context81.p = _context81.n) {
4613
+ var _ref99 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee82(params) {
4614
+ var _ref100, curve, addressFormats, _ref100$successPageDu, successPageDuration, stampWith, keyName, organizationId, _t15;
4615
+ return _regenerator().w(function (_context82) {
4616
+ while (1) switch (_context82.p = _context82.n) {
4574
4617
  case 0:
4575
- _ref99 = params || {}, curve = _ref99.curve, addressFormats = _ref99.addressFormats, _ref99$successPageDur = _ref99.successPageDuration, successPageDuration = _ref99$successPageDur === void 0 ? 2000 : _ref99$successPageDur, stampWith = _ref99.stampWith, keyName = _ref99.keyName, organizationId = _ref99.organizationId;
4576
- _context81.p = 1;
4577
- return _context81.a(2, withTurnkeyErrorHandling(function () {
4618
+ _ref100 = params || {}, curve = _ref100.curve, addressFormats = _ref100.addressFormats, _ref100$successPageDu = _ref100.successPageDuration, successPageDuration = _ref100$successPageDu === void 0 ? 2000 : _ref100$successPageDu, stampWith = _ref100.stampWith, keyName = _ref100.keyName, organizationId = _ref100.organizationId;
4619
+ _context82.p = 1;
4620
+ return _context82.a(2, withTurnkeyErrorHandling(function () {
4578
4621
  return new Promise(function (resolve, reject) {
4579
4622
  return pushPage({
4580
4623
  key: "Import private key",
@@ -4603,51 +4646,51 @@ var ClientProvider = function ClientProvider(_ref) {
4603
4646
  return logout();
4604
4647
  }));
4605
4648
  case 2:
4606
- _context81.p = 2;
4607
- _t15 = _context81.v;
4649
+ _context82.p = 2;
4650
+ _t15 = _context82.v;
4608
4651
  if (!(_t15 instanceof TurnkeyError)) {
4609
- _context81.n = 3;
4652
+ _context82.n = 3;
4610
4653
  break;
4611
4654
  }
4612
4655
  throw _t15;
4613
4656
  case 3:
4614
4657
  throw new TurnkeyError("Failed to import private key.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t15);
4615
4658
  case 4:
4616
- return _context81.a(2);
4659
+ return _context82.a(2);
4617
4660
  }
4618
- }, _callee81, null, [[1, 2]]);
4661
+ }, _callee82, null, [[1, 2]]);
4619
4662
  }));
4620
- return function (_x69) {
4621
- return _ref98.apply(this, arguments);
4663
+ return function (_x70) {
4664
+ return _ref99.apply(this, arguments);
4622
4665
  };
4623
4666
  }(), [pushPage, masterConfig, client, session, user]);
4624
4667
  var handleUpdateUserName = useCallback(/*#__PURE__*/function () {
4625
- var _ref100 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee82(params) {
4626
- var _ref101, _ref101$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, res, _t16;
4627
- return _regenerator().w(function (_context82) {
4628
- while (1) switch (_context82.p = _context82.n) {
4668
+ var _ref101 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee83(params) {
4669
+ var _ref102, _ref102$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, res, _t16;
4670
+ return _regenerator().w(function (_context83) {
4671
+ while (1) switch (_context83.p = _context83.n) {
4629
4672
  case 0:
4630
- _ref101 = params || {}, _ref101$successPageDu = _ref101.successPageDuration, successPageDuration = _ref101$successPageDu === void 0 ? 2000 : _ref101$successPageDu, subTitle = _ref101.subTitle, title = _ref101.title, stampWith = _ref101.stampWith;
4673
+ _ref102 = params || {}, _ref102$successPageDu = _ref102.successPageDuration, successPageDuration = _ref102$successPageDu === void 0 ? 2000 : _ref102$successPageDu, subTitle = _ref102.subTitle, title = _ref102.title, stampWith = _ref102.stampWith;
4631
4674
  if (client) {
4632
- _context82.n = 1;
4675
+ _context83.n = 1;
4633
4676
  break;
4634
4677
  }
4635
4678
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4636
4679
  case 1:
4637
- _context82.n = 2;
4680
+ _context83.n = 2;
4638
4681
  return getSession();
4639
4682
  case 2:
4640
- s = _context82.v;
4683
+ s = _context83.v;
4641
4684
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4642
4685
  if (organizationId) {
4643
- _context82.n = 3;
4686
+ _context83.n = 3;
4644
4687
  break;
4645
4688
  }
4646
4689
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
4647
4690
  case 3:
4648
4691
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (user === null || user === void 0 ? void 0 : user.userId);
4649
4692
  if (userId) {
4650
- _context82.n = 4;
4693
+ _context83.n = 4;
4651
4694
  break;
4652
4695
  }
4653
4696
  throw new TurnkeyError("A user ID is required to update a user name.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -4667,12 +4710,12 @@ var ClientProvider = function ClientProvider(_ref) {
4667
4710
  showTitle: false
4668
4711
  });
4669
4712
  };
4670
- _context82.p = 5;
4713
+ _context83.p = 5;
4671
4714
  if (!(!(params !== null && params !== void 0 && params.userName) && (params === null || params === void 0 ? void 0 : params.userName) !== "")) {
4672
- _context82.n = 6;
4715
+ _context83.n = 6;
4673
4716
  break;
4674
4717
  }
4675
- return _context82.a(2, withTurnkeyErrorHandling(function () {
4718
+ return _context83.a(2, withTurnkeyErrorHandling(function () {
4676
4719
  return new Promise(function (resolve, reject) {
4677
4720
  pushPage({
4678
4721
  key: "Update User Name",
@@ -4700,7 +4743,7 @@ var ClientProvider = function ClientProvider(_ref) {
4700
4743
  return logout();
4701
4744
  }));
4702
4745
  case 6:
4703
- _context82.n = 7;
4746
+ _context83.n = 7;
4704
4747
  return updateUserName(_objectSpread2({
4705
4748
  userName: params.userName,
4706
4749
  userId: user.userId,
@@ -4709,71 +4752,71 @@ var ClientProvider = function ClientProvider(_ref) {
4709
4752
  organizationId: organizationId
4710
4753
  }));
4711
4754
  case 7:
4712
- res = _context82.v;
4755
+ res = _context83.v;
4713
4756
  onSuccess();
4714
- return _context82.a(2, res);
4757
+ return _context83.a(2, res);
4715
4758
  case 8:
4716
- _context82.n = 11;
4759
+ _context83.n = 11;
4717
4760
  break;
4718
4761
  case 9:
4719
- _context82.p = 9;
4720
- _t16 = _context82.v;
4762
+ _context83.p = 9;
4763
+ _t16 = _context83.v;
4721
4764
  if (!(_t16 instanceof TurnkeyError)) {
4722
- _context82.n = 10;
4765
+ _context83.n = 10;
4723
4766
  break;
4724
4767
  }
4725
4768
  throw _t16;
4726
4769
  case 10:
4727
4770
  throw new TurnkeyError("Failed to update user name.", TurnkeyErrorCodes.UPDATE_USER_NAME_ERROR, _t16);
4728
4771
  case 11:
4729
- return _context82.a(2);
4772
+ return _context83.a(2);
4730
4773
  }
4731
- }, _callee82, null, [[5, 9]]);
4774
+ }, _callee83, null, [[5, 9]]);
4732
4775
  }));
4733
- return function (_x70) {
4734
- return _ref100.apply(this, arguments);
4776
+ return function (_x71) {
4777
+ return _ref101.apply(this, arguments);
4735
4778
  };
4736
4779
  }(), [pushPage, masterConfig, client, session, user]);
4737
4780
  var handleUpdateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
4738
- var _ref102 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee84(params) {
4739
- var _masterConfig$auth38, _masterConfig$auth38$;
4740
- var _ref103, _ref103$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t18;
4741
- return _regenerator().w(function (_context84) {
4742
- while (1) switch (_context84.p = _context84.n) {
4781
+ var _ref103 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee85(params) {
4782
+ var _masterConfig$auth39, _masterConfig$auth39$;
4783
+ var _ref104, _ref104$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t18;
4784
+ return _regenerator().w(function (_context85) {
4785
+ while (1) switch (_context85.p = _context85.n) {
4743
4786
  case 0:
4744
- _ref103 = params || {}, _ref103$successPageDu = _ref103.successPageDuration, successPageDuration = _ref103$successPageDu === void 0 ? 2000 : _ref103$successPageDu, subTitle = _ref103.subTitle, title = _ref103.title, stampWith = _ref103.stampWith;
4787
+ _ref104 = params || {}, _ref104$successPageDu = _ref104.successPageDuration, successPageDuration = _ref104$successPageDu === void 0 ? 2000 : _ref104$successPageDu, subTitle = _ref104.subTitle, title = _ref104.title, stampWith = _ref104.stampWith;
4745
4788
  if (client) {
4746
- _context84.n = 1;
4789
+ _context85.n = 1;
4747
4790
  break;
4748
4791
  }
4749
4792
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4750
4793
  case 1:
4751
4794
  if (masterConfig) {
4752
- _context84.n = 2;
4795
+ _context85.n = 2;
4753
4796
  break;
4754
4797
  }
4755
4798
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
4756
4799
  case 2:
4757
- if ((_masterConfig$auth38 = masterConfig.auth) !== null && _masterConfig$auth38 !== void 0 && (_masterConfig$auth38$ = _masterConfig$auth38.methods) !== null && _masterConfig$auth38$ !== void 0 && _masterConfig$auth38$.smsOtpAuthEnabled) {
4758
- _context84.n = 3;
4800
+ if ((_masterConfig$auth39 = masterConfig.auth) !== null && _masterConfig$auth39 !== void 0 && (_masterConfig$auth39$ = _masterConfig$auth39.methods) !== null && _masterConfig$auth39$ !== void 0 && _masterConfig$auth39$.smsOtpAuthEnabled) {
4801
+ _context85.n = 3;
4759
4802
  break;
4760
4803
  }
4761
4804
  throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
4762
4805
  case 3:
4763
- _context84.n = 4;
4806
+ _context85.n = 4;
4764
4807
  return getSession();
4765
4808
  case 4:
4766
- s = _context84.v;
4809
+ s = _context85.v;
4767
4810
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4768
4811
  if (organizationId) {
4769
- _context84.n = 5;
4812
+ _context85.n = 5;
4770
4813
  break;
4771
4814
  }
4772
4815
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
4773
4816
  case 5:
4774
4817
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
4775
4818
  if (userId) {
4776
- _context84.n = 6;
4819
+ _context85.n = 6;
4777
4820
  break;
4778
4821
  }
4779
4822
  throw new TurnkeyError("A user ID is required to update a phone number.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -4793,12 +4836,12 @@ var ClientProvider = function ClientProvider(_ref) {
4793
4836
  showTitle: false
4794
4837
  });
4795
4838
  };
4796
- _context84.p = 7;
4839
+ _context85.p = 7;
4797
4840
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
4798
- _context84.n = 8;
4841
+ _context85.n = 8;
4799
4842
  break;
4800
4843
  }
4801
- return _context84.a(2, withTurnkeyErrorHandling(function () {
4844
+ return _context85.a(2, withTurnkeyErrorHandling(function () {
4802
4845
  return new Promise(function (resolve, reject) {
4803
4846
  pushPage({
4804
4847
  key: "Update Phone Number",
@@ -4826,32 +4869,32 @@ var ClientProvider = function ClientProvider(_ref) {
4826
4869
  return logout();
4827
4870
  }));
4828
4871
  case 8:
4829
- _context84.n = 9;
4872
+ _context85.n = 9;
4830
4873
  return initOtp({
4831
4874
  otpType: OtpType.Sms,
4832
4875
  contact: params.phoneNumber
4833
4876
  });
4834
4877
  case 9:
4835
- otpId = _context84.v;
4836
- return _context84.a(2, withTurnkeyErrorHandling(function () {
4878
+ otpId = _context85.v;
4879
+ return _context85.a(2, withTurnkeyErrorHandling(function () {
4837
4880
  return new Promise(function (resolve, reject) {
4838
- var _masterConfig$auth39, _masterConfig$auth40;
4881
+ var _masterConfig$auth40, _masterConfig$auth41;
4839
4882
  pushPage({
4840
4883
  key: "Update Phone Number",
4841
4884
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2(_objectSpread2({
4842
4885
  otpType: OtpType.Sms,
4843
4886
  contact: params.phoneNumber,
4844
4887
  otpId: otpId,
4845
- otpLength: ((_masterConfig$auth39 = masterConfig.auth) === null || _masterConfig$auth39 === void 0 ? void 0 : _masterConfig$auth39.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
4846
- alphanumeric: (_masterConfig$auth40 = masterConfig.auth) === null || _masterConfig$auth40 === void 0 ? void 0 : _masterConfig$auth40.otpAlphanumeric,
4888
+ otpLength: ((_masterConfig$auth40 = masterConfig.auth) === null || _masterConfig$auth40 === void 0 ? void 0 : _masterConfig$auth40.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
4889
+ alphanumeric: (_masterConfig$auth41 = masterConfig.auth) === null || _masterConfig$auth41 === void 0 ? void 0 : _masterConfig$auth41.otpAlphanumeric,
4847
4890
  onContinue: function () {
4848
- var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee83(otpCode) {
4891
+ var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee84(otpCode) {
4849
4892
  var _yield$verifyOtp, verificationToken, res, _t17;
4850
- return _regenerator().w(function (_context83) {
4851
- while (1) switch (_context83.p = _context83.n) {
4893
+ return _regenerator().w(function (_context84) {
4894
+ while (1) switch (_context84.p = _context84.n) {
4852
4895
  case 0:
4853
- _context83.p = 0;
4854
- _context83.n = 1;
4896
+ _context84.p = 0;
4897
+ _context84.n = 1;
4855
4898
  return verifyOtp({
4856
4899
  otpId: otpId,
4857
4900
  otpCode: otpCode,
@@ -4859,9 +4902,9 @@ var ClientProvider = function ClientProvider(_ref) {
4859
4902
  otpType: OtpType.Sms
4860
4903
  });
4861
4904
  case 1:
4862
- _yield$verifyOtp = _context83.v;
4905
+ _yield$verifyOtp = _context84.v;
4863
4906
  verificationToken = _yield$verifyOtp.verificationToken;
4864
- _context83.n = 2;
4907
+ _context84.n = 2;
4865
4908
  return updateUserPhoneNumber(_objectSpread2({
4866
4909
  phoneNumber: params.phoneNumber,
4867
4910
  verificationToken: verificationToken,
@@ -4871,21 +4914,21 @@ var ClientProvider = function ClientProvider(_ref) {
4871
4914
  stampWith: stampWith
4872
4915
  }));
4873
4916
  case 2:
4874
- res = _context83.v;
4917
+ res = _context84.v;
4875
4918
  onSuccess();
4876
4919
  resolve(res);
4877
- _context83.n = 4;
4920
+ _context84.n = 4;
4878
4921
  break;
4879
4922
  case 3:
4880
- _context83.p = 3;
4881
- _t17 = _context83.v;
4923
+ _context84.p = 3;
4924
+ _t17 = _context84.v;
4882
4925
  reject(_t17);
4883
4926
  case 4:
4884
- return _context83.a(2);
4927
+ return _context84.a(2);
4885
4928
  }
4886
- }, _callee83, null, [[0, 3]]);
4929
+ }, _callee84, null, [[0, 3]]);
4887
4930
  }));
4888
- function onContinue(_x72) {
4931
+ function onContinue(_x73) {
4889
4932
  return _onContinue.apply(this, arguments);
4890
4933
  }
4891
4934
  return onContinue;
@@ -4904,54 +4947,54 @@ var ClientProvider = function ClientProvider(_ref) {
4904
4947
  return logout();
4905
4948
  }, callbacks, "Failed to update phone number"));
4906
4949
  case 10:
4907
- _context84.n = 13;
4950
+ _context85.n = 13;
4908
4951
  break;
4909
4952
  case 11:
4910
- _context84.p = 11;
4911
- _t18 = _context84.v;
4953
+ _context85.p = 11;
4954
+ _t18 = _context85.v;
4912
4955
  if (!(_t18 instanceof TurnkeyError)) {
4913
- _context84.n = 12;
4956
+ _context85.n = 12;
4914
4957
  break;
4915
4958
  }
4916
4959
  throw _t18;
4917
4960
  case 12:
4918
4961
  throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t18);
4919
4962
  case 13:
4920
- return _context84.a(2);
4963
+ return _context85.a(2);
4921
4964
  }
4922
- }, _callee84, null, [[7, 11]]);
4965
+ }, _callee85, null, [[7, 11]]);
4923
4966
  }));
4924
- return function (_x71) {
4925
- return _ref102.apply(this, arguments);
4967
+ return function (_x72) {
4968
+ return _ref103.apply(this, arguments);
4926
4969
  };
4927
4970
  }(), [pushPage, masterConfig, client, session, user]);
4928
4971
  var handleUpdateUserEmail = useCallback(/*#__PURE__*/function () {
4929
- var _ref104 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee86(params) {
4930
- var _ref105, _ref105$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t20;
4931
- return _regenerator().w(function (_context86) {
4932
- while (1) switch (_context86.p = _context86.n) {
4972
+ var _ref105 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee87(params) {
4973
+ var _ref106, _ref106$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t20;
4974
+ return _regenerator().w(function (_context87) {
4975
+ while (1) switch (_context87.p = _context87.n) {
4933
4976
  case 0:
4934
- _ref105 = params || {}, _ref105$successPageDu = _ref105.successPageDuration, successPageDuration = _ref105$successPageDu === void 0 ? 2000 : _ref105$successPageDu, subTitle = _ref105.subTitle, title = _ref105.title, stampWith = _ref105.stampWith;
4977
+ _ref106 = params || {}, _ref106$successPageDu = _ref106.successPageDuration, successPageDuration = _ref106$successPageDu === void 0 ? 2000 : _ref106$successPageDu, subTitle = _ref106.subTitle, title = _ref106.title, stampWith = _ref106.stampWith;
4935
4978
  if (client) {
4936
- _context86.n = 1;
4979
+ _context87.n = 1;
4937
4980
  break;
4938
4981
  }
4939
4982
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4940
4983
  case 1:
4941
- _context86.n = 2;
4984
+ _context87.n = 2;
4942
4985
  return getSession();
4943
4986
  case 2:
4944
- s = _context86.v;
4987
+ s = _context87.v;
4945
4988
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4946
4989
  if (organizationId) {
4947
- _context86.n = 3;
4990
+ _context87.n = 3;
4948
4991
  break;
4949
4992
  }
4950
4993
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
4951
4994
  case 3:
4952
4995
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
4953
4996
  if (userId) {
4954
- _context86.n = 4;
4997
+ _context87.n = 4;
4955
4998
  break;
4956
4999
  }
4957
5000
  throw new TurnkeyError("A user ID is required to update an email.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -4971,12 +5014,12 @@ var ClientProvider = function ClientProvider(_ref) {
4971
5014
  showTitle: false
4972
5015
  });
4973
5016
  };
4974
- _context86.p = 5;
5017
+ _context87.p = 5;
4975
5018
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
4976
- _context86.n = 6;
5019
+ _context87.n = 6;
4977
5020
  break;
4978
5021
  }
4979
- return _context86.a(2, withTurnkeyErrorHandling(function () {
5022
+ return _context87.a(2, withTurnkeyErrorHandling(function () {
4980
5023
  return new Promise(function (resolve, reject) {
4981
5024
  pushPage({
4982
5025
  key: "Update Email",
@@ -5004,32 +5047,32 @@ var ClientProvider = function ClientProvider(_ref) {
5004
5047
  return logout();
5005
5048
  }));
5006
5049
  case 6:
5007
- _context86.n = 7;
5050
+ _context87.n = 7;
5008
5051
  return initOtp({
5009
5052
  otpType: OtpType.Email,
5010
5053
  contact: params.email
5011
5054
  });
5012
5055
  case 7:
5013
- otpId = _context86.v;
5014
- return _context86.a(2, withTurnkeyErrorHandling(function () {
5056
+ otpId = _context87.v;
5057
+ return _context87.a(2, withTurnkeyErrorHandling(function () {
5015
5058
  return new Promise(function (resolve, reject) {
5016
- var _masterConfig$auth41, _masterConfig$auth42;
5059
+ var _masterConfig$auth42, _masterConfig$auth43;
5017
5060
  pushPage({
5018
5061
  key: "Update Email",
5019
5062
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2({
5020
5063
  otpType: OtpType.Email,
5021
5064
  contact: params.email,
5022
5065
  otpId: otpId,
5023
- otpLength: (masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth41 = masterConfig.auth) === null || _masterConfig$auth41 === void 0 ? void 0 : _masterConfig$auth41.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5024
- alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth42 = masterConfig.auth) === null || _masterConfig$auth42 === void 0 ? void 0 : _masterConfig$auth42.otpAlphanumeric,
5066
+ otpLength: (masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth42 = masterConfig.auth) === null || _masterConfig$auth42 === void 0 ? void 0 : _masterConfig$auth42.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5067
+ alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth43 = masterConfig.auth) === null || _masterConfig$auth43 === void 0 ? void 0 : _masterConfig$auth43.otpAlphanumeric,
5025
5068
  onContinue: function () {
5026
- var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee85(otpCode) {
5069
+ var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee86(otpCode) {
5027
5070
  var _yield$verifyOtp2, verificationToken, res, _t19;
5028
- return _regenerator().w(function (_context85) {
5029
- while (1) switch (_context85.p = _context85.n) {
5071
+ return _regenerator().w(function (_context86) {
5072
+ while (1) switch (_context86.p = _context86.n) {
5030
5073
  case 0:
5031
- _context85.p = 0;
5032
- _context85.n = 1;
5074
+ _context86.p = 0;
5075
+ _context86.n = 1;
5033
5076
  return verifyOtp({
5034
5077
  otpId: otpId,
5035
5078
  otpCode: otpCode,
@@ -5037,9 +5080,9 @@ var ClientProvider = function ClientProvider(_ref) {
5037
5080
  otpType: OtpType.Email
5038
5081
  });
5039
5082
  case 1:
5040
- _yield$verifyOtp2 = _context85.v;
5083
+ _yield$verifyOtp2 = _context86.v;
5041
5084
  verificationToken = _yield$verifyOtp2.verificationToken;
5042
- _context85.n = 2;
5085
+ _context86.n = 2;
5043
5086
  return updateUserEmail(_objectSpread2({
5044
5087
  email: params.email,
5045
5088
  verificationToken: verificationToken,
@@ -5049,21 +5092,21 @@ var ClientProvider = function ClientProvider(_ref) {
5049
5092
  stampWith: stampWith
5050
5093
  }));
5051
5094
  case 2:
5052
- res = _context85.v;
5095
+ res = _context86.v;
5053
5096
  onSuccess();
5054
5097
  resolve(res);
5055
- _context85.n = 4;
5098
+ _context86.n = 4;
5056
5099
  break;
5057
5100
  case 3:
5058
- _context85.p = 3;
5059
- _t19 = _context85.v;
5101
+ _context86.p = 3;
5102
+ _t19 = _context86.v;
5060
5103
  reject(_t19);
5061
5104
  case 4:
5062
- return _context85.a(2);
5105
+ return _context86.a(2);
5063
5106
  }
5064
- }, _callee85, null, [[0, 3]]);
5107
+ }, _callee86, null, [[0, 3]]);
5065
5108
  }));
5066
- function onContinue(_x74) {
5109
+ function onContinue(_x75) {
5067
5110
  return _onContinue2.apply(this, arguments);
5068
5111
  }
5069
5112
  return onContinue;
@@ -5080,54 +5123,54 @@ var ClientProvider = function ClientProvider(_ref) {
5080
5123
  return logout();
5081
5124
  }, callbacks, "Failed to update email"));
5082
5125
  case 8:
5083
- _context86.n = 11;
5126
+ _context87.n = 11;
5084
5127
  break;
5085
5128
  case 9:
5086
- _context86.p = 9;
5087
- _t20 = _context86.v;
5129
+ _context87.p = 9;
5130
+ _t20 = _context87.v;
5088
5131
  if (!(_t20 instanceof TurnkeyError)) {
5089
- _context86.n = 10;
5132
+ _context87.n = 10;
5090
5133
  break;
5091
5134
  }
5092
5135
  throw _t20;
5093
5136
  case 10:
5094
5137
  throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t20);
5095
5138
  case 11:
5096
- return _context86.a(2);
5139
+ return _context87.a(2);
5097
5140
  }
5098
- }, _callee86, null, [[5, 9]]);
5141
+ }, _callee87, null, [[5, 9]]);
5099
5142
  }));
5100
- return function (_x73) {
5101
- return _ref104.apply(this, arguments);
5143
+ return function (_x74) {
5144
+ return _ref105.apply(this, arguments);
5102
5145
  };
5103
5146
  }(), [pushPage, masterConfig, client, session, user]);
5104
5147
  var handleAddEmail = useCallback(/*#__PURE__*/function () {
5105
- var _ref106 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee88(params) {
5106
- var _ref107, _ref107$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t22;
5107
- return _regenerator().w(function (_context88) {
5108
- while (1) switch (_context88.p = _context88.n) {
5148
+ var _ref107 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee89(params) {
5149
+ var _ref108, _ref108$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t22;
5150
+ return _regenerator().w(function (_context89) {
5151
+ while (1) switch (_context89.p = _context89.n) {
5109
5152
  case 0:
5110
- _ref107 = params || {}, _ref107$successPageDu = _ref107.successPageDuration, successPageDuration = _ref107$successPageDu === void 0 ? 2000 : _ref107$successPageDu, subTitle = _ref107.subTitle, title = _ref107.title, stampWith = _ref107.stampWith;
5153
+ _ref108 = params || {}, _ref108$successPageDu = _ref108.successPageDuration, successPageDuration = _ref108$successPageDu === void 0 ? 2000 : _ref108$successPageDu, subTitle = _ref108.subTitle, title = _ref108.title, stampWith = _ref108.stampWith;
5111
5154
  if (client) {
5112
- _context88.n = 1;
5155
+ _context89.n = 1;
5113
5156
  break;
5114
5157
  }
5115
5158
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5116
5159
  case 1:
5117
- _context88.n = 2;
5160
+ _context89.n = 2;
5118
5161
  return getSession();
5119
5162
  case 2:
5120
- s = _context88.v;
5163
+ s = _context89.v;
5121
5164
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5122
5165
  if (organizationId) {
5123
- _context88.n = 3;
5166
+ _context89.n = 3;
5124
5167
  break;
5125
5168
  }
5126
5169
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5127
5170
  case 3:
5128
5171
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5129
5172
  if (userId) {
5130
- _context88.n = 4;
5173
+ _context89.n = 4;
5131
5174
  break;
5132
5175
  }
5133
5176
  throw new TurnkeyError("A user ID is required to add an email.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5147,12 +5190,12 @@ var ClientProvider = function ClientProvider(_ref) {
5147
5190
  showTitle: false
5148
5191
  });
5149
5192
  };
5150
- _context88.p = 5;
5193
+ _context89.p = 5;
5151
5194
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
5152
- _context88.n = 6;
5195
+ _context89.n = 6;
5153
5196
  break;
5154
5197
  }
5155
- return _context88.a(2, withTurnkeyErrorHandling(function () {
5198
+ return _context89.a(2, withTurnkeyErrorHandling(function () {
5156
5199
  return new Promise(function (resolve, reject) {
5157
5200
  pushPage({
5158
5201
  key: "Add Email",
@@ -5180,32 +5223,32 @@ var ClientProvider = function ClientProvider(_ref) {
5180
5223
  return logout();
5181
5224
  }));
5182
5225
  case 6:
5183
- _context88.n = 7;
5226
+ _context89.n = 7;
5184
5227
  return initOtp({
5185
5228
  otpType: OtpType.Email,
5186
5229
  contact: params.email
5187
5230
  });
5188
5231
  case 7:
5189
- otpId = _context88.v;
5190
- return _context88.a(2, withTurnkeyErrorHandling(function () {
5232
+ otpId = _context89.v;
5233
+ return _context89.a(2, withTurnkeyErrorHandling(function () {
5191
5234
  return new Promise(function (resolve, reject) {
5192
- var _masterConfig$auth43, _masterConfig$auth44;
5235
+ var _masterConfig$auth44, _masterConfig$auth45;
5193
5236
  pushPage({
5194
5237
  key: "Add Email",
5195
5238
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2({
5196
5239
  otpType: OtpType.Email,
5197
5240
  contact: params.email,
5198
5241
  otpId: otpId,
5199
- otpLength: (masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth43 = masterConfig.auth) === null || _masterConfig$auth43 === void 0 ? void 0 : _masterConfig$auth43.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5200
- alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth44 = masterConfig.auth) === null || _masterConfig$auth44 === void 0 ? void 0 : _masterConfig$auth44.otpAlphanumeric,
5242
+ otpLength: (masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth44 = masterConfig.auth) === null || _masterConfig$auth44 === void 0 ? void 0 : _masterConfig$auth44.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5243
+ alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth45 = masterConfig.auth) === null || _masterConfig$auth45 === void 0 ? void 0 : _masterConfig$auth45.otpAlphanumeric,
5201
5244
  onContinue: function () {
5202
- var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee87(otpCode) {
5245
+ var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee88(otpCode) {
5203
5246
  var _yield$verifyOtp3, verificationToken, res, _t21;
5204
- return _regenerator().w(function (_context87) {
5205
- while (1) switch (_context87.p = _context87.n) {
5247
+ return _regenerator().w(function (_context88) {
5248
+ while (1) switch (_context88.p = _context88.n) {
5206
5249
  case 0:
5207
- _context87.p = 0;
5208
- _context87.n = 1;
5250
+ _context88.p = 0;
5251
+ _context88.n = 1;
5209
5252
  return verifyOtp({
5210
5253
  otpId: otpId,
5211
5254
  otpCode: otpCode,
@@ -5213,9 +5256,9 @@ var ClientProvider = function ClientProvider(_ref) {
5213
5256
  otpType: OtpType.Email
5214
5257
  });
5215
5258
  case 1:
5216
- _yield$verifyOtp3 = _context87.v;
5259
+ _yield$verifyOtp3 = _context88.v;
5217
5260
  verificationToken = _yield$verifyOtp3.verificationToken;
5218
- _context87.n = 2;
5261
+ _context88.n = 2;
5219
5262
  return updateUserEmail({
5220
5263
  email: params.email,
5221
5264
  verificationToken: verificationToken,
@@ -5224,21 +5267,21 @@ var ClientProvider = function ClientProvider(_ref) {
5224
5267
  stampWith: stampWith
5225
5268
  });
5226
5269
  case 2:
5227
- res = _context87.v;
5270
+ res = _context88.v;
5228
5271
  onSuccess();
5229
5272
  resolve(res);
5230
- _context87.n = 4;
5273
+ _context88.n = 4;
5231
5274
  break;
5232
5275
  case 3:
5233
- _context87.p = 3;
5234
- _t21 = _context87.v;
5276
+ _context88.p = 3;
5277
+ _t21 = _context88.v;
5235
5278
  reject(_t21);
5236
5279
  case 4:
5237
- return _context87.a(2);
5280
+ return _context88.a(2);
5238
5281
  }
5239
- }, _callee87, null, [[0, 3]]);
5282
+ }, _callee88, null, [[0, 3]]);
5240
5283
  }));
5241
- function onContinue(_x76) {
5284
+ function onContinue(_x77) {
5242
5285
  return _onContinue3.apply(this, arguments);
5243
5286
  }
5244
5287
  return onContinue;
@@ -5255,67 +5298,67 @@ var ClientProvider = function ClientProvider(_ref) {
5255
5298
  return logout();
5256
5299
  }, callbacks, "Failed to add email"));
5257
5300
  case 8:
5258
- _context88.n = 11;
5301
+ _context89.n = 11;
5259
5302
  break;
5260
5303
  case 9:
5261
- _context88.p = 9;
5262
- _t22 = _context88.v;
5304
+ _context89.p = 9;
5305
+ _t22 = _context89.v;
5263
5306
  if (!(_t22 instanceof TurnkeyError)) {
5264
- _context88.n = 10;
5307
+ _context89.n = 10;
5265
5308
  break;
5266
5309
  }
5267
5310
  throw _t22;
5268
5311
  case 10:
5269
5312
  throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t22);
5270
5313
  case 11:
5271
- return _context88.a(2);
5314
+ return _context89.a(2);
5272
5315
  }
5273
- }, _callee88, null, [[5, 9]]);
5316
+ }, _callee89, null, [[5, 9]]);
5274
5317
  }));
5275
- return function (_x75) {
5276
- return _ref106.apply(this, arguments);
5318
+ return function (_x76) {
5319
+ return _ref107.apply(this, arguments);
5277
5320
  };
5278
5321
  }(), [pushPage, client, session, user]);
5279
5322
  var handleAddPhoneNumber = useCallback(/*#__PURE__*/function () {
5280
- var _ref108 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee90(params) {
5281
- var _masterConfig$auth45, _masterConfig$auth45$;
5282
- var _ref109, _ref109$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t24;
5283
- return _regenerator().w(function (_context90) {
5284
- while (1) switch (_context90.p = _context90.n) {
5323
+ var _ref109 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(params) {
5324
+ var _masterConfig$auth46, _masterConfig$auth46$;
5325
+ var _ref110, _ref110$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t24;
5326
+ return _regenerator().w(function (_context91) {
5327
+ while (1) switch (_context91.p = _context91.n) {
5285
5328
  case 0:
5286
- _ref109 = params || {}, _ref109$successPageDu = _ref109.successPageDuration, successPageDuration = _ref109$successPageDu === void 0 ? 2000 : _ref109$successPageDu, subTitle = _ref109.subTitle, title = _ref109.title, stampWith = _ref109.stampWith;
5329
+ _ref110 = params || {}, _ref110$successPageDu = _ref110.successPageDuration, successPageDuration = _ref110$successPageDu === void 0 ? 2000 : _ref110$successPageDu, subTitle = _ref110.subTitle, title = _ref110.title, stampWith = _ref110.stampWith;
5287
5330
  if (client) {
5288
- _context90.n = 1;
5331
+ _context91.n = 1;
5289
5332
  break;
5290
5333
  }
5291
5334
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5292
5335
  case 1:
5293
5336
  if (masterConfig) {
5294
- _context90.n = 2;
5337
+ _context91.n = 2;
5295
5338
  break;
5296
5339
  }
5297
5340
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
5298
5341
  case 2:
5299
- if ((_masterConfig$auth45 = masterConfig.auth) !== null && _masterConfig$auth45 !== void 0 && (_masterConfig$auth45$ = _masterConfig$auth45.methods) !== null && _masterConfig$auth45$ !== void 0 && _masterConfig$auth45$.smsOtpAuthEnabled) {
5300
- _context90.n = 3;
5342
+ if ((_masterConfig$auth46 = masterConfig.auth) !== null && _masterConfig$auth46 !== void 0 && (_masterConfig$auth46$ = _masterConfig$auth46.methods) !== null && _masterConfig$auth46$ !== void 0 && _masterConfig$auth46$.smsOtpAuthEnabled) {
5343
+ _context91.n = 3;
5301
5344
  break;
5302
5345
  }
5303
5346
  throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
5304
5347
  case 3:
5305
- _context90.n = 4;
5348
+ _context91.n = 4;
5306
5349
  return getSession();
5307
5350
  case 4:
5308
- s = _context90.v;
5351
+ s = _context91.v;
5309
5352
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5310
5353
  if (organizationId) {
5311
- _context90.n = 5;
5354
+ _context91.n = 5;
5312
5355
  break;
5313
5356
  }
5314
5357
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5315
5358
  case 5:
5316
5359
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5317
5360
  if (userId) {
5318
- _context90.n = 6;
5361
+ _context91.n = 6;
5319
5362
  break;
5320
5363
  }
5321
5364
  throw new TurnkeyError("A user ID is required to add a phone number.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5335,12 +5378,12 @@ var ClientProvider = function ClientProvider(_ref) {
5335
5378
  showTitle: false
5336
5379
  });
5337
5380
  };
5338
- _context90.p = 7;
5381
+ _context91.p = 7;
5339
5382
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
5340
- _context90.n = 8;
5383
+ _context91.n = 8;
5341
5384
  break;
5342
5385
  }
5343
- return _context90.a(2, withTurnkeyErrorHandling(function () {
5386
+ return _context91.a(2, withTurnkeyErrorHandling(function () {
5344
5387
  return new Promise(function (resolve, reject) {
5345
5388
  pushPage({
5346
5389
  key: "Add Phone Number",
@@ -5368,32 +5411,32 @@ var ClientProvider = function ClientProvider(_ref) {
5368
5411
  return logout();
5369
5412
  }, callbacks, "Failed to add phone number"));
5370
5413
  case 8:
5371
- _context90.n = 9;
5414
+ _context91.n = 9;
5372
5415
  return initOtp({
5373
5416
  otpType: OtpType.Sms,
5374
5417
  contact: params.phoneNumber
5375
5418
  });
5376
5419
  case 9:
5377
- otpId = _context90.v;
5378
- return _context90.a(2, withTurnkeyErrorHandling(function () {
5420
+ otpId = _context91.v;
5421
+ return _context91.a(2, withTurnkeyErrorHandling(function () {
5379
5422
  return new Promise(function (resolve, reject) {
5380
- var _masterConfig$auth46, _masterConfig$auth47;
5423
+ var _masterConfig$auth47, _masterConfig$auth48;
5381
5424
  pushPage({
5382
5425
  key: "Add Phone Number",
5383
5426
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2(_objectSpread2({
5384
5427
  otpType: OtpType.Sms,
5385
5428
  contact: params.phoneNumber,
5386
5429
  otpId: otpId,
5387
- otpLength: ((_masterConfig$auth46 = masterConfig.auth) === null || _masterConfig$auth46 === void 0 ? void 0 : _masterConfig$auth46.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5388
- alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth47 = masterConfig.auth) === null || _masterConfig$auth47 === void 0 ? void 0 : _masterConfig$auth47.otpAlphanumeric,
5430
+ otpLength: ((_masterConfig$auth47 = masterConfig.auth) === null || _masterConfig$auth47 === void 0 ? void 0 : _masterConfig$auth47.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5431
+ alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth48 = masterConfig.auth) === null || _masterConfig$auth48 === void 0 ? void 0 : _masterConfig$auth48.otpAlphanumeric,
5389
5432
  onContinue: function () {
5390
- var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee89(otpCode) {
5433
+ var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee90(otpCode) {
5391
5434
  var _yield$verifyOtp4, verificationToken, res, _t23;
5392
- return _regenerator().w(function (_context89) {
5393
- while (1) switch (_context89.p = _context89.n) {
5435
+ return _regenerator().w(function (_context90) {
5436
+ while (1) switch (_context90.p = _context90.n) {
5394
5437
  case 0:
5395
- _context89.p = 0;
5396
- _context89.n = 1;
5438
+ _context90.p = 0;
5439
+ _context90.n = 1;
5397
5440
  return verifyOtp({
5398
5441
  otpId: otpId,
5399
5442
  otpCode: otpCode,
@@ -5401,9 +5444,9 @@ var ClientProvider = function ClientProvider(_ref) {
5401
5444
  otpType: OtpType.Sms
5402
5445
  });
5403
5446
  case 1:
5404
- _yield$verifyOtp4 = _context89.v;
5447
+ _yield$verifyOtp4 = _context90.v;
5405
5448
  verificationToken = _yield$verifyOtp4.verificationToken;
5406
- _context89.n = 2;
5449
+ _context90.n = 2;
5407
5450
  return updateUserPhoneNumber({
5408
5451
  phoneNumber: params.phoneNumber,
5409
5452
  verificationToken: verificationToken,
@@ -5412,21 +5455,21 @@ var ClientProvider = function ClientProvider(_ref) {
5412
5455
  stampWith: stampWith
5413
5456
  });
5414
5457
  case 2:
5415
- res = _context89.v;
5458
+ res = _context90.v;
5416
5459
  onSuccess();
5417
5460
  resolve(res);
5418
- _context89.n = 4;
5461
+ _context90.n = 4;
5419
5462
  break;
5420
5463
  case 3:
5421
- _context89.p = 3;
5422
- _t23 = _context89.v;
5464
+ _context90.p = 3;
5465
+ _t23 = _context90.v;
5423
5466
  reject(_t23);
5424
5467
  case 4:
5425
- return _context89.a(2);
5468
+ return _context90.a(2);
5426
5469
  }
5427
- }, _callee89, null, [[0, 3]]);
5470
+ }, _callee90, null, [[0, 3]]);
5428
5471
  }));
5429
- function onContinue(_x78) {
5472
+ function onContinue(_x79) {
5430
5473
  return _onContinue4.apply(this, arguments);
5431
5474
  }
5432
5475
  return onContinue;
@@ -5445,52 +5488,52 @@ var ClientProvider = function ClientProvider(_ref) {
5445
5488
  return logout();
5446
5489
  }, callbacks, "Failed to add phone number"));
5447
5490
  case 10:
5448
- _context90.n = 13;
5491
+ _context91.n = 13;
5449
5492
  break;
5450
5493
  case 11:
5451
- _context90.p = 11;
5452
- _t24 = _context90.v;
5494
+ _context91.p = 11;
5495
+ _t24 = _context91.v;
5453
5496
  if (!(_t24 instanceof TurnkeyError)) {
5454
- _context90.n = 12;
5497
+ _context91.n = 12;
5455
5498
  break;
5456
5499
  }
5457
5500
  throw _t24;
5458
5501
  case 12:
5459
5502
  throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t24);
5460
5503
  case 13:
5461
- return _context90.a(2);
5504
+ return _context91.a(2);
5462
5505
  }
5463
- }, _callee90, null, [[7, 11]]);
5506
+ }, _callee91, null, [[7, 11]]);
5464
5507
  }));
5465
- return function (_x77) {
5466
- return _ref108.apply(this, arguments);
5508
+ return function (_x78) {
5509
+ return _ref109.apply(this, arguments);
5467
5510
  };
5468
5511
  }(), [pushPage, masterConfig, client, session, user]);
5469
5512
  var handleRemovePasskey = useCallback(/*#__PURE__*/function () {
5470
- var _ref110 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(params) {
5513
+ var _ref111 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee92(params) {
5471
5514
  var authenticatorId, _params$successPageDu2, successPageDuration, subTitle, title, stampWith, userId, s, organizationId;
5472
- return _regenerator().w(function (_context91) {
5473
- while (1) switch (_context91.n) {
5515
+ return _regenerator().w(function (_context92) {
5516
+ while (1) switch (_context92.n) {
5474
5517
  case 0:
5475
5518
  authenticatorId = params.authenticatorId, _params$successPageDu2 = params.successPageDuration, successPageDuration = _params$successPageDu2 === void 0 ? 2000 : _params$successPageDu2, subTitle = params.subTitle, title = params.title, stampWith = params.stampWith, userId = params.userId;
5476
5519
  if (client) {
5477
- _context91.n = 1;
5520
+ _context92.n = 1;
5478
5521
  break;
5479
5522
  }
5480
5523
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5481
5524
  case 1:
5482
- _context91.n = 2;
5525
+ _context92.n = 2;
5483
5526
  return getSession();
5484
5527
  case 2:
5485
- s = _context91.v;
5528
+ s = _context92.v;
5486
5529
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5487
5530
  if (organizationId) {
5488
- _context91.n = 3;
5531
+ _context92.n = 3;
5489
5532
  break;
5490
5533
  }
5491
5534
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5492
5535
  case 3:
5493
- return _context91.a(2, withTurnkeyErrorHandling(function () {
5536
+ return _context92.a(2, withTurnkeyErrorHandling(function () {
5494
5537
  return new Promise(function (resolve, reject) {
5495
5538
  pushPage({
5496
5539
  key: "Remove Passkey",
@@ -5521,44 +5564,44 @@ var ClientProvider = function ClientProvider(_ref) {
5521
5564
  return logout();
5522
5565
  }, callbacks, "Failed to remove passkey"));
5523
5566
  }
5524
- }, _callee91);
5567
+ }, _callee92);
5525
5568
  }));
5526
- return function (_x79) {
5527
- return _ref110.apply(this, arguments);
5569
+ return function (_x80) {
5570
+ return _ref111.apply(this, arguments);
5528
5571
  };
5529
5572
  }(), [pushPage, masterConfig, client, session, user]);
5530
5573
  var handleAddPasskey = useCallback(/*#__PURE__*/function () {
5531
- var _ref111 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee92(params) {
5532
- var _ref112, name, displayName, _ref112$successPageDu, successPageDuration, stampWith, s, organizationId, userId, resPromise, _t25;
5533
- return _regenerator().w(function (_context92) {
5534
- while (1) switch (_context92.p = _context92.n) {
5574
+ var _ref112 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(params) {
5575
+ var _ref113, name, displayName, _ref113$successPageDu, successPageDuration, stampWith, s, organizationId, userId, resPromise, _t25;
5576
+ return _regenerator().w(function (_context93) {
5577
+ while (1) switch (_context93.p = _context93.n) {
5535
5578
  case 0:
5536
- _ref112 = params || {}, name = _ref112.name, displayName = _ref112.displayName, _ref112$successPageDu = _ref112.successPageDuration, successPageDuration = _ref112$successPageDu === void 0 ? 2000 : _ref112$successPageDu, stampWith = _ref112.stampWith;
5579
+ _ref113 = params || {}, name = _ref113.name, displayName = _ref113.displayName, _ref113$successPageDu = _ref113.successPageDuration, successPageDuration = _ref113$successPageDu === void 0 ? 2000 : _ref113$successPageDu, stampWith = _ref113.stampWith;
5537
5580
  if (client) {
5538
- _context92.n = 1;
5581
+ _context93.n = 1;
5539
5582
  break;
5540
5583
  }
5541
5584
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5542
5585
  case 1:
5543
- _context92.n = 2;
5586
+ _context93.n = 2;
5544
5587
  return getSession();
5545
5588
  case 2:
5546
- s = _context92.v;
5589
+ s = _context93.v;
5547
5590
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5548
5591
  if (organizationId) {
5549
- _context92.n = 3;
5592
+ _context93.n = 3;
5550
5593
  break;
5551
5594
  }
5552
5595
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5553
5596
  case 3:
5554
5597
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5555
5598
  if (userId) {
5556
- _context92.n = 4;
5599
+ _context93.n = 4;
5557
5600
  break;
5558
5601
  }
5559
5602
  throw new TurnkeyError("A user ID or a valid session is required to add a passkey.", TurnkeyErrorCodes.INVALID_REQUEST);
5560
5603
  case 4:
5561
- _context92.p = 4;
5604
+ _context93.p = 4;
5562
5605
  resPromise = addPasskey(_objectSpread2(_objectSpread2(_objectSpread2({}, name && {
5563
5606
  name: name
5564
5607
  }), displayName && {
@@ -5583,55 +5626,55 @@ var ClientProvider = function ClientProvider(_ref) {
5583
5626
  showTitle: false
5584
5627
  });
5585
5628
  });
5586
- _context92.n = 5;
5629
+ _context93.n = 5;
5587
5630
  return resPromise;
5588
5631
  case 5:
5589
- return _context92.a(2, _context92.v);
5632
+ return _context93.a(2, _context93.v);
5590
5633
  case 6:
5591
- _context92.p = 6;
5592
- _t25 = _context92.v;
5634
+ _context93.p = 6;
5635
+ _t25 = _context93.v;
5593
5636
  if (!(_t25 instanceof TurnkeyError)) {
5594
- _context92.n = 7;
5637
+ _context93.n = 7;
5595
5638
  break;
5596
5639
  }
5597
5640
  throw _t25;
5598
5641
  case 7:
5599
5642
  throw new TurnkeyError("Failed to add passkey in handler.", TurnkeyErrorCodes.ADD_PASSKEY_ERROR, _t25);
5600
5643
  case 8:
5601
- return _context92.a(2);
5644
+ return _context93.a(2);
5602
5645
  }
5603
- }, _callee92, null, [[4, 6]]);
5646
+ }, _callee93, null, [[4, 6]]);
5604
5647
  }));
5605
- return function (_x80) {
5606
- return _ref111.apply(this, arguments);
5648
+ return function (_x81) {
5649
+ return _ref112.apply(this, arguments);
5607
5650
  };
5608
5651
  }(), [pushPage, masterConfig, client, session, user]);
5609
5652
  var handleRemoveOauthProvider = useCallback(/*#__PURE__*/function () {
5610
- var _ref113 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(params) {
5653
+ var _ref114 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(params) {
5611
5654
  var providerId, _params$successPageDu3, successPageDuration, subTitle, title, stampWith, s, organizationId, _t26;
5612
- return _regenerator().w(function (_context93) {
5613
- while (1) switch (_context93.p = _context93.n) {
5655
+ return _regenerator().w(function (_context94) {
5656
+ while (1) switch (_context94.p = _context94.n) {
5614
5657
  case 0:
5615
5658
  providerId = params.providerId, _params$successPageDu3 = params.successPageDuration, successPageDuration = _params$successPageDu3 === void 0 ? 2000 : _params$successPageDu3, subTitle = params.subTitle, title = params.title, stampWith = params.stampWith;
5616
5659
  if (client) {
5617
- _context93.n = 1;
5660
+ _context94.n = 1;
5618
5661
  break;
5619
5662
  }
5620
5663
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5621
5664
  case 1:
5622
- _context93.n = 2;
5665
+ _context94.n = 2;
5623
5666
  return getSession();
5624
5667
  case 2:
5625
- s = _context93.v;
5668
+ s = _context94.v;
5626
5669
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5627
5670
  if (organizationId) {
5628
- _context93.n = 3;
5671
+ _context94.n = 3;
5629
5672
  break;
5630
5673
  }
5631
5674
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5632
5675
  case 3:
5633
- _context93.p = 3;
5634
- return _context93.a(2, new Promise(function (resolve, reject) {
5676
+ _context94.p = 3;
5677
+ return _context94.a(2, new Promise(function (resolve, reject) {
5635
5678
  pushPage({
5636
5679
  key: "Remove OAuth Provider",
5637
5680
  content: jsx(RemoveOAuthProvider, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5659,68 +5702,68 @@ var ClientProvider = function ClientProvider(_ref) {
5659
5702
  });
5660
5703
  }));
5661
5704
  case 4:
5662
- _context93.p = 4;
5663
- _t26 = _context93.v;
5705
+ _context94.p = 4;
5706
+ _t26 = _context94.v;
5664
5707
  if (!(_t26 instanceof TurnkeyError)) {
5665
- _context93.n = 5;
5708
+ _context94.n = 5;
5666
5709
  break;
5667
5710
  }
5668
5711
  throw _t26;
5669
5712
  case 5:
5670
5713
  throw new TurnkeyError("Failed to remove OAuth provider in handler.", TurnkeyErrorCodes.REMOVE_OAUTH_PROVIDER_ERROR, _t26);
5671
5714
  case 6:
5672
- return _context93.a(2);
5715
+ return _context94.a(2);
5673
5716
  }
5674
- }, _callee93, null, [[3, 4]]);
5717
+ }, _callee94, null, [[3, 4]]);
5675
5718
  }));
5676
- return function (_x81) {
5677
- return _ref113.apply(this, arguments);
5719
+ return function (_x82) {
5720
+ return _ref114.apply(this, arguments);
5678
5721
  };
5679
5722
  }(), [pushPage, masterConfig, client, session, user]);
5680
5723
  var handleAddOauthProvider = useCallback(/*#__PURE__*/function () {
5681
- var _ref114 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(params) {
5724
+ var _ref115 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(params) {
5682
5725
  var providerName, stampWith, _params$successPageDu4, successPageDuration, s, organizationId, userId;
5683
- return _regenerator().w(function (_context96) {
5684
- while (1) switch (_context96.n) {
5726
+ return _regenerator().w(function (_context97) {
5727
+ while (1) switch (_context97.n) {
5685
5728
  case 0:
5686
5729
  if (client) {
5687
- _context96.n = 1;
5730
+ _context97.n = 1;
5688
5731
  break;
5689
5732
  }
5690
5733
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5691
5734
  case 1:
5692
5735
  providerName = params.providerName, stampWith = params.stampWith, _params$successPageDu4 = params.successPageDuration, successPageDuration = _params$successPageDu4 === void 0 ? 2000 : _params$successPageDu4;
5693
- _context96.n = 2;
5736
+ _context97.n = 2;
5694
5737
  return getSession();
5695
5738
  case 2:
5696
- s = _context96.v;
5739
+ s = _context97.v;
5697
5740
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5698
5741
  if (organizationId) {
5699
- _context96.n = 3;
5742
+ _context97.n = 3;
5700
5743
  break;
5701
5744
  }
5702
5745
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5703
5746
  case 3:
5704
5747
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5705
5748
  if (userId) {
5706
- _context96.n = 4;
5749
+ _context97.n = 4;
5707
5750
  break;
5708
5751
  }
5709
5752
  throw new TurnkeyError("A user ID is required to add an OAuth provider.", TurnkeyErrorCodes.INVALID_REQUEST);
5710
5753
  case 4:
5711
- return _context96.a(2, new Promise(/*#__PURE__*/function () {
5712
- var _ref115 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(resolve, reject) {
5754
+ return _context97.a(2, new Promise(/*#__PURE__*/function () {
5755
+ var _ref116 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(resolve, reject) {
5713
5756
  var onOauthSuccess, _t27, _t28;
5714
- return _regenerator().w(function (_context95) {
5715
- while (1) switch (_context95.p = _context95.n) {
5757
+ return _regenerator().w(function (_context96) {
5758
+ while (1) switch (_context96.p = _context96.n) {
5716
5759
  case 0:
5717
- _context95.p = 0;
5760
+ _context96.p = 0;
5718
5761
  onOauthSuccess = /*#__PURE__*/function () {
5719
- var _ref116 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(params) {
5720
- return _regenerator().w(function (_context94) {
5721
- while (1) switch (_context94.n) {
5762
+ var _ref117 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(params) {
5763
+ return _regenerator().w(function (_context95) {
5764
+ while (1) switch (_context95.n) {
5722
5765
  case 0:
5723
- _context94.n = 1;
5766
+ _context95.n = 1;
5724
5767
  return addOauthProvider({
5725
5768
  providerName: params.providerName,
5726
5769
  oidcToken: params.oidcToken,
@@ -5743,107 +5786,107 @@ var ClientProvider = function ClientProvider(_ref) {
5743
5786
  showTitle: false
5744
5787
  });
5745
5788
  case 2:
5746
- return _context94.a(2);
5789
+ return _context95.a(2);
5747
5790
  }
5748
- }, _callee94);
5791
+ }, _callee95);
5749
5792
  }));
5750
- return function onOauthSuccess(_x85) {
5751
- return _ref116.apply(this, arguments);
5793
+ return function onOauthSuccess(_x86) {
5794
+ return _ref117.apply(this, arguments);
5752
5795
  };
5753
5796
  }();
5754
5797
  _t27 = providerName;
5755
- _context95.n = _t27 === OAuthProviders.DISCORD ? 1 : _t27 === OAuthProviders.X ? 3 : _t27 === OAuthProviders.GOOGLE ? 5 : _t27 === OAuthProviders.APPLE ? 7 : _t27 === OAuthProviders.FACEBOOK ? 9 : 11;
5798
+ _context96.n = _t27 === OAuthProviders.DISCORD ? 1 : _t27 === OAuthProviders.X ? 3 : _t27 === OAuthProviders.GOOGLE ? 5 : _t27 === OAuthProviders.APPLE ? 7 : _t27 === OAuthProviders.FACEBOOK ? 9 : 11;
5756
5799
  break;
5757
5800
  case 1:
5758
- _context95.n = 2;
5801
+ _context96.n = 2;
5759
5802
  return handleDiscordOauth({
5760
5803
  openInPage: false,
5761
5804
  onOauthSuccess: onOauthSuccess
5762
5805
  });
5763
5806
  case 2:
5764
- return _context95.a(2, _context95.v);
5807
+ return _context96.a(2, _context96.v);
5765
5808
  case 3:
5766
- _context95.n = 4;
5809
+ _context96.n = 4;
5767
5810
  return handleXOauth({
5768
5811
  openInPage: false,
5769
5812
  onOauthSuccess: onOauthSuccess
5770
5813
  });
5771
5814
  case 4:
5772
- return _context95.a(2, _context95.v);
5815
+ return _context96.a(2, _context96.v);
5773
5816
  case 5:
5774
- _context95.n = 6;
5817
+ _context96.n = 6;
5775
5818
  return handleGoogleOauth({
5776
5819
  openInPage: false,
5777
5820
  onOauthSuccess: onOauthSuccess
5778
5821
  });
5779
5822
  case 6:
5780
- return _context95.a(2, _context95.v);
5823
+ return _context96.a(2, _context96.v);
5781
5824
  case 7:
5782
- _context95.n = 8;
5825
+ _context96.n = 8;
5783
5826
  return handleAppleOauth({
5784
5827
  openInPage: false,
5785
5828
  onOauthSuccess: onOauthSuccess
5786
5829
  });
5787
5830
  case 8:
5788
- return _context95.a(2, _context95.v);
5831
+ return _context96.a(2, _context96.v);
5789
5832
  case 9:
5790
- _context95.n = 10;
5833
+ _context96.n = 10;
5791
5834
  return handleFacebookOauth({
5792
5835
  openInPage: false,
5793
5836
  onOauthSuccess: onOauthSuccess
5794
5837
  });
5795
5838
  case 10:
5796
- return _context95.a(2, _context95.v);
5839
+ return _context96.a(2, _context96.v);
5797
5840
  case 11:
5798
5841
  throw new TurnkeyError("Unsupported OAuth provider: ".concat(providerName), TurnkeyErrorCodes.NOT_FOUND);
5799
5842
  case 12:
5800
- _context95.n = 14;
5843
+ _context96.n = 14;
5801
5844
  break;
5802
5845
  case 13:
5803
- _context95.p = 13;
5804
- _t28 = _context95.v;
5846
+ _context96.p = 13;
5847
+ _t28 = _context96.v;
5805
5848
  reject(_t28);
5806
5849
  case 14:
5807
- return _context95.a(2);
5850
+ return _context96.a(2);
5808
5851
  }
5809
- }, _callee95, null, [[0, 13]]);
5852
+ }, _callee96, null, [[0, 13]]);
5810
5853
  }));
5811
- return function (_x83, _x84) {
5812
- return _ref115.apply(this, arguments);
5854
+ return function (_x84, _x85) {
5855
+ return _ref116.apply(this, arguments);
5813
5856
  };
5814
5857
  }()));
5815
5858
  }
5816
- }, _callee96);
5859
+ }, _callee97);
5817
5860
  }));
5818
- return function (_x82) {
5819
- return _ref114.apply(this, arguments);
5861
+ return function (_x83) {
5862
+ return _ref115.apply(this, arguments);
5820
5863
  };
5821
5864
  }(), [pushPage, masterConfig, client, session, user]);
5822
5865
  var handleConnectExternalWallet = useCallback(/*#__PURE__*/function () {
5823
- var _ref117 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(params) {
5866
+ var _ref118 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(params) {
5824
5867
  var _masterConfig$walletC4, _masterConfig$walletC5;
5825
- var _ref118, _ref118$successPageDu, successPageDuration, providers;
5826
- return _regenerator().w(function (_context97) {
5827
- while (1) switch (_context97.n) {
5868
+ var _ref119, _ref119$successPageDu, successPageDuration, providers;
5869
+ return _regenerator().w(function (_context98) {
5870
+ while (1) switch (_context98.n) {
5828
5871
  case 0:
5829
- _ref118 = params || {}, _ref118$successPageDu = _ref118.successPageDuration, successPageDuration = _ref118$successPageDu === void 0 ? 2000 : _ref118$successPageDu;
5872
+ _ref119 = params || {}, _ref119$successPageDu = _ref119.successPageDuration, successPageDuration = _ref119$successPageDu === void 0 ? 2000 : _ref119$successPageDu;
5830
5873
  if (client) {
5831
- _context97.n = 1;
5874
+ _context98.n = 1;
5832
5875
  break;
5833
5876
  }
5834
5877
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5835
5878
  case 1:
5836
5879
  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) {
5837
- _context97.n = 2;
5880
+ _context98.n = 2;
5838
5881
  break;
5839
5882
  }
5840
5883
  throw new TurnkeyError("Wallet connecting is not enabled.", TurnkeyErrorCodes.FEATURE_NOT_ENABLED);
5841
5884
  case 2:
5842
- _context97.n = 3;
5885
+ _context98.n = 3;
5843
5886
  return fetchWalletProviders();
5844
5887
  case 3:
5845
- providers = _context97.v;
5846
- return _context97.a(2, new Promise(function (resolve, reject) {
5888
+ providers = _context98.v;
5889
+ return _context98.a(2, new Promise(function (resolve, reject) {
5847
5890
  pushPage({
5848
5891
  key: "Connect wallet",
5849
5892
  content: jsx(ConnectWalletModal, {
@@ -5865,32 +5908,32 @@ var ClientProvider = function ClientProvider(_ref) {
5865
5908
  });
5866
5909
  }));
5867
5910
  }
5868
- }, _callee97);
5911
+ }, _callee98);
5869
5912
  }));
5870
- return function (_x86) {
5871
- return _ref117.apply(this, arguments);
5913
+ return function (_x87) {
5914
+ return _ref118.apply(this, arguments);
5872
5915
  };
5873
5916
  }(), [pushPage, masterConfig, client, session, user]);
5874
5917
  var handleRemoveUserEmail = useCallback(/*#__PURE__*/function () {
5875
- var _ref119 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(params) {
5876
- var _ref120, _ref120$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t29;
5877
- return _regenerator().w(function (_context98) {
5878
- while (1) switch (_context98.p = _context98.n) {
5918
+ var _ref120 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99(params) {
5919
+ var _ref121, _ref121$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t29;
5920
+ return _regenerator().w(function (_context99) {
5921
+ while (1) switch (_context99.p = _context99.n) {
5879
5922
  case 0:
5880
- _ref120 = params || {}, _ref120$successPageDu = _ref120.successPageDuration, successPageDuration = _ref120$successPageDu === void 0 ? 2000 : _ref120$successPageDu, stampWith = _ref120.stampWith, userId = _ref120.userId;
5881
- _context98.n = 1;
5923
+ _ref121 = params || {}, _ref121$successPageDu = _ref121.successPageDuration, successPageDuration = _ref121$successPageDu === void 0 ? 2000 : _ref121$successPageDu, stampWith = _ref121.stampWith, userId = _ref121.userId;
5924
+ _context99.n = 1;
5882
5925
  return getSession();
5883
5926
  case 1:
5884
- s = _context98.v;
5927
+ s = _context99.v;
5885
5928
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5886
5929
  if (organizationId) {
5887
- _context98.n = 2;
5930
+ _context99.n = 2;
5888
5931
  break;
5889
5932
  }
5890
5933
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5891
5934
  case 2:
5892
- _context98.p = 2;
5893
- return _context98.a(2, new Promise(function (resolve, reject) {
5935
+ _context99.p = 2;
5936
+ return _context99.a(2, new Promise(function (resolve, reject) {
5894
5937
  pushPage({
5895
5938
  key: "Remove Email",
5896
5939
  content: jsx(RemoveEmail, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5917,44 +5960,44 @@ var ClientProvider = function ClientProvider(_ref) {
5917
5960
  });
5918
5961
  }));
5919
5962
  case 3:
5920
- _context98.p = 3;
5921
- _t29 = _context98.v;
5963
+ _context99.p = 3;
5964
+ _t29 = _context99.v;
5922
5965
  if (!(_t29 instanceof TurnkeyError)) {
5923
- _context98.n = 4;
5966
+ _context99.n = 4;
5924
5967
  break;
5925
5968
  }
5926
5969
  throw _t29;
5927
5970
  case 4:
5928
5971
  throw new TurnkeyError("Failed to remove user email.", TurnkeyErrorCodes.UPDATE_USER_EMAIL_ERROR, _t29);
5929
5972
  case 5:
5930
- return _context98.a(2);
5973
+ return _context99.a(2);
5931
5974
  }
5932
- }, _callee98, null, [[2, 3]]);
5975
+ }, _callee99, null, [[2, 3]]);
5933
5976
  }));
5934
- return function (_x87) {
5935
- return _ref119.apply(this, arguments);
5977
+ return function (_x88) {
5978
+ return _ref120.apply(this, arguments);
5936
5979
  };
5937
5980
  }(), [pushPage, masterConfig, client, session, user]);
5938
5981
  var handleRemoveUserPhoneNumber = useCallback(/*#__PURE__*/function () {
5939
- var _ref121 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99(params) {
5940
- var _ref122, _ref122$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t30;
5941
- return _regenerator().w(function (_context99) {
5942
- while (1) switch (_context99.p = _context99.n) {
5982
+ var _ref122 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100(params) {
5983
+ var _ref123, _ref123$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t30;
5984
+ return _regenerator().w(function (_context100) {
5985
+ while (1) switch (_context100.p = _context100.n) {
5943
5986
  case 0:
5944
- _ref122 = params || {}, _ref122$successPageDu = _ref122.successPageDuration, successPageDuration = _ref122$successPageDu === void 0 ? 2000 : _ref122$successPageDu, stampWith = _ref122.stampWith, userId = _ref122.userId;
5945
- _context99.n = 1;
5987
+ _ref123 = params || {}, _ref123$successPageDu = _ref123.successPageDuration, successPageDuration = _ref123$successPageDu === void 0 ? 2000 : _ref123$successPageDu, stampWith = _ref123.stampWith, userId = _ref123.userId;
5988
+ _context100.n = 1;
5946
5989
  return getSession();
5947
5990
  case 1:
5948
- s = _context99.v;
5991
+ s = _context100.v;
5949
5992
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5950
5993
  if (organizationId) {
5951
- _context99.n = 2;
5994
+ _context100.n = 2;
5952
5995
  break;
5953
5996
  }
5954
5997
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5955
5998
  case 2:
5956
- _context99.p = 2;
5957
- return _context99.a(2, new Promise(function (resolve, reject) {
5999
+ _context100.p = 2;
6000
+ return _context100.a(2, new Promise(function (resolve, reject) {
5958
6001
  pushPage({
5959
6002
  key: "Remove Phone Number",
5960
6003
  content: jsx(RemovePhoneNumber, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5981,58 +6024,58 @@ var ClientProvider = function ClientProvider(_ref) {
5981
6024
  });
5982
6025
  }));
5983
6026
  case 3:
5984
- _context99.p = 3;
5985
- _t30 = _context99.v;
6027
+ _context100.p = 3;
6028
+ _t30 = _context100.v;
5986
6029
  if (!(_t30 instanceof TurnkeyError)) {
5987
- _context99.n = 4;
6030
+ _context100.n = 4;
5988
6031
  break;
5989
6032
  }
5990
6033
  throw _t30;
5991
6034
  case 4:
5992
6035
  throw new TurnkeyError("Failed to remove user phone number.", TurnkeyErrorCodes.UPDATE_USER_PHONE_NUMBER_ERROR, _t30);
5993
6036
  case 5:
5994
- return _context99.a(2);
6037
+ return _context100.a(2);
5995
6038
  }
5996
- }, _callee99, null, [[2, 3]]);
6039
+ }, _callee100, null, [[2, 3]]);
5997
6040
  }));
5998
- return function (_x88) {
5999
- return _ref121.apply(this, arguments);
6041
+ return function (_x89) {
6042
+ return _ref122.apply(this, arguments);
6000
6043
  };
6001
6044
  }(), [pushPage, masterConfig, client, session, user]);
6002
6045
  useEffect(function () {
6003
6046
  if (proxyAuthConfigRef.current) return;
6004
6047
  // Only fetch the proxy auth config once. Use that to build the master config.
6005
6048
  var fetchProxyAuthConfig = /*#__PURE__*/function () {
6006
- var _ref123 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100() {
6049
+ var _ref124 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101() {
6007
6050
  var proxyAuthConfig;
6008
- return _regenerator().w(function (_context100) {
6009
- while (1) switch (_context100.p = _context100.n) {
6051
+ return _regenerator().w(function (_context101) {
6052
+ while (1) switch (_context101.p = _context101.n) {
6010
6053
  case 0:
6011
- _context100.p = 0;
6054
+ _context101.p = 0;
6012
6055
  if (!config.authProxyConfigId) {
6013
- _context100.n = 2;
6056
+ _context101.n = 2;
6014
6057
  break;
6015
6058
  }
6016
- _context100.n = 1;
6059
+ _context101.n = 1;
6017
6060
  return getAuthProxyConfig(config.authProxyConfigId, config.authProxyUrl);
6018
6061
  case 1:
6019
- proxyAuthConfig = _context100.v;
6062
+ proxyAuthConfig = _context101.v;
6020
6063
  proxyAuthConfigRef.current = proxyAuthConfig;
6021
6064
  case 2:
6022
6065
  setMasterConfig(buildConfig(proxyAuthConfig));
6023
- _context100.n = 4;
6066
+ _context101.n = 4;
6024
6067
  break;
6025
6068
  case 3:
6026
- _context100.p = 3;
6027
- _context100.v;
6069
+ _context101.p = 3;
6070
+ _context101.v;
6028
6071
  setClientState(ClientState.Error);
6029
6072
  case 4:
6030
- return _context100.a(2);
6073
+ return _context101.a(2);
6031
6074
  }
6032
- }, _callee100, null, [[0, 3]]);
6075
+ }, _callee101, null, [[0, 3]]);
6033
6076
  }));
6034
6077
  return function fetchProxyAuthConfig() {
6035
- return _ref123.apply(this, arguments);
6078
+ return _ref124.apply(this, arguments);
6036
6079
  };
6037
6080
  }();
6038
6081
  fetchProxyAuthConfig();
@@ -6064,29 +6107,29 @@ var ClientProvider = function ClientProvider(_ref) {
6064
6107
  useEffect(function () {
6065
6108
  if (!client) return;
6066
6109
  var handleUpdateState = /*#__PURE__*/function () {
6067
- var _ref124 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101() {
6068
- return _regenerator().w(function (_context101) {
6069
- while (1) switch (_context101.n) {
6110
+ var _ref125 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102() {
6111
+ return _regenerator().w(function (_context102) {
6112
+ while (1) switch (_context102.n) {
6070
6113
  case 0:
6071
6114
  if (!session) {
6072
- _context101.n = 2;
6115
+ _context102.n = 2;
6073
6116
  break;
6074
6117
  }
6075
- _context101.n = 1;
6118
+ _context102.n = 1;
6076
6119
  return debouncedRefreshWallets();
6077
6120
  case 1:
6078
- _context101.n = 3;
6121
+ _context102.n = 3;
6079
6122
  break;
6080
6123
  case 2:
6081
- _context101.n = 3;
6124
+ _context102.n = 3;
6082
6125
  return debouncedFetchWalletProviders();
6083
6126
  case 3:
6084
- return _context101.a(2);
6127
+ return _context102.a(2);
6085
6128
  }
6086
- }, _callee101);
6129
+ }, _callee102);
6087
6130
  }));
6088
6131
  return function handleUpdateState() {
6089
- return _ref124.apply(this, arguments);
6132
+ return _ref125.apply(this, arguments);
6090
6133
  };
6091
6134
  }();
6092
6135
  var cleanup = function cleanup() {};
@@ -6139,6 +6182,7 @@ var ClientProvider = function ClientProvider(_ref) {
6139
6182
  walletProviders: walletProviders,
6140
6183
  config: masterConfig,
6141
6184
  httpClient: client === null || client === void 0 ? void 0 : client.httpClient,
6185
+ createHttpClient: createHttpClient,
6142
6186
  createPasskey: createPasskey,
6143
6187
  logout: logout,
6144
6188
  loginWithPasskey: loginWithPasskey,
@@ -6147,6 +6191,7 @@ var ClientProvider = function ClientProvider(_ref) {
6147
6191
  connectWalletAccount: connectWalletAccount,
6148
6192
  disconnectWalletAccount: disconnectWalletAccount,
6149
6193
  switchWalletAccountChain: switchWalletAccountChain,
6194
+ buildWalletLoginRequest: buildWalletLoginRequest,
6150
6195
  loginWithWallet: loginWithWallet,
6151
6196
  signUpWithWallet: signUpWithWallet,
6152
6197
  loginOrSignupWithWallet: loginOrSignupWithWallet,