@0xkey-io/react-wallet-kit 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,6 +34,7 @@ import { OtpVerification } from '../../components/auth/OTP.mjs';
34
34
  import { RemoveEmail } from '../../components/user/RemoveEmail.mjs';
35
35
  import { RemovePhoneNumber } from '../../components/user/RemovePhoneNumber.mjs';
36
36
  import { VerifyPage } from '../../components/verify/Verify.mjs';
37
+ import { VerifyEnclavePage } from '../../components/verify/VerifyEnclave.mjs';
37
38
  import { OnRampPage } from '../../components/onramp/OnRamp.mjs';
38
39
  import { CoinbaseLogo, MoonPayLogo } from '../../components/design/Svg.mjs';
39
40
  import { SendTransactionPage } from '../../components/send-transaction/SendTransaction.mjs';
@@ -865,11 +866,11 @@ var ClientProvider = function ClientProvider(_ref) {
865
866
  * @throws {ZeroXKeyError} If an error occurs while clearing the timers.
866
867
  */
867
868
  function _initializeWalletProviderListeners() {
868
- _initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee138(walletProviders, onUpdateState) {
869
+ _initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee141(walletProviders, onUpdateState) {
869
870
  var _masterConfig$walletC0, _masterConfig$walletC1, _masterConfig$walletC10, _masterConfig$walletC11;
870
871
  var cleanups, nativeOnly, ethProviders, solProviders, wcProviders, wcProvider, attachEthereumListeners, attachSolanaListeners, _wcProvider$provider, _wcProvider$provider$, standardEvents, unsubscribe;
871
- return _regenerator().w(function (_context138) {
872
- while (1) switch (_context138.n) {
872
+ return _regenerator().w(function (_context141) {
873
+ while (1) switch (_context141.n) {
873
874
  case 0:
874
875
  attachSolanaListeners = function _attachSolanaListener(provider, onUpdateState) {
875
876
  var _provider$features;
@@ -877,19 +878,19 @@ var ClientProvider = function ClientProvider(_ref) {
877
878
  var walletEvents = provider === null || provider === void 0 ? void 0 : (_provider$features = provider.features) === null || _provider$features === void 0 ? void 0 : _provider$features["standard:events"];
878
879
  if (walletEvents !== null && walletEvents !== void 0 && walletEvents.on) {
879
880
  var offChange = walletEvents.on("change", /*#__PURE__*/function () {
880
- var _ref159 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee136(_evt) {
881
- return _regenerator().w(function (_context136) {
882
- while (1) switch (_context136.n) {
881
+ var _ref163 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee139(_evt) {
882
+ return _regenerator().w(function (_context139) {
883
+ while (1) switch (_context139.n) {
883
884
  case 0:
884
- _context136.n = 1;
885
+ _context139.n = 1;
885
886
  return onUpdateState();
886
887
  case 1:
887
- return _context136.a(2);
888
+ return _context139.a(2);
888
889
  }
889
- }, _callee136);
890
+ }, _callee139);
890
891
  }));
891
- return function (_x114) {
892
- return _ref159.apply(this, arguments);
892
+ return function (_x117) {
893
+ return _ref163.apply(this, arguments);
893
894
  };
894
895
  }());
895
896
  cleanups.push(offChange);
@@ -903,31 +904,31 @@ var ClientProvider = function ClientProvider(_ref) {
903
904
  attachEthereumListeners = function _attachEthereumListen(provider, onUpdateState) {
904
905
  if (typeof provider.on !== "function") return;
905
906
  var handleChainChanged = /*#__PURE__*/function () {
906
- var _ref157 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee134(_chainId) {
907
- return _regenerator().w(function (_context134) {
908
- while (1) switch (_context134.n) {
907
+ var _ref161 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee137(_chainId) {
908
+ return _regenerator().w(function (_context137) {
909
+ while (1) switch (_context137.n) {
909
910
  case 0:
910
- return _context134.a(2, onUpdateState());
911
+ return _context137.a(2, onUpdateState());
911
912
  }
912
- }, _callee134);
913
+ }, _callee137);
913
914
  }));
914
- return function handleChainChanged(_x112) {
915
- return _ref157.apply(this, arguments);
915
+ return function handleChainChanged(_x115) {
916
+ return _ref161.apply(this, arguments);
916
917
  };
917
918
  }();
918
919
  var handleAccountsChanged = /*#__PURE__*/function () {
919
- var _ref158 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee135(accounts) {
920
- return _regenerator().w(function (_context135) {
921
- while (1) switch (_context135.n) {
920
+ var _ref162 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee138(accounts) {
921
+ return _regenerator().w(function (_context138) {
922
+ while (1) switch (_context138.n) {
922
923
  case 0:
923
924
  if (accounts.length === 0) onUpdateState();
924
925
  case 1:
925
- return _context135.a(2);
926
+ return _context138.a(2);
926
927
  }
927
- }, _callee135);
928
+ }, _callee138);
928
929
  }));
929
- return function handleAccountsChanged(_x113) {
930
- return _ref158.apply(this, arguments);
930
+ return function handleAccountsChanged(_x116) {
931
+ return _ref162.apply(this, arguments);
931
932
  };
932
933
  }();
933
934
  var handleDisconnect = function handleDisconnect() {
@@ -943,10 +944,10 @@ var ClientProvider = function ClientProvider(_ref) {
943
944
  };
944
945
  };
945
946
  if (!(walletProviders.length === 0)) {
946
- _context138.n = 1;
947
+ _context141.n = 1;
947
948
  break;
948
949
  }
949
- return _context138.a(2, function () {});
950
+ return _context141.a(2, function () {});
950
951
  case 1:
951
952
  cleanups = []; // we only want to initialize these listeners for connected walletProviders
952
953
  nativeOnly = function nativeOnly(provider) {
@@ -984,82 +985,82 @@ var ClientProvider = function ClientProvider(_ref) {
984
985
  if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
985
986
  if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
986
987
  unsubscribe = standardEvents.on("change", /*#__PURE__*/function () {
987
- var _ref160 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee137(evt) {
988
+ var _ref164 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee140(evt) {
988
989
  var _callbacks$onError10, providers, currentSession, _wcProviders, wcWallets;
989
- return _regenerator().w(function (_context137) {
990
- while (1) switch (_context137.n) {
990
+ return _regenerator().w(function (_context140) {
991
+ while (1) switch (_context140.n) {
991
992
  case 0:
992
993
  if (!((evt === null || evt === void 0 ? void 0 : evt.type) === "pairingExpired")) {
993
- _context137.n = 1;
994
+ _context140.n = 1;
994
995
  break;
995
996
  }
996
997
  debouncedFetchWalletProviders();
997
- return _context137.a(2);
998
+ return _context140.a(2);
998
999
  case 1:
999
1000
  if (!((evt === null || evt === void 0 ? void 0 : evt.type) === "failed")) {
1000
- _context137.n = 2;
1001
+ _context140.n = 2;
1001
1002
  break;
1002
1003
  }
1003
1004
  debouncedFetchWalletProviders();
1004
1005
  callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError10 = callbacks.onError) === null || _callbacks$onError10 === void 0 ? void 0 : _callbacks$onError10.call(callbacks, new ZeroXKeyError("WalletConnect initialization failed: ".concat(evt.error || "Unknown error"), ZeroXKeyErrorCodes.WALLET_CONNECT_INITIALIZATION_ERROR, evt.error));
1005
- return _context137.a(2);
1006
+ return _context140.a(2);
1006
1007
  case 2:
1007
1008
  if (!((evt === null || evt === void 0 ? void 0 : evt.type) === "initialized")) {
1008
- _context137.n = 7;
1009
+ _context140.n = 7;
1009
1010
  break;
1010
1011
  }
1011
- _context137.n = 3;
1012
+ _context140.n = 3;
1012
1013
  return debouncedFetchWalletProviders();
1013
1014
  case 3:
1014
- providers = _context137.v;
1015
- _context137.n = 4;
1015
+ providers = _context140.v;
1016
+ _context140.n = 4;
1016
1017
  return getSession();
1017
1018
  case 4:
1018
- currentSession = _context137.v;
1019
+ currentSession = _context140.v;
1019
1020
  if (!currentSession) {
1020
- _context137.n = 6;
1021
+ _context140.n = 6;
1021
1022
  break;
1022
1023
  }
1023
1024
  _wcProviders = providers === null || providers === void 0 ? void 0 : providers.filter(function (p) {
1024
1025
  return p.interfaceType === WalletInterfaceType.WalletConnect;
1025
1026
  });
1026
- _context137.n = 5;
1027
+ _context140.n = 5;
1027
1028
  return fetchWallets({
1028
1029
  walletProviders: _wcProviders,
1029
1030
  connectedOnly: true
1030
1031
  });
1031
1032
  case 5:
1032
- wcWallets = _context137.v;
1033
+ wcWallets = _context140.v;
1033
1034
  if (wcWallets.length > 0) {
1034
1035
  setWallets(function (prev) {
1035
1036
  return mergeWalletsWithoutDuplicates(prev, wcWallets);
1036
1037
  });
1037
1038
  }
1038
1039
  case 6:
1039
- return _context137.a(2);
1040
+ return _context140.a(2);
1040
1041
  case 7:
1041
- _context137.n = 8;
1042
+ _context140.n = 8;
1042
1043
  return onUpdateState();
1043
1044
  case 8:
1044
- return _context137.a(2);
1045
+ return _context140.a(2);
1045
1046
  }
1046
- }, _callee137);
1047
+ }, _callee140);
1047
1048
  }));
1048
- return function (_x115) {
1049
- return _ref160.apply(this, arguments);
1049
+ return function (_x118) {
1050
+ return _ref164.apply(this, arguments);
1050
1051
  };
1051
1052
  }());
1052
1053
  cleanups.push(unsubscribe);
1053
1054
  }
1054
1055
  }
1055
1056
  }
1056
- return _context138.a(2, function () {
1057
+ return _context141.a(2, function () {
1057
1058
  cleanups.forEach(function (remove) {
1058
1059
  return remove();
1059
1060
  });
1060
1061
  });
1061
1062
  }
1062
- }, _callee138);
1063
+ }, _callee141);
1063
1064
  }));
1064
1065
  return _initializeWalletProviderListeners.apply(this, arguments);
1065
1066
  }
@@ -3787,7 +3788,7 @@ var ClientProvider = function ClientProvider(_ref) {
3787
3788
  return _ref102.apply(this, arguments);
3788
3789
  };
3789
3790
  }(), [client, callbacks, logout]);
3790
- var verifyAppProofs = useCallback(/*#__PURE__*/function () {
3791
+ var fetchLatestBootProof = useCallback(/*#__PURE__*/function () {
3791
3792
  var _ref103 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(params) {
3792
3793
  return _regenerator().w(function (_context91) {
3793
3794
  while (1) switch (_context91.n) {
@@ -3799,10 +3800,10 @@ var ClientProvider = function ClientProvider(_ref) {
3799
3800
  throw new ZeroXKeyError("Client is not initialized.", ZeroXKeyErrorCodes.CLIENT_NOT_INITIALIZED);
3800
3801
  case 1:
3801
3802
  return _context91.a(2, withZeroXKeyErrorHandling(function () {
3802
- return client.verifyAppProofs(params);
3803
+ return client.fetchLatestBootProof(params);
3803
3804
  }, function () {
3804
3805
  return logout();
3805
- }, callbacks, "Failed to verify app proofs"));
3806
+ }, callbacks, "Failed to get the latest boot proof"));
3806
3807
  }
3807
3808
  }, _callee91);
3808
3809
  }));
@@ -3810,50 +3811,96 @@ var ClientProvider = function ClientProvider(_ref) {
3810
3811
  return _ref103.apply(this, arguments);
3811
3812
  };
3812
3813
  }(), [client, callbacks, logout]);
3813
- var handleDiscordOauth = useCallback(/*#__PURE__*/function () {
3814
- var _ref104 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(params) {
3815
- var _masterConfig$auth21, _masterConfig$auth21$, _masterConfig$auth$oa2, _masterConfig$auth22, _masterConfig$auth22$, _masterConfig$auth23, _masterConfig$auth23$, _masterConfig$auth24;
3816
- var _ref105, _ref105$clientId, clientId, _ref105$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, authUrl, authWindow;
3814
+ var verifyLatestBootProof = useCallback(/*#__PURE__*/function () {
3815
+ var _ref104 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee92(params) {
3816
+ return _regenerator().w(function (_context92) {
3817
+ while (1) switch (_context92.n) {
3818
+ case 0:
3819
+ if (client) {
3820
+ _context92.n = 1;
3821
+ break;
3822
+ }
3823
+ throw new ZeroXKeyError("Client is not initialized.", ZeroXKeyErrorCodes.CLIENT_NOT_INITIALIZED);
3824
+ case 1:
3825
+ return _context92.a(2, withZeroXKeyErrorHandling(function () {
3826
+ return client.verifyLatestBootProof(params);
3827
+ }, function () {
3828
+ return logout();
3829
+ }, callbacks, "Failed to verify the latest boot proof"));
3830
+ }
3831
+ }, _callee92);
3832
+ }));
3833
+ return function (_x75) {
3834
+ return _ref104.apply(this, arguments);
3835
+ };
3836
+ }(), [client, callbacks, logout]);
3837
+ var verifyAppProofs = useCallback(/*#__PURE__*/function () {
3838
+ var _ref105 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(params) {
3817
3839
  return _regenerator().w(function (_context93) {
3818
3840
  while (1) switch (_context93.n) {
3819
3841
  case 0:
3820
- _ref105 = params || {}, _ref105$clientId = _ref105.clientId, clientId = _ref105$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 : _ref105$clientId, _ref105$openInPage = _ref105.openInPage, openInPage = _ref105$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 : _ref105$openInPage, additionalParameters = _ref105.additionalState;
3842
+ if (client) {
3843
+ _context93.n = 1;
3844
+ break;
3845
+ }
3846
+ throw new ZeroXKeyError("Client is not initialized.", ZeroXKeyErrorCodes.CLIENT_NOT_INITIALIZED);
3847
+ case 1:
3848
+ return _context93.a(2, withZeroXKeyErrorHandling(function () {
3849
+ return client.verifyAppProofs(params);
3850
+ }, function () {
3851
+ return logout();
3852
+ }, callbacks, "Failed to verify app proofs"));
3853
+ }
3854
+ }, _callee93);
3855
+ }));
3856
+ return function (_x76) {
3857
+ return _ref105.apply(this, arguments);
3858
+ };
3859
+ }(), [client, callbacks, logout]);
3860
+ var handleDiscordOauth = useCallback(/*#__PURE__*/function () {
3861
+ var _ref106 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(params) {
3862
+ var _masterConfig$auth21, _masterConfig$auth21$, _masterConfig$auth$oa2, _masterConfig$auth22, _masterConfig$auth22$, _masterConfig$auth23, _masterConfig$auth23$, _masterConfig$auth24;
3863
+ var _ref107, _ref107$clientId, clientId, _ref107$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, authUrl, authWindow;
3864
+ return _regenerator().w(function (_context95) {
3865
+ while (1) switch (_context95.n) {
3866
+ case 0:
3867
+ _ref107 = params || {}, _ref107$clientId = _ref107.clientId, clientId = _ref107$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 : _ref107$clientId, _ref107$openInPage = _ref107.openInPage, openInPage = _ref107$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 : _ref107$openInPage, additionalParameters = _ref107.additionalState;
3821
3868
  provider = OAuthProviders.DISCORD;
3822
3869
  if (masterConfig) {
3823
- _context93.n = 1;
3870
+ _context95.n = 1;
3824
3871
  break;
3825
3872
  }
3826
3873
  throw new ZeroXKeyError("Config is not ready yet!", ZeroXKeyErrorCodes.INVALID_CONFIGURATION);
3827
3874
  case 1:
3828
3875
  if (clientId) {
3829
- _context93.n = 2;
3876
+ _context95.n = 2;
3830
3877
  break;
3831
3878
  }
3832
3879
  throw new ZeroXKeyError("Discord Client ID is not configured.", ZeroXKeyErrorCodes.INVALID_CONFIGURATION);
3833
3880
  case 2:
3834
3881
  if ((_masterConfig$auth23 = masterConfig.auth) !== null && _masterConfig$auth23 !== void 0 && (_masterConfig$auth23$ = _masterConfig$auth23.oauthConfig) !== null && _masterConfig$auth23$ !== void 0 && _masterConfig$auth23$.oauthRedirectUri) {
3835
- _context93.n = 3;
3882
+ _context95.n = 3;
3836
3883
  break;
3837
3884
  }
3838
3885
  throw new ZeroXKeyError("OAuth Redirect URI is not configured.", ZeroXKeyErrorCodes.INVALID_CONFIGURATION);
3839
3886
  case 3:
3840
3887
  flow = openInPage ? "redirect" : "popup";
3841
3888
  redirectUri = (_masterConfig$auth24 = masterConfig.auth) === null || _masterConfig$auth24 === void 0 ? void 0 : _masterConfig$auth24.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3842
- _context93.n = 4;
3889
+ _context95.n = 4;
3843
3890
  return createApiKeyPair();
3844
3891
  case 4:
3845
- publicKey = _context93.v;
3892
+ publicKey = _context95.v;
3846
3893
  if (publicKey) {
3847
- _context93.n = 5;
3894
+ _context95.n = 5;
3848
3895
  break;
3849
3896
  }
3850
3897
  throw new Error("Failed to create public key for OAuth.");
3851
3898
  case 5:
3852
3899
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair and store verifier
3853
- _context93.n = 6;
3900
+ _context95.n = 6;
3854
3901
  return generateChallengePair();
3855
3902
  case 6:
3856
- _yield$generateChalle = _context93.v;
3903
+ _yield$generateChalle = _context95.v;
3857
3904
  verifier = _yield$generateChalle.verifier;
3858
3905
  codeChallenge = _yield$generateChalle.codeChallenge;
3859
3906
  storePKCEVerifier(provider, verifier);
@@ -3869,21 +3916,21 @@ var ClientProvider = function ClientProvider(_ref) {
3869
3916
  additionalState: additionalParameters
3870
3917
  });
3871
3918
  if (!openInPage) {
3872
- _context93.n = 7;
3919
+ _context95.n = 7;
3873
3920
  break;
3874
3921
  }
3875
- return _context93.a(2, redirectToOAuthProvider(authUrl));
3922
+ return _context95.a(2, redirectToOAuthProvider(authUrl));
3876
3923
  case 7:
3877
3924
  // Popup flow
3878
3925
  authWindow = openOAuthPopup();
3879
3926
  if (authWindow) {
3880
- _context93.n = 8;
3927
+ _context95.n = 8;
3881
3928
  break;
3882
3929
  }
3883
3930
  throw new Error("Failed to open ".concat(capitalizeProviderName(provider), " login window."));
3884
3931
  case 8:
3885
3932
  authWindow.location.href = authUrl;
3886
- return _context93.a(2, new Promise(function (resolve, reject) {
3933
+ return _context95.a(2, new Promise(function (resolve, reject) {
3887
3934
  var interval = setInterval(function () {
3888
3935
  try {
3889
3936
  if (authWindow.closed) {
@@ -3905,13 +3952,13 @@ var ClientProvider = function ClientProvider(_ref) {
3905
3952
  completeOauth: completeOauth,
3906
3953
  onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess,
3907
3954
  exchangeCodeForToken: function () {
3908
- var _exchangeCodeForToken = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee92(codeVerifier) {
3955
+ var _exchangeCodeForToken = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(codeVerifier) {
3909
3956
  var _resp$oidcToken;
3910
3957
  var resp;
3911
- return _regenerator().w(function (_context92) {
3912
- while (1) switch (_context92.n) {
3958
+ return _regenerator().w(function (_context94) {
3959
+ while (1) switch (_context94.n) {
3913
3960
  case 0:
3914
- _context92.n = 1;
3961
+ _context94.n = 1;
3915
3962
  return client === null || client === void 0 ? void 0 : client.httpClient.proxyOAuth2Authenticate({
3916
3963
  provider: "OAUTH2_PROVIDER_DISCORD",
3917
3964
  authCode: result.authCode,
@@ -3921,12 +3968,12 @@ var ClientProvider = function ClientProvider(_ref) {
3921
3968
  nonce: nonce
3922
3969
  });
3923
3970
  case 1:
3924
- resp = _context92.v;
3925
- return _context92.a(2, (_resp$oidcToken = resp === null || resp === void 0 ? void 0 : resp.oidcToken) !== null && _resp$oidcToken !== void 0 ? _resp$oidcToken : "");
3971
+ resp = _context94.v;
3972
+ return _context94.a(2, (_resp$oidcToken = resp === null || resp === void 0 ? void 0 : resp.oidcToken) !== null && _resp$oidcToken !== void 0 ? _resp$oidcToken : "");
3926
3973
  }
3927
- }, _callee92);
3974
+ }, _callee94);
3928
3975
  }));
3929
- function exchangeCodeForToken(_x76) {
3976
+ function exchangeCodeForToken(_x78) {
3930
3977
  return _exchangeCodeForToken.apply(this, arguments);
3931
3978
  }
3932
3979
  return exchangeCodeForToken;
@@ -3945,56 +3992,56 @@ var ClientProvider = function ClientProvider(_ref) {
3945
3992
  }
3946
3993
  }));
3947
3994
  }
3948
- }, _callee93);
3995
+ }, _callee95);
3949
3996
  }));
3950
- return function (_x75) {
3951
- return _ref104.apply(this, arguments);
3997
+ return function (_x77) {
3998
+ return _ref106.apply(this, arguments);
3952
3999
  };
3953
4000
  }(), [client, callbacks, completeOauth, createApiKeyPair, masterConfig]);
3954
4001
  var handleXOauth = useCallback(/*#__PURE__*/function () {
3955
- var _ref106 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(params) {
4002
+ var _ref108 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(params) {
3956
4003
  var _masterConfig$auth25, _masterConfig$auth25$, _masterConfig$auth$oa3, _masterConfig$auth26, _masterConfig$auth26$, _masterConfig$auth27, _masterConfig$auth27$, _masterConfig$auth28;
3957
- var _ref107, _ref107$clientId, clientId, _ref107$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, authUrl, authWindow;
3958
- return _regenerator().w(function (_context95) {
3959
- while (1) switch (_context95.n) {
4004
+ var _ref109, _ref109$clientId, clientId, _ref109$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, authUrl, authWindow;
4005
+ return _regenerator().w(function (_context97) {
4006
+ while (1) switch (_context97.n) {
3960
4007
  case 0:
3961
- _ref107 = params || {}, _ref107$clientId = _ref107.clientId, clientId = _ref107$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 : _ref107$clientId, _ref107$openInPage = _ref107.openInPage, openInPage = _ref107$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 : _ref107$openInPage, additionalParameters = _ref107.additionalState;
4008
+ _ref109 = params || {}, _ref109$clientId = _ref109.clientId, clientId = _ref109$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 : _ref109$clientId, _ref109$openInPage = _ref109.openInPage, openInPage = _ref109$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 : _ref109$openInPage, additionalParameters = _ref109.additionalState;
3962
4009
  provider = OAuthProviders.X;
3963
4010
  if (masterConfig) {
3964
- _context95.n = 1;
4011
+ _context97.n = 1;
3965
4012
  break;
3966
4013
  }
3967
4014
  throw new ZeroXKeyError("Config is not ready yet!", ZeroXKeyErrorCodes.INVALID_CONFIGURATION);
3968
4015
  case 1:
3969
4016
  if (clientId) {
3970
- _context95.n = 2;
4017
+ _context97.n = 2;
3971
4018
  break;
3972
4019
  }
3973
4020
  throw new ZeroXKeyError("Twitter Client ID is not configured.", ZeroXKeyErrorCodes.INVALID_CONFIGURATION);
3974
4021
  case 2:
3975
4022
  if ((_masterConfig$auth27 = masterConfig.auth) !== null && _masterConfig$auth27 !== void 0 && (_masterConfig$auth27$ = _masterConfig$auth27.oauthConfig) !== null && _masterConfig$auth27$ !== void 0 && _masterConfig$auth27$.oauthRedirectUri) {
3976
- _context95.n = 3;
4023
+ _context97.n = 3;
3977
4024
  break;
3978
4025
  }
3979
4026
  throw new ZeroXKeyError("OAuth Redirect URI is not configured.", ZeroXKeyErrorCodes.INVALID_CONFIGURATION);
3980
4027
  case 3:
3981
4028
  flow = openInPage ? "redirect" : "popup";
3982
4029
  redirectUri = (_masterConfig$auth28 = masterConfig.auth) === null || _masterConfig$auth28 === void 0 ? void 0 : _masterConfig$auth28.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
3983
- _context95.n = 4;
4030
+ _context97.n = 4;
3984
4031
  return createApiKeyPair();
3985
4032
  case 4:
3986
- publicKey = _context95.v;
4033
+ publicKey = _context97.v;
3987
4034
  if (publicKey) {
3988
- _context95.n = 5;
4035
+ _context97.n = 5;
3989
4036
  break;
3990
4037
  }
3991
4038
  throw new Error("Failed to create public key for OAuth.");
3992
4039
  case 5:
3993
4040
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair and store verifier
3994
- _context95.n = 6;
4041
+ _context97.n = 6;
3995
4042
  return generateChallengePair();
3996
4043
  case 6:
3997
- _yield$generateChalle2 = _context95.v;
4044
+ _yield$generateChalle2 = _context97.v;
3998
4045
  verifier = _yield$generateChalle2.verifier;
3999
4046
  codeChallenge = _yield$generateChalle2.codeChallenge;
4000
4047
  storePKCEVerifier(provider, verifier);
@@ -4010,21 +4057,21 @@ var ClientProvider = function ClientProvider(_ref) {
4010
4057
  additionalState: additionalParameters
4011
4058
  });
4012
4059
  if (!openInPage) {
4013
- _context95.n = 7;
4060
+ _context97.n = 7;
4014
4061
  break;
4015
4062
  }
4016
- return _context95.a(2, redirectToOAuthProvider(authUrl));
4063
+ return _context97.a(2, redirectToOAuthProvider(authUrl));
4017
4064
  case 7:
4018
4065
  // Popup flow
4019
4066
  authWindow = openOAuthPopup();
4020
4067
  if (authWindow) {
4021
- _context95.n = 8;
4068
+ _context97.n = 8;
4022
4069
  break;
4023
4070
  }
4024
4071
  throw new Error("Failed to open ".concat(capitalizeProviderName(provider), " login window."));
4025
4072
  case 8:
4026
4073
  authWindow.location.href = authUrl;
4027
- return _context95.a(2, new Promise(function (resolve, reject) {
4074
+ return _context97.a(2, new Promise(function (resolve, reject) {
4028
4075
  var interval = setInterval(function () {
4029
4076
  try {
4030
4077
  if (authWindow.closed) {
@@ -4046,13 +4093,13 @@ var ClientProvider = function ClientProvider(_ref) {
4046
4093
  completeOauth: completeOauth,
4047
4094
  onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess,
4048
4095
  exchangeCodeForToken: function () {
4049
- var _exchangeCodeForToken2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(codeVerifier) {
4096
+ var _exchangeCodeForToken2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(codeVerifier) {
4050
4097
  var _resp$oidcToken2;
4051
4098
  var resp;
4052
- return _regenerator().w(function (_context94) {
4053
- while (1) switch (_context94.n) {
4099
+ return _regenerator().w(function (_context96) {
4100
+ while (1) switch (_context96.n) {
4054
4101
  case 0:
4055
- _context94.n = 1;
4102
+ _context96.n = 1;
4056
4103
  return client === null || client === void 0 ? void 0 : client.httpClient.proxyOAuth2Authenticate({
4057
4104
  provider: "OAUTH2_PROVIDER_X",
4058
4105
  authCode: result.authCode,
@@ -4062,12 +4109,12 @@ var ClientProvider = function ClientProvider(_ref) {
4062
4109
  nonce: nonce
4063
4110
  });
4064
4111
  case 1:
4065
- resp = _context94.v;
4066
- return _context94.a(2, (_resp$oidcToken2 = resp === null || resp === void 0 ? void 0 : resp.oidcToken) !== null && _resp$oidcToken2 !== void 0 ? _resp$oidcToken2 : "");
4112
+ resp = _context96.v;
4113
+ return _context96.a(2, (_resp$oidcToken2 = resp === null || resp === void 0 ? void 0 : resp.oidcToken) !== null && _resp$oidcToken2 !== void 0 ? _resp$oidcToken2 : "");
4067
4114
  }
4068
- }, _callee94);
4115
+ }, _callee96);
4069
4116
  }));
4070
- function exchangeCodeForToken(_x78) {
4117
+ function exchangeCodeForToken(_x80) {
4071
4118
  return _exchangeCodeForToken2.apply(this, arguments);
4072
4119
  }
4073
4120
  return exchangeCodeForToken;
@@ -4086,47 +4133,47 @@ var ClientProvider = function ClientProvider(_ref) {
4086
4133
  }
4087
4134
  }));
4088
4135
  }
4089
- }, _callee95);
4136
+ }, _callee97);
4090
4137
  }));
4091
- return function (_x77) {
4092
- return _ref106.apply(this, arguments);
4138
+ return function (_x79) {
4139
+ return _ref108.apply(this, arguments);
4093
4140
  };
4094
4141
  }(), [client, callbacks, completeOauth, createApiKeyPair, masterConfig]);
4095
4142
  var handleGoogleOauth = useCallback(/*#__PURE__*/function () {
4096
- var _ref108 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(params) {
4143
+ var _ref110 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(params) {
4097
4144
  var _masterConfig$auth29, _masterConfig$auth29$, _masterConfig$auth$oa4, _masterConfig$auth30, _masterConfig$auth30$, _masterConfig$auth31, _masterConfig$auth31$, _masterConfig$auth32;
4098
- var _ref109, _ref109$clientId, clientId, _ref109$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4099
- return _regenerator().w(function (_context96) {
4100
- while (1) switch (_context96.n) {
4145
+ var _ref111, _ref111$clientId, clientId, _ref111$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4146
+ return _regenerator().w(function (_context98) {
4147
+ while (1) switch (_context98.n) {
4101
4148
  case 0:
4102
- _ref109 = params || {}, _ref109$clientId = _ref109.clientId, clientId = _ref109$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 : _ref109$clientId, _ref109$openInPage = _ref109.openInPage, openInPage = _ref109$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 : _ref109$openInPage, additionalParameters = _ref109.additionalState;
4149
+ _ref111 = params || {}, _ref111$clientId = _ref111.clientId, clientId = _ref111$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 : _ref111$clientId, _ref111$openInPage = _ref111.openInPage, openInPage = _ref111$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 : _ref111$openInPage, additionalParameters = _ref111.additionalState;
4103
4150
  provider = OAuthProviders.GOOGLE;
4104
4151
  if (masterConfig) {
4105
- _context96.n = 1;
4152
+ _context98.n = 1;
4106
4153
  break;
4107
4154
  }
4108
4155
  throw new ZeroXKeyError("Config is not ready yet!", ZeroXKeyErrorCodes.INVALID_CONFIGURATION);
4109
4156
  case 1:
4110
4157
  if (clientId) {
4111
- _context96.n = 2;
4158
+ _context98.n = 2;
4112
4159
  break;
4113
4160
  }
4114
4161
  throw new ZeroXKeyError("Google Client ID is not configured.", ZeroXKeyErrorCodes.INVALID_CONFIGURATION);
4115
4162
  case 2:
4116
4163
  if ((_masterConfig$auth31 = masterConfig.auth) !== null && _masterConfig$auth31 !== void 0 && (_masterConfig$auth31$ = _masterConfig$auth31.oauthConfig) !== null && _masterConfig$auth31$ !== void 0 && _masterConfig$auth31$.oauthRedirectUri) {
4117
- _context96.n = 3;
4164
+ _context98.n = 3;
4118
4165
  break;
4119
4166
  }
4120
4167
  throw new ZeroXKeyError("OAuth Redirect URI is not configured.", ZeroXKeyErrorCodes.INVALID_CONFIGURATION);
4121
4168
  case 3:
4122
4169
  flow = openInPage ? "redirect" : "popup"; // Google requires no trailing slash
4123
4170
  redirectUri = (_masterConfig$auth32 = masterConfig.auth) === null || _masterConfig$auth32 === void 0 ? void 0 : _masterConfig$auth32.oauthConfig.oauthRedirectUri.replace(/\/$/, ""); // Create key pair and generate nonce
4124
- _context96.n = 4;
4171
+ _context98.n = 4;
4125
4172
  return createApiKeyPair();
4126
4173
  case 4:
4127
- publicKey = _context96.v;
4174
+ publicKey = _context98.v;
4128
4175
  if (publicKey) {
4129
- _context96.n = 5;
4176
+ _context98.n = 5;
4130
4177
  break;
4131
4178
  }
4132
4179
  throw new Error("Failed to create public key for OAuth.");
@@ -4142,21 +4189,21 @@ var ClientProvider = function ClientProvider(_ref) {
4142
4189
  additionalState: additionalParameters
4143
4190
  });
4144
4191
  if (!openInPage) {
4145
- _context96.n = 6;
4192
+ _context98.n = 6;
4146
4193
  break;
4147
4194
  }
4148
- return _context96.a(2, redirectToOAuthProvider(authUrl));
4195
+ return _context98.a(2, redirectToOAuthProvider(authUrl));
4149
4196
  case 6:
4150
4197
  // Popup flow
4151
4198
  authWindow = openOAuthPopup();
4152
4199
  if (authWindow) {
4153
- _context96.n = 7;
4200
+ _context98.n = 7;
4154
4201
  break;
4155
4202
  }
4156
4203
  throw new Error("Failed to open ".concat(capitalizeProviderName(provider), " login window."));
4157
4204
  case 7:
4158
4205
  authWindow.location.href = authUrl;
4159
- return _context96.a(2, new Promise(function (resolve, reject) {
4206
+ return _context98.a(2, new Promise(function (resolve, reject) {
4160
4207
  var interval = setInterval(function () {
4161
4208
  try {
4162
4209
  if (authWindow.closed) {
@@ -4191,47 +4238,47 @@ var ClientProvider = function ClientProvider(_ref) {
4191
4238
  }
4192
4239
  }));
4193
4240
  }
4194
- }, _callee96);
4241
+ }, _callee98);
4195
4242
  }));
4196
- return function (_x79) {
4197
- return _ref108.apply(this, arguments);
4243
+ return function (_x81) {
4244
+ return _ref110.apply(this, arguments);
4198
4245
  };
4199
4246
  }(), [callbacks, completeOauth, createApiKeyPair, masterConfig]);
4200
4247
  var handleAppleOauth = useCallback(/*#__PURE__*/function () {
4201
- var _ref110 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(params) {
4248
+ var _ref112 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99(params) {
4202
4249
  var _masterConfig$auth33, _masterConfig$auth33$, _masterConfig$auth$oa5, _masterConfig$auth34, _masterConfig$auth34$, _masterConfig$auth35, _masterConfig$auth35$, _masterConfig$auth36;
4203
- var _ref111, _ref111$clientId, clientId, _ref111$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4204
- return _regenerator().w(function (_context97) {
4205
- while (1) switch (_context97.n) {
4250
+ var _ref113, _ref113$clientId, clientId, _ref113$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4251
+ return _regenerator().w(function (_context99) {
4252
+ while (1) switch (_context99.n) {
4206
4253
  case 0:
4207
- _ref111 = params || {}, _ref111$clientId = _ref111.clientId, clientId = _ref111$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 : _ref111$clientId, _ref111$openInPage = _ref111.openInPage, openInPage = _ref111$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 : _ref111$openInPage, additionalParameters = _ref111.additionalState;
4254
+ _ref113 = params || {}, _ref113$clientId = _ref113.clientId, clientId = _ref113$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 : _ref113$clientId, _ref113$openInPage = _ref113.openInPage, openInPage = _ref113$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 : _ref113$openInPage, additionalParameters = _ref113.additionalState;
4208
4255
  provider = OAuthProviders.APPLE;
4209
4256
  if (masterConfig) {
4210
- _context97.n = 1;
4257
+ _context99.n = 1;
4211
4258
  break;
4212
4259
  }
4213
4260
  throw new ZeroXKeyError("Config is not ready yet!", ZeroXKeyErrorCodes.INVALID_CONFIGURATION);
4214
4261
  case 1:
4215
4262
  if (clientId) {
4216
- _context97.n = 2;
4263
+ _context99.n = 2;
4217
4264
  break;
4218
4265
  }
4219
4266
  throw new ZeroXKeyError("Apple Client ID is not configured.", ZeroXKeyErrorCodes.INVALID_CONFIGURATION);
4220
4267
  case 2:
4221
4268
  if ((_masterConfig$auth35 = masterConfig.auth) !== null && _masterConfig$auth35 !== void 0 && (_masterConfig$auth35$ = _masterConfig$auth35.oauthConfig) !== null && _masterConfig$auth35$ !== void 0 && _masterConfig$auth35$.oauthRedirectUri) {
4222
- _context97.n = 3;
4269
+ _context99.n = 3;
4223
4270
  break;
4224
4271
  }
4225
4272
  throw new ZeroXKeyError("OAuth Redirect URI is not configured.", ZeroXKeyErrorCodes.INVALID_CONFIGURATION);
4226
4273
  case 3:
4227
4274
  flow = openInPage ? "redirect" : "popup"; // TODO (Amir): Apple needs the '/' at the end. Maybe we should add it if not there?
4228
4275
  redirectUri = (_masterConfig$auth36 = masterConfig.auth) === null || _masterConfig$auth36 === void 0 ? void 0 : _masterConfig$auth36.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4229
- _context97.n = 4;
4276
+ _context99.n = 4;
4230
4277
  return createApiKeyPair();
4231
4278
  case 4:
4232
- publicKey = _context97.v;
4279
+ publicKey = _context99.v;
4233
4280
  if (publicKey) {
4234
- _context97.n = 5;
4281
+ _context99.n = 5;
4235
4282
  break;
4236
4283
  }
4237
4284
  throw new Error("Failed to create public key for OAuth.");
@@ -4247,21 +4294,21 @@ var ClientProvider = function ClientProvider(_ref) {
4247
4294
  additionalState: additionalParameters
4248
4295
  });
4249
4296
  if (!openInPage) {
4250
- _context97.n = 6;
4297
+ _context99.n = 6;
4251
4298
  break;
4252
4299
  }
4253
- return _context97.a(2, redirectToOAuthProvider(authUrl));
4300
+ return _context99.a(2, redirectToOAuthProvider(authUrl));
4254
4301
  case 6:
4255
4302
  // Popup flow
4256
4303
  authWindow = openOAuthPopup();
4257
4304
  if (authWindow) {
4258
- _context97.n = 7;
4305
+ _context99.n = 7;
4259
4306
  break;
4260
4307
  }
4261
4308
  throw new Error("Failed to open ".concat(capitalizeProviderName(provider), " login window."));
4262
4309
  case 7:
4263
4310
  authWindow.location.href = authUrl;
4264
- return _context97.a(2, new Promise(function (resolve, reject) {
4311
+ return _context99.a(2, new Promise(function (resolve, reject) {
4265
4312
  var interval = setInterval(function () {
4266
4313
  try {
4267
4314
  if (authWindow.closed) {
@@ -4296,56 +4343,56 @@ var ClientProvider = function ClientProvider(_ref) {
4296
4343
  }
4297
4344
  }));
4298
4345
  }
4299
- }, _callee97);
4346
+ }, _callee99);
4300
4347
  }));
4301
- return function (_x80) {
4302
- return _ref110.apply(this, arguments);
4348
+ return function (_x82) {
4349
+ return _ref112.apply(this, arguments);
4303
4350
  };
4304
4351
  }(), [callbacks, completeOauth, createApiKeyPair, masterConfig]);
4305
4352
  var handleFacebookOauth = useCallback(/*#__PURE__*/function () {
4306
- var _ref112 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99(params) {
4353
+ var _ref114 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101(params) {
4307
4354
  var _masterConfig$auth37, _masterConfig$auth37$, _masterConfig$auth$oa6, _masterConfig$auth38, _masterConfig$auth38$, _masterConfig$auth39, _masterConfig$auth39$, _masterConfig$auth40;
4308
- var _ref113, _ref113$clientId, clientId, _ref113$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, authUrl, authWindow;
4309
- return _regenerator().w(function (_context99) {
4310
- while (1) switch (_context99.n) {
4355
+ var _ref115, _ref115$clientId, clientId, _ref115$openInPage, openInPage, additionalParameters, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, authUrl, authWindow;
4356
+ return _regenerator().w(function (_context101) {
4357
+ while (1) switch (_context101.n) {
4311
4358
  case 0:
4312
- _ref113 = params || {}, _ref113$clientId = _ref113.clientId, clientId = _ref113$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 : _ref113$clientId, _ref113$openInPage = _ref113.openInPage, openInPage = _ref113$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 : _ref113$openInPage, additionalParameters = _ref113.additionalState;
4359
+ _ref115 = params || {}, _ref115$clientId = _ref115.clientId, clientId = _ref115$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 : _ref115$clientId, _ref115$openInPage = _ref115.openInPage, openInPage = _ref115$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 : _ref115$openInPage, additionalParameters = _ref115.additionalState;
4313
4360
  provider = OAuthProviders.FACEBOOK;
4314
4361
  if (masterConfig) {
4315
- _context99.n = 1;
4362
+ _context101.n = 1;
4316
4363
  break;
4317
4364
  }
4318
4365
  throw new ZeroXKeyError("Config is not ready yet!", ZeroXKeyErrorCodes.INVALID_CONFIGURATION);
4319
4366
  case 1:
4320
4367
  if (clientId) {
4321
- _context99.n = 2;
4368
+ _context101.n = 2;
4322
4369
  break;
4323
4370
  }
4324
4371
  throw new ZeroXKeyError("Facebook Client ID is not configured.", ZeroXKeyErrorCodes.INVALID_CONFIGURATION);
4325
4372
  case 2:
4326
4373
  if ((_masterConfig$auth39 = masterConfig.auth) !== null && _masterConfig$auth39 !== void 0 && (_masterConfig$auth39$ = _masterConfig$auth39.oauthConfig) !== null && _masterConfig$auth39$ !== void 0 && _masterConfig$auth39$.oauthRedirectUri) {
4327
- _context99.n = 3;
4374
+ _context101.n = 3;
4328
4375
  break;
4329
4376
  }
4330
4377
  throw new ZeroXKeyError("OAuth Redirect URI is not configured.", ZeroXKeyErrorCodes.INVALID_CONFIGURATION);
4331
4378
  case 3:
4332
4379
  flow = openInPage ? "redirect" : "popup";
4333
4380
  redirectUri = (_masterConfig$auth40 = masterConfig.auth) === null || _masterConfig$auth40 === void 0 ? void 0 : _masterConfig$auth40.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
4334
- _context99.n = 4;
4381
+ _context101.n = 4;
4335
4382
  return createApiKeyPair();
4336
4383
  case 4:
4337
- publicKey = _context99.v;
4384
+ publicKey = _context101.v;
4338
4385
  if (publicKey) {
4339
- _context99.n = 5;
4386
+ _context101.n = 5;
4340
4387
  break;
4341
4388
  }
4342
4389
  throw new Error("Failed to create public key for OAuth.");
4343
4390
  case 5:
4344
4391
  nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair and store verifier
4345
- _context99.n = 6;
4392
+ _context101.n = 6;
4346
4393
  return generateChallengePair();
4347
4394
  case 6:
4348
- _yield$generateChalle3 = _context99.v;
4395
+ _yield$generateChalle3 = _context101.v;
4349
4396
  verifier = _yield$generateChalle3.verifier;
4350
4397
  codeChallenge = _yield$generateChalle3.codeChallenge;
4351
4398
  storePKCEVerifier(provider, verifier);
@@ -4361,21 +4408,21 @@ var ClientProvider = function ClientProvider(_ref) {
4361
4408
  additionalState: additionalParameters
4362
4409
  });
4363
4410
  if (!openInPage) {
4364
- _context99.n = 7;
4411
+ _context101.n = 7;
4365
4412
  break;
4366
4413
  }
4367
- return _context99.a(2, redirectToOAuthProvider(authUrl));
4414
+ return _context101.a(2, redirectToOAuthProvider(authUrl));
4368
4415
  case 7:
4369
4416
  // Popup flow
4370
4417
  authWindow = openOAuthPopup();
4371
4418
  if (authWindow) {
4372
- _context99.n = 8;
4419
+ _context101.n = 8;
4373
4420
  break;
4374
4421
  }
4375
4422
  throw new Error("Failed to open ".concat(capitalizeProviderName(provider), " login window."));
4376
4423
  case 8:
4377
4424
  authWindow.location.href = authUrl;
4378
- return _context99.a(2, new Promise(function (resolve, reject) {
4425
+ return _context101.a(2, new Promise(function (resolve, reject) {
4379
4426
  var interval = setInterval(function () {
4380
4427
  try {
4381
4428
  if (authWindow.closed) {
@@ -4397,20 +4444,20 @@ var ClientProvider = function ClientProvider(_ref) {
4397
4444
  completeOauth: completeOauth,
4398
4445
  onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess,
4399
4446
  exchangeCodeForToken: function () {
4400
- var _exchangeCodeForToken3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(codeVerifier) {
4447
+ var _exchangeCodeForToken3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100(codeVerifier) {
4401
4448
  var tokenData;
4402
- return _regenerator().w(function (_context98) {
4403
- while (1) switch (_context98.n) {
4449
+ return _regenerator().w(function (_context100) {
4450
+ while (1) switch (_context100.n) {
4404
4451
  case 0:
4405
- _context98.n = 1;
4452
+ _context100.n = 1;
4406
4453
  return exchangeFacebookCodeForToken(clientId, redirectUri, result.authCode, codeVerifier);
4407
4454
  case 1:
4408
- tokenData = _context98.v;
4409
- return _context98.a(2, tokenData.id_token);
4455
+ tokenData = _context100.v;
4456
+ return _context100.a(2, tokenData.id_token);
4410
4457
  }
4411
- }, _callee98);
4458
+ }, _callee100);
4412
4459
  }));
4413
- function exchangeCodeForToken(_x82) {
4460
+ function exchangeCodeForToken(_x84) {
4414
4461
  return _exchangeCodeForToken3.apply(this, arguments);
4415
4462
  }
4416
4463
  return exchangeCodeForToken;
@@ -4429,18 +4476,18 @@ var ClientProvider = function ClientProvider(_ref) {
4429
4476
  }
4430
4477
  }));
4431
4478
  }
4432
- }, _callee99);
4479
+ }, _callee101);
4433
4480
  }));
4434
- return function (_x81) {
4435
- return _ref112.apply(this, arguments);
4481
+ return function (_x83) {
4482
+ return _ref114.apply(this, arguments);
4436
4483
  };
4437
4484
  }(), [callbacks, completeOauth, createApiKeyPair, masterConfig]);
4438
4485
  var handleLogin = useCallback(/*#__PURE__*/function () {
4439
- var _ref114 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100(params) {
4486
+ var _ref116 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102(params) {
4440
4487
  var _masterConfig$ui, _params$logoDark, _masterConfig$ui2, _params$logoLight, _masterConfig$ui3, _params$title;
4441
4488
  var logo;
4442
- return _regenerator().w(function (_context100) {
4443
- while (1) switch (_context100.n) {
4489
+ return _regenerator().w(function (_context102) {
4490
+ while (1) switch (_context102.n) {
4444
4491
  case 0:
4445
4492
  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;
4446
4493
  pushPage({
@@ -4455,22 +4502,22 @@ var ClientProvider = function ClientProvider(_ref) {
4455
4502
  preventClose: true
4456
4503
  });
4457
4504
  case 1:
4458
- return _context100.a(2);
4505
+ return _context102.a(2);
4459
4506
  }
4460
- }, _callee100);
4507
+ }, _callee102);
4461
4508
  }));
4462
- return function (_x83) {
4463
- return _ref114.apply(this, arguments);
4509
+ return function (_x85) {
4510
+ return _ref116.apply(this, arguments);
4464
4511
  };
4465
4512
  }(), [pushPage, masterConfig]);
4466
4513
  var handleExportWallet = useCallback(/*#__PURE__*/function () {
4467
- var _ref115 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101(params) {
4514
+ var _ref117 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee103(params) {
4468
4515
  var walletId, targetPublicKey, stampWith, organizationId;
4469
- return _regenerator().w(function (_context101) {
4470
- while (1) switch (_context101.n) {
4516
+ return _regenerator().w(function (_context103) {
4517
+ while (1) switch (_context103.n) {
4471
4518
  case 0:
4472
4519
  walletId = params.walletId, targetPublicKey = params.targetPublicKey, stampWith = params.stampWith, organizationId = params.organizationId;
4473
- return _context101.a(2, new Promise(function (resolve, reject) {
4520
+ return _context103.a(2, new Promise(function (resolve, reject) {
4474
4521
  return pushPage({
4475
4522
  key: "Export wallet",
4476
4523
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4496,20 +4543,20 @@ var ClientProvider = function ClientProvider(_ref) {
4496
4543
  });
4497
4544
  }));
4498
4545
  }
4499
- }, _callee101);
4546
+ }, _callee103);
4500
4547
  }));
4501
- return function (_x84) {
4502
- return _ref115.apply(this, arguments);
4548
+ return function (_x86) {
4549
+ return _ref117.apply(this, arguments);
4503
4550
  };
4504
4551
  }(), [pushPage]);
4505
4552
  var handleExportPrivateKey = useCallback(/*#__PURE__*/function () {
4506
- var _ref116 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102(params) {
4553
+ var _ref118 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee104(params) {
4507
4554
  var privateKeyId, targetPublicKey, keyFormat, stampWith, organizationId;
4508
- return _regenerator().w(function (_context102) {
4509
- while (1) switch (_context102.n) {
4555
+ return _regenerator().w(function (_context104) {
4556
+ while (1) switch (_context104.n) {
4510
4557
  case 0:
4511
4558
  privateKeyId = params.privateKeyId, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith, organizationId = params.organizationId;
4512
- return _context102.a(2, new Promise(function (resolve, reject) {
4559
+ return _context104.a(2, new Promise(function (resolve, reject) {
4513
4560
  return pushPage({
4514
4561
  key: "Export private key",
4515
4562
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4537,20 +4584,20 @@ var ClientProvider = function ClientProvider(_ref) {
4537
4584
  });
4538
4585
  }));
4539
4586
  }
4540
- }, _callee102);
4587
+ }, _callee104);
4541
4588
  }));
4542
- return function (_x85) {
4543
- return _ref116.apply(this, arguments);
4589
+ return function (_x87) {
4590
+ return _ref118.apply(this, arguments);
4544
4591
  };
4545
4592
  }(), [pushPage]);
4546
4593
  var handleExportWalletAccount = useCallback(/*#__PURE__*/function () {
4547
- var _ref117 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee103(params) {
4594
+ var _ref119 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee105(params) {
4548
4595
  var address, targetPublicKey, keyFormat, stampWith, organizationId;
4549
- return _regenerator().w(function (_context103) {
4550
- while (1) switch (_context103.n) {
4596
+ return _regenerator().w(function (_context105) {
4597
+ while (1) switch (_context105.n) {
4551
4598
  case 0:
4552
4599
  address = params.address, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith, organizationId = params.organizationId;
4553
- return _context103.a(2, new Promise(function (resolve, reject) {
4600
+ return _context105.a(2, new Promise(function (resolve, reject) {
4554
4601
  return pushPage({
4555
4602
  key: "Export wallet account",
4556
4603
  content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
@@ -4578,21 +4625,21 @@ var ClientProvider = function ClientProvider(_ref) {
4578
4625
  });
4579
4626
  }));
4580
4627
  }
4581
- }, _callee103);
4628
+ }, _callee105);
4582
4629
  }));
4583
- return function (_x86) {
4584
- return _ref117.apply(this, arguments);
4630
+ return function (_x88) {
4631
+ return _ref119.apply(this, arguments);
4585
4632
  };
4586
4633
  }(), [pushPage]);
4587
4634
  var handleImportWallet = useCallback(/*#__PURE__*/function () {
4588
- var _ref118 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee104(params) {
4589
- var _ref119, defaultWalletAccounts, _ref119$successPageDu, successPageDuration, stampWith, walletName, clearClipboardOnPaste, organizationId, userId, _t10;
4590
- return _regenerator().w(function (_context104) {
4591
- while (1) switch (_context104.p = _context104.n) {
4635
+ var _ref120 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee106(params) {
4636
+ var _ref121, defaultWalletAccounts, _ref121$successPageDu, successPageDuration, stampWith, walletName, clearClipboardOnPaste, organizationId, userId, _t10;
4637
+ return _regenerator().w(function (_context106) {
4638
+ while (1) switch (_context106.p = _context106.n) {
4592
4639
  case 0:
4593
- _ref119 = params || {}, defaultWalletAccounts = _ref119.defaultWalletAccounts, _ref119$successPageDu = _ref119.successPageDuration, successPageDuration = _ref119$successPageDu === void 0 ? 2000 : _ref119$successPageDu, stampWith = _ref119.stampWith, walletName = _ref119.walletName, clearClipboardOnPaste = _ref119.clearClipboardOnPaste, organizationId = _ref119.organizationId, userId = _ref119.userId;
4594
- _context104.p = 1;
4595
- return _context104.a(2, withZeroXKeyErrorHandling(function () {
4640
+ _ref121 = params || {}, defaultWalletAccounts = _ref121.defaultWalletAccounts, _ref121$successPageDu = _ref121.successPageDuration, successPageDuration = _ref121$successPageDu === void 0 ? 2000 : _ref121$successPageDu, stampWith = _ref121.stampWith, walletName = _ref121.walletName, clearClipboardOnPaste = _ref121.clearClipboardOnPaste, organizationId = _ref121.organizationId, userId = _ref121.userId;
4641
+ _context106.p = 1;
4642
+ return _context106.a(2, withZeroXKeyErrorHandling(function () {
4596
4643
  return new Promise(function (resolve, reject) {
4597
4644
  return pushPage({
4598
4645
  key: "Import wallet",
@@ -4625,33 +4672,33 @@ var ClientProvider = function ClientProvider(_ref) {
4625
4672
  return logout();
4626
4673
  }));
4627
4674
  case 2:
4628
- _context104.p = 2;
4629
- _t10 = _context104.v;
4675
+ _context106.p = 2;
4676
+ _t10 = _context106.v;
4630
4677
  if (!(_t10 instanceof ZeroXKeyError)) {
4631
- _context104.n = 3;
4678
+ _context106.n = 3;
4632
4679
  break;
4633
4680
  }
4634
4681
  throw _t10;
4635
4682
  case 3:
4636
4683
  throw new ZeroXKeyError("Failed to import wallet.", ZeroXKeyErrorCodes.IMPORT_WALLET_ERROR, _t10);
4637
4684
  case 4:
4638
- return _context104.a(2);
4685
+ return _context106.a(2);
4639
4686
  }
4640
- }, _callee104, null, [[1, 2]]);
4687
+ }, _callee106, null, [[1, 2]]);
4641
4688
  }));
4642
- return function (_x87) {
4643
- return _ref118.apply(this, arguments);
4689
+ return function (_x89) {
4690
+ return _ref120.apply(this, arguments);
4644
4691
  };
4645
4692
  }(), [pushPage, logout]);
4646
4693
  var handleImportPrivateKey = useCallback(/*#__PURE__*/function () {
4647
- var _ref120 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee105(params) {
4648
- var _ref121, curve, addressFormats, _ref121$successPageDu, successPageDuration, stampWith, keyName, keyFormat, clearClipboardOnPaste, organizationId, _t11;
4649
- return _regenerator().w(function (_context105) {
4650
- while (1) switch (_context105.p = _context105.n) {
4694
+ var _ref122 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee107(params) {
4695
+ var _ref123, curve, addressFormats, _ref123$successPageDu, successPageDuration, stampWith, keyName, keyFormat, clearClipboardOnPaste, organizationId, _t11;
4696
+ return _regenerator().w(function (_context107) {
4697
+ while (1) switch (_context107.p = _context107.n) {
4651
4698
  case 0:
4652
- _ref121 = params || {}, curve = _ref121.curve, addressFormats = _ref121.addressFormats, _ref121$successPageDu = _ref121.successPageDuration, successPageDuration = _ref121$successPageDu === void 0 ? 2000 : _ref121$successPageDu, stampWith = _ref121.stampWith, keyName = _ref121.keyName, keyFormat = _ref121.keyFormat, clearClipboardOnPaste = _ref121.clearClipboardOnPaste, organizationId = _ref121.organizationId;
4653
- _context105.p = 1;
4654
- return _context105.a(2, withZeroXKeyErrorHandling(function () {
4699
+ _ref123 = params || {}, curve = _ref123.curve, addressFormats = _ref123.addressFormats, _ref123$successPageDu = _ref123.successPageDuration, successPageDuration = _ref123$successPageDu === void 0 ? 2000 : _ref123$successPageDu, stampWith = _ref123.stampWith, keyName = _ref123.keyName, keyFormat = _ref123.keyFormat, clearClipboardOnPaste = _ref123.clearClipboardOnPaste, organizationId = _ref123.organizationId;
4700
+ _context107.p = 1;
4701
+ return _context107.a(2, withZeroXKeyErrorHandling(function () {
4655
4702
  return new Promise(function (resolve, reject) {
4656
4703
  return pushPage({
4657
4704
  key: "Import private key",
@@ -4683,51 +4730,51 @@ var ClientProvider = function ClientProvider(_ref) {
4683
4730
  return logout();
4684
4731
  }));
4685
4732
  case 2:
4686
- _context105.p = 2;
4687
- _t11 = _context105.v;
4733
+ _context107.p = 2;
4734
+ _t11 = _context107.v;
4688
4735
  if (!(_t11 instanceof ZeroXKeyError)) {
4689
- _context105.n = 3;
4736
+ _context107.n = 3;
4690
4737
  break;
4691
4738
  }
4692
4739
  throw _t11;
4693
4740
  case 3:
4694
4741
  throw new ZeroXKeyError("Failed to import private key.", ZeroXKeyErrorCodes.IMPORT_WALLET_ERROR, _t11);
4695
4742
  case 4:
4696
- return _context105.a(2);
4743
+ return _context107.a(2);
4697
4744
  }
4698
- }, _callee105, null, [[1, 2]]);
4745
+ }, _callee107, null, [[1, 2]]);
4699
4746
  }));
4700
- return function (_x88) {
4701
- return _ref120.apply(this, arguments);
4747
+ return function (_x90) {
4748
+ return _ref122.apply(this, arguments);
4702
4749
  };
4703
4750
  }(), [pushPage, logout]);
4704
4751
  var handleUpdateUserName = useCallback(/*#__PURE__*/function () {
4705
- var _ref122 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee106(params) {
4706
- var _ref123, _ref123$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _params$userId, res, _t12;
4707
- return _regenerator().w(function (_context106) {
4708
- while (1) switch (_context106.p = _context106.n) {
4752
+ var _ref124 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee108(params) {
4753
+ var _ref125, _ref125$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _params$userId, res, _t12;
4754
+ return _regenerator().w(function (_context108) {
4755
+ while (1) switch (_context108.p = _context108.n) {
4709
4756
  case 0:
4710
- _ref123 = params || {}, _ref123$successPageDu = _ref123.successPageDuration, successPageDuration = _ref123$successPageDu === void 0 ? 2000 : _ref123$successPageDu, subTitle = _ref123.subTitle, title = _ref123.title, stampWith = _ref123.stampWith;
4757
+ _ref125 = params || {}, _ref125$successPageDu = _ref125.successPageDuration, successPageDuration = _ref125$successPageDu === void 0 ? 2000 : _ref125$successPageDu, subTitle = _ref125.subTitle, title = _ref125.title, stampWith = _ref125.stampWith;
4711
4758
  if (client) {
4712
- _context106.n = 1;
4759
+ _context108.n = 1;
4713
4760
  break;
4714
4761
  }
4715
4762
  throw new ZeroXKeyError("Client is not initialized.", ZeroXKeyErrorCodes.CLIENT_NOT_INITIALIZED);
4716
4763
  case 1:
4717
- _context106.n = 2;
4764
+ _context108.n = 2;
4718
4765
  return getSession();
4719
4766
  case 2:
4720
- s = _context106.v;
4767
+ s = _context108.v;
4721
4768
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4722
4769
  if (organizationId) {
4723
- _context106.n = 3;
4770
+ _context108.n = 3;
4724
4771
  break;
4725
4772
  }
4726
4773
  throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
4727
4774
  case 3:
4728
4775
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (user === null || user === void 0 ? void 0 : user.userId);
4729
4776
  if (userId) {
4730
- _context106.n = 4;
4777
+ _context108.n = 4;
4731
4778
  break;
4732
4779
  }
4733
4780
  throw new ZeroXKeyError("A user ID is required to update a user name.", ZeroXKeyErrorCodes.INVALID_REQUEST);
@@ -4747,12 +4794,12 @@ var ClientProvider = function ClientProvider(_ref) {
4747
4794
  showTitle: false
4748
4795
  });
4749
4796
  };
4750
- _context106.p = 5;
4797
+ _context108.p = 5;
4751
4798
  if (!(!(params !== null && params !== void 0 && params.userName) && (params === null || params === void 0 ? void 0 : params.userName) !== "")) {
4752
- _context106.n = 6;
4799
+ _context108.n = 6;
4753
4800
  break;
4754
4801
  }
4755
- return _context106.a(2, withZeroXKeyErrorHandling(function () {
4802
+ return _context108.a(2, withZeroXKeyErrorHandling(function () {
4756
4803
  return new Promise(function (resolve, reject) {
4757
4804
  pushPage({
4758
4805
  key: "Update User Name",
@@ -4780,7 +4827,7 @@ var ClientProvider = function ClientProvider(_ref) {
4780
4827
  return logout();
4781
4828
  }));
4782
4829
  case 6:
4783
- _context106.n = 7;
4830
+ _context108.n = 7;
4784
4831
  return updateUserName(_objectSpread2({
4785
4832
  userName: params.userName,
4786
4833
  userId: (_params$userId = params.userId) !== null && _params$userId !== void 0 ? _params$userId : user.userId,
@@ -4789,71 +4836,71 @@ var ClientProvider = function ClientProvider(_ref) {
4789
4836
  organizationId: organizationId
4790
4837
  }));
4791
4838
  case 7:
4792
- res = _context106.v;
4839
+ res = _context108.v;
4793
4840
  onSuccess();
4794
- return _context106.a(2, res);
4841
+ return _context108.a(2, res);
4795
4842
  case 8:
4796
- _context106.n = 11;
4843
+ _context108.n = 11;
4797
4844
  break;
4798
4845
  case 9:
4799
- _context106.p = 9;
4800
- _t12 = _context106.v;
4846
+ _context108.p = 9;
4847
+ _t12 = _context108.v;
4801
4848
  if (!(_t12 instanceof ZeroXKeyError)) {
4802
- _context106.n = 10;
4849
+ _context108.n = 10;
4803
4850
  break;
4804
4851
  }
4805
4852
  throw _t12;
4806
4853
  case 10:
4807
4854
  throw new ZeroXKeyError("Failed to update user name.", ZeroXKeyErrorCodes.UPDATE_USER_NAME_ERROR, _t12);
4808
4855
  case 11:
4809
- return _context106.a(2);
4856
+ return _context108.a(2);
4810
4857
  }
4811
- }, _callee106, null, [[5, 9]]);
4858
+ }, _callee108, null, [[5, 9]]);
4812
4859
  }));
4813
- return function (_x89) {
4814
- return _ref122.apply(this, arguments);
4860
+ return function (_x91) {
4861
+ return _ref124.apply(this, arguments);
4815
4862
  };
4816
4863
  }(), [client, getSession, user, pushPage, closeModal, updateUserName, logout]);
4817
4864
  var handleUpdateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
4818
- var _ref124 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee108(params) {
4865
+ var _ref126 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee110(params) {
4819
4866
  var _masterConfig$auth41, _masterConfig$auth41$;
4820
- var _ref125, _ref125$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp, otpId, otpEncryptionTargetBundle, _t14;
4821
- return _regenerator().w(function (_context108) {
4822
- while (1) switch (_context108.p = _context108.n) {
4867
+ var _ref127, _ref127$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp, otpId, otpEncryptionTargetBundle, _t14;
4868
+ return _regenerator().w(function (_context110) {
4869
+ while (1) switch (_context110.p = _context110.n) {
4823
4870
  case 0:
4824
- _ref125 = params || {}, _ref125$successPageDu = _ref125.successPageDuration, successPageDuration = _ref125$successPageDu === void 0 ? 2000 : _ref125$successPageDu, subTitle = _ref125.subTitle, title = _ref125.title, stampWith = _ref125.stampWith;
4871
+ _ref127 = params || {}, _ref127$successPageDu = _ref127.successPageDuration, successPageDuration = _ref127$successPageDu === void 0 ? 2000 : _ref127$successPageDu, subTitle = _ref127.subTitle, title = _ref127.title, stampWith = _ref127.stampWith;
4825
4872
  if (client) {
4826
- _context108.n = 1;
4873
+ _context110.n = 1;
4827
4874
  break;
4828
4875
  }
4829
4876
  throw new ZeroXKeyError("Client is not initialized.", ZeroXKeyErrorCodes.CLIENT_NOT_INITIALIZED);
4830
4877
  case 1:
4831
4878
  if (masterConfig) {
4832
- _context108.n = 2;
4879
+ _context110.n = 2;
4833
4880
  break;
4834
4881
  }
4835
4882
  throw new ZeroXKeyError("Config is not ready yet!", ZeroXKeyErrorCodes.CONFIG_NOT_INITIALIZED);
4836
4883
  case 2:
4837
4884
  if ((_masterConfig$auth41 = masterConfig.auth) !== null && _masterConfig$auth41 !== void 0 && (_masterConfig$auth41$ = _masterConfig$auth41.methods) !== null && _masterConfig$auth41$ !== void 0 && _masterConfig$auth41$.smsOtpAuthEnabled) {
4838
- _context108.n = 3;
4885
+ _context110.n = 3;
4839
4886
  break;
4840
4887
  }
4841
4888
  throw new ZeroXKeyError("SMS OTP authentication is not enabled in the configuration.", ZeroXKeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
4842
4889
  case 3:
4843
- _context108.n = 4;
4890
+ _context110.n = 4;
4844
4891
  return getSession();
4845
4892
  case 4:
4846
- s = _context108.v;
4893
+ s = _context110.v;
4847
4894
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
4848
4895
  if (organizationId) {
4849
- _context108.n = 5;
4896
+ _context110.n = 5;
4850
4897
  break;
4851
4898
  }
4852
4899
  throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
4853
4900
  case 5:
4854
4901
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
4855
4902
  if (userId) {
4856
- _context108.n = 6;
4903
+ _context110.n = 6;
4857
4904
  break;
4858
4905
  }
4859
4906
  throw new ZeroXKeyError("A user ID is required to update a phone number.", ZeroXKeyErrorCodes.INVALID_REQUEST);
@@ -4873,12 +4920,12 @@ var ClientProvider = function ClientProvider(_ref) {
4873
4920
  showTitle: false
4874
4921
  });
4875
4922
  };
4876
- _context108.p = 7;
4923
+ _context110.p = 7;
4877
4924
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
4878
- _context108.n = 8;
4925
+ _context110.n = 8;
4879
4926
  break;
4880
4927
  }
4881
- return _context108.a(2, withZeroXKeyErrorHandling(function () {
4928
+ return _context110.a(2, withZeroXKeyErrorHandling(function () {
4882
4929
  return new Promise(function (resolve, reject) {
4883
4930
  pushPage({
4884
4931
  key: "Update Phone Number",
@@ -4906,16 +4953,16 @@ var ClientProvider = function ClientProvider(_ref) {
4906
4953
  return logout();
4907
4954
  }));
4908
4955
  case 8:
4909
- _context108.n = 9;
4956
+ _context110.n = 9;
4910
4957
  return initOtp({
4911
4958
  otpType: OtpType.Sms,
4912
4959
  contact: params.phoneNumber
4913
4960
  });
4914
4961
  case 9:
4915
- _yield$initOtp = _context108.v;
4962
+ _yield$initOtp = _context110.v;
4916
4963
  otpId = _yield$initOtp.otpId;
4917
4964
  otpEncryptionTargetBundle = _yield$initOtp.otpEncryptionTargetBundle;
4918
- return _context108.a(2, withZeroXKeyErrorHandling(function () {
4965
+ return _context110.a(2, withZeroXKeyErrorHandling(function () {
4919
4966
  return new Promise(function (resolve, reject) {
4920
4967
  var _masterConfig$auth42, _masterConfig$auth43;
4921
4968
  pushPage({
@@ -4928,13 +4975,13 @@ var ClientProvider = function ClientProvider(_ref) {
4928
4975
  otpLength: ((_masterConfig$auth42 = masterConfig.auth) === null || _masterConfig$auth42 === void 0 ? void 0 : _masterConfig$auth42.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
4929
4976
  alphanumeric: (_masterConfig$auth43 = masterConfig.auth) === null || _masterConfig$auth43 === void 0 ? void 0 : _masterConfig$auth43.otpAlphanumeric,
4930
4977
  onContinue: function () {
4931
- var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee107(otpCode) {
4978
+ var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee109(otpCode) {
4932
4979
  var _yield$verifyOtp, verificationToken, res, _t13;
4933
- return _regenerator().w(function (_context107) {
4934
- while (1) switch (_context107.p = _context107.n) {
4980
+ return _regenerator().w(function (_context109) {
4981
+ while (1) switch (_context109.p = _context109.n) {
4935
4982
  case 0:
4936
- _context107.p = 0;
4937
- _context107.n = 1;
4983
+ _context109.p = 0;
4984
+ _context109.n = 1;
4938
4985
  return verifyOtp({
4939
4986
  otpId: otpId,
4940
4987
  otpCode: otpCode,
@@ -4943,9 +4990,9 @@ var ClientProvider = function ClientProvider(_ref) {
4943
4990
  otpType: OtpType.Sms
4944
4991
  });
4945
4992
  case 1:
4946
- _yield$verifyOtp = _context107.v;
4993
+ _yield$verifyOtp = _context109.v;
4947
4994
  verificationToken = _yield$verifyOtp.verificationToken;
4948
- _context107.n = 2;
4995
+ _context109.n = 2;
4949
4996
  return updateUserPhoneNumber(_objectSpread2({
4950
4997
  phoneNumber: params.phoneNumber,
4951
4998
  verificationToken: verificationToken,
@@ -4955,21 +5002,21 @@ var ClientProvider = function ClientProvider(_ref) {
4955
5002
  stampWith: stampWith
4956
5003
  }));
4957
5004
  case 2:
4958
- res = _context107.v;
5005
+ res = _context109.v;
4959
5006
  onSuccess();
4960
5007
  resolve(res);
4961
- _context107.n = 4;
5008
+ _context109.n = 4;
4962
5009
  break;
4963
5010
  case 3:
4964
- _context107.p = 3;
4965
- _t13 = _context107.v;
5011
+ _context109.p = 3;
5012
+ _t13 = _context109.v;
4966
5013
  reject(_t13);
4967
5014
  case 4:
4968
- return _context107.a(2);
5015
+ return _context109.a(2);
4969
5016
  }
4970
- }, _callee107, null, [[0, 3]]);
5017
+ }, _callee109, null, [[0, 3]]);
4971
5018
  }));
4972
- function onContinue(_x91) {
5019
+ function onContinue(_x93) {
4973
5020
  return _onContinue.apply(this, arguments);
4974
5021
  }
4975
5022
  return onContinue;
@@ -4988,54 +5035,54 @@ var ClientProvider = function ClientProvider(_ref) {
4988
5035
  return logout();
4989
5036
  }, callbacks, "Failed to update phone number"));
4990
5037
  case 10:
4991
- _context108.n = 13;
5038
+ _context110.n = 13;
4992
5039
  break;
4993
5040
  case 11:
4994
- _context108.p = 11;
4995
- _t14 = _context108.v;
5041
+ _context110.p = 11;
5042
+ _t14 = _context110.v;
4996
5043
  if (!(_t14 instanceof ZeroXKeyError)) {
4997
- _context108.n = 12;
5044
+ _context110.n = 12;
4998
5045
  break;
4999
5046
  }
5000
5047
  throw _t14;
5001
5048
  case 12:
5002
5049
  throw new ZeroXKeyError("Failed to initialize OTP for sms verification.", ZeroXKeyErrorCodes.INIT_OTP_ERROR, _t14);
5003
5050
  case 13:
5004
- return _context108.a(2);
5051
+ return _context110.a(2);
5005
5052
  }
5006
- }, _callee108, null, [[7, 11]]);
5053
+ }, _callee110, null, [[7, 11]]);
5007
5054
  }));
5008
- return function (_x90) {
5009
- return _ref124.apply(this, arguments);
5055
+ return function (_x92) {
5056
+ return _ref126.apply(this, arguments);
5010
5057
  };
5011
5058
  }(), [client, masterConfig, getSession, pushPage, closeModal, logout, initOtp, verifyOtp, updateUserPhoneNumber, user, callbacks]);
5012
5059
  var handleUpdateUserEmail = useCallback(/*#__PURE__*/function () {
5013
- var _ref126 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee110(params) {
5014
- var _ref127, _ref127$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp2, otpId, otpEncryptionTargetBundle, _t16;
5015
- return _regenerator().w(function (_context110) {
5016
- while (1) switch (_context110.p = _context110.n) {
5060
+ var _ref128 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee112(params) {
5061
+ var _ref129, _ref129$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp2, otpId, otpEncryptionTargetBundle, _t16;
5062
+ return _regenerator().w(function (_context112) {
5063
+ while (1) switch (_context112.p = _context112.n) {
5017
5064
  case 0:
5018
- _ref127 = params || {}, _ref127$successPageDu = _ref127.successPageDuration, successPageDuration = _ref127$successPageDu === void 0 ? 2000 : _ref127$successPageDu, subTitle = _ref127.subTitle, title = _ref127.title, stampWith = _ref127.stampWith;
5065
+ _ref129 = params || {}, _ref129$successPageDu = _ref129.successPageDuration, successPageDuration = _ref129$successPageDu === void 0 ? 2000 : _ref129$successPageDu, subTitle = _ref129.subTitle, title = _ref129.title, stampWith = _ref129.stampWith;
5019
5066
  if (client) {
5020
- _context110.n = 1;
5067
+ _context112.n = 1;
5021
5068
  break;
5022
5069
  }
5023
5070
  throw new ZeroXKeyError("Client is not initialized.", ZeroXKeyErrorCodes.CLIENT_NOT_INITIALIZED);
5024
5071
  case 1:
5025
- _context110.n = 2;
5072
+ _context112.n = 2;
5026
5073
  return getSession();
5027
5074
  case 2:
5028
- s = _context110.v;
5075
+ s = _context112.v;
5029
5076
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5030
5077
  if (organizationId) {
5031
- _context110.n = 3;
5078
+ _context112.n = 3;
5032
5079
  break;
5033
5080
  }
5034
5081
  throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
5035
5082
  case 3:
5036
5083
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5037
5084
  if (userId) {
5038
- _context110.n = 4;
5085
+ _context112.n = 4;
5039
5086
  break;
5040
5087
  }
5041
5088
  throw new ZeroXKeyError("A user ID is required to update an email.", ZeroXKeyErrorCodes.INVALID_REQUEST);
@@ -5055,12 +5102,12 @@ var ClientProvider = function ClientProvider(_ref) {
5055
5102
  showTitle: false
5056
5103
  });
5057
5104
  };
5058
- _context110.p = 5;
5105
+ _context112.p = 5;
5059
5106
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
5060
- _context110.n = 6;
5107
+ _context112.n = 6;
5061
5108
  break;
5062
5109
  }
5063
- return _context110.a(2, withZeroXKeyErrorHandling(function () {
5110
+ return _context112.a(2, withZeroXKeyErrorHandling(function () {
5064
5111
  return new Promise(function (resolve, reject) {
5065
5112
  pushPage({
5066
5113
  key: "Update Email",
@@ -5088,16 +5135,16 @@ var ClientProvider = function ClientProvider(_ref) {
5088
5135
  return logout();
5089
5136
  }));
5090
5137
  case 6:
5091
- _context110.n = 7;
5138
+ _context112.n = 7;
5092
5139
  return initOtp({
5093
5140
  otpType: OtpType.Email,
5094
5141
  contact: params.email
5095
5142
  });
5096
5143
  case 7:
5097
- _yield$initOtp2 = _context110.v;
5144
+ _yield$initOtp2 = _context112.v;
5098
5145
  otpId = _yield$initOtp2.otpId;
5099
5146
  otpEncryptionTargetBundle = _yield$initOtp2.otpEncryptionTargetBundle;
5100
- return _context110.a(2, withZeroXKeyErrorHandling(function () {
5147
+ return _context112.a(2, withZeroXKeyErrorHandling(function () {
5101
5148
  return new Promise(function (resolve, reject) {
5102
5149
  var _masterConfig$auth44, _masterConfig$auth45;
5103
5150
  pushPage({
@@ -5110,13 +5157,13 @@ var ClientProvider = function ClientProvider(_ref) {
5110
5157
  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,
5111
5158
  alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth45 = masterConfig.auth) === null || _masterConfig$auth45 === void 0 ? void 0 : _masterConfig$auth45.otpAlphanumeric,
5112
5159
  onContinue: function () {
5113
- var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee109(otpCode) {
5160
+ var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee111(otpCode) {
5114
5161
  var _yield$verifyOtp2, verificationToken, res, _t15;
5115
- return _regenerator().w(function (_context109) {
5116
- while (1) switch (_context109.p = _context109.n) {
5162
+ return _regenerator().w(function (_context111) {
5163
+ while (1) switch (_context111.p = _context111.n) {
5117
5164
  case 0:
5118
- _context109.p = 0;
5119
- _context109.n = 1;
5165
+ _context111.p = 0;
5166
+ _context111.n = 1;
5120
5167
  return verifyOtp({
5121
5168
  otpId: otpId,
5122
5169
  otpCode: otpCode,
@@ -5125,9 +5172,9 @@ var ClientProvider = function ClientProvider(_ref) {
5125
5172
  otpType: OtpType.Email
5126
5173
  });
5127
5174
  case 1:
5128
- _yield$verifyOtp2 = _context109.v;
5175
+ _yield$verifyOtp2 = _context111.v;
5129
5176
  verificationToken = _yield$verifyOtp2.verificationToken;
5130
- _context109.n = 2;
5177
+ _context111.n = 2;
5131
5178
  return updateUserEmail(_objectSpread2({
5132
5179
  email: params.email,
5133
5180
  verificationToken: verificationToken,
@@ -5137,21 +5184,21 @@ var ClientProvider = function ClientProvider(_ref) {
5137
5184
  stampWith: stampWith
5138
5185
  }));
5139
5186
  case 2:
5140
- res = _context109.v;
5187
+ res = _context111.v;
5141
5188
  onSuccess();
5142
5189
  resolve(res);
5143
- _context109.n = 4;
5190
+ _context111.n = 4;
5144
5191
  break;
5145
5192
  case 3:
5146
- _context109.p = 3;
5147
- _t15 = _context109.v;
5193
+ _context111.p = 3;
5194
+ _t15 = _context111.v;
5148
5195
  reject(_t15);
5149
5196
  case 4:
5150
- return _context109.a(2);
5197
+ return _context111.a(2);
5151
5198
  }
5152
- }, _callee109, null, [[0, 3]]);
5199
+ }, _callee111, null, [[0, 3]]);
5153
5200
  }));
5154
- function onContinue(_x93) {
5201
+ function onContinue(_x95) {
5155
5202
  return _onContinue2.apply(this, arguments);
5156
5203
  }
5157
5204
  return onContinue;
@@ -5168,54 +5215,54 @@ var ClientProvider = function ClientProvider(_ref) {
5168
5215
  return logout();
5169
5216
  }, callbacks, "Failed to update email"));
5170
5217
  case 8:
5171
- _context110.n = 11;
5218
+ _context112.n = 11;
5172
5219
  break;
5173
5220
  case 9:
5174
- _context110.p = 9;
5175
- _t16 = _context110.v;
5221
+ _context112.p = 9;
5222
+ _t16 = _context112.v;
5176
5223
  if (!(_t16 instanceof ZeroXKeyError)) {
5177
- _context110.n = 10;
5224
+ _context112.n = 10;
5178
5225
  break;
5179
5226
  }
5180
5227
  throw _t16;
5181
5228
  case 10:
5182
5229
  throw new ZeroXKeyError("Failed to initialize OTP for email verification.", ZeroXKeyErrorCodes.INIT_OTP_ERROR, _t16);
5183
5230
  case 11:
5184
- return _context110.a(2);
5231
+ return _context112.a(2);
5185
5232
  }
5186
- }, _callee110, null, [[5, 9]]);
5233
+ }, _callee112, null, [[5, 9]]);
5187
5234
  }));
5188
- return function (_x92) {
5189
- return _ref126.apply(this, arguments);
5235
+ return function (_x94) {
5236
+ return _ref128.apply(this, arguments);
5190
5237
  };
5191
5238
  }(), [client, getSession, pushPage, closeModal, logout, initOtp, masterConfig, verifyOtp, updateUserEmail, user, callbacks]);
5192
5239
  var handleAddEmail = useCallback(/*#__PURE__*/function () {
5193
- var _ref128 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee112(params) {
5194
- var _ref129, _ref129$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp3, otpId, otpEncryptionTargetBundle, _t18;
5195
- return _regenerator().w(function (_context112) {
5196
- while (1) switch (_context112.p = _context112.n) {
5240
+ var _ref130 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee114(params) {
5241
+ var _ref131, _ref131$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp3, otpId, otpEncryptionTargetBundle, _t18;
5242
+ return _regenerator().w(function (_context114) {
5243
+ while (1) switch (_context114.p = _context114.n) {
5197
5244
  case 0:
5198
- _ref129 = params || {}, _ref129$successPageDu = _ref129.successPageDuration, successPageDuration = _ref129$successPageDu === void 0 ? 2000 : _ref129$successPageDu, subTitle = _ref129.subTitle, title = _ref129.title, stampWith = _ref129.stampWith;
5245
+ _ref131 = params || {}, _ref131$successPageDu = _ref131.successPageDuration, successPageDuration = _ref131$successPageDu === void 0 ? 2000 : _ref131$successPageDu, subTitle = _ref131.subTitle, title = _ref131.title, stampWith = _ref131.stampWith;
5199
5246
  if (client) {
5200
- _context112.n = 1;
5247
+ _context114.n = 1;
5201
5248
  break;
5202
5249
  }
5203
5250
  throw new ZeroXKeyError("Client is not initialized.", ZeroXKeyErrorCodes.CLIENT_NOT_INITIALIZED);
5204
5251
  case 1:
5205
- _context112.n = 2;
5252
+ _context114.n = 2;
5206
5253
  return getSession();
5207
5254
  case 2:
5208
- s = _context112.v;
5255
+ s = _context114.v;
5209
5256
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5210
5257
  if (organizationId) {
5211
- _context112.n = 3;
5258
+ _context114.n = 3;
5212
5259
  break;
5213
5260
  }
5214
5261
  throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
5215
5262
  case 3:
5216
5263
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5217
5264
  if (userId) {
5218
- _context112.n = 4;
5265
+ _context114.n = 4;
5219
5266
  break;
5220
5267
  }
5221
5268
  throw new ZeroXKeyError("A user ID is required to add an email.", ZeroXKeyErrorCodes.INVALID_REQUEST);
@@ -5235,12 +5282,12 @@ var ClientProvider = function ClientProvider(_ref) {
5235
5282
  showTitle: false
5236
5283
  });
5237
5284
  };
5238
- _context112.p = 5;
5285
+ _context114.p = 5;
5239
5286
  if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
5240
- _context112.n = 6;
5287
+ _context114.n = 6;
5241
5288
  break;
5242
5289
  }
5243
- return _context112.a(2, withZeroXKeyErrorHandling(function () {
5290
+ return _context114.a(2, withZeroXKeyErrorHandling(function () {
5244
5291
  return new Promise(function (resolve, reject) {
5245
5292
  pushPage({
5246
5293
  key: "Add Email",
@@ -5268,16 +5315,16 @@ var ClientProvider = function ClientProvider(_ref) {
5268
5315
  return logout();
5269
5316
  }));
5270
5317
  case 6:
5271
- _context112.n = 7;
5318
+ _context114.n = 7;
5272
5319
  return initOtp({
5273
5320
  otpType: OtpType.Email,
5274
5321
  contact: params.email
5275
5322
  });
5276
5323
  case 7:
5277
- _yield$initOtp3 = _context112.v;
5324
+ _yield$initOtp3 = _context114.v;
5278
5325
  otpId = _yield$initOtp3.otpId;
5279
5326
  otpEncryptionTargetBundle = _yield$initOtp3.otpEncryptionTargetBundle;
5280
- return _context112.a(2, withZeroXKeyErrorHandling(function () {
5327
+ return _context114.a(2, withZeroXKeyErrorHandling(function () {
5281
5328
  return new Promise(function (resolve, reject) {
5282
5329
  var _masterConfig$auth46, _masterConfig$auth47;
5283
5330
  pushPage({
@@ -5290,13 +5337,13 @@ var ClientProvider = function ClientProvider(_ref) {
5290
5337
  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,
5291
5338
  alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth47 = masterConfig.auth) === null || _masterConfig$auth47 === void 0 ? void 0 : _masterConfig$auth47.otpAlphanumeric,
5292
5339
  onContinue: function () {
5293
- var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee111(otpCode) {
5340
+ var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee113(otpCode) {
5294
5341
  var _yield$verifyOtp3, verificationToken, res, _t17;
5295
- return _regenerator().w(function (_context111) {
5296
- while (1) switch (_context111.p = _context111.n) {
5342
+ return _regenerator().w(function (_context113) {
5343
+ while (1) switch (_context113.p = _context113.n) {
5297
5344
  case 0:
5298
- _context111.p = 0;
5299
- _context111.n = 1;
5345
+ _context113.p = 0;
5346
+ _context113.n = 1;
5300
5347
  return verifyOtp({
5301
5348
  otpId: otpId,
5302
5349
  otpCode: otpCode,
@@ -5305,9 +5352,9 @@ var ClientProvider = function ClientProvider(_ref) {
5305
5352
  otpType: OtpType.Email
5306
5353
  });
5307
5354
  case 1:
5308
- _yield$verifyOtp3 = _context111.v;
5355
+ _yield$verifyOtp3 = _context113.v;
5309
5356
  verificationToken = _yield$verifyOtp3.verificationToken;
5310
- _context111.n = 2;
5357
+ _context113.n = 2;
5311
5358
  return updateUserEmail({
5312
5359
  email: params.email,
5313
5360
  verificationToken: verificationToken,
@@ -5316,21 +5363,21 @@ var ClientProvider = function ClientProvider(_ref) {
5316
5363
  stampWith: stampWith
5317
5364
  });
5318
5365
  case 2:
5319
- res = _context111.v;
5366
+ res = _context113.v;
5320
5367
  onSuccess();
5321
5368
  resolve(res);
5322
- _context111.n = 4;
5369
+ _context113.n = 4;
5323
5370
  break;
5324
5371
  case 3:
5325
- _context111.p = 3;
5326
- _t17 = _context111.v;
5372
+ _context113.p = 3;
5373
+ _t17 = _context113.v;
5327
5374
  reject(_t17);
5328
5375
  case 4:
5329
- return _context111.a(2);
5376
+ return _context113.a(2);
5330
5377
  }
5331
- }, _callee111, null, [[0, 3]]);
5378
+ }, _callee113, null, [[0, 3]]);
5332
5379
  }));
5333
- function onContinue(_x95) {
5380
+ function onContinue(_x97) {
5334
5381
  return _onContinue3.apply(this, arguments);
5335
5382
  }
5336
5383
  return onContinue;
@@ -5347,67 +5394,67 @@ var ClientProvider = function ClientProvider(_ref) {
5347
5394
  return logout();
5348
5395
  }, callbacks, "Failed to add email"));
5349
5396
  case 8:
5350
- _context112.n = 11;
5397
+ _context114.n = 11;
5351
5398
  break;
5352
5399
  case 9:
5353
- _context112.p = 9;
5354
- _t18 = _context112.v;
5400
+ _context114.p = 9;
5401
+ _t18 = _context114.v;
5355
5402
  if (!(_t18 instanceof ZeroXKeyError)) {
5356
- _context112.n = 10;
5403
+ _context114.n = 10;
5357
5404
  break;
5358
5405
  }
5359
5406
  throw _t18;
5360
5407
  case 10:
5361
5408
  throw new ZeroXKeyError("Failed to initialize OTP for email verification.", ZeroXKeyErrorCodes.INIT_OTP_ERROR, _t18);
5362
5409
  case 11:
5363
- return _context112.a(2);
5410
+ return _context114.a(2);
5364
5411
  }
5365
- }, _callee112, null, [[5, 9]]);
5412
+ }, _callee114, null, [[5, 9]]);
5366
5413
  }));
5367
- return function (_x94) {
5368
- return _ref128.apply(this, arguments);
5414
+ return function (_x96) {
5415
+ return _ref130.apply(this, arguments);
5369
5416
  };
5370
5417
  }(), [client, getSession, pushPage, closeModal, user, logout, initOtp, masterConfig, verifyOtp, updateUserEmail, callbacks]);
5371
5418
  var handleAddPhoneNumber = useCallback(/*#__PURE__*/function () {
5372
- var _ref130 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee114(params) {
5419
+ var _ref132 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee116(params) {
5373
5420
  var _masterConfig$auth48, _masterConfig$auth48$;
5374
- var _ref131, _ref131$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp4, otpId, otpEncryptionTargetBundle, _t20;
5375
- return _regenerator().w(function (_context114) {
5376
- while (1) switch (_context114.p = _context114.n) {
5421
+ var _ref133, _ref133$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _yield$initOtp4, otpId, otpEncryptionTargetBundle, _t20;
5422
+ return _regenerator().w(function (_context116) {
5423
+ while (1) switch (_context116.p = _context116.n) {
5377
5424
  case 0:
5378
- _ref131 = params || {}, _ref131$successPageDu = _ref131.successPageDuration, successPageDuration = _ref131$successPageDu === void 0 ? 2000 : _ref131$successPageDu, subTitle = _ref131.subTitle, title = _ref131.title, stampWith = _ref131.stampWith;
5425
+ _ref133 = params || {}, _ref133$successPageDu = _ref133.successPageDuration, successPageDuration = _ref133$successPageDu === void 0 ? 2000 : _ref133$successPageDu, subTitle = _ref133.subTitle, title = _ref133.title, stampWith = _ref133.stampWith;
5379
5426
  if (client) {
5380
- _context114.n = 1;
5427
+ _context116.n = 1;
5381
5428
  break;
5382
5429
  }
5383
5430
  throw new ZeroXKeyError("Client is not initialized.", ZeroXKeyErrorCodes.CLIENT_NOT_INITIALIZED);
5384
5431
  case 1:
5385
5432
  if (masterConfig) {
5386
- _context114.n = 2;
5433
+ _context116.n = 2;
5387
5434
  break;
5388
5435
  }
5389
5436
  throw new ZeroXKeyError("Config is not ready yet!", ZeroXKeyErrorCodes.CONFIG_NOT_INITIALIZED);
5390
5437
  case 2:
5391
5438
  if ((_masterConfig$auth48 = masterConfig.auth) !== null && _masterConfig$auth48 !== void 0 && (_masterConfig$auth48$ = _masterConfig$auth48.methods) !== null && _masterConfig$auth48$ !== void 0 && _masterConfig$auth48$.smsOtpAuthEnabled) {
5392
- _context114.n = 3;
5439
+ _context116.n = 3;
5393
5440
  break;
5394
5441
  }
5395
5442
  throw new ZeroXKeyError("SMS OTP authentication is not enabled in the configuration.", ZeroXKeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
5396
5443
  case 3:
5397
- _context114.n = 4;
5444
+ _context116.n = 4;
5398
5445
  return getSession();
5399
5446
  case 4:
5400
- s = _context114.v;
5447
+ s = _context116.v;
5401
5448
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5402
5449
  if (organizationId) {
5403
- _context114.n = 5;
5450
+ _context116.n = 5;
5404
5451
  break;
5405
5452
  }
5406
5453
  throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
5407
5454
  case 5:
5408
5455
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5409
5456
  if (userId) {
5410
- _context114.n = 6;
5457
+ _context116.n = 6;
5411
5458
  break;
5412
5459
  }
5413
5460
  throw new ZeroXKeyError("A user ID is required to add a phone number.", ZeroXKeyErrorCodes.INVALID_REQUEST);
@@ -5427,12 +5474,12 @@ var ClientProvider = function ClientProvider(_ref) {
5427
5474
  showTitle: false
5428
5475
  });
5429
5476
  };
5430
- _context114.p = 7;
5477
+ _context116.p = 7;
5431
5478
  if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
5432
- _context114.n = 8;
5479
+ _context116.n = 8;
5433
5480
  break;
5434
5481
  }
5435
- return _context114.a(2, withZeroXKeyErrorHandling(function () {
5482
+ return _context116.a(2, withZeroXKeyErrorHandling(function () {
5436
5483
  return new Promise(function (resolve, reject) {
5437
5484
  pushPage({
5438
5485
  key: "Add Phone Number",
@@ -5460,16 +5507,16 @@ var ClientProvider = function ClientProvider(_ref) {
5460
5507
  return logout();
5461
5508
  }, callbacks, "Failed to add phone number"));
5462
5509
  case 8:
5463
- _context114.n = 9;
5510
+ _context116.n = 9;
5464
5511
  return initOtp({
5465
5512
  otpType: OtpType.Sms,
5466
5513
  contact: params.phoneNumber
5467
5514
  });
5468
5515
  case 9:
5469
- _yield$initOtp4 = _context114.v;
5516
+ _yield$initOtp4 = _context116.v;
5470
5517
  otpId = _yield$initOtp4.otpId;
5471
5518
  otpEncryptionTargetBundle = _yield$initOtp4.otpEncryptionTargetBundle;
5472
- return _context114.a(2, withZeroXKeyErrorHandling(function () {
5519
+ return _context116.a(2, withZeroXKeyErrorHandling(function () {
5473
5520
  return new Promise(function (resolve, reject) {
5474
5521
  var _masterConfig$auth49, _masterConfig$auth50;
5475
5522
  pushPage({
@@ -5482,13 +5529,13 @@ var ClientProvider = function ClientProvider(_ref) {
5482
5529
  otpLength: ((_masterConfig$auth49 = masterConfig.auth) === null || _masterConfig$auth49 === void 0 ? void 0 : _masterConfig$auth49.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
5483
5530
  alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth50 = masterConfig.auth) === null || _masterConfig$auth50 === void 0 ? void 0 : _masterConfig$auth50.otpAlphanumeric,
5484
5531
  onContinue: function () {
5485
- var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee113(otpCode) {
5532
+ var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee115(otpCode) {
5486
5533
  var _yield$verifyOtp4, verificationToken, res, _t19;
5487
- return _regenerator().w(function (_context113) {
5488
- while (1) switch (_context113.p = _context113.n) {
5534
+ return _regenerator().w(function (_context115) {
5535
+ while (1) switch (_context115.p = _context115.n) {
5489
5536
  case 0:
5490
- _context113.p = 0;
5491
- _context113.n = 1;
5537
+ _context115.p = 0;
5538
+ _context115.n = 1;
5492
5539
  return verifyOtp({
5493
5540
  otpId: otpId,
5494
5541
  otpCode: otpCode,
@@ -5497,9 +5544,9 @@ var ClientProvider = function ClientProvider(_ref) {
5497
5544
  otpType: OtpType.Sms
5498
5545
  });
5499
5546
  case 1:
5500
- _yield$verifyOtp4 = _context113.v;
5547
+ _yield$verifyOtp4 = _context115.v;
5501
5548
  verificationToken = _yield$verifyOtp4.verificationToken;
5502
- _context113.n = 2;
5549
+ _context115.n = 2;
5503
5550
  return updateUserPhoneNumber({
5504
5551
  phoneNumber: params.phoneNumber,
5505
5552
  verificationToken: verificationToken,
@@ -5508,21 +5555,21 @@ var ClientProvider = function ClientProvider(_ref) {
5508
5555
  stampWith: stampWith
5509
5556
  });
5510
5557
  case 2:
5511
- res = _context113.v;
5558
+ res = _context115.v;
5512
5559
  onSuccess();
5513
5560
  resolve(res);
5514
- _context113.n = 4;
5561
+ _context115.n = 4;
5515
5562
  break;
5516
5563
  case 3:
5517
- _context113.p = 3;
5518
- _t19 = _context113.v;
5564
+ _context115.p = 3;
5565
+ _t19 = _context115.v;
5519
5566
  reject(_t19);
5520
5567
  case 4:
5521
- return _context113.a(2);
5568
+ return _context115.a(2);
5522
5569
  }
5523
- }, _callee113, null, [[0, 3]]);
5570
+ }, _callee115, null, [[0, 3]]);
5524
5571
  }));
5525
- function onContinue(_x97) {
5572
+ function onContinue(_x99) {
5526
5573
  return _onContinue4.apply(this, arguments);
5527
5574
  }
5528
5575
  return onContinue;
@@ -5541,52 +5588,52 @@ var ClientProvider = function ClientProvider(_ref) {
5541
5588
  return logout();
5542
5589
  }, callbacks, "Failed to add phone number"));
5543
5590
  case 10:
5544
- _context114.n = 13;
5591
+ _context116.n = 13;
5545
5592
  break;
5546
5593
  case 11:
5547
- _context114.p = 11;
5548
- _t20 = _context114.v;
5594
+ _context116.p = 11;
5595
+ _t20 = _context116.v;
5549
5596
  if (!(_t20 instanceof ZeroXKeyError)) {
5550
- _context114.n = 12;
5597
+ _context116.n = 12;
5551
5598
  break;
5552
5599
  }
5553
5600
  throw _t20;
5554
5601
  case 12:
5555
5602
  throw new ZeroXKeyError("Failed to initialize OTP for sms verification.", ZeroXKeyErrorCodes.INIT_OTP_ERROR, _t20);
5556
5603
  case 13:
5557
- return _context114.a(2);
5604
+ return _context116.a(2);
5558
5605
  }
5559
- }, _callee114, null, [[7, 11]]);
5606
+ }, _callee116, null, [[7, 11]]);
5560
5607
  }));
5561
- return function (_x96) {
5562
- return _ref130.apply(this, arguments);
5608
+ return function (_x98) {
5609
+ return _ref132.apply(this, arguments);
5563
5610
  };
5564
5611
  }(), [client, masterConfig, getSession, pushPage, closeModal, user, logout, callbacks, initOtp, verifyOtp, updateUserPhoneNumber]);
5565
5612
  var handleRemovePasskey = useCallback(/*#__PURE__*/function () {
5566
- var _ref132 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee115(params) {
5613
+ var _ref134 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee117(params) {
5567
5614
  var authenticatorId, _params$successPageDu2, successPageDuration, subTitle, title, stampWith, userId, s, organizationId;
5568
- return _regenerator().w(function (_context115) {
5569
- while (1) switch (_context115.n) {
5615
+ return _regenerator().w(function (_context117) {
5616
+ while (1) switch (_context117.n) {
5570
5617
  case 0:
5571
5618
  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;
5572
5619
  if (client) {
5573
- _context115.n = 1;
5620
+ _context117.n = 1;
5574
5621
  break;
5575
5622
  }
5576
5623
  throw new ZeroXKeyError("Client is not initialized.", ZeroXKeyErrorCodes.CLIENT_NOT_INITIALIZED);
5577
5624
  case 1:
5578
- _context115.n = 2;
5625
+ _context117.n = 2;
5579
5626
  return getSession();
5580
5627
  case 2:
5581
- s = _context115.v;
5628
+ s = _context117.v;
5582
5629
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5583
5630
  if (organizationId) {
5584
- _context115.n = 3;
5631
+ _context117.n = 3;
5585
5632
  break;
5586
5633
  }
5587
5634
  throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
5588
5635
  case 3:
5589
- return _context115.a(2, withZeroXKeyErrorHandling(function () {
5636
+ return _context117.a(2, withZeroXKeyErrorHandling(function () {
5590
5637
  return new Promise(function (resolve, reject) {
5591
5638
  pushPage({
5592
5639
  key: "Remove Passkey",
@@ -5617,44 +5664,44 @@ var ClientProvider = function ClientProvider(_ref) {
5617
5664
  return logout();
5618
5665
  }, callbacks, "Failed to remove passkey"));
5619
5666
  }
5620
- }, _callee115);
5667
+ }, _callee117);
5621
5668
  }));
5622
- return function (_x98) {
5623
- return _ref132.apply(this, arguments);
5669
+ return function (_x100) {
5670
+ return _ref134.apply(this, arguments);
5624
5671
  };
5625
5672
  }(), [client, getSession, pushPage, logout, callbacks]);
5626
5673
  var handleAddPasskey = useCallback(/*#__PURE__*/function () {
5627
- var _ref133 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee116(params) {
5628
- var _ref134, name, displayName, _ref134$successPageDu, successPageDuration, stampWith, s, organizationId, userId, resPromise, _t21;
5629
- return _regenerator().w(function (_context116) {
5630
- while (1) switch (_context116.p = _context116.n) {
5674
+ var _ref135 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee118(params) {
5675
+ var _ref136, name, displayName, _ref136$successPageDu, successPageDuration, stampWith, s, organizationId, userId, resPromise, _t21;
5676
+ return _regenerator().w(function (_context118) {
5677
+ while (1) switch (_context118.p = _context118.n) {
5631
5678
  case 0:
5632
- _ref134 = params || {}, name = _ref134.name, displayName = _ref134.displayName, _ref134$successPageDu = _ref134.successPageDuration, successPageDuration = _ref134$successPageDu === void 0 ? 2000 : _ref134$successPageDu, stampWith = _ref134.stampWith;
5679
+ _ref136 = params || {}, name = _ref136.name, displayName = _ref136.displayName, _ref136$successPageDu = _ref136.successPageDuration, successPageDuration = _ref136$successPageDu === void 0 ? 2000 : _ref136$successPageDu, stampWith = _ref136.stampWith;
5633
5680
  if (client) {
5634
- _context116.n = 1;
5681
+ _context118.n = 1;
5635
5682
  break;
5636
5683
  }
5637
5684
  throw new ZeroXKeyError("Client is not initialized.", ZeroXKeyErrorCodes.CLIENT_NOT_INITIALIZED);
5638
5685
  case 1:
5639
- _context116.n = 2;
5686
+ _context118.n = 2;
5640
5687
  return getSession();
5641
5688
  case 2:
5642
- s = _context116.v;
5689
+ s = _context118.v;
5643
5690
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5644
5691
  if (organizationId) {
5645
- _context116.n = 3;
5692
+ _context118.n = 3;
5646
5693
  break;
5647
5694
  }
5648
5695
  throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
5649
5696
  case 3:
5650
5697
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5651
5698
  if (userId) {
5652
- _context116.n = 4;
5699
+ _context118.n = 4;
5653
5700
  break;
5654
5701
  }
5655
5702
  throw new ZeroXKeyError("A user ID or a valid session is required to add a passkey.", ZeroXKeyErrorCodes.INVALID_REQUEST);
5656
5703
  case 4:
5657
- _context116.p = 4;
5704
+ _context118.p = 4;
5658
5705
  resPromise = addPasskey(_objectSpread2(_objectSpread2(_objectSpread2({}, name && {
5659
5706
  name: name
5660
5707
  }), displayName && {
@@ -5679,55 +5726,55 @@ var ClientProvider = function ClientProvider(_ref) {
5679
5726
  showTitle: false
5680
5727
  });
5681
5728
  });
5682
- _context116.n = 5;
5729
+ _context118.n = 5;
5683
5730
  return resPromise;
5684
5731
  case 5:
5685
- return _context116.a(2, _context116.v);
5732
+ return _context118.a(2, _context118.v);
5686
5733
  case 6:
5687
- _context116.p = 6;
5688
- _t21 = _context116.v;
5734
+ _context118.p = 6;
5735
+ _t21 = _context118.v;
5689
5736
  if (!(_t21 instanceof ZeroXKeyError)) {
5690
- _context116.n = 7;
5737
+ _context118.n = 7;
5691
5738
  break;
5692
5739
  }
5693
5740
  throw _t21;
5694
5741
  case 7:
5695
5742
  throw new ZeroXKeyError("Failed to add passkey in handler.", ZeroXKeyErrorCodes.ADD_PASSKEY_ERROR, _t21);
5696
5743
  case 8:
5697
- return _context116.a(2);
5744
+ return _context118.a(2);
5698
5745
  }
5699
- }, _callee116, null, [[4, 6]]);
5746
+ }, _callee118, null, [[4, 6]]);
5700
5747
  }));
5701
- return function (_x99) {
5702
- return _ref133.apply(this, arguments);
5748
+ return function (_x101) {
5749
+ return _ref135.apply(this, arguments);
5703
5750
  };
5704
5751
  }(), [client, getSession, addPasskey, pushPage, closeModal]);
5705
5752
  var handleRemoveOauthProvider = useCallback(/*#__PURE__*/function () {
5706
- var _ref135 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee117(params) {
5753
+ var _ref137 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee119(params) {
5707
5754
  var providerId, _params$successPageDu3, successPageDuration, subTitle, title, stampWith, s, organizationId, _t22;
5708
- return _regenerator().w(function (_context117) {
5709
- while (1) switch (_context117.p = _context117.n) {
5755
+ return _regenerator().w(function (_context119) {
5756
+ while (1) switch (_context119.p = _context119.n) {
5710
5757
  case 0:
5711
5758
  providerId = params.providerId, _params$successPageDu3 = params.successPageDuration, successPageDuration = _params$successPageDu3 === void 0 ? 2000 : _params$successPageDu3, subTitle = params.subTitle, title = params.title, stampWith = params.stampWith;
5712
5759
  if (client) {
5713
- _context117.n = 1;
5760
+ _context119.n = 1;
5714
5761
  break;
5715
5762
  }
5716
5763
  throw new ZeroXKeyError("Client is not initialized.", ZeroXKeyErrorCodes.CLIENT_NOT_INITIALIZED);
5717
5764
  case 1:
5718
- _context117.n = 2;
5765
+ _context119.n = 2;
5719
5766
  return getSession();
5720
5767
  case 2:
5721
- s = _context117.v;
5768
+ s = _context119.v;
5722
5769
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5723
5770
  if (organizationId) {
5724
- _context117.n = 3;
5771
+ _context119.n = 3;
5725
5772
  break;
5726
5773
  }
5727
5774
  throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
5728
5775
  case 3:
5729
- _context117.p = 3;
5730
- return _context117.a(2, new Promise(function (resolve, reject) {
5776
+ _context119.p = 3;
5777
+ return _context119.a(2, new Promise(function (resolve, reject) {
5731
5778
  pushPage({
5732
5779
  key: "Remove OAuth Provider",
5733
5780
  content: jsx(RemoveOAuthProvider, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -5755,69 +5802,69 @@ var ClientProvider = function ClientProvider(_ref) {
5755
5802
  });
5756
5803
  }));
5757
5804
  case 4:
5758
- _context117.p = 4;
5759
- _t22 = _context117.v;
5805
+ _context119.p = 4;
5806
+ _t22 = _context119.v;
5760
5807
  if (!(_t22 instanceof ZeroXKeyError)) {
5761
- _context117.n = 5;
5808
+ _context119.n = 5;
5762
5809
  break;
5763
5810
  }
5764
5811
  throw _t22;
5765
5812
  case 5:
5766
5813
  throw new ZeroXKeyError("Failed to remove OAuth provider in handler.", ZeroXKeyErrorCodes.REMOVE_OAUTH_PROVIDER_ERROR, _t22);
5767
5814
  case 6:
5768
- return _context117.a(2);
5815
+ return _context119.a(2);
5769
5816
  }
5770
- }, _callee117, null, [[3, 4]]);
5817
+ }, _callee119, null, [[3, 4]]);
5771
5818
  }));
5772
- return function (_x100) {
5773
- return _ref135.apply(this, arguments);
5819
+ return function (_x102) {
5820
+ return _ref137.apply(this, arguments);
5774
5821
  };
5775
5822
  }(), [client, getSession, pushPage]);
5776
5823
  var handleAddOauthProvider = useCallback(/*#__PURE__*/function () {
5777
- var _ref136 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee120(params) {
5824
+ var _ref138 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee122(params) {
5778
5825
  var _masterConfig$auth$oa7, _masterConfig$auth51, _masterConfig$auth51$;
5779
5826
  var providerName, stampWith, _params$successPageDu4, successPageDuration, _params$openInPage, openInPage, s, organizationId, userId;
5780
- return _regenerator().w(function (_context120) {
5781
- while (1) switch (_context120.n) {
5827
+ return _regenerator().w(function (_context122) {
5828
+ while (1) switch (_context122.n) {
5782
5829
  case 0:
5783
5830
  if (client) {
5784
- _context120.n = 1;
5831
+ _context122.n = 1;
5785
5832
  break;
5786
5833
  }
5787
5834
  throw new ZeroXKeyError("Client is not initialized.", ZeroXKeyErrorCodes.CLIENT_NOT_INITIALIZED);
5788
5835
  case 1:
5789
5836
  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;
5790
- _context120.n = 2;
5837
+ _context122.n = 2;
5791
5838
  return getSession();
5792
5839
  case 2:
5793
- s = _context120.v;
5840
+ s = _context122.v;
5794
5841
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
5795
5842
  if (organizationId) {
5796
- _context120.n = 3;
5843
+ _context122.n = 3;
5797
5844
  break;
5798
5845
  }
5799
5846
  throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
5800
5847
  case 3:
5801
5848
  userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
5802
5849
  if (userId) {
5803
- _context120.n = 4;
5850
+ _context122.n = 4;
5804
5851
  break;
5805
5852
  }
5806
5853
  throw new ZeroXKeyError("A user ID is required to add an OAuth provider.", ZeroXKeyErrorCodes.INVALID_REQUEST);
5807
5854
  case 4:
5808
- return _context120.a(2, new Promise(/*#__PURE__*/function () {
5809
- var _ref137 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee119(resolve, reject) {
5855
+ return _context122.a(2, new Promise(/*#__PURE__*/function () {
5856
+ var _ref139 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee121(resolve, reject) {
5810
5857
  var onOauthSuccess, additionalState, _t23, _t24;
5811
- return _regenerator().w(function (_context119) {
5812
- while (1) switch (_context119.p = _context119.n) {
5858
+ return _regenerator().w(function (_context121) {
5859
+ while (1) switch (_context121.p = _context121.n) {
5813
5860
  case 0:
5814
- _context119.p = 0;
5861
+ _context121.p = 0;
5815
5862
  onOauthSuccess = /*#__PURE__*/function () {
5816
- var _ref138 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee118(params) {
5817
- return _regenerator().w(function (_context118) {
5818
- while (1) switch (_context118.n) {
5863
+ var _ref140 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee120(params) {
5864
+ return _regenerator().w(function (_context120) {
5865
+ while (1) switch (_context120.n) {
5819
5866
  case 0:
5820
- _context118.n = 1;
5867
+ _context120.n = 1;
5821
5868
  return addOauthProvider({
5822
5869
  providerName: params.providerName,
5823
5870
  oidcToken: params.oidcToken,
@@ -5840,12 +5887,12 @@ var ClientProvider = function ClientProvider(_ref) {
5840
5887
  showTitle: false
5841
5888
  });
5842
5889
  case 2:
5843
- return _context118.a(2);
5890
+ return _context120.a(2);
5844
5891
  }
5845
- }, _callee118);
5892
+ }, _callee120);
5846
5893
  }));
5847
- return function onOauthSuccess(_x104) {
5848
- return _ref138.apply(this, arguments);
5894
+ return function onOauthSuccess(_x106) {
5895
+ return _ref140.apply(this, arguments);
5849
5896
  };
5850
5897
  }();
5851
5898
  if (openInPage) {
@@ -5864,10 +5911,10 @@ var ClientProvider = function ClientProvider(_ref) {
5864
5911
  openModal: "true"
5865
5912
  }) : undefined;
5866
5913
  _t23 = providerName;
5867
- _context119.n = _t23 === OAuthProviders.DISCORD ? 1 : _t23 === OAuthProviders.X ? 3 : _t23 === OAuthProviders.GOOGLE ? 5 : _t23 === OAuthProviders.APPLE ? 7 : _t23 === OAuthProviders.FACEBOOK ? 9 : 11;
5914
+ _context121.n = _t23 === OAuthProviders.DISCORD ? 1 : _t23 === OAuthProviders.X ? 3 : _t23 === OAuthProviders.GOOGLE ? 5 : _t23 === OAuthProviders.APPLE ? 7 : _t23 === OAuthProviders.FACEBOOK ? 9 : 11;
5868
5915
  break;
5869
5916
  case 1:
5870
- _context119.n = 2;
5917
+ _context121.n = 2;
5871
5918
  return handleDiscordOauth(_objectSpread2(_objectSpread2({
5872
5919
  openInPage: openInPage
5873
5920
  }, additionalState && {
@@ -5876,9 +5923,9 @@ var ClientProvider = function ClientProvider(_ref) {
5876
5923
  onOauthSuccess: onOauthSuccess
5877
5924
  }));
5878
5925
  case 2:
5879
- return _context119.a(2, _context119.v);
5926
+ return _context121.a(2, _context121.v);
5880
5927
  case 3:
5881
- _context119.n = 4;
5928
+ _context121.n = 4;
5882
5929
  return handleXOauth(_objectSpread2(_objectSpread2({
5883
5930
  openInPage: openInPage
5884
5931
  }, additionalState && {
@@ -5887,9 +5934,9 @@ var ClientProvider = function ClientProvider(_ref) {
5887
5934
  onOauthSuccess: onOauthSuccess
5888
5935
  }));
5889
5936
  case 4:
5890
- return _context119.a(2, _context119.v);
5937
+ return _context121.a(2, _context121.v);
5891
5938
  case 5:
5892
- _context119.n = 6;
5939
+ _context121.n = 6;
5893
5940
  return handleGoogleOauth(_objectSpread2(_objectSpread2({
5894
5941
  openInPage: openInPage
5895
5942
  }, additionalState && {
@@ -5898,9 +5945,9 @@ var ClientProvider = function ClientProvider(_ref) {
5898
5945
  onOauthSuccess: onOauthSuccess
5899
5946
  }));
5900
5947
  case 6:
5901
- return _context119.a(2, _context119.v);
5948
+ return _context121.a(2, _context121.v);
5902
5949
  case 7:
5903
- _context119.n = 8;
5950
+ _context121.n = 8;
5904
5951
  return handleAppleOauth(_objectSpread2(_objectSpread2({
5905
5952
  openInPage: openInPage
5906
5953
  }, additionalState && {
@@ -5909,9 +5956,9 @@ var ClientProvider = function ClientProvider(_ref) {
5909
5956
  onOauthSuccess: onOauthSuccess
5910
5957
  }));
5911
5958
  case 8:
5912
- return _context119.a(2, _context119.v);
5959
+ return _context121.a(2, _context121.v);
5913
5960
  case 9:
5914
- _context119.n = 10;
5961
+ _context121.n = 10;
5915
5962
  return handleFacebookOauth(_objectSpread2(_objectSpread2({
5916
5963
  openInPage: openInPage
5917
5964
  }, additionalState && {
@@ -5920,53 +5967,53 @@ var ClientProvider = function ClientProvider(_ref) {
5920
5967
  onOauthSuccess: onOauthSuccess
5921
5968
  }));
5922
5969
  case 10:
5923
- return _context119.a(2, _context119.v);
5970
+ return _context121.a(2, _context121.v);
5924
5971
  case 11:
5925
5972
  throw new ZeroXKeyError("Unsupported OAuth provider: ".concat(providerName), ZeroXKeyErrorCodes.NOT_FOUND);
5926
5973
  case 12:
5927
- _context119.n = 14;
5974
+ _context121.n = 14;
5928
5975
  break;
5929
5976
  case 13:
5930
- _context119.p = 13;
5931
- _t24 = _context119.v;
5977
+ _context121.p = 13;
5978
+ _t24 = _context121.v;
5932
5979
  reject(_t24);
5933
5980
  case 14:
5934
- return _context119.a(2);
5981
+ return _context121.a(2);
5935
5982
  }
5936
- }, _callee119, null, [[0, 13]]);
5983
+ }, _callee121, null, [[0, 13]]);
5937
5984
  }));
5938
- return function (_x102, _x103) {
5939
- return _ref137.apply(this, arguments);
5985
+ return function (_x104, _x105) {
5986
+ return _ref139.apply(this, arguments);
5940
5987
  };
5941
5988
  }()));
5942
5989
  }
5943
- }, _callee120);
5990
+ }, _callee122);
5944
5991
  }));
5945
- return function (_x101) {
5946
- return _ref136.apply(this, arguments);
5992
+ return function (_x103) {
5993
+ return _ref138.apply(this, arguments);
5947
5994
  };
5948
5995
  }(), [client, getSession, addOauthProvider, pushPage, closeModal, handleDiscordOauth, handleXOauth, handleGoogleOauth, handleAppleOauth, handleFacebookOauth]);
5949
5996
  var handleConnectExternalWallet = useCallback(/*#__PURE__*/function () {
5950
- var _ref139 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee121(params) {
5997
+ var _ref141 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee123(params) {
5951
5998
  var _masterConfig$walletC4, _masterConfig$walletC5;
5952
- var _ref140, _ref140$successPageDu, successPageDuration;
5953
- return _regenerator().w(function (_context121) {
5954
- while (1) switch (_context121.n) {
5999
+ var _ref142, _ref142$successPageDu, successPageDuration;
6000
+ return _regenerator().w(function (_context123) {
6001
+ while (1) switch (_context123.n) {
5955
6002
  case 0:
5956
- _ref140 = params || {}, _ref140$successPageDu = _ref140.successPageDuration, successPageDuration = _ref140$successPageDu === void 0 ? 2000 : _ref140$successPageDu;
6003
+ _ref142 = params || {}, _ref142$successPageDu = _ref142.successPageDuration, successPageDuration = _ref142$successPageDu === void 0 ? 2000 : _ref142$successPageDu;
5957
6004
  if (client) {
5958
- _context121.n = 1;
6005
+ _context123.n = 1;
5959
6006
  break;
5960
6007
  }
5961
6008
  throw new ZeroXKeyError("Client is not initialized.", ZeroXKeyErrorCodes.CLIENT_NOT_INITIALIZED);
5962
6009
  case 1:
5963
6010
  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) {
5964
- _context121.n = 2;
6011
+ _context123.n = 2;
5965
6012
  break;
5966
6013
  }
5967
6014
  throw new ZeroXKeyError("Wallet connecting is not enabled.", ZeroXKeyErrorCodes.FEATURE_NOT_ENABLED);
5968
6015
  case 2:
5969
- return _context121.a(2, new Promise(function (resolve, reject) {
6016
+ return _context123.a(2, new Promise(function (resolve, reject) {
5970
6017
  pushPage({
5971
6018
  key: "Connect wallet",
5972
6019
  content: jsx(ConnectWalletModal, {
@@ -5984,32 +6031,32 @@ var ClientProvider = function ClientProvider(_ref) {
5984
6031
  });
5985
6032
  }));
5986
6033
  }
5987
- }, _callee121);
6034
+ }, _callee123);
5988
6035
  }));
5989
- return function (_x105) {
5990
- return _ref139.apply(this, arguments);
6036
+ return function (_x107) {
6037
+ return _ref141.apply(this, arguments);
5991
6038
  };
5992
6039
  }(), [client, masterConfig, fetchWalletProviders, pushPage]);
5993
6040
  var handleRemoveUserEmail = useCallback(/*#__PURE__*/function () {
5994
- var _ref141 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee122(params) {
5995
- var _ref142, _ref142$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t25;
5996
- return _regenerator().w(function (_context122) {
5997
- while (1) switch (_context122.p = _context122.n) {
6041
+ var _ref143 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee124(params) {
6042
+ var _ref144, _ref144$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t25;
6043
+ return _regenerator().w(function (_context124) {
6044
+ while (1) switch (_context124.p = _context124.n) {
5998
6045
  case 0:
5999
- _ref142 = params || {}, _ref142$successPageDu = _ref142.successPageDuration, successPageDuration = _ref142$successPageDu === void 0 ? 2000 : _ref142$successPageDu, stampWith = _ref142.stampWith, userId = _ref142.userId;
6000
- _context122.n = 1;
6046
+ _ref144 = params || {}, _ref144$successPageDu = _ref144.successPageDuration, successPageDuration = _ref144$successPageDu === void 0 ? 2000 : _ref144$successPageDu, stampWith = _ref144.stampWith, userId = _ref144.userId;
6047
+ _context124.n = 1;
6001
6048
  return getSession();
6002
6049
  case 1:
6003
- s = _context122.v;
6050
+ s = _context124.v;
6004
6051
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
6005
6052
  if (organizationId) {
6006
- _context122.n = 2;
6053
+ _context124.n = 2;
6007
6054
  break;
6008
6055
  }
6009
6056
  throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
6010
6057
  case 2:
6011
- _context122.p = 2;
6012
- return _context122.a(2, new Promise(function (resolve, reject) {
6058
+ _context124.p = 2;
6059
+ return _context124.a(2, new Promise(function (resolve, reject) {
6013
6060
  pushPage({
6014
6061
  key: "Remove Email",
6015
6062
  content: jsx(RemoveEmail, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -6036,44 +6083,44 @@ var ClientProvider = function ClientProvider(_ref) {
6036
6083
  });
6037
6084
  }));
6038
6085
  case 3:
6039
- _context122.p = 3;
6040
- _t25 = _context122.v;
6086
+ _context124.p = 3;
6087
+ _t25 = _context124.v;
6041
6088
  if (!(_t25 instanceof ZeroXKeyError)) {
6042
- _context122.n = 4;
6089
+ _context124.n = 4;
6043
6090
  break;
6044
6091
  }
6045
6092
  throw _t25;
6046
6093
  case 4:
6047
6094
  throw new ZeroXKeyError("Failed to remove user email.", ZeroXKeyErrorCodes.UPDATE_USER_EMAIL_ERROR, _t25);
6048
6095
  case 5:
6049
- return _context122.a(2);
6096
+ return _context124.a(2);
6050
6097
  }
6051
- }, _callee122, null, [[2, 3]]);
6098
+ }, _callee124, null, [[2, 3]]);
6052
6099
  }));
6053
- return function (_x106) {
6054
- return _ref141.apply(this, arguments);
6100
+ return function (_x108) {
6101
+ return _ref143.apply(this, arguments);
6055
6102
  };
6056
6103
  }(), [getSession, pushPage]);
6057
6104
  var handleRemoveUserPhoneNumber = useCallback(/*#__PURE__*/function () {
6058
- var _ref143 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee123(params) {
6059
- var _ref144, _ref144$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t26;
6060
- return _regenerator().w(function (_context123) {
6061
- while (1) switch (_context123.p = _context123.n) {
6105
+ var _ref145 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee125(params) {
6106
+ var _ref146, _ref146$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t26;
6107
+ return _regenerator().w(function (_context125) {
6108
+ while (1) switch (_context125.p = _context125.n) {
6062
6109
  case 0:
6063
- _ref144 = params || {}, _ref144$successPageDu = _ref144.successPageDuration, successPageDuration = _ref144$successPageDu === void 0 ? 2000 : _ref144$successPageDu, stampWith = _ref144.stampWith, userId = _ref144.userId;
6064
- _context123.n = 1;
6110
+ _ref146 = params || {}, _ref146$successPageDu = _ref146.successPageDuration, successPageDuration = _ref146$successPageDu === void 0 ? 2000 : _ref146$successPageDu, stampWith = _ref146.stampWith, userId = _ref146.userId;
6111
+ _context125.n = 1;
6065
6112
  return getSession();
6066
6113
  case 1:
6067
- s = _context123.v;
6114
+ s = _context125.v;
6068
6115
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
6069
6116
  if (organizationId) {
6070
- _context123.n = 2;
6117
+ _context125.n = 2;
6071
6118
  break;
6072
6119
  }
6073
6120
  throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
6074
6121
  case 2:
6075
- _context123.p = 2;
6076
- return _context123.a(2, new Promise(function (resolve, reject) {
6122
+ _context125.p = 2;
6123
+ return _context125.a(2, new Promise(function (resolve, reject) {
6077
6124
  pushPage({
6078
6125
  key: "Remove Phone Number",
6079
6126
  content: jsx(RemovePhoneNumber, _objectSpread2(_objectSpread2(_objectSpread2({
@@ -6100,37 +6147,37 @@ var ClientProvider = function ClientProvider(_ref) {
6100
6147
  });
6101
6148
  }));
6102
6149
  case 3:
6103
- _context123.p = 3;
6104
- _t26 = _context123.v;
6150
+ _context125.p = 3;
6151
+ _t26 = _context125.v;
6105
6152
  if (!(_t26 instanceof ZeroXKeyError)) {
6106
- _context123.n = 4;
6153
+ _context125.n = 4;
6107
6154
  break;
6108
6155
  }
6109
6156
  throw _t26;
6110
6157
  case 4:
6111
6158
  throw new ZeroXKeyError("Failed to remove user phone number.", ZeroXKeyErrorCodes.UPDATE_USER_PHONE_NUMBER_ERROR, _t26);
6112
6159
  case 5:
6113
- return _context123.a(2);
6160
+ return _context125.a(2);
6114
6161
  }
6115
- }, _callee123, null, [[2, 3]]);
6162
+ }, _callee125, null, [[2, 3]]);
6116
6163
  }));
6117
- return function (_x107) {
6118
- return _ref143.apply(this, arguments);
6164
+ return function (_x109) {
6165
+ return _ref145.apply(this, arguments);
6119
6166
  };
6120
6167
  }(), [getSession, pushPage]);
6121
6168
  var handleSendTransaction = useCallback(/*#__PURE__*/function () {
6122
- var _ref145 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee126(params) {
6169
+ var _ref147 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee128(params) {
6123
6170
  var session, organizationId, transaction, icon, stampWith, _params$successPageDu5, successPageDuration, caip2, isSolanaTransaction;
6124
- return _regenerator().w(function (_context126) {
6125
- while (1) switch (_context126.n) {
6171
+ return _regenerator().w(function (_context128) {
6172
+ while (1) switch (_context128.n) {
6126
6173
  case 0:
6127
- _context126.n = 1;
6174
+ _context128.n = 1;
6128
6175
  return getSession();
6129
6176
  case 1:
6130
- session = _context126.v;
6177
+ session = _context128.v;
6131
6178
  organizationId = params.organizationId || (session === null || session === void 0 ? void 0 : session.organizationId);
6132
6179
  if (organizationId) {
6133
- _context126.n = 2;
6180
+ _context128.n = 2;
6134
6181
  break;
6135
6182
  }
6136
6183
  throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
@@ -6138,34 +6185,34 @@ var ClientProvider = function ClientProvider(_ref) {
6138
6185
  transaction = params.transaction, icon = params.icon, stampWith = params.stampWith, _params$successPageDu5 = params.successPageDuration, successPageDuration = _params$successPageDu5 === void 0 ? 2000 : _params$successPageDu5;
6139
6186
  caip2 = transaction.caip2;
6140
6187
  isSolanaTransaction = caip2.startsWith("solana:");
6141
- return _context126.a(2, new Promise(function (resolve, reject) {
6188
+ return _context128.a(2, new Promise(function (resolve, reject) {
6142
6189
  var action = /*#__PURE__*/function () {
6143
- var _ref146 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee125() {
6144
- var _ref148, _txDetails$eth$txHash, _txDetails$eth, _txDetails$solana;
6190
+ var _ref148 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee127() {
6191
+ var _ref150, _txDetails$eth$txHash, _txDetails$eth, _txDetails$solana;
6145
6192
  var sendTransactionStatusId, pollResult, txDetails, txHash, _t27;
6146
- return _regenerator().w(function (_context125) {
6147
- while (1) switch (_context125.n) {
6193
+ return _regenerator().w(function (_context127) {
6194
+ while (1) switch (_context127.n) {
6148
6195
  case 0:
6149
6196
  if (!isSolanaTransaction) {
6150
- _context125.n = 2;
6197
+ _context127.n = 2;
6151
6198
  break;
6152
6199
  }
6153
- _context125.n = 1;
6200
+ _context127.n = 1;
6154
6201
  return solSendTransaction({
6155
6202
  organizationId: organizationId,
6156
6203
  transaction: transaction,
6157
6204
  stampWith: stampWith
6158
6205
  });
6159
6206
  case 1:
6160
- _t27 = _context125.v;
6161
- _context125.n = 4;
6207
+ _t27 = _context127.v;
6208
+ _context127.n = 4;
6162
6209
  break;
6163
6210
  case 2:
6164
- _context125.n = 3;
6165
- return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee124() {
6211
+ _context127.n = 3;
6212
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee126() {
6166
6213
  var from, to, value, data, nonce, gasLimit, maxFeePerGas, maxPriorityFeePerGas, sponsor, cleanedData, tx;
6167
- return _regenerator().w(function (_context124) {
6168
- while (1) switch (_context124.n) {
6214
+ return _regenerator().w(function (_context126) {
6215
+ while (1) switch (_context126.n) {
6169
6216
  case 0:
6170
6217
  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;
6171
6218
  cleanedData = data && data !== "0x" && data !== "" ? data : undefined;
@@ -6187,41 +6234,41 @@ var ClientProvider = function ClientProvider(_ref) {
6187
6234
  } : {}), maxPriorityFeePerGas ? {
6188
6235
  maxPriorityFeePerGas: maxPriorityFeePerGas
6189
6236
  } : {});
6190
- return _context124.a(2, ethSendTransaction({
6237
+ return _context126.a(2, ethSendTransaction({
6191
6238
  organizationId: organizationId,
6192
6239
  transaction: tx,
6193
6240
  stampWith: stampWith
6194
6241
  }));
6195
6242
  }
6196
- }, _callee124);
6243
+ }, _callee126);
6197
6244
  }))();
6198
6245
  case 3:
6199
- _t27 = _context125.v;
6246
+ _t27 = _context127.v;
6200
6247
  case 4:
6201
6248
  sendTransactionStatusId = _t27;
6202
6249
  if (sendTransactionStatusId) {
6203
- _context125.n = 5;
6250
+ _context127.n = 5;
6204
6251
  break;
6205
6252
  }
6206
6253
  throw new ZeroXKeyError("Missing sendTransactionStatusId", ZeroXKeyErrorCodes.BAD_RESPONSE);
6207
6254
  case 5:
6208
- _context125.n = 6;
6255
+ _context127.n = 6;
6209
6256
  return pollTransactionStatus({
6210
6257
  organizationId: organizationId,
6211
6258
  sendTransactionStatusId: sendTransactionStatusId
6212
6259
  });
6213
6260
  case 6:
6214
- pollResult = _context125.v;
6261
+ pollResult = _context127.v;
6215
6262
  txDetails = pollResult;
6216
- txHash = (_ref148 = (_txDetails$eth$txHash = (_txDetails$eth = txDetails.eth) === null || _txDetails$eth === void 0 ? void 0 : _txDetails$eth.txHash) !== null && _txDetails$eth$txHash !== void 0 ? _txDetails$eth$txHash : (_txDetails$solana = txDetails.solana) === null || _txDetails$solana === void 0 ? void 0 : _txDetails$solana.signature) !== null && _ref148 !== void 0 ? _ref148 : txDetails.txHash;
6217
- return _context125.a(2, txHash ? {
6263
+ txHash = (_ref150 = (_txDetails$eth$txHash = (_txDetails$eth = txDetails.eth) === null || _txDetails$eth === void 0 ? void 0 : _txDetails$eth.txHash) !== null && _txDetails$eth$txHash !== void 0 ? _txDetails$eth$txHash : (_txDetails$solana = txDetails.solana) === null || _txDetails$solana === void 0 ? void 0 : _txDetails$solana.signature) !== null && _ref150 !== void 0 ? _ref150 : txDetails.txHash;
6264
+ return _context127.a(2, txHash ? {
6218
6265
  txHash: txHash
6219
6266
  } : {});
6220
6267
  }
6221
- }, _callee125);
6268
+ }, _callee127);
6222
6269
  }));
6223
6270
  return function action() {
6224
- return _ref146.apply(this, arguments);
6271
+ return _ref148.apply(this, arguments);
6225
6272
  };
6226
6273
  }();
6227
6274
  pushPage({
@@ -6246,69 +6293,69 @@ var ClientProvider = function ClientProvider(_ref) {
6246
6293
  });
6247
6294
  }));
6248
6295
  }
6249
- }, _callee126);
6296
+ }, _callee128);
6250
6297
  }));
6251
- return function (_x108) {
6252
- return _ref145.apply(this, arguments);
6298
+ return function (_x110) {
6299
+ return _ref147.apply(this, arguments);
6253
6300
  };
6254
6301
  }(), [ethSendTransaction, getSession, pollTransactionStatus, pushPage, solSendTransaction]);
6255
6302
  var handleSendErc20Transfer = useCallback(/*#__PURE__*/function () {
6256
- var _ref149 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee128(params) {
6303
+ var _ref151 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee130(params) {
6257
6304
  var session, organizationId, transfer, icon, stampWith, _params$successPageDu6, successPageDuration, caip2;
6258
- return _regenerator().w(function (_context128) {
6259
- while (1) switch (_context128.n) {
6305
+ return _regenerator().w(function (_context130) {
6306
+ while (1) switch (_context130.n) {
6260
6307
  case 0:
6261
- _context128.n = 1;
6308
+ _context130.n = 1;
6262
6309
  return getSession();
6263
6310
  case 1:
6264
- session = _context128.v;
6311
+ session = _context130.v;
6265
6312
  organizationId = params.organizationId || (session === null || session === void 0 ? void 0 : session.organizationId);
6266
6313
  if (organizationId) {
6267
- _context128.n = 2;
6314
+ _context130.n = 2;
6268
6315
  break;
6269
6316
  }
6270
6317
  throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
6271
6318
  case 2:
6272
6319
  transfer = params.transfer, icon = params.icon, stampWith = params.stampWith, _params$successPageDu6 = params.successPageDuration, successPageDuration = _params$successPageDu6 === void 0 ? 2000 : _params$successPageDu6;
6273
6320
  caip2 = transfer.caip2;
6274
- return _context128.a(2, new Promise(function (resolve, reject) {
6321
+ return _context130.a(2, new Promise(function (resolve, reject) {
6275
6322
  var action = /*#__PURE__*/function () {
6276
- var _ref150 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee127() {
6323
+ var _ref152 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee129() {
6277
6324
  var _pollResult$eth$txHas, _pollResult$eth;
6278
6325
  var sendTransactionStatusId, pollResult, txHash;
6279
- return _regenerator().w(function (_context127) {
6280
- while (1) switch (_context127.n) {
6326
+ return _regenerator().w(function (_context129) {
6327
+ while (1) switch (_context129.n) {
6281
6328
  case 0:
6282
- _context127.n = 1;
6329
+ _context129.n = 1;
6283
6330
  return ethSendErc20Transfer({
6284
6331
  organizationId: organizationId,
6285
6332
  transfer: transfer,
6286
6333
  stampWith: stampWith
6287
6334
  });
6288
6335
  case 1:
6289
- sendTransactionStatusId = _context127.v;
6336
+ sendTransactionStatusId = _context129.v;
6290
6337
  if (sendTransactionStatusId) {
6291
- _context127.n = 2;
6338
+ _context129.n = 2;
6292
6339
  break;
6293
6340
  }
6294
6341
  throw new ZeroXKeyError("Missing sendTransactionStatusId", ZeroXKeyErrorCodes.BAD_RESPONSE);
6295
6342
  case 2:
6296
- _context127.n = 3;
6343
+ _context129.n = 3;
6297
6344
  return pollTransactionStatus({
6298
6345
  organizationId: organizationId,
6299
6346
  sendTransactionStatusId: sendTransactionStatusId
6300
6347
  });
6301
6348
  case 3:
6302
- pollResult = _context127.v;
6349
+ pollResult = _context129.v;
6303
6350
  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;
6304
- return _context127.a(2, txHash ? {
6351
+ return _context129.a(2, txHash ? {
6305
6352
  txHash: txHash
6306
6353
  } : {});
6307
6354
  }
6308
- }, _callee127);
6355
+ }, _callee129);
6309
6356
  }));
6310
6357
  return function action() {
6311
- return _ref150.apply(this, arguments);
6358
+ return _ref152.apply(this, arguments);
6312
6359
  };
6313
6360
  }();
6314
6361
  pushPage({
@@ -6333,22 +6380,22 @@ var ClientProvider = function ClientProvider(_ref) {
6333
6380
  });
6334
6381
  }));
6335
6382
  }
6336
- }, _callee128);
6383
+ }, _callee130);
6337
6384
  }));
6338
- return function (_x109) {
6339
- return _ref149.apply(this, arguments);
6385
+ return function (_x111) {
6386
+ return _ref151.apply(this, arguments);
6340
6387
  };
6341
6388
  }(), [ethSendErc20Transfer, getSession, pollTransactionStatus, pushPage]);
6342
6389
  var handleOnRamp = useCallback(/*#__PURE__*/function () {
6343
- var _ref151 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee130(params) {
6390
+ var _ref153 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee132(params) {
6344
6391
  var _params$cryptoCurrenc, _params$network;
6345
6392
  var walletAccount, fiatCurrencyAmount, fiatCurrencyCode, paymentMethod, countrySubdivisionCode, urlForSignature, countryCode, _params$onrampProvide, onrampProvider, _params$successPageDu7, successPageDuration, _params$openInNewTab, openInNewTab, openMode, polling, onStatusChange, s, organizationId, inferredAsset, cryptoCurrencyCode, network, resolvedOpenMode;
6346
- return _regenerator().w(function (_context130) {
6347
- while (1) switch (_context130.n) {
6393
+ return _regenerator().w(function (_context132) {
6394
+ while (1) switch (_context132.n) {
6348
6395
  case 0:
6349
6396
  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$successPageDu7 = params.successPageDuration, successPageDuration = _params$successPageDu7 === void 0 ? 2000 : _params$successPageDu7, _params$openInNewTab = params.openInNewTab, openInNewTab = _params$openInNewTab === void 0 ? false : _params$openInNewTab, openMode = params.openMode, polling = params.polling, onStatusChange = params.onStatusChange;
6350
6397
  if (!(params.sandboxMode === undefined)) {
6351
- _context130.n = 1;
6398
+ _context132.n = 1;
6352
6399
  break;
6353
6400
  }
6354
6401
  throw new OnRampError(OnRampErrorCode.SANDBOX_MODE_REQUIRED, "sandboxMode must be explicitly set for on-ramp flows.");
@@ -6357,18 +6404,18 @@ var ClientProvider = function ClientProvider(_ref) {
6357
6404
  // supported runtime, so callers get a typed error instead of a popup.
6358
6405
  assertOnRampProviderSupported(onrampProvider);
6359
6406
  if (client !== null && client !== void 0 && client.httpClient) {
6360
- _context130.n = 2;
6407
+ _context132.n = 2;
6361
6408
  break;
6362
6409
  }
6363
6410
  throw new ZeroXKeyError("Client is not initialized.", ZeroXKeyErrorCodes.CLIENT_NOT_INITIALIZED);
6364
6411
  case 2:
6365
- _context130.n = 3;
6412
+ _context132.n = 3;
6366
6413
  return getSession();
6367
6414
  case 3:
6368
- s = _context130.v;
6415
+ s = _context132.v;
6369
6416
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
6370
6417
  if (organizationId) {
6371
- _context130.n = 4;
6418
+ _context132.n = 4;
6372
6419
  break;
6373
6420
  }
6374
6421
  throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
@@ -6377,13 +6424,13 @@ var ClientProvider = function ClientProvider(_ref) {
6377
6424
  cryptoCurrencyCode = (_params$cryptoCurrenc = params.cryptoCurrencyCode) !== null && _params$cryptoCurrenc !== void 0 ? _params$cryptoCurrenc : inferredAsset === null || inferredAsset === void 0 ? void 0 : inferredAsset.cryptoCurrencyCode;
6378
6425
  network = (_params$network = params.network) !== null && _params$network !== void 0 ? _params$network : inferredAsset === null || inferredAsset === void 0 ? void 0 : inferredAsset.network;
6379
6426
  if (!(!cryptoCurrencyCode || !network)) {
6380
- _context130.n = 5;
6427
+ _context132.n = 5;
6381
6428
  break;
6382
6429
  }
6383
6430
  throw new OnRampError(OnRampErrorCode.ASSET_REQUIRED, "network and cryptoCurrencyCode are required for on-ramp flows.");
6384
6431
  case 5:
6385
6432
  resolvedOpenMode = openMode !== null && openMode !== void 0 ? openMode : openInNewTab || isMobile ? "newTab" : "popup";
6386
- return _context130.a(2, new Promise(function (resolve, reject) {
6433
+ return _context132.a(2, new Promise(function (resolve, reject) {
6387
6434
  var OnRampContainer = function OnRampContainer() {
6388
6435
  var _useState15 = useState(false),
6389
6436
  _useState16 = _slicedToArray(_useState15, 2),
@@ -6404,25 +6451,25 @@ var ClientProvider = function ClientProvider(_ref) {
6404
6451
  };
6405
6452
  }, []);
6406
6453
  var action = /*#__PURE__*/function () {
6407
- var _ref152 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee129() {
6454
+ var _ref154 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee131() {
6408
6455
  var _initResult$signedUrl, _polling$refresh, onRampWindow, initResult, providerUrl, popupWidth, popupHeight, left, top, status, _onRampWindow, _t28;
6409
- return _regenerator().w(function (_context129) {
6410
- while (1) switch (_context129.p = _context129.n) {
6456
+ return _regenerator().w(function (_context131) {
6457
+ while (1) switch (_context131.p = _context131.n) {
6411
6458
  case 0:
6412
- _context129.p = 0;
6459
+ _context131.p = 0;
6413
6460
  onRampWindow = null;
6414
6461
  if (!(resolvedOpenMode === "newTab")) {
6415
- _context129.n = 1;
6462
+ _context131.n = 1;
6416
6463
  break;
6417
6464
  }
6418
6465
  onRampWindow = window.open("", "_blank");
6419
6466
  if (onRampWindow) {
6420
- _context129.n = 1;
6467
+ _context131.n = 1;
6421
6468
  break;
6422
6469
  }
6423
6470
  throw new OnRampError(OnRampErrorCode.POPUP_BLOCKED, "Failed to open On Ramp tab.");
6424
6471
  case 1:
6425
- _context129.n = 2;
6472
+ _context131.n = 2;
6426
6473
  return initOnRampFlow(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
6427
6474
  runtimeClient: client.httpClient,
6428
6475
  onrampProvider: onrampProvider,
@@ -6447,23 +6494,23 @@ var ClientProvider = function ClientProvider(_ref) {
6447
6494
  urlForSignature: urlForSignature
6448
6495
  } : {}));
6449
6496
  case 2:
6450
- initResult = _context129.v;
6497
+ initResult = _context131.v;
6451
6498
  onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange(initResult);
6452
6499
  if (!(resolvedOpenMode === "returnUrl")) {
6453
- _context129.n = 3;
6500
+ _context131.n = 3;
6454
6501
  break;
6455
6502
  }
6456
6503
  setResult(initResult);
6457
6504
  setCompleted(true);
6458
- return _context129.a(2);
6505
+ return _context131.a(2);
6459
6506
  case 3:
6460
6507
  providerUrl = (_initResult$signedUrl = initResult.signedUrl) !== null && _initResult$signedUrl !== void 0 ? _initResult$signedUrl : initResult.onRampUrl;
6461
6508
  if (!(resolvedOpenMode === "newTab" && onRampWindow)) {
6462
- _context129.n = 4;
6509
+ _context131.n = 4;
6463
6510
  break;
6464
6511
  }
6465
6512
  onRampWindow.location.href = providerUrl;
6466
- _context129.n = 5;
6513
+ _context131.n = 5;
6467
6514
  break;
6468
6515
  case 4:
6469
6516
  popupWidth = 500;
@@ -6472,13 +6519,13 @@ var ClientProvider = function ClientProvider(_ref) {
6472
6519
  top = window.screenY + (window.innerHeight - popupHeight) / 2;
6473
6520
  onRampWindow = window.open(providerUrl, "_blank", "width=".concat(popupWidth, ",height=").concat(popupHeight, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
6474
6521
  if (onRampWindow) {
6475
- _context129.n = 5;
6522
+ _context131.n = 5;
6476
6523
  break;
6477
6524
  }
6478
6525
  throw new OnRampError(OnRampErrorCode.POPUP_BLOCKED, "Failed to open On Ramp window.");
6479
6526
  case 5:
6480
6527
  abortRef.current = new AbortController();
6481
- _context129.n = 6;
6528
+ _context131.n = 6;
6482
6529
  return pollOnRampTransactionStatus(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
6483
6530
  runtimeClient: client.httpClient,
6484
6531
  organizationId: organizationId,
@@ -6500,7 +6547,7 @@ var ClientProvider = function ClientProvider(_ref) {
6500
6547
  maxConsecutiveErrors: polling.maxConsecutiveErrors
6501
6548
  } : {}));
6502
6549
  case 6:
6503
- status = _context129.v;
6550
+ status = _context131.v;
6504
6551
  try {
6505
6552
  (_onRampWindow = onRampWindow) === null || _onRampWindow === void 0 ? void 0 : _onRampWindow.close();
6506
6553
  } catch (_unused6) {}
@@ -6510,20 +6557,20 @@ var ClientProvider = function ClientProvider(_ref) {
6510
6557
  status: status
6511
6558
  }));
6512
6559
  setCompleted(true);
6513
- _context129.n = 8;
6560
+ _context131.n = 8;
6514
6561
  break;
6515
6562
  case 7:
6516
- _context129.p = 7;
6517
- _t28 = _context129.v;
6563
+ _context131.p = 7;
6564
+ _t28 = _context131.v;
6518
6565
  cleanup();
6519
6566
  throw _t28;
6520
6567
  case 8:
6521
- return _context129.a(2);
6568
+ return _context131.a(2);
6522
6569
  }
6523
- }, _callee129, null, [[0, 7]]);
6570
+ }, _callee131, null, [[0, 7]]);
6524
6571
  }));
6525
6572
  return function action() {
6526
- return _ref152.apply(this, arguments);
6573
+ return _ref154.apply(this, arguments);
6527
6574
  };
6528
6575
  }();
6529
6576
  return jsx(OnRampPage, {
@@ -6557,32 +6604,32 @@ var ClientProvider = function ClientProvider(_ref) {
6557
6604
  });
6558
6605
  }));
6559
6606
  }
6560
- }, _callee130);
6607
+ }, _callee132);
6561
6608
  }));
6562
- return function (_x110) {
6563
- return _ref151.apply(this, arguments);
6609
+ return function (_x112) {
6610
+ return _ref153.apply(this, arguments);
6564
6611
  };
6565
6612
  }(), [getSession, client, pushPage]);
6566
6613
  var handleVerifyAppProofs = useCallback(/*#__PURE__*/function () {
6567
- var _ref153 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee131(params) {
6568
- var _ref154, appProofs, _ref154$successPageDu, successPageDuration, stampWith, s, organizationId, _t29;
6569
- return _regenerator().w(function (_context131) {
6570
- while (1) switch (_context131.p = _context131.n) {
6614
+ var _ref155 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee133(params) {
6615
+ var _ref156, appProofs, _ref156$successPageDu, successPageDuration, stampWith, s, organizationId, _t29;
6616
+ return _regenerator().w(function (_context133) {
6617
+ while (1) switch (_context133.p = _context133.n) {
6571
6618
  case 0:
6572
- _ref154 = params || {}, appProofs = _ref154.appProofs, _ref154$successPageDu = _ref154.successPageDuration, successPageDuration = _ref154$successPageDu === void 0 ? 3000 : _ref154$successPageDu, stampWith = _ref154.stampWith;
6573
- _context131.n = 1;
6619
+ _ref156 = params || {}, appProofs = _ref156.appProofs, _ref156$successPageDu = _ref156.successPageDuration, successPageDuration = _ref156$successPageDu === void 0 ? 3000 : _ref156$successPageDu, stampWith = _ref156.stampWith;
6620
+ _context133.n = 1;
6574
6621
  return getSession();
6575
6622
  case 1:
6576
- s = _context131.v;
6623
+ s = _context133.v;
6577
6624
  organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
6578
6625
  if (organizationId) {
6579
- _context131.n = 2;
6626
+ _context133.n = 2;
6580
6627
  break;
6581
6628
  }
6582
6629
  throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
6583
6630
  case 2:
6584
- _context131.p = 2;
6585
- return _context131.a(2, new Promise(function (resolve, reject) {
6631
+ _context133.p = 2;
6632
+ return _context133.a(2, new Promise(function (resolve, reject) {
6586
6633
  pushPage({
6587
6634
  key: "Verify app proofs",
6588
6635
  content: jsx(VerifyPage, _objectSpread2(_objectSpread2({
@@ -6607,60 +6654,127 @@ var ClientProvider = function ClientProvider(_ref) {
6607
6654
  });
6608
6655
  }));
6609
6656
  case 3:
6610
- _context131.p = 3;
6611
- _t29 = _context131.v;
6657
+ _context133.p = 3;
6658
+ _t29 = _context133.v;
6612
6659
  if (!(_t29 instanceof ZeroXKeyError)) {
6613
- _context131.n = 4;
6660
+ _context133.n = 4;
6614
6661
  break;
6615
6662
  }
6616
6663
  throw _t29;
6617
6664
  case 4:
6618
6665
  throw new ZeroXKeyError("Failed to verify app proofs.", ZeroXKeyErrorCodes.VERIFY_APP_PROOFS_ERROR, _t29);
6619
6666
  case 5:
6620
- return _context131.a(2);
6667
+ return _context133.a(2);
6621
6668
  }
6622
- }, _callee131, null, [[2, 3]]);
6669
+ }, _callee133, null, [[2, 3]]);
6623
6670
  }));
6624
- return function (_x111) {
6625
- return _ref153.apply(this, arguments);
6671
+ return function (_x113) {
6672
+ return _ref155.apply(this, arguments);
6673
+ };
6674
+ }(), [getSession, pushPage]);
6675
+ var handleVerifyEnclave = useCallback(/*#__PURE__*/function () {
6676
+ var _ref157 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee134(params) {
6677
+ var _ref158, appName, _ref158$successPageDu, successPageDuration, stampWith, anchor, s, organizationId, _t30;
6678
+ return _regenerator().w(function (_context134) {
6679
+ while (1) switch (_context134.p = _context134.n) {
6680
+ case 0:
6681
+ _ref158 = params || {}, appName = _ref158.appName, _ref158$successPageDu = _ref158.successPageDuration, successPageDuration = _ref158$successPageDu === void 0 ? 3000 : _ref158$successPageDu, stampWith = _ref158.stampWith, anchor = _ref158.anchor;
6682
+ _context134.n = 1;
6683
+ return getSession();
6684
+ case 1:
6685
+ s = _context134.v;
6686
+ organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
6687
+ if (organizationId) {
6688
+ _context134.n = 2;
6689
+ break;
6690
+ }
6691
+ throw new ZeroXKeyError("A session or passed in organization ID is required.", ZeroXKeyErrorCodes.INVALID_REQUEST);
6692
+ case 2:
6693
+ _context134.p = 2;
6694
+ _context134.n = 3;
6695
+ return new Promise(function (resolve, reject) {
6696
+ pushPage({
6697
+ key: "Verify enclave",
6698
+ content: jsx(VerifyEnclavePage, _objectSpread2(_objectSpread2(_objectSpread2({
6699
+ appName: appName,
6700
+ onSuccess: function onSuccess(pivotHashHex) {
6701
+ resolve(pivotHashHex);
6702
+ },
6703
+ onError: function onError(error) {
6704
+ reject(error);
6705
+ },
6706
+ successPageDuration: successPageDuration
6707
+ }, stampWith && {
6708
+ stampWith: stampWith
6709
+ }), anchor && {
6710
+ anchor: anchor
6711
+ }), organizationId !== undefined && {
6712
+ organizationId: organizationId
6713
+ })),
6714
+ showTitle: false,
6715
+ preventBack: true,
6716
+ onClose: function onClose() {
6717
+ return reject(new ZeroXKeyError("User canceled the verify enclave process.", ZeroXKeyErrorCodes.USER_CANCELED));
6718
+ }
6719
+ });
6720
+ });
6721
+ case 3:
6722
+ return _context134.a(2, _context134.v);
6723
+ case 4:
6724
+ _context134.p = 4;
6725
+ _t30 = _context134.v;
6726
+ if (!(_t30 instanceof ZeroXKeyError)) {
6727
+ _context134.n = 5;
6728
+ break;
6729
+ }
6730
+ throw _t30;
6731
+ case 5:
6732
+ throw new ZeroXKeyError("Failed to verify enclave.", ZeroXKeyErrorCodes.VERIFY_LATEST_BOOT_PROOF_ERROR, _t30);
6733
+ case 6:
6734
+ return _context134.a(2);
6735
+ }
6736
+ }, _callee134, null, [[2, 4]]);
6737
+ }));
6738
+ return function (_x114) {
6739
+ return _ref157.apply(this, arguments);
6626
6740
  };
6627
6741
  }(), [getSession, pushPage]);
6628
6742
  useEffect(function () {
6629
6743
  if (proxyAuthConfigRef.current) return;
6630
6744
  // Only fetch the proxy auth config once. Use that to build the master config.
6631
6745
  var fetchProxyAuthConfig = /*#__PURE__*/function () {
6632
- var _ref155 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee132() {
6746
+ var _ref159 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee135() {
6633
6747
  var proxyAuthConfig;
6634
- return _regenerator().w(function (_context132) {
6635
- while (1) switch (_context132.p = _context132.n) {
6748
+ return _regenerator().w(function (_context135) {
6749
+ while (1) switch (_context135.p = _context135.n) {
6636
6750
  case 0:
6637
- _context132.p = 0;
6751
+ _context135.p = 0;
6638
6752
  if (!shouldFetchWalletKitConfig) {
6639
- _context132.n = 2;
6753
+ _context135.n = 2;
6640
6754
  break;
6641
6755
  }
6642
- _context132.n = 1;
6756
+ _context135.n = 1;
6643
6757
  return getAuthProxyConfig(config.authProxyConfigId,
6644
6758
  // Can assert safely. See shouldFetchWalletKitConfig definition.
6645
6759
  config.authProxyUrl);
6646
6760
  case 1:
6647
- proxyAuthConfig = _context132.v;
6761
+ proxyAuthConfig = _context135.v;
6648
6762
  proxyAuthConfigRef.current = proxyAuthConfig;
6649
6763
  case 2:
6650
6764
  setMasterConfig(buildConfig(proxyAuthConfig));
6651
- _context132.n = 4;
6765
+ _context135.n = 4;
6652
6766
  break;
6653
6767
  case 3:
6654
- _context132.p = 3;
6655
- _context132.v;
6768
+ _context135.p = 3;
6769
+ _context135.v;
6656
6770
  setClientState(ClientState.Error);
6657
6771
  case 4:
6658
- return _context132.a(2);
6772
+ return _context135.a(2);
6659
6773
  }
6660
- }, _callee132, null, [[0, 3]]);
6774
+ }, _callee135, null, [[0, 3]]);
6661
6775
  }));
6662
6776
  return function fetchProxyAuthConfig() {
6663
- return _ref155.apply(this, arguments);
6777
+ return _ref159.apply(this, arguments);
6664
6778
  };
6665
6779
  }();
6666
6780
  fetchProxyAuthConfig();
@@ -6693,34 +6807,34 @@ var ClientProvider = function ClientProvider(_ref) {
6693
6807
  var debouncedFetchWalletProviders = useDebouncedCallback(fetchWalletProviders, 100);
6694
6808
  useEffect(function () {
6695
6809
  var handleUpdateState = /*#__PURE__*/function () {
6696
- var _ref156 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee133() {
6810
+ var _ref160 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee136() {
6697
6811
  var currentSession;
6698
- return _regenerator().w(function (_context133) {
6699
- while (1) switch (_context133.n) {
6812
+ return _regenerator().w(function (_context136) {
6813
+ while (1) switch (_context136.n) {
6700
6814
  case 0:
6701
- _context133.n = 1;
6815
+ _context136.n = 1;
6702
6816
  return getSession();
6703
6817
  case 1:
6704
- currentSession = _context133.v;
6818
+ currentSession = _context136.v;
6705
6819
  if (!currentSession) {
6706
- _context133.n = 3;
6820
+ _context136.n = 3;
6707
6821
  break;
6708
6822
  }
6709
- _context133.n = 2;
6823
+ _context136.n = 2;
6710
6824
  return debouncedRefreshWallets();
6711
6825
  case 2:
6712
- _context133.n = 4;
6826
+ _context136.n = 4;
6713
6827
  break;
6714
6828
  case 3:
6715
- _context133.n = 4;
6829
+ _context136.n = 4;
6716
6830
  return debouncedFetchWalletProviders();
6717
6831
  case 4:
6718
- return _context133.a(2);
6832
+ return _context136.a(2);
6719
6833
  }
6720
- }, _callee133);
6834
+ }, _callee136);
6721
6835
  }));
6722
6836
  return function handleUpdateState() {
6723
- return _ref156.apply(this, arguments);
6837
+ return _ref160.apply(this, arguments);
6724
6838
  };
6725
6839
  }();
6726
6840
  var cleanup = function cleanup() {};
@@ -6838,6 +6952,8 @@ var ClientProvider = function ClientProvider(_ref) {
6838
6952
  createApiKeyPair: createApiKeyPair,
6839
6953
  getProxyAuthConfig: getProxyAuthConfig,
6840
6954
  fetchBootProofForAppProof: fetchBootProofForAppProof,
6955
+ fetchLatestBootProof: fetchLatestBootProof,
6956
+ verifyLatestBootProof: verifyLatestBootProof,
6841
6957
  verifyAppProofs: verifyAppProofs,
6842
6958
  handleLogin: handleLogin,
6843
6959
  handleGoogleOauth: handleGoogleOauth,
@@ -6864,6 +6980,7 @@ var ClientProvider = function ClientProvider(_ref) {
6864
6980
  handleRemoveUserEmail: handleRemoveUserEmail,
6865
6981
  handleRemoveUserPhoneNumber: handleRemoveUserPhoneNumber,
6866
6982
  handleVerifyAppProofs: handleVerifyAppProofs,
6983
+ handleVerifyEnclave: handleVerifyEnclave,
6867
6984
  handleOnRamp: handleOnRamp,
6868
6985
  handleSendTransaction: handleSendTransaction,
6869
6986
  handleSendErc20Transfer: handleSendErc20Transfer