@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.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { A as version, D as BaseError, O as
|
|
2
|
-
import { A as
|
|
3
|
-
import { D as onceEvent, E as onEvent, O as setCookie, S as splitWalletProviderKey, T as offEvent, _ as getWalletAccounts, b as formatWalletAccountId, c as getWalletProviders, d as DYNAMIC_AUTH_COOKIE_NAME, f as getWalletProviderFromWalletAccount, g as NoWalletProviderFoundError, i as restoreUserSharesForAllWalletAccounts, l as checkAndRaiseWalletAccountsChangedEvent, n as getWalletProviderByKey, r as updateAuthFromVerifyResponse, t as getVerifiedCredentialForWalletAccount, u as emitWalletAccountsChangedEvent, w as emitEvent, x as normalizeAddress } from "./getVerifiedCredentialForWalletAccount-
|
|
4
|
-
import { n as
|
|
5
|
-
import { n as
|
|
1
|
+
import { A as randomString, B as version, C as InvalidExternalAuthError, D as isCookieEnabled, F as setDefaultClient, L as BaseError, N as NONCE_POOL_SIZE, O as assertDefined, P as getDefaultClient, R as getCore, S as LinkCredentialError, a as DYNAMIC_ICONIC_SPRITE_URL, b as MfaRateLimitedError, c as CHAINS_INFO_MAP, d as UnauthorizedError, g as createStorageKeySchema, j as CLIENT_SDK_NAME, k as ValueMustBeDefinedError, l as fetchAndStoreNonces, o as SDK_API_CORE_VERSION, s as getChainFromVerifiedCredentialChain, t as InvalidParamError, u as createApiClient, v as getNonce, w as APIError, x as MfaInvalidOtpError, y as SandboxMaximumThresholdReachedError, z as name } from "./InvalidParamError-Cty-xWsw.esm.js";
|
|
2
|
+
import { A as isEqualShallow, C as isServerSideRendering, D as REFRESH_USER_STATE_FROM_COOKIE_TRACKER_KEY, E as INITIALIZE_STORAGE_SYNC_TRACKER_KEY, N as createLocalStorageAdapter, O as generateSessionKeys, S as createDeferredPromise, T as GENERATE_SESSION_KEYS_TRACKER_KEY, _ as NoNetworkProvidersError, a as updateWalletProviderKeysForVerifiedCredentials, c as createSignInMessageStatement, d as createVisit, f as hasExtension, g as WalletAlreadyLinkedToAnotherUserError, h as isCaptchaRequired, i as getNetworksData, j as createStorage, k as subscribeWithSelector, l as formatSignInMessage, m as consumeCaptchaToken, o as verifyMessageSignatureOwnership, p as setCaptchaToken, s as removeUnverifiedWalletAccount, t as getNetworkProviderFromNetworkId, u as setUnverifiedWalletAccounts, v as createLogger, w as FETCH_PROJECT_SETTINGS_TRACKER_KEY, x as CannotTrackError, y as createCrossTabBroadcast } from "./getNetworkProviderFromNetworkId-DKM-ec3L.esm.js";
|
|
3
|
+
import { D as onceEvent, E as onEvent, O as setCookie, S as splitWalletProviderKey, T as offEvent, _ as getWalletAccounts, b as formatWalletAccountId, c as getWalletProviders, d as DYNAMIC_AUTH_COOKIE_NAME, f as getWalletProviderFromWalletAccount, g as NoWalletProviderFoundError, i as restoreUserSharesForAllWalletAccounts, l as checkAndRaiseWalletAccountsChangedEvent, n as getWalletProviderByKey, r as updateAuthFromVerifyResponse, t as getVerifiedCredentialForWalletAccount, u as emitWalletAccountsChangedEvent, w as emitEvent, x as normalizeAddress } from "./getVerifiedCredentialForWalletAccount-CpUomVzT.esm.js";
|
|
4
|
+
import { n as refreshAuth, t as NotWaasWalletAccountError } from "./NotWaasWalletAccountError-x0HlFCot.esm.js";
|
|
5
|
+
import { n as getMfaMethods, r as consumeMfaToken, t as isMfaRequiredForAction } from "./isMfaRequiredForAction-Hi4dCidj.esm.js";
|
|
6
6
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
7
|
-
import { AuthModeEnum, ExchangeKeyEnum, JwtVerifiedCredentialFormatEnum, MFAAction, MfaBackupCodeAcknowledgement, ProviderEnum, WaasBackupOptionsEnum } from "@dynamic-labs/sdk-api-core";
|
|
7
|
+
import { AuthModeEnum, ExchangeKeyEnum, JwtVerifiedCredentialFormatEnum, MFAAction, MfaBackupCodeAcknowledgement, ProviderEnum, WaasBackupOptionsEnum, WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
|
|
8
8
|
import * as z from "zod/mini";
|
|
9
9
|
import EventEmitter, { EventEmitter as EventEmitter$1 } from "eventemitter3";
|
|
10
10
|
import { browserSupportsWebAuthn, startAuthentication, startRegistration } from "@simplewebauthn/browser";
|
|
@@ -25,6 +25,13 @@ const stateChangeEvents = {
|
|
|
25
25
|
user: "userChanged"
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/utils/getNonce/prefetchNoncesIfNeeded/prefetchNoncesIfNeeded.ts
|
|
30
|
+
const prefetchNoncesIfNeeded = async (client) => {
|
|
31
|
+
if (getCore(client).state.get().prefetchedNonces.length >= NONCE_POOL_SIZE) return;
|
|
32
|
+
await fetchAndStoreNonces(client);
|
|
33
|
+
};
|
|
34
|
+
|
|
28
35
|
//#endregion
|
|
29
36
|
//#region src/utils/retryOnFail/InvalidRetryOnFailCallError.ts
|
|
30
37
|
/**
|
|
@@ -117,26 +124,6 @@ const fetchProjectSettings = async (client = getDefaultClient()) => {
|
|
|
117
124
|
return projectSettings;
|
|
118
125
|
};
|
|
119
126
|
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/modules/sessionKeys/generateSessionKeys/generateSessionKeys.ts
|
|
122
|
-
const generateSessionKeys = async (client) => {
|
|
123
|
-
const { private: privateKey, public: publicKey, privateJwk: privateKeyJwk } = await p256Keygen();
|
|
124
|
-
const core = getCore(client);
|
|
125
|
-
const stringifiedSessionKeys = JSON.stringify({
|
|
126
|
-
privateKey,
|
|
127
|
-
privateKeyJwk,
|
|
128
|
-
publicKey,
|
|
129
|
-
registered: false
|
|
130
|
-
});
|
|
131
|
-
const encodedSessionKeys = getBuffer().from(stringifiedSessionKeys).toString("base64");
|
|
132
|
-
core.state.set({ sessionKeys: encodedSessionKeys });
|
|
133
|
-
return {
|
|
134
|
-
privateKey,
|
|
135
|
-
privateKeyJwk,
|
|
136
|
-
publicKey
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
|
|
140
127
|
//#endregion
|
|
141
128
|
//#region src/services/runtimeServices/createRuntimeServices/createRuntimeServices.ts
|
|
142
129
|
/**
|
|
@@ -349,6 +336,8 @@ const stateStorageKeySchema = createStorageKeySchema({
|
|
|
349
336
|
key: "state",
|
|
350
337
|
schema: z.object({
|
|
351
338
|
apiVersion: z.string(),
|
|
339
|
+
prefetchedNonces: z.array(z.string()),
|
|
340
|
+
prefetchedNoncesExpiration: z.nullable(z.number()),
|
|
352
341
|
projectSettings: z.custom(),
|
|
353
342
|
unverifiedWalletAccounts: z.array(unverifiedWalletAccountSchema),
|
|
354
343
|
user: z.custom(),
|
|
@@ -399,6 +388,10 @@ const hydrateStateWithStorage = async (client) => {
|
|
|
399
388
|
if (storedState?.apiVersion === SDK_API_CORE_VERSION) {
|
|
400
389
|
stateChanges.unverifiedWalletAccounts = storedState.unverifiedWalletAccounts;
|
|
401
390
|
stateChanges.walletProviderKeyMap = storedState.walletProviderKeyMap;
|
|
391
|
+
if (storedState.prefetchedNoncesExpiration && storedState.prefetchedNoncesExpiration > Date.now()) {
|
|
392
|
+
stateChanges.prefetchedNonces = storedState.prefetchedNonces;
|
|
393
|
+
stateChanges.prefetchedNoncesExpiration = storedState.prefetchedNoncesExpiration;
|
|
394
|
+
}
|
|
402
395
|
if (isSessionValid) stateChanges.user = storedState.user;
|
|
403
396
|
if (isSessionValid || (storedState.unverifiedWalletAccounts ?? []).length > 0) stateChanges.projectSettings = storedState.projectSettings;
|
|
404
397
|
}
|
|
@@ -428,6 +421,8 @@ const syncStateWithStorage = (client) => {
|
|
|
428
421
|
});
|
|
429
422
|
core.storage.setItem(stateStorageKeySchema, {
|
|
430
423
|
apiVersion: SDK_API_CORE_VERSION,
|
|
424
|
+
prefetchedNonces: state.prefetchedNonces,
|
|
425
|
+
prefetchedNoncesExpiration: state.prefetchedNoncesExpiration,
|
|
431
426
|
projectSettings: state.projectSettings,
|
|
432
427
|
unverifiedWalletAccounts: state.unverifiedWalletAccounts,
|
|
433
428
|
user: state.user,
|
|
@@ -484,6 +479,9 @@ const initializeClient = async (client = getDefaultClient()) => {
|
|
|
484
479
|
const fetchProjectSettingsPromise = initializeStorageSyncPromise.then(async () => {
|
|
485
480
|
if (!core.state.get().projectSettings) await fetchProjectSettings(client);
|
|
486
481
|
});
|
|
482
|
+
fetchProjectSettingsPromise.then(() => prefetchNoncesIfNeeded(client)).catch((error) => {
|
|
483
|
+
core.logger.error("Failed to prefetch nonces:", error);
|
|
484
|
+
});
|
|
487
485
|
/**
|
|
488
486
|
* Generate session keys if they don't exist
|
|
489
487
|
*/
|
|
@@ -642,12 +640,22 @@ const createNavigationHandler = () => {
|
|
|
642
640
|
//#endregion
|
|
643
641
|
//#region src/services/openDeeplink/createWebDeeplinkOpener/createWebDeeplinkOpener.ts
|
|
644
642
|
/**
|
|
645
|
-
* Creates a deeplink opener that
|
|
643
|
+
* Creates a deeplink opener that navigates the current tab to the deeplink URL.
|
|
644
|
+
*
|
|
645
|
+
* Uses `window.location.assign` instead of `window.open` deliberately.
|
|
646
|
+
* This matters for Phantom redirect specifically, which is the only deep link
|
|
647
|
+
* provider that redirects back to the app in a new tab. With `window.open`,
|
|
648
|
+
* the browser first opens an `about:blank` tab before the native wallet app
|
|
649
|
+
* handles the deep link. When Phantom redirects back, it opens yet another
|
|
650
|
+
* tab. The user ends up with three tabs (original, about:blank, redirect) and
|
|
651
|
+
* the browser focuses the lingering about:blank after the redirect tab closes.
|
|
652
|
+
* `window.location.assign` reuses the current tab, avoiding the extra tab
|
|
653
|
+
* entirely.
|
|
646
654
|
*/
|
|
647
655
|
const createWebDeeplinkOpener = () => {
|
|
648
656
|
if (isServerSideRendering()) return () => Promise.reject(new UnavailableInServerSideError("createWebDeeplinkOpener"));
|
|
649
657
|
return async (url) => {
|
|
650
|
-
window.
|
|
658
|
+
window.location.assign(url);
|
|
651
659
|
};
|
|
652
660
|
};
|
|
653
661
|
|
|
@@ -802,6 +810,8 @@ const getInitialState = () => ({
|
|
|
802
810
|
initStatus: "uninitialized",
|
|
803
811
|
legacyToken: null,
|
|
804
812
|
mfaToken: null,
|
|
813
|
+
prefetchedNonces: [],
|
|
814
|
+
prefetchedNoncesExpiration: null,
|
|
805
815
|
projectSettings: null,
|
|
806
816
|
sessionExpiresAt: null,
|
|
807
817
|
sessionKeys: null,
|
|
@@ -923,6 +933,27 @@ var CheckoutSessionTokenMissingError = class extends BaseError {
|
|
|
923
933
|
}
|
|
924
934
|
};
|
|
925
935
|
|
|
936
|
+
//#endregion
|
|
937
|
+
//#region src/errors/DeeplinkConnectAndVerifyUnsupportedError.ts
|
|
938
|
+
var DeeplinkConnectAndVerifyUnsupportedError = class extends BaseError {
|
|
939
|
+
constructor({ walletProviderKey }) {
|
|
940
|
+
super({
|
|
941
|
+
cause: null,
|
|
942
|
+
code: "deeplink_connect_and_verify_unsupported",
|
|
943
|
+
docsUrl: null,
|
|
944
|
+
metaMessages: [
|
|
945
|
+
`Wallet provider key: ${walletProviderKey}`,
|
|
946
|
+
"On mobile, deep link wallet providers (e.g. Phantom redirect) cannot connect and verify in a single step.",
|
|
947
|
+
"iOS does not allow two sequential deep links — the second one is silently ignored because it is no longer tied to a user gesture.",
|
|
948
|
+
"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.",
|
|
949
|
+
"Use connectWithWalletProvider() first, then call verifyWalletAccount() from a separate user action (e.g. a \"Verify Ownership\" button)."
|
|
950
|
+
],
|
|
951
|
+
name: "DeeplinkConnectAndVerifyUnsupportedError",
|
|
952
|
+
shortMessage: "connectAndVerifyWithWalletProvider is not supported for deep link wallet providers on mobile. Use connectWithWalletProvider and verifyWalletAccount separately."
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
|
|
926
957
|
//#endregion
|
|
927
958
|
//#region src/errors/FeeEstimationFailedError.ts
|
|
928
959
|
var FeeEstimationFailedError = class extends BaseError {
|
|
@@ -1549,8 +1580,8 @@ const buildOAuthUrl = async (core, provider) => {
|
|
|
1549
1580
|
const isGoogleDriveBackupEnabled = projectSettings.sdk.waas?.backupOptions?.includes(WaasBackupOptionsEnum.GoogleDrive);
|
|
1550
1581
|
const socialProviderUrl = addOAuthUrlParams(socialProvider, getOAuthBaseUrl(socialProvider), { isGoogleDriveBackupEnabled });
|
|
1551
1582
|
const usingPkce = providersRequiringPkce.includes(provider);
|
|
1552
|
-
const state = randomString(32);
|
|
1553
|
-
const codeVerifier = randomString(43);
|
|
1583
|
+
const state = randomString({ length: 32 });
|
|
1584
|
+
const codeVerifier = randomString({ length: 43 });
|
|
1554
1585
|
socialProviderUrl.searchParams.set("state", state);
|
|
1555
1586
|
socialProviderUrl.searchParams.set("response_type", "code");
|
|
1556
1587
|
if (usingPkce) {
|
|
@@ -1767,12 +1798,13 @@ const createCheckoutApiClient = async ({ transactionId }, client) => {
|
|
|
1767
1798
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1768
1799
|
* @returns The updated checkout transaction
|
|
1769
1800
|
*/
|
|
1770
|
-
const attachCheckoutTransactionSource = async ({ fromAddress, fromChainId, transactionId }, client = getDefaultClient()) => {
|
|
1801
|
+
const attachCheckoutTransactionSource = async ({ fromAddress, fromChainId, fromChainName, transactionId }, client = getDefaultClient()) => {
|
|
1771
1802
|
const { apiClient, environmentId, sessionToken } = await createCheckoutApiClient({ transactionId }, client);
|
|
1772
1803
|
return apiClient.attachSource({
|
|
1773
1804
|
attachSourceRequest: {
|
|
1774
1805
|
fromAddress,
|
|
1775
1806
|
fromChainId,
|
|
1807
|
+
fromChainName,
|
|
1776
1808
|
sourceType: "wallet"
|
|
1777
1809
|
},
|
|
1778
1810
|
environmentId,
|
|
@@ -1820,6 +1852,14 @@ const cancelCheckoutTransaction = async ({ transactionId }, client = getDefaultC
|
|
|
1820
1852
|
return result;
|
|
1821
1853
|
};
|
|
1822
1854
|
|
|
1855
|
+
//#endregion
|
|
1856
|
+
//#region src/modules/checkout/getCheckouts/getCheckouts.ts
|
|
1857
|
+
const getCheckouts = async (client) => {
|
|
1858
|
+
const projectSettings = client.projectSettings;
|
|
1859
|
+
assertDefined(projectSettings, "Project settings are not available");
|
|
1860
|
+
return projectSettings.checkouts ?? [];
|
|
1861
|
+
};
|
|
1862
|
+
|
|
1823
1863
|
//#endregion
|
|
1824
1864
|
//#region src/modules/checkout/createCheckoutTransaction/createCheckoutTransaction.ts
|
|
1825
1865
|
/**
|
|
@@ -1831,8 +1871,12 @@ const cancelCheckoutTransaction = async ({ transactionId }, client = getDefaultC
|
|
|
1831
1871
|
*/
|
|
1832
1872
|
const createCheckoutTransaction = async (params, client = getDefaultClient()) => {
|
|
1833
1873
|
const core = getCore(client);
|
|
1834
|
-
const
|
|
1835
|
-
|
|
1874
|
+
const apiClient = createApiClient({}, client);
|
|
1875
|
+
const checkouts = await getCheckouts(client);
|
|
1876
|
+
const checkoutId = params.checkoutId ?? checkouts?.[0]?.id;
|
|
1877
|
+
assertDefined(checkoutId, "No checkout found. Please make sure you have a Checkout setup in the Dashboard.");
|
|
1878
|
+
const result = await apiClient.createCheckoutTransaction({
|
|
1879
|
+
checkoutId,
|
|
1836
1880
|
checkoutTransactionCreateRequest: {
|
|
1837
1881
|
amount: params.amount,
|
|
1838
1882
|
currency: params.currency,
|
|
@@ -1871,14 +1915,13 @@ const getCheckoutTransaction = async ({ transactionId }, client = getDefaultClie
|
|
|
1871
1915
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1872
1916
|
* @returns The updated checkout transaction with quote data
|
|
1873
1917
|
*/
|
|
1874
|
-
const getCheckoutTransactionQuote = async ({ fromTokenAddress, slippage,
|
|
1918
|
+
const getCheckoutTransactionQuote = async ({ fromTokenAddress, slippage, transactionId }, client = getDefaultClient()) => {
|
|
1875
1919
|
const { apiClient, environmentId, sessionToken } = await createCheckoutApiClient({ transactionId }, client);
|
|
1876
1920
|
return apiClient.quoteCheckoutTransaction({
|
|
1877
1921
|
environmentId,
|
|
1878
1922
|
quoteRequest: {
|
|
1879
1923
|
fromTokenAddress,
|
|
1880
|
-
slippage
|
|
1881
|
-
toTokenAddress
|
|
1924
|
+
slippage
|
|
1882
1925
|
},
|
|
1883
1926
|
transactionId,
|
|
1884
1927
|
xDynamicCheckoutSessionToken: sessionToken
|
|
@@ -1905,6 +1948,67 @@ const prepareCheckoutTransaction = async ({ transactionId }, client = getDefault
|
|
|
1905
1948
|
});
|
|
1906
1949
|
};
|
|
1907
1950
|
|
|
1951
|
+
//#endregion
|
|
1952
|
+
//#region src/modules/wallets/utils/assertWalletProviderMethodDefined/assertWalletProviderMethodDefined.ts
|
|
1953
|
+
/**
|
|
1954
|
+
* Asserts that a specific wallet provider method is defined, throwing an error if it's not.
|
|
1955
|
+
* This function acts as a type guard, narrowing the type to ensure the method exists.
|
|
1956
|
+
*
|
|
1957
|
+
* @template T - The specific wallet provider method key being checked
|
|
1958
|
+
* @param walletProvider - The wallet provider object to check
|
|
1959
|
+
* @param methodName - The name of the method to check for availability
|
|
1960
|
+
* @throws Throws WalletProviderMethodUnavailableError if the method is not defined
|
|
1961
|
+
* @example
|
|
1962
|
+
* ```typescript
|
|
1963
|
+
* const walletProvider: WalletProvider = getWalletProvider();
|
|
1964
|
+
* assertWalletProviderMethodDefined(walletProvider, 'connect');
|
|
1965
|
+
* // walletProvider.connect is now guaranteed to be defined
|
|
1966
|
+
* await walletProvider.connect();
|
|
1967
|
+
* ```
|
|
1968
|
+
*/
|
|
1969
|
+
function assertWalletProviderMethodDefined(walletProvider, methodName) {
|
|
1970
|
+
if (walletProvider[methodName] === void 0) throw new WalletProviderMethodUnavailableError({
|
|
1971
|
+
methodName,
|
|
1972
|
+
walletProviderKey: walletProvider.key
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
//#endregion
|
|
1977
|
+
//#region src/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.ts
|
|
1978
|
+
/**
|
|
1979
|
+
* Prepares, signs, and broadcasts a checkout transaction in one call.
|
|
1980
|
+
*
|
|
1981
|
+
* Orchestrates the full submission flow:
|
|
1982
|
+
* 1. Calls prepareCheckoutTransaction to advance to signing state and lock the quote
|
|
1983
|
+
* 2. Ensures the wallet is on the correct network for the transaction
|
|
1984
|
+
* 3. Delegates on-chain signing to the wallet provider's executeCheckoutTransaction method
|
|
1985
|
+
* 4. Calls broadcastCheckoutTransaction with the resulting txHash
|
|
1986
|
+
*
|
|
1987
|
+
* @param params SubmitCheckoutTransactionParams - The transaction ID, wallet account, and optional step callback.
|
|
1988
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1989
|
+
* @returns The broadcasted checkout transaction
|
|
1990
|
+
*/
|
|
1991
|
+
const submitCheckoutTransaction = async ({ onStepChange, transactionId, walletAccount }, client = getDefaultClient()) => {
|
|
1992
|
+
const prepared = await prepareCheckoutTransaction({ transactionId }, client);
|
|
1993
|
+
assertDefined(prepared.signingPayload, "No signing payload returned from prepare — quote may be missing transaction data");
|
|
1994
|
+
const walletProvider = getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
1995
|
+
assertWalletProviderMethodDefined(walletProvider, "executeCheckoutTransaction");
|
|
1996
|
+
const requiredNetworkId = prepared.signingPayload.chainId;
|
|
1997
|
+
if (requiredNetworkId && walletProvider.switchActiveNetwork) {
|
|
1998
|
+
const { networkId: activeNetworkId } = await walletProvider.getActiveNetworkId();
|
|
1999
|
+
if (activeNetworkId !== requiredNetworkId) await walletProvider.switchActiveNetwork({ networkId: requiredNetworkId });
|
|
2000
|
+
}
|
|
2001
|
+
const { transactionHash } = await walletProvider.executeCheckoutTransaction({
|
|
2002
|
+
onStepChange,
|
|
2003
|
+
signingPayload: prepared.signingPayload,
|
|
2004
|
+
walletAccount
|
|
2005
|
+
});
|
|
2006
|
+
return broadcastCheckoutTransaction({
|
|
2007
|
+
transactionId,
|
|
2008
|
+
txHash: transactionHash
|
|
2009
|
+
}, client);
|
|
2010
|
+
};
|
|
2011
|
+
|
|
1908
2012
|
//#endregion
|
|
1909
2013
|
//#region src/modules/deviceRegistration/completeDeviceRegistration/completeDeviceRegistration.ts
|
|
1910
2014
|
const DEVICE_REGISTRATION_TOKEN_HEADER = "x-dynamic-device-registration-token";
|
|
@@ -1959,6 +2063,23 @@ const detectDeviceRegistrationRedirect = ({ url }) => {
|
|
|
1959
2063
|
}
|
|
1960
2064
|
};
|
|
1961
2065
|
|
|
2066
|
+
//#endregion
|
|
2067
|
+
//#region src/modules/deviceRegistration/getRegisteredDevices/getRegisteredDevices.ts
|
|
2068
|
+
const getRegisteredDevices = async (client = getDefaultClient()) => {
|
|
2069
|
+
const core = getCore(client);
|
|
2070
|
+
const apiClient = createApiClient({}, client);
|
|
2071
|
+
try {
|
|
2072
|
+
return (await apiClient.listDeviceRegistrations({ environmentId: core.environmentId })).deviceRegistrations;
|
|
2073
|
+
} catch (error) {
|
|
2074
|
+
/**
|
|
2075
|
+
* The API will return 401 when no devices are registered when there are no
|
|
2076
|
+
* devices registered. We need to handle this case gracefully.
|
|
2077
|
+
*/
|
|
2078
|
+
if (error instanceof UnauthorizedError) return [];
|
|
2079
|
+
throw error;
|
|
2080
|
+
}
|
|
2081
|
+
};
|
|
2082
|
+
|
|
1962
2083
|
//#endregion
|
|
1963
2084
|
//#region src/modules/deviceRegistration/isDeviceRegistrationRequired/isDeviceRegistrationRequired.ts
|
|
1964
2085
|
/**
|
|
@@ -1975,6 +2096,25 @@ const isDeviceRegistrationRequired = (client = getDefaultClient()) => {
|
|
|
1975
2096
|
return Boolean(user.scope?.includes("device:register"));
|
|
1976
2097
|
};
|
|
1977
2098
|
|
|
2099
|
+
//#endregion
|
|
2100
|
+
//#region src/modules/deviceRegistration/revokeAllRegisteredDevices/revokeAllRegisteredDevices.ts
|
|
2101
|
+
const revokeAllRegisteredDevices = async (client = getDefaultClient()) => {
|
|
2102
|
+
const core = getCore(client);
|
|
2103
|
+
await createApiClient({}, client).deleteAllDeviceRegistrations({ environmentId: core.environmentId });
|
|
2104
|
+
await logout(client);
|
|
2105
|
+
};
|
|
2106
|
+
|
|
2107
|
+
//#endregion
|
|
2108
|
+
//#region src/modules/deviceRegistration/revokeRegisteredDevice/revokeRegisteredDevice.ts
|
|
2109
|
+
const revokeRegisteredDevice = async ({ deviceRegistrationId }, client = getDefaultClient()) => {
|
|
2110
|
+
assertDefined(deviceRegistrationId, "deviceRegistrationId is required");
|
|
2111
|
+
const core = getCore(client);
|
|
2112
|
+
if ((await createApiClient({}, client).deleteDeviceRegistration({
|
|
2113
|
+
deviceRegistrationId,
|
|
2114
|
+
environmentId: core.environmentId
|
|
2115
|
+
})).currentDeviceRevoked) await logout(client);
|
|
2116
|
+
};
|
|
2117
|
+
|
|
1978
2118
|
//#endregion
|
|
1979
2119
|
//#region src/modules/funding/coinbase/addCoinbaseOnrampOrderEventListener/addCoinbaseOnrampOrderEventListener.ts
|
|
1980
2120
|
/**
|
|
@@ -4125,29 +4265,27 @@ const assertWalletAccountSigningAvailability = async ({ walletAccount }, client
|
|
|
4125
4265
|
};
|
|
4126
4266
|
|
|
4127
4267
|
//#endregion
|
|
4128
|
-
//#region src/
|
|
4268
|
+
//#region src/utils/isMobile/isMobile.ts
|
|
4129
4269
|
/**
|
|
4130
|
-
*
|
|
4131
|
-
* This function acts as a type guard, narrowing the type to ensure the method exists.
|
|
4132
|
-
*
|
|
4133
|
-
* @template T - The specific wallet provider method key being checked
|
|
4134
|
-
* @param walletProvider - The wallet provider object to check
|
|
4135
|
-
* @param methodName - The name of the method to check for availability
|
|
4136
|
-
* @throws Throws WalletProviderMethodUnavailableError if the method is not defined
|
|
4137
|
-
* @example
|
|
4138
|
-
* ```typescript
|
|
4139
|
-
* const walletProvider: WalletProvider = getWalletProvider();
|
|
4140
|
-
* assertWalletProviderMethodDefined(walletProvider, 'connect');
|
|
4141
|
-
* // walletProvider.connect is now guaranteed to be defined
|
|
4142
|
-
* await walletProvider.connect();
|
|
4143
|
-
* ```
|
|
4270
|
+
* Sourced from http://detectmobilebrowsers.com/
|
|
4144
4271
|
*/
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
}
|
|
4272
|
+
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;
|
|
4273
|
+
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;
|
|
4274
|
+
const isMobile = (maxTouchPointsOverride) => {
|
|
4275
|
+
if (typeof window === "undefined" || typeof navigator === "undefined") return false;
|
|
4276
|
+
return userAgentRegex1.test(navigator.userAgent) || userAgentRegex2.test(navigator.userAgent.substring(0, 4)) || isIPad(maxTouchPointsOverride) || isIPhone();
|
|
4277
|
+
};
|
|
4278
|
+
const isIPhone = () => typeof window === "undefined" || typeof navigator === "undefined" ? false : /iPhone|ios/.test(navigator.userAgent);
|
|
4279
|
+
/**
|
|
4280
|
+
* @param [optional] maxTouchPointsOverride - this is used for testing since
|
|
4281
|
+
* it seems that JSDOM doesn't support maxTouchPoints, so it was impossible
|
|
4282
|
+
* to mock it
|
|
4283
|
+
*/
|
|
4284
|
+
const isIPad = (maxTouchPointsOverride) => {
|
|
4285
|
+
if (typeof window === "undefined" || typeof navigator === "undefined") return false;
|
|
4286
|
+
const maxTouchPoints = maxTouchPointsOverride || navigator.maxTouchPoints;
|
|
4287
|
+
return /iPad/.test(navigator.userAgent) || /Mac/.test(navigator.userAgent) && maxTouchPoints === 5;
|
|
4288
|
+
};
|
|
4151
4289
|
|
|
4152
4290
|
//#endregion
|
|
4153
4291
|
//#region src/modules/wallets/utils/getAddressesWithTypesFromConnectionResult/getAddressesWithTypesFromConnectionResult.ts
|
|
@@ -4357,6 +4495,13 @@ const verifyWalletAccount = async ({ walletAccount, requestedScopes }, client =
|
|
|
4357
4495
|
}, client);
|
|
4358
4496
|
};
|
|
4359
4497
|
|
|
4498
|
+
//#endregion
|
|
4499
|
+
//#region src/modules/wallets/walletProvider/isDeeplinkWalletProvider/isDeeplinkWalletProvider.ts
|
|
4500
|
+
/**
|
|
4501
|
+
* Returns true if the wallet provider uses the deep link protocol (e.g. Phantom redirect on mobile).
|
|
4502
|
+
*/
|
|
4503
|
+
const isDeeplinkWalletProvider = ({ walletProvider }) => walletProvider.walletProviderType === WalletProviderEnum.DeepLink;
|
|
4504
|
+
|
|
4360
4505
|
//#endregion
|
|
4361
4506
|
//#region src/modules/wallets/connectAndVerifyWithWalletProvider/connectAndVerifyWithWalletProvider.ts
|
|
4362
4507
|
/**
|
|
@@ -4366,12 +4511,24 @@ const verifyWalletAccount = async ({ walletAccount, requestedScopes }, client =
|
|
|
4366
4511
|
* requiring the user to sign a message to prove wallet ownership before
|
|
4367
4512
|
* the wallet account is added to their profile.
|
|
4368
4513
|
*
|
|
4514
|
+
* @throws {DeeplinkConnectAndVerifyUnsupportedError} On mobile with deep link
|
|
4515
|
+
* wallet providers (e.g. Phantom redirect). This function triggers two sequential
|
|
4516
|
+
* deeplinks — one to connect and another to sign for verification. iOS will not
|
|
4517
|
+
* honor the second deeplink because it is no longer tied to a user gesture.
|
|
4518
|
+
* Android may handle sequential deeplinks differently, but this guard applies to
|
|
4519
|
+
* all mobile platforms to ensure a stable experience and prevent production-only
|
|
4520
|
+
* errors. Use `connectWithWalletProvider` first and then invoke
|
|
4521
|
+
* `verifyWalletAccount` separately from a new user gesture (e.g. a "Verify
|
|
4522
|
+
* Ownership" button).
|
|
4523
|
+
*
|
|
4369
4524
|
* @param params.walletProviderKey - The unique key identifying the wallet provider to connect to.
|
|
4370
4525
|
* @param [params.hardwareWalletVendor] - The hardware wallet vendor, if connecting via a hardware wallet (e.g. 'ledger').
|
|
4371
4526
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4372
4527
|
* @returns A promise that resolves to the connected and verified wallet account.
|
|
4373
4528
|
*/
|
|
4374
4529
|
const connectAndVerifyWithWalletProvider = async ({ walletProviderKey, hardwareWalletVendor }, client = getDefaultClient()) => {
|
|
4530
|
+
const walletProvider = getWalletProviderByKey({ walletProviderKey }, client);
|
|
4531
|
+
if (isMobile() && isDeeplinkWalletProvider({ walletProvider })) throw new DeeplinkConnectAndVerifyUnsupportedError({ walletProviderKey });
|
|
4375
4532
|
const walletAccount = await connectWithWalletProvider({
|
|
4376
4533
|
addToDynamicWalletAccounts: false,
|
|
4377
4534
|
hardwareWalletVendor,
|
|
@@ -4743,6 +4900,34 @@ const signMessage = async ({ walletAccount, message }, client = getDefaultClient
|
|
|
4743
4900
|
return { signature };
|
|
4744
4901
|
};
|
|
4745
4902
|
|
|
4903
|
+
//#endregion
|
|
4904
|
+
//#region src/modules/wallets/transferAmount/transferAmount.ts
|
|
4905
|
+
/**
|
|
4906
|
+
* Transfers an amount of currency from the wallet account to a recipient.
|
|
4907
|
+
*
|
|
4908
|
+
* Supports native token transfers and, where supported by the chain,
|
|
4909
|
+
* fungible/token transfers via the optional `token` parameter.
|
|
4910
|
+
*
|
|
4911
|
+
* @param params.walletAccount - The wallet account to transfer from.
|
|
4912
|
+
* @param params.amount - The amount to transfer as a decimal string (e.g. "1.5").
|
|
4913
|
+
* @param params.recipient - The recipient address.
|
|
4914
|
+
* @param params.token - Optional token info for non-native transfers.
|
|
4915
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4916
|
+
* @returns A promise that resolves to an object containing the transaction hash.
|
|
4917
|
+
* @throws If the wallet provider does not support the transfer amount method.
|
|
4918
|
+
*/
|
|
4919
|
+
const transferAmount = async ({ walletAccount, amount, recipient, token }, client = getDefaultClient()) => {
|
|
4920
|
+
const walletProvider = getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
4921
|
+
assertWalletProviderMethodDefined(walletProvider, "transferAmount");
|
|
4922
|
+
const { transactionHash } = await walletProvider.transferAmount({
|
|
4923
|
+
amount,
|
|
4924
|
+
recipient,
|
|
4925
|
+
token,
|
|
4926
|
+
walletAccount
|
|
4927
|
+
});
|
|
4928
|
+
return { transactionHash };
|
|
4929
|
+
};
|
|
4930
|
+
|
|
4746
4931
|
//#endregion
|
|
4747
4932
|
//#region src/modules/wallets/transferWalletAccount/transferWalletAccount.ts
|
|
4748
4933
|
/**
|
|
@@ -4821,26 +5006,78 @@ const onWalletProviderEvent = ({ callback, event, walletProviderKey }, client =
|
|
|
4821
5006
|
};
|
|
4822
5007
|
|
|
4823
5008
|
//#endregion
|
|
4824
|
-
//#region src/utils/
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
}
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
5009
|
+
//#region src/utils/parseUserAgent/parseUserAgent.ts
|
|
5010
|
+
const browserMatchers = [
|
|
5011
|
+
{
|
|
5012
|
+
name: "Edge",
|
|
5013
|
+
pattern: /Edg(e|A|iOS)?\//
|
|
5014
|
+
},
|
|
5015
|
+
{
|
|
5016
|
+
name: "Opera",
|
|
5017
|
+
pattern: /OPR\/|Opera/
|
|
5018
|
+
},
|
|
5019
|
+
{
|
|
5020
|
+
name: "Samsung Browser",
|
|
5021
|
+
pattern: /SamsungBrowser/
|
|
5022
|
+
},
|
|
5023
|
+
{
|
|
5024
|
+
name: "Firefox",
|
|
5025
|
+
pattern: /Firefox/
|
|
5026
|
+
},
|
|
5027
|
+
{
|
|
5028
|
+
name: "Safari",
|
|
5029
|
+
pattern: /^(?!.*(?:Chrome|Chromium|CriOS)).*Safari/
|
|
5030
|
+
},
|
|
5031
|
+
{
|
|
5032
|
+
name: "Chrome",
|
|
5033
|
+
pattern: /Chrome|CriOS/
|
|
5034
|
+
}
|
|
5035
|
+
];
|
|
5036
|
+
const mobileOsNames = new Set([
|
|
5037
|
+
"iPhone",
|
|
5038
|
+
"iPad",
|
|
5039
|
+
"Android"
|
|
5040
|
+
]);
|
|
5041
|
+
const osMatchers = [
|
|
5042
|
+
{
|
|
5043
|
+
name: "iPhone",
|
|
5044
|
+
pattern: /iPhone/
|
|
5045
|
+
},
|
|
5046
|
+
{
|
|
5047
|
+
name: "iPad",
|
|
5048
|
+
pattern: /iPad/
|
|
5049
|
+
},
|
|
5050
|
+
{
|
|
5051
|
+
name: "Android",
|
|
5052
|
+
pattern: /Android/
|
|
5053
|
+
},
|
|
5054
|
+
{
|
|
5055
|
+
name: "Windows",
|
|
5056
|
+
pattern: /Windows/
|
|
5057
|
+
},
|
|
5058
|
+
{
|
|
5059
|
+
name: "macOS",
|
|
5060
|
+
pattern: /Macintosh|Mac OS X/
|
|
5061
|
+
},
|
|
5062
|
+
{
|
|
5063
|
+
name: "Linux",
|
|
5064
|
+
pattern: /Linux/
|
|
5065
|
+
},
|
|
5066
|
+
{
|
|
5067
|
+
name: "ChromeOS",
|
|
5068
|
+
pattern: /CrOS/
|
|
5069
|
+
}
|
|
5070
|
+
];
|
|
5071
|
+
const parseUserAgent = ({ userAgent }) => {
|
|
5072
|
+
if (!userAgent?.trim()) return null;
|
|
5073
|
+
const browser = browserMatchers.find(({ pattern }) => pattern.test(userAgent))?.name;
|
|
5074
|
+
const os = osMatchers.find(({ pattern }) => pattern.test(userAgent))?.name;
|
|
5075
|
+
if (!browser && !os) return null;
|
|
5076
|
+
const isMobile$1 = os ? mobileOsNames.has(os) : false;
|
|
5077
|
+
return {
|
|
5078
|
+
displayText: browser && os ? `${browser} on ${os}` : browser ?? os ?? "",
|
|
5079
|
+
type: isMobile$1 ? "mobile" : "desktop"
|
|
5080
|
+
};
|
|
4844
5081
|
};
|
|
4845
5082
|
|
|
4846
5083
|
//#endregion
|
|
@@ -4848,5 +5085,5 @@ const isIPad = (maxTouchPointsOverride) => {
|
|
|
4848
5085
|
assertPackageVersion(name, version);
|
|
4849
5086
|
|
|
4850
5087
|
//#endregion
|
|
4851
|
-
export { BaseError, CheckoutSessionTokenMissingError, ClientAlreadyInitializedError, FeeEstimationFailedError, InvalidDeviceRegistrationRedirectError, InvalidExternalAuthError, InvalidParamError, InvalidRedirectStorageStateError, LinkCredentialError, MFAAction, MfaInvalidOtpError, MfaRateLimitedError, MissingRedirectStorageStateError, MissingSocialUrlParamError, MissingUserVerificationError, NetworkAddingUnavailableError, NetworkNotAddedError, NetworkSwitchingUnavailableError, NoAddressFoundError, NoNetworkProvidersError, NoPasskeyCredentialsFoundError, NoSmartWalletAccountSignerFoundError, NoWebAuthNSupportError, NotWaasWalletAccountError, SandboxMaximumThresholdReachedError, SimulationFailedError, UnavailableInServerSideError, UnrecognizedNetworkError, UserNotAuthenticatedError, UserRejectedError, WalletAccountAlreadyVerifiedError, WalletAccountNotSelectedError, WalletAlreadyLinkedToAnotherUserError, WalletProviderMethodUnavailableError, acknowledgeRecoveryCodes, addCoinbaseOnrampOrderEventListener, addNetwork, assertWalletAccountSigningAvailability, assertWalletProviderMethodDefined, attachCheckoutTransactionSource, authenticateMfaRecoveryCode, authenticatePasskeyMFA, authenticateTotpMfaDevice, authenticateWithSocial, broadcastCheckoutTransaction, canConnectWithHardwareWallet, cancelCheckoutTransaction, completeDeviceRegistration, completeSocialAuthentication, connectAndVerifyWithWalletProvider, connectWithWalletProvider, consumeMfaToken, createCheckoutTransaction, createCoinbaseOnrampOrder, createCryptoDotComPayment, createDynamicClient, createKrakenExchangeTransfer, createNewMfaRecoveryCodes, deleteMfaDevice, deletePasskey, deleteUser, detectDeviceRegistrationRedirect, detectOAuthRedirect, fetchProjectSettings, getActiveNetworkData, getActiveNetworkId, getAvailableWalletProvidersData, getBalance, getBalanceForAddress, getCheckoutTransaction, getCheckoutTransactionQuote, getCoinbaseBuyUrl, getConnectedAddresses, getDefaultClient, getDeviceRegistrationTokenFromUrl, getElevatedAccessToken, getKrakenAccounts, getKrakenWhitelistedAddresses, getMfaDevices, getMfaMethods, getMfaRecoveryCodes, getMissingVerificationForCoinbaseOnrampOrder, getMultichainBalances, getNetworksData, getOwnerWalletAccountForSmartWalletAccount, getPasskeys, getPrimaryWalletAccount, getTransactionHistory, getUserSocialAccounts, getWalletAccountAddressByType, getWalletAccountFromAddress, getWalletAccounts, getWalletConnectCatalog, getWalletConnectCatalogWalletByWalletProviderKey, getWalletProviderDataByKey, hasExtension, initializeClient, isCaptchaRequired, isDeviceRegistrationRequired, isHardwareWalletAccount, isMfaRequiredForAction, isMobile, isPendingRecoveryCodesAcknowledgment, isProgrammaticNetworkSwitchAvailable, isSignedIn, isUserMissingMfaAuth, isUserOnboardingComplete, isWalletAccountVerified, logout, offEvent, offWalletProviderEvent, onEvent, onWalletProviderEvent, onceEvent, prepareCheckoutTransaction, proveWalletAccountOwnership, refreshAuth, refreshUser, registerPasskey, registerTotpMfaDevice, removeWalletAccount, selectPrimaryWalletAccount, sendEmailOTP, sendSmsOTP, setCaptchaToken, setDefaultMfaDevice, signInWithExternalJwt, signInWithPasskey, signMessage, supportedCountries, switchActiveNetwork, transferWalletAccount, unlinkSocialAccount, updateUser, verifyOTP, verifyWalletAccount, waitForClientInitialized };
|
|
5088
|
+
export { BaseError, CheckoutSessionTokenMissingError, ClientAlreadyInitializedError, DeeplinkConnectAndVerifyUnsupportedError, FeeEstimationFailedError, InvalidDeviceRegistrationRedirectError, InvalidExternalAuthError, InvalidParamError, InvalidRedirectStorageStateError, LinkCredentialError, MFAAction, MfaInvalidOtpError, MfaRateLimitedError, MissingRedirectStorageStateError, MissingSocialUrlParamError, MissingUserVerificationError, NetworkAddingUnavailableError, NetworkNotAddedError, NetworkSwitchingUnavailableError, NoAddressFoundError, NoNetworkProvidersError, NoPasskeyCredentialsFoundError, NoSmartWalletAccountSignerFoundError, NoWebAuthNSupportError, NotWaasWalletAccountError, SandboxMaximumThresholdReachedError, SimulationFailedError, UnauthorizedError, UnavailableInServerSideError, UnrecognizedNetworkError, UserNotAuthenticatedError, UserRejectedError, WalletAccountAlreadyVerifiedError, WalletAccountNotSelectedError, WalletAlreadyLinkedToAnotherUserError, WalletProviderMethodUnavailableError, acknowledgeRecoveryCodes, addCoinbaseOnrampOrderEventListener, addNetwork, assertWalletAccountSigningAvailability, assertWalletProviderMethodDefined, attachCheckoutTransactionSource, authenticateMfaRecoveryCode, authenticatePasskeyMFA, authenticateTotpMfaDevice, authenticateWithSocial, broadcastCheckoutTransaction, canConnectWithHardwareWallet, cancelCheckoutTransaction, completeDeviceRegistration, completeSocialAuthentication, connectAndVerifyWithWalletProvider, connectWithWalletProvider, consumeMfaToken, createCheckoutTransaction, createCoinbaseOnrampOrder, createCryptoDotComPayment, createDynamicClient, createKrakenExchangeTransfer, createNewMfaRecoveryCodes, deleteMfaDevice, deletePasskey, deleteUser, detectDeviceRegistrationRedirect, detectOAuthRedirect, fetchProjectSettings, getActiveNetworkData, getActiveNetworkId, getAvailableWalletProvidersData, getBalance, getBalanceForAddress, getCheckoutTransaction, getCheckoutTransactionQuote, getCoinbaseBuyUrl, getConnectedAddresses, getDefaultClient, getDeviceRegistrationTokenFromUrl, getElevatedAccessToken, getKrakenAccounts, getKrakenWhitelistedAddresses, getMfaDevices, getMfaMethods, getMfaRecoveryCodes, getMissingVerificationForCoinbaseOnrampOrder, getMultichainBalances, getNetworksData, getOwnerWalletAccountForSmartWalletAccount, getPasskeys, getPrimaryWalletAccount, getRegisteredDevices, getTransactionHistory, getUserSocialAccounts, getWalletAccountAddressByType, getWalletAccountFromAddress, getWalletAccounts, getWalletConnectCatalog, getWalletConnectCatalogWalletByWalletProviderKey, getWalletProviderDataByKey, hasExtension, initializeClient, isCaptchaRequired, isDeeplinkWalletProvider, isDeviceRegistrationRequired, isHardwareWalletAccount, isMfaRequiredForAction, isMobile, isPendingRecoveryCodesAcknowledgment, isProgrammaticNetworkSwitchAvailable, isSignedIn, isUserMissingMfaAuth, isUserOnboardingComplete, isWalletAccountVerified, logout, offEvent, offWalletProviderEvent, onEvent, onWalletProviderEvent, onceEvent, parseUserAgent, prepareCheckoutTransaction, proveWalletAccountOwnership, refreshAuth, refreshUser, registerPasskey, registerTotpMfaDevice, removeWalletAccount, revokeAllRegisteredDevices, revokeRegisteredDevice, selectPrimaryWalletAccount, sendEmailOTP, sendSmsOTP, setCaptchaToken, setDefaultMfaDevice, signInWithExternalJwt, signInWithPasskey, signMessage, submitCheckoutTransaction, supportedCountries, switchActiveNetwork, transferAmount, transferWalletAccount, unlinkSocialAccount, updateUser, verifyOTP, verifyWalletAccount, waitForClientInitialized };
|
|
4852
5089
|
//# sourceMappingURL=index.esm.js.map
|