@dynamic-labs-sdk/client 1.33.0 → 1.33.2
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/{apiClient-4r7VAsLC.native.esm.js → apiClient-B0eCQXEJ.native.esm.js} +3 -3
- package/dist/{apiClient-4r7VAsLC.native.esm.js.map → apiClient-B0eCQXEJ.native.esm.js.map} +1 -1
- package/dist/core.cjs +24 -5
- package/dist/core.cjs.map +1 -1
- package/dist/core.esm.js +9 -8
- package/dist/core.esm.js.map +1 -1
- package/dist/core.native.esm.js +9 -8
- package/dist/core.native.esm.js.map +1 -1
- package/dist/exports/core.d.ts +8 -0
- package/dist/exports/core.d.ts.map +1 -1
- package/dist/{getNetworkProviderFromNetworkId-D9oRzWA6.esm.js → getNetworkProviderFromNetworkId-CgxCy8qP.esm.js} +9 -8
- package/dist/getNetworkProviderFromNetworkId-CgxCy8qP.esm.js.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-DOrcvuFv.cjs → getNetworkProviderFromNetworkId-DaxDzIv4.cjs} +9 -2
- package/dist/getNetworkProviderFromNetworkId-DaxDzIv4.cjs.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-BV229QF3.native.esm.js → getNetworkProviderFromNetworkId-OXG2gPby.native.esm.js} +10 -9
- package/dist/getNetworkProviderFromNetworkId-OXG2gPby.native.esm.js.map +1 -0
- package/dist/{getSignedSessionId-Cd8CCp5d.native.esm.js → getSignedSessionId-B2s2UuwJ.native.esm.js} +3 -3
- package/dist/{getSignedSessionId-Cd8CCp5d.native.esm.js.map → getSignedSessionId-B2s2UuwJ.native.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-DA-MMsJm.esm.js → getSignedSessionId-DdMeCIV-.esm.js} +3 -3
- package/dist/{getSignedSessionId-DA-MMsJm.esm.js.map → getSignedSessionId-DdMeCIV-.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-4qHh_BOh.cjs → getSignedSessionId-KiBgLtda.cjs} +3 -3
- package/dist/{getSignedSessionId-4qHh_BOh.cjs.map → getSignedSessionId-KiBgLtda.cjs.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-Fr3bEKeU.esm.js → getVerifiedCredentialForWalletAccount-DzZ-0SaQ.esm.js} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-Fr3bEKeU.esm.js.map → getVerifiedCredentialForWalletAccount-DzZ-0SaQ.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-Bw5q7QZn.cjs → getVerifiedCredentialForWalletAccount-y2drOcyb.cjs} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-Bw5q7QZn.cjs.map → getVerifiedCredentialForWalletAccount-y2drOcyb.cjs.map} +1 -1
- package/dist/index.cjs +56 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +50 -63
- package/dist/index.esm.js.map +1 -1
- package/dist/index.native.esm.js +50 -63
- package/dist/index.native.esm.js.map +1 -1
- package/dist/{isMfaRequiredForAction-BdU62usM.esm.js → isMfaRequiredForAction-BLegdReE.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-BdU62usM.esm.js.map → isMfaRequiredForAction-BLegdReE.esm.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-Djd-jkSl.cjs → isMfaRequiredForAction-By7uHgpn.cjs} +2 -2
- package/dist/{isMfaRequiredForAction-Djd-jkSl.cjs.map → isMfaRequiredForAction-By7uHgpn.cjs.map} +1 -1
- package/dist/{isMfaRequiredForAction-DZfEkyIU.native.esm.js → isMfaRequiredForAction-CXuuO-wy.native.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-DZfEkyIU.native.esm.js.map → isMfaRequiredForAction-CXuuO-wy.native.esm.js.map} +1 -1
- package/dist/{isUserOnboardingComplete-BEZOYohA.esm.js → isUserOnboardingComplete-Bvh4NLBz.esm.js} +3 -3
- package/dist/{isUserOnboardingComplete-BEZOYohA.esm.js.map → isUserOnboardingComplete-Bvh4NLBz.esm.js.map} +1 -1
- package/dist/{isUserOnboardingComplete-Bwvv6Urs.cjs → isUserOnboardingComplete-DMefkHRY.cjs} +3 -3
- package/dist/{isUserOnboardingComplete-Bwvv6Urs.cjs.map → isUserOnboardingComplete-DMefkHRY.cjs.map} +1 -1
- package/dist/{isUserOnboardingComplete-CEUkAzCi.native.esm.js → isUserOnboardingComplete-hn1rWlA-.native.esm.js} +3 -3
- package/dist/{isUserOnboardingComplete-CEUkAzCi.native.esm.js.map → isUserOnboardingComplete-hn1rWlA-.native.esm.js.map} +1 -1
- package/dist/{logoutWithReason-I6vShLpA.esm.js → logoutWithReason-B-cf-dUs.esm.js} +62 -50
- package/dist/logoutWithReason-B-cf-dUs.esm.js.map +1 -0
- package/dist/{logoutWithReason-DvnEa2Uv.native.esm.js → logoutWithReason-C4AgSbjv.native.esm.js} +61 -49
- package/dist/logoutWithReason-C4AgSbjv.native.esm.js.map +1 -0
- package/dist/{logoutWithReason-B-ZF0VmN.cjs → logoutWithReason-c1DmyRBx.cjs} +73 -55
- package/dist/logoutWithReason-c1DmyRBx.cjs.map +1 -0
- package/dist/{migrateFromFireblocks-6I7lkraQ.native.esm.js → migrateFromFireblocks-B0pkwAaK.native.esm.js} +2 -2
- package/dist/{migrateFromFireblocks-6I7lkraQ.native.esm.js.map → migrateFromFireblocks-B0pkwAaK.native.esm.js.map} +1 -1
- package/dist/{migrateFromFireblocks-Dtk6t8hN.esm.js → migrateFromFireblocks-B76sFd7a.esm.js} +2 -2
- package/dist/{migrateFromFireblocks-Dtk6t8hN.esm.js.map → migrateFromFireblocks-B76sFd7a.esm.js.map} +1 -1
- package/dist/{migrateFromFireblocks-C23-24bK.cjs → migrateFromFireblocks-RCqy2qOG.cjs} +2 -2
- package/dist/{migrateFromFireblocks-C23-24bK.cjs.map → migrateFromFireblocks-RCqy2qOG.cjs.map} +1 -1
- package/dist/modules/initializeClient/consts.d.ts +1 -0
- package/dist/modules/initializeClient/consts.d.ts.map +1 -1
- package/dist/modules/initializeClient/initializeClient.d.ts.map +1 -1
- package/dist/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.d.ts +4 -5
- package/dist/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.d.ts +8 -3
- package/dist/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/parseGovernedResponse.d.ts +34 -0
- package/dist/modules/waas/businessAccounts/parseGovernedResponse.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/removeBusinessAccountMember.d.ts +4 -3
- package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/removeBusinessAccountMember.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/removeBusinessAccountSigner.d.ts +4 -3
- package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/removeBusinessAccountSigner.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/removeBusinessAccountWallet/removeBusinessAccountWallet.d.ts +4 -3
- package/dist/modules/waas/businessAccounts/removeBusinessAccountWallet/removeBusinessAccountWallet.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/transferBusinessAccountOwnership/transferBusinessAccountOwnership.d.ts +4 -3
- package/dist/modules/waas/businessAccounts/transferBusinessAccountOwnership/transferBusinessAccountOwnership.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/updateBusinessAccountMemberRole/updateBusinessAccountMemberRole.d.ts +4 -3
- package/dist/modules/waas/businessAccounts/updateBusinessAccountMemberRole/updateBusinessAccountMemberRole.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/{waas-C0IDCf3u.cjs → waas-7vSYuH3H.cjs} +104 -30
- package/dist/waas-7vSYuH3H.cjs.map +1 -0
- package/dist/{waas-DJeW02-Y.native.esm.js → waas-DIlnOHm6.native.esm.js} +104 -30
- package/dist/waas-DIlnOHm6.native.esm.js.map +1 -0
- package/dist/{waas-D_alZrtb.esm.js → waas-H5xyBfTI.esm.js} +104 -30
- package/dist/waas-H5xyBfTI.esm.js.map +1 -0
- package/dist/waas.cjs +4 -4
- package/dist/waas.esm.js +4 -4
- package/dist/waas.native.esm.js +4 -4
- package/dist/waasCore.cjs +5 -5
- package/dist/waasCore.esm.js +5 -5
- package/dist/waasCore.native.esm.js +5 -5
- package/package.json +3 -3
- package/dist/getNetworkProviderFromNetworkId-BV229QF3.native.esm.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-D9oRzWA6.esm.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-DOrcvuFv.cjs.map +0 -1
- package/dist/logoutWithReason-B-ZF0VmN.cjs.map +0 -1
- package/dist/logoutWithReason-DvnEa2Uv.native.esm.js.map +0 -1
- package/dist/logoutWithReason-I6vShLpA.esm.js.map +0 -1
- package/dist/modules/projectSettings/fetchProjectSettings/projectSettingsExpirationScheme.d.ts +0 -5
- package/dist/modules/projectSettings/fetchProjectSettings/projectSettingsExpirationScheme.d.ts.map +0 -1
- package/dist/waas-C0IDCf3u.cjs.map +0 -1
- package/dist/waas-DJeW02-Y.native.esm.js.map +0 -1
- package/dist/waas-D_alZrtb.esm.js.map +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { a as TransactionBroadcastError, i as NotWaasWalletAccountError } from "./migrateFromFireblocks-
|
|
3
|
-
import { $ as WaasChainEnum } from "./waas-
|
|
4
|
-
import { A as createLogger, B as
|
|
5
|
-
import { n as getWalletProviderByKey, t as getVerifiedCredentialForWalletAccount } from "./getVerifiedCredentialForWalletAccount-
|
|
6
|
-
import { a as WaasRbacStaleRetryUnsafeError, i as preconnectWaasIframe, n as isPendingRecoveryCodesAcknowledgment, o as WaasOnboardingIncompleteError, r as isDeviceRegistrationRequired, s as WaasLoadFailedError, t as isUserOnboardingComplete } from "./isUserOnboardingComplete-
|
|
7
|
-
import { n as getMfaMethods, r as __consumeMfaToken_wrapped, t as isMfaRequiredForAction } from "./isMfaRequiredForAction-
|
|
1
|
+
import { $ as getNonce, B as getWalletAccounts, C as checkAndRaiseWalletAccountsChangedEvent, Ct as setDefaultClient, Dt as TokenScope, Et as BaseError, F as emitEvent, G as formatWalletAccountId, I as offEvent, K as normalizeAddress, L as onEvent, M as getWalletProviders, N as WalletProviderPriority, Ot as name, P as getWalletProviderRegistry, R as onceEvent, S as InvalidParamError, St as getDefaultClient, T as initializeWaasClientsForEagerRecovery, Tt as getCore, U as getChainFromVerifiedCredentialChain, W as CHAINS_INFO_MAP, Y as isUserMissingMfaAuth, _ as extractSessionId, _t as assertDefined, a as stateStorageKeySchema, at as SandboxMaximumThresholdReachedError, b as parseElevatedAccessToken, bt as randomString, c as NoWalletProviderFoundError, ct as LinkCredentialError, d as resolveInstrumentationCore, et as fetchAndStoreNonces, f as instrumentFunction, ft as DYNAMIC_ICONIC_SPRITE_URL, g as getOperatingSystem, gt as isCookieEnabled, h as getUserAgent, i as sessionStorageKeySchema, it as UnauthorizedError, kt as version, l as createApiClient, lt as InvalidExternalAuthError, m as DEFAULT_PII_FIELDS, mt as SDK_API_CORE_VERSION, n as generateSessionKeys, nt as createStorageKeySchema, o as retryOnFail, ot as MfaRateLimitedError, p as scrubParameters, q as splitWalletProviderKey, r as fetchProjectSettings, rt as NONCE_POOL_SIZE, s as getWalletProviderFromWalletAccount, st as MfaInvalidOtpError, t as __logoutWithReason_wrapped, tt as updateNoncePoolStorage, u as __refreshAuth_wrapped, ut as APIError, v as updateAuthFromVerifyResponse, vt as ValueMustBeDefinedError, x as decodeJwt, xt as getPlatform, y as upsertElevatedAccessToken, yt as getElevatedAccessToken } from "./logoutWithReason-B-cf-dUs.esm.js";
|
|
2
|
+
import { a as TransactionBroadcastError, i as NotWaasWalletAccountError } from "./migrateFromFireblocks-B76sFd7a.esm.js";
|
|
3
|
+
import { $ as WaasChainEnum } from "./waas-H5xyBfTI.esm.js";
|
|
4
|
+
import { A as createLogger, B as MIGRATE_SESSION_KEY_TRACKER_KEY, C as MergeAccountsConfirmationError, D as createKeychainService, E as assertSafeDeeplinkUrl, F as createDeferredPromise, G as isEqualShallow, H as REFRESH_USER_STATE_FROM_VALID_TOKEN_TRACKER_KEY, I as createAppForegroundSubscriber, J as createLocalStorageAdapter, K as createStorage, L as FETCH_PROJECT_SETTINGS_TRACKER_KEY, M as createCrossTabBroadcast, O as assertSafeNavigationUrl, P as CannotTrackError, R as GENERATE_SESSION_KEYS_TRACKER_KEY, S as NoNetworkProvidersError, T as createRealtimeService, U as getBuffer, V as REFRESH_USER_STATE_FROM_COOKIE_TRACKER_KEY, W as subscribeWithSelector, X as UnavailableInServerSideError, Y as isServerSideRendering, _ as MethodNotImplementedError, a as removeUnverifiedWalletAccount, b as WalletScreeningBlockedError, c as getAppMetadata, d as setUnverifiedWalletAccounts, f as createVisit, g as __setCaptchaToken_wrapped, h as hasExtension, i as verifyMessageSignatureOwnership, j as createEventEmitter, l as reconcileWalletAccountsAgainstClient, m as getNetworkProviderBuilderRegistry, o as createSignInMessageStatement, p as getUriConnectionStarterRegistry, r as getNetworksData, s as formatSignInMessage, t as getNetworkProviderFromNetworkId, u as updateWalletProviderKeysForVerifiedCredentials, v as consumeCaptchaToken, w as getKeychainIndexedDBName, x as WalletAlreadyLinkedToAnotherUserError, y as isCaptchaRequired, z as INITIALIZE_STORAGE_SYNC_TRACKER_KEY } from "./getNetworkProviderFromNetworkId-CgxCy8qP.esm.js";
|
|
5
|
+
import { n as getWalletProviderByKey, t as getVerifiedCredentialForWalletAccount } from "./getVerifiedCredentialForWalletAccount-DzZ-0SaQ.esm.js";
|
|
6
|
+
import { a as WaasRbacStaleRetryUnsafeError, i as preconnectWaasIframe, n as isPendingRecoveryCodesAcknowledgment, o as WaasOnboardingIncompleteError, r as isDeviceRegistrationRequired, s as WaasLoadFailedError, t as isUserOnboardingComplete } from "./isUserOnboardingComplete-Bvh4NLBz.esm.js";
|
|
7
|
+
import { n as getMfaMethods, r as __consumeMfaToken_wrapped, t as isMfaRequiredForAction } from "./isMfaRequiredForAction-BLegdReE.esm.js";
|
|
8
8
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
9
9
|
import { AuthModeEnum, CaptchaProviderEnum as CaptchaProviderEnum$1, ChainEnum, ExchangeKeyEnum, JwtVerifiedCredentialFormatEnum as JwtVerifiedCredentialFormatEnum$1, MFAAction as MFAAction$1, MfaBackupCodeAcknowledgement, ProviderEnum as ProviderEnum$1, TokenScope as TokenScope$1, WaasBackupOptionsEnum, WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
|
|
10
10
|
import * as z from "zod/mini";
|
|
11
|
-
import { EventEmitter
|
|
11
|
+
import { EventEmitter } from "eventemitter3";
|
|
12
12
|
import { browserSupportsWebAuthn, startAuthentication, startRegistration } from "@simplewebauthn/browser";
|
|
13
13
|
|
|
14
14
|
//#region src/modules/state/raiseStateEvents/events.ts
|
|
@@ -165,57 +165,6 @@ const setupCrossTabEventSync = (client) => {
|
|
|
165
165
|
core.crossTabBroadcast.on("deviceRegistrationCompleted", handleCrossTabDeviceRegistrationCompleted);
|
|
166
166
|
};
|
|
167
167
|
|
|
168
|
-
//#endregion
|
|
169
|
-
//#region src/modules/wallets/unverifiedWalletAccounts/schema.ts
|
|
170
|
-
const unverifiedWalletAccountSchema = z.object({
|
|
171
|
-
address: z.string(),
|
|
172
|
-
addressesWithTypes: z.optional(z.array(z.object({
|
|
173
|
-
address: z.string(),
|
|
174
|
-
publicKey: z.optional(z.string()),
|
|
175
|
-
type: z.custom((val) => typeof val === "string")
|
|
176
|
-
}))),
|
|
177
|
-
chain: z.custom((val) => typeof val === "string"),
|
|
178
|
-
hardwareWalletVendor: z.optional(z.custom((val) => typeof val === "string")),
|
|
179
|
-
id: z.string(),
|
|
180
|
-
lastSelectedAt: z.nullable(z.date()),
|
|
181
|
-
walletProviderKey: z.string()
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
//#endregion
|
|
185
|
-
//#region src/modules/wallets/walletProvider/walletProviderKeyMap/schema.ts
|
|
186
|
-
const walletProviderKeyMapSchema = z.record(z.string(), z.string());
|
|
187
|
-
|
|
188
|
-
//#endregion
|
|
189
|
-
//#region src/modules/storageSync/schema.ts
|
|
190
|
-
const stateStorageKeySchema = createStorageKeySchema({
|
|
191
|
-
key: "state",
|
|
192
|
-
schema: z.object({
|
|
193
|
-
apiVersion: z.string(),
|
|
194
|
-
projectSettings: z.custom(),
|
|
195
|
-
unverifiedWalletAccounts: z.array(unverifiedWalletAccountSchema),
|
|
196
|
-
user: z.custom(),
|
|
197
|
-
walletProviderKeyMap: walletProviderKeyMapSchema
|
|
198
|
-
})
|
|
199
|
-
});
|
|
200
|
-
const sessionStorageKeySchema = createStorageKeySchema({
|
|
201
|
-
config: { storageTier: "secure" },
|
|
202
|
-
key: "session",
|
|
203
|
-
schema: z.object({
|
|
204
|
-
captchaToken: z.nullable(z.string()),
|
|
205
|
-
elevatedAccessTokens: z.array(z.object({
|
|
206
|
-
expiresAt: z.number(),
|
|
207
|
-
scopes: z.array(z.string()),
|
|
208
|
-
singleUse: z.nullable(z.boolean()),
|
|
209
|
-
token: z.string()
|
|
210
|
-
})),
|
|
211
|
-
legacyToken: z.nullable(z.string()),
|
|
212
|
-
mfaToken: z.nullable(z.string()),
|
|
213
|
-
sessionExpiration: z.number(),
|
|
214
|
-
sessionKeys: z.nullable(z.string()),
|
|
215
|
-
token: z.nullable(z.string())
|
|
216
|
-
})
|
|
217
|
-
});
|
|
218
|
-
|
|
219
168
|
//#endregion
|
|
220
169
|
//#region src/modules/keychainMigration/migrateSessionKeyToKeychain/KeyMigrationError.ts
|
|
221
170
|
var KeyMigrationError = class extends BaseError {
|
|
@@ -507,7 +456,7 @@ const initializeClient = async (client = getDefaultClient()) => {
|
|
|
507
456
|
raiseStateEvents(client);
|
|
508
457
|
setupCrossTabEventSync(client);
|
|
509
458
|
const initializeStorageSyncPromise = initializeStorageSync(client);
|
|
510
|
-
const
|
|
459
|
+
const migrationPromise = initializeStorageSyncPromise.then(async () => {
|
|
511
460
|
await migrateSessionKeyToKeychain({
|
|
512
461
|
keychain: core.keychain,
|
|
513
462
|
logger: core.logger,
|
|
@@ -516,8 +465,13 @@ const initializeClient = async (client = getDefaultClient()) => {
|
|
|
516
465
|
}).catch(() => __logoutWithReason_wrapped({ reason: "keychain-migration-failed" }, client));
|
|
517
466
|
if (core.state.get().sessionKeys && !await core.keychain.hasKey("session")) await __logoutWithReason_wrapped({ reason: "keychain-key-missing" }, client);
|
|
518
467
|
await logoutIfSessionPublicKeyMismatched(client);
|
|
519
|
-
})
|
|
520
|
-
|
|
468
|
+
});
|
|
469
|
+
core.initTrack.track({
|
|
470
|
+
name: MIGRATE_SESSION_KEY_TRACKER_KEY,
|
|
471
|
+
promise: migrationPromise
|
|
472
|
+
});
|
|
473
|
+
const fetchProjectSettingsPromise = initializeStorageSyncPromise.then(async () => {
|
|
474
|
+
await fetchProjectSettings(client);
|
|
521
475
|
});
|
|
522
476
|
fetchProjectSettingsPromise.then(() => prefetchNoncesIfNeeded(client)).catch((error) => {
|
|
523
477
|
core.logger.error("Failed to prefetch nonces:", error);
|
|
@@ -619,7 +573,7 @@ const createAsyncTrack = () => {
|
|
|
619
573
|
* This ensures no process is missed (as it would throw when tracked on a different node tick).
|
|
620
574
|
*/
|
|
621
575
|
let isTrackEnabled = true;
|
|
622
|
-
const eventEmitter = new EventEmitter
|
|
576
|
+
const eventEmitter = new EventEmitter();
|
|
623
577
|
const allSettledPromise = createDeferredPromise();
|
|
624
578
|
const tracker = /* @__PURE__ */ new Map();
|
|
625
579
|
/**
|
|
@@ -2157,6 +2111,39 @@ const __signInWithExternalJwt_wrapped = instrumentFunction({
|
|
|
2157
2111
|
getCore: resolveInstrumentationCore
|
|
2158
2112
|
});
|
|
2159
2113
|
|
|
2114
|
+
//#endregion
|
|
2115
|
+
//#region src/modules/auth/isSignedIn/isSignedIn.ts
|
|
2116
|
+
/**
|
|
2117
|
+
* Checks if the user is currently signed in to the Dynamic client.
|
|
2118
|
+
*
|
|
2119
|
+
* The client is considered to be in a signed in state if a user has
|
|
2120
|
+
* authenticated or if the client has at least one wallet connected.
|
|
2121
|
+
*
|
|
2122
|
+
* @deprecated What counts as "signed in" is your app's business logic, not the
|
|
2123
|
+
* SDK's. This helper bakes in one opinion (a user OR any connected wallet),
|
|
2124
|
+
* which rarely matches every app and forces a dependency on us for every
|
|
2125
|
+
* variation. Compose your own check from the underlying primitives instead —
|
|
2126
|
+
* e.g. `Boolean(client.user) || isAnyWalletAccountConnected(client)` — and
|
|
2127
|
+
* layer in whatever your app requires (device registration, completed
|
|
2128
|
+
* onboarding, satisfied MFA, a required embedded wallet, …). See the
|
|
2129
|
+
* "Check if signed in" guide:
|
|
2130
|
+
* https://www.dynamic.xyz/docs/javascript/user-session-management
|
|
2131
|
+
*
|
|
2132
|
+
* @example
|
|
2133
|
+
* ```ts
|
|
2134
|
+
* if (isSignedIn()) {
|
|
2135
|
+
* console.log('User is authenticated or has a wallet connected');
|
|
2136
|
+
* }
|
|
2137
|
+
* ```
|
|
2138
|
+
*
|
|
2139
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2140
|
+
* @returns True if the user is signed in, false otherwise.
|
|
2141
|
+
* @see logout
|
|
2142
|
+
* @see isAnyWalletAccountConnected
|
|
2143
|
+
* @notInstrumented
|
|
2144
|
+
*/
|
|
2145
|
+
const isSignedIn = (client = getDefaultClient()) => Boolean(client.user || getWalletAccounts(client).length > 0);
|
|
2146
|
+
|
|
2160
2147
|
//#endregion
|
|
2161
2148
|
//#region src/modules/auth/logout/logout.ts
|
|
2162
2149
|
/**
|