@turnkey/react-wallet-kit 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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) {
@@ -3644,65 +3682,65 @@ var ClientProvider = function ClientProvider(_ref) {
3644
3682
  }
3645
3683
  }));
3646
3684
  case 10:
3647
- _context71.n = 12;
3685
+ _context72.n = 12;
3648
3686
  break;
3649
3687
  case 11:
3650
- _context71.p = 11;
3651
- _t1 = _context71.v;
3688
+ _context72.p = 11;
3689
+ _t1 = _context72.v;
3652
3690
  throw _t1;
3653
3691
  case 12:
3654
- return _context71.a(2);
3692
+ return _context72.a(2);
3655
3693
  }
3656
- }, _callee71, null, [[1, 11]]);
3694
+ }, _callee72, null, [[1, 11]]);
3657
3695
  }));
3658
- return function (_x59) {
3659
- return _ref72.apply(this, arguments);
3696
+ return function (_x60) {
3697
+ return _ref73.apply(this, arguments);
3660
3698
  };
3661
3699
  }(), [client, callbacks, completeOauth, createApiKeyPair, masterConfig, session, user]);
3662
3700
  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) {
3701
+ var _ref77 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee73(params) {
3702
+ var _masterConfig$auth23, _masterConfig$auth23$, _masterConfig$auth$oa3, _masterConfig$auth24, _masterConfig$auth24$;
3703
+ 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;
3704
+ return _regenerator().w(function (_context73) {
3705
+ while (1) switch (_context73.p = _context73.n) {
3668
3706
  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;
3707
+ _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;
3708
+ _context73.p = 1;
3671
3709
  if (masterConfig) {
3672
- _context72.n = 2;
3710
+ _context73.n = 2;
3673
3711
  break;
3674
3712
  }
3675
3713
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3676
3714
  case 2:
3677
3715
  if (clientId) {
3678
- _context72.n = 3;
3716
+ _context73.n = 3;
3679
3717
  break;
3680
3718
  }
3681
3719
  throw new TurnkeyError("Twitter Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3682
3720
  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;
3721
+ if ((_masterConfig$auth25 = masterConfig.auth) !== null && _masterConfig$auth25 !== void 0 && (_masterConfig$auth25$ = _masterConfig$auth25.oauthConfig) !== null && _masterConfig$auth25$ !== void 0 && _masterConfig$auth25$.oauthRedirectUri) {
3722
+ _context73.n = 4;
3685
3723
  break;
3686
3724
  }
3687
3725
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3688
3726
  case 4:
3689
3727
  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;
3728
+ redirectURI = (_masterConfig$auth26 = masterConfig.auth) === null || _masterConfig$auth26 === void 0 ? void 0 : _masterConfig$auth26.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3729
+ _context73.n = 5;
3692
3730
  return createApiKeyPair();
3693
3731
  case 5:
3694
- publicKey = _context72.v;
3732
+ publicKey = _context73.v;
3695
3733
  if (publicKey) {
3696
- _context72.n = 6;
3734
+ _context73.n = 6;
3697
3735
  break;
3698
3736
  }
3699
3737
  throw new Error("Failed to create public key for OAuth.");
3700
3738
  case 6:
3701
3739
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
3702
- _context72.n = 7;
3740
+ _context73.n = 7;
3703
3741
  return generateChallengePair();
3704
3742
  case 7:
3705
- _yield$generateChalle2 = _context72.v;
3743
+ _yield$generateChalle2 = _context73.v;
3706
3744
  verifier = _yield$generateChalle2.verifier;
3707
3745
  codeChallenge = _yield$generateChalle2.codeChallenge;
3708
3746
  sessionStorage.setItem("twitter_verifier", verifier);
@@ -3716,10 +3754,10 @@ var ClientProvider = function ClientProvider(_ref) {
3716
3754
  twitterAuthUrl.searchParams.set("scope", "tweet.read users.read");
3717
3755
  twitterAuthUrl.searchParams.set("state", "provider=twitter&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey), "&nonce=").concat(nonce));
3718
3756
  if (additionalParameters) {
3719
- extra = Object.entries(additionalParameters).map(function (_ref78) {
3720
- var _ref79 = _slicedToArray(_ref78, 2),
3721
- k = _ref79[0],
3722
- v = _ref79[1];
3757
+ extra = Object.entries(additionalParameters).map(function (_ref79) {
3758
+ var _ref80 = _slicedToArray(_ref79, 2),
3759
+ k = _ref80[0],
3760
+ v = _ref80[1];
3723
3761
  return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(v));
3724
3762
  }).join("&");
3725
3763
  if (extra) {
@@ -3727,11 +3765,11 @@ var ClientProvider = function ClientProvider(_ref) {
3727
3765
  }
3728
3766
  }
3729
3767
  if (!openInPage) {
3730
- _context72.n = 8;
3768
+ _context73.n = 8;
3731
3769
  break;
3732
3770
  }
3733
3771
  window.location.href = twitterAuthUrl.toString();
3734
- return _context72.a(2, new Promise(function (_, reject) {
3772
+ return _context73.a(2, new Promise(function (_, reject) {
3735
3773
  var timeout = setTimeout(function () {
3736
3774
  reject(new Error("Authentication timed out."));
3737
3775
  }, 300000);
@@ -3746,13 +3784,13 @@ var ClientProvider = function ClientProvider(_ref) {
3746
3784
  top = window.screenY + (window.innerHeight - height) / 2;
3747
3785
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3748
3786
  if (authWindow) {
3749
- _context72.n = 9;
3787
+ _context73.n = 9;
3750
3788
  break;
3751
3789
  }
3752
3790
  throw new Error("Failed to open Twitter login window.");
3753
3791
  case 9:
3754
3792
  authWindow.location.href = twitterAuthUrl.toString();
3755
- return _context72.a(2, new Promise(function (resolve, reject) {
3793
+ return _context73.a(2, new Promise(function (resolve, reject) {
3756
3794
  var interval = setInterval(function () {
3757
3795
  try {
3758
3796
  if (authWindow.closed) {
@@ -3826,56 +3864,56 @@ var ClientProvider = function ClientProvider(_ref) {
3826
3864
  }
3827
3865
  }));
3828
3866
  case 10:
3829
- _context72.n = 12;
3867
+ _context73.n = 12;
3830
3868
  break;
3831
3869
  case 11:
3832
- _context72.p = 11;
3833
- _t10 = _context72.v;
3870
+ _context73.p = 11;
3871
+ _t10 = _context73.v;
3834
3872
  throw _t10;
3835
3873
  case 12:
3836
- return _context72.a(2);
3874
+ return _context73.a(2);
3837
3875
  }
3838
- }, _callee72, null, [[1, 11]]);
3876
+ }, _callee73, null, [[1, 11]]);
3839
3877
  }));
3840
- return function (_x60) {
3841
- return _ref76.apply(this, arguments);
3878
+ return function (_x61) {
3879
+ return _ref77.apply(this, arguments);
3842
3880
  };
3843
3881
  }(), [client, callbacks, masterConfig, session, user]);
3844
3882
  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) {
3883
+ var _ref81 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee74(params) {
3884
+ var _masterConfig$auth27, _masterConfig$auth27$, _masterConfig$auth$oa4, _masterConfig$auth28, _masterConfig$auth28$;
3885
+ 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;
3886
+ return _regenerator().w(function (_context74) {
3887
+ while (1) switch (_context74.p = _context74.n) {
3850
3888
  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;
3889
+ _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;
3890
+ _context74.p = 1;
3853
3891
  if (masterConfig) {
3854
- _context73.n = 2;
3892
+ _context74.n = 2;
3855
3893
  break;
3856
3894
  }
3857
3895
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3858
3896
  case 2:
3859
3897
  if (clientId) {
3860
- _context73.n = 3;
3898
+ _context74.n = 3;
3861
3899
  break;
3862
3900
  }
3863
3901
  throw new TurnkeyError("Google Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3864
3902
  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;
3903
+ if ((_masterConfig$auth29 = masterConfig.auth) !== null && _masterConfig$auth29 !== void 0 && (_masterConfig$auth29$ = _masterConfig$auth29.oauthConfig) !== null && _masterConfig$auth29$ !== void 0 && _masterConfig$auth29$.oauthRedirectUri) {
3904
+ _context74.n = 4;
3867
3905
  break;
3868
3906
  }
3869
3907
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3870
3908
  case 4:
3871
3909
  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;
3910
+ redirectURI = (_masterConfig$auth30 = masterConfig.auth) === null || _masterConfig$auth30 === void 0 ? void 0 : _masterConfig$auth30.oauthConfig.oauthRedirectUri.replace(/\/$/, ""); // Create key pair and generate nonce
3911
+ _context74.n = 5;
3874
3912
  return createApiKeyPair();
3875
3913
  case 5:
3876
- publicKey = _context73.v;
3914
+ publicKey = _context74.v;
3877
3915
  if (publicKey) {
3878
- _context73.n = 6;
3916
+ _context74.n = 6;
3879
3917
  break;
3880
3918
  }
3881
3919
  throw new Error("Failed to create public key for OAuth.");
@@ -3891,10 +3929,10 @@ var ClientProvider = function ClientProvider(_ref) {
3891
3929
  // Create state parameter
3892
3930
  state = "provider=google&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
3893
3931
  if (additionalParameters) {
3894
- additionalState = Object.entries(additionalParameters).map(function (_ref82) {
3895
- var _ref83 = _slicedToArray(_ref82, 2),
3896
- key = _ref83[0],
3897
- value = _ref83[1];
3932
+ additionalState = Object.entries(additionalParameters).map(function (_ref83) {
3933
+ var _ref84 = _slicedToArray(_ref83, 2),
3934
+ key = _ref84[0],
3935
+ value = _ref84[1];
3898
3936
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
3899
3937
  }).join("&");
3900
3938
  if (additionalState) {
@@ -3903,12 +3941,12 @@ var ClientProvider = function ClientProvider(_ref) {
3903
3941
  }
3904
3942
  googleAuthUrl.searchParams.set("state", state);
3905
3943
  if (!openInPage) {
3906
- _context73.n = 7;
3944
+ _context74.n = 7;
3907
3945
  break;
3908
3946
  }
3909
3947
  // Redirect current page to Google Auth
3910
3948
  window.location.href = googleAuthUrl.toString();
3911
- return _context73.a(2, new Promise(function (_, reject) {
3949
+ return _context74.a(2, new Promise(function (_, reject) {
3912
3950
  // By here, the page should have already redirected. We wait here since the function is async.
3913
3951
  // We want any function that runs this to simply wait until the page redirects.
3914
3952
  // A 5 min timeout is set just in case, idk
@@ -3928,7 +3966,7 @@ var ClientProvider = function ClientProvider(_ref) {
3928
3966
  top = window.screenY + (window.innerHeight - height) / 2;
3929
3967
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3930
3968
  if (authWindow) {
3931
- _context73.n = 8;
3969
+ _context74.n = 8;
3932
3970
  break;
3933
3971
  }
3934
3972
  throw new Error("Failed to open Google login window.");
@@ -3936,7 +3974,7 @@ var ClientProvider = function ClientProvider(_ref) {
3936
3974
  authWindow.location.href = googleAuthUrl.toString();
3937
3975
  // Return a promise that resolves when the OAuth flow completes
3938
3976
  // This following code will only run for the popup flow
3939
- return _context73.a(2, new Promise(function (resolve, reject) {
3977
+ return _context74.a(2, new Promise(function (resolve, reject) {
3940
3978
  var interval = setInterval(function () {
3941
3979
  try {
3942
3980
  // Check if window was closed without completing auth
@@ -3995,57 +4033,57 @@ var ClientProvider = function ClientProvider(_ref) {
3995
4033
  }
3996
4034
  }));
3997
4035
  case 9:
3998
- _context73.n = 11;
4036
+ _context74.n = 11;
3999
4037
  break;
4000
4038
  case 10:
4001
- _context73.p = 10;
4002
- _t11 = _context73.v;
4039
+ _context74.p = 10;
4040
+ _t11 = _context74.v;
4003
4041
  throw _t11;
4004
4042
  case 11:
4005
- return _context73.a(2);
4043
+ return _context74.a(2);
4006
4044
  }
4007
- }, _callee73, null, [[1, 10]]);
4045
+ }, _callee74, null, [[1, 10]]);
4008
4046
  }));
4009
- return function (_x61) {
4010
- return _ref80.apply(this, arguments);
4047
+ return function (_x62) {
4048
+ return _ref81.apply(this, arguments);
4011
4049
  };
4012
4050
  }(), [client, callbacks, masterConfig, session, user]);
4013
4051
  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) {
4052
+ var _ref85 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee75(params) {
4053
+ var _masterConfig$auth31, _masterConfig$auth31$, _masterConfig$auth$oa5, _masterConfig$auth32, _masterConfig$auth32$;
4054
+ 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;
4055
+ return _regenerator().w(function (_context75) {
4056
+ while (1) switch (_context75.p = _context75.n) {
4019
4057
  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;
4058
+ _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;
4059
+ _context75.p = 1;
4022
4060
  if (masterConfig) {
4023
- _context74.n = 2;
4061
+ _context75.n = 2;
4024
4062
  break;
4025
4063
  }
4026
4064
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4027
4065
  case 2:
4028
4066
  if (clientId) {
4029
- _context74.n = 3;
4067
+ _context75.n = 3;
4030
4068
  break;
4031
4069
  }
4032
4070
  throw new TurnkeyError("Apple Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4033
4071
  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;
4072
+ if ((_masterConfig$auth33 = masterConfig.auth) !== null && _masterConfig$auth33 !== void 0 && (_masterConfig$auth33$ = _masterConfig$auth33.oauthConfig) !== null && _masterConfig$auth33$ !== void 0 && _masterConfig$auth33$.oauthRedirectUri) {
4073
+ _context75.n = 4;
4036
4074
  break;
4037
4075
  }
4038
4076
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4039
4077
  case 4:
4040
4078
  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?
4079
+ 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
4080
  // Create key pair and generate nonce
4043
- _context74.n = 5;
4081
+ _context75.n = 5;
4044
4082
  return createApiKeyPair();
4045
4083
  case 5:
4046
- publicKey = _context74.v;
4084
+ publicKey = _context75.v;
4047
4085
  if (publicKey) {
4048
- _context74.n = 6;
4086
+ _context75.n = 6;
4049
4087
  break;
4050
4088
  }
4051
4089
  throw new Error("Failed to create public key for OAuth.");
@@ -4060,10 +4098,10 @@ var ClientProvider = function ClientProvider(_ref) {
4060
4098
  // Create state parameter
4061
4099
  state = "provider=apple&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
4062
4100
  if (additionalParameters) {
4063
- additionalState = Object.entries(additionalParameters).map(function (_ref86) {
4064
- var _ref87 = _slicedToArray(_ref86, 2),
4065
- key = _ref87[0],
4066
- value = _ref87[1];
4101
+ additionalState = Object.entries(additionalParameters).map(function (_ref87) {
4102
+ var _ref88 = _slicedToArray(_ref87, 2),
4103
+ key = _ref88[0],
4104
+ value = _ref88[1];
4067
4105
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
4068
4106
  }).join("&");
4069
4107
  if (additionalState) {
@@ -4072,12 +4110,12 @@ var ClientProvider = function ClientProvider(_ref) {
4072
4110
  }
4073
4111
  appleAuthUrl.searchParams.set("state", state);
4074
4112
  if (!openInPage) {
4075
- _context74.n = 7;
4113
+ _context75.n = 7;
4076
4114
  break;
4077
4115
  }
4078
4116
  // Redirect current page to Apple Auth
4079
4117
  window.location.href = appleAuthUrl.toString();
4080
- return _context74.a(2, new Promise(function (_, reject) {
4118
+ return _context75.a(2, new Promise(function (_, reject) {
4081
4119
  // Set a timeout just in case the redirect doesn't happen
4082
4120
  var timeout = setTimeout(function () {
4083
4121
  reject(new Error("Authentication timed out."));
@@ -4095,14 +4133,14 @@ var ClientProvider = function ClientProvider(_ref) {
4095
4133
  top = window.screenY + (window.innerHeight - height) / 2;
4096
4134
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
4097
4135
  if (authWindow) {
4098
- _context74.n = 8;
4136
+ _context75.n = 8;
4099
4137
  break;
4100
4138
  }
4101
4139
  throw new Error("Failed to open Apple login window.");
4102
4140
  case 8:
4103
4141
  authWindow.location.href = appleAuthUrl.toString();
4104
4142
  // Return a promise that resolves when the OAuth flow completes
4105
- return _context74.a(2, new Promise(function (resolve, reject) {
4143
+ return _context75.a(2, new Promise(function (resolve, reject) {
4106
4144
  var interval = setInterval(function () {
4107
4145
  try {
4108
4146
  // Check if window was closed without completing auth
@@ -4161,65 +4199,65 @@ var ClientProvider = function ClientProvider(_ref) {
4161
4199
  }
4162
4200
  }));
4163
4201
  case 9:
4164
- _context74.n = 11;
4202
+ _context75.n = 11;
4165
4203
  break;
4166
4204
  case 10:
4167
- _context74.p = 10;
4168
- _t12 = _context74.v;
4205
+ _context75.p = 10;
4206
+ _t12 = _context75.v;
4169
4207
  throw _t12;
4170
4208
  case 11:
4171
- return _context74.a(2);
4209
+ return _context75.a(2);
4172
4210
  }
4173
- }, _callee74, null, [[1, 10]]);
4211
+ }, _callee75, null, [[1, 10]]);
4174
4212
  }));
4175
- return function (_x62) {
4176
- return _ref84.apply(this, arguments);
4213
+ return function (_x63) {
4214
+ return _ref85.apply(this, arguments);
4177
4215
  };
4178
4216
  }(), [client, callbacks, masterConfig, session, user]);
4179
4217
  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) {
4218
+ var _ref89 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee76(params) {
4219
+ var _masterConfig$auth35, _masterConfig$auth35$, _masterConfig$auth$oa6, _masterConfig$auth36, _masterConfig$auth36$;
4220
+ 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;
4221
+ return _regenerator().w(function (_context76) {
4222
+ while (1) switch (_context76.p = _context76.n) {
4185
4223
  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;
4224
+ _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;
4225
+ _context76.p = 1;
4188
4226
  if (masterConfig) {
4189
- _context75.n = 2;
4227
+ _context76.n = 2;
4190
4228
  break;
4191
4229
  }
4192
4230
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4193
4231
  case 2:
4194
4232
  if (clientId) {
4195
- _context75.n = 3;
4233
+ _context76.n = 3;
4196
4234
  break;
4197
4235
  }
4198
4236
  throw new TurnkeyError("Facebook Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4199
4237
  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;
4238
+ if ((_masterConfig$auth37 = masterConfig.auth) !== null && _masterConfig$auth37 !== void 0 && (_masterConfig$auth37$ = _masterConfig$auth37.oauthConfig) !== null && _masterConfig$auth37$ !== void 0 && _masterConfig$auth37$.oauthRedirectUri) {
4239
+ _context76.n = 4;
4202
4240
  break;
4203
4241
  }
4204
4242
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4205
4243
  case 4:
4206
4244
  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;
4245
+ redirectURI = (_masterConfig$auth38 = masterConfig.auth) === null || _masterConfig$auth38 === void 0 ? void 0 : _masterConfig$auth38.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4246
+ _context76.n = 5;
4209
4247
  return createApiKeyPair();
4210
4248
  case 5:
4211
- publicKey = _context75.v;
4249
+ publicKey = _context76.v;
4212
4250
  if (publicKey) {
4213
- _context75.n = 6;
4251
+ _context76.n = 6;
4214
4252
  break;
4215
4253
  }
4216
4254
  throw new Error("Failed to create public key for OAuth.");
4217
4255
  case 6:
4218
4256
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
4219
- _context75.n = 7;
4257
+ _context76.n = 7;
4220
4258
  return generateChallengePair();
4221
4259
  case 7:
4222
- _yield$generateChalle3 = _context75.v;
4260
+ _yield$generateChalle3 = _context76.v;
4223
4261
  verifier = _yield$generateChalle3.verifier;
4224
4262
  codeChallenge = _yield$generateChalle3.codeChallenge;
4225
4263
  // Store verifier for later token exchange
@@ -4236,10 +4274,10 @@ var ClientProvider = function ClientProvider(_ref) {
4236
4274
  // Create state parameter
4237
4275
  state = "provider=facebook&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
4238
4276
  if (additionalParameters) {
4239
- additionalState = Object.entries(additionalParameters).map(function (_ref90) {
4240
- var _ref91 = _slicedToArray(_ref90, 2),
4241
- key = _ref91[0],
4242
- value = _ref91[1];
4277
+ additionalState = Object.entries(additionalParameters).map(function (_ref91) {
4278
+ var _ref92 = _slicedToArray(_ref91, 2),
4279
+ key = _ref92[0],
4280
+ value = _ref92[1];
4243
4281
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
4244
4282
  }).join("&");
4245
4283
  if (additionalState) {
@@ -4248,12 +4286,12 @@ var ClientProvider = function ClientProvider(_ref) {
4248
4286
  }
4249
4287
  facebookAuthUrl.searchParams.set("state", state);
4250
4288
  if (!openInPage) {
4251
- _context75.n = 8;
4289
+ _context76.n = 8;
4252
4290
  break;
4253
4291
  }
4254
4292
  // Redirect current page to Facebook Auth
4255
4293
  window.location.href = facebookAuthUrl.toString();
4256
- return _context75.a(2, new Promise(function (_, reject) {
4294
+ return _context76.a(2, new Promise(function (_, reject) {
4257
4295
  // Set a timeout just in case the redirect doesn't happen
4258
4296
  var timeout = setTimeout(function () {
4259
4297
  reject(new Error("Authentication timed out."));
@@ -4271,14 +4309,14 @@ var ClientProvider = function ClientProvider(_ref) {
4271
4309
  top = window.screenY + (window.innerHeight - height) / 2;
4272
4310
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
4273
4311
  if (authWindow) {
4274
- _context75.n = 9;
4312
+ _context76.n = 9;
4275
4313
  break;
4276
4314
  }
4277
4315
  throw new Error("Failed to open Facebook login window.");
4278
4316
  case 9:
4279
4317
  authWindow.location.href = facebookAuthUrl.toString();
4280
4318
  // Return a promise that resolves when the OAuth flow completes
4281
- return _context75.a(2, new Promise(function (resolve, reject) {
4319
+ return _context76.a(2, new Promise(function (resolve, reject) {
4282
4320
  var interval = setInterval(function () {
4283
4321
  try {
4284
4322
  // Check if window was closed without completing auth
@@ -4346,27 +4384,27 @@ var ClientProvider = function ClientProvider(_ref) {
4346
4384
  }
4347
4385
  }));
4348
4386
  case 10:
4349
- _context75.n = 12;
4387
+ _context76.n = 12;
4350
4388
  break;
4351
4389
  case 11:
4352
- _context75.p = 11;
4353
- _t13 = _context75.v;
4390
+ _context76.p = 11;
4391
+ _t13 = _context76.v;
4354
4392
  throw _t13;
4355
4393
  case 12:
4356
- return _context75.a(2);
4394
+ return _context76.a(2);
4357
4395
  }
4358
- }, _callee75, null, [[1, 11]]);
4396
+ }, _callee76, null, [[1, 11]]);
4359
4397
  }));
4360
- return function (_x63) {
4361
- return _ref88.apply(this, arguments);
4398
+ return function (_x64) {
4399
+ return _ref89.apply(this, arguments);
4362
4400
  };
4363
4401
  }(), [client, callbacks, masterConfig, client, session, user]);
4364
4402
  var handleLogin = useCallback(/*#__PURE__*/function () {
4365
- var _ref92 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee76(params) {
4403
+ var _ref93 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee77(params) {
4366
4404
  var _masterConfig$ui, _params$logoDark, _masterConfig$ui2, _params$logoLight, _masterConfig$ui3, _params$title;
4367
4405
  var logo;
4368
- return _regenerator().w(function (_context76) {
4369
- while (1) switch (_context76.n) {
4406
+ return _regenerator().w(function (_context77) {
4407
+ while (1) switch (_context77.n) {
4370
4408
  case 0:
4371
4409
  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
4410
  pushPage({
@@ -4380,22 +4418,22 @@ var ClientProvider = function ClientProvider(_ref) {
4380
4418
  showTitle: logo ? false : true
4381
4419
  });
4382
4420
  case 1:
4383
- return _context76.a(2);
4421
+ return _context77.a(2);
4384
4422
  }
4385
- }, _callee76);
4423
+ }, _callee77);
4386
4424
  }));
4387
- return function (_x64) {
4388
- return _ref92.apply(this, arguments);
4425
+ return function (_x65) {
4426
+ return _ref93.apply(this, arguments);
4389
4427
  };
4390
4428
  }(), [pushPage, masterConfig, client, session, user]);
4391
4429
  var handleExportWallet = useCallback(/*#__PURE__*/function () {
4392
- var _ref93 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee77(params) {
4430
+ var _ref94 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee78(params) {
4393
4431
  var walletId, targetPublicKey, stampWith, organizationId;
4394
- return _regenerator().w(function (_context77) {
4395
- while (1) switch (_context77.n) {
4432
+ return _regenerator().w(function (_context78) {
4433
+ while (1) switch (_context78.n) {
4396
4434
  case 0:
4397
4435
  walletId = params.walletId, targetPublicKey = params.targetPublicKey, stampWith = params.stampWith, organizationId = params.organizationId;
4398
- return _context77.a(2, new Promise(function (resolve, reject) {
4436
+ return _context78.a(2, new Promise(function (resolve, reject) {
4399
4437
  return pushPage({
4400
4438
  key: "Export wallet",
4401
4439
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4421,20 +4459,20 @@ var ClientProvider = function ClientProvider(_ref) {
4421
4459
  });
4422
4460
  }));
4423
4461
  }
4424
- }, _callee77);
4462
+ }, _callee78);
4425
4463
  }));
4426
- return function (_x65) {
4427
- return _ref93.apply(this, arguments);
4464
+ return function (_x66) {
4465
+ return _ref94.apply(this, arguments);
4428
4466
  };
4429
4467
  }(), [pushPage, masterConfig, client, session, user]);
4430
4468
  var handleExportPrivateKey = useCallback(/*#__PURE__*/function () {
4431
- var _ref94 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee78(params) {
4469
+ var _ref95 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee79(params) {
4432
4470
  var privateKeyId, targetPublicKey, keyFormat, stampWith, organizationId;
4433
- return _regenerator().w(function (_context78) {
4434
- while (1) switch (_context78.n) {
4471
+ return _regenerator().w(function (_context79) {
4472
+ while (1) switch (_context79.n) {
4435
4473
  case 0:
4436
4474
  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) {
4475
+ return _context79.a(2, new Promise(function (resolve, reject) {
4438
4476
  return pushPage({
4439
4477
  key: "Export private key",
4440
4478
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4462,20 +4500,20 @@ var ClientProvider = function ClientProvider(_ref) {
4462
4500
  });
4463
4501
  }));
4464
4502
  }
4465
- }, _callee78);
4503
+ }, _callee79);
4466
4504
  }));
4467
- return function (_x66) {
4468
- return _ref94.apply(this, arguments);
4505
+ return function (_x67) {
4506
+ return _ref95.apply(this, arguments);
4469
4507
  };
4470
4508
  }(), [pushPage, masterConfig, client, session, user]);
4471
4509
  var handleExportWalletAccount = useCallback(/*#__PURE__*/function () {
4472
- var _ref95 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee79(params) {
4510
+ var _ref96 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee80(params) {
4473
4511
  var address, targetPublicKey, keyFormat, stampWith, organizationId;
4474
- return _regenerator().w(function (_context79) {
4475
- while (1) switch (_context79.n) {
4512
+ return _regenerator().w(function (_context80) {
4513
+ while (1) switch (_context80.n) {
4476
4514
  case 0:
4477
4515
  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) {
4516
+ return _context80.a(2, new Promise(function (resolve, reject) {
4479
4517
  return pushPage({
4480
4518
  key: "Export wallet account",
4481
4519
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4503,21 +4541,21 @@ var ClientProvider = function ClientProvider(_ref) {
4503
4541
  });
4504
4542
  }));
4505
4543
  }
4506
- }, _callee79);
4544
+ }, _callee80);
4507
4545
  }));
4508
- return function (_x67) {
4509
- return _ref95.apply(this, arguments);
4546
+ return function (_x68) {
4547
+ return _ref96.apply(this, arguments);
4510
4548
  };
4511
4549
  }(), [pushPage, masterConfig, client, session, user]);
4512
4550
  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) {
4551
+ var _ref97 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee81(params) {
4552
+ var _ref98, defaultWalletAccounts, _ref98$successPageDur, successPageDuration, stampWith, walletName, organizationId, userId, _t14;
4553
+ return _regenerator().w(function (_context81) {
4554
+ while (1) switch (_context81.p = _context81.n) {
4517
4555
  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 () {
4556
+ _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;
4557
+ _context81.p = 1;
4558
+ return _context81.a(2, withTurnkeyErrorHandling(function () {
4521
4559
  return new Promise(function (resolve, reject) {
4522
4560
  return pushPage({
4523
4561
  key: "Import wallet",
@@ -4548,33 +4586,33 @@ var ClientProvider = function ClientProvider(_ref) {
4548
4586
  return logout();
4549
4587
  }));
4550
4588
  case 2:
4551
- _context80.p = 2;
4552
- _t14 = _context80.v;
4589
+ _context81.p = 2;
4590
+ _t14 = _context81.v;
4553
4591
  if (!(_t14 instanceof TurnkeyError)) {
4554
- _context80.n = 3;
4592
+ _context81.n = 3;
4555
4593
  break;
4556
4594
  }
4557
4595
  throw _t14;
4558
4596
  case 3:
4559
4597
  throw new TurnkeyError("Failed to import wallet.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t14);
4560
4598
  case 4:
4561
- return _context80.a(2);
4599
+ return _context81.a(2);
4562
4600
  }
4563
- }, _callee80, null, [[1, 2]]);
4601
+ }, _callee81, null, [[1, 2]]);
4564
4602
  }));
4565
- return function (_x68) {
4566
- return _ref96.apply(this, arguments);
4603
+ return function (_x69) {
4604
+ return _ref97.apply(this, arguments);
4567
4605
  };
4568
4606
  }(), [pushPage, masterConfig, client, session, user]);
4569
4607
  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) {
4608
+ var _ref99 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee82(params) {
4609
+ var _ref100, curve, addressFormats, _ref100$successPageDu, successPageDuration, stampWith, keyName, organizationId, _t15;
4610
+ return _regenerator().w(function (_context82) {
4611
+ while (1) switch (_context82.p = _context82.n) {
4574
4612
  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 () {
4613
+ _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;
4614
+ _context82.p = 1;
4615
+ return _context82.a(2, withTurnkeyErrorHandling(function () {
4578
4616
  return new Promise(function (resolve, reject) {
4579
4617
  return pushPage({
4580
4618
  key: "Import private key",
@@ -4603,51 +4641,51 @@ var ClientProvider = function ClientProvider(_ref) {
4603
4641
  return logout();
4604
4642
  }));
4605
4643
  case 2:
4606
- _context81.p = 2;
4607
- _t15 = _context81.v;
4644
+ _context82.p = 2;
4645
+ _t15 = _context82.v;
4608
4646
  if (!(_t15 instanceof TurnkeyError)) {
4609
- _context81.n = 3;
4647
+ _context82.n = 3;
4610
4648
  break;
4611
4649
  }
4612
4650
  throw _t15;
4613
4651
  case 3:
4614
4652
  throw new TurnkeyError("Failed to import private key.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t15);
4615
4653
  case 4:
4616
- return _context81.a(2);
4654
+ return _context82.a(2);
4617
4655
  }
4618
- }, _callee81, null, [[1, 2]]);
4656
+ }, _callee82, null, [[1, 2]]);
4619
4657
  }));
4620
- return function (_x69) {
4621
- return _ref98.apply(this, arguments);
4658
+ return function (_x70) {
4659
+ return _ref99.apply(this, arguments);
4622
4660
  };
4623
4661
  }(), [pushPage, masterConfig, client, session, user]);
4624
4662
  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) {
4663
+ var _ref101 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee83(params) {
4664
+ var _ref102, _ref102$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, res, _t16;
4665
+ return _regenerator().w(function (_context83) {
4666
+ while (1) switch (_context83.p = _context83.n) {
4629
4667
  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;
4668
+ _ref102 = params || {}, _ref102$successPageDu = _ref102.successPageDuration, successPageDuration = _ref102$successPageDu === void 0 ? 2000 : _ref102$successPageDu, subTitle = _ref102.subTitle, title = _ref102.title, stampWith = _ref102.stampWith;
4631
4669
  if (client) {
4632
- _context82.n = 1;
4670
+ _context83.n = 1;
4633
4671
  break;
4634
4672
  }
4635
4673
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4636
4674
  case 1:
4637
- _context82.n = 2;
4675
+ _context83.n = 2;
4638
4676
  return getSession();
4639
4677
  case 2:
4640
- s = _context82.v;
4678
+ s = _context83.v;
4641
4679
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4642
4680
  if (organizationId) {
4643
- _context82.n = 3;
4681
+ _context83.n = 3;
4644
4682
  break;
4645
4683
  }
4646
4684
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
4647
4685
  case 3:
4648
4686
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (user === null || user === void 0 ? void 0 : user.userId);
4649
4687
  if (userId) {
4650
- _context82.n = 4;
4688
+ _context83.n = 4;
4651
4689
  break;
4652
4690
  }
4653
4691
  throw new TurnkeyError("A user ID is required to update a user name.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -4667,12 +4705,12 @@ var ClientProvider = function ClientProvider(_ref) {
4667
4705
  showTitle: false
4668
4706
  });
4669
4707
  };
4670
- _context82.p = 5;
4708
+ _context83.p = 5;
4671
4709
  if (!(!(params !== null && params !== void 0 && params.userName) && (params === null || params === void 0 ? void 0 : params.userName) !== "")) {
4672
- _context82.n = 6;
4710
+ _context83.n = 6;
4673
4711
  break;
4674
4712
  }
4675
- return _context82.a(2, withTurnkeyErrorHandling(function () {
4713
+ return _context83.a(2, withTurnkeyErrorHandling(function () {
4676
4714
  return new Promise(function (resolve, reject) {
4677
4715
  pushPage({
4678
4716
  key: "Update User Name",
@@ -4700,7 +4738,7 @@ var ClientProvider = function ClientProvider(_ref) {
4700
4738
  return logout();
4701
4739
  }));
4702
4740
  case 6:
4703
- _context82.n = 7;
4741
+ _context83.n = 7;
4704
4742
  return updateUserName(_objectSpread2({
4705
4743
  userName: params.userName,
4706
4744
  userId: user.userId,
@@ -4709,71 +4747,71 @@ var ClientProvider = function ClientProvider(_ref) {
4709
4747
  organizationId: organizationId
4710
4748
  }));
4711
4749
  case 7:
4712
- res = _context82.v;
4750
+ res = _context83.v;
4713
4751
  onSuccess();
4714
- return _context82.a(2, res);
4752
+ return _context83.a(2, res);
4715
4753
  case 8:
4716
- _context82.n = 11;
4754
+ _context83.n = 11;
4717
4755
  break;
4718
4756
  case 9:
4719
- _context82.p = 9;
4720
- _t16 = _context82.v;
4757
+ _context83.p = 9;
4758
+ _t16 = _context83.v;
4721
4759
  if (!(_t16 instanceof TurnkeyError)) {
4722
- _context82.n = 10;
4760
+ _context83.n = 10;
4723
4761
  break;
4724
4762
  }
4725
4763
  throw _t16;
4726
4764
  case 10:
4727
4765
  throw new TurnkeyError("Failed to update user name.", TurnkeyErrorCodes.UPDATE_USER_NAME_ERROR, _t16);
4728
4766
  case 11:
4729
- return _context82.a(2);
4767
+ return _context83.a(2);
4730
4768
  }
4731
- }, _callee82, null, [[5, 9]]);
4769
+ }, _callee83, null, [[5, 9]]);
4732
4770
  }));
4733
- return function (_x70) {
4734
- return _ref100.apply(this, arguments);
4771
+ return function (_x71) {
4772
+ return _ref101.apply(this, arguments);
4735
4773
  };
4736
4774
  }(), [pushPage, masterConfig, client, session, user]);
4737
4775
  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) {
4776
+ var _ref103 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee85(params) {
4777
+ var _masterConfig$auth39, _masterConfig$auth39$;
4778
+ var _ref104, _ref104$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t18;
4779
+ return _regenerator().w(function (_context85) {
4780
+ while (1) switch (_context85.p = _context85.n) {
4743
4781
  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;
4782
+ _ref104 = params || {}, _ref104$successPageDu = _ref104.successPageDuration, successPageDuration = _ref104$successPageDu === void 0 ? 2000 : _ref104$successPageDu, subTitle = _ref104.subTitle, title = _ref104.title, stampWith = _ref104.stampWith;
4745
4783
  if (client) {
4746
- _context84.n = 1;
4784
+ _context85.n = 1;
4747
4785
  break;
4748
4786
  }
4749
4787
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4750
4788
  case 1:
4751
4789
  if (masterConfig) {
4752
- _context84.n = 2;
4790
+ _context85.n = 2;
4753
4791
  break;
4754
4792
  }
4755
4793
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
4756
4794
  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;
4795
+ if ((_masterConfig$auth39 = masterConfig.auth) !== null && _masterConfig$auth39 !== void 0 && (_masterConfig$auth39$ = _masterConfig$auth39.methods) !== null && _masterConfig$auth39$ !== void 0 && _masterConfig$auth39$.smsOtpAuthEnabled) {
4796
+ _context85.n = 3;
4759
4797
  break;
4760
4798
  }
4761
4799
  throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
4762
4800
  case 3:
4763
- _context84.n = 4;
4801
+ _context85.n = 4;
4764
4802
  return getSession();
4765
4803
  case 4:
4766
- s = _context84.v;
4804
+ s = _context85.v;
4767
4805
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4768
4806
  if (organizationId) {
4769
- _context84.n = 5;
4807
+ _context85.n = 5;
4770
4808
  break;
4771
4809
  }
4772
4810
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
4773
4811
  case 5:
4774
4812
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
4775
4813
  if (userId) {
4776
- _context84.n = 6;
4814
+ _context85.n = 6;
4777
4815
  break;
4778
4816
  }
4779
4817
  throw new TurnkeyError("A user ID is required to update a phone number.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -4793,12 +4831,12 @@ var ClientProvider = function ClientProvider(_ref) {
4793
4831
  showTitle: false
4794
4832
  });
4795
4833
  };
4796
- _context84.p = 7;
4834
+ _context85.p = 7;
4797
4835
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
4798
- _context84.n = 8;
4836
+ _context85.n = 8;
4799
4837
  break;
4800
4838
  }
4801
- return _context84.a(2, withTurnkeyErrorHandling(function () {
4839
+ return _context85.a(2, withTurnkeyErrorHandling(function () {
4802
4840
  return new Promise(function (resolve, reject) {
4803
4841
  pushPage({
4804
4842
  key: "Update Phone Number",
@@ -4826,32 +4864,32 @@ var ClientProvider = function ClientProvider(_ref) {
4826
4864
  return logout();
4827
4865
  }));
4828
4866
  case 8:
4829
- _context84.n = 9;
4867
+ _context85.n = 9;
4830
4868
  return initOtp({
4831
4869
  otpType: OtpType.Sms,
4832
4870
  contact: params.phoneNumber
4833
4871
  });
4834
4872
  case 9:
4835
- otpId = _context84.v;
4836
- return _context84.a(2, withTurnkeyErrorHandling(function () {
4873
+ otpId = _context85.v;
4874
+ return _context85.a(2, withTurnkeyErrorHandling(function () {
4837
4875
  return new Promise(function (resolve, reject) {
4838
- var _masterConfig$auth39, _masterConfig$auth40;
4876
+ var _masterConfig$auth40, _masterConfig$auth41;
4839
4877
  pushPage({
4840
4878
  key: "Update Phone Number",
4841
4879
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2(_objectSpread2({
4842
4880
  otpType: OtpType.Sms,
4843
4881
  contact: params.phoneNumber,
4844
4882
  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,
4883
+ otpLength: ((_masterConfig$auth40 = masterConfig.auth) === null || _masterConfig$auth40 === void 0 ? void 0 : _masterConfig$auth40.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
4884
+ alphanumeric: (_masterConfig$auth41 = masterConfig.auth) === null || _masterConfig$auth41 === void 0 ? void 0 : _masterConfig$auth41.otpAlphanumeric,
4847
4885
  onContinue: function () {
4848
- var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee83(otpCode) {
4886
+ var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee84(otpCode) {
4849
4887
  var _yield$verifyOtp, verificationToken, res, _t17;
4850
- return _regenerator().w(function (_context83) {
4851
- while (1) switch (_context83.p = _context83.n) {
4888
+ return _regenerator().w(function (_context84) {
4889
+ while (1) switch (_context84.p = _context84.n) {
4852
4890
  case 0:
4853
- _context83.p = 0;
4854
- _context83.n = 1;
4891
+ _context84.p = 0;
4892
+ _context84.n = 1;
4855
4893
  return verifyOtp({
4856
4894
  otpId: otpId,
4857
4895
  otpCode: otpCode,
@@ -4859,9 +4897,9 @@ var ClientProvider = function ClientProvider(_ref) {
4859
4897
  otpType: OtpType.Sms
4860
4898
  });
4861
4899
  case 1:
4862
- _yield$verifyOtp = _context83.v;
4900
+ _yield$verifyOtp = _context84.v;
4863
4901
  verificationToken = _yield$verifyOtp.verificationToken;
4864
- _context83.n = 2;
4902
+ _context84.n = 2;
4865
4903
  return updateUserPhoneNumber(_objectSpread2({
4866
4904
  phoneNumber: params.phoneNumber,
4867
4905
  verificationToken: verificationToken,
@@ -4871,21 +4909,21 @@ var ClientProvider = function ClientProvider(_ref) {
4871
4909
  stampWith: stampWith
4872
4910
  }));
4873
4911
  case 2:
4874
- res = _context83.v;
4912
+ res = _context84.v;
4875
4913
  onSuccess();
4876
4914
  resolve(res);
4877
- _context83.n = 4;
4915
+ _context84.n = 4;
4878
4916
  break;
4879
4917
  case 3:
4880
- _context83.p = 3;
4881
- _t17 = _context83.v;
4918
+ _context84.p = 3;
4919
+ _t17 = _context84.v;
4882
4920
  reject(_t17);
4883
4921
  case 4:
4884
- return _context83.a(2);
4922
+ return _context84.a(2);
4885
4923
  }
4886
- }, _callee83, null, [[0, 3]]);
4924
+ }, _callee84, null, [[0, 3]]);
4887
4925
  }));
4888
- function onContinue(_x72) {
4926
+ function onContinue(_x73) {
4889
4927
  return _onContinue.apply(this, arguments);
4890
4928
  }
4891
4929
  return onContinue;
@@ -4904,54 +4942,54 @@ var ClientProvider = function ClientProvider(_ref) {
4904
4942
  return logout();
4905
4943
  }, callbacks, "Failed to update phone number"));
4906
4944
  case 10:
4907
- _context84.n = 13;
4945
+ _context85.n = 13;
4908
4946
  break;
4909
4947
  case 11:
4910
- _context84.p = 11;
4911
- _t18 = _context84.v;
4948
+ _context85.p = 11;
4949
+ _t18 = _context85.v;
4912
4950
  if (!(_t18 instanceof TurnkeyError)) {
4913
- _context84.n = 12;
4951
+ _context85.n = 12;
4914
4952
  break;
4915
4953
  }
4916
4954
  throw _t18;
4917
4955
  case 12:
4918
4956
  throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t18);
4919
4957
  case 13:
4920
- return _context84.a(2);
4958
+ return _context85.a(2);
4921
4959
  }
4922
- }, _callee84, null, [[7, 11]]);
4960
+ }, _callee85, null, [[7, 11]]);
4923
4961
  }));
4924
- return function (_x71) {
4925
- return _ref102.apply(this, arguments);
4962
+ return function (_x72) {
4963
+ return _ref103.apply(this, arguments);
4926
4964
  };
4927
4965
  }(), [pushPage, masterConfig, client, session, user]);
4928
4966
  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) {
4967
+ var _ref105 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee87(params) {
4968
+ var _ref106, _ref106$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t20;
4969
+ return _regenerator().w(function (_context87) {
4970
+ while (1) switch (_context87.p = _context87.n) {
4933
4971
  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;
4972
+ _ref106 = params || {}, _ref106$successPageDu = _ref106.successPageDuration, successPageDuration = _ref106$successPageDu === void 0 ? 2000 : _ref106$successPageDu, subTitle = _ref106.subTitle, title = _ref106.title, stampWith = _ref106.stampWith;
4935
4973
  if (client) {
4936
- _context86.n = 1;
4974
+ _context87.n = 1;
4937
4975
  break;
4938
4976
  }
4939
4977
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4940
4978
  case 1:
4941
- _context86.n = 2;
4979
+ _context87.n = 2;
4942
4980
  return getSession();
4943
4981
  case 2:
4944
- s = _context86.v;
4982
+ s = _context87.v;
4945
4983
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4946
4984
  if (organizationId) {
4947
- _context86.n = 3;
4985
+ _context87.n = 3;
4948
4986
  break;
4949
4987
  }
4950
4988
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
4951
4989
  case 3:
4952
4990
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
4953
4991
  if (userId) {
4954
- _context86.n = 4;
4992
+ _context87.n = 4;
4955
4993
  break;
4956
4994
  }
4957
4995
  throw new TurnkeyError("A user ID is required to update an email.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -4971,12 +5009,12 @@ var ClientProvider = function ClientProvider(_ref) {
4971
5009
  showTitle: false
4972
5010
  });
4973
5011
  };
4974
- _context86.p = 5;
5012
+ _context87.p = 5;
4975
5013
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
4976
- _context86.n = 6;
5014
+ _context87.n = 6;
4977
5015
  break;
4978
5016
  }
4979
- return _context86.a(2, withTurnkeyErrorHandling(function () {
5017
+ return _context87.a(2, withTurnkeyErrorHandling(function () {
4980
5018
  return new Promise(function (resolve, reject) {
4981
5019
  pushPage({
4982
5020
  key: "Update Email",
@@ -5004,32 +5042,32 @@ var ClientProvider = function ClientProvider(_ref) {
5004
5042
  return logout();
5005
5043
  }));
5006
5044
  case 6:
5007
- _context86.n = 7;
5045
+ _context87.n = 7;
5008
5046
  return initOtp({
5009
5047
  otpType: OtpType.Email,
5010
5048
  contact: params.email
5011
5049
  });
5012
5050
  case 7:
5013
- otpId = _context86.v;
5014
- return _context86.a(2, withTurnkeyErrorHandling(function () {
5051
+ otpId = _context87.v;
5052
+ return _context87.a(2, withTurnkeyErrorHandling(function () {
5015
5053
  return new Promise(function (resolve, reject) {
5016
- var _masterConfig$auth41, _masterConfig$auth42;
5054
+ var _masterConfig$auth42, _masterConfig$auth43;
5017
5055
  pushPage({
5018
5056
  key: "Update Email",
5019
5057
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2({
5020
5058
  otpType: OtpType.Email,
5021
5059
  contact: params.email,
5022
5060
  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,
5061
+ 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,
5062
+ alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth43 = masterConfig.auth) === null || _masterConfig$auth43 === void 0 ? void 0 : _masterConfig$auth43.otpAlphanumeric,
5025
5063
  onContinue: function () {
5026
- var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee85(otpCode) {
5064
+ var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee86(otpCode) {
5027
5065
  var _yield$verifyOtp2, verificationToken, res, _t19;
5028
- return _regenerator().w(function (_context85) {
5029
- while (1) switch (_context85.p = _context85.n) {
5066
+ return _regenerator().w(function (_context86) {
5067
+ while (1) switch (_context86.p = _context86.n) {
5030
5068
  case 0:
5031
- _context85.p = 0;
5032
- _context85.n = 1;
5069
+ _context86.p = 0;
5070
+ _context86.n = 1;
5033
5071
  return verifyOtp({
5034
5072
  otpId: otpId,
5035
5073
  otpCode: otpCode,
@@ -5037,9 +5075,9 @@ var ClientProvider = function ClientProvider(_ref) {
5037
5075
  otpType: OtpType.Email
5038
5076
  });
5039
5077
  case 1:
5040
- _yield$verifyOtp2 = _context85.v;
5078
+ _yield$verifyOtp2 = _context86.v;
5041
5079
  verificationToken = _yield$verifyOtp2.verificationToken;
5042
- _context85.n = 2;
5080
+ _context86.n = 2;
5043
5081
  return updateUserEmail(_objectSpread2({
5044
5082
  email: params.email,
5045
5083
  verificationToken: verificationToken,
@@ -5049,21 +5087,21 @@ var ClientProvider = function ClientProvider(_ref) {
5049
5087
  stampWith: stampWith
5050
5088
  }));
5051
5089
  case 2:
5052
- res = _context85.v;
5090
+ res = _context86.v;
5053
5091
  onSuccess();
5054
5092
  resolve(res);
5055
- _context85.n = 4;
5093
+ _context86.n = 4;
5056
5094
  break;
5057
5095
  case 3:
5058
- _context85.p = 3;
5059
- _t19 = _context85.v;
5096
+ _context86.p = 3;
5097
+ _t19 = _context86.v;
5060
5098
  reject(_t19);
5061
5099
  case 4:
5062
- return _context85.a(2);
5100
+ return _context86.a(2);
5063
5101
  }
5064
- }, _callee85, null, [[0, 3]]);
5102
+ }, _callee86, null, [[0, 3]]);
5065
5103
  }));
5066
- function onContinue(_x74) {
5104
+ function onContinue(_x75) {
5067
5105
  return _onContinue2.apply(this, arguments);
5068
5106
  }
5069
5107
  return onContinue;
@@ -5080,54 +5118,54 @@ var ClientProvider = function ClientProvider(_ref) {
5080
5118
  return logout();
5081
5119
  }, callbacks, "Failed to update email"));
5082
5120
  case 8:
5083
- _context86.n = 11;
5121
+ _context87.n = 11;
5084
5122
  break;
5085
5123
  case 9:
5086
- _context86.p = 9;
5087
- _t20 = _context86.v;
5124
+ _context87.p = 9;
5125
+ _t20 = _context87.v;
5088
5126
  if (!(_t20 instanceof TurnkeyError)) {
5089
- _context86.n = 10;
5127
+ _context87.n = 10;
5090
5128
  break;
5091
5129
  }
5092
5130
  throw _t20;
5093
5131
  case 10:
5094
5132
  throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t20);
5095
5133
  case 11:
5096
- return _context86.a(2);
5134
+ return _context87.a(2);
5097
5135
  }
5098
- }, _callee86, null, [[5, 9]]);
5136
+ }, _callee87, null, [[5, 9]]);
5099
5137
  }));
5100
- return function (_x73) {
5101
- return _ref104.apply(this, arguments);
5138
+ return function (_x74) {
5139
+ return _ref105.apply(this, arguments);
5102
5140
  };
5103
5141
  }(), [pushPage, masterConfig, client, session, user]);
5104
5142
  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) {
5143
+ var _ref107 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee89(params) {
5144
+ var _ref108, _ref108$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t22;
5145
+ return _regenerator().w(function (_context89) {
5146
+ while (1) switch (_context89.p = _context89.n) {
5109
5147
  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;
5148
+ _ref108 = params || {}, _ref108$successPageDu = _ref108.successPageDuration, successPageDuration = _ref108$successPageDu === void 0 ? 2000 : _ref108$successPageDu, subTitle = _ref108.subTitle, title = _ref108.title, stampWith = _ref108.stampWith;
5111
5149
  if (client) {
5112
- _context88.n = 1;
5150
+ _context89.n = 1;
5113
5151
  break;
5114
5152
  }
5115
5153
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5116
5154
  case 1:
5117
- _context88.n = 2;
5155
+ _context89.n = 2;
5118
5156
  return getSession();
5119
5157
  case 2:
5120
- s = _context88.v;
5158
+ s = _context89.v;
5121
5159
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5122
5160
  if (organizationId) {
5123
- _context88.n = 3;
5161
+ _context89.n = 3;
5124
5162
  break;
5125
5163
  }
5126
5164
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5127
5165
  case 3:
5128
5166
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5129
5167
  if (userId) {
5130
- _context88.n = 4;
5168
+ _context89.n = 4;
5131
5169
  break;
5132
5170
  }
5133
5171
  throw new TurnkeyError("A user ID is required to add an email.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5147,12 +5185,12 @@ var ClientProvider = function ClientProvider(_ref) {
5147
5185
  showTitle: false
5148
5186
  });
5149
5187
  };
5150
- _context88.p = 5;
5188
+ _context89.p = 5;
5151
5189
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
5152
- _context88.n = 6;
5190
+ _context89.n = 6;
5153
5191
  break;
5154
5192
  }
5155
- return _context88.a(2, withTurnkeyErrorHandling(function () {
5193
+ return _context89.a(2, withTurnkeyErrorHandling(function () {
5156
5194
  return new Promise(function (resolve, reject) {
5157
5195
  pushPage({
5158
5196
  key: "Add Email",
@@ -5180,32 +5218,32 @@ var ClientProvider = function ClientProvider(_ref) {
5180
5218
  return logout();
5181
5219
  }));
5182
5220
  case 6:
5183
- _context88.n = 7;
5221
+ _context89.n = 7;
5184
5222
  return initOtp({
5185
5223
  otpType: OtpType.Email,
5186
5224
  contact: params.email
5187
5225
  });
5188
5226
  case 7:
5189
- otpId = _context88.v;
5190
- return _context88.a(2, withTurnkeyErrorHandling(function () {
5227
+ otpId = _context89.v;
5228
+ return _context89.a(2, withTurnkeyErrorHandling(function () {
5191
5229
  return new Promise(function (resolve, reject) {
5192
- var _masterConfig$auth43, _masterConfig$auth44;
5230
+ var _masterConfig$auth44, _masterConfig$auth45;
5193
5231
  pushPage({
5194
5232
  key: "Add Email",
5195
5233
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2({
5196
5234
  otpType: OtpType.Email,
5197
5235
  contact: params.email,
5198
5236
  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,
5237
+ 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,
5238
+ alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth45 = masterConfig.auth) === null || _masterConfig$auth45 === void 0 ? void 0 : _masterConfig$auth45.otpAlphanumeric,
5201
5239
  onContinue: function () {
5202
- var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee87(otpCode) {
5240
+ var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee88(otpCode) {
5203
5241
  var _yield$verifyOtp3, verificationToken, res, _t21;
5204
- return _regenerator().w(function (_context87) {
5205
- while (1) switch (_context87.p = _context87.n) {
5242
+ return _regenerator().w(function (_context88) {
5243
+ while (1) switch (_context88.p = _context88.n) {
5206
5244
  case 0:
5207
- _context87.p = 0;
5208
- _context87.n = 1;
5245
+ _context88.p = 0;
5246
+ _context88.n = 1;
5209
5247
  return verifyOtp({
5210
5248
  otpId: otpId,
5211
5249
  otpCode: otpCode,
@@ -5213,9 +5251,9 @@ var ClientProvider = function ClientProvider(_ref) {
5213
5251
  otpType: OtpType.Email
5214
5252
  });
5215
5253
  case 1:
5216
- _yield$verifyOtp3 = _context87.v;
5254
+ _yield$verifyOtp3 = _context88.v;
5217
5255
  verificationToken = _yield$verifyOtp3.verificationToken;
5218
- _context87.n = 2;
5256
+ _context88.n = 2;
5219
5257
  return updateUserEmail({
5220
5258
  email: params.email,
5221
5259
  verificationToken: verificationToken,
@@ -5224,21 +5262,21 @@ var ClientProvider = function ClientProvider(_ref) {
5224
5262
  stampWith: stampWith
5225
5263
  });
5226
5264
  case 2:
5227
- res = _context87.v;
5265
+ res = _context88.v;
5228
5266
  onSuccess();
5229
5267
  resolve(res);
5230
- _context87.n = 4;
5268
+ _context88.n = 4;
5231
5269
  break;
5232
5270
  case 3:
5233
- _context87.p = 3;
5234
- _t21 = _context87.v;
5271
+ _context88.p = 3;
5272
+ _t21 = _context88.v;
5235
5273
  reject(_t21);
5236
5274
  case 4:
5237
- return _context87.a(2);
5275
+ return _context88.a(2);
5238
5276
  }
5239
- }, _callee87, null, [[0, 3]]);
5277
+ }, _callee88, null, [[0, 3]]);
5240
5278
  }));
5241
- function onContinue(_x76) {
5279
+ function onContinue(_x77) {
5242
5280
  return _onContinue3.apply(this, arguments);
5243
5281
  }
5244
5282
  return onContinue;
@@ -5255,67 +5293,67 @@ var ClientProvider = function ClientProvider(_ref) {
5255
5293
  return logout();
5256
5294
  }, callbacks, "Failed to add email"));
5257
5295
  case 8:
5258
- _context88.n = 11;
5296
+ _context89.n = 11;
5259
5297
  break;
5260
5298
  case 9:
5261
- _context88.p = 9;
5262
- _t22 = _context88.v;
5299
+ _context89.p = 9;
5300
+ _t22 = _context89.v;
5263
5301
  if (!(_t22 instanceof TurnkeyError)) {
5264
- _context88.n = 10;
5302
+ _context89.n = 10;
5265
5303
  break;
5266
5304
  }
5267
5305
  throw _t22;
5268
5306
  case 10:
5269
5307
  throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t22);
5270
5308
  case 11:
5271
- return _context88.a(2);
5309
+ return _context89.a(2);
5272
5310
  }
5273
- }, _callee88, null, [[5, 9]]);
5311
+ }, _callee89, null, [[5, 9]]);
5274
5312
  }));
5275
- return function (_x75) {
5276
- return _ref106.apply(this, arguments);
5313
+ return function (_x76) {
5314
+ return _ref107.apply(this, arguments);
5277
5315
  };
5278
5316
  }(), [pushPage, client, session, user]);
5279
5317
  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) {
5318
+ var _ref109 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(params) {
5319
+ var _masterConfig$auth46, _masterConfig$auth46$;
5320
+ var _ref110, _ref110$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t24;
5321
+ return _regenerator().w(function (_context91) {
5322
+ while (1) switch (_context91.p = _context91.n) {
5285
5323
  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;
5324
+ _ref110 = params || {}, _ref110$successPageDu = _ref110.successPageDuration, successPageDuration = _ref110$successPageDu === void 0 ? 2000 : _ref110$successPageDu, subTitle = _ref110.subTitle, title = _ref110.title, stampWith = _ref110.stampWith;
5287
5325
  if (client) {
5288
- _context90.n = 1;
5326
+ _context91.n = 1;
5289
5327
  break;
5290
5328
  }
5291
5329
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5292
5330
  case 1:
5293
5331
  if (masterConfig) {
5294
- _context90.n = 2;
5332
+ _context91.n = 2;
5295
5333
  break;
5296
5334
  }
5297
5335
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
5298
5336
  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;
5337
+ if ((_masterConfig$auth46 = masterConfig.auth) !== null && _masterConfig$auth46 !== void 0 && (_masterConfig$auth46$ = _masterConfig$auth46.methods) !== null && _masterConfig$auth46$ !== void 0 && _masterConfig$auth46$.smsOtpAuthEnabled) {
5338
+ _context91.n = 3;
5301
5339
  break;
5302
5340
  }
5303
5341
  throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
5304
5342
  case 3:
5305
- _context90.n = 4;
5343
+ _context91.n = 4;
5306
5344
  return getSession();
5307
5345
  case 4:
5308
- s = _context90.v;
5346
+ s = _context91.v;
5309
5347
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5310
5348
  if (organizationId) {
5311
- _context90.n = 5;
5349
+ _context91.n = 5;
5312
5350
  break;
5313
5351
  }
5314
5352
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5315
5353
  case 5:
5316
5354
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5317
5355
  if (userId) {
5318
- _context90.n = 6;
5356
+ _context91.n = 6;
5319
5357
  break;
5320
5358
  }
5321
5359
  throw new TurnkeyError("A user ID is required to add a phone number.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5335,12 +5373,12 @@ var ClientProvider = function ClientProvider(_ref) {
5335
5373
  showTitle: false
5336
5374
  });
5337
5375
  };
5338
- _context90.p = 7;
5376
+ _context91.p = 7;
5339
5377
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
5340
- _context90.n = 8;
5378
+ _context91.n = 8;
5341
5379
  break;
5342
5380
  }
5343
- return _context90.a(2, withTurnkeyErrorHandling(function () {
5381
+ return _context91.a(2, withTurnkeyErrorHandling(function () {
5344
5382
  return new Promise(function (resolve, reject) {
5345
5383
  pushPage({
5346
5384
  key: "Add Phone Number",
@@ -5368,32 +5406,32 @@ var ClientProvider = function ClientProvider(_ref) {
5368
5406
  return logout();
5369
5407
  }, callbacks, "Failed to add phone number"));
5370
5408
  case 8:
5371
- _context90.n = 9;
5409
+ _context91.n = 9;
5372
5410
  return initOtp({
5373
5411
  otpType: OtpType.Sms,
5374
5412
  contact: params.phoneNumber
5375
5413
  });
5376
5414
  case 9:
5377
- otpId = _context90.v;
5378
- return _context90.a(2, withTurnkeyErrorHandling(function () {
5415
+ otpId = _context91.v;
5416
+ return _context91.a(2, withTurnkeyErrorHandling(function () {
5379
5417
  return new Promise(function (resolve, reject) {
5380
- var _masterConfig$auth46, _masterConfig$auth47;
5418
+ var _masterConfig$auth47, _masterConfig$auth48;
5381
5419
  pushPage({
5382
5420
  key: "Add Phone Number",
5383
5421
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2(_objectSpread2({
5384
5422
  otpType: OtpType.Sms,
5385
5423
  contact: params.phoneNumber,
5386
5424
  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,
5425
+ otpLength: ((_masterConfig$auth47 = masterConfig.auth) === null || _masterConfig$auth47 === void 0 ? void 0 : _masterConfig$auth47.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5426
+ alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth48 = masterConfig.auth) === null || _masterConfig$auth48 === void 0 ? void 0 : _masterConfig$auth48.otpAlphanumeric,
5389
5427
  onContinue: function () {
5390
- var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee89(otpCode) {
5428
+ var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee90(otpCode) {
5391
5429
  var _yield$verifyOtp4, verificationToken, res, _t23;
5392
- return _regenerator().w(function (_context89) {
5393
- while (1) switch (_context89.p = _context89.n) {
5430
+ return _regenerator().w(function (_context90) {
5431
+ while (1) switch (_context90.p = _context90.n) {
5394
5432
  case 0:
5395
- _context89.p = 0;
5396
- _context89.n = 1;
5433
+ _context90.p = 0;
5434
+ _context90.n = 1;
5397
5435
  return verifyOtp({
5398
5436
  otpId: otpId,
5399
5437
  otpCode: otpCode,
@@ -5401,9 +5439,9 @@ var ClientProvider = function ClientProvider(_ref) {
5401
5439
  otpType: OtpType.Sms
5402
5440
  });
5403
5441
  case 1:
5404
- _yield$verifyOtp4 = _context89.v;
5442
+ _yield$verifyOtp4 = _context90.v;
5405
5443
  verificationToken = _yield$verifyOtp4.verificationToken;
5406
- _context89.n = 2;
5444
+ _context90.n = 2;
5407
5445
  return updateUserPhoneNumber({
5408
5446
  phoneNumber: params.phoneNumber,
5409
5447
  verificationToken: verificationToken,
@@ -5412,21 +5450,21 @@ var ClientProvider = function ClientProvider(_ref) {
5412
5450
  stampWith: stampWith
5413
5451
  });
5414
5452
  case 2:
5415
- res = _context89.v;
5453
+ res = _context90.v;
5416
5454
  onSuccess();
5417
5455
  resolve(res);
5418
- _context89.n = 4;
5456
+ _context90.n = 4;
5419
5457
  break;
5420
5458
  case 3:
5421
- _context89.p = 3;
5422
- _t23 = _context89.v;
5459
+ _context90.p = 3;
5460
+ _t23 = _context90.v;
5423
5461
  reject(_t23);
5424
5462
  case 4:
5425
- return _context89.a(2);
5463
+ return _context90.a(2);
5426
5464
  }
5427
- }, _callee89, null, [[0, 3]]);
5465
+ }, _callee90, null, [[0, 3]]);
5428
5466
  }));
5429
- function onContinue(_x78) {
5467
+ function onContinue(_x79) {
5430
5468
  return _onContinue4.apply(this, arguments);
5431
5469
  }
5432
5470
  return onContinue;
@@ -5445,52 +5483,52 @@ var ClientProvider = function ClientProvider(_ref) {
5445
5483
  return logout();
5446
5484
  }, callbacks, "Failed to add phone number"));
5447
5485
  case 10:
5448
- _context90.n = 13;
5486
+ _context91.n = 13;
5449
5487
  break;
5450
5488
  case 11:
5451
- _context90.p = 11;
5452
- _t24 = _context90.v;
5489
+ _context91.p = 11;
5490
+ _t24 = _context91.v;
5453
5491
  if (!(_t24 instanceof TurnkeyError)) {
5454
- _context90.n = 12;
5492
+ _context91.n = 12;
5455
5493
  break;
5456
5494
  }
5457
5495
  throw _t24;
5458
5496
  case 12:
5459
5497
  throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t24);
5460
5498
  case 13:
5461
- return _context90.a(2);
5499
+ return _context91.a(2);
5462
5500
  }
5463
- }, _callee90, null, [[7, 11]]);
5501
+ }, _callee91, null, [[7, 11]]);
5464
5502
  }));
5465
- return function (_x77) {
5466
- return _ref108.apply(this, arguments);
5503
+ return function (_x78) {
5504
+ return _ref109.apply(this, arguments);
5467
5505
  };
5468
5506
  }(), [pushPage, masterConfig, client, session, user]);
5469
5507
  var handleRemovePasskey = useCallback(/*#__PURE__*/function () {
5470
- var _ref110 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(params) {
5508
+ var _ref111 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee92(params) {
5471
5509
  var authenticatorId, _params$successPageDu2, successPageDuration, subTitle, title, stampWith, userId, s, organizationId;
5472
- return _regenerator().w(function (_context91) {
5473
- while (1) switch (_context91.n) {
5510
+ return _regenerator().w(function (_context92) {
5511
+ while (1) switch (_context92.n) {
5474
5512
  case 0:
5475
5513
  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
5514
  if (client) {
5477
- _context91.n = 1;
5515
+ _context92.n = 1;
5478
5516
  break;
5479
5517
  }
5480
5518
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5481
5519
  case 1:
5482
- _context91.n = 2;
5520
+ _context92.n = 2;
5483
5521
  return getSession();
5484
5522
  case 2:
5485
- s = _context91.v;
5523
+ s = _context92.v;
5486
5524
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5487
5525
  if (organizationId) {
5488
- _context91.n = 3;
5526
+ _context92.n = 3;
5489
5527
  break;
5490
5528
  }
5491
5529
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5492
5530
  case 3:
5493
- return _context91.a(2, withTurnkeyErrorHandling(function () {
5531
+ return _context92.a(2, withTurnkeyErrorHandling(function () {
5494
5532
  return new Promise(function (resolve, reject) {
5495
5533
  pushPage({
5496
5534
  key: "Remove Passkey",
@@ -5521,44 +5559,44 @@ var ClientProvider = function ClientProvider(_ref) {
5521
5559
  return logout();
5522
5560
  }, callbacks, "Failed to remove passkey"));
5523
5561
  }
5524
- }, _callee91);
5562
+ }, _callee92);
5525
5563
  }));
5526
- return function (_x79) {
5527
- return _ref110.apply(this, arguments);
5564
+ return function (_x80) {
5565
+ return _ref111.apply(this, arguments);
5528
5566
  };
5529
5567
  }(), [pushPage, masterConfig, client, session, user]);
5530
5568
  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) {
5569
+ var _ref112 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(params) {
5570
+ var _ref113, name, displayName, _ref113$successPageDu, successPageDuration, stampWith, s, organizationId, userId, resPromise, _t25;
5571
+ return _regenerator().w(function (_context93) {
5572
+ while (1) switch (_context93.p = _context93.n) {
5535
5573
  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;
5574
+ _ref113 = params || {}, name = _ref113.name, displayName = _ref113.displayName, _ref113$successPageDu = _ref113.successPageDuration, successPageDuration = _ref113$successPageDu === void 0 ? 2000 : _ref113$successPageDu, stampWith = _ref113.stampWith;
5537
5575
  if (client) {
5538
- _context92.n = 1;
5576
+ _context93.n = 1;
5539
5577
  break;
5540
5578
  }
5541
5579
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5542
5580
  case 1:
5543
- _context92.n = 2;
5581
+ _context93.n = 2;
5544
5582
  return getSession();
5545
5583
  case 2:
5546
- s = _context92.v;
5584
+ s = _context93.v;
5547
5585
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5548
5586
  if (organizationId) {
5549
- _context92.n = 3;
5587
+ _context93.n = 3;
5550
5588
  break;
5551
5589
  }
5552
5590
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5553
5591
  case 3:
5554
5592
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5555
5593
  if (userId) {
5556
- _context92.n = 4;
5594
+ _context93.n = 4;
5557
5595
  break;
5558
5596
  }
5559
5597
  throw new TurnkeyError("A user ID or a valid session is required to add a passkey.", TurnkeyErrorCodes.INVALID_REQUEST);
5560
5598
  case 4:
5561
- _context92.p = 4;
5599
+ _context93.p = 4;
5562
5600
  resPromise = addPasskey(_objectSpread2(_objectSpread2(_objectSpread2({}, name && {
5563
5601
  name: name
5564
5602
  }), displayName && {
@@ -5583,55 +5621,55 @@ var ClientProvider = function ClientProvider(_ref) {
5583
5621
  showTitle: false
5584
5622
  });
5585
5623
  });
5586
- _context92.n = 5;
5624
+ _context93.n = 5;
5587
5625
  return resPromise;
5588
5626
  case 5:
5589
- return _context92.a(2, _context92.v);
5627
+ return _context93.a(2, _context93.v);
5590
5628
  case 6:
5591
- _context92.p = 6;
5592
- _t25 = _context92.v;
5629
+ _context93.p = 6;
5630
+ _t25 = _context93.v;
5593
5631
  if (!(_t25 instanceof TurnkeyError)) {
5594
- _context92.n = 7;
5632
+ _context93.n = 7;
5595
5633
  break;
5596
5634
  }
5597
5635
  throw _t25;
5598
5636
  case 7:
5599
5637
  throw new TurnkeyError("Failed to add passkey in handler.", TurnkeyErrorCodes.ADD_PASSKEY_ERROR, _t25);
5600
5638
  case 8:
5601
- return _context92.a(2);
5639
+ return _context93.a(2);
5602
5640
  }
5603
- }, _callee92, null, [[4, 6]]);
5641
+ }, _callee93, null, [[4, 6]]);
5604
5642
  }));
5605
- return function (_x80) {
5606
- return _ref111.apply(this, arguments);
5643
+ return function (_x81) {
5644
+ return _ref112.apply(this, arguments);
5607
5645
  };
5608
5646
  }(), [pushPage, masterConfig, client, session, user]);
5609
5647
  var handleRemoveOauthProvider = useCallback(/*#__PURE__*/function () {
5610
- var _ref113 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(params) {
5648
+ var _ref114 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(params) {
5611
5649
  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) {
5650
+ return _regenerator().w(function (_context94) {
5651
+ while (1) switch (_context94.p = _context94.n) {
5614
5652
  case 0:
5615
5653
  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
5654
  if (client) {
5617
- _context93.n = 1;
5655
+ _context94.n = 1;
5618
5656
  break;
5619
5657
  }
5620
5658
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5621
5659
  case 1:
5622
- _context93.n = 2;
5660
+ _context94.n = 2;
5623
5661
  return getSession();
5624
5662
  case 2:
5625
- s = _context93.v;
5663
+ s = _context94.v;
5626
5664
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5627
5665
  if (organizationId) {
5628
- _context93.n = 3;
5666
+ _context94.n = 3;
5629
5667
  break;
5630
5668
  }
5631
5669
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5632
5670
  case 3:
5633
- _context93.p = 3;
5634
- return _context93.a(2, new Promise(function (resolve, reject) {
5671
+ _context94.p = 3;
5672
+ return _context94.a(2, new Promise(function (resolve, reject) {
5635
5673
  pushPage({
5636
5674
  key: "Remove OAuth Provider",
5637
5675
  content: jsx(RemoveOAuthProvider, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5659,68 +5697,68 @@ var ClientProvider = function ClientProvider(_ref) {
5659
5697
  });
5660
5698
  }));
5661
5699
  case 4:
5662
- _context93.p = 4;
5663
- _t26 = _context93.v;
5700
+ _context94.p = 4;
5701
+ _t26 = _context94.v;
5664
5702
  if (!(_t26 instanceof TurnkeyError)) {
5665
- _context93.n = 5;
5703
+ _context94.n = 5;
5666
5704
  break;
5667
5705
  }
5668
5706
  throw _t26;
5669
5707
  case 5:
5670
5708
  throw new TurnkeyError("Failed to remove OAuth provider in handler.", TurnkeyErrorCodes.REMOVE_OAUTH_PROVIDER_ERROR, _t26);
5671
5709
  case 6:
5672
- return _context93.a(2);
5710
+ return _context94.a(2);
5673
5711
  }
5674
- }, _callee93, null, [[3, 4]]);
5712
+ }, _callee94, null, [[3, 4]]);
5675
5713
  }));
5676
- return function (_x81) {
5677
- return _ref113.apply(this, arguments);
5714
+ return function (_x82) {
5715
+ return _ref114.apply(this, arguments);
5678
5716
  };
5679
5717
  }(), [pushPage, masterConfig, client, session, user]);
5680
5718
  var handleAddOauthProvider = useCallback(/*#__PURE__*/function () {
5681
- var _ref114 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(params) {
5719
+ var _ref115 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(params) {
5682
5720
  var providerName, stampWith, _params$successPageDu4, successPageDuration, s, organizationId, userId;
5683
- return _regenerator().w(function (_context96) {
5684
- while (1) switch (_context96.n) {
5721
+ return _regenerator().w(function (_context97) {
5722
+ while (1) switch (_context97.n) {
5685
5723
  case 0:
5686
5724
  if (client) {
5687
- _context96.n = 1;
5725
+ _context97.n = 1;
5688
5726
  break;
5689
5727
  }
5690
5728
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5691
5729
  case 1:
5692
5730
  providerName = params.providerName, stampWith = params.stampWith, _params$successPageDu4 = params.successPageDuration, successPageDuration = _params$successPageDu4 === void 0 ? 2000 : _params$successPageDu4;
5693
- _context96.n = 2;
5731
+ _context97.n = 2;
5694
5732
  return getSession();
5695
5733
  case 2:
5696
- s = _context96.v;
5734
+ s = _context97.v;
5697
5735
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5698
5736
  if (organizationId) {
5699
- _context96.n = 3;
5737
+ _context97.n = 3;
5700
5738
  break;
5701
5739
  }
5702
5740
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5703
5741
  case 3:
5704
5742
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5705
5743
  if (userId) {
5706
- _context96.n = 4;
5744
+ _context97.n = 4;
5707
5745
  break;
5708
5746
  }
5709
5747
  throw new TurnkeyError("A user ID is required to add an OAuth provider.", TurnkeyErrorCodes.INVALID_REQUEST);
5710
5748
  case 4:
5711
- return _context96.a(2, new Promise(/*#__PURE__*/function () {
5712
- var _ref115 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(resolve, reject) {
5749
+ return _context97.a(2, new Promise(/*#__PURE__*/function () {
5750
+ var _ref116 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(resolve, reject) {
5713
5751
  var onOauthSuccess, _t27, _t28;
5714
- return _regenerator().w(function (_context95) {
5715
- while (1) switch (_context95.p = _context95.n) {
5752
+ return _regenerator().w(function (_context96) {
5753
+ while (1) switch (_context96.p = _context96.n) {
5716
5754
  case 0:
5717
- _context95.p = 0;
5755
+ _context96.p = 0;
5718
5756
  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) {
5757
+ var _ref117 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(params) {
5758
+ return _regenerator().w(function (_context95) {
5759
+ while (1) switch (_context95.n) {
5722
5760
  case 0:
5723
- _context94.n = 1;
5761
+ _context95.n = 1;
5724
5762
  return addOauthProvider({
5725
5763
  providerName: params.providerName,
5726
5764
  oidcToken: params.oidcToken,
@@ -5743,107 +5781,107 @@ var ClientProvider = function ClientProvider(_ref) {
5743
5781
  showTitle: false
5744
5782
  });
5745
5783
  case 2:
5746
- return _context94.a(2);
5784
+ return _context95.a(2);
5747
5785
  }
5748
- }, _callee94);
5786
+ }, _callee95);
5749
5787
  }));
5750
- return function onOauthSuccess(_x85) {
5751
- return _ref116.apply(this, arguments);
5788
+ return function onOauthSuccess(_x86) {
5789
+ return _ref117.apply(this, arguments);
5752
5790
  };
5753
5791
  }();
5754
5792
  _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;
5793
+ _context96.n = _t27 === OAuthProviders.DISCORD ? 1 : _t27 === OAuthProviders.X ? 3 : _t27 === OAuthProviders.GOOGLE ? 5 : _t27 === OAuthProviders.APPLE ? 7 : _t27 === OAuthProviders.FACEBOOK ? 9 : 11;
5756
5794
  break;
5757
5795
  case 1:
5758
- _context95.n = 2;
5796
+ _context96.n = 2;
5759
5797
  return handleDiscordOauth({
5760
5798
  openInPage: false,
5761
5799
  onOauthSuccess: onOauthSuccess
5762
5800
  });
5763
5801
  case 2:
5764
- return _context95.a(2, _context95.v);
5802
+ return _context96.a(2, _context96.v);
5765
5803
  case 3:
5766
- _context95.n = 4;
5804
+ _context96.n = 4;
5767
5805
  return handleXOauth({
5768
5806
  openInPage: false,
5769
5807
  onOauthSuccess: onOauthSuccess
5770
5808
  });
5771
5809
  case 4:
5772
- return _context95.a(2, _context95.v);
5810
+ return _context96.a(2, _context96.v);
5773
5811
  case 5:
5774
- _context95.n = 6;
5812
+ _context96.n = 6;
5775
5813
  return handleGoogleOauth({
5776
5814
  openInPage: false,
5777
5815
  onOauthSuccess: onOauthSuccess
5778
5816
  });
5779
5817
  case 6:
5780
- return _context95.a(2, _context95.v);
5818
+ return _context96.a(2, _context96.v);
5781
5819
  case 7:
5782
- _context95.n = 8;
5820
+ _context96.n = 8;
5783
5821
  return handleAppleOauth({
5784
5822
  openInPage: false,
5785
5823
  onOauthSuccess: onOauthSuccess
5786
5824
  });
5787
5825
  case 8:
5788
- return _context95.a(2, _context95.v);
5826
+ return _context96.a(2, _context96.v);
5789
5827
  case 9:
5790
- _context95.n = 10;
5828
+ _context96.n = 10;
5791
5829
  return handleFacebookOauth({
5792
5830
  openInPage: false,
5793
5831
  onOauthSuccess: onOauthSuccess
5794
5832
  });
5795
5833
  case 10:
5796
- return _context95.a(2, _context95.v);
5834
+ return _context96.a(2, _context96.v);
5797
5835
  case 11:
5798
5836
  throw new TurnkeyError("Unsupported OAuth provider: ".concat(providerName), TurnkeyErrorCodes.NOT_FOUND);
5799
5837
  case 12:
5800
- _context95.n = 14;
5838
+ _context96.n = 14;
5801
5839
  break;
5802
5840
  case 13:
5803
- _context95.p = 13;
5804
- _t28 = _context95.v;
5841
+ _context96.p = 13;
5842
+ _t28 = _context96.v;
5805
5843
  reject(_t28);
5806
5844
  case 14:
5807
- return _context95.a(2);
5845
+ return _context96.a(2);
5808
5846
  }
5809
- }, _callee95, null, [[0, 13]]);
5847
+ }, _callee96, null, [[0, 13]]);
5810
5848
  }));
5811
- return function (_x83, _x84) {
5812
- return _ref115.apply(this, arguments);
5849
+ return function (_x84, _x85) {
5850
+ return _ref116.apply(this, arguments);
5813
5851
  };
5814
5852
  }()));
5815
5853
  }
5816
- }, _callee96);
5854
+ }, _callee97);
5817
5855
  }));
5818
- return function (_x82) {
5819
- return _ref114.apply(this, arguments);
5856
+ return function (_x83) {
5857
+ return _ref115.apply(this, arguments);
5820
5858
  };
5821
5859
  }(), [pushPage, masterConfig, client, session, user]);
5822
5860
  var handleConnectExternalWallet = useCallback(/*#__PURE__*/function () {
5823
- var _ref117 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(params) {
5861
+ var _ref118 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(params) {
5824
5862
  var _masterConfig$walletC4, _masterConfig$walletC5;
5825
- var _ref118, _ref118$successPageDu, successPageDuration, providers;
5826
- return _regenerator().w(function (_context97) {
5827
- while (1) switch (_context97.n) {
5863
+ var _ref119, _ref119$successPageDu, successPageDuration, providers;
5864
+ return _regenerator().w(function (_context98) {
5865
+ while (1) switch (_context98.n) {
5828
5866
  case 0:
5829
- _ref118 = params || {}, _ref118$successPageDu = _ref118.successPageDuration, successPageDuration = _ref118$successPageDu === void 0 ? 2000 : _ref118$successPageDu;
5867
+ _ref119 = params || {}, _ref119$successPageDu = _ref119.successPageDuration, successPageDuration = _ref119$successPageDu === void 0 ? 2000 : _ref119$successPageDu;
5830
5868
  if (client) {
5831
- _context97.n = 1;
5869
+ _context98.n = 1;
5832
5870
  break;
5833
5871
  }
5834
5872
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5835
5873
  case 1:
5836
5874
  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;
5875
+ _context98.n = 2;
5838
5876
  break;
5839
5877
  }
5840
5878
  throw new TurnkeyError("Wallet connecting is not enabled.", TurnkeyErrorCodes.FEATURE_NOT_ENABLED);
5841
5879
  case 2:
5842
- _context97.n = 3;
5880
+ _context98.n = 3;
5843
5881
  return fetchWalletProviders();
5844
5882
  case 3:
5845
- providers = _context97.v;
5846
- return _context97.a(2, new Promise(function (resolve, reject) {
5883
+ providers = _context98.v;
5884
+ return _context98.a(2, new Promise(function (resolve, reject) {
5847
5885
  pushPage({
5848
5886
  key: "Connect wallet",
5849
5887
  content: jsx(ConnectWalletModal, {
@@ -5865,32 +5903,32 @@ var ClientProvider = function ClientProvider(_ref) {
5865
5903
  });
5866
5904
  }));
5867
5905
  }
5868
- }, _callee97);
5906
+ }, _callee98);
5869
5907
  }));
5870
- return function (_x86) {
5871
- return _ref117.apply(this, arguments);
5908
+ return function (_x87) {
5909
+ return _ref118.apply(this, arguments);
5872
5910
  };
5873
5911
  }(), [pushPage, masterConfig, client, session, user]);
5874
5912
  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) {
5913
+ var _ref120 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99(params) {
5914
+ var _ref121, _ref121$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t29;
5915
+ return _regenerator().w(function (_context99) {
5916
+ while (1) switch (_context99.p = _context99.n) {
5879
5917
  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;
5918
+ _ref121 = params || {}, _ref121$successPageDu = _ref121.successPageDuration, successPageDuration = _ref121$successPageDu === void 0 ? 2000 : _ref121$successPageDu, stampWith = _ref121.stampWith, userId = _ref121.userId;
5919
+ _context99.n = 1;
5882
5920
  return getSession();
5883
5921
  case 1:
5884
- s = _context98.v;
5922
+ s = _context99.v;
5885
5923
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5886
5924
  if (organizationId) {
5887
- _context98.n = 2;
5925
+ _context99.n = 2;
5888
5926
  break;
5889
5927
  }
5890
5928
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5891
5929
  case 2:
5892
- _context98.p = 2;
5893
- return _context98.a(2, new Promise(function (resolve, reject) {
5930
+ _context99.p = 2;
5931
+ return _context99.a(2, new Promise(function (resolve, reject) {
5894
5932
  pushPage({
5895
5933
  key: "Remove Email",
5896
5934
  content: jsx(RemoveEmail, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5917,44 +5955,44 @@ var ClientProvider = function ClientProvider(_ref) {
5917
5955
  });
5918
5956
  }));
5919
5957
  case 3:
5920
- _context98.p = 3;
5921
- _t29 = _context98.v;
5958
+ _context99.p = 3;
5959
+ _t29 = _context99.v;
5922
5960
  if (!(_t29 instanceof TurnkeyError)) {
5923
- _context98.n = 4;
5961
+ _context99.n = 4;
5924
5962
  break;
5925
5963
  }
5926
5964
  throw _t29;
5927
5965
  case 4:
5928
5966
  throw new TurnkeyError("Failed to remove user email.", TurnkeyErrorCodes.UPDATE_USER_EMAIL_ERROR, _t29);
5929
5967
  case 5:
5930
- return _context98.a(2);
5968
+ return _context99.a(2);
5931
5969
  }
5932
- }, _callee98, null, [[2, 3]]);
5970
+ }, _callee99, null, [[2, 3]]);
5933
5971
  }));
5934
- return function (_x87) {
5935
- return _ref119.apply(this, arguments);
5972
+ return function (_x88) {
5973
+ return _ref120.apply(this, arguments);
5936
5974
  };
5937
5975
  }(), [pushPage, masterConfig, client, session, user]);
5938
5976
  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) {
5977
+ var _ref122 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100(params) {
5978
+ var _ref123, _ref123$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t30;
5979
+ return _regenerator().w(function (_context100) {
5980
+ while (1) switch (_context100.p = _context100.n) {
5943
5981
  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;
5982
+ _ref123 = params || {}, _ref123$successPageDu = _ref123.successPageDuration, successPageDuration = _ref123$successPageDu === void 0 ? 2000 : _ref123$successPageDu, stampWith = _ref123.stampWith, userId = _ref123.userId;
5983
+ _context100.n = 1;
5946
5984
  return getSession();
5947
5985
  case 1:
5948
- s = _context99.v;
5986
+ s = _context100.v;
5949
5987
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5950
5988
  if (organizationId) {
5951
- _context99.n = 2;
5989
+ _context100.n = 2;
5952
5990
  break;
5953
5991
  }
5954
5992
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5955
5993
  case 2:
5956
- _context99.p = 2;
5957
- return _context99.a(2, new Promise(function (resolve, reject) {
5994
+ _context100.p = 2;
5995
+ return _context100.a(2, new Promise(function (resolve, reject) {
5958
5996
  pushPage({
5959
5997
  key: "Remove Phone Number",
5960
5998
  content: jsx(RemovePhoneNumber, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5981,58 +6019,58 @@ var ClientProvider = function ClientProvider(_ref) {
5981
6019
  });
5982
6020
  }));
5983
6021
  case 3:
5984
- _context99.p = 3;
5985
- _t30 = _context99.v;
6022
+ _context100.p = 3;
6023
+ _t30 = _context100.v;
5986
6024
  if (!(_t30 instanceof TurnkeyError)) {
5987
- _context99.n = 4;
6025
+ _context100.n = 4;
5988
6026
  break;
5989
6027
  }
5990
6028
  throw _t30;
5991
6029
  case 4:
5992
6030
  throw new TurnkeyError("Failed to remove user phone number.", TurnkeyErrorCodes.UPDATE_USER_PHONE_NUMBER_ERROR, _t30);
5993
6031
  case 5:
5994
- return _context99.a(2);
6032
+ return _context100.a(2);
5995
6033
  }
5996
- }, _callee99, null, [[2, 3]]);
6034
+ }, _callee100, null, [[2, 3]]);
5997
6035
  }));
5998
- return function (_x88) {
5999
- return _ref121.apply(this, arguments);
6036
+ return function (_x89) {
6037
+ return _ref122.apply(this, arguments);
6000
6038
  };
6001
6039
  }(), [pushPage, masterConfig, client, session, user]);
6002
6040
  useEffect(function () {
6003
6041
  if (proxyAuthConfigRef.current) return;
6004
6042
  // Only fetch the proxy auth config once. Use that to build the master config.
6005
6043
  var fetchProxyAuthConfig = /*#__PURE__*/function () {
6006
- var _ref123 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100() {
6044
+ var _ref124 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101() {
6007
6045
  var proxyAuthConfig;
6008
- return _regenerator().w(function (_context100) {
6009
- while (1) switch (_context100.p = _context100.n) {
6046
+ return _regenerator().w(function (_context101) {
6047
+ while (1) switch (_context101.p = _context101.n) {
6010
6048
  case 0:
6011
- _context100.p = 0;
6049
+ _context101.p = 0;
6012
6050
  if (!config.authProxyConfigId) {
6013
- _context100.n = 2;
6051
+ _context101.n = 2;
6014
6052
  break;
6015
6053
  }
6016
- _context100.n = 1;
6054
+ _context101.n = 1;
6017
6055
  return getAuthProxyConfig(config.authProxyConfigId, config.authProxyUrl);
6018
6056
  case 1:
6019
- proxyAuthConfig = _context100.v;
6057
+ proxyAuthConfig = _context101.v;
6020
6058
  proxyAuthConfigRef.current = proxyAuthConfig;
6021
6059
  case 2:
6022
6060
  setMasterConfig(buildConfig(proxyAuthConfig));
6023
- _context100.n = 4;
6061
+ _context101.n = 4;
6024
6062
  break;
6025
6063
  case 3:
6026
- _context100.p = 3;
6027
- _context100.v;
6064
+ _context101.p = 3;
6065
+ _context101.v;
6028
6066
  setClientState(ClientState.Error);
6029
6067
  case 4:
6030
- return _context100.a(2);
6068
+ return _context101.a(2);
6031
6069
  }
6032
- }, _callee100, null, [[0, 3]]);
6070
+ }, _callee101, null, [[0, 3]]);
6033
6071
  }));
6034
6072
  return function fetchProxyAuthConfig() {
6035
- return _ref123.apply(this, arguments);
6073
+ return _ref124.apply(this, arguments);
6036
6074
  };
6037
6075
  }();
6038
6076
  fetchProxyAuthConfig();
@@ -6064,29 +6102,29 @@ var ClientProvider = function ClientProvider(_ref) {
6064
6102
  useEffect(function () {
6065
6103
  if (!client) return;
6066
6104
  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) {
6105
+ var _ref125 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102() {
6106
+ return _regenerator().w(function (_context102) {
6107
+ while (1) switch (_context102.n) {
6070
6108
  case 0:
6071
6109
  if (!session) {
6072
- _context101.n = 2;
6110
+ _context102.n = 2;
6073
6111
  break;
6074
6112
  }
6075
- _context101.n = 1;
6113
+ _context102.n = 1;
6076
6114
  return debouncedRefreshWallets();
6077
6115
  case 1:
6078
- _context101.n = 3;
6116
+ _context102.n = 3;
6079
6117
  break;
6080
6118
  case 2:
6081
- _context101.n = 3;
6119
+ _context102.n = 3;
6082
6120
  return debouncedFetchWalletProviders();
6083
6121
  case 3:
6084
- return _context101.a(2);
6122
+ return _context102.a(2);
6085
6123
  }
6086
- }, _callee101);
6124
+ }, _callee102);
6087
6125
  }));
6088
6126
  return function handleUpdateState() {
6089
- return _ref124.apply(this, arguments);
6127
+ return _ref125.apply(this, arguments);
6090
6128
  };
6091
6129
  }();
6092
6130
  var cleanup = function cleanup() {};
@@ -6139,6 +6177,7 @@ var ClientProvider = function ClientProvider(_ref) {
6139
6177
  walletProviders: walletProviders,
6140
6178
  config: masterConfig,
6141
6179
  httpClient: client === null || client === void 0 ? void 0 : client.httpClient,
6180
+ createHttpClient: createHttpClient,
6142
6181
  createPasskey: createPasskey,
6143
6182
  logout: logout,
6144
6183
  loginWithPasskey: loginWithPasskey,
@@ -6147,6 +6186,7 @@ var ClientProvider = function ClientProvider(_ref) {
6147
6186
  connectWalletAccount: connectWalletAccount,
6148
6187
  disconnectWalletAccount: disconnectWalletAccount,
6149
6188
  switchWalletAccountChain: switchWalletAccountChain,
6189
+ buildWalletLoginRequest: buildWalletLoginRequest,
6150
6190
  loginWithWallet: loginWithWallet,
6151
6191
  signUpWithWallet: signUpWithWallet,
6152
6192
  loginOrSignupWithWallet: loginOrSignupWithWallet,