@turnkey/react-wallet-kit 1.1.2 → 1.2.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.
@@ -198,7 +198,7 @@ var ClientProvider = function ClientProvider(_ref) {
198
198
  }),
199
199
  showTitle: false,
200
200
  onClose: function onClose() {
201
- reject(new TurnkeyError("User cancelled the Facebook authentication process.", TurnkeyErrorCodes.USER_CANCELED));
201
+ reject(new TurnkeyError("User canceled the Facebook authentication process.", TurnkeyErrorCodes.USER_CANCELED));
202
202
  }
203
203
  });
204
204
  });
@@ -293,7 +293,7 @@ var ClientProvider = function ClientProvider(_ref) {
293
293
  }),
294
294
  showTitle: false,
295
295
  onClose: function onClose() {
296
- reject(new TurnkeyError("User cancelled the Discord authentication process.", TurnkeyErrorCodes.USER_CANCELED));
296
+ reject(new TurnkeyError("User canceled the Discord authentication process.", TurnkeyErrorCodes.USER_CANCELED));
297
297
  }
298
298
  });
299
299
  });
@@ -381,7 +381,7 @@ var ClientProvider = function ClientProvider(_ref) {
381
381
  }),
382
382
  showTitle: false,
383
383
  onClose: function onClose() {
384
- reject(new TurnkeyError("User cancelled the Twitter authentication process.", TurnkeyErrorCodes.USER_CANCELED));
384
+ reject(new TurnkeyError("User canceled the Twitter authentication process.", TurnkeyErrorCodes.USER_CANCELED));
385
385
  }
386
386
  });
387
387
  });
@@ -461,7 +461,7 @@ var ClientProvider = function ClientProvider(_ref) {
461
461
  }),
462
462
  showTitle: false,
463
463
  onClose: function onClose() {
464
- reject(new TurnkeyError("User cancelled the ".concat(providerName, " authentication process."), TurnkeyErrorCodes.USER_CANCELED));
464
+ reject(new TurnkeyError("User canceled the ".concat(providerName, " authentication process."), TurnkeyErrorCodes.USER_CANCELED));
465
465
  }
466
466
  });
467
467
  });
@@ -787,11 +787,11 @@ var ClientProvider = function ClientProvider(_ref) {
787
787
  * @throws {TurnkeyError} If an error occurs while scheduling the session expiration.
788
788
  */
789
789
  function _initializeWalletProviderListeners() {
790
- _initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee105(walletProviders, onUpdateState) {
790
+ _initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee106(walletProviders, onUpdateState) {
791
791
  var _masterConfig$walletC0, _masterConfig$walletC1, _masterConfig$walletC10, _masterConfig$walletC11;
792
792
  var cleanups, nativeOnly, ethProviders, solProviders, wcProviders, wcProvider, attachEthereumListeners, attachSolanaListeners, _wcProvider$provider, _wcProvider$provider$, standardEvents, unsubscribe;
793
- return _regenerator().w(function (_context105) {
794
- while (1) switch (_context105.n) {
793
+ return _regenerator().w(function (_context106) {
794
+ while (1) switch (_context106.n) {
795
795
  case 0:
796
796
  attachSolanaListeners = function _attachSolanaListener(provider, onUpdateState) {
797
797
  var _provider$features;
@@ -799,19 +799,19 @@ var ClientProvider = function ClientProvider(_ref) {
799
799
  var walletEvents = provider === null || provider === void 0 ? void 0 : (_provider$features = provider.features) === null || _provider$features === void 0 ? void 0 : _provider$features["standard:events"];
800
800
  if (walletEvents !== null && walletEvents !== void 0 && walletEvents.on) {
801
801
  var offChange = walletEvents.on("change", /*#__PURE__*/function () {
802
- var _ref126 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee103(_evt) {
803
- return _regenerator().w(function (_context103) {
804
- while (1) switch (_context103.n) {
802
+ var _ref127 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee104(_evt) {
803
+ return _regenerator().w(function (_context104) {
804
+ while (1) switch (_context104.n) {
805
805
  case 0:
806
- _context103.n = 1;
806
+ _context104.n = 1;
807
807
  return onUpdateState();
808
808
  case 1:
809
- return _context103.a(2);
809
+ return _context104.a(2);
810
810
  }
811
- }, _callee103);
811
+ }, _callee104);
812
812
  }));
813
- return function (_x90) {
814
- return _ref126.apply(this, arguments);
813
+ return function (_x91) {
814
+ return _ref127.apply(this, arguments);
815
815
  };
816
816
  }());
817
817
  cleanups.push(offChange);
@@ -825,31 +825,31 @@ var ClientProvider = function ClientProvider(_ref) {
825
825
  attachEthereumListeners = function _attachEthereumListen(provider, onUpdateState) {
826
826
  if (typeof provider.on !== "function") return;
827
827
  var handleChainChanged = /*#__PURE__*/function () {
828
- var _ref124 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101(_chainId) {
829
- return _regenerator().w(function (_context101) {
830
- while (1) switch (_context101.n) {
828
+ var _ref125 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102(_chainId) {
829
+ return _regenerator().w(function (_context102) {
830
+ while (1) switch (_context102.n) {
831
831
  case 0:
832
- return _context101.a(2, onUpdateState());
832
+ return _context102.a(2, onUpdateState());
833
833
  }
834
- }, _callee101);
834
+ }, _callee102);
835
835
  }));
836
- return function handleChainChanged(_x88) {
837
- return _ref124.apply(this, arguments);
836
+ return function handleChainChanged(_x89) {
837
+ return _ref125.apply(this, arguments);
838
838
  };
839
839
  }();
840
840
  var handleAccountsChanged = /*#__PURE__*/function () {
841
- var _ref125 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102(accounts) {
842
- return _regenerator().w(function (_context102) {
843
- while (1) switch (_context102.n) {
841
+ var _ref126 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee103(accounts) {
842
+ return _regenerator().w(function (_context103) {
843
+ while (1) switch (_context103.n) {
844
844
  case 0:
845
845
  if (accounts.length === 0) onUpdateState();
846
846
  case 1:
847
- return _context102.a(2);
847
+ return _context103.a(2);
848
848
  }
849
- }, _callee102);
849
+ }, _callee103);
850
850
  }));
851
- return function handleAccountsChanged(_x89) {
852
- return _ref125.apply(this, arguments);
851
+ return function handleAccountsChanged(_x90) {
852
+ return _ref126.apply(this, arguments);
853
853
  };
854
854
  }();
855
855
  var handleDisconnect = function handleDisconnect() {
@@ -865,10 +865,10 @@ var ClientProvider = function ClientProvider(_ref) {
865
865
  };
866
866
  };
867
867
  if (!(walletProviders.length === 0)) {
868
- _context105.n = 1;
868
+ _context106.n = 1;
869
869
  break;
870
870
  }
871
- return _context105.a(2, function () {});
871
+ return _context106.a(2, function () {});
872
872
  case 1:
873
873
  cleanups = []; // we only want to initialize these listeners for connected walletProviders
874
874
  nativeOnly = function nativeOnly(provider) {
@@ -906,9 +906,9 @@ var ClientProvider = function ClientProvider(_ref) {
906
906
  if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
907
907
  if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
908
908
  unsubscribe = standardEvents.on("change", /*#__PURE__*/function () {
909
- var _ref127 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee104(evt) {
910
- return _regenerator().w(function (_context104) {
911
- while (1) switch (_context104.n) {
909
+ var _ref128 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee105(evt) {
910
+ return _regenerator().w(function (_context105) {
911
+ while (1) switch (_context105.n) {
912
912
  case 0:
913
913
  // if the event is a proposalExpired, we want to re-fetch the providers
914
914
  // to refresh the uri, there is no need to refresh the wallets state
@@ -917,28 +917,28 @@ var ClientProvider = function ClientProvider(_ref) {
917
917
  }
918
918
  // any other event (disconnect, chain switch, accounts changed)
919
919
  // we refresh the wallets state
920
- _context104.n = 1;
920
+ _context105.n = 1;
921
921
  return onUpdateState();
922
922
  case 1:
923
- return _context104.a(2);
923
+ return _context105.a(2);
924
924
  }
925
- }, _callee104);
925
+ }, _callee105);
926
926
  }));
927
- return function (_x91) {
928
- return _ref127.apply(this, arguments);
927
+ return function (_x92) {
928
+ return _ref128.apply(this, arguments);
929
929
  };
930
930
  }());
931
931
  cleanups.push(unsubscribe);
932
932
  }
933
933
  }
934
934
  }
935
- return _context105.a(2, function () {
935
+ return _context106.a(2, function () {
936
936
  cleanups.forEach(function (remove) {
937
937
  return remove();
938
938
  });
939
939
  });
940
940
  }
941
- }, _callee105);
941
+ }, _callee106);
942
942
  }));
943
943
  return _initializeWalletProviderListeners.apply(this, arguments);
944
944
  }
@@ -954,13 +954,13 @@ var ClientProvider = function ClientProvider(_ref) {
954
954
  * @throws {TurnkeyError} If an error occurs while clearing the timers.
955
955
  */
956
956
  function _scheduleSessionExpiration() {
957
- _scheduleSessionExpiration = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee108(params) {
957
+ _scheduleSessionExpiration = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee109(params) {
958
958
  var sessionKey, expiry, warnKey, now, expiryMs, timeUntilExpiry, _beforeExpiry, expireSession, warnAt, _callbacks$onError0, _callbacks$onError1, _t34;
959
- return _regenerator().w(function (_context108) {
960
- while (1) switch (_context108.p = _context108.n) {
959
+ return _regenerator().w(function (_context109) {
960
+ while (1) switch (_context109.p = _context109.n) {
961
961
  case 0:
962
962
  sessionKey = params.sessionKey, expiry = params.expiry;
963
- _context108.p = 1;
963
+ _context109.p = 1;
964
964
  warnKey = "".concat(sessionKey, "-warning"); // Replace any prior timers for this session
965
965
  clearKey(expiryTimeoutsRef.current, sessionKey);
966
966
  clearKey(expiryTimeoutsRef.current, warnKey);
@@ -968,86 +968,86 @@ var ClientProvider = function ClientProvider(_ref) {
968
968
  expiryMs = expiry * 1000;
969
969
  timeUntilExpiry = expiryMs - now;
970
970
  _beforeExpiry = /*#__PURE__*/function () {
971
- var _ref128 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee106() {
971
+ var _ref129 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee107() {
972
972
  var _callbacks$beforeSess, _masterConfig$auth48;
973
973
  var activeSession, session;
974
- return _regenerator().w(function (_context106) {
975
- while (1) switch (_context106.n) {
974
+ return _regenerator().w(function (_context107) {
975
+ while (1) switch (_context107.n) {
976
976
  case 0:
977
- _context106.n = 1;
977
+ _context107.n = 1;
978
978
  return getSession();
979
979
  case 1:
980
- activeSession = _context106.v;
980
+ activeSession = _context107.v;
981
981
  if (!(!activeSession && expiryTimeoutsRef.current[warnKey])) {
982
- _context106.n = 2;
982
+ _context107.n = 2;
983
983
  break;
984
984
  }
985
985
  // Keep nudging until session materializes (short 10s timer is fine)
986
986
  setTimeoutInMap(expiryTimeoutsRef.current, warnKey, _beforeExpiry, 10000);
987
- return _context106.a(2);
987
+ return _context107.a(2);
988
988
  case 2:
989
- _context106.n = 3;
989
+ _context107.n = 3;
990
990
  return getSession({
991
991
  sessionKey: sessionKey
992
992
  });
993
993
  case 3:
994
- session = _context106.v;
994
+ session = _context107.v;
995
995
  if (session) {
996
- _context106.n = 4;
996
+ _context107.n = 4;
997
997
  break;
998
998
  }
999
- return _context106.a(2);
999
+ return _context107.a(2);
1000
1000
  case 4:
1001
1001
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$beforeSess = callbacks.beforeSessionExpiry) === null || _callbacks$beforeSess === void 0 ? void 0 : _callbacks$beforeSess.call(callbacks, {
1002
1002
  sessionKey: sessionKey
1003
1003
  });
1004
1004
  if (!(masterConfig !== null && masterConfig !== void 0 && (_masterConfig$auth48 = masterConfig.auth) !== null && _masterConfig$auth48 !== void 0 && _masterConfig$auth48.autoRefreshSession)) {
1005
- _context106.n = 5;
1005
+ _context107.n = 5;
1006
1006
  break;
1007
1007
  }
1008
- _context106.n = 5;
1008
+ _context107.n = 5;
1009
1009
  return refreshSession({
1010
1010
  expirationSeconds: session.expirationSeconds,
1011
1011
  sessionKey: sessionKey
1012
1012
  });
1013
1013
  case 5:
1014
- return _context106.a(2);
1014
+ return _context107.a(2);
1015
1015
  }
1016
- }, _callee106);
1016
+ }, _callee107);
1017
1017
  }));
1018
1018
  return function beforeExpiry() {
1019
- return _ref128.apply(this, arguments);
1019
+ return _ref129.apply(this, arguments);
1020
1020
  };
1021
1021
  }();
1022
1022
  expireSession = /*#__PURE__*/function () {
1023
- var _ref129 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee107() {
1023
+ var _ref130 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee108() {
1024
1024
  var _callbacks$onSessionE;
1025
1025
  var expiredSession, _t32, _t33;
1026
- return _regenerator().w(function (_context107) {
1027
- while (1) switch (_context107.n) {
1026
+ return _regenerator().w(function (_context108) {
1027
+ while (1) switch (_context108.n) {
1028
1028
  case 0:
1029
- _context107.n = 1;
1029
+ _context108.n = 1;
1030
1030
  return getSession({
1031
1031
  sessionKey: sessionKey
1032
1032
  });
1033
1033
  case 1:
1034
- expiredSession = _context107.v;
1034
+ expiredSession = _context108.v;
1035
1035
  if (expiredSession) {
1036
- _context107.n = 2;
1036
+ _context108.n = 2;
1037
1037
  break;
1038
1038
  }
1039
- return _context107.a(2);
1039
+ return _context108.a(2);
1040
1040
  case 2:
1041
1041
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onSessionE = callbacks.onSessionExpired) === null || _callbacks$onSessionE === void 0 ? void 0 : _callbacks$onSessionE.call(callbacks, {
1042
1042
  sessionKey: sessionKey
1043
1043
  });
1044
- _context107.n = 3;
1044
+ _context108.n = 3;
1045
1045
  return getActiveSessionKey();
1046
1046
  case 3:
1047
- _t32 = _context107.v;
1047
+ _t32 = _context108.v;
1048
1048
  _t33 = sessionKey;
1049
1049
  if (!(_t32 === _t33)) {
1050
- _context107.n = 4;
1050
+ _context108.n = 4;
1051
1051
  break;
1052
1052
  }
1053
1053
  setSession(undefined);
@@ -1058,7 +1058,7 @@ var ClientProvider = function ClientProvider(_ref) {
1058
1058
  delete next[sessionKey];
1059
1059
  return next;
1060
1060
  });
1061
- _context107.n = 5;
1061
+ _context108.n = 5;
1062
1062
  return clearSession({
1063
1063
  sessionKey: sessionKey
1064
1064
  });
@@ -1066,25 +1066,25 @@ var ClientProvider = function ClientProvider(_ref) {
1066
1066
  // Remove timers for this session
1067
1067
  clearKey(expiryTimeoutsRef.current, sessionKey);
1068
1068
  clearKey(expiryTimeoutsRef.current, warnKey);
1069
- _context107.n = 6;
1069
+ _context108.n = 6;
1070
1070
  return logout();
1071
1071
  case 6:
1072
- return _context107.a(2);
1072
+ return _context108.a(2);
1073
1073
  }
1074
- }, _callee107);
1074
+ }, _callee108);
1075
1075
  }));
1076
1076
  return function expireSession() {
1077
- return _ref129.apply(this, arguments);
1077
+ return _ref130.apply(this, arguments);
1078
1078
  };
1079
1079
  }(); // Already expired → expire immediately
1080
1080
  if (!(timeUntilExpiry <= 0)) {
1081
- _context108.n = 3;
1081
+ _context109.n = 3;
1082
1082
  break;
1083
1083
  }
1084
- _context108.n = 2;
1084
+ _context109.n = 2;
1085
1085
  return expireSession();
1086
1086
  case 2:
1087
- return _context108.a(2);
1087
+ return _context109.a(2);
1088
1088
  case 3:
1089
1089
  // Warning timer (if threshold is in the future)
1090
1090
  warnAt = expiryMs - SESSION_WARNING_THRESHOLD_MS;
@@ -1095,20 +1095,20 @@ var ClientProvider = function ClientProvider(_ref) {
1095
1095
  }
1096
1096
  // Actual expiry timer (safe for long delays)
1097
1097
  setCappedTimeoutInMap(expiryTimeoutsRef.current, sessionKey, expireSession, timeUntilExpiry);
1098
- _context108.n = 5;
1098
+ _context109.n = 5;
1099
1099
  break;
1100
1100
  case 4:
1101
- _context108.p = 4;
1102
- _t34 = _context108.v;
1101
+ _context109.p = 4;
1102
+ _t34 = _context109.v;
1103
1103
  if (_t34 instanceof TurnkeyError || _t34 instanceof TurnkeyNetworkError) {
1104
1104
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError0 = callbacks.onError) === null || _callbacks$onError0 === void 0 ? void 0 : _callbacks$onError0.call(callbacks, _t34);
1105
1105
  } else {
1106
1106
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError1 = callbacks.onError) === null || _callbacks$onError1 === void 0 ? void 0 : _callbacks$onError1.call(callbacks, new TurnkeyError("Failed to schedule session expiration for ".concat(sessionKey), TurnkeyErrorCodes.SCHEDULE_SESSION_EXPIRY_ERROR, _t34));
1107
1107
  }
1108
1108
  case 5:
1109
- return _context108.a(2);
1109
+ return _context109.a(2);
1110
1110
  }
1111
- }, _callee108, null, [[1, 4]]);
1111
+ }, _callee109, null, [[1, 4]]);
1112
1112
  }));
1113
1113
  return _scheduleSessionExpiration.apply(this, arguments);
1114
1114
  }
@@ -2177,7 +2177,7 @@ var ClientProvider = function ClientProvider(_ref) {
2177
2177
  organizationId: params.organizationId
2178
2178
  })),
2179
2179
  onClose: function onClose() {
2180
- return reject(new TurnkeyError("User cancelled the signing process.", TurnkeyErrorCodes.USER_CANCELED));
2180
+ return reject(new TurnkeyError("User canceled the signing process.", TurnkeyErrorCodes.USER_CANCELED));
2181
2181
  }
2182
2182
  });
2183
2183
  }));
@@ -3401,34 +3401,57 @@ var ClientProvider = function ClientProvider(_ref) {
3401
3401
  return _ref67.apply(this, arguments);
3402
3402
  };
3403
3403
  }(), [client, callbacks, fetchUser, masterConfig, session, user]);
3404
- var refreshWallets = useCallback(/*#__PURE__*/function () {
3404
+ var fetchBootProofForAppProof = useCallback(/*#__PURE__*/function () {
3405
3405
  var _ref69 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee69(params) {
3406
- var _ref70, stampWith, organizationId, userId, walletProviders, wallets;
3407
3406
  return _regenerator().w(function (_context69) {
3408
3407
  while (1) switch (_context69.n) {
3409
3408
  case 0:
3410
- if (masterConfig !== null && masterConfig !== void 0 && masterConfig.autoRefreshManagedState) {
3409
+ if (client) {
3411
3410
  _context69.n = 1;
3412
3411
  break;
3413
3412
  }
3414
- return _context69.a(2, []);
3413
+ throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3414
+ case 1:
3415
+ return _context69.a(2, withTurnkeyErrorHandling(function () {
3416
+ return client.fetchBootProofForAppProof(params);
3417
+ }, function () {
3418
+ return logout();
3419
+ }, callbacks, "Failed to fetch or create delegated access user"));
3420
+ }
3421
+ }, _callee69);
3422
+ }));
3423
+ return function (_x57) {
3424
+ return _ref69.apply(this, arguments);
3425
+ };
3426
+ }(), [client, callbacks]);
3427
+ var refreshWallets = useCallback(/*#__PURE__*/function () {
3428
+ var _ref70 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee70(params) {
3429
+ var _ref71, stampWith, organizationId, userId, walletProviders, wallets;
3430
+ return _regenerator().w(function (_context70) {
3431
+ while (1) switch (_context70.n) {
3432
+ case 0:
3433
+ if (masterConfig !== null && masterConfig !== void 0 && masterConfig.autoRefreshManagedState) {
3434
+ _context70.n = 1;
3435
+ break;
3436
+ }
3437
+ return _context70.a(2, []);
3415
3438
  case 1:
3416
- _ref70 = params || {}, stampWith = _ref70.stampWith, organizationId = _ref70.organizationId, userId = _ref70.userId;
3439
+ _ref71 = params || {}, stampWith = _ref71.stampWith, organizationId = _ref71.organizationId, userId = _ref71.userId;
3417
3440
  if (client) {
3418
- _context69.n = 2;
3441
+ _context70.n = 2;
3419
3442
  break;
3420
3443
  }
3421
3444
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3422
3445
  case 2:
3423
- _context69.n = 3;
3446
+ _context70.n = 3;
3424
3447
  return withTurnkeyErrorHandling(function () {
3425
3448
  return fetchWalletProviders();
3426
3449
  }, function () {
3427
3450
  return logout();
3428
3451
  }, callbacks, "Failed to refresh wallets");
3429
3452
  case 3:
3430
- walletProviders = _context69.v;
3431
- _context69.n = 4;
3453
+ walletProviders = _context70.v;
3454
+ _context70.n = 4;
3432
3455
  return withTurnkeyErrorHandling(function () {
3433
3456
  return fetchWallets(_objectSpread2(_objectSpread2({
3434
3457
  stampWith: stampWith,
@@ -3442,62 +3465,62 @@ var ClientProvider = function ClientProvider(_ref) {
3442
3465
  return logout();
3443
3466
  }, callbacks, "Failed to refresh wallets");
3444
3467
  case 4:
3445
- wallets = _context69.v;
3468
+ wallets = _context70.v;
3446
3469
  if (wallets) {
3447
3470
  setWallets(wallets);
3448
3471
  }
3449
- return _context69.a(2, wallets);
3472
+ return _context70.a(2, wallets);
3450
3473
  }
3451
- }, _callee69);
3474
+ }, _callee70);
3452
3475
  }));
3453
- return function (_x57) {
3454
- return _ref69.apply(this, arguments);
3476
+ return function (_x58) {
3477
+ return _ref70.apply(this, arguments);
3455
3478
  };
3456
3479
  }(), [client, callbacks, fetchWalletProviders, fetchWallets, masterConfig, session, user]);
3457
3480
  var handleDiscordOauth = useCallback(/*#__PURE__*/function () {
3458
- var _ref71 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee70(params) {
3481
+ var _ref72 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee71(params) {
3459
3482
  var _masterConfig$auth18, _masterConfig$auth18$, _masterConfig$auth$oa2, _masterConfig$auth19, _masterConfig$auth19$;
3460
- var _ref72, _ref72$clientId, clientId, _ref72$openInPage, openInPage, additionalParameters, _masterConfig$auth20, _masterConfig$auth20$, _masterConfig$auth21, flow, redirectURI, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, discordAuthUrl, extra, width, height, left, top, authWindow, _t1;
3461
- return _regenerator().w(function (_context70) {
3462
- while (1) switch (_context70.p = _context70.n) {
3483
+ var _ref73, _ref73$clientId, clientId, _ref73$openInPage, openInPage, additionalParameters, _masterConfig$auth20, _masterConfig$auth20$, _masterConfig$auth21, flow, redirectURI, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, discordAuthUrl, extra, width, height, left, top, authWindow, _t1;
3484
+ return _regenerator().w(function (_context71) {
3485
+ while (1) switch (_context71.p = _context71.n) {
3463
3486
  case 0:
3464
- _ref72 = params || {}, _ref72$clientId = _ref72.clientId, clientId = _ref72$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth18 = masterConfig.auth) === null || _masterConfig$auth18 === void 0 ? void 0 : (_masterConfig$auth18$ = _masterConfig$auth18.oauthConfig) === null || _masterConfig$auth18$ === void 0 ? void 0 : _masterConfig$auth18$.discordClientId : _ref72$clientId, _ref72$openInPage = _ref72.openInPage, openInPage = _ref72$openInPage === void 0 ? (_masterConfig$auth$oa2 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth19 = masterConfig.auth) === null || _masterConfig$auth19 === void 0 ? void 0 : (_masterConfig$auth19$ = _masterConfig$auth19.oauthConfig) === null || _masterConfig$auth19$ === void 0 ? void 0 : _masterConfig$auth19$.openOauthInPage) !== null && _masterConfig$auth$oa2 !== void 0 ? _masterConfig$auth$oa2 : false : _ref72$openInPage, additionalParameters = _ref72.additionalState;
3465
- _context70.p = 1;
3487
+ _ref73 = params || {}, _ref73$clientId = _ref73.clientId, clientId = _ref73$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth18 = masterConfig.auth) === null || _masterConfig$auth18 === void 0 ? void 0 : (_masterConfig$auth18$ = _masterConfig$auth18.oauthConfig) === null || _masterConfig$auth18$ === void 0 ? void 0 : _masterConfig$auth18$.discordClientId : _ref73$clientId, _ref73$openInPage = _ref73.openInPage, openInPage = _ref73$openInPage === void 0 ? (_masterConfig$auth$oa2 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth19 = masterConfig.auth) === null || _masterConfig$auth19 === void 0 ? void 0 : (_masterConfig$auth19$ = _masterConfig$auth19.oauthConfig) === null || _masterConfig$auth19$ === void 0 ? void 0 : _masterConfig$auth19$.openOauthInPage) !== null && _masterConfig$auth$oa2 !== void 0 ? _masterConfig$auth$oa2 : false : _ref73$openInPage, additionalParameters = _ref73.additionalState;
3488
+ _context71.p = 1;
3466
3489
  if (masterConfig) {
3467
- _context70.n = 2;
3490
+ _context71.n = 2;
3468
3491
  break;
3469
3492
  }
3470
3493
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3471
3494
  case 2:
3472
3495
  if (clientId) {
3473
- _context70.n = 3;
3496
+ _context71.n = 3;
3474
3497
  break;
3475
3498
  }
3476
3499
  throw new TurnkeyError("Discord Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3477
3500
  case 3:
3478
3501
  if ((_masterConfig$auth20 = masterConfig.auth) !== null && _masterConfig$auth20 !== void 0 && (_masterConfig$auth20$ = _masterConfig$auth20.oauthConfig) !== null && _masterConfig$auth20$ !== void 0 && _masterConfig$auth20$.oauthRedirectUri) {
3479
- _context70.n = 4;
3502
+ _context71.n = 4;
3480
3503
  break;
3481
3504
  }
3482
3505
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3483
3506
  case 4:
3484
3507
  flow = openInPage ? "redirect" : "popup";
3485
3508
  redirectURI = (_masterConfig$auth21 = masterConfig.auth) === null || _masterConfig$auth21 === void 0 ? void 0 : _masterConfig$auth21.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3486
- _context70.n = 5;
3509
+ _context71.n = 5;
3487
3510
  return createApiKeyPair();
3488
3511
  case 5:
3489
- publicKey = _context70.v;
3512
+ publicKey = _context71.v;
3490
3513
  if (publicKey) {
3491
- _context70.n = 6;
3514
+ _context71.n = 6;
3492
3515
  break;
3493
3516
  }
3494
3517
  throw new Error("Failed to create public key for OAuth.");
3495
3518
  case 6:
3496
3519
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
3497
- _context70.n = 7;
3520
+ _context71.n = 7;
3498
3521
  return generateChallengePair();
3499
3522
  case 7:
3500
- _yield$generateChalle = _context70.v;
3523
+ _yield$generateChalle = _context71.v;
3501
3524
  verifier = _yield$generateChalle.verifier;
3502
3525
  codeChallenge = _yield$generateChalle.codeChallenge;
3503
3526
  sessionStorage.setItem("discord_verifier", verifier);
@@ -3511,10 +3534,10 @@ var ClientProvider = function ClientProvider(_ref) {
3511
3534
  discordAuthUrl.searchParams.set("scope", "identify email");
3512
3535
  discordAuthUrl.searchParams.set("state", "provider=discord&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey), "&nonce=").concat(nonce));
3513
3536
  if (additionalParameters) {
3514
- extra = Object.entries(additionalParameters).map(function (_ref73) {
3515
- var _ref74 = _slicedToArray(_ref73, 2),
3516
- k = _ref74[0],
3517
- v = _ref74[1];
3537
+ extra = Object.entries(additionalParameters).map(function (_ref74) {
3538
+ var _ref75 = _slicedToArray(_ref74, 2),
3539
+ k = _ref75[0],
3540
+ v = _ref75[1];
3518
3541
  return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(v));
3519
3542
  }).join("&");
3520
3543
  if (extra) {
@@ -3522,11 +3545,11 @@ var ClientProvider = function ClientProvider(_ref) {
3522
3545
  }
3523
3546
  }
3524
3547
  if (!openInPage) {
3525
- _context70.n = 8;
3548
+ _context71.n = 8;
3526
3549
  break;
3527
3550
  }
3528
3551
  window.location.href = discordAuthUrl.toString();
3529
- return _context70.a(2, new Promise(function (_, reject) {
3552
+ return _context71.a(2, new Promise(function (_, reject) {
3530
3553
  var timeout = setTimeout(function () {
3531
3554
  reject(new Error("Authentication timed out."));
3532
3555
  }, 300000);
@@ -3541,13 +3564,13 @@ var ClientProvider = function ClientProvider(_ref) {
3541
3564
  top = window.screenY + (window.innerHeight - height) / 2;
3542
3565
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3543
3566
  if (authWindow) {
3544
- _context70.n = 9;
3567
+ _context71.n = 9;
3545
3568
  break;
3546
3569
  }
3547
3570
  throw new Error("Failed to open Discord login window.");
3548
3571
  case 9:
3549
3572
  authWindow.location.href = discordAuthUrl.toString();
3550
- return _context70.a(2, new Promise(function (resolve, reject) {
3573
+ return _context71.a(2, new Promise(function (resolve, reject) {
3551
3574
  var interval = setInterval(function () {
3552
3575
  try {
3553
3576
  if (authWindow.closed) {
@@ -3621,65 +3644,65 @@ var ClientProvider = function ClientProvider(_ref) {
3621
3644
  }
3622
3645
  }));
3623
3646
  case 10:
3624
- _context70.n = 12;
3647
+ _context71.n = 12;
3625
3648
  break;
3626
3649
  case 11:
3627
- _context70.p = 11;
3628
- _t1 = _context70.v;
3650
+ _context71.p = 11;
3651
+ _t1 = _context71.v;
3629
3652
  throw _t1;
3630
3653
  case 12:
3631
- return _context70.a(2);
3654
+ return _context71.a(2);
3632
3655
  }
3633
- }, _callee70, null, [[1, 11]]);
3656
+ }, _callee71, null, [[1, 11]]);
3634
3657
  }));
3635
- return function (_x58) {
3636
- return _ref71.apply(this, arguments);
3658
+ return function (_x59) {
3659
+ return _ref72.apply(this, arguments);
3637
3660
  };
3638
3661
  }(), [client, callbacks, completeOauth, createApiKeyPair, masterConfig, session, user]);
3639
3662
  var handleXOauth = useCallback(/*#__PURE__*/function () {
3640
- var _ref75 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee71(params) {
3663
+ var _ref76 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee72(params) {
3641
3664
  var _masterConfig$auth22, _masterConfig$auth22$, _masterConfig$auth$oa3, _masterConfig$auth23, _masterConfig$auth23$;
3642
- var _ref76, _ref76$clientId, clientId, _ref76$openInPage, openInPage, additionalParameters, _masterConfig$auth24, _masterConfig$auth24$, _masterConfig$auth25, flow, redirectURI, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, twitterAuthUrl, extra, width, height, left, top, authWindow, _t10;
3643
- return _regenerator().w(function (_context71) {
3644
- while (1) switch (_context71.p = _context71.n) {
3665
+ var _ref77, _ref77$clientId, clientId, _ref77$openInPage, openInPage, additionalParameters, _masterConfig$auth24, _masterConfig$auth24$, _masterConfig$auth25, flow, redirectURI, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, twitterAuthUrl, extra, width, height, left, top, authWindow, _t10;
3666
+ return _regenerator().w(function (_context72) {
3667
+ while (1) switch (_context72.p = _context72.n) {
3645
3668
  case 0:
3646
- _ref76 = params || {}, _ref76$clientId = _ref76.clientId, clientId = _ref76$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth22 = masterConfig.auth) === null || _masterConfig$auth22 === void 0 ? void 0 : (_masterConfig$auth22$ = _masterConfig$auth22.oauthConfig) === null || _masterConfig$auth22$ === void 0 ? void 0 : _masterConfig$auth22$.xClientId : _ref76$clientId, _ref76$openInPage = _ref76.openInPage, openInPage = _ref76$openInPage === void 0 ? (_masterConfig$auth$oa3 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth23 = masterConfig.auth) === null || _masterConfig$auth23 === void 0 ? void 0 : (_masterConfig$auth23$ = _masterConfig$auth23.oauthConfig) === null || _masterConfig$auth23$ === void 0 ? void 0 : _masterConfig$auth23$.openOauthInPage) !== null && _masterConfig$auth$oa3 !== void 0 ? _masterConfig$auth$oa3 : false : _ref76$openInPage, additionalParameters = _ref76.additionalState;
3647
- _context71.p = 1;
3669
+ _ref77 = params || {}, _ref77$clientId = _ref77.clientId, clientId = _ref77$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth22 = masterConfig.auth) === null || _masterConfig$auth22 === void 0 ? void 0 : (_masterConfig$auth22$ = _masterConfig$auth22.oauthConfig) === null || _masterConfig$auth22$ === void 0 ? void 0 : _masterConfig$auth22$.xClientId : _ref77$clientId, _ref77$openInPage = _ref77.openInPage, openInPage = _ref77$openInPage === void 0 ? (_masterConfig$auth$oa3 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth23 = masterConfig.auth) === null || _masterConfig$auth23 === void 0 ? void 0 : (_masterConfig$auth23$ = _masterConfig$auth23.oauthConfig) === null || _masterConfig$auth23$ === void 0 ? void 0 : _masterConfig$auth23$.openOauthInPage) !== null && _masterConfig$auth$oa3 !== void 0 ? _masterConfig$auth$oa3 : false : _ref77$openInPage, additionalParameters = _ref77.additionalState;
3670
+ _context72.p = 1;
3648
3671
  if (masterConfig) {
3649
- _context71.n = 2;
3672
+ _context72.n = 2;
3650
3673
  break;
3651
3674
  }
3652
3675
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3653
3676
  case 2:
3654
3677
  if (clientId) {
3655
- _context71.n = 3;
3678
+ _context72.n = 3;
3656
3679
  break;
3657
3680
  }
3658
3681
  throw new TurnkeyError("Twitter Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3659
3682
  case 3:
3660
3683
  if ((_masterConfig$auth24 = masterConfig.auth) !== null && _masterConfig$auth24 !== void 0 && (_masterConfig$auth24$ = _masterConfig$auth24.oauthConfig) !== null && _masterConfig$auth24$ !== void 0 && _masterConfig$auth24$.oauthRedirectUri) {
3661
- _context71.n = 4;
3684
+ _context72.n = 4;
3662
3685
  break;
3663
3686
  }
3664
3687
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3665
3688
  case 4:
3666
3689
  flow = openInPage ? "redirect" : "popup";
3667
3690
  redirectURI = (_masterConfig$auth25 = masterConfig.auth) === null || _masterConfig$auth25 === void 0 ? void 0 : _masterConfig$auth25.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3668
- _context71.n = 5;
3691
+ _context72.n = 5;
3669
3692
  return createApiKeyPair();
3670
3693
  case 5:
3671
- publicKey = _context71.v;
3694
+ publicKey = _context72.v;
3672
3695
  if (publicKey) {
3673
- _context71.n = 6;
3696
+ _context72.n = 6;
3674
3697
  break;
3675
3698
  }
3676
3699
  throw new Error("Failed to create public key for OAuth.");
3677
3700
  case 6:
3678
3701
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
3679
- _context71.n = 7;
3702
+ _context72.n = 7;
3680
3703
  return generateChallengePair();
3681
3704
  case 7:
3682
- _yield$generateChalle2 = _context71.v;
3705
+ _yield$generateChalle2 = _context72.v;
3683
3706
  verifier = _yield$generateChalle2.verifier;
3684
3707
  codeChallenge = _yield$generateChalle2.codeChallenge;
3685
3708
  sessionStorage.setItem("twitter_verifier", verifier);
@@ -3693,10 +3716,10 @@ var ClientProvider = function ClientProvider(_ref) {
3693
3716
  twitterAuthUrl.searchParams.set("scope", "tweet.read users.read");
3694
3717
  twitterAuthUrl.searchParams.set("state", "provider=twitter&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey), "&nonce=").concat(nonce));
3695
3718
  if (additionalParameters) {
3696
- extra = Object.entries(additionalParameters).map(function (_ref77) {
3697
- var _ref78 = _slicedToArray(_ref77, 2),
3698
- k = _ref78[0],
3699
- v = _ref78[1];
3719
+ extra = Object.entries(additionalParameters).map(function (_ref78) {
3720
+ var _ref79 = _slicedToArray(_ref78, 2),
3721
+ k = _ref79[0],
3722
+ v = _ref79[1];
3700
3723
  return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(v));
3701
3724
  }).join("&");
3702
3725
  if (extra) {
@@ -3704,11 +3727,11 @@ var ClientProvider = function ClientProvider(_ref) {
3704
3727
  }
3705
3728
  }
3706
3729
  if (!openInPage) {
3707
- _context71.n = 8;
3730
+ _context72.n = 8;
3708
3731
  break;
3709
3732
  }
3710
3733
  window.location.href = twitterAuthUrl.toString();
3711
- return _context71.a(2, new Promise(function (_, reject) {
3734
+ return _context72.a(2, new Promise(function (_, reject) {
3712
3735
  var timeout = setTimeout(function () {
3713
3736
  reject(new Error("Authentication timed out."));
3714
3737
  }, 300000);
@@ -3723,13 +3746,13 @@ var ClientProvider = function ClientProvider(_ref) {
3723
3746
  top = window.screenY + (window.innerHeight - height) / 2;
3724
3747
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3725
3748
  if (authWindow) {
3726
- _context71.n = 9;
3749
+ _context72.n = 9;
3727
3750
  break;
3728
3751
  }
3729
3752
  throw new Error("Failed to open Twitter login window.");
3730
3753
  case 9:
3731
3754
  authWindow.location.href = twitterAuthUrl.toString();
3732
- return _context71.a(2, new Promise(function (resolve, reject) {
3755
+ return _context72.a(2, new Promise(function (resolve, reject) {
3733
3756
  var interval = setInterval(function () {
3734
3757
  try {
3735
3758
  if (authWindow.closed) {
@@ -3803,56 +3826,56 @@ var ClientProvider = function ClientProvider(_ref) {
3803
3826
  }
3804
3827
  }));
3805
3828
  case 10:
3806
- _context71.n = 12;
3829
+ _context72.n = 12;
3807
3830
  break;
3808
3831
  case 11:
3809
- _context71.p = 11;
3810
- _t10 = _context71.v;
3832
+ _context72.p = 11;
3833
+ _t10 = _context72.v;
3811
3834
  throw _t10;
3812
3835
  case 12:
3813
- return _context71.a(2);
3836
+ return _context72.a(2);
3814
3837
  }
3815
- }, _callee71, null, [[1, 11]]);
3838
+ }, _callee72, null, [[1, 11]]);
3816
3839
  }));
3817
- return function (_x59) {
3818
- return _ref75.apply(this, arguments);
3840
+ return function (_x60) {
3841
+ return _ref76.apply(this, arguments);
3819
3842
  };
3820
3843
  }(), [client, callbacks, masterConfig, session, user]);
3821
3844
  var handleGoogleOauth = useCallback(/*#__PURE__*/function () {
3822
- var _ref79 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee72(params) {
3845
+ var _ref80 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee73(params) {
3823
3846
  var _masterConfig$auth26, _masterConfig$auth26$, _masterConfig$auth$oa4, _masterConfig$auth27, _masterConfig$auth27$;
3824
- var _ref80, _ref80$clientId, clientId, _ref80$openInPage, openInPage, additionalParameters, _masterConfig$auth28, _masterConfig$auth28$, _masterConfig$auth29, flow, redirectURI, publicKey, nonce, googleAuthUrl, state, additionalState, width, height, left, top, authWindow, _t11;
3825
- return _regenerator().w(function (_context72) {
3826
- while (1) switch (_context72.p = _context72.n) {
3847
+ var _ref81, _ref81$clientId, clientId, _ref81$openInPage, openInPage, additionalParameters, _masterConfig$auth28, _masterConfig$auth28$, _masterConfig$auth29, flow, redirectURI, publicKey, nonce, googleAuthUrl, state, additionalState, width, height, left, top, authWindow, _t11;
3848
+ return _regenerator().w(function (_context73) {
3849
+ while (1) switch (_context73.p = _context73.n) {
3827
3850
  case 0:
3828
- _ref80 = params || {}, _ref80$clientId = _ref80.clientId, clientId = _ref80$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth26 = masterConfig.auth) === null || _masterConfig$auth26 === void 0 ? void 0 : (_masterConfig$auth26$ = _masterConfig$auth26.oauthConfig) === null || _masterConfig$auth26$ === void 0 ? void 0 : _masterConfig$auth26$.googleClientId : _ref80$clientId, _ref80$openInPage = _ref80.openInPage, openInPage = _ref80$openInPage === void 0 ? (_masterConfig$auth$oa4 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth27 = masterConfig.auth) === null || _masterConfig$auth27 === void 0 ? void 0 : (_masterConfig$auth27$ = _masterConfig$auth27.oauthConfig) === null || _masterConfig$auth27$ === void 0 ? void 0 : _masterConfig$auth27$.openOauthInPage) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : false : _ref80$openInPage, additionalParameters = _ref80.additionalState;
3829
- _context72.p = 1;
3851
+ _ref81 = params || {}, _ref81$clientId = _ref81.clientId, clientId = _ref81$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth26 = masterConfig.auth) === null || _masterConfig$auth26 === void 0 ? void 0 : (_masterConfig$auth26$ = _masterConfig$auth26.oauthConfig) === null || _masterConfig$auth26$ === void 0 ? void 0 : _masterConfig$auth26$.googleClientId : _ref81$clientId, _ref81$openInPage = _ref81.openInPage, openInPage = _ref81$openInPage === void 0 ? (_masterConfig$auth$oa4 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth27 = masterConfig.auth) === null || _masterConfig$auth27 === void 0 ? void 0 : (_masterConfig$auth27$ = _masterConfig$auth27.oauthConfig) === null || _masterConfig$auth27$ === void 0 ? void 0 : _masterConfig$auth27$.openOauthInPage) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : false : _ref81$openInPage, additionalParameters = _ref81.additionalState;
3852
+ _context73.p = 1;
3830
3853
  if (masterConfig) {
3831
- _context72.n = 2;
3854
+ _context73.n = 2;
3832
3855
  break;
3833
3856
  }
3834
3857
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3835
3858
  case 2:
3836
3859
  if (clientId) {
3837
- _context72.n = 3;
3860
+ _context73.n = 3;
3838
3861
  break;
3839
3862
  }
3840
3863
  throw new TurnkeyError("Google Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3841
3864
  case 3:
3842
3865
  if ((_masterConfig$auth28 = masterConfig.auth) !== null && _masterConfig$auth28 !== void 0 && (_masterConfig$auth28$ = _masterConfig$auth28.oauthConfig) !== null && _masterConfig$auth28$ !== void 0 && _masterConfig$auth28$.oauthRedirectUri) {
3843
- _context72.n = 4;
3866
+ _context73.n = 4;
3844
3867
  break;
3845
3868
  }
3846
3869
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3847
3870
  case 4:
3848
3871
  flow = openInPage ? "redirect" : "popup";
3849
3872
  redirectURI = (_masterConfig$auth29 = masterConfig.auth) === null || _masterConfig$auth29 === void 0 ? void 0 : _masterConfig$auth29.oauthConfig.oauthRedirectUri.replace(/\/$/, ""); // Create key pair and generate nonce
3850
- _context72.n = 5;
3873
+ _context73.n = 5;
3851
3874
  return createApiKeyPair();
3852
3875
  case 5:
3853
- publicKey = _context72.v;
3876
+ publicKey = _context73.v;
3854
3877
  if (publicKey) {
3855
- _context72.n = 6;
3878
+ _context73.n = 6;
3856
3879
  break;
3857
3880
  }
3858
3881
  throw new Error("Failed to create public key for OAuth.");
@@ -3868,10 +3891,10 @@ var ClientProvider = function ClientProvider(_ref) {
3868
3891
  // Create state parameter
3869
3892
  state = "provider=google&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
3870
3893
  if (additionalParameters) {
3871
- additionalState = Object.entries(additionalParameters).map(function (_ref81) {
3872
- var _ref82 = _slicedToArray(_ref81, 2),
3873
- key = _ref82[0],
3874
- value = _ref82[1];
3894
+ additionalState = Object.entries(additionalParameters).map(function (_ref82) {
3895
+ var _ref83 = _slicedToArray(_ref82, 2),
3896
+ key = _ref83[0],
3897
+ value = _ref83[1];
3875
3898
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
3876
3899
  }).join("&");
3877
3900
  if (additionalState) {
@@ -3880,12 +3903,12 @@ var ClientProvider = function ClientProvider(_ref) {
3880
3903
  }
3881
3904
  googleAuthUrl.searchParams.set("state", state);
3882
3905
  if (!openInPage) {
3883
- _context72.n = 7;
3906
+ _context73.n = 7;
3884
3907
  break;
3885
3908
  }
3886
3909
  // Redirect current page to Google Auth
3887
3910
  window.location.href = googleAuthUrl.toString();
3888
- return _context72.a(2, new Promise(function (_, reject) {
3911
+ return _context73.a(2, new Promise(function (_, reject) {
3889
3912
  // By here, the page should have already redirected. We wait here since the function is async.
3890
3913
  // We want any function that runs this to simply wait until the page redirects.
3891
3914
  // A 5 min timeout is set just in case, idk
@@ -3905,7 +3928,7 @@ var ClientProvider = function ClientProvider(_ref) {
3905
3928
  top = window.screenY + (window.innerHeight - height) / 2;
3906
3929
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
3907
3930
  if (authWindow) {
3908
- _context72.n = 8;
3931
+ _context73.n = 8;
3909
3932
  break;
3910
3933
  }
3911
3934
  throw new Error("Failed to open Google login window.");
@@ -3913,7 +3936,7 @@ var ClientProvider = function ClientProvider(_ref) {
3913
3936
  authWindow.location.href = googleAuthUrl.toString();
3914
3937
  // Return a promise that resolves when the OAuth flow completes
3915
3938
  // This following code will only run for the popup flow
3916
- return _context72.a(2, new Promise(function (resolve, reject) {
3939
+ return _context73.a(2, new Promise(function (resolve, reject) {
3917
3940
  var interval = setInterval(function () {
3918
3941
  try {
3919
3942
  // Check if window was closed without completing auth
@@ -3972,44 +3995,44 @@ var ClientProvider = function ClientProvider(_ref) {
3972
3995
  }
3973
3996
  }));
3974
3997
  case 9:
3975
- _context72.n = 11;
3998
+ _context73.n = 11;
3976
3999
  break;
3977
4000
  case 10:
3978
- _context72.p = 10;
3979
- _t11 = _context72.v;
4001
+ _context73.p = 10;
4002
+ _t11 = _context73.v;
3980
4003
  throw _t11;
3981
4004
  case 11:
3982
- return _context72.a(2);
4005
+ return _context73.a(2);
3983
4006
  }
3984
- }, _callee72, null, [[1, 10]]);
4007
+ }, _callee73, null, [[1, 10]]);
3985
4008
  }));
3986
- return function (_x60) {
3987
- return _ref79.apply(this, arguments);
4009
+ return function (_x61) {
4010
+ return _ref80.apply(this, arguments);
3988
4011
  };
3989
4012
  }(), [client, callbacks, masterConfig, session, user]);
3990
4013
  var handleAppleOauth = useCallback(/*#__PURE__*/function () {
3991
- var _ref83 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee73(params) {
4014
+ var _ref84 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee74(params) {
3992
4015
  var _masterConfig$auth30, _masterConfig$auth30$, _masterConfig$auth$oa5, _masterConfig$auth31, _masterConfig$auth31$;
3993
- var _ref84, _ref84$clientId, clientId, _ref84$openInPage, openInPage, additionalParameters, _masterConfig$auth32, _masterConfig$auth32$, _masterConfig$auth33, flow, redirectURI, publicKey, nonce, appleAuthUrl, state, additionalState, width, height, left, top, authWindow, _t12;
3994
- return _regenerator().w(function (_context73) {
3995
- while (1) switch (_context73.p = _context73.n) {
4016
+ var _ref85, _ref85$clientId, clientId, _ref85$openInPage, openInPage, additionalParameters, _masterConfig$auth32, _masterConfig$auth32$, _masterConfig$auth33, flow, redirectURI, publicKey, nonce, appleAuthUrl, state, additionalState, width, height, left, top, authWindow, _t12;
4017
+ return _regenerator().w(function (_context74) {
4018
+ while (1) switch (_context74.p = _context74.n) {
3996
4019
  case 0:
3997
- _ref84 = params || {}, _ref84$clientId = _ref84.clientId, clientId = _ref84$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth30 = masterConfig.auth) === null || _masterConfig$auth30 === void 0 ? void 0 : (_masterConfig$auth30$ = _masterConfig$auth30.oauthConfig) === null || _masterConfig$auth30$ === void 0 ? void 0 : _masterConfig$auth30$.appleClientId : _ref84$clientId, _ref84$openInPage = _ref84.openInPage, openInPage = _ref84$openInPage === void 0 ? (_masterConfig$auth$oa5 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth31 = masterConfig.auth) === null || _masterConfig$auth31 === void 0 ? void 0 : (_masterConfig$auth31$ = _masterConfig$auth31.oauthConfig) === null || _masterConfig$auth31$ === void 0 ? void 0 : _masterConfig$auth31$.openOauthInPage) !== null && _masterConfig$auth$oa5 !== void 0 ? _masterConfig$auth$oa5 : false : _ref84$openInPage, additionalParameters = _ref84.additionalState;
3998
- _context73.p = 1;
4020
+ _ref85 = params || {}, _ref85$clientId = _ref85.clientId, clientId = _ref85$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth30 = masterConfig.auth) === null || _masterConfig$auth30 === void 0 ? void 0 : (_masterConfig$auth30$ = _masterConfig$auth30.oauthConfig) === null || _masterConfig$auth30$ === void 0 ? void 0 : _masterConfig$auth30$.appleClientId : _ref85$clientId, _ref85$openInPage = _ref85.openInPage, openInPage = _ref85$openInPage === void 0 ? (_masterConfig$auth$oa5 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth31 = masterConfig.auth) === null || _masterConfig$auth31 === void 0 ? void 0 : (_masterConfig$auth31$ = _masterConfig$auth31.oauthConfig) === null || _masterConfig$auth31$ === void 0 ? void 0 : _masterConfig$auth31$.openOauthInPage) !== null && _masterConfig$auth$oa5 !== void 0 ? _masterConfig$auth$oa5 : false : _ref85$openInPage, additionalParameters = _ref85.additionalState;
4021
+ _context74.p = 1;
3999
4022
  if (masterConfig) {
4000
- _context73.n = 2;
4023
+ _context74.n = 2;
4001
4024
  break;
4002
4025
  }
4003
4026
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4004
4027
  case 2:
4005
4028
  if (clientId) {
4006
- _context73.n = 3;
4029
+ _context74.n = 3;
4007
4030
  break;
4008
4031
  }
4009
4032
  throw new TurnkeyError("Apple Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4010
4033
  case 3:
4011
4034
  if ((_masterConfig$auth32 = masterConfig.auth) !== null && _masterConfig$auth32 !== void 0 && (_masterConfig$auth32$ = _masterConfig$auth32.oauthConfig) !== null && _masterConfig$auth32$ !== void 0 && _masterConfig$auth32$.oauthRedirectUri) {
4012
- _context73.n = 4;
4035
+ _context74.n = 4;
4013
4036
  break;
4014
4037
  }
4015
4038
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
@@ -4017,12 +4040,12 @@ var ClientProvider = function ClientProvider(_ref) {
4017
4040
  flow = openInPage ? "redirect" : "popup";
4018
4041
  redirectURI = (_masterConfig$auth33 = masterConfig.auth) === null || _masterConfig$auth33 === void 0 ? void 0 : _masterConfig$auth33.oauthConfig.oauthRedirectUri; // TODO (Amir): Apple needs the '/' at the end. Maybe we should add it if not there?
4019
4042
  // Create key pair and generate nonce
4020
- _context73.n = 5;
4043
+ _context74.n = 5;
4021
4044
  return createApiKeyPair();
4022
4045
  case 5:
4023
- publicKey = _context73.v;
4046
+ publicKey = _context74.v;
4024
4047
  if (publicKey) {
4025
- _context73.n = 6;
4048
+ _context74.n = 6;
4026
4049
  break;
4027
4050
  }
4028
4051
  throw new Error("Failed to create public key for OAuth.");
@@ -4037,10 +4060,10 @@ var ClientProvider = function ClientProvider(_ref) {
4037
4060
  // Create state parameter
4038
4061
  state = "provider=apple&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
4039
4062
  if (additionalParameters) {
4040
- additionalState = Object.entries(additionalParameters).map(function (_ref85) {
4041
- var _ref86 = _slicedToArray(_ref85, 2),
4042
- key = _ref86[0],
4043
- value = _ref86[1];
4063
+ additionalState = Object.entries(additionalParameters).map(function (_ref86) {
4064
+ var _ref87 = _slicedToArray(_ref86, 2),
4065
+ key = _ref87[0],
4066
+ value = _ref87[1];
4044
4067
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
4045
4068
  }).join("&");
4046
4069
  if (additionalState) {
@@ -4049,12 +4072,12 @@ var ClientProvider = function ClientProvider(_ref) {
4049
4072
  }
4050
4073
  appleAuthUrl.searchParams.set("state", state);
4051
4074
  if (!openInPage) {
4052
- _context73.n = 7;
4075
+ _context74.n = 7;
4053
4076
  break;
4054
4077
  }
4055
4078
  // Redirect current page to Apple Auth
4056
4079
  window.location.href = appleAuthUrl.toString();
4057
- return _context73.a(2, new Promise(function (_, reject) {
4080
+ return _context74.a(2, new Promise(function (_, reject) {
4058
4081
  // Set a timeout just in case the redirect doesn't happen
4059
4082
  var timeout = setTimeout(function () {
4060
4083
  reject(new Error("Authentication timed out."));
@@ -4072,14 +4095,14 @@ var ClientProvider = function ClientProvider(_ref) {
4072
4095
  top = window.screenY + (window.innerHeight - height) / 2;
4073
4096
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
4074
4097
  if (authWindow) {
4075
- _context73.n = 8;
4098
+ _context74.n = 8;
4076
4099
  break;
4077
4100
  }
4078
4101
  throw new Error("Failed to open Apple login window.");
4079
4102
  case 8:
4080
4103
  authWindow.location.href = appleAuthUrl.toString();
4081
4104
  // Return a promise that resolves when the OAuth flow completes
4082
- return _context73.a(2, new Promise(function (resolve, reject) {
4105
+ return _context74.a(2, new Promise(function (resolve, reject) {
4083
4106
  var interval = setInterval(function () {
4084
4107
  try {
4085
4108
  // Check if window was closed without completing auth
@@ -4138,65 +4161,65 @@ var ClientProvider = function ClientProvider(_ref) {
4138
4161
  }
4139
4162
  }));
4140
4163
  case 9:
4141
- _context73.n = 11;
4164
+ _context74.n = 11;
4142
4165
  break;
4143
4166
  case 10:
4144
- _context73.p = 10;
4145
- _t12 = _context73.v;
4167
+ _context74.p = 10;
4168
+ _t12 = _context74.v;
4146
4169
  throw _t12;
4147
4170
  case 11:
4148
- return _context73.a(2);
4171
+ return _context74.a(2);
4149
4172
  }
4150
- }, _callee73, null, [[1, 10]]);
4173
+ }, _callee74, null, [[1, 10]]);
4151
4174
  }));
4152
- return function (_x61) {
4153
- return _ref83.apply(this, arguments);
4175
+ return function (_x62) {
4176
+ return _ref84.apply(this, arguments);
4154
4177
  };
4155
4178
  }(), [client, callbacks, masterConfig, session, user]);
4156
4179
  var handleFacebookOauth = useCallback(/*#__PURE__*/function () {
4157
- var _ref87 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee74(params) {
4180
+ var _ref88 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee75(params) {
4158
4181
  var _masterConfig$auth34, _masterConfig$auth34$, _masterConfig$auth$oa6, _masterConfig$auth35, _masterConfig$auth35$;
4159
- var _ref88, _ref88$clientId, clientId, _ref88$openInPage, openInPage, additionalParameters, _masterConfig$auth36, _masterConfig$auth36$, _masterConfig$auth37, flow, redirectURI, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, facebookAuthUrl, state, additionalState, width, height, left, top, authWindow, _t13;
4160
- return _regenerator().w(function (_context74) {
4161
- while (1) switch (_context74.p = _context74.n) {
4182
+ var _ref89, _ref89$clientId, clientId, _ref89$openInPage, openInPage, additionalParameters, _masterConfig$auth36, _masterConfig$auth36$, _masterConfig$auth37, flow, redirectURI, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, facebookAuthUrl, state, additionalState, width, height, left, top, authWindow, _t13;
4183
+ return _regenerator().w(function (_context75) {
4184
+ while (1) switch (_context75.p = _context75.n) {
4162
4185
  case 0:
4163
- _ref88 = params || {}, _ref88$clientId = _ref88.clientId, clientId = _ref88$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth34 = masterConfig.auth) === null || _masterConfig$auth34 === void 0 ? void 0 : (_masterConfig$auth34$ = _masterConfig$auth34.oauthConfig) === null || _masterConfig$auth34$ === void 0 ? void 0 : _masterConfig$auth34$.facebookClientId : _ref88$clientId, _ref88$openInPage = _ref88.openInPage, openInPage = _ref88$openInPage === void 0 ? (_masterConfig$auth$oa6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth35 = masterConfig.auth) === null || _masterConfig$auth35 === void 0 ? void 0 : (_masterConfig$auth35$ = _masterConfig$auth35.oauthConfig) === null || _masterConfig$auth35$ === void 0 ? void 0 : _masterConfig$auth35$.openOauthInPage) !== null && _masterConfig$auth$oa6 !== void 0 ? _masterConfig$auth$oa6 : false : _ref88$openInPage, additionalParameters = _ref88.additionalState;
4164
- _context74.p = 1;
4186
+ _ref89 = params || {}, _ref89$clientId = _ref89.clientId, clientId = _ref89$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth34 = masterConfig.auth) === null || _masterConfig$auth34 === void 0 ? void 0 : (_masterConfig$auth34$ = _masterConfig$auth34.oauthConfig) === null || _masterConfig$auth34$ === void 0 ? void 0 : _masterConfig$auth34$.facebookClientId : _ref89$clientId, _ref89$openInPage = _ref89.openInPage, openInPage = _ref89$openInPage === void 0 ? (_masterConfig$auth$oa6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth35 = masterConfig.auth) === null || _masterConfig$auth35 === void 0 ? void 0 : (_masterConfig$auth35$ = _masterConfig$auth35.oauthConfig) === null || _masterConfig$auth35$ === void 0 ? void 0 : _masterConfig$auth35$.openOauthInPage) !== null && _masterConfig$auth$oa6 !== void 0 ? _masterConfig$auth$oa6 : false : _ref89$openInPage, additionalParameters = _ref89.additionalState;
4187
+ _context75.p = 1;
4165
4188
  if (masterConfig) {
4166
- _context74.n = 2;
4189
+ _context75.n = 2;
4167
4190
  break;
4168
4191
  }
4169
4192
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4170
4193
  case 2:
4171
4194
  if (clientId) {
4172
- _context74.n = 3;
4195
+ _context75.n = 3;
4173
4196
  break;
4174
4197
  }
4175
4198
  throw new TurnkeyError("Facebook Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4176
4199
  case 3:
4177
4200
  if ((_masterConfig$auth36 = masterConfig.auth) !== null && _masterConfig$auth36 !== void 0 && (_masterConfig$auth36$ = _masterConfig$auth36.oauthConfig) !== null && _masterConfig$auth36$ !== void 0 && _masterConfig$auth36$.oauthRedirectUri) {
4178
- _context74.n = 4;
4201
+ _context75.n = 4;
4179
4202
  break;
4180
4203
  }
4181
4204
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4182
4205
  case 4:
4183
4206
  flow = openInPage ? "redirect" : "popup";
4184
4207
  redirectURI = (_masterConfig$auth37 = masterConfig.auth) === null || _masterConfig$auth37 === void 0 ? void 0 : _masterConfig$auth37.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4185
- _context74.n = 5;
4208
+ _context75.n = 5;
4186
4209
  return createApiKeyPair();
4187
4210
  case 5:
4188
- publicKey = _context74.v;
4211
+ publicKey = _context75.v;
4189
4212
  if (publicKey) {
4190
- _context74.n = 6;
4213
+ _context75.n = 6;
4191
4214
  break;
4192
4215
  }
4193
4216
  throw new Error("Failed to create public key for OAuth.");
4194
4217
  case 6:
4195
4218
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
4196
- _context74.n = 7;
4219
+ _context75.n = 7;
4197
4220
  return generateChallengePair();
4198
4221
  case 7:
4199
- _yield$generateChalle3 = _context74.v;
4222
+ _yield$generateChalle3 = _context75.v;
4200
4223
  verifier = _yield$generateChalle3.verifier;
4201
4224
  codeChallenge = _yield$generateChalle3.codeChallenge;
4202
4225
  // Store verifier for later token exchange
@@ -4213,10 +4236,10 @@ var ClientProvider = function ClientProvider(_ref) {
4213
4236
  // Create state parameter
4214
4237
  state = "provider=facebook&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
4215
4238
  if (additionalParameters) {
4216
- additionalState = Object.entries(additionalParameters).map(function (_ref89) {
4217
- var _ref90 = _slicedToArray(_ref89, 2),
4218
- key = _ref90[0],
4219
- value = _ref90[1];
4239
+ additionalState = Object.entries(additionalParameters).map(function (_ref90) {
4240
+ var _ref91 = _slicedToArray(_ref90, 2),
4241
+ key = _ref91[0],
4242
+ value = _ref91[1];
4220
4243
  return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
4221
4244
  }).join("&");
4222
4245
  if (additionalState) {
@@ -4225,12 +4248,12 @@ var ClientProvider = function ClientProvider(_ref) {
4225
4248
  }
4226
4249
  facebookAuthUrl.searchParams.set("state", state);
4227
4250
  if (!openInPage) {
4228
- _context74.n = 8;
4251
+ _context75.n = 8;
4229
4252
  break;
4230
4253
  }
4231
4254
  // Redirect current page to Facebook Auth
4232
4255
  window.location.href = facebookAuthUrl.toString();
4233
- return _context74.a(2, new Promise(function (_, reject) {
4256
+ return _context75.a(2, new Promise(function (_, reject) {
4234
4257
  // Set a timeout just in case the redirect doesn't happen
4235
4258
  var timeout = setTimeout(function () {
4236
4259
  reject(new Error("Authentication timed out."));
@@ -4248,14 +4271,14 @@ var ClientProvider = function ClientProvider(_ref) {
4248
4271
  top = window.screenY + (window.innerHeight - height) / 2;
4249
4272
  authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
4250
4273
  if (authWindow) {
4251
- _context74.n = 9;
4274
+ _context75.n = 9;
4252
4275
  break;
4253
4276
  }
4254
4277
  throw new Error("Failed to open Facebook login window.");
4255
4278
  case 9:
4256
4279
  authWindow.location.href = facebookAuthUrl.toString();
4257
4280
  // Return a promise that resolves when the OAuth flow completes
4258
- return _context74.a(2, new Promise(function (resolve, reject) {
4281
+ return _context75.a(2, new Promise(function (resolve, reject) {
4259
4282
  var interval = setInterval(function () {
4260
4283
  try {
4261
4284
  // Check if window was closed without completing auth
@@ -4323,27 +4346,27 @@ var ClientProvider = function ClientProvider(_ref) {
4323
4346
  }
4324
4347
  }));
4325
4348
  case 10:
4326
- _context74.n = 12;
4349
+ _context75.n = 12;
4327
4350
  break;
4328
4351
  case 11:
4329
- _context74.p = 11;
4330
- _t13 = _context74.v;
4352
+ _context75.p = 11;
4353
+ _t13 = _context75.v;
4331
4354
  throw _t13;
4332
4355
  case 12:
4333
- return _context74.a(2);
4356
+ return _context75.a(2);
4334
4357
  }
4335
- }, _callee74, null, [[1, 11]]);
4358
+ }, _callee75, null, [[1, 11]]);
4336
4359
  }));
4337
- return function (_x62) {
4338
- return _ref87.apply(this, arguments);
4360
+ return function (_x63) {
4361
+ return _ref88.apply(this, arguments);
4339
4362
  };
4340
4363
  }(), [client, callbacks, masterConfig, client, session, user]);
4341
4364
  var handleLogin = useCallback(/*#__PURE__*/function () {
4342
- var _ref91 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee75(params) {
4365
+ var _ref92 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee76(params) {
4343
4366
  var _masterConfig$ui, _params$logoDark, _masterConfig$ui2, _params$logoLight, _masterConfig$ui3, _params$title;
4344
4367
  var logo;
4345
- return _regenerator().w(function (_context75) {
4346
- while (1) switch (_context75.n) {
4368
+ return _regenerator().w(function (_context76) {
4369
+ while (1) switch (_context76.n) {
4347
4370
  case 0:
4348
4371
  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;
4349
4372
  pushPage({
@@ -4357,22 +4380,22 @@ var ClientProvider = function ClientProvider(_ref) {
4357
4380
  showTitle: logo ? false : true
4358
4381
  });
4359
4382
  case 1:
4360
- return _context75.a(2);
4383
+ return _context76.a(2);
4361
4384
  }
4362
- }, _callee75);
4385
+ }, _callee76);
4363
4386
  }));
4364
- return function (_x63) {
4365
- return _ref91.apply(this, arguments);
4387
+ return function (_x64) {
4388
+ return _ref92.apply(this, arguments);
4366
4389
  };
4367
4390
  }(), [pushPage, masterConfig, client, session, user]);
4368
4391
  var handleExportWallet = useCallback(/*#__PURE__*/function () {
4369
- var _ref92 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee76(params) {
4392
+ var _ref93 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee77(params) {
4370
4393
  var walletId, targetPublicKey, stampWith, organizationId;
4371
- return _regenerator().w(function (_context76) {
4372
- while (1) switch (_context76.n) {
4394
+ return _regenerator().w(function (_context77) {
4395
+ while (1) switch (_context77.n) {
4373
4396
  case 0:
4374
4397
  walletId = params.walletId, targetPublicKey = params.targetPublicKey, stampWith = params.stampWith, organizationId = params.organizationId;
4375
- return _context76.a(2, new Promise(function (resolve, reject) {
4398
+ return _context77.a(2, new Promise(function (resolve, reject) {
4376
4399
  return pushPage({
4377
4400
  key: "Export wallet",
4378
4401
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4391,24 +4414,27 @@ var ClientProvider = function ClientProvider(_ref) {
4391
4414
  onError: function onError(error) {
4392
4415
  return reject(error);
4393
4416
  }
4394
- }))
4417
+ })),
4418
+ onClose: function onClose() {
4419
+ return reject(new TurnkeyError("User canceled the export wallet process.", TurnkeyErrorCodes.USER_CANCELED));
4420
+ }
4395
4421
  });
4396
4422
  }));
4397
4423
  }
4398
- }, _callee76);
4424
+ }, _callee77);
4399
4425
  }));
4400
- return function (_x64) {
4401
- return _ref92.apply(this, arguments);
4426
+ return function (_x65) {
4427
+ return _ref93.apply(this, arguments);
4402
4428
  };
4403
4429
  }(), [pushPage, masterConfig, client, session, user]);
4404
4430
  var handleExportPrivateKey = useCallback(/*#__PURE__*/function () {
4405
- var _ref93 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee77(params) {
4431
+ var _ref94 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee78(params) {
4406
4432
  var privateKeyId, targetPublicKey, keyFormat, stampWith, organizationId;
4407
- return _regenerator().w(function (_context77) {
4408
- while (1) switch (_context77.n) {
4433
+ return _regenerator().w(function (_context78) {
4434
+ while (1) switch (_context78.n) {
4409
4435
  case 0:
4410
4436
  privateKeyId = params.privateKeyId, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith, organizationId = params.organizationId;
4411
- return _context77.a(2, new Promise(function (resolve, reject) {
4437
+ return _context78.a(2, new Promise(function (resolve, reject) {
4412
4438
  return pushPage({
4413
4439
  key: "Export private key",
4414
4440
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4429,24 +4455,27 @@ var ClientProvider = function ClientProvider(_ref) {
4429
4455
  onError: function onError(error) {
4430
4456
  return reject(error);
4431
4457
  }
4432
- }))
4458
+ })),
4459
+ onClose: function onClose() {
4460
+ return reject(new TurnkeyError("User canceled the export private key process.", TurnkeyErrorCodes.USER_CANCELED));
4461
+ }
4433
4462
  });
4434
4463
  }));
4435
4464
  }
4436
- }, _callee77);
4465
+ }, _callee78);
4437
4466
  }));
4438
- return function (_x65) {
4439
- return _ref93.apply(this, arguments);
4467
+ return function (_x66) {
4468
+ return _ref94.apply(this, arguments);
4440
4469
  };
4441
4470
  }(), [pushPage, masterConfig, client, session, user]);
4442
4471
  var handleExportWalletAccount = useCallback(/*#__PURE__*/function () {
4443
- var _ref94 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee78(params) {
4472
+ var _ref95 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee79(params) {
4444
4473
  var address, targetPublicKey, keyFormat, stampWith, organizationId;
4445
- return _regenerator().w(function (_context78) {
4446
- while (1) switch (_context78.n) {
4474
+ return _regenerator().w(function (_context79) {
4475
+ while (1) switch (_context79.n) {
4447
4476
  case 0:
4448
4477
  address = params.address, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith, organizationId = params.organizationId;
4449
- return _context78.a(2, new Promise(function (resolve, reject) {
4478
+ return _context79.a(2, new Promise(function (resolve, reject) {
4450
4479
  return pushPage({
4451
4480
  key: "Export wallet account",
4452
4481
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4467,25 +4496,28 @@ var ClientProvider = function ClientProvider(_ref) {
4467
4496
  onError: function onError(error) {
4468
4497
  return reject(error);
4469
4498
  }
4470
- }))
4499
+ })),
4500
+ onClose: function onClose() {
4501
+ return reject(new TurnkeyError("User canceled the export wallet account process.", TurnkeyErrorCodes.USER_CANCELED));
4502
+ }
4471
4503
  });
4472
4504
  }));
4473
4505
  }
4474
- }, _callee78);
4506
+ }, _callee79);
4475
4507
  }));
4476
- return function (_x66) {
4477
- return _ref94.apply(this, arguments);
4508
+ return function (_x67) {
4509
+ return _ref95.apply(this, arguments);
4478
4510
  };
4479
4511
  }(), [pushPage, masterConfig, client, session, user]);
4480
4512
  var handleImportWallet = useCallback(/*#__PURE__*/function () {
4481
- var _ref95 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee79(params) {
4482
- var _ref96, defaultWalletAccounts, _ref96$successPageDur, successPageDuration, stampWith, walletName, organizationId, userId, _t14;
4483
- return _regenerator().w(function (_context79) {
4484
- while (1) switch (_context79.p = _context79.n) {
4513
+ var _ref96 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee80(params) {
4514
+ var _ref97, defaultWalletAccounts, _ref97$successPageDur, successPageDuration, stampWith, walletName, organizationId, userId, _t14;
4515
+ return _regenerator().w(function (_context80) {
4516
+ while (1) switch (_context80.p = _context80.n) {
4485
4517
  case 0:
4486
- _ref96 = params || {}, defaultWalletAccounts = _ref96.defaultWalletAccounts, _ref96$successPageDur = _ref96.successPageDuration, successPageDuration = _ref96$successPageDur === void 0 ? 2000 : _ref96$successPageDur, stampWith = _ref96.stampWith, walletName = _ref96.walletName, organizationId = _ref96.organizationId, userId = _ref96.userId;
4487
- _context79.p = 1;
4488
- return _context79.a(2, withTurnkeyErrorHandling(function () {
4518
+ _ref97 = params || {}, defaultWalletAccounts = _ref97.defaultWalletAccounts, _ref97$successPageDur = _ref97.successPageDuration, successPageDuration = _ref97$successPageDur === void 0 ? 2000 : _ref97$successPageDur, stampWith = _ref97.stampWith, walletName = _ref97.walletName, organizationId = _ref97.organizationId, userId = _ref97.userId;
4519
+ _context80.p = 1;
4520
+ return _context80.a(2, withTurnkeyErrorHandling(function () {
4489
4521
  return new Promise(function (resolve, reject) {
4490
4522
  return pushPage({
4491
4523
  key: "Import wallet",
@@ -4516,33 +4548,33 @@ var ClientProvider = function ClientProvider(_ref) {
4516
4548
  return logout();
4517
4549
  }));
4518
4550
  case 2:
4519
- _context79.p = 2;
4520
- _t14 = _context79.v;
4551
+ _context80.p = 2;
4552
+ _t14 = _context80.v;
4521
4553
  if (!(_t14 instanceof TurnkeyError)) {
4522
- _context79.n = 3;
4554
+ _context80.n = 3;
4523
4555
  break;
4524
4556
  }
4525
4557
  throw _t14;
4526
4558
  case 3:
4527
4559
  throw new TurnkeyError("Failed to import wallet.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t14);
4528
4560
  case 4:
4529
- return _context79.a(2);
4561
+ return _context80.a(2);
4530
4562
  }
4531
- }, _callee79, null, [[1, 2]]);
4563
+ }, _callee80, null, [[1, 2]]);
4532
4564
  }));
4533
- return function (_x67) {
4534
- return _ref95.apply(this, arguments);
4565
+ return function (_x68) {
4566
+ return _ref96.apply(this, arguments);
4535
4567
  };
4536
4568
  }(), [pushPage, masterConfig, client, session, user]);
4537
4569
  var handleImportPrivateKey = useCallback(/*#__PURE__*/function () {
4538
- var _ref97 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee80(params) {
4539
- var _ref98, curve, addressFormats, _ref98$successPageDur, successPageDuration, stampWith, keyName, organizationId, _t15;
4540
- return _regenerator().w(function (_context80) {
4541
- while (1) switch (_context80.p = _context80.n) {
4570
+ var _ref98 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee81(params) {
4571
+ var _ref99, curve, addressFormats, _ref99$successPageDur, successPageDuration, stampWith, keyName, organizationId, _t15;
4572
+ return _regenerator().w(function (_context81) {
4573
+ while (1) switch (_context81.p = _context81.n) {
4542
4574
  case 0:
4543
- _ref98 = params || {}, curve = _ref98.curve, addressFormats = _ref98.addressFormats, _ref98$successPageDur = _ref98.successPageDuration, successPageDuration = _ref98$successPageDur === void 0 ? 2000 : _ref98$successPageDur, stampWith = _ref98.stampWith, keyName = _ref98.keyName, organizationId = _ref98.organizationId;
4544
- _context80.p = 1;
4545
- return _context80.a(2, withTurnkeyErrorHandling(function () {
4575
+ _ref99 = params || {}, curve = _ref99.curve, addressFormats = _ref99.addressFormats, _ref99$successPageDur = _ref99.successPageDuration, successPageDuration = _ref99$successPageDur === void 0 ? 2000 : _ref99$successPageDur, stampWith = _ref99.stampWith, keyName = _ref99.keyName, organizationId = _ref99.organizationId;
4576
+ _context81.p = 1;
4577
+ return _context81.a(2, withTurnkeyErrorHandling(function () {
4546
4578
  return new Promise(function (resolve, reject) {
4547
4579
  return pushPage({
4548
4580
  key: "Import private key",
@@ -4571,51 +4603,51 @@ var ClientProvider = function ClientProvider(_ref) {
4571
4603
  return logout();
4572
4604
  }));
4573
4605
  case 2:
4574
- _context80.p = 2;
4575
- _t15 = _context80.v;
4606
+ _context81.p = 2;
4607
+ _t15 = _context81.v;
4576
4608
  if (!(_t15 instanceof TurnkeyError)) {
4577
- _context80.n = 3;
4609
+ _context81.n = 3;
4578
4610
  break;
4579
4611
  }
4580
4612
  throw _t15;
4581
4613
  case 3:
4582
4614
  throw new TurnkeyError("Failed to import private key.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t15);
4583
4615
  case 4:
4584
- return _context80.a(2);
4616
+ return _context81.a(2);
4585
4617
  }
4586
- }, _callee80, null, [[1, 2]]);
4618
+ }, _callee81, null, [[1, 2]]);
4587
4619
  }));
4588
- return function (_x68) {
4589
- return _ref97.apply(this, arguments);
4620
+ return function (_x69) {
4621
+ return _ref98.apply(this, arguments);
4590
4622
  };
4591
4623
  }(), [pushPage, masterConfig, client, session, user]);
4592
4624
  var handleUpdateUserName = useCallback(/*#__PURE__*/function () {
4593
- var _ref99 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee81(params) {
4594
- var _ref100, _ref100$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, res, _t16;
4595
- return _regenerator().w(function (_context81) {
4596
- while (1) switch (_context81.p = _context81.n) {
4625
+ var _ref100 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee82(params) {
4626
+ var _ref101, _ref101$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, res, _t16;
4627
+ return _regenerator().w(function (_context82) {
4628
+ while (1) switch (_context82.p = _context82.n) {
4597
4629
  case 0:
4598
- _ref100 = params || {}, _ref100$successPageDu = _ref100.successPageDuration, successPageDuration = _ref100$successPageDu === void 0 ? 2000 : _ref100$successPageDu, subTitle = _ref100.subTitle, title = _ref100.title, stampWith = _ref100.stampWith;
4630
+ _ref101 = params || {}, _ref101$successPageDu = _ref101.successPageDuration, successPageDuration = _ref101$successPageDu === void 0 ? 2000 : _ref101$successPageDu, subTitle = _ref101.subTitle, title = _ref101.title, stampWith = _ref101.stampWith;
4599
4631
  if (client) {
4600
- _context81.n = 1;
4632
+ _context82.n = 1;
4601
4633
  break;
4602
4634
  }
4603
4635
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4604
4636
  case 1:
4605
- _context81.n = 2;
4637
+ _context82.n = 2;
4606
4638
  return getSession();
4607
4639
  case 2:
4608
- s = _context81.v;
4640
+ s = _context82.v;
4609
4641
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4610
4642
  if (organizationId) {
4611
- _context81.n = 3;
4643
+ _context82.n = 3;
4612
4644
  break;
4613
4645
  }
4614
4646
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
4615
4647
  case 3:
4616
4648
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (user === null || user === void 0 ? void 0 : user.userId);
4617
4649
  if (userId) {
4618
- _context81.n = 4;
4650
+ _context82.n = 4;
4619
4651
  break;
4620
4652
  }
4621
4653
  throw new TurnkeyError("A user ID is required to update a user name.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -4635,12 +4667,12 @@ var ClientProvider = function ClientProvider(_ref) {
4635
4667
  showTitle: false
4636
4668
  });
4637
4669
  };
4638
- _context81.p = 5;
4670
+ _context82.p = 5;
4639
4671
  if (!(!(params !== null && params !== void 0 && params.userName) && (params === null || params === void 0 ? void 0 : params.userName) !== "")) {
4640
- _context81.n = 6;
4672
+ _context82.n = 6;
4641
4673
  break;
4642
4674
  }
4643
- return _context81.a(2, withTurnkeyErrorHandling(function () {
4675
+ return _context82.a(2, withTurnkeyErrorHandling(function () {
4644
4676
  return new Promise(function (resolve, reject) {
4645
4677
  pushPage({
4646
4678
  key: "Update User Name",
@@ -4668,7 +4700,7 @@ var ClientProvider = function ClientProvider(_ref) {
4668
4700
  return logout();
4669
4701
  }));
4670
4702
  case 6:
4671
- _context81.n = 7;
4703
+ _context82.n = 7;
4672
4704
  return updateUserName(_objectSpread2({
4673
4705
  userName: params.userName,
4674
4706
  userId: user.userId,
@@ -4677,71 +4709,71 @@ var ClientProvider = function ClientProvider(_ref) {
4677
4709
  organizationId: organizationId
4678
4710
  }));
4679
4711
  case 7:
4680
- res = _context81.v;
4712
+ res = _context82.v;
4681
4713
  onSuccess();
4682
- return _context81.a(2, res);
4714
+ return _context82.a(2, res);
4683
4715
  case 8:
4684
- _context81.n = 11;
4716
+ _context82.n = 11;
4685
4717
  break;
4686
4718
  case 9:
4687
- _context81.p = 9;
4688
- _t16 = _context81.v;
4719
+ _context82.p = 9;
4720
+ _t16 = _context82.v;
4689
4721
  if (!(_t16 instanceof TurnkeyError)) {
4690
- _context81.n = 10;
4722
+ _context82.n = 10;
4691
4723
  break;
4692
4724
  }
4693
4725
  throw _t16;
4694
4726
  case 10:
4695
4727
  throw new TurnkeyError("Failed to update user name.", TurnkeyErrorCodes.UPDATE_USER_NAME_ERROR, _t16);
4696
4728
  case 11:
4697
- return _context81.a(2);
4729
+ return _context82.a(2);
4698
4730
  }
4699
- }, _callee81, null, [[5, 9]]);
4731
+ }, _callee82, null, [[5, 9]]);
4700
4732
  }));
4701
- return function (_x69) {
4702
- return _ref99.apply(this, arguments);
4733
+ return function (_x70) {
4734
+ return _ref100.apply(this, arguments);
4703
4735
  };
4704
4736
  }(), [pushPage, masterConfig, client, session, user]);
4705
4737
  var handleUpdateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
4706
- var _ref101 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee83(params) {
4738
+ var _ref102 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee84(params) {
4707
4739
  var _masterConfig$auth38, _masterConfig$auth38$;
4708
- var _ref102, _ref102$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t18;
4709
- return _regenerator().w(function (_context83) {
4710
- while (1) switch (_context83.p = _context83.n) {
4740
+ var _ref103, _ref103$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t18;
4741
+ return _regenerator().w(function (_context84) {
4742
+ while (1) switch (_context84.p = _context84.n) {
4711
4743
  case 0:
4712
- _ref102 = params || {}, _ref102$successPageDu = _ref102.successPageDuration, successPageDuration = _ref102$successPageDu === void 0 ? 2000 : _ref102$successPageDu, subTitle = _ref102.subTitle, title = _ref102.title, stampWith = _ref102.stampWith;
4744
+ _ref103 = params || {}, _ref103$successPageDu = _ref103.successPageDuration, successPageDuration = _ref103$successPageDu === void 0 ? 2000 : _ref103$successPageDu, subTitle = _ref103.subTitle, title = _ref103.title, stampWith = _ref103.stampWith;
4713
4745
  if (client) {
4714
- _context83.n = 1;
4746
+ _context84.n = 1;
4715
4747
  break;
4716
4748
  }
4717
4749
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4718
4750
  case 1:
4719
4751
  if (masterConfig) {
4720
- _context83.n = 2;
4752
+ _context84.n = 2;
4721
4753
  break;
4722
4754
  }
4723
4755
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
4724
4756
  case 2:
4725
4757
  if ((_masterConfig$auth38 = masterConfig.auth) !== null && _masterConfig$auth38 !== void 0 && (_masterConfig$auth38$ = _masterConfig$auth38.methods) !== null && _masterConfig$auth38$ !== void 0 && _masterConfig$auth38$.smsOtpAuthEnabled) {
4726
- _context83.n = 3;
4758
+ _context84.n = 3;
4727
4759
  break;
4728
4760
  }
4729
4761
  throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
4730
4762
  case 3:
4731
- _context83.n = 4;
4763
+ _context84.n = 4;
4732
4764
  return getSession();
4733
4765
  case 4:
4734
- s = _context83.v;
4766
+ s = _context84.v;
4735
4767
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4736
4768
  if (organizationId) {
4737
- _context83.n = 5;
4769
+ _context84.n = 5;
4738
4770
  break;
4739
4771
  }
4740
4772
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
4741
4773
  case 5:
4742
4774
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
4743
4775
  if (userId) {
4744
- _context83.n = 6;
4776
+ _context84.n = 6;
4745
4777
  break;
4746
4778
  }
4747
4779
  throw new TurnkeyError("A user ID is required to update a phone number.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -4761,12 +4793,12 @@ var ClientProvider = function ClientProvider(_ref) {
4761
4793
  showTitle: false
4762
4794
  });
4763
4795
  };
4764
- _context83.p = 7;
4796
+ _context84.p = 7;
4765
4797
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
4766
- _context83.n = 8;
4798
+ _context84.n = 8;
4767
4799
  break;
4768
4800
  }
4769
- return _context83.a(2, withTurnkeyErrorHandling(function () {
4801
+ return _context84.a(2, withTurnkeyErrorHandling(function () {
4770
4802
  return new Promise(function (resolve, reject) {
4771
4803
  pushPage({
4772
4804
  key: "Update Phone Number",
@@ -4794,14 +4826,14 @@ var ClientProvider = function ClientProvider(_ref) {
4794
4826
  return logout();
4795
4827
  }));
4796
4828
  case 8:
4797
- _context83.n = 9;
4829
+ _context84.n = 9;
4798
4830
  return initOtp({
4799
4831
  otpType: OtpType.Sms,
4800
4832
  contact: params.phoneNumber
4801
4833
  });
4802
4834
  case 9:
4803
- otpId = _context83.v;
4804
- return _context83.a(2, withTurnkeyErrorHandling(function () {
4835
+ otpId = _context84.v;
4836
+ return _context84.a(2, withTurnkeyErrorHandling(function () {
4805
4837
  return new Promise(function (resolve, reject) {
4806
4838
  var _masterConfig$auth39, _masterConfig$auth40;
4807
4839
  pushPage({
@@ -4813,13 +4845,13 @@ var ClientProvider = function ClientProvider(_ref) {
4813
4845
  otpLength: ((_masterConfig$auth39 = masterConfig.auth) === null || _masterConfig$auth39 === void 0 ? void 0 : _masterConfig$auth39.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
4814
4846
  alphanumeric: (_masterConfig$auth40 = masterConfig.auth) === null || _masterConfig$auth40 === void 0 ? void 0 : _masterConfig$auth40.otpAlphanumeric,
4815
4847
  onContinue: function () {
4816
- var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee82(otpCode) {
4848
+ var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee83(otpCode) {
4817
4849
  var _yield$verifyOtp, verificationToken, res, _t17;
4818
- return _regenerator().w(function (_context82) {
4819
- while (1) switch (_context82.p = _context82.n) {
4850
+ return _regenerator().w(function (_context83) {
4851
+ while (1) switch (_context83.p = _context83.n) {
4820
4852
  case 0:
4821
- _context82.p = 0;
4822
- _context82.n = 1;
4853
+ _context83.p = 0;
4854
+ _context83.n = 1;
4823
4855
  return verifyOtp({
4824
4856
  otpId: otpId,
4825
4857
  otpCode: otpCode,
@@ -4827,9 +4859,9 @@ var ClientProvider = function ClientProvider(_ref) {
4827
4859
  otpType: OtpType.Sms
4828
4860
  });
4829
4861
  case 1:
4830
- _yield$verifyOtp = _context82.v;
4862
+ _yield$verifyOtp = _context83.v;
4831
4863
  verificationToken = _yield$verifyOtp.verificationToken;
4832
- _context82.n = 2;
4864
+ _context83.n = 2;
4833
4865
  return updateUserPhoneNumber(_objectSpread2({
4834
4866
  phoneNumber: params.phoneNumber,
4835
4867
  verificationToken: verificationToken,
@@ -4839,21 +4871,21 @@ var ClientProvider = function ClientProvider(_ref) {
4839
4871
  stampWith: stampWith
4840
4872
  }));
4841
4873
  case 2:
4842
- res = _context82.v;
4874
+ res = _context83.v;
4843
4875
  onSuccess();
4844
4876
  resolve(res);
4845
- _context82.n = 4;
4877
+ _context83.n = 4;
4846
4878
  break;
4847
4879
  case 3:
4848
- _context82.p = 3;
4849
- _t17 = _context82.v;
4880
+ _context83.p = 3;
4881
+ _t17 = _context83.v;
4850
4882
  reject(_t17);
4851
4883
  case 4:
4852
- return _context82.a(2);
4884
+ return _context83.a(2);
4853
4885
  }
4854
- }, _callee82, null, [[0, 3]]);
4886
+ }, _callee83, null, [[0, 3]]);
4855
4887
  }));
4856
- function onContinue(_x71) {
4888
+ function onContinue(_x72) {
4857
4889
  return _onContinue.apply(this, arguments);
4858
4890
  }
4859
4891
  return onContinue;
@@ -4872,54 +4904,54 @@ var ClientProvider = function ClientProvider(_ref) {
4872
4904
  return logout();
4873
4905
  }, callbacks, "Failed to update phone number"));
4874
4906
  case 10:
4875
- _context83.n = 13;
4907
+ _context84.n = 13;
4876
4908
  break;
4877
4909
  case 11:
4878
- _context83.p = 11;
4879
- _t18 = _context83.v;
4910
+ _context84.p = 11;
4911
+ _t18 = _context84.v;
4880
4912
  if (!(_t18 instanceof TurnkeyError)) {
4881
- _context83.n = 12;
4913
+ _context84.n = 12;
4882
4914
  break;
4883
4915
  }
4884
4916
  throw _t18;
4885
4917
  case 12:
4886
4918
  throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t18);
4887
4919
  case 13:
4888
- return _context83.a(2);
4920
+ return _context84.a(2);
4889
4921
  }
4890
- }, _callee83, null, [[7, 11]]);
4922
+ }, _callee84, null, [[7, 11]]);
4891
4923
  }));
4892
- return function (_x70) {
4893
- return _ref101.apply(this, arguments);
4924
+ return function (_x71) {
4925
+ return _ref102.apply(this, arguments);
4894
4926
  };
4895
4927
  }(), [pushPage, masterConfig, client, session, user]);
4896
4928
  var handleUpdateUserEmail = useCallback(/*#__PURE__*/function () {
4897
- var _ref103 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee85(params) {
4898
- var _ref104, _ref104$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t20;
4899
- return _regenerator().w(function (_context85) {
4900
- while (1) switch (_context85.p = _context85.n) {
4929
+ var _ref104 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee86(params) {
4930
+ var _ref105, _ref105$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t20;
4931
+ return _regenerator().w(function (_context86) {
4932
+ while (1) switch (_context86.p = _context86.n) {
4901
4933
  case 0:
4902
- _ref104 = params || {}, _ref104$successPageDu = _ref104.successPageDuration, successPageDuration = _ref104$successPageDu === void 0 ? 2000 : _ref104$successPageDu, subTitle = _ref104.subTitle, title = _ref104.title, stampWith = _ref104.stampWith;
4934
+ _ref105 = params || {}, _ref105$successPageDu = _ref105.successPageDuration, successPageDuration = _ref105$successPageDu === void 0 ? 2000 : _ref105$successPageDu, subTitle = _ref105.subTitle, title = _ref105.title, stampWith = _ref105.stampWith;
4903
4935
  if (client) {
4904
- _context85.n = 1;
4936
+ _context86.n = 1;
4905
4937
  break;
4906
4938
  }
4907
4939
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4908
4940
  case 1:
4909
- _context85.n = 2;
4941
+ _context86.n = 2;
4910
4942
  return getSession();
4911
4943
  case 2:
4912
- s = _context85.v;
4944
+ s = _context86.v;
4913
4945
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4914
4946
  if (organizationId) {
4915
- _context85.n = 3;
4947
+ _context86.n = 3;
4916
4948
  break;
4917
4949
  }
4918
4950
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
4919
4951
  case 3:
4920
4952
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
4921
4953
  if (userId) {
4922
- _context85.n = 4;
4954
+ _context86.n = 4;
4923
4955
  break;
4924
4956
  }
4925
4957
  throw new TurnkeyError("A user ID is required to update an email.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -4939,12 +4971,12 @@ var ClientProvider = function ClientProvider(_ref) {
4939
4971
  showTitle: false
4940
4972
  });
4941
4973
  };
4942
- _context85.p = 5;
4974
+ _context86.p = 5;
4943
4975
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
4944
- _context85.n = 6;
4976
+ _context86.n = 6;
4945
4977
  break;
4946
4978
  }
4947
- return _context85.a(2, withTurnkeyErrorHandling(function () {
4979
+ return _context86.a(2, withTurnkeyErrorHandling(function () {
4948
4980
  return new Promise(function (resolve, reject) {
4949
4981
  pushPage({
4950
4982
  key: "Update Email",
@@ -4972,14 +5004,14 @@ var ClientProvider = function ClientProvider(_ref) {
4972
5004
  return logout();
4973
5005
  }));
4974
5006
  case 6:
4975
- _context85.n = 7;
5007
+ _context86.n = 7;
4976
5008
  return initOtp({
4977
5009
  otpType: OtpType.Email,
4978
5010
  contact: params.email
4979
5011
  });
4980
5012
  case 7:
4981
- otpId = _context85.v;
4982
- return _context85.a(2, withTurnkeyErrorHandling(function () {
5013
+ otpId = _context86.v;
5014
+ return _context86.a(2, withTurnkeyErrorHandling(function () {
4983
5015
  return new Promise(function (resolve, reject) {
4984
5016
  var _masterConfig$auth41, _masterConfig$auth42;
4985
5017
  pushPage({
@@ -4991,13 +5023,13 @@ var ClientProvider = function ClientProvider(_ref) {
4991
5023
  otpLength: (masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth41 = masterConfig.auth) === null || _masterConfig$auth41 === void 0 ? void 0 : _masterConfig$auth41.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
4992
5024
  alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth42 = masterConfig.auth) === null || _masterConfig$auth42 === void 0 ? void 0 : _masterConfig$auth42.otpAlphanumeric,
4993
5025
  onContinue: function () {
4994
- var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee84(otpCode) {
5026
+ var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee85(otpCode) {
4995
5027
  var _yield$verifyOtp2, verificationToken, res, _t19;
4996
- return _regenerator().w(function (_context84) {
4997
- while (1) switch (_context84.p = _context84.n) {
5028
+ return _regenerator().w(function (_context85) {
5029
+ while (1) switch (_context85.p = _context85.n) {
4998
5030
  case 0:
4999
- _context84.p = 0;
5000
- _context84.n = 1;
5031
+ _context85.p = 0;
5032
+ _context85.n = 1;
5001
5033
  return verifyOtp({
5002
5034
  otpId: otpId,
5003
5035
  otpCode: otpCode,
@@ -5005,9 +5037,9 @@ var ClientProvider = function ClientProvider(_ref) {
5005
5037
  otpType: OtpType.Email
5006
5038
  });
5007
5039
  case 1:
5008
- _yield$verifyOtp2 = _context84.v;
5040
+ _yield$verifyOtp2 = _context85.v;
5009
5041
  verificationToken = _yield$verifyOtp2.verificationToken;
5010
- _context84.n = 2;
5042
+ _context85.n = 2;
5011
5043
  return updateUserEmail(_objectSpread2({
5012
5044
  email: params.email,
5013
5045
  verificationToken: verificationToken,
@@ -5017,21 +5049,21 @@ var ClientProvider = function ClientProvider(_ref) {
5017
5049
  stampWith: stampWith
5018
5050
  }));
5019
5051
  case 2:
5020
- res = _context84.v;
5052
+ res = _context85.v;
5021
5053
  onSuccess();
5022
5054
  resolve(res);
5023
- _context84.n = 4;
5055
+ _context85.n = 4;
5024
5056
  break;
5025
5057
  case 3:
5026
- _context84.p = 3;
5027
- _t19 = _context84.v;
5058
+ _context85.p = 3;
5059
+ _t19 = _context85.v;
5028
5060
  reject(_t19);
5029
5061
  case 4:
5030
- return _context84.a(2);
5062
+ return _context85.a(2);
5031
5063
  }
5032
- }, _callee84, null, [[0, 3]]);
5064
+ }, _callee85, null, [[0, 3]]);
5033
5065
  }));
5034
- function onContinue(_x73) {
5066
+ function onContinue(_x74) {
5035
5067
  return _onContinue2.apply(this, arguments);
5036
5068
  }
5037
5069
  return onContinue;
@@ -5048,54 +5080,54 @@ var ClientProvider = function ClientProvider(_ref) {
5048
5080
  return logout();
5049
5081
  }, callbacks, "Failed to update email"));
5050
5082
  case 8:
5051
- _context85.n = 11;
5083
+ _context86.n = 11;
5052
5084
  break;
5053
5085
  case 9:
5054
- _context85.p = 9;
5055
- _t20 = _context85.v;
5086
+ _context86.p = 9;
5087
+ _t20 = _context86.v;
5056
5088
  if (!(_t20 instanceof TurnkeyError)) {
5057
- _context85.n = 10;
5089
+ _context86.n = 10;
5058
5090
  break;
5059
5091
  }
5060
5092
  throw _t20;
5061
5093
  case 10:
5062
5094
  throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t20);
5063
5095
  case 11:
5064
- return _context85.a(2);
5096
+ return _context86.a(2);
5065
5097
  }
5066
- }, _callee85, null, [[5, 9]]);
5098
+ }, _callee86, null, [[5, 9]]);
5067
5099
  }));
5068
- return function (_x72) {
5069
- return _ref103.apply(this, arguments);
5100
+ return function (_x73) {
5101
+ return _ref104.apply(this, arguments);
5070
5102
  };
5071
5103
  }(), [pushPage, masterConfig, client, session, user]);
5072
5104
  var handleAddEmail = useCallback(/*#__PURE__*/function () {
5073
- var _ref105 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee87(params) {
5074
- var _ref106, _ref106$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t22;
5075
- return _regenerator().w(function (_context87) {
5076
- while (1) switch (_context87.p = _context87.n) {
5105
+ var _ref106 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee88(params) {
5106
+ var _ref107, _ref107$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t22;
5107
+ return _regenerator().w(function (_context88) {
5108
+ while (1) switch (_context88.p = _context88.n) {
5077
5109
  case 0:
5078
- _ref106 = params || {}, _ref106$successPageDu = _ref106.successPageDuration, successPageDuration = _ref106$successPageDu === void 0 ? 2000 : _ref106$successPageDu, subTitle = _ref106.subTitle, title = _ref106.title, stampWith = _ref106.stampWith;
5110
+ _ref107 = params || {}, _ref107$successPageDu = _ref107.successPageDuration, successPageDuration = _ref107$successPageDu === void 0 ? 2000 : _ref107$successPageDu, subTitle = _ref107.subTitle, title = _ref107.title, stampWith = _ref107.stampWith;
5079
5111
  if (client) {
5080
- _context87.n = 1;
5112
+ _context88.n = 1;
5081
5113
  break;
5082
5114
  }
5083
5115
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5084
5116
  case 1:
5085
- _context87.n = 2;
5117
+ _context88.n = 2;
5086
5118
  return getSession();
5087
5119
  case 2:
5088
- s = _context87.v;
5120
+ s = _context88.v;
5089
5121
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5090
5122
  if (organizationId) {
5091
- _context87.n = 3;
5123
+ _context88.n = 3;
5092
5124
  break;
5093
5125
  }
5094
5126
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5095
5127
  case 3:
5096
5128
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5097
5129
  if (userId) {
5098
- _context87.n = 4;
5130
+ _context88.n = 4;
5099
5131
  break;
5100
5132
  }
5101
5133
  throw new TurnkeyError("A user ID is required to add an email.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5115,12 +5147,12 @@ var ClientProvider = function ClientProvider(_ref) {
5115
5147
  showTitle: false
5116
5148
  });
5117
5149
  };
5118
- _context87.p = 5;
5150
+ _context88.p = 5;
5119
5151
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
5120
- _context87.n = 6;
5152
+ _context88.n = 6;
5121
5153
  break;
5122
5154
  }
5123
- return _context87.a(2, withTurnkeyErrorHandling(function () {
5155
+ return _context88.a(2, withTurnkeyErrorHandling(function () {
5124
5156
  return new Promise(function (resolve, reject) {
5125
5157
  pushPage({
5126
5158
  key: "Add Email",
@@ -5148,14 +5180,14 @@ var ClientProvider = function ClientProvider(_ref) {
5148
5180
  return logout();
5149
5181
  }));
5150
5182
  case 6:
5151
- _context87.n = 7;
5183
+ _context88.n = 7;
5152
5184
  return initOtp({
5153
5185
  otpType: OtpType.Email,
5154
5186
  contact: params.email
5155
5187
  });
5156
5188
  case 7:
5157
- otpId = _context87.v;
5158
- return _context87.a(2, withTurnkeyErrorHandling(function () {
5189
+ otpId = _context88.v;
5190
+ return _context88.a(2, withTurnkeyErrorHandling(function () {
5159
5191
  return new Promise(function (resolve, reject) {
5160
5192
  var _masterConfig$auth43, _masterConfig$auth44;
5161
5193
  pushPage({
@@ -5167,13 +5199,13 @@ var ClientProvider = function ClientProvider(_ref) {
5167
5199
  otpLength: (masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth43 = masterConfig.auth) === null || _masterConfig$auth43 === void 0 ? void 0 : _masterConfig$auth43.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5168
5200
  alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth44 = masterConfig.auth) === null || _masterConfig$auth44 === void 0 ? void 0 : _masterConfig$auth44.otpAlphanumeric,
5169
5201
  onContinue: function () {
5170
- var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee86(otpCode) {
5202
+ var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee87(otpCode) {
5171
5203
  var _yield$verifyOtp3, verificationToken, res, _t21;
5172
- return _regenerator().w(function (_context86) {
5173
- while (1) switch (_context86.p = _context86.n) {
5204
+ return _regenerator().w(function (_context87) {
5205
+ while (1) switch (_context87.p = _context87.n) {
5174
5206
  case 0:
5175
- _context86.p = 0;
5176
- _context86.n = 1;
5207
+ _context87.p = 0;
5208
+ _context87.n = 1;
5177
5209
  return verifyOtp({
5178
5210
  otpId: otpId,
5179
5211
  otpCode: otpCode,
@@ -5181,9 +5213,9 @@ var ClientProvider = function ClientProvider(_ref) {
5181
5213
  otpType: OtpType.Email
5182
5214
  });
5183
5215
  case 1:
5184
- _yield$verifyOtp3 = _context86.v;
5216
+ _yield$verifyOtp3 = _context87.v;
5185
5217
  verificationToken = _yield$verifyOtp3.verificationToken;
5186
- _context86.n = 2;
5218
+ _context87.n = 2;
5187
5219
  return updateUserEmail({
5188
5220
  email: params.email,
5189
5221
  verificationToken: verificationToken,
@@ -5192,21 +5224,21 @@ var ClientProvider = function ClientProvider(_ref) {
5192
5224
  stampWith: stampWith
5193
5225
  });
5194
5226
  case 2:
5195
- res = _context86.v;
5227
+ res = _context87.v;
5196
5228
  onSuccess();
5197
5229
  resolve(res);
5198
- _context86.n = 4;
5230
+ _context87.n = 4;
5199
5231
  break;
5200
5232
  case 3:
5201
- _context86.p = 3;
5202
- _t21 = _context86.v;
5233
+ _context87.p = 3;
5234
+ _t21 = _context87.v;
5203
5235
  reject(_t21);
5204
5236
  case 4:
5205
- return _context86.a(2);
5237
+ return _context87.a(2);
5206
5238
  }
5207
- }, _callee86, null, [[0, 3]]);
5239
+ }, _callee87, null, [[0, 3]]);
5208
5240
  }));
5209
- function onContinue(_x75) {
5241
+ function onContinue(_x76) {
5210
5242
  return _onContinue3.apply(this, arguments);
5211
5243
  }
5212
5244
  return onContinue;
@@ -5223,67 +5255,67 @@ var ClientProvider = function ClientProvider(_ref) {
5223
5255
  return logout();
5224
5256
  }, callbacks, "Failed to add email"));
5225
5257
  case 8:
5226
- _context87.n = 11;
5258
+ _context88.n = 11;
5227
5259
  break;
5228
5260
  case 9:
5229
- _context87.p = 9;
5230
- _t22 = _context87.v;
5261
+ _context88.p = 9;
5262
+ _t22 = _context88.v;
5231
5263
  if (!(_t22 instanceof TurnkeyError)) {
5232
- _context87.n = 10;
5264
+ _context88.n = 10;
5233
5265
  break;
5234
5266
  }
5235
5267
  throw _t22;
5236
5268
  case 10:
5237
5269
  throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t22);
5238
5270
  case 11:
5239
- return _context87.a(2);
5271
+ return _context88.a(2);
5240
5272
  }
5241
- }, _callee87, null, [[5, 9]]);
5273
+ }, _callee88, null, [[5, 9]]);
5242
5274
  }));
5243
- return function (_x74) {
5244
- return _ref105.apply(this, arguments);
5275
+ return function (_x75) {
5276
+ return _ref106.apply(this, arguments);
5245
5277
  };
5246
5278
  }(), [pushPage, client, session, user]);
5247
5279
  var handleAddPhoneNumber = useCallback(/*#__PURE__*/function () {
5248
- var _ref107 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee89(params) {
5280
+ var _ref108 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee90(params) {
5249
5281
  var _masterConfig$auth45, _masterConfig$auth45$;
5250
- var _ref108, _ref108$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t24;
5251
- return _regenerator().w(function (_context89) {
5252
- while (1) switch (_context89.p = _context89.n) {
5282
+ var _ref109, _ref109$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t24;
5283
+ return _regenerator().w(function (_context90) {
5284
+ while (1) switch (_context90.p = _context90.n) {
5253
5285
  case 0:
5254
- _ref108 = params || {}, _ref108$successPageDu = _ref108.successPageDuration, successPageDuration = _ref108$successPageDu === void 0 ? 2000 : _ref108$successPageDu, subTitle = _ref108.subTitle, title = _ref108.title, stampWith = _ref108.stampWith;
5286
+ _ref109 = params || {}, _ref109$successPageDu = _ref109.successPageDuration, successPageDuration = _ref109$successPageDu === void 0 ? 2000 : _ref109$successPageDu, subTitle = _ref109.subTitle, title = _ref109.title, stampWith = _ref109.stampWith;
5255
5287
  if (client) {
5256
- _context89.n = 1;
5288
+ _context90.n = 1;
5257
5289
  break;
5258
5290
  }
5259
5291
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5260
5292
  case 1:
5261
5293
  if (masterConfig) {
5262
- _context89.n = 2;
5294
+ _context90.n = 2;
5263
5295
  break;
5264
5296
  }
5265
5297
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
5266
5298
  case 2:
5267
5299
  if ((_masterConfig$auth45 = masterConfig.auth) !== null && _masterConfig$auth45 !== void 0 && (_masterConfig$auth45$ = _masterConfig$auth45.methods) !== null && _masterConfig$auth45$ !== void 0 && _masterConfig$auth45$.smsOtpAuthEnabled) {
5268
- _context89.n = 3;
5300
+ _context90.n = 3;
5269
5301
  break;
5270
5302
  }
5271
5303
  throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
5272
5304
  case 3:
5273
- _context89.n = 4;
5305
+ _context90.n = 4;
5274
5306
  return getSession();
5275
5307
  case 4:
5276
- s = _context89.v;
5308
+ s = _context90.v;
5277
5309
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5278
5310
  if (organizationId) {
5279
- _context89.n = 5;
5311
+ _context90.n = 5;
5280
5312
  break;
5281
5313
  }
5282
5314
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5283
5315
  case 5:
5284
5316
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5285
5317
  if (userId) {
5286
- _context89.n = 6;
5318
+ _context90.n = 6;
5287
5319
  break;
5288
5320
  }
5289
5321
  throw new TurnkeyError("A user ID is required to add a phone number.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5303,12 +5335,12 @@ var ClientProvider = function ClientProvider(_ref) {
5303
5335
  showTitle: false
5304
5336
  });
5305
5337
  };
5306
- _context89.p = 7;
5338
+ _context90.p = 7;
5307
5339
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
5308
- _context89.n = 8;
5340
+ _context90.n = 8;
5309
5341
  break;
5310
5342
  }
5311
- return _context89.a(2, withTurnkeyErrorHandling(function () {
5343
+ return _context90.a(2, withTurnkeyErrorHandling(function () {
5312
5344
  return new Promise(function (resolve, reject) {
5313
5345
  pushPage({
5314
5346
  key: "Add Phone Number",
@@ -5336,14 +5368,14 @@ var ClientProvider = function ClientProvider(_ref) {
5336
5368
  return logout();
5337
5369
  }, callbacks, "Failed to add phone number"));
5338
5370
  case 8:
5339
- _context89.n = 9;
5371
+ _context90.n = 9;
5340
5372
  return initOtp({
5341
5373
  otpType: OtpType.Sms,
5342
5374
  contact: params.phoneNumber
5343
5375
  });
5344
5376
  case 9:
5345
- otpId = _context89.v;
5346
- return _context89.a(2, withTurnkeyErrorHandling(function () {
5377
+ otpId = _context90.v;
5378
+ return _context90.a(2, withTurnkeyErrorHandling(function () {
5347
5379
  return new Promise(function (resolve, reject) {
5348
5380
  var _masterConfig$auth46, _masterConfig$auth47;
5349
5381
  pushPage({
@@ -5355,13 +5387,13 @@ var ClientProvider = function ClientProvider(_ref) {
5355
5387
  otpLength: ((_masterConfig$auth46 = masterConfig.auth) === null || _masterConfig$auth46 === void 0 ? void 0 : _masterConfig$auth46.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5356
5388
  alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth47 = masterConfig.auth) === null || _masterConfig$auth47 === void 0 ? void 0 : _masterConfig$auth47.otpAlphanumeric,
5357
5389
  onContinue: function () {
5358
- var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee88(otpCode) {
5390
+ var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee89(otpCode) {
5359
5391
  var _yield$verifyOtp4, verificationToken, res, _t23;
5360
- return _regenerator().w(function (_context88) {
5361
- while (1) switch (_context88.p = _context88.n) {
5392
+ return _regenerator().w(function (_context89) {
5393
+ while (1) switch (_context89.p = _context89.n) {
5362
5394
  case 0:
5363
- _context88.p = 0;
5364
- _context88.n = 1;
5395
+ _context89.p = 0;
5396
+ _context89.n = 1;
5365
5397
  return verifyOtp({
5366
5398
  otpId: otpId,
5367
5399
  otpCode: otpCode,
@@ -5369,9 +5401,9 @@ var ClientProvider = function ClientProvider(_ref) {
5369
5401
  otpType: OtpType.Sms
5370
5402
  });
5371
5403
  case 1:
5372
- _yield$verifyOtp4 = _context88.v;
5404
+ _yield$verifyOtp4 = _context89.v;
5373
5405
  verificationToken = _yield$verifyOtp4.verificationToken;
5374
- _context88.n = 2;
5406
+ _context89.n = 2;
5375
5407
  return updateUserPhoneNumber({
5376
5408
  phoneNumber: params.phoneNumber,
5377
5409
  verificationToken: verificationToken,
@@ -5380,21 +5412,21 @@ var ClientProvider = function ClientProvider(_ref) {
5380
5412
  stampWith: stampWith
5381
5413
  });
5382
5414
  case 2:
5383
- res = _context88.v;
5415
+ res = _context89.v;
5384
5416
  onSuccess();
5385
5417
  resolve(res);
5386
- _context88.n = 4;
5418
+ _context89.n = 4;
5387
5419
  break;
5388
5420
  case 3:
5389
- _context88.p = 3;
5390
- _t23 = _context88.v;
5421
+ _context89.p = 3;
5422
+ _t23 = _context89.v;
5391
5423
  reject(_t23);
5392
5424
  case 4:
5393
- return _context88.a(2);
5425
+ return _context89.a(2);
5394
5426
  }
5395
- }, _callee88, null, [[0, 3]]);
5427
+ }, _callee89, null, [[0, 3]]);
5396
5428
  }));
5397
- function onContinue(_x77) {
5429
+ function onContinue(_x78) {
5398
5430
  return _onContinue4.apply(this, arguments);
5399
5431
  }
5400
5432
  return onContinue;
@@ -5413,52 +5445,52 @@ var ClientProvider = function ClientProvider(_ref) {
5413
5445
  return logout();
5414
5446
  }, callbacks, "Failed to add phone number"));
5415
5447
  case 10:
5416
- _context89.n = 13;
5448
+ _context90.n = 13;
5417
5449
  break;
5418
5450
  case 11:
5419
- _context89.p = 11;
5420
- _t24 = _context89.v;
5451
+ _context90.p = 11;
5452
+ _t24 = _context90.v;
5421
5453
  if (!(_t24 instanceof TurnkeyError)) {
5422
- _context89.n = 12;
5454
+ _context90.n = 12;
5423
5455
  break;
5424
5456
  }
5425
5457
  throw _t24;
5426
5458
  case 12:
5427
5459
  throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t24);
5428
5460
  case 13:
5429
- return _context89.a(2);
5461
+ return _context90.a(2);
5430
5462
  }
5431
- }, _callee89, null, [[7, 11]]);
5463
+ }, _callee90, null, [[7, 11]]);
5432
5464
  }));
5433
- return function (_x76) {
5434
- return _ref107.apply(this, arguments);
5465
+ return function (_x77) {
5466
+ return _ref108.apply(this, arguments);
5435
5467
  };
5436
5468
  }(), [pushPage, masterConfig, client, session, user]);
5437
5469
  var handleRemovePasskey = useCallback(/*#__PURE__*/function () {
5438
- var _ref109 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee90(params) {
5470
+ var _ref110 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(params) {
5439
5471
  var authenticatorId, _params$successPageDu2, successPageDuration, subTitle, title, stampWith, userId, s, organizationId;
5440
- return _regenerator().w(function (_context90) {
5441
- while (1) switch (_context90.n) {
5472
+ return _regenerator().w(function (_context91) {
5473
+ while (1) switch (_context91.n) {
5442
5474
  case 0:
5443
5475
  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;
5444
5476
  if (client) {
5445
- _context90.n = 1;
5477
+ _context91.n = 1;
5446
5478
  break;
5447
5479
  }
5448
5480
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5449
5481
  case 1:
5450
- _context90.n = 2;
5482
+ _context91.n = 2;
5451
5483
  return getSession();
5452
5484
  case 2:
5453
- s = _context90.v;
5485
+ s = _context91.v;
5454
5486
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5455
5487
  if (organizationId) {
5456
- _context90.n = 3;
5488
+ _context91.n = 3;
5457
5489
  break;
5458
5490
  }
5459
5491
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5460
5492
  case 3:
5461
- return _context90.a(2, withTurnkeyErrorHandling(function () {
5493
+ return _context91.a(2, withTurnkeyErrorHandling(function () {
5462
5494
  return new Promise(function (resolve, reject) {
5463
5495
  pushPage({
5464
5496
  key: "Remove Passkey",
@@ -5489,44 +5521,44 @@ var ClientProvider = function ClientProvider(_ref) {
5489
5521
  return logout();
5490
5522
  }, callbacks, "Failed to remove passkey"));
5491
5523
  }
5492
- }, _callee90);
5524
+ }, _callee91);
5493
5525
  }));
5494
- return function (_x78) {
5495
- return _ref109.apply(this, arguments);
5526
+ return function (_x79) {
5527
+ return _ref110.apply(this, arguments);
5496
5528
  };
5497
5529
  }(), [pushPage, masterConfig, client, session, user]);
5498
5530
  var handleAddPasskey = useCallback(/*#__PURE__*/function () {
5499
- var _ref110 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(params) {
5500
- var _ref111, name, displayName, _ref111$successPageDu, successPageDuration, stampWith, s, organizationId, userId, resPromise, _t25;
5501
- return _regenerator().w(function (_context91) {
5502
- while (1) switch (_context91.p = _context91.n) {
5531
+ var _ref111 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee92(params) {
5532
+ var _ref112, name, displayName, _ref112$successPageDu, successPageDuration, stampWith, s, organizationId, userId, resPromise, _t25;
5533
+ return _regenerator().w(function (_context92) {
5534
+ while (1) switch (_context92.p = _context92.n) {
5503
5535
  case 0:
5504
- _ref111 = params || {}, name = _ref111.name, displayName = _ref111.displayName, _ref111$successPageDu = _ref111.successPageDuration, successPageDuration = _ref111$successPageDu === void 0 ? 2000 : _ref111$successPageDu, stampWith = _ref111.stampWith;
5536
+ _ref112 = params || {}, name = _ref112.name, displayName = _ref112.displayName, _ref112$successPageDu = _ref112.successPageDuration, successPageDuration = _ref112$successPageDu === void 0 ? 2000 : _ref112$successPageDu, stampWith = _ref112.stampWith;
5505
5537
  if (client) {
5506
- _context91.n = 1;
5538
+ _context92.n = 1;
5507
5539
  break;
5508
5540
  }
5509
5541
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5510
5542
  case 1:
5511
- _context91.n = 2;
5543
+ _context92.n = 2;
5512
5544
  return getSession();
5513
5545
  case 2:
5514
- s = _context91.v;
5546
+ s = _context92.v;
5515
5547
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5516
5548
  if (organizationId) {
5517
- _context91.n = 3;
5549
+ _context92.n = 3;
5518
5550
  break;
5519
5551
  }
5520
5552
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5521
5553
  case 3:
5522
5554
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5523
5555
  if (userId) {
5524
- _context91.n = 4;
5556
+ _context92.n = 4;
5525
5557
  break;
5526
5558
  }
5527
5559
  throw new TurnkeyError("A user ID or a valid session is required to add a passkey.", TurnkeyErrorCodes.INVALID_REQUEST);
5528
5560
  case 4:
5529
- _context91.p = 4;
5561
+ _context92.p = 4;
5530
5562
  resPromise = addPasskey(_objectSpread2(_objectSpread2(_objectSpread2({}, name && {
5531
5563
  name: name
5532
5564
  }), displayName && {
@@ -5551,55 +5583,55 @@ var ClientProvider = function ClientProvider(_ref) {
5551
5583
  showTitle: false
5552
5584
  });
5553
5585
  });
5554
- _context91.n = 5;
5586
+ _context92.n = 5;
5555
5587
  return resPromise;
5556
5588
  case 5:
5557
- return _context91.a(2, _context91.v);
5589
+ return _context92.a(2, _context92.v);
5558
5590
  case 6:
5559
- _context91.p = 6;
5560
- _t25 = _context91.v;
5591
+ _context92.p = 6;
5592
+ _t25 = _context92.v;
5561
5593
  if (!(_t25 instanceof TurnkeyError)) {
5562
- _context91.n = 7;
5594
+ _context92.n = 7;
5563
5595
  break;
5564
5596
  }
5565
5597
  throw _t25;
5566
5598
  case 7:
5567
5599
  throw new TurnkeyError("Failed to add passkey in handler.", TurnkeyErrorCodes.ADD_PASSKEY_ERROR, _t25);
5568
5600
  case 8:
5569
- return _context91.a(2);
5601
+ return _context92.a(2);
5570
5602
  }
5571
- }, _callee91, null, [[4, 6]]);
5603
+ }, _callee92, null, [[4, 6]]);
5572
5604
  }));
5573
- return function (_x79) {
5574
- return _ref110.apply(this, arguments);
5605
+ return function (_x80) {
5606
+ return _ref111.apply(this, arguments);
5575
5607
  };
5576
5608
  }(), [pushPage, masterConfig, client, session, user]);
5577
5609
  var handleRemoveOauthProvider = useCallback(/*#__PURE__*/function () {
5578
- var _ref112 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee92(params) {
5610
+ var _ref113 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(params) {
5579
5611
  var providerId, _params$successPageDu3, successPageDuration, subTitle, title, stampWith, s, organizationId, _t26;
5580
- return _regenerator().w(function (_context92) {
5581
- while (1) switch (_context92.p = _context92.n) {
5612
+ return _regenerator().w(function (_context93) {
5613
+ while (1) switch (_context93.p = _context93.n) {
5582
5614
  case 0:
5583
5615
  providerId = params.providerId, _params$successPageDu3 = params.successPageDuration, successPageDuration = _params$successPageDu3 === void 0 ? 2000 : _params$successPageDu3, subTitle = params.subTitle, title = params.title, stampWith = params.stampWith;
5584
5616
  if (client) {
5585
- _context92.n = 1;
5617
+ _context93.n = 1;
5586
5618
  break;
5587
5619
  }
5588
5620
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5589
5621
  case 1:
5590
- _context92.n = 2;
5622
+ _context93.n = 2;
5591
5623
  return getSession();
5592
5624
  case 2:
5593
- s = _context92.v;
5625
+ s = _context93.v;
5594
5626
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5595
5627
  if (organizationId) {
5596
- _context92.n = 3;
5628
+ _context93.n = 3;
5597
5629
  break;
5598
5630
  }
5599
5631
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5600
5632
  case 3:
5601
- _context92.p = 3;
5602
- return _context92.a(2, new Promise(function (resolve, reject) {
5633
+ _context93.p = 3;
5634
+ return _context93.a(2, new Promise(function (resolve, reject) {
5603
5635
  pushPage({
5604
5636
  key: "Remove OAuth Provider",
5605
5637
  content: jsx(RemoveOAuthProvider, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5622,73 +5654,73 @@ var ClientProvider = function ClientProvider(_ref) {
5622
5654
  showTitle: false,
5623
5655
  preventBack: true,
5624
5656
  onClose: function onClose() {
5625
- return reject(new TurnkeyError("User cancelled the remove OAuth provider process.", TurnkeyErrorCodes.USER_CANCELED));
5657
+ return reject(new TurnkeyError("User canceled the remove OAuth provider process.", TurnkeyErrorCodes.USER_CANCELED));
5626
5658
  }
5627
5659
  });
5628
5660
  }));
5629
5661
  case 4:
5630
- _context92.p = 4;
5631
- _t26 = _context92.v;
5662
+ _context93.p = 4;
5663
+ _t26 = _context93.v;
5632
5664
  if (!(_t26 instanceof TurnkeyError)) {
5633
- _context92.n = 5;
5665
+ _context93.n = 5;
5634
5666
  break;
5635
5667
  }
5636
5668
  throw _t26;
5637
5669
  case 5:
5638
5670
  throw new TurnkeyError("Failed to remove OAuth provider in handler.", TurnkeyErrorCodes.REMOVE_OAUTH_PROVIDER_ERROR, _t26);
5639
5671
  case 6:
5640
- return _context92.a(2);
5672
+ return _context93.a(2);
5641
5673
  }
5642
- }, _callee92, null, [[3, 4]]);
5674
+ }, _callee93, null, [[3, 4]]);
5643
5675
  }));
5644
- return function (_x80) {
5645
- return _ref112.apply(this, arguments);
5676
+ return function (_x81) {
5677
+ return _ref113.apply(this, arguments);
5646
5678
  };
5647
5679
  }(), [pushPage, masterConfig, client, session, user]);
5648
5680
  var handleAddOauthProvider = useCallback(/*#__PURE__*/function () {
5649
- var _ref113 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(params) {
5681
+ var _ref114 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(params) {
5650
5682
  var providerName, stampWith, _params$successPageDu4, successPageDuration, s, organizationId, userId;
5651
- return _regenerator().w(function (_context95) {
5652
- while (1) switch (_context95.n) {
5683
+ return _regenerator().w(function (_context96) {
5684
+ while (1) switch (_context96.n) {
5653
5685
  case 0:
5654
5686
  if (client) {
5655
- _context95.n = 1;
5687
+ _context96.n = 1;
5656
5688
  break;
5657
5689
  }
5658
5690
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5659
5691
  case 1:
5660
5692
  providerName = params.providerName, stampWith = params.stampWith, _params$successPageDu4 = params.successPageDuration, successPageDuration = _params$successPageDu4 === void 0 ? 2000 : _params$successPageDu4;
5661
- _context95.n = 2;
5693
+ _context96.n = 2;
5662
5694
  return getSession();
5663
5695
  case 2:
5664
- s = _context95.v;
5696
+ s = _context96.v;
5665
5697
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5666
5698
  if (organizationId) {
5667
- _context95.n = 3;
5699
+ _context96.n = 3;
5668
5700
  break;
5669
5701
  }
5670
5702
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5671
5703
  case 3:
5672
5704
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5673
5705
  if (userId) {
5674
- _context95.n = 4;
5706
+ _context96.n = 4;
5675
5707
  break;
5676
5708
  }
5677
5709
  throw new TurnkeyError("A user ID is required to add an OAuth provider.", TurnkeyErrorCodes.INVALID_REQUEST);
5678
5710
  case 4:
5679
- return _context95.a(2, new Promise(/*#__PURE__*/function () {
5680
- var _ref114 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(resolve, reject) {
5711
+ return _context96.a(2, new Promise(/*#__PURE__*/function () {
5712
+ var _ref115 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(resolve, reject) {
5681
5713
  var onOauthSuccess, _t27, _t28;
5682
- return _regenerator().w(function (_context94) {
5683
- while (1) switch (_context94.p = _context94.n) {
5714
+ return _regenerator().w(function (_context95) {
5715
+ while (1) switch (_context95.p = _context95.n) {
5684
5716
  case 0:
5685
- _context94.p = 0;
5717
+ _context95.p = 0;
5686
5718
  onOauthSuccess = /*#__PURE__*/function () {
5687
- var _ref115 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(params) {
5688
- return _regenerator().w(function (_context93) {
5689
- while (1) switch (_context93.n) {
5719
+ var _ref116 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(params) {
5720
+ return _regenerator().w(function (_context94) {
5721
+ while (1) switch (_context94.n) {
5690
5722
  case 0:
5691
- _context93.n = 1;
5723
+ _context94.n = 1;
5692
5724
  return addOauthProvider({
5693
5725
  providerName: params.providerName,
5694
5726
  oidcToken: params.oidcToken,
@@ -5711,107 +5743,107 @@ var ClientProvider = function ClientProvider(_ref) {
5711
5743
  showTitle: false
5712
5744
  });
5713
5745
  case 2:
5714
- return _context93.a(2);
5746
+ return _context94.a(2);
5715
5747
  }
5716
- }, _callee93);
5748
+ }, _callee94);
5717
5749
  }));
5718
- return function onOauthSuccess(_x84) {
5719
- return _ref115.apply(this, arguments);
5750
+ return function onOauthSuccess(_x85) {
5751
+ return _ref116.apply(this, arguments);
5720
5752
  };
5721
5753
  }();
5722
5754
  _t27 = providerName;
5723
- _context94.n = _t27 === OAuthProviders.DISCORD ? 1 : _t27 === OAuthProviders.X ? 3 : _t27 === OAuthProviders.GOOGLE ? 5 : _t27 === OAuthProviders.APPLE ? 7 : _t27 === OAuthProviders.FACEBOOK ? 9 : 11;
5755
+ _context95.n = _t27 === OAuthProviders.DISCORD ? 1 : _t27 === OAuthProviders.X ? 3 : _t27 === OAuthProviders.GOOGLE ? 5 : _t27 === OAuthProviders.APPLE ? 7 : _t27 === OAuthProviders.FACEBOOK ? 9 : 11;
5724
5756
  break;
5725
5757
  case 1:
5726
- _context94.n = 2;
5758
+ _context95.n = 2;
5727
5759
  return handleDiscordOauth({
5728
5760
  openInPage: false,
5729
5761
  onOauthSuccess: onOauthSuccess
5730
5762
  });
5731
5763
  case 2:
5732
- return _context94.a(2, _context94.v);
5764
+ return _context95.a(2, _context95.v);
5733
5765
  case 3:
5734
- _context94.n = 4;
5766
+ _context95.n = 4;
5735
5767
  return handleXOauth({
5736
5768
  openInPage: false,
5737
5769
  onOauthSuccess: onOauthSuccess
5738
5770
  });
5739
5771
  case 4:
5740
- return _context94.a(2, _context94.v);
5772
+ return _context95.a(2, _context95.v);
5741
5773
  case 5:
5742
- _context94.n = 6;
5774
+ _context95.n = 6;
5743
5775
  return handleGoogleOauth({
5744
5776
  openInPage: false,
5745
5777
  onOauthSuccess: onOauthSuccess
5746
5778
  });
5747
5779
  case 6:
5748
- return _context94.a(2, _context94.v);
5780
+ return _context95.a(2, _context95.v);
5749
5781
  case 7:
5750
- _context94.n = 8;
5782
+ _context95.n = 8;
5751
5783
  return handleAppleOauth({
5752
5784
  openInPage: false,
5753
5785
  onOauthSuccess: onOauthSuccess
5754
5786
  });
5755
5787
  case 8:
5756
- return _context94.a(2, _context94.v);
5788
+ return _context95.a(2, _context95.v);
5757
5789
  case 9:
5758
- _context94.n = 10;
5790
+ _context95.n = 10;
5759
5791
  return handleFacebookOauth({
5760
5792
  openInPage: false,
5761
5793
  onOauthSuccess: onOauthSuccess
5762
5794
  });
5763
5795
  case 10:
5764
- return _context94.a(2, _context94.v);
5796
+ return _context95.a(2, _context95.v);
5765
5797
  case 11:
5766
5798
  throw new TurnkeyError("Unsupported OAuth provider: ".concat(providerName), TurnkeyErrorCodes.NOT_FOUND);
5767
5799
  case 12:
5768
- _context94.n = 14;
5800
+ _context95.n = 14;
5769
5801
  break;
5770
5802
  case 13:
5771
- _context94.p = 13;
5772
- _t28 = _context94.v;
5803
+ _context95.p = 13;
5804
+ _t28 = _context95.v;
5773
5805
  reject(_t28);
5774
5806
  case 14:
5775
- return _context94.a(2);
5807
+ return _context95.a(2);
5776
5808
  }
5777
- }, _callee94, null, [[0, 13]]);
5809
+ }, _callee95, null, [[0, 13]]);
5778
5810
  }));
5779
- return function (_x82, _x83) {
5780
- return _ref114.apply(this, arguments);
5811
+ return function (_x83, _x84) {
5812
+ return _ref115.apply(this, arguments);
5781
5813
  };
5782
5814
  }()));
5783
5815
  }
5784
- }, _callee95);
5816
+ }, _callee96);
5785
5817
  }));
5786
- return function (_x81) {
5787
- return _ref113.apply(this, arguments);
5818
+ return function (_x82) {
5819
+ return _ref114.apply(this, arguments);
5788
5820
  };
5789
5821
  }(), [pushPage, masterConfig, client, session, user]);
5790
5822
  var handleConnectExternalWallet = useCallback(/*#__PURE__*/function () {
5791
- var _ref116 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(params) {
5823
+ var _ref117 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(params) {
5792
5824
  var _masterConfig$walletC4, _masterConfig$walletC5;
5793
- var _ref117, _ref117$successPageDu, successPageDuration, providers;
5794
- return _regenerator().w(function (_context96) {
5795
- while (1) switch (_context96.n) {
5825
+ var _ref118, _ref118$successPageDu, successPageDuration, providers;
5826
+ return _regenerator().w(function (_context97) {
5827
+ while (1) switch (_context97.n) {
5796
5828
  case 0:
5797
- _ref117 = params || {}, _ref117$successPageDu = _ref117.successPageDuration, successPageDuration = _ref117$successPageDu === void 0 ? 2000 : _ref117$successPageDu;
5829
+ _ref118 = params || {}, _ref118$successPageDu = _ref118.successPageDuration, successPageDuration = _ref118$successPageDu === void 0 ? 2000 : _ref118$successPageDu;
5798
5830
  if (client) {
5799
- _context96.n = 1;
5831
+ _context97.n = 1;
5800
5832
  break;
5801
5833
  }
5802
5834
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5803
5835
  case 1:
5804
5836
  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) {
5805
- _context96.n = 2;
5837
+ _context97.n = 2;
5806
5838
  break;
5807
5839
  }
5808
5840
  throw new TurnkeyError("Wallet connecting is not enabled.", TurnkeyErrorCodes.FEATURE_NOT_ENABLED);
5809
5841
  case 2:
5810
- _context96.n = 3;
5842
+ _context97.n = 3;
5811
5843
  return fetchWalletProviders();
5812
5844
  case 3:
5813
- providers = _context96.v;
5814
- return _context96.a(2, new Promise(function (resolve, reject) {
5845
+ providers = _context97.v;
5846
+ return _context97.a(2, new Promise(function (resolve, reject) {
5815
5847
  pushPage({
5816
5848
  key: "Connect wallet",
5817
5849
  content: jsx(ConnectWalletModal, {
@@ -5828,37 +5860,37 @@ var ClientProvider = function ClientProvider(_ref) {
5828
5860
  }
5829
5861
  }),
5830
5862
  onClose: function onClose() {
5831
- return reject(new TurnkeyError("User cancelled the connect wallet process.", TurnkeyErrorCodes.USER_CANCELED));
5863
+ return reject(new TurnkeyError("User canceled the connect wallet process.", TurnkeyErrorCodes.USER_CANCELED));
5832
5864
  }
5833
5865
  });
5834
5866
  }));
5835
5867
  }
5836
- }, _callee96);
5868
+ }, _callee97);
5837
5869
  }));
5838
- return function (_x85) {
5839
- return _ref116.apply(this, arguments);
5870
+ return function (_x86) {
5871
+ return _ref117.apply(this, arguments);
5840
5872
  };
5841
5873
  }(), [pushPage, masterConfig, client, session, user]);
5842
5874
  var handleRemoveUserEmail = useCallback(/*#__PURE__*/function () {
5843
- var _ref118 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(params) {
5844
- var _ref119, _ref119$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t29;
5845
- return _regenerator().w(function (_context97) {
5846
- while (1) switch (_context97.p = _context97.n) {
5875
+ var _ref119 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(params) {
5876
+ var _ref120, _ref120$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t29;
5877
+ return _regenerator().w(function (_context98) {
5878
+ while (1) switch (_context98.p = _context98.n) {
5847
5879
  case 0:
5848
- _ref119 = params || {}, _ref119$successPageDu = _ref119.successPageDuration, successPageDuration = _ref119$successPageDu === void 0 ? 2000 : _ref119$successPageDu, stampWith = _ref119.stampWith, userId = _ref119.userId;
5849
- _context97.n = 1;
5880
+ _ref120 = params || {}, _ref120$successPageDu = _ref120.successPageDuration, successPageDuration = _ref120$successPageDu === void 0 ? 2000 : _ref120$successPageDu, stampWith = _ref120.stampWith, userId = _ref120.userId;
5881
+ _context98.n = 1;
5850
5882
  return getSession();
5851
5883
  case 1:
5852
- s = _context97.v;
5884
+ s = _context98.v;
5853
5885
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5854
5886
  if (organizationId) {
5855
- _context97.n = 2;
5887
+ _context98.n = 2;
5856
5888
  break;
5857
5889
  }
5858
5890
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5859
5891
  case 2:
5860
- _context97.p = 2;
5861
- return _context97.a(2, new Promise(function (resolve, reject) {
5892
+ _context98.p = 2;
5893
+ return _context98.a(2, new Promise(function (resolve, reject) {
5862
5894
  pushPage({
5863
5895
  key: "Remove Email",
5864
5896
  content: jsx(RemoveEmail, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5880,49 +5912,49 @@ var ClientProvider = function ClientProvider(_ref) {
5880
5912
  showTitle: false,
5881
5913
  preventBack: true,
5882
5914
  onClose: function onClose() {
5883
- return reject(new TurnkeyError("User cancelled the remove email process.", TurnkeyErrorCodes.USER_CANCELED));
5915
+ return reject(new TurnkeyError("User canceled the remove email process.", TurnkeyErrorCodes.USER_CANCELED));
5884
5916
  }
5885
5917
  });
5886
5918
  }));
5887
5919
  case 3:
5888
- _context97.p = 3;
5889
- _t29 = _context97.v;
5920
+ _context98.p = 3;
5921
+ _t29 = _context98.v;
5890
5922
  if (!(_t29 instanceof TurnkeyError)) {
5891
- _context97.n = 4;
5923
+ _context98.n = 4;
5892
5924
  break;
5893
5925
  }
5894
5926
  throw _t29;
5895
5927
  case 4:
5896
5928
  throw new TurnkeyError("Failed to remove user email.", TurnkeyErrorCodes.UPDATE_USER_EMAIL_ERROR, _t29);
5897
5929
  case 5:
5898
- return _context97.a(2);
5930
+ return _context98.a(2);
5899
5931
  }
5900
- }, _callee97, null, [[2, 3]]);
5932
+ }, _callee98, null, [[2, 3]]);
5901
5933
  }));
5902
- return function (_x86) {
5903
- return _ref118.apply(this, arguments);
5934
+ return function (_x87) {
5935
+ return _ref119.apply(this, arguments);
5904
5936
  };
5905
5937
  }(), [pushPage, masterConfig, client, session, user]);
5906
5938
  var handleRemoveUserPhoneNumber = useCallback(/*#__PURE__*/function () {
5907
- var _ref120 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(params) {
5908
- var _ref121, _ref121$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t30;
5909
- return _regenerator().w(function (_context98) {
5910
- while (1) switch (_context98.p = _context98.n) {
5939
+ var _ref121 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99(params) {
5940
+ var _ref122, _ref122$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t30;
5941
+ return _regenerator().w(function (_context99) {
5942
+ while (1) switch (_context99.p = _context99.n) {
5911
5943
  case 0:
5912
- _ref121 = params || {}, _ref121$successPageDu = _ref121.successPageDuration, successPageDuration = _ref121$successPageDu === void 0 ? 2000 : _ref121$successPageDu, stampWith = _ref121.stampWith, userId = _ref121.userId;
5913
- _context98.n = 1;
5944
+ _ref122 = params || {}, _ref122$successPageDu = _ref122.successPageDuration, successPageDuration = _ref122$successPageDu === void 0 ? 2000 : _ref122$successPageDu, stampWith = _ref122.stampWith, userId = _ref122.userId;
5945
+ _context99.n = 1;
5914
5946
  return getSession();
5915
5947
  case 1:
5916
- s = _context98.v;
5948
+ s = _context99.v;
5917
5949
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5918
5950
  if (organizationId) {
5919
- _context98.n = 2;
5951
+ _context99.n = 2;
5920
5952
  break;
5921
5953
  }
5922
5954
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5923
5955
  case 2:
5924
- _context98.p = 2;
5925
- return _context98.a(2, new Promise(function (resolve, reject) {
5956
+ _context99.p = 2;
5957
+ return _context99.a(2, new Promise(function (resolve, reject) {
5926
5958
  pushPage({
5927
5959
  key: "Remove Phone Number",
5928
5960
  content: jsx(RemovePhoneNumber, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5944,63 +5976,63 @@ var ClientProvider = function ClientProvider(_ref) {
5944
5976
  showTitle: false,
5945
5977
  preventBack: true,
5946
5978
  onClose: function onClose() {
5947
- return reject(new TurnkeyError("User cancelled the remove phone number process.", TurnkeyErrorCodes.USER_CANCELED));
5979
+ return reject(new TurnkeyError("User canceled the remove phone number process.", TurnkeyErrorCodes.USER_CANCELED));
5948
5980
  }
5949
5981
  });
5950
5982
  }));
5951
5983
  case 3:
5952
- _context98.p = 3;
5953
- _t30 = _context98.v;
5984
+ _context99.p = 3;
5985
+ _t30 = _context99.v;
5954
5986
  if (!(_t30 instanceof TurnkeyError)) {
5955
- _context98.n = 4;
5987
+ _context99.n = 4;
5956
5988
  break;
5957
5989
  }
5958
5990
  throw _t30;
5959
5991
  case 4:
5960
5992
  throw new TurnkeyError("Failed to remove user phone number.", TurnkeyErrorCodes.UPDATE_USER_PHONE_NUMBER_ERROR, _t30);
5961
5993
  case 5:
5962
- return _context98.a(2);
5994
+ return _context99.a(2);
5963
5995
  }
5964
- }, _callee98, null, [[2, 3]]);
5996
+ }, _callee99, null, [[2, 3]]);
5965
5997
  }));
5966
- return function (_x87) {
5967
- return _ref120.apply(this, arguments);
5998
+ return function (_x88) {
5999
+ return _ref121.apply(this, arguments);
5968
6000
  };
5969
6001
  }(), [pushPage, masterConfig, client, session, user]);
5970
6002
  useEffect(function () {
5971
6003
  if (proxyAuthConfigRef.current) return;
5972
6004
  // Only fetch the proxy auth config once. Use that to build the master config.
5973
6005
  var fetchProxyAuthConfig = /*#__PURE__*/function () {
5974
- var _ref122 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99() {
6006
+ var _ref123 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100() {
5975
6007
  var proxyAuthConfig;
5976
- return _regenerator().w(function (_context99) {
5977
- while (1) switch (_context99.p = _context99.n) {
6008
+ return _regenerator().w(function (_context100) {
6009
+ while (1) switch (_context100.p = _context100.n) {
5978
6010
  case 0:
5979
- _context99.p = 0;
6011
+ _context100.p = 0;
5980
6012
  if (!config.authProxyConfigId) {
5981
- _context99.n = 2;
6013
+ _context100.n = 2;
5982
6014
  break;
5983
6015
  }
5984
- _context99.n = 1;
6016
+ _context100.n = 1;
5985
6017
  return getAuthProxyConfig(config.authProxyConfigId, config.authProxyUrl);
5986
6018
  case 1:
5987
- proxyAuthConfig = _context99.v;
6019
+ proxyAuthConfig = _context100.v;
5988
6020
  proxyAuthConfigRef.current = proxyAuthConfig;
5989
6021
  case 2:
5990
6022
  setMasterConfig(buildConfig(proxyAuthConfig));
5991
- _context99.n = 4;
6023
+ _context100.n = 4;
5992
6024
  break;
5993
6025
  case 3:
5994
- _context99.p = 3;
5995
- _context99.v;
6026
+ _context100.p = 3;
6027
+ _context100.v;
5996
6028
  setClientState(ClientState.Error);
5997
6029
  case 4:
5998
- return _context99.a(2);
6030
+ return _context100.a(2);
5999
6031
  }
6000
- }, _callee99, null, [[0, 3]]);
6032
+ }, _callee100, null, [[0, 3]]);
6001
6033
  }));
6002
6034
  return function fetchProxyAuthConfig() {
6003
- return _ref122.apply(this, arguments);
6035
+ return _ref123.apply(this, arguments);
6004
6036
  };
6005
6037
  }();
6006
6038
  fetchProxyAuthConfig();
@@ -6032,29 +6064,29 @@ var ClientProvider = function ClientProvider(_ref) {
6032
6064
  useEffect(function () {
6033
6065
  if (!client) return;
6034
6066
  var handleUpdateState = /*#__PURE__*/function () {
6035
- var _ref123 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100() {
6036
- return _regenerator().w(function (_context100) {
6037
- while (1) switch (_context100.n) {
6067
+ var _ref124 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101() {
6068
+ return _regenerator().w(function (_context101) {
6069
+ while (1) switch (_context101.n) {
6038
6070
  case 0:
6039
6071
  if (!session) {
6040
- _context100.n = 2;
6072
+ _context101.n = 2;
6041
6073
  break;
6042
6074
  }
6043
- _context100.n = 1;
6075
+ _context101.n = 1;
6044
6076
  return debouncedRefreshWallets();
6045
6077
  case 1:
6046
- _context100.n = 3;
6078
+ _context101.n = 3;
6047
6079
  break;
6048
6080
  case 2:
6049
- _context100.n = 3;
6081
+ _context101.n = 3;
6050
6082
  return debouncedFetchWalletProviders();
6051
6083
  case 3:
6052
- return _context100.a(2);
6084
+ return _context101.a(2);
6053
6085
  }
6054
- }, _callee100);
6086
+ }, _callee101);
6055
6087
  }));
6056
6088
  return function handleUpdateState() {
6057
- return _ref123.apply(this, arguments);
6089
+ return _ref124.apply(this, arguments);
6058
6090
  };
6059
6091
  }();
6060
6092
  var cleanup = function cleanup() {};
@@ -6165,6 +6197,7 @@ var ClientProvider = function ClientProvider(_ref) {
6165
6197
  getActiveSessionKey: getActiveSessionKey,
6166
6198
  createApiKeyPair: createApiKeyPair,
6167
6199
  getProxyAuthConfig: getProxyAuthConfig,
6200
+ fetchBootProofForAppProof: fetchBootProofForAppProof,
6168
6201
  handleLogin: handleLogin,
6169
6202
  handleGoogleOauth: handleGoogleOauth,
6170
6203
  handleXOauth: handleXOauth,