@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.cjs.js CHANGED
@@ -1,8 +1,8 @@
1
- const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-Its21Jgg.cjs.js');
2
- const require_InvalidParamError = require('./InvalidParamError-AGSIdKWg.cjs.js');
3
- const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-CExk0n4h.cjs.js');
4
- const require_NotWaasWalletAccountError = require('./NotWaasWalletAccountError-BF6AAjX2.cjs.js');
5
- const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-Drc_xwpq.cjs.js');
1
+ const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-BZ0Yi99m.cjs.js');
2
+ const require_InvalidParamError = require('./InvalidParamError-D2mY6bDm.cjs.js');
3
+ const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-6iZSd5T2.cjs.js');
4
+ const require_NotWaasWalletAccountError = require('./NotWaasWalletAccountError-DKt-e0jp.cjs.js');
5
+ const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-DRetUSWZ.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");
@@ -589,6 +589,40 @@ const initializeStorageSync = async (client) => {
589
589
  syncStateWithStorage(client);
590
590
  };
591
591
 
592
+ //#endregion
593
+ //#region src/modules/user/refreshUser/refreshUser.ts
594
+ /**
595
+ * Refreshes the current user's data from the server.
596
+ *
597
+ * This function fetches the latest authenticated user information from the backend
598
+ * and updates the local user state.
599
+ *
600
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
601
+ * @returns A promise that resolves to the authenticated user.
602
+ * @instrumented
603
+ */
604
+ const refreshUser = async (client = require_InvalidParamError.getDefaultClient()) => {
605
+ const core = require_InvalidParamError.getCore(client);
606
+ const apiClient = require_InvalidParamError.__createApiClient_wrapped({}, client);
607
+ const previousState = { ...core.state.get() };
608
+ const user = await apiClient.getAuthenticatedUser({ environmentId: core.environmentId });
609
+ core.state.set({ user });
610
+ require_getVerifiedCredentialForWalletAccount.checkAndRaiseWalletAccountsChangedEvent({ previousState }, client);
611
+ return user;
612
+ };
613
+ const __refreshUser_impl = refreshUser;
614
+ const __refreshUser_wrapped = require_InvalidParamError.instrumentFunction({
615
+ fn: __refreshUser_impl,
616
+ functionName: "refreshUser",
617
+ getCore: () => {
618
+ try {
619
+ return require_InvalidParamError.getCore(require_InvalidParamError.getDefaultClient());
620
+ } catch {
621
+ return;
622
+ }
623
+ }
624
+ });
625
+
592
626
  //#endregion
593
627
  //#region src/errors/ClientAlreadyInitializedError.ts
594
628
  var ClientAlreadyInitializedError = class extends require_InvalidParamError.BaseError {
@@ -675,6 +709,16 @@ const initializeClient = async (client = require_InvalidParamError.getDefaultCli
675
709
  } else throw error;
676
710
  });
677
711
  });
712
+ /**
713
+ * When a token is persisted but the user state was lost (e.g. storage cleared
714
+ * partially), re-fetch the user from the server. This path is skipped when
715
+ * cookies are enabled because the token is not stored in SDK state.
716
+ */
717
+ const refreshUserStateFromValidTokenPromise = refreshUserStateFromCookiePromise.then(async () => {
718
+ if (core.state.get().token && !core.state.get().user) await __refreshUser_wrapped(client).catch(async () => {
719
+ await __logout_wrapped(client);
720
+ });
721
+ });
678
722
  core.initTrack.track({
679
723
  name: require_getNetworkProviderFromNetworkId.INITIALIZE_STORAGE_SYNC_TRACKER_KEY,
680
724
  promise: initializeStorageSyncPromise
@@ -691,6 +735,10 @@ const initializeClient = async (client = require_InvalidParamError.getDefaultCli
691
735
  name: require_getNetworkProviderFromNetworkId.REFRESH_USER_STATE_FROM_COOKIE_TRACKER_KEY,
692
736
  promise: refreshUserStateFromCookiePromise
693
737
  });
738
+ core.initTrack.track({
739
+ name: require_getNetworkProviderFromNetworkId.REFRESH_USER_STATE_FROM_VALID_TOKEN_TRACKER_KEY,
740
+ promise: refreshUserStateFromValidTokenPromise
741
+ });
694
742
  try {
695
743
  await core.initTrack.waitForAll();
696
744
  core.state.set({ initStatus: "finished" });
@@ -5639,40 +5687,6 @@ const isUserOnboardingComplete = (client = require_InvalidParamError.getDefaultC
5639
5687
  return !hasMissingKycFields && !hasPendingMfaAuth && !hasPendingRecoveryCodes;
5640
5688
  };
5641
5689
 
5642
- //#endregion
5643
- //#region src/modules/user/refreshUser/refreshUser.ts
5644
- /**
5645
- * Refreshes the current user's data from the server.
5646
- *
5647
- * This function fetches the latest authenticated user information from the backend
5648
- * and updates the local user state.
5649
- *
5650
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
5651
- * @returns A promise that resolves to the authenticated user.
5652
- * @instrumented
5653
- */
5654
- const refreshUser = async (client = require_InvalidParamError.getDefaultClient()) => {
5655
- const core = require_InvalidParamError.getCore(client);
5656
- const apiClient = require_InvalidParamError.__createApiClient_wrapped({}, client);
5657
- const previousState = { ...core.state.get() };
5658
- const user = await apiClient.getAuthenticatedUser({ environmentId: core.environmentId });
5659
- core.state.set({ user });
5660
- require_getVerifiedCredentialForWalletAccount.checkAndRaiseWalletAccountsChangedEvent({ previousState }, client);
5661
- return user;
5662
- };
5663
- const __refreshUser_impl = refreshUser;
5664
- const __refreshUser_wrapped = require_InvalidParamError.instrumentFunction({
5665
- fn: __refreshUser_impl,
5666
- functionName: "refreshUser",
5667
- getCore: () => {
5668
- try {
5669
- return require_InvalidParamError.getCore(require_InvalidParamError.getDefaultClient());
5670
- } catch {
5671
- return;
5672
- }
5673
- }
5674
- });
5675
-
5676
5690
  //#endregion
5677
5691
  //#region src/modules/wallets/assertWalletAccountSigningAvailability/assertWalletAccountSigningAvailability.ts
5678
5692
  /**