@dynamic-labs/sdk-react-core 2.0.0-alpha.31 → 2.0.0-alpha.32
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/CHANGELOG.md +2 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +14 -14
- package/src/index.d.ts +1 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +21 -6
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +16 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.cjs +17 -3
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.js +15 -1
- package/src/lib/context/ConnectWithOtpContext/utils/findEmailProvider.cjs +19 -4
- package/src/lib/context/ConnectWithOtpContext/utils/findEmailProvider.js +16 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +17 -17
- package/src/lib/context/DynamicContext/DynamicContext.js +3 -3
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +6 -6
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +5 -5
- package/src/lib/context/FundingContext/FundingContext.cjs +6 -6
- package/src/lib/context/FundingContext/FundingContext.js +5 -5
- package/src/lib/context/PasskeyContext/PasskeyContext.cjs +4 -4
- package/src/lib/context/PasskeyContext/PasskeyContext.js +3 -3
- package/src/lib/data/api/api.cjs +24 -0
- package/src/lib/data/api/api.d.ts +2 -0
- package/src/lib/data/api/api.js +20 -0
- package/src/lib/data/api/email/email.cjs +118 -0
- package/src/lib/data/api/email/email.d.ts +26 -0
- package/src/lib/data/api/email/email.js +110 -0
- package/src/lib/data/api/email/index.d.ts +1 -0
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +191 -0
- package/src/lib/data/api/embeddedWallets/embeddedWallets.d.ts +30 -0
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +177 -0
- package/src/lib/data/api/embeddedWallets/index.d.ts +2 -0
- package/src/lib/data/api/embeddedWallets/types.d.ts +39 -0
- package/src/lib/data/api/index.d.ts +10 -0
- package/src/lib/data/api/oauth/index.d.ts +1 -0
- package/src/lib/data/api/oauth/oauth.cjs +136 -0
- package/src/lib/data/api/oauth/oauth.d.ts +11 -0
- package/src/lib/data/api/oauth/oauth.js +128 -0
- package/src/lib/data/api/onramp/index.d.ts +1 -0
- package/src/lib/data/api/onramp/onramp.cjs +22 -0
- package/src/lib/data/api/onramp/onramp.d.ts +8 -0
- package/src/lib/data/api/onramp/onramp.js +18 -0
- package/src/lib/data/api/session/index.d.ts +1 -0
- package/src/lib/data/api/session/session.cjs +77 -0
- package/src/lib/data/api/session/session.d.ts +17 -0
- package/src/lib/data/api/session/session.js +69 -0
- package/src/lib/data/api/settings/index.d.ts +1 -0
- package/src/lib/data/api/settings/settings.cjs +58 -0
- package/src/lib/data/api/settings/settings.d.ts +7 -0
- package/src/lib/data/api/settings/settings.js +53 -0
- package/src/lib/data/api/sms/index.d.ts +1 -0
- package/src/lib/data/api/sms/sms.cjs +102 -0
- package/src/lib/data/api/sms/sms.d.ts +32 -0
- package/src/lib/data/api/sms/sms.js +95 -0
- package/src/lib/data/api/user/index.d.ts +1 -0
- package/src/lib/data/api/user/user.cjs +77 -0
- package/src/lib/data/api/user/user.d.ts +9 -0
- package/src/lib/data/api/user/user.js +71 -0
- package/src/lib/data/api/utils.cjs +20 -0
- package/src/lib/data/api/utils.d.ts +1 -0
- package/src/lib/data/api/utils.js +16 -0
- package/src/lib/data/api/wallets/index.d.ts +1 -0
- package/src/lib/data/api/wallets/wallets.cjs +137 -0
- package/src/lib/data/api/wallets/wallets.d.ts +10 -0
- package/src/lib/data/api/wallets/wallets.js +130 -0
- package/src/lib/data/index.d.ts +1 -0
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +3 -4
- package/src/lib/shared/types/general.d.ts +1 -0
- package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.cjs +18 -4
- package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.js +15 -1
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.cjs +6 -4
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.js +5 -3
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.cjs +4 -3
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.d.ts +3 -3
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.js +3 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +4 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +3 -1
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.cjs +6 -6
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.js +3 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +4 -4
- package/src/lib/utils/hooks/useEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +3 -3
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.cjs +4 -4
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.js +3 -3
- package/src/lib/utils/hooks/useFetchNonce/useFetchNonce.cjs +6 -4
- package/src/lib/utils/hooks/useFetchNonce/useFetchNonce.js +3 -1
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.cjs +6 -6
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.js +3 -3
- package/src/lib/utils/hooks/useHandleVerificationRequired/useHandleVerificationRequired.d.ts +4 -4
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs +8 -8
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js +3 -3
- package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.cjs +9 -6
- package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.js +4 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +4 -4
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +3 -3
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +7 -7
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +3 -3
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +4 -4
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +3 -3
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +5 -5
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +3 -3
- package/src/lib/views/EmailUpdate/EmailUpdate.cjs +4 -4
- package/src/lib/views/EmailUpdate/EmailUpdate.js +3 -3
- package/src/lib/views/EmailVerification/EmailVerification.cjs +11 -11
- package/src/lib/views/EmailVerification/EmailVerification.js +3 -3
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +4 -2
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +3 -1
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.cjs +3 -3
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.js +2 -2
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +7 -7
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +3 -3
- package/src/lib/views/Passkey/RenamePasskeyView/RenamePasskeyView.cjs +4 -4
- package/src/lib/views/Passkey/RenamePasskeyView/RenamePasskeyView.js +3 -3
- package/src/lib/views/Passkey/utils/createEmbeddedWalletWithPasskey/createEmbeddedWalletWithPasskey.cjs +4 -2
- package/src/lib/views/Passkey/utils/createEmbeddedWalletWithPasskey/createEmbeddedWalletWithPasskey.js +3 -1
- package/src/lib/views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.cjs +4 -2
- package/src/lib/views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.js +3 -1
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +11 -8
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +5 -2
- package/src/lib/views/SelectWalletInWalletGroupView/components/WalletGroupItem/index.d.ts +1 -0
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +4 -4
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +2 -2
- package/src/lib/views/WalletUsedView/WalletUsedView.cjs +4 -4
- package/src/lib/views/WalletUsedView/WalletUsedView.js +3 -3
- package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.cjs +6 -2
- package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.js +6 -2
- package/src/lib/data/api.cjs +0 -797
- package/src/lib/data/api.d.ts +0 -179
- package/src/lib/data/api.js +0 -753
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
3
|
+
import { ChainEnum, WalletProviderEnum, AuthModeEnum } from '@dynamic-labs/sdk-api-core';
|
|
4
|
+
import { logger } from '../../../shared/logger.js';
|
|
5
|
+
import '@dynamic-labs/iconic';
|
|
6
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
7
|
+
import 'react/jsx-runtime';
|
|
8
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
9
|
+
import 'react';
|
|
10
|
+
import '@dynamic-labs/wallet-book';
|
|
11
|
+
import '../../../utils/constants/colors.js';
|
|
12
|
+
import '../../../utils/constants/values.js';
|
|
13
|
+
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
14
|
+
import '../../../shared/consts/index.js';
|
|
15
|
+
import { sdkApi } from '../api.js';
|
|
16
|
+
|
|
17
|
+
const revokeSession = ({ environmentId, sessionId, }, userJwt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
try {
|
|
19
|
+
yield sdkApi(userJwt).revokeSession({
|
|
20
|
+
environmentId,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
const body = yield error.json();
|
|
25
|
+
logger.error(Error(body.error.message));
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const mapChainToChainEnum = (chain) => {
|
|
29
|
+
const foundChain = Object.values(ChainEnum).find((value) => value === chain);
|
|
30
|
+
if (!foundChain) {
|
|
31
|
+
throw new DynamicError(`Invalid chain ${chain}`);
|
|
32
|
+
}
|
|
33
|
+
return foundChain;
|
|
34
|
+
};
|
|
35
|
+
const mapProviderToProviderEnum = (provider) => {
|
|
36
|
+
const foundProvider = Object.values(WalletProviderEnum).find((value) => value === provider);
|
|
37
|
+
if (!foundProvider) {
|
|
38
|
+
throw new DynamicError(`Invalid provider ${provider}`);
|
|
39
|
+
}
|
|
40
|
+
return foundProvider;
|
|
41
|
+
};
|
|
42
|
+
const mapAuthModeTypeToEnum = (authMode) => {
|
|
43
|
+
const found = Object.values(AuthModeEnum).find((value) => value === authMode);
|
|
44
|
+
if (!found) {
|
|
45
|
+
throw new DynamicError(`Invalid authMode ${authMode}`);
|
|
46
|
+
}
|
|
47
|
+
return found;
|
|
48
|
+
};
|
|
49
|
+
const createVisit = ({ authMode, chain, environmentId, walletProvider, publicWalletAddress, walletName, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
try {
|
|
51
|
+
const connectRequest = {
|
|
52
|
+
address: publicWalletAddress,
|
|
53
|
+
authMode: mapAuthModeTypeToEnum(authMode),
|
|
54
|
+
chain: mapChainToChainEnum(chain),
|
|
55
|
+
provider: mapProviderToProviderEnum(walletProvider),
|
|
56
|
+
walletName,
|
|
57
|
+
};
|
|
58
|
+
yield sdkApi().createVisit({
|
|
59
|
+
connectRequest,
|
|
60
|
+
environmentId,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
// log error to console, don't do anything else
|
|
65
|
+
logger.error(error);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export { createVisit, mapAuthModeTypeToEnum, mapChainToChainEnum, mapProviderToProviderEnum, revokeSession };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './settings';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
|
+
require('@dynamic-labs/sdk-api-core');
|
|
7
|
+
var logger = require('../../../shared/logger.cjs');
|
|
8
|
+
require('@dynamic-labs/iconic');
|
|
9
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
10
|
+
require('react/jsx-runtime');
|
|
11
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
12
|
+
require('react');
|
|
13
|
+
require('@dynamic-labs/wallet-book');
|
|
14
|
+
require('../../../utils/constants/colors.cjs');
|
|
15
|
+
require('../../../utils/constants/values.cjs');
|
|
16
|
+
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
17
|
+
require('@dynamic-labs/utils');
|
|
18
|
+
require('../../../shared/consts/index.cjs');
|
|
19
|
+
var api = require('../api.cjs');
|
|
20
|
+
var helpers = require('../../../context/DynamicContext/helpers/helpers.cjs');
|
|
21
|
+
|
|
22
|
+
const fetchProjectSettings = (environmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
try {
|
|
24
|
+
const res = yield api.sdkApi().getEnvironmentSettings({
|
|
25
|
+
environmentId,
|
|
26
|
+
});
|
|
27
|
+
return res;
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
logger.logger.error(e);
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const sendDynamicProps = (environmentId, settingsToSend) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
try {
|
|
36
|
+
const { dynamicContextProps, dynamicWagmiSettings, frameworkSettings } = settingsToSend;
|
|
37
|
+
if (dynamicContextProps) {
|
|
38
|
+
yield sendDynamicContextSettings(environmentId, { dynamicContextProps, frameworkSettings }, helpers.isDynamicContextSessionSettingExpired, helpers.setDynamicContextSessionSettings);
|
|
39
|
+
}
|
|
40
|
+
if (dynamicWagmiSettings) {
|
|
41
|
+
yield sendDynamicContextSettings(environmentId, { dynamicWagmiSettings }, helpers.isWagmiSessionSettingExpired, helpers.setWagmiSessionSettings);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
logger.logger.warn('Error caught when sending sdkSettings to api. Please notify Dynamic, and send the DynamicContextProvider settings you currently have configured', { error });
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const sendDynamicContextSettings = (environmentId, sdkSettingsRequest, isSdkSettingExpired, setSDKSessionSettings) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
// sent once. no need to send again
|
|
50
|
+
if (!isSdkSettingExpired()) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
yield api.sdkApi().logDynamicSdkSettings({ environmentId, sdkSettingsRequest });
|
|
54
|
+
setSDKSessionSettings();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
exports.fetchProjectSettings = fetchProjectSettings;
|
|
58
|
+
exports.sendDynamicProps = sendDynamicProps;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProjectSettings } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
export declare const fetchProjectSettings: (environmentId: string) => Promise<ProjectSettings | undefined>;
|
|
3
|
+
export declare const sendDynamicProps: (environmentId: string, settingsToSend: {
|
|
4
|
+
dynamicContextProps?: object;
|
|
5
|
+
dynamicWagmiSettings?: object;
|
|
6
|
+
frameworkSettings?: object;
|
|
7
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
+
import '@dynamic-labs/sdk-api-core';
|
|
3
|
+
import { logger } from '../../../shared/logger.js';
|
|
4
|
+
import '@dynamic-labs/iconic';
|
|
5
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
6
|
+
import 'react/jsx-runtime';
|
|
7
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
8
|
+
import 'react';
|
|
9
|
+
import '@dynamic-labs/wallet-book';
|
|
10
|
+
import '../../../utils/constants/colors.js';
|
|
11
|
+
import '../../../utils/constants/values.js';
|
|
12
|
+
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
13
|
+
import '@dynamic-labs/utils';
|
|
14
|
+
import '../../../shared/consts/index.js';
|
|
15
|
+
import { sdkApi } from '../api.js';
|
|
16
|
+
import { isDynamicContextSessionSettingExpired, setDynamicContextSessionSettings, isWagmiSessionSettingExpired, setWagmiSessionSettings } from '../../../context/DynamicContext/helpers/helpers.js';
|
|
17
|
+
|
|
18
|
+
const fetchProjectSettings = (environmentId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
try {
|
|
20
|
+
const res = yield sdkApi().getEnvironmentSettings({
|
|
21
|
+
environmentId,
|
|
22
|
+
});
|
|
23
|
+
return res;
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
logger.error(e);
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const sendDynamicProps = (environmentId, settingsToSend) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
try {
|
|
32
|
+
const { dynamicContextProps, dynamicWagmiSettings, frameworkSettings } = settingsToSend;
|
|
33
|
+
if (dynamicContextProps) {
|
|
34
|
+
yield sendDynamicContextSettings(environmentId, { dynamicContextProps, frameworkSettings }, isDynamicContextSessionSettingExpired, setDynamicContextSessionSettings);
|
|
35
|
+
}
|
|
36
|
+
if (dynamicWagmiSettings) {
|
|
37
|
+
yield sendDynamicContextSettings(environmentId, { dynamicWagmiSettings }, isWagmiSessionSettingExpired, setWagmiSessionSettings);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
logger.warn('Error caught when sending sdkSettings to api. Please notify Dynamic, and send the DynamicContextProvider settings you currently have configured', { error });
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const sendDynamicContextSettings = (environmentId, sdkSettingsRequest, isSdkSettingExpired, setSDKSessionSettings) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
// sent once. no need to send again
|
|
46
|
+
if (!isSdkSettingExpired()) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
yield sdkApi().logDynamicSdkSettings({ environmentId, sdkSettingsRequest });
|
|
50
|
+
setSDKSessionSettings();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export { fetchProjectSettings, sendDynamicProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sms';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
|
+
var utils = require('@dynamic-labs/utils');
|
|
7
|
+
var locale = require('../../../locale/locale.cjs');
|
|
8
|
+
require('@dynamic-labs/sdk-api-core');
|
|
9
|
+
var logger = require('../../../shared/logger.cjs');
|
|
10
|
+
require('@dynamic-labs/iconic');
|
|
11
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
12
|
+
require('react/jsx-runtime');
|
|
13
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
14
|
+
require('react');
|
|
15
|
+
require('@dynamic-labs/wallet-book');
|
|
16
|
+
require('../../../utils/constants/colors.cjs');
|
|
17
|
+
require('../../../utils/constants/values.cjs');
|
|
18
|
+
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
19
|
+
require('../../../shared/consts/index.cjs');
|
|
20
|
+
var api = require('../api.cjs');
|
|
21
|
+
|
|
22
|
+
const createSmsVerification = ({ isoCountryCode, phoneNumber, phoneCountryCode, environmentId, captchaToken, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
try {
|
|
24
|
+
return yield api.sdkApi().createSmsVerification({
|
|
25
|
+
environmentId,
|
|
26
|
+
smsVerificationCreateRequest: {
|
|
27
|
+
captchaToken,
|
|
28
|
+
isoCountryCode,
|
|
29
|
+
phoneCountryCode,
|
|
30
|
+
phoneNumber,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
const data = yield e.json();
|
|
36
|
+
logger.logger.error(data.error);
|
|
37
|
+
throw new utils.SmsVerificationError(data.error, data.code);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const signInWithSmsVerification = ({ verificationToken, verificationUUID, environmentId, captchaToken, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
var _a;
|
|
42
|
+
try {
|
|
43
|
+
return yield api.sdkApi().signInWithSmsVerification({
|
|
44
|
+
environmentId,
|
|
45
|
+
smsVerificationVerifyRequest: {
|
|
46
|
+
captchaToken,
|
|
47
|
+
verificationToken,
|
|
48
|
+
verificationUUID,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
const data = yield e.json();
|
|
54
|
+
logger.logger.error(data.error);
|
|
55
|
+
if (((_a = data.error) === null || _a === void 0 ? void 0 : _a.code) === 'missing_from_list') {
|
|
56
|
+
throw new utils.NoAccessError({ phoneNumber: data.payload.phoneNumber });
|
|
57
|
+
}
|
|
58
|
+
if (data.code === 'wrong_sms_verification_token') {
|
|
59
|
+
throw new utils.SmsVerificationError(locale.Locale.getInstance().t('dyn_login.helper.phone_number_form.invalid_sms_verification'), data.code);
|
|
60
|
+
}
|
|
61
|
+
throw new utils.SmsVerificationError(data.error, data.code);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const retrySmsVerification = ({ isoCountryCode, phoneCountryCode, phoneNumber, environmentId, verificationUUID, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
try {
|
|
66
|
+
return yield api.sdkApi().retrySmsVerification({
|
|
67
|
+
environmentId,
|
|
68
|
+
smsVerificationRetryRequest: {
|
|
69
|
+
isoCountryCode,
|
|
70
|
+
phoneCountryCode,
|
|
71
|
+
phoneNumber,
|
|
72
|
+
verificationUUID,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
const data = yield e.json();
|
|
78
|
+
logger.logger.error(data.error);
|
|
79
|
+
throw new utils.SmsVerificationError(data.error, data.code);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const verifySms = ({ verificationToken, verificationUUID, environmentId, }, userJwt) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
+
try {
|
|
84
|
+
return yield api.sdkApi(userJwt).verifySmsVerification({
|
|
85
|
+
environmentId,
|
|
86
|
+
smsVerificationVerifyRequest: {
|
|
87
|
+
verificationToken,
|
|
88
|
+
verificationUUID,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
const data = yield e.json();
|
|
94
|
+
logger.logger.error(data.error);
|
|
95
|
+
throw new utils.SmsVerificationError(data.error, data.code);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
exports.createSmsVerification = createSmsVerification;
|
|
100
|
+
exports.retrySmsVerification = retrySmsVerification;
|
|
101
|
+
exports.signInWithSmsVerification = signInWithSmsVerification;
|
|
102
|
+
exports.verifySms = verifySms;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { UpdateSelfResponse, VerifyResponse, SmsVerificationCreateResponse } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
export declare const createSmsVerification: ({ isoCountryCode, phoneNumber, phoneCountryCode, environmentId, captchaToken, }: {
|
|
3
|
+
/** The iso2 of the country ex: US, FR or BR */
|
|
4
|
+
isoCountryCode: string;
|
|
5
|
+
/** The country code ex: 1, 33, or 55 */
|
|
6
|
+
phoneCountryCode: string;
|
|
7
|
+
/** Only the phone number, without country code or anything but digits */
|
|
8
|
+
phoneNumber: string;
|
|
9
|
+
environmentId: string;
|
|
10
|
+
captchaToken?: string | undefined;
|
|
11
|
+
}) => Promise<SmsVerificationCreateResponse>;
|
|
12
|
+
export declare const signInWithSmsVerification: ({ verificationToken, verificationUUID, environmentId, captchaToken, }: {
|
|
13
|
+
environmentId: string;
|
|
14
|
+
verificationToken: string;
|
|
15
|
+
verificationUUID: string;
|
|
16
|
+
captchaToken?: string | undefined;
|
|
17
|
+
}) => Promise<VerifyResponse>;
|
|
18
|
+
export declare const retrySmsVerification: ({ isoCountryCode, phoneCountryCode, phoneNumber, environmentId, verificationUUID, }: {
|
|
19
|
+
/** The iso2 of the country ex: US, FR or BR */
|
|
20
|
+
isoCountryCode: string;
|
|
21
|
+
/** The country code ex: 1, 33, or 55 */
|
|
22
|
+
phoneCountryCode: string;
|
|
23
|
+
/** Only the phone number, without country code or anything but digits */
|
|
24
|
+
phoneNumber: string;
|
|
25
|
+
environmentId: string;
|
|
26
|
+
verificationUUID: string;
|
|
27
|
+
}) => Promise<SmsVerificationCreateResponse>;
|
|
28
|
+
export declare const verifySms: ({ verificationToken, verificationUUID, environmentId, }: {
|
|
29
|
+
environmentId: string;
|
|
30
|
+
verificationToken: string;
|
|
31
|
+
verificationUUID: string;
|
|
32
|
+
}, userJwt: string) => Promise<UpdateSelfResponse>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
+
import { NoAccessError, SmsVerificationError } from '@dynamic-labs/utils';
|
|
3
|
+
import { Locale } from '../../../locale/locale.js';
|
|
4
|
+
import '@dynamic-labs/sdk-api-core';
|
|
5
|
+
import { logger } from '../../../shared/logger.js';
|
|
6
|
+
import '@dynamic-labs/iconic';
|
|
7
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
8
|
+
import 'react/jsx-runtime';
|
|
9
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
10
|
+
import 'react';
|
|
11
|
+
import '@dynamic-labs/wallet-book';
|
|
12
|
+
import '../../../utils/constants/colors.js';
|
|
13
|
+
import '../../../utils/constants/values.js';
|
|
14
|
+
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
15
|
+
import '../../../shared/consts/index.js';
|
|
16
|
+
import { sdkApi } from '../api.js';
|
|
17
|
+
|
|
18
|
+
const createSmsVerification = ({ isoCountryCode, phoneNumber, phoneCountryCode, environmentId, captchaToken, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
try {
|
|
20
|
+
return yield sdkApi().createSmsVerification({
|
|
21
|
+
environmentId,
|
|
22
|
+
smsVerificationCreateRequest: {
|
|
23
|
+
captchaToken,
|
|
24
|
+
isoCountryCode,
|
|
25
|
+
phoneCountryCode,
|
|
26
|
+
phoneNumber,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
const data = yield e.json();
|
|
32
|
+
logger.error(data.error);
|
|
33
|
+
throw new SmsVerificationError(data.error, data.code);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const signInWithSmsVerification = ({ verificationToken, verificationUUID, environmentId, captchaToken, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
var _a;
|
|
38
|
+
try {
|
|
39
|
+
return yield sdkApi().signInWithSmsVerification({
|
|
40
|
+
environmentId,
|
|
41
|
+
smsVerificationVerifyRequest: {
|
|
42
|
+
captchaToken,
|
|
43
|
+
verificationToken,
|
|
44
|
+
verificationUUID,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
const data = yield e.json();
|
|
50
|
+
logger.error(data.error);
|
|
51
|
+
if (((_a = data.error) === null || _a === void 0 ? void 0 : _a.code) === 'missing_from_list') {
|
|
52
|
+
throw new NoAccessError({ phoneNumber: data.payload.phoneNumber });
|
|
53
|
+
}
|
|
54
|
+
if (data.code === 'wrong_sms_verification_token') {
|
|
55
|
+
throw new SmsVerificationError(Locale.getInstance().t('dyn_login.helper.phone_number_form.invalid_sms_verification'), data.code);
|
|
56
|
+
}
|
|
57
|
+
throw new SmsVerificationError(data.error, data.code);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const retrySmsVerification = ({ isoCountryCode, phoneCountryCode, phoneNumber, environmentId, verificationUUID, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
try {
|
|
62
|
+
return yield sdkApi().retrySmsVerification({
|
|
63
|
+
environmentId,
|
|
64
|
+
smsVerificationRetryRequest: {
|
|
65
|
+
isoCountryCode,
|
|
66
|
+
phoneCountryCode,
|
|
67
|
+
phoneNumber,
|
|
68
|
+
verificationUUID,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
const data = yield e.json();
|
|
74
|
+
logger.error(data.error);
|
|
75
|
+
throw new SmsVerificationError(data.error, data.code);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const verifySms = ({ verificationToken, verificationUUID, environmentId, }, userJwt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
+
try {
|
|
80
|
+
return yield sdkApi(userJwt).verifySmsVerification({
|
|
81
|
+
environmentId,
|
|
82
|
+
smsVerificationVerifyRequest: {
|
|
83
|
+
verificationToken,
|
|
84
|
+
verificationUUID,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
const data = yield e.json();
|
|
90
|
+
logger.error(data.error);
|
|
91
|
+
throw new SmsVerificationError(data.error, data.code);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export { createSmsVerification, retrySmsVerification, signInWithSmsVerification, verifySms };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './user';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
|
+
var utils = require('@dynamic-labs/utils');
|
|
7
|
+
require('@dynamic-labs/sdk-api-core');
|
|
8
|
+
var logger = require('../../../shared/logger.cjs');
|
|
9
|
+
require('@dynamic-labs/iconic');
|
|
10
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
11
|
+
require('react/jsx-runtime');
|
|
12
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
13
|
+
require('react');
|
|
14
|
+
require('@dynamic-labs/wallet-book');
|
|
15
|
+
require('../../../utils/constants/colors.cjs');
|
|
16
|
+
require('../../../utils/constants/values.cjs');
|
|
17
|
+
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
18
|
+
require('../../../shared/consts/index.cjs');
|
|
19
|
+
var api = require('../api.cjs');
|
|
20
|
+
|
|
21
|
+
const updateUserProfileFields = (jwt, environmentId, fields) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
try {
|
|
23
|
+
if (!jwt)
|
|
24
|
+
throw new utils.DynamicError('User not authenticated');
|
|
25
|
+
const res = yield api.sdkApi(jwt).updateSelf({
|
|
26
|
+
environmentId,
|
|
27
|
+
userFields: fields,
|
|
28
|
+
});
|
|
29
|
+
return res;
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
logger.logger.error(e);
|
|
33
|
+
if (e instanceof Response) {
|
|
34
|
+
const error = yield e.json();
|
|
35
|
+
if (error.code === 'email_already_exists') {
|
|
36
|
+
throw new utils.EmailAlreadyExistsError();
|
|
37
|
+
}
|
|
38
|
+
else if (error.code === 'username_already_exists') {
|
|
39
|
+
throw new utils.UsernameAlreadyExistsError();
|
|
40
|
+
}
|
|
41
|
+
else if (error.code === 'too_many_verification_attempts') {
|
|
42
|
+
throw new utils.TooManyEmailVerificationsError();
|
|
43
|
+
}
|
|
44
|
+
else if (error.code === 'invalid_phone') {
|
|
45
|
+
throw new utils.InvalidPhoneNumberError();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
throw e;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const mergeUserAccounts = (userJwt, environmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
try {
|
|
53
|
+
const response = yield api.sdkApi(userJwt).mergeUsers({
|
|
54
|
+
environmentId,
|
|
55
|
+
});
|
|
56
|
+
return response;
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
logger.logger.error(e);
|
|
60
|
+
throw e;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const refreshUserJwt = ({ environmentId, }, userJwt) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
try {
|
|
65
|
+
const { jwt, minifiedJwt } = yield api.sdkApi(userJwt).refreshAuth({
|
|
66
|
+
environmentId,
|
|
67
|
+
});
|
|
68
|
+
return { jwt, minifiedJwt };
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
exports.mergeUserAccounts = mergeUserAccounts;
|
|
76
|
+
exports.refreshUserJwt = refreshUserJwt;
|
|
77
|
+
exports.updateUserProfileFields = updateUserProfileFields;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UserFields, UpdateSelfResponse, VerifyResponse } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
export declare const updateUserProfileFields: (jwt: string | undefined, environmentId: string, fields: UserFields) => Promise<UpdateSelfResponse>;
|
|
3
|
+
export declare const mergeUserAccounts: (userJwt: string, environmentId: string) => Promise<VerifyResponse | undefined>;
|
|
4
|
+
export declare const refreshUserJwt: ({ environmentId, }: {
|
|
5
|
+
environmentId: string;
|
|
6
|
+
}, userJwt: string) => Promise<{
|
|
7
|
+
jwt: string;
|
|
8
|
+
minifiedJwt: string;
|
|
9
|
+
} | undefined>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
+
import { DynamicError, EmailAlreadyExistsError, UsernameAlreadyExistsError, TooManyEmailVerificationsError, InvalidPhoneNumberError } from '@dynamic-labs/utils';
|
|
3
|
+
import '@dynamic-labs/sdk-api-core';
|
|
4
|
+
import { logger } from '../../../shared/logger.js';
|
|
5
|
+
import '@dynamic-labs/iconic';
|
|
6
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
7
|
+
import 'react/jsx-runtime';
|
|
8
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
9
|
+
import 'react';
|
|
10
|
+
import '@dynamic-labs/wallet-book';
|
|
11
|
+
import '../../../utils/constants/colors.js';
|
|
12
|
+
import '../../../utils/constants/values.js';
|
|
13
|
+
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
14
|
+
import '../../../shared/consts/index.js';
|
|
15
|
+
import { sdkApi } from '../api.js';
|
|
16
|
+
|
|
17
|
+
const updateUserProfileFields = (jwt, environmentId, fields) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
try {
|
|
19
|
+
if (!jwt)
|
|
20
|
+
throw new DynamicError('User not authenticated');
|
|
21
|
+
const res = yield sdkApi(jwt).updateSelf({
|
|
22
|
+
environmentId,
|
|
23
|
+
userFields: fields,
|
|
24
|
+
});
|
|
25
|
+
return res;
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
logger.error(e);
|
|
29
|
+
if (e instanceof Response) {
|
|
30
|
+
const error = yield e.json();
|
|
31
|
+
if (error.code === 'email_already_exists') {
|
|
32
|
+
throw new EmailAlreadyExistsError();
|
|
33
|
+
}
|
|
34
|
+
else if (error.code === 'username_already_exists') {
|
|
35
|
+
throw new UsernameAlreadyExistsError();
|
|
36
|
+
}
|
|
37
|
+
else if (error.code === 'too_many_verification_attempts') {
|
|
38
|
+
throw new TooManyEmailVerificationsError();
|
|
39
|
+
}
|
|
40
|
+
else if (error.code === 'invalid_phone') {
|
|
41
|
+
throw new InvalidPhoneNumberError();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const mergeUserAccounts = (userJwt, environmentId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
try {
|
|
49
|
+
const response = yield sdkApi(userJwt).mergeUsers({
|
|
50
|
+
environmentId,
|
|
51
|
+
});
|
|
52
|
+
return response;
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
logger.error(e);
|
|
56
|
+
throw e;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const refreshUserJwt = ({ environmentId, }, userJwt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
try {
|
|
61
|
+
const { jwt, minifiedJwt } = yield sdkApi(userJwt).refreshAuth({
|
|
62
|
+
environmentId,
|
|
63
|
+
});
|
|
64
|
+
return { jwt, minifiedJwt };
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export { mergeUserAccounts, refreshUserJwt, updateUserProfileFields };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
6
|
+
var api = require('./api.cjs');
|
|
7
|
+
|
|
8
|
+
const fetchNonce = (environmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
+
try {
|
|
10
|
+
const res = yield api.sdkApi().getNonce({
|
|
11
|
+
environmentId,
|
|
12
|
+
});
|
|
13
|
+
return res.nonce;
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
exports.fetchNonce = fetchNonce;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fetchNonce: (environmentId: string) => Promise<string | undefined>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
2
|
+
import { sdkApi } from './api.js';
|
|
3
|
+
|
|
4
|
+
const fetchNonce = (environmentId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5
|
+
try {
|
|
6
|
+
const res = yield sdkApi().getNonce({
|
|
7
|
+
environmentId,
|
|
8
|
+
});
|
|
9
|
+
return res.nonce;
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export { fetchNonce };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './wallets';
|