@turnkey/react-wallet-kit 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/components/design/Svg.d.ts.map +1 -1
  2. package/dist/components/design/Svg.js +0 -2
  3. package/dist/components/design/Svg.js.map +1 -1
  4. package/dist/components/design/Svg.mjs +0 -2
  5. package/dist/components/design/Svg.mjs.map +1 -1
  6. package/dist/components/verify/Verify.d.ts +9 -0
  7. package/dist/components/verify/Verify.d.ts.map +1 -0
  8. package/dist/components/verify/Verify.js +121 -0
  9. package/dist/components/verify/Verify.js.map +1 -0
  10. package/dist/components/verify/Verify.mjs +149 -0
  11. package/dist/components/verify/Verify.mjs.map +1 -0
  12. package/dist/providers/client/Provider.d.ts.map +1 -1
  13. package/dist/providers/client/Provider.js +83 -14
  14. package/dist/providers/client/Provider.js.map +1 -1
  15. package/dist/providers/client/Provider.mjs +823 -714
  16. package/dist/providers/client/Provider.mjs.map +1 -1
  17. package/dist/providers/client/Types.d.ts +16 -1
  18. package/dist/providers/client/Types.d.ts.map +1 -1
  19. package/dist/providers/client/Types.js.map +1 -1
  20. package/dist/providers/client/Types.mjs.map +1 -1
  21. package/dist/providers/modal/Provider.d.ts +1 -0
  22. package/dist/providers/modal/Provider.d.ts.map +1 -1
  23. package/dist/providers/modal/Provider.js.map +1 -1
  24. package/dist/providers/modal/Provider.mjs.map +1 -1
  25. package/dist/providers/modal/Root.d.ts.map +1 -1
  26. package/dist/providers/modal/Root.js +4 -2
  27. package/dist/providers/modal/Root.js.map +1 -1
  28. package/dist/providers/modal/Root.mjs +4 -2
  29. package/dist/providers/modal/Root.mjs.map +1 -1
  30. package/dist/styles.css +1 -1
  31. package/dist/types/base.d.ts +2 -0
  32. package/dist/types/base.d.ts.map +1 -1
  33. package/dist/types/base.js.map +1 -1
  34. package/dist/types/base.mjs.map +1 -1
  35. package/dist/types/method-types.d.ts +7 -1
  36. package/dist/types/method-types.d.ts.map +1 -1
  37. package/package.json +4 -4
@@ -28,6 +28,7 @@ import { ClientContext } from './Types.mjs';
28
28
  import { OtpVerification } from '../../components/auth/OTP.mjs';
29
29
  import { RemoveEmail } from '../../components/user/RemoveEmail.mjs';
30
30
  import { RemovePhoneNumber } from '../../components/user/RemovePhoneNumber.mjs';
31
+ import { VerifyPage } from '../../components/verify/Verify.mjs';
31
32
 
32
33
  /**
33
34
  * Provides Turnkey client authentication, session management, wallet operations, and user profile management
@@ -788,11 +789,11 @@ var ClientProvider = function ClientProvider(_ref) {
788
789
  * @throws {TurnkeyError} If an error occurs while scheduling the session expiration.
789
790
  */
790
791
  function _initializeWalletProviderListeners() {
791
- _initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee107(walletProviders, onUpdateState) {
792
+ _initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee109(walletProviders, onUpdateState) {
792
793
  var _masterConfig$walletC0, _masterConfig$walletC1, _masterConfig$walletC10, _masterConfig$walletC11;
793
794
  var cleanups, nativeOnly, ethProviders, solProviders, wcProviders, wcProvider, attachEthereumListeners, attachSolanaListeners, _wcProvider$provider, _wcProvider$provider$, standardEvents, unsubscribe;
794
- return _regenerator().w(function (_context107) {
795
- while (1) switch (_context107.n) {
795
+ return _regenerator().w(function (_context109) {
796
+ while (1) switch (_context109.n) {
796
797
  case 0:
797
798
  attachSolanaListeners = function _attachSolanaListener(provider, onUpdateState) {
798
799
  var _provider$features;
@@ -800,19 +801,19 @@ var ClientProvider = function ClientProvider(_ref) {
800
801
  var walletEvents = provider === null || provider === void 0 ? void 0 : (_provider$features = provider.features) === null || _provider$features === void 0 ? void 0 : _provider$features["standard:events"];
801
802
  if (walletEvents !== null && walletEvents !== void 0 && walletEvents.on) {
802
803
  var offChange = walletEvents.on("change", /*#__PURE__*/function () {
803
- var _ref128 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee105(_evt) {
804
- return _regenerator().w(function (_context105) {
805
- while (1) switch (_context105.n) {
804
+ var _ref131 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee107(_evt) {
805
+ return _regenerator().w(function (_context107) {
806
+ while (1) switch (_context107.n) {
806
807
  case 0:
807
- _context105.n = 1;
808
+ _context107.n = 1;
808
809
  return onUpdateState();
809
810
  case 1:
810
- return _context105.a(2);
811
+ return _context107.a(2);
811
812
  }
812
- }, _callee105);
813
+ }, _callee107);
813
814
  }));
814
- return function (_x92) {
815
- return _ref128.apply(this, arguments);
815
+ return function (_x94) {
816
+ return _ref131.apply(this, arguments);
816
817
  };
817
818
  }());
818
819
  cleanups.push(offChange);
@@ -826,31 +827,31 @@ var ClientProvider = function ClientProvider(_ref) {
826
827
  attachEthereumListeners = function _attachEthereumListen(provider, onUpdateState) {
827
828
  if (typeof provider.on !== "function") return;
828
829
  var handleChainChanged = /*#__PURE__*/function () {
829
- var _ref126 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee103(_chainId) {
830
- return _regenerator().w(function (_context103) {
831
- while (1) switch (_context103.n) {
830
+ var _ref129 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee105(_chainId) {
831
+ return _regenerator().w(function (_context105) {
832
+ while (1) switch (_context105.n) {
832
833
  case 0:
833
- return _context103.a(2, onUpdateState());
834
+ return _context105.a(2, onUpdateState());
834
835
  }
835
- }, _callee103);
836
+ }, _callee105);
836
837
  }));
837
- return function handleChainChanged(_x90) {
838
- return _ref126.apply(this, arguments);
838
+ return function handleChainChanged(_x92) {
839
+ return _ref129.apply(this, arguments);
839
840
  };
840
841
  }();
841
842
  var handleAccountsChanged = /*#__PURE__*/function () {
842
- var _ref127 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee104(accounts) {
843
- return _regenerator().w(function (_context104) {
844
- while (1) switch (_context104.n) {
843
+ var _ref130 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee106(accounts) {
844
+ return _regenerator().w(function (_context106) {
845
+ while (1) switch (_context106.n) {
845
846
  case 0:
846
847
  if (accounts.length === 0) onUpdateState();
847
848
  case 1:
848
- return _context104.a(2);
849
+ return _context106.a(2);
849
850
  }
850
- }, _callee104);
851
+ }, _callee106);
851
852
  }));
852
- return function handleAccountsChanged(_x91) {
853
- return _ref127.apply(this, arguments);
853
+ return function handleAccountsChanged(_x93) {
854
+ return _ref130.apply(this, arguments);
854
855
  };
855
856
  }();
856
857
  var handleDisconnect = function handleDisconnect() {
@@ -866,10 +867,10 @@ var ClientProvider = function ClientProvider(_ref) {
866
867
  };
867
868
  };
868
869
  if (!(walletProviders.length === 0)) {
869
- _context107.n = 1;
870
+ _context109.n = 1;
870
871
  break;
871
872
  }
872
- return _context107.a(2, function () {});
873
+ return _context109.a(2, function () {});
873
874
  case 1:
874
875
  cleanups = []; // we only want to initialize these listeners for connected walletProviders
875
876
  nativeOnly = function nativeOnly(provider) {
@@ -907,9 +908,9 @@ var ClientProvider = function ClientProvider(_ref) {
907
908
  if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
908
909
  if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
909
910
  unsubscribe = standardEvents.on("change", /*#__PURE__*/function () {
910
- var _ref129 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee106(evt) {
911
- return _regenerator().w(function (_context106) {
912
- while (1) switch (_context106.n) {
911
+ var _ref132 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee108(evt) {
912
+ return _regenerator().w(function (_context108) {
913
+ while (1) switch (_context108.n) {
913
914
  case 0:
914
915
  // if the event is a proposalExpired, we want to re-fetch the providers
915
916
  // to refresh the uri, there is no need to refresh the wallets state
@@ -918,28 +919,28 @@ var ClientProvider = function ClientProvider(_ref) {
918
919
  }
919
920
  // any other event (disconnect, chain switch, accounts changed)
920
921
  // we refresh the wallets state
921
- _context106.n = 1;
922
+ _context108.n = 1;
922
923
  return onUpdateState();
923
924
  case 1:
924
- return _context106.a(2);
925
+ return _context108.a(2);
925
926
  }
926
- }, _callee106);
927
+ }, _callee108);
927
928
  }));
928
- return function (_x93) {
929
- return _ref129.apply(this, arguments);
929
+ return function (_x95) {
930
+ return _ref132.apply(this, arguments);
930
931
  };
931
932
  }());
932
933
  cleanups.push(unsubscribe);
933
934
  }
934
935
  }
935
936
  }
936
- return _context107.a(2, function () {
937
+ return _context109.a(2, function () {
937
938
  cleanups.forEach(function (remove) {
938
939
  return remove();
939
940
  });
940
941
  });
941
942
  }
942
- }, _callee107);
943
+ }, _callee109);
943
944
  }));
944
945
  return _initializeWalletProviderListeners.apply(this, arguments);
945
946
  }
@@ -955,13 +956,13 @@ var ClientProvider = function ClientProvider(_ref) {
955
956
  * @throws {TurnkeyError} If an error occurs while clearing the timers.
956
957
  */
957
958
  function _scheduleSessionExpiration() {
958
- _scheduleSessionExpiration = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee110(params) {
959
- var sessionKey, expiry, warnKey, now, expiryMs, timeUntilExpiry, _beforeExpiry, expireSession, warnAt, _callbacks$onError0, _callbacks$onError1, _t34;
960
- return _regenerator().w(function (_context110) {
961
- while (1) switch (_context110.p = _context110.n) {
959
+ _scheduleSessionExpiration = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee112(params) {
960
+ var sessionKey, expiry, warnKey, now, expiryMs, timeUntilExpiry, _beforeExpiry, expireSession, warnAt, _callbacks$onError0, _callbacks$onError1, _t35;
961
+ return _regenerator().w(function (_context112) {
962
+ while (1) switch (_context112.p = _context112.n) {
962
963
  case 0:
963
964
  sessionKey = params.sessionKey, expiry = params.expiry;
964
- _context110.p = 1;
965
+ _context112.p = 1;
965
966
  warnKey = "".concat(sessionKey, "-warning"); // Replace any prior timers for this session
966
967
  clearKey(expiryTimeoutsRef.current, sessionKey);
967
968
  clearKey(expiryTimeoutsRef.current, warnKey);
@@ -969,86 +970,86 @@ var ClientProvider = function ClientProvider(_ref) {
969
970
  expiryMs = expiry * 1000;
970
971
  timeUntilExpiry = expiryMs - now;
971
972
  _beforeExpiry = /*#__PURE__*/function () {
972
- var _ref130 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee108() {
973
- var _callbacks$beforeSess, _masterConfig$auth49;
973
+ var _ref133 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee110() {
974
+ var _callbacks$beforeSess, _masterConfig$auth50;
974
975
  var activeSession, session;
975
- return _regenerator().w(function (_context108) {
976
- while (1) switch (_context108.n) {
976
+ return _regenerator().w(function (_context110) {
977
+ while (1) switch (_context110.n) {
977
978
  case 0:
978
- _context108.n = 1;
979
+ _context110.n = 1;
979
980
  return getSession();
980
981
  case 1:
981
- activeSession = _context108.v;
982
+ activeSession = _context110.v;
982
983
  if (!(!activeSession && expiryTimeoutsRef.current[warnKey])) {
983
- _context108.n = 2;
984
+ _context110.n = 2;
984
985
  break;
985
986
  }
986
987
  // Keep nudging until session materializes (short 10s timer is fine)
987
988
  setTimeoutInMap(expiryTimeoutsRef.current, warnKey, _beforeExpiry, 10000);
988
- return _context108.a(2);
989
+ return _context110.a(2);
989
990
  case 2:
990
- _context108.n = 3;
991
+ _context110.n = 3;
991
992
  return getSession({
992
993
  sessionKey: sessionKey
993
994
  });
994
995
  case 3:
995
- session = _context108.v;
996
+ session = _context110.v;
996
997
  if (session) {
997
- _context108.n = 4;
998
+ _context110.n = 4;
998
999
  break;
999
1000
  }
1000
- return _context108.a(2);
1001
+ return _context110.a(2);
1001
1002
  case 4:
1002
1003
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$beforeSess = callbacks.beforeSessionExpiry) === null || _callbacks$beforeSess === void 0 ? void 0 : _callbacks$beforeSess.call(callbacks, {
1003
1004
  sessionKey: sessionKey
1004
1005
  });
1005
- if (!(masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth49 = masterConfig.auth) !== null && _masterConfig$auth49 !== void 0 && _masterConfig$auth49.autoRefreshSession)) {
1006
- _context108.n = 5;
1006
+ if (!(masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth50 = masterConfig.auth) !== null && _masterConfig$auth50 !== void 0 && _masterConfig$auth50.autoRefreshSession)) {
1007
+ _context110.n = 5;
1007
1008
  break;
1008
1009
  }
1009
- _context108.n = 5;
1010
+ _context110.n = 5;
1010
1011
  return refreshSession({
1011
1012
  expirationSeconds: session.expirationSeconds,
1012
1013
  sessionKey: sessionKey
1013
1014
  });
1014
1015
  case 5:
1015
- return _context108.a(2);
1016
+ return _context110.a(2);
1016
1017
  }
1017
- }, _callee108);
1018
+ }, _callee110);
1018
1019
  }));
1019
1020
  return function beforeExpiry() {
1020
- return _ref130.apply(this, arguments);
1021
+ return _ref133.apply(this, arguments);
1021
1022
  };
1022
1023
  }();
1023
1024
  expireSession = /*#__PURE__*/function () {
1024
- var _ref131 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee109() {
1025
+ var _ref134 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee111() {
1025
1026
  var _callbacks$onSessionE;
1026
- var expiredSession, _t32, _t33;
1027
- return _regenerator().w(function (_context109) {
1028
- while (1) switch (_context109.n) {
1027
+ var expiredSession, _t33, _t34;
1028
+ return _regenerator().w(function (_context111) {
1029
+ while (1) switch (_context111.n) {
1029
1030
  case 0:
1030
- _context109.n = 1;
1031
+ _context111.n = 1;
1031
1032
  return getSession({
1032
1033
  sessionKey: sessionKey
1033
1034
  });
1034
1035
  case 1:
1035
- expiredSession = _context109.v;
1036
+ expiredSession = _context111.v;
1036
1037
  if (expiredSession) {
1037
- _context109.n = 2;
1038
+ _context111.n = 2;
1038
1039
  break;
1039
1040
  }
1040
- return _context109.a(2);
1041
+ return _context111.a(2);
1041
1042
  case 2:
1042
1043
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onSessionE = callbacks.onSessionExpired) === null || _callbacks$onSessionE === void 0 ? void 0 : _callbacks$onSessionE.call(callbacks, {
1043
1044
  sessionKey: sessionKey
1044
1045
  });
1045
- _context109.n = 3;
1046
+ _context111.n = 3;
1046
1047
  return getActiveSessionKey();
1047
1048
  case 3:
1048
- _t32 = _context109.v;
1049
- _t33 = sessionKey;
1050
- if (!(_t32 === _t33)) {
1051
- _context109.n = 4;
1049
+ _t33 = _context111.v;
1050
+ _t34 = sessionKey;
1051
+ if (!(_t33 === _t34)) {
1052
+ _context111.n = 4;
1052
1053
  break;
1053
1054
  }
1054
1055
  setSession(undefined);
@@ -1059,7 +1060,7 @@ var ClientProvider = function ClientProvider(_ref) {
1059
1060
  delete next[sessionKey];
1060
1061
  return next;
1061
1062
  });
1062
- _context109.n = 5;
1063
+ _context111.n = 5;
1063
1064
  return clearSession({
1064
1065
  sessionKey: sessionKey
1065
1066
  });
@@ -1067,25 +1068,25 @@ var ClientProvider = function ClientProvider(_ref) {
1067
1068
  // Remove timers for this session
1068
1069
  clearKey(expiryTimeoutsRef.current, sessionKey);
1069
1070
  clearKey(expiryTimeoutsRef.current, warnKey);
1070
- _context109.n = 6;
1071
+ _context111.n = 6;
1071
1072
  return logout();
1072
1073
  case 6:
1073
- return _context109.a(2);
1074
+ return _context111.a(2);
1074
1075
  }
1075
- }, _callee109);
1076
+ }, _callee111);
1076
1077
  }));
1077
1078
  return function expireSession() {
1078
- return _ref131.apply(this, arguments);
1079
+ return _ref134.apply(this, arguments);
1079
1080
  };
1080
1081
  }(); // Already expired → expire immediately
1081
1082
  if (!(timeUntilExpiry <= 0)) {
1082
- _context110.n = 3;
1083
+ _context112.n = 3;
1083
1084
  break;
1084
1085
  }
1085
- _context110.n = 2;
1086
+ _context112.n = 2;
1086
1087
  return expireSession();
1087
1088
  case 2:
1088
- return _context110.a(2);
1089
+ return _context112.a(2);
1089
1090
  case 3:
1090
1091
  // Warning timer (if threshold is in the future)
1091
1092
  warnAt = expiryMs - SESSION_WARNING_THRESHOLD_MS;
@@ -1096,20 +1097,20 @@ var ClientProvider = function ClientProvider(_ref) {
1096
1097
  }
1097
1098
  // Actual expiry timer (safe for long delays)
1098
1099
  setCappedTimeoutInMap(expiryTimeoutsRef.current, sessionKey, expireSession, timeUntilExpiry);
1099
- _context110.n = 5;
1100
+ _context112.n = 5;
1100
1101
  break;
1101
1102
  case 4:
1102
- _context110.p = 4;
1103
- _t34 = _context110.v;
1104
- if (_t34 instanceof TurnkeyError || _t34 instanceof TurnkeyNetworkError) {
1105
- callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError0 = callbacks.onError) === null || _callbacks$onError0 === void 0 ? void 0 : _callbacks$onError0.call(callbacks, _t34);
1103
+ _context112.p = 4;
1104
+ _t35 = _context112.v;
1105
+ if (_t35 instanceof TurnkeyError || _t35 instanceof TurnkeyNetworkError) {
1106
+ callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError0 = callbacks.onError) === null || _callbacks$onError0 === void 0 ? void 0 : _callbacks$onError0.call(callbacks, _t35);
1106
1107
  } else {
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));
1108
+ 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, _t35));
1108
1109
  }
1109
1110
  case 5:
1110
- return _context110.a(2);
1111
+ return _context112.a(2);
1111
1112
  }
1112
- }, _callee110, null, [[1, 4]]);
1113
+ }, _callee112, null, [[1, 4]]);
1113
1114
  }));
1114
1115
  return _scheduleSessionExpiration.apply(this, arguments);
1115
1116
  }
@@ -1144,11 +1145,11 @@ var ClientProvider = function ClientProvider(_ref) {
1144
1145
  */
1145
1146
  var handlePostAuth = /*#__PURE__*/function () {
1146
1147
  var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(params) {
1147
- var method, action, identifier, _callbacks$onAuthenti, sessionKey, _session, _allSessions, _callbacks$onError7, _callbacks$onError8, _t9;
1148
+ var method, action, identifier, appProofs, _masterConfig$auth7, _callbacks$onAuthenti, sessionKey, _session, _allSessions, _callbacks$onError7, _callbacks$onError8, _t9;
1148
1149
  return _regenerator().w(function (_context9) {
1149
1150
  while (1) switch (_context9.p = _context9.n) {
1150
1151
  case 0:
1151
- method = params.method, action = params.action, identifier = params.identifier;
1152
+ method = params.method, action = params.action, identifier = params.identifier, appProofs = params.appProofs;
1152
1153
  _context9.p = 1;
1153
1154
  _context9.n = 2;
1154
1155
  return getActiveSessionKey();
@@ -1182,26 +1183,35 @@ var ClientProvider = function ClientProvider(_ref) {
1182
1183
  _context9.n = 7;
1183
1184
  return refreshUser();
1184
1185
  case 7:
1186
+ if (!((masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth7 = masterConfig.auth) === null || _masterConfig$auth7 === void 0 ? void 0 : _masterConfig$auth7.verifyWalletOnSignup) === true && appProofs && appProofs.length > 0 && action === AuthAction.SIGNUP)) {
1187
+ _context9.n = 8;
1188
+ break;
1189
+ }
1190
+ _context9.n = 8;
1191
+ return handleVerifyAppProofs({
1192
+ appProofs: appProofs
1193
+ });
1194
+ case 8:
1185
1195
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onAuthenti = callbacks.onAuthenticationSuccess) === null || _callbacks$onAuthenti === void 0 ? void 0 : _callbacks$onAuthenti.call(callbacks, {
1186
1196
  session: _session,
1187
1197
  method: method,
1188
1198
  action: action,
1189
1199
  identifier: identifier
1190
1200
  });
1191
- _context9.n = 9;
1201
+ _context9.n = 10;
1192
1202
  break;
1193
- case 8:
1194
- _context9.p = 8;
1203
+ case 9:
1204
+ _context9.p = 9;
1195
1205
  _t9 = _context9.v;
1196
1206
  if (_t9 instanceof TurnkeyError || _t9 instanceof TurnkeyNetworkError) {
1197
1207
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError7 = callbacks.onError) === null || _callbacks$onError7 === void 0 ? void 0 : _callbacks$onError7.call(callbacks, _t9);
1198
1208
  } else {
1199
1209
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError8 = callbacks.onError) === null || _callbacks$onError8 === void 0 ? void 0 : _callbacks$onError8.call(callbacks, new TurnkeyError("Failed to handle post-authentication", TurnkeyErrorCodes.HANDLE_POST_AUTH_ERROR, _t9));
1200
1210
  }
1201
- case 9:
1211
+ case 10:
1202
1212
  return _context9.a(2);
1203
1213
  }
1204
- }, _callee9, null, [[1, 8]]);
1214
+ }, _callee9, null, [[1, 9]]);
1205
1215
  }));
1206
1216
  return function handlePostAuth(_x5) {
1207
1217
  return _ref7.apply(this, arguments);
@@ -1320,7 +1330,7 @@ var ClientProvider = function ClientProvider(_ref) {
1320
1330
  }(), [client, callbacks]);
1321
1331
  var loginWithPasskey = useCallback(/*#__PURE__*/function () {
1322
1332
  var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(params) {
1323
- var _masterConfig$auth$se, _masterConfig$auth7;
1333
+ var _masterConfig$auth$se, _masterConfig$auth8;
1324
1334
  var expirationSeconds, res;
1325
1335
  return _regenerator().w(function (_context11) {
1326
1336
  while (1) switch (_context11.n) {
@@ -1331,7 +1341,7 @@ var ClientProvider = function ClientProvider(_ref) {
1331
1341
  }
1332
1342
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1333
1343
  case 1:
1334
- expirationSeconds = (_masterConfig$auth$se = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth7 = masterConfig.auth) === null || _masterConfig$auth7 === void 0 ? void 0 : _masterConfig$auth7.sessionExpirationSeconds) !== null && _masterConfig$auth$se !== void 0 ? _masterConfig$auth$se : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
1344
+ expirationSeconds = (_masterConfig$auth$se = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth8 = masterConfig.auth) === null || _masterConfig$auth8 === void 0 ? void 0 : _masterConfig$auth8.sessionExpirationSeconds) !== null && _masterConfig$auth$se !== void 0 ? _masterConfig$auth$se : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
1335
1345
  _context11.n = 2;
1336
1346
  return withTurnkeyErrorHandling(function () {
1337
1347
  return client.loginWithPasskey(_objectSpread2(_objectSpread2({}, params), {}, {
@@ -1350,7 +1360,8 @@ var ClientProvider = function ClientProvider(_ref) {
1350
1360
  return handlePostAuth({
1351
1361
  method: AuthMethod.Passkey,
1352
1362
  action: AuthAction.LOGIN,
1353
- identifier: res.credentialId
1363
+ identifier: res.credentialId,
1364
+ appProofs: res.appProofs
1354
1365
  });
1355
1366
  case 3:
1356
1367
  return _context11.a(2, res);
@@ -1363,7 +1374,7 @@ var ClientProvider = function ClientProvider(_ref) {
1363
1374
  }(), [client, callbacks]);
1364
1375
  var signUpWithPasskey = useCallback(/*#__PURE__*/function () {
1365
1376
  var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(params) {
1366
- var _params$createSubOrgP, _params, _masterConfig$auth8, _masterConfig$auth8$c, _masterConfig$auth$se2, _masterConfig$auth9, _ref11, _params$passkeyDispla, _params2, _masterConfig$auth0, _masterConfig$auth0$c, _masterConfig$auth0$c2;
1377
+ var _params$createSubOrgP, _params, _masterConfig$auth9, _masterConfig$auth9$c, _masterConfig$auth$se2, _masterConfig$auth0, _ref11, _params$passkeyDispla, _params2, _masterConfig$auth1, _masterConfig$auth1$c, _masterConfig$auth1$c2;
1367
1378
  var createSubOrgParams, expirationSeconds, websiteName, timestamp, passkeyName, res;
1368
1379
  return _regenerator().w(function (_context12) {
1369
1380
  while (1) switch (_context12.n) {
@@ -1381,11 +1392,11 @@ var ClientProvider = function ClientProvider(_ref) {
1381
1392
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
1382
1393
  case 2:
1383
1394
  // If createSubOrgParams is not provided, use the default from masterConfig
1384
- createSubOrgParams = (_params$createSubOrgP = (_params = params) === null || _params === void 0 ? void 0 : _params.createSubOrgParams) !== null && _params$createSubOrgP !== void 0 ? _params$createSubOrgP : (_masterConfig$auth8 = masterConfig.auth) === null || _masterConfig$auth8 === void 0 ? void 0 : (_masterConfig$auth8$c = _masterConfig$auth8.createSuborgParams) === null || _masterConfig$auth8$c === void 0 ? void 0 : _masterConfig$auth8$c.passkeyAuth;
1395
+ createSubOrgParams = (_params$createSubOrgP = (_params = params) === null || _params === void 0 ? void 0 : _params.createSubOrgParams) !== null && _params$createSubOrgP !== void 0 ? _params$createSubOrgP : (_masterConfig$auth9 = masterConfig.auth) === null || _masterConfig$auth9 === void 0 ? void 0 : (_masterConfig$auth9$c = _masterConfig$auth9.createSuborgParams) === null || _masterConfig$auth9$c === void 0 ? void 0 : _masterConfig$auth9$c.passkeyAuth;
1385
1396
  params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
1386
1397
  createSubOrgParams: createSubOrgParams
1387
1398
  }) : _objectSpread2({}, params);
1388
- expirationSeconds = (_masterConfig$auth$se2 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth9 = masterConfig.auth) === null || _masterConfig$auth9 === void 0 ? void 0 : _masterConfig$auth9.sessionExpirationSeconds) !== null && _masterConfig$auth$se2 !== void 0 ? _masterConfig$auth$se2 : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
1399
+ expirationSeconds = (_masterConfig$auth$se2 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth0 = masterConfig.auth) === null || _masterConfig$auth0 === void 0 ? void 0 : _masterConfig$auth0.sessionExpirationSeconds) !== null && _masterConfig$auth$se2 !== void 0 ? _masterConfig$auth$se2 : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
1389
1400
  websiteName = window.location.hostname;
1390
1401
  timestamp = new Date().toLocaleDateString() + "-" + new Date().toLocaleTimeString([], {
1391
1402
  hour: "2-digit",
@@ -1393,7 +1404,7 @@ var ClientProvider = function ClientProvider(_ref) {
1393
1404
  }); // We allow passkeyName to be passed in thru the provider or thru the params of this function directly.
1394
1405
  // This is because signUpWithPasskey will create a new passkey using that name.
1395
1406
  // Any extra authenticators will be created after the first one. (see core implementation)
1396
- passkeyName = (_ref11 = (_params$passkeyDispla = (_params2 = params) === null || _params2 === void 0 ? void 0 : _params2.passkeyDisplayName) !== null && _params$passkeyDispla !== void 0 ? _params$passkeyDispla : (_masterConfig$auth0 = masterConfig.auth) === null || _masterConfig$auth0 === void 0 ? void 0 : (_masterConfig$auth0$c = _masterConfig$auth0.createSuborgParams) === null || _masterConfig$auth0$c === void 0 ? void 0 : (_masterConfig$auth0$c2 = _masterConfig$auth0$c.passkeyAuth) === null || _masterConfig$auth0$c2 === void 0 ? void 0 : _masterConfig$auth0$c2.passkeyName) !== null && _ref11 !== void 0 ? _ref11 : "".concat(websiteName, "-").concat(timestamp);
1407
+ passkeyName = (_ref11 = (_params$passkeyDispla = (_params2 = params) === null || _params2 === void 0 ? void 0 : _params2.passkeyDisplayName) !== null && _params$passkeyDispla !== void 0 ? _params$passkeyDispla : (_masterConfig$auth1 = masterConfig.auth) === null || _masterConfig$auth1 === void 0 ? void 0 : (_masterConfig$auth1$c = _masterConfig$auth1.createSuborgParams) === null || _masterConfig$auth1$c === void 0 ? void 0 : (_masterConfig$auth1$c2 = _masterConfig$auth1$c.passkeyAuth) === null || _masterConfig$auth1$c2 === void 0 ? void 0 : _masterConfig$auth1$c2.passkeyName) !== null && _ref11 !== void 0 ? _ref11 : "".concat(websiteName, "-").concat(timestamp);
1397
1408
  _context12.n = 3;
1398
1409
  return withTurnkeyErrorHandling(function () {
1399
1410
  return client.signUpWithPasskey(_objectSpread2(_objectSpread2({}, params), {}, {
@@ -1413,7 +1424,8 @@ var ClientProvider = function ClientProvider(_ref) {
1413
1424
  return handlePostAuth({
1414
1425
  method: AuthMethod.Passkey,
1415
1426
  action: AuthAction.SIGNUP,
1416
- identifier: res.credentialId
1427
+ identifier: res.credentialId,
1428
+ appProofs: res.appProofs
1417
1429
  });
1418
1430
  case 4:
1419
1431
  return _context12.a(2, res);
@@ -1560,10 +1572,10 @@ var ClientProvider = function ClientProvider(_ref) {
1560
1572
  return function (_x11) {
1561
1573
  return _ref15.apply(this, arguments);
1562
1574
  };
1563
- }(), [client, callbacks]);
1575
+ }(), [client, callbacks, walletProviders]);
1564
1576
  var buildWalletLoginRequest = useCallback(/*#__PURE__*/function () {
1565
1577
  var _ref16 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(params) {
1566
- var _masterConfig$auth$se3, _masterConfig$auth1;
1578
+ var _masterConfig$auth$se3, _masterConfig$auth10;
1567
1579
  var expirationSeconds;
1568
1580
  return _regenerator().w(function (_context17) {
1569
1581
  while (1) switch (_context17.n) {
@@ -1574,7 +1586,7 @@ var ClientProvider = function ClientProvider(_ref) {
1574
1586
  }
1575
1587
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1576
1588
  case 1:
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;
1589
+ expirationSeconds = (_masterConfig$auth$se3 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth10 = masterConfig.auth) === null || _masterConfig$auth10 === void 0 ? void 0 : _masterConfig$auth10.sessionExpirationSeconds) !== null && _masterConfig$auth$se3 !== void 0 ? _masterConfig$auth$se3 : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
1578
1590
  _context17.n = 2;
1579
1591
  return withTurnkeyErrorHandling(function () {
1580
1592
  return client.buildWalletLoginRequest(_objectSpread2(_objectSpread2({}, params), {}, {
@@ -1594,7 +1606,7 @@ var ClientProvider = function ClientProvider(_ref) {
1594
1606
  }(), [client, callbacks]);
1595
1607
  var loginWithWallet = useCallback(/*#__PURE__*/function () {
1596
1608
  var _ref17 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(params) {
1597
- var _masterConfig$auth$se4, _masterConfig$auth10;
1609
+ var _masterConfig$auth$se4, _masterConfig$auth11;
1598
1610
  var expirationSeconds, res;
1599
1611
  return _regenerator().w(function (_context18) {
1600
1612
  while (1) switch (_context18.n) {
@@ -1605,7 +1617,7 @@ var ClientProvider = function ClientProvider(_ref) {
1605
1617
  }
1606
1618
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
1607
1619
  case 1:
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;
1620
+ 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;
1609
1621
  _context18.n = 2;
1610
1622
  return withTurnkeyErrorHandling(function () {
1611
1623
  return client.loginWithWallet(_objectSpread2(_objectSpread2({}, params), {}, {
@@ -1624,7 +1636,8 @@ var ClientProvider = function ClientProvider(_ref) {
1624
1636
  return handlePostAuth({
1625
1637
  method: AuthMethod.Wallet,
1626
1638
  action: AuthAction.LOGIN,
1627
- identifier: res.address
1639
+ identifier: res.address,
1640
+ appProofs: res.appProofs
1628
1641
  });
1629
1642
  case 3:
1630
1643
  return _context18.a(2, res);
@@ -1637,7 +1650,7 @@ var ClientProvider = function ClientProvider(_ref) {
1637
1650
  }(), [client, callbacks]);
1638
1651
  var signUpWithWallet = useCallback(/*#__PURE__*/function () {
1639
1652
  var _ref18 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(params) {
1640
- var _params$createSubOrgP2, _masterConfig$auth11, _masterConfig$auth11$, _masterConfig$auth$se5, _masterConfig$auth12;
1653
+ var _params$createSubOrgP2, _masterConfig$auth12, _masterConfig$auth12$, _masterConfig$auth$se5, _masterConfig$auth13;
1641
1654
  var createSubOrgParams, expirationSeconds, res;
1642
1655
  return _regenerator().w(function (_context19) {
1643
1656
  while (1) switch (_context19.n) {
@@ -1655,11 +1668,11 @@ var ClientProvider = function ClientProvider(_ref) {
1655
1668
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
1656
1669
  case 2:
1657
1670
  // If createSubOrgParams is not provided, use the default from masterConfig
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;
1671
+ createSubOrgParams = (_params$createSubOrgP2 = params.createSubOrgParams) !== null && _params$createSubOrgP2 !== void 0 ? _params$createSubOrgP2 : (_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;
1659
1672
  params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
1660
1673
  createSubOrgParams: createSubOrgParams
1661
1674
  }) : _objectSpread2({}, params);
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;
1675
+ 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;
1663
1676
  _context19.n = 3;
1664
1677
  return withTurnkeyErrorHandling(function () {
1665
1678
  return client.signUpWithWallet(_objectSpread2(_objectSpread2({}, params), {}, {
@@ -1678,7 +1691,8 @@ var ClientProvider = function ClientProvider(_ref) {
1678
1691
  return handlePostAuth({
1679
1692
  method: AuthMethod.Wallet,
1680
1693
  action: AuthAction.SIGNUP,
1681
- identifier: res.address
1694
+ identifier: res.address,
1695
+ appProofs: res.appProofs
1682
1696
  });
1683
1697
  case 4:
1684
1698
  return _context19.a(2, res);
@@ -1691,7 +1705,7 @@ var ClientProvider = function ClientProvider(_ref) {
1691
1705
  }(), [client, callbacks, masterConfig]);
1692
1706
  var loginOrSignupWithWallet = useCallback(/*#__PURE__*/function () {
1693
1707
  var _ref19 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(params) {
1694
- var _params$createSubOrgP3, _masterConfig$auth13, _masterConfig$auth13$, _masterConfig$auth$se6, _masterConfig$auth14;
1708
+ var _params$createSubOrgP3, _masterConfig$auth14, _masterConfig$auth14$, _masterConfig$auth$se6, _masterConfig$auth15;
1695
1709
  var createSubOrgParams, expirationSeconds, res;
1696
1710
  return _regenerator().w(function (_context20) {
1697
1711
  while (1) switch (_context20.n) {
@@ -1709,11 +1723,11 @@ var ClientProvider = function ClientProvider(_ref) {
1709
1723
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
1710
1724
  case 2:
1711
1725
  // 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;
1726
+ createSubOrgParams = (_params$createSubOrgP3 = params.createSubOrgParams) !== null && _params$createSubOrgP3 !== void 0 ? _params$createSubOrgP3 : (_masterConfig$auth14 = masterConfig.auth) === null || _masterConfig$auth14 === void 0 ? void 0 : (_masterConfig$auth14$ = _masterConfig$auth14.createSuborgParams) === null || _masterConfig$auth14$ === void 0 ? void 0 : _masterConfig$auth14$.walletAuth;
1713
1727
  params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
1714
1728
  createSubOrgParams: createSubOrgParams
1715
1729
  }) : _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;
1730
+ expirationSeconds = (_masterConfig$auth$se6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth15 = masterConfig.auth) === null || _masterConfig$auth15 === void 0 ? void 0 : _masterConfig$auth15.sessionExpirationSeconds) !== null && _masterConfig$auth$se6 !== void 0 ? _masterConfig$auth$se6 : DEFAULT_SESSION_EXPIRATION_IN_SECONDS;
1717
1731
  _context20.n = 3;
1718
1732
  return withTurnkeyErrorHandling(function () {
1719
1733
  return client.loginOrSignupWithWallet(_objectSpread2(_objectSpread2({}, params), {}, {
@@ -1732,7 +1746,8 @@ var ClientProvider = function ClientProvider(_ref) {
1732
1746
  return handlePostAuth({
1733
1747
  method: AuthMethod.Wallet,
1734
1748
  action: res.action,
1735
- identifier: res.address
1749
+ identifier: res.address,
1750
+ appProofs: res.appProofs
1736
1751
  });
1737
1752
  case 4:
1738
1753
  return _context20.a(2, res);
@@ -1817,7 +1832,8 @@ var ClientProvider = function ClientProvider(_ref) {
1817
1832
  return handlePostAuth({
1818
1833
  method: AuthMethod.Otp,
1819
1834
  action: AuthAction.LOGIN,
1820
- identifier: params.verificationToken
1835
+ identifier: params.verificationToken,
1836
+ appProofs: res.appProofs
1821
1837
  });
1822
1838
  case 3:
1823
1839
  return _context23.a(2, res);
@@ -1830,7 +1846,7 @@ var ClientProvider = function ClientProvider(_ref) {
1830
1846
  }(), [client, callbacks]);
1831
1847
  var signUpWithOtp = useCallback(/*#__PURE__*/function () {
1832
1848
  var _ref23 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24(params) {
1833
- var _masterConfig$auth15;
1849
+ var _masterConfig$auth16;
1834
1850
  var createSubOrgParams, res;
1835
1851
  return _regenerator().w(function (_context24) {
1836
1852
  while (1) switch (_context24.n) {
@@ -1849,7 +1865,7 @@ var ClientProvider = function ClientProvider(_ref) {
1849
1865
  case 2:
1850
1866
  // If createSubOrgParams is not provided, use the default from masterConfig
1851
1867
  createSubOrgParams = params.createSubOrgParams;
1852
- if (!createSubOrgParams && masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth15 = masterConfig.auth) !== null && _masterConfig$auth15 !== void 0 && _masterConfig$auth15.createSuborgParams) {
1868
+ if (!createSubOrgParams && masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth16 = masterConfig.auth) !== null && _masterConfig$auth16 !== void 0 && _masterConfig$auth16.createSuborgParams) {
1853
1869
  if (params.otpType === OtpType.Email) {
1854
1870
  createSubOrgParams = masterConfig.auth.createSuborgParams.emailOtpAuth;
1855
1871
  } else if (params.otpType === OtpType.Sms) {
@@ -1875,7 +1891,8 @@ var ClientProvider = function ClientProvider(_ref) {
1875
1891
  return handlePostAuth({
1876
1892
  method: AuthMethod.Otp,
1877
1893
  action: AuthAction.SIGNUP,
1878
- identifier: params.verificationToken
1894
+ identifier: params.verificationToken,
1895
+ appProofs: res.appProofs
1879
1896
  });
1880
1897
  case 4:
1881
1898
  return _context24.a(2, res);
@@ -1888,7 +1905,7 @@ var ClientProvider = function ClientProvider(_ref) {
1888
1905
  }(), [client, callbacks, masterConfig]);
1889
1906
  var completeOtp = useCallback(/*#__PURE__*/function () {
1890
1907
  var _ref24 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25(params) {
1891
- var _masterConfig$auth16;
1908
+ var _masterConfig$auth17;
1892
1909
  var createSubOrgParams, res;
1893
1910
  return _regenerator().w(function (_context25) {
1894
1911
  while (1) switch (_context25.n) {
@@ -1907,7 +1924,7 @@ var ClientProvider = function ClientProvider(_ref) {
1907
1924
  case 2:
1908
1925
  // If createSubOrgParams is not provided, use the default from masterConfig
1909
1926
  createSubOrgParams = params.createSubOrgParams;
1910
- if (!createSubOrgParams && masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth16 = masterConfig.auth) !== null && _masterConfig$auth16 !== void 0 && _masterConfig$auth16.createSuborgParams) {
1927
+ if (!createSubOrgParams && masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth17 = masterConfig.auth) !== null && _masterConfig$auth17 !== void 0 && _masterConfig$auth17.createSuborgParams) {
1911
1928
  if (params.otpType === OtpType.Email) {
1912
1929
  createSubOrgParams = masterConfig.auth.createSuborgParams.emailOtpAuth;
1913
1930
  } else if (params.otpType === OtpType.Sms) {
@@ -1933,7 +1950,8 @@ var ClientProvider = function ClientProvider(_ref) {
1933
1950
  return handlePostAuth({
1934
1951
  method: AuthMethod.Otp,
1935
1952
  action: res.action,
1936
- identifier: res.verificationToken
1953
+ identifier: res.verificationToken,
1954
+ appProofs: res.appProofs
1937
1955
  });
1938
1956
  case 4:
1939
1957
  return _context25.a(2, res);
@@ -1972,7 +1990,8 @@ var ClientProvider = function ClientProvider(_ref) {
1972
1990
  return handlePostAuth({
1973
1991
  method: AuthMethod.Oauth,
1974
1992
  action: AuthAction.LOGIN,
1975
- identifier: params.oidcToken
1993
+ identifier: params.oidcToken,
1994
+ appProofs: res.appProofs
1976
1995
  });
1977
1996
  case 3:
1978
1997
  return _context26.a(2, res);
@@ -1985,7 +2004,7 @@ var ClientProvider = function ClientProvider(_ref) {
1985
2004
  }(), [client, callbacks]);
1986
2005
  var signUpWithOauth = useCallback(/*#__PURE__*/function () {
1987
2006
  var _ref26 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee27(params) {
1988
- var _params$createSubOrgP4, _masterConfig$auth17, _masterConfig$auth17$;
2007
+ var _params$createSubOrgP4, _masterConfig$auth18, _masterConfig$auth18$;
1989
2008
  var createSubOrgParams, res;
1990
2009
  return _regenerator().w(function (_context27) {
1991
2010
  while (1) switch (_context27.n) {
@@ -2003,7 +2022,7 @@ var ClientProvider = function ClientProvider(_ref) {
2003
2022
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
2004
2023
  case 2:
2005
2024
  // If createSubOrgParams is not provided, use the default from masterConfig
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;
2025
+ createSubOrgParams = (_params$createSubOrgP4 = params.createSubOrgParams) !== null && _params$createSubOrgP4 !== void 0 ? _params$createSubOrgP4 : (_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;
2007
2026
  params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
2008
2027
  createSubOrgParams: createSubOrgParams
2009
2028
  }) : _objectSpread2({}, params);
@@ -2023,7 +2042,8 @@ var ClientProvider = function ClientProvider(_ref) {
2023
2042
  return handlePostAuth({
2024
2043
  method: AuthMethod.Oauth,
2025
2044
  action: AuthAction.SIGNUP,
2026
- identifier: params.oidcToken
2045
+ identifier: params.oidcToken,
2046
+ appProofs: res.appProofs
2027
2047
  });
2028
2048
  case 4:
2029
2049
  return _context27.a(2, res);
@@ -2036,7 +2056,7 @@ var ClientProvider = function ClientProvider(_ref) {
2036
2056
  }(), [client, callbacks, masterConfig]);
2037
2057
  var completeOauth = useCallback(/*#__PURE__*/function () {
2038
2058
  var _ref27 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee28(params) {
2039
- var _params$createSubOrgP5, _masterConfig$auth18, _masterConfig$auth18$;
2059
+ var _params$createSubOrgP5, _masterConfig$auth19, _masterConfig$auth19$;
2040
2060
  var createSubOrgParams, res;
2041
2061
  return _regenerator().w(function (_context28) {
2042
2062
  while (1) switch (_context28.n) {
@@ -2054,7 +2074,7 @@ var ClientProvider = function ClientProvider(_ref) {
2054
2074
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
2055
2075
  case 2:
2056
2076
  // 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;
2077
+ createSubOrgParams = (_params$createSubOrgP5 = params.createSubOrgParams) !== null && _params$createSubOrgP5 !== void 0 ? _params$createSubOrgP5 : (_masterConfig$auth19 = masterConfig.auth) === null || _masterConfig$auth19 === void 0 ? void 0 : (_masterConfig$auth19$ = _masterConfig$auth19.createSuborgParams) === null || _masterConfig$auth19$ === void 0 ? void 0 : _masterConfig$auth19$.oauth;
2058
2078
  params = createSubOrgParams !== undefined ? _objectSpread2(_objectSpread2({}, params), {}, {
2059
2079
  createSubOrgParams: createSubOrgParams
2060
2080
  }) : _objectSpread2({}, params);
@@ -2074,7 +2094,8 @@ var ClientProvider = function ClientProvider(_ref) {
2074
2094
  return handlePostAuth({
2075
2095
  method: AuthMethod.Oauth,
2076
2096
  action: res.action,
2077
- identifier: params.oidcToken
2097
+ identifier: params.oidcToken,
2098
+ appProofs: res.appProofs
2078
2099
  });
2079
2100
  case 4:
2080
2101
  return _context28.a(2, res);
@@ -3462,34 +3483,57 @@ var ClientProvider = function ClientProvider(_ref) {
3462
3483
  return _ref70.apply(this, arguments);
3463
3484
  };
3464
3485
  }(), [client, callbacks]);
3465
- var refreshWallets = useCallback(/*#__PURE__*/function () {
3486
+ var verifyAppProofs = useCallback(/*#__PURE__*/function () {
3466
3487
  var _ref71 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee71(params) {
3467
- var _ref72, stampWith, organizationId, userId, walletProviders, wallets;
3468
3488
  return _regenerator().w(function (_context71) {
3469
3489
  while (1) switch (_context71.n) {
3470
3490
  case 0:
3471
- if (masterConfig !== null && masterConfig !== void 0 && masterConfig.autoRefreshManagedState) {
3491
+ if (client) {
3472
3492
  _context71.n = 1;
3473
3493
  break;
3474
3494
  }
3475
- return _context71.a(2, []);
3495
+ throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3496
+ case 1:
3497
+ return _context71.a(2, withTurnkeyErrorHandling(function () {
3498
+ return client.verifyAppProofs(params);
3499
+ }, function () {
3500
+ return logout();
3501
+ }, callbacks, "Failed to verify app proofs"));
3502
+ }
3503
+ }, _callee71);
3504
+ }));
3505
+ return function (_x59) {
3506
+ return _ref71.apply(this, arguments);
3507
+ };
3508
+ }(), [client, callbacks]);
3509
+ var refreshWallets = useCallback(/*#__PURE__*/function () {
3510
+ var _ref72 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee72(params) {
3511
+ var _ref73, stampWith, organizationId, userId, walletProviders, wallets;
3512
+ return _regenerator().w(function (_context72) {
3513
+ while (1) switch (_context72.n) {
3514
+ case 0:
3515
+ if (masterConfig !== null && masterConfig !== void 0 && masterConfig.autoRefreshManagedState) {
3516
+ _context72.n = 1;
3517
+ break;
3518
+ }
3519
+ return _context72.a(2, []);
3476
3520
  case 1:
3477
- _ref72 = params || {}, stampWith = _ref72.stampWith, organizationId = _ref72.organizationId, userId = _ref72.userId;
3521
+ _ref73 = params || {}, stampWith = _ref73.stampWith, organizationId = _ref73.organizationId, userId = _ref73.userId;
3478
3522
  if (client) {
3479
- _context71.n = 2;
3523
+ _context72.n = 2;
3480
3524
  break;
3481
3525
  }
3482
3526
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3483
3527
  case 2:
3484
- _context71.n = 3;
3528
+ _context72.n = 3;
3485
3529
  return withTurnkeyErrorHandling(function () {
3486
3530
  return fetchWalletProviders();
3487
3531
  }, function () {
3488
3532
  return logout();
3489
3533
  }, callbacks, "Failed to refresh wallets");
3490
3534
  case 3:
3491
- walletProviders = _context71.v;
3492
- _context71.n = 4;
3535
+ walletProviders = _context72.v;
3536
+ _context72.n = 4;
3493
3537
  return withTurnkeyErrorHandling(function () {
3494
3538
  return fetchWallets(_objectSpread2(_objectSpread2({
3495
3539
  stampWith: stampWith,
@@ -3503,62 +3547,62 @@ var ClientProvider = function ClientProvider(_ref) {
3503
3547
  return logout();
3504
3548
  }, callbacks, "Failed to refresh wallets");
3505
3549
  case 4:
3506
- wallets = _context71.v;
3550
+ wallets = _context72.v;
3507
3551
  if (wallets) {
3508
3552
  setWallets(wallets);
3509
3553
  }
3510
- return _context71.a(2, wallets);
3554
+ return _context72.a(2, wallets);
3511
3555
  }
3512
- }, _callee71);
3556
+ }, _callee72);
3513
3557
  }));
3514
- return function (_x59) {
3515
- return _ref71.apply(this, arguments);
3558
+ return function (_x60) {
3559
+ return _ref72.apply(this, arguments);
3516
3560
  };
3517
3561
  }(), [client, callbacks, fetchWalletProviders, fetchWallets, masterConfig, session, user]);
3518
3562
  var handleDiscordOauth = useCallback(/*#__PURE__*/function () {
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) {
3563
+ var _ref74 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee73(params) {
3564
+ var _masterConfig$auth20, _masterConfig$auth20$, _masterConfig$auth$oa2, _masterConfig$auth21, _masterConfig$auth21$;
3565
+ var _ref75, _ref75$clientId, clientId, _ref75$openInPage, openInPage, additionalParameters, _masterConfig$auth22, _masterConfig$auth22$, _masterConfig$auth23, flow, redirectURI, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, discordAuthUrl, extra, width, height, left, top, authWindow, _t1;
3566
+ return _regenerator().w(function (_context73) {
3567
+ while (1) switch (_context73.p = _context73.n) {
3524
3568
  case 0:
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;
3569
+ _ref75 = params || {}, _ref75$clientId = _ref75.clientId, clientId = _ref75$clientId === void 0 ? 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$.discordClientId : _ref75$clientId, _ref75$openInPage = _ref75.openInPage, openInPage = _ref75$openInPage === void 0 ? (_masterConfig$auth$oa2 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth21 = masterConfig.auth) === null || _masterConfig$auth21 === void 0 ? void 0 : (_masterConfig$auth21$ = _masterConfig$auth21.oauthConfig) === null || _masterConfig$auth21$ === void 0 ? void 0 : _masterConfig$auth21$.openOauthInPage) !== null && _masterConfig$auth$oa2 !== void 0 ? _masterConfig$auth$oa2 : false : _ref75$openInPage, additionalParameters = _ref75.additionalState;
3570
+ _context73.p = 1;
3527
3571
  if (masterConfig) {
3528
- _context72.n = 2;
3572
+ _context73.n = 2;
3529
3573
  break;
3530
3574
  }
3531
3575
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3532
3576
  case 2:
3533
3577
  if (clientId) {
3534
- _context72.n = 3;
3578
+ _context73.n = 3;
3535
3579
  break;
3536
3580
  }
3537
3581
  throw new TurnkeyError("Discord Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3538
3582
  case 3:
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;
3583
+ if ((_masterConfig$auth22 = masterConfig.auth) !== null && _masterConfig$auth22 !== void 0 && (_masterConfig$auth22$ = _masterConfig$auth22.oauthConfig) !== null && _masterConfig$auth22$ !== void 0 && _masterConfig$auth22$.oauthRedirectUri) {
3584
+ _context73.n = 4;
3541
3585
  break;
3542
3586
  }
3543
3587
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3544
3588
  case 4:
3545
3589
  flow = openInPage ? "redirect" : "popup";
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;
3590
+ redirectURI = (_masterConfig$auth23 = masterConfig.auth) === null || _masterConfig$auth23 === void 0 ? void 0 : _masterConfig$auth23.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3591
+ _context73.n = 5;
3548
3592
  return createApiKeyPair();
3549
3593
  case 5:
3550
- publicKey = _context72.v;
3594
+ publicKey = _context73.v;
3551
3595
  if (publicKey) {
3552
- _context72.n = 6;
3596
+ _context73.n = 6;
3553
3597
  break;
3554
3598
  }
3555
3599
  throw new Error("Failed to create public key for OAuth.");
3556
3600
  case 6:
3557
3601
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
3558
- _context72.n = 7;
3602
+ _context73.n = 7;
3559
3603
  return generateChallengePair();
3560
3604
  case 7:
3561
- _yield$generateChalle = _context72.v;
3605
+ _yield$generateChalle = _context73.v;
3562
3606
  verifier = _yield$generateChalle.verifier;
3563
3607
  codeChallenge = _yield$generateChalle.codeChallenge;
3564
3608
  sessionStorage.setItem("discord_verifier", verifier);
@@ -3572,10 +3616,10 @@ var ClientProvider = function ClientProvider(_ref) {
3572
3616
  discordAuthUrl.searchParams.set("scope", "identify email");
3573
3617
  discordAuthUrl.searchParams.set("state", "provider=discord&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey), "&nonce=").concat(nonce));
3574
3618
  if (additionalParameters) {
3575
- extra = Object.entries(additionalParameters).map(function (_ref75) {
3576
- var _ref76 = _slicedToArray(_ref75, 2),
3577
- k = _ref76[0],
3578
- v = _ref76[1];
3619
+ extra = Object.entries(additionalParameters).map(function (_ref76) {
3620
+ var _ref77 = _slicedToArray(_ref76, 2),
3621
+ k = _ref77[0],
3622
+ v = _ref77[1];
3579
3623
  return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(v));
3580
3624
  }).join("&");
3581
3625
  if (extra) {
@@ -3583,11 +3627,11 @@ var ClientProvider = function ClientProvider(_ref) {
3583
3627
  }
3584
3628
  }
3585
3629
  if (!openInPage) {
3586
- _context72.n = 8;
3630
+ _context73.n = 8;
3587
3631
  break;
3588
3632
  }
3589
3633
  window.location.href = discordAuthUrl.toString();
3590
- return _context72.a(2, new Promise(function (_, reject) {
3634
+ return _context73.a(2, new Promise(function (_, reject) {
3591
3635
  var timeout = setTimeout(function () {
3592
3636
  reject(new Error("Authentication timed out."));
3593
3637
  }, 300000);
@@ -3602,13 +3646,13 @@ var ClientProvider = function ClientProvider(_ref) {
3602
3646
  top = window.screenY + (window.innerHeight - height) / 2;
3603
3647
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3604
3648
  if (authWindow) {
3605
- _context72.n = 9;
3649
+ _context73.n = 9;
3606
3650
  break;
3607
3651
  }
3608
3652
  throw new Error("Failed to open Discord login window.");
3609
3653
  case 9:
3610
3654
  authWindow.location.href = discordAuthUrl.toString();
3611
- return _context72.a(2, new Promise(function (resolve, reject) {
3655
+ return _context73.a(2, new Promise(function (resolve, reject) {
3612
3656
  var interval = setInterval(function () {
3613
3657
  try {
3614
3658
  if (authWindow.closed) {
@@ -3683,65 +3727,65 @@ var ClientProvider = function ClientProvider(_ref) {
3683
3727
  }
3684
3728
  }));
3685
3729
  case 10:
3686
- _context72.n = 12;
3730
+ _context73.n = 12;
3687
3731
  break;
3688
3732
  case 11:
3689
- _context72.p = 11;
3690
- _t1 = _context72.v;
3733
+ _context73.p = 11;
3734
+ _t1 = _context73.v;
3691
3735
  throw _t1;
3692
3736
  case 12:
3693
- return _context72.a(2);
3737
+ return _context73.a(2);
3694
3738
  }
3695
- }, _callee72, null, [[1, 11]]);
3739
+ }, _callee73, null, [[1, 11]]);
3696
3740
  }));
3697
- return function (_x60) {
3698
- return _ref73.apply(this, arguments);
3741
+ return function (_x61) {
3742
+ return _ref74.apply(this, arguments);
3699
3743
  };
3700
3744
  }(), [client, callbacks, completeOauth, createApiKeyPair, masterConfig, session, user]);
3701
3745
  var handleXOauth = useCallback(/*#__PURE__*/function () {
3702
- var _ref77 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee73(params) {
3703
- var _masterConfig$auth23, _masterConfig$auth23$, _masterConfig$auth$oa3, _masterConfig$auth24, _masterConfig$auth24$;
3704
- var _ref78, _ref78$clientId, clientId, _ref78$openInPage, openInPage, additionalParameters, _masterConfig$auth25, _masterConfig$auth25$, _masterConfig$auth26, flow, redirectURI, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, twitterAuthUrl, extra, width, height, left, top, authWindow, _t10;
3705
- return _regenerator().w(function (_context73) {
3706
- while (1) switch (_context73.p = _context73.n) {
3746
+ var _ref78 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee74(params) {
3747
+ var _masterConfig$auth24, _masterConfig$auth24$, _masterConfig$auth$oa3, _masterConfig$auth25, _masterConfig$auth25$;
3748
+ var _ref79, _ref79$clientId, clientId, _ref79$openInPage, openInPage, additionalParameters, _masterConfig$auth26, _masterConfig$auth26$, _masterConfig$auth27, flow, redirectURI, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, twitterAuthUrl, extra, width, height, left, top, authWindow, _t10;
3749
+ return _regenerator().w(function (_context74) {
3750
+ while (1) switch (_context74.p = _context74.n) {
3707
3751
  case 0:
3708
- _ref78 = params || {}, _ref78$clientId = _ref78.clientId, clientId = _ref78$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth23 = masterConfig.auth) === null || _masterConfig$auth23 === void 0 ? void 0 : (_masterConfig$auth23$ = _masterConfig$auth23.oauthConfig) === null || _masterConfig$auth23$ === void 0 ? void 0 : _masterConfig$auth23$.xClientId : _ref78$clientId, _ref78$openInPage = _ref78.openInPage, openInPage = _ref78$openInPage === void 0 ? (_masterConfig$auth$oa3 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth24 = masterConfig.auth) === null || _masterConfig$auth24 === void 0 ? void 0 : (_masterConfig$auth24$ = _masterConfig$auth24.oauthConfig) === null || _masterConfig$auth24$ === void 0 ? void 0 : _masterConfig$auth24$.openOauthInPage) !== null && _masterConfig$auth$oa3 !== void 0 ? _masterConfig$auth$oa3 : false : _ref78$openInPage, additionalParameters = _ref78.additionalState;
3709
- _context73.p = 1;
3752
+ _ref79 = params || {}, _ref79$clientId = _ref79.clientId, clientId = _ref79$clientId === void 0 ? 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$.xClientId : _ref79$clientId, _ref79$openInPage = _ref79.openInPage, openInPage = _ref79$openInPage === void 0 ? (_masterConfig$auth$oa3 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth25 = masterConfig.auth) === null || _masterConfig$auth25 === void 0 ? void 0 : (_masterConfig$auth25$ = _masterConfig$auth25.oauthConfig) === null || _masterConfig$auth25$ === void 0 ? void 0 : _masterConfig$auth25$.openOauthInPage) !== null && _masterConfig$auth$oa3 !== void 0 ? _masterConfig$auth$oa3 : false : _ref79$openInPage, additionalParameters = _ref79.additionalState;
3753
+ _context74.p = 1;
3710
3754
  if (masterConfig) {
3711
- _context73.n = 2;
3755
+ _context74.n = 2;
3712
3756
  break;
3713
3757
  }
3714
3758
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3715
3759
  case 2:
3716
3760
  if (clientId) {
3717
- _context73.n = 3;
3761
+ _context74.n = 3;
3718
3762
  break;
3719
3763
  }
3720
3764
  throw new TurnkeyError("Twitter Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3721
3765
  case 3:
3722
- if ((_masterConfig$auth25 = masterConfig.auth) !== null && _masterConfig$auth25 !== void 0 && (_masterConfig$auth25$ = _masterConfig$auth25.oauthConfig) !== null && _masterConfig$auth25$ !== void 0 && _masterConfig$auth25$.oauthRedirectUri) {
3723
- _context73.n = 4;
3766
+ if ((_masterConfig$auth26 = masterConfig.auth) !== null && _masterConfig$auth26 !== void 0 && (_masterConfig$auth26$ = _masterConfig$auth26.oauthConfig) !== null && _masterConfig$auth26$ !== void 0 && _masterConfig$auth26$.oauthRedirectUri) {
3767
+ _context74.n = 4;
3724
3768
  break;
3725
3769
  }
3726
3770
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3727
3771
  case 4:
3728
3772
  flow = openInPage ? "redirect" : "popup";
3729
- redirectURI = (_masterConfig$auth26 = masterConfig.auth) === null || _masterConfig$auth26 === void 0 ? void 0 : _masterConfig$auth26.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3730
- _context73.n = 5;
3773
+ redirectURI = (_masterConfig$auth27 = masterConfig.auth) === null || _masterConfig$auth27 === void 0 ? void 0 : _masterConfig$auth27.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3774
+ _context74.n = 5;
3731
3775
  return createApiKeyPair();
3732
3776
  case 5:
3733
- publicKey = _context73.v;
3777
+ publicKey = _context74.v;
3734
3778
  if (publicKey) {
3735
- _context73.n = 6;
3779
+ _context74.n = 6;
3736
3780
  break;
3737
3781
  }
3738
3782
  throw new Error("Failed to create public key for OAuth.");
3739
3783
  case 6:
3740
3784
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
3741
- _context73.n = 7;
3785
+ _context74.n = 7;
3742
3786
  return generateChallengePair();
3743
3787
  case 7:
3744
- _yield$generateChalle2 = _context73.v;
3788
+ _yield$generateChalle2 = _context74.v;
3745
3789
  verifier = _yield$generateChalle2.verifier;
3746
3790
  codeChallenge = _yield$generateChalle2.codeChallenge;
3747
3791
  sessionStorage.setItem("twitter_verifier", verifier);
@@ -3755,10 +3799,10 @@ var ClientProvider = function ClientProvider(_ref) {
3755
3799
  twitterAuthUrl.searchParams.set("scope", "tweet.read users.read");
3756
3800
  twitterAuthUrl.searchParams.set("state", "provider=twitter&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey), "&nonce=").concat(nonce));
3757
3801
  if (additionalParameters) {
3758
- extra = Object.entries(additionalParameters).map(function (_ref79) {
3759
- var _ref80 = _slicedToArray(_ref79, 2),
3760
- k = _ref80[0],
3761
- v = _ref80[1];
3802
+ extra = Object.entries(additionalParameters).map(function (_ref80) {
3803
+ var _ref81 = _slicedToArray(_ref80, 2),
3804
+ k = _ref81[0],
3805
+ v = _ref81[1];
3762
3806
  return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(v));
3763
3807
  }).join("&");
3764
3808
  if (extra) {
@@ -3766,11 +3810,11 @@ var ClientProvider = function ClientProvider(_ref) {
3766
3810
  }
3767
3811
  }
3768
3812
  if (!openInPage) {
3769
- _context73.n = 8;
3813
+ _context74.n = 8;
3770
3814
  break;
3771
3815
  }
3772
3816
  window.location.href = twitterAuthUrl.toString();
3773
- return _context73.a(2, new Promise(function (_, reject) {
3817
+ return _context74.a(2, new Promise(function (_, reject) {
3774
3818
  var timeout = setTimeout(function () {
3775
3819
  reject(new Error("Authentication timed out."));
3776
3820
  }, 300000);
@@ -3785,13 +3829,13 @@ var ClientProvider = function ClientProvider(_ref) {
3785
3829
  top = window.screenY + (window.innerHeight - height) / 2;
3786
3830
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3787
3831
  if (authWindow) {
3788
- _context73.n = 9;
3832
+ _context74.n = 9;
3789
3833
  break;
3790
3834
  }
3791
3835
  throw new Error("Failed to open Twitter login window.");
3792
3836
  case 9:
3793
3837
  authWindow.location.href = twitterAuthUrl.toString();
3794
- return _context73.a(2, new Promise(function (resolve, reject) {
3838
+ return _context74.a(2, new Promise(function (resolve, reject) {
3795
3839
  var interval = setInterval(function () {
3796
3840
  try {
3797
3841
  if (authWindow.closed) {
@@ -3866,56 +3910,56 @@ var ClientProvider = function ClientProvider(_ref) {
3866
3910
  }
3867
3911
  }));
3868
3912
  case 10:
3869
- _context73.n = 12;
3913
+ _context74.n = 12;
3870
3914
  break;
3871
3915
  case 11:
3872
- _context73.p = 11;
3873
- _t10 = _context73.v;
3916
+ _context74.p = 11;
3917
+ _t10 = _context74.v;
3874
3918
  throw _t10;
3875
3919
  case 12:
3876
- return _context73.a(2);
3920
+ return _context74.a(2);
3877
3921
  }
3878
- }, _callee73, null, [[1, 11]]);
3922
+ }, _callee74, null, [[1, 11]]);
3879
3923
  }));
3880
- return function (_x61) {
3881
- return _ref77.apply(this, arguments);
3924
+ return function (_x62) {
3925
+ return _ref78.apply(this, arguments);
3882
3926
  };
3883
3927
  }(), [client, callbacks, masterConfig, session, user]);
3884
3928
  var handleGoogleOauth = useCallback(/*#__PURE__*/function () {
3885
- var _ref81 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee74(params) {
3886
- var _masterConfig$auth27, _masterConfig$auth27$, _masterConfig$auth$oa4, _masterConfig$auth28, _masterConfig$auth28$;
3887
- var _ref82, _ref82$clientId, clientId, _ref82$openInPage, openInPage, additionalParameters, _masterConfig$auth29, _masterConfig$auth29$, _masterConfig$auth30, flow, redirectURI, publicKey, nonce, googleAuthUrl, state, additionalState, width, height, left, top, authWindow, _t11;
3888
- return _regenerator().w(function (_context74) {
3889
- while (1) switch (_context74.p = _context74.n) {
3929
+ var _ref82 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee75(params) {
3930
+ var _masterConfig$auth28, _masterConfig$auth28$, _masterConfig$auth$oa4, _masterConfig$auth29, _masterConfig$auth29$;
3931
+ var _ref83, _ref83$clientId, clientId, _ref83$openInPage, openInPage, additionalParameters, _masterConfig$auth30, _masterConfig$auth30$, _masterConfig$auth31, flow, redirectURI, publicKey, nonce, googleAuthUrl, state, additionalState, width, height, left, top, authWindow, _t11;
3932
+ return _regenerator().w(function (_context75) {
3933
+ while (1) switch (_context75.p = _context75.n) {
3890
3934
  case 0:
3891
- _ref82 = params || {}, _ref82$clientId = _ref82.clientId, clientId = _ref82$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth27 = masterConfig.auth) === null || _masterConfig$auth27 === void 0 ? void 0 : (_masterConfig$auth27$ = _masterConfig$auth27.oauthConfig) === null || _masterConfig$auth27$ === void 0 ? void 0 : _masterConfig$auth27$.googleClientId : _ref82$clientId, _ref82$openInPage = _ref82.openInPage, openInPage = _ref82$openInPage === void 0 ? (_masterConfig$auth$oa4 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth28 = masterConfig.auth) === null || _masterConfig$auth28 === void 0 ? void 0 : (_masterConfig$auth28$ = _masterConfig$auth28.oauthConfig) === null || _masterConfig$auth28$ === void 0 ? void 0 : _masterConfig$auth28$.openOauthInPage) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : false : _ref82$openInPage, additionalParameters = _ref82.additionalState;
3892
- _context74.p = 1;
3935
+ _ref83 = params || {}, _ref83$clientId = _ref83.clientId, clientId = _ref83$clientId === void 0 ? 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$.googleClientId : _ref83$clientId, _ref83$openInPage = _ref83.openInPage, openInPage = _ref83$openInPage === void 0 ? (_masterConfig$auth$oa4 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth29 = masterConfig.auth) === null || _masterConfig$auth29 === void 0 ? void 0 : (_masterConfig$auth29$ = _masterConfig$auth29.oauthConfig) === null || _masterConfig$auth29$ === void 0 ? void 0 : _masterConfig$auth29$.openOauthInPage) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : false : _ref83$openInPage, additionalParameters = _ref83.additionalState;
3936
+ _context75.p = 1;
3893
3937
  if (masterConfig) {
3894
- _context74.n = 2;
3938
+ _context75.n = 2;
3895
3939
  break;
3896
3940
  }
3897
3941
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3898
3942
  case 2:
3899
3943
  if (clientId) {
3900
- _context74.n = 3;
3944
+ _context75.n = 3;
3901
3945
  break;
3902
3946
  }
3903
3947
  throw new TurnkeyError("Google Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3904
3948
  case 3:
3905
- if ((_masterConfig$auth29 = masterConfig.auth) !== null && _masterConfig$auth29 !== void 0 && (_masterConfig$auth29$ = _masterConfig$auth29.oauthConfig) !== null && _masterConfig$auth29$ !== void 0 && _masterConfig$auth29$.oauthRedirectUri) {
3906
- _context74.n = 4;
3949
+ if ((_masterConfig$auth30 = masterConfig.auth) !== null && _masterConfig$auth30 !== void 0 && (_masterConfig$auth30$ = _masterConfig$auth30.oauthConfig) !== null && _masterConfig$auth30$ !== void 0 && _masterConfig$auth30$.oauthRedirectUri) {
3950
+ _context75.n = 4;
3907
3951
  break;
3908
3952
  }
3909
3953
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3910
3954
  case 4:
3911
3955
  flow = openInPage ? "redirect" : "popup";
3912
- redirectURI = (_masterConfig$auth30 = masterConfig.auth) === null || _masterConfig$auth30 === void 0 ? void 0 : _masterConfig$auth30.oauthConfig.oauthRedirectUri.replace(/\/$/, ""); // Create key pair and generate nonce
3913
- _context74.n = 5;
3956
+ redirectURI = (_masterConfig$auth31 = masterConfig.auth) === null || _masterConfig$auth31 === void 0 ? void 0 : _masterConfig$auth31.oauthConfig.oauthRedirectUri.replace(/\/$/, ""); // Create key pair and generate nonce
3957
+ _context75.n = 5;
3914
3958
  return createApiKeyPair();
3915
3959
  case 5:
3916
- publicKey = _context74.v;
3960
+ publicKey = _context75.v;
3917
3961
  if (publicKey) {
3918
- _context74.n = 6;
3962
+ _context75.n = 6;
3919
3963
  break;
3920
3964
  }
3921
3965
  throw new Error("Failed to create public key for OAuth.");
@@ -3931,10 +3975,10 @@ var ClientProvider = function ClientProvider(_ref) {
3931
3975
  // Create state parameter
3932
3976
  state = "provider=google&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
3933
3977
  if (additionalParameters) {
3934
- additionalState = Object.entries(additionalParameters).map(function (_ref83) {
3935
- var _ref84 = _slicedToArray(_ref83, 2),
3936
- key = _ref84[0],
3937
- value = _ref84[1];
3978
+ additionalState = Object.entries(additionalParameters).map(function (_ref84) {
3979
+ var _ref85 = _slicedToArray(_ref84, 2),
3980
+ key = _ref85[0],
3981
+ value = _ref85[1];
3938
3982
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
3939
3983
  }).join("&");
3940
3984
  if (additionalState) {
@@ -3943,12 +3987,12 @@ var ClientProvider = function ClientProvider(_ref) {
3943
3987
  }
3944
3988
  googleAuthUrl.searchParams.set("state", state);
3945
3989
  if (!openInPage) {
3946
- _context74.n = 7;
3990
+ _context75.n = 7;
3947
3991
  break;
3948
3992
  }
3949
3993
  // Redirect current page to Google Auth
3950
3994
  window.location.href = googleAuthUrl.toString();
3951
- return _context74.a(2, new Promise(function (_, reject) {
3995
+ return _context75.a(2, new Promise(function (_, reject) {
3952
3996
  // By here, the page should have already redirected. We wait here since the function is async.
3953
3997
  // We want any function that runs this to simply wait until the page redirects.
3954
3998
  // A 5 min timeout is set just in case, idk
@@ -3968,7 +4012,7 @@ var ClientProvider = function ClientProvider(_ref) {
3968
4012
  top = window.screenY + (window.innerHeight - height) / 2;
3969
4013
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3970
4014
  if (authWindow) {
3971
- _context74.n = 8;
4015
+ _context75.n = 8;
3972
4016
  break;
3973
4017
  }
3974
4018
  throw new Error("Failed to open Google login window.");
@@ -3976,7 +4020,7 @@ var ClientProvider = function ClientProvider(_ref) {
3976
4020
  authWindow.location.href = googleAuthUrl.toString();
3977
4021
  // Return a promise that resolves when the OAuth flow completes
3978
4022
  // This following code will only run for the popup flow
3979
- return _context74.a(2, new Promise(function (resolve, reject) {
4023
+ return _context75.a(2, new Promise(function (resolve, reject) {
3980
4024
  var interval = setInterval(function () {
3981
4025
  try {
3982
4026
  // Check if window was closed without completing auth
@@ -4036,57 +4080,57 @@ var ClientProvider = function ClientProvider(_ref) {
4036
4080
  }
4037
4081
  }));
4038
4082
  case 9:
4039
- _context74.n = 11;
4083
+ _context75.n = 11;
4040
4084
  break;
4041
4085
  case 10:
4042
- _context74.p = 10;
4043
- _t11 = _context74.v;
4086
+ _context75.p = 10;
4087
+ _t11 = _context75.v;
4044
4088
  throw _t11;
4045
4089
  case 11:
4046
- return _context74.a(2);
4090
+ return _context75.a(2);
4047
4091
  }
4048
- }, _callee74, null, [[1, 10]]);
4092
+ }, _callee75, null, [[1, 10]]);
4049
4093
  }));
4050
- return function (_x62) {
4051
- return _ref81.apply(this, arguments);
4094
+ return function (_x63) {
4095
+ return _ref82.apply(this, arguments);
4052
4096
  };
4053
4097
  }(), [client, callbacks, masterConfig, session, user]);
4054
4098
  var handleAppleOauth = useCallback(/*#__PURE__*/function () {
4055
- var _ref85 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee75(params) {
4056
- var _masterConfig$auth31, _masterConfig$auth31$, _masterConfig$auth$oa5, _masterConfig$auth32, _masterConfig$auth32$;
4057
- var _ref86, _ref86$clientId, clientId, _ref86$openInPage, openInPage, additionalParameters, _masterConfig$auth33, _masterConfig$auth33$, _masterConfig$auth34, flow, redirectURI, publicKey, nonce, appleAuthUrl, state, additionalState, width, height, left, top, authWindow, _t12;
4058
- return _regenerator().w(function (_context75) {
4059
- while (1) switch (_context75.p = _context75.n) {
4099
+ var _ref86 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee76(params) {
4100
+ var _masterConfig$auth32, _masterConfig$auth32$, _masterConfig$auth$oa5, _masterConfig$auth33, _masterConfig$auth33$;
4101
+ var _ref87, _ref87$clientId, clientId, _ref87$openInPage, openInPage, additionalParameters, _masterConfig$auth34, _masterConfig$auth34$, _masterConfig$auth35, flow, redirectURI, publicKey, nonce, appleAuthUrl, state, additionalState, width, height, left, top, authWindow, _t12;
4102
+ return _regenerator().w(function (_context76) {
4103
+ while (1) switch (_context76.p = _context76.n) {
4060
4104
  case 0:
4061
- _ref86 = params || {}, _ref86$clientId = _ref86.clientId, clientId = _ref86$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth31 = masterConfig.auth) === null || _masterConfig$auth31 === void 0 ? void 0 : (_masterConfig$auth31$ = _masterConfig$auth31.oauthConfig) === null || _masterConfig$auth31$ === void 0 ? void 0 : _masterConfig$auth31$.appleClientId : _ref86$clientId, _ref86$openInPage = _ref86.openInPage, openInPage = _ref86$openInPage === void 0 ? (_masterConfig$auth$oa5 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth32 = masterConfig.auth) === null || _masterConfig$auth32 === void 0 ? void 0 : (_masterConfig$auth32$ = _masterConfig$auth32.oauthConfig) === null || _masterConfig$auth32$ === void 0 ? void 0 : _masterConfig$auth32$.openOauthInPage) !== null && _masterConfig$auth$oa5 !== void 0 ? _masterConfig$auth$oa5 : false : _ref86$openInPage, additionalParameters = _ref86.additionalState;
4062
- _context75.p = 1;
4105
+ _ref87 = params || {}, _ref87$clientId = _ref87.clientId, clientId = _ref87$clientId === void 0 ? 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$.appleClientId : _ref87$clientId, _ref87$openInPage = _ref87.openInPage, openInPage = _ref87$openInPage === void 0 ? (_masterConfig$auth$oa5 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth33 = masterConfig.auth) === null || _masterConfig$auth33 === void 0 ? void 0 : (_masterConfig$auth33$ = _masterConfig$auth33.oauthConfig) === null || _masterConfig$auth33$ === void 0 ? void 0 : _masterConfig$auth33$.openOauthInPage) !== null && _masterConfig$auth$oa5 !== void 0 ? _masterConfig$auth$oa5 : false : _ref87$openInPage, additionalParameters = _ref87.additionalState;
4106
+ _context76.p = 1;
4063
4107
  if (masterConfig) {
4064
- _context75.n = 2;
4108
+ _context76.n = 2;
4065
4109
  break;
4066
4110
  }
4067
4111
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4068
4112
  case 2:
4069
4113
  if (clientId) {
4070
- _context75.n = 3;
4114
+ _context76.n = 3;
4071
4115
  break;
4072
4116
  }
4073
4117
  throw new TurnkeyError("Apple Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4074
4118
  case 3:
4075
- if ((_masterConfig$auth33 = masterConfig.auth) !== null && _masterConfig$auth33 !== void 0 && (_masterConfig$auth33$ = _masterConfig$auth33.oauthConfig) !== null && _masterConfig$auth33$ !== void 0 && _masterConfig$auth33$.oauthRedirectUri) {
4076
- _context75.n = 4;
4119
+ if ((_masterConfig$auth34 = masterConfig.auth) !== null && _masterConfig$auth34 !== void 0 && (_masterConfig$auth34$ = _masterConfig$auth34.oauthConfig) !== null && _masterConfig$auth34$ !== void 0 && _masterConfig$auth34$.oauthRedirectUri) {
4120
+ _context76.n = 4;
4077
4121
  break;
4078
4122
  }
4079
4123
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4080
4124
  case 4:
4081
4125
  flow = openInPage ? "redirect" : "popup";
4082
- redirectURI = (_masterConfig$auth34 = masterConfig.auth) === null || _masterConfig$auth34 === void 0 ? void 0 : _masterConfig$auth34.oauthConfig.oauthRedirectUri; // TODO (Amir): Apple needs the '/' at the end. Maybe we should add it if not there?
4126
+ redirectURI = (_masterConfig$auth35 = masterConfig.auth) === null || _masterConfig$auth35 === void 0 ? void 0 : _masterConfig$auth35.oauthConfig.oauthRedirectUri; // TODO (Amir): Apple needs the '/' at the end. Maybe we should add it if not there?
4083
4127
  // Create key pair and generate nonce
4084
- _context75.n = 5;
4128
+ _context76.n = 5;
4085
4129
  return createApiKeyPair();
4086
4130
  case 5:
4087
- publicKey = _context75.v;
4131
+ publicKey = _context76.v;
4088
4132
  if (publicKey) {
4089
- _context75.n = 6;
4133
+ _context76.n = 6;
4090
4134
  break;
4091
4135
  }
4092
4136
  throw new Error("Failed to create public key for OAuth.");
@@ -4101,10 +4145,10 @@ var ClientProvider = function ClientProvider(_ref) {
4101
4145
  // Create state parameter
4102
4146
  state = "provider=apple&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
4103
4147
  if (additionalParameters) {
4104
- additionalState = Object.entries(additionalParameters).map(function (_ref87) {
4105
- var _ref88 = _slicedToArray(_ref87, 2),
4106
- key = _ref88[0],
4107
- value = _ref88[1];
4148
+ additionalState = Object.entries(additionalParameters).map(function (_ref88) {
4149
+ var _ref89 = _slicedToArray(_ref88, 2),
4150
+ key = _ref89[0],
4151
+ value = _ref89[1];
4108
4152
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
4109
4153
  }).join("&");
4110
4154
  if (additionalState) {
@@ -4113,12 +4157,12 @@ var ClientProvider = function ClientProvider(_ref) {
4113
4157
  }
4114
4158
  appleAuthUrl.searchParams.set("state", state);
4115
4159
  if (!openInPage) {
4116
- _context75.n = 7;
4160
+ _context76.n = 7;
4117
4161
  break;
4118
4162
  }
4119
4163
  // Redirect current page to Apple Auth
4120
4164
  window.location.href = appleAuthUrl.toString();
4121
- return _context75.a(2, new Promise(function (_, reject) {
4165
+ return _context76.a(2, new Promise(function (_, reject) {
4122
4166
  // Set a timeout just in case the redirect doesn't happen
4123
4167
  var timeout = setTimeout(function () {
4124
4168
  reject(new Error("Authentication timed out."));
@@ -4136,14 +4180,14 @@ var ClientProvider = function ClientProvider(_ref) {
4136
4180
  top = window.screenY + (window.innerHeight - height) / 2;
4137
4181
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
4138
4182
  if (authWindow) {
4139
- _context75.n = 8;
4183
+ _context76.n = 8;
4140
4184
  break;
4141
4185
  }
4142
4186
  throw new Error("Failed to open Apple login window.");
4143
4187
  case 8:
4144
4188
  authWindow.location.href = appleAuthUrl.toString();
4145
4189
  // Return a promise that resolves when the OAuth flow completes
4146
- return _context75.a(2, new Promise(function (resolve, reject) {
4190
+ return _context76.a(2, new Promise(function (resolve, reject) {
4147
4191
  var interval = setInterval(function () {
4148
4192
  try {
4149
4193
  // Check if window was closed without completing auth
@@ -4203,65 +4247,65 @@ var ClientProvider = function ClientProvider(_ref) {
4203
4247
  }
4204
4248
  }));
4205
4249
  case 9:
4206
- _context75.n = 11;
4250
+ _context76.n = 11;
4207
4251
  break;
4208
4252
  case 10:
4209
- _context75.p = 10;
4210
- _t12 = _context75.v;
4253
+ _context76.p = 10;
4254
+ _t12 = _context76.v;
4211
4255
  throw _t12;
4212
4256
  case 11:
4213
- return _context75.a(2);
4257
+ return _context76.a(2);
4214
4258
  }
4215
- }, _callee75, null, [[1, 10]]);
4259
+ }, _callee76, null, [[1, 10]]);
4216
4260
  }));
4217
- return function (_x63) {
4218
- return _ref85.apply(this, arguments);
4261
+ return function (_x64) {
4262
+ return _ref86.apply(this, arguments);
4219
4263
  };
4220
4264
  }(), [client, callbacks, masterConfig, session, user]);
4221
4265
  var handleFacebookOauth = useCallback(/*#__PURE__*/function () {
4222
- var _ref89 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee76(params) {
4223
- var _masterConfig$auth35, _masterConfig$auth35$, _masterConfig$auth$oa6, _masterConfig$auth36, _masterConfig$auth36$;
4224
- var _ref90, _ref90$clientId, clientId, _ref90$openInPage, openInPage, additionalParameters, _masterConfig$auth37, _masterConfig$auth37$, _masterConfig$auth38, flow, redirectURI, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, facebookAuthUrl, state, additionalState, width, height, left, top, authWindow, _t13;
4225
- return _regenerator().w(function (_context76) {
4226
- while (1) switch (_context76.p = _context76.n) {
4266
+ var _ref90 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee77(params) {
4267
+ var _masterConfig$auth36, _masterConfig$auth36$, _masterConfig$auth$oa6, _masterConfig$auth37, _masterConfig$auth37$;
4268
+ var _ref91, _ref91$clientId, clientId, _ref91$openInPage, openInPage, additionalParameters, _masterConfig$auth38, _masterConfig$auth38$, _masterConfig$auth39, flow, redirectURI, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, facebookAuthUrl, state, additionalState, width, height, left, top, authWindow, _t13;
4269
+ return _regenerator().w(function (_context77) {
4270
+ while (1) switch (_context77.p = _context77.n) {
4227
4271
  case 0:
4228
- _ref90 = params || {}, _ref90$clientId = _ref90.clientId, clientId = _ref90$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth35 = masterConfig.auth) === null || _masterConfig$auth35 === void 0 ? void 0 : (_masterConfig$auth35$ = _masterConfig$auth35.oauthConfig) === null || _masterConfig$auth35$ === void 0 ? void 0 : _masterConfig$auth35$.facebookClientId : _ref90$clientId, _ref90$openInPage = _ref90.openInPage, openInPage = _ref90$openInPage === void 0 ? (_masterConfig$auth$oa6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth36 = masterConfig.auth) === null || _masterConfig$auth36 === void 0 ? void 0 : (_masterConfig$auth36$ = _masterConfig$auth36.oauthConfig) === null || _masterConfig$auth36$ === void 0 ? void 0 : _masterConfig$auth36$.openOauthInPage) !== null && _masterConfig$auth$oa6 !== void 0 ? _masterConfig$auth$oa6 : false : _ref90$openInPage, additionalParameters = _ref90.additionalState;
4229
- _context76.p = 1;
4272
+ _ref91 = params || {}, _ref91$clientId = _ref91.clientId, clientId = _ref91$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth36 = masterConfig.auth) === null || _masterConfig$auth36 === void 0 ? void 0 : (_masterConfig$auth36$ = _masterConfig$auth36.oauthConfig) === null || _masterConfig$auth36$ === void 0 ? void 0 : _masterConfig$auth36$.facebookClientId : _ref91$clientId, _ref91$openInPage = _ref91.openInPage, openInPage = _ref91$openInPage === void 0 ? (_masterConfig$auth$oa6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth37 = masterConfig.auth) === null || _masterConfig$auth37 === void 0 ? void 0 : (_masterConfig$auth37$ = _masterConfig$auth37.oauthConfig) === null || _masterConfig$auth37$ === void 0 ? void 0 : _masterConfig$auth37$.openOauthInPage) !== null && _masterConfig$auth$oa6 !== void 0 ? _masterConfig$auth$oa6 : false : _ref91$openInPage, additionalParameters = _ref91.additionalState;
4273
+ _context77.p = 1;
4230
4274
  if (masterConfig) {
4231
- _context76.n = 2;
4275
+ _context77.n = 2;
4232
4276
  break;
4233
4277
  }
4234
4278
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4235
4279
  case 2:
4236
4280
  if (clientId) {
4237
- _context76.n = 3;
4281
+ _context77.n = 3;
4238
4282
  break;
4239
4283
  }
4240
4284
  throw new TurnkeyError("Facebook Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4241
4285
  case 3:
4242
- if ((_masterConfig$auth37 = masterConfig.auth) !== null && _masterConfig$auth37 !== void 0 && (_masterConfig$auth37$ = _masterConfig$auth37.oauthConfig) !== null && _masterConfig$auth37$ !== void 0 && _masterConfig$auth37$.oauthRedirectUri) {
4243
- _context76.n = 4;
4286
+ if ((_masterConfig$auth38 = masterConfig.auth) !== null && _masterConfig$auth38 !== void 0 && (_masterConfig$auth38$ = _masterConfig$auth38.oauthConfig) !== null && _masterConfig$auth38$ !== void 0 && _masterConfig$auth38$.oauthRedirectUri) {
4287
+ _context77.n = 4;
4244
4288
  break;
4245
4289
  }
4246
4290
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4247
4291
  case 4:
4248
4292
  flow = openInPage ? "redirect" : "popup";
4249
- redirectURI = (_masterConfig$auth38 = masterConfig.auth) === null || _masterConfig$auth38 === void 0 ? void 0 : _masterConfig$auth38.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4250
- _context76.n = 5;
4293
+ redirectURI = (_masterConfig$auth39 = masterConfig.auth) === null || _masterConfig$auth39 === void 0 ? void 0 : _masterConfig$auth39.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4294
+ _context77.n = 5;
4251
4295
  return createApiKeyPair();
4252
4296
  case 5:
4253
- publicKey = _context76.v;
4297
+ publicKey = _context77.v;
4254
4298
  if (publicKey) {
4255
- _context76.n = 6;
4299
+ _context77.n = 6;
4256
4300
  break;
4257
4301
  }
4258
4302
  throw new Error("Failed to create public key for OAuth.");
4259
4303
  case 6:
4260
4304
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
4261
- _context76.n = 7;
4305
+ _context77.n = 7;
4262
4306
  return generateChallengePair();
4263
4307
  case 7:
4264
- _yield$generateChalle3 = _context76.v;
4308
+ _yield$generateChalle3 = _context77.v;
4265
4309
  verifier = _yield$generateChalle3.verifier;
4266
4310
  codeChallenge = _yield$generateChalle3.codeChallenge;
4267
4311
  // Store verifier for later token exchange
@@ -4278,10 +4322,10 @@ var ClientProvider = function ClientProvider(_ref) {
4278
4322
  // Create state parameter
4279
4323
  state = "provider=facebook&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
4280
4324
  if (additionalParameters) {
4281
- additionalState = Object.entries(additionalParameters).map(function (_ref91) {
4282
- var _ref92 = _slicedToArray(_ref91, 2),
4283
- key = _ref92[0],
4284
- value = _ref92[1];
4325
+ additionalState = Object.entries(additionalParameters).map(function (_ref92) {
4326
+ var _ref93 = _slicedToArray(_ref92, 2),
4327
+ key = _ref93[0],
4328
+ value = _ref93[1];
4285
4329
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
4286
4330
  }).join("&");
4287
4331
  if (additionalState) {
@@ -4290,12 +4334,12 @@ var ClientProvider = function ClientProvider(_ref) {
4290
4334
  }
4291
4335
  facebookAuthUrl.searchParams.set("state", state);
4292
4336
  if (!openInPage) {
4293
- _context76.n = 8;
4337
+ _context77.n = 8;
4294
4338
  break;
4295
4339
  }
4296
4340
  // Redirect current page to Facebook Auth
4297
4341
  window.location.href = facebookAuthUrl.toString();
4298
- return _context76.a(2, new Promise(function (_, reject) {
4342
+ return _context77.a(2, new Promise(function (_, reject) {
4299
4343
  // Set a timeout just in case the redirect doesn't happen
4300
4344
  var timeout = setTimeout(function () {
4301
4345
  reject(new Error("Authentication timed out."));
@@ -4313,14 +4357,14 @@ var ClientProvider = function ClientProvider(_ref) {
4313
4357
  top = window.screenY + (window.innerHeight - height) / 2;
4314
4358
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
4315
4359
  if (authWindow) {
4316
- _context76.n = 9;
4360
+ _context77.n = 9;
4317
4361
  break;
4318
4362
  }
4319
4363
  throw new Error("Failed to open Facebook login window.");
4320
4364
  case 9:
4321
4365
  authWindow.location.href = facebookAuthUrl.toString();
4322
4366
  // Return a promise that resolves when the OAuth flow completes
4323
- return _context76.a(2, new Promise(function (resolve, reject) {
4367
+ return _context77.a(2, new Promise(function (resolve, reject) {
4324
4368
  var interval = setInterval(function () {
4325
4369
  try {
4326
4370
  // Check if window was closed without completing auth
@@ -4389,27 +4433,27 @@ var ClientProvider = function ClientProvider(_ref) {
4389
4433
  }
4390
4434
  }));
4391
4435
  case 10:
4392
- _context76.n = 12;
4436
+ _context77.n = 12;
4393
4437
  break;
4394
4438
  case 11:
4395
- _context76.p = 11;
4396
- _t13 = _context76.v;
4439
+ _context77.p = 11;
4440
+ _t13 = _context77.v;
4397
4441
  throw _t13;
4398
4442
  case 12:
4399
- return _context76.a(2);
4443
+ return _context77.a(2);
4400
4444
  }
4401
- }, _callee76, null, [[1, 11]]);
4445
+ }, _callee77, null, [[1, 11]]);
4402
4446
  }));
4403
- return function (_x64) {
4404
- return _ref89.apply(this, arguments);
4447
+ return function (_x65) {
4448
+ return _ref90.apply(this, arguments);
4405
4449
  };
4406
4450
  }(), [client, callbacks, masterConfig, client, session, user]);
4407
4451
  var handleLogin = useCallback(/*#__PURE__*/function () {
4408
- var _ref93 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee77(params) {
4452
+ var _ref94 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee78(params) {
4409
4453
  var _masterConfig$ui, _params$logoDark, _masterConfig$ui2, _params$logoLight, _masterConfig$ui3, _params$title;
4410
4454
  var logo;
4411
- return _regenerator().w(function (_context77) {
4412
- while (1) switch (_context77.n) {
4455
+ return _regenerator().w(function (_context78) {
4456
+ while (1) switch (_context78.n) {
4413
4457
  case 0:
4414
4458
  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;
4415
4459
  pushPage({
@@ -4423,22 +4467,22 @@ var ClientProvider = function ClientProvider(_ref) {
4423
4467
  showTitle: logo ? false : true
4424
4468
  });
4425
4469
  case 1:
4426
- return _context77.a(2);
4470
+ return _context78.a(2);
4427
4471
  }
4428
- }, _callee77);
4472
+ }, _callee78);
4429
4473
  }));
4430
- return function (_x65) {
4431
- return _ref93.apply(this, arguments);
4474
+ return function (_x66) {
4475
+ return _ref94.apply(this, arguments);
4432
4476
  };
4433
4477
  }(), [pushPage, masterConfig, client, session, user]);
4434
4478
  var handleExportWallet = useCallback(/*#__PURE__*/function () {
4435
- var _ref94 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee78(params) {
4479
+ var _ref95 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee79(params) {
4436
4480
  var walletId, targetPublicKey, stampWith, organizationId;
4437
- return _regenerator().w(function (_context78) {
4438
- while (1) switch (_context78.n) {
4481
+ return _regenerator().w(function (_context79) {
4482
+ while (1) switch (_context79.n) {
4439
4483
  case 0:
4440
4484
  walletId = params.walletId, targetPublicKey = params.targetPublicKey, stampWith = params.stampWith, organizationId = params.organizationId;
4441
- return _context78.a(2, new Promise(function (resolve, reject) {
4485
+ return _context79.a(2, new Promise(function (resolve, reject) {
4442
4486
  return pushPage({
4443
4487
  key: "Export wallet",
4444
4488
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4464,20 +4508,20 @@ var ClientProvider = function ClientProvider(_ref) {
4464
4508
  });
4465
4509
  }));
4466
4510
  }
4467
- }, _callee78);
4511
+ }, _callee79);
4468
4512
  }));
4469
- return function (_x66) {
4470
- return _ref94.apply(this, arguments);
4513
+ return function (_x67) {
4514
+ return _ref95.apply(this, arguments);
4471
4515
  };
4472
4516
  }(), [pushPage, masterConfig, client, session, user]);
4473
4517
  var handleExportPrivateKey = useCallback(/*#__PURE__*/function () {
4474
- var _ref95 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee79(params) {
4518
+ var _ref96 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee80(params) {
4475
4519
  var privateKeyId, targetPublicKey, keyFormat, stampWith, organizationId;
4476
- return _regenerator().w(function (_context79) {
4477
- while (1) switch (_context79.n) {
4520
+ return _regenerator().w(function (_context80) {
4521
+ while (1) switch (_context80.n) {
4478
4522
  case 0:
4479
4523
  privateKeyId = params.privateKeyId, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith, organizationId = params.organizationId;
4480
- return _context79.a(2, new Promise(function (resolve, reject) {
4524
+ return _context80.a(2, new Promise(function (resolve, reject) {
4481
4525
  return pushPage({
4482
4526
  key: "Export private key",
4483
4527
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4505,20 +4549,20 @@ var ClientProvider = function ClientProvider(_ref) {
4505
4549
  });
4506
4550
  }));
4507
4551
  }
4508
- }, _callee79);
4552
+ }, _callee80);
4509
4553
  }));
4510
- return function (_x67) {
4511
- return _ref95.apply(this, arguments);
4554
+ return function (_x68) {
4555
+ return _ref96.apply(this, arguments);
4512
4556
  };
4513
4557
  }(), [pushPage, masterConfig, client, session, user]);
4514
4558
  var handleExportWalletAccount = useCallback(/*#__PURE__*/function () {
4515
- var _ref96 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee80(params) {
4559
+ var _ref97 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee81(params) {
4516
4560
  var address, targetPublicKey, keyFormat, stampWith, organizationId;
4517
- return _regenerator().w(function (_context80) {
4518
- while (1) switch (_context80.n) {
4561
+ return _regenerator().w(function (_context81) {
4562
+ while (1) switch (_context81.n) {
4519
4563
  case 0:
4520
4564
  address = params.address, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith, organizationId = params.organizationId;
4521
- return _context80.a(2, new Promise(function (resolve, reject) {
4565
+ return _context81.a(2, new Promise(function (resolve, reject) {
4522
4566
  return pushPage({
4523
4567
  key: "Export wallet account",
4524
4568
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4546,21 +4590,21 @@ var ClientProvider = function ClientProvider(_ref) {
4546
4590
  });
4547
4591
  }));
4548
4592
  }
4549
- }, _callee80);
4593
+ }, _callee81);
4550
4594
  }));
4551
- return function (_x68) {
4552
- return _ref96.apply(this, arguments);
4595
+ return function (_x69) {
4596
+ return _ref97.apply(this, arguments);
4553
4597
  };
4554
4598
  }(), [pushPage, masterConfig, client, session, user]);
4555
4599
  var handleImportWallet = useCallback(/*#__PURE__*/function () {
4556
- var _ref97 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee81(params) {
4557
- var _ref98, defaultWalletAccounts, _ref98$successPageDur, successPageDuration, stampWith, walletName, organizationId, userId, _t14;
4558
- return _regenerator().w(function (_context81) {
4559
- while (1) switch (_context81.p = _context81.n) {
4600
+ var _ref98 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee82(params) {
4601
+ var _ref99, defaultWalletAccounts, _ref99$successPageDur, successPageDuration, stampWith, walletName, organizationId, userId, _t14;
4602
+ return _regenerator().w(function (_context82) {
4603
+ while (1) switch (_context82.p = _context82.n) {
4560
4604
  case 0:
4561
- _ref98 = params || {}, defaultWalletAccounts = _ref98.defaultWalletAccounts, _ref98$successPageDur = _ref98.successPageDuration, successPageDuration = _ref98$successPageDur === void 0 ? 2000 : _ref98$successPageDur, stampWith = _ref98.stampWith, walletName = _ref98.walletName, organizationId = _ref98.organizationId, userId = _ref98.userId;
4562
- _context81.p = 1;
4563
- return _context81.a(2, withTurnkeyErrorHandling(function () {
4605
+ _ref99 = params || {}, defaultWalletAccounts = _ref99.defaultWalletAccounts, _ref99$successPageDur = _ref99.successPageDuration, successPageDuration = _ref99$successPageDur === void 0 ? 2000 : _ref99$successPageDur, stampWith = _ref99.stampWith, walletName = _ref99.walletName, organizationId = _ref99.organizationId, userId = _ref99.userId;
4606
+ _context82.p = 1;
4607
+ return _context82.a(2, withTurnkeyErrorHandling(function () {
4564
4608
  return new Promise(function (resolve, reject) {
4565
4609
  return pushPage({
4566
4610
  key: "Import wallet",
@@ -4591,33 +4635,33 @@ var ClientProvider = function ClientProvider(_ref) {
4591
4635
  return logout();
4592
4636
  }));
4593
4637
  case 2:
4594
- _context81.p = 2;
4595
- _t14 = _context81.v;
4638
+ _context82.p = 2;
4639
+ _t14 = _context82.v;
4596
4640
  if (!(_t14 instanceof TurnkeyError)) {
4597
- _context81.n = 3;
4641
+ _context82.n = 3;
4598
4642
  break;
4599
4643
  }
4600
4644
  throw _t14;
4601
4645
  case 3:
4602
4646
  throw new TurnkeyError("Failed to import wallet.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t14);
4603
4647
  case 4:
4604
- return _context81.a(2);
4648
+ return _context82.a(2);
4605
4649
  }
4606
- }, _callee81, null, [[1, 2]]);
4650
+ }, _callee82, null, [[1, 2]]);
4607
4651
  }));
4608
- return function (_x69) {
4609
- return _ref97.apply(this, arguments);
4652
+ return function (_x70) {
4653
+ return _ref98.apply(this, arguments);
4610
4654
  };
4611
4655
  }(), [pushPage, masterConfig, client, session, user]);
4612
4656
  var handleImportPrivateKey = useCallback(/*#__PURE__*/function () {
4613
- var _ref99 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee82(params) {
4614
- var _ref100, curve, addressFormats, _ref100$successPageDu, successPageDuration, stampWith, keyName, organizationId, _t15;
4615
- return _regenerator().w(function (_context82) {
4616
- while (1) switch (_context82.p = _context82.n) {
4657
+ var _ref100 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee83(params) {
4658
+ var _ref101, curve, addressFormats, _ref101$successPageDu, successPageDuration, stampWith, keyName, organizationId, _t15;
4659
+ return _regenerator().w(function (_context83) {
4660
+ while (1) switch (_context83.p = _context83.n) {
4617
4661
  case 0:
4618
- _ref100 = params || {}, curve = _ref100.curve, addressFormats = _ref100.addressFormats, _ref100$successPageDu = _ref100.successPageDuration, successPageDuration = _ref100$successPageDu === void 0 ? 2000 : _ref100$successPageDu, stampWith = _ref100.stampWith, keyName = _ref100.keyName, organizationId = _ref100.organizationId;
4619
- _context82.p = 1;
4620
- return _context82.a(2, withTurnkeyErrorHandling(function () {
4662
+ _ref101 = params || {}, curve = _ref101.curve, addressFormats = _ref101.addressFormats, _ref101$successPageDu = _ref101.successPageDuration, successPageDuration = _ref101$successPageDu === void 0 ? 2000 : _ref101$successPageDu, stampWith = _ref101.stampWith, keyName = _ref101.keyName, organizationId = _ref101.organizationId;
4663
+ _context83.p = 1;
4664
+ return _context83.a(2, withTurnkeyErrorHandling(function () {
4621
4665
  return new Promise(function (resolve, reject) {
4622
4666
  return pushPage({
4623
4667
  key: "Import private key",
@@ -4646,51 +4690,51 @@ var ClientProvider = function ClientProvider(_ref) {
4646
4690
  return logout();
4647
4691
  }));
4648
4692
  case 2:
4649
- _context82.p = 2;
4650
- _t15 = _context82.v;
4693
+ _context83.p = 2;
4694
+ _t15 = _context83.v;
4651
4695
  if (!(_t15 instanceof TurnkeyError)) {
4652
- _context82.n = 3;
4696
+ _context83.n = 3;
4653
4697
  break;
4654
4698
  }
4655
4699
  throw _t15;
4656
4700
  case 3:
4657
4701
  throw new TurnkeyError("Failed to import private key.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t15);
4658
4702
  case 4:
4659
- return _context82.a(2);
4703
+ return _context83.a(2);
4660
4704
  }
4661
- }, _callee82, null, [[1, 2]]);
4705
+ }, _callee83, null, [[1, 2]]);
4662
4706
  }));
4663
- return function (_x70) {
4664
- return _ref99.apply(this, arguments);
4707
+ return function (_x71) {
4708
+ return _ref100.apply(this, arguments);
4665
4709
  };
4666
4710
  }(), [pushPage, masterConfig, client, session, user]);
4667
4711
  var handleUpdateUserName = useCallback(/*#__PURE__*/function () {
4668
- var _ref101 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee83(params) {
4669
- var _ref102, _ref102$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, res, _t16;
4670
- return _regenerator().w(function (_context83) {
4671
- while (1) switch (_context83.p = _context83.n) {
4712
+ var _ref102 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee84(params) {
4713
+ var _ref103, _ref103$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, res, _t16;
4714
+ return _regenerator().w(function (_context84) {
4715
+ while (1) switch (_context84.p = _context84.n) {
4672
4716
  case 0:
4673
- _ref102 = params || {}, _ref102$successPageDu = _ref102.successPageDuration, successPageDuration = _ref102$successPageDu === void 0 ? 2000 : _ref102$successPageDu, subTitle = _ref102.subTitle, title = _ref102.title, stampWith = _ref102.stampWith;
4717
+ _ref103 = params || {}, _ref103$successPageDu = _ref103.successPageDuration, successPageDuration = _ref103$successPageDu === void 0 ? 2000 : _ref103$successPageDu, subTitle = _ref103.subTitle, title = _ref103.title, stampWith = _ref103.stampWith;
4674
4718
  if (client) {
4675
- _context83.n = 1;
4719
+ _context84.n = 1;
4676
4720
  break;
4677
4721
  }
4678
4722
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4679
4723
  case 1:
4680
- _context83.n = 2;
4724
+ _context84.n = 2;
4681
4725
  return getSession();
4682
4726
  case 2:
4683
- s = _context83.v;
4727
+ s = _context84.v;
4684
4728
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4685
4729
  if (organizationId) {
4686
- _context83.n = 3;
4730
+ _context84.n = 3;
4687
4731
  break;
4688
4732
  }
4689
4733
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
4690
4734
  case 3:
4691
4735
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (user === null || user === void 0 ? void 0 : user.userId);
4692
4736
  if (userId) {
4693
- _context83.n = 4;
4737
+ _context84.n = 4;
4694
4738
  break;
4695
4739
  }
4696
4740
  throw new TurnkeyError("A user ID is required to update a user name.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -4710,12 +4754,12 @@ var ClientProvider = function ClientProvider(_ref) {
4710
4754
  showTitle: false
4711
4755
  });
4712
4756
  };
4713
- _context83.p = 5;
4757
+ _context84.p = 5;
4714
4758
  if (!(!(params !== null && params !== void 0 && params.userName) && (params === null || params === void 0 ? void 0 : params.userName) !== "")) {
4715
- _context83.n = 6;
4759
+ _context84.n = 6;
4716
4760
  break;
4717
4761
  }
4718
- return _context83.a(2, withTurnkeyErrorHandling(function () {
4762
+ return _context84.a(2, withTurnkeyErrorHandling(function () {
4719
4763
  return new Promise(function (resolve, reject) {
4720
4764
  pushPage({
4721
4765
  key: "Update User Name",
@@ -4743,7 +4787,7 @@ var ClientProvider = function ClientProvider(_ref) {
4743
4787
  return logout();
4744
4788
  }));
4745
4789
  case 6:
4746
- _context83.n = 7;
4790
+ _context84.n = 7;
4747
4791
  return updateUserName(_objectSpread2({
4748
4792
  userName: params.userName,
4749
4793
  userId: user.userId,
@@ -4752,71 +4796,71 @@ var ClientProvider = function ClientProvider(_ref) {
4752
4796
  organizationId: organizationId
4753
4797
  }));
4754
4798
  case 7:
4755
- res = _context83.v;
4799
+ res = _context84.v;
4756
4800
  onSuccess();
4757
- return _context83.a(2, res);
4801
+ return _context84.a(2, res);
4758
4802
  case 8:
4759
- _context83.n = 11;
4803
+ _context84.n = 11;
4760
4804
  break;
4761
4805
  case 9:
4762
- _context83.p = 9;
4763
- _t16 = _context83.v;
4806
+ _context84.p = 9;
4807
+ _t16 = _context84.v;
4764
4808
  if (!(_t16 instanceof TurnkeyError)) {
4765
- _context83.n = 10;
4809
+ _context84.n = 10;
4766
4810
  break;
4767
4811
  }
4768
4812
  throw _t16;
4769
4813
  case 10:
4770
4814
  throw new TurnkeyError("Failed to update user name.", TurnkeyErrorCodes.UPDATE_USER_NAME_ERROR, _t16);
4771
4815
  case 11:
4772
- return _context83.a(2);
4816
+ return _context84.a(2);
4773
4817
  }
4774
- }, _callee83, null, [[5, 9]]);
4818
+ }, _callee84, null, [[5, 9]]);
4775
4819
  }));
4776
- return function (_x71) {
4777
- return _ref101.apply(this, arguments);
4820
+ return function (_x72) {
4821
+ return _ref102.apply(this, arguments);
4778
4822
  };
4779
4823
  }(), [pushPage, masterConfig, client, session, user]);
4780
4824
  var handleUpdateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
4781
- var _ref103 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee85(params) {
4782
- var _masterConfig$auth39, _masterConfig$auth39$;
4783
- var _ref104, _ref104$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t18;
4784
- return _regenerator().w(function (_context85) {
4785
- while (1) switch (_context85.p = _context85.n) {
4825
+ var _ref104 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee86(params) {
4826
+ var _masterConfig$auth40, _masterConfig$auth40$;
4827
+ var _ref105, _ref105$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t18;
4828
+ return _regenerator().w(function (_context86) {
4829
+ while (1) switch (_context86.p = _context86.n) {
4786
4830
  case 0:
4787
- _ref104 = params || {}, _ref104$successPageDu = _ref104.successPageDuration, successPageDuration = _ref104$successPageDu === void 0 ? 2000 : _ref104$successPageDu, subTitle = _ref104.subTitle, title = _ref104.title, stampWith = _ref104.stampWith;
4831
+ _ref105 = params || {}, _ref105$successPageDu = _ref105.successPageDuration, successPageDuration = _ref105$successPageDu === void 0 ? 2000 : _ref105$successPageDu, subTitle = _ref105.subTitle, title = _ref105.title, stampWith = _ref105.stampWith;
4788
4832
  if (client) {
4789
- _context85.n = 1;
4833
+ _context86.n = 1;
4790
4834
  break;
4791
4835
  }
4792
4836
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4793
4837
  case 1:
4794
4838
  if (masterConfig) {
4795
- _context85.n = 2;
4839
+ _context86.n = 2;
4796
4840
  break;
4797
4841
  }
4798
4842
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
4799
4843
  case 2:
4800
- if ((_masterConfig$auth39 = masterConfig.auth) !== null && _masterConfig$auth39 !== void 0 && (_masterConfig$auth39$ = _masterConfig$auth39.methods) !== null && _masterConfig$auth39$ !== void 0 && _masterConfig$auth39$.smsOtpAuthEnabled) {
4801
- _context85.n = 3;
4844
+ if ((_masterConfig$auth40 = masterConfig.auth) !== null && _masterConfig$auth40 !== void 0 && (_masterConfig$auth40$ = _masterConfig$auth40.methods) !== null && _masterConfig$auth40$ !== void 0 && _masterConfig$auth40$.smsOtpAuthEnabled) {
4845
+ _context86.n = 3;
4802
4846
  break;
4803
4847
  }
4804
4848
  throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
4805
4849
  case 3:
4806
- _context85.n = 4;
4850
+ _context86.n = 4;
4807
4851
  return getSession();
4808
4852
  case 4:
4809
- s = _context85.v;
4853
+ s = _context86.v;
4810
4854
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4811
4855
  if (organizationId) {
4812
- _context85.n = 5;
4856
+ _context86.n = 5;
4813
4857
  break;
4814
4858
  }
4815
4859
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
4816
4860
  case 5:
4817
4861
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
4818
4862
  if (userId) {
4819
- _context85.n = 6;
4863
+ _context86.n = 6;
4820
4864
  break;
4821
4865
  }
4822
4866
  throw new TurnkeyError("A user ID is required to update a phone number.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -4836,12 +4880,12 @@ var ClientProvider = function ClientProvider(_ref) {
4836
4880
  showTitle: false
4837
4881
  });
4838
4882
  };
4839
- _context85.p = 7;
4883
+ _context86.p = 7;
4840
4884
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
4841
- _context85.n = 8;
4885
+ _context86.n = 8;
4842
4886
  break;
4843
4887
  }
4844
- return _context85.a(2, withTurnkeyErrorHandling(function () {
4888
+ return _context86.a(2, withTurnkeyErrorHandling(function () {
4845
4889
  return new Promise(function (resolve, reject) {
4846
4890
  pushPage({
4847
4891
  key: "Update Phone Number",
@@ -4869,32 +4913,32 @@ var ClientProvider = function ClientProvider(_ref) {
4869
4913
  return logout();
4870
4914
  }));
4871
4915
  case 8:
4872
- _context85.n = 9;
4916
+ _context86.n = 9;
4873
4917
  return initOtp({
4874
4918
  otpType: OtpType.Sms,
4875
4919
  contact: params.phoneNumber
4876
4920
  });
4877
4921
  case 9:
4878
- otpId = _context85.v;
4879
- return _context85.a(2, withTurnkeyErrorHandling(function () {
4922
+ otpId = _context86.v;
4923
+ return _context86.a(2, withTurnkeyErrorHandling(function () {
4880
4924
  return new Promise(function (resolve, reject) {
4881
- var _masterConfig$auth40, _masterConfig$auth41;
4925
+ var _masterConfig$auth41, _masterConfig$auth42;
4882
4926
  pushPage({
4883
4927
  key: "Update Phone Number",
4884
4928
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2(_objectSpread2({
4885
4929
  otpType: OtpType.Sms,
4886
4930
  contact: params.phoneNumber,
4887
4931
  otpId: otpId,
4888
- otpLength: ((_masterConfig$auth40 = masterConfig.auth) === null || _masterConfig$auth40 === void 0 ? void 0 : _masterConfig$auth40.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
4889
- alphanumeric: (_masterConfig$auth41 = masterConfig.auth) === null || _masterConfig$auth41 === void 0 ? void 0 : _masterConfig$auth41.otpAlphanumeric,
4932
+ otpLength: ((_masterConfig$auth41 = masterConfig.auth) === null || _masterConfig$auth41 === void 0 ? void 0 : _masterConfig$auth41.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
4933
+ alphanumeric: (_masterConfig$auth42 = masterConfig.auth) === null || _masterConfig$auth42 === void 0 ? void 0 : _masterConfig$auth42.otpAlphanumeric,
4890
4934
  onContinue: function () {
4891
- var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee84(otpCode) {
4935
+ var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee85(otpCode) {
4892
4936
  var _yield$verifyOtp, verificationToken, res, _t17;
4893
- return _regenerator().w(function (_context84) {
4894
- while (1) switch (_context84.p = _context84.n) {
4937
+ return _regenerator().w(function (_context85) {
4938
+ while (1) switch (_context85.p = _context85.n) {
4895
4939
  case 0:
4896
- _context84.p = 0;
4897
- _context84.n = 1;
4940
+ _context85.p = 0;
4941
+ _context85.n = 1;
4898
4942
  return verifyOtp({
4899
4943
  otpId: otpId,
4900
4944
  otpCode: otpCode,
@@ -4902,9 +4946,9 @@ var ClientProvider = function ClientProvider(_ref) {
4902
4946
  otpType: OtpType.Sms
4903
4947
  });
4904
4948
  case 1:
4905
- _yield$verifyOtp = _context84.v;
4949
+ _yield$verifyOtp = _context85.v;
4906
4950
  verificationToken = _yield$verifyOtp.verificationToken;
4907
- _context84.n = 2;
4951
+ _context85.n = 2;
4908
4952
  return updateUserPhoneNumber(_objectSpread2({
4909
4953
  phoneNumber: params.phoneNumber,
4910
4954
  verificationToken: verificationToken,
@@ -4914,21 +4958,21 @@ var ClientProvider = function ClientProvider(_ref) {
4914
4958
  stampWith: stampWith
4915
4959
  }));
4916
4960
  case 2:
4917
- res = _context84.v;
4961
+ res = _context85.v;
4918
4962
  onSuccess();
4919
4963
  resolve(res);
4920
- _context84.n = 4;
4964
+ _context85.n = 4;
4921
4965
  break;
4922
4966
  case 3:
4923
- _context84.p = 3;
4924
- _t17 = _context84.v;
4967
+ _context85.p = 3;
4968
+ _t17 = _context85.v;
4925
4969
  reject(_t17);
4926
4970
  case 4:
4927
- return _context84.a(2);
4971
+ return _context85.a(2);
4928
4972
  }
4929
- }, _callee84, null, [[0, 3]]);
4973
+ }, _callee85, null, [[0, 3]]);
4930
4974
  }));
4931
- function onContinue(_x73) {
4975
+ function onContinue(_x74) {
4932
4976
  return _onContinue.apply(this, arguments);
4933
4977
  }
4934
4978
  return onContinue;
@@ -4947,54 +4991,54 @@ var ClientProvider = function ClientProvider(_ref) {
4947
4991
  return logout();
4948
4992
  }, callbacks, "Failed to update phone number"));
4949
4993
  case 10:
4950
- _context85.n = 13;
4994
+ _context86.n = 13;
4951
4995
  break;
4952
4996
  case 11:
4953
- _context85.p = 11;
4954
- _t18 = _context85.v;
4997
+ _context86.p = 11;
4998
+ _t18 = _context86.v;
4955
4999
  if (!(_t18 instanceof TurnkeyError)) {
4956
- _context85.n = 12;
5000
+ _context86.n = 12;
4957
5001
  break;
4958
5002
  }
4959
5003
  throw _t18;
4960
5004
  case 12:
4961
5005
  throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t18);
4962
5006
  case 13:
4963
- return _context85.a(2);
5007
+ return _context86.a(2);
4964
5008
  }
4965
- }, _callee85, null, [[7, 11]]);
5009
+ }, _callee86, null, [[7, 11]]);
4966
5010
  }));
4967
- return function (_x72) {
4968
- return _ref103.apply(this, arguments);
5011
+ return function (_x73) {
5012
+ return _ref104.apply(this, arguments);
4969
5013
  };
4970
5014
  }(), [pushPage, masterConfig, client, session, user]);
4971
5015
  var handleUpdateUserEmail = useCallback(/*#__PURE__*/function () {
4972
- var _ref105 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee87(params) {
4973
- var _ref106, _ref106$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t20;
4974
- return _regenerator().w(function (_context87) {
4975
- while (1) switch (_context87.p = _context87.n) {
5016
+ var _ref106 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee88(params) {
5017
+ var _ref107, _ref107$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t20;
5018
+ return _regenerator().w(function (_context88) {
5019
+ while (1) switch (_context88.p = _context88.n) {
4976
5020
  case 0:
4977
- _ref106 = params || {}, _ref106$successPageDu = _ref106.successPageDuration, successPageDuration = _ref106$successPageDu === void 0 ? 2000 : _ref106$successPageDu, subTitle = _ref106.subTitle, title = _ref106.title, stampWith = _ref106.stampWith;
5021
+ _ref107 = params || {}, _ref107$successPageDu = _ref107.successPageDuration, successPageDuration = _ref107$successPageDu === void 0 ? 2000 : _ref107$successPageDu, subTitle = _ref107.subTitle, title = _ref107.title, stampWith = _ref107.stampWith;
4978
5022
  if (client) {
4979
- _context87.n = 1;
5023
+ _context88.n = 1;
4980
5024
  break;
4981
5025
  }
4982
5026
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4983
5027
  case 1:
4984
- _context87.n = 2;
5028
+ _context88.n = 2;
4985
5029
  return getSession();
4986
5030
  case 2:
4987
- s = _context87.v;
5031
+ s = _context88.v;
4988
5032
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4989
5033
  if (organizationId) {
4990
- _context87.n = 3;
5034
+ _context88.n = 3;
4991
5035
  break;
4992
5036
  }
4993
5037
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
4994
5038
  case 3:
4995
5039
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
4996
5040
  if (userId) {
4997
- _context87.n = 4;
5041
+ _context88.n = 4;
4998
5042
  break;
4999
5043
  }
5000
5044
  throw new TurnkeyError("A user ID is required to update an email.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5014,12 +5058,12 @@ var ClientProvider = function ClientProvider(_ref) {
5014
5058
  showTitle: false
5015
5059
  });
5016
5060
  };
5017
- _context87.p = 5;
5061
+ _context88.p = 5;
5018
5062
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
5019
- _context87.n = 6;
5063
+ _context88.n = 6;
5020
5064
  break;
5021
5065
  }
5022
- return _context87.a(2, withTurnkeyErrorHandling(function () {
5066
+ return _context88.a(2, withTurnkeyErrorHandling(function () {
5023
5067
  return new Promise(function (resolve, reject) {
5024
5068
  pushPage({
5025
5069
  key: "Update Email",
@@ -5047,32 +5091,32 @@ var ClientProvider = function ClientProvider(_ref) {
5047
5091
  return logout();
5048
5092
  }));
5049
5093
  case 6:
5050
- _context87.n = 7;
5094
+ _context88.n = 7;
5051
5095
  return initOtp({
5052
5096
  otpType: OtpType.Email,
5053
5097
  contact: params.email
5054
5098
  });
5055
5099
  case 7:
5056
- otpId = _context87.v;
5057
- return _context87.a(2, withTurnkeyErrorHandling(function () {
5100
+ otpId = _context88.v;
5101
+ return _context88.a(2, withTurnkeyErrorHandling(function () {
5058
5102
  return new Promise(function (resolve, reject) {
5059
- var _masterConfig$auth42, _masterConfig$auth43;
5103
+ var _masterConfig$auth43, _masterConfig$auth44;
5060
5104
  pushPage({
5061
5105
  key: "Update Email",
5062
5106
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2({
5063
5107
  otpType: OtpType.Email,
5064
5108
  contact: params.email,
5065
5109
  otpId: otpId,
5066
- otpLength: (masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth42 = masterConfig.auth) === null || _masterConfig$auth42 === void 0 ? void 0 : _masterConfig$auth42.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5067
- alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth43 = masterConfig.auth) === null || _masterConfig$auth43 === void 0 ? void 0 : _masterConfig$auth43.otpAlphanumeric,
5110
+ 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,
5111
+ alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth44 = masterConfig.auth) === null || _masterConfig$auth44 === void 0 ? void 0 : _masterConfig$auth44.otpAlphanumeric,
5068
5112
  onContinue: function () {
5069
- var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee86(otpCode) {
5113
+ var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee87(otpCode) {
5070
5114
  var _yield$verifyOtp2, verificationToken, res, _t19;
5071
- return _regenerator().w(function (_context86) {
5072
- while (1) switch (_context86.p = _context86.n) {
5115
+ return _regenerator().w(function (_context87) {
5116
+ while (1) switch (_context87.p = _context87.n) {
5073
5117
  case 0:
5074
- _context86.p = 0;
5075
- _context86.n = 1;
5118
+ _context87.p = 0;
5119
+ _context87.n = 1;
5076
5120
  return verifyOtp({
5077
5121
  otpId: otpId,
5078
5122
  otpCode: otpCode,
@@ -5080,9 +5124,9 @@ var ClientProvider = function ClientProvider(_ref) {
5080
5124
  otpType: OtpType.Email
5081
5125
  });
5082
5126
  case 1:
5083
- _yield$verifyOtp2 = _context86.v;
5127
+ _yield$verifyOtp2 = _context87.v;
5084
5128
  verificationToken = _yield$verifyOtp2.verificationToken;
5085
- _context86.n = 2;
5129
+ _context87.n = 2;
5086
5130
  return updateUserEmail(_objectSpread2({
5087
5131
  email: params.email,
5088
5132
  verificationToken: verificationToken,
@@ -5092,21 +5136,21 @@ var ClientProvider = function ClientProvider(_ref) {
5092
5136
  stampWith: stampWith
5093
5137
  }));
5094
5138
  case 2:
5095
- res = _context86.v;
5139
+ res = _context87.v;
5096
5140
  onSuccess();
5097
5141
  resolve(res);
5098
- _context86.n = 4;
5142
+ _context87.n = 4;
5099
5143
  break;
5100
5144
  case 3:
5101
- _context86.p = 3;
5102
- _t19 = _context86.v;
5145
+ _context87.p = 3;
5146
+ _t19 = _context87.v;
5103
5147
  reject(_t19);
5104
5148
  case 4:
5105
- return _context86.a(2);
5149
+ return _context87.a(2);
5106
5150
  }
5107
- }, _callee86, null, [[0, 3]]);
5151
+ }, _callee87, null, [[0, 3]]);
5108
5152
  }));
5109
- function onContinue(_x75) {
5153
+ function onContinue(_x76) {
5110
5154
  return _onContinue2.apply(this, arguments);
5111
5155
  }
5112
5156
  return onContinue;
@@ -5123,54 +5167,54 @@ var ClientProvider = function ClientProvider(_ref) {
5123
5167
  return logout();
5124
5168
  }, callbacks, "Failed to update email"));
5125
5169
  case 8:
5126
- _context87.n = 11;
5170
+ _context88.n = 11;
5127
5171
  break;
5128
5172
  case 9:
5129
- _context87.p = 9;
5130
- _t20 = _context87.v;
5173
+ _context88.p = 9;
5174
+ _t20 = _context88.v;
5131
5175
  if (!(_t20 instanceof TurnkeyError)) {
5132
- _context87.n = 10;
5176
+ _context88.n = 10;
5133
5177
  break;
5134
5178
  }
5135
5179
  throw _t20;
5136
5180
  case 10:
5137
5181
  throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t20);
5138
5182
  case 11:
5139
- return _context87.a(2);
5183
+ return _context88.a(2);
5140
5184
  }
5141
- }, _callee87, null, [[5, 9]]);
5185
+ }, _callee88, null, [[5, 9]]);
5142
5186
  }));
5143
- return function (_x74) {
5144
- return _ref105.apply(this, arguments);
5187
+ return function (_x75) {
5188
+ return _ref106.apply(this, arguments);
5145
5189
  };
5146
5190
  }(), [pushPage, masterConfig, client, session, user]);
5147
5191
  var handleAddEmail = useCallback(/*#__PURE__*/function () {
5148
- var _ref107 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee89(params) {
5149
- var _ref108, _ref108$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t22;
5150
- return _regenerator().w(function (_context89) {
5151
- while (1) switch (_context89.p = _context89.n) {
5192
+ var _ref108 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee90(params) {
5193
+ var _ref109, _ref109$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t22;
5194
+ return _regenerator().w(function (_context90) {
5195
+ while (1) switch (_context90.p = _context90.n) {
5152
5196
  case 0:
5153
- _ref108 = params || {}, _ref108$successPageDu = _ref108.successPageDuration, successPageDuration = _ref108$successPageDu === void 0 ? 2000 : _ref108$successPageDu, subTitle = _ref108.subTitle, title = _ref108.title, stampWith = _ref108.stampWith;
5197
+ _ref109 = params || {}, _ref109$successPageDu = _ref109.successPageDuration, successPageDuration = _ref109$successPageDu === void 0 ? 2000 : _ref109$successPageDu, subTitle = _ref109.subTitle, title = _ref109.title, stampWith = _ref109.stampWith;
5154
5198
  if (client) {
5155
- _context89.n = 1;
5199
+ _context90.n = 1;
5156
5200
  break;
5157
5201
  }
5158
5202
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5159
5203
  case 1:
5160
- _context89.n = 2;
5204
+ _context90.n = 2;
5161
5205
  return getSession();
5162
5206
  case 2:
5163
- s = _context89.v;
5207
+ s = _context90.v;
5164
5208
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5165
5209
  if (organizationId) {
5166
- _context89.n = 3;
5210
+ _context90.n = 3;
5167
5211
  break;
5168
5212
  }
5169
5213
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5170
5214
  case 3:
5171
5215
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5172
5216
  if (userId) {
5173
- _context89.n = 4;
5217
+ _context90.n = 4;
5174
5218
  break;
5175
5219
  }
5176
5220
  throw new TurnkeyError("A user ID is required to add an email.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5190,12 +5234,12 @@ var ClientProvider = function ClientProvider(_ref) {
5190
5234
  showTitle: false
5191
5235
  });
5192
5236
  };
5193
- _context89.p = 5;
5237
+ _context90.p = 5;
5194
5238
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
5195
- _context89.n = 6;
5239
+ _context90.n = 6;
5196
5240
  break;
5197
5241
  }
5198
- return _context89.a(2, withTurnkeyErrorHandling(function () {
5242
+ return _context90.a(2, withTurnkeyErrorHandling(function () {
5199
5243
  return new Promise(function (resolve, reject) {
5200
5244
  pushPage({
5201
5245
  key: "Add Email",
@@ -5223,32 +5267,32 @@ var ClientProvider = function ClientProvider(_ref) {
5223
5267
  return logout();
5224
5268
  }));
5225
5269
  case 6:
5226
- _context89.n = 7;
5270
+ _context90.n = 7;
5227
5271
  return initOtp({
5228
5272
  otpType: OtpType.Email,
5229
5273
  contact: params.email
5230
5274
  });
5231
5275
  case 7:
5232
- otpId = _context89.v;
5233
- return _context89.a(2, withTurnkeyErrorHandling(function () {
5276
+ otpId = _context90.v;
5277
+ return _context90.a(2, withTurnkeyErrorHandling(function () {
5234
5278
  return new Promise(function (resolve, reject) {
5235
- var _masterConfig$auth44, _masterConfig$auth45;
5279
+ var _masterConfig$auth45, _masterConfig$auth46;
5236
5280
  pushPage({
5237
5281
  key: "Add Email",
5238
5282
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2({
5239
5283
  otpType: OtpType.Email,
5240
5284
  contact: params.email,
5241
5285
  otpId: otpId,
5242
- otpLength: (masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth44 = masterConfig.auth) === null || _masterConfig$auth44 === void 0 ? void 0 : _masterConfig$auth44.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5243
- alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth45 = masterConfig.auth) === null || _masterConfig$auth45 === void 0 ? void 0 : _masterConfig$auth45.otpAlphanumeric,
5286
+ otpLength: (masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth45 = masterConfig.auth) === null || _masterConfig$auth45 === void 0 ? void 0 : _masterConfig$auth45.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5287
+ alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth46 = masterConfig.auth) === null || _masterConfig$auth46 === void 0 ? void 0 : _masterConfig$auth46.otpAlphanumeric,
5244
5288
  onContinue: function () {
5245
- var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee88(otpCode) {
5289
+ var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee89(otpCode) {
5246
5290
  var _yield$verifyOtp3, verificationToken, res, _t21;
5247
- return _regenerator().w(function (_context88) {
5248
- while (1) switch (_context88.p = _context88.n) {
5291
+ return _regenerator().w(function (_context89) {
5292
+ while (1) switch (_context89.p = _context89.n) {
5249
5293
  case 0:
5250
- _context88.p = 0;
5251
- _context88.n = 1;
5294
+ _context89.p = 0;
5295
+ _context89.n = 1;
5252
5296
  return verifyOtp({
5253
5297
  otpId: otpId,
5254
5298
  otpCode: otpCode,
@@ -5256,9 +5300,9 @@ var ClientProvider = function ClientProvider(_ref) {
5256
5300
  otpType: OtpType.Email
5257
5301
  });
5258
5302
  case 1:
5259
- _yield$verifyOtp3 = _context88.v;
5303
+ _yield$verifyOtp3 = _context89.v;
5260
5304
  verificationToken = _yield$verifyOtp3.verificationToken;
5261
- _context88.n = 2;
5305
+ _context89.n = 2;
5262
5306
  return updateUserEmail({
5263
5307
  email: params.email,
5264
5308
  verificationToken: verificationToken,
@@ -5267,21 +5311,21 @@ var ClientProvider = function ClientProvider(_ref) {
5267
5311
  stampWith: stampWith
5268
5312
  });
5269
5313
  case 2:
5270
- res = _context88.v;
5314
+ res = _context89.v;
5271
5315
  onSuccess();
5272
5316
  resolve(res);
5273
- _context88.n = 4;
5317
+ _context89.n = 4;
5274
5318
  break;
5275
5319
  case 3:
5276
- _context88.p = 3;
5277
- _t21 = _context88.v;
5320
+ _context89.p = 3;
5321
+ _t21 = _context89.v;
5278
5322
  reject(_t21);
5279
5323
  case 4:
5280
- return _context88.a(2);
5324
+ return _context89.a(2);
5281
5325
  }
5282
- }, _callee88, null, [[0, 3]]);
5326
+ }, _callee89, null, [[0, 3]]);
5283
5327
  }));
5284
- function onContinue(_x77) {
5328
+ function onContinue(_x78) {
5285
5329
  return _onContinue3.apply(this, arguments);
5286
5330
  }
5287
5331
  return onContinue;
@@ -5298,67 +5342,67 @@ var ClientProvider = function ClientProvider(_ref) {
5298
5342
  return logout();
5299
5343
  }, callbacks, "Failed to add email"));
5300
5344
  case 8:
5301
- _context89.n = 11;
5345
+ _context90.n = 11;
5302
5346
  break;
5303
5347
  case 9:
5304
- _context89.p = 9;
5305
- _t22 = _context89.v;
5348
+ _context90.p = 9;
5349
+ _t22 = _context90.v;
5306
5350
  if (!(_t22 instanceof TurnkeyError)) {
5307
- _context89.n = 10;
5351
+ _context90.n = 10;
5308
5352
  break;
5309
5353
  }
5310
5354
  throw _t22;
5311
5355
  case 10:
5312
5356
  throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t22);
5313
5357
  case 11:
5314
- return _context89.a(2);
5358
+ return _context90.a(2);
5315
5359
  }
5316
- }, _callee89, null, [[5, 9]]);
5360
+ }, _callee90, null, [[5, 9]]);
5317
5361
  }));
5318
- return function (_x76) {
5319
- return _ref107.apply(this, arguments);
5362
+ return function (_x77) {
5363
+ return _ref108.apply(this, arguments);
5320
5364
  };
5321
5365
  }(), [pushPage, client, session, user]);
5322
5366
  var handleAddPhoneNumber = useCallback(/*#__PURE__*/function () {
5323
- var _ref109 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(params) {
5324
- var _masterConfig$auth46, _masterConfig$auth46$;
5325
- var _ref110, _ref110$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t24;
5326
- return _regenerator().w(function (_context91) {
5327
- while (1) switch (_context91.p = _context91.n) {
5367
+ var _ref110 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee92(params) {
5368
+ var _masterConfig$auth47, _masterConfig$auth47$;
5369
+ var _ref111, _ref111$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t24;
5370
+ return _regenerator().w(function (_context92) {
5371
+ while (1) switch (_context92.p = _context92.n) {
5328
5372
  case 0:
5329
- _ref110 = params || {}, _ref110$successPageDu = _ref110.successPageDuration, successPageDuration = _ref110$successPageDu === void 0 ? 2000 : _ref110$successPageDu, subTitle = _ref110.subTitle, title = _ref110.title, stampWith = _ref110.stampWith;
5373
+ _ref111 = params || {}, _ref111$successPageDu = _ref111.successPageDuration, successPageDuration = _ref111$successPageDu === void 0 ? 2000 : _ref111$successPageDu, subTitle = _ref111.subTitle, title = _ref111.title, stampWith = _ref111.stampWith;
5330
5374
  if (client) {
5331
- _context91.n = 1;
5375
+ _context92.n = 1;
5332
5376
  break;
5333
5377
  }
5334
5378
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5335
5379
  case 1:
5336
5380
  if (masterConfig) {
5337
- _context91.n = 2;
5381
+ _context92.n = 2;
5338
5382
  break;
5339
5383
  }
5340
5384
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
5341
5385
  case 2:
5342
- if ((_masterConfig$auth46 = masterConfig.auth) !== null && _masterConfig$auth46 !== void 0 && (_masterConfig$auth46$ = _masterConfig$auth46.methods) !== null && _masterConfig$auth46$ !== void 0 && _masterConfig$auth46$.smsOtpAuthEnabled) {
5343
- _context91.n = 3;
5386
+ if ((_masterConfig$auth47 = masterConfig.auth) !== null && _masterConfig$auth47 !== void 0 && (_masterConfig$auth47$ = _masterConfig$auth47.methods) !== null && _masterConfig$auth47$ !== void 0 && _masterConfig$auth47$.smsOtpAuthEnabled) {
5387
+ _context92.n = 3;
5344
5388
  break;
5345
5389
  }
5346
5390
  throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
5347
5391
  case 3:
5348
- _context91.n = 4;
5392
+ _context92.n = 4;
5349
5393
  return getSession();
5350
5394
  case 4:
5351
- s = _context91.v;
5395
+ s = _context92.v;
5352
5396
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5353
5397
  if (organizationId) {
5354
- _context91.n = 5;
5398
+ _context92.n = 5;
5355
5399
  break;
5356
5400
  }
5357
5401
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5358
5402
  case 5:
5359
5403
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5360
5404
  if (userId) {
5361
- _context91.n = 6;
5405
+ _context92.n = 6;
5362
5406
  break;
5363
5407
  }
5364
5408
  throw new TurnkeyError("A user ID is required to add a phone number.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5378,12 +5422,12 @@ var ClientProvider = function ClientProvider(_ref) {
5378
5422
  showTitle: false
5379
5423
  });
5380
5424
  };
5381
- _context91.p = 7;
5425
+ _context92.p = 7;
5382
5426
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
5383
- _context91.n = 8;
5427
+ _context92.n = 8;
5384
5428
  break;
5385
5429
  }
5386
- return _context91.a(2, withTurnkeyErrorHandling(function () {
5430
+ return _context92.a(2, withTurnkeyErrorHandling(function () {
5387
5431
  return new Promise(function (resolve, reject) {
5388
5432
  pushPage({
5389
5433
  key: "Add Phone Number",
@@ -5411,32 +5455,32 @@ var ClientProvider = function ClientProvider(_ref) {
5411
5455
  return logout();
5412
5456
  }, callbacks, "Failed to add phone number"));
5413
5457
  case 8:
5414
- _context91.n = 9;
5458
+ _context92.n = 9;
5415
5459
  return initOtp({
5416
5460
  otpType: OtpType.Sms,
5417
5461
  contact: params.phoneNumber
5418
5462
  });
5419
5463
  case 9:
5420
- otpId = _context91.v;
5421
- return _context91.a(2, withTurnkeyErrorHandling(function () {
5464
+ otpId = _context92.v;
5465
+ return _context92.a(2, withTurnkeyErrorHandling(function () {
5422
5466
  return new Promise(function (resolve, reject) {
5423
- var _masterConfig$auth47, _masterConfig$auth48;
5467
+ var _masterConfig$auth48, _masterConfig$auth49;
5424
5468
  pushPage({
5425
5469
  key: "Add Phone Number",
5426
5470
  content: jsx(OtpVerification, _objectSpread2(_objectSpread2(_objectSpread2({
5427
5471
  otpType: OtpType.Sms,
5428
5472
  contact: params.phoneNumber,
5429
5473
  otpId: otpId,
5430
- otpLength: ((_masterConfig$auth47 = masterConfig.auth) === null || _masterConfig$auth47 === void 0 ? void 0 : _masterConfig$auth47.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5431
- alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth48 = masterConfig.auth) === null || _masterConfig$auth48 === void 0 ? void 0 : _masterConfig$auth48.otpAlphanumeric,
5474
+ otpLength: ((_masterConfig$auth48 = masterConfig.auth) === null || _masterConfig$auth48 === void 0 ? void 0 : _masterConfig$auth48.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5475
+ alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth49 = masterConfig.auth) === null || _masterConfig$auth49 === void 0 ? void 0 : _masterConfig$auth49.otpAlphanumeric,
5432
5476
  onContinue: function () {
5433
- var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee90(otpCode) {
5477
+ var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(otpCode) {
5434
5478
  var _yield$verifyOtp4, verificationToken, res, _t23;
5435
- return _regenerator().w(function (_context90) {
5436
- while (1) switch (_context90.p = _context90.n) {
5479
+ return _regenerator().w(function (_context91) {
5480
+ while (1) switch (_context91.p = _context91.n) {
5437
5481
  case 0:
5438
- _context90.p = 0;
5439
- _context90.n = 1;
5482
+ _context91.p = 0;
5483
+ _context91.n = 1;
5440
5484
  return verifyOtp({
5441
5485
  otpId: otpId,
5442
5486
  otpCode: otpCode,
@@ -5444,9 +5488,9 @@ var ClientProvider = function ClientProvider(_ref) {
5444
5488
  otpType: OtpType.Sms
5445
5489
  });
5446
5490
  case 1:
5447
- _yield$verifyOtp4 = _context90.v;
5491
+ _yield$verifyOtp4 = _context91.v;
5448
5492
  verificationToken = _yield$verifyOtp4.verificationToken;
5449
- _context90.n = 2;
5493
+ _context91.n = 2;
5450
5494
  return updateUserPhoneNumber({
5451
5495
  phoneNumber: params.phoneNumber,
5452
5496
  verificationToken: verificationToken,
@@ -5455,21 +5499,21 @@ var ClientProvider = function ClientProvider(_ref) {
5455
5499
  stampWith: stampWith
5456
5500
  });
5457
5501
  case 2:
5458
- res = _context90.v;
5502
+ res = _context91.v;
5459
5503
  onSuccess();
5460
5504
  resolve(res);
5461
- _context90.n = 4;
5505
+ _context91.n = 4;
5462
5506
  break;
5463
5507
  case 3:
5464
- _context90.p = 3;
5465
- _t23 = _context90.v;
5508
+ _context91.p = 3;
5509
+ _t23 = _context91.v;
5466
5510
  reject(_t23);
5467
5511
  case 4:
5468
- return _context90.a(2);
5512
+ return _context91.a(2);
5469
5513
  }
5470
- }, _callee90, null, [[0, 3]]);
5514
+ }, _callee91, null, [[0, 3]]);
5471
5515
  }));
5472
- function onContinue(_x79) {
5516
+ function onContinue(_x80) {
5473
5517
  return _onContinue4.apply(this, arguments);
5474
5518
  }
5475
5519
  return onContinue;
@@ -5488,52 +5532,52 @@ var ClientProvider = function ClientProvider(_ref) {
5488
5532
  return logout();
5489
5533
  }, callbacks, "Failed to add phone number"));
5490
5534
  case 10:
5491
- _context91.n = 13;
5535
+ _context92.n = 13;
5492
5536
  break;
5493
5537
  case 11:
5494
- _context91.p = 11;
5495
- _t24 = _context91.v;
5538
+ _context92.p = 11;
5539
+ _t24 = _context92.v;
5496
5540
  if (!(_t24 instanceof TurnkeyError)) {
5497
- _context91.n = 12;
5541
+ _context92.n = 12;
5498
5542
  break;
5499
5543
  }
5500
5544
  throw _t24;
5501
5545
  case 12:
5502
5546
  throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t24);
5503
5547
  case 13:
5504
- return _context91.a(2);
5548
+ return _context92.a(2);
5505
5549
  }
5506
- }, _callee91, null, [[7, 11]]);
5550
+ }, _callee92, null, [[7, 11]]);
5507
5551
  }));
5508
- return function (_x78) {
5509
- return _ref109.apply(this, arguments);
5552
+ return function (_x79) {
5553
+ return _ref110.apply(this, arguments);
5510
5554
  };
5511
5555
  }(), [pushPage, masterConfig, client, session, user]);
5512
5556
  var handleRemovePasskey = useCallback(/*#__PURE__*/function () {
5513
- var _ref111 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee92(params) {
5557
+ var _ref112 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(params) {
5514
5558
  var authenticatorId, _params$successPageDu2, successPageDuration, subTitle, title, stampWith, userId, s, organizationId;
5515
- return _regenerator().w(function (_context92) {
5516
- while (1) switch (_context92.n) {
5559
+ return _regenerator().w(function (_context93) {
5560
+ while (1) switch (_context93.n) {
5517
5561
  case 0:
5518
5562
  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;
5519
5563
  if (client) {
5520
- _context92.n = 1;
5564
+ _context93.n = 1;
5521
5565
  break;
5522
5566
  }
5523
5567
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5524
5568
  case 1:
5525
- _context92.n = 2;
5569
+ _context93.n = 2;
5526
5570
  return getSession();
5527
5571
  case 2:
5528
- s = _context92.v;
5572
+ s = _context93.v;
5529
5573
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5530
5574
  if (organizationId) {
5531
- _context92.n = 3;
5575
+ _context93.n = 3;
5532
5576
  break;
5533
5577
  }
5534
5578
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5535
5579
  case 3:
5536
- return _context92.a(2, withTurnkeyErrorHandling(function () {
5580
+ return _context93.a(2, withTurnkeyErrorHandling(function () {
5537
5581
  return new Promise(function (resolve, reject) {
5538
5582
  pushPage({
5539
5583
  key: "Remove Passkey",
@@ -5564,44 +5608,44 @@ var ClientProvider = function ClientProvider(_ref) {
5564
5608
  return logout();
5565
5609
  }, callbacks, "Failed to remove passkey"));
5566
5610
  }
5567
- }, _callee92);
5611
+ }, _callee93);
5568
5612
  }));
5569
- return function (_x80) {
5570
- return _ref111.apply(this, arguments);
5613
+ return function (_x81) {
5614
+ return _ref112.apply(this, arguments);
5571
5615
  };
5572
5616
  }(), [pushPage, masterConfig, client, session, user]);
5573
5617
  var handleAddPasskey = useCallback(/*#__PURE__*/function () {
5574
- var _ref112 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(params) {
5575
- var _ref113, name, displayName, _ref113$successPageDu, successPageDuration, stampWith, s, organizationId, userId, resPromise, _t25;
5576
- return _regenerator().w(function (_context93) {
5577
- while (1) switch (_context93.p = _context93.n) {
5618
+ var _ref113 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(params) {
5619
+ var _ref114, name, displayName, _ref114$successPageDu, successPageDuration, stampWith, s, organizationId, userId, resPromise, _t25;
5620
+ return _regenerator().w(function (_context94) {
5621
+ while (1) switch (_context94.p = _context94.n) {
5578
5622
  case 0:
5579
- _ref113 = params || {}, name = _ref113.name, displayName = _ref113.displayName, _ref113$successPageDu = _ref113.successPageDuration, successPageDuration = _ref113$successPageDu === void 0 ? 2000 : _ref113$successPageDu, stampWith = _ref113.stampWith;
5623
+ _ref114 = params || {}, name = _ref114.name, displayName = _ref114.displayName, _ref114$successPageDu = _ref114.successPageDuration, successPageDuration = _ref114$successPageDu === void 0 ? 2000 : _ref114$successPageDu, stampWith = _ref114.stampWith;
5580
5624
  if (client) {
5581
- _context93.n = 1;
5625
+ _context94.n = 1;
5582
5626
  break;
5583
5627
  }
5584
5628
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5585
5629
  case 1:
5586
- _context93.n = 2;
5630
+ _context94.n = 2;
5587
5631
  return getSession();
5588
5632
  case 2:
5589
- s = _context93.v;
5633
+ s = _context94.v;
5590
5634
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5591
5635
  if (organizationId) {
5592
- _context93.n = 3;
5636
+ _context94.n = 3;
5593
5637
  break;
5594
5638
  }
5595
5639
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5596
5640
  case 3:
5597
5641
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5598
5642
  if (userId) {
5599
- _context93.n = 4;
5643
+ _context94.n = 4;
5600
5644
  break;
5601
5645
  }
5602
5646
  throw new TurnkeyError("A user ID or a valid session is required to add a passkey.", TurnkeyErrorCodes.INVALID_REQUEST);
5603
5647
  case 4:
5604
- _context93.p = 4;
5648
+ _context94.p = 4;
5605
5649
  resPromise = addPasskey(_objectSpread2(_objectSpread2(_objectSpread2({}, name && {
5606
5650
  name: name
5607
5651
  }), displayName && {
@@ -5626,55 +5670,55 @@ var ClientProvider = function ClientProvider(_ref) {
5626
5670
  showTitle: false
5627
5671
  });
5628
5672
  });
5629
- _context93.n = 5;
5673
+ _context94.n = 5;
5630
5674
  return resPromise;
5631
5675
  case 5:
5632
- return _context93.a(2, _context93.v);
5676
+ return _context94.a(2, _context94.v);
5633
5677
  case 6:
5634
- _context93.p = 6;
5635
- _t25 = _context93.v;
5678
+ _context94.p = 6;
5679
+ _t25 = _context94.v;
5636
5680
  if (!(_t25 instanceof TurnkeyError)) {
5637
- _context93.n = 7;
5681
+ _context94.n = 7;
5638
5682
  break;
5639
5683
  }
5640
5684
  throw _t25;
5641
5685
  case 7:
5642
5686
  throw new TurnkeyError("Failed to add passkey in handler.", TurnkeyErrorCodes.ADD_PASSKEY_ERROR, _t25);
5643
5687
  case 8:
5644
- return _context93.a(2);
5688
+ return _context94.a(2);
5645
5689
  }
5646
- }, _callee93, null, [[4, 6]]);
5690
+ }, _callee94, null, [[4, 6]]);
5647
5691
  }));
5648
- return function (_x81) {
5649
- return _ref112.apply(this, arguments);
5692
+ return function (_x82) {
5693
+ return _ref113.apply(this, arguments);
5650
5694
  };
5651
5695
  }(), [pushPage, masterConfig, client, session, user]);
5652
5696
  var handleRemoveOauthProvider = useCallback(/*#__PURE__*/function () {
5653
- var _ref114 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(params) {
5697
+ var _ref115 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(params) {
5654
5698
  var providerId, _params$successPageDu3, successPageDuration, subTitle, title, stampWith, s, organizationId, _t26;
5655
- return _regenerator().w(function (_context94) {
5656
- while (1) switch (_context94.p = _context94.n) {
5699
+ return _regenerator().w(function (_context95) {
5700
+ while (1) switch (_context95.p = _context95.n) {
5657
5701
  case 0:
5658
5702
  providerId = params.providerId, _params$successPageDu3 = params.successPageDuration, successPageDuration = _params$successPageDu3 === void 0 ? 2000 : _params$successPageDu3, subTitle = params.subTitle, title = params.title, stampWith = params.stampWith;
5659
5703
  if (client) {
5660
- _context94.n = 1;
5704
+ _context95.n = 1;
5661
5705
  break;
5662
5706
  }
5663
5707
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5664
5708
  case 1:
5665
- _context94.n = 2;
5709
+ _context95.n = 2;
5666
5710
  return getSession();
5667
5711
  case 2:
5668
- s = _context94.v;
5712
+ s = _context95.v;
5669
5713
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5670
5714
  if (organizationId) {
5671
- _context94.n = 3;
5715
+ _context95.n = 3;
5672
5716
  break;
5673
5717
  }
5674
5718
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5675
5719
  case 3:
5676
- _context94.p = 3;
5677
- return _context94.a(2, new Promise(function (resolve, reject) {
5720
+ _context95.p = 3;
5721
+ return _context95.a(2, new Promise(function (resolve, reject) {
5678
5722
  pushPage({
5679
5723
  key: "Remove OAuth Provider",
5680
5724
  content: jsx(RemoveOAuthProvider, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5702,68 +5746,68 @@ var ClientProvider = function ClientProvider(_ref) {
5702
5746
  });
5703
5747
  }));
5704
5748
  case 4:
5705
- _context94.p = 4;
5706
- _t26 = _context94.v;
5749
+ _context95.p = 4;
5750
+ _t26 = _context95.v;
5707
5751
  if (!(_t26 instanceof TurnkeyError)) {
5708
- _context94.n = 5;
5752
+ _context95.n = 5;
5709
5753
  break;
5710
5754
  }
5711
5755
  throw _t26;
5712
5756
  case 5:
5713
5757
  throw new TurnkeyError("Failed to remove OAuth provider in handler.", TurnkeyErrorCodes.REMOVE_OAUTH_PROVIDER_ERROR, _t26);
5714
5758
  case 6:
5715
- return _context94.a(2);
5759
+ return _context95.a(2);
5716
5760
  }
5717
- }, _callee94, null, [[3, 4]]);
5761
+ }, _callee95, null, [[3, 4]]);
5718
5762
  }));
5719
- return function (_x82) {
5720
- return _ref114.apply(this, arguments);
5763
+ return function (_x83) {
5764
+ return _ref115.apply(this, arguments);
5721
5765
  };
5722
5766
  }(), [pushPage, masterConfig, client, session, user]);
5723
5767
  var handleAddOauthProvider = useCallback(/*#__PURE__*/function () {
5724
- var _ref115 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(params) {
5768
+ var _ref116 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(params) {
5725
5769
  var providerName, stampWith, _params$successPageDu4, successPageDuration, s, organizationId, userId;
5726
- return _regenerator().w(function (_context97) {
5727
- while (1) switch (_context97.n) {
5770
+ return _regenerator().w(function (_context98) {
5771
+ while (1) switch (_context98.n) {
5728
5772
  case 0:
5729
5773
  if (client) {
5730
- _context97.n = 1;
5774
+ _context98.n = 1;
5731
5775
  break;
5732
5776
  }
5733
5777
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5734
5778
  case 1:
5735
5779
  providerName = params.providerName, stampWith = params.stampWith, _params$successPageDu4 = params.successPageDuration, successPageDuration = _params$successPageDu4 === void 0 ? 2000 : _params$successPageDu4;
5736
- _context97.n = 2;
5780
+ _context98.n = 2;
5737
5781
  return getSession();
5738
5782
  case 2:
5739
- s = _context97.v;
5783
+ s = _context98.v;
5740
5784
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5741
5785
  if (organizationId) {
5742
- _context97.n = 3;
5786
+ _context98.n = 3;
5743
5787
  break;
5744
5788
  }
5745
5789
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5746
5790
  case 3:
5747
5791
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5748
5792
  if (userId) {
5749
- _context97.n = 4;
5793
+ _context98.n = 4;
5750
5794
  break;
5751
5795
  }
5752
5796
  throw new TurnkeyError("A user ID is required to add an OAuth provider.", TurnkeyErrorCodes.INVALID_REQUEST);
5753
5797
  case 4:
5754
- return _context97.a(2, new Promise(/*#__PURE__*/function () {
5755
- var _ref116 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(resolve, reject) {
5798
+ return _context98.a(2, new Promise(/*#__PURE__*/function () {
5799
+ var _ref117 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(resolve, reject) {
5756
5800
  var onOauthSuccess, _t27, _t28;
5757
- return _regenerator().w(function (_context96) {
5758
- while (1) switch (_context96.p = _context96.n) {
5801
+ return _regenerator().w(function (_context97) {
5802
+ while (1) switch (_context97.p = _context97.n) {
5759
5803
  case 0:
5760
- _context96.p = 0;
5804
+ _context97.p = 0;
5761
5805
  onOauthSuccess = /*#__PURE__*/function () {
5762
- var _ref117 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(params) {
5763
- return _regenerator().w(function (_context95) {
5764
- while (1) switch (_context95.n) {
5806
+ var _ref118 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(params) {
5807
+ return _regenerator().w(function (_context96) {
5808
+ while (1) switch (_context96.n) {
5765
5809
  case 0:
5766
- _context95.n = 1;
5810
+ _context96.n = 1;
5767
5811
  return addOauthProvider({
5768
5812
  providerName: params.providerName,
5769
5813
  oidcToken: params.oidcToken,
@@ -5786,107 +5830,107 @@ var ClientProvider = function ClientProvider(_ref) {
5786
5830
  showTitle: false
5787
5831
  });
5788
5832
  case 2:
5789
- return _context95.a(2);
5833
+ return _context96.a(2);
5790
5834
  }
5791
- }, _callee95);
5835
+ }, _callee96);
5792
5836
  }));
5793
- return function onOauthSuccess(_x86) {
5794
- return _ref117.apply(this, arguments);
5837
+ return function onOauthSuccess(_x87) {
5838
+ return _ref118.apply(this, arguments);
5795
5839
  };
5796
5840
  }();
5797
5841
  _t27 = providerName;
5798
- _context96.n = _t27 === OAuthProviders.DISCORD ? 1 : _t27 === OAuthProviders.X ? 3 : _t27 === OAuthProviders.GOOGLE ? 5 : _t27 === OAuthProviders.APPLE ? 7 : _t27 === OAuthProviders.FACEBOOK ? 9 : 11;
5842
+ _context97.n = _t27 === OAuthProviders.DISCORD ? 1 : _t27 === OAuthProviders.X ? 3 : _t27 === OAuthProviders.GOOGLE ? 5 : _t27 === OAuthProviders.APPLE ? 7 : _t27 === OAuthProviders.FACEBOOK ? 9 : 11;
5799
5843
  break;
5800
5844
  case 1:
5801
- _context96.n = 2;
5845
+ _context97.n = 2;
5802
5846
  return handleDiscordOauth({
5803
5847
  openInPage: false,
5804
5848
  onOauthSuccess: onOauthSuccess
5805
5849
  });
5806
5850
  case 2:
5807
- return _context96.a(2, _context96.v);
5851
+ return _context97.a(2, _context97.v);
5808
5852
  case 3:
5809
- _context96.n = 4;
5853
+ _context97.n = 4;
5810
5854
  return handleXOauth({
5811
5855
  openInPage: false,
5812
5856
  onOauthSuccess: onOauthSuccess
5813
5857
  });
5814
5858
  case 4:
5815
- return _context96.a(2, _context96.v);
5859
+ return _context97.a(2, _context97.v);
5816
5860
  case 5:
5817
- _context96.n = 6;
5861
+ _context97.n = 6;
5818
5862
  return handleGoogleOauth({
5819
5863
  openInPage: false,
5820
5864
  onOauthSuccess: onOauthSuccess
5821
5865
  });
5822
5866
  case 6:
5823
- return _context96.a(2, _context96.v);
5867
+ return _context97.a(2, _context97.v);
5824
5868
  case 7:
5825
- _context96.n = 8;
5869
+ _context97.n = 8;
5826
5870
  return handleAppleOauth({
5827
5871
  openInPage: false,
5828
5872
  onOauthSuccess: onOauthSuccess
5829
5873
  });
5830
5874
  case 8:
5831
- return _context96.a(2, _context96.v);
5875
+ return _context97.a(2, _context97.v);
5832
5876
  case 9:
5833
- _context96.n = 10;
5877
+ _context97.n = 10;
5834
5878
  return handleFacebookOauth({
5835
5879
  openInPage: false,
5836
5880
  onOauthSuccess: onOauthSuccess
5837
5881
  });
5838
5882
  case 10:
5839
- return _context96.a(2, _context96.v);
5883
+ return _context97.a(2, _context97.v);
5840
5884
  case 11:
5841
5885
  throw new TurnkeyError("Unsupported OAuth provider: ".concat(providerName), TurnkeyErrorCodes.NOT_FOUND);
5842
5886
  case 12:
5843
- _context96.n = 14;
5887
+ _context97.n = 14;
5844
5888
  break;
5845
5889
  case 13:
5846
- _context96.p = 13;
5847
- _t28 = _context96.v;
5890
+ _context97.p = 13;
5891
+ _t28 = _context97.v;
5848
5892
  reject(_t28);
5849
5893
  case 14:
5850
- return _context96.a(2);
5894
+ return _context97.a(2);
5851
5895
  }
5852
- }, _callee96, null, [[0, 13]]);
5896
+ }, _callee97, null, [[0, 13]]);
5853
5897
  }));
5854
- return function (_x84, _x85) {
5855
- return _ref116.apply(this, arguments);
5898
+ return function (_x85, _x86) {
5899
+ return _ref117.apply(this, arguments);
5856
5900
  };
5857
5901
  }()));
5858
5902
  }
5859
- }, _callee97);
5903
+ }, _callee98);
5860
5904
  }));
5861
- return function (_x83) {
5862
- return _ref115.apply(this, arguments);
5905
+ return function (_x84) {
5906
+ return _ref116.apply(this, arguments);
5863
5907
  };
5864
5908
  }(), [pushPage, masterConfig, client, session, user]);
5865
5909
  var handleConnectExternalWallet = useCallback(/*#__PURE__*/function () {
5866
- var _ref118 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(params) {
5910
+ var _ref119 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99(params) {
5867
5911
  var _masterConfig$walletC4, _masterConfig$walletC5;
5868
- var _ref119, _ref119$successPageDu, successPageDuration, providers;
5869
- return _regenerator().w(function (_context98) {
5870
- while (1) switch (_context98.n) {
5912
+ var _ref120, _ref120$successPageDu, successPageDuration, providers;
5913
+ return _regenerator().w(function (_context99) {
5914
+ while (1) switch (_context99.n) {
5871
5915
  case 0:
5872
- _ref119 = params || {}, _ref119$successPageDu = _ref119.successPageDuration, successPageDuration = _ref119$successPageDu === void 0 ? 2000 : _ref119$successPageDu;
5916
+ _ref120 = params || {}, _ref120$successPageDu = _ref120.successPageDuration, successPageDuration = _ref120$successPageDu === void 0 ? 2000 : _ref120$successPageDu;
5873
5917
  if (client) {
5874
- _context98.n = 1;
5918
+ _context99.n = 1;
5875
5919
  break;
5876
5920
  }
5877
5921
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5878
5922
  case 1:
5879
5923
  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) {
5880
- _context98.n = 2;
5924
+ _context99.n = 2;
5881
5925
  break;
5882
5926
  }
5883
5927
  throw new TurnkeyError("Wallet connecting is not enabled.", TurnkeyErrorCodes.FEATURE_NOT_ENABLED);
5884
5928
  case 2:
5885
- _context98.n = 3;
5929
+ _context99.n = 3;
5886
5930
  return fetchWalletProviders();
5887
5931
  case 3:
5888
- providers = _context98.v;
5889
- return _context98.a(2, new Promise(function (resolve, reject) {
5932
+ providers = _context99.v;
5933
+ return _context99.a(2, new Promise(function (resolve, reject) {
5890
5934
  pushPage({
5891
5935
  key: "Connect wallet",
5892
5936
  content: jsx(ConnectWalletModal, {
@@ -5905,32 +5949,32 @@ var ClientProvider = function ClientProvider(_ref) {
5905
5949
  });
5906
5950
  }));
5907
5951
  }
5908
- }, _callee98);
5952
+ }, _callee99);
5909
5953
  }));
5910
- return function (_x87) {
5911
- return _ref118.apply(this, arguments);
5954
+ return function (_x88) {
5955
+ return _ref119.apply(this, arguments);
5912
5956
  };
5913
5957
  }(), [pushPage, masterConfig, client, session, user]);
5914
5958
  var handleRemoveUserEmail = useCallback(/*#__PURE__*/function () {
5915
- var _ref120 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99(params) {
5916
- var _ref121, _ref121$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t29;
5917
- return _regenerator().w(function (_context99) {
5918
- while (1) switch (_context99.p = _context99.n) {
5959
+ var _ref121 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100(params) {
5960
+ var _ref122, _ref122$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t29;
5961
+ return _regenerator().w(function (_context100) {
5962
+ while (1) switch (_context100.p = _context100.n) {
5919
5963
  case 0:
5920
- _ref121 = params || {}, _ref121$successPageDu = _ref121.successPageDuration, successPageDuration = _ref121$successPageDu === void 0 ? 2000 : _ref121$successPageDu, stampWith = _ref121.stampWith, userId = _ref121.userId;
5921
- _context99.n = 1;
5964
+ _ref122 = params || {}, _ref122$successPageDu = _ref122.successPageDuration, successPageDuration = _ref122$successPageDu === void 0 ? 2000 : _ref122$successPageDu, stampWith = _ref122.stampWith, userId = _ref122.userId;
5965
+ _context100.n = 1;
5922
5966
  return getSession();
5923
5967
  case 1:
5924
- s = _context99.v;
5968
+ s = _context100.v;
5925
5969
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5926
5970
  if (organizationId) {
5927
- _context99.n = 2;
5971
+ _context100.n = 2;
5928
5972
  break;
5929
5973
  }
5930
5974
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5931
5975
  case 2:
5932
- _context99.p = 2;
5933
- return _context99.a(2, new Promise(function (resolve, reject) {
5976
+ _context100.p = 2;
5977
+ return _context100.a(2, new Promise(function (resolve, reject) {
5934
5978
  pushPage({
5935
5979
  key: "Remove Email",
5936
5980
  content: jsx(RemoveEmail, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5957,44 +6001,44 @@ var ClientProvider = function ClientProvider(_ref) {
5957
6001
  });
5958
6002
  }));
5959
6003
  case 3:
5960
- _context99.p = 3;
5961
- _t29 = _context99.v;
6004
+ _context100.p = 3;
6005
+ _t29 = _context100.v;
5962
6006
  if (!(_t29 instanceof TurnkeyError)) {
5963
- _context99.n = 4;
6007
+ _context100.n = 4;
5964
6008
  break;
5965
6009
  }
5966
6010
  throw _t29;
5967
6011
  case 4:
5968
6012
  throw new TurnkeyError("Failed to remove user email.", TurnkeyErrorCodes.UPDATE_USER_EMAIL_ERROR, _t29);
5969
6013
  case 5:
5970
- return _context99.a(2);
6014
+ return _context100.a(2);
5971
6015
  }
5972
- }, _callee99, null, [[2, 3]]);
6016
+ }, _callee100, null, [[2, 3]]);
5973
6017
  }));
5974
- return function (_x88) {
5975
- return _ref120.apply(this, arguments);
6018
+ return function (_x89) {
6019
+ return _ref121.apply(this, arguments);
5976
6020
  };
5977
6021
  }(), [pushPage, masterConfig, client, session, user]);
5978
6022
  var handleRemoveUserPhoneNumber = useCallback(/*#__PURE__*/function () {
5979
- var _ref122 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100(params) {
5980
- var _ref123, _ref123$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t30;
5981
- return _regenerator().w(function (_context100) {
5982
- while (1) switch (_context100.p = _context100.n) {
6023
+ var _ref123 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101(params) {
6024
+ var _ref124, _ref124$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t30;
6025
+ return _regenerator().w(function (_context101) {
6026
+ while (1) switch (_context101.p = _context101.n) {
5983
6027
  case 0:
5984
- _ref123 = params || {}, _ref123$successPageDu = _ref123.successPageDuration, successPageDuration = _ref123$successPageDu === void 0 ? 2000 : _ref123$successPageDu, stampWith = _ref123.stampWith, userId = _ref123.userId;
5985
- _context100.n = 1;
6028
+ _ref124 = params || {}, _ref124$successPageDu = _ref124.successPageDuration, successPageDuration = _ref124$successPageDu === void 0 ? 2000 : _ref124$successPageDu, stampWith = _ref124.stampWith, userId = _ref124.userId;
6029
+ _context101.n = 1;
5986
6030
  return getSession();
5987
6031
  case 1:
5988
- s = _context100.v;
6032
+ s = _context101.v;
5989
6033
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5990
6034
  if (organizationId) {
5991
- _context100.n = 2;
6035
+ _context101.n = 2;
5992
6036
  break;
5993
6037
  }
5994
6038
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5995
6039
  case 2:
5996
- _context100.p = 2;
5997
- return _context100.a(2, new Promise(function (resolve, reject) {
6040
+ _context101.p = 2;
6041
+ return _context101.a(2, new Promise(function (resolve, reject) {
5998
6042
  pushPage({
5999
6043
  key: "Remove Phone Number",
6000
6044
  content: jsx(RemovePhoneNumber, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -6021,58 +6065,121 @@ var ClientProvider = function ClientProvider(_ref) {
6021
6065
  });
6022
6066
  }));
6023
6067
  case 3:
6024
- _context100.p = 3;
6025
- _t30 = _context100.v;
6068
+ _context101.p = 3;
6069
+ _t30 = _context101.v;
6026
6070
  if (!(_t30 instanceof TurnkeyError)) {
6027
- _context100.n = 4;
6071
+ _context101.n = 4;
6028
6072
  break;
6029
6073
  }
6030
6074
  throw _t30;
6031
6075
  case 4:
6032
6076
  throw new TurnkeyError("Failed to remove user phone number.", TurnkeyErrorCodes.UPDATE_USER_PHONE_NUMBER_ERROR, _t30);
6033
6077
  case 5:
6034
- return _context100.a(2);
6078
+ return _context101.a(2);
6035
6079
  }
6036
- }, _callee100, null, [[2, 3]]);
6080
+ }, _callee101, null, [[2, 3]]);
6037
6081
  }));
6038
- return function (_x89) {
6039
- return _ref122.apply(this, arguments);
6082
+ return function (_x90) {
6083
+ return _ref123.apply(this, arguments);
6040
6084
  };
6041
6085
  }(), [pushPage, masterConfig, client, session, user]);
6086
+ var handleVerifyAppProofs = useCallback(/*#__PURE__*/function () {
6087
+ var _ref125 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102(params) {
6088
+ var _ref126, appProofs, _ref126$successPageDu, successPageDuration, stampWith, s, organizationId, _t31;
6089
+ return _regenerator().w(function (_context102) {
6090
+ while (1) switch (_context102.p = _context102.n) {
6091
+ case 0:
6092
+ _ref126 = params || {}, appProofs = _ref126.appProofs, _ref126$successPageDu = _ref126.successPageDuration, successPageDuration = _ref126$successPageDu === void 0 ? 3000 : _ref126$successPageDu, stampWith = _ref126.stampWith;
6093
+ _context102.n = 1;
6094
+ return getSession();
6095
+ case 1:
6096
+ s = _context102.v;
6097
+ organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
6098
+ if (organizationId) {
6099
+ _context102.n = 2;
6100
+ break;
6101
+ }
6102
+ throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
6103
+ case 2:
6104
+ _context102.p = 2;
6105
+ return _context102.a(2, new Promise(function (resolve, reject) {
6106
+ pushPage({
6107
+ key: "Verify app proofs",
6108
+ showTurnkeyBranding: false,
6109
+ content: jsx(VerifyPage, _objectSpread2(_objectSpread2({
6110
+ appProofs: appProofs,
6111
+ onSuccess: function onSuccess() {
6112
+ resolve();
6113
+ },
6114
+ onError: function onError(error) {
6115
+ reject(error);
6116
+ },
6117
+ successPageDuration: successPageDuration
6118
+ }, stampWith && {
6119
+ stampWith: stampWith
6120
+ }), organizationId !== undefined && {
6121
+ organizationId: organizationId
6122
+ })),
6123
+ showTitle: false,
6124
+ preventBack: true,
6125
+ onClose: function onClose() {
6126
+ return reject(new TurnkeyError("User canceled the verify app proofs process.", TurnkeyErrorCodes.USER_CANCELED));
6127
+ }
6128
+ });
6129
+ }));
6130
+ case 3:
6131
+ _context102.p = 3;
6132
+ _t31 = _context102.v;
6133
+ if (!(_t31 instanceof TurnkeyError)) {
6134
+ _context102.n = 4;
6135
+ break;
6136
+ }
6137
+ throw _t31;
6138
+ case 4:
6139
+ throw new TurnkeyError("Failed to verify app proofs.", TurnkeyErrorCodes.VERIFY_APP_PROOFS_ERROR, _t31);
6140
+ case 5:
6141
+ return _context102.a(2);
6142
+ }
6143
+ }, _callee102, null, [[2, 3]]);
6144
+ }));
6145
+ return function (_x91) {
6146
+ return _ref125.apply(this, arguments);
6147
+ };
6148
+ }(), [pushPage, client]);
6042
6149
  useEffect(function () {
6043
6150
  if (proxyAuthConfigRef.current) return;
6044
6151
  // Only fetch the proxy auth config once. Use that to build the master config.
6045
6152
  var fetchProxyAuthConfig = /*#__PURE__*/function () {
6046
- var _ref124 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101() {
6153
+ var _ref127 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee103() {
6047
6154
  var proxyAuthConfig;
6048
- return _regenerator().w(function (_context101) {
6049
- while (1) switch (_context101.p = _context101.n) {
6155
+ return _regenerator().w(function (_context103) {
6156
+ while (1) switch (_context103.p = _context103.n) {
6050
6157
  case 0:
6051
- _context101.p = 0;
6158
+ _context103.p = 0;
6052
6159
  if (!config.authProxyConfigId) {
6053
- _context101.n = 2;
6160
+ _context103.n = 2;
6054
6161
  break;
6055
6162
  }
6056
- _context101.n = 1;
6163
+ _context103.n = 1;
6057
6164
  return getAuthProxyConfig(config.authProxyConfigId, config.authProxyUrl);
6058
6165
  case 1:
6059
- proxyAuthConfig = _context101.v;
6166
+ proxyAuthConfig = _context103.v;
6060
6167
  proxyAuthConfigRef.current = proxyAuthConfig;
6061
6168
  case 2:
6062
6169
  setMasterConfig(buildConfig(proxyAuthConfig));
6063
- _context101.n = 4;
6170
+ _context103.n = 4;
6064
6171
  break;
6065
6172
  case 3:
6066
- _context101.p = 3;
6067
- _context101.v;
6173
+ _context103.p = 3;
6174
+ _context103.v;
6068
6175
  setClientState(ClientState.Error);
6069
6176
  case 4:
6070
- return _context101.a(2);
6177
+ return _context103.a(2);
6071
6178
  }
6072
- }, _callee101, null, [[0, 3]]);
6179
+ }, _callee103, null, [[0, 3]]);
6073
6180
  }));
6074
6181
  return function fetchProxyAuthConfig() {
6075
- return _ref124.apply(this, arguments);
6182
+ return _ref127.apply(this, arguments);
6076
6183
  };
6077
6184
  }();
6078
6185
  fetchProxyAuthConfig();
@@ -6104,29 +6211,29 @@ var ClientProvider = function ClientProvider(_ref) {
6104
6211
  useEffect(function () {
6105
6212
  if (!client) return;
6106
6213
  var handleUpdateState = /*#__PURE__*/function () {
6107
- var _ref125 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102() {
6108
- return _regenerator().w(function (_context102) {
6109
- while (1) switch (_context102.n) {
6214
+ var _ref128 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee104() {
6215
+ return _regenerator().w(function (_context104) {
6216
+ while (1) switch (_context104.n) {
6110
6217
  case 0:
6111
6218
  if (!session) {
6112
- _context102.n = 2;
6219
+ _context104.n = 2;
6113
6220
  break;
6114
6221
  }
6115
- _context102.n = 1;
6222
+ _context104.n = 1;
6116
6223
  return debouncedRefreshWallets();
6117
6224
  case 1:
6118
- _context102.n = 3;
6225
+ _context104.n = 3;
6119
6226
  break;
6120
6227
  case 2:
6121
- _context102.n = 3;
6228
+ _context104.n = 3;
6122
6229
  return debouncedFetchWalletProviders();
6123
6230
  case 3:
6124
- return _context102.a(2);
6231
+ return _context104.a(2);
6125
6232
  }
6126
- }, _callee102);
6233
+ }, _callee104);
6127
6234
  }));
6128
6235
  return function handleUpdateState() {
6129
- return _ref125.apply(this, arguments);
6236
+ return _ref128.apply(this, arguments);
6130
6237
  };
6131
6238
  }();
6132
6239
  var cleanup = function cleanup() {};
@@ -6240,6 +6347,7 @@ var ClientProvider = function ClientProvider(_ref) {
6240
6347
  createApiKeyPair: createApiKeyPair,
6241
6348
  getProxyAuthConfig: getProxyAuthConfig,
6242
6349
  fetchBootProofForAppProof: fetchBootProofForAppProof,
6350
+ verifyAppProofs: verifyAppProofs,
6243
6351
  handleLogin: handleLogin,
6244
6352
  handleGoogleOauth: handleGoogleOauth,
6245
6353
  handleXOauth: handleXOauth,
@@ -6263,7 +6371,8 @@ var ClientProvider = function ClientProvider(_ref) {
6263
6371
  handleSignMessage: handleSignMessage,
6264
6372
  handleConnectExternalWallet: handleConnectExternalWallet,
6265
6373
  handleRemoveUserEmail: handleRemoveUserEmail,
6266
- handleRemoveUserPhoneNumber: handleRemoveUserPhoneNumber
6374
+ handleRemoveUserPhoneNumber: handleRemoveUserPhoneNumber,
6375
+ handleVerifyAppProofs: handleVerifyAppProofs
6267
6376
  },
6268
6377
  children: children
6269
6378
  });