@dynamic-labs-sdk/client 1.0.0 → 1.2.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-DQ1ABzoy.esm.js → InvalidParamError-BWWTxQ9d.esm.js} +4 -3
- package/dist/{InvalidParamError-DQ1ABzoy.esm.js.map → InvalidParamError-BWWTxQ9d.esm.js.map} +1 -1
- package/dist/{InvalidParamError-WOyVlLys.cjs → InvalidParamError-CPzPxL0l.cjs} +5 -4
- package/dist/{InvalidParamError-WOyVlLys.cjs.map → InvalidParamError-CPzPxL0l.cjs.map} +1 -1
- package/dist/{InvalidParamError-p9-9P-lf.native.esm.js → InvalidParamError-Dhv4EhOy.native.esm.js} +4 -3
- package/dist/{InvalidParamError-p9-9P-lf.native.esm.js.map → InvalidParamError-Dhv4EhOy.native.esm.js.map} +1 -1
- package/dist/{NotWaasWalletAccountError-CM_mmb18.cjs → NotWaasWalletAccountError-BcIbGm0s.cjs} +3 -3
- package/dist/{NotWaasWalletAccountError-CM_mmb18.cjs.map → NotWaasWalletAccountError-BcIbGm0s.cjs.map} +1 -1
- package/dist/{NotWaasWalletAccountError-PrroboxR.esm.js → NotWaasWalletAccountError-D1EuiYyR.esm.js} +3 -3
- package/dist/{NotWaasWalletAccountError-PrroboxR.esm.js.map → NotWaasWalletAccountError-D1EuiYyR.esm.js.map} +1 -1
- package/dist/{NotWaasWalletAccountError-DXS6Quo_.native.esm.js → NotWaasWalletAccountError-D_mLDrYD.native.esm.js} +3 -3
- package/dist/{NotWaasWalletAccountError-DXS6Quo_.native.esm.js.map → NotWaasWalletAccountError-D_mLDrYD.native.esm.js.map} +1 -1
- package/dist/core.cjs +5 -5
- package/dist/core.esm.js +7 -7
- package/dist/core.esm.js.map +1 -1
- package/dist/core.native.esm.js +5 -5
- package/dist/{getNetworkProviderFromNetworkId-D9h1iRX7.esm.js → getNetworkProviderFromNetworkId-C9QzgcLs.esm.js} +7 -7
- package/dist/getNetworkProviderFromNetworkId-C9QzgcLs.esm.js.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-CLf4WTzA.cjs → getNetworkProviderFromNetworkId-D26TNjm4.cjs} +3 -3
- package/dist/{getNetworkProviderFromNetworkId-CLf4WTzA.cjs.map → getNetworkProviderFromNetworkId-D26TNjm4.cjs.map} +1 -1
- package/dist/{getNetworkProviderFromNetworkId-CKxfzZDr.native.esm.js → getNetworkProviderFromNetworkId-VkHaRqMa.native.esm.js} +3 -3
- package/dist/{getNetworkProviderFromNetworkId-CKxfzZDr.native.esm.js.map → getNetworkProviderFromNetworkId-VkHaRqMa.native.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-Amzjohh4.cjs → getSignedSessionId-D52QC0hh.cjs} +3 -3
- package/dist/{getSignedSessionId-Amzjohh4.cjs.map → getSignedSessionId-D52QC0hh.cjs.map} +1 -1
- package/dist/{getSignedSessionId-C4COaxNK.esm.js → getSignedSessionId-DcJl2sy8.esm.js} +3 -3
- package/dist/{getSignedSessionId-C4COaxNK.esm.js.map → getSignedSessionId-DcJl2sy8.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-BfoAvhGi.native.esm.js → getSignedSessionId-L0T26uTy.native.esm.js} +3 -3
- package/dist/{getSignedSessionId-BfoAvhGi.native.esm.js.map → getSignedSessionId-L0T26uTy.native.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-QkdDRxzf.cjs → getVerifiedCredentialForWalletAccount-C94BZhqL.cjs} +3 -3
- package/dist/{getVerifiedCredentialForWalletAccount-QkdDRxzf.cjs.map → getVerifiedCredentialForWalletAccount-C94BZhqL.cjs.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-DUzAvFYd.native.esm.js → getVerifiedCredentialForWalletAccount-CMEe9e1b.native.esm.js} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-DUzAvFYd.native.esm.js.map → getVerifiedCredentialForWalletAccount-CMEe9e1b.native.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-CFLGCivi.esm.js → getVerifiedCredentialForWalletAccount-Cm2e3Boz.esm.js} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-CFLGCivi.esm.js.map → getVerifiedCredentialForWalletAccount-Cm2e3Boz.esm.js.map} +1 -1
- package/dist/index.cjs +40 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +43 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.native.esm.js +40 -11
- package/dist/index.native.esm.js.map +1 -1
- package/dist/{isMfaRequiredForAction-C7PeETG7.native.esm.js → isMfaRequiredForAction-B6kjcIA2.native.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-C7PeETG7.native.esm.js.map → isMfaRequiredForAction-B6kjcIA2.native.esm.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-zlHmSSKB.cjs → isMfaRequiredForAction-kxGzZLB_.cjs} +2 -2
- package/dist/{isMfaRequiredForAction-zlHmSSKB.cjs.map → isMfaRequiredForAction-kxGzZLB_.cjs.map} +1 -1
- package/dist/{isMfaRequiredForAction-DLo5DjM6.esm.js → isMfaRequiredForAction-vbGFqLFc.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-DLo5DjM6.esm.js.map → isMfaRequiredForAction-vbGFqLFc.esm.js.map} +1 -1
- package/dist/modules/checkout/getCheckoutTransactionQuote/getCheckoutTransactionQuote.d.ts +9 -1
- package/dist/modules/checkout/getCheckoutTransactionQuote/getCheckoutTransactionQuote.d.ts.map +1 -1
- package/dist/modules/swap/executeSwapTransaction/executeSwapTransaction.d.ts.map +1 -1
- package/dist/modules/swap/utils/ensureCorrectActiveNetwork/ensureCorrectActiveNetwork.d.ts +15 -0
- package/dist/modules/swap/utils/ensureCorrectActiveNetwork/ensureCorrectActiveNetwork.d.ts.map +1 -0
- package/dist/modules/swap/utils/ensureCorrectActiveNetwork/index.d.ts +2 -0
- package/dist/modules/swap/utils/ensureCorrectActiveNetwork/index.d.ts.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/waas.cjs +4 -4
- package/dist/waas.esm.js +3 -3
- package/dist/waas.native.esm.js +3 -3
- package/dist/waasCore.cjs +4 -4
- package/dist/waasCore.esm.js +3 -3
- package/dist/waasCore.native.esm.js +3 -3
- package/package.json +5 -4
- package/dist/getNetworkProviderFromNetworkId-D9h1iRX7.esm.js.map +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { A as extractSessionId, B as name, C as isCookieEnabled, D as instrumentFunction, E as __getElevatedAccessToken_wrapped, F as getDefaultClient, I as setDefaultClient, O as DEFAULT_PII_FIELDS, P as NONCE_POOL_SIZE, R as BaseError, T as ValueMustBeDefinedError, V as version, _ as MfaRateLimitedError, a as DYNAMIC_ICONIC_SPRITE_URL, b as InvalidExternalAuthError, c as CHAINS_INFO_MAP, d as UnauthorizedError, g as SandboxMaximumThresholdReachedError, h as getNonce, j as randomString, k as getUserAgent, l as fetchAndStoreNonces, o as SDK_API_CORE_VERSION, s as getChainFromVerifiedCredentialChain, t as InvalidParamError, u as createApiClient, v as MfaInvalidOtpError, w as assertDefined, x as APIError, y as LinkCredentialError, z as getCore } from "./InvalidParamError-
|
|
2
|
-
import { A as REFRESH_USER_STATE_FROM_COOKIE_TRACKER_KEY, B as createLocalStorageAdapter, C as createCrossTabBroadcast, D as FETCH_PROJECT_SETTINGS_TRACKER_KEY, E as createDeferredPromise, F as generateSessionKeys, H as retryOnFail, I as fetchProjectSettings, L as createStorageKeySchema, M as isServerSideRendering, N as getBuffer, O as GENERATE_SESSION_KEYS_TRACKER_KEY, P as __logoutWithReason_wrapped, R as createStorage, S as createLogger, T as CannotTrackError, U as subscribeWithSelector, V as isSignedIn, W as isEqualShallow, _ as WalletAlreadyLinkedToAnotherUserError, a as updateWalletProviderKeysForVerifiedCredentials, b as createRealtimeService, c as createSignInMessageStatement, d as createVisit, f as hasExtension, g as MethodNotImplementedError, h as isCaptchaRequired, i as getNetworksData, j as REFRESH_USER_STATE_FROM_VALID_TOKEN_TRACKER_KEY, k as INITIALIZE_STORAGE_SYNC_TRACKER_KEY, l as formatSignInMessage, m as consumeCaptchaToken, o as verifyMessageSignatureOwnership, p as __setCaptchaToken_wrapped, s as removeUnverifiedWalletAccount, t as getNetworkProviderFromNetworkId, u as setUnverifiedWalletAccounts, v as NoNetworkProvidersError, x as createKeychainService, y as getKeychainIndexedDBName } from "./getNetworkProviderFromNetworkId-
|
|
3
|
-
import { A as onceEvent, C as formatWalletAccountId, D as emitEvent, O as offEvent, T as splitWalletProviderKey, a as parseElevatedAccessToken, b as getWalletAccounts, d as isUserMissingMfaAuth, f as checkAndRaiseWalletAccountsChangedEvent, h as getWalletProviderFromWalletAccount, i as upsertElevatedAccessToken, k as onEvent, n as getWalletProviderByKey, o as restoreUserSharesForAllWalletAccounts, p as emitWalletAccountsChangedEvent, r as updateAuthFromVerifyResponse, t as getVerifiedCredentialForWalletAccount, u as getWalletProviders, w as normalizeAddress, y as NoWalletProviderFoundError } from "./getVerifiedCredentialForWalletAccount-
|
|
4
|
-
import { n as __refreshAuth_wrapped, t as NotWaasWalletAccountError } from "./NotWaasWalletAccountError-
|
|
5
|
-
import { n as getMfaMethods, r as __consumeMfaToken_wrapped, t as isMfaRequiredForAction } from "./isMfaRequiredForAction-
|
|
1
|
+
import { A as extractSessionId, B as name, C as isCookieEnabled, D as instrumentFunction, E as __getElevatedAccessToken_wrapped, F as getDefaultClient, I as setDefaultClient, O as DEFAULT_PII_FIELDS, P as NONCE_POOL_SIZE, R as BaseError, T as ValueMustBeDefinedError, V as version, _ as MfaRateLimitedError, a as DYNAMIC_ICONIC_SPRITE_URL, b as InvalidExternalAuthError, c as CHAINS_INFO_MAP, d as UnauthorizedError, g as SandboxMaximumThresholdReachedError, h as getNonce, j as randomString, k as getUserAgent, l as fetchAndStoreNonces, o as SDK_API_CORE_VERSION, s as getChainFromVerifiedCredentialChain, t as InvalidParamError, u as createApiClient, v as MfaInvalidOtpError, w as assertDefined, x as APIError, y as LinkCredentialError, z as getCore } from "./InvalidParamError-BWWTxQ9d.esm.js";
|
|
2
|
+
import { A as REFRESH_USER_STATE_FROM_COOKIE_TRACKER_KEY, B as createLocalStorageAdapter, C as createCrossTabBroadcast, D as FETCH_PROJECT_SETTINGS_TRACKER_KEY, E as createDeferredPromise, F as generateSessionKeys, H as retryOnFail, I as fetchProjectSettings, L as createStorageKeySchema, M as isServerSideRendering, N as getBuffer, O as GENERATE_SESSION_KEYS_TRACKER_KEY, P as __logoutWithReason_wrapped, R as createStorage, S as createLogger, T as CannotTrackError, U as subscribeWithSelector, V as isSignedIn, W as isEqualShallow, _ as WalletAlreadyLinkedToAnotherUserError, a as updateWalletProviderKeysForVerifiedCredentials, b as createRealtimeService, c as createSignInMessageStatement, d as createVisit, f as hasExtension, g as MethodNotImplementedError, h as isCaptchaRequired, i as getNetworksData, j as REFRESH_USER_STATE_FROM_VALID_TOKEN_TRACKER_KEY, k as INITIALIZE_STORAGE_SYNC_TRACKER_KEY, l as formatSignInMessage, m as consumeCaptchaToken, o as verifyMessageSignatureOwnership, p as __setCaptchaToken_wrapped, s as removeUnverifiedWalletAccount, t as getNetworkProviderFromNetworkId, u as setUnverifiedWalletAccounts, v as NoNetworkProvidersError, x as createKeychainService, y as getKeychainIndexedDBName } from "./getNetworkProviderFromNetworkId-C9QzgcLs.esm.js";
|
|
3
|
+
import { A as onceEvent, C as formatWalletAccountId, D as emitEvent, O as offEvent, T as splitWalletProviderKey, a as parseElevatedAccessToken, b as getWalletAccounts, d as isUserMissingMfaAuth, f as checkAndRaiseWalletAccountsChangedEvent, h as getWalletProviderFromWalletAccount, i as upsertElevatedAccessToken, k as onEvent, n as getWalletProviderByKey, o as restoreUserSharesForAllWalletAccounts, p as emitWalletAccountsChangedEvent, r as updateAuthFromVerifyResponse, t as getVerifiedCredentialForWalletAccount, u as getWalletProviders, w as normalizeAddress, y as NoWalletProviderFoundError } from "./getVerifiedCredentialForWalletAccount-Cm2e3Boz.esm.js";
|
|
4
|
+
import { n as __refreshAuth_wrapped, t as NotWaasWalletAccountError } from "./NotWaasWalletAccountError-D1EuiYyR.esm.js";
|
|
5
|
+
import { n as getMfaMethods, r as __consumeMfaToken_wrapped, t as isMfaRequiredForAction } from "./isMfaRequiredForAction-vbGFqLFc.esm.js";
|
|
6
6
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
7
7
|
import { AuthModeEnum, ExchangeKeyEnum, JwtVerifiedCredentialFormatEnum, MFAAction, MfaBackupCodeAcknowledgement, ProviderEnum, TokenScope, WaasBackupOptionsEnum, WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
|
|
8
8
|
import * as z from "zod/mini";
|
|
9
|
-
import EventEmitter, { EventEmitter
|
|
9
|
+
import EventEmitter$1, { EventEmitter } from "eventemitter3";
|
|
10
10
|
import { browserSupportsWebAuthn, startAuthentication, startRegistration } from "@simplewebauthn/browser";
|
|
11
11
|
|
|
12
12
|
//#region src/modules/state/raiseStateEvents/events.ts
|
|
@@ -535,7 +535,7 @@ const createAsyncTrack = () => {
|
|
|
535
535
|
* This ensures no process is missed (as it would throw when tracked on a different node tick).
|
|
536
536
|
*/
|
|
537
537
|
let isTrackEnabled = true;
|
|
538
|
-
const eventEmitter = new EventEmitter
|
|
538
|
+
const eventEmitter = new EventEmitter();
|
|
539
539
|
const allSettledPromise = createDeferredPromise();
|
|
540
540
|
const tracker = /* @__PURE__ */ new Map();
|
|
541
541
|
/**
|
|
@@ -582,7 +582,7 @@ const createAsyncTrack = () => {
|
|
|
582
582
|
//#endregion
|
|
583
583
|
//#region src/services/eventEmitter/createEventEmitter.ts
|
|
584
584
|
/** @not-instrumented */
|
|
585
|
-
const createEventEmitter = () => new EventEmitter();
|
|
585
|
+
const createEventEmitter = () => new EventEmitter$1();
|
|
586
586
|
|
|
587
587
|
//#endregion
|
|
588
588
|
//#region src/errors/UnavailableInServerSideError.ts
|
|
@@ -2550,11 +2550,12 @@ const getCheckoutTransaction = async ({ transactionId }, client = getDefaultClie
|
|
|
2550
2550
|
* @returns The updated checkout transaction with quote data
|
|
2551
2551
|
* @not-instrumented
|
|
2552
2552
|
*/
|
|
2553
|
-
const getCheckoutTransactionQuote = async ({ fromTokenAddress, slippage, transactionId }, client = getDefaultClient()) => {
|
|
2553
|
+
const getCheckoutTransactionQuote = async ({ fromChainId, fromTokenAddress, slippage, transactionId }, client = getDefaultClient()) => {
|
|
2554
2554
|
const { apiClient, environmentId, sessionToken } = await createCheckoutApiClient({ transactionId }, client);
|
|
2555
2555
|
return apiClient.quoteCheckoutTransaction({
|
|
2556
2556
|
environmentId,
|
|
2557
2557
|
quoteRequest: {
|
|
2558
|
+
fromChainId,
|
|
2558
2559
|
fromTokenAddress,
|
|
2559
2560
|
slippage
|
|
2560
2561
|
},
|
|
@@ -2635,6 +2636,35 @@ const SWAP_SUPPORTED_CHAINS = [
|
|
|
2635
2636
|
"TRON"
|
|
2636
2637
|
];
|
|
2637
2638
|
|
|
2639
|
+
//#endregion
|
|
2640
|
+
//#region src/modules/swap/utils/ensureCorrectActiveNetwork/ensureCorrectActiveNetwork.ts
|
|
2641
|
+
/**
|
|
2642
|
+
* Ensures the wallet provider is on the correct active network if possible.
|
|
2643
|
+
* If the wallet provider is not on the correct active network, it will try to switch to the correct active network.
|
|
2644
|
+
* It's not a blocker, so it will just log the error and skip the step if it fails.
|
|
2645
|
+
*
|
|
2646
|
+
* @not-instrumented
|
|
2647
|
+
*/
|
|
2648
|
+
const ensureCorrectActiveNetwork = async ({ requiredNetworkId, walletProvider }, client) => {
|
|
2649
|
+
const { logger } = getCore(client);
|
|
2650
|
+
if (!requiredNetworkId || !walletProvider.switchActiveNetwork) return;
|
|
2651
|
+
logger.debug("[ensureCorrectActiveNetwork] Required network id", requiredNetworkId);
|
|
2652
|
+
try {
|
|
2653
|
+
const { networkId: activeNetworkId } = await walletProvider.getActiveNetworkId();
|
|
2654
|
+
logger.debug("[ensureCorrectActiveNetwork] Check if should switch network", {
|
|
2655
|
+
activeNetworkId,
|
|
2656
|
+
requiredNetworkId
|
|
2657
|
+
});
|
|
2658
|
+
if (!activeNetworkId || activeNetworkId === requiredNetworkId) {
|
|
2659
|
+
logger.debug("[ensureCorrectActiveNetwork] No active network id found or active network id is the same as the required network id - skipping this step");
|
|
2660
|
+
return;
|
|
2661
|
+
}
|
|
2662
|
+
await walletProvider.switchActiveNetwork({ networkId: requiredNetworkId });
|
|
2663
|
+
} catch (error) {
|
|
2664
|
+
logger.debug("[ensureCorrectActiveNetwork] Error getting active network id or switching network - skipping this step", error);
|
|
2665
|
+
}
|
|
2666
|
+
};
|
|
2667
|
+
|
|
2638
2668
|
//#endregion
|
|
2639
2669
|
//#region src/modules/swap/executeSwapTransaction/executeSwapTransaction.ts
|
|
2640
2670
|
/**
|
|
@@ -2649,11 +2679,10 @@ const executeSwapTransaction = async ({ walletAccount, signingPayload, onStepCha
|
|
|
2649
2679
|
if (!SWAP_SUPPORTED_CHAINS.includes(walletAccount.chain)) throw new InvalidParamError(`Chain ${walletAccount.chain} is not supported for swap transactions`);
|
|
2650
2680
|
const walletProvider = getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
2651
2681
|
assertWalletProviderMethodDefined(walletProvider, "executeSwapTransaction");
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
}
|
|
2682
|
+
await ensureCorrectActiveNetwork({
|
|
2683
|
+
requiredNetworkId: signingPayload.chainId,
|
|
2684
|
+
walletProvider
|
|
2685
|
+
}, client);
|
|
2657
2686
|
const { transactionHash } = await walletProvider.executeSwapTransaction({
|
|
2658
2687
|
onStepChange,
|
|
2659
2688
|
signingPayload,
|