@dynamic-labs-sdk/react-hooks 1.3.0 → 1.5.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.
Files changed (168) hide show
  1. package/dist/exports/index.d.ts +36 -7
  2. package/dist/exports/index.d.ts.map +1 -1
  3. package/dist/foundation/useBaseMutation/index.d.ts +3 -0
  4. package/dist/foundation/useBaseMutation/index.d.ts.map +1 -0
  5. package/dist/foundation/useBaseMutation/useBaseMutation.d.ts +34 -0
  6. package/dist/foundation/useBaseMutation/useBaseMutation.d.ts.map +1 -0
  7. package/dist/foundation/useBaseQuery/index.d.ts +3 -0
  8. package/dist/foundation/useBaseQuery/index.d.ts.map +1 -0
  9. package/dist/foundation/useBaseQuery/useBaseQuery.d.ts +45 -0
  10. package/dist/foundation/useBaseQuery/useBaseQuery.d.ts.map +1 -0
  11. package/dist/foundation/useBaseState/index.d.ts +3 -0
  12. package/dist/foundation/useBaseState/index.d.ts.map +1 -0
  13. package/dist/foundation/useBaseState/useBaseState.d.ts +58 -0
  14. package/dist/foundation/useBaseState/useBaseState.d.ts.map +1 -0
  15. package/dist/hooks/useAuthenticateTotpMfaDevice/index.d.ts +3 -0
  16. package/dist/hooks/useAuthenticateTotpMfaDevice/index.d.ts.map +1 -0
  17. package/dist/hooks/useAuthenticateTotpMfaDevice/useAuthenticateTotpMfaDevice.d.ts +34 -0
  18. package/dist/hooks/useAuthenticateTotpMfaDevice/useAuthenticateTotpMfaDevice.d.ts.map +1 -0
  19. package/dist/hooks/useAvailableWalletProvidersData/index.d.ts +2 -0
  20. package/dist/hooks/useAvailableWalletProvidersData/index.d.ts.map +1 -0
  21. package/dist/hooks/useAvailableWalletProvidersData/useAvailableWalletProvidersData.d.ts +7 -0
  22. package/dist/hooks/useAvailableWalletProvidersData/useAvailableWalletProvidersData.d.ts.map +1 -0
  23. package/dist/hooks/useCreateNewMfaRecoveryCodes/index.d.ts +3 -0
  24. package/dist/hooks/useCreateNewMfaRecoveryCodes/index.d.ts.map +1 -0
  25. package/dist/hooks/useCreateNewMfaRecoveryCodes/useCreateNewMfaRecoveryCodes.d.ts +29 -0
  26. package/dist/hooks/useCreateNewMfaRecoveryCodes/useCreateNewMfaRecoveryCodes.d.ts.map +1 -0
  27. package/dist/hooks/useDeleteMfaDevice/index.d.ts +3 -0
  28. package/dist/hooks/useDeleteMfaDevice/index.d.ts.map +1 -0
  29. package/dist/hooks/useDeleteMfaDevice/useDeleteMfaDevice.d.ts +32 -0
  30. package/dist/hooks/useDeleteMfaDevice/useDeleteMfaDevice.d.ts.map +1 -0
  31. package/dist/hooks/useDeletePasskey/index.d.ts +3 -0
  32. package/dist/hooks/useDeletePasskey/index.d.ts.map +1 -0
  33. package/dist/hooks/useDeletePasskey/useDeletePasskey.d.ts +31 -0
  34. package/dist/hooks/useDeletePasskey/useDeletePasskey.d.ts.map +1 -0
  35. package/dist/hooks/useEvent/index.d.ts +2 -0
  36. package/dist/hooks/useEvent/index.d.ts.map +1 -0
  37. package/dist/hooks/useInitStatus/index.d.ts +2 -0
  38. package/dist/hooks/useInitStatus/index.d.ts.map +1 -0
  39. package/dist/hooks/useInitStatus/useInitStatus.d.ts +1 -1
  40. package/dist/hooks/useInitStatus/useInitStatus.d.ts.map +1 -1
  41. package/dist/hooks/useIsCaptchaRequired/index.d.ts +2 -0
  42. package/dist/hooks/useIsCaptchaRequired/index.d.ts.map +1 -0
  43. package/dist/hooks/useIsCaptchaRequired/useIsCaptchaRequired.d.ts +13 -0
  44. package/dist/hooks/useIsCaptchaRequired/useIsCaptchaRequired.d.ts.map +1 -0
  45. package/dist/hooks/useIsUserMissingMfaAuth/index.d.ts +2 -0
  46. package/dist/hooks/useIsUserMissingMfaAuth/index.d.ts.map +1 -0
  47. package/dist/hooks/useIsUserMissingMfaAuth/useIsUserMissingMfaAuth.d.ts +13 -0
  48. package/dist/hooks/useIsUserMissingMfaAuth/useIsUserMissingMfaAuth.d.ts.map +1 -0
  49. package/dist/hooks/useIsUserOnboardingComplete/index.d.ts +2 -0
  50. package/dist/hooks/useIsUserOnboardingComplete/index.d.ts.map +1 -0
  51. package/dist/hooks/useIsUserOnboardingComplete/useIsUserOnboardingComplete.d.ts +14 -0
  52. package/dist/hooks/useIsUserOnboardingComplete/useIsUserOnboardingComplete.d.ts.map +1 -0
  53. package/dist/hooks/useLogout/index.d.ts +2 -0
  54. package/dist/hooks/useLogout/index.d.ts.map +1 -0
  55. package/dist/hooks/useLogout/useLogout.d.ts +23 -0
  56. package/dist/hooks/useLogout/useLogout.d.ts.map +1 -0
  57. package/dist/hooks/useMfaDevices/index.d.ts +3 -0
  58. package/dist/hooks/useMfaDevices/index.d.ts.map +1 -0
  59. package/dist/hooks/useMfaDevices/useMfaDevices.d.ts +24 -0
  60. package/dist/hooks/useMfaDevices/useMfaDevices.d.ts.map +1 -0
  61. package/dist/hooks/useMultichainTokenBalances/index.d.ts +3 -0
  62. package/dist/hooks/useMultichainTokenBalances/index.d.ts.map +1 -0
  63. package/dist/hooks/useMultichainTokenBalances/useMultichainTokenBalances.d.ts +37 -0
  64. package/dist/hooks/useMultichainTokenBalances/useMultichainTokenBalances.d.ts.map +1 -0
  65. package/dist/hooks/useNativeBalance/index.d.ts +2 -0
  66. package/dist/hooks/useNativeBalance/index.d.ts.map +1 -0
  67. package/dist/hooks/useNativeBalance/useNativeBalance.d.ts +34 -0
  68. package/dist/hooks/useNativeBalance/useNativeBalance.d.ts.map +1 -0
  69. package/dist/hooks/useNetworksData/index.d.ts +2 -0
  70. package/dist/hooks/useNetworksData/index.d.ts.map +1 -0
  71. package/dist/hooks/useNetworksData/useNetworksData.d.ts +7 -0
  72. package/dist/hooks/useNetworksData/useNetworksData.d.ts.map +1 -0
  73. package/dist/hooks/useRegisterPasskey/index.d.ts +3 -0
  74. package/dist/hooks/useRegisterPasskey/index.d.ts.map +1 -0
  75. package/dist/hooks/useRegisterPasskey/useRegisterPasskey.d.ts +31 -0
  76. package/dist/hooks/useRegisterPasskey/useRegisterPasskey.d.ts.map +1 -0
  77. package/dist/hooks/useRegisterTotpMfaDevice/index.d.ts +3 -0
  78. package/dist/hooks/useRegisterTotpMfaDevice/index.d.ts.map +1 -0
  79. package/dist/hooks/useRegisterTotpMfaDevice/useRegisterTotpMfaDevice.d.ts +28 -0
  80. package/dist/hooks/useRegisterTotpMfaDevice/useRegisterTotpMfaDevice.d.ts.map +1 -0
  81. package/dist/hooks/useRegisteredDevices/index.d.ts +3 -0
  82. package/dist/hooks/useRegisteredDevices/index.d.ts.map +1 -0
  83. package/dist/hooks/useRegisteredDevices/useRegisteredDevices.d.ts +25 -0
  84. package/dist/hooks/useRegisteredDevices/useRegisteredDevices.d.ts.map +1 -0
  85. package/dist/hooks/useRemoveWalletAccount/index.d.ts +3 -0
  86. package/dist/hooks/useRemoveWalletAccount/index.d.ts.map +1 -0
  87. package/dist/hooks/useRemoveWalletAccount/useRemoveWalletAccount.d.ts +34 -0
  88. package/dist/hooks/useRemoveWalletAccount/useRemoveWalletAccount.d.ts.map +1 -0
  89. package/dist/hooks/useRevokeRegisteredDevice/index.d.ts +3 -0
  90. package/dist/hooks/useRevokeRegisteredDevice/index.d.ts.map +1 -0
  91. package/dist/hooks/useRevokeRegisteredDevice/useRevokeRegisteredDevice.d.ts +35 -0
  92. package/dist/hooks/useRevokeRegisteredDevice/useRevokeRegisteredDevice.d.ts.map +1 -0
  93. package/dist/hooks/useSendEmailOtp/index.d.ts +3 -0
  94. package/dist/hooks/useSendEmailOtp/index.d.ts.map +1 -0
  95. package/dist/hooks/useSendEmailOtp/useSendEmailOtp.d.ts +34 -0
  96. package/dist/hooks/useSendEmailOtp/useSendEmailOtp.d.ts.map +1 -0
  97. package/dist/hooks/useSendSmsOtp/index.d.ts +3 -0
  98. package/dist/hooks/useSendSmsOtp/index.d.ts.map +1 -0
  99. package/dist/hooks/useSendSmsOtp/useSendSmsOtp.d.ts +36 -0
  100. package/dist/hooks/useSendSmsOtp/useSendSmsOtp.d.ts.map +1 -0
  101. package/dist/hooks/useSessionExpiresAt/index.d.ts +2 -0
  102. package/dist/hooks/useSessionExpiresAt/index.d.ts.map +1 -0
  103. package/dist/hooks/useSessionExpiresAt/useSessionExpiresAt.d.ts +1 -1
  104. package/dist/hooks/useSessionExpiresAt/useSessionExpiresAt.d.ts.map +1 -1
  105. package/dist/hooks/useSetDefaultMfaDevice/index.d.ts +3 -0
  106. package/dist/hooks/useSetDefaultMfaDevice/index.d.ts.map +1 -0
  107. package/dist/hooks/useSetDefaultMfaDevice/useSetDefaultMfaDevice.d.ts +30 -0
  108. package/dist/hooks/useSetDefaultMfaDevice/useSetDefaultMfaDevice.d.ts.map +1 -0
  109. package/dist/hooks/useSignInWithPasskey/index.d.ts +3 -0
  110. package/dist/hooks/useSignInWithPasskey/index.d.ts.map +1 -0
  111. package/dist/hooks/useSignInWithPasskey/useSignInWithPasskey.d.ts +29 -0
  112. package/dist/hooks/useSignInWithPasskey/useSignInWithPasskey.d.ts.map +1 -0
  113. package/dist/hooks/useSignMessage/index.d.ts +3 -0
  114. package/dist/hooks/useSignMessage/index.d.ts.map +1 -0
  115. package/dist/hooks/useSignMessage/useSignMessage.d.ts +37 -0
  116. package/dist/hooks/useSignMessage/useSignMessage.d.ts.map +1 -0
  117. package/dist/hooks/useSwitchActiveNetwork/index.d.ts +3 -0
  118. package/dist/hooks/useSwitchActiveNetwork/index.d.ts.map +1 -0
  119. package/dist/hooks/useSwitchActiveNetwork/useSwitchActiveNetwork.d.ts +36 -0
  120. package/dist/hooks/useSwitchActiveNetwork/useSwitchActiveNetwork.d.ts.map +1 -0
  121. package/dist/hooks/useTokenBalances/index.d.ts +3 -0
  122. package/dist/hooks/useTokenBalances/index.d.ts.map +1 -0
  123. package/dist/hooks/useTokenBalances/useTokenBalances.d.ts +47 -0
  124. package/dist/hooks/useTokenBalances/useTokenBalances.d.ts.map +1 -0
  125. package/dist/hooks/useTransactionHistory/index.d.ts +3 -0
  126. package/dist/hooks/useTransactionHistory/index.d.ts.map +1 -0
  127. package/dist/hooks/useTransactionHistory/useTransactionHistory.d.ts +47 -0
  128. package/dist/hooks/useTransactionHistory/useTransactionHistory.d.ts.map +1 -0
  129. package/dist/hooks/useUnlinkSocialAccount/index.d.ts +3 -0
  130. package/dist/hooks/useUnlinkSocialAccount/index.d.ts.map +1 -0
  131. package/dist/hooks/useUnlinkSocialAccount/useUnlinkSocialAccount.d.ts +35 -0
  132. package/dist/hooks/useUnlinkSocialAccount/useUnlinkSocialAccount.d.ts.map +1 -0
  133. package/dist/hooks/useUpdateUser/index.d.ts +3 -0
  134. package/dist/hooks/useUpdateUser/index.d.ts.map +1 -0
  135. package/dist/hooks/useUpdateUser/useUpdateUser.d.ts +36 -0
  136. package/dist/hooks/useUpdateUser/useUpdateUser.d.ts.map +1 -0
  137. package/dist/hooks/useUser/index.d.ts +2 -0
  138. package/dist/hooks/useUser/index.d.ts.map +1 -0
  139. package/dist/hooks/useUser/useUser.d.ts +1 -1
  140. package/dist/hooks/useUser/useUser.d.ts.map +1 -1
  141. package/dist/hooks/useUserSocialAccounts/index.d.ts +2 -0
  142. package/dist/hooks/useUserSocialAccounts/index.d.ts.map +1 -0
  143. package/dist/hooks/useUserSocialAccounts/useUserSocialAccounts.d.ts +7 -0
  144. package/dist/hooks/useUserSocialAccounts/useUserSocialAccounts.d.ts.map +1 -0
  145. package/dist/hooks/useVerifyOtp/index.d.ts +3 -0
  146. package/dist/hooks/useVerifyOtp/index.d.ts.map +1 -0
  147. package/dist/hooks/useVerifyOtp/useVerifyOtp.d.ts +35 -0
  148. package/dist/hooks/useVerifyOtp/useVerifyOtp.d.ts.map +1 -0
  149. package/dist/hooks/useVerifyWalletAccount/index.d.ts +3 -0
  150. package/dist/hooks/useVerifyWalletAccount/index.d.ts.map +1 -0
  151. package/dist/hooks/useVerifyWalletAccount/useVerifyWalletAccount.d.ts +41 -0
  152. package/dist/hooks/useVerifyWalletAccount/useVerifyWalletAccount.d.ts.map +1 -0
  153. package/dist/hooks/useWalletAccounts/index.d.ts +2 -0
  154. package/dist/hooks/useWalletAccounts/index.d.ts.map +1 -0
  155. package/dist/hooks/useWalletAccounts/useWalletAccounts.d.ts +1 -2
  156. package/dist/hooks/useWalletAccounts/useWalletAccounts.d.ts.map +1 -1
  157. package/dist/index.cjs +949 -34
  158. package/dist/index.cjs.map +1 -1
  159. package/dist/index.esm.js +921 -35
  160. package/dist/index.esm.js.map +1 -1
  161. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  162. package/package.json +6 -4
  163. package/dist/foundation/useClientState/useClientState.d.ts +0 -9
  164. package/dist/foundation/useClientState/useClientState.d.ts.map +0 -1
  165. package/dist/hooks/useSocialAccounts/useSocialAccounts.d.ts +0 -7
  166. package/dist/hooks/useSocialAccounts/useSocialAccounts.d.ts.map +0 -1
  167. package/dist/hooks/useWalletProviders/useWalletProviders.d.ts +0 -7
  168. package/dist/hooks/useWalletProviders/useWalletProviders.d.ts.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,11 +1,13 @@
1
1
  let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
2
2
  let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
3
+ let _tanstack_react_query = require("@tanstack/react-query");
3
4
  let react = require("react");
4
5
  let react_jsx_runtime = require("react/jsx-runtime");
6
+ let _dynamic_labs_sdk_client_core = require("@dynamic-labs-sdk/client/core");
5
7
 
6
8
  //#region package.json
7
9
  var name = "@dynamic-labs-sdk/react-hooks";
8
- var version = "1.3.0";
10
+ var version = "1.5.0";
9
11
 
10
12
  //#endregion
11
13
  //#region src/modules/DynamicContext/DynamicContext.ts
@@ -53,6 +55,248 @@ const useDynamicClient = () => {
53
55
  return client;
54
56
  };
55
57
 
58
+ //#endregion
59
+ //#region src/foundation/useBaseMutation/useBaseMutation.ts
60
+ /**
61
+ * Internal hook that wraps a react-query `useMutation` with the conventions
62
+ * used by every async-write hook in this package:
63
+ *
64
+ * - `mutationFn` receives the resolved `DynamicClient` from context plus
65
+ * the caller-supplied `variables`, and is gated behind
66
+ * `waitForClientInitialized`.
67
+ * - Callers pass `mutateParams` to override any default
68
+ * `UseMutationOptions`, so consumers can wire `onSuccess` / `onError` /
69
+ * etc.
70
+ *
71
+ * Returns the full `useMutation` result — `mutate`, `mutateAsync`, `data`,
72
+ * `error`, `isPending`, `isSuccess`, `reset`, `status`, etc.
73
+ */
74
+ const useBaseMutation = ({ mutationFn, mutateParams }) => {
75
+ const client = useDynamicClient();
76
+ return (0, _tanstack_react_query.useMutation)({
77
+ mutationFn: async (variables) => {
78
+ await (0, _dynamic_labs_sdk_client.waitForClientInitialized)(client);
79
+ return mutationFn({
80
+ client,
81
+ variables
82
+ });
83
+ },
84
+ ...mutateParams
85
+ });
86
+ };
87
+
88
+ //#endregion
89
+ //#region src/hooks/useAuthenticateTotpMfaDevice/useAuthenticateTotpMfaDevice.ts
90
+ /**
91
+ * Authenticates the current user with a TOTP code from an authenticator app.
92
+ *
93
+ * Wraps `authenticateTotpMfaDevice` from `@dynamic-labs-sdk/client`. Call
94
+ * `mutate({ code })` with the 6-digit code; the resolved `data` is the MFA
95
+ * authentication response.
96
+ *
97
+ * @example
98
+ * ```tsx
99
+ * const { mutate: authenticateTotp, isPending } = useAuthenticateTotpMfaDevice();
100
+ * <button onClick={() => authenticateTotp({ code })} disabled={isPending}>
101
+ * Verify code
102
+ * </button>
103
+ * ```
104
+ */
105
+ const useAuthenticateTotpMfaDevice = ({ mutateParams } = {}) => useBaseMutation({
106
+ mutateParams,
107
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.authenticateTotpMfaDevice)(variables, client)
108
+ });
109
+
110
+ //#endregion
111
+ //#region src/foundation/useBaseState/useBaseState.ts
112
+ /**
113
+ * Internal hook that bridges Dynamic client event-driven state to React via
114
+ * react-query.
115
+ *
116
+ * - `queryFn` waits for the client to finish initializing (so the first
117
+ * render never sees a half-built client) and then runs `selector`. Init
118
+ * failures surface on `error`.
119
+ * - The supplied `event`(s) invalidate the query whenever they fire — a
120
+ * per-event predicate can narrow this so unrelated fires don't refetch.
121
+ * - Returns the full `useQuery` result so consumers can read every field
122
+ * react-query exposes (`data`, `error`, `isLoading`, `isFetching`,
123
+ * `refetch`, `status`, ...).
124
+ */
125
+ const normalizeEvents = (event) => {
126
+ if (typeof event !== "string") return event;
127
+ const map = {};
128
+ map[event] = true;
129
+ return map;
130
+ };
131
+ /**
132
+ * Per-event subscription wrapper. Extracted from `useBaseState` so the
133
+ * listener generics resolve at the per-event call site rather than as the
134
+ * intersection across all events.
135
+ */
136
+ const subscribeWithPredicate = ({ event, predicate, onMatch }, client) => {
137
+ const listener = (args) => {
138
+ if (predicate === true || predicate(args)) onMatch();
139
+ };
140
+ return (0, _dynamic_labs_sdk_client.onEvent)({
141
+ event,
142
+ listener
143
+ }, client);
144
+ };
145
+ const useBaseState = ({ event, queryKey, queryParams, selector, defaultValue, skipWaitForInit = false }) => {
146
+ const client = useDynamicClient();
147
+ const queryClient = (0, _tanstack_react_query.useQueryClient)();
148
+ /**
149
+ * Normalize the `event` shorthand into an events map. `useMemo` keyed
150
+ * on a stable JSON shape so callers can pass an inline literal each
151
+ * render without churning the event-subscription effect.
152
+ */
153
+ const eventsMapJson = (0, react.useMemo)(() => {
154
+ const map = normalizeEvents(event);
155
+ const sortedKeys = Object.keys(map).sort((a, b) => a.localeCompare(b));
156
+ return JSON.stringify(sortedKeys.map((k) => ({
157
+ event: k,
158
+ predicate: map[k] === true ? "__always__" : "__fn__"
159
+ })));
160
+ }, [event]);
161
+ /**
162
+ * Per-event predicates resolved from the latest render. The effect
163
+ * stays subscribed across re-renders (its deps are stable), so it
164
+ * reads predicates through this ref to pick up the most recent
165
+ * functions a caller passed inline.
166
+ */
167
+ const eventsMapRef = (0, react.useRef)(normalizeEvents(event));
168
+ eventsMapRef.current = normalizeEvents(event);
169
+ /**
170
+ * Stable list of event names the effect needs to subscribe to. Driven
171
+ * by `eventsMapJson` so callers can swap predicate identities each
172
+ * render without re-subscribing.
173
+ */
174
+ const eventNames = (0, react.useMemo)(() => {
175
+ const map = eventsMapRef.current;
176
+ return Object.keys(map).sort((a, b) => a.localeCompare(b));
177
+ }, [eventsMapJson]);
178
+ const fullQueryKey = (0, react.useMemo)(() => [
179
+ "@dynamic-labs-sdk/react-hooks",
180
+ "state",
181
+ ...queryKey
182
+ ], [JSON.stringify(queryKey)]);
183
+ (0, react.useEffect)(() => {
184
+ const core = (0, _dynamic_labs_sdk_client_core.getCore)(client);
185
+ const invalidate = () => {
186
+ queryClient.invalidateQueries({ queryKey: fullQueryKey }).catch((invalidateError) => {
187
+ core.logger.error("[useBaseState] invalidateQueries failed", invalidateError);
188
+ });
189
+ };
190
+ const unsubscribers = eventNames.map((eventName) => subscribeWithPredicate({
191
+ event: eventName,
192
+ onMatch: invalidate,
193
+ predicate: (args) => {
194
+ const predicate = eventsMapRef.current[eventName];
195
+ if (predicate === void 0) return false;
196
+ return predicate === true || predicate(args);
197
+ }
198
+ }, client));
199
+ return () => {
200
+ for (const unsubscribe of unsubscribers) unsubscribe();
201
+ };
202
+ }, [
203
+ client,
204
+ eventNames,
205
+ queryClient,
206
+ fullQueryKey
207
+ ]);
208
+ return (0, _tanstack_react_query.useQuery)({
209
+ ...queryParams,
210
+ placeholderData: defaultValue,
211
+ queryFn: skipWaitForInit ? () => selector(client) : async () => {
212
+ await (0, _dynamic_labs_sdk_client.waitForClientInitialized)(client);
213
+ return selector(client);
214
+ },
215
+ queryKey: fullQueryKey
216
+ });
217
+ };
218
+
219
+ //#endregion
220
+ //#region src/hooks/useAvailableWalletProvidersData/useAvailableWalletProvidersData.ts
221
+ /**
222
+ * Returns the available wallet providers and their data.
223
+ *
224
+ * Re-renders when a wallet provider changes (e.g. network switch).
225
+ */
226
+ const useAvailableWalletProvidersData = () => useBaseState({
227
+ defaultValue: [],
228
+ event: "walletProviderChanged",
229
+ queryKey: ["useAvailableWalletProvidersData"],
230
+ selector: (client) => (0, _dynamic_labs_sdk_client.getAvailableWalletProvidersData)(client)
231
+ });
232
+
233
+ //#endregion
234
+ //#region src/hooks/useCreateNewMfaRecoveryCodes/useCreateNewMfaRecoveryCodes.ts
235
+ /**
236
+ * Regenerates the current user's MFA recovery codes.
237
+ *
238
+ * Wraps `createNewMfaRecoveryCodes` from `@dynamic-labs-sdk/client`. Takes
239
+ * no arguments — call `mutate()` to issue a fresh set of codes (invalidating
240
+ * the previous set); the resolved `data` is the new recovery codes.
241
+ *
242
+ * @example
243
+ * ```tsx
244
+ * const { mutate: regenerateCodes, data, isPending } =
245
+ * useCreateNewMfaRecoveryCodes();
246
+ * <button onClick={() => regenerateCodes()} disabled={isPending}>
247
+ * Regenerate recovery codes
248
+ * </button>
249
+ * ```
250
+ */
251
+ const useCreateNewMfaRecoveryCodes = ({ mutateParams } = {}) => useBaseMutation({
252
+ mutateParams,
253
+ mutationFn: ({ client }) => (0, _dynamic_labs_sdk_client.createNewMfaRecoveryCodes)(client)
254
+ });
255
+
256
+ //#endregion
257
+ //#region src/hooks/useDeleteMfaDevice/useDeleteMfaDevice.ts
258
+ /**
259
+ * Deletes one of the current user's MFA devices.
260
+ *
261
+ * Wraps `deleteMfaDevice` from `@dynamic-labs-sdk/client`. Call
262
+ * `mutate({ deviceId })` to remove the device; when no elevated access
263
+ * token is available, also pass `mfaAuthToken`.
264
+ *
265
+ * @example
266
+ * ```tsx
267
+ * const { mutate: deleteDevice, isPending } = useDeleteMfaDevice();
268
+ * <button onClick={() => deleteDevice({ deviceId })} disabled={isPending}>
269
+ * Remove device
270
+ * </button>
271
+ * ```
272
+ */
273
+ const useDeleteMfaDevice = ({ mutateParams } = {}) => useBaseMutation({
274
+ mutateParams,
275
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.deleteMfaDevice)(variables, client)
276
+ });
277
+
278
+ //#endregion
279
+ //#region src/hooks/useDeletePasskey/useDeletePasskey.ts
280
+ /**
281
+ * Deletes one of the current user's passkeys.
282
+ *
283
+ * Wraps `deletePasskey` from `@dynamic-labs-sdk/client`. Call
284
+ * `mutate({ passkeyId })` to remove the passkey; the resolved `data` is
285
+ * `void`.
286
+ *
287
+ * @example
288
+ * ```tsx
289
+ * const { mutate: deletePasskey, isPending } = useDeletePasskey();
290
+ * <button onClick={() => deletePasskey({ passkeyId })} disabled={isPending}>
291
+ * Remove passkey
292
+ * </button>
293
+ * ```
294
+ */
295
+ const useDeletePasskey = ({ mutateParams } = {}) => useBaseMutation({
296
+ mutateParams,
297
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.deletePasskey)(variables, client)
298
+ });
299
+
56
300
  //#endregion
57
301
  //#region src/hooks/useEvent/useEvent.ts
58
302
  /**
@@ -74,33 +318,385 @@ const useEvent = ({ event, listener }) => {
74
318
  };
75
319
 
76
320
  //#endregion
77
- //#region src/foundation/useClientState/useClientState.ts
321
+ //#region src/hooks/useInitStatus/useInitStatus.ts
322
+ /**
323
+ * Returns the current initialization status of the Dynamic client.
324
+ *
325
+ * Possible values: 'uninitialized', 'in-progress', 'finished', 'failed'.
326
+ */
327
+ const useInitStatus = () => useBaseState({
328
+ defaultValue: "uninitialized",
329
+ event: "initStatusChanged",
330
+ queryKey: ["useInitStatus"],
331
+ selector: (client) => client.initStatus,
332
+ skipWaitForInit: true
333
+ });
334
+
335
+ //#endregion
336
+ //#region src/hooks/useIsCaptchaRequired/useIsCaptchaRequired.ts
337
+ /**
338
+ * Returns whether hCaptcha is required by the current project settings.
339
+ *
340
+ * Re-renders whenever project settings change (e.g. after the first
341
+ * settings fetch or a live settings update).
342
+ *
343
+ * Returns `false` whenever project settings have not loaded yet — callers
344
+ * that need to distinguish "still resolving" from "settings loaded, captcha
345
+ * really not required" can read `isPlaceholderData` / `isFetching` on the
346
+ * result.
347
+ */
348
+ const useIsCaptchaRequired = () => useBaseState({
349
+ defaultValue: false,
350
+ event: "projectSettingsChanged",
351
+ queryKey: ["useIsCaptchaRequired"],
352
+ selector: (client) => client.projectSettings === null ? false : (0, _dynamic_labs_sdk_client.isCaptchaRequired)(client)
353
+ });
354
+
355
+ //#endregion
356
+ //#region src/hooks/useIsUserMissingMfaAuth/useIsUserMissingMfaAuth.ts
357
+ /**
358
+ * Returns whether the current user still needs to complete additional MFA
359
+ * authentication (i.e. their session scope contains `requiresAdditionalAuth`).
360
+ *
361
+ * Re-renders whenever the user changes (login, logout, scope refresh).
362
+ *
363
+ * Returns `false` whenever no user is signed in — a signed-out user
364
+ * trivially has nothing pending. Callers that need to distinguish "still
365
+ * resolving" from "really nothing pending" can read `isPlaceholderData` /
366
+ * `isFetching` on the result.
367
+ */
368
+ const useIsUserMissingMfaAuth = () => useBaseState({
369
+ defaultValue: false,
370
+ event: "userChanged",
371
+ queryKey: ["useIsUserMissingMfaAuth"],
372
+ selector: (client) => client.user === null ? false : (0, _dynamic_labs_sdk_client.isUserMissingMfaAuth)(client)
373
+ });
374
+
375
+ //#endregion
376
+ //#region src/hooks/useIsUserOnboardingComplete/useIsUserOnboardingComplete.ts
78
377
  /**
79
- * Internal hook that bridges Dynamic client event-driven state to React.
378
+ * Returns whether the current user has completed onboarding (no missing KYC
379
+ * fields, MFA enrollment, or pending recovery-code acknowledgement).
80
380
  *
81
- * Subscribes to a client event and re-derives a snapshot via the selector
82
- * each time the event fires, using useSyncExternalStore for tear-free reads.
381
+ * Re-renders whenever the user changes (login, logout, profile update) or
382
+ * project settings change (which affects what counts as a missing field).
383
+ *
384
+ * Returns `false` whenever no user is signed in, mirroring the "not yet
385
+ * complete" semantics — callers should use the loading flags on the result
386
+ * (`isPlaceholderData`, `isFetching`) to distinguish "still resolving" from
387
+ * "really not complete".
388
+ */
389
+ const useIsUserOnboardingComplete = () => useBaseState({
390
+ defaultValue: false,
391
+ event: {
392
+ projectSettingsChanged: true,
393
+ userChanged: true
394
+ },
395
+ queryKey: ["useIsUserOnboardingComplete"],
396
+ selector: (client) => client.user === null ? false : (0, _dynamic_labs_sdk_client.isUserOnboardingComplete)(client)
397
+ });
398
+
399
+ //#endregion
400
+ //#region src/hooks/useLogout/useLogout.ts
401
+ /**
402
+ * Logs the current user out.
403
+ *
404
+ * Wraps `logout` from `@dynamic-labs-sdk/client`. Takes no required
405
+ * arguments — call `mutate()` to trigger the logout.
406
+ *
407
+ * @example
408
+ * ```tsx
409
+ * const { mutate: logOut, isPending } = useLogout();
410
+ * <button onClick={() => logOut()} disabled={isPending}>Logout</button>
411
+ * ```
83
412
  */
84
- const useClientState = (eventName, getSnapshot) => {
413
+ const useLogout = ({ mutateParams } = {}) => useBaseMutation({
414
+ mutateParams,
415
+ mutationFn: ({ client }) => (0, _dynamic_labs_sdk_client.logout)(client)
416
+ });
417
+
418
+ //#endregion
419
+ //#region src/foundation/useBaseQuery/useBaseQuery.ts
420
+ /**
421
+ * Internal hook that wraps a react-query `useQuery` with the conventions used
422
+ * by every async-read hook in this package:
423
+ *
424
+ * - `queryFn` receives the resolved `DynamicClient` from context, and is
425
+ * gated behind `waitForClientInitialized` so customers never see "client
426
+ * not ready" errors on first render.
427
+ * - Callers pass `queryParams` to override any default `UseQueryOptions`,
428
+ * so consumers can opt into retries / custom staleTime / etc.
429
+ * - Callers pass `enabled: false` (typically derived from whether their
430
+ * pseudo-required arguments are present) to short-circuit fetches.
431
+ *
432
+ * Returns the full `useQuery` result — `data`, `error`, `isLoading`,
433
+ * `isFetching`, `isSuccess`, `refetch`, `status`, etc.
434
+ */
435
+ const useBaseQuery = ({ queryFn, queryKey, queryParams, enabled = true }) => {
85
436
  const client = useDynamicClient();
86
- const valueRef = (0, react.useRef)(getSnapshot(client));
87
- return (0, react.useSyncExternalStore)((onStoreChange) => (0, _dynamic_labs_sdk_client.onEvent)({
88
- event: eventName,
89
- listener: () => {
90
- valueRef.current = getSnapshot(client);
91
- onStoreChange();
92
- }
93
- }, client), () => valueRef.current, () => valueRef.current);
437
+ return (0, _tanstack_react_query.useQuery)({
438
+ queryFn: async () => {
439
+ await (0, _dynamic_labs_sdk_client.waitForClientInitialized)(client);
440
+ return queryFn(client);
441
+ },
442
+ queryKey: (0, react.useMemo)(() => [
443
+ "@dynamic-labs-sdk/react-hooks",
444
+ "query",
445
+ ...queryKey
446
+ ], [queryKey]),
447
+ ...queryParams,
448
+ enabled: enabled && queryParams?.enabled !== false
449
+ });
94
450
  };
95
451
 
96
452
  //#endregion
97
- //#region src/hooks/useInitStatus/useInitStatus.ts
453
+ //#region src/hooks/useMfaDevices/useMfaDevices.ts
98
454
  /**
99
- * Returns the current initialization status of the Dynamic client.
455
+ * Returns the multi-factor authentication devices registered for the
456
+ * current user.
100
457
  *
101
- * Possible values: 'uninitialized', 'in-progress', 'finished', 'failed'.
458
+ * Wraps `getMfaDevices` from `@dynamic-labs-sdk/client`.
459
+ *
460
+ * @example
461
+ * ```tsx
462
+ * const { data: mfaDevices, isLoading, refetch } = useMfaDevices();
463
+ * ```
464
+ */
465
+ const useMfaDevices = ({ queryParams } = {}) => useBaseQuery({
466
+ queryFn: (client) => (0, _dynamic_labs_sdk_client.getMfaDevices)(client),
467
+ queryKey: ["useMfaDevices"],
468
+ queryParams
469
+ });
470
+
471
+ //#endregion
472
+ //#region src/hooks/useMultichainTokenBalances/useMultichainTokenBalances.ts
473
+ /**
474
+ * Returns token balances across multiple chains, networks, and addresses
475
+ * in a single batched API request.
476
+ *
477
+ * Wraps `getMultichainTokenBalances` from `@dynamic-labs-sdk/client`. The
478
+ * hook stays disabled until `balanceRequest` is defined. Use this for
479
+ * portfolio-style views; for a single account on one chain prefer
480
+ * {@link useTokenBalances}.
481
+ *
482
+ * @example
483
+ * ```tsx
484
+ * const { data, isLoading, refetch } = useMultichainTokenBalances({
485
+ * balanceRequest,
486
+ * });
487
+ * ```
488
+ */
489
+ const useMultichainTokenBalances = ({ balanceRequest, queryParams }) => useBaseQuery({
490
+ enabled: balanceRequest !== void 0,
491
+ queryFn: (client) => (0, _dynamic_labs_sdk_client.getMultichainTokenBalances)({ balanceRequest }, client),
492
+ queryKey: ["useMultichainTokenBalances", balanceRequest],
493
+ queryParams
494
+ });
495
+
496
+ //#endregion
497
+ //#region src/hooks/useNativeBalance/useNativeBalance.ts
498
+ /**
499
+ * Returns the native token balance for a wallet account.
500
+ *
501
+ * Calls `getNativeBalance` from `@dynamic-labs-sdk/client`. The hook stays
502
+ * disabled until `walletAccount` is defined.
503
+ *
504
+ * @example
505
+ * ```tsx
506
+ * const { data, isLoading, refetch } = useNativeBalance({ walletAccount });
507
+ * ```
508
+ */
509
+ const useNativeBalance = ({ walletAccount, queryParams }) => useBaseQuery({
510
+ enabled: walletAccount !== void 0,
511
+ queryFn: (client) => (0, _dynamic_labs_sdk_client.getNativeBalance)({ walletAccount }, client),
512
+ queryKey: ["useNativeBalance", walletAccount?.id],
513
+ queryParams
514
+ });
515
+
516
+ //#endregion
517
+ //#region src/hooks/useNetworksData/useNetworksData.ts
518
+ /**
519
+ * Returns the network configurations for all networks enabled in the Dynamic project.
520
+ *
521
+ * Re-renders when project settings change.
522
+ */
523
+ const useNetworksData = () => useBaseState({
524
+ defaultValue: [],
525
+ event: "projectSettingsChanged",
526
+ queryKey: ["useNetworksData"],
527
+ selector: (client) => (0, _dynamic_labs_sdk_client.getNetworksData)(client)
528
+ });
529
+
530
+ //#endregion
531
+ //#region src/hooks/useRegisteredDevices/useRegisteredDevices.ts
532
+ /**
533
+ * Returns the devices registered for the current user.
534
+ *
535
+ * Wraps `getRegisteredDevices` from `@dynamic-labs-sdk/client`. Pair with
536
+ * {@link useRevokeRegisteredDevice} to let users revoke a device from the
537
+ * list.
538
+ *
539
+ * @example
540
+ * ```tsx
541
+ * const { data: devices, isLoading, refetch } = useRegisteredDevices();
542
+ * ```
102
543
  */
103
- const useInitStatus = () => useClientState("initStatusChanged", (client) => client.initStatus);
544
+ const useRegisteredDevices = ({ queryParams } = {}) => useBaseQuery({
545
+ queryFn: (client) => (0, _dynamic_labs_sdk_client.getRegisteredDevices)(client),
546
+ queryKey: ["useRegisteredDevices"],
547
+ queryParams
548
+ });
549
+
550
+ //#endregion
551
+ //#region src/hooks/useRegisterPasskey/useRegisterPasskey.ts
552
+ /**
553
+ * Registers a new passkey for the current user.
554
+ *
555
+ * Wraps `registerPasskey` from `@dynamic-labs-sdk/client`. Call `mutate()`
556
+ * to prompt the device's WebAuthn flow; the resolved `data` is the
557
+ * registration response.
558
+ *
559
+ * @example
560
+ * ```tsx
561
+ * const { mutate: registerPasskey, isPending } = useRegisterPasskey();
562
+ * <button onClick={() => registerPasskey()} disabled={isPending}>
563
+ * Add passkey
564
+ * </button>
565
+ * ```
566
+ */
567
+ const useRegisterPasskey = ({ mutateParams } = {}) => useBaseMutation({
568
+ mutateParams,
569
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.registerPasskey)(variables, client)
570
+ });
571
+
572
+ //#endregion
573
+ //#region src/hooks/useRegisterTotpMfaDevice/useRegisterTotpMfaDevice.ts
574
+ /**
575
+ * Registers a new TOTP MFA device for the current user.
576
+ *
577
+ * Wraps `registerTotpMfaDevice` from `@dynamic-labs-sdk/client`. Takes no
578
+ * arguments — call `mutate()` to start enrollment; the resolved `data`
579
+ * contains the secret/URI used to render the authenticator QR code.
580
+ *
581
+ * @example
582
+ * ```tsx
583
+ * const { mutate: registerTotp, data, isPending } = useRegisterTotpMfaDevice();
584
+ * <button onClick={() => registerTotp()} disabled={isPending}>
585
+ * Add authenticator app
586
+ * </button>
587
+ * ```
588
+ */
589
+ const useRegisterTotpMfaDevice = ({ mutateParams } = {}) => useBaseMutation({
590
+ mutateParams,
591
+ mutationFn: ({ client }) => (0, _dynamic_labs_sdk_client.registerTotpMfaDevice)(client)
592
+ });
593
+
594
+ //#endregion
595
+ //#region src/hooks/useRemoveWalletAccount/useRemoveWalletAccount.ts
596
+ /**
597
+ * Removes a wallet account from the current user.
598
+ *
599
+ * Wraps `removeWalletAccount` from `@dynamic-labs-sdk/client`. Call
600
+ * `mutate({ walletAccount })` to disconnect/unlink the account; the
601
+ * resolved `data` is `void`.
602
+ *
603
+ * @example
604
+ * ```tsx
605
+ * const { mutate: removeWallet, isPending } = useRemoveWalletAccount();
606
+ * <button
607
+ * onClick={() => removeWallet({ walletAccount })}
608
+ * disabled={isPending}
609
+ * >
610
+ * Remove wallet
611
+ * </button>
612
+ * ```
613
+ */
614
+ const useRemoveWalletAccount = ({ mutateParams } = {}) => useBaseMutation({
615
+ mutateParams,
616
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.removeWalletAccount)(variables, client)
617
+ });
618
+
619
+ //#endregion
620
+ //#region src/hooks/useRevokeRegisteredDevice/useRevokeRegisteredDevice.ts
621
+ /**
622
+ * Revokes a previously registered device.
623
+ *
624
+ * Wraps `revokeRegisteredDevice` from `@dynamic-labs-sdk/client`. Call
625
+ * `mutate({ deviceRegistrationId })` with the id of the device to revoke
626
+ * (e.g. one returned by {@link useRegisteredDevices}); the resolved `data`
627
+ * is `void`.
628
+ *
629
+ * @example
630
+ * ```tsx
631
+ * const { mutate: revokeDevice, isPending } = useRevokeRegisteredDevice();
632
+ * <button
633
+ * onClick={() => revokeDevice({ deviceRegistrationId })}
634
+ * disabled={isPending}
635
+ * >
636
+ * Revoke device
637
+ * </button>
638
+ * ```
639
+ */
640
+ const useRevokeRegisteredDevice = ({ mutateParams } = {}) => useBaseMutation({
641
+ mutateParams,
642
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.revokeRegisteredDevice)(variables, client)
643
+ });
644
+
645
+ //#endregion
646
+ //#region src/hooks/useSendEmailOtp/useSendEmailOtp.ts
647
+ /**
648
+ * Sends a one-time password to an email address.
649
+ *
650
+ * Wraps `sendEmailOTP` from `@dynamic-labs-sdk/client`. Call
651
+ * `mutate({ email })` to dispatch the code; the resolved `data` is the
652
+ * `OTPVerification` payload to hand to {@link useVerifyOtp} once the user
653
+ * enters the code they received.
654
+ *
655
+ * @example
656
+ * ```tsx
657
+ * const { mutate: sendEmailOtp, data: otpVerification, isPending } =
658
+ * useSendEmailOtp();
659
+ * <button
660
+ * onClick={() => sendEmailOtp({ email: 'velma@mystery.inc' })}
661
+ * disabled={isPending}
662
+ * >
663
+ * Email me a code
664
+ * </button>
665
+ * ```
666
+ */
667
+ const useSendEmailOtp = ({ mutateParams } = {}) => useBaseMutation({
668
+ mutateParams,
669
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.sendEmailOTP)(variables, client)
670
+ });
671
+
672
+ //#endregion
673
+ //#region src/hooks/useSendSmsOtp/useSendSmsOtp.ts
674
+ /**
675
+ * Sends a one-time password to a phone number via SMS.
676
+ *
677
+ * Wraps `sendSmsOTP` from `@dynamic-labs-sdk/client`. Call
678
+ * `mutate({ isoCountryCode, phoneNumber })` to dispatch the code; the
679
+ * resolved `data` is the `OTPVerification` payload to hand to
680
+ * {@link useVerifyOtp} once the user enters the code they received.
681
+ *
682
+ * @example
683
+ * ```tsx
684
+ * const { mutate: sendSmsOtp, data: otpVerification, isPending } =
685
+ * useSendSmsOtp();
686
+ * <button
687
+ * onClick={() =>
688
+ * sendSmsOtp({ isoCountryCode: 'US', phoneNumber: '5550100' })
689
+ * }
690
+ * disabled={isPending}
691
+ * >
692
+ * Text me a code
693
+ * </button>
694
+ * ```
695
+ */
696
+ const useSendSmsOtp = ({ mutateParams } = {}) => useBaseMutation({
697
+ mutateParams,
698
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.sendSmsOTP)(variables, client)
699
+ });
104
700
 
105
701
  //#endregion
106
702
  //#region src/hooks/useSessionExpiresAt/useSessionExpiresAt.ts
@@ -109,16 +705,229 @@ const useInitStatus = () => useClientState("initStatusChanged", (client) => clie
109
705
  *
110
706
  * Re-renders when the user changes (which includes session updates).
111
707
  */
112
- const useSessionExpiresAt = () => useClientState("userChanged", (client) => client.sessionExpiresAt);
708
+ const useSessionExpiresAt = () => useBaseState({
709
+ defaultValue: null,
710
+ event: "userChanged",
711
+ queryKey: ["useSessionExpiresAt"],
712
+ selector: (client) => client.sessionExpiresAt
713
+ });
113
714
 
114
715
  //#endregion
115
- //#region src/hooks/useSocialAccounts/useSocialAccounts.ts
716
+ //#region src/hooks/useSetDefaultMfaDevice/useSetDefaultMfaDevice.ts
116
717
  /**
117
- * Returns the current user's linked social accounts.
718
+ * Sets the current user's default MFA device.
118
719
  *
119
- * Re-renders when the user changes.
720
+ * Wraps `setDefaultMfaDevice` from `@dynamic-labs-sdk/client`. Call
721
+ * `mutate({ deviceId })` to designate the device used for MFA challenges.
722
+ *
723
+ * @example
724
+ * ```tsx
725
+ * const { mutate: setDefaultDevice, isPending } = useSetDefaultMfaDevice();
726
+ * <button onClick={() => setDefaultDevice({ deviceId })} disabled={isPending}>
727
+ * Make default
728
+ * </button>
729
+ * ```
730
+ */
731
+ const useSetDefaultMfaDevice = ({ mutateParams } = {}) => useBaseMutation({
732
+ mutateParams,
733
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.setDefaultMfaDevice)(variables, client)
734
+ });
735
+
736
+ //#endregion
737
+ //#region src/hooks/useSignInWithPasskey/useSignInWithPasskey.ts
738
+ /**
739
+ * Signs the user in with a previously registered passkey.
740
+ *
741
+ * Wraps `signInWithPasskey` from `@dynamic-labs-sdk/client`. Call `mutate()`
742
+ * to start the WebAuthn authentication; the resolved `data` is the
743
+ * authentication response.
744
+ *
745
+ * @example
746
+ * ```tsx
747
+ * const { mutate: signInWithPasskey, isPending } = useSignInWithPasskey();
748
+ * <button onClick={() => signInWithPasskey()} disabled={isPending}>
749
+ * Sign in with passkey
750
+ * </button>
751
+ * ```
752
+ */
753
+ const useSignInWithPasskey = ({ mutateParams } = {}) => useBaseMutation({
754
+ mutateParams,
755
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.signInWithPasskey)(variables, client)
756
+ });
757
+
758
+ //#endregion
759
+ //#region src/hooks/useSignMessage/useSignMessage.ts
760
+ /**
761
+ * Signs an arbitrary message with a wallet account.
762
+ *
763
+ * Wraps `signMessage` from `@dynamic-labs-sdk/client`. Call
764
+ * `mutate({ walletAccount, message })` to trigger the signature flow —
765
+ * the wallet provider will prompt the user via its native UI.
766
+ *
767
+ * @example
768
+ * ```tsx
769
+ * const { mutate: signMessage, data, isPending } = useSignMessage();
770
+ * <button
771
+ * onClick={() => signMessage({ message: 'gm', walletAccount })}
772
+ * disabled={isPending}
773
+ * >
774
+ * Sign
775
+ * </button>
776
+ * ```
777
+ */
778
+ const useSignMessage = ({ mutateParams } = {}) => useBaseMutation({
779
+ mutateParams,
780
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.signMessage)(variables, client)
781
+ });
782
+
783
+ //#endregion
784
+ //#region src/hooks/useSwitchActiveNetwork/useSwitchActiveNetwork.ts
785
+ /**
786
+ * Switches the active network for a wallet account.
787
+ *
788
+ * Wraps `switchActiveNetwork` from `@dynamic-labs-sdk/client`. Call
789
+ * `mutate({ networkId, walletAccount })` to request the switch — the
790
+ * wallet provider may prompt the user to approve adding/changing the
791
+ * chain via its native UI.
792
+ *
793
+ * @example
794
+ * ```tsx
795
+ * const { mutate: switchNetwork, isPending } = useSwitchActiveNetwork();
796
+ * <button
797
+ * onClick={() => switchNetwork({ networkId: 1, walletAccount })}
798
+ * disabled={isPending}
799
+ * >
800
+ * Switch to Ethereum
801
+ * </button>
802
+ * ```
803
+ */
804
+ const useSwitchActiveNetwork = ({ mutateParams } = {}) => useBaseMutation({
805
+ mutateParams,
806
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.switchActiveNetwork)(variables, client)
807
+ });
808
+
809
+ //#endregion
810
+ //#region src/hooks/useTokenBalances/useTokenBalances.ts
811
+ /**
812
+ * Returns the ERC-20-style token balances for a wallet account on a single
813
+ * chain.
814
+ *
815
+ * Wraps `getTokenBalances` from `@dynamic-labs-sdk/client`. The hook stays
816
+ * disabled until `walletAccount` is defined.
817
+ *
818
+ * For native-only balance use {@link useNativeBalance}; for a multi-chain
819
+ * portfolio use {@link useMultichainTokenBalances}.
820
+ *
821
+ * @example
822
+ * ```tsx
823
+ * const { data, isLoading, refetch } = useTokenBalances({ walletAccount });
824
+ * ```
825
+ */
826
+ const useTokenBalances = ({ walletAccount, queryParams, ...rest }) => useBaseQuery({
827
+ enabled: walletAccount !== void 0,
828
+ queryFn: (client) => (0, _dynamic_labs_sdk_client.getTokenBalances)({
829
+ walletAccount,
830
+ ...rest
831
+ }, client),
832
+ queryKey: [
833
+ "useTokenBalances",
834
+ walletAccount?.id,
835
+ rest
836
+ ],
837
+ queryParams
838
+ });
839
+
840
+ //#endregion
841
+ //#region src/hooks/useTransactionHistory/useTransactionHistory.ts
842
+ /**
843
+ * Returns the transaction history for a given wallet address, chain, and
844
+ * network.
845
+ *
846
+ * Wraps `getTransactionHistory` from `@dynamic-labs-sdk/client`. The hook
847
+ * stays disabled until `address`, `chain`, and `networkId` are all
848
+ * defined. Pagination is driven by `offset` — callers can swap in a new
849
+ * `offset` to fetch the next page (each unique key produces its own cache
850
+ * entry).
851
+ *
852
+ * @example
853
+ * ```tsx
854
+ * const { data, isLoading, refetch } = useTransactionHistory({
855
+ * address,
856
+ * chain,
857
+ * networkId,
858
+ * });
859
+ * ```
860
+ */
861
+ const useTransactionHistory = ({ address, chain, networkId, queryParams, ...rest }) => useBaseQuery({
862
+ enabled: address !== void 0 && chain !== void 0 && networkId !== void 0,
863
+ queryFn: (client) => (0, _dynamic_labs_sdk_client.getTransactionHistory)({
864
+ address,
865
+ chain,
866
+ networkId,
867
+ ...rest
868
+ }, client),
869
+ queryKey: [
870
+ "useTransactionHistory",
871
+ address,
872
+ chain,
873
+ networkId,
874
+ rest
875
+ ],
876
+ queryParams
877
+ });
878
+
879
+ //#endregion
880
+ //#region src/hooks/useUnlinkSocialAccount/useUnlinkSocialAccount.ts
881
+ /**
882
+ * Unlinks a social account from the current user.
883
+ *
884
+ * Wraps `unlinkSocialAccount` from `@dynamic-labs-sdk/client`. Call
885
+ * `mutate({ verifiedCredentialId })` with the id of the social credential
886
+ * to remove (e.g. from {@link useUserSocialAccounts}); the resolved `data`
887
+ * is the updated `VerifyResponse`.
888
+ *
889
+ * @example
890
+ * ```tsx
891
+ * const { mutate: unlinkSocial, isPending } = useUnlinkSocialAccount();
892
+ * <button
893
+ * onClick={() => unlinkSocial({ verifiedCredentialId })}
894
+ * disabled={isPending}
895
+ * >
896
+ * Disconnect
897
+ * </button>
898
+ * ```
120
899
  */
121
- const useSocialAccounts = () => useClientState("userChanged", (client) => (0, _dynamic_labs_sdk_client.getUserSocialAccounts)(client));
900
+ const useUnlinkSocialAccount = ({ mutateParams } = {}) => useBaseMutation({
901
+ mutateParams,
902
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.unlinkSocialAccount)(variables, client)
903
+ });
904
+
905
+ //#endregion
906
+ //#region src/hooks/useUpdateUser/useUpdateUser.ts
907
+ /**
908
+ * Updates the current user's profile information.
909
+ *
910
+ * Wraps `updateUser` from `@dynamic-labs-sdk/client`. Call
911
+ * `mutate({ userFields })` to push the new values; if a sensitive field
912
+ * (email, phone) changed the resolved `data` will contain an
913
+ * `OTPVerification` payload the caller needs to follow up on, otherwise
914
+ * `data` is `undefined`.
915
+ *
916
+ * @example
917
+ * ```tsx
918
+ * const { mutate: updateUser, data: otp, isPending } = useUpdateUser();
919
+ * <button
920
+ * onClick={() => updateUser({ userFields: { firstName: 'Velma' } })}
921
+ * disabled={isPending}
922
+ * >
923
+ * Save
924
+ * </button>
925
+ * ```
926
+ */
927
+ const useUpdateUser = ({ mutateParams } = {}) => useBaseMutation({
928
+ mutateParams,
929
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.updateUser)(variables, client)
930
+ });
122
931
 
123
932
  //#endregion
124
933
  //#region src/hooks/useUser/useUser.ts
@@ -127,25 +936,102 @@ const useSocialAccounts = () => useClientState("userChanged", (client) => (0, _d
127
936
  *
128
937
  * Re-renders when the user changes (login, logout, profile update).
129
938
  */
130
- const useUser = () => useClientState("userChanged", (client) => client.user);
939
+ const useUser = () => useBaseState({
940
+ defaultValue: null,
941
+ event: "userChanged",
942
+ queryKey: ["useUser"],
943
+ selector: (client) => client.user
944
+ });
131
945
 
132
946
  //#endregion
133
- //#region src/hooks/useWalletAccounts/useWalletAccounts.ts
947
+ //#region src/hooks/useUserSocialAccounts/useUserSocialAccounts.ts
134
948
  /**
135
- * Returns all wallet accounts connected to the current user.
949
+ * Returns the current user's linked social accounts.
136
950
  *
137
- * Re-renders when wallet accounts change (connect, disconnect, verify).
951
+ * Re-renders when the user changes.
138
952
  */
139
- const useWalletAccounts = () => useClientState("walletAccountsChanged", (client) => (0, _dynamic_labs_sdk_client.getWalletAccounts)(client));
953
+ const useUserSocialAccounts = () => useBaseState({
954
+ defaultValue: [],
955
+ event: "userChanged",
956
+ queryKey: ["useUserSocialAccounts"],
957
+ selector: (client) => (0, _dynamic_labs_sdk_client.getUserSocialAccounts)(client)
958
+ });
140
959
 
141
960
  //#endregion
142
- //#region src/hooks/useWalletProviders/useWalletProviders.ts
961
+ //#region src/hooks/useVerifyOtp/useVerifyOtp.ts
143
962
  /**
144
- * Returns the available wallet providers and their data.
963
+ * Verifies a one-time password the user received via email or SMS.
145
964
  *
146
- * Re-renders when a wallet provider changes (e.g. network switch).
965
+ * Wraps `verifyOTP` from `@dynamic-labs-sdk/client`. Call
966
+ * `mutate({ otpVerification, verificationToken })` with the
967
+ * `OTPVerification` returned by {@link useSendEmailOtp} /
968
+ * {@link useSendSmsOtp} and the code the user entered. A single hook
969
+ * covers both flows — `verifyOTP` resolves sign-in vs. user-update
970
+ * internally based on the current session.
971
+ *
972
+ * @example
973
+ * ```tsx
974
+ * const { mutate: verifyOtp, isPending } = useVerifyOtp();
975
+ * <button
976
+ * onClick={() => verifyOtp({ otpVerification, verificationToken: code })}
977
+ * disabled={isPending}
978
+ * >
979
+ * Verify
980
+ * </button>
981
+ * ```
147
982
  */
148
- const useWalletProviders = () => useClientState("walletProviderChanged", (client) => (0, _dynamic_labs_sdk_client.getAvailableWalletProvidersData)(client));
983
+ const useVerifyOtp = ({ mutateParams } = {}) => useBaseMutation({
984
+ mutateParams,
985
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.verifyOTP)(variables, client)
986
+ });
987
+
988
+ //#endregion
989
+ //#region src/hooks/useVerifyWalletAccount/useVerifyWalletAccount.ts
990
+ /**
991
+ * Verifies ownership of a wallet account and adds it to the user's profile.
992
+ *
993
+ * Wraps `verifyWalletAccount` from `@dynamic-labs-sdk/client`. Call
994
+ * `mutate({ walletAccount })` to trigger the verification flow — the
995
+ * wallet provider will prompt the user to sign a proof-of-ownership
996
+ * message. On success, `data` resolves to the verified
997
+ * {@link WalletAccount}.
998
+ *
999
+ * Throws `WalletAccountAlreadyVerifiedError` if the wallet is already
1000
+ * verified, or `WalletAlreadyLinkedToAnotherUserError` if the wallet is
1001
+ * linked to a different user — both surface through `error`.
1002
+ *
1003
+ * @example
1004
+ * ```tsx
1005
+ * const { mutate: verifyWalletAccount, isPending } = useVerifyWalletAccount();
1006
+ * <button
1007
+ * onClick={() => verifyWalletAccount({ walletAccount })}
1008
+ * disabled={isPending}
1009
+ * >
1010
+ * Verify
1011
+ * </button>
1012
+ * ```
1013
+ */
1014
+ const useVerifyWalletAccount = ({ mutateParams } = {}) => useBaseMutation({
1015
+ mutateParams,
1016
+ mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.verifyWalletAccount)(variables, client)
1017
+ });
1018
+
1019
+ //#endregion
1020
+ //#region src/hooks/useWalletAccounts/useWalletAccounts.ts
1021
+ /**
1022
+ * Returns all wallet accounts connected to the current user.
1023
+ *
1024
+ * Re-renders when wallet accounts change (connect, disconnect, verify).
1025
+ */
1026
+ const useWalletAccounts = () => useBaseState({
1027
+ defaultValue: [],
1028
+ event: {
1029
+ userChanged: true,
1030
+ walletAccountsChanged: true
1031
+ },
1032
+ queryKey: ["useWalletAccounts"],
1033
+ selector: (client) => (0, _dynamic_labs_sdk_client.getWalletAccounts)(client)
1034
+ });
149
1035
 
150
1036
  //#endregion
151
1037
  //#region src/exports/index.ts
@@ -153,12 +1039,41 @@ const useWalletProviders = () => useClientState("walletProviderChanged", (client
153
1039
 
154
1040
  //#endregion
155
1041
  exports.DynamicProvider = DynamicProvider;
1042
+ exports.useAuthenticateTotpMfaDevice = useAuthenticateTotpMfaDevice;
1043
+ exports.useAvailableWalletProvidersData = useAvailableWalletProvidersData;
1044
+ exports.useCreateNewMfaRecoveryCodes = useCreateNewMfaRecoveryCodes;
1045
+ exports.useDeleteMfaDevice = useDeleteMfaDevice;
1046
+ exports.useDeletePasskey = useDeletePasskey;
156
1047
  exports.useDynamicClient = useDynamicClient;
157
1048
  exports.useEvent = useEvent;
158
1049
  exports.useInitStatus = useInitStatus;
1050
+ exports.useIsCaptchaRequired = useIsCaptchaRequired;
1051
+ exports.useIsUserMissingMfaAuth = useIsUserMissingMfaAuth;
1052
+ exports.useIsUserOnboardingComplete = useIsUserOnboardingComplete;
1053
+ exports.useLogout = useLogout;
1054
+ exports.useMfaDevices = useMfaDevices;
1055
+ exports.useMultichainTokenBalances = useMultichainTokenBalances;
1056
+ exports.useNativeBalance = useNativeBalance;
1057
+ exports.useNetworksData = useNetworksData;
1058
+ exports.useRegisterPasskey = useRegisterPasskey;
1059
+ exports.useRegisterTotpMfaDevice = useRegisterTotpMfaDevice;
1060
+ exports.useRegisteredDevices = useRegisteredDevices;
1061
+ exports.useRemoveWalletAccount = useRemoveWalletAccount;
1062
+ exports.useRevokeRegisteredDevice = useRevokeRegisteredDevice;
1063
+ exports.useSendEmailOtp = useSendEmailOtp;
1064
+ exports.useSendSmsOtp = useSendSmsOtp;
159
1065
  exports.useSessionExpiresAt = useSessionExpiresAt;
160
- exports.useSocialAccounts = useSocialAccounts;
1066
+ exports.useSetDefaultMfaDevice = useSetDefaultMfaDevice;
1067
+ exports.useSignInWithPasskey = useSignInWithPasskey;
1068
+ exports.useSignMessage = useSignMessage;
1069
+ exports.useSwitchActiveNetwork = useSwitchActiveNetwork;
1070
+ exports.useTokenBalances = useTokenBalances;
1071
+ exports.useTransactionHistory = useTransactionHistory;
1072
+ exports.useUnlinkSocialAccount = useUnlinkSocialAccount;
1073
+ exports.useUpdateUser = useUpdateUser;
161
1074
  exports.useUser = useUser;
1075
+ exports.useUserSocialAccounts = useUserSocialAccounts;
1076
+ exports.useVerifyOtp = useVerifyOtp;
1077
+ exports.useVerifyWalletAccount = useVerifyWalletAccount;
162
1078
  exports.useWalletAccounts = useWalletAccounts;
163
- exports.useWalletProviders = useWalletProviders;
164
1079
  //# sourceMappingURL=index.cjs.map