@turnkey/react-wallet-kit 1.8.0 → 1.9.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.
@@ -876,11 +876,11 @@ var ClientProvider = function ClientProvider(_ref) {
876
876
  * @throws {TurnkeyError} If an error occurs while clearing the timers.
877
877
  */
878
878
  function _initializeWalletProviderListeners() {
879
- _initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee134(walletProviders, onUpdateState) {
879
+ _initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee136(walletProviders, onUpdateState) {
880
880
  var _masterConfig$walletC0, _masterConfig$walletC1, _masterConfig$walletC10, _masterConfig$walletC11;
881
881
  var cleanups, nativeOnly, ethProviders, solProviders, wcProviders, wcProvider, attachEthereumListeners, attachSolanaListeners, _wcProvider$provider, _wcProvider$provider$, standardEvents, unsubscribe;
882
- return _regenerator().w(function (_context134) {
883
- while (1) switch (_context134.n) {
882
+ return _regenerator().w(function (_context136) {
883
+ while (1) switch (_context136.n) {
884
884
  case 0:
885
885
  attachSolanaListeners = function _attachSolanaListener(provider, onUpdateState) {
886
886
  var _provider$features;
@@ -888,19 +888,19 @@ var ClientProvider = function ClientProvider(_ref) {
888
888
  var walletEvents = provider === null || provider === void 0 ? void 0 : (_provider$features = provider.features) === null || _provider$features === void 0 ? void 0 : _provider$features["standard:events"];
889
889
  if (walletEvents !== null && walletEvents !== void 0 && walletEvents.on) {
890
890
  var offChange = walletEvents.on("change", /*#__PURE__*/function () {
891
- var _ref154 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee132(_evt) {
892
- return _regenerator().w(function (_context132) {
893
- while (1) switch (_context132.n) {
891
+ var _ref156 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee134(_evt) {
892
+ return _regenerator().w(function (_context134) {
893
+ while (1) switch (_context134.n) {
894
894
  case 0:
895
- _context132.n = 1;
895
+ _context134.n = 1;
896
896
  return onUpdateState();
897
897
  case 1:
898
- return _context132.a(2);
898
+ return _context134.a(2);
899
899
  }
900
- }, _callee132);
900
+ }, _callee134);
901
901
  }));
902
- return function (_x111) {
903
- return _ref154.apply(this, arguments);
902
+ return function (_x112) {
903
+ return _ref156.apply(this, arguments);
904
904
  };
905
905
  }());
906
906
  cleanups.push(offChange);
@@ -914,31 +914,31 @@ var ClientProvider = function ClientProvider(_ref) {
914
914
  attachEthereumListeners = function _attachEthereumListen(provider, onUpdateState) {
915
915
  if (typeof provider.on !== "function") return;
916
916
  var handleChainChanged = /*#__PURE__*/function () {
917
- var _ref152 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee130(_chainId) {
918
- return _regenerator().w(function (_context130) {
919
- while (1) switch (_context130.n) {
917
+ var _ref154 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee132(_chainId) {
918
+ return _regenerator().w(function (_context132) {
919
+ while (1) switch (_context132.n) {
920
920
  case 0:
921
- return _context130.a(2, onUpdateState());
921
+ return _context132.a(2, onUpdateState());
922
922
  }
923
- }, _callee130);
923
+ }, _callee132);
924
924
  }));
925
- return function handleChainChanged(_x109) {
926
- return _ref152.apply(this, arguments);
925
+ return function handleChainChanged(_x110) {
926
+ return _ref154.apply(this, arguments);
927
927
  };
928
928
  }();
929
929
  var handleAccountsChanged = /*#__PURE__*/function () {
930
- var _ref153 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee131(accounts) {
931
- return _regenerator().w(function (_context131) {
932
- while (1) switch (_context131.n) {
930
+ var _ref155 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee133(accounts) {
931
+ return _regenerator().w(function (_context133) {
932
+ while (1) switch (_context133.n) {
933
933
  case 0:
934
934
  if (accounts.length === 0) onUpdateState();
935
935
  case 1:
936
- return _context131.a(2);
936
+ return _context133.a(2);
937
937
  }
938
- }, _callee131);
938
+ }, _callee133);
939
939
  }));
940
- return function handleAccountsChanged(_x110) {
941
- return _ref153.apply(this, arguments);
940
+ return function handleAccountsChanged(_x111) {
941
+ return _ref155.apply(this, arguments);
942
942
  };
943
943
  }();
944
944
  var handleDisconnect = function handleDisconnect() {
@@ -954,10 +954,10 @@ var ClientProvider = function ClientProvider(_ref) {
954
954
  };
955
955
  };
956
956
  if (!(walletProviders.length === 0)) {
957
- _context134.n = 1;
957
+ _context136.n = 1;
958
958
  break;
959
959
  }
960
- return _context134.a(2, function () {});
960
+ return _context136.a(2, function () {});
961
961
  case 1:
962
962
  cleanups = []; // we only want to initialize these listeners for connected walletProviders
963
963
  nativeOnly = function nativeOnly(provider) {
@@ -995,82 +995,82 @@ var ClientProvider = function ClientProvider(_ref) {
995
995
  if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
996
996
  if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
997
997
  unsubscribe = standardEvents.on("change", /*#__PURE__*/function () {
998
- var _ref155 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee133(evt) {
998
+ var _ref157 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee135(evt) {
999
999
  var _callbacks$onError10, providers, currentSession, _wcProviders, wcWallets;
1000
- return _regenerator().w(function (_context133) {
1001
- while (1) switch (_context133.n) {
1000
+ return _regenerator().w(function (_context135) {
1001
+ while (1) switch (_context135.n) {
1002
1002
  case 0:
1003
1003
  if (!((evt === null || evt === void 0 ? void 0 : evt.type) === "pairingExpired")) {
1004
- _context133.n = 1;
1004
+ _context135.n = 1;
1005
1005
  break;
1006
1006
  }
1007
1007
  debouncedFetchWalletProviders();
1008
- return _context133.a(2);
1008
+ return _context135.a(2);
1009
1009
  case 1:
1010
1010
  if (!((evt === null || evt === void 0 ? void 0 : evt.type) === "failed")) {
1011
- _context133.n = 2;
1011
+ _context135.n = 2;
1012
1012
  break;
1013
1013
  }
1014
1014
  debouncedFetchWalletProviders();
1015
1015
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError10 = callbacks.onError) === null || _callbacks$onError10 === void 0 ? void 0 : _callbacks$onError10.call(callbacks, new TurnkeyError("WalletConnect initialization failed: ".concat(evt.error || "Unknown error"), TurnkeyErrorCodes.WALLET_CONNECT_INITIALIZATION_ERROR, evt.error));
1016
- return _context133.a(2);
1016
+ return _context135.a(2);
1017
1017
  case 2:
1018
1018
  if (!((evt === null || evt === void 0 ? void 0 : evt.type) === "initialized")) {
1019
- _context133.n = 7;
1019
+ _context135.n = 7;
1020
1020
  break;
1021
1021
  }
1022
- _context133.n = 3;
1022
+ _context135.n = 3;
1023
1023
  return debouncedFetchWalletProviders();
1024
1024
  case 3:
1025
- providers = _context133.v;
1026
- _context133.n = 4;
1025
+ providers = _context135.v;
1026
+ _context135.n = 4;
1027
1027
  return getSession();
1028
1028
  case 4:
1029
- currentSession = _context133.v;
1029
+ currentSession = _context135.v;
1030
1030
  if (!currentSession) {
1031
- _context133.n = 6;
1031
+ _context135.n = 6;
1032
1032
  break;
1033
1033
  }
1034
1034
  _wcProviders = providers === null || providers === void 0 ? void 0 : providers.filter(function (p) {
1035
1035
  return p.interfaceType === WalletInterfaceType.WalletConnect;
1036
1036
  });
1037
- _context133.n = 5;
1037
+ _context135.n = 5;
1038
1038
  return fetchWallets({
1039
1039
  walletProviders: _wcProviders,
1040
1040
  connectedOnly: true
1041
1041
  });
1042
1042
  case 5:
1043
- wcWallets = _context133.v;
1043
+ wcWallets = _context135.v;
1044
1044
  if (wcWallets.length > 0) {
1045
1045
  setWallets(function (prev) {
1046
1046
  return mergeWalletsWithoutDuplicates(prev, wcWallets);
1047
1047
  });
1048
1048
  }
1049
1049
  case 6:
1050
- return _context133.a(2);
1050
+ return _context135.a(2);
1051
1051
  case 7:
1052
- _context133.n = 8;
1052
+ _context135.n = 8;
1053
1053
  return onUpdateState();
1054
1054
  case 8:
1055
- return _context133.a(2);
1055
+ return _context135.a(2);
1056
1056
  }
1057
- }, _callee133);
1057
+ }, _callee135);
1058
1058
  }));
1059
- return function (_x112) {
1060
- return _ref155.apply(this, arguments);
1059
+ return function (_x113) {
1060
+ return _ref157.apply(this, arguments);
1061
1061
  };
1062
1062
  }());
1063
1063
  cleanups.push(unsubscribe);
1064
1064
  }
1065
1065
  }
1066
1066
  }
1067
- return _context134.a(2, function () {
1067
+ return _context136.a(2, function () {
1068
1068
  cleanups.forEach(function (remove) {
1069
1069
  return remove();
1070
1070
  });
1071
1071
  });
1072
1072
  }
1073
- }, _callee134);
1073
+ }, _callee136);
1074
1074
  }));
1075
1075
  return _initializeWalletProviderListeners.apply(this, arguments);
1076
1076
  }
@@ -2776,7 +2776,7 @@ var ClientProvider = function ClientProvider(_ref) {
2776
2776
  return _ref71.apply(this, arguments);
2777
2777
  };
2778
2778
  }(), [client, callbacks, logout]);
2779
- var signAndSendTransaction = useCallback(/*#__PURE__*/function () {
2779
+ var solSendTransaction = useCallback(/*#__PURE__*/function () {
2780
2780
  var _ref72 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee60(params) {
2781
2781
  return _regenerator().w(function (_context60) {
2782
2782
  while (1) switch (_context60.n) {
@@ -2788,10 +2788,10 @@ var ClientProvider = function ClientProvider(_ref) {
2788
2788
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2789
2789
  case 1:
2790
2790
  return _context60.a(2, withTurnkeyErrorHandling(function () {
2791
- return client.signAndSendTransaction(params);
2791
+ return client.solSendTransaction(params);
2792
2792
  }, function () {
2793
2793
  return logout();
2794
- }, callbacks, "Failed to sign and send transaction"));
2794
+ }, callbacks, "Failed to send sol transaction"));
2795
2795
  }
2796
2796
  }, _callee60);
2797
2797
  }));
@@ -2799,7 +2799,7 @@ var ClientProvider = function ClientProvider(_ref) {
2799
2799
  return _ref72.apply(this, arguments);
2800
2800
  };
2801
2801
  }(), [client, callbacks, logout]);
2802
- var pollTransactionStatus = useCallback(/*#__PURE__*/function () {
2802
+ var signAndSendTransaction = useCallback(/*#__PURE__*/function () {
2803
2803
  var _ref73 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee61(params) {
2804
2804
  return _regenerator().w(function (_context61) {
2805
2805
  while (1) switch (_context61.n) {
@@ -2811,18 +2811,18 @@ var ClientProvider = function ClientProvider(_ref) {
2811
2811
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2812
2812
  case 1:
2813
2813
  return _context61.a(2, withTurnkeyErrorHandling(function () {
2814
- return client.pollTransactionStatus(params);
2814
+ return client.signAndSendTransaction(params);
2815
2815
  }, function () {
2816
2816
  return logout();
2817
- }, callbacks, "Failed to poll transaction status"));
2817
+ }, callbacks, "Failed to sign and send transaction"));
2818
2818
  }
2819
2819
  }, _callee61);
2820
2820
  }));
2821
2821
  return function (_x48) {
2822
2822
  return _ref73.apply(this, arguments);
2823
2823
  };
2824
- }(), [client, callbacks]);
2825
- var fetchOrCreateP256ApiKeyUser = useCallback(/*#__PURE__*/function () {
2824
+ }(), [client, callbacks, logout]);
2825
+ var pollTransactionStatus = useCallback(/*#__PURE__*/function () {
2826
2826
  var _ref74 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee62(params) {
2827
2827
  return _regenerator().w(function (_context62) {
2828
2828
  while (1) switch (_context62.n) {
@@ -2834,18 +2834,18 @@ var ClientProvider = function ClientProvider(_ref) {
2834
2834
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2835
2835
  case 1:
2836
2836
  return _context62.a(2, withTurnkeyErrorHandling(function () {
2837
- return client.fetchOrCreateP256ApiKeyUser(params);
2837
+ return client.pollTransactionStatus(params);
2838
2838
  }, function () {
2839
2839
  return logout();
2840
- }, callbacks, "Failed to fetch or create delegated access user"));
2840
+ }, callbacks, "Failed to poll transaction status"));
2841
2841
  }
2842
2842
  }, _callee62);
2843
2843
  }));
2844
2844
  return function (_x49) {
2845
2845
  return _ref74.apply(this, arguments);
2846
2846
  };
2847
- }(), [client, callbacks, logout]);
2848
- var fetchOrCreatePolicies = useCallback(/*#__PURE__*/function () {
2847
+ }(), [client, callbacks]);
2848
+ var fetchOrCreateP256ApiKeyUser = useCallback(/*#__PURE__*/function () {
2849
2849
  var _ref75 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee63(params) {
2850
2850
  return _regenerator().w(function (_context63) {
2851
2851
  while (1) switch (_context63.n) {
@@ -2857,7 +2857,7 @@ var ClientProvider = function ClientProvider(_ref) {
2857
2857
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2858
2858
  case 1:
2859
2859
  return _context63.a(2, withTurnkeyErrorHandling(function () {
2860
- return client.fetchOrCreatePolicies(params);
2860
+ return client.fetchOrCreateP256ApiKeyUser(params);
2861
2861
  }, function () {
2862
2862
  return logout();
2863
2863
  }, callbacks, "Failed to fetch or create delegated access user"));
@@ -2868,9 +2868,8 @@ var ClientProvider = function ClientProvider(_ref) {
2868
2868
  return _ref75.apply(this, arguments);
2869
2869
  };
2870
2870
  }(), [client, callbacks, logout]);
2871
- var updateUserEmail = useCallback(/*#__PURE__*/function () {
2871
+ var fetchOrCreatePolicies = useCallback(/*#__PURE__*/function () {
2872
2872
  var _ref76 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee64(params) {
2873
- var res;
2874
2873
  return _regenerator().w(function (_context64) {
2875
2874
  while (1) switch (_context64.n) {
2876
2875
  case 0:
@@ -2880,36 +2879,19 @@ var ClientProvider = function ClientProvider(_ref) {
2880
2879
  }
2881
2880
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
2882
2881
  case 1:
2883
- _context64.n = 2;
2884
- return withTurnkeyErrorHandling(function () {
2885
- return client.updateUserEmail(params);
2882
+ return _context64.a(2, withTurnkeyErrorHandling(function () {
2883
+ return client.fetchOrCreatePolicies(params);
2886
2884
  }, function () {
2887
2885
  return logout();
2888
- }, callbacks, "Failed to update user email");
2889
- case 2:
2890
- res = _context64.v;
2891
- if (!res) {
2892
- _context64.n = 3;
2893
- break;
2894
- }
2895
- _context64.n = 3;
2896
- return maybeRefreshUser(_objectSpread2(_objectSpread2({
2897
- stampWith: params === null || params === void 0 ? void 0 : params.stampWith
2898
- }, (params === null || params === void 0 ? void 0 : params.organizationId) && {
2899
- organizationId: params.organizationId
2900
- }), (params === null || params === void 0 ? void 0 : params.userId) && {
2901
- userId: params.userId
2902
- }));
2903
- case 3:
2904
- return _context64.a(2, res);
2886
+ }, callbacks, "Failed to fetch or create delegated access user"));
2905
2887
  }
2906
2888
  }, _callee64);
2907
2889
  }));
2908
2890
  return function (_x51) {
2909
2891
  return _ref76.apply(this, arguments);
2910
2892
  };
2911
- }(), [client, callbacks, logout, maybeRefreshUser]);
2912
- var removeUserEmail = useCallback(/*#__PURE__*/function () {
2893
+ }(), [client, callbacks, logout]);
2894
+ var updateUserEmail = useCallback(/*#__PURE__*/function () {
2913
2895
  var _ref77 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee65(params) {
2914
2896
  var res;
2915
2897
  return _regenerator().w(function (_context65) {
@@ -2923,10 +2905,10 @@ var ClientProvider = function ClientProvider(_ref) {
2923
2905
  case 1:
2924
2906
  _context65.n = 2;
2925
2907
  return withTurnkeyErrorHandling(function () {
2926
- return client.removeUserEmail(params);
2908
+ return client.updateUserEmail(params);
2927
2909
  }, function () {
2928
2910
  return logout();
2929
- }, callbacks, "Failed to remove user email");
2911
+ }, callbacks, "Failed to update user email");
2930
2912
  case 2:
2931
2913
  res = _context65.v;
2932
2914
  if (!res) {
@@ -2950,7 +2932,7 @@ var ClientProvider = function ClientProvider(_ref) {
2950
2932
  return _ref77.apply(this, arguments);
2951
2933
  };
2952
2934
  }(), [client, callbacks, logout, maybeRefreshUser]);
2953
- var updateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
2935
+ var removeUserEmail = useCallback(/*#__PURE__*/function () {
2954
2936
  var _ref78 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee66(params) {
2955
2937
  var res;
2956
2938
  return _regenerator().w(function (_context66) {
@@ -2964,10 +2946,10 @@ var ClientProvider = function ClientProvider(_ref) {
2964
2946
  case 1:
2965
2947
  _context66.n = 2;
2966
2948
  return withTurnkeyErrorHandling(function () {
2967
- return client.updateUserPhoneNumber(params);
2949
+ return client.removeUserEmail(params);
2968
2950
  }, function () {
2969
2951
  return logout();
2970
- }, callbacks, "Failed to update user phone number");
2952
+ }, callbacks, "Failed to remove user email");
2971
2953
  case 2:
2972
2954
  res = _context66.v;
2973
2955
  if (!res) {
@@ -2991,7 +2973,7 @@ var ClientProvider = function ClientProvider(_ref) {
2991
2973
  return _ref78.apply(this, arguments);
2992
2974
  };
2993
2975
  }(), [client, callbacks, logout, maybeRefreshUser]);
2994
- var removeUserPhoneNumber = useCallback(/*#__PURE__*/function () {
2976
+ var updateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
2995
2977
  var _ref79 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee67(params) {
2996
2978
  var res;
2997
2979
  return _regenerator().w(function (_context67) {
@@ -3005,10 +2987,10 @@ var ClientProvider = function ClientProvider(_ref) {
3005
2987
  case 1:
3006
2988
  _context67.n = 2;
3007
2989
  return withTurnkeyErrorHandling(function () {
3008
- return client.removeUserPhoneNumber(params);
2990
+ return client.updateUserPhoneNumber(params);
3009
2991
  }, function () {
3010
2992
  return logout();
3011
- }, callbacks, "Failed to remove user phone number");
2993
+ }, callbacks, "Failed to update user phone number");
3012
2994
  case 2:
3013
2995
  res = _context67.v;
3014
2996
  if (!res) {
@@ -3032,7 +3014,7 @@ var ClientProvider = function ClientProvider(_ref) {
3032
3014
  return _ref79.apply(this, arguments);
3033
3015
  };
3034
3016
  }(), [client, callbacks, logout, maybeRefreshUser]);
3035
- var updateUserName = useCallback(/*#__PURE__*/function () {
3017
+ var removeUserPhoneNumber = useCallback(/*#__PURE__*/function () {
3036
3018
  var _ref80 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee68(params) {
3037
3019
  var res;
3038
3020
  return _regenerator().w(function (_context68) {
@@ -3046,10 +3028,10 @@ var ClientProvider = function ClientProvider(_ref) {
3046
3028
  case 1:
3047
3029
  _context68.n = 2;
3048
3030
  return withTurnkeyErrorHandling(function () {
3049
- return client.updateUserName(params);
3031
+ return client.removeUserPhoneNumber(params);
3050
3032
  }, function () {
3051
3033
  return logout();
3052
- }, callbacks, "Failed to update user name");
3034
+ }, callbacks, "Failed to remove user phone number");
3053
3035
  case 2:
3054
3036
  res = _context68.v;
3055
3037
  if (!res) {
@@ -3073,7 +3055,7 @@ var ClientProvider = function ClientProvider(_ref) {
3073
3055
  return _ref80.apply(this, arguments);
3074
3056
  };
3075
3057
  }(), [client, callbacks, logout, maybeRefreshUser]);
3076
- var addOauthProvider = useCallback(/*#__PURE__*/function () {
3058
+ var updateUserName = useCallback(/*#__PURE__*/function () {
3077
3059
  var _ref81 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee69(params) {
3078
3060
  var res;
3079
3061
  return _regenerator().w(function (_context69) {
@@ -3087,10 +3069,10 @@ var ClientProvider = function ClientProvider(_ref) {
3087
3069
  case 1:
3088
3070
  _context69.n = 2;
3089
3071
  return withTurnkeyErrorHandling(function () {
3090
- return client.addOauthProvider(params);
3072
+ return client.updateUserName(params);
3091
3073
  }, function () {
3092
3074
  return logout();
3093
- }, callbacks, "Failed to add OAuth provider");
3075
+ }, callbacks, "Failed to update user name");
3094
3076
  case 2:
3095
3077
  res = _context69.v;
3096
3078
  if (!res) {
@@ -3114,7 +3096,7 @@ var ClientProvider = function ClientProvider(_ref) {
3114
3096
  return _ref81.apply(this, arguments);
3115
3097
  };
3116
3098
  }(), [client, callbacks, logout, maybeRefreshUser]);
3117
- var removeOauthProviders = useCallback(/*#__PURE__*/function () {
3099
+ var addOauthProvider = useCallback(/*#__PURE__*/function () {
3118
3100
  var _ref82 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee70(params) {
3119
3101
  var res;
3120
3102
  return _regenerator().w(function (_context70) {
@@ -3128,10 +3110,10 @@ var ClientProvider = function ClientProvider(_ref) {
3128
3110
  case 1:
3129
3111
  _context70.n = 2;
3130
3112
  return withTurnkeyErrorHandling(function () {
3131
- return client.removeOauthProviders(params);
3113
+ return client.addOauthProvider(params);
3132
3114
  }, function () {
3133
3115
  return logout();
3134
- }, callbacks, "Failed to remove OAuth providers");
3116
+ }, callbacks, "Failed to add OAuth provider");
3135
3117
  case 2:
3136
3118
  res = _context70.v;
3137
3119
  if (!res) {
@@ -3155,7 +3137,7 @@ var ClientProvider = function ClientProvider(_ref) {
3155
3137
  return _ref82.apply(this, arguments);
3156
3138
  };
3157
3139
  }(), [client, callbacks, logout, maybeRefreshUser]);
3158
- var addPasskey = useCallback(/*#__PURE__*/function () {
3140
+ var removeOauthProviders = useCallback(/*#__PURE__*/function () {
3159
3141
  var _ref83 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee71(params) {
3160
3142
  var res;
3161
3143
  return _regenerator().w(function (_context71) {
@@ -3169,10 +3151,10 @@ var ClientProvider = function ClientProvider(_ref) {
3169
3151
  case 1:
3170
3152
  _context71.n = 2;
3171
3153
  return withTurnkeyErrorHandling(function () {
3172
- return client.addPasskey(params);
3154
+ return client.removeOauthProviders(params);
3173
3155
  }, function () {
3174
3156
  return logout();
3175
- }, callbacks, "Failed to add passkey");
3157
+ }, callbacks, "Failed to remove OAuth providers");
3176
3158
  case 2:
3177
3159
  res = _context71.v;
3178
3160
  if (!res) {
@@ -3196,7 +3178,7 @@ var ClientProvider = function ClientProvider(_ref) {
3196
3178
  return _ref83.apply(this, arguments);
3197
3179
  };
3198
3180
  }(), [client, callbacks, logout, maybeRefreshUser]);
3199
- var removePasskeys = useCallback(/*#__PURE__*/function () {
3181
+ var addPasskey = useCallback(/*#__PURE__*/function () {
3200
3182
  var _ref84 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee72(params) {
3201
3183
  var res;
3202
3184
  return _regenerator().w(function (_context72) {
@@ -3210,10 +3192,10 @@ var ClientProvider = function ClientProvider(_ref) {
3210
3192
  case 1:
3211
3193
  _context72.n = 2;
3212
3194
  return withTurnkeyErrorHandling(function () {
3213
- return client.removePasskeys(params);
3195
+ return client.addPasskey(params);
3214
3196
  }, function () {
3215
3197
  return logout();
3216
- }, callbacks, "Failed to remove passkeys");
3198
+ }, callbacks, "Failed to add passkey");
3217
3199
  case 2:
3218
3200
  res = _context72.v;
3219
3201
  if (!res) {
@@ -3237,9 +3219,9 @@ var ClientProvider = function ClientProvider(_ref) {
3237
3219
  return _ref84.apply(this, arguments);
3238
3220
  };
3239
3221
  }(), [client, callbacks, logout, maybeRefreshUser]);
3240
- var createWallet = useCallback(/*#__PURE__*/function () {
3222
+ var removePasskeys = useCallback(/*#__PURE__*/function () {
3241
3223
  var _ref85 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee73(params) {
3242
- var res, s;
3224
+ var res;
3243
3225
  return _regenerator().w(function (_context73) {
3244
3226
  while (1) switch (_context73.n) {
3245
3227
  case 0:
@@ -3251,27 +3233,25 @@ var ClientProvider = function ClientProvider(_ref) {
3251
3233
  case 1:
3252
3234
  _context73.n = 2;
3253
3235
  return withTurnkeyErrorHandling(function () {
3254
- return client.createWallet(params);
3236
+ return client.removePasskeys(params);
3255
3237
  }, function () {
3256
3238
  return logout();
3257
- }, callbacks, "Failed to create wallet");
3239
+ }, callbacks, "Failed to remove passkeys");
3258
3240
  case 2:
3259
3241
  res = _context73.v;
3260
- _context73.n = 3;
3261
- return getSession();
3262
- case 3:
3263
- s = _context73.v;
3264
- if (!(res && s)) {
3265
- _context73.n = 4;
3242
+ if (!res) {
3243
+ _context73.n = 3;
3266
3244
  break;
3267
3245
  }
3268
- _context73.n = 4;
3269
- return maybeRefreshWallets(_objectSpread2({
3246
+ _context73.n = 3;
3247
+ return maybeRefreshUser(_objectSpread2(_objectSpread2({
3270
3248
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
3271
3249
  }, (params === null || params === void 0 ? void 0 : params.organizationId) && {
3272
3250
  organizationId: params.organizationId
3251
+ }), (params === null || params === void 0 ? void 0 : params.userId) && {
3252
+ userId: params.userId
3273
3253
  }));
3274
- case 4:
3254
+ case 3:
3275
3255
  return _context73.a(2, res);
3276
3256
  }
3277
3257
  }, _callee73);
@@ -3279,8 +3259,8 @@ var ClientProvider = function ClientProvider(_ref) {
3279
3259
  return function (_x60) {
3280
3260
  return _ref85.apply(this, arguments);
3281
3261
  };
3282
- }(), [client, session, callbacks, logout, maybeRefreshWallets, getSession]);
3283
- var createWalletAccounts = useCallback(/*#__PURE__*/function () {
3262
+ }(), [client, callbacks, logout, maybeRefreshUser]);
3263
+ var createWallet = useCallback(/*#__PURE__*/function () {
3284
3264
  var _ref86 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee74(params) {
3285
3265
  var res, s;
3286
3266
  return _regenerator().w(function (_context74) {
@@ -3294,10 +3274,10 @@ var ClientProvider = function ClientProvider(_ref) {
3294
3274
  case 1:
3295
3275
  _context74.n = 2;
3296
3276
  return withTurnkeyErrorHandling(function () {
3297
- return client.createWalletAccounts(params);
3277
+ return client.createWallet(params);
3298
3278
  }, function () {
3299
3279
  return logout();
3300
- }, callbacks, "Failed to create wallet accounts");
3280
+ }, callbacks, "Failed to create wallet");
3301
3281
  case 2:
3302
3282
  res = _context74.v;
3303
3283
  _context74.n = 3;
@@ -3322,8 +3302,8 @@ var ClientProvider = function ClientProvider(_ref) {
3322
3302
  return function (_x61) {
3323
3303
  return _ref86.apply(this, arguments);
3324
3304
  };
3325
- }(), [client, session, callbacks, logout, getSession, maybeRefreshWallets]);
3326
- var exportWallet = useCallback(/*#__PURE__*/function () {
3305
+ }(), [client, session, callbacks, logout, maybeRefreshWallets, getSession]);
3306
+ var createWalletAccounts = useCallback(/*#__PURE__*/function () {
3327
3307
  var _ref87 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee75(params) {
3328
3308
  var res, s;
3329
3309
  return _regenerator().w(function (_context75) {
@@ -3337,10 +3317,10 @@ var ClientProvider = function ClientProvider(_ref) {
3337
3317
  case 1:
3338
3318
  _context75.n = 2;
3339
3319
  return withTurnkeyErrorHandling(function () {
3340
- return client.exportWallet(params);
3320
+ return client.createWalletAccounts(params);
3341
3321
  }, function () {
3342
3322
  return logout();
3343
- }, callbacks, "Failed to export wallet");
3323
+ }, callbacks, "Failed to create wallet accounts");
3344
3324
  case 2:
3345
3325
  res = _context75.v;
3346
3326
  _context75.n = 3;
@@ -3366,9 +3346,9 @@ var ClientProvider = function ClientProvider(_ref) {
3366
3346
  return _ref87.apply(this, arguments);
3367
3347
  };
3368
3348
  }(), [client, session, callbacks, logout, getSession, maybeRefreshWallets]);
3369
- var exportPrivateKey = useCallback(/*#__PURE__*/function () {
3349
+ var exportWallet = useCallback(/*#__PURE__*/function () {
3370
3350
  var _ref88 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee76(params) {
3371
- var res;
3351
+ var res, s;
3372
3352
  return _regenerator().w(function (_context76) {
3373
3353
  while (1) switch (_context76.n) {
3374
3354
  case 0:
@@ -3380,12 +3360,27 @@ var ClientProvider = function ClientProvider(_ref) {
3380
3360
  case 1:
3381
3361
  _context76.n = 2;
3382
3362
  return withTurnkeyErrorHandling(function () {
3383
- return client.exportPrivateKey(params);
3363
+ return client.exportWallet(params);
3384
3364
  }, function () {
3385
3365
  return logout();
3386
- }, callbacks, "Failed to export private key");
3366
+ }, callbacks, "Failed to export wallet");
3387
3367
  case 2:
3388
3368
  res = _context76.v;
3369
+ _context76.n = 3;
3370
+ return getSession();
3371
+ case 3:
3372
+ s = _context76.v;
3373
+ if (!(res && s)) {
3374
+ _context76.n = 4;
3375
+ break;
3376
+ }
3377
+ _context76.n = 4;
3378
+ return maybeRefreshWallets(_objectSpread2({
3379
+ stampWith: params === null || params === void 0 ? void 0 : params.stampWith
3380
+ }, (params === null || params === void 0 ? void 0 : params.organizationId) && {
3381
+ organizationId: params.organizationId
3382
+ }));
3383
+ case 4:
3389
3384
  return _context76.a(2, res);
3390
3385
  }
3391
3386
  }, _callee76);
@@ -3393,10 +3388,10 @@ var ClientProvider = function ClientProvider(_ref) {
3393
3388
  return function (_x63) {
3394
3389
  return _ref88.apply(this, arguments);
3395
3390
  };
3396
- }(), [client, callbacks, logout]);
3397
- var exportWalletAccount = useCallback(/*#__PURE__*/function () {
3391
+ }(), [client, session, callbacks, logout, getSession, maybeRefreshWallets]);
3392
+ var exportPrivateKey = useCallback(/*#__PURE__*/function () {
3398
3393
  var _ref89 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee77(params) {
3399
- var res, s;
3394
+ var res;
3400
3395
  return _regenerator().w(function (_context77) {
3401
3396
  while (1) switch (_context77.n) {
3402
3397
  case 0:
@@ -3408,27 +3403,12 @@ var ClientProvider = function ClientProvider(_ref) {
3408
3403
  case 1:
3409
3404
  _context77.n = 2;
3410
3405
  return withTurnkeyErrorHandling(function () {
3411
- return client.exportWalletAccount(params);
3406
+ return client.exportPrivateKey(params);
3412
3407
  }, function () {
3413
3408
  return logout();
3414
- }, callbacks, "Failed to export wallet accounts");
3409
+ }, callbacks, "Failed to export private key");
3415
3410
  case 2:
3416
3411
  res = _context77.v;
3417
- _context77.n = 3;
3418
- return getSession();
3419
- case 3:
3420
- s = _context77.v;
3421
- if (!(res && s)) {
3422
- _context77.n = 4;
3423
- break;
3424
- }
3425
- _context77.n = 4;
3426
- return maybeRefreshWallets(_objectSpread2({
3427
- stampWith: params === null || params === void 0 ? void 0 : params.stampWith
3428
- }, (params === null || params === void 0 ? void 0 : params.organizationId) && {
3429
- organizationId: params.organizationId
3430
- }));
3431
- case 4:
3432
3412
  return _context77.a(2, res);
3433
3413
  }
3434
3414
  }, _callee77);
@@ -3436,8 +3416,8 @@ var ClientProvider = function ClientProvider(_ref) {
3436
3416
  return function (_x64) {
3437
3417
  return _ref89.apply(this, arguments);
3438
3418
  };
3439
- }(), [client, callbacks, logout, getSession, maybeRefreshWallets]);
3440
- var importWallet = useCallback(/*#__PURE__*/function () {
3419
+ }(), [client, callbacks, logout]);
3420
+ var exportWalletAccount = useCallback(/*#__PURE__*/function () {
3441
3421
  var _ref90 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee78(params) {
3442
3422
  var res, s;
3443
3423
  return _regenerator().w(function (_context78) {
@@ -3451,10 +3431,10 @@ var ClientProvider = function ClientProvider(_ref) {
3451
3431
  case 1:
3452
3432
  _context78.n = 2;
3453
3433
  return withTurnkeyErrorHandling(function () {
3454
- return client.importWallet(params);
3434
+ return client.exportWalletAccount(params);
3455
3435
  }, function () {
3456
3436
  return logout();
3457
- }, callbacks, "Failed to import wallet");
3437
+ }, callbacks, "Failed to export wallet accounts");
3458
3438
  case 2:
3459
3439
  res = _context78.v;
3460
3440
  _context78.n = 3;
@@ -3466,12 +3446,10 @@ var ClientProvider = function ClientProvider(_ref) {
3466
3446
  break;
3467
3447
  }
3468
3448
  _context78.n = 4;
3469
- return maybeRefreshWallets(_objectSpread2(_objectSpread2({
3449
+ return maybeRefreshWallets(_objectSpread2({
3470
3450
  stampWith: params === null || params === void 0 ? void 0 : params.stampWith
3471
3451
  }, (params === null || params === void 0 ? void 0 : params.organizationId) && {
3472
3452
  organizationId: params.organizationId
3473
- }), (params === null || params === void 0 ? void 0 : params.userId) && {
3474
- userId: params.userId
3475
3453
  }));
3476
3454
  case 4:
3477
3455
  return _context78.a(2, res);
@@ -3482,9 +3460,9 @@ var ClientProvider = function ClientProvider(_ref) {
3482
3460
  return _ref90.apply(this, arguments);
3483
3461
  };
3484
3462
  }(), [client, callbacks, logout, getSession, maybeRefreshWallets]);
3485
- var importPrivateKey = useCallback(/*#__PURE__*/function () {
3463
+ var importWallet = useCallback(/*#__PURE__*/function () {
3486
3464
  var _ref91 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee79(params) {
3487
- var res;
3465
+ var res, s;
3488
3466
  return _regenerator().w(function (_context79) {
3489
3467
  while (1) switch (_context79.n) {
3490
3468
  case 0:
@@ -3496,12 +3474,29 @@ var ClientProvider = function ClientProvider(_ref) {
3496
3474
  case 1:
3497
3475
  _context79.n = 2;
3498
3476
  return withTurnkeyErrorHandling(function () {
3499
- return client.importPrivateKey(params);
3477
+ return client.importWallet(params);
3500
3478
  }, function () {
3501
3479
  return logout();
3502
- }, callbacks, "Failed to import private key");
3480
+ }, callbacks, "Failed to import wallet");
3503
3481
  case 2:
3504
3482
  res = _context79.v;
3483
+ _context79.n = 3;
3484
+ return getSession();
3485
+ case 3:
3486
+ s = _context79.v;
3487
+ if (!(res && s)) {
3488
+ _context79.n = 4;
3489
+ break;
3490
+ }
3491
+ _context79.n = 4;
3492
+ return maybeRefreshWallets(_objectSpread2(_objectSpread2({
3493
+ stampWith: params === null || params === void 0 ? void 0 : params.stampWith
3494
+ }, (params === null || params === void 0 ? void 0 : params.organizationId) && {
3495
+ organizationId: params.organizationId
3496
+ }), (params === null || params === void 0 ? void 0 : params.userId) && {
3497
+ userId: params.userId
3498
+ }));
3499
+ case 4:
3505
3500
  return _context79.a(2, res);
3506
3501
  }
3507
3502
  }, _callee79);
@@ -3509,9 +3504,10 @@ var ClientProvider = function ClientProvider(_ref) {
3509
3504
  return function (_x66) {
3510
3505
  return _ref91.apply(this, arguments);
3511
3506
  };
3512
- }(), [client, callbacks, logout]);
3513
- var deleteSubOrganization = useCallback(/*#__PURE__*/function () {
3507
+ }(), [client, callbacks, logout, getSession, maybeRefreshWallets]);
3508
+ var importPrivateKey = useCallback(/*#__PURE__*/function () {
3514
3509
  var _ref92 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee80(params) {
3510
+ var res;
3515
3511
  return _regenerator().w(function (_context80) {
3516
3512
  while (1) switch (_context80.n) {
3517
3513
  case 0:
@@ -3521,11 +3517,15 @@ var ClientProvider = function ClientProvider(_ref) {
3521
3517
  }
3522
3518
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3523
3519
  case 1:
3524
- return _context80.a(2, withTurnkeyErrorHandling(function () {
3525
- return client.deleteSubOrganization(params);
3520
+ _context80.n = 2;
3521
+ return withTurnkeyErrorHandling(function () {
3522
+ return client.importPrivateKey(params);
3526
3523
  }, function () {
3527
3524
  return logout();
3528
- }, callbacks, "Failed to delete sub-organization"));
3525
+ }, callbacks, "Failed to import private key");
3526
+ case 2:
3527
+ res = _context80.v;
3528
+ return _context80.a(2, res);
3529
3529
  }
3530
3530
  }, _callee80);
3531
3531
  }));
@@ -3533,9 +3533,8 @@ var ClientProvider = function ClientProvider(_ref) {
3533
3533
  return _ref92.apply(this, arguments);
3534
3534
  };
3535
3535
  }(), [client, callbacks, logout]);
3536
- var storeSession = useCallback(/*#__PURE__*/function () {
3536
+ var deleteSubOrganization = useCallback(/*#__PURE__*/function () {
3537
3537
  var _ref93 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee81(params) {
3538
- var sessionKey, session, allSessions;
3539
3538
  return _regenerator().w(function (_context81) {
3540
3539
  while (1) switch (_context81.n) {
3541
3540
  case 0:
@@ -3545,56 +3544,80 @@ var ClientProvider = function ClientProvider(_ref) {
3545
3544
  }
3546
3545
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3547
3546
  case 1:
3548
- _context81.n = 2;
3547
+ return _context81.a(2, withTurnkeyErrorHandling(function () {
3548
+ return client.deleteSubOrganization(params);
3549
+ }, function () {
3550
+ return logout();
3551
+ }, callbacks, "Failed to delete sub-organization"));
3552
+ }
3553
+ }, _callee81);
3554
+ }));
3555
+ return function (_x68) {
3556
+ return _ref93.apply(this, arguments);
3557
+ };
3558
+ }(), [client, callbacks, logout]);
3559
+ var storeSession = useCallback(/*#__PURE__*/function () {
3560
+ var _ref94 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee82(params) {
3561
+ var sessionKey, session, allSessions;
3562
+ return _regenerator().w(function (_context82) {
3563
+ while (1) switch (_context82.n) {
3564
+ case 0:
3565
+ if (client) {
3566
+ _context82.n = 1;
3567
+ break;
3568
+ }
3569
+ throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3570
+ case 1:
3571
+ _context82.n = 2;
3549
3572
  return withTurnkeyErrorHandling(function () {
3550
3573
  return client.storeSession(params);
3551
3574
  }, function () {
3552
3575
  return logout();
3553
3576
  }, callbacks, "Failed to store session");
3554
3577
  case 2:
3555
- _context81.n = 3;
3578
+ _context82.n = 3;
3556
3579
  return getActiveSessionKey();
3557
3580
  case 3:
3558
- sessionKey = _context81.v;
3559
- _context81.n = 4;
3581
+ sessionKey = _context82.v;
3582
+ _context82.n = 4;
3560
3583
  return getSession(_objectSpread2({}, sessionKey && {
3561
3584
  sessionKey: sessionKey
3562
3585
  }));
3563
3586
  case 4:
3564
- session = _context81.v;
3587
+ session = _context82.v;
3565
3588
  if (!(session && sessionKey)) {
3566
- _context81.n = 5;
3589
+ _context82.n = 5;
3567
3590
  break;
3568
3591
  }
3569
- _context81.n = 5;
3592
+ _context82.n = 5;
3570
3593
  return scheduleSessionExpiration({
3571
3594
  sessionKey: sessionKey,
3572
3595
  expiry: session.expiry
3573
3596
  });
3574
3597
  case 5:
3575
- _context81.n = 6;
3598
+ _context82.n = 6;
3576
3599
  return getAllSessions();
3577
3600
  case 6:
3578
- allSessions = _context81.v;
3601
+ allSessions = _context82.v;
3579
3602
  setSession(session);
3580
3603
  setAllSessions(allSessions);
3581
- _context81.n = 7;
3604
+ _context82.n = 7;
3582
3605
  return Promise.all([maybeRefreshWallets(), maybeRefreshUser()]);
3583
3606
  case 7:
3584
- return _context81.a(2);
3607
+ return _context82.a(2);
3585
3608
  }
3586
- }, _callee81);
3609
+ }, _callee82);
3587
3610
  }));
3588
- return function (_x68) {
3589
- return _ref93.apply(this, arguments);
3611
+ return function (_x69) {
3612
+ return _ref94.apply(this, arguments);
3590
3613
  };
3591
3614
  }(), [client, callbacks, logout, getActiveSessionKey, getSession, scheduleSessionExpiration, getAllSessions, maybeRefreshWallets, maybeRefreshUser]);
3592
- var clearAllSessions = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee82() {
3593
- return _regenerator().w(function (_context82) {
3594
- while (1) switch (_context82.n) {
3615
+ var clearAllSessions = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee83() {
3616
+ return _regenerator().w(function (_context83) {
3617
+ while (1) switch (_context83.n) {
3595
3618
  case 0:
3596
3619
  if (client) {
3597
- _context82.n = 1;
3620
+ _context83.n = 1;
3598
3621
  break;
3599
3622
  }
3600
3623
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
@@ -3602,30 +3625,30 @@ var ClientProvider = function ClientProvider(_ref) {
3602
3625
  setSession(undefined);
3603
3626
  setAllSessions(undefined);
3604
3627
  clearSessionTimeouts();
3605
- _context82.n = 2;
3628
+ _context83.n = 2;
3606
3629
  return withTurnkeyErrorHandling(function () {
3607
3630
  return client.clearAllSessions();
3608
3631
  }, function () {
3609
3632
  return logout();
3610
3633
  }, callbacks, "Failed to clear all sessions");
3611
3634
  case 2:
3612
- return _context82.a(2, _context82.v);
3635
+ return _context83.a(2, _context83.v);
3613
3636
  }
3614
- }, _callee82);
3637
+ }, _callee83);
3615
3638
  })), [client, callbacks, logout, clearSessionTimeouts]);
3616
3639
  var setActiveSession = useCallback(/*#__PURE__*/function () {
3617
- var _ref95 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee84(params) {
3640
+ var _ref96 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee85(params) {
3618
3641
  var session, s;
3619
- return _regenerator().w(function (_context84) {
3620
- while (1) switch (_context84.n) {
3642
+ return _regenerator().w(function (_context85) {
3643
+ while (1) switch (_context85.n) {
3621
3644
  case 0:
3622
3645
  if (client) {
3623
- _context84.n = 1;
3646
+ _context85.n = 1;
3624
3647
  break;
3625
3648
  }
3626
3649
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3627
3650
  case 1:
3628
- _context84.n = 2;
3651
+ _context85.n = 2;
3629
3652
  return withTurnkeyErrorHandling(function () {
3630
3653
  return client.getSession({
3631
3654
  sessionKey: params.sessionKey
@@ -3634,18 +3657,18 @@ var ClientProvider = function ClientProvider(_ref) {
3634
3657
  return logout();
3635
3658
  }, callbacks, "Failed to get session");
3636
3659
  case 2:
3637
- session = _context84.v;
3638
- _context84.n = 3;
3660
+ session = _context85.v;
3661
+ _context85.n = 3;
3639
3662
  return getSession();
3640
3663
  case 3:
3641
- s = _context84.v;
3664
+ s = _context85.v;
3642
3665
  if (s) {
3643
- _context84.n = 4;
3666
+ _context85.n = 4;
3644
3667
  break;
3645
3668
  }
3646
3669
  throw new TurnkeyError("Session not found.", TurnkeyErrorCodes.NOT_FOUND);
3647
3670
  case 4:
3648
- _context84.n = 5;
3671
+ _context85.n = 5;
3649
3672
  return withTurnkeyErrorHandling(function () {
3650
3673
  return client.setActiveSession(params);
3651
3674
  }, function () {
@@ -3653,172 +3676,172 @@ var ClientProvider = function ClientProvider(_ref) {
3653
3676
  }, callbacks, "Failed to set active session");
3654
3677
  case 5:
3655
3678
  setSession(session);
3656
- _context84.n = 6;
3657
- return withTurnkeyErrorHandling(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee83() {
3658
- return _regenerator().w(function (_context83) {
3659
- while (1) switch (_context83.n) {
3679
+ _context85.n = 6;
3680
+ return withTurnkeyErrorHandling(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee84() {
3681
+ return _regenerator().w(function (_context84) {
3682
+ while (1) switch (_context84.n) {
3660
3683
  case 0:
3661
- _context83.n = 1;
3684
+ _context84.n = 1;
3662
3685
  return Promise.all([maybeRefreshWallets(), maybeRefreshUser()]);
3663
3686
  case 1:
3664
- return _context83.a(2);
3687
+ return _context84.a(2);
3665
3688
  }
3666
- }, _callee83);
3689
+ }, _callee84);
3667
3690
  })), function () {
3668
3691
  return logout();
3669
3692
  }, callbacks, "Failed to refresh data after setting active session");
3670
3693
  case 6:
3671
- return _context84.a(2);
3694
+ return _context85.a(2);
3672
3695
  }
3673
- }, _callee84);
3696
+ }, _callee85);
3674
3697
  }));
3675
- return function (_x69) {
3676
- return _ref95.apply(this, arguments);
3698
+ return function (_x70) {
3699
+ return _ref96.apply(this, arguments);
3677
3700
  };
3678
3701
  }(), [client, callbacks, logout, getSession, maybeRefreshWallets, maybeRefreshUser]);
3679
- var clearUnusedKeyPairs = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee85() {
3680
- return _regenerator().w(function (_context85) {
3681
- while (1) switch (_context85.n) {
3702
+ var clearUnusedKeyPairs = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee86() {
3703
+ return _regenerator().w(function (_context86) {
3704
+ while (1) switch (_context86.n) {
3682
3705
  case 0:
3683
3706
  if (client) {
3684
- _context85.n = 1;
3707
+ _context86.n = 1;
3685
3708
  break;
3686
3709
  }
3687
3710
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3688
3711
  case 1:
3689
- return _context85.a(2, withTurnkeyErrorHandling(function () {
3712
+ return _context86.a(2, withTurnkeyErrorHandling(function () {
3690
3713
  return client.clearUnusedKeyPairs();
3691
3714
  }, undefined, callbacks, "Failed to clear unused key pairs"));
3692
3715
  }
3693
- }, _callee85);
3716
+ }, _callee86);
3694
3717
  })), [client, callbacks]);
3695
3718
  var createApiKeyPair = useCallback(/*#__PURE__*/function () {
3696
- var _ref98 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee86(params) {
3697
- return _regenerator().w(function (_context86) {
3698
- while (1) switch (_context86.n) {
3719
+ var _ref99 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee87(params) {
3720
+ return _regenerator().w(function (_context87) {
3721
+ while (1) switch (_context87.n) {
3699
3722
  case 0:
3700
3723
  if (client) {
3701
- _context86.n = 1;
3724
+ _context87.n = 1;
3702
3725
  break;
3703
3726
  }
3704
3727
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3705
3728
  case 1:
3706
- return _context86.a(2, withTurnkeyErrorHandling(function () {
3729
+ return _context87.a(2, withTurnkeyErrorHandling(function () {
3707
3730
  return client.createApiKeyPair(params);
3708
3731
  }, undefined, callbacks, "Failed to create API key pair"));
3709
3732
  }
3710
- }, _callee86);
3733
+ }, _callee87);
3711
3734
  }));
3712
- return function (_x70) {
3713
- return _ref98.apply(this, arguments);
3735
+ return function (_x71) {
3736
+ return _ref99.apply(this, arguments);
3714
3737
  };
3715
3738
  }(), [client, callbacks]);
3716
- var getProxyAuthConfig = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee87() {
3717
- return _regenerator().w(function (_context87) {
3718
- while (1) switch (_context87.n) {
3739
+ var getProxyAuthConfig = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee88() {
3740
+ return _regenerator().w(function (_context88) {
3741
+ while (1) switch (_context88.n) {
3719
3742
  case 0:
3720
3743
  if (client) {
3721
- _context87.n = 1;
3744
+ _context88.n = 1;
3722
3745
  break;
3723
3746
  }
3724
3747
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3725
3748
  case 1:
3726
- return _context87.a(2, withTurnkeyErrorHandling(function () {
3749
+ return _context88.a(2, withTurnkeyErrorHandling(function () {
3727
3750
  return client.getProxyAuthConfig();
3728
3751
  }, undefined, callbacks, "Failed to get proxy auth config"));
3729
3752
  }
3730
- }, _callee87);
3753
+ }, _callee88);
3731
3754
  })), [client, callbacks]);
3732
3755
  var fetchBootProofForAppProof = useCallback(/*#__PURE__*/function () {
3733
- var _ref100 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee88(params) {
3734
- return _regenerator().w(function (_context88) {
3735
- while (1) switch (_context88.n) {
3756
+ var _ref101 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee89(params) {
3757
+ return _regenerator().w(function (_context89) {
3758
+ while (1) switch (_context89.n) {
3736
3759
  case 0:
3737
3760
  if (client) {
3738
- _context88.n = 1;
3761
+ _context89.n = 1;
3739
3762
  break;
3740
3763
  }
3741
3764
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3742
3765
  case 1:
3743
- return _context88.a(2, withTurnkeyErrorHandling(function () {
3766
+ return _context89.a(2, withTurnkeyErrorHandling(function () {
3744
3767
  return client.fetchBootProofForAppProof(params);
3745
3768
  }, function () {
3746
3769
  return logout();
3747
3770
  }, callbacks, "Failed to fetch or create delegated access user"));
3748
3771
  }
3749
- }, _callee88);
3772
+ }, _callee89);
3750
3773
  }));
3751
- return function (_x71) {
3752
- return _ref100.apply(this, arguments);
3774
+ return function (_x72) {
3775
+ return _ref101.apply(this, arguments);
3753
3776
  };
3754
3777
  }(), [client, callbacks, logout]);
3755
3778
  var verifyAppProofs = useCallback(/*#__PURE__*/function () {
3756
- var _ref101 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee89(params) {
3757
- return _regenerator().w(function (_context89) {
3758
- while (1) switch (_context89.n) {
3779
+ var _ref102 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee90(params) {
3780
+ return _regenerator().w(function (_context90) {
3781
+ while (1) switch (_context90.n) {
3759
3782
  case 0:
3760
3783
  if (client) {
3761
- _context89.n = 1;
3784
+ _context90.n = 1;
3762
3785
  break;
3763
3786
  }
3764
3787
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
3765
3788
  case 1:
3766
- return _context89.a(2, withTurnkeyErrorHandling(function () {
3789
+ return _context90.a(2, withTurnkeyErrorHandling(function () {
3767
3790
  return client.verifyAppProofs(params);
3768
3791
  }, function () {
3769
3792
  return logout();
3770
3793
  }, callbacks, "Failed to verify app proofs"));
3771
3794
  }
3772
- }, _callee89);
3795
+ }, _callee90);
3773
3796
  }));
3774
- return function (_x72) {
3775
- return _ref101.apply(this, arguments);
3797
+ return function (_x73) {
3798
+ return _ref102.apply(this, arguments);
3776
3799
  };
3777
3800
  }(), [client, callbacks, logout]);
3778
3801
  var handleDiscordOauth = useCallback(/*#__PURE__*/function () {
3779
- var _ref102 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(params) {
3802
+ var _ref103 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee92(params) {
3780
3803
  var _masterConfig$auth21, _masterConfig$auth21$, _masterConfig$auth$oa2, _masterConfig$auth22, _masterConfig$auth22$, _masterConfig$auth23, _masterConfig$auth23$, _masterConfig$auth24;
3781
- var _ref103, _ref103$clientId, clientId, _ref103$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, authUrl, authWindow;
3782
- return _regenerator().w(function (_context91) {
3783
- while (1) switch (_context91.n) {
3804
+ var _ref104, _ref104$clientId, clientId, _ref104$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, authUrl, authWindow;
3805
+ return _regenerator().w(function (_context92) {
3806
+ while (1) switch (_context92.n) {
3784
3807
  case 0:
3785
- _ref103 = params || {}, _ref103$clientId = _ref103.clientId, clientId = _ref103$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth21 = masterConfig.auth) === null || _masterConfig$auth21 === void 0 ? void 0 : (_masterConfig$auth21$ = _masterConfig$auth21.oauthConfig) === null || _masterConfig$auth21$ === void 0 ? void 0 : _masterConfig$auth21$.discordClientId : _ref103$clientId, _ref103$openInPage = _ref103.openInPage, openInPage = _ref103$openInPage === void 0 ? (_masterConfig$auth$oa2 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth22 = masterConfig.auth) === null || _masterConfig$auth22 === void 0 ? void 0 : (_masterConfig$auth22$ = _masterConfig$auth22.oauthConfig) === null || _masterConfig$auth22$ === void 0 ? void 0 : _masterConfig$auth22$.openOauthInPage) !== null && _masterConfig$auth$oa2 !== void 0 ? _masterConfig$auth$oa2 : false : _ref103$openInPage, additionalParameters = _ref103.additionalState;
3808
+ _ref104 = params || {}, _ref104$clientId = _ref104.clientId, clientId = _ref104$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth21 = masterConfig.auth) === null || _masterConfig$auth21 === void 0 ? void 0 : (_masterConfig$auth21$ = _masterConfig$auth21.oauthConfig) === null || _masterConfig$auth21$ === void 0 ? void 0 : _masterConfig$auth21$.discordClientId : _ref104$clientId, _ref104$openInPage = _ref104.openInPage, openInPage = _ref104$openInPage === void 0 ? (_masterConfig$auth$oa2 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth22 = masterConfig.auth) === null || _masterConfig$auth22 === void 0 ? void 0 : (_masterConfig$auth22$ = _masterConfig$auth22.oauthConfig) === null || _masterConfig$auth22$ === void 0 ? void 0 : _masterConfig$auth22$.openOauthInPage) !== null && _masterConfig$auth$oa2 !== void 0 ? _masterConfig$auth$oa2 : false : _ref104$openInPage, additionalParameters = _ref104.additionalState;
3786
3809
  provider = OAuthProviders.DISCORD;
3787
3810
  if (masterConfig) {
3788
- _context91.n = 1;
3811
+ _context92.n = 1;
3789
3812
  break;
3790
3813
  }
3791
3814
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3792
3815
  case 1:
3793
3816
  if (clientId) {
3794
- _context91.n = 2;
3817
+ _context92.n = 2;
3795
3818
  break;
3796
3819
  }
3797
3820
  throw new TurnkeyError("Discord Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3798
3821
  case 2:
3799
3822
  if ((_masterConfig$auth23 = masterConfig.auth) !== null && _masterConfig$auth23 !== void 0 && (_masterConfig$auth23$ = _masterConfig$auth23.oauthConfig) !== null && _masterConfig$auth23$ !== void 0 && _masterConfig$auth23$.oauthRedirectUri) {
3800
- _context91.n = 3;
3823
+ _context92.n = 3;
3801
3824
  break;
3802
3825
  }
3803
3826
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3804
3827
  case 3:
3805
3828
  flow = openInPage ? "redirect" : "popup";
3806
3829
  redirectUri = (_masterConfig$auth24 = masterConfig.auth) === null || _masterConfig$auth24 === void 0 ? void 0 : _masterConfig$auth24.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3807
- _context91.n = 4;
3830
+ _context92.n = 4;
3808
3831
  return createApiKeyPair();
3809
3832
  case 4:
3810
- publicKey = _context91.v;
3833
+ publicKey = _context92.v;
3811
3834
  if (publicKey) {
3812
- _context91.n = 5;
3835
+ _context92.n = 5;
3813
3836
  break;
3814
3837
  }
3815
3838
  throw new Error("Failed to create public key for OAuth.");
3816
3839
  case 5:
3817
3840
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair and store verifier
3818
- _context91.n = 6;
3841
+ _context92.n = 6;
3819
3842
  return generateChallengePair();
3820
3843
  case 6:
3821
- _yield$generateChalle = _context91.v;
3844
+ _yield$generateChalle = _context92.v;
3822
3845
  verifier = _yield$generateChalle.verifier;
3823
3846
  codeChallenge = _yield$generateChalle.codeChallenge;
3824
3847
  storePKCEVerifier(provider, verifier);
@@ -3834,21 +3857,21 @@ var ClientProvider = function ClientProvider(_ref) {
3834
3857
  additionalState: additionalParameters
3835
3858
  });
3836
3859
  if (!openInPage) {
3837
- _context91.n = 7;
3860
+ _context92.n = 7;
3838
3861
  break;
3839
3862
  }
3840
- return _context91.a(2, redirectToOAuthProvider(authUrl));
3863
+ return _context92.a(2, redirectToOAuthProvider(authUrl));
3841
3864
  case 7:
3842
3865
  // Popup flow
3843
3866
  authWindow = openOAuthPopup();
3844
3867
  if (authWindow) {
3845
- _context91.n = 8;
3868
+ _context92.n = 8;
3846
3869
  break;
3847
3870
  }
3848
3871
  throw new Error("Failed to open ".concat(capitalizeProviderName(provider), " login window."));
3849
3872
  case 8:
3850
3873
  authWindow.location.href = authUrl;
3851
- return _context91.a(2, new Promise(function (resolve, reject) {
3874
+ return _context92.a(2, new Promise(function (resolve, reject) {
3852
3875
  var interval = setInterval(function () {
3853
3876
  try {
3854
3877
  if (authWindow.closed) {
@@ -3870,13 +3893,13 @@ var ClientProvider = function ClientProvider(_ref) {
3870
3893
  completeOauth: completeOauth,
3871
3894
  onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess,
3872
3895
  exchangeCodeForToken: function () {
3873
- var _exchangeCodeForToken = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee90(codeVerifier) {
3896
+ var _exchangeCodeForToken = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(codeVerifier) {
3874
3897
  var _resp$oidcToken;
3875
3898
  var resp;
3876
- return _regenerator().w(function (_context90) {
3877
- while (1) switch (_context90.n) {
3899
+ return _regenerator().w(function (_context91) {
3900
+ while (1) switch (_context91.n) {
3878
3901
  case 0:
3879
- _context90.n = 1;
3902
+ _context91.n = 1;
3880
3903
  return client === null || client === void 0 ? void 0 : client.httpClient.proxyOAuth2Authenticate({
3881
3904
  provider: "OAUTH2_PROVIDER_DISCORD",
3882
3905
  authCode: result.authCode,
@@ -3886,12 +3909,12 @@ var ClientProvider = function ClientProvider(_ref) {
3886
3909
  nonce: nonce
3887
3910
  });
3888
3911
  case 1:
3889
- resp = _context90.v;
3890
- return _context90.a(2, (_resp$oidcToken = resp === null || resp === void 0 ? void 0 : resp.oidcToken) !== null && _resp$oidcToken !== void 0 ? _resp$oidcToken : "");
3912
+ resp = _context91.v;
3913
+ return _context91.a(2, (_resp$oidcToken = resp === null || resp === void 0 ? void 0 : resp.oidcToken) !== null && _resp$oidcToken !== void 0 ? _resp$oidcToken : "");
3891
3914
  }
3892
- }, _callee90);
3915
+ }, _callee91);
3893
3916
  }));
3894
- function exchangeCodeForToken(_x74) {
3917
+ function exchangeCodeForToken(_x75) {
3895
3918
  return _exchangeCodeForToken.apply(this, arguments);
3896
3919
  }
3897
3920
  return exchangeCodeForToken;
@@ -3910,56 +3933,56 @@ var ClientProvider = function ClientProvider(_ref) {
3910
3933
  }
3911
3934
  }));
3912
3935
  }
3913
- }, _callee91);
3936
+ }, _callee92);
3914
3937
  }));
3915
- return function (_x73) {
3916
- return _ref102.apply(this, arguments);
3938
+ return function (_x74) {
3939
+ return _ref103.apply(this, arguments);
3917
3940
  };
3918
3941
  }(), [client, callbacks, completeOauth, createApiKeyPair, masterConfig]);
3919
3942
  var handleXOauth = useCallback(/*#__PURE__*/function () {
3920
- var _ref104 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(params) {
3943
+ var _ref105 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(params) {
3921
3944
  var _masterConfig$auth25, _masterConfig$auth25$, _masterConfig$auth$oa3, _masterConfig$auth26, _masterConfig$auth26$, _masterConfig$auth27, _masterConfig$auth27$, _masterConfig$auth28;
3922
- var _ref105, _ref105$clientId, clientId, _ref105$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, authUrl, authWindow;
3923
- return _regenerator().w(function (_context93) {
3924
- while (1) switch (_context93.n) {
3945
+ var _ref106, _ref106$clientId, clientId, _ref106$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, authUrl, authWindow;
3946
+ return _regenerator().w(function (_context94) {
3947
+ while (1) switch (_context94.n) {
3925
3948
  case 0:
3926
- _ref105 = params || {}, _ref105$clientId = _ref105.clientId, clientId = _ref105$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth25 = masterConfig.auth) === null || _masterConfig$auth25 === void 0 ? void 0 : (_masterConfig$auth25$ = _masterConfig$auth25.oauthConfig) === null || _masterConfig$auth25$ === void 0 ? void 0 : _masterConfig$auth25$.xClientId : _ref105$clientId, _ref105$openInPage = _ref105.openInPage, openInPage = _ref105$openInPage === void 0 ? (_masterConfig$auth$oa3 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth26 = masterConfig.auth) === null || _masterConfig$auth26 === void 0 ? void 0 : (_masterConfig$auth26$ = _masterConfig$auth26.oauthConfig) === null || _masterConfig$auth26$ === void 0 ? void 0 : _masterConfig$auth26$.openOauthInPage) !== null && _masterConfig$auth$oa3 !== void 0 ? _masterConfig$auth$oa3 : false : _ref105$openInPage, additionalParameters = _ref105.additionalState;
3949
+ _ref106 = params || {}, _ref106$clientId = _ref106.clientId, clientId = _ref106$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth25 = masterConfig.auth) === null || _masterConfig$auth25 === void 0 ? void 0 : (_masterConfig$auth25$ = _masterConfig$auth25.oauthConfig) === null || _masterConfig$auth25$ === void 0 ? void 0 : _masterConfig$auth25$.xClientId : _ref106$clientId, _ref106$openInPage = _ref106.openInPage, openInPage = _ref106$openInPage === void 0 ? (_masterConfig$auth$oa3 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth26 = masterConfig.auth) === null || _masterConfig$auth26 === void 0 ? void 0 : (_masterConfig$auth26$ = _masterConfig$auth26.oauthConfig) === null || _masterConfig$auth26$ === void 0 ? void 0 : _masterConfig$auth26$.openOauthInPage) !== null && _masterConfig$auth$oa3 !== void 0 ? _masterConfig$auth$oa3 : false : _ref106$openInPage, additionalParameters = _ref106.additionalState;
3927
3950
  provider = OAuthProviders.X;
3928
3951
  if (masterConfig) {
3929
- _context93.n = 1;
3952
+ _context94.n = 1;
3930
3953
  break;
3931
3954
  }
3932
3955
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3933
3956
  case 1:
3934
3957
  if (clientId) {
3935
- _context93.n = 2;
3958
+ _context94.n = 2;
3936
3959
  break;
3937
3960
  }
3938
3961
  throw new TurnkeyError("Twitter Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3939
3962
  case 2:
3940
3963
  if ((_masterConfig$auth27 = masterConfig.auth) !== null && _masterConfig$auth27 !== void 0 && (_masterConfig$auth27$ = _masterConfig$auth27.oauthConfig) !== null && _masterConfig$auth27$ !== void 0 && _masterConfig$auth27$.oauthRedirectUri) {
3941
- _context93.n = 3;
3964
+ _context94.n = 3;
3942
3965
  break;
3943
3966
  }
3944
3967
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
3945
3968
  case 3:
3946
3969
  flow = openInPage ? "redirect" : "popup";
3947
3970
  redirectUri = (_masterConfig$auth28 = masterConfig.auth) === null || _masterConfig$auth28 === void 0 ? void 0 : _masterConfig$auth28.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3948
- _context93.n = 4;
3971
+ _context94.n = 4;
3949
3972
  return createApiKeyPair();
3950
3973
  case 4:
3951
- publicKey = _context93.v;
3974
+ publicKey = _context94.v;
3952
3975
  if (publicKey) {
3953
- _context93.n = 5;
3976
+ _context94.n = 5;
3954
3977
  break;
3955
3978
  }
3956
3979
  throw new Error("Failed to create public key for OAuth.");
3957
3980
  case 5:
3958
3981
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair and store verifier
3959
- _context93.n = 6;
3982
+ _context94.n = 6;
3960
3983
  return generateChallengePair();
3961
3984
  case 6:
3962
- _yield$generateChalle2 = _context93.v;
3985
+ _yield$generateChalle2 = _context94.v;
3963
3986
  verifier = _yield$generateChalle2.verifier;
3964
3987
  codeChallenge = _yield$generateChalle2.codeChallenge;
3965
3988
  storePKCEVerifier(provider, verifier);
@@ -3975,21 +3998,21 @@ var ClientProvider = function ClientProvider(_ref) {
3975
3998
  additionalState: additionalParameters
3976
3999
  });
3977
4000
  if (!openInPage) {
3978
- _context93.n = 7;
4001
+ _context94.n = 7;
3979
4002
  break;
3980
4003
  }
3981
- return _context93.a(2, redirectToOAuthProvider(authUrl));
4004
+ return _context94.a(2, redirectToOAuthProvider(authUrl));
3982
4005
  case 7:
3983
4006
  // Popup flow
3984
4007
  authWindow = openOAuthPopup();
3985
4008
  if (authWindow) {
3986
- _context93.n = 8;
4009
+ _context94.n = 8;
3987
4010
  break;
3988
4011
  }
3989
4012
  throw new Error("Failed to open ".concat(capitalizeProviderName(provider), " login window."));
3990
4013
  case 8:
3991
4014
  authWindow.location.href = authUrl;
3992
- return _context93.a(2, new Promise(function (resolve, reject) {
4015
+ return _context94.a(2, new Promise(function (resolve, reject) {
3993
4016
  var interval = setInterval(function () {
3994
4017
  try {
3995
4018
  if (authWindow.closed) {
@@ -4011,13 +4034,13 @@ var ClientProvider = function ClientProvider(_ref) {
4011
4034
  completeOauth: completeOauth,
4012
4035
  onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess,
4013
4036
  exchangeCodeForToken: function () {
4014
- var _exchangeCodeForToken2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee92(codeVerifier) {
4037
+ var _exchangeCodeForToken2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(codeVerifier) {
4015
4038
  var _resp$oidcToken2;
4016
4039
  var resp;
4017
- return _regenerator().w(function (_context92) {
4018
- while (1) switch (_context92.n) {
4040
+ return _regenerator().w(function (_context93) {
4041
+ while (1) switch (_context93.n) {
4019
4042
  case 0:
4020
- _context92.n = 1;
4043
+ _context93.n = 1;
4021
4044
  return client === null || client === void 0 ? void 0 : client.httpClient.proxyOAuth2Authenticate({
4022
4045
  provider: "OAUTH2_PROVIDER_X",
4023
4046
  authCode: result.authCode,
@@ -4027,12 +4050,12 @@ var ClientProvider = function ClientProvider(_ref) {
4027
4050
  nonce: nonce
4028
4051
  });
4029
4052
  case 1:
4030
- resp = _context92.v;
4031
- return _context92.a(2, (_resp$oidcToken2 = resp === null || resp === void 0 ? void 0 : resp.oidcToken) !== null && _resp$oidcToken2 !== void 0 ? _resp$oidcToken2 : "");
4053
+ resp = _context93.v;
4054
+ return _context93.a(2, (_resp$oidcToken2 = resp === null || resp === void 0 ? void 0 : resp.oidcToken) !== null && _resp$oidcToken2 !== void 0 ? _resp$oidcToken2 : "");
4032
4055
  }
4033
- }, _callee92);
4056
+ }, _callee93);
4034
4057
  }));
4035
- function exchangeCodeForToken(_x76) {
4058
+ function exchangeCodeForToken(_x77) {
4036
4059
  return _exchangeCodeForToken2.apply(this, arguments);
4037
4060
  }
4038
4061
  return exchangeCodeForToken;
@@ -4051,47 +4074,47 @@ var ClientProvider = function ClientProvider(_ref) {
4051
4074
  }
4052
4075
  }));
4053
4076
  }
4054
- }, _callee93);
4077
+ }, _callee94);
4055
4078
  }));
4056
- return function (_x75) {
4057
- return _ref104.apply(this, arguments);
4079
+ return function (_x76) {
4080
+ return _ref105.apply(this, arguments);
4058
4081
  };
4059
4082
  }(), [client, callbacks, completeOauth, createApiKeyPair, masterConfig]);
4060
4083
  var handleGoogleOauth = useCallback(/*#__PURE__*/function () {
4061
- var _ref106 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(params) {
4084
+ var _ref107 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(params) {
4062
4085
  var _masterConfig$auth29, _masterConfig$auth29$, _masterConfig$auth$oa4, _masterConfig$auth30, _masterConfig$auth30$, _masterConfig$auth31, _masterConfig$auth31$, _masterConfig$auth32;
4063
- var _ref107, _ref107$clientId, clientId, _ref107$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4064
- return _regenerator().w(function (_context94) {
4065
- while (1) switch (_context94.n) {
4086
+ var _ref108, _ref108$clientId, clientId, _ref108$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4087
+ return _regenerator().w(function (_context95) {
4088
+ while (1) switch (_context95.n) {
4066
4089
  case 0:
4067
- _ref107 = params || {}, _ref107$clientId = _ref107.clientId, clientId = _ref107$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth29 = masterConfig.auth) === null || _masterConfig$auth29 === void 0 ? void 0 : (_masterConfig$auth29$ = _masterConfig$auth29.oauthConfig) === null || _masterConfig$auth29$ === void 0 ? void 0 : _masterConfig$auth29$.googleClientId : _ref107$clientId, _ref107$openInPage = _ref107.openInPage, openInPage = _ref107$openInPage === void 0 ? (_masterConfig$auth$oa4 = 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$.openOauthInPage) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : false : _ref107$openInPage, additionalParameters = _ref107.additionalState;
4090
+ _ref108 = params || {}, _ref108$clientId = _ref108.clientId, clientId = _ref108$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth29 = masterConfig.auth) === null || _masterConfig$auth29 === void 0 ? void 0 : (_masterConfig$auth29$ = _masterConfig$auth29.oauthConfig) === null || _masterConfig$auth29$ === void 0 ? void 0 : _masterConfig$auth29$.googleClientId : _ref108$clientId, _ref108$openInPage = _ref108.openInPage, openInPage = _ref108$openInPage === void 0 ? (_masterConfig$auth$oa4 = 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$.openOauthInPage) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : false : _ref108$openInPage, additionalParameters = _ref108.additionalState;
4068
4091
  provider = OAuthProviders.GOOGLE;
4069
4092
  if (masterConfig) {
4070
- _context94.n = 1;
4093
+ _context95.n = 1;
4071
4094
  break;
4072
4095
  }
4073
4096
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4074
4097
  case 1:
4075
4098
  if (clientId) {
4076
- _context94.n = 2;
4099
+ _context95.n = 2;
4077
4100
  break;
4078
4101
  }
4079
4102
  throw new TurnkeyError("Google Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4080
4103
  case 2:
4081
4104
  if ((_masterConfig$auth31 = masterConfig.auth) !== null && _masterConfig$auth31 !== void 0 && (_masterConfig$auth31$ = _masterConfig$auth31.oauthConfig) !== null && _masterConfig$auth31$ !== void 0 && _masterConfig$auth31$.oauthRedirectUri) {
4082
- _context94.n = 3;
4105
+ _context95.n = 3;
4083
4106
  break;
4084
4107
  }
4085
4108
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4086
4109
  case 3:
4087
4110
  flow = openInPage ? "redirect" : "popup"; // Google requires no trailing slash
4088
4111
  redirectUri = (_masterConfig$auth32 = masterConfig.auth) === null || _masterConfig$auth32 === void 0 ? void 0 : _masterConfig$auth32.oauthConfig.oauthRedirectUri.replace(/\/$/, ""); // Create key pair and generate nonce
4089
- _context94.n = 4;
4112
+ _context95.n = 4;
4090
4113
  return createApiKeyPair();
4091
4114
  case 4:
4092
- publicKey = _context94.v;
4115
+ publicKey = _context95.v;
4093
4116
  if (publicKey) {
4094
- _context94.n = 5;
4117
+ _context95.n = 5;
4095
4118
  break;
4096
4119
  }
4097
4120
  throw new Error("Failed to create public key for OAuth.");
@@ -4107,21 +4130,21 @@ var ClientProvider = function ClientProvider(_ref) {
4107
4130
  additionalState: additionalParameters
4108
4131
  });
4109
4132
  if (!openInPage) {
4110
- _context94.n = 6;
4133
+ _context95.n = 6;
4111
4134
  break;
4112
4135
  }
4113
- return _context94.a(2, redirectToOAuthProvider(authUrl));
4136
+ return _context95.a(2, redirectToOAuthProvider(authUrl));
4114
4137
  case 6:
4115
4138
  // Popup flow
4116
4139
  authWindow = openOAuthPopup();
4117
4140
  if (authWindow) {
4118
- _context94.n = 7;
4141
+ _context95.n = 7;
4119
4142
  break;
4120
4143
  }
4121
4144
  throw new Error("Failed to open ".concat(capitalizeProviderName(provider), " login window."));
4122
4145
  case 7:
4123
4146
  authWindow.location.href = authUrl;
4124
- return _context94.a(2, new Promise(function (resolve, reject) {
4147
+ return _context95.a(2, new Promise(function (resolve, reject) {
4125
4148
  var interval = setInterval(function () {
4126
4149
  try {
4127
4150
  if (authWindow.closed) {
@@ -4156,47 +4179,47 @@ var ClientProvider = function ClientProvider(_ref) {
4156
4179
  }
4157
4180
  }));
4158
4181
  }
4159
- }, _callee94);
4182
+ }, _callee95);
4160
4183
  }));
4161
- return function (_x77) {
4162
- return _ref106.apply(this, arguments);
4184
+ return function (_x78) {
4185
+ return _ref107.apply(this, arguments);
4163
4186
  };
4164
4187
  }(), [callbacks, completeOauth, createApiKeyPair, masterConfig]);
4165
4188
  var handleAppleOauth = useCallback(/*#__PURE__*/function () {
4166
- var _ref108 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(params) {
4189
+ var _ref109 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(params) {
4167
4190
  var _masterConfig$auth33, _masterConfig$auth33$, _masterConfig$auth$oa5, _masterConfig$auth34, _masterConfig$auth34$, _masterConfig$auth35, _masterConfig$auth35$, _masterConfig$auth36;
4168
- var _ref109, _ref109$clientId, clientId, _ref109$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4169
- return _regenerator().w(function (_context95) {
4170
- while (1) switch (_context95.n) {
4191
+ var _ref110, _ref110$clientId, clientId, _ref110$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4192
+ return _regenerator().w(function (_context96) {
4193
+ while (1) switch (_context96.n) {
4171
4194
  case 0:
4172
- _ref109 = params || {}, _ref109$clientId = _ref109.clientId, clientId = _ref109$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth33 = masterConfig.auth) === null || _masterConfig$auth33 === void 0 ? void 0 : (_masterConfig$auth33$ = _masterConfig$auth33.oauthConfig) === null || _masterConfig$auth33$ === void 0 ? void 0 : _masterConfig$auth33$.appleClientId : _ref109$clientId, _ref109$openInPage = _ref109.openInPage, openInPage = _ref109$openInPage === void 0 ? (_masterConfig$auth$oa5 = 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$.openOauthInPage) !== null && _masterConfig$auth$oa5 !== void 0 ? _masterConfig$auth$oa5 : false : _ref109$openInPage, additionalParameters = _ref109.additionalState;
4195
+ _ref110 = params || {}, _ref110$clientId = _ref110.clientId, clientId = _ref110$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth33 = masterConfig.auth) === null || _masterConfig$auth33 === void 0 ? void 0 : (_masterConfig$auth33$ = _masterConfig$auth33.oauthConfig) === null || _masterConfig$auth33$ === void 0 ? void 0 : _masterConfig$auth33$.appleClientId : _ref110$clientId, _ref110$openInPage = _ref110.openInPage, openInPage = _ref110$openInPage === void 0 ? (_masterConfig$auth$oa5 = 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$.openOauthInPage) !== null && _masterConfig$auth$oa5 !== void 0 ? _masterConfig$auth$oa5 : false : _ref110$openInPage, additionalParameters = _ref110.additionalState;
4173
4196
  provider = OAuthProviders.APPLE;
4174
4197
  if (masterConfig) {
4175
- _context95.n = 1;
4198
+ _context96.n = 1;
4176
4199
  break;
4177
4200
  }
4178
4201
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4179
4202
  case 1:
4180
4203
  if (clientId) {
4181
- _context95.n = 2;
4204
+ _context96.n = 2;
4182
4205
  break;
4183
4206
  }
4184
4207
  throw new TurnkeyError("Apple Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4185
4208
  case 2:
4186
4209
  if ((_masterConfig$auth35 = masterConfig.auth) !== null && _masterConfig$auth35 !== void 0 && (_masterConfig$auth35$ = _masterConfig$auth35.oauthConfig) !== null && _masterConfig$auth35$ !== void 0 && _masterConfig$auth35$.oauthRedirectUri) {
4187
- _context95.n = 3;
4210
+ _context96.n = 3;
4188
4211
  break;
4189
4212
  }
4190
4213
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4191
4214
  case 3:
4192
4215
  flow = openInPage ? "redirect" : "popup"; // TODO (Amir): Apple needs the '/' at the end. Maybe we should add it if not there?
4193
4216
  redirectUri = (_masterConfig$auth36 = masterConfig.auth) === null || _masterConfig$auth36 === void 0 ? void 0 : _masterConfig$auth36.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4194
- _context95.n = 4;
4217
+ _context96.n = 4;
4195
4218
  return createApiKeyPair();
4196
4219
  case 4:
4197
- publicKey = _context95.v;
4220
+ publicKey = _context96.v;
4198
4221
  if (publicKey) {
4199
- _context95.n = 5;
4222
+ _context96.n = 5;
4200
4223
  break;
4201
4224
  }
4202
4225
  throw new Error("Failed to create public key for OAuth.");
@@ -4212,21 +4235,21 @@ var ClientProvider = function ClientProvider(_ref) {
4212
4235
  additionalState: additionalParameters
4213
4236
  });
4214
4237
  if (!openInPage) {
4215
- _context95.n = 6;
4238
+ _context96.n = 6;
4216
4239
  break;
4217
4240
  }
4218
- return _context95.a(2, redirectToOAuthProvider(authUrl));
4241
+ return _context96.a(2, redirectToOAuthProvider(authUrl));
4219
4242
  case 6:
4220
4243
  // Popup flow
4221
4244
  authWindow = openOAuthPopup();
4222
4245
  if (authWindow) {
4223
- _context95.n = 7;
4246
+ _context96.n = 7;
4224
4247
  break;
4225
4248
  }
4226
4249
  throw new Error("Failed to open ".concat(capitalizeProviderName(provider), " login window."));
4227
4250
  case 7:
4228
4251
  authWindow.location.href = authUrl;
4229
- return _context95.a(2, new Promise(function (resolve, reject) {
4252
+ return _context96.a(2, new Promise(function (resolve, reject) {
4230
4253
  var interval = setInterval(function () {
4231
4254
  try {
4232
4255
  if (authWindow.closed) {
@@ -4261,56 +4284,56 @@ var ClientProvider = function ClientProvider(_ref) {
4261
4284
  }
4262
4285
  }));
4263
4286
  }
4264
- }, _callee95);
4287
+ }, _callee96);
4265
4288
  }));
4266
- return function (_x78) {
4267
- return _ref108.apply(this, arguments);
4289
+ return function (_x79) {
4290
+ return _ref109.apply(this, arguments);
4268
4291
  };
4269
4292
  }(), [callbacks, completeOauth, createApiKeyPair, masterConfig]);
4270
4293
  var handleFacebookOauth = useCallback(/*#__PURE__*/function () {
4271
- var _ref110 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(params) {
4294
+ var _ref111 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(params) {
4272
4295
  var _masterConfig$auth37, _masterConfig$auth37$, _masterConfig$auth$oa6, _masterConfig$auth38, _masterConfig$auth38$, _masterConfig$auth39, _masterConfig$auth39$, _masterConfig$auth40;
4273
- var _ref111, _ref111$clientId, clientId, _ref111$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, authUrl, authWindow;
4274
- return _regenerator().w(function (_context97) {
4275
- while (1) switch (_context97.n) {
4296
+ var _ref112, _ref112$clientId, clientId, _ref112$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, authUrl, authWindow;
4297
+ return _regenerator().w(function (_context98) {
4298
+ while (1) switch (_context98.n) {
4276
4299
  case 0:
4277
- _ref111 = params || {}, _ref111$clientId = _ref111.clientId, clientId = _ref111$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth37 = masterConfig.auth) === null || _masterConfig$auth37 === void 0 ? void 0 : (_masterConfig$auth37$ = _masterConfig$auth37.oauthConfig) === null || _masterConfig$auth37$ === void 0 ? void 0 : _masterConfig$auth37$.facebookClientId : _ref111$clientId, _ref111$openInPage = _ref111.openInPage, openInPage = _ref111$openInPage === void 0 ? (_masterConfig$auth$oa6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth38 = masterConfig.auth) === null || _masterConfig$auth38 === void 0 ? void 0 : (_masterConfig$auth38$ = _masterConfig$auth38.oauthConfig) === null || _masterConfig$auth38$ === void 0 ? void 0 : _masterConfig$auth38$.openOauthInPage) !== null && _masterConfig$auth$oa6 !== void 0 ? _masterConfig$auth$oa6 : false : _ref111$openInPage, additionalParameters = _ref111.additionalState;
4300
+ _ref112 = params || {}, _ref112$clientId = _ref112.clientId, clientId = _ref112$clientId === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth37 = masterConfig.auth) === null || _masterConfig$auth37 === void 0 ? void 0 : (_masterConfig$auth37$ = _masterConfig$auth37.oauthConfig) === null || _masterConfig$auth37$ === void 0 ? void 0 : _masterConfig$auth37$.facebookClientId : _ref112$clientId, _ref112$openInPage = _ref112.openInPage, openInPage = _ref112$openInPage === void 0 ? (_masterConfig$auth$oa6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth38 = masterConfig.auth) === null || _masterConfig$auth38 === void 0 ? void 0 : (_masterConfig$auth38$ = _masterConfig$auth38.oauthConfig) === null || _masterConfig$auth38$ === void 0 ? void 0 : _masterConfig$auth38$.openOauthInPage) !== null && _masterConfig$auth$oa6 !== void 0 ? _masterConfig$auth$oa6 : false : _ref112$openInPage, additionalParameters = _ref112.additionalState;
4278
4301
  provider = OAuthProviders.FACEBOOK;
4279
4302
  if (masterConfig) {
4280
- _context97.n = 1;
4303
+ _context98.n = 1;
4281
4304
  break;
4282
4305
  }
4283
4306
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4284
4307
  case 1:
4285
4308
  if (clientId) {
4286
- _context97.n = 2;
4309
+ _context98.n = 2;
4287
4310
  break;
4288
4311
  }
4289
4312
  throw new TurnkeyError("Facebook Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4290
4313
  case 2:
4291
4314
  if ((_masterConfig$auth39 = masterConfig.auth) !== null && _masterConfig$auth39 !== void 0 && (_masterConfig$auth39$ = _masterConfig$auth39.oauthConfig) !== null && _masterConfig$auth39$ !== void 0 && _masterConfig$auth39$.oauthRedirectUri) {
4292
- _context97.n = 3;
4315
+ _context98.n = 3;
4293
4316
  break;
4294
4317
  }
4295
4318
  throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
4296
4319
  case 3:
4297
4320
  flow = openInPage ? "redirect" : "popup";
4298
4321
  redirectUri = (_masterConfig$auth40 = masterConfig.auth) === null || _masterConfig$auth40 === void 0 ? void 0 : _masterConfig$auth40.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4299
- _context97.n = 4;
4322
+ _context98.n = 4;
4300
4323
  return createApiKeyPair();
4301
4324
  case 4:
4302
- publicKey = _context97.v;
4325
+ publicKey = _context98.v;
4303
4326
  if (publicKey) {
4304
- _context97.n = 5;
4327
+ _context98.n = 5;
4305
4328
  break;
4306
4329
  }
4307
4330
  throw new Error("Failed to create public key for OAuth.");
4308
4331
  case 5:
4309
4332
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair and store verifier
4310
- _context97.n = 6;
4333
+ _context98.n = 6;
4311
4334
  return generateChallengePair();
4312
4335
  case 6:
4313
- _yield$generateChalle3 = _context97.v;
4336
+ _yield$generateChalle3 = _context98.v;
4314
4337
  verifier = _yield$generateChalle3.verifier;
4315
4338
  codeChallenge = _yield$generateChalle3.codeChallenge;
4316
4339
  storePKCEVerifier(provider, verifier);
@@ -4326,21 +4349,21 @@ var ClientProvider = function ClientProvider(_ref) {
4326
4349
  additionalState: additionalParameters
4327
4350
  });
4328
4351
  if (!openInPage) {
4329
- _context97.n = 7;
4352
+ _context98.n = 7;
4330
4353
  break;
4331
4354
  }
4332
- return _context97.a(2, redirectToOAuthProvider(authUrl));
4355
+ return _context98.a(2, redirectToOAuthProvider(authUrl));
4333
4356
  case 7:
4334
4357
  // Popup flow
4335
4358
  authWindow = openOAuthPopup();
4336
4359
  if (authWindow) {
4337
- _context97.n = 8;
4360
+ _context98.n = 8;
4338
4361
  break;
4339
4362
  }
4340
4363
  throw new Error("Failed to open ".concat(capitalizeProviderName(provider), " login window."));
4341
4364
  case 8:
4342
4365
  authWindow.location.href = authUrl;
4343
- return _context97.a(2, new Promise(function (resolve, reject) {
4366
+ return _context98.a(2, new Promise(function (resolve, reject) {
4344
4367
  var interval = setInterval(function () {
4345
4368
  try {
4346
4369
  if (authWindow.closed) {
@@ -4362,20 +4385,20 @@ var ClientProvider = function ClientProvider(_ref) {
4362
4385
  completeOauth: completeOauth,
4363
4386
  onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess,
4364
4387
  exchangeCodeForToken: function () {
4365
- var _exchangeCodeForToken3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(codeVerifier) {
4388
+ var _exchangeCodeForToken3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(codeVerifier) {
4366
4389
  var tokenData;
4367
- return _regenerator().w(function (_context96) {
4368
- while (1) switch (_context96.n) {
4390
+ return _regenerator().w(function (_context97) {
4391
+ while (1) switch (_context97.n) {
4369
4392
  case 0:
4370
- _context96.n = 1;
4393
+ _context97.n = 1;
4371
4394
  return exchangeFacebookCodeForToken(clientId, redirectUri, result.authCode, codeVerifier);
4372
4395
  case 1:
4373
- tokenData = _context96.v;
4374
- return _context96.a(2, tokenData.id_token);
4396
+ tokenData = _context97.v;
4397
+ return _context97.a(2, tokenData.id_token);
4375
4398
  }
4376
- }, _callee96);
4399
+ }, _callee97);
4377
4400
  }));
4378
- function exchangeCodeForToken(_x80) {
4401
+ function exchangeCodeForToken(_x81) {
4379
4402
  return _exchangeCodeForToken3.apply(this, arguments);
4380
4403
  }
4381
4404
  return exchangeCodeForToken;
@@ -4394,18 +4417,18 @@ var ClientProvider = function ClientProvider(_ref) {
4394
4417
  }
4395
4418
  }));
4396
4419
  }
4397
- }, _callee97);
4420
+ }, _callee98);
4398
4421
  }));
4399
- return function (_x79) {
4400
- return _ref110.apply(this, arguments);
4422
+ return function (_x80) {
4423
+ return _ref111.apply(this, arguments);
4401
4424
  };
4402
4425
  }(), [callbacks, completeOauth, createApiKeyPair, masterConfig]);
4403
4426
  var handleLogin = useCallback(/*#__PURE__*/function () {
4404
- var _ref112 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(params) {
4427
+ var _ref113 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99(params) {
4405
4428
  var _masterConfig$ui, _params$logoDark, _masterConfig$ui2, _params$logoLight, _masterConfig$ui3, _params$title;
4406
4429
  var logo;
4407
- return _regenerator().w(function (_context98) {
4408
- while (1) switch (_context98.n) {
4430
+ return _regenerator().w(function (_context99) {
4431
+ while (1) switch (_context99.n) {
4409
4432
  case 0:
4410
4433
  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;
4411
4434
  pushPage({
@@ -4419,22 +4442,22 @@ var ClientProvider = function ClientProvider(_ref) {
4419
4442
  showTitle: logo ? false : true
4420
4443
  });
4421
4444
  case 1:
4422
- return _context98.a(2);
4445
+ return _context99.a(2);
4423
4446
  }
4424
- }, _callee98);
4447
+ }, _callee99);
4425
4448
  }));
4426
- return function (_x81) {
4427
- return _ref112.apply(this, arguments);
4449
+ return function (_x82) {
4450
+ return _ref113.apply(this, arguments);
4428
4451
  };
4429
4452
  }(), [pushPage, masterConfig]);
4430
4453
  var handleExportWallet = useCallback(/*#__PURE__*/function () {
4431
- var _ref113 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99(params) {
4454
+ var _ref114 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100(params) {
4432
4455
  var walletId, targetPublicKey, stampWith, organizationId;
4433
- return _regenerator().w(function (_context99) {
4434
- while (1) switch (_context99.n) {
4456
+ return _regenerator().w(function (_context100) {
4457
+ while (1) switch (_context100.n) {
4435
4458
  case 0:
4436
4459
  walletId = params.walletId, targetPublicKey = params.targetPublicKey, stampWith = params.stampWith, organizationId = params.organizationId;
4437
- return _context99.a(2, new Promise(function (resolve, reject) {
4460
+ return _context100.a(2, new Promise(function (resolve, reject) {
4438
4461
  return pushPage({
4439
4462
  key: "Export wallet",
4440
4463
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4460,20 +4483,20 @@ var ClientProvider = function ClientProvider(_ref) {
4460
4483
  });
4461
4484
  }));
4462
4485
  }
4463
- }, _callee99);
4486
+ }, _callee100);
4464
4487
  }));
4465
- return function (_x82) {
4466
- return _ref113.apply(this, arguments);
4488
+ return function (_x83) {
4489
+ return _ref114.apply(this, arguments);
4467
4490
  };
4468
4491
  }(), [pushPage]);
4469
4492
  var handleExportPrivateKey = useCallback(/*#__PURE__*/function () {
4470
- var _ref114 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100(params) {
4493
+ var _ref115 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101(params) {
4471
4494
  var privateKeyId, targetPublicKey, keyFormat, stampWith, organizationId;
4472
- return _regenerator().w(function (_context100) {
4473
- while (1) switch (_context100.n) {
4495
+ return _regenerator().w(function (_context101) {
4496
+ while (1) switch (_context101.n) {
4474
4497
  case 0:
4475
4498
  privateKeyId = params.privateKeyId, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith, organizationId = params.organizationId;
4476
- return _context100.a(2, new Promise(function (resolve, reject) {
4499
+ return _context101.a(2, new Promise(function (resolve, reject) {
4477
4500
  return pushPage({
4478
4501
  key: "Export private key",
4479
4502
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4501,20 +4524,20 @@ var ClientProvider = function ClientProvider(_ref) {
4501
4524
  });
4502
4525
  }));
4503
4526
  }
4504
- }, _callee100);
4527
+ }, _callee101);
4505
4528
  }));
4506
- return function (_x83) {
4507
- return _ref114.apply(this, arguments);
4529
+ return function (_x84) {
4530
+ return _ref115.apply(this, arguments);
4508
4531
  };
4509
4532
  }(), [pushPage]);
4510
4533
  var handleExportWalletAccount = useCallback(/*#__PURE__*/function () {
4511
- var _ref115 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101(params) {
4534
+ var _ref116 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102(params) {
4512
4535
  var address, targetPublicKey, keyFormat, stampWith, organizationId;
4513
- return _regenerator().w(function (_context101) {
4514
- while (1) switch (_context101.n) {
4536
+ return _regenerator().w(function (_context102) {
4537
+ while (1) switch (_context102.n) {
4515
4538
  case 0:
4516
4539
  address = params.address, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith, organizationId = params.organizationId;
4517
- return _context101.a(2, new Promise(function (resolve, reject) {
4540
+ return _context102.a(2, new Promise(function (resolve, reject) {
4518
4541
  return pushPage({
4519
4542
  key: "Export wallet account",
4520
4543
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4542,21 +4565,21 @@ var ClientProvider = function ClientProvider(_ref) {
4542
4565
  });
4543
4566
  }));
4544
4567
  }
4545
- }, _callee101);
4568
+ }, _callee102);
4546
4569
  }));
4547
- return function (_x84) {
4548
- return _ref115.apply(this, arguments);
4570
+ return function (_x85) {
4571
+ return _ref116.apply(this, arguments);
4549
4572
  };
4550
4573
  }(), [pushPage]);
4551
4574
  var handleImportWallet = useCallback(/*#__PURE__*/function () {
4552
- var _ref116 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102(params) {
4553
- var _ref117, defaultWalletAccounts, _ref117$successPageDu, successPageDuration, stampWith, walletName, clearClipboardOnPaste, organizationId, userId, _t11;
4554
- return _regenerator().w(function (_context102) {
4555
- while (1) switch (_context102.p = _context102.n) {
4575
+ var _ref117 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee103(params) {
4576
+ var _ref118, defaultWalletAccounts, _ref118$successPageDu, successPageDuration, stampWith, walletName, clearClipboardOnPaste, organizationId, userId, _t11;
4577
+ return _regenerator().w(function (_context103) {
4578
+ while (1) switch (_context103.p = _context103.n) {
4556
4579
  case 0:
4557
- _ref117 = params || {}, defaultWalletAccounts = _ref117.defaultWalletAccounts, _ref117$successPageDu = _ref117.successPageDuration, successPageDuration = _ref117$successPageDu === void 0 ? 2000 : _ref117$successPageDu, stampWith = _ref117.stampWith, walletName = _ref117.walletName, clearClipboardOnPaste = _ref117.clearClipboardOnPaste, organizationId = _ref117.organizationId, userId = _ref117.userId;
4558
- _context102.p = 1;
4559
- return _context102.a(2, withTurnkeyErrorHandling(function () {
4580
+ _ref118 = params || {}, defaultWalletAccounts = _ref118.defaultWalletAccounts, _ref118$successPageDu = _ref118.successPageDuration, successPageDuration = _ref118$successPageDu === void 0 ? 2000 : _ref118$successPageDu, stampWith = _ref118.stampWith, walletName = _ref118.walletName, clearClipboardOnPaste = _ref118.clearClipboardOnPaste, organizationId = _ref118.organizationId, userId = _ref118.userId;
4581
+ _context103.p = 1;
4582
+ return _context103.a(2, withTurnkeyErrorHandling(function () {
4560
4583
  return new Promise(function (resolve, reject) {
4561
4584
  return pushPage({
4562
4585
  key: "Import wallet",
@@ -4589,33 +4612,33 @@ var ClientProvider = function ClientProvider(_ref) {
4589
4612
  return logout();
4590
4613
  }));
4591
4614
  case 2:
4592
- _context102.p = 2;
4593
- _t11 = _context102.v;
4615
+ _context103.p = 2;
4616
+ _t11 = _context103.v;
4594
4617
  if (!(_t11 instanceof TurnkeyError)) {
4595
- _context102.n = 3;
4618
+ _context103.n = 3;
4596
4619
  break;
4597
4620
  }
4598
4621
  throw _t11;
4599
4622
  case 3:
4600
4623
  throw new TurnkeyError("Failed to import wallet.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t11);
4601
4624
  case 4:
4602
- return _context102.a(2);
4625
+ return _context103.a(2);
4603
4626
  }
4604
- }, _callee102, null, [[1, 2]]);
4627
+ }, _callee103, null, [[1, 2]]);
4605
4628
  }));
4606
- return function (_x85) {
4607
- return _ref116.apply(this, arguments);
4629
+ return function (_x86) {
4630
+ return _ref117.apply(this, arguments);
4608
4631
  };
4609
4632
  }(), [pushPage, logout]);
4610
4633
  var handleImportPrivateKey = useCallback(/*#__PURE__*/function () {
4611
- var _ref118 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee103(params) {
4612
- var _ref119, curve, addressFormats, _ref119$successPageDu, successPageDuration, stampWith, keyName, keyFormat, clearClipboardOnPaste, organizationId, _t12;
4613
- return _regenerator().w(function (_context103) {
4614
- while (1) switch (_context103.p = _context103.n) {
4634
+ var _ref119 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee104(params) {
4635
+ var _ref120, curve, addressFormats, _ref120$successPageDu, successPageDuration, stampWith, keyName, keyFormat, clearClipboardOnPaste, organizationId, _t12;
4636
+ return _regenerator().w(function (_context104) {
4637
+ while (1) switch (_context104.p = _context104.n) {
4615
4638
  case 0:
4616
- _ref119 = params || {}, curve = _ref119.curve, addressFormats = _ref119.addressFormats, _ref119$successPageDu = _ref119.successPageDuration, successPageDuration = _ref119$successPageDu === void 0 ? 2000 : _ref119$successPageDu, stampWith = _ref119.stampWith, keyName = _ref119.keyName, keyFormat = _ref119.keyFormat, clearClipboardOnPaste = _ref119.clearClipboardOnPaste, organizationId = _ref119.organizationId;
4617
- _context103.p = 1;
4618
- return _context103.a(2, withTurnkeyErrorHandling(function () {
4639
+ _ref120 = params || {}, curve = _ref120.curve, addressFormats = _ref120.addressFormats, _ref120$successPageDu = _ref120.successPageDuration, successPageDuration = _ref120$successPageDu === void 0 ? 2000 : _ref120$successPageDu, stampWith = _ref120.stampWith, keyName = _ref120.keyName, keyFormat = _ref120.keyFormat, clearClipboardOnPaste = _ref120.clearClipboardOnPaste, organizationId = _ref120.organizationId;
4640
+ _context104.p = 1;
4641
+ return _context104.a(2, withTurnkeyErrorHandling(function () {
4619
4642
  return new Promise(function (resolve, reject) {
4620
4643
  return pushPage({
4621
4644
  key: "Import private key",
@@ -4647,51 +4670,51 @@ var ClientProvider = function ClientProvider(_ref) {
4647
4670
  return logout();
4648
4671
  }));
4649
4672
  case 2:
4650
- _context103.p = 2;
4651
- _t12 = _context103.v;
4673
+ _context104.p = 2;
4674
+ _t12 = _context104.v;
4652
4675
  if (!(_t12 instanceof TurnkeyError)) {
4653
- _context103.n = 3;
4676
+ _context104.n = 3;
4654
4677
  break;
4655
4678
  }
4656
4679
  throw _t12;
4657
4680
  case 3:
4658
4681
  throw new TurnkeyError("Failed to import private key.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t12);
4659
4682
  case 4:
4660
- return _context103.a(2);
4683
+ return _context104.a(2);
4661
4684
  }
4662
- }, _callee103, null, [[1, 2]]);
4685
+ }, _callee104, null, [[1, 2]]);
4663
4686
  }));
4664
- return function (_x86) {
4665
- return _ref118.apply(this, arguments);
4687
+ return function (_x87) {
4688
+ return _ref119.apply(this, arguments);
4666
4689
  };
4667
4690
  }(), [pushPage, logout]);
4668
4691
  var handleUpdateUserName = useCallback(/*#__PURE__*/function () {
4669
- var _ref120 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee104(params) {
4670
- var _ref121, _ref121$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _params$userId, res, _t13;
4671
- return _regenerator().w(function (_context104) {
4672
- while (1) switch (_context104.p = _context104.n) {
4692
+ var _ref121 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee105(params) {
4693
+ var _ref122, _ref122$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _params$userId, res, _t13;
4694
+ return _regenerator().w(function (_context105) {
4695
+ while (1) switch (_context105.p = _context105.n) {
4673
4696
  case 0:
4674
- _ref121 = params || {}, _ref121$successPageDu = _ref121.successPageDuration, successPageDuration = _ref121$successPageDu === void 0 ? 2000 : _ref121$successPageDu, subTitle = _ref121.subTitle, title = _ref121.title, stampWith = _ref121.stampWith;
4697
+ _ref122 = params || {}, _ref122$successPageDu = _ref122.successPageDuration, successPageDuration = _ref122$successPageDu === void 0 ? 2000 : _ref122$successPageDu, subTitle = _ref122.subTitle, title = _ref122.title, stampWith = _ref122.stampWith;
4675
4698
  if (client) {
4676
- _context104.n = 1;
4699
+ _context105.n = 1;
4677
4700
  break;
4678
4701
  }
4679
4702
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4680
4703
  case 1:
4681
- _context104.n = 2;
4704
+ _context105.n = 2;
4682
4705
  return getSession();
4683
4706
  case 2:
4684
- s = _context104.v;
4707
+ s = _context105.v;
4685
4708
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4686
4709
  if (organizationId) {
4687
- _context104.n = 3;
4710
+ _context105.n = 3;
4688
4711
  break;
4689
4712
  }
4690
4713
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
4691
4714
  case 3:
4692
4715
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (user === null || user === void 0 ? void 0 : user.userId);
4693
4716
  if (userId) {
4694
- _context104.n = 4;
4717
+ _context105.n = 4;
4695
4718
  break;
4696
4719
  }
4697
4720
  throw new TurnkeyError("A user ID is required to update a user name.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -4711,12 +4734,12 @@ var ClientProvider = function ClientProvider(_ref) {
4711
4734
  showTitle: false
4712
4735
  });
4713
4736
  };
4714
- _context104.p = 5;
4737
+ _context105.p = 5;
4715
4738
  if (!(!(params !== null && params !== void 0 && params.userName) && (params === null || params === void 0 ? void 0 : params.userName) !== "")) {
4716
- _context104.n = 6;
4739
+ _context105.n = 6;
4717
4740
  break;
4718
4741
  }
4719
- return _context104.a(2, withTurnkeyErrorHandling(function () {
4742
+ return _context105.a(2, withTurnkeyErrorHandling(function () {
4720
4743
  return new Promise(function (resolve, reject) {
4721
4744
  pushPage({
4722
4745
  key: "Update User Name",
@@ -4744,7 +4767,7 @@ var ClientProvider = function ClientProvider(_ref) {
4744
4767
  return logout();
4745
4768
  }));
4746
4769
  case 6:
4747
- _context104.n = 7;
4770
+ _context105.n = 7;
4748
4771
  return updateUserName(_objectSpread2({
4749
4772
  userName: params.userName,
4750
4773
  userId: (_params$userId = params.userId) !== null && _params$userId !== void 0 ? _params$userId : user.userId,
@@ -4753,71 +4776,71 @@ var ClientProvider = function ClientProvider(_ref) {
4753
4776
  organizationId: organizationId
4754
4777
  }));
4755
4778
  case 7:
4756
- res = _context104.v;
4779
+ res = _context105.v;
4757
4780
  onSuccess();
4758
- return _context104.a(2, res);
4781
+ return _context105.a(2, res);
4759
4782
  case 8:
4760
- _context104.n = 11;
4783
+ _context105.n = 11;
4761
4784
  break;
4762
4785
  case 9:
4763
- _context104.p = 9;
4764
- _t13 = _context104.v;
4786
+ _context105.p = 9;
4787
+ _t13 = _context105.v;
4765
4788
  if (!(_t13 instanceof TurnkeyError)) {
4766
- _context104.n = 10;
4789
+ _context105.n = 10;
4767
4790
  break;
4768
4791
  }
4769
4792
  throw _t13;
4770
4793
  case 10:
4771
4794
  throw new TurnkeyError("Failed to update user name.", TurnkeyErrorCodes.UPDATE_USER_NAME_ERROR, _t13);
4772
4795
  case 11:
4773
- return _context104.a(2);
4796
+ return _context105.a(2);
4774
4797
  }
4775
- }, _callee104, null, [[5, 9]]);
4798
+ }, _callee105, null, [[5, 9]]);
4776
4799
  }));
4777
- return function (_x87) {
4778
- return _ref120.apply(this, arguments);
4800
+ return function (_x88) {
4801
+ return _ref121.apply(this, arguments);
4779
4802
  };
4780
4803
  }(), [client, getSession, user, pushPage, closeModal, updateUserName, logout]);
4781
4804
  var handleUpdateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
4782
- var _ref122 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee106(params) {
4805
+ var _ref123 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee107(params) {
4783
4806
  var _masterConfig$auth41, _masterConfig$auth41$;
4784
- var _ref123, _ref123$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t15;
4785
- return _regenerator().w(function (_context106) {
4786
- while (1) switch (_context106.p = _context106.n) {
4807
+ var _ref124, _ref124$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t15;
4808
+ return _regenerator().w(function (_context107) {
4809
+ while (1) switch (_context107.p = _context107.n) {
4787
4810
  case 0:
4788
- _ref123 = params || {}, _ref123$successPageDu = _ref123.successPageDuration, successPageDuration = _ref123$successPageDu === void 0 ? 2000 : _ref123$successPageDu, subTitle = _ref123.subTitle, title = _ref123.title, stampWith = _ref123.stampWith;
4811
+ _ref124 = params || {}, _ref124$successPageDu = _ref124.successPageDuration, successPageDuration = _ref124$successPageDu === void 0 ? 2000 : _ref124$successPageDu, subTitle = _ref124.subTitle, title = _ref124.title, stampWith = _ref124.stampWith;
4789
4812
  if (client) {
4790
- _context106.n = 1;
4813
+ _context107.n = 1;
4791
4814
  break;
4792
4815
  }
4793
4816
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4794
4817
  case 1:
4795
4818
  if (masterConfig) {
4796
- _context106.n = 2;
4819
+ _context107.n = 2;
4797
4820
  break;
4798
4821
  }
4799
4822
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
4800
4823
  case 2:
4801
4824
  if ((_masterConfig$auth41 = masterConfig.auth) !== null && _masterConfig$auth41 !== void 0 && (_masterConfig$auth41$ = _masterConfig$auth41.methods) !== null && _masterConfig$auth41$ !== void 0 && _masterConfig$auth41$.smsOtpAuthEnabled) {
4802
- _context106.n = 3;
4825
+ _context107.n = 3;
4803
4826
  break;
4804
4827
  }
4805
4828
  throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
4806
4829
  case 3:
4807
- _context106.n = 4;
4830
+ _context107.n = 4;
4808
4831
  return getSession();
4809
4832
  case 4:
4810
- s = _context106.v;
4833
+ s = _context107.v;
4811
4834
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4812
4835
  if (organizationId) {
4813
- _context106.n = 5;
4836
+ _context107.n = 5;
4814
4837
  break;
4815
4838
  }
4816
4839
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
4817
4840
  case 5:
4818
4841
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
4819
4842
  if (userId) {
4820
- _context106.n = 6;
4843
+ _context107.n = 6;
4821
4844
  break;
4822
4845
  }
4823
4846
  throw new TurnkeyError("A user ID is required to update a phone number.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -4837,12 +4860,12 @@ var ClientProvider = function ClientProvider(_ref) {
4837
4860
  showTitle: false
4838
4861
  });
4839
4862
  };
4840
- _context106.p = 7;
4863
+ _context107.p = 7;
4841
4864
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
4842
- _context106.n = 8;
4865
+ _context107.n = 8;
4843
4866
  break;
4844
4867
  }
4845
- return _context106.a(2, withTurnkeyErrorHandling(function () {
4868
+ return _context107.a(2, withTurnkeyErrorHandling(function () {
4846
4869
  return new Promise(function (resolve, reject) {
4847
4870
  pushPage({
4848
4871
  key: "Update Phone Number",
@@ -4870,14 +4893,14 @@ var ClientProvider = function ClientProvider(_ref) {
4870
4893
  return logout();
4871
4894
  }));
4872
4895
  case 8:
4873
- _context106.n = 9;
4896
+ _context107.n = 9;
4874
4897
  return initOtp({
4875
4898
  otpType: OtpType.Sms,
4876
4899
  contact: params.phoneNumber
4877
4900
  });
4878
4901
  case 9:
4879
- otpId = _context106.v;
4880
- return _context106.a(2, withTurnkeyErrorHandling(function () {
4902
+ otpId = _context107.v;
4903
+ return _context107.a(2, withTurnkeyErrorHandling(function () {
4881
4904
  return new Promise(function (resolve, reject) {
4882
4905
  var _masterConfig$auth42, _masterConfig$auth43;
4883
4906
  pushPage({
@@ -4889,13 +4912,13 @@ var ClientProvider = function ClientProvider(_ref) {
4889
4912
  otpLength: ((_masterConfig$auth42 = masterConfig.auth) === null || _masterConfig$auth42 === void 0 ? void 0 : _masterConfig$auth42.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
4890
4913
  alphanumeric: (_masterConfig$auth43 = masterConfig.auth) === null || _masterConfig$auth43 === void 0 ? void 0 : _masterConfig$auth43.otpAlphanumeric,
4891
4914
  onContinue: function () {
4892
- var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee105(otpCode) {
4915
+ var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee106(otpCode) {
4893
4916
  var _yield$verifyOtp, verificationToken, res, _t14;
4894
- return _regenerator().w(function (_context105) {
4895
- while (1) switch (_context105.p = _context105.n) {
4917
+ return _regenerator().w(function (_context106) {
4918
+ while (1) switch (_context106.p = _context106.n) {
4896
4919
  case 0:
4897
- _context105.p = 0;
4898
- _context105.n = 1;
4920
+ _context106.p = 0;
4921
+ _context106.n = 1;
4899
4922
  return verifyOtp({
4900
4923
  otpId: otpId,
4901
4924
  otpCode: otpCode,
@@ -4903,9 +4926,9 @@ var ClientProvider = function ClientProvider(_ref) {
4903
4926
  otpType: OtpType.Sms
4904
4927
  });
4905
4928
  case 1:
4906
- _yield$verifyOtp = _context105.v;
4929
+ _yield$verifyOtp = _context106.v;
4907
4930
  verificationToken = _yield$verifyOtp.verificationToken;
4908
- _context105.n = 2;
4931
+ _context106.n = 2;
4909
4932
  return updateUserPhoneNumber(_objectSpread2({
4910
4933
  phoneNumber: params.phoneNumber,
4911
4934
  verificationToken: verificationToken,
@@ -4915,21 +4938,21 @@ var ClientProvider = function ClientProvider(_ref) {
4915
4938
  stampWith: stampWith
4916
4939
  }));
4917
4940
  case 2:
4918
- res = _context105.v;
4941
+ res = _context106.v;
4919
4942
  onSuccess();
4920
4943
  resolve(res);
4921
- _context105.n = 4;
4944
+ _context106.n = 4;
4922
4945
  break;
4923
4946
  case 3:
4924
- _context105.p = 3;
4925
- _t14 = _context105.v;
4947
+ _context106.p = 3;
4948
+ _t14 = _context106.v;
4926
4949
  reject(_t14);
4927
4950
  case 4:
4928
- return _context105.a(2);
4951
+ return _context106.a(2);
4929
4952
  }
4930
- }, _callee105, null, [[0, 3]]);
4953
+ }, _callee106, null, [[0, 3]]);
4931
4954
  }));
4932
- function onContinue(_x89) {
4955
+ function onContinue(_x90) {
4933
4956
  return _onContinue.apply(this, arguments);
4934
4957
  }
4935
4958
  return onContinue;
@@ -4948,54 +4971,54 @@ var ClientProvider = function ClientProvider(_ref) {
4948
4971
  return logout();
4949
4972
  }, callbacks, "Failed to update phone number"));
4950
4973
  case 10:
4951
- _context106.n = 13;
4974
+ _context107.n = 13;
4952
4975
  break;
4953
4976
  case 11:
4954
- _context106.p = 11;
4955
- _t15 = _context106.v;
4977
+ _context107.p = 11;
4978
+ _t15 = _context107.v;
4956
4979
  if (!(_t15 instanceof TurnkeyError)) {
4957
- _context106.n = 12;
4980
+ _context107.n = 12;
4958
4981
  break;
4959
4982
  }
4960
4983
  throw _t15;
4961
4984
  case 12:
4962
4985
  throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t15);
4963
4986
  case 13:
4964
- return _context106.a(2);
4987
+ return _context107.a(2);
4965
4988
  }
4966
- }, _callee106, null, [[7, 11]]);
4989
+ }, _callee107, null, [[7, 11]]);
4967
4990
  }));
4968
- return function (_x88) {
4969
- return _ref122.apply(this, arguments);
4991
+ return function (_x89) {
4992
+ return _ref123.apply(this, arguments);
4970
4993
  };
4971
4994
  }(), [client, masterConfig, getSession, pushPage, closeModal, logout, initOtp, verifyOtp, updateUserPhoneNumber, user, callbacks]);
4972
4995
  var handleUpdateUserEmail = useCallback(/*#__PURE__*/function () {
4973
- var _ref124 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee108(params) {
4974
- var _ref125, _ref125$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t17;
4975
- return _regenerator().w(function (_context108) {
4976
- while (1) switch (_context108.p = _context108.n) {
4996
+ var _ref125 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee109(params) {
4997
+ var _ref126, _ref126$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t17;
4998
+ return _regenerator().w(function (_context109) {
4999
+ while (1) switch (_context109.p = _context109.n) {
4977
5000
  case 0:
4978
- _ref125 = params || {}, _ref125$successPageDu = _ref125.successPageDuration, successPageDuration = _ref125$successPageDu === void 0 ? 2000 : _ref125$successPageDu, subTitle = _ref125.subTitle, title = _ref125.title, stampWith = _ref125.stampWith;
5001
+ _ref126 = params || {}, _ref126$successPageDu = _ref126.successPageDuration, successPageDuration = _ref126$successPageDu === void 0 ? 2000 : _ref126$successPageDu, subTitle = _ref126.subTitle, title = _ref126.title, stampWith = _ref126.stampWith;
4979
5002
  if (client) {
4980
- _context108.n = 1;
5003
+ _context109.n = 1;
4981
5004
  break;
4982
5005
  }
4983
5006
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
4984
5007
  case 1:
4985
- _context108.n = 2;
5008
+ _context109.n = 2;
4986
5009
  return getSession();
4987
5010
  case 2:
4988
- s = _context108.v;
5011
+ s = _context109.v;
4989
5012
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4990
5013
  if (organizationId) {
4991
- _context108.n = 3;
5014
+ _context109.n = 3;
4992
5015
  break;
4993
5016
  }
4994
5017
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
4995
5018
  case 3:
4996
5019
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
4997
5020
  if (userId) {
4998
- _context108.n = 4;
5021
+ _context109.n = 4;
4999
5022
  break;
5000
5023
  }
5001
5024
  throw new TurnkeyError("A user ID is required to update an email.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5015,12 +5038,12 @@ var ClientProvider = function ClientProvider(_ref) {
5015
5038
  showTitle: false
5016
5039
  });
5017
5040
  };
5018
- _context108.p = 5;
5041
+ _context109.p = 5;
5019
5042
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
5020
- _context108.n = 6;
5043
+ _context109.n = 6;
5021
5044
  break;
5022
5045
  }
5023
- return _context108.a(2, withTurnkeyErrorHandling(function () {
5046
+ return _context109.a(2, withTurnkeyErrorHandling(function () {
5024
5047
  return new Promise(function (resolve, reject) {
5025
5048
  pushPage({
5026
5049
  key: "Update Email",
@@ -5048,14 +5071,14 @@ var ClientProvider = function ClientProvider(_ref) {
5048
5071
  return logout();
5049
5072
  }));
5050
5073
  case 6:
5051
- _context108.n = 7;
5074
+ _context109.n = 7;
5052
5075
  return initOtp({
5053
5076
  otpType: OtpType.Email,
5054
5077
  contact: params.email
5055
5078
  });
5056
5079
  case 7:
5057
- otpId = _context108.v;
5058
- return _context108.a(2, withTurnkeyErrorHandling(function () {
5080
+ otpId = _context109.v;
5081
+ return _context109.a(2, withTurnkeyErrorHandling(function () {
5059
5082
  return new Promise(function (resolve, reject) {
5060
5083
  var _masterConfig$auth44, _masterConfig$auth45;
5061
5084
  pushPage({
@@ -5067,13 +5090,13 @@ var ClientProvider = function ClientProvider(_ref) {
5067
5090
  otpLength: (masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth44 = masterConfig.auth) === null || _masterConfig$auth44 === void 0 ? void 0 : _masterConfig$auth44.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5068
5091
  alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth45 = masterConfig.auth) === null || _masterConfig$auth45 === void 0 ? void 0 : _masterConfig$auth45.otpAlphanumeric,
5069
5092
  onContinue: function () {
5070
- var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee107(otpCode) {
5093
+ var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee108(otpCode) {
5071
5094
  var _yield$verifyOtp2, verificationToken, res, _t16;
5072
- return _regenerator().w(function (_context107) {
5073
- while (1) switch (_context107.p = _context107.n) {
5095
+ return _regenerator().w(function (_context108) {
5096
+ while (1) switch (_context108.p = _context108.n) {
5074
5097
  case 0:
5075
- _context107.p = 0;
5076
- _context107.n = 1;
5098
+ _context108.p = 0;
5099
+ _context108.n = 1;
5077
5100
  return verifyOtp({
5078
5101
  otpId: otpId,
5079
5102
  otpCode: otpCode,
@@ -5081,9 +5104,9 @@ var ClientProvider = function ClientProvider(_ref) {
5081
5104
  otpType: OtpType.Email
5082
5105
  });
5083
5106
  case 1:
5084
- _yield$verifyOtp2 = _context107.v;
5107
+ _yield$verifyOtp2 = _context108.v;
5085
5108
  verificationToken = _yield$verifyOtp2.verificationToken;
5086
- _context107.n = 2;
5109
+ _context108.n = 2;
5087
5110
  return updateUserEmail(_objectSpread2({
5088
5111
  email: params.email,
5089
5112
  verificationToken: verificationToken,
@@ -5093,21 +5116,21 @@ var ClientProvider = function ClientProvider(_ref) {
5093
5116
  stampWith: stampWith
5094
5117
  }));
5095
5118
  case 2:
5096
- res = _context107.v;
5119
+ res = _context108.v;
5097
5120
  onSuccess();
5098
5121
  resolve(res);
5099
- _context107.n = 4;
5122
+ _context108.n = 4;
5100
5123
  break;
5101
5124
  case 3:
5102
- _context107.p = 3;
5103
- _t16 = _context107.v;
5125
+ _context108.p = 3;
5126
+ _t16 = _context108.v;
5104
5127
  reject(_t16);
5105
5128
  case 4:
5106
- return _context107.a(2);
5129
+ return _context108.a(2);
5107
5130
  }
5108
- }, _callee107, null, [[0, 3]]);
5131
+ }, _callee108, null, [[0, 3]]);
5109
5132
  }));
5110
- function onContinue(_x91) {
5133
+ function onContinue(_x92) {
5111
5134
  return _onContinue2.apply(this, arguments);
5112
5135
  }
5113
5136
  return onContinue;
@@ -5124,54 +5147,54 @@ var ClientProvider = function ClientProvider(_ref) {
5124
5147
  return logout();
5125
5148
  }, callbacks, "Failed to update email"));
5126
5149
  case 8:
5127
- _context108.n = 11;
5150
+ _context109.n = 11;
5128
5151
  break;
5129
5152
  case 9:
5130
- _context108.p = 9;
5131
- _t17 = _context108.v;
5153
+ _context109.p = 9;
5154
+ _t17 = _context109.v;
5132
5155
  if (!(_t17 instanceof TurnkeyError)) {
5133
- _context108.n = 10;
5156
+ _context109.n = 10;
5134
5157
  break;
5135
5158
  }
5136
5159
  throw _t17;
5137
5160
  case 10:
5138
5161
  throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t17);
5139
5162
  case 11:
5140
- return _context108.a(2);
5163
+ return _context109.a(2);
5141
5164
  }
5142
- }, _callee108, null, [[5, 9]]);
5165
+ }, _callee109, null, [[5, 9]]);
5143
5166
  }));
5144
- return function (_x90) {
5145
- return _ref124.apply(this, arguments);
5167
+ return function (_x91) {
5168
+ return _ref125.apply(this, arguments);
5146
5169
  };
5147
5170
  }(), [client, getSession, pushPage, closeModal, logout, initOtp, masterConfig, verifyOtp, updateUserEmail, user, callbacks]);
5148
5171
  var handleAddEmail = useCallback(/*#__PURE__*/function () {
5149
- var _ref126 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee110(params) {
5150
- var _ref127, _ref127$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t19;
5151
- return _regenerator().w(function (_context110) {
5152
- while (1) switch (_context110.p = _context110.n) {
5172
+ var _ref127 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee111(params) {
5173
+ var _ref128, _ref128$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t19;
5174
+ return _regenerator().w(function (_context111) {
5175
+ while (1) switch (_context111.p = _context111.n) {
5153
5176
  case 0:
5154
- _ref127 = params || {}, _ref127$successPageDu = _ref127.successPageDuration, successPageDuration = _ref127$successPageDu === void 0 ? 2000 : _ref127$successPageDu, subTitle = _ref127.subTitle, title = _ref127.title, stampWith = _ref127.stampWith;
5177
+ _ref128 = params || {}, _ref128$successPageDu = _ref128.successPageDuration, successPageDuration = _ref128$successPageDu === void 0 ? 2000 : _ref128$successPageDu, subTitle = _ref128.subTitle, title = _ref128.title, stampWith = _ref128.stampWith;
5155
5178
  if (client) {
5156
- _context110.n = 1;
5179
+ _context111.n = 1;
5157
5180
  break;
5158
5181
  }
5159
5182
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5160
5183
  case 1:
5161
- _context110.n = 2;
5184
+ _context111.n = 2;
5162
5185
  return getSession();
5163
5186
  case 2:
5164
- s = _context110.v;
5187
+ s = _context111.v;
5165
5188
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5166
5189
  if (organizationId) {
5167
- _context110.n = 3;
5190
+ _context111.n = 3;
5168
5191
  break;
5169
5192
  }
5170
5193
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5171
5194
  case 3:
5172
5195
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5173
5196
  if (userId) {
5174
- _context110.n = 4;
5197
+ _context111.n = 4;
5175
5198
  break;
5176
5199
  }
5177
5200
  throw new TurnkeyError("A user ID is required to add an email.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5191,12 +5214,12 @@ var ClientProvider = function ClientProvider(_ref) {
5191
5214
  showTitle: false
5192
5215
  });
5193
5216
  };
5194
- _context110.p = 5;
5217
+ _context111.p = 5;
5195
5218
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
5196
- _context110.n = 6;
5219
+ _context111.n = 6;
5197
5220
  break;
5198
5221
  }
5199
- return _context110.a(2, withTurnkeyErrorHandling(function () {
5222
+ return _context111.a(2, withTurnkeyErrorHandling(function () {
5200
5223
  return new Promise(function (resolve, reject) {
5201
5224
  pushPage({
5202
5225
  key: "Add Email",
@@ -5224,14 +5247,14 @@ var ClientProvider = function ClientProvider(_ref) {
5224
5247
  return logout();
5225
5248
  }));
5226
5249
  case 6:
5227
- _context110.n = 7;
5250
+ _context111.n = 7;
5228
5251
  return initOtp({
5229
5252
  otpType: OtpType.Email,
5230
5253
  contact: params.email
5231
5254
  });
5232
5255
  case 7:
5233
- otpId = _context110.v;
5234
- return _context110.a(2, withTurnkeyErrorHandling(function () {
5256
+ otpId = _context111.v;
5257
+ return _context111.a(2, withTurnkeyErrorHandling(function () {
5235
5258
  return new Promise(function (resolve, reject) {
5236
5259
  var _masterConfig$auth46, _masterConfig$auth47;
5237
5260
  pushPage({
@@ -5243,13 +5266,13 @@ var ClientProvider = function ClientProvider(_ref) {
5243
5266
  otpLength: (masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth46 = masterConfig.auth) === null || _masterConfig$auth46 === void 0 ? void 0 : _masterConfig$auth46.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5244
5267
  alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth47 = masterConfig.auth) === null || _masterConfig$auth47 === void 0 ? void 0 : _masterConfig$auth47.otpAlphanumeric,
5245
5268
  onContinue: function () {
5246
- var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee109(otpCode) {
5269
+ var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee110(otpCode) {
5247
5270
  var _yield$verifyOtp3, verificationToken, res, _t18;
5248
- return _regenerator().w(function (_context109) {
5249
- while (1) switch (_context109.p = _context109.n) {
5271
+ return _regenerator().w(function (_context110) {
5272
+ while (1) switch (_context110.p = _context110.n) {
5250
5273
  case 0:
5251
- _context109.p = 0;
5252
- _context109.n = 1;
5274
+ _context110.p = 0;
5275
+ _context110.n = 1;
5253
5276
  return verifyOtp({
5254
5277
  otpId: otpId,
5255
5278
  otpCode: otpCode,
@@ -5257,9 +5280,9 @@ var ClientProvider = function ClientProvider(_ref) {
5257
5280
  otpType: OtpType.Email
5258
5281
  });
5259
5282
  case 1:
5260
- _yield$verifyOtp3 = _context109.v;
5283
+ _yield$verifyOtp3 = _context110.v;
5261
5284
  verificationToken = _yield$verifyOtp3.verificationToken;
5262
- _context109.n = 2;
5285
+ _context110.n = 2;
5263
5286
  return updateUserEmail({
5264
5287
  email: params.email,
5265
5288
  verificationToken: verificationToken,
@@ -5268,21 +5291,21 @@ var ClientProvider = function ClientProvider(_ref) {
5268
5291
  stampWith: stampWith
5269
5292
  });
5270
5293
  case 2:
5271
- res = _context109.v;
5294
+ res = _context110.v;
5272
5295
  onSuccess();
5273
5296
  resolve(res);
5274
- _context109.n = 4;
5297
+ _context110.n = 4;
5275
5298
  break;
5276
5299
  case 3:
5277
- _context109.p = 3;
5278
- _t18 = _context109.v;
5300
+ _context110.p = 3;
5301
+ _t18 = _context110.v;
5279
5302
  reject(_t18);
5280
5303
  case 4:
5281
- return _context109.a(2);
5304
+ return _context110.a(2);
5282
5305
  }
5283
- }, _callee109, null, [[0, 3]]);
5306
+ }, _callee110, null, [[0, 3]]);
5284
5307
  }));
5285
- function onContinue(_x93) {
5308
+ function onContinue(_x94) {
5286
5309
  return _onContinue3.apply(this, arguments);
5287
5310
  }
5288
5311
  return onContinue;
@@ -5299,67 +5322,67 @@ var ClientProvider = function ClientProvider(_ref) {
5299
5322
  return logout();
5300
5323
  }, callbacks, "Failed to add email"));
5301
5324
  case 8:
5302
- _context110.n = 11;
5325
+ _context111.n = 11;
5303
5326
  break;
5304
5327
  case 9:
5305
- _context110.p = 9;
5306
- _t19 = _context110.v;
5328
+ _context111.p = 9;
5329
+ _t19 = _context111.v;
5307
5330
  if (!(_t19 instanceof TurnkeyError)) {
5308
- _context110.n = 10;
5331
+ _context111.n = 10;
5309
5332
  break;
5310
5333
  }
5311
5334
  throw _t19;
5312
5335
  case 10:
5313
5336
  throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t19);
5314
5337
  case 11:
5315
- return _context110.a(2);
5338
+ return _context111.a(2);
5316
5339
  }
5317
- }, _callee110, null, [[5, 9]]);
5340
+ }, _callee111, null, [[5, 9]]);
5318
5341
  }));
5319
- return function (_x92) {
5320
- return _ref126.apply(this, arguments);
5342
+ return function (_x93) {
5343
+ return _ref127.apply(this, arguments);
5321
5344
  };
5322
5345
  }(), [client, getSession, pushPage, closeModal, user, logout, initOtp, masterConfig, verifyOtp, updateUserEmail, callbacks]);
5323
5346
  var handleAddPhoneNumber = useCallback(/*#__PURE__*/function () {
5324
- var _ref128 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee112(params) {
5347
+ var _ref129 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee113(params) {
5325
5348
  var _masterConfig$auth48, _masterConfig$auth48$;
5326
- var _ref129, _ref129$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t21;
5327
- return _regenerator().w(function (_context112) {
5328
- while (1) switch (_context112.p = _context112.n) {
5349
+ var _ref130, _ref130$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t21;
5350
+ return _regenerator().w(function (_context113) {
5351
+ while (1) switch (_context113.p = _context113.n) {
5329
5352
  case 0:
5330
- _ref129 = params || {}, _ref129$successPageDu = _ref129.successPageDuration, successPageDuration = _ref129$successPageDu === void 0 ? 2000 : _ref129$successPageDu, subTitle = _ref129.subTitle, title = _ref129.title, stampWith = _ref129.stampWith;
5353
+ _ref130 = params || {}, _ref130$successPageDu = _ref130.successPageDuration, successPageDuration = _ref130$successPageDu === void 0 ? 2000 : _ref130$successPageDu, subTitle = _ref130.subTitle, title = _ref130.title, stampWith = _ref130.stampWith;
5331
5354
  if (client) {
5332
- _context112.n = 1;
5355
+ _context113.n = 1;
5333
5356
  break;
5334
5357
  }
5335
5358
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5336
5359
  case 1:
5337
5360
  if (masterConfig) {
5338
- _context112.n = 2;
5361
+ _context113.n = 2;
5339
5362
  break;
5340
5363
  }
5341
5364
  throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
5342
5365
  case 2:
5343
5366
  if ((_masterConfig$auth48 = masterConfig.auth) !== null && _masterConfig$auth48 !== void 0 && (_masterConfig$auth48$ = _masterConfig$auth48.methods) !== null && _masterConfig$auth48$ !== void 0 && _masterConfig$auth48$.smsOtpAuthEnabled) {
5344
- _context112.n = 3;
5367
+ _context113.n = 3;
5345
5368
  break;
5346
5369
  }
5347
5370
  throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
5348
5371
  case 3:
5349
- _context112.n = 4;
5372
+ _context113.n = 4;
5350
5373
  return getSession();
5351
5374
  case 4:
5352
- s = _context112.v;
5375
+ s = _context113.v;
5353
5376
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5354
5377
  if (organizationId) {
5355
- _context112.n = 5;
5378
+ _context113.n = 5;
5356
5379
  break;
5357
5380
  }
5358
5381
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5359
5382
  case 5:
5360
5383
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5361
5384
  if (userId) {
5362
- _context112.n = 6;
5385
+ _context113.n = 6;
5363
5386
  break;
5364
5387
  }
5365
5388
  throw new TurnkeyError("A user ID is required to add a phone number.", TurnkeyErrorCodes.INVALID_REQUEST);
@@ -5379,12 +5402,12 @@ var ClientProvider = function ClientProvider(_ref) {
5379
5402
  showTitle: false
5380
5403
  });
5381
5404
  };
5382
- _context112.p = 7;
5405
+ _context113.p = 7;
5383
5406
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
5384
- _context112.n = 8;
5407
+ _context113.n = 8;
5385
5408
  break;
5386
5409
  }
5387
- return _context112.a(2, withTurnkeyErrorHandling(function () {
5410
+ return _context113.a(2, withTurnkeyErrorHandling(function () {
5388
5411
  return new Promise(function (resolve, reject) {
5389
5412
  pushPage({
5390
5413
  key: "Add Phone Number",
@@ -5412,14 +5435,14 @@ var ClientProvider = function ClientProvider(_ref) {
5412
5435
  return logout();
5413
5436
  }, callbacks, "Failed to add phone number"));
5414
5437
  case 8:
5415
- _context112.n = 9;
5438
+ _context113.n = 9;
5416
5439
  return initOtp({
5417
5440
  otpType: OtpType.Sms,
5418
5441
  contact: params.phoneNumber
5419
5442
  });
5420
5443
  case 9:
5421
- otpId = _context112.v;
5422
- return _context112.a(2, withTurnkeyErrorHandling(function () {
5444
+ otpId = _context113.v;
5445
+ return _context113.a(2, withTurnkeyErrorHandling(function () {
5423
5446
  return new Promise(function (resolve, reject) {
5424
5447
  var _masterConfig$auth49, _masterConfig$auth50;
5425
5448
  pushPage({
@@ -5431,13 +5454,13 @@ var ClientProvider = function ClientProvider(_ref) {
5431
5454
  otpLength: ((_masterConfig$auth49 = masterConfig.auth) === null || _masterConfig$auth49 === void 0 ? void 0 : _masterConfig$auth49.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5432
5455
  alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth50 = masterConfig.auth) === null || _masterConfig$auth50 === void 0 ? void 0 : _masterConfig$auth50.otpAlphanumeric,
5433
5456
  onContinue: function () {
5434
- var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee111(otpCode) {
5457
+ var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee112(otpCode) {
5435
5458
  var _yield$verifyOtp4, verificationToken, res, _t20;
5436
- return _regenerator().w(function (_context111) {
5437
- while (1) switch (_context111.p = _context111.n) {
5459
+ return _regenerator().w(function (_context112) {
5460
+ while (1) switch (_context112.p = _context112.n) {
5438
5461
  case 0:
5439
- _context111.p = 0;
5440
- _context111.n = 1;
5462
+ _context112.p = 0;
5463
+ _context112.n = 1;
5441
5464
  return verifyOtp({
5442
5465
  otpId: otpId,
5443
5466
  otpCode: otpCode,
@@ -5445,9 +5468,9 @@ var ClientProvider = function ClientProvider(_ref) {
5445
5468
  otpType: OtpType.Sms
5446
5469
  });
5447
5470
  case 1:
5448
- _yield$verifyOtp4 = _context111.v;
5471
+ _yield$verifyOtp4 = _context112.v;
5449
5472
  verificationToken = _yield$verifyOtp4.verificationToken;
5450
- _context111.n = 2;
5473
+ _context112.n = 2;
5451
5474
  return updateUserPhoneNumber({
5452
5475
  phoneNumber: params.phoneNumber,
5453
5476
  verificationToken: verificationToken,
@@ -5456,21 +5479,21 @@ var ClientProvider = function ClientProvider(_ref) {
5456
5479
  stampWith: stampWith
5457
5480
  });
5458
5481
  case 2:
5459
- res = _context111.v;
5482
+ res = _context112.v;
5460
5483
  onSuccess();
5461
5484
  resolve(res);
5462
- _context111.n = 4;
5485
+ _context112.n = 4;
5463
5486
  break;
5464
5487
  case 3:
5465
- _context111.p = 3;
5466
- _t20 = _context111.v;
5488
+ _context112.p = 3;
5489
+ _t20 = _context112.v;
5467
5490
  reject(_t20);
5468
5491
  case 4:
5469
- return _context111.a(2);
5492
+ return _context112.a(2);
5470
5493
  }
5471
- }, _callee111, null, [[0, 3]]);
5494
+ }, _callee112, null, [[0, 3]]);
5472
5495
  }));
5473
- function onContinue(_x95) {
5496
+ function onContinue(_x96) {
5474
5497
  return _onContinue4.apply(this, arguments);
5475
5498
  }
5476
5499
  return onContinue;
@@ -5489,52 +5512,52 @@ var ClientProvider = function ClientProvider(_ref) {
5489
5512
  return logout();
5490
5513
  }, callbacks, "Failed to add phone number"));
5491
5514
  case 10:
5492
- _context112.n = 13;
5515
+ _context113.n = 13;
5493
5516
  break;
5494
5517
  case 11:
5495
- _context112.p = 11;
5496
- _t21 = _context112.v;
5518
+ _context113.p = 11;
5519
+ _t21 = _context113.v;
5497
5520
  if (!(_t21 instanceof TurnkeyError)) {
5498
- _context112.n = 12;
5521
+ _context113.n = 12;
5499
5522
  break;
5500
5523
  }
5501
5524
  throw _t21;
5502
5525
  case 12:
5503
5526
  throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t21);
5504
5527
  case 13:
5505
- return _context112.a(2);
5528
+ return _context113.a(2);
5506
5529
  }
5507
- }, _callee112, null, [[7, 11]]);
5530
+ }, _callee113, null, [[7, 11]]);
5508
5531
  }));
5509
- return function (_x94) {
5510
- return _ref128.apply(this, arguments);
5532
+ return function (_x95) {
5533
+ return _ref129.apply(this, arguments);
5511
5534
  };
5512
5535
  }(), [client, masterConfig, getSession, pushPage, closeModal, user, logout, callbacks, initOtp, verifyOtp, updateUserPhoneNumber]);
5513
5536
  var handleRemovePasskey = useCallback(/*#__PURE__*/function () {
5514
- var _ref130 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee113(params) {
5537
+ var _ref131 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee114(params) {
5515
5538
  var authenticatorId, _params$successPageDu2, successPageDuration, subTitle, title, stampWith, userId, s, organizationId;
5516
- return _regenerator().w(function (_context113) {
5517
- while (1) switch (_context113.n) {
5539
+ return _regenerator().w(function (_context114) {
5540
+ while (1) switch (_context114.n) {
5518
5541
  case 0:
5519
5542
  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;
5520
5543
  if (client) {
5521
- _context113.n = 1;
5544
+ _context114.n = 1;
5522
5545
  break;
5523
5546
  }
5524
5547
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5525
5548
  case 1:
5526
- _context113.n = 2;
5549
+ _context114.n = 2;
5527
5550
  return getSession();
5528
5551
  case 2:
5529
- s = _context113.v;
5552
+ s = _context114.v;
5530
5553
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5531
5554
  if (organizationId) {
5532
- _context113.n = 3;
5555
+ _context114.n = 3;
5533
5556
  break;
5534
5557
  }
5535
5558
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5536
5559
  case 3:
5537
- return _context113.a(2, withTurnkeyErrorHandling(function () {
5560
+ return _context114.a(2, withTurnkeyErrorHandling(function () {
5538
5561
  return new Promise(function (resolve, reject) {
5539
5562
  pushPage({
5540
5563
  key: "Remove Passkey",
@@ -5565,44 +5588,44 @@ var ClientProvider = function ClientProvider(_ref) {
5565
5588
  return logout();
5566
5589
  }, callbacks, "Failed to remove passkey"));
5567
5590
  }
5568
- }, _callee113);
5591
+ }, _callee114);
5569
5592
  }));
5570
- return function (_x96) {
5571
- return _ref130.apply(this, arguments);
5593
+ return function (_x97) {
5594
+ return _ref131.apply(this, arguments);
5572
5595
  };
5573
5596
  }(), [client, getSession, pushPage, logout, callbacks]);
5574
5597
  var handleAddPasskey = useCallback(/*#__PURE__*/function () {
5575
- var _ref131 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee114(params) {
5576
- var _ref132, name, displayName, _ref132$successPageDu, successPageDuration, stampWith, s, organizationId, userId, resPromise, _t22;
5577
- return _regenerator().w(function (_context114) {
5578
- while (1) switch (_context114.p = _context114.n) {
5598
+ var _ref132 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee115(params) {
5599
+ var _ref133, name, displayName, _ref133$successPageDu, successPageDuration, stampWith, s, organizationId, userId, resPromise, _t22;
5600
+ return _regenerator().w(function (_context115) {
5601
+ while (1) switch (_context115.p = _context115.n) {
5579
5602
  case 0:
5580
- _ref132 = params || {}, name = _ref132.name, displayName = _ref132.displayName, _ref132$successPageDu = _ref132.successPageDuration, successPageDuration = _ref132$successPageDu === void 0 ? 2000 : _ref132$successPageDu, stampWith = _ref132.stampWith;
5603
+ _ref133 = params || {}, name = _ref133.name, displayName = _ref133.displayName, _ref133$successPageDu = _ref133.successPageDuration, successPageDuration = _ref133$successPageDu === void 0 ? 2000 : _ref133$successPageDu, stampWith = _ref133.stampWith;
5581
5604
  if (client) {
5582
- _context114.n = 1;
5605
+ _context115.n = 1;
5583
5606
  break;
5584
5607
  }
5585
5608
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5586
5609
  case 1:
5587
- _context114.n = 2;
5610
+ _context115.n = 2;
5588
5611
  return getSession();
5589
5612
  case 2:
5590
- s = _context114.v;
5613
+ s = _context115.v;
5591
5614
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5592
5615
  if (organizationId) {
5593
- _context114.n = 3;
5616
+ _context115.n = 3;
5594
5617
  break;
5595
5618
  }
5596
5619
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5597
5620
  case 3:
5598
5621
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5599
5622
  if (userId) {
5600
- _context114.n = 4;
5623
+ _context115.n = 4;
5601
5624
  break;
5602
5625
  }
5603
5626
  throw new TurnkeyError("A user ID or a valid session is required to add a passkey.", TurnkeyErrorCodes.INVALID_REQUEST);
5604
5627
  case 4:
5605
- _context114.p = 4;
5628
+ _context115.p = 4;
5606
5629
  resPromise = addPasskey(_objectSpread2(_objectSpread2(_objectSpread2({}, name && {
5607
5630
  name: name
5608
5631
  }), displayName && {
@@ -5627,55 +5650,55 @@ var ClientProvider = function ClientProvider(_ref) {
5627
5650
  showTitle: false
5628
5651
  });
5629
5652
  });
5630
- _context114.n = 5;
5653
+ _context115.n = 5;
5631
5654
  return resPromise;
5632
5655
  case 5:
5633
- return _context114.a(2, _context114.v);
5656
+ return _context115.a(2, _context115.v);
5634
5657
  case 6:
5635
- _context114.p = 6;
5636
- _t22 = _context114.v;
5658
+ _context115.p = 6;
5659
+ _t22 = _context115.v;
5637
5660
  if (!(_t22 instanceof TurnkeyError)) {
5638
- _context114.n = 7;
5661
+ _context115.n = 7;
5639
5662
  break;
5640
5663
  }
5641
5664
  throw _t22;
5642
5665
  case 7:
5643
5666
  throw new TurnkeyError("Failed to add passkey in handler.", TurnkeyErrorCodes.ADD_PASSKEY_ERROR, _t22);
5644
5667
  case 8:
5645
- return _context114.a(2);
5668
+ return _context115.a(2);
5646
5669
  }
5647
- }, _callee114, null, [[4, 6]]);
5670
+ }, _callee115, null, [[4, 6]]);
5648
5671
  }));
5649
- return function (_x97) {
5650
- return _ref131.apply(this, arguments);
5672
+ return function (_x98) {
5673
+ return _ref132.apply(this, arguments);
5651
5674
  };
5652
5675
  }(), [client, getSession, addPasskey, pushPage, closeModal]);
5653
5676
  var handleRemoveOauthProvider = useCallback(/*#__PURE__*/function () {
5654
- var _ref133 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee115(params) {
5677
+ var _ref134 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee116(params) {
5655
5678
  var providerId, _params$successPageDu3, successPageDuration, subTitle, title, stampWith, s, organizationId, _t23;
5656
- return _regenerator().w(function (_context115) {
5657
- while (1) switch (_context115.p = _context115.n) {
5679
+ return _regenerator().w(function (_context116) {
5680
+ while (1) switch (_context116.p = _context116.n) {
5658
5681
  case 0:
5659
5682
  providerId = params.providerId, _params$successPageDu3 = params.successPageDuration, successPageDuration = _params$successPageDu3 === void 0 ? 2000 : _params$successPageDu3, subTitle = params.subTitle, title = params.title, stampWith = params.stampWith;
5660
5683
  if (client) {
5661
- _context115.n = 1;
5684
+ _context116.n = 1;
5662
5685
  break;
5663
5686
  }
5664
5687
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5665
5688
  case 1:
5666
- _context115.n = 2;
5689
+ _context116.n = 2;
5667
5690
  return getSession();
5668
5691
  case 2:
5669
- s = _context115.v;
5692
+ s = _context116.v;
5670
5693
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5671
5694
  if (organizationId) {
5672
- _context115.n = 3;
5695
+ _context116.n = 3;
5673
5696
  break;
5674
5697
  }
5675
5698
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5676
5699
  case 3:
5677
- _context115.p = 3;
5678
- return _context115.a(2, new Promise(function (resolve, reject) {
5700
+ _context116.p = 3;
5701
+ return _context116.a(2, new Promise(function (resolve, reject) {
5679
5702
  pushPage({
5680
5703
  key: "Remove OAuth Provider",
5681
5704
  content: jsx(RemoveOAuthProvider, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5703,69 +5726,69 @@ var ClientProvider = function ClientProvider(_ref) {
5703
5726
  });
5704
5727
  }));
5705
5728
  case 4:
5706
- _context115.p = 4;
5707
- _t23 = _context115.v;
5729
+ _context116.p = 4;
5730
+ _t23 = _context116.v;
5708
5731
  if (!(_t23 instanceof TurnkeyError)) {
5709
- _context115.n = 5;
5732
+ _context116.n = 5;
5710
5733
  break;
5711
5734
  }
5712
5735
  throw _t23;
5713
5736
  case 5:
5714
5737
  throw new TurnkeyError("Failed to remove OAuth provider in handler.", TurnkeyErrorCodes.REMOVE_OAUTH_PROVIDER_ERROR, _t23);
5715
5738
  case 6:
5716
- return _context115.a(2);
5739
+ return _context116.a(2);
5717
5740
  }
5718
- }, _callee115, null, [[3, 4]]);
5741
+ }, _callee116, null, [[3, 4]]);
5719
5742
  }));
5720
- return function (_x98) {
5721
- return _ref133.apply(this, arguments);
5743
+ return function (_x99) {
5744
+ return _ref134.apply(this, arguments);
5722
5745
  };
5723
5746
  }(), [client, getSession, pushPage]);
5724
5747
  var handleAddOauthProvider = useCallback(/*#__PURE__*/function () {
5725
- var _ref134 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee118(params) {
5748
+ var _ref135 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee119(params) {
5726
5749
  var _masterConfig$auth$oa7, _masterConfig$auth51, _masterConfig$auth51$;
5727
5750
  var providerName, stampWith, _params$successPageDu4, successPageDuration, _params$openInPage, openInPage, s, organizationId, userId;
5728
- return _regenerator().w(function (_context118) {
5729
- while (1) switch (_context118.n) {
5751
+ return _regenerator().w(function (_context119) {
5752
+ while (1) switch (_context119.n) {
5730
5753
  case 0:
5731
5754
  if (client) {
5732
- _context118.n = 1;
5755
+ _context119.n = 1;
5733
5756
  break;
5734
5757
  }
5735
5758
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5736
5759
  case 1:
5737
5760
  providerName = params.providerName, stampWith = params.stampWith, _params$successPageDu4 = params.successPageDuration, successPageDuration = _params$successPageDu4 === void 0 ? 2000 : _params$successPageDu4, _params$openInPage = params.openInPage, openInPage = _params$openInPage === void 0 ? (_masterConfig$auth$oa7 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth51 = masterConfig.auth) === null || _masterConfig$auth51 === void 0 ? void 0 : (_masterConfig$auth51$ = _masterConfig$auth51.oauthConfig) === null || _masterConfig$auth51$ === void 0 ? void 0 : _masterConfig$auth51$.openOauthInPage) !== null && _masterConfig$auth$oa7 !== void 0 ? _masterConfig$auth$oa7 : false : _params$openInPage;
5738
- _context118.n = 2;
5761
+ _context119.n = 2;
5739
5762
  return getSession();
5740
5763
  case 2:
5741
- s = _context118.v;
5764
+ s = _context119.v;
5742
5765
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5743
5766
  if (organizationId) {
5744
- _context118.n = 3;
5767
+ _context119.n = 3;
5745
5768
  break;
5746
5769
  }
5747
5770
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5748
5771
  case 3:
5749
5772
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5750
5773
  if (userId) {
5751
- _context118.n = 4;
5774
+ _context119.n = 4;
5752
5775
  break;
5753
5776
  }
5754
5777
  throw new TurnkeyError("A user ID is required to add an OAuth provider.", TurnkeyErrorCodes.INVALID_REQUEST);
5755
5778
  case 4:
5756
- return _context118.a(2, new Promise(/*#__PURE__*/function () {
5757
- var _ref135 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee117(resolve, reject) {
5779
+ return _context119.a(2, new Promise(/*#__PURE__*/function () {
5780
+ var _ref136 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee118(resolve, reject) {
5758
5781
  var onOauthSuccess, additionalState, _t24, _t25;
5759
- return _regenerator().w(function (_context117) {
5760
- while (1) switch (_context117.p = _context117.n) {
5782
+ return _regenerator().w(function (_context118) {
5783
+ while (1) switch (_context118.p = _context118.n) {
5761
5784
  case 0:
5762
- _context117.p = 0;
5785
+ _context118.p = 0;
5763
5786
  onOauthSuccess = /*#__PURE__*/function () {
5764
- var _ref136 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee116(params) {
5765
- return _regenerator().w(function (_context116) {
5766
- while (1) switch (_context116.n) {
5787
+ var _ref137 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee117(params) {
5788
+ return _regenerator().w(function (_context117) {
5789
+ while (1) switch (_context117.n) {
5767
5790
  case 0:
5768
- _context116.n = 1;
5791
+ _context117.n = 1;
5769
5792
  return addOauthProvider({
5770
5793
  providerName: params.providerName,
5771
5794
  oidcToken: params.oidcToken,
@@ -5788,12 +5811,12 @@ var ClientProvider = function ClientProvider(_ref) {
5788
5811
  showTitle: false
5789
5812
  });
5790
5813
  case 2:
5791
- return _context116.a(2);
5814
+ return _context117.a(2);
5792
5815
  }
5793
- }, _callee116);
5816
+ }, _callee117);
5794
5817
  }));
5795
- return function onOauthSuccess(_x102) {
5796
- return _ref136.apply(this, arguments);
5818
+ return function onOauthSuccess(_x103) {
5819
+ return _ref137.apply(this, arguments);
5797
5820
  };
5798
5821
  }();
5799
5822
  if (openInPage) {
@@ -5812,10 +5835,10 @@ var ClientProvider = function ClientProvider(_ref) {
5812
5835
  openModal: "true"
5813
5836
  }) : undefined;
5814
5837
  _t24 = providerName;
5815
- _context117.n = _t24 === OAuthProviders.DISCORD ? 1 : _t24 === OAuthProviders.X ? 3 : _t24 === OAuthProviders.GOOGLE ? 5 : _t24 === OAuthProviders.APPLE ? 7 : _t24 === OAuthProviders.FACEBOOK ? 9 : 11;
5838
+ _context118.n = _t24 === OAuthProviders.DISCORD ? 1 : _t24 === OAuthProviders.X ? 3 : _t24 === OAuthProviders.GOOGLE ? 5 : _t24 === OAuthProviders.APPLE ? 7 : _t24 === OAuthProviders.FACEBOOK ? 9 : 11;
5816
5839
  break;
5817
5840
  case 1:
5818
- _context117.n = 2;
5841
+ _context118.n = 2;
5819
5842
  return handleDiscordOauth(_objectSpread2(_objectSpread2({
5820
5843
  openInPage: openInPage
5821
5844
  }, additionalState && {
@@ -5824,9 +5847,9 @@ var ClientProvider = function ClientProvider(_ref) {
5824
5847
  onOauthSuccess: onOauthSuccess
5825
5848
  }));
5826
5849
  case 2:
5827
- return _context117.a(2, _context117.v);
5850
+ return _context118.a(2, _context118.v);
5828
5851
  case 3:
5829
- _context117.n = 4;
5852
+ _context118.n = 4;
5830
5853
  return handleXOauth(_objectSpread2(_objectSpread2({
5831
5854
  openInPage: openInPage
5832
5855
  }, additionalState && {
@@ -5835,9 +5858,9 @@ var ClientProvider = function ClientProvider(_ref) {
5835
5858
  onOauthSuccess: onOauthSuccess
5836
5859
  }));
5837
5860
  case 4:
5838
- return _context117.a(2, _context117.v);
5861
+ return _context118.a(2, _context118.v);
5839
5862
  case 5:
5840
- _context117.n = 6;
5863
+ _context118.n = 6;
5841
5864
  return handleGoogleOauth(_objectSpread2(_objectSpread2({
5842
5865
  openInPage: openInPage
5843
5866
  }, additionalState && {
@@ -5846,9 +5869,9 @@ var ClientProvider = function ClientProvider(_ref) {
5846
5869
  onOauthSuccess: onOauthSuccess
5847
5870
  }));
5848
5871
  case 6:
5849
- return _context117.a(2, _context117.v);
5872
+ return _context118.a(2, _context118.v);
5850
5873
  case 7:
5851
- _context117.n = 8;
5874
+ _context118.n = 8;
5852
5875
  return handleAppleOauth(_objectSpread2(_objectSpread2({
5853
5876
  openInPage: openInPage
5854
5877
  }, additionalState && {
@@ -5857,9 +5880,9 @@ var ClientProvider = function ClientProvider(_ref) {
5857
5880
  onOauthSuccess: onOauthSuccess
5858
5881
  }));
5859
5882
  case 8:
5860
- return _context117.a(2, _context117.v);
5883
+ return _context118.a(2, _context118.v);
5861
5884
  case 9:
5862
- _context117.n = 10;
5885
+ _context118.n = 10;
5863
5886
  return handleFacebookOauth(_objectSpread2(_objectSpread2({
5864
5887
  openInPage: openInPage
5865
5888
  }, additionalState && {
@@ -5868,53 +5891,53 @@ var ClientProvider = function ClientProvider(_ref) {
5868
5891
  onOauthSuccess: onOauthSuccess
5869
5892
  }));
5870
5893
  case 10:
5871
- return _context117.a(2, _context117.v);
5894
+ return _context118.a(2, _context118.v);
5872
5895
  case 11:
5873
5896
  throw new TurnkeyError("Unsupported OAuth provider: ".concat(providerName), TurnkeyErrorCodes.NOT_FOUND);
5874
5897
  case 12:
5875
- _context117.n = 14;
5898
+ _context118.n = 14;
5876
5899
  break;
5877
5900
  case 13:
5878
- _context117.p = 13;
5879
- _t25 = _context117.v;
5901
+ _context118.p = 13;
5902
+ _t25 = _context118.v;
5880
5903
  reject(_t25);
5881
5904
  case 14:
5882
- return _context117.a(2);
5905
+ return _context118.a(2);
5883
5906
  }
5884
- }, _callee117, null, [[0, 13]]);
5907
+ }, _callee118, null, [[0, 13]]);
5885
5908
  }));
5886
- return function (_x100, _x101) {
5887
- return _ref135.apply(this, arguments);
5909
+ return function (_x101, _x102) {
5910
+ return _ref136.apply(this, arguments);
5888
5911
  };
5889
5912
  }()));
5890
5913
  }
5891
- }, _callee118);
5914
+ }, _callee119);
5892
5915
  }));
5893
- return function (_x99) {
5894
- return _ref134.apply(this, arguments);
5916
+ return function (_x100) {
5917
+ return _ref135.apply(this, arguments);
5895
5918
  };
5896
5919
  }(), [client, getSession, addOauthProvider, pushPage, closeModal, handleDiscordOauth, handleXOauth, handleGoogleOauth, handleAppleOauth, handleFacebookOauth]);
5897
5920
  var handleConnectExternalWallet = useCallback(/*#__PURE__*/function () {
5898
- var _ref137 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee119(params) {
5921
+ var _ref138 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee120(params) {
5899
5922
  var _masterConfig$walletC4, _masterConfig$walletC5;
5900
- var _ref138, _ref138$successPageDu, successPageDuration;
5901
- return _regenerator().w(function (_context119) {
5902
- while (1) switch (_context119.n) {
5923
+ var _ref139, _ref139$successPageDu, successPageDuration;
5924
+ return _regenerator().w(function (_context120) {
5925
+ while (1) switch (_context120.n) {
5903
5926
  case 0:
5904
- _ref138 = params || {}, _ref138$successPageDu = _ref138.successPageDuration, successPageDuration = _ref138$successPageDu === void 0 ? 2000 : _ref138$successPageDu;
5927
+ _ref139 = params || {}, _ref139$successPageDu = _ref139.successPageDuration, successPageDuration = _ref139$successPageDu === void 0 ? 2000 : _ref139$successPageDu;
5905
5928
  if (client) {
5906
- _context119.n = 1;
5929
+ _context120.n = 1;
5907
5930
  break;
5908
5931
  }
5909
5932
  throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
5910
5933
  case 1:
5911
5934
  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) {
5912
- _context119.n = 2;
5935
+ _context120.n = 2;
5913
5936
  break;
5914
5937
  }
5915
5938
  throw new TurnkeyError("Wallet connecting is not enabled.", TurnkeyErrorCodes.FEATURE_NOT_ENABLED);
5916
5939
  case 2:
5917
- return _context119.a(2, new Promise(function (resolve, reject) {
5940
+ return _context120.a(2, new Promise(function (resolve, reject) {
5918
5941
  pushPage({
5919
5942
  key: "Connect wallet",
5920
5943
  content: jsx(ConnectWalletModal, {
@@ -5932,32 +5955,32 @@ var ClientProvider = function ClientProvider(_ref) {
5932
5955
  });
5933
5956
  }));
5934
5957
  }
5935
- }, _callee119);
5958
+ }, _callee120);
5936
5959
  }));
5937
- return function (_x103) {
5938
- return _ref137.apply(this, arguments);
5960
+ return function (_x104) {
5961
+ return _ref138.apply(this, arguments);
5939
5962
  };
5940
5963
  }(), [client, masterConfig, fetchWalletProviders, pushPage]);
5941
5964
  var handleRemoveUserEmail = useCallback(/*#__PURE__*/function () {
5942
- var _ref139 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee120(params) {
5943
- var _ref140, _ref140$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t26;
5944
- return _regenerator().w(function (_context120) {
5945
- while (1) switch (_context120.p = _context120.n) {
5965
+ var _ref140 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee121(params) {
5966
+ var _ref141, _ref141$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t26;
5967
+ return _regenerator().w(function (_context121) {
5968
+ while (1) switch (_context121.p = _context121.n) {
5946
5969
  case 0:
5947
- _ref140 = params || {}, _ref140$successPageDu = _ref140.successPageDuration, successPageDuration = _ref140$successPageDu === void 0 ? 2000 : _ref140$successPageDu, stampWith = _ref140.stampWith, userId = _ref140.userId;
5948
- _context120.n = 1;
5970
+ _ref141 = params || {}, _ref141$successPageDu = _ref141.successPageDuration, successPageDuration = _ref141$successPageDu === void 0 ? 2000 : _ref141$successPageDu, stampWith = _ref141.stampWith, userId = _ref141.userId;
5971
+ _context121.n = 1;
5949
5972
  return getSession();
5950
5973
  case 1:
5951
- s = _context120.v;
5974
+ s = _context121.v;
5952
5975
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5953
5976
  if (organizationId) {
5954
- _context120.n = 2;
5977
+ _context121.n = 2;
5955
5978
  break;
5956
5979
  }
5957
5980
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
5958
5981
  case 2:
5959
- _context120.p = 2;
5960
- return _context120.a(2, new Promise(function (resolve, reject) {
5982
+ _context121.p = 2;
5983
+ return _context121.a(2, new Promise(function (resolve, reject) {
5961
5984
  pushPage({
5962
5985
  key: "Remove Email",
5963
5986
  content: jsx(RemoveEmail, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5984,44 +6007,44 @@ var ClientProvider = function ClientProvider(_ref) {
5984
6007
  });
5985
6008
  }));
5986
6009
  case 3:
5987
- _context120.p = 3;
5988
- _t26 = _context120.v;
6010
+ _context121.p = 3;
6011
+ _t26 = _context121.v;
5989
6012
  if (!(_t26 instanceof TurnkeyError)) {
5990
- _context120.n = 4;
6013
+ _context121.n = 4;
5991
6014
  break;
5992
6015
  }
5993
6016
  throw _t26;
5994
6017
  case 4:
5995
6018
  throw new TurnkeyError("Failed to remove user email.", TurnkeyErrorCodes.UPDATE_USER_EMAIL_ERROR, _t26);
5996
6019
  case 5:
5997
- return _context120.a(2);
6020
+ return _context121.a(2);
5998
6021
  }
5999
- }, _callee120, null, [[2, 3]]);
6022
+ }, _callee121, null, [[2, 3]]);
6000
6023
  }));
6001
- return function (_x104) {
6002
- return _ref139.apply(this, arguments);
6024
+ return function (_x105) {
6025
+ return _ref140.apply(this, arguments);
6003
6026
  };
6004
6027
  }(), [getSession, pushPage]);
6005
6028
  var handleRemoveUserPhoneNumber = useCallback(/*#__PURE__*/function () {
6006
- var _ref141 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee121(params) {
6007
- var _ref142, _ref142$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t27;
6008
- return _regenerator().w(function (_context121) {
6009
- while (1) switch (_context121.p = _context121.n) {
6029
+ var _ref142 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee122(params) {
6030
+ var _ref143, _ref143$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t27;
6031
+ return _regenerator().w(function (_context122) {
6032
+ while (1) switch (_context122.p = _context122.n) {
6010
6033
  case 0:
6011
- _ref142 = params || {}, _ref142$successPageDu = _ref142.successPageDuration, successPageDuration = _ref142$successPageDu === void 0 ? 2000 : _ref142$successPageDu, stampWith = _ref142.stampWith, userId = _ref142.userId;
6012
- _context121.n = 1;
6034
+ _ref143 = params || {}, _ref143$successPageDu = _ref143.successPageDuration, successPageDuration = _ref143$successPageDu === void 0 ? 2000 : _ref143$successPageDu, stampWith = _ref143.stampWith, userId = _ref143.userId;
6035
+ _context122.n = 1;
6013
6036
  return getSession();
6014
6037
  case 1:
6015
- s = _context121.v;
6038
+ s = _context122.v;
6016
6039
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
6017
6040
  if (organizationId) {
6018
- _context121.n = 2;
6041
+ _context122.n = 2;
6019
6042
  break;
6020
6043
  }
6021
6044
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
6022
6045
  case 2:
6023
- _context121.p = 2;
6024
- return _context121.a(2, new Promise(function (resolve, reject) {
6046
+ _context122.p = 2;
6047
+ return _context122.a(2, new Promise(function (resolve, reject) {
6025
6048
  pushPage({
6026
6049
  key: "Remove Phone Number",
6027
6050
  content: jsx(RemovePhoneNumber, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -6048,106 +6071,127 @@ var ClientProvider = function ClientProvider(_ref) {
6048
6071
  });
6049
6072
  }));
6050
6073
  case 3:
6051
- _context121.p = 3;
6052
- _t27 = _context121.v;
6074
+ _context122.p = 3;
6075
+ _t27 = _context122.v;
6053
6076
  if (!(_t27 instanceof TurnkeyError)) {
6054
- _context121.n = 4;
6077
+ _context122.n = 4;
6055
6078
  break;
6056
6079
  }
6057
6080
  throw _t27;
6058
6081
  case 4:
6059
6082
  throw new TurnkeyError("Failed to remove user phone number.", TurnkeyErrorCodes.UPDATE_USER_PHONE_NUMBER_ERROR, _t27);
6060
6083
  case 5:
6061
- return _context121.a(2);
6084
+ return _context122.a(2);
6062
6085
  }
6063
- }, _callee121, null, [[2, 3]]);
6086
+ }, _callee122, null, [[2, 3]]);
6064
6087
  }));
6065
- return function (_x105) {
6066
- return _ref141.apply(this, arguments);
6088
+ return function (_x106) {
6089
+ return _ref142.apply(this, arguments);
6067
6090
  };
6068
6091
  }(), [getSession, pushPage]);
6069
6092
  var handleSendTransaction = useCallback(/*#__PURE__*/function () {
6070
- var _ref143 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee123(params) {
6071
- var session, organizationId, transaction, icon, stampWith, _params$successPageDu5, successPageDuration, from, to, caip2, value, data, nonce, gasLimit, maxFeePerGas, maxPriorityFeePerGas, sponsor, cleanedData;
6072
- return _regenerator().w(function (_context123) {
6073
- while (1) switch (_context123.n) {
6093
+ var _ref144 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee125(params) {
6094
+ var session, organizationId, transaction, icon, stampWith, _params$successPageDu5, successPageDuration, caip2, isSolanaTransaction;
6095
+ return _regenerator().w(function (_context125) {
6096
+ while (1) switch (_context125.n) {
6074
6097
  case 0:
6075
- _context123.n = 1;
6098
+ _context125.n = 1;
6076
6099
  return getSession();
6077
6100
  case 1:
6078
- session = _context123.v;
6101
+ session = _context125.v;
6079
6102
  organizationId = params.organizationId || (session === null || session === void 0 ? void 0 : session.organizationId);
6080
6103
  if (organizationId) {
6081
- _context123.n = 2;
6104
+ _context125.n = 2;
6082
6105
  break;
6083
6106
  }
6084
6107
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
6085
6108
  case 2:
6086
6109
  transaction = params.transaction, icon = params.icon, stampWith = params.stampWith, _params$successPageDu5 = params.successPageDuration, successPageDuration = _params$successPageDu5 === void 0 ? 2000 : _params$successPageDu5;
6087
- from = transaction.from, to = transaction.to, caip2 = transaction.caip2, value = transaction.value, data = transaction.data, nonce = transaction.nonce, gasLimit = transaction.gasLimit, maxFeePerGas = transaction.maxFeePerGas, maxPriorityFeePerGas = transaction.maxPriorityFeePerGas, sponsor = transaction.sponsor;
6088
- cleanedData = data && data !== "0x" && data !== "" ? data : undefined;
6089
- return _context123.a(2, new Promise(function (resolve, reject) {
6110
+ caip2 = transaction.caip2;
6111
+ isSolanaTransaction = caip2.startsWith("solana:");
6112
+ return _context125.a(2, new Promise(function (resolve, reject) {
6090
6113
  var action = /*#__PURE__*/function () {
6091
- var _ref144 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee122() {
6092
- var _pollResult$eth;
6093
- var tx, sendTransactionStatusId, pollResult, txHash;
6094
- return _regenerator().w(function (_context122) {
6095
- while (1) switch (_context122.n) {
6114
+ var _ref145 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee124() {
6115
+ var _pollResult$eth$txHas, _pollResult$eth;
6116
+ var sendTransactionStatusId, pollResult, txHash, _t28;
6117
+ return _regenerator().w(function (_context124) {
6118
+ while (1) switch (_context124.n) {
6096
6119
  case 0:
6097
- tx = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
6098
- from: from,
6099
- to: to,
6100
- caip2: caip2,
6101
- sponsor: sponsor !== null && sponsor !== void 0 ? sponsor : false
6102
- }, value ? {
6103
- value: value
6104
- } : {}), cleanedData ? {
6105
- data: cleanedData
6106
- } : {}), nonce ? {
6107
- nonce: nonce
6108
- } : {}), gasLimit ? {
6109
- gasLimit: gasLimit
6110
- } : {}), maxFeePerGas ? {
6111
- maxFeePerGas: maxFeePerGas
6112
- } : {}), maxPriorityFeePerGas ? {
6113
- maxPriorityFeePerGas: maxPriorityFeePerGas
6114
- } : {});
6115
- _context122.n = 1;
6116
- return ethSendTransaction({
6120
+ if (!isSolanaTransaction) {
6121
+ _context124.n = 2;
6122
+ break;
6123
+ }
6124
+ _context124.n = 1;
6125
+ return solSendTransaction({
6117
6126
  organizationId: organizationId,
6118
- transaction: tx,
6127
+ transaction: transaction,
6119
6128
  stampWith: stampWith
6120
6129
  });
6121
6130
  case 1:
6122
- sendTransactionStatusId = _context122.v;
6131
+ _t28 = _context124.v;
6132
+ _context124.n = 4;
6133
+ break;
6134
+ case 2:
6135
+ _context124.n = 3;
6136
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee123() {
6137
+ var from, to, value, data, nonce, gasLimit, maxFeePerGas, maxPriorityFeePerGas, sponsor, cleanedData, tx;
6138
+ return _regenerator().w(function (_context123) {
6139
+ while (1) switch (_context123.n) {
6140
+ case 0:
6141
+ from = transaction.from, to = transaction.to, value = transaction.value, data = transaction.data, nonce = transaction.nonce, gasLimit = transaction.gasLimit, maxFeePerGas = transaction.maxFeePerGas, maxPriorityFeePerGas = transaction.maxPriorityFeePerGas, sponsor = transaction.sponsor;
6142
+ cleanedData = data && data !== "0x" && data !== "" ? data : undefined;
6143
+ tx = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
6144
+ from: from,
6145
+ to: to,
6146
+ caip2: caip2,
6147
+ sponsor: sponsor !== null && sponsor !== void 0 ? sponsor : false
6148
+ }, value ? {
6149
+ value: value
6150
+ } : {}), cleanedData ? {
6151
+ data: cleanedData
6152
+ } : {}), nonce ? {
6153
+ nonce: nonce
6154
+ } : {}), gasLimit ? {
6155
+ gasLimit: gasLimit
6156
+ } : {}), maxFeePerGas ? {
6157
+ maxFeePerGas: maxFeePerGas
6158
+ } : {}), maxPriorityFeePerGas ? {
6159
+ maxPriorityFeePerGas: maxPriorityFeePerGas
6160
+ } : {});
6161
+ return _context123.a(2, ethSendTransaction({
6162
+ organizationId: organizationId,
6163
+ transaction: tx,
6164
+ stampWith: stampWith
6165
+ }));
6166
+ }
6167
+ }, _callee123);
6168
+ }))();
6169
+ case 3:
6170
+ _t28 = _context124.v;
6171
+ case 4:
6172
+ sendTransactionStatusId = _t28;
6123
6173
  if (sendTransactionStatusId) {
6124
- _context122.n = 2;
6174
+ _context124.n = 5;
6125
6175
  break;
6126
6176
  }
6127
- throw new TurnkeyError("Missing sendTransactionStatusId", TurnkeyErrorCodes.ETH_SEND_TRANSACTION_ERROR);
6128
- case 2:
6129
- _context122.n = 3;
6177
+ throw new TurnkeyError("Missing sendTransactionStatusId", TurnkeyErrorCodes.BAD_RESPONSE);
6178
+ case 5:
6179
+ _context124.n = 6;
6130
6180
  return pollTransactionStatus({
6131
6181
  organizationId: organizationId,
6132
6182
  sendTransactionStatusId: sendTransactionStatusId
6133
6183
  });
6134
- case 3:
6135
- pollResult = _context122.v;
6136
- txHash = pollResult === null || pollResult === void 0 ? void 0 : (_pollResult$eth = pollResult.eth) === null || _pollResult$eth === void 0 ? void 0 : _pollResult$eth.txHash;
6137
- if (txHash) {
6138
- _context122.n = 4;
6139
- break;
6140
- }
6141
- throw new TurnkeyError("Missing txHash in transaction result", TurnkeyErrorCodes.POLL_TRANSACTION_STATUS_ERROR);
6142
- case 4:
6143
- return _context122.a(2, {
6184
+ case 6:
6185
+ pollResult = _context124.v;
6186
+ txHash = (_pollResult$eth$txHas = pollResult === null || pollResult === void 0 ? void 0 : (_pollResult$eth = pollResult.eth) === null || _pollResult$eth === void 0 ? void 0 : _pollResult$eth.txHash) !== null && _pollResult$eth$txHas !== void 0 ? _pollResult$eth$txHas : pollResult === null || pollResult === void 0 ? void 0 : pollResult.txHash;
6187
+ return _context124.a(2, txHash ? {
6144
6188
  txHash: txHash
6145
- });
6189
+ } : {});
6146
6190
  }
6147
- }, _callee122);
6191
+ }, _callee124);
6148
6192
  }));
6149
6193
  return function action() {
6150
- return _ref144.apply(this, arguments);
6194
+ return _ref145.apply(this, arguments);
6151
6195
  };
6152
6196
  }();
6153
6197
  pushPage({
@@ -6172,55 +6216,55 @@ var ClientProvider = function ClientProvider(_ref) {
6172
6216
  });
6173
6217
  }));
6174
6218
  }
6175
- }, _callee123);
6219
+ }, _callee125);
6176
6220
  }));
6177
- return function (_x106) {
6178
- return _ref143.apply(this, arguments);
6221
+ return function (_x107) {
6222
+ return _ref144.apply(this, arguments);
6179
6223
  };
6180
- }(), [pushPage, client]);
6224
+ }(), [ethSendTransaction, getSession, pollTransactionStatus, pushPage, solSendTransaction]);
6181
6225
  var handleOnRamp = useCallback(/*#__PURE__*/function () {
6182
- var _ref145 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee126(params) {
6226
+ var _ref147 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee128(params) {
6183
6227
  var _walletAccount$addres;
6184
- var walletAccount, fiatCurrencyAmount, fiatCurrencyCode, paymentMethod, countrySubdivisionCode, urlForSignature, countryCode, _params$onrampProvide, onrampProvider, _params$sandboxMode, sandboxMode, _params$successPageDu6, successPageDuration, _params$openInNewTab, openInNewTab, s, organizationId, cryptoCurrencyCode, network, openNewTab, _t30;
6185
- return _regenerator().w(function (_context126) {
6186
- while (1) switch (_context126.n) {
6228
+ var walletAccount, fiatCurrencyAmount, fiatCurrencyCode, paymentMethod, countrySubdivisionCode, urlForSignature, countryCode, _params$onrampProvide, onrampProvider, _params$sandboxMode, sandboxMode, _params$successPageDu6, successPageDuration, _params$openInNewTab, openInNewTab, s, organizationId, cryptoCurrencyCode, network, openNewTab, _t31;
6229
+ return _regenerator().w(function (_context128) {
6230
+ while (1) switch (_context128.n) {
6187
6231
  case 0:
6188
6232
  walletAccount = params.walletAccount, fiatCurrencyAmount = params.fiatCurrencyAmount, fiatCurrencyCode = params.fiatCurrencyCode, paymentMethod = params.paymentMethod, countrySubdivisionCode = params.countrySubdivisionCode, urlForSignature = params.urlForSignature, countryCode = params.countryCode, _params$onrampProvide = params.onrampProvider, onrampProvider = _params$onrampProvide === void 0 ? "FIAT_ON_RAMP_PROVIDER_MOONPAY" : _params$onrampProvide, _params$sandboxMode = params.sandboxMode, sandboxMode = _params$sandboxMode === void 0 ? true : _params$sandboxMode, _params$successPageDu6 = params.successPageDuration, successPageDuration = _params$successPageDu6 === void 0 ? 2000 : _params$successPageDu6, _params$openInNewTab = params.openInNewTab, openInNewTab = _params$openInNewTab === void 0 ? false : _params$openInNewTab;
6189
- _context126.n = 1;
6233
+ _context128.n = 1;
6190
6234
  return getSession();
6191
6235
  case 1:
6192
- s = _context126.v;
6236
+ s = _context128.v;
6193
6237
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
6194
6238
  if (organizationId) {
6195
- _context126.n = 2;
6239
+ _context128.n = 2;
6196
6240
  break;
6197
6241
  }
6198
6242
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
6199
6243
  case 2:
6200
- _t30 = true;
6201
- _context126.n = _t30 === (walletAccount.addressFormat === "ADDRESS_FORMAT_ETHEREUM") ? 3 : _t30 === ((_walletAccount$addres = walletAccount.addressFormat) === null || _walletAccount$addres === void 0 ? void 0 : _walletAccount$addres.includes("ADDRESS_FORMAT_BITCOIN")) ? 4 : _t30 === (walletAccount.addressFormat === "ADDRESS_FORMAT_SOLANA") ? 5 : 6;
6244
+ _t31 = true;
6245
+ _context128.n = _t31 === (walletAccount.addressFormat === "ADDRESS_FORMAT_ETHEREUM") ? 3 : _t31 === ((_walletAccount$addres = walletAccount.addressFormat) === null || _walletAccount$addres === void 0 ? void 0 : _walletAccount$addres.includes("ADDRESS_FORMAT_BITCOIN")) ? 4 : _t31 === (walletAccount.addressFormat === "ADDRESS_FORMAT_SOLANA") ? 5 : 6;
6202
6246
  break;
6203
6247
  case 3:
6204
6248
  cryptoCurrencyCode = FiatOnRampCryptoCurrency.ETHEREUM;
6205
6249
  network = FiatOnRampBlockchainNetwork.ETHEREUM;
6206
- return _context126.a(3, 7);
6250
+ return _context128.a(3, 7);
6207
6251
  case 4:
6208
6252
  cryptoCurrencyCode = FiatOnRampCryptoCurrency.BITCOIN;
6209
6253
  network = FiatOnRampBlockchainNetwork.BITCOIN;
6210
- return _context126.a(3, 7);
6254
+ return _context128.a(3, 7);
6211
6255
  case 5:
6212
6256
  cryptoCurrencyCode = FiatOnRampCryptoCurrency.SOLANA;
6213
6257
  network = FiatOnRampBlockchainNetwork.SOLANA;
6214
- return _context126.a(3, 7);
6258
+ return _context128.a(3, 7);
6215
6259
  case 6:
6216
6260
  cryptoCurrencyCode = FiatOnRampCryptoCurrency.ETHEREUM;
6217
6261
  network = FiatOnRampBlockchainNetwork.ETHEREUM;
6218
- return _context126.a(3, 7);
6262
+ return _context128.a(3, 7);
6219
6263
  case 7:
6220
6264
  openNewTab = openInNewTab || isMobile;
6221
6265
  cryptoCurrencyCode = params.cryptoCurrencyCode || cryptoCurrencyCode;
6222
6266
  network = params.network || network;
6223
- return _context126.a(2, new Promise(function (resolve, reject) {
6267
+ return _context128.a(2, new Promise(function (resolve, reject) {
6224
6268
  var OnRampContainer = function OnRampContainer() {
6225
6269
  var _useState15 = useState(false),
6226
6270
  _useState16 = _slicedToArray(_useState15, 2),
@@ -6239,25 +6283,25 @@ var ClientProvider = function ClientProvider(_ref) {
6239
6283
  };
6240
6284
  }, []);
6241
6285
  var action = /*#__PURE__*/function () {
6242
- var _ref146 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee125() {
6243
- var _client$httpClient, onRampWindow, result, popupWidth, popupHeight, left, top, onRampTransactionId, _t29;
6244
- return _regenerator().w(function (_context125) {
6245
- while (1) switch (_context125.p = _context125.n) {
6286
+ var _ref148 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee127() {
6287
+ var _client$httpClient, onRampWindow, result, popupWidth, popupHeight, left, top, onRampTransactionId, _t30;
6288
+ return _regenerator().w(function (_context127) {
6289
+ while (1) switch (_context127.p = _context127.n) {
6246
6290
  case 0:
6247
- _context125.p = 0;
6291
+ _context127.p = 0;
6248
6292
  onRampWindow = null;
6249
6293
  if (!openNewTab) {
6250
- _context125.n = 1;
6294
+ _context127.n = 1;
6251
6295
  break;
6252
6296
  }
6253
6297
  onRampWindow = window.open("", "_blank");
6254
6298
  if (onRampWindow) {
6255
- _context125.n = 1;
6299
+ _context127.n = 1;
6256
6300
  break;
6257
6301
  }
6258
6302
  throw new Error("Failed to open On Ramp tab.");
6259
6303
  case 1:
6260
- _context125.n = 2;
6304
+ _context127.n = 2;
6261
6305
  return client === null || client === void 0 ? void 0 : (_client$httpClient = client.httpClient) === null || _client$httpClient === void 0 ? void 0 : _client$httpClient.initFiatOnRamp(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
6262
6306
  onrampProvider: onrampProvider,
6263
6307
  walletAddress: walletAccount.address,
@@ -6281,19 +6325,19 @@ var ClientProvider = function ClientProvider(_ref) {
6281
6325
  urlForSignature: urlForSignature
6282
6326
  } : {}));
6283
6327
  case 2:
6284
- result = _context125.v;
6328
+ result = _context127.v;
6285
6329
  if (result !== null && result !== void 0 && result.onRampUrl) {
6286
- _context125.n = 3;
6330
+ _context127.n = 3;
6287
6331
  break;
6288
6332
  }
6289
6333
  throw new Error("Missing onRampUrl");
6290
6334
  case 3:
6291
6335
  if (!(openNewTab && onRampWindow)) {
6292
- _context125.n = 4;
6336
+ _context127.n = 4;
6293
6337
  break;
6294
6338
  }
6295
6339
  onRampWindow.location.href = result.onRampUrl.toString();
6296
- _context125.n = 5;
6340
+ _context127.n = 5;
6297
6341
  break;
6298
6342
  case 4:
6299
6343
  popupWidth = 500;
@@ -6302,54 +6346,54 @@ var ClientProvider = function ClientProvider(_ref) {
6302
6346
  top = window.screenY + (window.innerHeight - popupHeight) / 2;
6303
6347
  onRampWindow = window.open(result.onRampUrl.toString(), "_blank", "width=".concat(popupWidth, ",height=").concat(popupHeight, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
6304
6348
  if (onRampWindow) {
6305
- _context125.n = 5;
6349
+ _context127.n = 5;
6306
6350
  break;
6307
6351
  }
6308
6352
  throw new Error("Failed to open On Ramp window.");
6309
6353
  case 5:
6310
6354
  onRampTransactionId = result.onRampTransactionId;
6311
6355
  if (onRampTransactionId) {
6312
- _context125.n = 6;
6356
+ _context127.n = 6;
6313
6357
  break;
6314
6358
  }
6315
6359
  throw new Error("No onRampTransactionId returned");
6316
6360
  case 6:
6317
- return _context125.a(2, new Promise(function (resolveAction, rejectAction) {
6318
- pollingRef.current = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee124() {
6319
- var _onRampWindow, _client$httpClient2, currentUrl, _onRampWindow2, _onRampWindow3, resp, status, _onRampWindow4, _t28;
6320
- return _regenerator().w(function (_context124) {
6321
- while (1) switch (_context124.p = _context124.n) {
6361
+ return _context127.a(2, new Promise(function (resolveAction, rejectAction) {
6362
+ pollingRef.current = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee126() {
6363
+ var _onRampWindow, _client$httpClient2, currentUrl, _onRampWindow2, _onRampWindow3, resp, status, _onRampWindow4, _t29;
6364
+ return _regenerator().w(function (_context126) {
6365
+ while (1) switch (_context126.p = _context126.n) {
6322
6366
  case 0:
6323
- _context124.p = 0;
6367
+ _context126.p = 0;
6324
6368
  if (!(onrampProvider === "FIAT_ON_RAMP_PROVIDER_COINBASE" && (_onRampWindow = onRampWindow) !== null && _onRampWindow !== void 0 && _onRampWindow.closed)) {
6325
- _context124.n = 1;
6369
+ _context126.n = 1;
6326
6370
  break;
6327
6371
  }
6328
6372
  cleanup();
6329
6373
  rejectAction(new Error("On-ramp popup closed by user"));
6330
- return _context124.a(2);
6374
+ return _context126.a(2);
6331
6375
  case 1:
6332
6376
  currentUrl = "";
6333
6377
  try {
6334
6378
  currentUrl = ((_onRampWindow2 = onRampWindow) === null || _onRampWindow2 === void 0 ? void 0 : _onRampWindow2.location.href) || "";
6335
6379
  } catch (_unused6) {}
6336
6380
  if (!(currentUrl && currentUrl.startsWith(window.location.origin))) {
6337
- _context124.n = 2;
6381
+ _context126.n = 2;
6338
6382
  break;
6339
6383
  }
6340
6384
  cleanup();
6341
6385
  (_onRampWindow3 = onRampWindow) === null || _onRampWindow3 === void 0 ? void 0 : _onRampWindow3.close();
6342
6386
  setCompleted(true);
6343
6387
  resolveAction();
6344
- return _context124.a(2);
6388
+ return _context126.a(2);
6345
6389
  case 2:
6346
- _context124.n = 3;
6390
+ _context126.n = 3;
6347
6391
  return client === null || client === void 0 ? void 0 : (_client$httpClient2 = client.httpClient) === null || _client$httpClient2 === void 0 ? void 0 : _client$httpClient2.getOnRampTransactionStatus({
6348
6392
  transactionId: onRampTransactionId,
6349
6393
  refresh: true
6350
6394
  });
6351
6395
  case 3:
6352
- resp = _context124.v;
6396
+ resp = _context126.v;
6353
6397
  status = resp === null || resp === void 0 ? void 0 : resp.transactionStatus;
6354
6398
  if (["COMPLETED", "FAILED", "CANCELLED"].includes(status !== null && status !== void 0 ? status : "")) {
6355
6399
  cleanup();
@@ -6359,30 +6403,30 @@ var ClientProvider = function ClientProvider(_ref) {
6359
6403
  setCompleted(true);
6360
6404
  resolveAction();
6361
6405
  }
6362
- _context124.n = 5;
6406
+ _context126.n = 5;
6363
6407
  break;
6364
6408
  case 4:
6365
- _context124.p = 4;
6366
- _t28 = _context124.v;
6367
- console.warn("Polling error (ignored):", _t28);
6409
+ _context126.p = 4;
6410
+ _t29 = _context126.v;
6411
+ console.warn("Polling error (ignored):", _t29);
6368
6412
  case 5:
6369
- return _context124.a(2);
6413
+ return _context126.a(2);
6370
6414
  }
6371
- }, _callee124, null, [[0, 4]]);
6415
+ }, _callee126, null, [[0, 4]]);
6372
6416
  })), 3000);
6373
6417
  }));
6374
6418
  case 7:
6375
- _context125.p = 7;
6376
- _t29 = _context125.v;
6419
+ _context127.p = 7;
6420
+ _t30 = _context127.v;
6377
6421
  cleanup();
6378
- throw _t29;
6422
+ throw _t30;
6379
6423
  case 8:
6380
- return _context125.a(2);
6424
+ return _context127.a(2);
6381
6425
  }
6382
- }, _callee125, null, [[0, 7]]);
6426
+ }, _callee127, null, [[0, 7]]);
6383
6427
  }));
6384
6428
  return function action() {
6385
- return _ref146.apply(this, arguments);
6429
+ return _ref148.apply(this, arguments);
6386
6430
  };
6387
6431
  }();
6388
6432
  return jsx(OnRampPage, {
@@ -6415,32 +6459,32 @@ var ClientProvider = function ClientProvider(_ref) {
6415
6459
  });
6416
6460
  }));
6417
6461
  }
6418
- }, _callee126);
6462
+ }, _callee128);
6419
6463
  }));
6420
- return function (_x107) {
6421
- return _ref145.apply(this, arguments);
6464
+ return function (_x108) {
6465
+ return _ref147.apply(this, arguments);
6422
6466
  };
6423
6467
  }(), [getSession, client, pushPage]);
6424
6468
  var handleVerifyAppProofs = useCallback(/*#__PURE__*/function () {
6425
- var _ref148 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee127(params) {
6426
- var _ref149, appProofs, _ref149$successPageDu, successPageDuration, stampWith, s, organizationId, _t31;
6427
- return _regenerator().w(function (_context127) {
6428
- while (1) switch (_context127.p = _context127.n) {
6469
+ var _ref150 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee129(params) {
6470
+ var _ref151, appProofs, _ref151$successPageDu, successPageDuration, stampWith, s, organizationId, _t32;
6471
+ return _regenerator().w(function (_context129) {
6472
+ while (1) switch (_context129.p = _context129.n) {
6429
6473
  case 0:
6430
- _ref149 = params || {}, appProofs = _ref149.appProofs, _ref149$successPageDu = _ref149.successPageDuration, successPageDuration = _ref149$successPageDu === void 0 ? 3000 : _ref149$successPageDu, stampWith = _ref149.stampWith;
6431
- _context127.n = 1;
6474
+ _ref151 = params || {}, appProofs = _ref151.appProofs, _ref151$successPageDu = _ref151.successPageDuration, successPageDuration = _ref151$successPageDu === void 0 ? 3000 : _ref151$successPageDu, stampWith = _ref151.stampWith;
6475
+ _context129.n = 1;
6432
6476
  return getSession();
6433
6477
  case 1:
6434
- s = _context127.v;
6478
+ s = _context129.v;
6435
6479
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
6436
6480
  if (organizationId) {
6437
- _context127.n = 2;
6481
+ _context129.n = 2;
6438
6482
  break;
6439
6483
  }
6440
6484
  throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
6441
6485
  case 2:
6442
- _context127.p = 2;
6443
- return _context127.a(2, new Promise(function (resolve, reject) {
6486
+ _context129.p = 2;
6487
+ return _context129.a(2, new Promise(function (resolve, reject) {
6444
6488
  pushPage({
6445
6489
  key: "Verify app proofs",
6446
6490
  showTurnkeyBranding: false,
@@ -6466,60 +6510,60 @@ var ClientProvider = function ClientProvider(_ref) {
6466
6510
  });
6467
6511
  }));
6468
6512
  case 3:
6469
- _context127.p = 3;
6470
- _t31 = _context127.v;
6471
- if (!(_t31 instanceof TurnkeyError)) {
6472
- _context127.n = 4;
6513
+ _context129.p = 3;
6514
+ _t32 = _context129.v;
6515
+ if (!(_t32 instanceof TurnkeyError)) {
6516
+ _context129.n = 4;
6473
6517
  break;
6474
6518
  }
6475
- throw _t31;
6519
+ throw _t32;
6476
6520
  case 4:
6477
- throw new TurnkeyError("Failed to verify app proofs.", TurnkeyErrorCodes.VERIFY_APP_PROOFS_ERROR, _t31);
6521
+ throw new TurnkeyError("Failed to verify app proofs.", TurnkeyErrorCodes.VERIFY_APP_PROOFS_ERROR, _t32);
6478
6522
  case 5:
6479
- return _context127.a(2);
6523
+ return _context129.a(2);
6480
6524
  }
6481
- }, _callee127, null, [[2, 3]]);
6525
+ }, _callee129, null, [[2, 3]]);
6482
6526
  }));
6483
- return function (_x108) {
6484
- return _ref148.apply(this, arguments);
6527
+ return function (_x109) {
6528
+ return _ref150.apply(this, arguments);
6485
6529
  };
6486
6530
  }(), [getSession, pushPage]);
6487
6531
  useEffect(function () {
6488
6532
  if (proxyAuthConfigRef.current) return;
6489
6533
  // Only fetch the proxy auth config once. Use that to build the master config.
6490
6534
  var fetchProxyAuthConfig = /*#__PURE__*/function () {
6491
- var _ref150 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee128() {
6535
+ var _ref152 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee130() {
6492
6536
  var proxyAuthConfig;
6493
- return _regenerator().w(function (_context128) {
6494
- while (1) switch (_context128.p = _context128.n) {
6537
+ return _regenerator().w(function (_context130) {
6538
+ while (1) switch (_context130.p = _context130.n) {
6495
6539
  case 0:
6496
- _context128.p = 0;
6540
+ _context130.p = 0;
6497
6541
  if (!shouldFetchWalletKitConfig) {
6498
- _context128.n = 2;
6542
+ _context130.n = 2;
6499
6543
  break;
6500
6544
  }
6501
- _context128.n = 1;
6545
+ _context130.n = 1;
6502
6546
  return getAuthProxyConfig(config.authProxyConfigId,
6503
6547
  // Can assert safely. See shouldFetchWalletKitConfig definition.
6504
6548
  config.authProxyUrl);
6505
6549
  case 1:
6506
- proxyAuthConfig = _context128.v;
6550
+ proxyAuthConfig = _context130.v;
6507
6551
  proxyAuthConfigRef.current = proxyAuthConfig;
6508
6552
  case 2:
6509
6553
  setMasterConfig(buildConfig(proxyAuthConfig));
6510
- _context128.n = 4;
6554
+ _context130.n = 4;
6511
6555
  break;
6512
6556
  case 3:
6513
- _context128.p = 3;
6514
- _context128.v;
6557
+ _context130.p = 3;
6558
+ _context130.v;
6515
6559
  setClientState(ClientState.Error);
6516
6560
  case 4:
6517
- return _context128.a(2);
6561
+ return _context130.a(2);
6518
6562
  }
6519
- }, _callee128, null, [[0, 3]]);
6563
+ }, _callee130, null, [[0, 3]]);
6520
6564
  }));
6521
6565
  return function fetchProxyAuthConfig() {
6522
- return _ref150.apply(this, arguments);
6566
+ return _ref152.apply(this, arguments);
6523
6567
  };
6524
6568
  }();
6525
6569
  fetchProxyAuthConfig();
@@ -6552,34 +6596,34 @@ var ClientProvider = function ClientProvider(_ref) {
6552
6596
  var debouncedFetchWalletProviders = useDebouncedCallback(fetchWalletProviders, 100);
6553
6597
  useEffect(function () {
6554
6598
  var handleUpdateState = /*#__PURE__*/function () {
6555
- var _ref151 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee129() {
6599
+ var _ref153 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee131() {
6556
6600
  var currentSession;
6557
- return _regenerator().w(function (_context129) {
6558
- while (1) switch (_context129.n) {
6601
+ return _regenerator().w(function (_context131) {
6602
+ while (1) switch (_context131.n) {
6559
6603
  case 0:
6560
- _context129.n = 1;
6604
+ _context131.n = 1;
6561
6605
  return getSession();
6562
6606
  case 1:
6563
- currentSession = _context129.v;
6607
+ currentSession = _context131.v;
6564
6608
  if (!currentSession) {
6565
- _context129.n = 3;
6609
+ _context131.n = 3;
6566
6610
  break;
6567
6611
  }
6568
- _context129.n = 2;
6612
+ _context131.n = 2;
6569
6613
  return debouncedRefreshWallets();
6570
6614
  case 2:
6571
- _context129.n = 4;
6615
+ _context131.n = 4;
6572
6616
  break;
6573
6617
  case 3:
6574
- _context129.n = 4;
6618
+ _context131.n = 4;
6575
6619
  return debouncedFetchWalletProviders();
6576
6620
  case 4:
6577
- return _context129.a(2);
6621
+ return _context131.a(2);
6578
6622
  }
6579
- }, _callee129);
6623
+ }, _callee131);
6580
6624
  }));
6581
6625
  return function handleUpdateState() {
6582
- return _ref151.apply(this, arguments);
6626
+ return _ref153.apply(this, arguments);
6583
6627
  };
6584
6628
  }();
6585
6629
  var cleanup = function cleanup() {};
@@ -6660,6 +6704,7 @@ var ClientProvider = function ClientProvider(_ref) {
6660
6704
  signMessage: signMessage,
6661
6705
  signTransaction: signTransaction,
6662
6706
  ethSendTransaction: ethSendTransaction,
6707
+ solSendTransaction: solSendTransaction,
6663
6708
  signAndSendTransaction: signAndSendTransaction,
6664
6709
  pollTransactionStatus: pollTransactionStatus,
6665
6710
  fetchUser: fetchUser,