@turnkey/react-wallet-kit 1.6.3 → 1.7.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.
- package/dist/components/send-transaction/SendTransaction.d.ts +12 -0
- package/dist/components/send-transaction/SendTransaction.d.ts.map +1 -0
- package/dist/components/send-transaction/SendTransaction.js +65 -0
- package/dist/components/send-transaction/SendTransaction.js.map +1 -0
- package/dist/components/send-transaction/SendTransaction.mjs +89 -0
- package/dist/components/send-transaction/SendTransaction.mjs.map +1 -0
- package/dist/components/send-transaction/helpers.d.ts +4 -0
- package/dist/components/send-transaction/helpers.d.ts.map +1 -0
- package/dist/components/send-transaction/helpers.js +31 -0
- package/dist/components/send-transaction/helpers.js.map +1 -0
- package/dist/components/send-transaction/helpers.mjs +28 -0
- package/dist/components/send-transaction/helpers.mjs.map +1 -0
- package/dist/providers/client/Provider.d.ts.map +1 -1
- package/dist/providers/client/Provider.js +102 -2
- package/dist/providers/client/Provider.js.map +1 -1
- package/dist/providers/client/Provider.mjs +1047 -884
- package/dist/providers/client/Provider.mjs.map +1 -1
- package/dist/providers/client/Types.d.ts +22 -1
- package/dist/providers/client/Types.d.ts.map +1 -1
- package/dist/providers/client/Types.js.map +1 -1
- package/dist/providers/client/Types.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/typedoc-entry/index.d.ts +1 -1
- package/dist/typedoc-entry/index.d.ts.map +1 -1
- package/dist/types/method-types.d.ts +9 -1
- package/dist/types/method-types.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -31,6 +31,8 @@ import { RemovePhoneNumber } from '../../components/user/RemovePhoneNumber.mjs';
|
|
|
31
31
|
import { VerifyPage } from '../../components/verify/Verify.mjs';
|
|
32
32
|
import { OnRampPage } from '../../components/onramp/OnRamp.mjs';
|
|
33
33
|
import { CoinbaseLogo, MoonPayLogo } from '../../components/design/Svg.mjs';
|
|
34
|
+
import { SendTransactionPage } from '../../components/send-transaction/SendTransaction.mjs';
|
|
35
|
+
import { getChainLogo } from '../../components/send-transaction/helpers.mjs';
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* Provides Turnkey client authentication, session management, wallet operations, and user profile management
|
|
@@ -807,11 +809,11 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
807
809
|
* @throws {TurnkeyError} If an error occurs while clearing the timers.
|
|
808
810
|
*/
|
|
809
811
|
function _initializeWalletProviderListeners() {
|
|
810
|
-
_initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
812
|
+
_initializeWalletProviderListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee125(walletProviders, onUpdateState) {
|
|
811
813
|
var _masterConfig$walletC0, _masterConfig$walletC1, _masterConfig$walletC10, _masterConfig$walletC11;
|
|
812
814
|
var cleanups, nativeOnly, ethProviders, solProviders, wcProviders, wcProvider, attachEthereumListeners, attachSolanaListeners, _wcProvider$provider, _wcProvider$provider$, standardEvents, unsubscribe;
|
|
813
|
-
return _regenerator().w(function (
|
|
814
|
-
while (1) switch (
|
|
815
|
+
return _regenerator().w(function (_context125) {
|
|
816
|
+
while (1) switch (_context125.n) {
|
|
815
817
|
case 0:
|
|
816
818
|
attachSolanaListeners = function _attachSolanaListener(provider, onUpdateState) {
|
|
817
819
|
var _provider$features;
|
|
@@ -819,19 +821,19 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
819
821
|
var walletEvents = provider === null || provider === void 0 ? void 0 : (_provider$features = provider.features) === null || _provider$features === void 0 ? void 0 : _provider$features["standard:events"];
|
|
820
822
|
if (walletEvents !== null && walletEvents !== void 0 && walletEvents.on) {
|
|
821
823
|
var offChange = walletEvents.on("change", /*#__PURE__*/function () {
|
|
822
|
-
var
|
|
823
|
-
return _regenerator().w(function (
|
|
824
|
-
while (1) switch (
|
|
824
|
+
var _ref155 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee123(_evt) {
|
|
825
|
+
return _regenerator().w(function (_context123) {
|
|
826
|
+
while (1) switch (_context123.n) {
|
|
825
827
|
case 0:
|
|
826
|
-
|
|
828
|
+
_context123.n = 1;
|
|
827
829
|
return onUpdateState();
|
|
828
830
|
case 1:
|
|
829
|
-
return
|
|
831
|
+
return _context123.a(2);
|
|
830
832
|
}
|
|
831
|
-
},
|
|
833
|
+
}, _callee123);
|
|
832
834
|
}));
|
|
833
|
-
return function (
|
|
834
|
-
return
|
|
835
|
+
return function (_x100) {
|
|
836
|
+
return _ref155.apply(this, arguments);
|
|
835
837
|
};
|
|
836
838
|
}());
|
|
837
839
|
cleanups.push(offChange);
|
|
@@ -845,31 +847,31 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
845
847
|
attachEthereumListeners = function _attachEthereumListen(provider, onUpdateState) {
|
|
846
848
|
if (typeof provider.on !== "function") return;
|
|
847
849
|
var handleChainChanged = /*#__PURE__*/function () {
|
|
848
|
-
var
|
|
849
|
-
return _regenerator().w(function (
|
|
850
|
-
while (1) switch (
|
|
850
|
+
var _ref153 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee121(_chainId) {
|
|
851
|
+
return _regenerator().w(function (_context121) {
|
|
852
|
+
while (1) switch (_context121.n) {
|
|
851
853
|
case 0:
|
|
852
|
-
return
|
|
854
|
+
return _context121.a(2, onUpdateState());
|
|
853
855
|
}
|
|
854
|
-
},
|
|
856
|
+
}, _callee121);
|
|
855
857
|
}));
|
|
856
|
-
return function handleChainChanged(
|
|
857
|
-
return
|
|
858
|
+
return function handleChainChanged(_x98) {
|
|
859
|
+
return _ref153.apply(this, arguments);
|
|
858
860
|
};
|
|
859
861
|
}();
|
|
860
862
|
var handleAccountsChanged = /*#__PURE__*/function () {
|
|
861
|
-
var
|
|
862
|
-
return _regenerator().w(function (
|
|
863
|
-
while (1) switch (
|
|
863
|
+
var _ref154 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee122(accounts) {
|
|
864
|
+
return _regenerator().w(function (_context122) {
|
|
865
|
+
while (1) switch (_context122.n) {
|
|
864
866
|
case 0:
|
|
865
867
|
if (accounts.length === 0) onUpdateState();
|
|
866
868
|
case 1:
|
|
867
|
-
return
|
|
869
|
+
return _context122.a(2);
|
|
868
870
|
}
|
|
869
|
-
},
|
|
871
|
+
}, _callee122);
|
|
870
872
|
}));
|
|
871
|
-
return function handleAccountsChanged(
|
|
872
|
-
return
|
|
873
|
+
return function handleAccountsChanged(_x99) {
|
|
874
|
+
return _ref154.apply(this, arguments);
|
|
873
875
|
};
|
|
874
876
|
}();
|
|
875
877
|
var handleDisconnect = function handleDisconnect() {
|
|
@@ -885,10 +887,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
885
887
|
};
|
|
886
888
|
};
|
|
887
889
|
if (!(walletProviders.length === 0)) {
|
|
888
|
-
|
|
890
|
+
_context125.n = 1;
|
|
889
891
|
break;
|
|
890
892
|
}
|
|
891
|
-
return
|
|
893
|
+
return _context125.a(2, function () {});
|
|
892
894
|
case 1:
|
|
893
895
|
cleanups = []; // we only want to initialize these listeners for connected walletProviders
|
|
894
896
|
nativeOnly = function nativeOnly(provider) {
|
|
@@ -926,82 +928,82 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
926
928
|
if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
|
|
927
929
|
if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
|
|
928
930
|
unsubscribe = standardEvents.on("change", /*#__PURE__*/function () {
|
|
929
|
-
var
|
|
931
|
+
var _ref156 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee124(evt) {
|
|
930
932
|
var _callbacks$onError10, providers, currentSession, _wcProviders, wcWallets;
|
|
931
|
-
return _regenerator().w(function (
|
|
932
|
-
while (1) switch (
|
|
933
|
+
return _regenerator().w(function (_context124) {
|
|
934
|
+
while (1) switch (_context124.n) {
|
|
933
935
|
case 0:
|
|
934
936
|
if (!((evt === null || evt === void 0 ? void 0 : evt.type) === "pairingExpired")) {
|
|
935
|
-
|
|
937
|
+
_context124.n = 1;
|
|
936
938
|
break;
|
|
937
939
|
}
|
|
938
940
|
debouncedFetchWalletProviders();
|
|
939
|
-
return
|
|
941
|
+
return _context124.a(2);
|
|
940
942
|
case 1:
|
|
941
943
|
if (!((evt === null || evt === void 0 ? void 0 : evt.type) === "failed")) {
|
|
942
|
-
|
|
944
|
+
_context124.n = 2;
|
|
943
945
|
break;
|
|
944
946
|
}
|
|
945
947
|
debouncedFetchWalletProviders();
|
|
946
948
|
callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onError10 = callbacks.onError) === null || _callbacks$onError10 === void 0 ? void 0 : _callbacks$onError10.call(callbacks, new TurnkeyError("WalletConnect initialization failed: ".concat(evt.error || "Unknown error"), TurnkeyErrorCodes.WALLET_CONNECT_INITIALIZATION_ERROR, evt.error));
|
|
947
|
-
return
|
|
949
|
+
return _context124.a(2);
|
|
948
950
|
case 2:
|
|
949
951
|
if (!((evt === null || evt === void 0 ? void 0 : evt.type) === "initialized")) {
|
|
950
|
-
|
|
952
|
+
_context124.n = 7;
|
|
951
953
|
break;
|
|
952
954
|
}
|
|
953
|
-
|
|
955
|
+
_context124.n = 3;
|
|
954
956
|
return debouncedFetchWalletProviders();
|
|
955
957
|
case 3:
|
|
956
|
-
providers =
|
|
957
|
-
|
|
958
|
+
providers = _context124.v;
|
|
959
|
+
_context124.n = 4;
|
|
958
960
|
return getSession();
|
|
959
961
|
case 4:
|
|
960
|
-
currentSession =
|
|
962
|
+
currentSession = _context124.v;
|
|
961
963
|
if (!currentSession) {
|
|
962
|
-
|
|
964
|
+
_context124.n = 6;
|
|
963
965
|
break;
|
|
964
966
|
}
|
|
965
967
|
_wcProviders = providers === null || providers === void 0 ? void 0 : providers.filter(function (p) {
|
|
966
968
|
return p.interfaceType === WalletInterfaceType.WalletConnect;
|
|
967
969
|
});
|
|
968
|
-
|
|
970
|
+
_context124.n = 5;
|
|
969
971
|
return fetchWallets({
|
|
970
972
|
walletProviders: _wcProviders,
|
|
971
973
|
connectedOnly: true
|
|
972
974
|
});
|
|
973
975
|
case 5:
|
|
974
|
-
wcWallets =
|
|
976
|
+
wcWallets = _context124.v;
|
|
975
977
|
if (wcWallets.length > 0) {
|
|
976
978
|
setWallets(function (prev) {
|
|
977
979
|
return mergeWalletsWithoutDuplicates(prev, wcWallets);
|
|
978
980
|
});
|
|
979
981
|
}
|
|
980
982
|
case 6:
|
|
981
|
-
return
|
|
983
|
+
return _context124.a(2);
|
|
982
984
|
case 7:
|
|
983
|
-
|
|
985
|
+
_context124.n = 8;
|
|
984
986
|
return onUpdateState();
|
|
985
987
|
case 8:
|
|
986
|
-
return
|
|
988
|
+
return _context124.a(2);
|
|
987
989
|
}
|
|
988
|
-
},
|
|
990
|
+
}, _callee124);
|
|
989
991
|
}));
|
|
990
|
-
return function (
|
|
991
|
-
return
|
|
992
|
+
return function (_x101) {
|
|
993
|
+
return _ref156.apply(this, arguments);
|
|
992
994
|
};
|
|
993
995
|
}());
|
|
994
996
|
cleanups.push(unsubscribe);
|
|
995
997
|
}
|
|
996
998
|
}
|
|
997
999
|
}
|
|
998
|
-
return
|
|
1000
|
+
return _context125.a(2, function () {
|
|
999
1001
|
cleanups.forEach(function (remove) {
|
|
1000
1002
|
return remove();
|
|
1001
1003
|
});
|
|
1002
1004
|
});
|
|
1003
1005
|
}
|
|
1004
|
-
},
|
|
1006
|
+
}, _callee125);
|
|
1005
1007
|
}));
|
|
1006
1008
|
return _initializeWalletProviderListeners.apply(this, arguments);
|
|
1007
1009
|
}
|
|
@@ -2684,7 +2686,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2684
2686
|
return _ref61.apply(this, arguments);
|
|
2685
2687
|
};
|
|
2686
2688
|
}(), [client, callbacks, logout]);
|
|
2687
|
-
var
|
|
2689
|
+
var ethSendTransaction = useCallback(/*#__PURE__*/function () {
|
|
2688
2690
|
var _ref62 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee53(params) {
|
|
2689
2691
|
return _regenerator().w(function (_context53) {
|
|
2690
2692
|
while (1) switch (_context53.n) {
|
|
@@ -2696,10 +2698,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2696
2698
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
2697
2699
|
case 1:
|
|
2698
2700
|
return _context53.a(2, withTurnkeyErrorHandling(function () {
|
|
2699
|
-
return client.
|
|
2701
|
+
return client.ethSendTransaction(params);
|
|
2700
2702
|
}, function () {
|
|
2701
2703
|
return logout();
|
|
2702
|
-
}, callbacks, "Failed to
|
|
2704
|
+
}, callbacks, "Failed to send eth transaction"));
|
|
2703
2705
|
}
|
|
2704
2706
|
}, _callee53);
|
|
2705
2707
|
}));
|
|
@@ -2707,7 +2709,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2707
2709
|
return _ref62.apply(this, arguments);
|
|
2708
2710
|
};
|
|
2709
2711
|
}(), [client, callbacks, logout]);
|
|
2710
|
-
var
|
|
2712
|
+
var signAndSendTransaction = useCallback(/*#__PURE__*/function () {
|
|
2711
2713
|
var _ref63 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee54(params) {
|
|
2712
2714
|
return _regenerator().w(function (_context54) {
|
|
2713
2715
|
while (1) switch (_context54.n) {
|
|
@@ -2719,10 +2721,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2719
2721
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
2720
2722
|
case 1:
|
|
2721
2723
|
return _context54.a(2, withTurnkeyErrorHandling(function () {
|
|
2722
|
-
return client.
|
|
2724
|
+
return client.signAndSendTransaction(params);
|
|
2723
2725
|
}, function () {
|
|
2724
2726
|
return logout();
|
|
2725
|
-
}, callbacks, "Failed to
|
|
2727
|
+
}, callbacks, "Failed to sign and send transaction"));
|
|
2726
2728
|
}
|
|
2727
2729
|
}, _callee54);
|
|
2728
2730
|
}));
|
|
@@ -2730,7 +2732,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2730
2732
|
return _ref63.apply(this, arguments);
|
|
2731
2733
|
};
|
|
2732
2734
|
}(), [client, callbacks, logout]);
|
|
2733
|
-
var
|
|
2735
|
+
var pollTransactionStatus = useCallback(/*#__PURE__*/function () {
|
|
2734
2736
|
var _ref64 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee55(params) {
|
|
2735
2737
|
return _regenerator().w(function (_context55) {
|
|
2736
2738
|
while (1) switch (_context55.n) {
|
|
@@ -2742,20 +2744,19 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2742
2744
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
2743
2745
|
case 1:
|
|
2744
2746
|
return _context55.a(2, withTurnkeyErrorHandling(function () {
|
|
2745
|
-
return client.
|
|
2747
|
+
return client.pollTransactionStatus(params);
|
|
2746
2748
|
}, function () {
|
|
2747
2749
|
return logout();
|
|
2748
|
-
}, callbacks, "Failed to
|
|
2750
|
+
}, callbacks, "Failed to poll transaction status"));
|
|
2749
2751
|
}
|
|
2750
2752
|
}, _callee55);
|
|
2751
2753
|
}));
|
|
2752
2754
|
return function (_x40) {
|
|
2753
2755
|
return _ref64.apply(this, arguments);
|
|
2754
2756
|
};
|
|
2755
|
-
}(), [client, callbacks
|
|
2756
|
-
var
|
|
2757
|
+
}(), [client, callbacks]);
|
|
2758
|
+
var fetchOrCreateP256ApiKeyUser = useCallback(/*#__PURE__*/function () {
|
|
2757
2759
|
var _ref65 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee56(params) {
|
|
2758
|
-
var res;
|
|
2759
2760
|
return _regenerator().w(function (_context56) {
|
|
2760
2761
|
while (1) switch (_context56.n) {
|
|
2761
2762
|
case 0:
|
|
@@ -2765,38 +2766,20 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2765
2766
|
}
|
|
2766
2767
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
2767
2768
|
case 1:
|
|
2768
|
-
_context56.
|
|
2769
|
-
|
|
2770
|
-
return client.updateUserEmail(params);
|
|
2769
|
+
return _context56.a(2, withTurnkeyErrorHandling(function () {
|
|
2770
|
+
return client.fetchOrCreateP256ApiKeyUser(params);
|
|
2771
2771
|
}, function () {
|
|
2772
2772
|
return logout();
|
|
2773
|
-
}, callbacks, "Failed to
|
|
2774
|
-
case 2:
|
|
2775
|
-
res = _context56.v;
|
|
2776
|
-
if (!res) {
|
|
2777
|
-
_context56.n = 3;
|
|
2778
|
-
break;
|
|
2779
|
-
}
|
|
2780
|
-
_context56.n = 3;
|
|
2781
|
-
return maybeRefreshUser(_objectSpread2(_objectSpread2({
|
|
2782
|
-
stampWith: params === null || params === void 0 ? void 0 : params.stampWith
|
|
2783
|
-
}, (params === null || params === void 0 ? void 0 : params.organizationId) && {
|
|
2784
|
-
organizationId: params.organizationId
|
|
2785
|
-
}), (params === null || params === void 0 ? void 0 : params.userId) && {
|
|
2786
|
-
userId: params.userId
|
|
2787
|
-
}));
|
|
2788
|
-
case 3:
|
|
2789
|
-
return _context56.a(2, res);
|
|
2773
|
+
}, callbacks, "Failed to fetch or create delegated access user"));
|
|
2790
2774
|
}
|
|
2791
2775
|
}, _callee56);
|
|
2792
2776
|
}));
|
|
2793
2777
|
return function (_x41) {
|
|
2794
2778
|
return _ref65.apply(this, arguments);
|
|
2795
2779
|
};
|
|
2796
|
-
}(), [client, callbacks, logout
|
|
2797
|
-
var
|
|
2780
|
+
}(), [client, callbacks, logout]);
|
|
2781
|
+
var fetchOrCreatePolicies = useCallback(/*#__PURE__*/function () {
|
|
2798
2782
|
var _ref66 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee57(params) {
|
|
2799
|
-
var res;
|
|
2800
2783
|
return _regenerator().w(function (_context57) {
|
|
2801
2784
|
while (1) switch (_context57.n) {
|
|
2802
2785
|
case 0:
|
|
@@ -2806,36 +2789,19 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2806
2789
|
}
|
|
2807
2790
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
2808
2791
|
case 1:
|
|
2809
|
-
_context57.
|
|
2810
|
-
|
|
2811
|
-
return client.removeUserEmail(params);
|
|
2792
|
+
return _context57.a(2, withTurnkeyErrorHandling(function () {
|
|
2793
|
+
return client.fetchOrCreatePolicies(params);
|
|
2812
2794
|
}, function () {
|
|
2813
2795
|
return logout();
|
|
2814
|
-
}, callbacks, "Failed to
|
|
2815
|
-
case 2:
|
|
2816
|
-
res = _context57.v;
|
|
2817
|
-
if (!res) {
|
|
2818
|
-
_context57.n = 3;
|
|
2819
|
-
break;
|
|
2820
|
-
}
|
|
2821
|
-
_context57.n = 3;
|
|
2822
|
-
return maybeRefreshUser(_objectSpread2(_objectSpread2({
|
|
2823
|
-
stampWith: params === null || params === void 0 ? void 0 : params.stampWith
|
|
2824
|
-
}, (params === null || params === void 0 ? void 0 : params.organizationId) && {
|
|
2825
|
-
organizationId: params.organizationId
|
|
2826
|
-
}), (params === null || params === void 0 ? void 0 : params.userId) && {
|
|
2827
|
-
userId: params.userId
|
|
2828
|
-
}));
|
|
2829
|
-
case 3:
|
|
2830
|
-
return _context57.a(2, res);
|
|
2796
|
+
}, callbacks, "Failed to fetch or create delegated access user"));
|
|
2831
2797
|
}
|
|
2832
2798
|
}, _callee57);
|
|
2833
2799
|
}));
|
|
2834
2800
|
return function (_x42) {
|
|
2835
2801
|
return _ref66.apply(this, arguments);
|
|
2836
2802
|
};
|
|
2837
|
-
}(), [client, callbacks, logout
|
|
2838
|
-
var
|
|
2803
|
+
}(), [client, callbacks, logout]);
|
|
2804
|
+
var updateUserEmail = useCallback(/*#__PURE__*/function () {
|
|
2839
2805
|
var _ref67 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee58(params) {
|
|
2840
2806
|
var res;
|
|
2841
2807
|
return _regenerator().w(function (_context58) {
|
|
@@ -2849,10 +2815,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2849
2815
|
case 1:
|
|
2850
2816
|
_context58.n = 2;
|
|
2851
2817
|
return withTurnkeyErrorHandling(function () {
|
|
2852
|
-
return client.
|
|
2818
|
+
return client.updateUserEmail(params);
|
|
2853
2819
|
}, function () {
|
|
2854
2820
|
return logout();
|
|
2855
|
-
}, callbacks, "Failed to update user
|
|
2821
|
+
}, callbacks, "Failed to update user email");
|
|
2856
2822
|
case 2:
|
|
2857
2823
|
res = _context58.v;
|
|
2858
2824
|
if (!res) {
|
|
@@ -2876,7 +2842,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2876
2842
|
return _ref67.apply(this, arguments);
|
|
2877
2843
|
};
|
|
2878
2844
|
}(), [client, callbacks, logout, maybeRefreshUser]);
|
|
2879
|
-
var
|
|
2845
|
+
var removeUserEmail = useCallback(/*#__PURE__*/function () {
|
|
2880
2846
|
var _ref68 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee59(params) {
|
|
2881
2847
|
var res;
|
|
2882
2848
|
return _regenerator().w(function (_context59) {
|
|
@@ -2890,10 +2856,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2890
2856
|
case 1:
|
|
2891
2857
|
_context59.n = 2;
|
|
2892
2858
|
return withTurnkeyErrorHandling(function () {
|
|
2893
|
-
return client.
|
|
2859
|
+
return client.removeUserEmail(params);
|
|
2894
2860
|
}, function () {
|
|
2895
2861
|
return logout();
|
|
2896
|
-
}, callbacks, "Failed to remove user
|
|
2862
|
+
}, callbacks, "Failed to remove user email");
|
|
2897
2863
|
case 2:
|
|
2898
2864
|
res = _context59.v;
|
|
2899
2865
|
if (!res) {
|
|
@@ -2917,7 +2883,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2917
2883
|
return _ref68.apply(this, arguments);
|
|
2918
2884
|
};
|
|
2919
2885
|
}(), [client, callbacks, logout, maybeRefreshUser]);
|
|
2920
|
-
var
|
|
2886
|
+
var updateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
|
|
2921
2887
|
var _ref69 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee60(params) {
|
|
2922
2888
|
var res;
|
|
2923
2889
|
return _regenerator().w(function (_context60) {
|
|
@@ -2931,10 +2897,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2931
2897
|
case 1:
|
|
2932
2898
|
_context60.n = 2;
|
|
2933
2899
|
return withTurnkeyErrorHandling(function () {
|
|
2934
|
-
return client.
|
|
2900
|
+
return client.updateUserPhoneNumber(params);
|
|
2935
2901
|
}, function () {
|
|
2936
2902
|
return logout();
|
|
2937
|
-
}, callbacks, "Failed to update user
|
|
2903
|
+
}, callbacks, "Failed to update user phone number");
|
|
2938
2904
|
case 2:
|
|
2939
2905
|
res = _context60.v;
|
|
2940
2906
|
if (!res) {
|
|
@@ -2958,7 +2924,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2958
2924
|
return _ref69.apply(this, arguments);
|
|
2959
2925
|
};
|
|
2960
2926
|
}(), [client, callbacks, logout, maybeRefreshUser]);
|
|
2961
|
-
var
|
|
2927
|
+
var removeUserPhoneNumber = useCallback(/*#__PURE__*/function () {
|
|
2962
2928
|
var _ref70 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee61(params) {
|
|
2963
2929
|
var res;
|
|
2964
2930
|
return _regenerator().w(function (_context61) {
|
|
@@ -2972,10 +2938,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2972
2938
|
case 1:
|
|
2973
2939
|
_context61.n = 2;
|
|
2974
2940
|
return withTurnkeyErrorHandling(function () {
|
|
2975
|
-
return client.
|
|
2941
|
+
return client.removeUserPhoneNumber(params);
|
|
2976
2942
|
}, function () {
|
|
2977
2943
|
return logout();
|
|
2978
|
-
}, callbacks, "Failed to
|
|
2944
|
+
}, callbacks, "Failed to remove user phone number");
|
|
2979
2945
|
case 2:
|
|
2980
2946
|
res = _context61.v;
|
|
2981
2947
|
if (!res) {
|
|
@@ -2999,7 +2965,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
2999
2965
|
return _ref70.apply(this, arguments);
|
|
3000
2966
|
};
|
|
3001
2967
|
}(), [client, callbacks, logout, maybeRefreshUser]);
|
|
3002
|
-
var
|
|
2968
|
+
var updateUserName = useCallback(/*#__PURE__*/function () {
|
|
3003
2969
|
var _ref71 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee62(params) {
|
|
3004
2970
|
var res;
|
|
3005
2971
|
return _regenerator().w(function (_context62) {
|
|
@@ -3013,10 +2979,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3013
2979
|
case 1:
|
|
3014
2980
|
_context62.n = 2;
|
|
3015
2981
|
return withTurnkeyErrorHandling(function () {
|
|
3016
|
-
return client.
|
|
2982
|
+
return client.updateUserName(params);
|
|
3017
2983
|
}, function () {
|
|
3018
2984
|
return logout();
|
|
3019
|
-
}, callbacks, "Failed to
|
|
2985
|
+
}, callbacks, "Failed to update user name");
|
|
3020
2986
|
case 2:
|
|
3021
2987
|
res = _context62.v;
|
|
3022
2988
|
if (!res) {
|
|
@@ -3040,7 +3006,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3040
3006
|
return _ref71.apply(this, arguments);
|
|
3041
3007
|
};
|
|
3042
3008
|
}(), [client, callbacks, logout, maybeRefreshUser]);
|
|
3043
|
-
var
|
|
3009
|
+
var addOauthProvider = useCallback(/*#__PURE__*/function () {
|
|
3044
3010
|
var _ref72 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee63(params) {
|
|
3045
3011
|
var res;
|
|
3046
3012
|
return _regenerator().w(function (_context63) {
|
|
@@ -3054,10 +3020,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3054
3020
|
case 1:
|
|
3055
3021
|
_context63.n = 2;
|
|
3056
3022
|
return withTurnkeyErrorHandling(function () {
|
|
3057
|
-
return client.
|
|
3023
|
+
return client.addOauthProvider(params);
|
|
3058
3024
|
}, function () {
|
|
3059
3025
|
return logout();
|
|
3060
|
-
}, callbacks, "Failed to add
|
|
3026
|
+
}, callbacks, "Failed to add OAuth provider");
|
|
3061
3027
|
case 2:
|
|
3062
3028
|
res = _context63.v;
|
|
3063
3029
|
if (!res) {
|
|
@@ -3081,7 +3047,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3081
3047
|
return _ref72.apply(this, arguments);
|
|
3082
3048
|
};
|
|
3083
3049
|
}(), [client, callbacks, logout, maybeRefreshUser]);
|
|
3084
|
-
var
|
|
3050
|
+
var removeOauthProviders = useCallback(/*#__PURE__*/function () {
|
|
3085
3051
|
var _ref73 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee64(params) {
|
|
3086
3052
|
var res;
|
|
3087
3053
|
return _regenerator().w(function (_context64) {
|
|
@@ -3095,10 +3061,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3095
3061
|
case 1:
|
|
3096
3062
|
_context64.n = 2;
|
|
3097
3063
|
return withTurnkeyErrorHandling(function () {
|
|
3098
|
-
return client.
|
|
3064
|
+
return client.removeOauthProviders(params);
|
|
3099
3065
|
}, function () {
|
|
3100
3066
|
return logout();
|
|
3101
|
-
}, callbacks, "Failed to remove
|
|
3067
|
+
}, callbacks, "Failed to remove OAuth providers");
|
|
3102
3068
|
case 2:
|
|
3103
3069
|
res = _context64.v;
|
|
3104
3070
|
if (!res) {
|
|
@@ -3122,9 +3088,9 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3122
3088
|
return _ref73.apply(this, arguments);
|
|
3123
3089
|
};
|
|
3124
3090
|
}(), [client, callbacks, logout, maybeRefreshUser]);
|
|
3125
|
-
var
|
|
3091
|
+
var addPasskey = useCallback(/*#__PURE__*/function () {
|
|
3126
3092
|
var _ref74 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee65(params) {
|
|
3127
|
-
var res
|
|
3093
|
+
var res;
|
|
3128
3094
|
return _regenerator().w(function (_context65) {
|
|
3129
3095
|
while (1) switch (_context65.n) {
|
|
3130
3096
|
case 0:
|
|
@@ -3136,27 +3102,25 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3136
3102
|
case 1:
|
|
3137
3103
|
_context65.n = 2;
|
|
3138
3104
|
return withTurnkeyErrorHandling(function () {
|
|
3139
|
-
return client.
|
|
3105
|
+
return client.addPasskey(params);
|
|
3140
3106
|
}, function () {
|
|
3141
3107
|
return logout();
|
|
3142
|
-
}, callbacks, "Failed to
|
|
3108
|
+
}, callbacks, "Failed to add passkey");
|
|
3143
3109
|
case 2:
|
|
3144
3110
|
res = _context65.v;
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
case 3:
|
|
3148
|
-
s = _context65.v;
|
|
3149
|
-
if (!(res && s)) {
|
|
3150
|
-
_context65.n = 4;
|
|
3111
|
+
if (!res) {
|
|
3112
|
+
_context65.n = 3;
|
|
3151
3113
|
break;
|
|
3152
3114
|
}
|
|
3153
|
-
_context65.n =
|
|
3154
|
-
return
|
|
3115
|
+
_context65.n = 3;
|
|
3116
|
+
return maybeRefreshUser(_objectSpread2(_objectSpread2({
|
|
3155
3117
|
stampWith: params === null || params === void 0 ? void 0 : params.stampWith
|
|
3156
3118
|
}, (params === null || params === void 0 ? void 0 : params.organizationId) && {
|
|
3157
3119
|
organizationId: params.organizationId
|
|
3120
|
+
}), (params === null || params === void 0 ? void 0 : params.userId) && {
|
|
3121
|
+
userId: params.userId
|
|
3158
3122
|
}));
|
|
3159
|
-
case
|
|
3123
|
+
case 3:
|
|
3160
3124
|
return _context65.a(2, res);
|
|
3161
3125
|
}
|
|
3162
3126
|
}, _callee65);
|
|
@@ -3164,10 +3128,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3164
3128
|
return function (_x50) {
|
|
3165
3129
|
return _ref74.apply(this, arguments);
|
|
3166
3130
|
};
|
|
3167
|
-
}(), [client,
|
|
3168
|
-
var
|
|
3131
|
+
}(), [client, callbacks, logout, maybeRefreshUser]);
|
|
3132
|
+
var removePasskeys = useCallback(/*#__PURE__*/function () {
|
|
3169
3133
|
var _ref75 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee66(params) {
|
|
3170
|
-
var res
|
|
3134
|
+
var res;
|
|
3171
3135
|
return _regenerator().w(function (_context66) {
|
|
3172
3136
|
while (1) switch (_context66.n) {
|
|
3173
3137
|
case 0:
|
|
@@ -3179,27 +3143,25 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3179
3143
|
case 1:
|
|
3180
3144
|
_context66.n = 2;
|
|
3181
3145
|
return withTurnkeyErrorHandling(function () {
|
|
3182
|
-
return client.
|
|
3146
|
+
return client.removePasskeys(params);
|
|
3183
3147
|
}, function () {
|
|
3184
3148
|
return logout();
|
|
3185
|
-
}, callbacks, "Failed to
|
|
3149
|
+
}, callbacks, "Failed to remove passkeys");
|
|
3186
3150
|
case 2:
|
|
3187
3151
|
res = _context66.v;
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
case 3:
|
|
3191
|
-
s = _context66.v;
|
|
3192
|
-
if (!(res && s)) {
|
|
3193
|
-
_context66.n = 4;
|
|
3152
|
+
if (!res) {
|
|
3153
|
+
_context66.n = 3;
|
|
3194
3154
|
break;
|
|
3195
3155
|
}
|
|
3196
|
-
_context66.n =
|
|
3197
|
-
return
|
|
3156
|
+
_context66.n = 3;
|
|
3157
|
+
return maybeRefreshUser(_objectSpread2(_objectSpread2({
|
|
3198
3158
|
stampWith: params === null || params === void 0 ? void 0 : params.stampWith
|
|
3199
3159
|
}, (params === null || params === void 0 ? void 0 : params.organizationId) && {
|
|
3200
3160
|
organizationId: params.organizationId
|
|
3161
|
+
}), (params === null || params === void 0 ? void 0 : params.userId) && {
|
|
3162
|
+
userId: params.userId
|
|
3201
3163
|
}));
|
|
3202
|
-
case
|
|
3164
|
+
case 3:
|
|
3203
3165
|
return _context66.a(2, res);
|
|
3204
3166
|
}
|
|
3205
3167
|
}, _callee66);
|
|
@@ -3207,8 +3169,8 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3207
3169
|
return function (_x51) {
|
|
3208
3170
|
return _ref75.apply(this, arguments);
|
|
3209
3171
|
};
|
|
3210
|
-
}(), [client,
|
|
3211
|
-
var
|
|
3172
|
+
}(), [client, callbacks, logout, maybeRefreshUser]);
|
|
3173
|
+
var createWallet = useCallback(/*#__PURE__*/function () {
|
|
3212
3174
|
var _ref76 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee67(params) {
|
|
3213
3175
|
var res, s;
|
|
3214
3176
|
return _regenerator().w(function (_context67) {
|
|
@@ -3222,10 +3184,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3222
3184
|
case 1:
|
|
3223
3185
|
_context67.n = 2;
|
|
3224
3186
|
return withTurnkeyErrorHandling(function () {
|
|
3225
|
-
return client.
|
|
3187
|
+
return client.createWallet(params);
|
|
3226
3188
|
}, function () {
|
|
3227
3189
|
return logout();
|
|
3228
|
-
}, callbacks, "Failed to
|
|
3190
|
+
}, callbacks, "Failed to create wallet");
|
|
3229
3191
|
case 2:
|
|
3230
3192
|
res = _context67.v;
|
|
3231
3193
|
_context67.n = 3;
|
|
@@ -3250,10 +3212,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3250
3212
|
return function (_x52) {
|
|
3251
3213
|
return _ref76.apply(this, arguments);
|
|
3252
3214
|
};
|
|
3253
|
-
}(), [client, session, callbacks, logout,
|
|
3254
|
-
var
|
|
3215
|
+
}(), [client, session, callbacks, logout, maybeRefreshWallets, getSession]);
|
|
3216
|
+
var createWalletAccounts = useCallback(/*#__PURE__*/function () {
|
|
3255
3217
|
var _ref77 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee68(params) {
|
|
3256
|
-
var res;
|
|
3218
|
+
var res, s;
|
|
3257
3219
|
return _regenerator().w(function (_context68) {
|
|
3258
3220
|
while (1) switch (_context68.n) {
|
|
3259
3221
|
case 0:
|
|
@@ -3265,12 +3227,27 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3265
3227
|
case 1:
|
|
3266
3228
|
_context68.n = 2;
|
|
3267
3229
|
return withTurnkeyErrorHandling(function () {
|
|
3268
|
-
return client.
|
|
3230
|
+
return client.createWalletAccounts(params);
|
|
3269
3231
|
}, function () {
|
|
3270
3232
|
return logout();
|
|
3271
|
-
}, callbacks, "Failed to
|
|
3233
|
+
}, callbacks, "Failed to create wallet accounts");
|
|
3272
3234
|
case 2:
|
|
3273
3235
|
res = _context68.v;
|
|
3236
|
+
_context68.n = 3;
|
|
3237
|
+
return getSession();
|
|
3238
|
+
case 3:
|
|
3239
|
+
s = _context68.v;
|
|
3240
|
+
if (!(res && s)) {
|
|
3241
|
+
_context68.n = 4;
|
|
3242
|
+
break;
|
|
3243
|
+
}
|
|
3244
|
+
_context68.n = 4;
|
|
3245
|
+
return maybeRefreshWallets(_objectSpread2({
|
|
3246
|
+
stampWith: params === null || params === void 0 ? void 0 : params.stampWith
|
|
3247
|
+
}, (params === null || params === void 0 ? void 0 : params.organizationId) && {
|
|
3248
|
+
organizationId: params.organizationId
|
|
3249
|
+
}));
|
|
3250
|
+
case 4:
|
|
3274
3251
|
return _context68.a(2, res);
|
|
3275
3252
|
}
|
|
3276
3253
|
}, _callee68);
|
|
@@ -3278,8 +3255,8 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3278
3255
|
return function (_x53) {
|
|
3279
3256
|
return _ref77.apply(this, arguments);
|
|
3280
3257
|
};
|
|
3281
|
-
}(), [client, callbacks, logout]);
|
|
3282
|
-
var
|
|
3258
|
+
}(), [client, session, callbacks, logout, getSession, maybeRefreshWallets]);
|
|
3259
|
+
var exportWallet = useCallback(/*#__PURE__*/function () {
|
|
3283
3260
|
var _ref78 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee69(params) {
|
|
3284
3261
|
var res, s;
|
|
3285
3262
|
return _regenerator().w(function (_context69) {
|
|
@@ -3293,10 +3270,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3293
3270
|
case 1:
|
|
3294
3271
|
_context69.n = 2;
|
|
3295
3272
|
return withTurnkeyErrorHandling(function () {
|
|
3296
|
-
return client.
|
|
3273
|
+
return client.exportWallet(params);
|
|
3297
3274
|
}, function () {
|
|
3298
3275
|
return logout();
|
|
3299
|
-
}, callbacks, "Failed to export wallet
|
|
3276
|
+
}, callbacks, "Failed to export wallet");
|
|
3300
3277
|
case 2:
|
|
3301
3278
|
res = _context69.v;
|
|
3302
3279
|
_context69.n = 3;
|
|
@@ -3321,10 +3298,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3321
3298
|
return function (_x54) {
|
|
3322
3299
|
return _ref78.apply(this, arguments);
|
|
3323
3300
|
};
|
|
3324
|
-
}(), [client, callbacks, logout, getSession, maybeRefreshWallets]);
|
|
3325
|
-
var
|
|
3301
|
+
}(), [client, session, callbacks, logout, getSession, maybeRefreshWallets]);
|
|
3302
|
+
var exportPrivateKey = useCallback(/*#__PURE__*/function () {
|
|
3326
3303
|
var _ref79 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee70(params) {
|
|
3327
|
-
var res
|
|
3304
|
+
var res;
|
|
3328
3305
|
return _regenerator().w(function (_context70) {
|
|
3329
3306
|
while (1) switch (_context70.n) {
|
|
3330
3307
|
case 0:
|
|
@@ -3335,22 +3312,93 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3335
3312
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
3336
3313
|
case 1:
|
|
3337
3314
|
_context70.n = 2;
|
|
3315
|
+
return withTurnkeyErrorHandling(function () {
|
|
3316
|
+
return client.exportPrivateKey(params);
|
|
3317
|
+
}, function () {
|
|
3318
|
+
return logout();
|
|
3319
|
+
}, callbacks, "Failed to export private key");
|
|
3320
|
+
case 2:
|
|
3321
|
+
res = _context70.v;
|
|
3322
|
+
return _context70.a(2, res);
|
|
3323
|
+
}
|
|
3324
|
+
}, _callee70);
|
|
3325
|
+
}));
|
|
3326
|
+
return function (_x55) {
|
|
3327
|
+
return _ref79.apply(this, arguments);
|
|
3328
|
+
};
|
|
3329
|
+
}(), [client, callbacks, logout]);
|
|
3330
|
+
var exportWalletAccount = useCallback(/*#__PURE__*/function () {
|
|
3331
|
+
var _ref80 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee71(params) {
|
|
3332
|
+
var res, s;
|
|
3333
|
+
return _regenerator().w(function (_context71) {
|
|
3334
|
+
while (1) switch (_context71.n) {
|
|
3335
|
+
case 0:
|
|
3336
|
+
if (client) {
|
|
3337
|
+
_context71.n = 1;
|
|
3338
|
+
break;
|
|
3339
|
+
}
|
|
3340
|
+
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
3341
|
+
case 1:
|
|
3342
|
+
_context71.n = 2;
|
|
3343
|
+
return withTurnkeyErrorHandling(function () {
|
|
3344
|
+
return client.exportWalletAccount(params);
|
|
3345
|
+
}, function () {
|
|
3346
|
+
return logout();
|
|
3347
|
+
}, callbacks, "Failed to export wallet accounts");
|
|
3348
|
+
case 2:
|
|
3349
|
+
res = _context71.v;
|
|
3350
|
+
_context71.n = 3;
|
|
3351
|
+
return getSession();
|
|
3352
|
+
case 3:
|
|
3353
|
+
s = _context71.v;
|
|
3354
|
+
if (!(res && s)) {
|
|
3355
|
+
_context71.n = 4;
|
|
3356
|
+
break;
|
|
3357
|
+
}
|
|
3358
|
+
_context71.n = 4;
|
|
3359
|
+
return maybeRefreshWallets(_objectSpread2({
|
|
3360
|
+
stampWith: params === null || params === void 0 ? void 0 : params.stampWith
|
|
3361
|
+
}, (params === null || params === void 0 ? void 0 : params.organizationId) && {
|
|
3362
|
+
organizationId: params.organizationId
|
|
3363
|
+
}));
|
|
3364
|
+
case 4:
|
|
3365
|
+
return _context71.a(2, res);
|
|
3366
|
+
}
|
|
3367
|
+
}, _callee71);
|
|
3368
|
+
}));
|
|
3369
|
+
return function (_x56) {
|
|
3370
|
+
return _ref80.apply(this, arguments);
|
|
3371
|
+
};
|
|
3372
|
+
}(), [client, callbacks, logout, getSession, maybeRefreshWallets]);
|
|
3373
|
+
var importWallet = useCallback(/*#__PURE__*/function () {
|
|
3374
|
+
var _ref81 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee72(params) {
|
|
3375
|
+
var res, s;
|
|
3376
|
+
return _regenerator().w(function (_context72) {
|
|
3377
|
+
while (1) switch (_context72.n) {
|
|
3378
|
+
case 0:
|
|
3379
|
+
if (client) {
|
|
3380
|
+
_context72.n = 1;
|
|
3381
|
+
break;
|
|
3382
|
+
}
|
|
3383
|
+
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
3384
|
+
case 1:
|
|
3385
|
+
_context72.n = 2;
|
|
3338
3386
|
return withTurnkeyErrorHandling(function () {
|
|
3339
3387
|
return client.importWallet(params);
|
|
3340
3388
|
}, function () {
|
|
3341
3389
|
return logout();
|
|
3342
3390
|
}, callbacks, "Failed to import wallet");
|
|
3343
3391
|
case 2:
|
|
3344
|
-
res =
|
|
3345
|
-
|
|
3392
|
+
res = _context72.v;
|
|
3393
|
+
_context72.n = 3;
|
|
3346
3394
|
return getSession();
|
|
3347
3395
|
case 3:
|
|
3348
|
-
s =
|
|
3396
|
+
s = _context72.v;
|
|
3349
3397
|
if (!(res && s)) {
|
|
3350
|
-
|
|
3398
|
+
_context72.n = 4;
|
|
3351
3399
|
break;
|
|
3352
3400
|
}
|
|
3353
|
-
|
|
3401
|
+
_context72.n = 4;
|
|
3354
3402
|
return maybeRefreshWallets(_objectSpread2(_objectSpread2({
|
|
3355
3403
|
stampWith: params === null || params === void 0 ? void 0 : params.stampWith
|
|
3356
3404
|
}, (params === null || params === void 0 ? void 0 : params.organizationId) && {
|
|
@@ -3359,127 +3407,127 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3359
3407
|
userId: params.userId
|
|
3360
3408
|
}));
|
|
3361
3409
|
case 4:
|
|
3362
|
-
return
|
|
3410
|
+
return _context72.a(2, res);
|
|
3363
3411
|
}
|
|
3364
|
-
},
|
|
3412
|
+
}, _callee72);
|
|
3365
3413
|
}));
|
|
3366
|
-
return function (
|
|
3367
|
-
return
|
|
3414
|
+
return function (_x57) {
|
|
3415
|
+
return _ref81.apply(this, arguments);
|
|
3368
3416
|
};
|
|
3369
3417
|
}(), [client, callbacks, logout, getSession, maybeRefreshWallets]);
|
|
3370
3418
|
var importPrivateKey = useCallback(/*#__PURE__*/function () {
|
|
3371
|
-
var
|
|
3419
|
+
var _ref82 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee73(params) {
|
|
3372
3420
|
var res;
|
|
3373
|
-
return _regenerator().w(function (
|
|
3374
|
-
while (1) switch (
|
|
3421
|
+
return _regenerator().w(function (_context73) {
|
|
3422
|
+
while (1) switch (_context73.n) {
|
|
3375
3423
|
case 0:
|
|
3376
3424
|
if (client) {
|
|
3377
|
-
|
|
3425
|
+
_context73.n = 1;
|
|
3378
3426
|
break;
|
|
3379
3427
|
}
|
|
3380
3428
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
3381
3429
|
case 1:
|
|
3382
|
-
|
|
3430
|
+
_context73.n = 2;
|
|
3383
3431
|
return withTurnkeyErrorHandling(function () {
|
|
3384
3432
|
return client.importPrivateKey(params);
|
|
3385
3433
|
}, function () {
|
|
3386
3434
|
return logout();
|
|
3387
3435
|
}, callbacks, "Failed to import private key");
|
|
3388
3436
|
case 2:
|
|
3389
|
-
res =
|
|
3390
|
-
return
|
|
3437
|
+
res = _context73.v;
|
|
3438
|
+
return _context73.a(2, res);
|
|
3391
3439
|
}
|
|
3392
|
-
},
|
|
3440
|
+
}, _callee73);
|
|
3393
3441
|
}));
|
|
3394
|
-
return function (
|
|
3395
|
-
return
|
|
3442
|
+
return function (_x58) {
|
|
3443
|
+
return _ref82.apply(this, arguments);
|
|
3396
3444
|
};
|
|
3397
3445
|
}(), [client, callbacks, logout]);
|
|
3398
3446
|
var deleteSubOrganization = useCallback(/*#__PURE__*/function () {
|
|
3399
|
-
var
|
|
3400
|
-
return _regenerator().w(function (
|
|
3401
|
-
while (1) switch (
|
|
3447
|
+
var _ref83 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee74(params) {
|
|
3448
|
+
return _regenerator().w(function (_context74) {
|
|
3449
|
+
while (1) switch (_context74.n) {
|
|
3402
3450
|
case 0:
|
|
3403
3451
|
if (client) {
|
|
3404
|
-
|
|
3452
|
+
_context74.n = 1;
|
|
3405
3453
|
break;
|
|
3406
3454
|
}
|
|
3407
3455
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
3408
3456
|
case 1:
|
|
3409
|
-
return
|
|
3457
|
+
return _context74.a(2, withTurnkeyErrorHandling(function () {
|
|
3410
3458
|
return client.deleteSubOrganization(params);
|
|
3411
3459
|
}, function () {
|
|
3412
3460
|
return logout();
|
|
3413
3461
|
}, callbacks, "Failed to delete sub-organization"));
|
|
3414
3462
|
}
|
|
3415
|
-
},
|
|
3463
|
+
}, _callee74);
|
|
3416
3464
|
}));
|
|
3417
|
-
return function (
|
|
3418
|
-
return
|
|
3465
|
+
return function (_x59) {
|
|
3466
|
+
return _ref83.apply(this, arguments);
|
|
3419
3467
|
};
|
|
3420
3468
|
}(), [client, callbacks, logout]);
|
|
3421
3469
|
var storeSession = useCallback(/*#__PURE__*/function () {
|
|
3422
|
-
var
|
|
3470
|
+
var _ref84 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee75(params) {
|
|
3423
3471
|
var sessionKey, session, allSessions;
|
|
3424
|
-
return _regenerator().w(function (
|
|
3425
|
-
while (1) switch (
|
|
3472
|
+
return _regenerator().w(function (_context75) {
|
|
3473
|
+
while (1) switch (_context75.n) {
|
|
3426
3474
|
case 0:
|
|
3427
3475
|
if (client) {
|
|
3428
|
-
|
|
3476
|
+
_context75.n = 1;
|
|
3429
3477
|
break;
|
|
3430
3478
|
}
|
|
3431
3479
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
3432
3480
|
case 1:
|
|
3433
|
-
|
|
3481
|
+
_context75.n = 2;
|
|
3434
3482
|
return withTurnkeyErrorHandling(function () {
|
|
3435
3483
|
return client.storeSession(params);
|
|
3436
3484
|
}, function () {
|
|
3437
3485
|
return logout();
|
|
3438
3486
|
}, callbacks, "Failed to store session");
|
|
3439
3487
|
case 2:
|
|
3440
|
-
|
|
3488
|
+
_context75.n = 3;
|
|
3441
3489
|
return getActiveSessionKey();
|
|
3442
3490
|
case 3:
|
|
3443
|
-
sessionKey =
|
|
3444
|
-
|
|
3491
|
+
sessionKey = _context75.v;
|
|
3492
|
+
_context75.n = 4;
|
|
3445
3493
|
return getSession(_objectSpread2({}, sessionKey && {
|
|
3446
3494
|
sessionKey: sessionKey
|
|
3447
3495
|
}));
|
|
3448
3496
|
case 4:
|
|
3449
|
-
session =
|
|
3497
|
+
session = _context75.v;
|
|
3450
3498
|
if (!(session && sessionKey)) {
|
|
3451
|
-
|
|
3499
|
+
_context75.n = 5;
|
|
3452
3500
|
break;
|
|
3453
3501
|
}
|
|
3454
|
-
|
|
3502
|
+
_context75.n = 5;
|
|
3455
3503
|
return scheduleSessionExpiration({
|
|
3456
3504
|
sessionKey: sessionKey,
|
|
3457
3505
|
expiry: session.expiry
|
|
3458
3506
|
});
|
|
3459
3507
|
case 5:
|
|
3460
|
-
|
|
3508
|
+
_context75.n = 6;
|
|
3461
3509
|
return getAllSessions();
|
|
3462
3510
|
case 6:
|
|
3463
|
-
allSessions =
|
|
3511
|
+
allSessions = _context75.v;
|
|
3464
3512
|
setSession(session);
|
|
3465
3513
|
setAllSessions(allSessions);
|
|
3466
|
-
|
|
3514
|
+
_context75.n = 7;
|
|
3467
3515
|
return Promise.all([maybeRefreshWallets(), maybeRefreshUser()]);
|
|
3468
3516
|
case 7:
|
|
3469
|
-
return
|
|
3517
|
+
return _context75.a(2);
|
|
3470
3518
|
}
|
|
3471
|
-
},
|
|
3519
|
+
}, _callee75);
|
|
3472
3520
|
}));
|
|
3473
|
-
return function (
|
|
3474
|
-
return
|
|
3521
|
+
return function (_x60) {
|
|
3522
|
+
return _ref84.apply(this, arguments);
|
|
3475
3523
|
};
|
|
3476
3524
|
}(), [client, callbacks, logout, getActiveSessionKey, getSession, scheduleSessionExpiration, getAllSessions, maybeRefreshWallets, maybeRefreshUser]);
|
|
3477
|
-
var clearAllSessions = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
3478
|
-
return _regenerator().w(function (
|
|
3479
|
-
while (1) switch (
|
|
3525
|
+
var clearAllSessions = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee76() {
|
|
3526
|
+
return _regenerator().w(function (_context76) {
|
|
3527
|
+
while (1) switch (_context76.n) {
|
|
3480
3528
|
case 0:
|
|
3481
3529
|
if (client) {
|
|
3482
|
-
|
|
3530
|
+
_context76.n = 1;
|
|
3483
3531
|
break;
|
|
3484
3532
|
}
|
|
3485
3533
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
@@ -3487,30 +3535,30 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3487
3535
|
setSession(undefined);
|
|
3488
3536
|
setAllSessions(undefined);
|
|
3489
3537
|
clearSessionTimeouts();
|
|
3490
|
-
|
|
3538
|
+
_context76.n = 2;
|
|
3491
3539
|
return withTurnkeyErrorHandling(function () {
|
|
3492
3540
|
return client.clearAllSessions();
|
|
3493
3541
|
}, function () {
|
|
3494
3542
|
return logout();
|
|
3495
3543
|
}, callbacks, "Failed to clear all sessions");
|
|
3496
3544
|
case 2:
|
|
3497
|
-
return
|
|
3545
|
+
return _context76.a(2, _context76.v);
|
|
3498
3546
|
}
|
|
3499
|
-
},
|
|
3547
|
+
}, _callee76);
|
|
3500
3548
|
})), [client, callbacks, logout, clearSessionTimeouts]);
|
|
3501
3549
|
var setActiveSession = useCallback(/*#__PURE__*/function () {
|
|
3502
|
-
var
|
|
3550
|
+
var _ref86 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee78(params) {
|
|
3503
3551
|
var session, s;
|
|
3504
|
-
return _regenerator().w(function (
|
|
3505
|
-
while (1) switch (
|
|
3552
|
+
return _regenerator().w(function (_context78) {
|
|
3553
|
+
while (1) switch (_context78.n) {
|
|
3506
3554
|
case 0:
|
|
3507
3555
|
if (client) {
|
|
3508
|
-
|
|
3556
|
+
_context78.n = 1;
|
|
3509
3557
|
break;
|
|
3510
3558
|
}
|
|
3511
3559
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
3512
3560
|
case 1:
|
|
3513
|
-
|
|
3561
|
+
_context78.n = 2;
|
|
3514
3562
|
return withTurnkeyErrorHandling(function () {
|
|
3515
3563
|
return client.getSession({
|
|
3516
3564
|
sessionKey: params.sessionKey
|
|
@@ -3519,18 +3567,18 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3519
3567
|
return logout();
|
|
3520
3568
|
}, callbacks, "Failed to get session");
|
|
3521
3569
|
case 2:
|
|
3522
|
-
session =
|
|
3523
|
-
|
|
3570
|
+
session = _context78.v;
|
|
3571
|
+
_context78.n = 3;
|
|
3524
3572
|
return getSession();
|
|
3525
3573
|
case 3:
|
|
3526
|
-
s =
|
|
3574
|
+
s = _context78.v;
|
|
3527
3575
|
if (s) {
|
|
3528
|
-
|
|
3576
|
+
_context78.n = 4;
|
|
3529
3577
|
break;
|
|
3530
3578
|
}
|
|
3531
3579
|
throw new TurnkeyError("Session not found.", TurnkeyErrorCodes.NOT_FOUND);
|
|
3532
3580
|
case 4:
|
|
3533
|
-
|
|
3581
|
+
_context78.n = 5;
|
|
3534
3582
|
return withTurnkeyErrorHandling(function () {
|
|
3535
3583
|
return client.setActiveSession(params);
|
|
3536
3584
|
}, function () {
|
|
@@ -3538,172 +3586,172 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3538
3586
|
}, callbacks, "Failed to set active session");
|
|
3539
3587
|
case 5:
|
|
3540
3588
|
setSession(session);
|
|
3541
|
-
|
|
3542
|
-
return withTurnkeyErrorHandling(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
3543
|
-
return _regenerator().w(function (
|
|
3544
|
-
while (1) switch (
|
|
3589
|
+
_context78.n = 6;
|
|
3590
|
+
return withTurnkeyErrorHandling(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee77() {
|
|
3591
|
+
return _regenerator().w(function (_context77) {
|
|
3592
|
+
while (1) switch (_context77.n) {
|
|
3545
3593
|
case 0:
|
|
3546
|
-
|
|
3594
|
+
_context77.n = 1;
|
|
3547
3595
|
return Promise.all([maybeRefreshWallets(), maybeRefreshUser()]);
|
|
3548
3596
|
case 1:
|
|
3549
|
-
return
|
|
3597
|
+
return _context77.a(2);
|
|
3550
3598
|
}
|
|
3551
|
-
},
|
|
3599
|
+
}, _callee77);
|
|
3552
3600
|
})), function () {
|
|
3553
3601
|
return logout();
|
|
3554
3602
|
}, callbacks, "Failed to refresh data after setting active session");
|
|
3555
3603
|
case 6:
|
|
3556
|
-
return
|
|
3604
|
+
return _context78.a(2);
|
|
3557
3605
|
}
|
|
3558
|
-
},
|
|
3606
|
+
}, _callee78);
|
|
3559
3607
|
}));
|
|
3560
|
-
return function (
|
|
3561
|
-
return
|
|
3608
|
+
return function (_x61) {
|
|
3609
|
+
return _ref86.apply(this, arguments);
|
|
3562
3610
|
};
|
|
3563
3611
|
}(), [client, callbacks, logout, getSession, maybeRefreshWallets, maybeRefreshUser]);
|
|
3564
|
-
var clearUnusedKeyPairs = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
3565
|
-
return _regenerator().w(function (
|
|
3566
|
-
while (1) switch (
|
|
3612
|
+
var clearUnusedKeyPairs = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee79() {
|
|
3613
|
+
return _regenerator().w(function (_context79) {
|
|
3614
|
+
while (1) switch (_context79.n) {
|
|
3567
3615
|
case 0:
|
|
3568
3616
|
if (client) {
|
|
3569
|
-
|
|
3617
|
+
_context79.n = 1;
|
|
3570
3618
|
break;
|
|
3571
3619
|
}
|
|
3572
3620
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
3573
3621
|
case 1:
|
|
3574
|
-
return
|
|
3622
|
+
return _context79.a(2, withTurnkeyErrorHandling(function () {
|
|
3575
3623
|
return client.clearUnusedKeyPairs();
|
|
3576
3624
|
}, undefined, callbacks, "Failed to clear unused key pairs"));
|
|
3577
3625
|
}
|
|
3578
|
-
},
|
|
3626
|
+
}, _callee79);
|
|
3579
3627
|
})), [client, callbacks]);
|
|
3580
3628
|
var createApiKeyPair = useCallback(/*#__PURE__*/function () {
|
|
3581
|
-
var
|
|
3582
|
-
return _regenerator().w(function (
|
|
3583
|
-
while (1) switch (
|
|
3629
|
+
var _ref89 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee80(params) {
|
|
3630
|
+
return _regenerator().w(function (_context80) {
|
|
3631
|
+
while (1) switch (_context80.n) {
|
|
3584
3632
|
case 0:
|
|
3585
3633
|
if (client) {
|
|
3586
|
-
|
|
3634
|
+
_context80.n = 1;
|
|
3587
3635
|
break;
|
|
3588
3636
|
}
|
|
3589
3637
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
3590
3638
|
case 1:
|
|
3591
|
-
return
|
|
3639
|
+
return _context80.a(2, withTurnkeyErrorHandling(function () {
|
|
3592
3640
|
return client.createApiKeyPair(params);
|
|
3593
3641
|
}, undefined, callbacks, "Failed to create API key pair"));
|
|
3594
3642
|
}
|
|
3595
|
-
},
|
|
3643
|
+
}, _callee80);
|
|
3596
3644
|
}));
|
|
3597
|
-
return function (
|
|
3598
|
-
return
|
|
3645
|
+
return function (_x62) {
|
|
3646
|
+
return _ref89.apply(this, arguments);
|
|
3599
3647
|
};
|
|
3600
3648
|
}(), [client, callbacks]);
|
|
3601
|
-
var getProxyAuthConfig = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
3602
|
-
return _regenerator().w(function (
|
|
3603
|
-
while (1) switch (
|
|
3649
|
+
var getProxyAuthConfig = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee81() {
|
|
3650
|
+
return _regenerator().w(function (_context81) {
|
|
3651
|
+
while (1) switch (_context81.n) {
|
|
3604
3652
|
case 0:
|
|
3605
3653
|
if (client) {
|
|
3606
|
-
|
|
3654
|
+
_context81.n = 1;
|
|
3607
3655
|
break;
|
|
3608
3656
|
}
|
|
3609
3657
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
3610
3658
|
case 1:
|
|
3611
|
-
return
|
|
3659
|
+
return _context81.a(2, withTurnkeyErrorHandling(function () {
|
|
3612
3660
|
return client.getProxyAuthConfig();
|
|
3613
3661
|
}, undefined, callbacks, "Failed to get proxy auth config"));
|
|
3614
3662
|
}
|
|
3615
|
-
},
|
|
3663
|
+
}, _callee81);
|
|
3616
3664
|
})), [client, callbacks]);
|
|
3617
3665
|
var fetchBootProofForAppProof = useCallback(/*#__PURE__*/function () {
|
|
3618
|
-
var
|
|
3619
|
-
return _regenerator().w(function (
|
|
3620
|
-
while (1) switch (
|
|
3666
|
+
var _ref91 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee82(params) {
|
|
3667
|
+
return _regenerator().w(function (_context82) {
|
|
3668
|
+
while (1) switch (_context82.n) {
|
|
3621
3669
|
case 0:
|
|
3622
3670
|
if (client) {
|
|
3623
|
-
|
|
3671
|
+
_context82.n = 1;
|
|
3624
3672
|
break;
|
|
3625
3673
|
}
|
|
3626
3674
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
3627
3675
|
case 1:
|
|
3628
|
-
return
|
|
3676
|
+
return _context82.a(2, withTurnkeyErrorHandling(function () {
|
|
3629
3677
|
return client.fetchBootProofForAppProof(params);
|
|
3630
3678
|
}, function () {
|
|
3631
3679
|
return logout();
|
|
3632
3680
|
}, callbacks, "Failed to fetch or create delegated access user"));
|
|
3633
3681
|
}
|
|
3634
|
-
},
|
|
3682
|
+
}, _callee82);
|
|
3635
3683
|
}));
|
|
3636
|
-
return function (
|
|
3637
|
-
return
|
|
3684
|
+
return function (_x63) {
|
|
3685
|
+
return _ref91.apply(this, arguments);
|
|
3638
3686
|
};
|
|
3639
3687
|
}(), [client, callbacks, logout]);
|
|
3640
3688
|
var verifyAppProofs = useCallback(/*#__PURE__*/function () {
|
|
3641
|
-
var
|
|
3642
|
-
return _regenerator().w(function (
|
|
3643
|
-
while (1) switch (
|
|
3689
|
+
var _ref92 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee83(params) {
|
|
3690
|
+
return _regenerator().w(function (_context83) {
|
|
3691
|
+
while (1) switch (_context83.n) {
|
|
3644
3692
|
case 0:
|
|
3645
3693
|
if (client) {
|
|
3646
|
-
|
|
3694
|
+
_context83.n = 1;
|
|
3647
3695
|
break;
|
|
3648
3696
|
}
|
|
3649
3697
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
3650
3698
|
case 1:
|
|
3651
|
-
return
|
|
3699
|
+
return _context83.a(2, withTurnkeyErrorHandling(function () {
|
|
3652
3700
|
return client.verifyAppProofs(params);
|
|
3653
3701
|
}, function () {
|
|
3654
3702
|
return logout();
|
|
3655
3703
|
}, callbacks, "Failed to verify app proofs"));
|
|
3656
3704
|
}
|
|
3657
|
-
},
|
|
3705
|
+
}, _callee83);
|
|
3658
3706
|
}));
|
|
3659
|
-
return function (
|
|
3660
|
-
return
|
|
3707
|
+
return function (_x64) {
|
|
3708
|
+
return _ref92.apply(this, arguments);
|
|
3661
3709
|
};
|
|
3662
3710
|
}(), [client, callbacks, logout]);
|
|
3663
3711
|
var handleDiscordOauth = useCallback(/*#__PURE__*/function () {
|
|
3664
|
-
var
|
|
3712
|
+
var _ref93 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee84(params) {
|
|
3665
3713
|
var _masterConfig$auth21, _masterConfig$auth21$, _masterConfig$auth$oa2, _masterConfig$auth22, _masterConfig$auth22$;
|
|
3666
|
-
var
|
|
3667
|
-
return _regenerator().w(function (
|
|
3668
|
-
while (1) switch (
|
|
3714
|
+
var _ref94, _ref94$clientId, clientId, _ref94$openInPage, openInPage, additionalParameters, _masterConfig$auth23, _masterConfig$auth23$, _masterConfig$auth24, flow, redirectURI, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, discordAuthUrl, extra, width, height, left, top, authWindow, _t12;
|
|
3715
|
+
return _regenerator().w(function (_context84) {
|
|
3716
|
+
while (1) switch (_context84.p = _context84.n) {
|
|
3669
3717
|
case 0:
|
|
3670
|
-
|
|
3671
|
-
|
|
3718
|
+
_ref94 = params || {}, _ref94$clientId = _ref94.clientId, clientId = _ref94$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 : _ref94$clientId, _ref94$openInPage = _ref94.openInPage, openInPage = _ref94$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 : _ref94$openInPage, additionalParameters = _ref94.additionalState;
|
|
3719
|
+
_context84.p = 1;
|
|
3672
3720
|
if (masterConfig) {
|
|
3673
|
-
|
|
3721
|
+
_context84.n = 2;
|
|
3674
3722
|
break;
|
|
3675
3723
|
}
|
|
3676
3724
|
throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
|
|
3677
3725
|
case 2:
|
|
3678
3726
|
if (clientId) {
|
|
3679
|
-
|
|
3727
|
+
_context84.n = 3;
|
|
3680
3728
|
break;
|
|
3681
3729
|
}
|
|
3682
3730
|
throw new TurnkeyError("Discord Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
|
|
3683
3731
|
case 3:
|
|
3684
3732
|
if ((_masterConfig$auth23 = masterConfig.auth) !== null && _masterConfig$auth23 !== void 0 && (_masterConfig$auth23$ = _masterConfig$auth23.oauthConfig) !== null && _masterConfig$auth23$ !== void 0 && _masterConfig$auth23$.oauthRedirectUri) {
|
|
3685
|
-
|
|
3733
|
+
_context84.n = 4;
|
|
3686
3734
|
break;
|
|
3687
3735
|
}
|
|
3688
3736
|
throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
|
|
3689
3737
|
case 4:
|
|
3690
3738
|
flow = openInPage ? "redirect" : "popup";
|
|
3691
3739
|
redirectURI = (_masterConfig$auth24 = masterConfig.auth) === null || _masterConfig$auth24 === void 0 ? void 0 : _masterConfig$auth24.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
|
|
3692
|
-
|
|
3740
|
+
_context84.n = 5;
|
|
3693
3741
|
return createApiKeyPair();
|
|
3694
3742
|
case 5:
|
|
3695
|
-
publicKey =
|
|
3743
|
+
publicKey = _context84.v;
|
|
3696
3744
|
if (publicKey) {
|
|
3697
|
-
|
|
3745
|
+
_context84.n = 6;
|
|
3698
3746
|
break;
|
|
3699
3747
|
}
|
|
3700
3748
|
throw new Error("Failed to create public key for OAuth.");
|
|
3701
3749
|
case 6:
|
|
3702
3750
|
nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
|
|
3703
|
-
|
|
3751
|
+
_context84.n = 7;
|
|
3704
3752
|
return generateChallengePair();
|
|
3705
3753
|
case 7:
|
|
3706
|
-
_yield$generateChalle =
|
|
3754
|
+
_yield$generateChalle = _context84.v;
|
|
3707
3755
|
verifier = _yield$generateChalle.verifier;
|
|
3708
3756
|
codeChallenge = _yield$generateChalle.codeChallenge;
|
|
3709
3757
|
sessionStorage.setItem("discord_verifier", verifier);
|
|
@@ -3717,10 +3765,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3717
3765
|
discordAuthUrl.searchParams.set("scope", "identify email");
|
|
3718
3766
|
discordAuthUrl.searchParams.set("state", "provider=discord&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey), "&nonce=").concat(nonce));
|
|
3719
3767
|
if (additionalParameters) {
|
|
3720
|
-
extra = Object.entries(additionalParameters).map(function (
|
|
3721
|
-
var
|
|
3722
|
-
k =
|
|
3723
|
-
v =
|
|
3768
|
+
extra = Object.entries(additionalParameters).map(function (_ref95) {
|
|
3769
|
+
var _ref96 = _slicedToArray(_ref95, 2),
|
|
3770
|
+
k = _ref96[0],
|
|
3771
|
+
v = _ref96[1];
|
|
3724
3772
|
return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(v));
|
|
3725
3773
|
}).join("&");
|
|
3726
3774
|
if (extra) {
|
|
@@ -3728,11 +3776,11 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3728
3776
|
}
|
|
3729
3777
|
}
|
|
3730
3778
|
if (!openInPage) {
|
|
3731
|
-
|
|
3779
|
+
_context84.n = 8;
|
|
3732
3780
|
break;
|
|
3733
3781
|
}
|
|
3734
3782
|
window.location.href = discordAuthUrl.toString();
|
|
3735
|
-
return
|
|
3783
|
+
return _context84.a(2, new Promise(function (_, reject) {
|
|
3736
3784
|
var timeout = setTimeout(function () {
|
|
3737
3785
|
reject(new Error("Authentication timed out."));
|
|
3738
3786
|
}, 300000);
|
|
@@ -3747,13 +3795,13 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3747
3795
|
top = window.screenY + (window.innerHeight - height) / 2;
|
|
3748
3796
|
authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
|
|
3749
3797
|
if (authWindow) {
|
|
3750
|
-
|
|
3798
|
+
_context84.n = 9;
|
|
3751
3799
|
break;
|
|
3752
3800
|
}
|
|
3753
3801
|
throw new Error("Failed to open Discord login window.");
|
|
3754
3802
|
case 9:
|
|
3755
3803
|
authWindow.location.href = discordAuthUrl.toString();
|
|
3756
|
-
return
|
|
3804
|
+
return _context84.a(2, new Promise(function (resolve, reject) {
|
|
3757
3805
|
var interval = setInterval(function () {
|
|
3758
3806
|
try {
|
|
3759
3807
|
if (authWindow.closed) {
|
|
@@ -3828,65 +3876,65 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3828
3876
|
}
|
|
3829
3877
|
}));
|
|
3830
3878
|
case 10:
|
|
3831
|
-
|
|
3879
|
+
_context84.n = 12;
|
|
3832
3880
|
break;
|
|
3833
3881
|
case 11:
|
|
3834
|
-
|
|
3835
|
-
_t12 =
|
|
3882
|
+
_context84.p = 11;
|
|
3883
|
+
_t12 = _context84.v;
|
|
3836
3884
|
throw _t12;
|
|
3837
3885
|
case 12:
|
|
3838
|
-
return
|
|
3886
|
+
return _context84.a(2);
|
|
3839
3887
|
}
|
|
3840
|
-
},
|
|
3888
|
+
}, _callee84, null, [[1, 11]]);
|
|
3841
3889
|
}));
|
|
3842
|
-
return function (
|
|
3843
|
-
return
|
|
3890
|
+
return function (_x65) {
|
|
3891
|
+
return _ref93.apply(this, arguments);
|
|
3844
3892
|
};
|
|
3845
3893
|
}(), [client, callbacks, completeOauth, createApiKeyPair, masterConfig]);
|
|
3846
3894
|
var handleXOauth = useCallback(/*#__PURE__*/function () {
|
|
3847
|
-
var
|
|
3895
|
+
var _ref97 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee85(params) {
|
|
3848
3896
|
var _masterConfig$auth25, _masterConfig$auth25$, _masterConfig$auth$oa3, _masterConfig$auth26, _masterConfig$auth26$;
|
|
3849
|
-
var
|
|
3850
|
-
return _regenerator().w(function (
|
|
3851
|
-
while (1) switch (
|
|
3897
|
+
var _ref98, _ref98$clientId, clientId, _ref98$openInPage, openInPage, additionalParameters, _masterConfig$auth27, _masterConfig$auth27$, _masterConfig$auth28, flow, redirectURI, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, twitterAuthUrl, extra, width, height, left, top, authWindow, _t13;
|
|
3898
|
+
return _regenerator().w(function (_context85) {
|
|
3899
|
+
while (1) switch (_context85.p = _context85.n) {
|
|
3852
3900
|
case 0:
|
|
3853
|
-
|
|
3854
|
-
|
|
3901
|
+
_ref98 = params || {}, _ref98$clientId = _ref98.clientId, clientId = _ref98$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 : _ref98$clientId, _ref98$openInPage = _ref98.openInPage, openInPage = _ref98$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 : _ref98$openInPage, additionalParameters = _ref98.additionalState;
|
|
3902
|
+
_context85.p = 1;
|
|
3855
3903
|
if (masterConfig) {
|
|
3856
|
-
|
|
3904
|
+
_context85.n = 2;
|
|
3857
3905
|
break;
|
|
3858
3906
|
}
|
|
3859
3907
|
throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
|
|
3860
3908
|
case 2:
|
|
3861
3909
|
if (clientId) {
|
|
3862
|
-
|
|
3910
|
+
_context85.n = 3;
|
|
3863
3911
|
break;
|
|
3864
3912
|
}
|
|
3865
3913
|
throw new TurnkeyError("Twitter Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
|
|
3866
3914
|
case 3:
|
|
3867
3915
|
if ((_masterConfig$auth27 = masterConfig.auth) !== null && _masterConfig$auth27 !== void 0 && (_masterConfig$auth27$ = _masterConfig$auth27.oauthConfig) !== null && _masterConfig$auth27$ !== void 0 && _masterConfig$auth27$.oauthRedirectUri) {
|
|
3868
|
-
|
|
3916
|
+
_context85.n = 4;
|
|
3869
3917
|
break;
|
|
3870
3918
|
}
|
|
3871
3919
|
throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
|
|
3872
3920
|
case 4:
|
|
3873
3921
|
flow = openInPage ? "redirect" : "popup";
|
|
3874
3922
|
redirectURI = (_masterConfig$auth28 = masterConfig.auth) === null || _masterConfig$auth28 === void 0 ? void 0 : _masterConfig$auth28.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
|
|
3875
|
-
|
|
3923
|
+
_context85.n = 5;
|
|
3876
3924
|
return createApiKeyPair();
|
|
3877
3925
|
case 5:
|
|
3878
|
-
publicKey =
|
|
3926
|
+
publicKey = _context85.v;
|
|
3879
3927
|
if (publicKey) {
|
|
3880
|
-
|
|
3928
|
+
_context85.n = 6;
|
|
3881
3929
|
break;
|
|
3882
3930
|
}
|
|
3883
3931
|
throw new Error("Failed to create public key for OAuth.");
|
|
3884
3932
|
case 6:
|
|
3885
3933
|
nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
|
|
3886
|
-
|
|
3934
|
+
_context85.n = 7;
|
|
3887
3935
|
return generateChallengePair();
|
|
3888
3936
|
case 7:
|
|
3889
|
-
_yield$generateChalle2 =
|
|
3937
|
+
_yield$generateChalle2 = _context85.v;
|
|
3890
3938
|
verifier = _yield$generateChalle2.verifier;
|
|
3891
3939
|
codeChallenge = _yield$generateChalle2.codeChallenge;
|
|
3892
3940
|
sessionStorage.setItem("twitter_verifier", verifier);
|
|
@@ -3900,10 +3948,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3900
3948
|
twitterAuthUrl.searchParams.set("scope", "tweet.read users.read");
|
|
3901
3949
|
twitterAuthUrl.searchParams.set("state", "provider=twitter&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey), "&nonce=").concat(nonce));
|
|
3902
3950
|
if (additionalParameters) {
|
|
3903
|
-
extra = Object.entries(additionalParameters).map(function (
|
|
3904
|
-
var
|
|
3905
|
-
k =
|
|
3906
|
-
v =
|
|
3951
|
+
extra = Object.entries(additionalParameters).map(function (_ref99) {
|
|
3952
|
+
var _ref100 = _slicedToArray(_ref99, 2),
|
|
3953
|
+
k = _ref100[0],
|
|
3954
|
+
v = _ref100[1];
|
|
3907
3955
|
return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(v));
|
|
3908
3956
|
}).join("&");
|
|
3909
3957
|
if (extra) {
|
|
@@ -3911,11 +3959,11 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3911
3959
|
}
|
|
3912
3960
|
}
|
|
3913
3961
|
if (!openInPage) {
|
|
3914
|
-
|
|
3962
|
+
_context85.n = 8;
|
|
3915
3963
|
break;
|
|
3916
3964
|
}
|
|
3917
3965
|
window.location.href = twitterAuthUrl.toString();
|
|
3918
|
-
return
|
|
3966
|
+
return _context85.a(2, new Promise(function (_, reject) {
|
|
3919
3967
|
var timeout = setTimeout(function () {
|
|
3920
3968
|
reject(new Error("Authentication timed out."));
|
|
3921
3969
|
}, 300000);
|
|
@@ -3930,13 +3978,13 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
3930
3978
|
top = window.screenY + (window.innerHeight - height) / 2;
|
|
3931
3979
|
authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
|
|
3932
3980
|
if (authWindow) {
|
|
3933
|
-
|
|
3981
|
+
_context85.n = 9;
|
|
3934
3982
|
break;
|
|
3935
3983
|
}
|
|
3936
3984
|
throw new Error("Failed to open Twitter login window.");
|
|
3937
3985
|
case 9:
|
|
3938
3986
|
authWindow.location.href = twitterAuthUrl.toString();
|
|
3939
|
-
return
|
|
3987
|
+
return _context85.a(2, new Promise(function (resolve, reject) {
|
|
3940
3988
|
var interval = setInterval(function () {
|
|
3941
3989
|
try {
|
|
3942
3990
|
if (authWindow.closed) {
|
|
@@ -4011,56 +4059,56 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4011
4059
|
}
|
|
4012
4060
|
}));
|
|
4013
4061
|
case 10:
|
|
4014
|
-
|
|
4062
|
+
_context85.n = 12;
|
|
4015
4063
|
break;
|
|
4016
4064
|
case 11:
|
|
4017
|
-
|
|
4018
|
-
_t13 =
|
|
4065
|
+
_context85.p = 11;
|
|
4066
|
+
_t13 = _context85.v;
|
|
4019
4067
|
throw _t13;
|
|
4020
4068
|
case 12:
|
|
4021
|
-
return
|
|
4069
|
+
return _context85.a(2);
|
|
4022
4070
|
}
|
|
4023
|
-
},
|
|
4071
|
+
}, _callee85, null, [[1, 11]]);
|
|
4024
4072
|
}));
|
|
4025
|
-
return function (
|
|
4026
|
-
return
|
|
4073
|
+
return function (_x66) {
|
|
4074
|
+
return _ref97.apply(this, arguments);
|
|
4027
4075
|
};
|
|
4028
4076
|
}(), [client, callbacks, completeOauth, createApiKeyPair, masterConfig]);
|
|
4029
4077
|
var handleGoogleOauth = useCallback(/*#__PURE__*/function () {
|
|
4030
|
-
var
|
|
4078
|
+
var _ref101 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee86(params) {
|
|
4031
4079
|
var _masterConfig$auth29, _masterConfig$auth29$, _masterConfig$auth$oa4, _masterConfig$auth30, _masterConfig$auth30$;
|
|
4032
|
-
var
|
|
4033
|
-
return _regenerator().w(function (
|
|
4034
|
-
while (1) switch (
|
|
4080
|
+
var _ref102, _ref102$clientId, clientId, _ref102$openInPage, openInPage, additionalParameters, _masterConfig$auth31, _masterConfig$auth31$, _masterConfig$auth32, flow, redirectURI, publicKey, nonce, googleAuthUrl, state, additionalState, width, height, left, top, authWindow, _t14;
|
|
4081
|
+
return _regenerator().w(function (_context86) {
|
|
4082
|
+
while (1) switch (_context86.p = _context86.n) {
|
|
4035
4083
|
case 0:
|
|
4036
|
-
|
|
4037
|
-
|
|
4084
|
+
_ref102 = params || {}, _ref102$clientId = _ref102.clientId, clientId = _ref102$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 : _ref102$clientId, _ref102$openInPage = _ref102.openInPage, openInPage = _ref102$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 : _ref102$openInPage, additionalParameters = _ref102.additionalState;
|
|
4085
|
+
_context86.p = 1;
|
|
4038
4086
|
if (masterConfig) {
|
|
4039
|
-
|
|
4087
|
+
_context86.n = 2;
|
|
4040
4088
|
break;
|
|
4041
4089
|
}
|
|
4042
4090
|
throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
|
|
4043
4091
|
case 2:
|
|
4044
4092
|
if (clientId) {
|
|
4045
|
-
|
|
4093
|
+
_context86.n = 3;
|
|
4046
4094
|
break;
|
|
4047
4095
|
}
|
|
4048
4096
|
throw new TurnkeyError("Google Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
|
|
4049
4097
|
case 3:
|
|
4050
4098
|
if ((_masterConfig$auth31 = masterConfig.auth) !== null && _masterConfig$auth31 !== void 0 && (_masterConfig$auth31$ = _masterConfig$auth31.oauthConfig) !== null && _masterConfig$auth31$ !== void 0 && _masterConfig$auth31$.oauthRedirectUri) {
|
|
4051
|
-
|
|
4099
|
+
_context86.n = 4;
|
|
4052
4100
|
break;
|
|
4053
4101
|
}
|
|
4054
4102
|
throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
|
|
4055
4103
|
case 4:
|
|
4056
4104
|
flow = openInPage ? "redirect" : "popup";
|
|
4057
4105
|
redirectURI = (_masterConfig$auth32 = masterConfig.auth) === null || _masterConfig$auth32 === void 0 ? void 0 : _masterConfig$auth32.oauthConfig.oauthRedirectUri.replace(/\/$/, ""); // Create key pair and generate nonce
|
|
4058
|
-
|
|
4106
|
+
_context86.n = 5;
|
|
4059
4107
|
return createApiKeyPair();
|
|
4060
4108
|
case 5:
|
|
4061
|
-
publicKey =
|
|
4109
|
+
publicKey = _context86.v;
|
|
4062
4110
|
if (publicKey) {
|
|
4063
|
-
|
|
4111
|
+
_context86.n = 6;
|
|
4064
4112
|
break;
|
|
4065
4113
|
}
|
|
4066
4114
|
throw new Error("Failed to create public key for OAuth.");
|
|
@@ -4076,10 +4124,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4076
4124
|
// Create state parameter
|
|
4077
4125
|
state = "provider=google&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
|
|
4078
4126
|
if (additionalParameters) {
|
|
4079
|
-
additionalState = Object.entries(additionalParameters).map(function (
|
|
4080
|
-
var
|
|
4081
|
-
key =
|
|
4082
|
-
value =
|
|
4127
|
+
additionalState = Object.entries(additionalParameters).map(function (_ref103) {
|
|
4128
|
+
var _ref104 = _slicedToArray(_ref103, 2),
|
|
4129
|
+
key = _ref104[0],
|
|
4130
|
+
value = _ref104[1];
|
|
4083
4131
|
return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
|
|
4084
4132
|
}).join("&");
|
|
4085
4133
|
if (additionalState) {
|
|
@@ -4088,12 +4136,12 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4088
4136
|
}
|
|
4089
4137
|
googleAuthUrl.searchParams.set("state", state);
|
|
4090
4138
|
if (!openInPage) {
|
|
4091
|
-
|
|
4139
|
+
_context86.n = 7;
|
|
4092
4140
|
break;
|
|
4093
4141
|
}
|
|
4094
4142
|
// Redirect current page to Google Auth
|
|
4095
4143
|
window.location.href = googleAuthUrl.toString();
|
|
4096
|
-
return
|
|
4144
|
+
return _context86.a(2, new Promise(function (_, reject) {
|
|
4097
4145
|
// By here, the page should have already redirected. We wait here since the function is async.
|
|
4098
4146
|
// We want any function that runs this to simply wait until the page redirects.
|
|
4099
4147
|
// A 5 min timeout is set just in case, idk
|
|
@@ -4113,7 +4161,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4113
4161
|
top = window.screenY + (window.innerHeight - height) / 2;
|
|
4114
4162
|
authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
|
|
4115
4163
|
if (authWindow) {
|
|
4116
|
-
|
|
4164
|
+
_context86.n = 8;
|
|
4117
4165
|
break;
|
|
4118
4166
|
}
|
|
4119
4167
|
throw new Error("Failed to open Google login window.");
|
|
@@ -4121,7 +4169,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4121
4169
|
authWindow.location.href = googleAuthUrl.toString();
|
|
4122
4170
|
// Return a promise that resolves when the OAuth flow completes
|
|
4123
4171
|
// This following code will only run for the popup flow
|
|
4124
|
-
return
|
|
4172
|
+
return _context86.a(2, new Promise(function (resolve, reject) {
|
|
4125
4173
|
var interval = setInterval(function () {
|
|
4126
4174
|
try {
|
|
4127
4175
|
// Check if window was closed without completing auth
|
|
@@ -4181,44 +4229,44 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4181
4229
|
}
|
|
4182
4230
|
}));
|
|
4183
4231
|
case 9:
|
|
4184
|
-
|
|
4232
|
+
_context86.n = 11;
|
|
4185
4233
|
break;
|
|
4186
4234
|
case 10:
|
|
4187
|
-
|
|
4188
|
-
_t14 =
|
|
4235
|
+
_context86.p = 10;
|
|
4236
|
+
_t14 = _context86.v;
|
|
4189
4237
|
throw _t14;
|
|
4190
4238
|
case 11:
|
|
4191
|
-
return
|
|
4239
|
+
return _context86.a(2);
|
|
4192
4240
|
}
|
|
4193
|
-
},
|
|
4241
|
+
}, _callee86, null, [[1, 10]]);
|
|
4194
4242
|
}));
|
|
4195
|
-
return function (
|
|
4196
|
-
return
|
|
4243
|
+
return function (_x67) {
|
|
4244
|
+
return _ref101.apply(this, arguments);
|
|
4197
4245
|
};
|
|
4198
4246
|
}(), [callbacks, completeOauth, createApiKeyPair, masterConfig]);
|
|
4199
4247
|
var handleAppleOauth = useCallback(/*#__PURE__*/function () {
|
|
4200
|
-
var
|
|
4248
|
+
var _ref105 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee87(params) {
|
|
4201
4249
|
var _masterConfig$auth33, _masterConfig$auth33$, _masterConfig$auth$oa5, _masterConfig$auth34, _masterConfig$auth34$;
|
|
4202
|
-
var
|
|
4203
|
-
return _regenerator().w(function (
|
|
4204
|
-
while (1) switch (
|
|
4250
|
+
var _ref106, _ref106$clientId, clientId, _ref106$openInPage, openInPage, additionalParameters, _masterConfig$auth35, _masterConfig$auth35$, _masterConfig$auth36, flow, redirectURI, publicKey, nonce, appleAuthUrl, state, additionalState, width, height, left, top, authWindow, _t15;
|
|
4251
|
+
return _regenerator().w(function (_context87) {
|
|
4252
|
+
while (1) switch (_context87.p = _context87.n) {
|
|
4205
4253
|
case 0:
|
|
4206
|
-
|
|
4207
|
-
|
|
4254
|
+
_ref106 = params || {}, _ref106$clientId = _ref106.clientId, clientId = _ref106$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 : _ref106$clientId, _ref106$openInPage = _ref106.openInPage, openInPage = _ref106$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 : _ref106$openInPage, additionalParameters = _ref106.additionalState;
|
|
4255
|
+
_context87.p = 1;
|
|
4208
4256
|
if (masterConfig) {
|
|
4209
|
-
|
|
4257
|
+
_context87.n = 2;
|
|
4210
4258
|
break;
|
|
4211
4259
|
}
|
|
4212
4260
|
throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
|
|
4213
4261
|
case 2:
|
|
4214
4262
|
if (clientId) {
|
|
4215
|
-
|
|
4263
|
+
_context87.n = 3;
|
|
4216
4264
|
break;
|
|
4217
4265
|
}
|
|
4218
4266
|
throw new TurnkeyError("Apple Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
|
|
4219
4267
|
case 3:
|
|
4220
4268
|
if ((_masterConfig$auth35 = masterConfig.auth) !== null && _masterConfig$auth35 !== void 0 && (_masterConfig$auth35$ = _masterConfig$auth35.oauthConfig) !== null && _masterConfig$auth35$ !== void 0 && _masterConfig$auth35$.oauthRedirectUri) {
|
|
4221
|
-
|
|
4269
|
+
_context87.n = 4;
|
|
4222
4270
|
break;
|
|
4223
4271
|
}
|
|
4224
4272
|
throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
|
|
@@ -4226,12 +4274,12 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4226
4274
|
flow = openInPage ? "redirect" : "popup";
|
|
4227
4275
|
redirectURI = (_masterConfig$auth36 = masterConfig.auth) === null || _masterConfig$auth36 === void 0 ? void 0 : _masterConfig$auth36.oauthConfig.oauthRedirectUri; // TODO (Amir): Apple needs the '/' at the end. Maybe we should add it if not there?
|
|
4228
4276
|
// Create key pair and generate nonce
|
|
4229
|
-
|
|
4277
|
+
_context87.n = 5;
|
|
4230
4278
|
return createApiKeyPair();
|
|
4231
4279
|
case 5:
|
|
4232
|
-
publicKey =
|
|
4280
|
+
publicKey = _context87.v;
|
|
4233
4281
|
if (publicKey) {
|
|
4234
|
-
|
|
4282
|
+
_context87.n = 6;
|
|
4235
4283
|
break;
|
|
4236
4284
|
}
|
|
4237
4285
|
throw new Error("Failed to create public key for OAuth.");
|
|
@@ -4246,10 +4294,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4246
4294
|
// Create state parameter
|
|
4247
4295
|
state = "provider=apple&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
|
|
4248
4296
|
if (additionalParameters) {
|
|
4249
|
-
additionalState = Object.entries(additionalParameters).map(function (
|
|
4250
|
-
var
|
|
4251
|
-
key =
|
|
4252
|
-
value =
|
|
4297
|
+
additionalState = Object.entries(additionalParameters).map(function (_ref107) {
|
|
4298
|
+
var _ref108 = _slicedToArray(_ref107, 2),
|
|
4299
|
+
key = _ref108[0],
|
|
4300
|
+
value = _ref108[1];
|
|
4253
4301
|
return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
|
|
4254
4302
|
}).join("&");
|
|
4255
4303
|
if (additionalState) {
|
|
@@ -4258,12 +4306,12 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4258
4306
|
}
|
|
4259
4307
|
appleAuthUrl.searchParams.set("state", state);
|
|
4260
4308
|
if (!openInPage) {
|
|
4261
|
-
|
|
4309
|
+
_context87.n = 7;
|
|
4262
4310
|
break;
|
|
4263
4311
|
}
|
|
4264
4312
|
// Redirect current page to Apple Auth
|
|
4265
4313
|
window.location.href = appleAuthUrl.toString();
|
|
4266
|
-
return
|
|
4314
|
+
return _context87.a(2, new Promise(function (_, reject) {
|
|
4267
4315
|
// Set a timeout just in case the redirect doesn't happen
|
|
4268
4316
|
var timeout = setTimeout(function () {
|
|
4269
4317
|
reject(new Error("Authentication timed out."));
|
|
@@ -4281,14 +4329,14 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4281
4329
|
top = window.screenY + (window.innerHeight - height) / 2;
|
|
4282
4330
|
authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
|
|
4283
4331
|
if (authWindow) {
|
|
4284
|
-
|
|
4332
|
+
_context87.n = 8;
|
|
4285
4333
|
break;
|
|
4286
4334
|
}
|
|
4287
4335
|
throw new Error("Failed to open Apple login window.");
|
|
4288
4336
|
case 8:
|
|
4289
4337
|
authWindow.location.href = appleAuthUrl.toString();
|
|
4290
4338
|
// Return a promise that resolves when the OAuth flow completes
|
|
4291
|
-
return
|
|
4339
|
+
return _context87.a(2, new Promise(function (resolve, reject) {
|
|
4292
4340
|
var interval = setInterval(function () {
|
|
4293
4341
|
try {
|
|
4294
4342
|
// Check if window was closed without completing auth
|
|
@@ -4348,65 +4396,65 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4348
4396
|
}
|
|
4349
4397
|
}));
|
|
4350
4398
|
case 9:
|
|
4351
|
-
|
|
4399
|
+
_context87.n = 11;
|
|
4352
4400
|
break;
|
|
4353
4401
|
case 10:
|
|
4354
|
-
|
|
4355
|
-
_t15 =
|
|
4402
|
+
_context87.p = 10;
|
|
4403
|
+
_t15 = _context87.v;
|
|
4356
4404
|
throw _t15;
|
|
4357
4405
|
case 11:
|
|
4358
|
-
return
|
|
4406
|
+
return _context87.a(2);
|
|
4359
4407
|
}
|
|
4360
|
-
},
|
|
4408
|
+
}, _callee87, null, [[1, 10]]);
|
|
4361
4409
|
}));
|
|
4362
|
-
return function (
|
|
4363
|
-
return
|
|
4410
|
+
return function (_x68) {
|
|
4411
|
+
return _ref105.apply(this, arguments);
|
|
4364
4412
|
};
|
|
4365
4413
|
}(), [callbacks, completeOauth, createApiKeyPair, masterConfig]);
|
|
4366
4414
|
var handleFacebookOauth = useCallback(/*#__PURE__*/function () {
|
|
4367
|
-
var
|
|
4415
|
+
var _ref109 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee88(params) {
|
|
4368
4416
|
var _masterConfig$auth37, _masterConfig$auth37$, _masterConfig$auth$oa6, _masterConfig$auth38, _masterConfig$auth38$;
|
|
4369
|
-
var
|
|
4370
|
-
return _regenerator().w(function (
|
|
4371
|
-
while (1) switch (
|
|
4417
|
+
var _ref110, _ref110$clientId, clientId, _ref110$openInPage, openInPage, additionalParameters, _masterConfig$auth39, _masterConfig$auth39$, _masterConfig$auth40, flow, redirectURI, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, facebookAuthUrl, state, additionalState, width, height, left, top, authWindow, _t16;
|
|
4418
|
+
return _regenerator().w(function (_context88) {
|
|
4419
|
+
while (1) switch (_context88.p = _context88.n) {
|
|
4372
4420
|
case 0:
|
|
4373
|
-
|
|
4374
|
-
|
|
4421
|
+
_ref110 = params || {}, _ref110$clientId = _ref110.clientId, clientId = _ref110$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 : _ref110$clientId, _ref110$openInPage = _ref110.openInPage, openInPage = _ref110$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 : _ref110$openInPage, additionalParameters = _ref110.additionalState;
|
|
4422
|
+
_context88.p = 1;
|
|
4375
4423
|
if (masterConfig) {
|
|
4376
|
-
|
|
4424
|
+
_context88.n = 2;
|
|
4377
4425
|
break;
|
|
4378
4426
|
}
|
|
4379
4427
|
throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.INVALID_CONFIGURATION);
|
|
4380
4428
|
case 2:
|
|
4381
4429
|
if (clientId) {
|
|
4382
|
-
|
|
4430
|
+
_context88.n = 3;
|
|
4383
4431
|
break;
|
|
4384
4432
|
}
|
|
4385
4433
|
throw new TurnkeyError("Facebook Client ID is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
|
|
4386
4434
|
case 3:
|
|
4387
4435
|
if ((_masterConfig$auth39 = masterConfig.auth) !== null && _masterConfig$auth39 !== void 0 && (_masterConfig$auth39$ = _masterConfig$auth39.oauthConfig) !== null && _masterConfig$auth39$ !== void 0 && _masterConfig$auth39$.oauthRedirectUri) {
|
|
4388
|
-
|
|
4436
|
+
_context88.n = 4;
|
|
4389
4437
|
break;
|
|
4390
4438
|
}
|
|
4391
4439
|
throw new TurnkeyError("OAuth Redirect URI is not configured.", TurnkeyErrorCodes.INVALID_CONFIGURATION);
|
|
4392
4440
|
case 4:
|
|
4393
4441
|
flow = openInPage ? "redirect" : "popup";
|
|
4394
4442
|
redirectURI = (_masterConfig$auth40 = masterConfig.auth) === null || _masterConfig$auth40 === void 0 ? void 0 : _masterConfig$auth40.oauthConfig.oauthRedirectUri; // Create key pair and generate nonce
|
|
4395
|
-
|
|
4443
|
+
_context88.n = 5;
|
|
4396
4444
|
return createApiKeyPair();
|
|
4397
4445
|
case 5:
|
|
4398
|
-
publicKey =
|
|
4446
|
+
publicKey = _context88.v;
|
|
4399
4447
|
if (publicKey) {
|
|
4400
|
-
|
|
4448
|
+
_context88.n = 6;
|
|
4401
4449
|
break;
|
|
4402
4450
|
}
|
|
4403
4451
|
throw new Error("Failed to create public key for OAuth.");
|
|
4404
4452
|
case 6:
|
|
4405
4453
|
nonce = bytesToHex(sha256(publicKey)); // Generate PKCE challenge pair
|
|
4406
|
-
|
|
4454
|
+
_context88.n = 7;
|
|
4407
4455
|
return generateChallengePair();
|
|
4408
4456
|
case 7:
|
|
4409
|
-
_yield$generateChalle3 =
|
|
4457
|
+
_yield$generateChalle3 = _context88.v;
|
|
4410
4458
|
verifier = _yield$generateChalle3.verifier;
|
|
4411
4459
|
codeChallenge = _yield$generateChalle3.codeChallenge;
|
|
4412
4460
|
// Store verifier for later token exchange
|
|
@@ -4423,10 +4471,10 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4423
4471
|
// Create state parameter
|
|
4424
4472
|
state = "provider=facebook&flow=".concat(flow, "&publicKey=").concat(encodeURIComponent(publicKey));
|
|
4425
4473
|
if (additionalParameters) {
|
|
4426
|
-
additionalState = Object.entries(additionalParameters).map(function (
|
|
4427
|
-
var
|
|
4428
|
-
key =
|
|
4429
|
-
value =
|
|
4474
|
+
additionalState = Object.entries(additionalParameters).map(function (_ref111) {
|
|
4475
|
+
var _ref112 = _slicedToArray(_ref111, 2),
|
|
4476
|
+
key = _ref112[0],
|
|
4477
|
+
value = _ref112[1];
|
|
4430
4478
|
return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
|
|
4431
4479
|
}).join("&");
|
|
4432
4480
|
if (additionalState) {
|
|
@@ -4435,12 +4483,12 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4435
4483
|
}
|
|
4436
4484
|
facebookAuthUrl.searchParams.set("state", state);
|
|
4437
4485
|
if (!openInPage) {
|
|
4438
|
-
|
|
4486
|
+
_context88.n = 8;
|
|
4439
4487
|
break;
|
|
4440
4488
|
}
|
|
4441
4489
|
// Redirect current page to Facebook Auth
|
|
4442
4490
|
window.location.href = facebookAuthUrl.toString();
|
|
4443
|
-
return
|
|
4491
|
+
return _context88.a(2, new Promise(function (_, reject) {
|
|
4444
4492
|
// Set a timeout just in case the redirect doesn't happen
|
|
4445
4493
|
var timeout = setTimeout(function () {
|
|
4446
4494
|
reject(new Error("Authentication timed out."));
|
|
@@ -4458,14 +4506,14 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4458
4506
|
top = window.screenY + (window.innerHeight - height) / 2;
|
|
4459
4507
|
authWindow = window.open("about:blank", "_blank", "width=".concat(width, ",height=").concat(height, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
|
|
4460
4508
|
if (authWindow) {
|
|
4461
|
-
|
|
4509
|
+
_context88.n = 9;
|
|
4462
4510
|
break;
|
|
4463
4511
|
}
|
|
4464
4512
|
throw new Error("Failed to open Facebook login window.");
|
|
4465
4513
|
case 9:
|
|
4466
4514
|
authWindow.location.href = facebookAuthUrl.toString();
|
|
4467
4515
|
// Return a promise that resolves when the OAuth flow completes
|
|
4468
|
-
return
|
|
4516
|
+
return _context88.a(2, new Promise(function (resolve, reject) {
|
|
4469
4517
|
var interval = setInterval(function () {
|
|
4470
4518
|
try {
|
|
4471
4519
|
// Check if window was closed without completing auth
|
|
@@ -4534,27 +4582,27 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4534
4582
|
}
|
|
4535
4583
|
}));
|
|
4536
4584
|
case 10:
|
|
4537
|
-
|
|
4585
|
+
_context88.n = 12;
|
|
4538
4586
|
break;
|
|
4539
4587
|
case 11:
|
|
4540
|
-
|
|
4541
|
-
_t16 =
|
|
4588
|
+
_context88.p = 11;
|
|
4589
|
+
_t16 = _context88.v;
|
|
4542
4590
|
throw _t16;
|
|
4543
4591
|
case 12:
|
|
4544
|
-
return
|
|
4592
|
+
return _context88.a(2);
|
|
4545
4593
|
}
|
|
4546
|
-
},
|
|
4594
|
+
}, _callee88, null, [[1, 11]]);
|
|
4547
4595
|
}));
|
|
4548
|
-
return function (
|
|
4549
|
-
return
|
|
4596
|
+
return function (_x69) {
|
|
4597
|
+
return _ref109.apply(this, arguments);
|
|
4550
4598
|
};
|
|
4551
4599
|
}(), [callbacks, completeOauth, createApiKeyPair, masterConfig]);
|
|
4552
4600
|
var handleLogin = useCallback(/*#__PURE__*/function () {
|
|
4553
|
-
var
|
|
4601
|
+
var _ref113 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee89(params) {
|
|
4554
4602
|
var _masterConfig$ui, _params$logoDark, _masterConfig$ui2, _params$logoLight, _masterConfig$ui3, _params$title;
|
|
4555
4603
|
var logo;
|
|
4556
|
-
return _regenerator().w(function (
|
|
4557
|
-
while (1) switch (
|
|
4604
|
+
return _regenerator().w(function (_context89) {
|
|
4605
|
+
while (1) switch (_context89.n) {
|
|
4558
4606
|
case 0:
|
|
4559
4607
|
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;
|
|
4560
4608
|
pushPage({
|
|
@@ -4568,22 +4616,22 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4568
4616
|
showTitle: logo ? false : true
|
|
4569
4617
|
});
|
|
4570
4618
|
case 1:
|
|
4571
|
-
return
|
|
4619
|
+
return _context89.a(2);
|
|
4572
4620
|
}
|
|
4573
|
-
},
|
|
4621
|
+
}, _callee89);
|
|
4574
4622
|
}));
|
|
4575
|
-
return function (
|
|
4576
|
-
return
|
|
4623
|
+
return function (_x70) {
|
|
4624
|
+
return _ref113.apply(this, arguments);
|
|
4577
4625
|
};
|
|
4578
4626
|
}(), [pushPage, masterConfig]);
|
|
4579
4627
|
var handleExportWallet = useCallback(/*#__PURE__*/function () {
|
|
4580
|
-
var
|
|
4628
|
+
var _ref114 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee90(params) {
|
|
4581
4629
|
var walletId, targetPublicKey, stampWith, organizationId;
|
|
4582
|
-
return _regenerator().w(function (
|
|
4583
|
-
while (1) switch (
|
|
4630
|
+
return _regenerator().w(function (_context90) {
|
|
4631
|
+
while (1) switch (_context90.n) {
|
|
4584
4632
|
case 0:
|
|
4585
4633
|
walletId = params.walletId, targetPublicKey = params.targetPublicKey, stampWith = params.stampWith, organizationId = params.organizationId;
|
|
4586
|
-
return
|
|
4634
|
+
return _context90.a(2, new Promise(function (resolve, reject) {
|
|
4587
4635
|
return pushPage({
|
|
4588
4636
|
key: "Export wallet",
|
|
4589
4637
|
content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
@@ -4609,20 +4657,20 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4609
4657
|
});
|
|
4610
4658
|
}));
|
|
4611
4659
|
}
|
|
4612
|
-
},
|
|
4660
|
+
}, _callee90);
|
|
4613
4661
|
}));
|
|
4614
|
-
return function (
|
|
4615
|
-
return
|
|
4662
|
+
return function (_x71) {
|
|
4663
|
+
return _ref114.apply(this, arguments);
|
|
4616
4664
|
};
|
|
4617
4665
|
}(), [pushPage]);
|
|
4618
4666
|
var handleExportPrivateKey = useCallback(/*#__PURE__*/function () {
|
|
4619
|
-
var
|
|
4667
|
+
var _ref115 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(params) {
|
|
4620
4668
|
var privateKeyId, targetPublicKey, keyFormat, stampWith, organizationId;
|
|
4621
|
-
return _regenerator().w(function (
|
|
4622
|
-
while (1) switch (
|
|
4669
|
+
return _regenerator().w(function (_context91) {
|
|
4670
|
+
while (1) switch (_context91.n) {
|
|
4623
4671
|
case 0:
|
|
4624
4672
|
privateKeyId = params.privateKeyId, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith, organizationId = params.organizationId;
|
|
4625
|
-
return
|
|
4673
|
+
return _context91.a(2, new Promise(function (resolve, reject) {
|
|
4626
4674
|
return pushPage({
|
|
4627
4675
|
key: "Export private key",
|
|
4628
4676
|
content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
@@ -4650,20 +4698,20 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4650
4698
|
});
|
|
4651
4699
|
}));
|
|
4652
4700
|
}
|
|
4653
|
-
},
|
|
4701
|
+
}, _callee91);
|
|
4654
4702
|
}));
|
|
4655
|
-
return function (
|
|
4656
|
-
return
|
|
4703
|
+
return function (_x72) {
|
|
4704
|
+
return _ref115.apply(this, arguments);
|
|
4657
4705
|
};
|
|
4658
4706
|
}(), [pushPage]);
|
|
4659
4707
|
var handleExportWalletAccount = useCallback(/*#__PURE__*/function () {
|
|
4660
|
-
var
|
|
4708
|
+
var _ref116 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee92(params) {
|
|
4661
4709
|
var address, targetPublicKey, keyFormat, stampWith, organizationId;
|
|
4662
|
-
return _regenerator().w(function (
|
|
4663
|
-
while (1) switch (
|
|
4710
|
+
return _regenerator().w(function (_context92) {
|
|
4711
|
+
while (1) switch (_context92.n) {
|
|
4664
4712
|
case 0:
|
|
4665
4713
|
address = params.address, targetPublicKey = params.targetPublicKey, keyFormat = params.keyFormat, stampWith = params.stampWith, organizationId = params.organizationId;
|
|
4666
|
-
return
|
|
4714
|
+
return _context92.a(2, new Promise(function (resolve, reject) {
|
|
4667
4715
|
return pushPage({
|
|
4668
4716
|
key: "Export wallet account",
|
|
4669
4717
|
content: jsx(ExportComponent, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
@@ -4691,21 +4739,21 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4691
4739
|
});
|
|
4692
4740
|
}));
|
|
4693
4741
|
}
|
|
4694
|
-
},
|
|
4742
|
+
}, _callee92);
|
|
4695
4743
|
}));
|
|
4696
|
-
return function (
|
|
4697
|
-
return
|
|
4744
|
+
return function (_x73) {
|
|
4745
|
+
return _ref116.apply(this, arguments);
|
|
4698
4746
|
};
|
|
4699
4747
|
}(), [pushPage]);
|
|
4700
4748
|
var handleImportWallet = useCallback(/*#__PURE__*/function () {
|
|
4701
|
-
var
|
|
4702
|
-
var
|
|
4703
|
-
return _regenerator().w(function (
|
|
4704
|
-
while (1) switch (
|
|
4749
|
+
var _ref117 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(params) {
|
|
4750
|
+
var _ref118, defaultWalletAccounts, _ref118$successPageDu, successPageDuration, stampWith, walletName, clearClipboardOnPaste, organizationId, userId, _t17;
|
|
4751
|
+
return _regenerator().w(function (_context93) {
|
|
4752
|
+
while (1) switch (_context93.p = _context93.n) {
|
|
4705
4753
|
case 0:
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
return
|
|
4754
|
+
_ref118 = params || {}, defaultWalletAccounts = _ref118.defaultWalletAccounts, _ref118$successPageDu = _ref118.successPageDuration, successPageDuration = _ref118$successPageDu === void 0 ? 2000 : _ref118$successPageDu, stampWith = _ref118.stampWith, walletName = _ref118.walletName, clearClipboardOnPaste = _ref118.clearClipboardOnPaste, organizationId = _ref118.organizationId, userId = _ref118.userId;
|
|
4755
|
+
_context93.p = 1;
|
|
4756
|
+
return _context93.a(2, withTurnkeyErrorHandling(function () {
|
|
4709
4757
|
return new Promise(function (resolve, reject) {
|
|
4710
4758
|
return pushPage({
|
|
4711
4759
|
key: "Import wallet",
|
|
@@ -4738,33 +4786,33 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4738
4786
|
return logout();
|
|
4739
4787
|
}));
|
|
4740
4788
|
case 2:
|
|
4741
|
-
|
|
4742
|
-
_t17 =
|
|
4789
|
+
_context93.p = 2;
|
|
4790
|
+
_t17 = _context93.v;
|
|
4743
4791
|
if (!(_t17 instanceof TurnkeyError)) {
|
|
4744
|
-
|
|
4792
|
+
_context93.n = 3;
|
|
4745
4793
|
break;
|
|
4746
4794
|
}
|
|
4747
4795
|
throw _t17;
|
|
4748
4796
|
case 3:
|
|
4749
4797
|
throw new TurnkeyError("Failed to import wallet.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t17);
|
|
4750
4798
|
case 4:
|
|
4751
|
-
return
|
|
4799
|
+
return _context93.a(2);
|
|
4752
4800
|
}
|
|
4753
|
-
},
|
|
4801
|
+
}, _callee93, null, [[1, 2]]);
|
|
4754
4802
|
}));
|
|
4755
|
-
return function (
|
|
4756
|
-
return
|
|
4803
|
+
return function (_x74) {
|
|
4804
|
+
return _ref117.apply(this, arguments);
|
|
4757
4805
|
};
|
|
4758
4806
|
}(), [pushPage, logout]);
|
|
4759
4807
|
var handleImportPrivateKey = useCallback(/*#__PURE__*/function () {
|
|
4760
|
-
var
|
|
4761
|
-
var
|
|
4762
|
-
return _regenerator().w(function (
|
|
4763
|
-
while (1) switch (
|
|
4808
|
+
var _ref119 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(params) {
|
|
4809
|
+
var _ref120, curve, addressFormats, _ref120$successPageDu, successPageDuration, stampWith, keyName, clearClipboardOnPaste, organizationId, _t18;
|
|
4810
|
+
return _regenerator().w(function (_context94) {
|
|
4811
|
+
while (1) switch (_context94.p = _context94.n) {
|
|
4764
4812
|
case 0:
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
return
|
|
4813
|
+
_ref120 = params || {}, curve = _ref120.curve, addressFormats = _ref120.addressFormats, _ref120$successPageDu = _ref120.successPageDuration, successPageDuration = _ref120$successPageDu === void 0 ? 2000 : _ref120$successPageDu, stampWith = _ref120.stampWith, keyName = _ref120.keyName, clearClipboardOnPaste = _ref120.clearClipboardOnPaste, organizationId = _ref120.organizationId;
|
|
4814
|
+
_context94.p = 1;
|
|
4815
|
+
return _context94.a(2, withTurnkeyErrorHandling(function () {
|
|
4768
4816
|
return new Promise(function (resolve, reject) {
|
|
4769
4817
|
return pushPage({
|
|
4770
4818
|
key: "Import private key",
|
|
@@ -4795,51 +4843,51 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4795
4843
|
return logout();
|
|
4796
4844
|
}));
|
|
4797
4845
|
case 2:
|
|
4798
|
-
|
|
4799
|
-
_t18 =
|
|
4846
|
+
_context94.p = 2;
|
|
4847
|
+
_t18 = _context94.v;
|
|
4800
4848
|
if (!(_t18 instanceof TurnkeyError)) {
|
|
4801
|
-
|
|
4849
|
+
_context94.n = 3;
|
|
4802
4850
|
break;
|
|
4803
4851
|
}
|
|
4804
4852
|
throw _t18;
|
|
4805
4853
|
case 3:
|
|
4806
4854
|
throw new TurnkeyError("Failed to import private key.", TurnkeyErrorCodes.IMPORT_WALLET_ERROR, _t18);
|
|
4807
4855
|
case 4:
|
|
4808
|
-
return
|
|
4856
|
+
return _context94.a(2);
|
|
4809
4857
|
}
|
|
4810
|
-
},
|
|
4858
|
+
}, _callee94, null, [[1, 2]]);
|
|
4811
4859
|
}));
|
|
4812
|
-
return function (
|
|
4813
|
-
return
|
|
4860
|
+
return function (_x75) {
|
|
4861
|
+
return _ref119.apply(this, arguments);
|
|
4814
4862
|
};
|
|
4815
4863
|
}(), [pushPage, logout]);
|
|
4816
4864
|
var handleUpdateUserName = useCallback(/*#__PURE__*/function () {
|
|
4817
|
-
var
|
|
4818
|
-
var
|
|
4819
|
-
return _regenerator().w(function (
|
|
4820
|
-
while (1) switch (
|
|
4865
|
+
var _ref121 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(params) {
|
|
4866
|
+
var _ref122, _ref122$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, _params$userId, res, _t19;
|
|
4867
|
+
return _regenerator().w(function (_context95) {
|
|
4868
|
+
while (1) switch (_context95.p = _context95.n) {
|
|
4821
4869
|
case 0:
|
|
4822
|
-
|
|
4870
|
+
_ref122 = params || {}, _ref122$successPageDu = _ref122.successPageDuration, successPageDuration = _ref122$successPageDu === void 0 ? 2000 : _ref122$successPageDu, subTitle = _ref122.subTitle, title = _ref122.title, stampWith = _ref122.stampWith;
|
|
4823
4871
|
if (client) {
|
|
4824
|
-
|
|
4872
|
+
_context95.n = 1;
|
|
4825
4873
|
break;
|
|
4826
4874
|
}
|
|
4827
4875
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
4828
4876
|
case 1:
|
|
4829
|
-
|
|
4877
|
+
_context95.n = 2;
|
|
4830
4878
|
return getSession();
|
|
4831
4879
|
case 2:
|
|
4832
|
-
s =
|
|
4880
|
+
s = _context95.v;
|
|
4833
4881
|
organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
|
|
4834
4882
|
if (organizationId) {
|
|
4835
|
-
|
|
4883
|
+
_context95.n = 3;
|
|
4836
4884
|
break;
|
|
4837
4885
|
}
|
|
4838
4886
|
throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
4839
4887
|
case 3:
|
|
4840
4888
|
userId = (params === null || params === void 0 ? void 0 : params.userId) || (user === null || user === void 0 ? void 0 : user.userId);
|
|
4841
4889
|
if (userId) {
|
|
4842
|
-
|
|
4890
|
+
_context95.n = 4;
|
|
4843
4891
|
break;
|
|
4844
4892
|
}
|
|
4845
4893
|
throw new TurnkeyError("A user ID is required to update a user name.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
@@ -4859,12 +4907,12 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4859
4907
|
showTitle: false
|
|
4860
4908
|
});
|
|
4861
4909
|
};
|
|
4862
|
-
|
|
4910
|
+
_context95.p = 5;
|
|
4863
4911
|
if (!(!(params !== null && params !== void 0 && params.userName) && (params === null || params === void 0 ? void 0 : params.userName) !== "")) {
|
|
4864
|
-
|
|
4912
|
+
_context95.n = 6;
|
|
4865
4913
|
break;
|
|
4866
4914
|
}
|
|
4867
|
-
return
|
|
4915
|
+
return _context95.a(2, withTurnkeyErrorHandling(function () {
|
|
4868
4916
|
return new Promise(function (resolve, reject) {
|
|
4869
4917
|
pushPage({
|
|
4870
4918
|
key: "Update User Name",
|
|
@@ -4892,7 +4940,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4892
4940
|
return logout();
|
|
4893
4941
|
}));
|
|
4894
4942
|
case 6:
|
|
4895
|
-
|
|
4943
|
+
_context95.n = 7;
|
|
4896
4944
|
return updateUserName(_objectSpread2({
|
|
4897
4945
|
userName: params.userName,
|
|
4898
4946
|
userId: (_params$userId = params.userId) !== null && _params$userId !== void 0 ? _params$userId : user.userId,
|
|
@@ -4901,71 +4949,71 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4901
4949
|
organizationId: organizationId
|
|
4902
4950
|
}));
|
|
4903
4951
|
case 7:
|
|
4904
|
-
res =
|
|
4952
|
+
res = _context95.v;
|
|
4905
4953
|
onSuccess();
|
|
4906
|
-
return
|
|
4954
|
+
return _context95.a(2, res);
|
|
4907
4955
|
case 8:
|
|
4908
|
-
|
|
4956
|
+
_context95.n = 11;
|
|
4909
4957
|
break;
|
|
4910
4958
|
case 9:
|
|
4911
|
-
|
|
4912
|
-
_t19 =
|
|
4959
|
+
_context95.p = 9;
|
|
4960
|
+
_t19 = _context95.v;
|
|
4913
4961
|
if (!(_t19 instanceof TurnkeyError)) {
|
|
4914
|
-
|
|
4962
|
+
_context95.n = 10;
|
|
4915
4963
|
break;
|
|
4916
4964
|
}
|
|
4917
4965
|
throw _t19;
|
|
4918
4966
|
case 10:
|
|
4919
4967
|
throw new TurnkeyError("Failed to update user name.", TurnkeyErrorCodes.UPDATE_USER_NAME_ERROR, _t19);
|
|
4920
4968
|
case 11:
|
|
4921
|
-
return
|
|
4969
|
+
return _context95.a(2);
|
|
4922
4970
|
}
|
|
4923
|
-
},
|
|
4971
|
+
}, _callee95, null, [[5, 9]]);
|
|
4924
4972
|
}));
|
|
4925
|
-
return function (
|
|
4926
|
-
return
|
|
4973
|
+
return function (_x76) {
|
|
4974
|
+
return _ref121.apply(this, arguments);
|
|
4927
4975
|
};
|
|
4928
4976
|
}(), [client, getSession, user, pushPage, closeModal, updateUserName, logout]);
|
|
4929
4977
|
var handleUpdateUserPhoneNumber = useCallback(/*#__PURE__*/function () {
|
|
4930
|
-
var
|
|
4978
|
+
var _ref123 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(params) {
|
|
4931
4979
|
var _masterConfig$auth41, _masterConfig$auth41$;
|
|
4932
|
-
var
|
|
4933
|
-
return _regenerator().w(function (
|
|
4934
|
-
while (1) switch (
|
|
4980
|
+
var _ref124, _ref124$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t21;
|
|
4981
|
+
return _regenerator().w(function (_context97) {
|
|
4982
|
+
while (1) switch (_context97.p = _context97.n) {
|
|
4935
4983
|
case 0:
|
|
4936
|
-
|
|
4984
|
+
_ref124 = params || {}, _ref124$successPageDu = _ref124.successPageDuration, successPageDuration = _ref124$successPageDu === void 0 ? 2000 : _ref124$successPageDu, subTitle = _ref124.subTitle, title = _ref124.title, stampWith = _ref124.stampWith;
|
|
4937
4985
|
if (client) {
|
|
4938
|
-
|
|
4986
|
+
_context97.n = 1;
|
|
4939
4987
|
break;
|
|
4940
4988
|
}
|
|
4941
4989
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
4942
4990
|
case 1:
|
|
4943
4991
|
if (masterConfig) {
|
|
4944
|
-
|
|
4992
|
+
_context97.n = 2;
|
|
4945
4993
|
break;
|
|
4946
4994
|
}
|
|
4947
4995
|
throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
|
|
4948
4996
|
case 2:
|
|
4949
4997
|
if ((_masterConfig$auth41 = masterConfig.auth) !== null && _masterConfig$auth41 !== void 0 && (_masterConfig$auth41$ = _masterConfig$auth41.methods) !== null && _masterConfig$auth41$ !== void 0 && _masterConfig$auth41$.smsOtpAuthEnabled) {
|
|
4950
|
-
|
|
4998
|
+
_context97.n = 3;
|
|
4951
4999
|
break;
|
|
4952
5000
|
}
|
|
4953
5001
|
throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
|
|
4954
5002
|
case 3:
|
|
4955
|
-
|
|
5003
|
+
_context97.n = 4;
|
|
4956
5004
|
return getSession();
|
|
4957
5005
|
case 4:
|
|
4958
|
-
s =
|
|
5006
|
+
s = _context97.v;
|
|
4959
5007
|
organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
|
|
4960
5008
|
if (organizationId) {
|
|
4961
|
-
|
|
5009
|
+
_context97.n = 5;
|
|
4962
5010
|
break;
|
|
4963
5011
|
}
|
|
4964
5012
|
throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
4965
5013
|
case 5:
|
|
4966
5014
|
userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
|
|
4967
5015
|
if (userId) {
|
|
4968
|
-
|
|
5016
|
+
_context97.n = 6;
|
|
4969
5017
|
break;
|
|
4970
5018
|
}
|
|
4971
5019
|
throw new TurnkeyError("A user ID is required to update a phone number.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
@@ -4985,12 +5033,12 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
4985
5033
|
showTitle: false
|
|
4986
5034
|
});
|
|
4987
5035
|
};
|
|
4988
|
-
|
|
5036
|
+
_context97.p = 7;
|
|
4989
5037
|
if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
|
|
4990
|
-
|
|
5038
|
+
_context97.n = 8;
|
|
4991
5039
|
break;
|
|
4992
5040
|
}
|
|
4993
|
-
return
|
|
5041
|
+
return _context97.a(2, withTurnkeyErrorHandling(function () {
|
|
4994
5042
|
return new Promise(function (resolve, reject) {
|
|
4995
5043
|
pushPage({
|
|
4996
5044
|
key: "Update Phone Number",
|
|
@@ -5018,14 +5066,14 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5018
5066
|
return logout();
|
|
5019
5067
|
}));
|
|
5020
5068
|
case 8:
|
|
5021
|
-
|
|
5069
|
+
_context97.n = 9;
|
|
5022
5070
|
return initOtp({
|
|
5023
5071
|
otpType: OtpType.Sms,
|
|
5024
5072
|
contact: params.phoneNumber
|
|
5025
5073
|
});
|
|
5026
5074
|
case 9:
|
|
5027
|
-
otpId =
|
|
5028
|
-
return
|
|
5075
|
+
otpId = _context97.v;
|
|
5076
|
+
return _context97.a(2, withTurnkeyErrorHandling(function () {
|
|
5029
5077
|
return new Promise(function (resolve, reject) {
|
|
5030
5078
|
var _masterConfig$auth42, _masterConfig$auth43;
|
|
5031
5079
|
pushPage({
|
|
@@ -5037,13 +5085,13 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5037
5085
|
otpLength: ((_masterConfig$auth42 = masterConfig.auth) === null || _masterConfig$auth42 === void 0 ? void 0 : _masterConfig$auth42.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
|
|
5038
5086
|
alphanumeric: (_masterConfig$auth43 = masterConfig.auth) === null || _masterConfig$auth43 === void 0 ? void 0 : _masterConfig$auth43.otpAlphanumeric,
|
|
5039
5087
|
onContinue: function () {
|
|
5040
|
-
var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
5088
|
+
var _onContinue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(otpCode) {
|
|
5041
5089
|
var _yield$verifyOtp, verificationToken, res, _t20;
|
|
5042
|
-
return _regenerator().w(function (
|
|
5043
|
-
while (1) switch (
|
|
5090
|
+
return _regenerator().w(function (_context96) {
|
|
5091
|
+
while (1) switch (_context96.p = _context96.n) {
|
|
5044
5092
|
case 0:
|
|
5045
|
-
|
|
5046
|
-
|
|
5093
|
+
_context96.p = 0;
|
|
5094
|
+
_context96.n = 1;
|
|
5047
5095
|
return verifyOtp({
|
|
5048
5096
|
otpId: otpId,
|
|
5049
5097
|
otpCode: otpCode,
|
|
@@ -5051,9 +5099,9 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5051
5099
|
otpType: OtpType.Sms
|
|
5052
5100
|
});
|
|
5053
5101
|
case 1:
|
|
5054
|
-
_yield$verifyOtp =
|
|
5102
|
+
_yield$verifyOtp = _context96.v;
|
|
5055
5103
|
verificationToken = _yield$verifyOtp.verificationToken;
|
|
5056
|
-
|
|
5104
|
+
_context96.n = 2;
|
|
5057
5105
|
return updateUserPhoneNumber(_objectSpread2({
|
|
5058
5106
|
phoneNumber: params.phoneNumber,
|
|
5059
5107
|
verificationToken: verificationToken,
|
|
@@ -5063,21 +5111,21 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5063
5111
|
stampWith: stampWith
|
|
5064
5112
|
}));
|
|
5065
5113
|
case 2:
|
|
5066
|
-
res =
|
|
5114
|
+
res = _context96.v;
|
|
5067
5115
|
onSuccess();
|
|
5068
5116
|
resolve(res);
|
|
5069
|
-
|
|
5117
|
+
_context96.n = 4;
|
|
5070
5118
|
break;
|
|
5071
5119
|
case 3:
|
|
5072
|
-
|
|
5073
|
-
_t20 =
|
|
5120
|
+
_context96.p = 3;
|
|
5121
|
+
_t20 = _context96.v;
|
|
5074
5122
|
reject(_t20);
|
|
5075
5123
|
case 4:
|
|
5076
|
-
return
|
|
5124
|
+
return _context96.a(2);
|
|
5077
5125
|
}
|
|
5078
|
-
},
|
|
5126
|
+
}, _callee96, null, [[0, 3]]);
|
|
5079
5127
|
}));
|
|
5080
|
-
function onContinue(
|
|
5128
|
+
function onContinue(_x78) {
|
|
5081
5129
|
return _onContinue.apply(this, arguments);
|
|
5082
5130
|
}
|
|
5083
5131
|
return onContinue;
|
|
@@ -5096,54 +5144,54 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5096
5144
|
return logout();
|
|
5097
5145
|
}, callbacks, "Failed to update phone number"));
|
|
5098
5146
|
case 10:
|
|
5099
|
-
|
|
5147
|
+
_context97.n = 13;
|
|
5100
5148
|
break;
|
|
5101
5149
|
case 11:
|
|
5102
|
-
|
|
5103
|
-
_t21 =
|
|
5150
|
+
_context97.p = 11;
|
|
5151
|
+
_t21 = _context97.v;
|
|
5104
5152
|
if (!(_t21 instanceof TurnkeyError)) {
|
|
5105
|
-
|
|
5153
|
+
_context97.n = 12;
|
|
5106
5154
|
break;
|
|
5107
5155
|
}
|
|
5108
5156
|
throw _t21;
|
|
5109
5157
|
case 12:
|
|
5110
5158
|
throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t21);
|
|
5111
5159
|
case 13:
|
|
5112
|
-
return
|
|
5160
|
+
return _context97.a(2);
|
|
5113
5161
|
}
|
|
5114
|
-
},
|
|
5162
|
+
}, _callee97, null, [[7, 11]]);
|
|
5115
5163
|
}));
|
|
5116
|
-
return function (
|
|
5117
|
-
return
|
|
5164
|
+
return function (_x77) {
|
|
5165
|
+
return _ref123.apply(this, arguments);
|
|
5118
5166
|
};
|
|
5119
5167
|
}(), [client, masterConfig, getSession, pushPage, closeModal, logout, initOtp, verifyOtp, updateUserPhoneNumber, user, callbacks]);
|
|
5120
5168
|
var handleUpdateUserEmail = useCallback(/*#__PURE__*/function () {
|
|
5121
|
-
var
|
|
5122
|
-
var
|
|
5123
|
-
return _regenerator().w(function (
|
|
5124
|
-
while (1) switch (
|
|
5169
|
+
var _ref125 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99(params) {
|
|
5170
|
+
var _ref126, _ref126$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t23;
|
|
5171
|
+
return _regenerator().w(function (_context99) {
|
|
5172
|
+
while (1) switch (_context99.p = _context99.n) {
|
|
5125
5173
|
case 0:
|
|
5126
|
-
|
|
5174
|
+
_ref126 = params || {}, _ref126$successPageDu = _ref126.successPageDuration, successPageDuration = _ref126$successPageDu === void 0 ? 2000 : _ref126$successPageDu, subTitle = _ref126.subTitle, title = _ref126.title, stampWith = _ref126.stampWith;
|
|
5127
5175
|
if (client) {
|
|
5128
|
-
|
|
5176
|
+
_context99.n = 1;
|
|
5129
5177
|
break;
|
|
5130
5178
|
}
|
|
5131
5179
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
5132
5180
|
case 1:
|
|
5133
|
-
|
|
5181
|
+
_context99.n = 2;
|
|
5134
5182
|
return getSession();
|
|
5135
5183
|
case 2:
|
|
5136
|
-
s =
|
|
5184
|
+
s = _context99.v;
|
|
5137
5185
|
organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
|
|
5138
5186
|
if (organizationId) {
|
|
5139
|
-
|
|
5187
|
+
_context99.n = 3;
|
|
5140
5188
|
break;
|
|
5141
5189
|
}
|
|
5142
5190
|
throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
5143
5191
|
case 3:
|
|
5144
5192
|
userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
|
|
5145
5193
|
if (userId) {
|
|
5146
|
-
|
|
5194
|
+
_context99.n = 4;
|
|
5147
5195
|
break;
|
|
5148
5196
|
}
|
|
5149
5197
|
throw new TurnkeyError("A user ID is required to update an email.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
@@ -5163,12 +5211,12 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5163
5211
|
showTitle: false
|
|
5164
5212
|
});
|
|
5165
5213
|
};
|
|
5166
|
-
|
|
5214
|
+
_context99.p = 5;
|
|
5167
5215
|
if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
|
|
5168
|
-
|
|
5216
|
+
_context99.n = 6;
|
|
5169
5217
|
break;
|
|
5170
5218
|
}
|
|
5171
|
-
return
|
|
5219
|
+
return _context99.a(2, withTurnkeyErrorHandling(function () {
|
|
5172
5220
|
return new Promise(function (resolve, reject) {
|
|
5173
5221
|
pushPage({
|
|
5174
5222
|
key: "Update Email",
|
|
@@ -5196,14 +5244,14 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5196
5244
|
return logout();
|
|
5197
5245
|
}));
|
|
5198
5246
|
case 6:
|
|
5199
|
-
|
|
5247
|
+
_context99.n = 7;
|
|
5200
5248
|
return initOtp({
|
|
5201
5249
|
otpType: OtpType.Email,
|
|
5202
5250
|
contact: params.email
|
|
5203
5251
|
});
|
|
5204
5252
|
case 7:
|
|
5205
|
-
otpId =
|
|
5206
|
-
return
|
|
5253
|
+
otpId = _context99.v;
|
|
5254
|
+
return _context99.a(2, withTurnkeyErrorHandling(function () {
|
|
5207
5255
|
return new Promise(function (resolve, reject) {
|
|
5208
5256
|
var _masterConfig$auth44, _masterConfig$auth45;
|
|
5209
5257
|
pushPage({
|
|
@@ -5215,13 +5263,13 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5215
5263
|
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,
|
|
5216
5264
|
alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth45 = masterConfig.auth) === null || _masterConfig$auth45 === void 0 ? void 0 : _masterConfig$auth45.otpAlphanumeric,
|
|
5217
5265
|
onContinue: function () {
|
|
5218
|
-
var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
5266
|
+
var _onContinue2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(otpCode) {
|
|
5219
5267
|
var _yield$verifyOtp2, verificationToken, res, _t22;
|
|
5220
|
-
return _regenerator().w(function (
|
|
5221
|
-
while (1) switch (
|
|
5268
|
+
return _regenerator().w(function (_context98) {
|
|
5269
|
+
while (1) switch (_context98.p = _context98.n) {
|
|
5222
5270
|
case 0:
|
|
5223
|
-
|
|
5224
|
-
|
|
5271
|
+
_context98.p = 0;
|
|
5272
|
+
_context98.n = 1;
|
|
5225
5273
|
return verifyOtp({
|
|
5226
5274
|
otpId: otpId,
|
|
5227
5275
|
otpCode: otpCode,
|
|
@@ -5229,9 +5277,9 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5229
5277
|
otpType: OtpType.Email
|
|
5230
5278
|
});
|
|
5231
5279
|
case 1:
|
|
5232
|
-
_yield$verifyOtp2 =
|
|
5280
|
+
_yield$verifyOtp2 = _context98.v;
|
|
5233
5281
|
verificationToken = _yield$verifyOtp2.verificationToken;
|
|
5234
|
-
|
|
5282
|
+
_context98.n = 2;
|
|
5235
5283
|
return updateUserEmail(_objectSpread2({
|
|
5236
5284
|
email: params.email,
|
|
5237
5285
|
verificationToken: verificationToken,
|
|
@@ -5241,21 +5289,21 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5241
5289
|
stampWith: stampWith
|
|
5242
5290
|
}));
|
|
5243
5291
|
case 2:
|
|
5244
|
-
res =
|
|
5292
|
+
res = _context98.v;
|
|
5245
5293
|
onSuccess();
|
|
5246
5294
|
resolve(res);
|
|
5247
|
-
|
|
5295
|
+
_context98.n = 4;
|
|
5248
5296
|
break;
|
|
5249
5297
|
case 3:
|
|
5250
|
-
|
|
5251
|
-
_t22 =
|
|
5298
|
+
_context98.p = 3;
|
|
5299
|
+
_t22 = _context98.v;
|
|
5252
5300
|
reject(_t22);
|
|
5253
5301
|
case 4:
|
|
5254
|
-
return
|
|
5302
|
+
return _context98.a(2);
|
|
5255
5303
|
}
|
|
5256
|
-
},
|
|
5304
|
+
}, _callee98, null, [[0, 3]]);
|
|
5257
5305
|
}));
|
|
5258
|
-
function onContinue(
|
|
5306
|
+
function onContinue(_x80) {
|
|
5259
5307
|
return _onContinue2.apply(this, arguments);
|
|
5260
5308
|
}
|
|
5261
5309
|
return onContinue;
|
|
@@ -5272,54 +5320,54 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5272
5320
|
return logout();
|
|
5273
5321
|
}, callbacks, "Failed to update email"));
|
|
5274
5322
|
case 8:
|
|
5275
|
-
|
|
5323
|
+
_context99.n = 11;
|
|
5276
5324
|
break;
|
|
5277
5325
|
case 9:
|
|
5278
|
-
|
|
5279
|
-
_t23 =
|
|
5326
|
+
_context99.p = 9;
|
|
5327
|
+
_t23 = _context99.v;
|
|
5280
5328
|
if (!(_t23 instanceof TurnkeyError)) {
|
|
5281
|
-
|
|
5329
|
+
_context99.n = 10;
|
|
5282
5330
|
break;
|
|
5283
5331
|
}
|
|
5284
5332
|
throw _t23;
|
|
5285
5333
|
case 10:
|
|
5286
5334
|
throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t23);
|
|
5287
5335
|
case 11:
|
|
5288
|
-
return
|
|
5336
|
+
return _context99.a(2);
|
|
5289
5337
|
}
|
|
5290
|
-
},
|
|
5338
|
+
}, _callee99, null, [[5, 9]]);
|
|
5291
5339
|
}));
|
|
5292
|
-
return function (
|
|
5293
|
-
return
|
|
5340
|
+
return function (_x79) {
|
|
5341
|
+
return _ref125.apply(this, arguments);
|
|
5294
5342
|
};
|
|
5295
5343
|
}(), [client, getSession, pushPage, closeModal, logout, initOtp, masterConfig, verifyOtp, updateUserEmail, user, callbacks]);
|
|
5296
5344
|
var handleAddEmail = useCallback(/*#__PURE__*/function () {
|
|
5297
|
-
var
|
|
5298
|
-
var
|
|
5299
|
-
return _regenerator().w(function (
|
|
5300
|
-
while (1) switch (
|
|
5345
|
+
var _ref127 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101(params) {
|
|
5346
|
+
var _ref128, _ref128$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t25;
|
|
5347
|
+
return _regenerator().w(function (_context101) {
|
|
5348
|
+
while (1) switch (_context101.p = _context101.n) {
|
|
5301
5349
|
case 0:
|
|
5302
|
-
|
|
5350
|
+
_ref128 = params || {}, _ref128$successPageDu = _ref128.successPageDuration, successPageDuration = _ref128$successPageDu === void 0 ? 2000 : _ref128$successPageDu, subTitle = _ref128.subTitle, title = _ref128.title, stampWith = _ref128.stampWith;
|
|
5303
5351
|
if (client) {
|
|
5304
|
-
|
|
5352
|
+
_context101.n = 1;
|
|
5305
5353
|
break;
|
|
5306
5354
|
}
|
|
5307
5355
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
5308
5356
|
case 1:
|
|
5309
|
-
|
|
5357
|
+
_context101.n = 2;
|
|
5310
5358
|
return getSession();
|
|
5311
5359
|
case 2:
|
|
5312
|
-
s =
|
|
5360
|
+
s = _context101.v;
|
|
5313
5361
|
organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
|
|
5314
5362
|
if (organizationId) {
|
|
5315
|
-
|
|
5363
|
+
_context101.n = 3;
|
|
5316
5364
|
break;
|
|
5317
5365
|
}
|
|
5318
5366
|
throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
5319
5367
|
case 3:
|
|
5320
5368
|
userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
|
|
5321
5369
|
if (userId) {
|
|
5322
|
-
|
|
5370
|
+
_context101.n = 4;
|
|
5323
5371
|
break;
|
|
5324
5372
|
}
|
|
5325
5373
|
throw new TurnkeyError("A user ID is required to add an email.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
@@ -5339,12 +5387,12 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5339
5387
|
showTitle: false
|
|
5340
5388
|
});
|
|
5341
5389
|
};
|
|
5342
|
-
|
|
5390
|
+
_context101.p = 5;
|
|
5343
5391
|
if (!(!(params !== null && params !== void 0 && params.email) && (params === null || params === void 0 ? void 0 : params.email) !== "")) {
|
|
5344
|
-
|
|
5392
|
+
_context101.n = 6;
|
|
5345
5393
|
break;
|
|
5346
5394
|
}
|
|
5347
|
-
return
|
|
5395
|
+
return _context101.a(2, withTurnkeyErrorHandling(function () {
|
|
5348
5396
|
return new Promise(function (resolve, reject) {
|
|
5349
5397
|
pushPage({
|
|
5350
5398
|
key: "Add Email",
|
|
@@ -5372,14 +5420,14 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5372
5420
|
return logout();
|
|
5373
5421
|
}));
|
|
5374
5422
|
case 6:
|
|
5375
|
-
|
|
5423
|
+
_context101.n = 7;
|
|
5376
5424
|
return initOtp({
|
|
5377
5425
|
otpType: OtpType.Email,
|
|
5378
5426
|
contact: params.email
|
|
5379
5427
|
});
|
|
5380
5428
|
case 7:
|
|
5381
|
-
otpId =
|
|
5382
|
-
return
|
|
5429
|
+
otpId = _context101.v;
|
|
5430
|
+
return _context101.a(2, withTurnkeyErrorHandling(function () {
|
|
5383
5431
|
return new Promise(function (resolve, reject) {
|
|
5384
5432
|
var _masterConfig$auth46, _masterConfig$auth47;
|
|
5385
5433
|
pushPage({
|
|
@@ -5391,13 +5439,13 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5391
5439
|
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,
|
|
5392
5440
|
alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth47 = masterConfig.auth) === null || _masterConfig$auth47 === void 0 ? void 0 : _masterConfig$auth47.otpAlphanumeric,
|
|
5393
5441
|
onContinue: function () {
|
|
5394
|
-
var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
5442
|
+
var _onContinue3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100(otpCode) {
|
|
5395
5443
|
var _yield$verifyOtp3, verificationToken, res, _t24;
|
|
5396
|
-
return _regenerator().w(function (
|
|
5397
|
-
while (1) switch (
|
|
5444
|
+
return _regenerator().w(function (_context100) {
|
|
5445
|
+
while (1) switch (_context100.p = _context100.n) {
|
|
5398
5446
|
case 0:
|
|
5399
|
-
|
|
5400
|
-
|
|
5447
|
+
_context100.p = 0;
|
|
5448
|
+
_context100.n = 1;
|
|
5401
5449
|
return verifyOtp({
|
|
5402
5450
|
otpId: otpId,
|
|
5403
5451
|
otpCode: otpCode,
|
|
@@ -5405,9 +5453,9 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5405
5453
|
otpType: OtpType.Email
|
|
5406
5454
|
});
|
|
5407
5455
|
case 1:
|
|
5408
|
-
_yield$verifyOtp3 =
|
|
5456
|
+
_yield$verifyOtp3 = _context100.v;
|
|
5409
5457
|
verificationToken = _yield$verifyOtp3.verificationToken;
|
|
5410
|
-
|
|
5458
|
+
_context100.n = 2;
|
|
5411
5459
|
return updateUserEmail({
|
|
5412
5460
|
email: params.email,
|
|
5413
5461
|
verificationToken: verificationToken,
|
|
@@ -5416,21 +5464,21 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5416
5464
|
stampWith: stampWith
|
|
5417
5465
|
});
|
|
5418
5466
|
case 2:
|
|
5419
|
-
res =
|
|
5467
|
+
res = _context100.v;
|
|
5420
5468
|
onSuccess();
|
|
5421
5469
|
resolve(res);
|
|
5422
|
-
|
|
5470
|
+
_context100.n = 4;
|
|
5423
5471
|
break;
|
|
5424
5472
|
case 3:
|
|
5425
|
-
|
|
5426
|
-
_t24 =
|
|
5473
|
+
_context100.p = 3;
|
|
5474
|
+
_t24 = _context100.v;
|
|
5427
5475
|
reject(_t24);
|
|
5428
5476
|
case 4:
|
|
5429
|
-
return
|
|
5477
|
+
return _context100.a(2);
|
|
5430
5478
|
}
|
|
5431
|
-
},
|
|
5479
|
+
}, _callee100, null, [[0, 3]]);
|
|
5432
5480
|
}));
|
|
5433
|
-
function onContinue(
|
|
5481
|
+
function onContinue(_x82) {
|
|
5434
5482
|
return _onContinue3.apply(this, arguments);
|
|
5435
5483
|
}
|
|
5436
5484
|
return onContinue;
|
|
@@ -5447,67 +5495,67 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5447
5495
|
return logout();
|
|
5448
5496
|
}, callbacks, "Failed to add email"));
|
|
5449
5497
|
case 8:
|
|
5450
|
-
|
|
5498
|
+
_context101.n = 11;
|
|
5451
5499
|
break;
|
|
5452
5500
|
case 9:
|
|
5453
|
-
|
|
5454
|
-
_t25 =
|
|
5501
|
+
_context101.p = 9;
|
|
5502
|
+
_t25 = _context101.v;
|
|
5455
5503
|
if (!(_t25 instanceof TurnkeyError)) {
|
|
5456
|
-
|
|
5504
|
+
_context101.n = 10;
|
|
5457
5505
|
break;
|
|
5458
5506
|
}
|
|
5459
5507
|
throw _t25;
|
|
5460
5508
|
case 10:
|
|
5461
5509
|
throw new TurnkeyError("Failed to initialize OTP for email verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t25);
|
|
5462
5510
|
case 11:
|
|
5463
|
-
return
|
|
5511
|
+
return _context101.a(2);
|
|
5464
5512
|
}
|
|
5465
|
-
},
|
|
5513
|
+
}, _callee101, null, [[5, 9]]);
|
|
5466
5514
|
}));
|
|
5467
|
-
return function (
|
|
5468
|
-
return
|
|
5515
|
+
return function (_x81) {
|
|
5516
|
+
return _ref127.apply(this, arguments);
|
|
5469
5517
|
};
|
|
5470
5518
|
}(), [client, getSession, pushPage, closeModal, user, logout, initOtp, masterConfig, verifyOtp, updateUserEmail, callbacks]);
|
|
5471
5519
|
var handleAddPhoneNumber = useCallback(/*#__PURE__*/function () {
|
|
5472
|
-
var
|
|
5520
|
+
var _ref129 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee103(params) {
|
|
5473
5521
|
var _masterConfig$auth48, _masterConfig$auth48$;
|
|
5474
|
-
var
|
|
5475
|
-
return _regenerator().w(function (
|
|
5476
|
-
while (1) switch (
|
|
5522
|
+
var _ref130, _ref130$successPageDu, successPageDuration, subTitle, title, stampWith, s, organizationId, userId, onSuccess, otpId, _t27;
|
|
5523
|
+
return _regenerator().w(function (_context103) {
|
|
5524
|
+
while (1) switch (_context103.p = _context103.n) {
|
|
5477
5525
|
case 0:
|
|
5478
|
-
|
|
5526
|
+
_ref130 = params || {}, _ref130$successPageDu = _ref130.successPageDuration, successPageDuration = _ref130$successPageDu === void 0 ? 2000 : _ref130$successPageDu, subTitle = _ref130.subTitle, title = _ref130.title, stampWith = _ref130.stampWith;
|
|
5479
5527
|
if (client) {
|
|
5480
|
-
|
|
5528
|
+
_context103.n = 1;
|
|
5481
5529
|
break;
|
|
5482
5530
|
}
|
|
5483
5531
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
5484
5532
|
case 1:
|
|
5485
5533
|
if (masterConfig) {
|
|
5486
|
-
|
|
5534
|
+
_context103.n = 2;
|
|
5487
5535
|
break;
|
|
5488
5536
|
}
|
|
5489
5537
|
throw new TurnkeyError("Config is not ready yet!", TurnkeyErrorCodes.CONFIG_NOT_INITIALIZED);
|
|
5490
5538
|
case 2:
|
|
5491
5539
|
if ((_masterConfig$auth48 = masterConfig.auth) !== null && _masterConfig$auth48 !== void 0 && (_masterConfig$auth48$ = _masterConfig$auth48.methods) !== null && _masterConfig$auth48$ !== void 0 && _masterConfig$auth48$.smsOtpAuthEnabled) {
|
|
5492
|
-
|
|
5540
|
+
_context103.n = 3;
|
|
5493
5541
|
break;
|
|
5494
5542
|
}
|
|
5495
5543
|
throw new TurnkeyError("SMS OTP authentication is not enabled in the configuration.", TurnkeyErrorCodes.AUTH_METHOD_NOT_ENABLED);
|
|
5496
5544
|
case 3:
|
|
5497
|
-
|
|
5545
|
+
_context103.n = 4;
|
|
5498
5546
|
return getSession();
|
|
5499
5547
|
case 4:
|
|
5500
|
-
s =
|
|
5548
|
+
s = _context103.v;
|
|
5501
5549
|
organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
|
|
5502
5550
|
if (organizationId) {
|
|
5503
|
-
|
|
5551
|
+
_context103.n = 5;
|
|
5504
5552
|
break;
|
|
5505
5553
|
}
|
|
5506
5554
|
throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
5507
5555
|
case 5:
|
|
5508
5556
|
userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
|
|
5509
5557
|
if (userId) {
|
|
5510
|
-
|
|
5558
|
+
_context103.n = 6;
|
|
5511
5559
|
break;
|
|
5512
5560
|
}
|
|
5513
5561
|
throw new TurnkeyError("A user ID is required to add a phone number.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
@@ -5527,12 +5575,12 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5527
5575
|
showTitle: false
|
|
5528
5576
|
});
|
|
5529
5577
|
};
|
|
5530
|
-
|
|
5578
|
+
_context103.p = 7;
|
|
5531
5579
|
if (!(!(params !== null && params !== void 0 && params.phoneNumber) && (params === null || params === void 0 ? void 0 : params.phoneNumber) !== "")) {
|
|
5532
|
-
|
|
5580
|
+
_context103.n = 8;
|
|
5533
5581
|
break;
|
|
5534
5582
|
}
|
|
5535
|
-
return
|
|
5583
|
+
return _context103.a(2, withTurnkeyErrorHandling(function () {
|
|
5536
5584
|
return new Promise(function (resolve, reject) {
|
|
5537
5585
|
pushPage({
|
|
5538
5586
|
key: "Add Phone Number",
|
|
@@ -5560,14 +5608,14 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5560
5608
|
return logout();
|
|
5561
5609
|
}, callbacks, "Failed to add phone number"));
|
|
5562
5610
|
case 8:
|
|
5563
|
-
|
|
5611
|
+
_context103.n = 9;
|
|
5564
5612
|
return initOtp({
|
|
5565
5613
|
otpType: OtpType.Sms,
|
|
5566
5614
|
contact: params.phoneNumber
|
|
5567
5615
|
});
|
|
5568
5616
|
case 9:
|
|
5569
|
-
otpId =
|
|
5570
|
-
return
|
|
5617
|
+
otpId = _context103.v;
|
|
5618
|
+
return _context103.a(2, withTurnkeyErrorHandling(function () {
|
|
5571
5619
|
return new Promise(function (resolve, reject) {
|
|
5572
5620
|
var _masterConfig$auth49, _masterConfig$auth50;
|
|
5573
5621
|
pushPage({
|
|
@@ -5579,13 +5627,13 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5579
5627
|
otpLength: ((_masterConfig$auth49 = masterConfig.auth) === null || _masterConfig$auth49 === void 0 ? void 0 : _masterConfig$auth49.otpLength) !== undefined ? Number(masterConfig.auth.otpLength) : undefined,
|
|
5580
5628
|
alphanumeric: masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth50 = masterConfig.auth) === null || _masterConfig$auth50 === void 0 ? void 0 : _masterConfig$auth50.otpAlphanumeric,
|
|
5581
5629
|
onContinue: function () {
|
|
5582
|
-
var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
5630
|
+
var _onContinue4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102(otpCode) {
|
|
5583
5631
|
var _yield$verifyOtp4, verificationToken, res, _t26;
|
|
5584
|
-
return _regenerator().w(function (
|
|
5585
|
-
while (1) switch (
|
|
5632
|
+
return _regenerator().w(function (_context102) {
|
|
5633
|
+
while (1) switch (_context102.p = _context102.n) {
|
|
5586
5634
|
case 0:
|
|
5587
|
-
|
|
5588
|
-
|
|
5635
|
+
_context102.p = 0;
|
|
5636
|
+
_context102.n = 1;
|
|
5589
5637
|
return verifyOtp({
|
|
5590
5638
|
otpId: otpId,
|
|
5591
5639
|
otpCode: otpCode,
|
|
@@ -5593,9 +5641,9 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5593
5641
|
otpType: OtpType.Sms
|
|
5594
5642
|
});
|
|
5595
5643
|
case 1:
|
|
5596
|
-
_yield$verifyOtp4 =
|
|
5644
|
+
_yield$verifyOtp4 = _context102.v;
|
|
5597
5645
|
verificationToken = _yield$verifyOtp4.verificationToken;
|
|
5598
|
-
|
|
5646
|
+
_context102.n = 2;
|
|
5599
5647
|
return updateUserPhoneNumber({
|
|
5600
5648
|
phoneNumber: params.phoneNumber,
|
|
5601
5649
|
verificationToken: verificationToken,
|
|
@@ -5604,21 +5652,21 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5604
5652
|
stampWith: stampWith
|
|
5605
5653
|
});
|
|
5606
5654
|
case 2:
|
|
5607
|
-
res =
|
|
5655
|
+
res = _context102.v;
|
|
5608
5656
|
onSuccess();
|
|
5609
5657
|
resolve(res);
|
|
5610
|
-
|
|
5658
|
+
_context102.n = 4;
|
|
5611
5659
|
break;
|
|
5612
5660
|
case 3:
|
|
5613
|
-
|
|
5614
|
-
_t26 =
|
|
5661
|
+
_context102.p = 3;
|
|
5662
|
+
_t26 = _context102.v;
|
|
5615
5663
|
reject(_t26);
|
|
5616
5664
|
case 4:
|
|
5617
|
-
return
|
|
5665
|
+
return _context102.a(2);
|
|
5618
5666
|
}
|
|
5619
|
-
},
|
|
5667
|
+
}, _callee102, null, [[0, 3]]);
|
|
5620
5668
|
}));
|
|
5621
|
-
function onContinue(
|
|
5669
|
+
function onContinue(_x84) {
|
|
5622
5670
|
return _onContinue4.apply(this, arguments);
|
|
5623
5671
|
}
|
|
5624
5672
|
return onContinue;
|
|
@@ -5637,52 +5685,52 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5637
5685
|
return logout();
|
|
5638
5686
|
}, callbacks, "Failed to add phone number"));
|
|
5639
5687
|
case 10:
|
|
5640
|
-
|
|
5688
|
+
_context103.n = 13;
|
|
5641
5689
|
break;
|
|
5642
5690
|
case 11:
|
|
5643
|
-
|
|
5644
|
-
_t27 =
|
|
5691
|
+
_context103.p = 11;
|
|
5692
|
+
_t27 = _context103.v;
|
|
5645
5693
|
if (!(_t27 instanceof TurnkeyError)) {
|
|
5646
|
-
|
|
5694
|
+
_context103.n = 12;
|
|
5647
5695
|
break;
|
|
5648
5696
|
}
|
|
5649
5697
|
throw _t27;
|
|
5650
5698
|
case 12:
|
|
5651
5699
|
throw new TurnkeyError("Failed to initialize OTP for sms verification.", TurnkeyErrorCodes.INIT_OTP_ERROR, _t27);
|
|
5652
5700
|
case 13:
|
|
5653
|
-
return
|
|
5701
|
+
return _context103.a(2);
|
|
5654
5702
|
}
|
|
5655
|
-
},
|
|
5703
|
+
}, _callee103, null, [[7, 11]]);
|
|
5656
5704
|
}));
|
|
5657
|
-
return function (
|
|
5658
|
-
return
|
|
5705
|
+
return function (_x83) {
|
|
5706
|
+
return _ref129.apply(this, arguments);
|
|
5659
5707
|
};
|
|
5660
5708
|
}(), [client, masterConfig, getSession, pushPage, closeModal, user, logout, callbacks, initOtp, verifyOtp, updateUserPhoneNumber]);
|
|
5661
5709
|
var handleRemovePasskey = useCallback(/*#__PURE__*/function () {
|
|
5662
|
-
var
|
|
5710
|
+
var _ref131 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee104(params) {
|
|
5663
5711
|
var authenticatorId, _params$successPageDu2, successPageDuration, subTitle, title, stampWith, userId, s, organizationId;
|
|
5664
|
-
return _regenerator().w(function (
|
|
5665
|
-
while (1) switch (
|
|
5712
|
+
return _regenerator().w(function (_context104) {
|
|
5713
|
+
while (1) switch (_context104.n) {
|
|
5666
5714
|
case 0:
|
|
5667
5715
|
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;
|
|
5668
5716
|
if (client) {
|
|
5669
|
-
|
|
5717
|
+
_context104.n = 1;
|
|
5670
5718
|
break;
|
|
5671
5719
|
}
|
|
5672
5720
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
5673
5721
|
case 1:
|
|
5674
|
-
|
|
5722
|
+
_context104.n = 2;
|
|
5675
5723
|
return getSession();
|
|
5676
5724
|
case 2:
|
|
5677
|
-
s =
|
|
5725
|
+
s = _context104.v;
|
|
5678
5726
|
organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
|
|
5679
5727
|
if (organizationId) {
|
|
5680
|
-
|
|
5728
|
+
_context104.n = 3;
|
|
5681
5729
|
break;
|
|
5682
5730
|
}
|
|
5683
5731
|
throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
5684
5732
|
case 3:
|
|
5685
|
-
return
|
|
5733
|
+
return _context104.a(2, withTurnkeyErrorHandling(function () {
|
|
5686
5734
|
return new Promise(function (resolve, reject) {
|
|
5687
5735
|
pushPage({
|
|
5688
5736
|
key: "Remove Passkey",
|
|
@@ -5713,44 +5761,44 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5713
5761
|
return logout();
|
|
5714
5762
|
}, callbacks, "Failed to remove passkey"));
|
|
5715
5763
|
}
|
|
5716
|
-
},
|
|
5764
|
+
}, _callee104);
|
|
5717
5765
|
}));
|
|
5718
|
-
return function (
|
|
5719
|
-
return
|
|
5766
|
+
return function (_x85) {
|
|
5767
|
+
return _ref131.apply(this, arguments);
|
|
5720
5768
|
};
|
|
5721
5769
|
}(), [client, getSession, pushPage, logout, callbacks]);
|
|
5722
5770
|
var handleAddPasskey = useCallback(/*#__PURE__*/function () {
|
|
5723
|
-
var
|
|
5724
|
-
var
|
|
5725
|
-
return _regenerator().w(function (
|
|
5726
|
-
while (1) switch (
|
|
5771
|
+
var _ref132 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee105(params) {
|
|
5772
|
+
var _ref133, name, displayName, _ref133$successPageDu, successPageDuration, stampWith, s, organizationId, userId, resPromise, _t28;
|
|
5773
|
+
return _regenerator().w(function (_context105) {
|
|
5774
|
+
while (1) switch (_context105.p = _context105.n) {
|
|
5727
5775
|
case 0:
|
|
5728
|
-
|
|
5776
|
+
_ref133 = params || {}, name = _ref133.name, displayName = _ref133.displayName, _ref133$successPageDu = _ref133.successPageDuration, successPageDuration = _ref133$successPageDu === void 0 ? 2000 : _ref133$successPageDu, stampWith = _ref133.stampWith;
|
|
5729
5777
|
if (client) {
|
|
5730
|
-
|
|
5778
|
+
_context105.n = 1;
|
|
5731
5779
|
break;
|
|
5732
5780
|
}
|
|
5733
5781
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
5734
5782
|
case 1:
|
|
5735
|
-
|
|
5783
|
+
_context105.n = 2;
|
|
5736
5784
|
return getSession();
|
|
5737
5785
|
case 2:
|
|
5738
|
-
s =
|
|
5786
|
+
s = _context105.v;
|
|
5739
5787
|
organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
|
|
5740
5788
|
if (organizationId) {
|
|
5741
|
-
|
|
5789
|
+
_context105.n = 3;
|
|
5742
5790
|
break;
|
|
5743
5791
|
}
|
|
5744
5792
|
throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
5745
5793
|
case 3:
|
|
5746
5794
|
userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
|
|
5747
5795
|
if (userId) {
|
|
5748
|
-
|
|
5796
|
+
_context105.n = 4;
|
|
5749
5797
|
break;
|
|
5750
5798
|
}
|
|
5751
5799
|
throw new TurnkeyError("A user ID or a valid session is required to add a passkey.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
5752
5800
|
case 4:
|
|
5753
|
-
|
|
5801
|
+
_context105.p = 4;
|
|
5754
5802
|
resPromise = addPasskey(_objectSpread2(_objectSpread2(_objectSpread2({}, name && {
|
|
5755
5803
|
name: name
|
|
5756
5804
|
}), displayName && {
|
|
@@ -5775,55 +5823,55 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5775
5823
|
showTitle: false
|
|
5776
5824
|
});
|
|
5777
5825
|
});
|
|
5778
|
-
|
|
5826
|
+
_context105.n = 5;
|
|
5779
5827
|
return resPromise;
|
|
5780
5828
|
case 5:
|
|
5781
|
-
return
|
|
5829
|
+
return _context105.a(2, _context105.v);
|
|
5782
5830
|
case 6:
|
|
5783
|
-
|
|
5784
|
-
_t28 =
|
|
5831
|
+
_context105.p = 6;
|
|
5832
|
+
_t28 = _context105.v;
|
|
5785
5833
|
if (!(_t28 instanceof TurnkeyError)) {
|
|
5786
|
-
|
|
5834
|
+
_context105.n = 7;
|
|
5787
5835
|
break;
|
|
5788
5836
|
}
|
|
5789
5837
|
throw _t28;
|
|
5790
5838
|
case 7:
|
|
5791
5839
|
throw new TurnkeyError("Failed to add passkey in handler.", TurnkeyErrorCodes.ADD_PASSKEY_ERROR, _t28);
|
|
5792
5840
|
case 8:
|
|
5793
|
-
return
|
|
5841
|
+
return _context105.a(2);
|
|
5794
5842
|
}
|
|
5795
|
-
},
|
|
5843
|
+
}, _callee105, null, [[4, 6]]);
|
|
5796
5844
|
}));
|
|
5797
|
-
return function (
|
|
5798
|
-
return
|
|
5845
|
+
return function (_x86) {
|
|
5846
|
+
return _ref132.apply(this, arguments);
|
|
5799
5847
|
};
|
|
5800
5848
|
}(), [client, getSession, addPasskey, pushPage, closeModal]);
|
|
5801
5849
|
var handleRemoveOauthProvider = useCallback(/*#__PURE__*/function () {
|
|
5802
|
-
var
|
|
5850
|
+
var _ref134 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee106(params) {
|
|
5803
5851
|
var providerId, _params$successPageDu3, successPageDuration, subTitle, title, stampWith, s, organizationId, _t29;
|
|
5804
|
-
return _regenerator().w(function (
|
|
5805
|
-
while (1) switch (
|
|
5852
|
+
return _regenerator().w(function (_context106) {
|
|
5853
|
+
while (1) switch (_context106.p = _context106.n) {
|
|
5806
5854
|
case 0:
|
|
5807
5855
|
providerId = params.providerId, _params$successPageDu3 = params.successPageDuration, successPageDuration = _params$successPageDu3 === void 0 ? 2000 : _params$successPageDu3, subTitle = params.subTitle, title = params.title, stampWith = params.stampWith;
|
|
5808
5856
|
if (client) {
|
|
5809
|
-
|
|
5857
|
+
_context106.n = 1;
|
|
5810
5858
|
break;
|
|
5811
5859
|
}
|
|
5812
5860
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
5813
5861
|
case 1:
|
|
5814
|
-
|
|
5862
|
+
_context106.n = 2;
|
|
5815
5863
|
return getSession();
|
|
5816
5864
|
case 2:
|
|
5817
|
-
s =
|
|
5865
|
+
s = _context106.v;
|
|
5818
5866
|
organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
|
|
5819
5867
|
if (organizationId) {
|
|
5820
|
-
|
|
5868
|
+
_context106.n = 3;
|
|
5821
5869
|
break;
|
|
5822
5870
|
}
|
|
5823
5871
|
throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
5824
5872
|
case 3:
|
|
5825
|
-
|
|
5826
|
-
return
|
|
5873
|
+
_context106.p = 3;
|
|
5874
|
+
return _context106.a(2, new Promise(function (resolve, reject) {
|
|
5827
5875
|
pushPage({
|
|
5828
5876
|
key: "Remove OAuth Provider",
|
|
5829
5877
|
content: jsx(RemoveOAuthProvider, _objectSpread2(_objectSpread2(_objectSpread2({
|
|
@@ -5851,68 +5899,68 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5851
5899
|
});
|
|
5852
5900
|
}));
|
|
5853
5901
|
case 4:
|
|
5854
|
-
|
|
5855
|
-
_t29 =
|
|
5902
|
+
_context106.p = 4;
|
|
5903
|
+
_t29 = _context106.v;
|
|
5856
5904
|
if (!(_t29 instanceof TurnkeyError)) {
|
|
5857
|
-
|
|
5905
|
+
_context106.n = 5;
|
|
5858
5906
|
break;
|
|
5859
5907
|
}
|
|
5860
5908
|
throw _t29;
|
|
5861
5909
|
case 5:
|
|
5862
5910
|
throw new TurnkeyError("Failed to remove OAuth provider in handler.", TurnkeyErrorCodes.REMOVE_OAUTH_PROVIDER_ERROR, _t29);
|
|
5863
5911
|
case 6:
|
|
5864
|
-
return
|
|
5912
|
+
return _context106.a(2);
|
|
5865
5913
|
}
|
|
5866
|
-
},
|
|
5914
|
+
}, _callee106, null, [[3, 4]]);
|
|
5867
5915
|
}));
|
|
5868
|
-
return function (
|
|
5869
|
-
return
|
|
5916
|
+
return function (_x87) {
|
|
5917
|
+
return _ref134.apply(this, arguments);
|
|
5870
5918
|
};
|
|
5871
5919
|
}(), [client, getSession, pushPage]);
|
|
5872
5920
|
var handleAddOauthProvider = useCallback(/*#__PURE__*/function () {
|
|
5873
|
-
var
|
|
5921
|
+
var _ref135 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee109(params) {
|
|
5874
5922
|
var providerName, stampWith, _params$successPageDu4, successPageDuration, s, organizationId, userId;
|
|
5875
|
-
return _regenerator().w(function (
|
|
5876
|
-
while (1) switch (
|
|
5923
|
+
return _regenerator().w(function (_context109) {
|
|
5924
|
+
while (1) switch (_context109.n) {
|
|
5877
5925
|
case 0:
|
|
5878
5926
|
if (client) {
|
|
5879
|
-
|
|
5927
|
+
_context109.n = 1;
|
|
5880
5928
|
break;
|
|
5881
5929
|
}
|
|
5882
5930
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
5883
5931
|
case 1:
|
|
5884
5932
|
providerName = params.providerName, stampWith = params.stampWith, _params$successPageDu4 = params.successPageDuration, successPageDuration = _params$successPageDu4 === void 0 ? 2000 : _params$successPageDu4;
|
|
5885
|
-
|
|
5933
|
+
_context109.n = 2;
|
|
5886
5934
|
return getSession();
|
|
5887
5935
|
case 2:
|
|
5888
|
-
s =
|
|
5936
|
+
s = _context109.v;
|
|
5889
5937
|
organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
|
|
5890
5938
|
if (organizationId) {
|
|
5891
|
-
|
|
5939
|
+
_context109.n = 3;
|
|
5892
5940
|
break;
|
|
5893
5941
|
}
|
|
5894
5942
|
throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
5895
5943
|
case 3:
|
|
5896
5944
|
userId = (params === null || params === void 0 ? void 0 : params.userId) || (s === null || s === void 0 ? void 0 : s.userId);
|
|
5897
5945
|
if (userId) {
|
|
5898
|
-
|
|
5946
|
+
_context109.n = 4;
|
|
5899
5947
|
break;
|
|
5900
5948
|
}
|
|
5901
5949
|
throw new TurnkeyError("A user ID is required to add an OAuth provider.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
5902
5950
|
case 4:
|
|
5903
|
-
return
|
|
5904
|
-
var
|
|
5951
|
+
return _context109.a(2, new Promise(/*#__PURE__*/function () {
|
|
5952
|
+
var _ref136 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee108(resolve, reject) {
|
|
5905
5953
|
var onOauthSuccess, _t30, _t31;
|
|
5906
|
-
return _regenerator().w(function (
|
|
5907
|
-
while (1) switch (
|
|
5954
|
+
return _regenerator().w(function (_context108) {
|
|
5955
|
+
while (1) switch (_context108.p = _context108.n) {
|
|
5908
5956
|
case 0:
|
|
5909
|
-
|
|
5957
|
+
_context108.p = 0;
|
|
5910
5958
|
onOauthSuccess = /*#__PURE__*/function () {
|
|
5911
|
-
var
|
|
5912
|
-
return _regenerator().w(function (
|
|
5913
|
-
while (1) switch (
|
|
5959
|
+
var _ref137 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee107(params) {
|
|
5960
|
+
return _regenerator().w(function (_context107) {
|
|
5961
|
+
while (1) switch (_context107.n) {
|
|
5914
5962
|
case 0:
|
|
5915
|
-
|
|
5963
|
+
_context107.n = 1;
|
|
5916
5964
|
return addOauthProvider({
|
|
5917
5965
|
providerName: params.providerName,
|
|
5918
5966
|
oidcToken: params.oidcToken,
|
|
@@ -5935,103 +5983,103 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
5935
5983
|
showTitle: false
|
|
5936
5984
|
});
|
|
5937
5985
|
case 2:
|
|
5938
|
-
return
|
|
5986
|
+
return _context107.a(2);
|
|
5939
5987
|
}
|
|
5940
|
-
},
|
|
5988
|
+
}, _callee107);
|
|
5941
5989
|
}));
|
|
5942
|
-
return function onOauthSuccess(
|
|
5943
|
-
return
|
|
5990
|
+
return function onOauthSuccess(_x91) {
|
|
5991
|
+
return _ref137.apply(this, arguments);
|
|
5944
5992
|
};
|
|
5945
5993
|
}();
|
|
5946
5994
|
_t30 = providerName;
|
|
5947
|
-
|
|
5995
|
+
_context108.n = _t30 === OAuthProviders.DISCORD ? 1 : _t30 === OAuthProviders.X ? 3 : _t30 === OAuthProviders.GOOGLE ? 5 : _t30 === OAuthProviders.APPLE ? 7 : _t30 === OAuthProviders.FACEBOOK ? 9 : 11;
|
|
5948
5996
|
break;
|
|
5949
5997
|
case 1:
|
|
5950
|
-
|
|
5998
|
+
_context108.n = 2;
|
|
5951
5999
|
return handleDiscordOauth({
|
|
5952
6000
|
openInPage: false,
|
|
5953
6001
|
onOauthSuccess: onOauthSuccess
|
|
5954
6002
|
});
|
|
5955
6003
|
case 2:
|
|
5956
|
-
return
|
|
6004
|
+
return _context108.a(2, _context108.v);
|
|
5957
6005
|
case 3:
|
|
5958
|
-
|
|
6006
|
+
_context108.n = 4;
|
|
5959
6007
|
return handleXOauth({
|
|
5960
6008
|
openInPage: false,
|
|
5961
6009
|
onOauthSuccess: onOauthSuccess
|
|
5962
6010
|
});
|
|
5963
6011
|
case 4:
|
|
5964
|
-
return
|
|
6012
|
+
return _context108.a(2, _context108.v);
|
|
5965
6013
|
case 5:
|
|
5966
|
-
|
|
6014
|
+
_context108.n = 6;
|
|
5967
6015
|
return handleGoogleOauth({
|
|
5968
6016
|
openInPage: false,
|
|
5969
6017
|
onOauthSuccess: onOauthSuccess
|
|
5970
6018
|
});
|
|
5971
6019
|
case 6:
|
|
5972
|
-
return
|
|
6020
|
+
return _context108.a(2, _context108.v);
|
|
5973
6021
|
case 7:
|
|
5974
|
-
|
|
6022
|
+
_context108.n = 8;
|
|
5975
6023
|
return handleAppleOauth({
|
|
5976
6024
|
openInPage: false,
|
|
5977
6025
|
onOauthSuccess: onOauthSuccess
|
|
5978
6026
|
});
|
|
5979
6027
|
case 8:
|
|
5980
|
-
return
|
|
6028
|
+
return _context108.a(2, _context108.v);
|
|
5981
6029
|
case 9:
|
|
5982
|
-
|
|
6030
|
+
_context108.n = 10;
|
|
5983
6031
|
return handleFacebookOauth({
|
|
5984
6032
|
openInPage: false,
|
|
5985
6033
|
onOauthSuccess: onOauthSuccess
|
|
5986
6034
|
});
|
|
5987
6035
|
case 10:
|
|
5988
|
-
return
|
|
6036
|
+
return _context108.a(2, _context108.v);
|
|
5989
6037
|
case 11:
|
|
5990
6038
|
throw new TurnkeyError("Unsupported OAuth provider: ".concat(providerName), TurnkeyErrorCodes.NOT_FOUND);
|
|
5991
6039
|
case 12:
|
|
5992
|
-
|
|
6040
|
+
_context108.n = 14;
|
|
5993
6041
|
break;
|
|
5994
6042
|
case 13:
|
|
5995
|
-
|
|
5996
|
-
_t31 =
|
|
6043
|
+
_context108.p = 13;
|
|
6044
|
+
_t31 = _context108.v;
|
|
5997
6045
|
reject(_t31);
|
|
5998
6046
|
case 14:
|
|
5999
|
-
return
|
|
6047
|
+
return _context108.a(2);
|
|
6000
6048
|
}
|
|
6001
|
-
},
|
|
6049
|
+
}, _callee108, null, [[0, 13]]);
|
|
6002
6050
|
}));
|
|
6003
|
-
return function (
|
|
6004
|
-
return
|
|
6051
|
+
return function (_x89, _x90) {
|
|
6052
|
+
return _ref136.apply(this, arguments);
|
|
6005
6053
|
};
|
|
6006
6054
|
}()));
|
|
6007
6055
|
}
|
|
6008
|
-
},
|
|
6056
|
+
}, _callee109);
|
|
6009
6057
|
}));
|
|
6010
|
-
return function (
|
|
6011
|
-
return
|
|
6058
|
+
return function (_x88) {
|
|
6059
|
+
return _ref135.apply(this, arguments);
|
|
6012
6060
|
};
|
|
6013
6061
|
}(), [client, getSession, addOauthProvider, pushPage, closeModal, handleDiscordOauth, handleXOauth, handleGoogleOauth, handleAppleOauth, handleFacebookOauth]);
|
|
6014
6062
|
var handleConnectExternalWallet = useCallback(/*#__PURE__*/function () {
|
|
6015
|
-
var
|
|
6063
|
+
var _ref138 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee110(params) {
|
|
6016
6064
|
var _masterConfig$walletC4, _masterConfig$walletC5;
|
|
6017
|
-
var
|
|
6018
|
-
return _regenerator().w(function (
|
|
6019
|
-
while (1) switch (
|
|
6065
|
+
var _ref139, _ref139$successPageDu, successPageDuration;
|
|
6066
|
+
return _regenerator().w(function (_context110) {
|
|
6067
|
+
while (1) switch (_context110.n) {
|
|
6020
6068
|
case 0:
|
|
6021
|
-
|
|
6069
|
+
_ref139 = params || {}, _ref139$successPageDu = _ref139.successPageDuration, successPageDuration = _ref139$successPageDu === void 0 ? 2000 : _ref139$successPageDu;
|
|
6022
6070
|
if (client) {
|
|
6023
|
-
|
|
6071
|
+
_context110.n = 1;
|
|
6024
6072
|
break;
|
|
6025
6073
|
}
|
|
6026
6074
|
throw new TurnkeyError("Client is not initialized.", TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
6027
6075
|
case 1:
|
|
6028
6076
|
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) {
|
|
6029
|
-
|
|
6077
|
+
_context110.n = 2;
|
|
6030
6078
|
break;
|
|
6031
6079
|
}
|
|
6032
6080
|
throw new TurnkeyError("Wallet connecting is not enabled.", TurnkeyErrorCodes.FEATURE_NOT_ENABLED);
|
|
6033
6081
|
case 2:
|
|
6034
|
-
return
|
|
6082
|
+
return _context110.a(2, new Promise(function (resolve, reject) {
|
|
6035
6083
|
pushPage({
|
|
6036
6084
|
key: "Connect wallet",
|
|
6037
6085
|
content: jsx(ConnectWalletModal, {
|
|
@@ -6049,32 +6097,32 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6049
6097
|
});
|
|
6050
6098
|
}));
|
|
6051
6099
|
}
|
|
6052
|
-
},
|
|
6100
|
+
}, _callee110);
|
|
6053
6101
|
}));
|
|
6054
|
-
return function (
|
|
6055
|
-
return
|
|
6102
|
+
return function (_x92) {
|
|
6103
|
+
return _ref138.apply(this, arguments);
|
|
6056
6104
|
};
|
|
6057
6105
|
}(), [client, masterConfig, fetchWalletProviders, pushPage]);
|
|
6058
6106
|
var handleRemoveUserEmail = useCallback(/*#__PURE__*/function () {
|
|
6059
|
-
var
|
|
6060
|
-
var
|
|
6061
|
-
return _regenerator().w(function (
|
|
6062
|
-
while (1) switch (
|
|
6107
|
+
var _ref140 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee111(params) {
|
|
6108
|
+
var _ref141, _ref141$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t32;
|
|
6109
|
+
return _regenerator().w(function (_context111) {
|
|
6110
|
+
while (1) switch (_context111.p = _context111.n) {
|
|
6063
6111
|
case 0:
|
|
6064
|
-
|
|
6065
|
-
|
|
6112
|
+
_ref141 = params || {}, _ref141$successPageDu = _ref141.successPageDuration, successPageDuration = _ref141$successPageDu === void 0 ? 2000 : _ref141$successPageDu, stampWith = _ref141.stampWith, userId = _ref141.userId;
|
|
6113
|
+
_context111.n = 1;
|
|
6066
6114
|
return getSession();
|
|
6067
6115
|
case 1:
|
|
6068
|
-
s =
|
|
6116
|
+
s = _context111.v;
|
|
6069
6117
|
organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
|
|
6070
6118
|
if (organizationId) {
|
|
6071
|
-
|
|
6119
|
+
_context111.n = 2;
|
|
6072
6120
|
break;
|
|
6073
6121
|
}
|
|
6074
6122
|
throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
6075
6123
|
case 2:
|
|
6076
|
-
|
|
6077
|
-
return
|
|
6124
|
+
_context111.p = 2;
|
|
6125
|
+
return _context111.a(2, new Promise(function (resolve, reject) {
|
|
6078
6126
|
pushPage({
|
|
6079
6127
|
key: "Remove Email",
|
|
6080
6128
|
content: jsx(RemoveEmail, _objectSpread2(_objectSpread2(_objectSpread2({
|
|
@@ -6101,44 +6149,44 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6101
6149
|
});
|
|
6102
6150
|
}));
|
|
6103
6151
|
case 3:
|
|
6104
|
-
|
|
6105
|
-
_t32 =
|
|
6152
|
+
_context111.p = 3;
|
|
6153
|
+
_t32 = _context111.v;
|
|
6106
6154
|
if (!(_t32 instanceof TurnkeyError)) {
|
|
6107
|
-
|
|
6155
|
+
_context111.n = 4;
|
|
6108
6156
|
break;
|
|
6109
6157
|
}
|
|
6110
6158
|
throw _t32;
|
|
6111
6159
|
case 4:
|
|
6112
6160
|
throw new TurnkeyError("Failed to remove user email.", TurnkeyErrorCodes.UPDATE_USER_EMAIL_ERROR, _t32);
|
|
6113
6161
|
case 5:
|
|
6114
|
-
return
|
|
6162
|
+
return _context111.a(2);
|
|
6115
6163
|
}
|
|
6116
|
-
},
|
|
6164
|
+
}, _callee111, null, [[2, 3]]);
|
|
6117
6165
|
}));
|
|
6118
|
-
return function (
|
|
6119
|
-
return
|
|
6166
|
+
return function (_x93) {
|
|
6167
|
+
return _ref140.apply(this, arguments);
|
|
6120
6168
|
};
|
|
6121
6169
|
}(), [getSession, pushPage]);
|
|
6122
6170
|
var handleRemoveUserPhoneNumber = useCallback(/*#__PURE__*/function () {
|
|
6123
|
-
var
|
|
6124
|
-
var
|
|
6125
|
-
return _regenerator().w(function (
|
|
6126
|
-
while (1) switch (
|
|
6171
|
+
var _ref142 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee112(params) {
|
|
6172
|
+
var _ref143, _ref143$successPageDu, successPageDuration, stampWith, userId, s, organizationId, _t33;
|
|
6173
|
+
return _regenerator().w(function (_context112) {
|
|
6174
|
+
while (1) switch (_context112.p = _context112.n) {
|
|
6127
6175
|
case 0:
|
|
6128
|
-
|
|
6129
|
-
|
|
6176
|
+
_ref143 = params || {}, _ref143$successPageDu = _ref143.successPageDuration, successPageDuration = _ref143$successPageDu === void 0 ? 2000 : _ref143$successPageDu, stampWith = _ref143.stampWith, userId = _ref143.userId;
|
|
6177
|
+
_context112.n = 1;
|
|
6130
6178
|
return getSession();
|
|
6131
6179
|
case 1:
|
|
6132
|
-
s =
|
|
6180
|
+
s = _context112.v;
|
|
6133
6181
|
organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
|
|
6134
6182
|
if (organizationId) {
|
|
6135
|
-
|
|
6183
|
+
_context112.n = 2;
|
|
6136
6184
|
break;
|
|
6137
6185
|
}
|
|
6138
6186
|
throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
6139
6187
|
case 2:
|
|
6140
|
-
|
|
6141
|
-
return
|
|
6188
|
+
_context112.p = 2;
|
|
6189
|
+
return _context112.a(2, new Promise(function (resolve, reject) {
|
|
6142
6190
|
pushPage({
|
|
6143
6191
|
key: "Remove Phone Number",
|
|
6144
6192
|
content: jsx(RemovePhoneNumber, _objectSpread2(_objectSpread2(_objectSpread2({
|
|
@@ -6165,67 +6213,179 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6165
6213
|
});
|
|
6166
6214
|
}));
|
|
6167
6215
|
case 3:
|
|
6168
|
-
|
|
6169
|
-
_t33 =
|
|
6216
|
+
_context112.p = 3;
|
|
6217
|
+
_t33 = _context112.v;
|
|
6170
6218
|
if (!(_t33 instanceof TurnkeyError)) {
|
|
6171
|
-
|
|
6219
|
+
_context112.n = 4;
|
|
6172
6220
|
break;
|
|
6173
6221
|
}
|
|
6174
6222
|
throw _t33;
|
|
6175
6223
|
case 4:
|
|
6176
6224
|
throw new TurnkeyError("Failed to remove user phone number.", TurnkeyErrorCodes.UPDATE_USER_PHONE_NUMBER_ERROR, _t33);
|
|
6177
6225
|
case 5:
|
|
6178
|
-
return
|
|
6226
|
+
return _context112.a(2);
|
|
6179
6227
|
}
|
|
6180
|
-
},
|
|
6228
|
+
}, _callee112, null, [[2, 3]]);
|
|
6181
6229
|
}));
|
|
6182
|
-
return function (
|
|
6183
|
-
return
|
|
6230
|
+
return function (_x94) {
|
|
6231
|
+
return _ref142.apply(this, arguments);
|
|
6184
6232
|
};
|
|
6185
6233
|
}(), [getSession, pushPage]);
|
|
6234
|
+
var handleSendTransaction = useCallback(/*#__PURE__*/function () {
|
|
6235
|
+
var _ref144 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee114(params) {
|
|
6236
|
+
var session, organizationId, transaction, icon, stampWith, _params$successPageDu5, successPageDuration, from, to, caip2, value, data, nonce, gasLimit, maxFeePerGas, maxPriorityFeePerGas, sponsor, cleanedData;
|
|
6237
|
+
return _regenerator().w(function (_context114) {
|
|
6238
|
+
while (1) switch (_context114.n) {
|
|
6239
|
+
case 0:
|
|
6240
|
+
_context114.n = 1;
|
|
6241
|
+
return getSession();
|
|
6242
|
+
case 1:
|
|
6243
|
+
session = _context114.v;
|
|
6244
|
+
organizationId = params.organizationId || (session === null || session === void 0 ? void 0 : session.organizationId);
|
|
6245
|
+
if (organizationId) {
|
|
6246
|
+
_context114.n = 2;
|
|
6247
|
+
break;
|
|
6248
|
+
}
|
|
6249
|
+
throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
6250
|
+
case 2:
|
|
6251
|
+
transaction = params.transaction, icon = params.icon, stampWith = params.stampWith, _params$successPageDu5 = params.successPageDuration, successPageDuration = _params$successPageDu5 === void 0 ? 2000 : _params$successPageDu5;
|
|
6252
|
+
from = transaction.from, to = transaction.to, caip2 = transaction.caip2, value = transaction.value, data = transaction.data, nonce = transaction.nonce, gasLimit = transaction.gasLimit, maxFeePerGas = transaction.maxFeePerGas, maxPriorityFeePerGas = transaction.maxPriorityFeePerGas, sponsor = transaction.sponsor;
|
|
6253
|
+
cleanedData = data && data !== "0x" && data !== "" ? data : undefined;
|
|
6254
|
+
return _context114.a(2, new Promise(function (resolve, reject) {
|
|
6255
|
+
var action = /*#__PURE__*/function () {
|
|
6256
|
+
var _ref145 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee113() {
|
|
6257
|
+
var _pollResult$eth;
|
|
6258
|
+
var tx, sendTransactionStatusId, pollResult, txHash;
|
|
6259
|
+
return _regenerator().w(function (_context113) {
|
|
6260
|
+
while (1) switch (_context113.n) {
|
|
6261
|
+
case 0:
|
|
6262
|
+
tx = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
6263
|
+
from: from,
|
|
6264
|
+
to: to,
|
|
6265
|
+
caip2: caip2,
|
|
6266
|
+
sponsor: sponsor !== null && sponsor !== void 0 ? sponsor : false
|
|
6267
|
+
}, value ? {
|
|
6268
|
+
value: value
|
|
6269
|
+
} : {}), cleanedData ? {
|
|
6270
|
+
data: cleanedData
|
|
6271
|
+
} : {}), nonce ? {
|
|
6272
|
+
nonce: nonce
|
|
6273
|
+
} : {}), gasLimit ? {
|
|
6274
|
+
gasLimit: gasLimit
|
|
6275
|
+
} : {}), maxFeePerGas ? {
|
|
6276
|
+
maxFeePerGas: maxFeePerGas
|
|
6277
|
+
} : {}), maxPriorityFeePerGas ? {
|
|
6278
|
+
maxPriorityFeePerGas: maxPriorityFeePerGas
|
|
6279
|
+
} : {});
|
|
6280
|
+
_context113.n = 1;
|
|
6281
|
+
return ethSendTransaction({
|
|
6282
|
+
organizationId: organizationId,
|
|
6283
|
+
transaction: tx,
|
|
6284
|
+
stampWith: stampWith
|
|
6285
|
+
});
|
|
6286
|
+
case 1:
|
|
6287
|
+
sendTransactionStatusId = _context113.v;
|
|
6288
|
+
if (sendTransactionStatusId) {
|
|
6289
|
+
_context113.n = 2;
|
|
6290
|
+
break;
|
|
6291
|
+
}
|
|
6292
|
+
throw new TurnkeyError("Missing sendTransactionStatusId", TurnkeyErrorCodes.ETH_SEND_TRANSACTION_ERROR);
|
|
6293
|
+
case 2:
|
|
6294
|
+
_context113.n = 3;
|
|
6295
|
+
return pollTransactionStatus({
|
|
6296
|
+
organizationId: organizationId,
|
|
6297
|
+
sendTransactionStatusId: sendTransactionStatusId
|
|
6298
|
+
});
|
|
6299
|
+
case 3:
|
|
6300
|
+
pollResult = _context113.v;
|
|
6301
|
+
txHash = pollResult === null || pollResult === void 0 ? void 0 : (_pollResult$eth = pollResult.eth) === null || _pollResult$eth === void 0 ? void 0 : _pollResult$eth.txHash;
|
|
6302
|
+
if (txHash) {
|
|
6303
|
+
_context113.n = 4;
|
|
6304
|
+
break;
|
|
6305
|
+
}
|
|
6306
|
+
throw new TurnkeyError("Missing txHash in transaction result", TurnkeyErrorCodes.POLL_TRANSACTION_STATUS_ERROR);
|
|
6307
|
+
case 4:
|
|
6308
|
+
return _context113.a(2, {
|
|
6309
|
+
txHash: txHash
|
|
6310
|
+
});
|
|
6311
|
+
}
|
|
6312
|
+
}, _callee113);
|
|
6313
|
+
}));
|
|
6314
|
+
return function action() {
|
|
6315
|
+
return _ref145.apply(this, arguments);
|
|
6316
|
+
};
|
|
6317
|
+
}();
|
|
6318
|
+
pushPage({
|
|
6319
|
+
key: "Send Transaction",
|
|
6320
|
+
showTitle: false,
|
|
6321
|
+
preventBack: true,
|
|
6322
|
+
onClose: function onClose() {
|
|
6323
|
+
return reject(new TurnkeyError("User canceled the transaction.", TurnkeyErrorCodes.USER_CANCELED));
|
|
6324
|
+
},
|
|
6325
|
+
content: jsx(SendTransactionPage, {
|
|
6326
|
+
icon: icon !== null && icon !== void 0 ? icon : getChainLogo(caip2),
|
|
6327
|
+
action: action,
|
|
6328
|
+
caip2: caip2,
|
|
6329
|
+
successPageDuration: successPageDuration,
|
|
6330
|
+
onSuccess: function onSuccess() {
|
|
6331
|
+
return resolve();
|
|
6332
|
+
},
|
|
6333
|
+
onError: function onError(err) {
|
|
6334
|
+
return reject(err);
|
|
6335
|
+
}
|
|
6336
|
+
})
|
|
6337
|
+
});
|
|
6338
|
+
}));
|
|
6339
|
+
}
|
|
6340
|
+
}, _callee114);
|
|
6341
|
+
}));
|
|
6342
|
+
return function (_x95) {
|
|
6343
|
+
return _ref144.apply(this, arguments);
|
|
6344
|
+
};
|
|
6345
|
+
}(), [pushPage, client]);
|
|
6186
6346
|
var handleOnRamp = useCallback(/*#__PURE__*/function () {
|
|
6187
|
-
var
|
|
6347
|
+
var _ref146 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee117(params) {
|
|
6188
6348
|
var _walletAccount$addres;
|
|
6189
|
-
var walletAccount, fiatCurrencyAmount, fiatCurrencyCode, paymentMethod, countrySubdivisionCode, urlForSignature, countryCode, _params$onrampProvide, onrampProvider, _params$sandboxMode, sandboxMode, _params$
|
|
6190
|
-
return _regenerator().w(function (
|
|
6191
|
-
while (1) switch (
|
|
6349
|
+
var walletAccount, fiatCurrencyAmount, fiatCurrencyCode, paymentMethod, countrySubdivisionCode, urlForSignature, countryCode, _params$onrampProvide, onrampProvider, _params$sandboxMode, sandboxMode, _params$successPageDu6, successPageDuration, _params$openInNewTab, openInNewTab, s, organizationId, cryptoCurrencyCode, network, openNewTab, _t36;
|
|
6350
|
+
return _regenerator().w(function (_context117) {
|
|
6351
|
+
while (1) switch (_context117.n) {
|
|
6192
6352
|
case 0:
|
|
6193
|
-
walletAccount = params.walletAccount, fiatCurrencyAmount = params.fiatCurrencyAmount, fiatCurrencyCode = params.fiatCurrencyCode, paymentMethod = params.paymentMethod, countrySubdivisionCode = params.countrySubdivisionCode, urlForSignature = params.urlForSignature, countryCode = params.countryCode, _params$onrampProvide = params.onrampProvider, onrampProvider = _params$onrampProvide === void 0 ? "FIAT_ON_RAMP_PROVIDER_MOONPAY" : _params$onrampProvide, _params$sandboxMode = params.sandboxMode, sandboxMode = _params$sandboxMode === void 0 ? true : _params$sandboxMode, _params$
|
|
6194
|
-
|
|
6353
|
+
walletAccount = params.walletAccount, fiatCurrencyAmount = params.fiatCurrencyAmount, fiatCurrencyCode = params.fiatCurrencyCode, paymentMethod = params.paymentMethod, countrySubdivisionCode = params.countrySubdivisionCode, urlForSignature = params.urlForSignature, countryCode = params.countryCode, _params$onrampProvide = params.onrampProvider, onrampProvider = _params$onrampProvide === void 0 ? "FIAT_ON_RAMP_PROVIDER_MOONPAY" : _params$onrampProvide, _params$sandboxMode = params.sandboxMode, sandboxMode = _params$sandboxMode === void 0 ? true : _params$sandboxMode, _params$successPageDu6 = params.successPageDuration, successPageDuration = _params$successPageDu6 === void 0 ? 2000 : _params$successPageDu6, _params$openInNewTab = params.openInNewTab, openInNewTab = _params$openInNewTab === void 0 ? false : _params$openInNewTab;
|
|
6354
|
+
_context117.n = 1;
|
|
6195
6355
|
return getSession();
|
|
6196
6356
|
case 1:
|
|
6197
|
-
s =
|
|
6357
|
+
s = _context117.v;
|
|
6198
6358
|
organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
|
|
6199
6359
|
if (organizationId) {
|
|
6200
|
-
|
|
6360
|
+
_context117.n = 2;
|
|
6201
6361
|
break;
|
|
6202
6362
|
}
|
|
6203
6363
|
throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
6204
6364
|
case 2:
|
|
6205
6365
|
_t36 = true;
|
|
6206
|
-
|
|
6366
|
+
_context117.n = _t36 === (walletAccount.addressFormat === "ADDRESS_FORMAT_ETHEREUM") ? 3 : _t36 === ((_walletAccount$addres = walletAccount.addressFormat) === null || _walletAccount$addres === void 0 ? void 0 : _walletAccount$addres.includes("ADDRESS_FORMAT_BITCOIN")) ? 4 : _t36 === (walletAccount.addressFormat === "ADDRESS_FORMAT_SOLANA") ? 5 : 6;
|
|
6207
6367
|
break;
|
|
6208
6368
|
case 3:
|
|
6209
6369
|
cryptoCurrencyCode = FiatOnRampCryptoCurrency.ETHEREUM;
|
|
6210
6370
|
network = FiatOnRampBlockchainNetwork.ETHEREUM;
|
|
6211
|
-
return
|
|
6371
|
+
return _context117.a(3, 7);
|
|
6212
6372
|
case 4:
|
|
6213
6373
|
cryptoCurrencyCode = FiatOnRampCryptoCurrency.BITCOIN;
|
|
6214
6374
|
network = FiatOnRampBlockchainNetwork.BITCOIN;
|
|
6215
|
-
return
|
|
6375
|
+
return _context117.a(3, 7);
|
|
6216
6376
|
case 5:
|
|
6217
6377
|
cryptoCurrencyCode = FiatOnRampCryptoCurrency.SOLANA;
|
|
6218
6378
|
network = FiatOnRampBlockchainNetwork.SOLANA;
|
|
6219
|
-
return
|
|
6379
|
+
return _context117.a(3, 7);
|
|
6220
6380
|
case 6:
|
|
6221
6381
|
cryptoCurrencyCode = FiatOnRampCryptoCurrency.ETHEREUM;
|
|
6222
6382
|
network = FiatOnRampBlockchainNetwork.ETHEREUM;
|
|
6223
|
-
return
|
|
6383
|
+
return _context117.a(3, 7);
|
|
6224
6384
|
case 7:
|
|
6225
6385
|
openNewTab = openInNewTab || isMobile;
|
|
6226
6386
|
cryptoCurrencyCode = params.cryptoCurrencyCode || cryptoCurrencyCode;
|
|
6227
6387
|
network = params.network || network;
|
|
6228
|
-
return
|
|
6388
|
+
return _context117.a(2, new Promise(function (resolve, reject) {
|
|
6229
6389
|
var OnRampContainer = function OnRampContainer() {
|
|
6230
6390
|
var _useState15 = useState(false),
|
|
6231
6391
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
@@ -6244,25 +6404,25 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6244
6404
|
};
|
|
6245
6405
|
}, []);
|
|
6246
6406
|
var action = /*#__PURE__*/function () {
|
|
6247
|
-
var
|
|
6407
|
+
var _ref147 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee116() {
|
|
6248
6408
|
var _client$httpClient, onRampWindow, result, _popupWidth, _popupHeight, left, top, onRampTransactionId, _t35;
|
|
6249
|
-
return _regenerator().w(function (
|
|
6250
|
-
while (1) switch (
|
|
6409
|
+
return _regenerator().w(function (_context116) {
|
|
6410
|
+
while (1) switch (_context116.p = _context116.n) {
|
|
6251
6411
|
case 0:
|
|
6252
|
-
|
|
6412
|
+
_context116.p = 0;
|
|
6253
6413
|
onRampWindow = null;
|
|
6254
6414
|
if (!openNewTab) {
|
|
6255
|
-
|
|
6415
|
+
_context116.n = 1;
|
|
6256
6416
|
break;
|
|
6257
6417
|
}
|
|
6258
6418
|
onRampWindow = window.open("", "_blank");
|
|
6259
6419
|
if (onRampWindow) {
|
|
6260
|
-
|
|
6420
|
+
_context116.n = 1;
|
|
6261
6421
|
break;
|
|
6262
6422
|
}
|
|
6263
6423
|
throw new Error("Failed to open On Ramp tab.");
|
|
6264
6424
|
case 1:
|
|
6265
|
-
|
|
6425
|
+
_context116.n = 2;
|
|
6266
6426
|
return client === null || client === void 0 ? void 0 : (_client$httpClient = client.httpClient) === null || _client$httpClient === void 0 ? void 0 : _client$httpClient.initFiatOnRamp(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
6267
6427
|
onrampProvider: onrampProvider,
|
|
6268
6428
|
walletAddress: walletAccount.address,
|
|
@@ -6286,19 +6446,19 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6286
6446
|
urlForSignature: urlForSignature
|
|
6287
6447
|
} : {}));
|
|
6288
6448
|
case 2:
|
|
6289
|
-
result =
|
|
6449
|
+
result = _context116.v;
|
|
6290
6450
|
if (result !== null && result !== void 0 && result.onRampUrl) {
|
|
6291
|
-
|
|
6451
|
+
_context116.n = 3;
|
|
6292
6452
|
break;
|
|
6293
6453
|
}
|
|
6294
6454
|
throw new Error("Missing onRampUrl");
|
|
6295
6455
|
case 3:
|
|
6296
6456
|
if (!(openNewTab && onRampWindow)) {
|
|
6297
|
-
|
|
6457
|
+
_context116.n = 4;
|
|
6298
6458
|
break;
|
|
6299
6459
|
}
|
|
6300
6460
|
onRampWindow.location.href = result.onRampUrl.toString();
|
|
6301
|
-
|
|
6461
|
+
_context116.n = 5;
|
|
6302
6462
|
break;
|
|
6303
6463
|
case 4:
|
|
6304
6464
|
_popupWidth = 500;
|
|
@@ -6307,54 +6467,54 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6307
6467
|
top = window.screenY + (window.innerHeight - _popupHeight) / 2;
|
|
6308
6468
|
onRampWindow = window.open(result.onRampUrl.toString(), "_blank", "width=".concat(_popupWidth, ",height=").concat(_popupHeight, ",top=").concat(top, ",left=").concat(left, ",scrollbars=yes,resizable=yes"));
|
|
6309
6469
|
if (onRampWindow) {
|
|
6310
|
-
|
|
6470
|
+
_context116.n = 5;
|
|
6311
6471
|
break;
|
|
6312
6472
|
}
|
|
6313
6473
|
throw new Error("Failed to open On Ramp window.");
|
|
6314
6474
|
case 5:
|
|
6315
6475
|
onRampTransactionId = result.onRampTransactionId;
|
|
6316
6476
|
if (onRampTransactionId) {
|
|
6317
|
-
|
|
6477
|
+
_context116.n = 6;
|
|
6318
6478
|
break;
|
|
6319
6479
|
}
|
|
6320
6480
|
throw new Error("No onRampTransactionId returned");
|
|
6321
6481
|
case 6:
|
|
6322
|
-
return
|
|
6323
|
-
pollingRef.current = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
6482
|
+
return _context116.a(2, new Promise(function (resolveAction, rejectAction) {
|
|
6483
|
+
pollingRef.current = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee115() {
|
|
6324
6484
|
var _onRampWindow, _client$httpClient2, currentUrl, _onRampWindow2, _onRampWindow3, resp, status, _onRampWindow4, _t34;
|
|
6325
|
-
return _regenerator().w(function (
|
|
6326
|
-
while (1) switch (
|
|
6485
|
+
return _regenerator().w(function (_context115) {
|
|
6486
|
+
while (1) switch (_context115.p = _context115.n) {
|
|
6327
6487
|
case 0:
|
|
6328
|
-
|
|
6488
|
+
_context115.p = 0;
|
|
6329
6489
|
if (!(onrampProvider === "FIAT_ON_RAMP_PROVIDER_COINBASE" && (_onRampWindow = onRampWindow) !== null && _onRampWindow !== void 0 && _onRampWindow.closed)) {
|
|
6330
|
-
|
|
6490
|
+
_context115.n = 1;
|
|
6331
6491
|
break;
|
|
6332
6492
|
}
|
|
6333
6493
|
cleanup();
|
|
6334
6494
|
rejectAction(new Error("On-ramp popup closed by user"));
|
|
6335
|
-
return
|
|
6495
|
+
return _context115.a(2);
|
|
6336
6496
|
case 1:
|
|
6337
6497
|
currentUrl = "";
|
|
6338
6498
|
try {
|
|
6339
6499
|
currentUrl = ((_onRampWindow2 = onRampWindow) === null || _onRampWindow2 === void 0 ? void 0 : _onRampWindow2.location.href) || "";
|
|
6340
6500
|
} catch (_unused3) {}
|
|
6341
6501
|
if (!(currentUrl && currentUrl.startsWith(window.location.origin))) {
|
|
6342
|
-
|
|
6502
|
+
_context115.n = 2;
|
|
6343
6503
|
break;
|
|
6344
6504
|
}
|
|
6345
6505
|
cleanup();
|
|
6346
6506
|
(_onRampWindow3 = onRampWindow) === null || _onRampWindow3 === void 0 ? void 0 : _onRampWindow3.close();
|
|
6347
6507
|
setCompleted(true);
|
|
6348
6508
|
resolveAction();
|
|
6349
|
-
return
|
|
6509
|
+
return _context115.a(2);
|
|
6350
6510
|
case 2:
|
|
6351
|
-
|
|
6511
|
+
_context115.n = 3;
|
|
6352
6512
|
return client === null || client === void 0 ? void 0 : (_client$httpClient2 = client.httpClient) === null || _client$httpClient2 === void 0 ? void 0 : _client$httpClient2.getOnRampTransactionStatus({
|
|
6353
6513
|
transactionId: onRampTransactionId,
|
|
6354
6514
|
refresh: true
|
|
6355
6515
|
});
|
|
6356
6516
|
case 3:
|
|
6357
|
-
resp =
|
|
6517
|
+
resp = _context115.v;
|
|
6358
6518
|
status = resp === null || resp === void 0 ? void 0 : resp.transactionStatus;
|
|
6359
6519
|
if (["COMPLETED", "FAILED", "CANCELLED"].includes(status !== null && status !== void 0 ? status : "")) {
|
|
6360
6520
|
cleanup();
|
|
@@ -6364,30 +6524,30 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6364
6524
|
setCompleted(true);
|
|
6365
6525
|
resolveAction();
|
|
6366
6526
|
}
|
|
6367
|
-
|
|
6527
|
+
_context115.n = 5;
|
|
6368
6528
|
break;
|
|
6369
6529
|
case 4:
|
|
6370
|
-
|
|
6371
|
-
_t34 =
|
|
6530
|
+
_context115.p = 4;
|
|
6531
|
+
_t34 = _context115.v;
|
|
6372
6532
|
console.warn("Polling error (ignored):", _t34);
|
|
6373
6533
|
case 5:
|
|
6374
|
-
return
|
|
6534
|
+
return _context115.a(2);
|
|
6375
6535
|
}
|
|
6376
|
-
},
|
|
6536
|
+
}, _callee115, null, [[0, 4]]);
|
|
6377
6537
|
})), 3000);
|
|
6378
6538
|
}));
|
|
6379
6539
|
case 7:
|
|
6380
|
-
|
|
6381
|
-
_t35 =
|
|
6540
|
+
_context116.p = 7;
|
|
6541
|
+
_t35 = _context116.v;
|
|
6382
6542
|
cleanup();
|
|
6383
6543
|
throw _t35;
|
|
6384
6544
|
case 8:
|
|
6385
|
-
return
|
|
6545
|
+
return _context116.a(2);
|
|
6386
6546
|
}
|
|
6387
|
-
},
|
|
6547
|
+
}, _callee116, null, [[0, 7]]);
|
|
6388
6548
|
}));
|
|
6389
6549
|
return function action() {
|
|
6390
|
-
return
|
|
6550
|
+
return _ref147.apply(this, arguments);
|
|
6391
6551
|
};
|
|
6392
6552
|
}();
|
|
6393
6553
|
return jsx(OnRampPage, {
|
|
@@ -6420,32 +6580,32 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6420
6580
|
});
|
|
6421
6581
|
}));
|
|
6422
6582
|
}
|
|
6423
|
-
},
|
|
6583
|
+
}, _callee117);
|
|
6424
6584
|
}));
|
|
6425
|
-
return function (
|
|
6426
|
-
return
|
|
6585
|
+
return function (_x96) {
|
|
6586
|
+
return _ref146.apply(this, arguments);
|
|
6427
6587
|
};
|
|
6428
6588
|
}(), [getSession, client, pushPage]);
|
|
6429
6589
|
var handleVerifyAppProofs = useCallback(/*#__PURE__*/function () {
|
|
6430
|
-
var
|
|
6431
|
-
var
|
|
6432
|
-
return _regenerator().w(function (
|
|
6433
|
-
while (1) switch (
|
|
6590
|
+
var _ref149 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee118(params) {
|
|
6591
|
+
var _ref150, appProofs, _ref150$successPageDu, successPageDuration, stampWith, s, organizationId, _t37;
|
|
6592
|
+
return _regenerator().w(function (_context118) {
|
|
6593
|
+
while (1) switch (_context118.p = _context118.n) {
|
|
6434
6594
|
case 0:
|
|
6435
|
-
|
|
6436
|
-
|
|
6595
|
+
_ref150 = params || {}, appProofs = _ref150.appProofs, _ref150$successPageDu = _ref150.successPageDuration, successPageDuration = _ref150$successPageDu === void 0 ? 3000 : _ref150$successPageDu, stampWith = _ref150.stampWith;
|
|
6596
|
+
_context118.n = 1;
|
|
6437
6597
|
return getSession();
|
|
6438
6598
|
case 1:
|
|
6439
|
-
s =
|
|
6599
|
+
s = _context118.v;
|
|
6440
6600
|
organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || (s === null || s === void 0 ? void 0 : s.organizationId);
|
|
6441
6601
|
if (organizationId) {
|
|
6442
|
-
|
|
6602
|
+
_context118.n = 2;
|
|
6443
6603
|
break;
|
|
6444
6604
|
}
|
|
6445
6605
|
throw new TurnkeyError("A session or passed in organization ID is required.", TurnkeyErrorCodes.INVALID_REQUEST);
|
|
6446
6606
|
case 2:
|
|
6447
|
-
|
|
6448
|
-
return
|
|
6607
|
+
_context118.p = 2;
|
|
6608
|
+
return _context118.a(2, new Promise(function (resolve, reject) {
|
|
6449
6609
|
pushPage({
|
|
6450
6610
|
key: "Verify app proofs",
|
|
6451
6611
|
showTurnkeyBranding: false,
|
|
@@ -6471,60 +6631,60 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6471
6631
|
});
|
|
6472
6632
|
}));
|
|
6473
6633
|
case 3:
|
|
6474
|
-
|
|
6475
|
-
_t37 =
|
|
6634
|
+
_context118.p = 3;
|
|
6635
|
+
_t37 = _context118.v;
|
|
6476
6636
|
if (!(_t37 instanceof TurnkeyError)) {
|
|
6477
|
-
|
|
6637
|
+
_context118.n = 4;
|
|
6478
6638
|
break;
|
|
6479
6639
|
}
|
|
6480
6640
|
throw _t37;
|
|
6481
6641
|
case 4:
|
|
6482
6642
|
throw new TurnkeyError("Failed to verify app proofs.", TurnkeyErrorCodes.VERIFY_APP_PROOFS_ERROR, _t37);
|
|
6483
6643
|
case 5:
|
|
6484
|
-
return
|
|
6644
|
+
return _context118.a(2);
|
|
6485
6645
|
}
|
|
6486
|
-
},
|
|
6646
|
+
}, _callee118, null, [[2, 3]]);
|
|
6487
6647
|
}));
|
|
6488
|
-
return function (
|
|
6489
|
-
return
|
|
6648
|
+
return function (_x97) {
|
|
6649
|
+
return _ref149.apply(this, arguments);
|
|
6490
6650
|
};
|
|
6491
6651
|
}(), [getSession, pushPage]);
|
|
6492
6652
|
useEffect(function () {
|
|
6493
6653
|
if (proxyAuthConfigRef.current) return;
|
|
6494
6654
|
// Only fetch the proxy auth config once. Use that to build the master config.
|
|
6495
6655
|
var fetchProxyAuthConfig = /*#__PURE__*/function () {
|
|
6496
|
-
var
|
|
6656
|
+
var _ref151 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee119() {
|
|
6497
6657
|
var proxyAuthConfig;
|
|
6498
|
-
return _regenerator().w(function (
|
|
6499
|
-
while (1) switch (
|
|
6658
|
+
return _regenerator().w(function (_context119) {
|
|
6659
|
+
while (1) switch (_context119.p = _context119.n) {
|
|
6500
6660
|
case 0:
|
|
6501
|
-
|
|
6661
|
+
_context119.p = 0;
|
|
6502
6662
|
if (!shouldFetchWalletKitConfig) {
|
|
6503
|
-
|
|
6663
|
+
_context119.n = 2;
|
|
6504
6664
|
break;
|
|
6505
6665
|
}
|
|
6506
|
-
|
|
6666
|
+
_context119.n = 1;
|
|
6507
6667
|
return getAuthProxyConfig(config.authProxyConfigId,
|
|
6508
6668
|
// Can assert safely. See shouldFetchWalletKitConfig definition.
|
|
6509
6669
|
config.authProxyUrl);
|
|
6510
6670
|
case 1:
|
|
6511
|
-
proxyAuthConfig =
|
|
6671
|
+
proxyAuthConfig = _context119.v;
|
|
6512
6672
|
proxyAuthConfigRef.current = proxyAuthConfig;
|
|
6513
6673
|
case 2:
|
|
6514
6674
|
setMasterConfig(buildConfig(proxyAuthConfig));
|
|
6515
|
-
|
|
6675
|
+
_context119.n = 4;
|
|
6516
6676
|
break;
|
|
6517
6677
|
case 3:
|
|
6518
|
-
|
|
6519
|
-
|
|
6678
|
+
_context119.p = 3;
|
|
6679
|
+
_context119.v;
|
|
6520
6680
|
setClientState(ClientState.Error);
|
|
6521
6681
|
case 4:
|
|
6522
|
-
return
|
|
6682
|
+
return _context119.a(2);
|
|
6523
6683
|
}
|
|
6524
|
-
},
|
|
6684
|
+
}, _callee119, null, [[0, 3]]);
|
|
6525
6685
|
}));
|
|
6526
6686
|
return function fetchProxyAuthConfig() {
|
|
6527
|
-
return
|
|
6687
|
+
return _ref151.apply(this, arguments);
|
|
6528
6688
|
};
|
|
6529
6689
|
}();
|
|
6530
6690
|
fetchProxyAuthConfig();
|
|
@@ -6557,34 +6717,34 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6557
6717
|
var debouncedFetchWalletProviders = useDebouncedCallback(fetchWalletProviders, 100);
|
|
6558
6718
|
useEffect(function () {
|
|
6559
6719
|
var handleUpdateState = /*#__PURE__*/function () {
|
|
6560
|
-
var
|
|
6720
|
+
var _ref152 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee120() {
|
|
6561
6721
|
var currentSession;
|
|
6562
|
-
return _regenerator().w(function (
|
|
6563
|
-
while (1) switch (
|
|
6722
|
+
return _regenerator().w(function (_context120) {
|
|
6723
|
+
while (1) switch (_context120.n) {
|
|
6564
6724
|
case 0:
|
|
6565
|
-
|
|
6725
|
+
_context120.n = 1;
|
|
6566
6726
|
return getSession();
|
|
6567
6727
|
case 1:
|
|
6568
|
-
currentSession =
|
|
6728
|
+
currentSession = _context120.v;
|
|
6569
6729
|
if (!currentSession) {
|
|
6570
|
-
|
|
6730
|
+
_context120.n = 3;
|
|
6571
6731
|
break;
|
|
6572
6732
|
}
|
|
6573
|
-
|
|
6733
|
+
_context120.n = 2;
|
|
6574
6734
|
return debouncedRefreshWallets();
|
|
6575
6735
|
case 2:
|
|
6576
|
-
|
|
6736
|
+
_context120.n = 4;
|
|
6577
6737
|
break;
|
|
6578
6738
|
case 3:
|
|
6579
|
-
|
|
6739
|
+
_context120.n = 4;
|
|
6580
6740
|
return debouncedFetchWalletProviders();
|
|
6581
6741
|
case 4:
|
|
6582
|
-
return
|
|
6742
|
+
return _context120.a(2);
|
|
6583
6743
|
}
|
|
6584
|
-
},
|
|
6744
|
+
}, _callee120);
|
|
6585
6745
|
}));
|
|
6586
6746
|
return function handleUpdateState() {
|
|
6587
|
-
return
|
|
6747
|
+
return _ref152.apply(this, arguments);
|
|
6588
6748
|
};
|
|
6589
6749
|
}();
|
|
6590
6750
|
var cleanup = function cleanup() {};
|
|
@@ -6664,7 +6824,9 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6664
6824
|
refreshWallets: refreshWallets,
|
|
6665
6825
|
signMessage: signMessage,
|
|
6666
6826
|
signTransaction: signTransaction,
|
|
6827
|
+
ethSendTransaction: ethSendTransaction,
|
|
6667
6828
|
signAndSendTransaction: signAndSendTransaction,
|
|
6829
|
+
pollTransactionStatus: pollTransactionStatus,
|
|
6668
6830
|
fetchUser: fetchUser,
|
|
6669
6831
|
fetchOrCreateP256ApiKeyUser: fetchOrCreateP256ApiKeyUser,
|
|
6670
6832
|
fetchOrCreatePolicies: fetchOrCreatePolicies,
|
|
@@ -6724,7 +6886,8 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6724
6886
|
handleRemoveUserEmail: handleRemoveUserEmail,
|
|
6725
6887
|
handleRemoveUserPhoneNumber: handleRemoveUserPhoneNumber,
|
|
6726
6888
|
handleVerifyAppProofs: handleVerifyAppProofs,
|
|
6727
|
-
handleOnRamp: handleOnRamp
|
|
6889
|
+
handleOnRamp: handleOnRamp,
|
|
6890
|
+
handleSendTransaction: handleSendTransaction
|
|
6728
6891
|
},
|
|
6729
6892
|
children: children
|
|
6730
6893
|
});
|