@dynamic-labs-sdk/client 0.8.0 → 0.9.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/{constants-58bHSI3b.cjs.js → InvalidParamError-D1yNl3r1.cjs.js} +24 -4
- package/dist/InvalidParamError-D1yNl3r1.cjs.js.map +1 -0
- package/dist/{constants-B8WQGUki.esm.js → InvalidParamError-DMz6QY8e.esm.js} +18 -4
- package/dist/InvalidParamError-DMz6QY8e.esm.js.map +1 -0
- package/dist/{NotWaasWalletAccountError-DJmbtj65.esm.js → NotWaasWalletAccountError-Cp3qfAxw.esm.js} +3 -3
- package/dist/{NotWaasWalletAccountError-DJmbtj65.esm.js.map → NotWaasWalletAccountError-Cp3qfAxw.esm.js.map} +1 -1
- package/dist/{NotWaasWalletAccountError-Dq2ssnPs.cjs.js → NotWaasWalletAccountError-s2J7fQHr.cjs.js} +7 -7
- package/dist/{NotWaasWalletAccountError-Dq2ssnPs.cjs.js.map → NotWaasWalletAccountError-s2J7fQHr.cjs.js.map} +1 -1
- package/dist/client/core/createCore/createCore.d.ts.map +1 -1
- package/dist/client/core/createCore/getInitialState.d.ts.map +1 -1
- package/dist/client/core/types/DynamicCore.d.ts +15 -0
- package/dist/client/core/types/DynamicCore.d.ts.map +1 -1
- package/dist/client/core/types/DynamicCoreConfig.d.ts +1 -1
- package/dist/client/core/types/DynamicCoreConfig.d.ts.map +1 -1
- package/dist/client/types/DynamicClientConfig.d.ts +46 -0
- package/dist/client/types/DynamicClientConfig.d.ts.map +1 -1
- package/dist/core.cjs.js +34 -32
- package/dist/core.cjs.js.map +1 -1
- package/dist/core.esm.js +8 -8
- package/dist/core.esm.js.map +1 -1
- package/dist/exports/core.d.ts +6 -0
- package/dist/exports/core.d.ts.map +1 -1
- package/dist/exports/index.d.ts +4 -1
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/exports/waas.d.ts +4 -1
- package/dist/exports/waas.d.ts.map +1 -1
- package/dist/{getNetworkProviderFromNetworkId-DCZQS4ot.cjs.js → getNetworkProviderFromNetworkId-BXGwNlcZ.cjs.js} +129 -45
- package/dist/getNetworkProviderFromNetworkId-BXGwNlcZ.cjs.js.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-HoSmTgsz.esm.js → getNetworkProviderFromNetworkId-CmLsKY7E.esm.js} +88 -24
- package/dist/getNetworkProviderFromNetworkId-CmLsKY7E.esm.js.map +1 -0
- package/dist/{getSignedSessionId-DZ5toWIx.cjs.js → getSignedSessionId-BO9omMlI.cjs.js} +8 -8
- package/dist/{getSignedSessionId-DZ5toWIx.cjs.js.map → getSignedSessionId-BO9omMlI.cjs.js.map} +1 -1
- package/dist/{getSignedSessionId-CWSJHTeG.esm.js → getSignedSessionId-BvQ4i928.esm.js} +3 -3
- package/dist/{getSignedSessionId-CWSJHTeG.esm.js.map → getSignedSessionId-BvQ4i928.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-bYTdp3TE.esm.js → getVerifiedCredentialForWalletAccount-54lCppnJ.esm.js} +113 -3
- package/dist/getVerifiedCredentialForWalletAccount-54lCppnJ.esm.js.map +1 -0
- package/dist/{getVerifiedCredentialForWalletAccount-86wjRIe0.cjs.js → getVerifiedCredentialForWalletAccount-BW8iluei.cjs.js} +140 -30
- package/dist/getVerifiedCredentialForWalletAccount-BW8iluei.cjs.js.map +1 -0
- package/dist/index.cjs.js +326 -267
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +85 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/{isMfaRequiredForAction-lt9nPT2M.esm.js → isMfaRequiredForAction-DIvUT6_k.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-lt9nPT2M.esm.js.map → isMfaRequiredForAction-DIvUT6_k.esm.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-BeZstT1P.cjs.js → isMfaRequiredForAction-DmYvEIJH.cjs.js} +9 -9
- package/dist/{isMfaRequiredForAction-BeZstT1P.cjs.js.map → isMfaRequiredForAction-DmYvEIJH.cjs.js.map} +1 -1
- package/dist/modules/auth/decodeJwt/decodeJwt.d.ts +26 -0
- package/dist/modules/auth/decodeJwt/decodeJwt.d.ts.map +1 -0
- package/dist/modules/auth/decodeJwt/index.d.ts +2 -0
- package/dist/modules/auth/decodeJwt/index.d.ts.map +1 -0
- package/dist/modules/auth/getElevatedAccessToken/getElevatedAccessToken.d.ts +30 -0
- package/dist/modules/auth/getElevatedAccessToken/getElevatedAccessToken.d.ts.map +1 -0
- package/dist/modules/auth/getElevatedAccessToken/index.d.ts +2 -0
- package/dist/modules/auth/getElevatedAccessToken/index.d.ts.map +1 -0
- package/dist/modules/auth/state.d.ts +13 -0
- package/dist/modules/auth/state.d.ts.map +1 -1
- package/dist/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/elevatedAccessTokens.types.d.ts +10 -0
- package/dist/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/elevatedAccessTokens.types.d.ts.map +1 -0
- package/dist/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/normalizeScopes/index.d.ts +2 -0
- package/dist/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/normalizeScopes/index.d.ts.map +1 -0
- package/dist/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/normalizeScopes/normalizeScopes.d.ts +9 -0
- package/dist/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/normalizeScopes/normalizeScopes.d.ts.map +1 -0
- package/dist/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/parseElevatedAccessToken/index.d.ts +2 -0
- package/dist/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/parseElevatedAccessToken/index.d.ts.map +1 -0
- package/dist/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/parseElevatedAccessToken/parseElevatedAccessToken.d.ts +17 -0
- package/dist/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/parseElevatedAccessToken/parseElevatedAccessToken.d.ts.map +1 -0
- package/dist/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/upsertElevatedAccessToken/index.d.ts +2 -0
- package/dist/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/upsertElevatedAccessToken/index.d.ts.map +1 -0
- package/dist/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/upsertElevatedAccessToken/upsertElevatedAccessToken.d.ts +17 -0
- package/dist/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/upsertElevatedAccessToken/upsertElevatedAccessToken.d.ts.map +1 -0
- package/dist/modules/auth/updateAuthFromVerifyResponse/updateAuthFromVerifyResponse.d.ts.map +1 -1
- package/dist/modules/deviceRegistration/detectDeviceRegistrationRedirect/detectDeviceRegistrationRedirect.d.ts +1 -1
- package/dist/modules/deviceRegistration/{getDeviceTokenFromUrl/getDeviceTokenFromUrl.d.ts → getDeviceRegistrationTokenFromUrl/getDeviceRegistrationTokenFromUrl.d.ts} +3 -3
- package/dist/modules/deviceRegistration/getDeviceRegistrationTokenFromUrl/getDeviceRegistrationTokenFromUrl.d.ts.map +1 -0
- package/dist/modules/deviceRegistration/getDeviceRegistrationTokenFromUrl/index.d.ts +2 -0
- package/dist/modules/deviceRegistration/getDeviceRegistrationTokenFromUrl/index.d.ts.map +1 -0
- package/dist/modules/user/isUserOnboardingComplete/index.d.ts +2 -0
- package/dist/modules/user/isUserOnboardingComplete/index.d.ts.map +1 -0
- package/dist/modules/user/isUserOnboardingComplete/isUserOnboardingComplete.d.ts +12 -0
- package/dist/modules/user/isUserOnboardingComplete/isUserOnboardingComplete.d.ts.map +1 -0
- package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
- package/dist/modules/waas/getWalletRecoveryState/getWalletRecoveryState.d.ts +16 -0
- package/dist/modules/waas/getWalletRecoveryState/getWalletRecoveryState.d.ts.map +1 -0
- package/dist/modules/waas/getWalletRecoveryState/index.d.ts +2 -0
- package/dist/modules/waas/getWalletRecoveryState/index.d.ts.map +1 -0
- package/dist/modules/waas/unlockWallet/index.d.ts +2 -0
- package/dist/modules/waas/unlockWallet/index.d.ts.map +1 -0
- package/dist/modules/waas/unlockWallet/unlockWallet.d.ts +17 -0
- package/dist/modules/waas/unlockWallet/unlockWallet.d.ts.map +1 -0
- package/dist/modules/waas/waas.types.d.ts +8 -1
- package/dist/modules/waas/waas.types.d.ts.map +1 -1
- package/dist/modules/wallets/networks/getNetworksData/getNetworksData.d.ts +4 -0
- package/dist/modules/wallets/networks/getNetworksData/getNetworksData.d.ts.map +1 -1
- package/dist/services/crossTabBroadcast/createCrossTabBroadcast/createCrossTabBroadcast.d.ts +19 -0
- package/dist/services/crossTabBroadcast/createCrossTabBroadcast/createCrossTabBroadcast.d.ts.map +1 -0
- package/dist/services/crossTabBroadcast/createCrossTabBroadcast/index.d.ts +2 -0
- package/dist/services/crossTabBroadcast/createCrossTabBroadcast/index.d.ts.map +1 -0
- package/dist/services/crossTabBroadcast/crossTabBroadcast.schema.d.ts +8 -0
- package/dist/services/crossTabBroadcast/crossTabBroadcast.schema.d.ts.map +1 -0
- package/dist/services/crossTabBroadcast/crossTabBroadcast.types.d.ts +35 -0
- package/dist/services/crossTabBroadcast/crossTabBroadcast.types.d.ts.map +1 -0
- package/dist/services/crossTabBroadcast/index.d.ts +3 -0
- package/dist/services/crossTabBroadcast/index.d.ts.map +1 -0
- package/dist/services/deviceSigner/deviceSigner.types.d.ts +21 -0
- package/dist/services/deviceSigner/deviceSigner.types.d.ts.map +1 -0
- package/dist/services/deviceSigner/index.d.ts +2 -0
- package/dist/services/deviceSigner/index.d.ts.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/waas.cjs.js +61 -29
- package/dist/waas.cjs.js.map +1 -1
- package/dist/waas.esm.js +34 -4
- package/dist/waas.esm.js.map +1 -1
- package/dist/waasCore.cjs.js +33 -15
- package/dist/waasCore.cjs.js.map +1 -1
- package/dist/waasCore.esm.js +22 -4
- package/dist/waasCore.esm.js.map +1 -1
- package/package.json +3 -3
- package/dist/InvalidParamError-C2c9HQ4V.esm.js +0 -18
- package/dist/InvalidParamError-C2c9HQ4V.esm.js.map +0 -1
- package/dist/InvalidParamError-D2oVXYDc.cjs.js +0 -23
- package/dist/InvalidParamError-D2oVXYDc.cjs.js.map +0 -1
- package/dist/constants-58bHSI3b.cjs.js.map +0 -1
- package/dist/constants-B8WQGUki.esm.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-DCZQS4ot.cjs.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-HoSmTgsz.esm.js.map +0 -1
- package/dist/getVerifiedCredentialForWalletAccount-86wjRIe0.cjs.js.map +0 -1
- package/dist/getVerifiedCredentialForWalletAccount-bYTdp3TE.esm.js.map +0 -1
- package/dist/modules/deviceRegistration/getDeviceTokenFromUrl/getDeviceTokenFromUrl.d.ts.map +0 -1
- package/dist/modules/deviceRegistration/getDeviceTokenFromUrl/index.d.ts +0 -2
- package/dist/modules/deviceRegistration/getDeviceTokenFromUrl/index.d.ts.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-
|
|
2
|
-
const
|
|
3
|
-
const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-
|
|
4
|
-
const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-
|
|
5
|
-
const require_NotWaasWalletAccountError = require('./NotWaasWalletAccountError-
|
|
6
|
-
const require_InvalidParamError = require('./InvalidParamError-D2oVXYDc.cjs.js');
|
|
1
|
+
const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-BXGwNlcZ.cjs.js');
|
|
2
|
+
const require_InvalidParamError = require('./InvalidParamError-D1yNl3r1.cjs.js');
|
|
3
|
+
const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-BW8iluei.cjs.js');
|
|
4
|
+
const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-DmYvEIJH.cjs.js');
|
|
5
|
+
const require_NotWaasWalletAccountError = require('./NotWaasWalletAccountError-s2J7fQHr.cjs.js');
|
|
7
6
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
8
7
|
let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
|
|
9
8
|
let zod_mini = require("zod/mini");
|
|
@@ -34,7 +33,7 @@ const stateChangeEvents = {
|
|
|
34
33
|
* This error is thrown when the `retryOnFail` function is called with an invalid
|
|
35
34
|
* number of retries (i.e. less than 0).
|
|
36
35
|
*/
|
|
37
|
-
var InvalidRetryOnFailCallError = class extends
|
|
36
|
+
var InvalidRetryOnFailCallError = class extends require_InvalidParamError.BaseError {
|
|
38
37
|
constructor(maxRetries) {
|
|
39
38
|
super({
|
|
40
39
|
cause: null,
|
|
@@ -73,7 +72,7 @@ const retryOnFail = async ({ delay = 0, fn, maxRetries }) => {
|
|
|
73
72
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
74
73
|
* @returns True if the user is signed in, false otherwise.
|
|
75
74
|
*/
|
|
76
|
-
const isSignedIn = (client =
|
|
75
|
+
const isSignedIn = (client = require_InvalidParamError.getDefaultClient()) => Boolean(client.user || require_getVerifiedCredentialForWalletAccount.getWalletAccounts(client).length > 0);
|
|
77
76
|
|
|
78
77
|
//#endregion
|
|
79
78
|
//#region src/modules/projectSettings/fetchProjectSettings/projectSettingsExpirationScheme.ts
|
|
@@ -101,15 +100,15 @@ const PROJECT_SETTINGS_EXPIRATION_TIME = 1e3 * 60 * 5;
|
|
|
101
100
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
102
101
|
* @returns A promise that resolves to the updated project settings.
|
|
103
102
|
*/
|
|
104
|
-
const fetchProjectSettings = async (client =
|
|
105
|
-
const core =
|
|
103
|
+
const fetchProjectSettings = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
104
|
+
const core = require_InvalidParamError.getCore(client);
|
|
106
105
|
const currentExpiration = await core.storage.getItem(projectSettingsExpirationStorageKeySchema);
|
|
107
106
|
if (Boolean(client.projectSettings) && !(currentExpiration && currentExpiration < Date.now()) && isSignedIn(client)) return client.projectSettings;
|
|
108
|
-
const apiClient =
|
|
107
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
109
108
|
core.logger.debug("[fetchProjectSettings] Fetching project settings...");
|
|
110
109
|
const doFetch = async () => apiClient.getEnvironmentSettings({
|
|
111
110
|
environmentId: core.environmentId,
|
|
112
|
-
sdkVersion: `${
|
|
111
|
+
sdkVersion: `${require_InvalidParamError.CLIENT_SDK_NAME}/${core.version}`
|
|
113
112
|
}, { credentials: "omit" });
|
|
114
113
|
const projectSettings = await retryOnFail({
|
|
115
114
|
fn: doFetch,
|
|
@@ -165,14 +164,14 @@ const p256Keygen = async () => {
|
|
|
165
164
|
//#region src/modules/sessionKeys/generateSessionKeys/generateSessionKeys.ts
|
|
166
165
|
const generateSessionKeys = async (client) => {
|
|
167
166
|
const { private: privateKey, public: publicKey, privateJwk: privateKeyJwk } = await p256Keygen();
|
|
168
|
-
const core =
|
|
167
|
+
const core = require_InvalidParamError.getCore(client);
|
|
169
168
|
const stringifiedSessionKeys = JSON.stringify({
|
|
170
169
|
privateKey,
|
|
171
170
|
privateKeyJwk,
|
|
172
171
|
publicKey,
|
|
173
172
|
registered: false
|
|
174
173
|
});
|
|
175
|
-
const encodedSessionKeys =
|
|
174
|
+
const encodedSessionKeys = require_InvalidParamError.getBuffer().from(stringifiedSessionKeys).toString("base64");
|
|
176
175
|
core.state.set({ sessionKeys: encodedSessionKeys });
|
|
177
176
|
return {
|
|
178
177
|
privateKey,
|
|
@@ -200,7 +199,7 @@ const createRuntimeServices = () => {
|
|
|
200
199
|
//#endregion
|
|
201
200
|
//#region src/modules/wallets/utils/getAvailableWalletProvidersFromWalletAccounts/getAvailableWalletProvidersFromWalletAccounts.ts
|
|
202
201
|
const getAvailableWalletProvidersFromWalletAccounts = (client) => {
|
|
203
|
-
const core =
|
|
202
|
+
const core = require_InvalidParamError.getCore(client);
|
|
204
203
|
const walletProvidersMap = /* @__PURE__ */ new Map();
|
|
205
204
|
require_getVerifiedCredentialForWalletAccount.getWalletAccounts(client).forEach((walletAccount) => {
|
|
206
205
|
if (walletProvidersMap.has(walletAccount.walletProviderKey)) return;
|
|
@@ -223,7 +222,7 @@ const getAvailableWalletProvidersFromWalletAccounts = (client) => {
|
|
|
223
222
|
* Disconnect and terminate each wallet provider, if available.
|
|
224
223
|
*/
|
|
225
224
|
const disconnectAndTerminateWalletProviders = async (client) => {
|
|
226
|
-
const core =
|
|
225
|
+
const core = require_InvalidParamError.getCore(client);
|
|
227
226
|
const walletProviders = getAvailableWalletProvidersFromWalletAccounts(client);
|
|
228
227
|
await Promise.all(walletProviders.map(async (walletProvider) => {
|
|
229
228
|
if (walletProvider.terminate) await walletProvider.terminate();
|
|
@@ -243,12 +242,12 @@ const disconnectAndTerminateWalletProviders = async (client) => {
|
|
|
243
242
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
244
243
|
* @returns A promise that resolves when the logout process is complete.
|
|
245
244
|
*/
|
|
246
|
-
const logout = async (client =
|
|
247
|
-
const core =
|
|
245
|
+
const logout = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
246
|
+
const core = require_InvalidParamError.getCore(client);
|
|
248
247
|
core.logger.debug("[logout] Logging out...");
|
|
249
248
|
await disconnectAndTerminateWalletProviders(client);
|
|
250
249
|
if (client.user !== null) {
|
|
251
|
-
const apiClient =
|
|
250
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
252
251
|
try {
|
|
253
252
|
await apiClient.revokeSession({ environmentId: core.environmentId });
|
|
254
253
|
} catch (error) {
|
|
@@ -258,7 +257,7 @@ const logout = async (client = require_constants.getDefaultClient()) => {
|
|
|
258
257
|
* This deletes the auth cookie if it exists.
|
|
259
258
|
* If the cookie doesn't exist, this sets a new cookie that expires immediately.
|
|
260
259
|
*/
|
|
261
|
-
if (
|
|
260
|
+
if (require_InvalidParamError.isCookieEnabled(client)) require_getVerifiedCredentialForWalletAccount.setCookie(`${require_getVerifiedCredentialForWalletAccount.DYNAMIC_AUTH_COOKIE_NAME}=; Max-Age=-99999999; path=/; SameSite=Lax`);
|
|
262
261
|
}
|
|
263
262
|
core.state.set({
|
|
264
263
|
captchaToken: null,
|
|
@@ -303,7 +302,7 @@ const setLongTimeout = (callback, delay) => {
|
|
|
303
302
|
* Sets up a timeout to log out the user when their token expires.
|
|
304
303
|
*/
|
|
305
304
|
const initializeAuth = (client) => {
|
|
306
|
-
const core =
|
|
305
|
+
const core = require_InvalidParamError.getCore(client);
|
|
307
306
|
let clearExpirationTimeout = null;
|
|
308
307
|
const onChangeExpiration = require_getNetworkProviderFromNetworkId.subscribeWithSelector(core.state, (state) => state.sessionExpiresAt);
|
|
309
308
|
const checkExpiration = () => {
|
|
@@ -325,7 +324,7 @@ const initializeAuth = (client) => {
|
|
|
325
324
|
//#endregion
|
|
326
325
|
//#region src/modules/state/raiseStateEvents/raiseStateEvents.ts
|
|
327
326
|
const raiseStateEvents = (client) => {
|
|
328
|
-
|
|
327
|
+
require_InvalidParamError.getCore(client).state.subscribe((value, previous) => {
|
|
329
328
|
Object.entries(stateChangeEvents).forEach(([key, event]) => {
|
|
330
329
|
if (require_getNetworkProviderFromNetworkId.isEqualShallow(value[key], previous[key])) return;
|
|
331
330
|
require_getVerifiedCredentialForWalletAccount.emitEvent({
|
|
@@ -382,7 +381,7 @@ const sessionStorageKeySchema = require_getNetworkProviderFromNetworkId.createSt
|
|
|
382
381
|
//#endregion
|
|
383
382
|
//#region src/modules/storageSync/hydrateStateWithStorage/hydrateStateWithStorage.ts
|
|
384
383
|
const hydrateStateWithStorage = async (client) => {
|
|
385
|
-
const core =
|
|
384
|
+
const core = require_InvalidParamError.getCore(client);
|
|
386
385
|
const previousState = core.state.get();
|
|
387
386
|
const stateChanges = {};
|
|
388
387
|
const session = await core.storage.getItem(sessionStorageKeySchema);
|
|
@@ -396,7 +395,7 @@ const hydrateStateWithStorage = async (client) => {
|
|
|
396
395
|
stateChanges.sessionKeys = session.sessionKeys;
|
|
397
396
|
}
|
|
398
397
|
const storedState = await core.storage.getItem(stateStorageKeySchema);
|
|
399
|
-
if (storedState?.apiVersion ===
|
|
398
|
+
if (storedState?.apiVersion === require_InvalidParamError.SDK_API_CORE_VERSION) {
|
|
400
399
|
stateChanges.unverifiedWalletAccounts = storedState.unverifiedWalletAccounts;
|
|
401
400
|
stateChanges.walletProviderKeyMap = storedState.walletProviderKeyMap;
|
|
402
401
|
if (isSessionValid) stateChanges.user = storedState.user;
|
|
@@ -409,7 +408,7 @@ const hydrateStateWithStorage = async (client) => {
|
|
|
409
408
|
//#endregion
|
|
410
409
|
//#region src/modules/storageSync/syncStateWithStorage/syncStateWithStorage.ts
|
|
411
410
|
const syncStateWithStorage = (client) => {
|
|
412
|
-
const core =
|
|
411
|
+
const core = require_InvalidParamError.getCore(client);
|
|
413
412
|
core.state.subscribe((state) => {
|
|
414
413
|
if (state.sessionExpiresAt === null) core.storage.removeItem(sessionStorageKeySchema);
|
|
415
414
|
else core.storage.setItem(sessionStorageKeySchema, {
|
|
@@ -421,7 +420,7 @@ const syncStateWithStorage = (client) => {
|
|
|
421
420
|
token: state.token
|
|
422
421
|
});
|
|
423
422
|
core.storage.setItem(stateStorageKeySchema, {
|
|
424
|
-
apiVersion:
|
|
423
|
+
apiVersion: require_InvalidParamError.SDK_API_CORE_VERSION,
|
|
425
424
|
projectSettings: state.projectSettings,
|
|
426
425
|
unverifiedWalletAccounts: state.unverifiedWalletAccounts,
|
|
427
426
|
user: state.user,
|
|
@@ -439,7 +438,7 @@ const initializeStorageSync = async (client) => {
|
|
|
439
438
|
|
|
440
439
|
//#endregion
|
|
441
440
|
//#region src/errors/ClientAlreadyInitializedError.ts
|
|
442
|
-
var ClientAlreadyInitializedError = class extends
|
|
441
|
+
var ClientAlreadyInitializedError = class extends require_InvalidParamError.BaseError {
|
|
443
442
|
constructor() {
|
|
444
443
|
super({
|
|
445
444
|
cause: null,
|
|
@@ -466,8 +465,8 @@ var ClientAlreadyInitializedError = class extends require_constants.BaseError {
|
|
|
466
465
|
* @returns A promise that resolves when initialization is complete.
|
|
467
466
|
* @throws ClientAlreadyInitializedError If the client is already initialized.
|
|
468
467
|
*/
|
|
469
|
-
const initializeClient = async (client =
|
|
470
|
-
const core =
|
|
468
|
+
const initializeClient = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
469
|
+
const core = require_InvalidParamError.getCore(client);
|
|
471
470
|
core.logger.debug("[initializeClient] Initializing client. Current init status", core.state.get().initStatus);
|
|
472
471
|
if (core.state.get().initStatus !== "uninitialized") throw new ClientAlreadyInitializedError();
|
|
473
472
|
core.state.set({ initStatus: "in-progress" });
|
|
@@ -503,7 +502,7 @@ const initializeClient = async (client = require_constants.getDefaultClient()) =
|
|
|
503
502
|
* This call can fail with a 401 error if the user is not logged in and the SDK should finish its initialization process
|
|
504
503
|
* without throwing an error because that is an expected behavior.
|
|
505
504
|
*/
|
|
506
|
-
if (
|
|
505
|
+
if (require_InvalidParamError.isCookieEnabled(client)) await require_NotWaasWalletAccountError.refreshAuth(client).catch(async (error) => {
|
|
507
506
|
if (error.status === 401) {
|
|
508
507
|
if (client.user) await logout(client);
|
|
509
508
|
} else throw error;
|
|
@@ -535,13 +534,6 @@ const initializeClient = async (client = require_constants.getDefaultClient()) =
|
|
|
535
534
|
if (client.user) require_getVerifiedCredentialForWalletAccount.restoreUserSharesForAllWalletAccounts(client);
|
|
536
535
|
};
|
|
537
536
|
|
|
538
|
-
//#endregion
|
|
539
|
-
//#region src/utils/isServerSideRendering/isServerSideRendering.ts
|
|
540
|
-
/**
|
|
541
|
-
* Indicates if the code is running in a server-side environment.
|
|
542
|
-
*/
|
|
543
|
-
const isServerSideRendering = () => typeof window === "undefined";
|
|
544
|
-
|
|
545
537
|
//#endregion
|
|
546
538
|
//#region src/services/asyncTrack/createAsyncTrack.ts
|
|
547
539
|
/**
|
|
@@ -605,7 +597,7 @@ const createEventEmitter = () => new eventemitter3.default();
|
|
|
605
597
|
|
|
606
598
|
//#endregion
|
|
607
599
|
//#region src/errors/UnavailableInServerSideError.ts
|
|
608
|
-
var UnavailableInServerSideError = class extends
|
|
600
|
+
var UnavailableInServerSideError = class extends require_InvalidParamError.BaseError {
|
|
609
601
|
constructor(unavailableFeature) {
|
|
610
602
|
super({
|
|
611
603
|
cause: null,
|
|
@@ -623,7 +615,7 @@ var UnavailableInServerSideError = class extends require_constants.BaseError {
|
|
|
623
615
|
* Creates a fetch instance that uses the native window.fetch API.
|
|
624
616
|
*/
|
|
625
617
|
const createWebFetch = () => {
|
|
626
|
-
if (isServerSideRendering()) return () => Promise.reject(new UnavailableInServerSideError("createWebFetch"));
|
|
618
|
+
if (require_getNetworkProviderFromNetworkId.isServerSideRendering()) return () => Promise.reject(new UnavailableInServerSideError("createWebFetch"));
|
|
627
619
|
return window.fetch.bind(window);
|
|
628
620
|
};
|
|
629
621
|
|
|
@@ -633,7 +625,7 @@ const createWebFetch = () => {
|
|
|
633
625
|
* Creates a navigation handler that uses the native window.location API.
|
|
634
626
|
*/
|
|
635
627
|
const createNavigationHandler = () => {
|
|
636
|
-
if (isServerSideRendering()) return () => Promise.reject(new UnavailableInServerSideError("createNavigationHandler"));
|
|
628
|
+
if (require_getNetworkProviderFromNetworkId.isServerSideRendering()) return () => Promise.reject(new UnavailableInServerSideError("createNavigationHandler"));
|
|
637
629
|
return async (url) => {
|
|
638
630
|
window.location.href = url;
|
|
639
631
|
};
|
|
@@ -645,7 +637,7 @@ const createNavigationHandler = () => {
|
|
|
645
637
|
* Creates a deeplink opener that uses the native window.open API.
|
|
646
638
|
*/
|
|
647
639
|
const createWebDeeplinkOpener = () => {
|
|
648
|
-
if (isServerSideRendering()) return () => Promise.reject(new UnavailableInServerSideError("createWebDeeplinkOpener"));
|
|
640
|
+
if (require_getNetworkProviderFromNetworkId.isServerSideRendering()) return () => Promise.reject(new UnavailableInServerSideError("createWebDeeplinkOpener"));
|
|
649
641
|
return async (url) => {
|
|
650
642
|
window.open(url, "_blank");
|
|
651
643
|
};
|
|
@@ -679,7 +671,7 @@ const createDebouncedMutex = () => {
|
|
|
679
671
|
timer: null
|
|
680
672
|
});
|
|
681
673
|
const currentState = mutexState.get(lockKey);
|
|
682
|
-
|
|
674
|
+
require_InvalidParamError.assertDefined(currentState, `Mutex state for key ${lockKey} not found`);
|
|
683
675
|
currentState.resolutionPromises.push(resolutionPromise);
|
|
684
676
|
if (currentState.timer) clearTimeout(currentState.timer);
|
|
685
677
|
currentState.nextCallback = callback;
|
|
@@ -706,7 +698,7 @@ const createDebouncedMutex = () => {
|
|
|
706
698
|
|
|
707
699
|
//#endregion
|
|
708
700
|
//#region src/errors/InvalidStorageValue.ts
|
|
709
|
-
var InvalidStorageValue = class extends
|
|
701
|
+
var InvalidStorageValue = class extends require_InvalidParamError.BaseError {
|
|
710
702
|
constructor(key, value) {
|
|
711
703
|
super({
|
|
712
704
|
cause: null,
|
|
@@ -798,6 +790,7 @@ const DEFAULT_API_BASE_URL = "https://app.dynamicauth.com/api/v0";
|
|
|
798
790
|
*/
|
|
799
791
|
const getInitialState = () => ({
|
|
800
792
|
captchaToken: null,
|
|
793
|
+
elevatedAccessTokens: [],
|
|
801
794
|
initStatus: "uninitialized",
|
|
802
795
|
legacyToken: null,
|
|
803
796
|
mfaToken: null,
|
|
@@ -831,9 +824,12 @@ const createCore = (config) => {
|
|
|
831
824
|
const initTrack = createAsyncTrack();
|
|
832
825
|
const runtimeServices = createRuntimeServices();
|
|
833
826
|
const passkey = config.coreConfig?.passkey ?? createWebPasskeyService();
|
|
827
|
+
const deviceSigner = config.coreConfig?.deviceSigner;
|
|
834
828
|
return {
|
|
835
829
|
apiBaseUrl,
|
|
830
|
+
crossTabBroadcast: config.coreConfig?.crossTabBroadcast ?? require_getNetworkProviderFromNetworkId.createCrossTabBroadcast({ channelName: `dynamic_${config.environmentId}_broadcast` }),
|
|
836
831
|
debouncedMutex,
|
|
832
|
+
deviceSigner,
|
|
837
833
|
environmentId: config.environmentId,
|
|
838
834
|
eventEmitter,
|
|
839
835
|
extensions: /* @__PURE__ */ new Set(),
|
|
@@ -848,7 +844,8 @@ const createCore = (config) => {
|
|
|
848
844
|
runtimeServices,
|
|
849
845
|
state,
|
|
850
846
|
storage,
|
|
851
|
-
|
|
847
|
+
transformers: config.transformers,
|
|
848
|
+
version: require_InvalidParamError.version
|
|
852
849
|
};
|
|
853
850
|
};
|
|
854
851
|
|
|
@@ -894,19 +891,19 @@ const createDynamicClient = (config) => {
|
|
|
894
891
|
}
|
|
895
892
|
};
|
|
896
893
|
const autoInitialize = config.autoInitialize ?? true;
|
|
897
|
-
const shouldAutoInitialize = isServerSideRendering() ? false : autoInitialize;
|
|
894
|
+
const shouldAutoInitialize = require_getNetworkProviderFromNetworkId.isServerSideRendering() ? false : autoInitialize;
|
|
898
895
|
core.logger.debug("[createDynamicClient] Creating client...");
|
|
899
896
|
if (shouldAutoInitialize) {
|
|
900
897
|
core.logger.debug("[createDynamicClient] Initializing client...");
|
|
901
898
|
initializeClient(client);
|
|
902
899
|
}
|
|
903
|
-
|
|
900
|
+
require_InvalidParamError.setDefaultClient(client);
|
|
904
901
|
return client;
|
|
905
902
|
};
|
|
906
903
|
|
|
907
904
|
//#endregion
|
|
908
905
|
//#region src/errors/InvalidDeviceRegistrationRedirectError.ts
|
|
909
|
-
var InvalidDeviceRegistrationRedirectError = class extends
|
|
906
|
+
var InvalidDeviceRegistrationRedirectError = class extends require_InvalidParamError.BaseError {
|
|
910
907
|
constructor() {
|
|
911
908
|
super({
|
|
912
909
|
cause: null,
|
|
@@ -921,7 +918,7 @@ var InvalidDeviceRegistrationRedirectError = class extends require_constants.Bas
|
|
|
921
918
|
|
|
922
919
|
//#endregion
|
|
923
920
|
//#region src/errors/InvalidRedirectStorageStateError.ts
|
|
924
|
-
var InvalidRedirectStorageStateError = class extends
|
|
921
|
+
var InvalidRedirectStorageStateError = class extends require_InvalidParamError.BaseError {
|
|
925
922
|
constructor() {
|
|
926
923
|
super({
|
|
927
924
|
cause: null,
|
|
@@ -935,7 +932,7 @@ var InvalidRedirectStorageStateError = class extends require_constants.BaseError
|
|
|
935
932
|
|
|
936
933
|
//#endregion
|
|
937
934
|
//#region src/errors/MissingRedirectStorageStateError.ts
|
|
938
|
-
var MissingRedirectStorageStateError = class extends
|
|
935
|
+
var MissingRedirectStorageStateError = class extends require_InvalidParamError.BaseError {
|
|
939
936
|
constructor() {
|
|
940
937
|
super({
|
|
941
938
|
cause: null,
|
|
@@ -949,7 +946,7 @@ var MissingRedirectStorageStateError = class extends require_constants.BaseError
|
|
|
949
946
|
|
|
950
947
|
//#endregion
|
|
951
948
|
//#region src/errors/MissingSocialUrlParamError.ts
|
|
952
|
-
var MissingSocialUrlParamError = class extends
|
|
949
|
+
var MissingSocialUrlParamError = class extends require_InvalidParamError.BaseError {
|
|
953
950
|
constructor(param) {
|
|
954
951
|
super({
|
|
955
952
|
cause: null,
|
|
@@ -963,7 +960,7 @@ var MissingSocialUrlParamError = class extends require_constants.BaseError {
|
|
|
963
960
|
|
|
964
961
|
//#endregion
|
|
965
962
|
//#region src/errors/MissingUserVerificationError.ts
|
|
966
|
-
var MissingUserVerificationError = class extends
|
|
963
|
+
var MissingUserVerificationError = class extends require_InvalidParamError.BaseError {
|
|
967
964
|
informationToVerify;
|
|
968
965
|
constructor({ informationToVerify, message }) {
|
|
969
966
|
super({
|
|
@@ -979,7 +976,7 @@ var MissingUserVerificationError = class extends require_constants.BaseError {
|
|
|
979
976
|
|
|
980
977
|
//#endregion
|
|
981
978
|
//#region src/errors/NetworkAddingUnavailableError.ts
|
|
982
|
-
var NetworkAddingUnavailableError = class extends
|
|
979
|
+
var NetworkAddingUnavailableError = class extends require_InvalidParamError.BaseError {
|
|
983
980
|
constructor({ walletProviderKey, originalError, extraMessages }) {
|
|
984
981
|
const cause = originalError instanceof Error ? originalError : null;
|
|
985
982
|
super({
|
|
@@ -995,7 +992,7 @@ var NetworkAddingUnavailableError = class extends require_constants.BaseError {
|
|
|
995
992
|
|
|
996
993
|
//#endregion
|
|
997
994
|
//#region src/errors/NetworkNotAddedError.ts
|
|
998
|
-
var NetworkNotAddedError = class extends
|
|
995
|
+
var NetworkNotAddedError = class extends require_InvalidParamError.BaseError {
|
|
999
996
|
networkData;
|
|
1000
997
|
constructor({ networkData, networkId, originalError, walletProviderKey }) {
|
|
1001
998
|
const cause = originalError instanceof Error ? originalError : null;
|
|
@@ -1018,7 +1015,7 @@ var NetworkNotAddedError = class extends require_constants.BaseError {
|
|
|
1018
1015
|
|
|
1019
1016
|
//#endregion
|
|
1020
1017
|
//#region src/errors/NetworkSwitchingUnavailableError.ts
|
|
1021
|
-
var NetworkSwitchingUnavailableError = class extends
|
|
1018
|
+
var NetworkSwitchingUnavailableError = class extends require_InvalidParamError.BaseError {
|
|
1022
1019
|
constructor({ walletProviderKey, originalError, extraMessages }) {
|
|
1023
1020
|
const cause = originalError instanceof Error ? originalError : null;
|
|
1024
1021
|
super({
|
|
@@ -1034,7 +1031,7 @@ var NetworkSwitchingUnavailableError = class extends require_constants.BaseError
|
|
|
1034
1031
|
|
|
1035
1032
|
//#endregion
|
|
1036
1033
|
//#region src/errors/NoAddressFoundError.ts
|
|
1037
|
-
var NoAddressFoundError = class extends
|
|
1034
|
+
var NoAddressFoundError = class extends require_InvalidParamError.BaseError {
|
|
1038
1035
|
constructor() {
|
|
1039
1036
|
super({
|
|
1040
1037
|
cause: null,
|
|
@@ -1048,7 +1045,7 @@ var NoAddressFoundError = class extends require_constants.BaseError {
|
|
|
1048
1045
|
|
|
1049
1046
|
//#endregion
|
|
1050
1047
|
//#region src/errors/NoPasskeyCredentialsFoundError.ts
|
|
1051
|
-
var NoPasskeyCredentialsFoundError = class extends
|
|
1048
|
+
var NoPasskeyCredentialsFoundError = class extends require_InvalidParamError.BaseError {
|
|
1052
1049
|
constructor() {
|
|
1053
1050
|
super({
|
|
1054
1051
|
cause: null,
|
|
@@ -1062,7 +1059,7 @@ var NoPasskeyCredentialsFoundError = class extends require_constants.BaseError {
|
|
|
1062
1059
|
|
|
1063
1060
|
//#endregion
|
|
1064
1061
|
//#region src/errors/NoSmartWalletAccountSignerFoundError.ts
|
|
1065
|
-
var NoSmartWalletAccountSignerFoundError = class extends
|
|
1062
|
+
var NoSmartWalletAccountSignerFoundError = class extends require_InvalidParamError.BaseError {
|
|
1066
1063
|
constructor(smartWalletAddress) {
|
|
1067
1064
|
super({
|
|
1068
1065
|
cause: null,
|
|
@@ -1076,7 +1073,7 @@ var NoSmartWalletAccountSignerFoundError = class extends require_constants.BaseE
|
|
|
1076
1073
|
|
|
1077
1074
|
//#endregion
|
|
1078
1075
|
//#region src/errors/NoWebAuthNSupportError.ts
|
|
1079
|
-
var NoWebAuthNSupportError = class extends
|
|
1076
|
+
var NoWebAuthNSupportError = class extends require_InvalidParamError.BaseError {
|
|
1080
1077
|
constructor() {
|
|
1081
1078
|
super({
|
|
1082
1079
|
cause: null,
|
|
@@ -1090,7 +1087,7 @@ var NoWebAuthNSupportError = class extends require_constants.BaseError {
|
|
|
1090
1087
|
|
|
1091
1088
|
//#endregion
|
|
1092
1089
|
//#region src/errors/UnrecognizedNetworkError.ts
|
|
1093
|
-
var UnrecognizedNetworkError = class extends
|
|
1090
|
+
var UnrecognizedNetworkError = class extends require_InvalidParamError.BaseError {
|
|
1094
1091
|
constructor({ networkId, originalError, walletProviderKey }) {
|
|
1095
1092
|
const cause = originalError instanceof Error ? originalError : null;
|
|
1096
1093
|
super({
|
|
@@ -1106,7 +1103,7 @@ var UnrecognizedNetworkError = class extends require_constants.BaseError {
|
|
|
1106
1103
|
|
|
1107
1104
|
//#endregion
|
|
1108
1105
|
//#region src/errors/UserNotAuthenticatedError.ts
|
|
1109
|
-
var UserNotAuthenticatedError = class extends
|
|
1106
|
+
var UserNotAuthenticatedError = class extends require_InvalidParamError.BaseError {
|
|
1110
1107
|
constructor({ shortMessage } = {}) {
|
|
1111
1108
|
super({
|
|
1112
1109
|
cause: null,
|
|
@@ -1120,7 +1117,7 @@ var UserNotAuthenticatedError = class extends require_constants.BaseError {
|
|
|
1120
1117
|
|
|
1121
1118
|
//#endregion
|
|
1122
1119
|
//#region src/errors/UserRejectedError.ts
|
|
1123
|
-
var UserRejectedError = class extends
|
|
1120
|
+
var UserRejectedError = class extends require_InvalidParamError.BaseError {
|
|
1124
1121
|
constructor({ action }) {
|
|
1125
1122
|
super({
|
|
1126
1123
|
cause: null,
|
|
@@ -1134,7 +1131,7 @@ var UserRejectedError = class extends require_constants.BaseError {
|
|
|
1134
1131
|
|
|
1135
1132
|
//#endregion
|
|
1136
1133
|
//#region src/errors/WalletAccountAlreadyVerifiedError.ts
|
|
1137
|
-
var WalletAccountAlreadyVerifiedError = class extends
|
|
1134
|
+
var WalletAccountAlreadyVerifiedError = class extends require_InvalidParamError.BaseError {
|
|
1138
1135
|
constructor(address) {
|
|
1139
1136
|
super({
|
|
1140
1137
|
cause: null,
|
|
@@ -1148,7 +1145,7 @@ var WalletAccountAlreadyVerifiedError = class extends require_constants.BaseErro
|
|
|
1148
1145
|
|
|
1149
1146
|
//#endregion
|
|
1150
1147
|
//#region src/errors/WalletAccountNotSelectedError.ts
|
|
1151
|
-
var WalletAccountNotSelectedError = class extends
|
|
1148
|
+
var WalletAccountNotSelectedError = class extends require_InvalidParamError.BaseError {
|
|
1152
1149
|
expectedAddress;
|
|
1153
1150
|
selectedAddress;
|
|
1154
1151
|
constructor(params) {
|
|
@@ -1167,7 +1164,7 @@ var WalletAccountNotSelectedError = class extends require_constants.BaseError {
|
|
|
1167
1164
|
|
|
1168
1165
|
//#endregion
|
|
1169
1166
|
//#region src/errors/WalletProviderMethodUnavailableError.ts
|
|
1170
|
-
var WalletProviderMethodUnavailableError = class extends
|
|
1167
|
+
var WalletProviderMethodUnavailableError = class extends require_InvalidParamError.BaseError {
|
|
1171
1168
|
constructor({ methodName, walletProviderKey }) {
|
|
1172
1169
|
super({
|
|
1173
1170
|
cause: null,
|
|
@@ -1191,9 +1188,9 @@ var WalletProviderMethodUnavailableError = class extends require_constants.BaseE
|
|
|
1191
1188
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1192
1189
|
* @returns A promise that resolves to the authentication response from the server.
|
|
1193
1190
|
*/
|
|
1194
|
-
const signInWithExternalJwt = async ({ externalJwt, sessionPublicKey } = {}, client =
|
|
1195
|
-
const core =
|
|
1196
|
-
const response = await
|
|
1191
|
+
const signInWithExternalJwt = async ({ externalJwt, sessionPublicKey } = {}, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1192
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1193
|
+
const response = await require_InvalidParamError.createApiClient({}, client).externalAuthSignin({
|
|
1197
1194
|
environmentId: core.environmentId,
|
|
1198
1195
|
externalAuthSigninRequest: {
|
|
1199
1196
|
jwt: externalJwt,
|
|
@@ -1204,6 +1201,47 @@ const signInWithExternalJwt = async ({ externalJwt, sessionPublicKey } = {}, cli
|
|
|
1204
1201
|
return response;
|
|
1205
1202
|
};
|
|
1206
1203
|
|
|
1204
|
+
//#endregion
|
|
1205
|
+
//#region src/modules/auth/getElevatedAccessToken/getElevatedAccessToken.ts
|
|
1206
|
+
/**
|
|
1207
|
+
* Gets an elevated access token by scope.
|
|
1208
|
+
*
|
|
1209
|
+
* This function retrieves an elevated access token that contains the specified scope.
|
|
1210
|
+
* Expired tokens are automatically filtered out.
|
|
1211
|
+
*
|
|
1212
|
+
* If the token has `singleUse: true`, it will be automatically
|
|
1213
|
+
* consumed (removed from state) after retrieval. Otherwise, it remains in state
|
|
1214
|
+
* for future use.
|
|
1215
|
+
*
|
|
1216
|
+
* @param params - The parameters object.
|
|
1217
|
+
* @param params.scope - The scope to match (e.g., 'wallet:export').
|
|
1218
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1219
|
+
* @returns The elevated access token if found and not expired, or undefined if not found or expired.
|
|
1220
|
+
*
|
|
1221
|
+
* @example
|
|
1222
|
+
* ```typescript
|
|
1223
|
+
* const token = getElevatedAccessToken({ scope: 'wallet:export' });
|
|
1224
|
+
* if (token) {
|
|
1225
|
+
* // Use the token
|
|
1226
|
+
* // Token is automatically consumed if singleUse: true
|
|
1227
|
+
* }
|
|
1228
|
+
* ```
|
|
1229
|
+
*/
|
|
1230
|
+
const getElevatedAccessToken = ({ scope }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1231
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1232
|
+
const now = /* @__PURE__ */ new Date();
|
|
1233
|
+
const elevatedAccessTokens = core.state.get().elevatedAccessTokens || [];
|
|
1234
|
+
const validTokens = elevatedAccessTokens.filter((token$1) => !token$1.expiresAt || token$1.expiresAt > now);
|
|
1235
|
+
if (validTokens.length !== elevatedAccessTokens.length) core.state.set({ elevatedAccessTokens: validTokens });
|
|
1236
|
+
const token = validTokens.find((token$1) => token$1.scopes.includes(scope));
|
|
1237
|
+
if (!token) return;
|
|
1238
|
+
if (token.singleUse) {
|
|
1239
|
+
const updatedTokens = validTokens.filter((t) => t !== token);
|
|
1240
|
+
core.state.set({ elevatedAccessTokens: updatedTokens });
|
|
1241
|
+
}
|
|
1242
|
+
return token.token;
|
|
1243
|
+
};
|
|
1244
|
+
|
|
1207
1245
|
//#endregion
|
|
1208
1246
|
//#region src/modules/auth/passkeys/deletePasskey/deletePasskey.ts
|
|
1209
1247
|
/**
|
|
@@ -1213,9 +1251,9 @@ const signInWithExternalJwt = async ({ externalJwt, sessionPublicKey } = {}, cli
|
|
|
1213
1251
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1214
1252
|
* @returns A promise that resolves when the passkey is successfully deleted.
|
|
1215
1253
|
*/
|
|
1216
|
-
const deletePasskey = async ({ passkeyId }, client =
|
|
1217
|
-
const core =
|
|
1218
|
-
await
|
|
1254
|
+
const deletePasskey = async ({ passkeyId }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1255
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1256
|
+
await require_InvalidParamError.createApiClient({ includeMfaToken: true }, client).deletePasskey({
|
|
1219
1257
|
deleteUserPasskeyRequest: { passkeyId },
|
|
1220
1258
|
environmentId: core.environmentId
|
|
1221
1259
|
});
|
|
@@ -1232,23 +1270,23 @@ const deletePasskey = async ({ passkeyId }, client = require_constants.getDefaul
|
|
|
1232
1270
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1233
1271
|
* @returns A promise that resolves to an array of the user's registered passkeys.
|
|
1234
1272
|
*/
|
|
1235
|
-
const getPasskeys = async (client =
|
|
1236
|
-
const core =
|
|
1237
|
-
return (await
|
|
1273
|
+
const getPasskeys = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
1274
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1275
|
+
return (await require_InvalidParamError.createApiClient({}, client).getUserPasskeys({ environmentId: core.environmentId })).passkeys;
|
|
1238
1276
|
};
|
|
1239
1277
|
|
|
1240
1278
|
//#endregion
|
|
1241
1279
|
//#region src/modules/auth/passkeys/getPasskeyRegistrationOptions/getPasskeyRegistrationOptions.ts
|
|
1242
1280
|
const getPasskeyRegistrationOptions = async (client) => {
|
|
1243
|
-
const core =
|
|
1244
|
-
return await
|
|
1281
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1282
|
+
return await require_InvalidParamError.createApiClient({}, client).getPasskeyRegistrationOptions({ environmentId: core.environmentId });
|
|
1245
1283
|
};
|
|
1246
1284
|
|
|
1247
1285
|
//#endregion
|
|
1248
1286
|
//#region src/modules/auth/passkeys/serverRegisterPasskey/serverRegisterPasskey.ts
|
|
1249
1287
|
const serverRegisterPasskey = async ({ registration, createMfaToken }, client) => {
|
|
1250
|
-
const core =
|
|
1251
|
-
return await
|
|
1288
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1289
|
+
return await require_InvalidParamError.createApiClient({}, client).registerPasskey({
|
|
1252
1290
|
environmentId: core.environmentId,
|
|
1253
1291
|
passkeyRegisterRequest: {
|
|
1254
1292
|
...registration,
|
|
@@ -1275,8 +1313,8 @@ const serverRegisterPasskey = async ({ registration, createMfaToken }, client) =
|
|
|
1275
1313
|
* @returns A promise that resolves to the registration response.
|
|
1276
1314
|
* @throws NoWebAuthNSupportError If WebAuthn is not supported by the browser.
|
|
1277
1315
|
*/
|
|
1278
|
-
const registerPasskey = async ({ createMfaToken } = {}, client =
|
|
1279
|
-
const core =
|
|
1316
|
+
const registerPasskey = async ({ createMfaToken } = {}, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1317
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1280
1318
|
if (!core.passkey.isSupported()) throw new NoWebAuthNSupportError();
|
|
1281
1319
|
const options = await getPasskeyRegistrationOptions(client);
|
|
1282
1320
|
const response = await serverRegisterPasskey({
|
|
@@ -1290,8 +1328,8 @@ const registerPasskey = async ({ createMfaToken } = {}, client = require_constan
|
|
|
1290
1328
|
//#endregion
|
|
1291
1329
|
//#region src/modules/auth/passkeys/getPasskeyAuthenticationSignInOptions/getPasskeyAuthenticationSignInOptions.ts
|
|
1292
1330
|
const getPasskeyAuthenticationSignInOptions = async ({ relatedOriginRpId } = {}, client) => {
|
|
1293
|
-
const core =
|
|
1294
|
-
return await
|
|
1331
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1332
|
+
return await require_InvalidParamError.createApiClient({}, client).getPasskeyAuthenticationSigninOptions({
|
|
1295
1333
|
environmentId: core.environmentId,
|
|
1296
1334
|
relatedOriginRpId
|
|
1297
1335
|
});
|
|
@@ -1300,8 +1338,8 @@ const getPasskeyAuthenticationSignInOptions = async ({ relatedOriginRpId } = {},
|
|
|
1300
1338
|
//#endregion
|
|
1301
1339
|
//#region src/modules/auth/passkeys/serverSigninPasskey/serverSigninPasskey.ts
|
|
1302
1340
|
const serverSigninPasskey = async ({ authentication, createMfaToken }, client) => {
|
|
1303
|
-
const core =
|
|
1304
|
-
return await
|
|
1341
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1342
|
+
return await require_InvalidParamError.createApiClient({}, client).signinWithPasskey({
|
|
1305
1343
|
environmentId: core.environmentId,
|
|
1306
1344
|
passkeyAuthRequest: {
|
|
1307
1345
|
...authentication,
|
|
@@ -1327,8 +1365,8 @@ const serverSigninPasskey = async ({ authentication, createMfaToken }, client) =
|
|
|
1327
1365
|
* @returns A promise that resolves to the authentication response.
|
|
1328
1366
|
* @throws NoWebAuthNSupportError If WebAuthn is not supported by the browser.
|
|
1329
1367
|
*/
|
|
1330
|
-
const signInWithPasskey = async ({ relatedOriginRpId } = {}, client =
|
|
1331
|
-
const core =
|
|
1368
|
+
const signInWithPasskey = async ({ relatedOriginRpId } = {}, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1369
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1332
1370
|
if (!core.passkey.isSupported()) throw new NoWebAuthNSupportError();
|
|
1333
1371
|
const formattedOptions = { ...await getPasskeyAuthenticationSignInOptions({ relatedOriginRpId }, client) };
|
|
1334
1372
|
const response = await serverSigninPasskey({ authentication: await core.passkey.authenticate({ optionsJSON: formattedOptions }) }, client);
|
|
@@ -1344,9 +1382,9 @@ const signInWithPasskey = async ({ relatedOriginRpId } = {}, client = require_co
|
|
|
1344
1382
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1345
1383
|
* @returns An array of `SocialAccount` objects associated with the user.
|
|
1346
1384
|
*/
|
|
1347
|
-
const getUserSocialAccounts = (client =
|
|
1385
|
+
const getUserSocialAccounts = (client = require_InvalidParamError.getDefaultClient()) => {
|
|
1348
1386
|
const { user } = client;
|
|
1349
|
-
|
|
1387
|
+
require_InvalidParamError.assertDefined(user, "User is not authenticated");
|
|
1350
1388
|
return (user.verifiedCredentials.filter((credential) => credential.format === _dynamic_labs_sdk_api_core.JwtVerifiedCredentialFormatEnum.Oauth) ?? []).map((credential) => ({
|
|
1351
1389
|
accountId: credential.oauthAccountId ?? void 0,
|
|
1352
1390
|
displayName: credential.oauthDisplayName ?? void 0,
|
|
@@ -1406,9 +1444,9 @@ const APPLE_RESPONSE_MODE = "form_post";
|
|
|
1406
1444
|
const APPLE_RESPONSE_TYPE = "code id_token";
|
|
1407
1445
|
/** Helper function to add OAuth URL parameters to a given base URL. */
|
|
1408
1446
|
const addOAuthUrlParams = (provider, baseUrl, options = {}) => {
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1447
|
+
require_InvalidParamError.assertDefined(provider.clientId, "Client ID not found");
|
|
1448
|
+
require_InvalidParamError.assertDefined(provider.provider, "Provider type not found");
|
|
1449
|
+
require_InvalidParamError.assertDefined(provider.redirectUrl, "Redirect URL not found");
|
|
1412
1450
|
const providerType = provider.provider;
|
|
1413
1451
|
baseUrl.searchParams.set("client_id", provider.clientId);
|
|
1414
1452
|
baseUrl.searchParams.set("response_type", "code");
|
|
@@ -1433,15 +1471,15 @@ const addOAuthUrlParams = (provider, baseUrl, options = {}) => {
|
|
|
1433
1471
|
//#region src/modules/auth/social/oauth/authenticateWithSocial/buildOAuthUrl/getOAuthBaseUrl/getOAuthBaseUrl.ts
|
|
1434
1472
|
/** Helper function to build the OAuth base URL for a given provider. */
|
|
1435
1473
|
const getOAuthBaseUrl = (provider) => {
|
|
1436
|
-
|
|
1474
|
+
require_InvalidParamError.assertDefined(provider.provider, "Provider type not found");
|
|
1437
1475
|
const providerType = provider.provider;
|
|
1438
1476
|
if (providerType === _dynamic_labs_sdk_api_core.ProviderEnum.Telegram) {
|
|
1439
|
-
|
|
1477
|
+
require_InvalidParamError.assertDefined(provider.authorizationUrl, "Telegram authorization URL not found");
|
|
1440
1478
|
return new URL(provider.authorizationUrl);
|
|
1441
1479
|
}
|
|
1442
|
-
|
|
1480
|
+
require_InvalidParamError.assertDefined(provider.baseAuthUrl, "Base auth URL not found");
|
|
1443
1481
|
if (providerType === _dynamic_labs_sdk_api_core.ProviderEnum.Shopify) {
|
|
1444
|
-
|
|
1482
|
+
require_InvalidParamError.assertDefined(provider.shopifyStore, "Shopify store value not found in provider");
|
|
1445
1483
|
const loginBaseUrl = provider.baseAuthUrl.replace("{{shopifyStore}}", provider.shopifyStore);
|
|
1446
1484
|
return new URL(loginBaseUrl);
|
|
1447
1485
|
}
|
|
@@ -1454,15 +1492,15 @@ const providersRequiringPkce = ["twitter", "github"];
|
|
|
1454
1492
|
/** Helper function to build the OAuth URL for a given provider. */
|
|
1455
1493
|
const buildOAuthUrl = async (core, provider) => {
|
|
1456
1494
|
const { projectSettings } = core.state.get();
|
|
1457
|
-
|
|
1458
|
-
|
|
1495
|
+
require_InvalidParamError.assertDefined(projectSettings, "Project settings not found");
|
|
1496
|
+
require_InvalidParamError.assertDefined(projectSettings.providers, "Project providers not found");
|
|
1459
1497
|
const socialProvider = projectSettings.providers.find((p) => p.provider === provider);
|
|
1460
|
-
|
|
1498
|
+
require_InvalidParamError.assertDefined(socialProvider, `Social provider ${provider} not supported`);
|
|
1461
1499
|
const isGoogleDriveBackupEnabled = projectSettings.sdk.waas?.backupOptions?.includes(_dynamic_labs_sdk_api_core.WaasBackupOptionsEnum.GoogleDrive);
|
|
1462
1500
|
const socialProviderUrl = addOAuthUrlParams(socialProvider, getOAuthBaseUrl(socialProvider), { isGoogleDriveBackupEnabled });
|
|
1463
1501
|
const usingPkce = providersRequiringPkce.includes(provider);
|
|
1464
|
-
const state =
|
|
1465
|
-
const codeVerifier =
|
|
1502
|
+
const state = require_InvalidParamError.randomString(32);
|
|
1503
|
+
const codeVerifier = require_InvalidParamError.randomString(43);
|
|
1466
1504
|
socialProviderUrl.searchParams.set("state", state);
|
|
1467
1505
|
socialProviderUrl.searchParams.set("response_type", "code");
|
|
1468
1506
|
if (usingPkce) {
|
|
@@ -1492,9 +1530,9 @@ const buildOAuthUrl = async (core, provider) => {
|
|
|
1492
1530
|
* @param params.redirectUrl - The URL to redirect back to after authentication.
|
|
1493
1531
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1494
1532
|
*/
|
|
1495
|
-
const authenticateWithSocial = async ({ provider, redirectUrl }, client =
|
|
1496
|
-
const core =
|
|
1497
|
-
const apiClient =
|
|
1533
|
+
const authenticateWithSocial = async ({ provider, redirectUrl }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1534
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1535
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
1498
1536
|
await core.initTrack.waitForAll();
|
|
1499
1537
|
const providerType = provider;
|
|
1500
1538
|
const { url, state, codeVerifier } = await buildOAuthUrl(core, providerType);
|
|
@@ -1528,9 +1566,9 @@ const authenticateWithSocial = async ({ provider, redirectUrl }, client = requir
|
|
|
1528
1566
|
* @throws MissingSocialUrlParamError If required OAuth parameters are missing.
|
|
1529
1567
|
* @throws InvalidRedirectStorageStateError If the stored state doesn't match.
|
|
1530
1568
|
*/
|
|
1531
|
-
const completeSocialAuthentication = async ({ url }, client =
|
|
1532
|
-
const core =
|
|
1533
|
-
const apiClient =
|
|
1569
|
+
const completeSocialAuthentication = async ({ url }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1570
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1571
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
1534
1572
|
await core.initTrack.waitForAll();
|
|
1535
1573
|
const dynamicOauthState = url.searchParams.get("dynamicOauthState");
|
|
1536
1574
|
const dynamicOauthCode = url.searchParams.get("dynamicOauthCode");
|
|
@@ -1577,8 +1615,8 @@ const completeSocialAuthentication = async ({ url }, client = require_constants.
|
|
|
1577
1615
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1578
1616
|
* @returns A promise that resolves to true if the URL is an OAuth redirect, false otherwise.
|
|
1579
1617
|
*/
|
|
1580
|
-
const detectOAuthRedirect = async ({ url }, client =
|
|
1581
|
-
const core =
|
|
1618
|
+
const detectOAuthRedirect = async ({ url }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1619
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1582
1620
|
const dynamicOauthState = url.searchParams.get("dynamicOauthState");
|
|
1583
1621
|
const dynamicOauthCode = url.searchParams.get("dynamicOauthCode");
|
|
1584
1622
|
if (!dynamicOauthState || !dynamicOauthCode) return false;
|
|
@@ -1596,7 +1634,7 @@ const detectOAuthRedirect = async ({ url }, client = require_constants.getDefaul
|
|
|
1596
1634
|
* This information is stored in both unverified and verified wallet accounts.
|
|
1597
1635
|
* This function consolidates this information to determine which wallet was most recently selected.
|
|
1598
1636
|
*/
|
|
1599
|
-
const getPrimaryWalletAccount = (client =
|
|
1637
|
+
const getPrimaryWalletAccount = (client = require_InvalidParamError.getDefaultClient()) => {
|
|
1600
1638
|
const sortedLastSelectedWalletAccounts = require_getVerifiedCredentialForWalletAccount.getWalletAccounts(client).filter((walletAccount) => Boolean(walletAccount.lastSelectedAt)).sort((a, b) => b.lastSelectedAt.getTime() - a.lastSelectedAt.getTime());
|
|
1601
1639
|
if (sortedLastSelectedWalletAccounts.length === 0) return null;
|
|
1602
1640
|
const [primaryWalletAccount] = sortedLastSelectedWalletAccounts;
|
|
@@ -1612,9 +1650,9 @@ const getPrimaryWalletAccount = (client = require_constants.getDefaultClient())
|
|
|
1612
1650
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1613
1651
|
* @returns A promise that resolves to the verify response.
|
|
1614
1652
|
*/
|
|
1615
|
-
const unlinkSocialAccount = async ({ verifiedCredentialId }, client =
|
|
1616
|
-
const core =
|
|
1617
|
-
const apiClient =
|
|
1653
|
+
const unlinkSocialAccount = async ({ verifiedCredentialId }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1654
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1655
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
1618
1656
|
const walletId = getPrimaryWalletAccount(client)?.verifiedCredentialId?.replace("-zerodev", "");
|
|
1619
1657
|
const response = await apiClient.verifyUnlink({
|
|
1620
1658
|
environmentId: core.environmentId,
|
|
@@ -1639,16 +1677,16 @@ const unlinkSocialAccount = async ({ verifiedCredentialId }, client = require_co
|
|
|
1639
1677
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1640
1678
|
* @returns A promise that resolves to the chain balances across multiple networks.
|
|
1641
1679
|
*/
|
|
1642
|
-
const getMultichainBalances = async ({ balanceRequest }, client =
|
|
1643
|
-
const core =
|
|
1644
|
-
return (await
|
|
1680
|
+
const getMultichainBalances = async ({ balanceRequest }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1681
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1682
|
+
return (await require_InvalidParamError.createApiClient({}, client).postMultichainAccountBalances({
|
|
1645
1683
|
environmentId: core.environmentId,
|
|
1646
1684
|
multichainAccountBalancesRequest: balanceRequest
|
|
1647
1685
|
})).chainBalances;
|
|
1648
1686
|
};
|
|
1649
1687
|
|
|
1650
1688
|
//#endregion
|
|
1651
|
-
//#region src/modules/deviceRegistration/
|
|
1689
|
+
//#region src/modules/deviceRegistration/getDeviceRegistrationTokenFromUrl/getDeviceRegistrationTokenFromUrl.ts
|
|
1652
1690
|
/**
|
|
1653
1691
|
* Safely extracts the device token from a device registration redirect URL.
|
|
1654
1692
|
*
|
|
@@ -1658,18 +1696,16 @@ const getMultichainBalances = async ({ balanceRequest }, client = require_consta
|
|
|
1658
1696
|
* @returns The device token as a string if valid.
|
|
1659
1697
|
* @throws InvalidDeviceRegistrationRedirectError If the URL is not a valid device registration redirect.
|
|
1660
1698
|
*/
|
|
1661
|
-
const
|
|
1699
|
+
const getDeviceRegistrationTokenFromUrl = ({ url }) => {
|
|
1662
1700
|
let urlObject;
|
|
1663
1701
|
try {
|
|
1664
1702
|
urlObject = new URL(url);
|
|
1665
1703
|
} catch {
|
|
1666
1704
|
throw new InvalidDeviceRegistrationRedirectError();
|
|
1667
1705
|
}
|
|
1668
|
-
const
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
if (!deviceToken || deviceToken.trim() === "") throw new InvalidDeviceRegistrationRedirectError();
|
|
1672
|
-
return deviceToken;
|
|
1706
|
+
const deviceRegistrationToken = urlObject.searchParams.get("deviceRegistrationToken");
|
|
1707
|
+
if (!deviceRegistrationToken || deviceRegistrationToken.trim() === "") throw new InvalidDeviceRegistrationRedirectError();
|
|
1708
|
+
return deviceRegistrationToken;
|
|
1673
1709
|
};
|
|
1674
1710
|
|
|
1675
1711
|
//#endregion
|
|
@@ -1677,14 +1713,14 @@ const getDeviceTokenFromUrl = ({ url }) => {
|
|
|
1677
1713
|
/**
|
|
1678
1714
|
* Detects if the current URL is a device registration redirect.
|
|
1679
1715
|
*
|
|
1680
|
-
* This function uses
|
|
1716
|
+
* This function uses getDeviceRegistrationTokenFromUrl to validate the URL and determine
|
|
1681
1717
|
* if it contains device registration redirect data from a device authentication flow.
|
|
1682
1718
|
*
|
|
1683
1719
|
* @returns True if the URL is a device registration redirect, false otherwise.
|
|
1684
1720
|
*/
|
|
1685
1721
|
const detectDeviceRegistrationRedirect = ({ url }) => {
|
|
1686
1722
|
try {
|
|
1687
|
-
|
|
1723
|
+
getDeviceRegistrationTokenFromUrl({ url });
|
|
1688
1724
|
return true;
|
|
1689
1725
|
} catch {
|
|
1690
1726
|
return false;
|
|
@@ -1701,10 +1737,10 @@ const detectDeviceRegistrationRedirect = ({ url }) => {
|
|
|
1701
1737
|
*
|
|
1702
1738
|
* @returns True if device registration is required, false otherwise.
|
|
1703
1739
|
*/
|
|
1704
|
-
const isDeviceRegistrationRequired = (client =
|
|
1740
|
+
const isDeviceRegistrationRequired = (client = require_InvalidParamError.getDefaultClient()) => {
|
|
1705
1741
|
const user = client.user;
|
|
1706
|
-
|
|
1707
|
-
return Boolean(user.scope?.includes("
|
|
1742
|
+
require_InvalidParamError.assertDefined(user, "User not logged in");
|
|
1743
|
+
return Boolean(user.scope?.includes("device:registration"));
|
|
1708
1744
|
};
|
|
1709
1745
|
|
|
1710
1746
|
//#endregion
|
|
@@ -1718,9 +1754,9 @@ const isDeviceRegistrationRequired = (client = require_constants.getDefaultClien
|
|
|
1718
1754
|
* @throws {ValueMustBeDefinedError} If the window is not available.
|
|
1719
1755
|
* @docs https://docs.cdp.coinbase.com/onramp-&-offramp/onramp-apis/apple-pay-onramp-api#events-names
|
|
1720
1756
|
*/
|
|
1721
|
-
const addCoinbaseOnrampOrderEventListener = ({ listener }, client =
|
|
1722
|
-
const core =
|
|
1723
|
-
if (typeof window === "undefined") throw new
|
|
1757
|
+
const addCoinbaseOnrampOrderEventListener = ({ listener }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1758
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1759
|
+
if (typeof window === "undefined") throw new require_InvalidParamError.ValueMustBeDefinedError("Window is not available to listen for Coinbase onramp order events");
|
|
1724
1760
|
const handleMessageEvent = (event) => {
|
|
1725
1761
|
if (event.origin !== "https://pay.coinbase.com") return;
|
|
1726
1762
|
core.logger.debug("[addCoinbaseOnrampOrderEventListener] pay.coinbase.com event received", { event });
|
|
@@ -1758,10 +1794,10 @@ const addCoinbaseOnrampOrderEventListener = ({ listener }, client = require_cons
|
|
|
1758
1794
|
* @throws {InvalidParamError} - If the payment method is not valid
|
|
1759
1795
|
* @throws {ValueMustBeDefinedError} - If the user is not authenticated
|
|
1760
1796
|
*/
|
|
1761
|
-
const getMissingVerificationForCoinbaseOnrampOrder = ({ paymentMethod }, client =
|
|
1797
|
+
const getMissingVerificationForCoinbaseOnrampOrder = ({ paymentMethod }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1762
1798
|
if (paymentMethod !== "GUEST_CHECKOUT_APPLE_PAY") throw new require_InvalidParamError.InvalidParamError(`Invalid payment method: ${paymentMethod}`);
|
|
1763
1799
|
const { user } = client;
|
|
1764
|
-
|
|
1800
|
+
require_InvalidParamError.assertDefined(user, "User is not authenticated");
|
|
1765
1801
|
const fieldsMissingVerification = [];
|
|
1766
1802
|
const emailVerifiedCredential = user.verifiedCredentials.find((credential) => credential.format === _dynamic_labs_sdk_api_core.JwtVerifiedCredentialFormatEnum.Email);
|
|
1767
1803
|
if (!user.email) fieldsMissingVerification.push({
|
|
@@ -1796,7 +1832,7 @@ const getMissingVerificationForCoinbaseOnrampOrder = ({ paymentMethod }, client
|
|
|
1796
1832
|
//#region src/modules/funding/coinbase/utils/validateUserCredentialsForCoinbaseOnrampOrder/validateUserCredentialsForCoinbaseOnrampOrder.ts
|
|
1797
1833
|
const validateUserCredentialsForCoinbaseOnrampOrder = (client) => {
|
|
1798
1834
|
const { user } = client;
|
|
1799
|
-
|
|
1835
|
+
require_InvalidParamError.assertDefined(user, "User is not authenticated");
|
|
1800
1836
|
const fieldsMissingVerification = getMissingVerificationForCoinbaseOnrampOrder({ paymentMethod: "GUEST_CHECKOUT_APPLE_PAY" }, client);
|
|
1801
1837
|
if (fieldsMissingVerification.find((field) => field.field === "email")) throw new MissingUserVerificationError({
|
|
1802
1838
|
informationToVerify: "email",
|
|
@@ -1824,10 +1860,10 @@ const validateUserCredentialsForCoinbaseOnrampOrder = (client) => {
|
|
|
1824
1860
|
* @returns The created order
|
|
1825
1861
|
* @throws {MissingUserVerificationError} If the user is missing verification for email or phone
|
|
1826
1862
|
*/
|
|
1827
|
-
const createCoinbaseOnrampOrder = async (orderParams, client =
|
|
1863
|
+
const createCoinbaseOnrampOrder = async (orderParams, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1828
1864
|
const user = validateUserCredentialsForCoinbaseOnrampOrder(client);
|
|
1829
|
-
const core =
|
|
1830
|
-
const apiClient =
|
|
1865
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1866
|
+
const apiClient = require_InvalidParamError.createApiClient({ includeMfaToken: true }, client);
|
|
1831
1867
|
const { isSandbox, ...restOrderParams } = orderParams;
|
|
1832
1868
|
const orderResponse = await apiClient.createCoinbaseOnrampOrder({
|
|
1833
1869
|
coinbaseOnrampOrderCreateRequest: {
|
|
@@ -1856,9 +1892,9 @@ const createCoinbaseOnrampOrder = async (orderParams, client = require_constants
|
|
|
1856
1892
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1857
1893
|
* @returns an object containing the buy URL
|
|
1858
1894
|
*/
|
|
1859
|
-
const getCoinbaseBuyUrl = async (buyUrlParams, client =
|
|
1860
|
-
const core =
|
|
1861
|
-
return await
|
|
1895
|
+
const getCoinbaseBuyUrl = async (buyUrlParams, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1896
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1897
|
+
return await require_InvalidParamError.createApiClient({ includeMfaToken: true }, client).generateCoinbaseOnrampBuyUrl({
|
|
1862
1898
|
coinbaseOnrampGetBuyUrlRequest: buyUrlParams,
|
|
1863
1899
|
environmentId: core.environmentId
|
|
1864
1900
|
});
|
|
@@ -1873,9 +1909,9 @@ const getCoinbaseBuyUrl = async (buyUrlParams, client = require_constants.getDef
|
|
|
1873
1909
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1874
1910
|
* @returns The created payment
|
|
1875
1911
|
*/
|
|
1876
|
-
const createCryptoDotComPayment = async (paymentParams, client =
|
|
1877
|
-
const core =
|
|
1878
|
-
return await
|
|
1912
|
+
const createCryptoDotComPayment = async (paymentParams, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1913
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1914
|
+
return await require_InvalidParamError.createApiClient({ includeMfaToken: true }, client).createCryptoDotComPayment({
|
|
1879
1915
|
cryptoDotComPaymentCreateRequest: {
|
|
1880
1916
|
...paymentParams,
|
|
1881
1917
|
chain: paymentParams.chain
|
|
@@ -1893,9 +1929,9 @@ const createCryptoDotComPayment = async (paymentParams, client = require_constan
|
|
|
1893
1929
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1894
1930
|
* @returns The created transfer
|
|
1895
1931
|
*/
|
|
1896
|
-
const createKrakenExchangeTransfer = async (transferParams, client =
|
|
1897
|
-
const core =
|
|
1898
|
-
const apiClient =
|
|
1932
|
+
const createKrakenExchangeTransfer = async (transferParams, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1933
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1934
|
+
const apiClient = require_InvalidParamError.createApiClient({ includeMfaToken: true }, client);
|
|
1899
1935
|
const { accountId, ...createExchangeTransferRequest } = transferParams;
|
|
1900
1936
|
return await apiClient.postExchangeAccountTransfer({
|
|
1901
1937
|
accountId,
|
|
@@ -1914,9 +1950,9 @@ const createKrakenExchangeTransfer = async (transferParams, client = require_con
|
|
|
1914
1950
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1915
1951
|
* @returns Array of Kraken accounts with balances
|
|
1916
1952
|
*/
|
|
1917
|
-
const getKrakenAccounts = async (params, client =
|
|
1918
|
-
const core =
|
|
1919
|
-
return await
|
|
1953
|
+
const getKrakenAccounts = async (params, client = require_InvalidParamError.getDefaultClient()) => {
|
|
1954
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1955
|
+
return await require_InvalidParamError.createApiClient({ includeMfaToken: true }, client).getUserAccounts({
|
|
1920
1956
|
chainName: params?.chainName,
|
|
1921
1957
|
environmentId: core.environmentId,
|
|
1922
1958
|
exchangeKey: _dynamic_labs_sdk_api_core.ExchangeKeyEnum.Kraken,
|
|
@@ -1932,9 +1968,9 @@ const getKrakenAccounts = async (params, client = require_constants.getDefaultCl
|
|
|
1932
1968
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1933
1969
|
* @returns Transfer destinations response with whitelisted addresses
|
|
1934
1970
|
*/
|
|
1935
|
-
const getKrakenWhitelistedAddresses = async (client =
|
|
1936
|
-
const core =
|
|
1937
|
-
return await
|
|
1971
|
+
const getKrakenWhitelistedAddresses = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
1972
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1973
|
+
return await require_InvalidParamError.createApiClient({ includeMfaToken: true }, client).getExchangeTransferDestinations({
|
|
1938
1974
|
environmentId: core.environmentId,
|
|
1939
1975
|
exchangeKey: _dynamic_labs_sdk_api_core.ExchangeKeyEnum.Kraken
|
|
1940
1976
|
});
|
|
@@ -1948,8 +1984,8 @@ const getKrakenWhitelistedAddresses = async (client = require_constants.getDefau
|
|
|
1948
1984
|
*
|
|
1949
1985
|
* @returns a promise that resolves once the client is fully initialized.
|
|
1950
1986
|
*/
|
|
1951
|
-
const waitForClientInitialized = async (client =
|
|
1952
|
-
await
|
|
1987
|
+
const waitForClientInitialized = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
1988
|
+
await require_InvalidParamError.getCore(client).initTrack.waitForAll();
|
|
1953
1989
|
};
|
|
1954
1990
|
|
|
1955
1991
|
//#endregion
|
|
@@ -1991,10 +2027,10 @@ const FETCH_TIMEOUT_MS = 3e4;
|
|
|
1991
2027
|
const fetchWithTimeout = async (client) => {
|
|
1992
2028
|
const controller = new AbortController();
|
|
1993
2029
|
const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
1994
|
-
const core =
|
|
2030
|
+
const core = require_InvalidParamError.getCore(client);
|
|
1995
2031
|
try {
|
|
1996
2032
|
const response = await core.fetch(getWalletBookCdnUrl(), { signal: controller.signal });
|
|
1997
|
-
if (!response.ok) throw new
|
|
2033
|
+
if (!response.ok) throw new require_InvalidParamError.APIError(`Failed to fetch wallet book: ${response.status} ${response.statusText}`, "wallet_book_fetch_error", response.status);
|
|
1998
2034
|
return await response.json();
|
|
1999
2035
|
} finally {
|
|
2000
2036
|
clearTimeout(timeoutId);
|
|
@@ -2036,7 +2072,7 @@ const RETRY_DELAY_MS = 100;
|
|
|
2036
2072
|
* @throws If both CDN fetch and cache retrieval fail.
|
|
2037
2073
|
*/
|
|
2038
2074
|
const fetchLegacyWalletBook = async (client) => {
|
|
2039
|
-
const core =
|
|
2075
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2040
2076
|
core.logger.debug("[fetchLegacyWalletBook] Fetching wallet book...");
|
|
2041
2077
|
try {
|
|
2042
2078
|
const walletBook = await retryOnFail({
|
|
@@ -2102,7 +2138,7 @@ const shouldFilterWallet = (walletKey, wallet) => {
|
|
|
2102
2138
|
* @param params.spriteId - The sprite identifier from the wallet book.
|
|
2103
2139
|
* @returns The full URL to the sprite icon
|
|
2104
2140
|
*/
|
|
2105
|
-
const getSpriteUrl = ({ spriteId }) => `${
|
|
2141
|
+
const getSpriteUrl = ({ spriteId }) => `${require_InvalidParamError.DYNAMIC_ICONIC_SPRITE_URL}#${spriteId}`;
|
|
2106
2142
|
|
|
2107
2143
|
//#endregion
|
|
2108
2144
|
//#region src/modules/legacyWalletBook/getWalletConnectCatalog/transformGroup/transformGroup.ts
|
|
@@ -2243,7 +2279,7 @@ const getChainFromWalletSchema = ({ wallet, walletKey }) => {
|
|
|
2243
2279
|
const firstChain = wallet.chains[0];
|
|
2244
2280
|
const chainPrefix = extractChainPrefix({ chainIdentifier: firstChain });
|
|
2245
2281
|
try {
|
|
2246
|
-
return
|
|
2282
|
+
return require_InvalidParamError.getChainFromVerifiedCredentialChain(chainPrefix);
|
|
2247
2283
|
} catch {}
|
|
2248
2284
|
}
|
|
2249
2285
|
if (walletKey) {
|
|
@@ -2317,7 +2353,7 @@ const transformWalletBook = ({ walletBook }) => {
|
|
|
2317
2353
|
* @returns A promise that resolves to the WalletConnect catalog containing groups and wallets.
|
|
2318
2354
|
* @throws If unable to fetch the wallet book from the API (when both CDN fetch and cache retrieval fail).
|
|
2319
2355
|
*/
|
|
2320
|
-
const getWalletConnectCatalog = async (client =
|
|
2356
|
+
const getWalletConnectCatalog = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
2321
2357
|
return transformWalletBook({ walletBook: await fetchLegacyWalletBook(client) });
|
|
2322
2358
|
};
|
|
2323
2359
|
|
|
@@ -2332,7 +2368,7 @@ const getWalletConnectCatalog = async (client = require_constants.getDefaultClie
|
|
|
2332
2368
|
*/
|
|
2333
2369
|
const extractChainFromNormalizedName = ({ normalizedWalletNameWithChain }) => {
|
|
2334
2370
|
const lowerName = normalizedWalletNameWithChain.toLowerCase();
|
|
2335
|
-
const chainSuffixes = Object.keys(
|
|
2371
|
+
const chainSuffixes = Object.keys(require_InvalidParamError.CHAINS_INFO_MAP).map((chain) => chain.toLowerCase()).sort((a, b) => b.length - a.length);
|
|
2336
2372
|
for (const suffix of chainSuffixes) if (lowerName.endsWith(suffix)) return suffix.toUpperCase();
|
|
2337
2373
|
};
|
|
2338
2374
|
|
|
@@ -2349,7 +2385,7 @@ const extractChainFromNormalizedName = ({ normalizedWalletNameWithChain }) => {
|
|
|
2349
2385
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2350
2386
|
* @returns A promise that resolves to the WalletConnect catalog wallet entry, or undefined if not found.
|
|
2351
2387
|
*/
|
|
2352
|
-
const getWalletConnectCatalogWalletByWalletProviderKey = async ({ walletProviderKey }, client =
|
|
2388
|
+
const getWalletConnectCatalogWalletByWalletProviderKey = async ({ walletProviderKey }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2353
2389
|
const { normalizedWalletNameWithChain } = require_getVerifiedCredentialForWalletAccount.splitWalletProviderKey(walletProviderKey);
|
|
2354
2390
|
const chain = extractChainFromNormalizedName({ normalizedWalletNameWithChain });
|
|
2355
2391
|
if (!chain) return;
|
|
@@ -2378,9 +2414,9 @@ const getWalletConnectCatalogWalletByWalletProviderKey = async ({ walletProvider
|
|
|
2378
2414
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2379
2415
|
* @returns A promise that resolves to OTP verification details if verification is required, or undefined.
|
|
2380
2416
|
*/
|
|
2381
|
-
const updateUser = async ({ userFields }, client =
|
|
2382
|
-
const core =
|
|
2383
|
-
const response = await
|
|
2417
|
+
const updateUser = async ({ userFields }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2418
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2419
|
+
const response = await require_InvalidParamError.createApiClient({ includeMfaToken: true }, client).updateSelf({
|
|
2384
2420
|
environmentId: core.environmentId,
|
|
2385
2421
|
userFields
|
|
2386
2422
|
});
|
|
@@ -2408,7 +2444,7 @@ const updateUser = async ({ userFields }, client = require_constants.getDefaultC
|
|
|
2408
2444
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2409
2445
|
* @returns A promise that resolves when the acknowledgment is complete.
|
|
2410
2446
|
*/
|
|
2411
|
-
const acknowledgeRecoveryCodes = async (client =
|
|
2447
|
+
const acknowledgeRecoveryCodes = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
2412
2448
|
return updateUser({ userFields: { mfaBackupCodeAcknowledgement: _dynamic_labs_sdk_api_core.MfaBackupCodeAcknowledgement.Complete } }, client);
|
|
2413
2449
|
};
|
|
2414
2450
|
|
|
@@ -2424,9 +2460,9 @@ const acknowledgeRecoveryCodes = async (client = require_constants.getDefaultCli
|
|
|
2424
2460
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2425
2461
|
* @returns A promise that resolves to the MFA authentication response with token.
|
|
2426
2462
|
*/
|
|
2427
|
-
const authenticateMfaRecoveryCode = async ({ code, createMfaTokenOptions }, client =
|
|
2428
|
-
const core =
|
|
2429
|
-
const apiClient =
|
|
2463
|
+
const authenticateMfaRecoveryCode = async ({ code, createMfaTokenOptions }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2464
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2465
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
2430
2466
|
try {
|
|
2431
2467
|
const response = await apiClient.authMfaRecovery({
|
|
2432
2468
|
environmentId: core.environmentId,
|
|
@@ -2453,8 +2489,8 @@ const authenticateMfaRecoveryCode = async ({ code, createMfaTokenOptions }, clie
|
|
|
2453
2489
|
//#endregion
|
|
2454
2490
|
//#region src/modules/auth/passkeys/getPasskeyAuthenticationOptions/getPasskeyAuthenticationOptions.ts
|
|
2455
2491
|
const getPasskeyAuthenticationOptions = async ({ relatedOriginRpId } = {}, client) => {
|
|
2456
|
-
const core =
|
|
2457
|
-
return await
|
|
2492
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2493
|
+
return await require_InvalidParamError.createApiClient({}, client).getPasskeyAuthenticationOptions({
|
|
2458
2494
|
environmentId: core.environmentId,
|
|
2459
2495
|
relatedOriginRpId
|
|
2460
2496
|
});
|
|
@@ -2463,8 +2499,8 @@ const getPasskeyAuthenticationOptions = async ({ relatedOriginRpId } = {}, clien
|
|
|
2463
2499
|
//#endregion
|
|
2464
2500
|
//#region src/modules/auth/passkeys/serverAuthenticatePasskey/serverAuthenticatePasskey.ts
|
|
2465
2501
|
const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, client) => {
|
|
2466
|
-
const core =
|
|
2467
|
-
return await
|
|
2502
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2503
|
+
return await require_InvalidParamError.createApiClient({}, client).authenticateMfaPasskeyDevice({
|
|
2468
2504
|
environmentId: core.environmentId,
|
|
2469
2505
|
passkeyAuthRequest: {
|
|
2470
2506
|
...authentication,
|
|
@@ -2491,8 +2527,8 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
2491
2527
|
* @throws NoWebAuthNSupportError If WebAuthn is not supported by the browser.
|
|
2492
2528
|
* @throws NoPasskeyCredentialsFoundError If no passkey credentials are found.
|
|
2493
2529
|
*/
|
|
2494
|
-
const authenticatePasskeyMFA = async ({ createMfaToken, relatedOriginRpId } = {}, client =
|
|
2495
|
-
const core =
|
|
2530
|
+
const authenticatePasskeyMFA = async ({ createMfaToken, relatedOriginRpId } = {}, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2531
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2496
2532
|
try {
|
|
2497
2533
|
if (!core.passkey.isSupported()) throw new NoWebAuthNSupportError();
|
|
2498
2534
|
const options = await getPasskeyAuthenticationOptions({ relatedOriginRpId }, client);
|
|
@@ -2538,9 +2574,9 @@ const authenticatePasskeyMFA = async ({ createMfaToken, relatedOriginRpId } = {}
|
|
|
2538
2574
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2539
2575
|
* @returns A promise that resolves to the MFA authentication response.
|
|
2540
2576
|
*/
|
|
2541
|
-
const authenticateTotpMfaDevice = async ({ deviceId, code, createMfaTokenOptions }, client =
|
|
2542
|
-
const core =
|
|
2543
|
-
const apiClient =
|
|
2577
|
+
const authenticateTotpMfaDevice = async ({ deviceId, code, createMfaTokenOptions }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2578
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2579
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
2544
2580
|
try {
|
|
2545
2581
|
const response = await apiClient.authMfaTotpDevice({
|
|
2546
2582
|
environmentId: core.environmentId,
|
|
@@ -2582,9 +2618,9 @@ const authenticateTotpMfaDevice = async ({ deviceId, code, createMfaTokenOptions
|
|
|
2582
2618
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2583
2619
|
* @returns A promise that resolves to the newly generated recovery codes.
|
|
2584
2620
|
*/
|
|
2585
|
-
const createNewMfaRecoveryCodes = async (client =
|
|
2586
|
-
const core =
|
|
2587
|
-
return
|
|
2621
|
+
const createNewMfaRecoveryCodes = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
2622
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2623
|
+
return require_InvalidParamError.createApiClient({}, client).createNewRecoveryCodes({ environmentId: core.environmentId });
|
|
2588
2624
|
};
|
|
2589
2625
|
|
|
2590
2626
|
//#endregion
|
|
@@ -2600,11 +2636,11 @@ const createNewMfaRecoveryCodes = async (client = require_constants.getDefaultCl
|
|
|
2600
2636
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2601
2637
|
* @returns A promise that resolves when the MFA device is successfully deleted.
|
|
2602
2638
|
*/
|
|
2603
|
-
const deleteMfaDevice = async ({ deviceId, mfaAuthToken }, client =
|
|
2604
|
-
const core =
|
|
2605
|
-
const apiClient =
|
|
2606
|
-
|
|
2607
|
-
|
|
2639
|
+
const deleteMfaDevice = async ({ deviceId, mfaAuthToken }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2640
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2641
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
2642
|
+
require_InvalidParamError.assertDefined(deviceId, "deviceId is required");
|
|
2643
|
+
require_InvalidParamError.assertDefined(mfaAuthToken, "mfaAuthToken is required");
|
|
2608
2644
|
return apiClient.deleteMfaDevice({
|
|
2609
2645
|
environmentId: core.environmentId,
|
|
2610
2646
|
mfaDeviceId: deviceId,
|
|
@@ -2623,9 +2659,9 @@ const deleteMfaDevice = async ({ deviceId, mfaAuthToken }, client = require_cons
|
|
|
2623
2659
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2624
2660
|
* @returns A promise that resolves to an array of the user's registered MFA devices.
|
|
2625
2661
|
*/
|
|
2626
|
-
const getMfaDevices = async (client =
|
|
2627
|
-
const core =
|
|
2628
|
-
const { devices } = await
|
|
2662
|
+
const getMfaDevices = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
2663
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2664
|
+
const { devices } = await require_InvalidParamError.createApiClient({}, client).getUserMfaDevices({ environmentId: core.environmentId });
|
|
2629
2665
|
return devices;
|
|
2630
2666
|
};
|
|
2631
2667
|
|
|
@@ -2642,9 +2678,9 @@ const getMfaDevices = async (client = require_constants.getDefaultClient()) => {
|
|
|
2642
2678
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2643
2679
|
* @returns A promise that resolves to the user's MFA recovery codes.
|
|
2644
2680
|
*/
|
|
2645
|
-
const getMfaRecoveryCodes = async (client =
|
|
2646
|
-
const core =
|
|
2647
|
-
return
|
|
2681
|
+
const getMfaRecoveryCodes = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
2682
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2683
|
+
return require_InvalidParamError.createApiClient({}, client).getRecoveryCodes({ environmentId: core.environmentId });
|
|
2648
2684
|
};
|
|
2649
2685
|
|
|
2650
2686
|
//#endregion
|
|
@@ -2658,10 +2694,10 @@ const getMfaRecoveryCodes = async (client = require_constants.getDefaultClient()
|
|
|
2658
2694
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2659
2695
|
* @returns True if recovery codes are pending acknowledgment, false otherwise.
|
|
2660
2696
|
*/
|
|
2661
|
-
const isPendingRecoveryCodesAcknowledgment = (client =
|
|
2697
|
+
const isPendingRecoveryCodesAcknowledgment = (client = require_InvalidParamError.getDefaultClient()) => {
|
|
2662
2698
|
const user = client.user;
|
|
2663
|
-
|
|
2664
|
-
return user.mfaBackupCodeAcknowledgement
|
|
2699
|
+
require_InvalidParamError.assertDefined(user, "User not logged in");
|
|
2700
|
+
return user.mfaBackupCodeAcknowledgement === _dynamic_labs_sdk_api_core.MfaBackupCodeAcknowledgement.Pending;
|
|
2665
2701
|
};
|
|
2666
2702
|
|
|
2667
2703
|
//#endregion
|
|
@@ -2675,9 +2711,9 @@ const isPendingRecoveryCodesAcknowledgment = (client = require_constants.getDefa
|
|
|
2675
2711
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2676
2712
|
* @returns True if the user needs additional MFA authentication, false otherwise.
|
|
2677
2713
|
*/
|
|
2678
|
-
const isUserMissingMfaAuth = (client =
|
|
2714
|
+
const isUserMissingMfaAuth = (client = require_InvalidParamError.getDefaultClient()) => {
|
|
2679
2715
|
const user = client.user;
|
|
2680
|
-
|
|
2716
|
+
require_InvalidParamError.assertDefined(user, "User not logged in");
|
|
2681
2717
|
return Boolean(user.scope?.includes("requiresAdditionalAuth"));
|
|
2682
2718
|
};
|
|
2683
2719
|
|
|
@@ -2693,9 +2729,9 @@ const isUserMissingMfaAuth = (client = require_constants.getDefaultClient()) =>
|
|
|
2693
2729
|
* @returns A promise that resolves to the TOTP registration response containing setup information,
|
|
2694
2730
|
* like the secret key and the OTP Auth URI.
|
|
2695
2731
|
*/
|
|
2696
|
-
const registerTotpMfaDevice = async (client =
|
|
2697
|
-
const core =
|
|
2698
|
-
return
|
|
2732
|
+
const registerTotpMfaDevice = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
2733
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2734
|
+
return require_InvalidParamError.createApiClient({}, client).registerTotpMfaDevice({ environmentId: core.environmentId });
|
|
2699
2735
|
};
|
|
2700
2736
|
|
|
2701
2737
|
//#endregion
|
|
@@ -2710,10 +2746,10 @@ const registerTotpMfaDevice = async (client = require_constants.getDefaultClient
|
|
|
2710
2746
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2711
2747
|
* @returns A promise that resolves when the default MFA device is successfully set.
|
|
2712
2748
|
*/
|
|
2713
|
-
const setDefaultMfaDevice = async ({ deviceId }, client =
|
|
2714
|
-
const core =
|
|
2715
|
-
const apiClient =
|
|
2716
|
-
|
|
2749
|
+
const setDefaultMfaDevice = async ({ deviceId }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2750
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2751
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
2752
|
+
require_InvalidParamError.assertDefined(deviceId, "deviceId is required");
|
|
2717
2753
|
return apiClient.updateUserMfaDevice({
|
|
2718
2754
|
environmentId: core.environmentId,
|
|
2719
2755
|
mfaDeviceId: deviceId
|
|
@@ -2731,9 +2767,9 @@ const setDefaultMfaDevice = async ({ deviceId }, client = require_constants.getD
|
|
|
2731
2767
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2732
2768
|
* @returns A promise that resolves to an OTPVerification object containing the email and verification UUID.
|
|
2733
2769
|
*/
|
|
2734
|
-
const sendEmailOTP = async ({ email }, client =
|
|
2735
|
-
const core =
|
|
2736
|
-
const { verificationUUID } = await
|
|
2770
|
+
const sendEmailOTP = async ({ email }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2771
|
+
const core = require_InvalidParamError.getCore(client);
|
|
2772
|
+
const { verificationUUID } = await require_InvalidParamError.createApiClient({}, client).createEmailVerification({
|
|
2737
2773
|
emailVerificationCreateRequest: {
|
|
2738
2774
|
captchaToken: require_getNetworkProviderFromNetworkId.consumeCaptchaToken(client),
|
|
2739
2775
|
email
|
|
@@ -3677,9 +3713,9 @@ const supportedCountries = {
|
|
|
3677
3713
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3678
3714
|
* @returns A promise that resolves to an OTPVerification object containing the phone details and verification UUID.
|
|
3679
3715
|
*/
|
|
3680
|
-
const sendSmsOTP = async ({ isoCountryCode, phoneNumber }, client =
|
|
3681
|
-
const core =
|
|
3682
|
-
const apiClient =
|
|
3716
|
+
const sendSmsOTP = async ({ isoCountryCode, phoneNumber }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
3717
|
+
const core = require_InvalidParamError.getCore(client);
|
|
3718
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
3683
3719
|
const phoneCountryCode = supportedCountries[isoCountryCode].code;
|
|
3684
3720
|
const { verificationUUID } = await apiClient.createSmsVerification({
|
|
3685
3721
|
environmentId: core.environmentId,
|
|
@@ -3701,8 +3737,8 @@ const sendSmsOTP = async ({ isoCountryCode, phoneNumber }, client = require_cons
|
|
|
3701
3737
|
//#endregion
|
|
3702
3738
|
//#region src/modules/otp/verifyOTP/verifyOTPForUserSignIn/verifyOTPForUserSignIn.ts
|
|
3703
3739
|
const verifyOTPForUserSignIn = async ({ otpVerification, verificationToken }, client) => {
|
|
3704
|
-
const core =
|
|
3705
|
-
const apiClient =
|
|
3740
|
+
const core = require_InvalidParamError.getCore(client);
|
|
3741
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
3706
3742
|
const verifyRequest = {
|
|
3707
3743
|
verificationToken,
|
|
3708
3744
|
verificationUUID: otpVerification.verificationUUID
|
|
@@ -3720,8 +3756,8 @@ const verifyOTPForUserSignIn = async ({ otpVerification, verificationToken }, cl
|
|
|
3720
3756
|
//#endregion
|
|
3721
3757
|
//#region src/modules/otp/verifyOTP/verifyOTPForUserUpdate/verifyOTPForUserUpdate.ts
|
|
3722
3758
|
const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, client) => {
|
|
3723
|
-
const core =
|
|
3724
|
-
const apiClient =
|
|
3759
|
+
const core = require_InvalidParamError.getCore(client);
|
|
3760
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
3725
3761
|
const verifyRequest = {
|
|
3726
3762
|
verificationToken,
|
|
3727
3763
|
verificationUUID: otpVerification.verificationUUID
|
|
@@ -3749,7 +3785,7 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
|
|
|
3749
3785
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3750
3786
|
* @returns A promise that resolves to the verify response object upon successful verification.
|
|
3751
3787
|
*/
|
|
3752
|
-
const verifyOTP = async ({ otpVerification, verificationToken }, client =
|
|
3788
|
+
const verifyOTP = async ({ otpVerification, verificationToken }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
3753
3789
|
const response = await (client.user ? verifyOTPForUserUpdate : verifyOTPForUserSignIn)({
|
|
3754
3790
|
otpVerification,
|
|
3755
3791
|
verificationToken
|
|
@@ -3769,12 +3805,33 @@ const verifyOTP = async ({ otpVerification, verificationToken }, client = requir
|
|
|
3769
3805
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3770
3806
|
* @returns A promise that resolves when the user account is successfully deleted.
|
|
3771
3807
|
*/
|
|
3772
|
-
const deleteUser = async (client =
|
|
3773
|
-
const core =
|
|
3774
|
-
await
|
|
3808
|
+
const deleteUser = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
3809
|
+
const core = require_InvalidParamError.getCore(client);
|
|
3810
|
+
await require_InvalidParamError.createApiClient({ includeMfaToken: true }, client).hardDeleteUser({ environmentId: core.environmentId });
|
|
3775
3811
|
await logout(client);
|
|
3776
3812
|
};
|
|
3777
3813
|
|
|
3814
|
+
//#endregion
|
|
3815
|
+
//#region src/modules/user/isUserOnboardingComplete/isUserOnboardingComplete.ts
|
|
3816
|
+
/**
|
|
3817
|
+
* Checks if the user has completed all onboarding requirements.
|
|
3818
|
+
*
|
|
3819
|
+
* This function verifies whether a user has fulfilled all necessary requirements
|
|
3820
|
+
* including KYC fields (Know Your Customer information) and MFA setup
|
|
3821
|
+
* (Multi-Factor Authentication including recovery codes acknowledgment).
|
|
3822
|
+
*
|
|
3823
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3824
|
+
* @returns True if onboarding is complete (no pending requirements), false if there are pending requirements.
|
|
3825
|
+
*/
|
|
3826
|
+
const isUserOnboardingComplete = (client = require_InvalidParamError.getDefaultClient()) => {
|
|
3827
|
+
const user = client.user;
|
|
3828
|
+
require_InvalidParamError.assertDefined(user, "User not logged in");
|
|
3829
|
+
const hasMissingKycFields = Boolean(user.missingFields?.length);
|
|
3830
|
+
const hasPendingMfaAuth = isUserMissingMfaAuth(client);
|
|
3831
|
+
const hasPendingRecoveryCodes = isPendingRecoveryCodesAcknowledgment(client);
|
|
3832
|
+
return !hasMissingKycFields && !hasPendingMfaAuth && !hasPendingRecoveryCodes;
|
|
3833
|
+
};
|
|
3834
|
+
|
|
3778
3835
|
//#endregion
|
|
3779
3836
|
//#region src/modules/user/refreshUser/refreshUser.ts
|
|
3780
3837
|
/**
|
|
@@ -3786,9 +3843,9 @@ const deleteUser = async (client = require_constants.getDefaultClient()) => {
|
|
|
3786
3843
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3787
3844
|
* @returns A promise that resolves to the authenticated user.
|
|
3788
3845
|
*/
|
|
3789
|
-
const refreshUser = async (client =
|
|
3790
|
-
const core =
|
|
3791
|
-
const apiClient =
|
|
3846
|
+
const refreshUser = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
3847
|
+
const core = require_InvalidParamError.getCore(client);
|
|
3848
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
3792
3849
|
const previousState = { ...core.state.get() };
|
|
3793
3850
|
const user = await apiClient.getAuthenticatedUser({ environmentId: core.environmentId });
|
|
3794
3851
|
core.state.set({ user });
|
|
@@ -3812,7 +3869,7 @@ const refreshUser = async (client = require_constants.getDefaultClient()) => {
|
|
|
3812
3869
|
* @returns A promise that resolves if the wallet is available for signing.
|
|
3813
3870
|
* @throws WalletAccountNotSelectedError If the wallet account is not currently selected.
|
|
3814
3871
|
*/
|
|
3815
|
-
const assertWalletAccountSigningAvailability = async ({ walletAccount }, client =
|
|
3872
|
+
const assertWalletAccountSigningAvailability = async ({ walletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
3816
3873
|
const { addresses } = await require_getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({ walletAccount }, client).getConnectedAddresses();
|
|
3817
3874
|
if (addresses.length > 0 && !addresses.includes(walletAccount.address)) throw new WalletAccountNotSelectedError({
|
|
3818
3875
|
expectedAddress: walletAccount.address,
|
|
@@ -3867,7 +3924,7 @@ const getAddressesWithTypesFromConnectionResult = (connectionResult) => {
|
|
|
3867
3924
|
* @returns A promise that resolves to the connected wallet account.
|
|
3868
3925
|
* @throws NoAddressFoundError If the request to connect was successful but no address is connected to your app.
|
|
3869
3926
|
*/
|
|
3870
|
-
const connectWithWalletProvider = async ({ walletProviderKey, addToDynamicWalletAccounts = true }, client =
|
|
3927
|
+
const connectWithWalletProvider = async ({ walletProviderKey, addToDynamicWalletAccounts = true }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
3871
3928
|
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderByKey({ walletProviderKey }, client);
|
|
3872
3929
|
assertWalletProviderMethodDefined(walletProvider, "connect");
|
|
3873
3930
|
const { addresses } = await walletProvider.connect();
|
|
@@ -3917,14 +3974,14 @@ const getChainIdForAccountVerification = async ({ walletProvider }) => {
|
|
|
3917
3974
|
//#endregion
|
|
3918
3975
|
//#region src/modules/wallets/utils/getSignInMessage/getSignInMessage.ts
|
|
3919
3976
|
const getSignInMessage = async ({ walletAccount }, client) => {
|
|
3920
|
-
const core =
|
|
3921
|
-
const apiClient =
|
|
3977
|
+
const core = require_InvalidParamError.getCore(client);
|
|
3978
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
3922
3979
|
const universalLink = core.metadata?.universalLink;
|
|
3923
|
-
|
|
3980
|
+
require_InvalidParamError.assertDefined(universalLink, "Universal link is not set");
|
|
3924
3981
|
const url = new URL(universalLink);
|
|
3925
3982
|
const domain = url.host;
|
|
3926
3983
|
const { nonce } = await apiClient.getNonce({ environmentId: core.environmentId });
|
|
3927
|
-
|
|
3984
|
+
require_InvalidParamError.assertDefined(nonce, "Failed to get nonce");
|
|
3928
3985
|
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
3929
3986
|
if (walletProvider.chain === "STARK")
|
|
3930
3987
|
/**
|
|
@@ -3939,7 +3996,7 @@ const getSignInMessage = async ({ walletAccount }, client) => {
|
|
|
3939
3996
|
const statement = require_getNetworkProviderFromNetworkId.createSignInMessageStatement(client);
|
|
3940
3997
|
return await require_getNetworkProviderFromNetworkId.formatSignInMessage({
|
|
3941
3998
|
address: walletAccount.address,
|
|
3942
|
-
blockchainName:
|
|
3999
|
+
blockchainName: require_InvalidParamError.CHAINS_INFO_MAP[walletProvider.chain].blockchainName,
|
|
3943
4000
|
chainId: await getChainIdForAccountVerification({ walletProvider }),
|
|
3944
4001
|
domain,
|
|
3945
4002
|
issuedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3962,7 +4019,7 @@ const getSignInMessage = async ({ walletAccount }, client) => {
|
|
|
3962
4019
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3963
4020
|
* @returns A promise that resolves to an object containing the message and signature.
|
|
3964
4021
|
*/
|
|
3965
|
-
const proveWalletAccountOwnership = async ({ walletAccount }, client =
|
|
4022
|
+
const proveWalletAccountOwnership = async ({ walletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
3966
4023
|
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
3967
4024
|
assertWalletProviderMethodDefined(walletProvider, "signMessage");
|
|
3968
4025
|
const messageToSign = await getSignInMessage({ walletAccount }, client);
|
|
@@ -3999,7 +4056,7 @@ const verifyWalletAccountForSignInOrTransfer = async ({ walletAccount, isTransfe
|
|
|
3999
4056
|
walletProviderType: walletProvider.walletProviderType
|
|
4000
4057
|
}, client);
|
|
4001
4058
|
const walletVerifiedCredential = response.user?.verifiedCredentials.find((verifiedCredential) => isSameAddress(verifiedCredential.address ?? "", walletAccount.address, walletAccount.chain));
|
|
4002
|
-
|
|
4059
|
+
require_InvalidParamError.assertDefined(walletVerifiedCredential, `After verifying, still unable to find verified wallet credential for wallet account ${walletAccount.address} on chain ${walletAccount.chain}`);
|
|
4003
4060
|
require_getNetworkProviderFromNetworkId.updateWalletProviderKeysForVerifiedCredentials({ keysToUpdate: { [walletVerifiedCredential.id]: walletProvider.key } }, client);
|
|
4004
4061
|
/**
|
|
4005
4062
|
* Adds the user with the new wallet verified credential
|
|
@@ -4011,7 +4068,7 @@ const verifyWalletAccountForSignInOrTransfer = async ({ walletAccount, isTransfe
|
|
|
4011
4068
|
*/
|
|
4012
4069
|
require_getNetworkProviderFromNetworkId.removeUnverifiedWalletAccount({ unverifiedWalletAccount: walletAccount }, client);
|
|
4013
4070
|
const verifiedWalletAccount = require_getVerifiedCredentialForWalletAccount.getWalletAccounts(client).find(({ address }) => isSameAddress(address, walletAccount.address, walletAccount.chain));
|
|
4014
|
-
|
|
4071
|
+
require_InvalidParamError.assertDefined(verifiedWalletAccount, `Unable to find wallet account ${walletAccount.address} on chain ${walletAccount.chain} for verified credential ${walletVerifiedCredential.id}`);
|
|
4015
4072
|
return verifiedWalletAccount;
|
|
4016
4073
|
};
|
|
4017
4074
|
|
|
@@ -4029,7 +4086,7 @@ const verifyWalletAccountForSignInOrTransfer = async ({ walletAccount, isTransfe
|
|
|
4029
4086
|
* @throws WalletAccountAlreadyVerifiedError If the wallet is already verified.
|
|
4030
4087
|
* @throws WalletAlreadyLinkedToAnotherUserError If the wallet is linked to another user.
|
|
4031
4088
|
*/
|
|
4032
|
-
const verifyWalletAccount = async ({ walletAccount }, client =
|
|
4089
|
+
const verifyWalletAccount = async ({ walletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4033
4090
|
return verifyWalletAccountForSignInOrTransfer({
|
|
4034
4091
|
isTransfer: false,
|
|
4035
4092
|
walletAccount
|
|
@@ -4049,7 +4106,7 @@ const verifyWalletAccount = async ({ walletAccount }, client = require_constants
|
|
|
4049
4106
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4050
4107
|
* @returns A promise that resolves to the connected and verified wallet account.
|
|
4051
4108
|
*/
|
|
4052
|
-
const connectAndVerifyWithWalletProvider = async ({ walletProviderKey }, client =
|
|
4109
|
+
const connectAndVerifyWithWalletProvider = async ({ walletProviderKey }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4053
4110
|
const walletAccount = await connectWithWalletProvider({
|
|
4054
4111
|
addToDynamicWalletAccounts: false,
|
|
4055
4112
|
walletProviderKey
|
|
@@ -4073,7 +4130,7 @@ const connectAndVerifyWithWalletProvider = async ({ walletProviderKey }, client
|
|
|
4073
4130
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4074
4131
|
* @returns An array of wallet provider data including chain, keys, and metadata.
|
|
4075
4132
|
*/
|
|
4076
|
-
const getAvailableWalletProvidersData = (client =
|
|
4133
|
+
const getAvailableWalletProvidersData = (client = require_InvalidParamError.getDefaultClient()) => {
|
|
4077
4134
|
return require_getVerifiedCredentialForWalletAccount.getWalletProviders(client).filter((walletProvider) => Boolean(walletProvider.connect)).map((walletProvider) => ({
|
|
4078
4135
|
chain: walletProvider.chain,
|
|
4079
4136
|
groupKey: walletProvider.groupKey,
|
|
@@ -4095,15 +4152,15 @@ const getAvailableWalletProvidersData = (client = require_constants.getDefaultCl
|
|
|
4095
4152
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4096
4153
|
* @returns An array of connected wallet addresses.
|
|
4097
4154
|
*/
|
|
4098
|
-
const getConnectedAddresses = ({ walletProviderKey }, client =
|
|
4155
|
+
const getConnectedAddresses = ({ walletProviderKey }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4099
4156
|
return require_getVerifiedCredentialForWalletAccount.getWalletProviderByKey({ walletProviderKey }, client).getConnectedAddresses();
|
|
4100
4157
|
};
|
|
4101
4158
|
|
|
4102
4159
|
//#endregion
|
|
4103
4160
|
//#region src/modules/wallets/getOwnerWalletAccountForSmartWalletAccount/getOwnerWalletAccountForSmartWalletAccount.ts
|
|
4104
|
-
const getOwnerWalletAccountForSmartWalletAccount = ({ smartWalletAccount }, client =
|
|
4161
|
+
const getOwnerWalletAccountForSmartWalletAccount = ({ smartWalletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4105
4162
|
const smartWalletVerifiedCredential = require_getVerifiedCredentialForWalletAccount.getVerifiedCredentialForWalletAccount({ walletAccount: smartWalletAccount }, client);
|
|
4106
|
-
|
|
4163
|
+
require_InvalidParamError.assertDefined(smartWalletVerifiedCredential?.signerRefId, "Invalid smart wallet account");
|
|
4107
4164
|
return require_getVerifiedCredentialForWalletAccount.getWalletAccounts(client).find((walletAccount) => walletAccount.verifiedCredentialId === smartWalletVerifiedCredential.signerRefId);
|
|
4108
4165
|
};
|
|
4109
4166
|
|
|
@@ -4122,7 +4179,7 @@ const getWalletAccountAddressByType = ({ type, walletAccount }) => {
|
|
|
4122
4179
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4123
4180
|
* @returns The data for the wallet provider.
|
|
4124
4181
|
*/
|
|
4125
|
-
const getWalletProviderDataByKey = ({ walletProviderKey }, client =
|
|
4182
|
+
const getWalletProviderDataByKey = ({ walletProviderKey }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4126
4183
|
const { chain, groupKey, key, metadata, walletProviderType } = require_getVerifiedCredentialForWalletAccount.getWalletProviderByKey({ walletProviderKey }, client);
|
|
4127
4184
|
return {
|
|
4128
4185
|
chain,
|
|
@@ -4159,7 +4216,7 @@ const isWalletAccountVerified = ({ walletAccount }) => {
|
|
|
4159
4216
|
* @returns A promise that resolves when the network addition is complete.
|
|
4160
4217
|
* @throws NetworkAddingUnavailableError If the wallet provider doesn't support adding networks.
|
|
4161
4218
|
*/
|
|
4162
|
-
const addNetwork = async ({ networkData, walletAccount }, client =
|
|
4219
|
+
const addNetwork = async ({ networkData, walletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4163
4220
|
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderByKey({ walletProviderKey: walletAccount.walletProviderKey }, client);
|
|
4164
4221
|
if (walletProvider.addNetwork === void 0) throw new NetworkAddingUnavailableError({
|
|
4165
4222
|
extraMessages: [`Wallet provider ${walletAccount.walletProviderKey} does not have addNetwork method`],
|
|
@@ -4182,7 +4239,7 @@ const addNetwork = async ({ networkData, walletAccount }, client = require_const
|
|
|
4182
4239
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4183
4240
|
* @returns A promise that resolves to the network data, or undefined if not found.
|
|
4184
4241
|
*/
|
|
4185
|
-
const getActiveNetworkData = async ({ walletAccount }, client =
|
|
4242
|
+
const getActiveNetworkData = async ({ walletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4186
4243
|
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
4187
4244
|
const { networkId } = await walletProvider.getActiveNetworkId();
|
|
4188
4245
|
return { networkData: require_getNetworkProviderFromNetworkId.getNetworksData(client).find((data) => data.networkId === networkId && data.chain === walletProvider.chain) };
|
|
@@ -4197,7 +4254,7 @@ const getActiveNetworkData = async ({ walletAccount }, client = require_constant
|
|
|
4197
4254
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4198
4255
|
* @returns A promise that resolves to the active network ID for the wallet account.
|
|
4199
4256
|
*/
|
|
4200
|
-
const getActiveNetworkId = ({ walletAccount }, client =
|
|
4257
|
+
const getActiveNetworkId = ({ walletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4201
4258
|
return require_getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({ walletAccount }, client).getActiveNetworkId();
|
|
4202
4259
|
};
|
|
4203
4260
|
|
|
@@ -4213,7 +4270,7 @@ const getActiveNetworkId = ({ walletAccount }, client = require_constants.getDef
|
|
|
4213
4270
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4214
4271
|
* @returns A promise that resolves to an object containing the balance as a string or null.
|
|
4215
4272
|
*/
|
|
4216
|
-
const getBalance = async ({ walletAccount }, client =
|
|
4273
|
+
const getBalance = async ({ walletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4217
4274
|
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
4218
4275
|
const { networkId } = await walletProvider.getActiveNetworkId();
|
|
4219
4276
|
return require_getNetworkProviderFromNetworkId.getNetworkProviderFromNetworkId({
|
|
@@ -4236,12 +4293,12 @@ const getBalance = async ({ walletAccount }, client = require_constants.getDefau
|
|
|
4236
4293
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4237
4294
|
* @returns A promise that resolves to an object containing the balance as a string or null.
|
|
4238
4295
|
*/
|
|
4239
|
-
const getBalanceForAddress = async ({ address, chain, networkId }, client =
|
|
4296
|
+
const getBalanceForAddress = async ({ address, chain, networkId }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4240
4297
|
const networkProvider = require_getNetworkProviderFromNetworkId.getNetworkProviderFromNetworkId({
|
|
4241
4298
|
chain,
|
|
4242
4299
|
networkId
|
|
4243
4300
|
}, client);
|
|
4244
|
-
|
|
4301
|
+
require_InvalidParamError.assertDefined(networkProvider, `No network found for chain ${chain} and network id ${networkId}. Please ensure you've enabled this network in the Dashboard.`);
|
|
4245
4302
|
return networkProvider.getBalance({ address });
|
|
4246
4303
|
};
|
|
4247
4304
|
|
|
@@ -4261,9 +4318,9 @@ const getBalanceForAddress = async ({ address, chain, networkId }, client = requ
|
|
|
4261
4318
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4262
4319
|
* @returns A promise that resolves to the transaction history along with nextOffset for the given wallet address and chain.
|
|
4263
4320
|
*/
|
|
4264
|
-
const getTransactionHistory = async (params, client =
|
|
4265
|
-
const core =
|
|
4266
|
-
return await
|
|
4321
|
+
const getTransactionHistory = async (params, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4322
|
+
const core = require_InvalidParamError.getCore(client);
|
|
4323
|
+
return await require_InvalidParamError.createApiClient({}, client).getWalletTransactions({
|
|
4267
4324
|
address: params.address,
|
|
4268
4325
|
chainName: params.chain,
|
|
4269
4326
|
environmentId: core.environmentId,
|
|
@@ -4283,7 +4340,7 @@ const getTransactionHistory = async (params, client = require_constants.getDefau
|
|
|
4283
4340
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4284
4341
|
* @returns True if programmatic network switching is available, false otherwise.
|
|
4285
4342
|
*/
|
|
4286
|
-
const isProgrammaticNetworkSwitchAvailable = ({ walletAccount }, client =
|
|
4343
|
+
const isProgrammaticNetworkSwitchAvailable = ({ walletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4287
4344
|
return require_getVerifiedCredentialForWalletAccount.getWalletProviderByKey({ walletProviderKey: walletAccount.walletProviderKey }, client).switchActiveNetwork !== void 0;
|
|
4288
4345
|
};
|
|
4289
4346
|
|
|
@@ -4301,7 +4358,7 @@ const isProgrammaticNetworkSwitchAvailable = ({ walletAccount }, client = requir
|
|
|
4301
4358
|
* @returns A promise that resolves when the network switch is complete.
|
|
4302
4359
|
* @throws NetworkSwitchingUnavailableError If the wallet provider doesn't support network switching.
|
|
4303
4360
|
*/
|
|
4304
|
-
const switchActiveNetwork = async ({ networkId, walletAccount }, client =
|
|
4361
|
+
const switchActiveNetwork = async ({ networkId, walletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4305
4362
|
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderByKey({ walletProviderKey: walletAccount.walletProviderKey }, client);
|
|
4306
4363
|
if (walletProvider.switchActiveNetwork === void 0) throw new NetworkSwitchingUnavailableError({
|
|
4307
4364
|
extraMessages: [`Wallet provider ${walletAccount.walletProviderKey} does not have switchActiveNetwork method`],
|
|
@@ -4316,10 +4373,10 @@ const switchActiveNetwork = async ({ networkId, walletAccount }, client = requir
|
|
|
4316
4373
|
/**
|
|
4317
4374
|
* Make the wallet account provided as the primary wallet account.
|
|
4318
4375
|
*/
|
|
4319
|
-
const selectPrimaryWalletAccount = async ({ walletAccount }, client =
|
|
4320
|
-
const core =
|
|
4376
|
+
const selectPrimaryWalletAccount = async ({ walletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4377
|
+
const core = require_InvalidParamError.getCore(client);
|
|
4321
4378
|
if (getPrimaryWalletAccount(client)?.id === walletAccount.id) return;
|
|
4322
|
-
if (walletAccount.verifiedCredentialId) require_getVerifiedCredentialForWalletAccount.updateAuthFromVerifyResponse({ response: await
|
|
4379
|
+
if (walletAccount.verifiedCredentialId) require_getVerifiedCredentialForWalletAccount.updateAuthFromVerifyResponse({ response: await require_InvalidParamError.createApiClient({}, client).selectUserWallet({
|
|
4323
4380
|
environmentId: core.environmentId,
|
|
4324
4381
|
userWalletSelectionRequest: { walletId: walletAccount.verifiedCredentialId }
|
|
4325
4382
|
}) }, client);
|
|
@@ -4359,9 +4416,9 @@ const disconnectWalletAccount = async ({ walletAccount }, client) => {
|
|
|
4359
4416
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4360
4417
|
* @returns A promise that resolves when the wallet account is successfully removed.
|
|
4361
4418
|
*/
|
|
4362
|
-
const removeWalletAccount = async ({ walletAccount }, client =
|
|
4363
|
-
const core =
|
|
4364
|
-
const apiClient =
|
|
4419
|
+
const removeWalletAccount = async ({ walletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4420
|
+
const core = require_InvalidParamError.getCore(client);
|
|
4421
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
4365
4422
|
await disconnectWalletAccount({ walletAccount }, client);
|
|
4366
4423
|
if (!walletAccount.verifiedCredentialId) {
|
|
4367
4424
|
require_getNetworkProviderFromNetworkId.removeUnverifiedWalletAccount({ unverifiedWalletAccount: walletAccount }, client);
|
|
@@ -4386,7 +4443,7 @@ const removeWalletAccount = async ({ walletAccount }, client = require_constants
|
|
|
4386
4443
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4387
4444
|
* @returns A promise that resolves to an object containing the signature.
|
|
4388
4445
|
*/
|
|
4389
|
-
const signMessage = async ({ walletAccount, message }, client =
|
|
4446
|
+
const signMessage = async ({ walletAccount, message }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4390
4447
|
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
4391
4448
|
assertWalletProviderMethodDefined(walletProvider, "signMessage");
|
|
4392
4449
|
const { signature } = await walletProvider.signMessage({
|
|
@@ -4408,7 +4465,7 @@ const signMessage = async ({ walletAccount, message }, client = require_constant
|
|
|
4408
4465
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4409
4466
|
* @returns A promise that resolves to the transferred wallet account.
|
|
4410
4467
|
*/
|
|
4411
|
-
const transferWalletAccount = async ({ walletProviderKey }, client =
|
|
4468
|
+
const transferWalletAccount = async ({ walletProviderKey }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4412
4469
|
return verifyWalletAccountForSignInOrTransfer({
|
|
4413
4470
|
isTransfer: true,
|
|
4414
4471
|
walletAccount: await connectWithWalletProvider({
|
|
@@ -4431,7 +4488,7 @@ const transferWalletAccount = async ({ walletProviderKey }, client = require_con
|
|
|
4431
4488
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4432
4489
|
* @returns The matching wallet account, or undefined if not found.
|
|
4433
4490
|
*/
|
|
4434
|
-
const getWalletAccountFromAddress = ({ address, chain }, client =
|
|
4491
|
+
const getWalletAccountFromAddress = ({ address, chain }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4435
4492
|
return require_getVerifiedCredentialForWalletAccount.getWalletAccounts(client).find((walletAccount) => walletAccount.address === address && walletAccount.chain === chain);
|
|
4436
4493
|
};
|
|
4437
4494
|
|
|
@@ -4447,7 +4504,7 @@ const getWalletAccountFromAddress = ({ address, chain }, client = require_consta
|
|
|
4447
4504
|
* @param params.walletProviderKey - The unique key identifying the wallet provider to remove the listener from.
|
|
4448
4505
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4449
4506
|
*/
|
|
4450
|
-
const offWalletProviderEvent = ({ callback, event, walletProviderKey }, client =
|
|
4507
|
+
const offWalletProviderEvent = ({ callback, event, walletProviderKey }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4451
4508
|
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderByKey({ walletProviderKey }, client);
|
|
4452
4509
|
assertWalletProviderMethodDefined(walletProvider, "events");
|
|
4453
4510
|
walletProvider.events.off(event, callback);
|
|
@@ -4464,7 +4521,7 @@ const offWalletProviderEvent = ({ callback, event, walletProviderKey }, client =
|
|
|
4464
4521
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4465
4522
|
* @returns A function that can be called to remove the listener.
|
|
4466
4523
|
*/
|
|
4467
|
-
const onWalletProviderEvent = ({ callback, event, walletProviderKey }, client =
|
|
4524
|
+
const onWalletProviderEvent = ({ callback, event, walletProviderKey }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4468
4525
|
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderByKey({ walletProviderKey }, client);
|
|
4469
4526
|
assertWalletProviderMethodDefined(walletProvider, "events");
|
|
4470
4527
|
walletProvider.events.on(event, callback);
|
|
@@ -4498,24 +4555,24 @@ const isIPad = (maxTouchPointsOverride) => {
|
|
|
4498
4555
|
|
|
4499
4556
|
//#endregion
|
|
4500
4557
|
//#region src/exports/index.ts
|
|
4501
|
-
(0, _dynamic_labs_sdk_assert_package_version.assertPackageVersion)(
|
|
4558
|
+
(0, _dynamic_labs_sdk_assert_package_version.assertPackageVersion)(require_InvalidParamError.name, require_InvalidParamError.version);
|
|
4502
4559
|
|
|
4503
4560
|
//#endregion
|
|
4504
|
-
exports.BaseError =
|
|
4561
|
+
exports.BaseError = require_InvalidParamError.BaseError;
|
|
4505
4562
|
exports.ClientAlreadyInitializedError = ClientAlreadyInitializedError;
|
|
4506
4563
|
exports.InvalidDeviceRegistrationRedirectError = InvalidDeviceRegistrationRedirectError;
|
|
4507
|
-
exports.InvalidExternalAuthError =
|
|
4564
|
+
exports.InvalidExternalAuthError = require_InvalidParamError.InvalidExternalAuthError;
|
|
4508
4565
|
exports.InvalidParamError = require_InvalidParamError.InvalidParamError;
|
|
4509
4566
|
exports.InvalidRedirectStorageStateError = InvalidRedirectStorageStateError;
|
|
4510
|
-
exports.LinkCredentialError =
|
|
4567
|
+
exports.LinkCredentialError = require_InvalidParamError.LinkCredentialError;
|
|
4511
4568
|
Object.defineProperty(exports, 'MFAAction', {
|
|
4512
4569
|
enumerable: true,
|
|
4513
4570
|
get: function () {
|
|
4514
4571
|
return _dynamic_labs_sdk_api_core.MFAAction;
|
|
4515
4572
|
}
|
|
4516
4573
|
});
|
|
4517
|
-
exports.MfaInvalidOtpError =
|
|
4518
|
-
exports.MfaRateLimitedError =
|
|
4574
|
+
exports.MfaInvalidOtpError = require_InvalidParamError.MfaInvalidOtpError;
|
|
4575
|
+
exports.MfaRateLimitedError = require_InvalidParamError.MfaRateLimitedError;
|
|
4519
4576
|
exports.MissingRedirectStorageStateError = MissingRedirectStorageStateError;
|
|
4520
4577
|
exports.MissingSocialUrlParamError = MissingSocialUrlParamError;
|
|
4521
4578
|
exports.MissingUserVerificationError = MissingUserVerificationError;
|
|
@@ -4528,7 +4585,7 @@ exports.NoPasskeyCredentialsFoundError = NoPasskeyCredentialsFoundError;
|
|
|
4528
4585
|
exports.NoSmartWalletAccountSignerFoundError = NoSmartWalletAccountSignerFoundError;
|
|
4529
4586
|
exports.NoWebAuthNSupportError = NoWebAuthNSupportError;
|
|
4530
4587
|
exports.NotWaasWalletAccountError = require_NotWaasWalletAccountError.NotWaasWalletAccountError;
|
|
4531
|
-
exports.SandboxMaximumThresholdReachedError =
|
|
4588
|
+
exports.SandboxMaximumThresholdReachedError = require_InvalidParamError.SandboxMaximumThresholdReachedError;
|
|
4532
4589
|
exports.UnavailableInServerSideError = UnavailableInServerSideError;
|
|
4533
4590
|
exports.UnrecognizedNetworkError = UnrecognizedNetworkError;
|
|
4534
4591
|
exports.UserNotAuthenticatedError = UserNotAuthenticatedError;
|
|
@@ -4568,8 +4625,9 @@ exports.getBalance = getBalance;
|
|
|
4568
4625
|
exports.getBalanceForAddress = getBalanceForAddress;
|
|
4569
4626
|
exports.getCoinbaseBuyUrl = getCoinbaseBuyUrl;
|
|
4570
4627
|
exports.getConnectedAddresses = getConnectedAddresses;
|
|
4571
|
-
exports.getDefaultClient =
|
|
4572
|
-
exports.
|
|
4628
|
+
exports.getDefaultClient = require_InvalidParamError.getDefaultClient;
|
|
4629
|
+
exports.getDeviceRegistrationTokenFromUrl = getDeviceRegistrationTokenFromUrl;
|
|
4630
|
+
exports.getElevatedAccessToken = getElevatedAccessToken;
|
|
4573
4631
|
exports.getKrakenAccounts = getKrakenAccounts;
|
|
4574
4632
|
exports.getKrakenWhitelistedAddresses = getKrakenWhitelistedAddresses;
|
|
4575
4633
|
exports.getMfaDevices = getMfaDevices;
|
|
@@ -4599,6 +4657,7 @@ exports.isPendingRecoveryCodesAcknowledgment = isPendingRecoveryCodesAcknowledgm
|
|
|
4599
4657
|
exports.isProgrammaticNetworkSwitchAvailable = isProgrammaticNetworkSwitchAvailable;
|
|
4600
4658
|
exports.isSignedIn = isSignedIn;
|
|
4601
4659
|
exports.isUserMissingMfaAuth = isUserMissingMfaAuth;
|
|
4660
|
+
exports.isUserOnboardingComplete = isUserOnboardingComplete;
|
|
4602
4661
|
exports.isWalletAccountVerified = isWalletAccountVerified;
|
|
4603
4662
|
exports.logout = logout;
|
|
4604
4663
|
exports.offEvent = require_getVerifiedCredentialForWalletAccount.offEvent;
|