@dynamic-labs-sdk/client 0.14.0 → 0.16.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/{InvalidParamError-DQn49mNB.esm.js → InvalidParamError-Cty-xWsw.esm.js} +268 -10
- package/dist/InvalidParamError-Cty-xWsw.esm.js.map +1 -0
- package/dist/{InvalidParamError-DVzrk97b.cjs.js → InvalidParamError-DO9X0rAe.cjs.js} +360 -9
- package/dist/InvalidParamError-DO9X0rAe.cjs.js.map +1 -0
- package/dist/{NotWaasWalletAccountError-IxbdRVGy.cjs.js → NotWaasWalletAccountError-Bj3-tWL3.cjs.js} +3 -3
- package/dist/{NotWaasWalletAccountError-IxbdRVGy.cjs.js.map → NotWaasWalletAccountError-Bj3-tWL3.cjs.js.map} +1 -1
- package/dist/{NotWaasWalletAccountError-D0BXVuKy.esm.js → NotWaasWalletAccountError-x0HlFCot.esm.js} +3 -3
- package/dist/{NotWaasWalletAccountError-D0BXVuKy.esm.js.map → NotWaasWalletAccountError-x0HlFCot.esm.js.map} +1 -1
- package/dist/client/core/createCore/getInitialState.d.ts.map +1 -1
- package/dist/core.cjs.js +34 -65
- package/dist/core.cjs.js.map +1 -1
- package/dist/core.esm.js +24 -60
- package/dist/core.esm.js.map +1 -1
- package/dist/errors/DeeplinkConnectAndVerifyUnsupportedError.d.ts +9 -0
- package/dist/errors/DeeplinkConnectAndVerifyUnsupportedError.d.ts.map +1 -0
- package/dist/errors/UnauthorizedError.d.ts +5 -0
- package/dist/errors/UnauthorizedError.d.ts.map +1 -0
- package/dist/exports/core.d.ts +11 -1
- package/dist/exports/core.d.ts.map +1 -1
- package/dist/exports/index.d.ts +13 -2
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/{getNetworkProviderFromNetworkId-z8WEapnj.cjs.js → getNetworkProviderFromNetworkId-B2NiAPL7.cjs.js} +66 -148
- package/dist/getNetworkProviderFromNetworkId-B2NiAPL7.cjs.js.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-DMMnYrfG.esm.js → getNetworkProviderFromNetworkId-DKM-ec3L.esm.js} +59 -96
- package/dist/getNetworkProviderFromNetworkId-DKM-ec3L.esm.js.map +1 -0
- package/dist/{getSignedSessionId-BdGOv_TA.cjs.js → getSignedSessionId-BQb75faX.cjs.js} +5 -24
- package/dist/getSignedSessionId-BQb75faX.cjs.js.map +1 -0
- package/dist/{getSignedSessionId-BKKO2mqj.esm.js → getSignedSessionId-DczIbYxd.esm.js} +4 -17
- package/dist/getSignedSessionId-DczIbYxd.esm.js.map +1 -0
- package/dist/{getVerifiedCredentialForWalletAccount-Ck7DNGPJ.cjs.js → getVerifiedCredentialForWalletAccount-CTL5-19B.cjs.js} +2 -3
- package/dist/{getVerifiedCredentialForWalletAccount-Ck7DNGPJ.cjs.js.map → getVerifiedCredentialForWalletAccount-CTL5-19B.cjs.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-DQ7g6O7y.esm.js → getVerifiedCredentialForWalletAccount-CpUomVzT.esm.js} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-DQ7g6O7y.esm.js.map → getVerifiedCredentialForWalletAccount-CpUomVzT.esm.js.map} +1 -1
- package/dist/index.cjs.js +333 -87
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +315 -78
- package/dist/index.esm.js.map +1 -1
- package/dist/{isMfaRequiredForAction-BINs954q.cjs.js → isMfaRequiredForAction-DyrKyoVd.cjs.js} +2 -15
- package/dist/isMfaRequiredForAction-DyrKyoVd.cjs.js.map +1 -0
- package/dist/{isMfaRequiredForAction-MvVGc7k3.esm.js → isMfaRequiredForAction-Hi4dCidj.esm.js} +3 -10
- package/dist/isMfaRequiredForAction-Hi4dCidj.esm.js.map +1 -0
- package/dist/modules/apiClient/createApiClient.d.ts.map +1 -1
- package/dist/modules/apiClient/utils/deviceSignatureHeadersMiddleware/createDeviceSignatureHeadersMiddleware.d.ts +4 -0
- package/dist/modules/apiClient/utils/deviceSignatureHeadersMiddleware/createDeviceSignatureHeadersMiddleware.d.ts.map +1 -0
- package/dist/modules/apiClient/utils/deviceSignatureHeadersMiddleware/index.d.ts +2 -0
- package/dist/modules/apiClient/utils/deviceSignatureHeadersMiddleware/index.d.ts.map +1 -0
- package/dist/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.d.ts +3 -0
- package/dist/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.d.ts.map +1 -0
- package/dist/modules/checkout/attachCheckoutTransactionSource/attachCheckoutTransactionSource.d.ts +3 -1
- package/dist/modules/checkout/attachCheckoutTransactionSource/attachCheckoutTransactionSource.d.ts.map +1 -1
- package/dist/modules/checkout/createCheckoutTransaction/createCheckoutTransaction.d.ts +1 -1
- package/dist/modules/checkout/createCheckoutTransaction/createCheckoutTransaction.d.ts.map +1 -1
- package/dist/modules/checkout/getCheckoutTransactionQuote/getCheckoutTransactionQuote.d.ts +1 -2
- package/dist/modules/checkout/getCheckoutTransactionQuote/getCheckoutTransactionQuote.d.ts.map +1 -1
- package/dist/modules/checkout/getCheckouts/getCheckouts.d.ts +4 -0
- package/dist/modules/checkout/getCheckouts/getCheckouts.d.ts.map +1 -0
- package/dist/modules/checkout/getCheckouts/index.d.ts +2 -0
- package/dist/modules/checkout/getCheckouts/index.d.ts.map +1 -0
- package/dist/modules/checkout/submitCheckoutTransaction/index.d.ts +3 -0
- package/dist/modules/checkout/submitCheckoutTransaction/index.d.ts.map +1 -0
- package/dist/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.d.ts +22 -0
- package/dist/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.d.ts.map +1 -0
- package/dist/modules/deviceRegistration/getDeviceSigner/getDeviceSigner.d.ts.map +1 -1
- package/dist/modules/deviceRegistration/getDeviceSigner/{getOrCreateUserDeviceSigningKeys/getOrCreateUserDeviceSigningKeys.d.ts → getOrCreateEnvironmentDeviceSigningKeys/getOrCreateEnvironmentDeviceSigningKeys.d.ts} +2 -2
- package/dist/modules/deviceRegistration/getDeviceSigner/getOrCreateEnvironmentDeviceSigningKeys/getOrCreateEnvironmentDeviceSigningKeys.d.ts.map +1 -0
- package/dist/modules/deviceRegistration/getDeviceSigner/getOrCreateEnvironmentDeviceSigningKeys/index.d.ts +2 -0
- package/dist/modules/deviceRegistration/getDeviceSigner/getOrCreateEnvironmentDeviceSigningKeys/index.d.ts.map +1 -0
- package/dist/modules/deviceRegistration/getHeadersForNonceSignedByDeviceSigners/getHeadersForNonceSignedByDeviceSigners.d.ts +3 -0
- package/dist/modules/deviceRegistration/getHeadersForNonceSignedByDeviceSigners/getHeadersForNonceSignedByDeviceSigners.d.ts.map +1 -0
- package/dist/modules/deviceRegistration/getHeadersForNonceSignedByDeviceSigners/index.d.ts +2 -0
- package/dist/modules/deviceRegistration/getHeadersForNonceSignedByDeviceSigners/index.d.ts.map +1 -0
- package/dist/modules/deviceRegistration/getRegisteredDevices/getRegisteredDevices.d.ts +3 -0
- package/dist/modules/deviceRegistration/getRegisteredDevices/getRegisteredDevices.d.ts.map +1 -0
- package/dist/modules/deviceRegistration/getRegisteredDevices/index.d.ts +2 -0
- package/dist/modules/deviceRegistration/getRegisteredDevices/index.d.ts.map +1 -0
- package/dist/modules/deviceRegistration/revokeAllRegisteredDevices/index.d.ts +2 -0
- package/dist/modules/deviceRegistration/revokeAllRegisteredDevices/index.d.ts.map +1 -0
- package/dist/modules/deviceRegistration/revokeAllRegisteredDevices/revokeAllRegisteredDevices.d.ts +2 -0
- package/dist/modules/deviceRegistration/revokeAllRegisteredDevices/revokeAllRegisteredDevices.d.ts.map +1 -0
- package/dist/modules/deviceRegistration/revokeRegisteredDevice/index.d.ts +2 -0
- package/dist/modules/deviceRegistration/revokeRegisteredDevice/index.d.ts.map +1 -0
- package/dist/modules/deviceRegistration/revokeRegisteredDevice/revokeRegisteredDevice.d.ts +6 -0
- package/dist/modules/deviceRegistration/revokeRegisteredDevice/revokeRegisteredDevice.d.ts.map +1 -0
- package/dist/modules/initializeClient/initializeClient.d.ts.map +1 -1
- package/dist/modules/storageSync/hydrateStateWithStorage/hydrateStateWithStorage.d.ts.map +1 -1
- package/dist/modules/storageSync/schema.d.ts +2 -0
- package/dist/modules/storageSync/schema.d.ts.map +1 -1
- package/dist/modules/storageSync/syncStateWithStorage/syncStateWithStorage.d.ts.map +1 -1
- package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
- package/dist/modules/waas/waas.types.d.ts +1 -0
- package/dist/modules/waas/waas.types.d.ts.map +1 -1
- package/dist/modules/wallets/connectAndVerifyWithWalletProvider/connectAndVerifyWithWalletProvider.d.ts +10 -0
- package/dist/modules/wallets/connectAndVerifyWithWalletProvider/connectAndVerifyWithWalletProvider.d.ts.map +1 -1
- package/dist/modules/wallets/transferAmount/index.d.ts +2 -0
- package/dist/modules/wallets/transferAmount/index.d.ts.map +1 -0
- package/dist/modules/wallets/transferAmount/transferAmount.d.ts +19 -0
- package/dist/modules/wallets/transferAmount/transferAmount.d.ts.map +1 -0
- package/dist/modules/wallets/walletProvider/index.d.ts +1 -1
- package/dist/modules/wallets/walletProvider/index.d.ts.map +1 -1
- package/dist/modules/wallets/walletProvider/isDeeplinkWalletProvider/index.d.ts +2 -0
- package/dist/modules/wallets/walletProvider/isDeeplinkWalletProvider/index.d.ts.map +1 -0
- package/dist/modules/wallets/walletProvider/isDeeplinkWalletProvider/isDeeplinkWalletProvider.d.ts +10 -0
- package/dist/modules/wallets/walletProvider/isDeeplinkWalletProvider/isDeeplinkWalletProvider.d.ts.map +1 -0
- package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts +17 -0
- package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts.map +1 -1
- package/dist/services/openDeeplink/createWebDeeplinkOpener/createWebDeeplinkOpener.d.ts +11 -1
- package/dist/services/openDeeplink/createWebDeeplinkOpener/createWebDeeplinkOpener.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/getNonce/constants.d.ts +3 -0
- package/dist/utils/getNonce/constants.d.ts.map +1 -0
- package/dist/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.d.ts +13 -0
- package/dist/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.d.ts.map +1 -0
- package/dist/utils/getNonce/fetchAndStoreNonces/index.d.ts +2 -0
- package/dist/utils/getNonce/fetchAndStoreNonces/index.d.ts.map +1 -0
- package/dist/utils/getNonce/getNonce.d.ts +7 -0
- package/dist/utils/getNonce/getNonce.d.ts.map +1 -1
- package/dist/utils/getNonce/prefetchNoncesIfNeeded/prefetchNoncesIfNeeded.d.ts +3 -0
- package/dist/utils/getNonce/prefetchNoncesIfNeeded/prefetchNoncesIfNeeded.d.ts.map +1 -0
- package/dist/utils/getNonce/state.d.ts +15 -0
- package/dist/utils/getNonce/state.d.ts.map +1 -0
- package/dist/utils/parseAmountToSmallestUnit/index.d.ts +2 -0
- package/dist/utils/parseAmountToSmallestUnit/index.d.ts.map +1 -0
- package/dist/utils/parseAmountToSmallestUnit/parseAmountToSmallestUnit.d.ts +22 -0
- package/dist/utils/parseAmountToSmallestUnit/parseAmountToSmallestUnit.d.ts.map +1 -0
- package/dist/utils/parseUserAgent/index.d.ts +2 -0
- package/dist/utils/parseUserAgent/index.d.ts.map +1 -0
- package/dist/utils/parseUserAgent/parseUserAgent.d.ts +10 -0
- package/dist/utils/parseUserAgent/parseUserAgent.d.ts.map +1 -0
- package/dist/utils/randomString/randomString.d.ts +6 -1
- package/dist/utils/randomString/randomString.d.ts.map +1 -1
- package/dist/waas.cjs.js +3 -4
- package/dist/waas.cjs.js.map +1 -1
- package/dist/waas.esm.js +3 -3
- package/dist/waasCore.cjs.js +5 -5
- package/dist/waasCore.cjs.js.map +1 -1
- package/dist/waasCore.esm.js +5 -4
- package/dist/waasCore.esm.js.map +1 -1
- package/package.json +4 -3
- package/dist/InvalidParamError-DQn49mNB.esm.js.map +0 -1
- package/dist/InvalidParamError-DVzrk97b.cjs.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-DMMnYrfG.esm.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-z8WEapnj.cjs.js.map +0 -1
- package/dist/getSignedSessionId-BKKO2mqj.esm.js.map +0 -1
- package/dist/getSignedSessionId-BdGOv_TA.cjs.js.map +0 -1
- package/dist/isMfaRequiredForAction-BINs954q.cjs.js.map +0 -1
- package/dist/isMfaRequiredForAction-MvVGc7k3.esm.js.map +0 -1
- package/dist/modules/deviceRegistration/getDeviceSigner/getOrCreateUserDeviceSigningKeys/getOrCreateUserDeviceSigningKeys.d.ts.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
1
|
+
const require_InvalidParamError = require('./InvalidParamError-DO9X0rAe.cjs.js');
|
|
2
|
+
const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-B2NiAPL7.cjs.js');
|
|
3
|
+
const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-CTL5-19B.cjs.js');
|
|
4
|
+
const require_NotWaasWalletAccountError = require('./NotWaasWalletAccountError-Bj3-tWL3.cjs.js');
|
|
5
|
+
const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-DyrKyoVd.cjs.js');
|
|
6
6
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
7
7
|
let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
|
|
8
8
|
let zod_mini = require("zod/mini");
|
|
9
|
-
zod_mini =
|
|
9
|
+
zod_mini = require_InvalidParamError.__toESM(zod_mini);
|
|
10
10
|
let eventemitter3 = require("eventemitter3");
|
|
11
|
-
eventemitter3 =
|
|
11
|
+
eventemitter3 = require_InvalidParamError.__toESM(eventemitter3);
|
|
12
12
|
let _simplewebauthn_browser = require("@simplewebauthn/browser");
|
|
13
13
|
|
|
14
14
|
//#region src/modules/state/raiseStateEvents/events.ts
|
|
@@ -27,6 +27,13 @@ const stateChangeEvents = {
|
|
|
27
27
|
user: "userChanged"
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/utils/getNonce/prefetchNoncesIfNeeded/prefetchNoncesIfNeeded.ts
|
|
32
|
+
const prefetchNoncesIfNeeded = async (client) => {
|
|
33
|
+
if (require_InvalidParamError.getCore(client).state.get().prefetchedNonces.length >= require_InvalidParamError.NONCE_POOL_SIZE) return;
|
|
34
|
+
await require_InvalidParamError.fetchAndStoreNonces(client);
|
|
35
|
+
};
|
|
36
|
+
|
|
30
37
|
//#endregion
|
|
31
38
|
//#region src/utils/retryOnFail/InvalidRetryOnFailCallError.ts
|
|
32
39
|
/**
|
|
@@ -79,7 +86,7 @@ const isSignedIn = (client = require_InvalidParamError.getDefaultClient()) => Bo
|
|
|
79
86
|
/**
|
|
80
87
|
* The schema to track the expiration time of the project settings.
|
|
81
88
|
*/
|
|
82
|
-
const projectSettingsExpirationStorageKeySchema =
|
|
89
|
+
const projectSettingsExpirationStorageKeySchema = require_InvalidParamError.createStorageKeySchema({
|
|
83
90
|
key: "projectSettingsExpiration",
|
|
84
91
|
schema: zod_mini.number()
|
|
85
92
|
});
|
|
@@ -119,26 +126,6 @@ const fetchProjectSettings = async (client = require_InvalidParamError.getDefaul
|
|
|
119
126
|
return projectSettings;
|
|
120
127
|
};
|
|
121
128
|
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region src/modules/sessionKeys/generateSessionKeys/generateSessionKeys.ts
|
|
124
|
-
const generateSessionKeys = async (client) => {
|
|
125
|
-
const { private: privateKey, public: publicKey, privateJwk: privateKeyJwk } = await require_getNetworkProviderFromNetworkId.p256Keygen();
|
|
126
|
-
const core = require_InvalidParamError.getCore(client);
|
|
127
|
-
const stringifiedSessionKeys = JSON.stringify({
|
|
128
|
-
privateKey,
|
|
129
|
-
privateKeyJwk,
|
|
130
|
-
publicKey,
|
|
131
|
-
registered: false
|
|
132
|
-
});
|
|
133
|
-
const encodedSessionKeys = require_InvalidParamError.getBuffer().from(stringifiedSessionKeys).toString("base64");
|
|
134
|
-
core.state.set({ sessionKeys: encodedSessionKeys });
|
|
135
|
-
return {
|
|
136
|
-
privateKey,
|
|
137
|
-
privateKeyJwk,
|
|
138
|
-
publicKey
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
|
|
142
129
|
//#endregion
|
|
143
130
|
//#region src/services/runtimeServices/createRuntimeServices/createRuntimeServices.ts
|
|
144
131
|
/**
|
|
@@ -231,7 +218,7 @@ const logout = async (client = require_InvalidParamError.getDefaultClient()) =>
|
|
|
231
218
|
});
|
|
232
219
|
require_getVerifiedCredentialForWalletAccount.emitEvent({ event: "logout" }, client);
|
|
233
220
|
fetchProjectSettings(client);
|
|
234
|
-
generateSessionKeys(client);
|
|
221
|
+
require_getNetworkProviderFromNetworkId.generateSessionKeys(client);
|
|
235
222
|
};
|
|
236
223
|
|
|
237
224
|
//#endregion
|
|
@@ -347,17 +334,19 @@ const walletProviderKeyMapSchema = zod_mini.record(zod_mini.string(), zod_mini.s
|
|
|
347
334
|
|
|
348
335
|
//#endregion
|
|
349
336
|
//#region src/modules/storageSync/schema.ts
|
|
350
|
-
const stateStorageKeySchema =
|
|
337
|
+
const stateStorageKeySchema = require_InvalidParamError.createStorageKeySchema({
|
|
351
338
|
key: "state",
|
|
352
339
|
schema: zod_mini.object({
|
|
353
340
|
apiVersion: zod_mini.string(),
|
|
341
|
+
prefetchedNonces: zod_mini.array(zod_mini.string()),
|
|
342
|
+
prefetchedNoncesExpiration: zod_mini.nullable(zod_mini.number()),
|
|
354
343
|
projectSettings: zod_mini.custom(),
|
|
355
344
|
unverifiedWalletAccounts: zod_mini.array(unverifiedWalletAccountSchema),
|
|
356
345
|
user: zod_mini.custom(),
|
|
357
346
|
walletProviderKeyMap: walletProviderKeyMapSchema
|
|
358
347
|
})
|
|
359
348
|
});
|
|
360
|
-
const sessionStorageKeySchema =
|
|
349
|
+
const sessionStorageKeySchema = require_InvalidParamError.createStorageKeySchema({
|
|
361
350
|
key: "session",
|
|
362
351
|
schema: zod_mini.object({
|
|
363
352
|
captchaToken: zod_mini.nullable(zod_mini.string()),
|
|
@@ -401,6 +390,10 @@ const hydrateStateWithStorage = async (client) => {
|
|
|
401
390
|
if (storedState?.apiVersion === require_InvalidParamError.SDK_API_CORE_VERSION) {
|
|
402
391
|
stateChanges.unverifiedWalletAccounts = storedState.unverifiedWalletAccounts;
|
|
403
392
|
stateChanges.walletProviderKeyMap = storedState.walletProviderKeyMap;
|
|
393
|
+
if (storedState.prefetchedNoncesExpiration && storedState.prefetchedNoncesExpiration > Date.now()) {
|
|
394
|
+
stateChanges.prefetchedNonces = storedState.prefetchedNonces;
|
|
395
|
+
stateChanges.prefetchedNoncesExpiration = storedState.prefetchedNoncesExpiration;
|
|
396
|
+
}
|
|
404
397
|
if (isSessionValid) stateChanges.user = storedState.user;
|
|
405
398
|
if (isSessionValid || (storedState.unverifiedWalletAccounts ?? []).length > 0) stateChanges.projectSettings = storedState.projectSettings;
|
|
406
399
|
}
|
|
@@ -430,6 +423,8 @@ const syncStateWithStorage = (client) => {
|
|
|
430
423
|
});
|
|
431
424
|
core.storage.setItem(stateStorageKeySchema, {
|
|
432
425
|
apiVersion: require_InvalidParamError.SDK_API_CORE_VERSION,
|
|
426
|
+
prefetchedNonces: state.prefetchedNonces,
|
|
427
|
+
prefetchedNoncesExpiration: state.prefetchedNoncesExpiration,
|
|
433
428
|
projectSettings: state.projectSettings,
|
|
434
429
|
unverifiedWalletAccounts: state.unverifiedWalletAccounts,
|
|
435
430
|
user: state.user,
|
|
@@ -486,11 +481,14 @@ const initializeClient = async (client = require_InvalidParamError.getDefaultCli
|
|
|
486
481
|
const fetchProjectSettingsPromise = initializeStorageSyncPromise.then(async () => {
|
|
487
482
|
if (!core.state.get().projectSettings) await fetchProjectSettings(client);
|
|
488
483
|
});
|
|
484
|
+
fetchProjectSettingsPromise.then(() => prefetchNoncesIfNeeded(client)).catch((error) => {
|
|
485
|
+
core.logger.error("Failed to prefetch nonces:", error);
|
|
486
|
+
});
|
|
489
487
|
/**
|
|
490
488
|
* Generate session keys if they don't exist
|
|
491
489
|
*/
|
|
492
490
|
const generateSessionKeysPromise = fetchProjectSettingsPromise.then(async () => {
|
|
493
|
-
if (!core.state.get().sessionKeys) await generateSessionKeys(client);
|
|
491
|
+
if (!core.state.get().sessionKeys) await require_getNetworkProviderFromNetworkId.generateSessionKeys(client);
|
|
494
492
|
});
|
|
495
493
|
/**
|
|
496
494
|
* Refresh user state on initialization when cookie is enabled.
|
|
@@ -644,12 +642,22 @@ const createNavigationHandler = () => {
|
|
|
644
642
|
//#endregion
|
|
645
643
|
//#region src/services/openDeeplink/createWebDeeplinkOpener/createWebDeeplinkOpener.ts
|
|
646
644
|
/**
|
|
647
|
-
* Creates a deeplink opener that
|
|
645
|
+
* Creates a deeplink opener that navigates the current tab to the deeplink URL.
|
|
646
|
+
*
|
|
647
|
+
* Uses `window.location.assign` instead of `window.open` deliberately.
|
|
648
|
+
* This matters for Phantom redirect specifically, which is the only deep link
|
|
649
|
+
* provider that redirects back to the app in a new tab. With `window.open`,
|
|
650
|
+
* the browser first opens an `about:blank` tab before the native wallet app
|
|
651
|
+
* handles the deep link. When Phantom redirects back, it opens yet another
|
|
652
|
+
* tab. The user ends up with three tabs (original, about:blank, redirect) and
|
|
653
|
+
* the browser focuses the lingering about:blank after the redirect tab closes.
|
|
654
|
+
* `window.location.assign` reuses the current tab, avoiding the extra tab
|
|
655
|
+
* entirely.
|
|
648
656
|
*/
|
|
649
657
|
const createWebDeeplinkOpener = () => {
|
|
650
658
|
if (require_getNetworkProviderFromNetworkId.isServerSideRendering()) return () => Promise.reject(new UnavailableInServerSideError("createWebDeeplinkOpener"));
|
|
651
659
|
return async (url) => {
|
|
652
|
-
window.
|
|
660
|
+
window.location.assign(url);
|
|
653
661
|
};
|
|
654
662
|
};
|
|
655
663
|
|
|
@@ -804,6 +812,8 @@ const getInitialState = () => ({
|
|
|
804
812
|
initStatus: "uninitialized",
|
|
805
813
|
legacyToken: null,
|
|
806
814
|
mfaToken: null,
|
|
815
|
+
prefetchedNonces: [],
|
|
816
|
+
prefetchedNoncesExpiration: null,
|
|
807
817
|
projectSettings: null,
|
|
808
818
|
sessionExpiresAt: null,
|
|
809
819
|
sessionKeys: null,
|
|
@@ -925,6 +935,27 @@ var CheckoutSessionTokenMissingError = class extends require_InvalidParamError.B
|
|
|
925
935
|
}
|
|
926
936
|
};
|
|
927
937
|
|
|
938
|
+
//#endregion
|
|
939
|
+
//#region src/errors/DeeplinkConnectAndVerifyUnsupportedError.ts
|
|
940
|
+
var DeeplinkConnectAndVerifyUnsupportedError = class extends require_InvalidParamError.BaseError {
|
|
941
|
+
constructor({ walletProviderKey }) {
|
|
942
|
+
super({
|
|
943
|
+
cause: null,
|
|
944
|
+
code: "deeplink_connect_and_verify_unsupported",
|
|
945
|
+
docsUrl: null,
|
|
946
|
+
metaMessages: [
|
|
947
|
+
`Wallet provider key: ${walletProviderKey}`,
|
|
948
|
+
"On mobile, deep link wallet providers (e.g. Phantom redirect) cannot connect and verify in a single step.",
|
|
949
|
+
"iOS does not allow two sequential deep links — the second one is silently ignored because it is no longer tied to a user gesture.",
|
|
950
|
+
"Android may handle sequential deep links differently, but this guard applies to all mobile platforms to ensure a stable experience and prevent production-only errors.",
|
|
951
|
+
"Use connectWithWalletProvider() first, then call verifyWalletAccount() from a separate user action (e.g. a \"Verify Ownership\" button)."
|
|
952
|
+
],
|
|
953
|
+
name: "DeeplinkConnectAndVerifyUnsupportedError",
|
|
954
|
+
shortMessage: "connectAndVerifyWithWalletProvider is not supported for deep link wallet providers on mobile. Use connectWithWalletProvider and verifyWalletAccount separately."
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
};
|
|
958
|
+
|
|
928
959
|
//#endregion
|
|
929
960
|
//#region src/errors/FeeEstimationFailedError.ts
|
|
930
961
|
var FeeEstimationFailedError = class extends require_InvalidParamError.BaseError {
|
|
@@ -1460,7 +1491,7 @@ const removeDynamicOauthParamsFromUrl = (url) => {
|
|
|
1460
1491
|
//#endregion
|
|
1461
1492
|
//#region src/modules/auth/social/oauth/redirectStateStorageSchema/redirectStateStorageSchema.ts
|
|
1462
1493
|
/** The schema to track the state of the OAuth flow. */
|
|
1463
|
-
const redirectStateStorageKeySchema =
|
|
1494
|
+
const redirectStateStorageKeySchema = require_InvalidParamError.createStorageKeySchema({
|
|
1464
1495
|
key: "redirectState",
|
|
1465
1496
|
schema: zod_mini.object({
|
|
1466
1497
|
codeVerifier: zod_mini.optional(zod_mini.string()),
|
|
@@ -1551,8 +1582,8 @@ const buildOAuthUrl = async (core, provider) => {
|
|
|
1551
1582
|
const isGoogleDriveBackupEnabled = projectSettings.sdk.waas?.backupOptions?.includes(_dynamic_labs_sdk_api_core.WaasBackupOptionsEnum.GoogleDrive);
|
|
1552
1583
|
const socialProviderUrl = addOAuthUrlParams(socialProvider, getOAuthBaseUrl(socialProvider), { isGoogleDriveBackupEnabled });
|
|
1553
1584
|
const usingPkce = providersRequiringPkce.includes(provider);
|
|
1554
|
-
const state = require_InvalidParamError.randomString(32);
|
|
1555
|
-
const codeVerifier = require_InvalidParamError.randomString(43);
|
|
1585
|
+
const state = require_InvalidParamError.randomString({ length: 32 });
|
|
1586
|
+
const codeVerifier = require_InvalidParamError.randomString({ length: 43 });
|
|
1556
1587
|
socialProviderUrl.searchParams.set("state", state);
|
|
1557
1588
|
socialProviderUrl.searchParams.set("response_type", "code");
|
|
1558
1589
|
if (usingPkce) {
|
|
@@ -1740,7 +1771,7 @@ const getMultichainBalances = async ({ balanceRequest }, client = require_Invali
|
|
|
1740
1771
|
//#endregion
|
|
1741
1772
|
//#region src/modules/checkout/utils/createCheckoutSessionTokenStorageKey/createCheckoutSessionTokenStorageKey.ts
|
|
1742
1773
|
const createCheckoutSessionTokenStorageKey = (transactionId) => {
|
|
1743
|
-
return
|
|
1774
|
+
return require_InvalidParamError.createStorageKeySchema({
|
|
1744
1775
|
key: `checkoutSessionToken:${transactionId}`,
|
|
1745
1776
|
schema: zod_mini.string()
|
|
1746
1777
|
});
|
|
@@ -1769,12 +1800,13 @@ const createCheckoutApiClient = async ({ transactionId }, client) => {
|
|
|
1769
1800
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1770
1801
|
* @returns The updated checkout transaction
|
|
1771
1802
|
*/
|
|
1772
|
-
const attachCheckoutTransactionSource = async ({ fromAddress, fromChainId, transactionId }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1803
|
+
const attachCheckoutTransactionSource = async ({ fromAddress, fromChainId, fromChainName, transactionId }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1773
1804
|
const { apiClient, environmentId, sessionToken } = await createCheckoutApiClient({ transactionId }, client);
|
|
1774
1805
|
return apiClient.attachSource({
|
|
1775
1806
|
attachSourceRequest: {
|
|
1776
1807
|
fromAddress,
|
|
1777
1808
|
fromChainId,
|
|
1809
|
+
fromChainName,
|
|
1778
1810
|
sourceType: "wallet"
|
|
1779
1811
|
},
|
|
1780
1812
|
environmentId,
|
|
@@ -1822,6 +1854,14 @@ const cancelCheckoutTransaction = async ({ transactionId }, client = require_Inv
|
|
|
1822
1854
|
return result;
|
|
1823
1855
|
};
|
|
1824
1856
|
|
|
1857
|
+
//#endregion
|
|
1858
|
+
//#region src/modules/checkout/getCheckouts/getCheckouts.ts
|
|
1859
|
+
const getCheckouts = async (client) => {
|
|
1860
|
+
const projectSettings = client.projectSettings;
|
|
1861
|
+
require_InvalidParamError.assertDefined(projectSettings, "Project settings are not available");
|
|
1862
|
+
return projectSettings.checkouts ?? [];
|
|
1863
|
+
};
|
|
1864
|
+
|
|
1825
1865
|
//#endregion
|
|
1826
1866
|
//#region src/modules/checkout/createCheckoutTransaction/createCheckoutTransaction.ts
|
|
1827
1867
|
/**
|
|
@@ -1833,8 +1873,12 @@ const cancelCheckoutTransaction = async ({ transactionId }, client = require_Inv
|
|
|
1833
1873
|
*/
|
|
1834
1874
|
const createCheckoutTransaction = async (params, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1835
1875
|
const core = require_InvalidParamError.getCore(client);
|
|
1836
|
-
const
|
|
1837
|
-
|
|
1876
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
1877
|
+
const checkouts = await getCheckouts(client);
|
|
1878
|
+
const checkoutId = params.checkoutId ?? checkouts?.[0]?.id;
|
|
1879
|
+
require_InvalidParamError.assertDefined(checkoutId, "No checkout found. Please make sure you have a Checkout setup in the Dashboard.");
|
|
1880
|
+
const result = await apiClient.createCheckoutTransaction({
|
|
1881
|
+
checkoutId,
|
|
1838
1882
|
checkoutTransactionCreateRequest: {
|
|
1839
1883
|
amount: params.amount,
|
|
1840
1884
|
currency: params.currency,
|
|
@@ -1873,14 +1917,13 @@ const getCheckoutTransaction = async ({ transactionId }, client = require_Invali
|
|
|
1873
1917
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1874
1918
|
* @returns The updated checkout transaction with quote data
|
|
1875
1919
|
*/
|
|
1876
|
-
const getCheckoutTransactionQuote = async ({ fromTokenAddress, slippage,
|
|
1920
|
+
const getCheckoutTransactionQuote = async ({ fromTokenAddress, slippage, transactionId }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1877
1921
|
const { apiClient, environmentId, sessionToken } = await createCheckoutApiClient({ transactionId }, client);
|
|
1878
1922
|
return apiClient.quoteCheckoutTransaction({
|
|
1879
1923
|
environmentId,
|
|
1880
1924
|
quoteRequest: {
|
|
1881
1925
|
fromTokenAddress,
|
|
1882
|
-
slippage
|
|
1883
|
-
toTokenAddress
|
|
1926
|
+
slippage
|
|
1884
1927
|
},
|
|
1885
1928
|
transactionId,
|
|
1886
1929
|
xDynamicCheckoutSessionToken: sessionToken
|
|
@@ -1907,6 +1950,67 @@ const prepareCheckoutTransaction = async ({ transactionId }, client = require_In
|
|
|
1907
1950
|
});
|
|
1908
1951
|
};
|
|
1909
1952
|
|
|
1953
|
+
//#endregion
|
|
1954
|
+
//#region src/modules/wallets/utils/assertWalletProviderMethodDefined/assertWalletProviderMethodDefined.ts
|
|
1955
|
+
/**
|
|
1956
|
+
* Asserts that a specific wallet provider method is defined, throwing an error if it's not.
|
|
1957
|
+
* This function acts as a type guard, narrowing the type to ensure the method exists.
|
|
1958
|
+
*
|
|
1959
|
+
* @template T - The specific wallet provider method key being checked
|
|
1960
|
+
* @param walletProvider - The wallet provider object to check
|
|
1961
|
+
* @param methodName - The name of the method to check for availability
|
|
1962
|
+
* @throws Throws WalletProviderMethodUnavailableError if the method is not defined
|
|
1963
|
+
* @example
|
|
1964
|
+
* ```typescript
|
|
1965
|
+
* const walletProvider: WalletProvider = getWalletProvider();
|
|
1966
|
+
* assertWalletProviderMethodDefined(walletProvider, 'connect');
|
|
1967
|
+
* // walletProvider.connect is now guaranteed to be defined
|
|
1968
|
+
* await walletProvider.connect();
|
|
1969
|
+
* ```
|
|
1970
|
+
*/
|
|
1971
|
+
function assertWalletProviderMethodDefined(walletProvider, methodName) {
|
|
1972
|
+
if (walletProvider[methodName] === void 0) throw new WalletProviderMethodUnavailableError({
|
|
1973
|
+
methodName,
|
|
1974
|
+
walletProviderKey: walletProvider.key
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
//#endregion
|
|
1979
|
+
//#region src/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.ts
|
|
1980
|
+
/**
|
|
1981
|
+
* Prepares, signs, and broadcasts a checkout transaction in one call.
|
|
1982
|
+
*
|
|
1983
|
+
* Orchestrates the full submission flow:
|
|
1984
|
+
* 1. Calls prepareCheckoutTransaction to advance to signing state and lock the quote
|
|
1985
|
+
* 2. Ensures the wallet is on the correct network for the transaction
|
|
1986
|
+
* 3. Delegates on-chain signing to the wallet provider's executeCheckoutTransaction method
|
|
1987
|
+
* 4. Calls broadcastCheckoutTransaction with the resulting txHash
|
|
1988
|
+
*
|
|
1989
|
+
* @param params SubmitCheckoutTransactionParams - The transaction ID, wallet account, and optional step callback.
|
|
1990
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1991
|
+
* @returns The broadcasted checkout transaction
|
|
1992
|
+
*/
|
|
1993
|
+
const submitCheckoutTransaction = async ({ onStepChange, transactionId, walletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1994
|
+
const prepared = await prepareCheckoutTransaction({ transactionId }, client);
|
|
1995
|
+
require_InvalidParamError.assertDefined(prepared.signingPayload, "No signing payload returned from prepare — quote may be missing transaction data");
|
|
1996
|
+
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
1997
|
+
assertWalletProviderMethodDefined(walletProvider, "executeCheckoutTransaction");
|
|
1998
|
+
const requiredNetworkId = prepared.signingPayload.chainId;
|
|
1999
|
+
if (requiredNetworkId && walletProvider.switchActiveNetwork) {
|
|
2000
|
+
const { networkId: activeNetworkId } = await walletProvider.getActiveNetworkId();
|
|
2001
|
+
if (activeNetworkId !== requiredNetworkId) await walletProvider.switchActiveNetwork({ networkId: requiredNetworkId });
|
|
2002
|
+
}
|
|
2003
|
+
const { transactionHash } = await walletProvider.executeCheckoutTransaction({
|
|
2004
|
+
onStepChange,
|
|
2005
|
+
signingPayload: prepared.signingPayload,
|
|
2006
|
+
walletAccount
|
|
2007
|
+
});
|
|
2008
|
+
return broadcastCheckoutTransaction({
|
|
2009
|
+
transactionId,
|
|
2010
|
+
txHash: transactionHash
|
|
2011
|
+
}, client);
|
|
2012
|
+
};
|
|
2013
|
+
|
|
1910
2014
|
//#endregion
|
|
1911
2015
|
//#region src/modules/deviceRegistration/completeDeviceRegistration/completeDeviceRegistration.ts
|
|
1912
2016
|
const DEVICE_REGISTRATION_TOKEN_HEADER = "x-dynamic-device-registration-token";
|
|
@@ -1961,6 +2065,23 @@ const detectDeviceRegistrationRedirect = ({ url }) => {
|
|
|
1961
2065
|
}
|
|
1962
2066
|
};
|
|
1963
2067
|
|
|
2068
|
+
//#endregion
|
|
2069
|
+
//#region src/modules/deviceRegistration/getRegisteredDevices/getRegisteredDevices.ts
|
|
2070
|
+
const getRegisteredDevices = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
2071
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2072
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
2073
|
+
try {
|
|
2074
|
+
return (await apiClient.listDeviceRegistrations({ environmentId: core.environmentId })).deviceRegistrations;
|
|
2075
|
+
} catch (error) {
|
|
2076
|
+
/**
|
|
2077
|
+
* The API will return 401 when no devices are registered when there are no
|
|
2078
|
+
* devices registered. We need to handle this case gracefully.
|
|
2079
|
+
*/
|
|
2080
|
+
if (error instanceof require_InvalidParamError.UnauthorizedError) return [];
|
|
2081
|
+
throw error;
|
|
2082
|
+
}
|
|
2083
|
+
};
|
|
2084
|
+
|
|
1964
2085
|
//#endregion
|
|
1965
2086
|
//#region src/modules/deviceRegistration/isDeviceRegistrationRequired/isDeviceRegistrationRequired.ts
|
|
1966
2087
|
/**
|
|
@@ -1977,6 +2098,25 @@ const isDeviceRegistrationRequired = (client = require_InvalidParamError.getDefa
|
|
|
1977
2098
|
return Boolean(user.scope?.includes("device:register"));
|
|
1978
2099
|
};
|
|
1979
2100
|
|
|
2101
|
+
//#endregion
|
|
2102
|
+
//#region src/modules/deviceRegistration/revokeAllRegisteredDevices/revokeAllRegisteredDevices.ts
|
|
2103
|
+
const revokeAllRegisteredDevices = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
2104
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2105
|
+
await require_InvalidParamError.createApiClient({}, client).deleteAllDeviceRegistrations({ environmentId: core.environmentId });
|
|
2106
|
+
await logout(client);
|
|
2107
|
+
};
|
|
2108
|
+
|
|
2109
|
+
//#endregion
|
|
2110
|
+
//#region src/modules/deviceRegistration/revokeRegisteredDevice/revokeRegisteredDevice.ts
|
|
2111
|
+
const revokeRegisteredDevice = async ({ deviceRegistrationId }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2112
|
+
require_InvalidParamError.assertDefined(deviceRegistrationId, "deviceRegistrationId is required");
|
|
2113
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2114
|
+
if ((await require_InvalidParamError.createApiClient({}, client).deleteDeviceRegistration({
|
|
2115
|
+
deviceRegistrationId,
|
|
2116
|
+
environmentId: core.environmentId
|
|
2117
|
+
})).currentDeviceRevoked) await logout(client);
|
|
2118
|
+
};
|
|
2119
|
+
|
|
1980
2120
|
//#endregion
|
|
1981
2121
|
//#region src/modules/funding/coinbase/addCoinbaseOnrampOrderEventListener/addCoinbaseOnrampOrderEventListener.ts
|
|
1982
2122
|
/**
|
|
@@ -2276,7 +2416,7 @@ const fetchWithTimeout = async (client) => {
|
|
|
2276
2416
|
/**
|
|
2277
2417
|
* The schema to store the cached wallet book data.
|
|
2278
2418
|
*/
|
|
2279
|
-
const walletBookCacheStorageKeySchema =
|
|
2419
|
+
const walletBookCacheStorageKeySchema = require_InvalidParamError.createStorageKeySchema({
|
|
2280
2420
|
key: "legacyWalletBookCache",
|
|
2281
2421
|
schema: zod_mini.object({
|
|
2282
2422
|
groups: zod_mini.record(zod_mini.string(), zod_mini.any()),
|
|
@@ -4127,29 +4267,27 @@ const assertWalletAccountSigningAvailability = async ({ walletAccount }, client
|
|
|
4127
4267
|
};
|
|
4128
4268
|
|
|
4129
4269
|
//#endregion
|
|
4130
|
-
//#region src/
|
|
4270
|
+
//#region src/utils/isMobile/isMobile.ts
|
|
4131
4271
|
/**
|
|
4132
|
-
*
|
|
4133
|
-
* This function acts as a type guard, narrowing the type to ensure the method exists.
|
|
4134
|
-
*
|
|
4135
|
-
* @template T - The specific wallet provider method key being checked
|
|
4136
|
-
* @param walletProvider - The wallet provider object to check
|
|
4137
|
-
* @param methodName - The name of the method to check for availability
|
|
4138
|
-
* @throws Throws WalletProviderMethodUnavailableError if the method is not defined
|
|
4139
|
-
* @example
|
|
4140
|
-
* ```typescript
|
|
4141
|
-
* const walletProvider: WalletProvider = getWalletProvider();
|
|
4142
|
-
* assertWalletProviderMethodDefined(walletProvider, 'connect');
|
|
4143
|
-
* // walletProvider.connect is now guaranteed to be defined
|
|
4144
|
-
* await walletProvider.connect();
|
|
4145
|
-
* ```
|
|
4272
|
+
* Sourced from http://detectmobilebrowsers.com/
|
|
4146
4273
|
*/
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
}
|
|
4274
|
+
const userAgentRegex1 = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ios|ipad|playbook|silk/i;
|
|
4275
|
+
const userAgentRegex2 = /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i;
|
|
4276
|
+
const isMobile = (maxTouchPointsOverride) => {
|
|
4277
|
+
if (typeof window === "undefined" || typeof navigator === "undefined") return false;
|
|
4278
|
+
return userAgentRegex1.test(navigator.userAgent) || userAgentRegex2.test(navigator.userAgent.substring(0, 4)) || isIPad(maxTouchPointsOverride) || isIPhone();
|
|
4279
|
+
};
|
|
4280
|
+
const isIPhone = () => typeof window === "undefined" || typeof navigator === "undefined" ? false : /iPhone|ios/.test(navigator.userAgent);
|
|
4281
|
+
/**
|
|
4282
|
+
* @param [optional] maxTouchPointsOverride - this is used for testing since
|
|
4283
|
+
* it seems that JSDOM doesn't support maxTouchPoints, so it was impossible
|
|
4284
|
+
* to mock it
|
|
4285
|
+
*/
|
|
4286
|
+
const isIPad = (maxTouchPointsOverride) => {
|
|
4287
|
+
if (typeof window === "undefined" || typeof navigator === "undefined") return false;
|
|
4288
|
+
const maxTouchPoints = maxTouchPointsOverride || navigator.maxTouchPoints;
|
|
4289
|
+
return /iPad/.test(navigator.userAgent) || /Mac/.test(navigator.userAgent) && maxTouchPoints === 5;
|
|
4290
|
+
};
|
|
4153
4291
|
|
|
4154
4292
|
//#endregion
|
|
4155
4293
|
//#region src/modules/wallets/utils/getAddressesWithTypesFromConnectionResult/getAddressesWithTypesFromConnectionResult.ts
|
|
@@ -4241,7 +4379,7 @@ const getSignInMessage = async ({ walletAccount }, client) => {
|
|
|
4241
4379
|
require_InvalidParamError.assertDefined(universalLink, "Universal link is not set");
|
|
4242
4380
|
const url = new URL(universalLink);
|
|
4243
4381
|
const domain = url.host;
|
|
4244
|
-
const nonce = await
|
|
4382
|
+
const nonce = await require_InvalidParamError.getNonce(client);
|
|
4245
4383
|
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
4246
4384
|
if (walletProvider.chain === "STARK")
|
|
4247
4385
|
/**
|
|
@@ -4359,6 +4497,13 @@ const verifyWalletAccount = async ({ walletAccount, requestedScopes }, client =
|
|
|
4359
4497
|
}, client);
|
|
4360
4498
|
};
|
|
4361
4499
|
|
|
4500
|
+
//#endregion
|
|
4501
|
+
//#region src/modules/wallets/walletProvider/isDeeplinkWalletProvider/isDeeplinkWalletProvider.ts
|
|
4502
|
+
/**
|
|
4503
|
+
* Returns true if the wallet provider uses the deep link protocol (e.g. Phantom redirect on mobile).
|
|
4504
|
+
*/
|
|
4505
|
+
const isDeeplinkWalletProvider = ({ walletProvider }) => walletProvider.walletProviderType === _dynamic_labs_sdk_api_core.WalletProviderEnum.DeepLink;
|
|
4506
|
+
|
|
4362
4507
|
//#endregion
|
|
4363
4508
|
//#region src/modules/wallets/connectAndVerifyWithWalletProvider/connectAndVerifyWithWalletProvider.ts
|
|
4364
4509
|
/**
|
|
@@ -4368,12 +4513,24 @@ const verifyWalletAccount = async ({ walletAccount, requestedScopes }, client =
|
|
|
4368
4513
|
* requiring the user to sign a message to prove wallet ownership before
|
|
4369
4514
|
* the wallet account is added to their profile.
|
|
4370
4515
|
*
|
|
4516
|
+
* @throws {DeeplinkConnectAndVerifyUnsupportedError} On mobile with deep link
|
|
4517
|
+
* wallet providers (e.g. Phantom redirect). This function triggers two sequential
|
|
4518
|
+
* deeplinks — one to connect and another to sign for verification. iOS will not
|
|
4519
|
+
* honor the second deeplink because it is no longer tied to a user gesture.
|
|
4520
|
+
* Android may handle sequential deeplinks differently, but this guard applies to
|
|
4521
|
+
* all mobile platforms to ensure a stable experience and prevent production-only
|
|
4522
|
+
* errors. Use `connectWithWalletProvider` first and then invoke
|
|
4523
|
+
* `verifyWalletAccount` separately from a new user gesture (e.g. a "Verify
|
|
4524
|
+
* Ownership" button).
|
|
4525
|
+
*
|
|
4371
4526
|
* @param params.walletProviderKey - The unique key identifying the wallet provider to connect to.
|
|
4372
4527
|
* @param [params.hardwareWalletVendor] - The hardware wallet vendor, if connecting via a hardware wallet (e.g. 'ledger').
|
|
4373
4528
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4374
4529
|
* @returns A promise that resolves to the connected and verified wallet account.
|
|
4375
4530
|
*/
|
|
4376
4531
|
const connectAndVerifyWithWalletProvider = async ({ walletProviderKey, hardwareWalletVendor }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4532
|
+
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderByKey({ walletProviderKey }, client);
|
|
4533
|
+
if (isMobile() && isDeeplinkWalletProvider({ walletProvider })) throw new DeeplinkConnectAndVerifyUnsupportedError({ walletProviderKey });
|
|
4377
4534
|
const walletAccount = await connectWithWalletProvider({
|
|
4378
4535
|
addToDynamicWalletAccounts: false,
|
|
4379
4536
|
hardwareWalletVendor,
|
|
@@ -4745,6 +4902,34 @@ const signMessage = async ({ walletAccount, message }, client = require_InvalidP
|
|
|
4745
4902
|
return { signature };
|
|
4746
4903
|
};
|
|
4747
4904
|
|
|
4905
|
+
//#endregion
|
|
4906
|
+
//#region src/modules/wallets/transferAmount/transferAmount.ts
|
|
4907
|
+
/**
|
|
4908
|
+
* Transfers an amount of currency from the wallet account to a recipient.
|
|
4909
|
+
*
|
|
4910
|
+
* Supports native token transfers and, where supported by the chain,
|
|
4911
|
+
* fungible/token transfers via the optional `token` parameter.
|
|
4912
|
+
*
|
|
4913
|
+
* @param params.walletAccount - The wallet account to transfer from.
|
|
4914
|
+
* @param params.amount - The amount to transfer as a decimal string (e.g. "1.5").
|
|
4915
|
+
* @param params.recipient - The recipient address.
|
|
4916
|
+
* @param params.token - Optional token info for non-native transfers.
|
|
4917
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4918
|
+
* @returns A promise that resolves to an object containing the transaction hash.
|
|
4919
|
+
* @throws If the wallet provider does not support the transfer amount method.
|
|
4920
|
+
*/
|
|
4921
|
+
const transferAmount = async ({ walletAccount, amount, recipient, token }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4922
|
+
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
4923
|
+
assertWalletProviderMethodDefined(walletProvider, "transferAmount");
|
|
4924
|
+
const { transactionHash } = await walletProvider.transferAmount({
|
|
4925
|
+
amount,
|
|
4926
|
+
recipient,
|
|
4927
|
+
token,
|
|
4928
|
+
walletAccount
|
|
4929
|
+
});
|
|
4930
|
+
return { transactionHash };
|
|
4931
|
+
};
|
|
4932
|
+
|
|
4748
4933
|
//#endregion
|
|
4749
4934
|
//#region src/modules/wallets/transferWalletAccount/transferWalletAccount.ts
|
|
4750
4935
|
/**
|
|
@@ -4823,26 +5008,78 @@ const onWalletProviderEvent = ({ callback, event, walletProviderKey }, client =
|
|
|
4823
5008
|
};
|
|
4824
5009
|
|
|
4825
5010
|
//#endregion
|
|
4826
|
-
//#region src/utils/
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
}
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
5011
|
+
//#region src/utils/parseUserAgent/parseUserAgent.ts
|
|
5012
|
+
const browserMatchers = [
|
|
5013
|
+
{
|
|
5014
|
+
name: "Edge",
|
|
5015
|
+
pattern: /Edg(e|A|iOS)?\//
|
|
5016
|
+
},
|
|
5017
|
+
{
|
|
5018
|
+
name: "Opera",
|
|
5019
|
+
pattern: /OPR\/|Opera/
|
|
5020
|
+
},
|
|
5021
|
+
{
|
|
5022
|
+
name: "Samsung Browser",
|
|
5023
|
+
pattern: /SamsungBrowser/
|
|
5024
|
+
},
|
|
5025
|
+
{
|
|
5026
|
+
name: "Firefox",
|
|
5027
|
+
pattern: /Firefox/
|
|
5028
|
+
},
|
|
5029
|
+
{
|
|
5030
|
+
name: "Safari",
|
|
5031
|
+
pattern: /^(?!.*(?:Chrome|Chromium|CriOS)).*Safari/
|
|
5032
|
+
},
|
|
5033
|
+
{
|
|
5034
|
+
name: "Chrome",
|
|
5035
|
+
pattern: /Chrome|CriOS/
|
|
5036
|
+
}
|
|
5037
|
+
];
|
|
5038
|
+
const mobileOsNames = new Set([
|
|
5039
|
+
"iPhone",
|
|
5040
|
+
"iPad",
|
|
5041
|
+
"Android"
|
|
5042
|
+
]);
|
|
5043
|
+
const osMatchers = [
|
|
5044
|
+
{
|
|
5045
|
+
name: "iPhone",
|
|
5046
|
+
pattern: /iPhone/
|
|
5047
|
+
},
|
|
5048
|
+
{
|
|
5049
|
+
name: "iPad",
|
|
5050
|
+
pattern: /iPad/
|
|
5051
|
+
},
|
|
5052
|
+
{
|
|
5053
|
+
name: "Android",
|
|
5054
|
+
pattern: /Android/
|
|
5055
|
+
},
|
|
5056
|
+
{
|
|
5057
|
+
name: "Windows",
|
|
5058
|
+
pattern: /Windows/
|
|
5059
|
+
},
|
|
5060
|
+
{
|
|
5061
|
+
name: "macOS",
|
|
5062
|
+
pattern: /Macintosh|Mac OS X/
|
|
5063
|
+
},
|
|
5064
|
+
{
|
|
5065
|
+
name: "Linux",
|
|
5066
|
+
pattern: /Linux/
|
|
5067
|
+
},
|
|
5068
|
+
{
|
|
5069
|
+
name: "ChromeOS",
|
|
5070
|
+
pattern: /CrOS/
|
|
5071
|
+
}
|
|
5072
|
+
];
|
|
5073
|
+
const parseUserAgent = ({ userAgent }) => {
|
|
5074
|
+
if (!userAgent?.trim()) return null;
|
|
5075
|
+
const browser = browserMatchers.find(({ pattern }) => pattern.test(userAgent))?.name;
|
|
5076
|
+
const os = osMatchers.find(({ pattern }) => pattern.test(userAgent))?.name;
|
|
5077
|
+
if (!browser && !os) return null;
|
|
5078
|
+
const isMobile$1 = os ? mobileOsNames.has(os) : false;
|
|
5079
|
+
return {
|
|
5080
|
+
displayText: browser && os ? `${browser} on ${os}` : browser ?? os ?? "",
|
|
5081
|
+
type: isMobile$1 ? "mobile" : "desktop"
|
|
5082
|
+
};
|
|
4846
5083
|
};
|
|
4847
5084
|
|
|
4848
5085
|
//#endregion
|
|
@@ -4853,6 +5090,7 @@ const isIPad = (maxTouchPointsOverride) => {
|
|
|
4853
5090
|
exports.BaseError = require_InvalidParamError.BaseError;
|
|
4854
5091
|
exports.CheckoutSessionTokenMissingError = CheckoutSessionTokenMissingError;
|
|
4855
5092
|
exports.ClientAlreadyInitializedError = ClientAlreadyInitializedError;
|
|
5093
|
+
exports.DeeplinkConnectAndVerifyUnsupportedError = DeeplinkConnectAndVerifyUnsupportedError;
|
|
4856
5094
|
exports.FeeEstimationFailedError = FeeEstimationFailedError;
|
|
4857
5095
|
exports.InvalidDeviceRegistrationRedirectError = InvalidDeviceRegistrationRedirectError;
|
|
4858
5096
|
exports.InvalidExternalAuthError = require_InvalidParamError.InvalidExternalAuthError;
|
|
@@ -4881,6 +5119,7 @@ exports.NoWebAuthNSupportError = NoWebAuthNSupportError;
|
|
|
4881
5119
|
exports.NotWaasWalletAccountError = require_NotWaasWalletAccountError.NotWaasWalletAccountError;
|
|
4882
5120
|
exports.SandboxMaximumThresholdReachedError = require_InvalidParamError.SandboxMaximumThresholdReachedError;
|
|
4883
5121
|
exports.SimulationFailedError = SimulationFailedError;
|
|
5122
|
+
exports.UnauthorizedError = require_InvalidParamError.UnauthorizedError;
|
|
4884
5123
|
exports.UnavailableInServerSideError = UnavailableInServerSideError;
|
|
4885
5124
|
exports.UnrecognizedNetworkError = UnrecognizedNetworkError;
|
|
4886
5125
|
exports.UserNotAuthenticatedError = UserNotAuthenticatedError;
|
|
@@ -4942,6 +5181,7 @@ exports.getNetworksData = require_getNetworkProviderFromNetworkId.getNetworksDat
|
|
|
4942
5181
|
exports.getOwnerWalletAccountForSmartWalletAccount = getOwnerWalletAccountForSmartWalletAccount;
|
|
4943
5182
|
exports.getPasskeys = getPasskeys;
|
|
4944
5183
|
exports.getPrimaryWalletAccount = getPrimaryWalletAccount;
|
|
5184
|
+
exports.getRegisteredDevices = getRegisteredDevices;
|
|
4945
5185
|
exports.getTransactionHistory = getTransactionHistory;
|
|
4946
5186
|
exports.getUserSocialAccounts = getUserSocialAccounts;
|
|
4947
5187
|
exports.getWalletAccountAddressByType = getWalletAccountAddressByType;
|
|
@@ -4953,6 +5193,7 @@ exports.getWalletProviderDataByKey = getWalletProviderDataByKey;
|
|
|
4953
5193
|
exports.hasExtension = require_getNetworkProviderFromNetworkId.hasExtension;
|
|
4954
5194
|
exports.initializeClient = initializeClient;
|
|
4955
5195
|
exports.isCaptchaRequired = require_getNetworkProviderFromNetworkId.isCaptchaRequired;
|
|
5196
|
+
exports.isDeeplinkWalletProvider = isDeeplinkWalletProvider;
|
|
4956
5197
|
exports.isDeviceRegistrationRequired = isDeviceRegistrationRequired;
|
|
4957
5198
|
exports.isHardwareWalletAccount = isHardwareWalletAccount;
|
|
4958
5199
|
exports.isMfaRequiredForAction = require_isMfaRequiredForAction.isMfaRequiredForAction;
|
|
@@ -4969,6 +5210,7 @@ exports.offWalletProviderEvent = offWalletProviderEvent;
|
|
|
4969
5210
|
exports.onEvent = require_getVerifiedCredentialForWalletAccount.onEvent;
|
|
4970
5211
|
exports.onWalletProviderEvent = onWalletProviderEvent;
|
|
4971
5212
|
exports.onceEvent = require_getVerifiedCredentialForWalletAccount.onceEvent;
|
|
5213
|
+
exports.parseUserAgent = parseUserAgent;
|
|
4972
5214
|
exports.prepareCheckoutTransaction = prepareCheckoutTransaction;
|
|
4973
5215
|
exports.proveWalletAccountOwnership = proveWalletAccountOwnership;
|
|
4974
5216
|
exports.refreshAuth = require_NotWaasWalletAccountError.refreshAuth;
|
|
@@ -4976,6 +5218,8 @@ exports.refreshUser = refreshUser;
|
|
|
4976
5218
|
exports.registerPasskey = registerPasskey;
|
|
4977
5219
|
exports.registerTotpMfaDevice = registerTotpMfaDevice;
|
|
4978
5220
|
exports.removeWalletAccount = removeWalletAccount;
|
|
5221
|
+
exports.revokeAllRegisteredDevices = revokeAllRegisteredDevices;
|
|
5222
|
+
exports.revokeRegisteredDevice = revokeRegisteredDevice;
|
|
4979
5223
|
exports.selectPrimaryWalletAccount = selectPrimaryWalletAccount;
|
|
4980
5224
|
exports.sendEmailOTP = sendEmailOTP;
|
|
4981
5225
|
exports.sendSmsOTP = sendSmsOTP;
|
|
@@ -4984,8 +5228,10 @@ exports.setDefaultMfaDevice = setDefaultMfaDevice;
|
|
|
4984
5228
|
exports.signInWithExternalJwt = signInWithExternalJwt;
|
|
4985
5229
|
exports.signInWithPasskey = signInWithPasskey;
|
|
4986
5230
|
exports.signMessage = signMessage;
|
|
5231
|
+
exports.submitCheckoutTransaction = submitCheckoutTransaction;
|
|
4987
5232
|
exports.supportedCountries = supportedCountries;
|
|
4988
5233
|
exports.switchActiveNetwork = switchActiveNetwork;
|
|
5234
|
+
exports.transferAmount = transferAmount;
|
|
4989
5235
|
exports.transferWalletAccount = transferWalletAccount;
|
|
4990
5236
|
exports.unlinkSocialAccount = unlinkSocialAccount;
|
|
4991
5237
|
exports.updateUser = updateUser;
|