@dynamic-labs/sdk-react-core 2.1.0-alpha.25 → 2.1.0-alpha.26
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 +13 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +13 -13
- package/src/lib/context/DynamicContext/DynamicContext.cjs +3 -5
- package/src/lib/context/DynamicContext/DynamicContext.js +3 -5
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/types.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +0 -1
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +2 -2
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +2 -2
- package/src/lib/context/DynamicContext/validators/validators.d.ts +2 -2
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +30 -14
- package/src/lib/data/api/embeddedWallets/embeddedWallets.d.ts +3 -2
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +30 -14
- package/src/lib/data/api/mfa/mfa.cjs +10 -5
- package/src/lib/data/api/mfa/mfa.d.ts +1 -1
- package/src/lib/data/api/mfa/mfa.js +10 -5
- package/src/lib/data/api/wallets/wallets.cjs +6 -3
- package/src/lib/data/api/wallets/wallets.d.ts +1 -1
- package/src/lib/data/api/wallets/wallets.js +6 -3
- package/src/lib/events/embeddedWallet.d.ts +2 -1
- package/src/lib/locale/en/translation.cjs +2 -2
- package/src/lib/locale/en/translation.d.ts +1 -1
- package/src/lib/locale/en/translation.js +2 -2
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +1 -1
- package/src/lib/shared/types/localStorage.d.ts +0 -13
- package/src/lib/store/actions/networkConfigurationsActions/index.d.ts +1 -0
- package/src/lib/store/actions/networkConfigurationsActions/networkConfigurationsActions.cjs +10 -0
- package/src/lib/store/actions/networkConfigurationsActions/networkConfigurationsActions.d.ts +7 -0
- package/src/lib/store/actions/networkConfigurationsActions/networkConfigurationsActions.js +6 -0
- package/src/lib/store/hooks/useNetworkConfigurations/index.d.ts +1 -0
- package/src/lib/store/hooks/useNetworkConfigurations/useNetworkConfigurations.cjs +139 -0
- package/src/lib/store/hooks/useNetworkConfigurations/useNetworkConfigurations.d.ts +12 -0
- package/src/lib/store/hooks/useNetworkConfigurations/useNetworkConfigurations.js +135 -0
- package/src/lib/store/index.d.ts +3 -1
- package/src/lib/store/store.cjs +1 -0
- package/src/lib/store/store.js +1 -0
- package/src/lib/store/types.d.ts +6 -1
- package/src/lib/store/utils/clearExpiredData/clearExpiredData.cjs +4 -1
- package/src/lib/store/utils/clearExpiredData/clearExpiredData.js +4 -1
- package/src/lib/utils/constants/localStorage.cjs +0 -2
- package/src/lib/utils/constants/localStorage.js +1 -2
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +12 -15
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +12 -15
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs +3 -3
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js +3 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +11 -10
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +11 -10
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +5 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +5 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +1 -1
- package/src/lib/utils/hooks/useInitEmbeddedWalletAuthMethod/useInitEmbeddedWalletAuthMethod.cjs +2 -6
- package/src/lib/utils/hooks/useInitEmbeddedWalletAuthMethod/useInitEmbeddedWalletAuthMethod.js +2 -6
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +1 -4
- package/src/lib/utils/hooks/useMfa/useMfa.js +1 -4
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs +29 -21
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js +29 -21
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +1 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +1 -1
- package/src/lib/utils/hooks/useSocialAuth/farcaster.cjs +13 -4
- package/src/lib/utils/hooks/useSocialAuth/farcaster.d.ts +2 -0
- package/src/lib/utils/hooks/useSocialAuth/farcaster.js +13 -4
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +4 -4
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +7 -6
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +5 -5
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.cjs +3 -5
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.js +3 -5
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +4 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +5 -2
- package/src/lib/views/EmailVerification/EmailVerification.cjs +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +1 -1
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.cjs +2 -2
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.js +2 -2
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.cjs +5 -4
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.js +5 -4
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.cjs +5 -6
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.d.ts +1 -2
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.js +5 -6
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +8 -18
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.d.ts +4 -12
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +8 -18
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/index.d.ts +0 -1
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.cjs +0 -117
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.d.ts +0 -14
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.js +0 -113
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
7
8
|
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
8
9
|
require('@dynamic-labs/sdk-api-core');
|
|
9
10
|
var logger = require('../../../shared/logger.cjs');
|
|
@@ -16,7 +17,6 @@ require('@dynamic-labs/wallet-book');
|
|
|
16
17
|
require('../../constants/colors.cjs');
|
|
17
18
|
require('../../constants/values.cjs');
|
|
18
19
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
19
|
-
require('@dynamic-labs/utils');
|
|
20
20
|
require('../../../shared/consts/index.cjs');
|
|
21
21
|
|
|
22
22
|
const CONNECT_URL = 'https://relay.farcaster.xyz/v1/channel';
|
|
@@ -25,7 +25,7 @@ const STATUS_TIMEOUT = 300000;
|
|
|
25
25
|
const STATUS_INTERVAL = 1000;
|
|
26
26
|
const connect = (connectRequest) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
27
27
|
try {
|
|
28
|
-
const response = yield fetch(CONNECT_URL, {
|
|
28
|
+
const response = yield utils.FetchService.fetch(CONNECT_URL, {
|
|
29
29
|
body: JSON.stringify(connectRequest),
|
|
30
30
|
headers: {
|
|
31
31
|
'Content-Type': 'application/json',
|
|
@@ -44,7 +44,7 @@ const connect = (connectRequest) => _tslib.__awaiter(void 0, void 0, void 0, fun
|
|
|
44
44
|
});
|
|
45
45
|
const status = (connectStatusRequest) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
46
46
|
try {
|
|
47
|
-
const response = yield fetch(STATUS_URL, {
|
|
47
|
+
const response = yield utils.FetchService.fetch(STATUS_URL, {
|
|
48
48
|
headers: {
|
|
49
49
|
Authorization: `Bearer ${connectStatusRequest.channelToken}`,
|
|
50
50
|
'Content-Type': 'application/json',
|
|
@@ -64,9 +64,18 @@ const status = (connectStatusRequest) => _tslib.__awaiter(void 0, void 0, void 0
|
|
|
64
64
|
const watchStatus = (connectStatusRequest_1, ...args_1) => _tslib.__awaiter(void 0, [connectStatusRequest_1, ...args_1], void 0, function* (connectStatusRequest, { timeout = STATUS_TIMEOUT, interval = STATUS_INTERVAL } = {}) {
|
|
65
65
|
const deadline = Date.now() + timeout;
|
|
66
66
|
let shouldPoll = true;
|
|
67
|
+
let storedResolve = undefined;
|
|
68
|
+
// When we cancel, immediately resolve the current timeout promise and abort status watch
|
|
67
69
|
dynamicEvents.dynamicEvents.on('farcasterConnectCancelled', () => {
|
|
68
70
|
shouldPoll = false;
|
|
71
|
+
storedResolve === null || storedResolve === void 0 ? void 0 : storedResolve();
|
|
72
|
+
storedResolve = undefined;
|
|
69
73
|
});
|
|
74
|
+
// Declaring the promise callback outside of loop to avoid unnecessary garbage generation
|
|
75
|
+
const timeoutCallback = (resolve) => {
|
|
76
|
+
storedResolve = resolve;
|
|
77
|
+
setTimeout(resolve, interval);
|
|
78
|
+
};
|
|
70
79
|
while (shouldPoll && Date.now() < deadline) {
|
|
71
80
|
const response = yield status(connectStatusRequest);
|
|
72
81
|
if (!response) {
|
|
@@ -75,7 +84,7 @@ const watchStatus = (connectStatusRequest_1, ...args_1) => _tslib.__awaiter(void
|
|
|
75
84
|
if (response.state === 'completed') {
|
|
76
85
|
return response;
|
|
77
86
|
}
|
|
78
|
-
yield new Promise(
|
|
87
|
+
yield new Promise(timeoutCallback);
|
|
79
88
|
}
|
|
80
89
|
if (!shouldPoll) {
|
|
81
90
|
return 'cancelled';
|
|
@@ -8,7 +8,9 @@ interface FarcasterConnectRequest {
|
|
|
8
8
|
redirectUrl?: string;
|
|
9
9
|
}
|
|
10
10
|
interface FarcasterConnectResponse {
|
|
11
|
+
/** Connect relay channel token UUID */
|
|
11
12
|
channelToken: string;
|
|
13
|
+
/** Sign in With Farcaster URL to present to the user */
|
|
12
14
|
url: string;
|
|
13
15
|
}
|
|
14
16
|
interface FarcasterConnectStatusRequest {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { FetchService } from '@dynamic-labs/utils';
|
|
3
4
|
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
4
5
|
import '@dynamic-labs/sdk-api-core';
|
|
5
6
|
import { logger } from '../../../shared/logger.js';
|
|
@@ -12,7 +13,6 @@ import '@dynamic-labs/wallet-book';
|
|
|
12
13
|
import '../../constants/colors.js';
|
|
13
14
|
import '../../constants/values.js';
|
|
14
15
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
15
|
-
import '@dynamic-labs/utils';
|
|
16
16
|
import '../../../shared/consts/index.js';
|
|
17
17
|
|
|
18
18
|
const CONNECT_URL = 'https://relay.farcaster.xyz/v1/channel';
|
|
@@ -21,7 +21,7 @@ const STATUS_TIMEOUT = 300000;
|
|
|
21
21
|
const STATUS_INTERVAL = 1000;
|
|
22
22
|
const connect = (connectRequest) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
23
|
try {
|
|
24
|
-
const response = yield fetch(CONNECT_URL, {
|
|
24
|
+
const response = yield FetchService.fetch(CONNECT_URL, {
|
|
25
25
|
body: JSON.stringify(connectRequest),
|
|
26
26
|
headers: {
|
|
27
27
|
'Content-Type': 'application/json',
|
|
@@ -40,7 +40,7 @@ const connect = (connectRequest) => __awaiter(void 0, void 0, void 0, function*
|
|
|
40
40
|
});
|
|
41
41
|
const status = (connectStatusRequest) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
42
|
try {
|
|
43
|
-
const response = yield fetch(STATUS_URL, {
|
|
43
|
+
const response = yield FetchService.fetch(STATUS_URL, {
|
|
44
44
|
headers: {
|
|
45
45
|
Authorization: `Bearer ${connectStatusRequest.channelToken}`,
|
|
46
46
|
'Content-Type': 'application/json',
|
|
@@ -60,9 +60,18 @@ const status = (connectStatusRequest) => __awaiter(void 0, void 0, void 0, funct
|
|
|
60
60
|
const watchStatus = (connectStatusRequest_1, ...args_1) => __awaiter(void 0, [connectStatusRequest_1, ...args_1], void 0, function* (connectStatusRequest, { timeout = STATUS_TIMEOUT, interval = STATUS_INTERVAL } = {}) {
|
|
61
61
|
const deadline = Date.now() + timeout;
|
|
62
62
|
let shouldPoll = true;
|
|
63
|
+
let storedResolve = undefined;
|
|
64
|
+
// When we cancel, immediately resolve the current timeout promise and abort status watch
|
|
63
65
|
dynamicEvents.on('farcasterConnectCancelled', () => {
|
|
64
66
|
shouldPoll = false;
|
|
67
|
+
storedResolve === null || storedResolve === void 0 ? void 0 : storedResolve();
|
|
68
|
+
storedResolve = undefined;
|
|
65
69
|
});
|
|
70
|
+
// Declaring the promise callback outside of loop to avoid unnecessary garbage generation
|
|
71
|
+
const timeoutCallback = (resolve) => {
|
|
72
|
+
storedResolve = resolve;
|
|
73
|
+
setTimeout(resolve, interval);
|
|
74
|
+
};
|
|
66
75
|
while (shouldPoll && Date.now() < deadline) {
|
|
67
76
|
const response = yield status(connectStatusRequest);
|
|
68
77
|
if (!response) {
|
|
@@ -71,7 +80,7 @@ const watchStatus = (connectStatusRequest_1, ...args_1) => __awaiter(void 0, [co
|
|
|
71
80
|
if (response.state === 'completed') {
|
|
72
81
|
return response;
|
|
73
82
|
}
|
|
74
|
-
yield new Promise(
|
|
83
|
+
yield new Promise(timeoutCallback);
|
|
75
84
|
}
|
|
76
85
|
if (!shouldPoll) {
|
|
77
86
|
return 'cancelled';
|
|
@@ -33,9 +33,9 @@ var stringifyURIQuery = require('../../functions/stringifyURIQuery/stringifyURIQ
|
|
|
33
33
|
require('viem');
|
|
34
34
|
require('viem/chains');
|
|
35
35
|
require('../../../config/ApiEndpoint.cjs');
|
|
36
|
+
require('@dynamic-labs/store');
|
|
36
37
|
var oauth = require('../../../data/api/oauth/oauth.cjs');
|
|
37
38
|
require('../../../locale/locale.cjs');
|
|
38
|
-
require('@dynamic-labs/store');
|
|
39
39
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
40
40
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
41
41
|
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
@@ -213,7 +213,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
213
213
|
type: 'social',
|
|
214
214
|
});
|
|
215
215
|
if (provider === sdkApiCore.ProviderEnum.Farcaster)
|
|
216
|
-
return connectWithFarcaster(authMode, captchaToken);
|
|
216
|
+
return connectWithFarcaster(authMode, { captchaToken });
|
|
217
217
|
const authWindow = window.open('', '_blank', 'width=500,height=600');
|
|
218
218
|
const state = randomString.randomString(8);
|
|
219
219
|
const verifier = randomString.randomString(43);
|
|
@@ -368,7 +368,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
368
368
|
}), authWindowTimeout);
|
|
369
369
|
}
|
|
370
370
|
});
|
|
371
|
-
const connectWithFarcaster = (
|
|
371
|
+
const connectWithFarcaster = (authMode_1, _g) => _tslib.__awaiter(void 0, [authMode_1, _g], void 0, function* (authMode, { captchaToken }) {
|
|
372
372
|
const dynamicNonce = consumeNonce();
|
|
373
373
|
const domain = window.location.host;
|
|
374
374
|
const data = yield farcaster.connect({
|
|
@@ -383,7 +383,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
383
383
|
}
|
|
384
384
|
// If on mobile, we want to redirect to the Warpcast app.
|
|
385
385
|
if (utils.isMobile()) {
|
|
386
|
-
|
|
386
|
+
yield utils.PlatformService.openURL(data.url);
|
|
387
387
|
}
|
|
388
388
|
else {
|
|
389
389
|
setShowAuthFlow(true);
|
|
@@ -8,14 +8,15 @@ type UseSocialAuthProps = {
|
|
|
8
8
|
onError?: () => void;
|
|
9
9
|
onFarcasterUrl?: (url: string) => void;
|
|
10
10
|
};
|
|
11
|
+
export type ConnectSocialAccountProps = {
|
|
12
|
+
authMode: SocialAuthMode;
|
|
13
|
+
provider: ProviderEnum;
|
|
14
|
+
validator?: (provider: ProviderEnum) => boolean;
|
|
15
|
+
captchaToken?: string;
|
|
16
|
+
};
|
|
11
17
|
export declare const useSocialAuth: ({ sessionTimeout, onSettled, onError, onFarcasterUrl, }: UseSocialAuthProps) => {
|
|
12
18
|
readonly checkValidProvider: (provider: ProviderEnum, authMode: SocialAuthMode) => boolean;
|
|
13
|
-
readonly connectSocialAccount: ({ authMode, provider, validator, captchaToken, }:
|
|
14
|
-
authMode: SocialAuthMode;
|
|
15
|
-
provider: ProviderEnum;
|
|
16
|
-
validator?: (provider: ProviderEnum) => boolean;
|
|
17
|
-
captchaToken?: string;
|
|
18
|
-
}) => Promise<void>;
|
|
19
|
+
readonly connectSocialAccount: ({ authMode, provider, validator, captchaToken, }: ConnectSocialAccountProps) => Promise<void>;
|
|
19
20
|
readonly error: SocialOAuthError | undefined;
|
|
20
21
|
readonly handleError: (provider: ProviderEnum | undefined, code: SocialOAuthErrorCode, message: string, options?: {
|
|
21
22
|
raiseAuthFailure?: boolean | undefined;
|
|
@@ -3,7 +3,7 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
|
3
3
|
import { useState, useRef } from 'react';
|
|
4
4
|
import { ProviderEnum, OauthResultStatus } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { SocialOAuthErrorCode } from '@dynamic-labs/types';
|
|
6
|
-
import { isMobile, SocialAccountAlreadyExistsError } from '@dynamic-labs/utils';
|
|
6
|
+
import { isMobile, PlatformService, SocialAccountAlreadyExistsError } from '@dynamic-labs/utils';
|
|
7
7
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
8
8
|
import { logger } from '../../../shared/logger.js';
|
|
9
9
|
import '@dynamic-labs/iconic';
|
|
@@ -29,9 +29,9 @@ import { stringifyURIQuery } from '../../functions/stringifyURIQuery/stringifyUR
|
|
|
29
29
|
import 'viem';
|
|
30
30
|
import 'viem/chains';
|
|
31
31
|
import '../../../config/ApiEndpoint.js';
|
|
32
|
+
import '@dynamic-labs/store';
|
|
32
33
|
import { getOAuthResult, signInOAuth, farcasterSignIn, verifyOAuth } from '../../../data/api/oauth/oauth.js';
|
|
33
34
|
import '../../../locale/locale.js';
|
|
34
|
-
import '@dynamic-labs/store';
|
|
35
35
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
36
36
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
37
37
|
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
@@ -209,7 +209,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
209
209
|
type: 'social',
|
|
210
210
|
});
|
|
211
211
|
if (provider === ProviderEnum.Farcaster)
|
|
212
|
-
return connectWithFarcaster(authMode, captchaToken);
|
|
212
|
+
return connectWithFarcaster(authMode, { captchaToken });
|
|
213
213
|
const authWindow = window.open('', '_blank', 'width=500,height=600');
|
|
214
214
|
const state = randomString(8);
|
|
215
215
|
const verifier = randomString(43);
|
|
@@ -364,7 +364,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
364
364
|
}), authWindowTimeout);
|
|
365
365
|
}
|
|
366
366
|
});
|
|
367
|
-
const connectWithFarcaster = (
|
|
367
|
+
const connectWithFarcaster = (authMode_1, _g) => __awaiter(void 0, [authMode_1, _g], void 0, function* (authMode, { captchaToken }) {
|
|
368
368
|
const dynamicNonce = consumeNonce();
|
|
369
369
|
const domain = window.location.host;
|
|
370
370
|
const data = yield connect({
|
|
@@ -379,7 +379,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
379
379
|
}
|
|
380
380
|
// If on mobile, we want to redirect to the Warpcast app.
|
|
381
381
|
if (isMobile()) {
|
|
382
|
-
|
|
382
|
+
yield PlatformService.openURL(data.url);
|
|
383
383
|
}
|
|
384
384
|
else {
|
|
385
385
|
setShowAuthFlow(true);
|
|
@@ -28,7 +28,7 @@ var getVerifyArgs = require('../../functions/getVerifyArgs/getVerifyArgs.cjs');
|
|
|
28
28
|
require('viem');
|
|
29
29
|
require('viem/chains');
|
|
30
30
|
require('../../../config/ApiEndpoint.cjs');
|
|
31
|
-
|
|
31
|
+
require('@dynamic-labs/store');
|
|
32
32
|
require('../../../locale/locale.cjs');
|
|
33
33
|
var wallets = require('../../../data/api/wallets/wallets.cjs');
|
|
34
34
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
@@ -47,7 +47,6 @@ require('../../../context/MockContext/MockContext.cjs');
|
|
|
47
47
|
require('../../../views/CollectUserDataView/useFields.cjs');
|
|
48
48
|
require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
49
49
|
require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
50
|
-
require('@dynamic-labs/store');
|
|
51
50
|
require('@dynamic-labs/rpc-providers');
|
|
52
51
|
require('react-i18next');
|
|
53
52
|
require('../../../components/Alert/Alert.cjs');
|
|
@@ -117,11 +116,10 @@ const useTransferWallet = () => {
|
|
|
117
116
|
// and if props doesn't have nonce, that means it has messageToSignOverride and signedMessageOverride
|
|
118
117
|
nonce: '', siweStatement: props.overrideSiweStatement, walletProvider: getWalletProvider.getWalletProvider(walletConnector) });
|
|
119
118
|
const verifyArgs = yield getVerifyArgs.getVerifyArgs(args);
|
|
120
|
-
const
|
|
121
|
-
if (!
|
|
119
|
+
const userProfile = yield wallets.transferWallet(environmentId, verifyArgs);
|
|
120
|
+
if (!userProfile) {
|
|
122
121
|
throw new utils.DynamicError('Error transferring wallet.');
|
|
123
122
|
}
|
|
124
|
-
const userProfile = storeAuthTokenAndUser.storeAuthTokenAndUser(response);
|
|
125
123
|
updatePrimaryWalletId(walletConnector, userProfile);
|
|
126
124
|
const walletId = userProfile.lastVerifiedCredentialId;
|
|
127
125
|
if (walletId) {
|
|
@@ -24,7 +24,7 @@ import { getVerifyArgs } from '../../functions/getVerifyArgs/getVerifyArgs.js';
|
|
|
24
24
|
import 'viem';
|
|
25
25
|
import 'viem/chains';
|
|
26
26
|
import '../../../config/ApiEndpoint.js';
|
|
27
|
-
import
|
|
27
|
+
import '@dynamic-labs/store';
|
|
28
28
|
import '../../../locale/locale.js';
|
|
29
29
|
import { transferWallet } from '../../../data/api/wallets/wallets.js';
|
|
30
30
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
@@ -43,7 +43,6 @@ import '../../../context/MockContext/MockContext.js';
|
|
|
43
43
|
import '../../../views/CollectUserDataView/useFields.js';
|
|
44
44
|
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
45
45
|
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
46
|
-
import '@dynamic-labs/store';
|
|
47
46
|
import '@dynamic-labs/rpc-providers';
|
|
48
47
|
import 'react-i18next';
|
|
49
48
|
import '../../../components/Alert/Alert.js';
|
|
@@ -113,11 +112,10 @@ const useTransferWallet = () => {
|
|
|
113
112
|
// and if props doesn't have nonce, that means it has messageToSignOverride and signedMessageOverride
|
|
114
113
|
nonce: '', siweStatement: props.overrideSiweStatement, walletProvider: getWalletProvider(walletConnector) });
|
|
115
114
|
const verifyArgs = yield getVerifyArgs(args);
|
|
116
|
-
const
|
|
117
|
-
if (!
|
|
115
|
+
const userProfile = yield transferWallet(environmentId, verifyArgs);
|
|
116
|
+
if (!userProfile) {
|
|
118
117
|
throw new DynamicError('Error transferring wallet.');
|
|
119
118
|
}
|
|
120
|
-
const userProfile = storeAuthTokenAndUser(response);
|
|
121
119
|
updatePrimaryWalletId(walletConnector, userProfile);
|
|
122
120
|
const walletId = userProfile.lastVerifiedCredentialId;
|
|
123
121
|
if (walletId) {
|
|
@@ -27,8 +27,8 @@ require('react-international-phone');
|
|
|
27
27
|
require('viem');
|
|
28
28
|
require('viem/chains');
|
|
29
29
|
require('../../../config/ApiEndpoint.cjs');
|
|
30
|
-
var mfa = require('../../../data/api/mfa/mfa.cjs');
|
|
31
30
|
var storeAuthTokenAndUser = require('../../../store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.cjs');
|
|
31
|
+
var mfa = require('../../../data/api/mfa/mfa.cjs');
|
|
32
32
|
require('../../../locale/locale.cjs');
|
|
33
33
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
34
34
|
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
@@ -178,6 +178,9 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
178
178
|
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
179
179
|
});
|
|
180
180
|
const handleError = (error, { options = {}, onError, }) => {
|
|
181
|
+
if (error instanceof utils.MfaInvalidOtpError) {
|
|
182
|
+
throw error;
|
|
183
|
+
}
|
|
181
184
|
// these get caught in onboarding form and handled there
|
|
182
185
|
if (error instanceof utils.EmailAlreadyExistsError ||
|
|
183
186
|
error instanceof utils.CustomFieldNotUniqueError ||
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { DynamicError, EmailAlreadyExistsError, CustomFieldNotUniqueError, UsernameAlreadyExistsError, TooManyEmailVerificationsError, InvalidPhoneNumberError, NoAccessError, AccountExistsError, UserHasAccountWithEmailError, sleep } from '@dynamic-labs/utils';
|
|
3
|
+
import { DynamicError, MfaInvalidOtpError, EmailAlreadyExistsError, CustomFieldNotUniqueError, UsernameAlreadyExistsError, TooManyEmailVerificationsError, InvalidPhoneNumberError, NoAccessError, AccountExistsError, UserHasAccountWithEmailError, sleep } from '@dynamic-labs/utils';
|
|
4
4
|
import { useAccountExistsContext } from '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
5
5
|
import 'react';
|
|
6
6
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
@@ -23,8 +23,8 @@ import 'react-international-phone';
|
|
|
23
23
|
import 'viem';
|
|
24
24
|
import 'viem/chains';
|
|
25
25
|
import '../../../config/ApiEndpoint.js';
|
|
26
|
-
import { getUserMfaDevices } from '../../../data/api/mfa/mfa.js';
|
|
27
26
|
import { storeAuthTokenAndUser } from '../../../store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.js';
|
|
27
|
+
import { getUserMfaDevices } from '../../../data/api/mfa/mfa.js';
|
|
28
28
|
import '../../../locale/locale.js';
|
|
29
29
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
30
30
|
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
@@ -174,6 +174,9 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
174
174
|
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
175
175
|
});
|
|
176
176
|
const handleError = (error, { options = {}, onError, }) => {
|
|
177
|
+
if (error instanceof MfaInvalidOtpError) {
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
177
180
|
// these get caught in onboarding form and handled there
|
|
178
181
|
if (error instanceof EmailAlreadyExistsError ||
|
|
179
182
|
error instanceof CustomFieldNotUniqueError ||
|
|
@@ -184,7 +184,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
184
184
|
id: embeddedWalletVerifiedCredential.id,
|
|
185
185
|
};
|
|
186
186
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
187
|
-
dynamicEvents.dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, updateUserProfileResponse.jwt);
|
|
187
|
+
dynamicEvents.dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, updateUserProfileResponse.jwt, user);
|
|
188
188
|
}
|
|
189
189
|
if (isUsingPregeneratedWallets || isManualMode) {
|
|
190
190
|
setShowAuthFlow(false);
|
|
@@ -180,7 +180,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
180
180
|
id: embeddedWalletVerifiedCredential.id,
|
|
181
181
|
};
|
|
182
182
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
183
|
-
dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, updateUserProfileResponse.jwt);
|
|
183
|
+
dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, updateUserProfileResponse.jwt, user);
|
|
184
184
|
}
|
|
185
185
|
if (isUsingPregeneratedWallets || isManualMode) {
|
|
186
186
|
setShowAuthFlow(false);
|
|
@@ -15,8 +15,8 @@ require('../../shared/logger.cjs');
|
|
|
15
15
|
require('@dynamic-labs/iconic');
|
|
16
16
|
require('@dynamic-labs/wallet-connector-core');
|
|
17
17
|
var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
|
|
18
|
-
var footerInfoIcon = require('../../shared/assets/footer-info-icon.cjs');
|
|
19
18
|
var link = require('../../shared/assets/link.cjs');
|
|
19
|
+
var passwordHero = require('../../shared/assets/password-hero.cjs');
|
|
20
20
|
require('@dynamic-labs/wallet-book');
|
|
21
21
|
require('../../utils/constants/colors.cjs');
|
|
22
22
|
require('../../utils/constants/values.cjs');
|
|
@@ -100,7 +100,7 @@ const MfaSecureDeviceView = ({ type }) => {
|
|
|
100
100
|
onBackClick: onMfaVerificationBackClick,
|
|
101
101
|
});
|
|
102
102
|
};
|
|
103
|
-
return (jsxRuntime.jsxs("div", { className: 'mfa-secure-device-view__body', "data-testid": 'mfa-secure-device-view', children: [jsxRuntime.jsx(Typography.Typography, { className: 'mfa-secure-device-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', children: t('dyn_mfa.secure_device_view.body') }), isLoading && (jsxRuntime.jsx(spinner.Spinner, { className: 'mfa-secure-device-view__loading-spinner' })), data && (jsxRuntime.jsxs("div", { className: 'mfa-secure-device-view__qrcode', children: [jsxRuntime.jsx(QRCode.QRCode, { Icon: jsxRuntime.jsx(
|
|
103
|
+
return (jsxRuntime.jsxs("div", { className: 'mfa-secure-device-view__body', "data-testid": 'mfa-secure-device-view', children: [jsxRuntime.jsx(Typography.Typography, { className: 'mfa-secure-device-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', children: t('dyn_mfa.secure_device_view.body') }), isLoading && (jsxRuntime.jsx(spinner.Spinner, { className: 'mfa-secure-device-view__loading-spinner' })), data && (jsxRuntime.jsxs("div", { className: 'mfa-secure-device-view__qrcode', children: [jsxRuntime.jsx(QRCode.QRCode, { Icon: jsxRuntime.jsx(passwordHero.ReactComponent, {}), value: data.uri, logoSize: 50 }), jsxRuntime.jsx("div", { className: 'button-container', children: jsxRuntime.jsx(CopyButton.CopyButton, { variant: 'button', textToCopy: data.uri, buttonClassName: 'qr-code-button', copykey: 'dyn_qr_code.copy_button', startSlot:
|
|
104
104
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
105
105
|
jsxRuntime.jsx(Icon.Icon, { size: 'mini', color: 'text-tertiary', children: jsxRuntime.jsx(link.ReactComponent, {}) }), children: t('dyn_qr_code.copy_button') }) })] })), jsxRuntime.jsx(TypographyButton.TypographyButton, { className: 'mfa-secure-device-view__button', expanded: true, onClick: onContinue, children: t('dyn_mfa.secure_device_view.continue') })] }));
|
|
106
106
|
};
|
|
@@ -11,8 +11,8 @@ import '../../shared/logger.js';
|
|
|
11
11
|
import '@dynamic-labs/iconic';
|
|
12
12
|
import '@dynamic-labs/wallet-connector-core';
|
|
13
13
|
import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
14
|
-
import { ReactComponent as SvgFooterInfoIcon } from '../../shared/assets/footer-info-icon.js';
|
|
15
14
|
import { ReactComponent as SvgLink } from '../../shared/assets/link.js';
|
|
15
|
+
import { ReactComponent as SvgPasswordHero } from '../../shared/assets/password-hero.js';
|
|
16
16
|
import '@dynamic-labs/wallet-book';
|
|
17
17
|
import '../../utils/constants/colors.js';
|
|
18
18
|
import '../../utils/constants/values.js';
|
|
@@ -96,7 +96,7 @@ const MfaSecureDeviceView = ({ type }) => {
|
|
|
96
96
|
onBackClick: onMfaVerificationBackClick,
|
|
97
97
|
});
|
|
98
98
|
};
|
|
99
|
-
return (jsxs("div", { className: 'mfa-secure-device-view__body', "data-testid": 'mfa-secure-device-view', children: [jsx(Typography, { className: 'mfa-secure-device-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', children: t('dyn_mfa.secure_device_view.body') }), isLoading && (jsx(Spinner, { className: 'mfa-secure-device-view__loading-spinner' })), data && (jsxs("div", { className: 'mfa-secure-device-view__qrcode', children: [jsx(QRCode, { Icon: jsx(
|
|
99
|
+
return (jsxs("div", { className: 'mfa-secure-device-view__body', "data-testid": 'mfa-secure-device-view', children: [jsx(Typography, { className: 'mfa-secure-device-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', children: t('dyn_mfa.secure_device_view.body') }), isLoading && (jsx(Spinner, { className: 'mfa-secure-device-view__loading-spinner' })), data && (jsxs("div", { className: 'mfa-secure-device-view__qrcode', children: [jsx(QRCode, { Icon: jsx(SvgPasswordHero, {}), value: data.uri, logoSize: 50 }), jsx("div", { className: 'button-container', children: jsx(CopyButton, { variant: 'button', textToCopy: data.uri, buttonClassName: 'qr-code-button', copykey: 'dyn_qr_code.copy_button', startSlot:
|
|
100
100
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
101
101
|
jsx(Icon, { size: 'mini', color: 'text-tertiary', children: jsx(SvgLink, {}) }), children: t('dyn_qr_code.copy_button') }) })] })), jsx(TypographyButton, { className: 'mfa-secure-device-view__button', expanded: true, onClick: onContinue, children: t('dyn_mfa.secure_device_view.continue') })] }));
|
|
102
102
|
};
|
|
@@ -32,7 +32,6 @@ var getEOAWallet = require('../../../../utils/functions/getEOAWallet/getEOAWalle
|
|
|
32
32
|
require('../../../../config/ApiEndpoint.cjs');
|
|
33
33
|
require('@dynamic-labs/store');
|
|
34
34
|
require('../../../../locale/locale.cjs');
|
|
35
|
-
var updateJWTAndCreateUserProfile = require('../../../../utils/functions/updateJWTAndCreateUserProfile/updateJWTAndCreateUserProfile.cjs');
|
|
36
35
|
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
37
36
|
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
38
37
|
require('../../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
@@ -91,18 +90,20 @@ require('../../../LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInS
|
|
|
91
90
|
require('../../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
92
91
|
|
|
93
92
|
const PasskeyCompleteRecovery = () => {
|
|
94
|
-
const { primaryWallet, environmentId, user, setShowAuthFlow,
|
|
93
|
+
const { primaryWallet, environmentId, user, setShowAuthFlow, setPasskeySuccessPopup, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
95
94
|
const { isTurnkeyWalletWithoutAuthenticator } = useIsTurnkeyWallet.useIsTurnkeyWallet();
|
|
96
95
|
const { t } = reactI18next.useTranslation();
|
|
97
96
|
const { mutate: completeRecovery, isLoading, error, } = useMutation.useMutation(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
98
97
|
const wallet = getEOAWallet.getEOAWallet(primaryWallet, (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || []);
|
|
99
|
-
const
|
|
98
|
+
const updatedUser = yield passkeyRecovery.completePasskeyRecovery({
|
|
100
99
|
environmentId,
|
|
101
100
|
user,
|
|
102
101
|
wallet,
|
|
103
102
|
});
|
|
103
|
+
if (!updatedUser) {
|
|
104
|
+
throw new utils.DynamicError('Error completing passkey recovery');
|
|
105
|
+
}
|
|
104
106
|
dynamicEvents.dynamicEvents.emit('passkeyRecoveryCompleted', primaryWallet);
|
|
105
|
-
setUser(updateJWTAndCreateUserProfile.updateJWTAndCreateUserProfile(passkeyRecoveryResponse.jwt, passkeyRecoveryResponse.minifiedJwt));
|
|
106
107
|
setShowAuthFlow(false);
|
|
107
108
|
setPasskeySuccessPopup(PasskeyCreatedSuccessBanner.PasskeySuccessEnum.CREATED);
|
|
108
109
|
}), {
|
|
@@ -28,7 +28,6 @@ import { getEOAWallet } from '../../../../utils/functions/getEOAWallet/getEOAWal
|
|
|
28
28
|
import '../../../../config/ApiEndpoint.js';
|
|
29
29
|
import '@dynamic-labs/store';
|
|
30
30
|
import '../../../../locale/locale.js';
|
|
31
|
-
import { updateJWTAndCreateUserProfile } from '../../../../utils/functions/updateJWTAndCreateUserProfile/updateJWTAndCreateUserProfile.js';
|
|
32
31
|
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
33
32
|
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
34
33
|
import '../../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
@@ -87,18 +86,20 @@ import '../../../LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSe
|
|
|
87
86
|
import '../../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
88
87
|
|
|
89
88
|
const PasskeyCompleteRecovery = () => {
|
|
90
|
-
const { primaryWallet, environmentId, user, setShowAuthFlow,
|
|
89
|
+
const { primaryWallet, environmentId, user, setShowAuthFlow, setPasskeySuccessPopup, } = useInternalDynamicContext();
|
|
91
90
|
const { isTurnkeyWalletWithoutAuthenticator } = useIsTurnkeyWallet();
|
|
92
91
|
const { t } = useTranslation();
|
|
93
92
|
const { mutate: completeRecovery, isLoading, error, } = useMutation(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
93
|
const wallet = getEOAWallet(primaryWallet, (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || []);
|
|
95
|
-
const
|
|
94
|
+
const updatedUser = yield completePasskeyRecovery({
|
|
96
95
|
environmentId,
|
|
97
96
|
user,
|
|
98
97
|
wallet,
|
|
99
98
|
});
|
|
99
|
+
if (!updatedUser) {
|
|
100
|
+
throw new DynamicError('Error completing passkey recovery');
|
|
101
|
+
}
|
|
100
102
|
dynamicEvents.emit('passkeyRecoveryCompleted', primaryWallet);
|
|
101
|
-
setUser(updateJWTAndCreateUserProfile(passkeyRecoveryResponse.jwt, passkeyRecoveryResponse.minifiedJwt));
|
|
102
103
|
setShowAuthFlow(false);
|
|
103
104
|
setPasskeySuccessPopup(PasskeySuccessEnum.CREATED);
|
|
104
105
|
}), {
|
package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.cjs
CHANGED
|
@@ -18,7 +18,6 @@ require('../../../../utils/constants/values.cjs');
|
|
|
18
18
|
require('../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
19
19
|
require('../../../../shared/consts/index.cjs');
|
|
20
20
|
require('../../../../config/ApiEndpoint.cjs');
|
|
21
|
-
var createUserProfile = require('../../../../utils/functions/createUserProfile/createUserProfile.cjs');
|
|
22
21
|
var findEmbeddedWalletFromVerifiedCredentials = require('../../../../utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.cjs');
|
|
23
22
|
require('@dynamic-labs/multi-wallet');
|
|
24
23
|
require('react-international-phone');
|
|
@@ -49,10 +48,11 @@ const createEmbeddedWalletRequest = (_a) => _tslib.__awaiter(void 0, [_a], void
|
|
|
49
48
|
passkeyAlias: displayName,
|
|
50
49
|
};
|
|
51
50
|
}
|
|
52
|
-
const
|
|
51
|
+
const updatedUser = yield embeddedWallets.createTurnkeyEmbeddedWallet(Object.assign({ chains,
|
|
53
52
|
environmentId }, authenticatorBody));
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
if (!updatedUser) {
|
|
54
|
+
throw new utils.DynamicError('Failed to create embedded wallet');
|
|
55
|
+
}
|
|
56
56
|
const primaryChain = walletConnector.connectedChain;
|
|
57
57
|
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials.findEmbeddedWalletFromVerifiedCredentials(updatedUser, [primaryChain]);
|
|
58
58
|
if (!embeddedWalletVerifiedCredential) {
|
|
@@ -61,8 +61,7 @@ const createEmbeddedWalletRequest = (_a) => _tslib.__awaiter(void 0, [_a], void
|
|
|
61
61
|
walletConnector.setVerifiedCredentials(updatedUser.verifiedCredentials);
|
|
62
62
|
return {
|
|
63
63
|
embeddedWalletVerifiedCredential,
|
|
64
|
-
|
|
65
|
-
signersResponse,
|
|
64
|
+
updatedUser,
|
|
66
65
|
walletConnector,
|
|
67
66
|
};
|
|
68
67
|
});
|
package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.d.ts
CHANGED
|
@@ -11,8 +11,7 @@ type CreateEmbeddedWalletRequestProps = {
|
|
|
11
11
|
};
|
|
12
12
|
export declare const createEmbeddedWalletRequest: ({ user, walletConnector, environmentId, chains, webAuthnAttestation, withAuthenticator, }: CreateEmbeddedWalletRequestProps) => Promise<{
|
|
13
13
|
embeddedWalletVerifiedCredential: import("@dynamic-labs/sdk-api-core").JwtVerifiedCredential;
|
|
14
|
-
|
|
15
|
-
signersResponse: import("@dynamic-labs/sdk-api-core").VerifyResponse;
|
|
14
|
+
updatedUser: UserProfile;
|
|
16
15
|
walletConnector: IPasskeyWalletConnector & IEmailWalletConnector;
|
|
17
16
|
}>;
|
|
18
17
|
export {};
|
package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.js
CHANGED
|
@@ -14,7 +14,6 @@ import '../../../../utils/constants/values.js';
|
|
|
14
14
|
import '../../../../shared/utils/classes/storage/localStorage.js';
|
|
15
15
|
import '../../../../shared/consts/index.js';
|
|
16
16
|
import '../../../../config/ApiEndpoint.js';
|
|
17
|
-
import { createUserProfileFromSdkUser } from '../../../../utils/functions/createUserProfile/createUserProfile.js';
|
|
18
17
|
import { findEmbeddedWalletFromVerifiedCredentials } from '../../../../utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.js';
|
|
19
18
|
import '@dynamic-labs/multi-wallet';
|
|
20
19
|
import 'react-international-phone';
|
|
@@ -45,10 +44,11 @@ const createEmbeddedWalletRequest = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
45
44
|
passkeyAlias: displayName,
|
|
46
45
|
};
|
|
47
46
|
}
|
|
48
|
-
const
|
|
47
|
+
const updatedUser = yield createTurnkeyEmbeddedWallet(Object.assign({ chains,
|
|
49
48
|
environmentId }, authenticatorBody));
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
if (!updatedUser) {
|
|
50
|
+
throw new DynamicError('Failed to create embedded wallet');
|
|
51
|
+
}
|
|
52
52
|
const primaryChain = walletConnector.connectedChain;
|
|
53
53
|
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials(updatedUser, [primaryChain]);
|
|
54
54
|
if (!embeddedWalletVerifiedCredential) {
|
|
@@ -57,8 +57,7 @@ const createEmbeddedWalletRequest = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
57
57
|
walletConnector.setVerifiedCredentials(updatedUser.verifiedCredentials);
|
|
58
58
|
return {
|
|
59
59
|
embeddedWalletVerifiedCredential,
|
|
60
|
-
|
|
61
|
-
signersResponse,
|
|
60
|
+
updatedUser,
|
|
62
61
|
walletConnector,
|
|
63
62
|
};
|
|
64
63
|
});
|