@dynamic-labs-sdk/client 0.23.3 → 0.23.4

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.
Files changed (43) hide show
  1. package/dist/{InvalidParamError-AGSIdKWg.cjs.js → InvalidParamError-D2mY6bDm.cjs.js} +3 -3
  2. package/dist/{InvalidParamError-AGSIdKWg.cjs.js.map → InvalidParamError-D2mY6bDm.cjs.js.map} +1 -1
  3. package/dist/{InvalidParamError-16q5iBqn.esm.js → InvalidParamError-DQNvDHoJ.esm.js} +2 -2
  4. package/dist/{InvalidParamError-16q5iBqn.esm.js.map → InvalidParamError-DQNvDHoJ.esm.js.map} +1 -1
  5. package/dist/{NotWaasWalletAccountError-nhXCxVcy.esm.js → NotWaasWalletAccountError-BycDPZE7.esm.js} +3 -3
  6. package/dist/{NotWaasWalletAccountError-nhXCxVcy.esm.js.map → NotWaasWalletAccountError-BycDPZE7.esm.js.map} +1 -1
  7. package/dist/{NotWaasWalletAccountError-BF6AAjX2.cjs.js → NotWaasWalletAccountError-DKt-e0jp.cjs.js} +3 -3
  8. package/dist/{NotWaasWalletAccountError-BF6AAjX2.cjs.js.map → NotWaasWalletAccountError-DKt-e0jp.cjs.js.map} +1 -1
  9. package/dist/core.cjs.js +5 -5
  10. package/dist/core.esm.js +5 -5
  11. package/dist/{getNetworkProviderFromNetworkId-Its21Jgg.cjs.js → getNetworkProviderFromNetworkId-BZ0Yi99m.cjs.js} +10 -3
  12. package/dist/getNetworkProviderFromNetworkId-BZ0Yi99m.cjs.js.map +1 -0
  13. package/dist/{getNetworkProviderFromNetworkId-BcIgAfM0.esm.js → getNetworkProviderFromNetworkId-Ck4qXPsJ.esm.js} +5 -4
  14. package/dist/getNetworkProviderFromNetworkId-Ck4qXPsJ.esm.js.map +1 -0
  15. package/dist/{getSignedSessionId-dezYwjyJ.esm.js → getSignedSessionId-lg-rT8W_.esm.js} +3 -3
  16. package/dist/{getSignedSessionId-dezYwjyJ.esm.js.map → getSignedSessionId-lg-rT8W_.esm.js.map} +1 -1
  17. package/dist/{getSignedSessionId-DzWdq-Af.cjs.js → getSignedSessionId-oiCgC33U.cjs.js} +3 -3
  18. package/dist/{getSignedSessionId-DzWdq-Af.cjs.js.map → getSignedSessionId-oiCgC33U.cjs.js.map} +1 -1
  19. package/dist/{getVerifiedCredentialForWalletAccount-CExk0n4h.cjs.js → getVerifiedCredentialForWalletAccount-6iZSd5T2.cjs.js} +3 -3
  20. package/dist/{getVerifiedCredentialForWalletAccount-CExk0n4h.cjs.js.map → getVerifiedCredentialForWalletAccount-6iZSd5T2.cjs.js.map} +1 -1
  21. package/dist/{getVerifiedCredentialForWalletAccount-BSZiw2I7.esm.js → getVerifiedCredentialForWalletAccount-C2m6GufK.esm.js} +2 -2
  22. package/dist/{getVerifiedCredentialForWalletAccount-BSZiw2I7.esm.js.map → getVerifiedCredentialForWalletAccount-C2m6GufK.esm.js.map} +1 -1
  23. package/dist/index.cjs.js +53 -39
  24. package/dist/index.cjs.js.map +1 -1
  25. package/dist/index.esm.js +53 -39
  26. package/dist/index.esm.js.map +1 -1
  27. package/dist/{isMfaRequiredForAction-Drc_xwpq.cjs.js → isMfaRequiredForAction-DRetUSWZ.cjs.js} +2 -2
  28. package/dist/{isMfaRequiredForAction-Drc_xwpq.cjs.js.map → isMfaRequiredForAction-DRetUSWZ.cjs.js.map} +1 -1
  29. package/dist/{isMfaRequiredForAction-DSjzrlmn.esm.js → isMfaRequiredForAction-DqZS12dt.esm.js} +2 -2
  30. package/dist/{isMfaRequiredForAction-DSjzrlmn.esm.js.map → isMfaRequiredForAction-DqZS12dt.esm.js.map} +1 -1
  31. package/dist/modules/initializeClient/consts.d.ts +1 -0
  32. package/dist/modules/initializeClient/consts.d.ts.map +1 -1
  33. package/dist/modules/initializeClient/initializeClient.d.ts +1 -1
  34. package/dist/modules/initializeClient/initializeClient.d.ts.map +1 -1
  35. package/dist/modules/user/refreshUser/refreshUser.d.ts +1 -1
  36. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  37. package/dist/waas.cjs.js +4 -4
  38. package/dist/waas.esm.js +3 -3
  39. package/dist/waasCore.cjs.js +4 -4
  40. package/dist/waasCore.esm.js +3 -3
  41. package/package.json +2 -2
  42. package/dist/getNetworkProviderFromNetworkId-BcIgAfM0.esm.js.map +0 -1
  43. package/dist/getNetworkProviderFromNetworkId-Its21Jgg.cjs.js.map +0 -1
package/dist/index.esm.js CHANGED
@@ -1,8 +1,8 @@
1
- import { A as ValueMustBeDefinedError, B as name, D as extractSessionId, E as getUserAgent, F as getDefaultClient, I as setDefaultClient, M as CLIENT_SDK_NAME, O as isCookieEnabled, P as NONCE_POOL_SIZE, R as BaseError, S as __getElevatedAccessToken_wrapped, T as DEFAULT_PII_FIELDS, 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_wrapped, j as randomString, k as assertDefined, l as fetchAndStoreNonces, o as SDK_API_CORE_VERSION, s as __getChainFromVerifiedCredentialChain_wrapped, t as InvalidParamError, u as __createApiClient_wrapped, v as MfaInvalidOtpError, w as instrumentFunction, x as APIError, y as LinkCredentialError, z as getCore } from "./InvalidParamError-16q5iBqn.esm.js";
2
- import { A as getBuffer, C as CannotTrackError, D as INITIALIZE_STORAGE_SYNC_TRACKER_KEY, E as GENERATE_SESSION_KEYS_TRACKER_KEY, F as __createLocalStorageAdapter_wrapped, I as __subscribeWithSelector_wrapped, L as isEqualShallow, M as __createStorageKeySchema_wrapped, N as __createStorage_wrapped, O as REFRESH_USER_STATE_FROM_COOKIE_TRACKER_KEY, T as FETCH_PROJECT_SETTINGS_TRACKER_KEY, _ as NoNetworkProvidersError, a as __updateWalletProviderKeysForVerifiedCredentials_wrapped, b as __createLogger_wrapped, c as __createSignInMessageStatement_wrapped, d as __createVisit_wrapped, f as hasExtension, g as WalletAlreadyLinkedToAnotherUserError, h as isCaptchaRequired, i as __getNetworksData_wrapped, j as __generateSessionKeys_wrapped, k as isServerSideRendering, l as formatSignInMessage, m as __consumeCaptchaToken_wrapped, o as __verifyMessageSignatureOwnership_wrapped, p as __setCaptchaToken_wrapped, s as __removeUnverifiedWalletAccount_wrapped, t as __getNetworkProviderFromNetworkId_wrapped, u as __setUnverifiedWalletAccounts_wrapped, v as __createRealtimeService_wrapped, w as __createDeferredPromise_wrapped, x as __createCrossTabBroadcast_wrapped, y as __createIndexedDBKeychainService_wrapped } from "./getNetworkProviderFromNetworkId-BcIgAfM0.esm.js";
3
- import { A as setCookie, C as normalizeAddress, D as __onEvent_wrapped, E as __offEvent_wrapped, O as __onceEvent_wrapped, S as formatWalletAccountId, a as parseElevatedAccessToken, d as checkAndRaiseWalletAccountsChangedEvent, f as emitWalletAccountsChangedEvent, i as upsertElevatedAccessToken, k as emitEvent, m as __getWalletProviderFromWalletAccount_wrapped, n as getWalletProviderByKey, o as restoreUserSharesForAllWalletAccounts, p as DYNAMIC_AUTH_COOKIE_NAME, r as __updateAuthFromVerifyResponse_wrapped, t as __getVerifiedCredentialForWalletAccount_wrapped, u as __getWalletProviders_wrapped, v as NoWalletProviderFoundError, w as splitWalletProviderKey, y as __getWalletAccounts_wrapped } from "./getVerifiedCredentialForWalletAccount-BSZiw2I7.esm.js";
4
- import { n as __refreshAuth_wrapped, t as NotWaasWalletAccountError } from "./NotWaasWalletAccountError-nhXCxVcy.esm.js";
5
- import { n as __getMfaMethods_wrapped, r as __consumeMfaToken_wrapped, t as isMfaRequiredForAction } from "./isMfaRequiredForAction-DSjzrlmn.esm.js";
1
+ import { A as ValueMustBeDefinedError, B as name, D as extractSessionId, E as getUserAgent, F as getDefaultClient, I as setDefaultClient, M as CLIENT_SDK_NAME, O as isCookieEnabled, P as NONCE_POOL_SIZE, R as BaseError, S as __getElevatedAccessToken_wrapped, T as DEFAULT_PII_FIELDS, 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_wrapped, j as randomString, k as assertDefined, l as fetchAndStoreNonces, o as SDK_API_CORE_VERSION, s as __getChainFromVerifiedCredentialChain_wrapped, t as InvalidParamError, u as __createApiClient_wrapped, v as MfaInvalidOtpError, w as instrumentFunction, x as APIError, y as LinkCredentialError, z as getCore } from "./InvalidParamError-DQNvDHoJ.esm.js";
2
+ import { A as isServerSideRendering, C as CannotTrackError, D as INITIALIZE_STORAGE_SYNC_TRACKER_KEY, E as GENERATE_SESSION_KEYS_TRACKER_KEY, I as __createLocalStorageAdapter_wrapped, L as __subscribeWithSelector_wrapped, M as __generateSessionKeys_wrapped, N as __createStorageKeySchema_wrapped, O as REFRESH_USER_STATE_FROM_COOKIE_TRACKER_KEY, P as __createStorage_wrapped, R as isEqualShallow, T as FETCH_PROJECT_SETTINGS_TRACKER_KEY, _ as NoNetworkProvidersError, a as __updateWalletProviderKeysForVerifiedCredentials_wrapped, b as __createLogger_wrapped, c as __createSignInMessageStatement_wrapped, d as __createVisit_wrapped, f as hasExtension, g as WalletAlreadyLinkedToAnotherUserError, h as isCaptchaRequired, i as __getNetworksData_wrapped, j as getBuffer, k as REFRESH_USER_STATE_FROM_VALID_TOKEN_TRACKER_KEY, l as formatSignInMessage, m as __consumeCaptchaToken_wrapped, o as __verifyMessageSignatureOwnership_wrapped, p as __setCaptchaToken_wrapped, s as __removeUnverifiedWalletAccount_wrapped, t as __getNetworkProviderFromNetworkId_wrapped, u as __setUnverifiedWalletAccounts_wrapped, v as __createRealtimeService_wrapped, w as __createDeferredPromise_wrapped, x as __createCrossTabBroadcast_wrapped, y as __createIndexedDBKeychainService_wrapped } from "./getNetworkProviderFromNetworkId-Ck4qXPsJ.esm.js";
3
+ import { A as setCookie, C as normalizeAddress, D as __onEvent_wrapped, E as __offEvent_wrapped, O as __onceEvent_wrapped, S as formatWalletAccountId, a as parseElevatedAccessToken, d as checkAndRaiseWalletAccountsChangedEvent, f as emitWalletAccountsChangedEvent, i as upsertElevatedAccessToken, k as emitEvent, m as __getWalletProviderFromWalletAccount_wrapped, n as getWalletProviderByKey, o as restoreUserSharesForAllWalletAccounts, p as DYNAMIC_AUTH_COOKIE_NAME, r as __updateAuthFromVerifyResponse_wrapped, t as __getVerifiedCredentialForWalletAccount_wrapped, u as __getWalletProviders_wrapped, v as NoWalletProviderFoundError, w as splitWalletProviderKey, y as __getWalletAccounts_wrapped } from "./getVerifiedCredentialForWalletAccount-C2m6GufK.esm.js";
4
+ import { n as __refreshAuth_wrapped, t as NotWaasWalletAccountError } from "./NotWaasWalletAccountError-BycDPZE7.esm.js";
5
+ import { n as __getMfaMethods_wrapped, r as __consumeMfaToken_wrapped, t as isMfaRequiredForAction } from "./isMfaRequiredForAction-DqZS12dt.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";
@@ -587,6 +587,40 @@ const initializeStorageSync = async (client) => {
587
587
  syncStateWithStorage(client);
588
588
  };
589
589
 
590
+ //#endregion
591
+ //#region src/modules/user/refreshUser/refreshUser.ts
592
+ /**
593
+ * Refreshes the current user's data from the server.
594
+ *
595
+ * This function fetches the latest authenticated user information from the backend
596
+ * and updates the local user state.
597
+ *
598
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
599
+ * @returns A promise that resolves to the authenticated user.
600
+ * @instrumented
601
+ */
602
+ const refreshUser = async (client = getDefaultClient()) => {
603
+ const core = getCore(client);
604
+ const apiClient = __createApiClient_wrapped({}, client);
605
+ const previousState = { ...core.state.get() };
606
+ const user = await apiClient.getAuthenticatedUser({ environmentId: core.environmentId });
607
+ core.state.set({ user });
608
+ checkAndRaiseWalletAccountsChangedEvent({ previousState }, client);
609
+ return user;
610
+ };
611
+ const __refreshUser_impl = refreshUser;
612
+ const __refreshUser_wrapped = instrumentFunction({
613
+ fn: __refreshUser_impl,
614
+ functionName: "refreshUser",
615
+ getCore: () => {
616
+ try {
617
+ return getCore(getDefaultClient());
618
+ } catch {
619
+ return;
620
+ }
621
+ }
622
+ });
623
+
590
624
  //#endregion
591
625
  //#region src/errors/ClientAlreadyInitializedError.ts
592
626
  var ClientAlreadyInitializedError = class extends BaseError {
@@ -673,6 +707,16 @@ const initializeClient = async (client = getDefaultClient()) => {
673
707
  } else throw error;
674
708
  });
675
709
  });
710
+ /**
711
+ * When a token is persisted but the user state was lost (e.g. storage cleared
712
+ * partially), re-fetch the user from the server. This path is skipped when
713
+ * cookies are enabled because the token is not stored in SDK state.
714
+ */
715
+ const refreshUserStateFromValidTokenPromise = refreshUserStateFromCookiePromise.then(async () => {
716
+ if (core.state.get().token && !core.state.get().user) await __refreshUser_wrapped(client).catch(async () => {
717
+ await __logout_wrapped(client);
718
+ });
719
+ });
676
720
  core.initTrack.track({
677
721
  name: INITIALIZE_STORAGE_SYNC_TRACKER_KEY,
678
722
  promise: initializeStorageSyncPromise
@@ -689,6 +733,10 @@ const initializeClient = async (client = getDefaultClient()) => {
689
733
  name: REFRESH_USER_STATE_FROM_COOKIE_TRACKER_KEY,
690
734
  promise: refreshUserStateFromCookiePromise
691
735
  });
736
+ core.initTrack.track({
737
+ name: REFRESH_USER_STATE_FROM_VALID_TOKEN_TRACKER_KEY,
738
+ promise: refreshUserStateFromValidTokenPromise
739
+ });
692
740
  try {
693
741
  await core.initTrack.waitForAll();
694
742
  core.state.set({ initStatus: "finished" });
@@ -5637,40 +5685,6 @@ const isUserOnboardingComplete = (client = getDefaultClient()) => {
5637
5685
  return !hasMissingKycFields && !hasPendingMfaAuth && !hasPendingRecoveryCodes;
5638
5686
  };
5639
5687
 
5640
- //#endregion
5641
- //#region src/modules/user/refreshUser/refreshUser.ts
5642
- /**
5643
- * Refreshes the current user's data from the server.
5644
- *
5645
- * This function fetches the latest authenticated user information from the backend
5646
- * and updates the local user state.
5647
- *
5648
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
5649
- * @returns A promise that resolves to the authenticated user.
5650
- * @instrumented
5651
- */
5652
- const refreshUser = async (client = getDefaultClient()) => {
5653
- const core = getCore(client);
5654
- const apiClient = __createApiClient_wrapped({}, client);
5655
- const previousState = { ...core.state.get() };
5656
- const user = await apiClient.getAuthenticatedUser({ environmentId: core.environmentId });
5657
- core.state.set({ user });
5658
- checkAndRaiseWalletAccountsChangedEvent({ previousState }, client);
5659
- return user;
5660
- };
5661
- const __refreshUser_impl = refreshUser;
5662
- const __refreshUser_wrapped = instrumentFunction({
5663
- fn: __refreshUser_impl,
5664
- functionName: "refreshUser",
5665
- getCore: () => {
5666
- try {
5667
- return getCore(getDefaultClient());
5668
- } catch {
5669
- return;
5670
- }
5671
- }
5672
- });
5673
-
5674
5688
  //#endregion
5675
5689
  //#region src/modules/wallets/assertWalletAccountSigningAvailability/assertWalletAccountSigningAvailability.ts
5676
5690
  /**