@dynamic-labs-sdk/client 1.32.0 → 1.33.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/{apiClient-Bwd6cllS.native.esm.js → apiClient-4r7VAsLC.native.esm.js} +45 -12
- package/dist/apiClient-4r7VAsLC.native.esm.js.map +1 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/core.cjs +78 -5
- package/dist/core.cjs.map +1 -1
- package/dist/core.esm.js +77 -6
- package/dist/core.esm.js.map +1 -1
- package/dist/core.native.esm.js +79 -8
- package/dist/core.native.esm.js.map +1 -1
- package/dist/errors/UnexpectedConsentResponseError.d.ts +7 -0
- package/dist/errors/UnexpectedConsentResponseError.d.ts.map +1 -0
- package/dist/exports/core.d.ts +2 -0
- package/dist/exports/core.d.ts.map +1 -1
- package/dist/exports/index.d.ts +2 -0
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/exports/waas.d.ts +2 -1
- package/dist/exports/waas.d.ts.map +1 -1
- package/dist/{getNetworkProviderFromNetworkId-DSsGkava.native.esm.js → getNetworkProviderFromNetworkId-BV229QF3.native.esm.js} +112 -89
- package/dist/getNetworkProviderFromNetworkId-BV229QF3.native.esm.js.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-TTqmAiJh.esm.js → getNetworkProviderFromNetworkId-D9oRzWA6.esm.js} +106 -83
- package/dist/getNetworkProviderFromNetworkId-D9oRzWA6.esm.js.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-5UBZwUg2.cjs → getNetworkProviderFromNetworkId-DOrcvuFv.cjs} +105 -82
- package/dist/getNetworkProviderFromNetworkId-DOrcvuFv.cjs.map +1 -0
- package/dist/{getSignedSessionId-DBUnRGjt.cjs → getSignedSessionId-4qHh_BOh.cjs} +3 -3
- package/dist/{getSignedSessionId-DBUnRGjt.cjs.map → getSignedSessionId-4qHh_BOh.cjs.map} +1 -1
- package/dist/{getSignedSessionId-BkYhH1zc.native.esm.js → getSignedSessionId-Cd8CCp5d.native.esm.js} +3 -3
- package/dist/{getSignedSessionId-BkYhH1zc.native.esm.js.map → getSignedSessionId-Cd8CCp5d.native.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-DeeDyino.esm.js → getSignedSessionId-DA-MMsJm.esm.js} +3 -3
- package/dist/{getSignedSessionId-DeeDyino.esm.js.map → getSignedSessionId-DA-MMsJm.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-BSxiaaVp.cjs → getVerifiedCredentialForWalletAccount-Bw5q7QZn.cjs} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-BSxiaaVp.cjs.map → getVerifiedCredentialForWalletAccount-Bw5q7QZn.cjs.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-C--Dza_K.esm.js → getVerifiedCredentialForWalletAccount-Fr3bEKeU.esm.js} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-C--Dza_K.esm.js.map → getVerifiedCredentialForWalletAccount-Fr3bEKeU.esm.js.map} +1 -1
- package/dist/index.cjs +379 -638
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +375 -635
- package/dist/index.esm.js.map +1 -1
- package/dist/index.native.esm.js +377 -637
- package/dist/index.native.esm.js.map +1 -1
- package/dist/{isMfaRequiredForAction-BPEXPqSt.esm.js → isMfaRequiredForAction-BdU62usM.esm.js} +3 -9
- package/dist/{isMfaRequiredForAction-BPEXPqSt.esm.js.map → isMfaRequiredForAction-BdU62usM.esm.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-DfrEFvU2.native.esm.js → isMfaRequiredForAction-DZfEkyIU.native.esm.js} +3 -9
- package/dist/{isMfaRequiredForAction-DfrEFvU2.native.esm.js.map → isMfaRequiredForAction-DZfEkyIU.native.esm.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-62zh3W-2.cjs → isMfaRequiredForAction-Djd-jkSl.cjs} +3 -9
- package/dist/{isMfaRequiredForAction-62zh3W-2.cjs.map → isMfaRequiredForAction-Djd-jkSl.cjs.map} +1 -1
- package/dist/{isUserOnboardingComplete-Dmck83_2.esm.js → isUserOnboardingComplete-BEZOYohA.esm.js} +3 -3
- package/dist/{isUserOnboardingComplete-Dmck83_2.esm.js.map → isUserOnboardingComplete-BEZOYohA.esm.js.map} +1 -1
- package/dist/{isUserOnboardingComplete-DtxIznZD.cjs → isUserOnboardingComplete-Bwvv6Urs.cjs} +3 -3
- package/dist/{isUserOnboardingComplete-DtxIznZD.cjs.map → isUserOnboardingComplete-Bwvv6Urs.cjs.map} +1 -1
- package/dist/{isUserOnboardingComplete-BWrCHXXO.native.esm.js → isUserOnboardingComplete-CEUkAzCi.native.esm.js} +3 -3
- package/dist/{isUserOnboardingComplete-BWrCHXXO.native.esm.js.map → isUserOnboardingComplete-CEUkAzCi.native.esm.js.map} +1 -1
- package/dist/{logoutWithReason-yDqQ0UIt.cjs → logoutWithReason-B-ZF0VmN.cjs} +57 -18
- package/dist/logoutWithReason-B-ZF0VmN.cjs.map +1 -0
- package/dist/{logoutWithReason-DIc7cC6T.native.esm.js → logoutWithReason-DvnEa2Uv.native.esm.js} +3 -9
- package/dist/{logoutWithReason-DIc7cC6T.native.esm.js.map → logoutWithReason-DvnEa2Uv.native.esm.js.map} +1 -1
- package/dist/{logoutWithReason-x8mE7EAy.esm.js → logoutWithReason-I6vShLpA.esm.js} +46 -19
- package/dist/logoutWithReason-I6vShLpA.esm.js.map +1 -0
- package/dist/{migrateFromFireblocks-BUhWQCqm.native.esm.js → migrateFromFireblocks-6I7lkraQ.native.esm.js} +2 -2
- package/dist/{migrateFromFireblocks-BUhWQCqm.native.esm.js.map → migrateFromFireblocks-6I7lkraQ.native.esm.js.map} +1 -1
- package/dist/{migrateFromFireblocks-qYPrnWF8.cjs → migrateFromFireblocks-C23-24bK.cjs} +2 -2
- package/dist/{migrateFromFireblocks-qYPrnWF8.cjs.map → migrateFromFireblocks-C23-24bK.cjs.map} +1 -1
- package/dist/{migrateFromFireblocks-BapjEhra.esm.js → migrateFromFireblocks-Dtk6t8hN.esm.js} +2 -2
- package/dist/{migrateFromFireblocks-BapjEhra.esm.js.map → migrateFromFireblocks-Dtk6t8hN.esm.js.map} +1 -1
- package/dist/modules/funding/coinbase/getCoinbaseAccounts/getCoinbaseAccounts.d.ts +1 -1
- package/dist/modules/funding/coinbase/getCoinbaseBuyUrl/getCoinbaseBuyUrl.d.ts +1 -1
- package/dist/modules/funding/kraken/getKrakenAccounts/getKrakenAccounts.d.ts +1 -1
- package/dist/modules/funding/kraken/getKrakenWhitelistedAddresses/getKrakenWhitelistedAddresses.d.ts +1 -1
- package/dist/modules/sessionKeys/signBusinessAccountIntent/signBusinessAccountIntent.d.ts +95 -0
- package/dist/modules/sessionKeys/signBusinessAccountIntent/signBusinessAccountIntent.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.d.ts +3 -1
- package/dist/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/addBusinessAccountSigner.d.ts +15 -6
- package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/addBusinessAccountSigner.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.d.ts +7 -3
- package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/businessAccounts.types.d.ts +115 -2
- package/dist/modules/waas/businessAccounts/businessAccounts.types.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/isBusinessAccountActionRequired/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/isBusinessAccountActionRequired/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/isBusinessAccountActionRequired/isBusinessAccountActionRequired.d.ts +27 -0
- package/dist/modules/waas/businessAccounts/isBusinessAccountActionRequired/isBusinessAccountActionRequired.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/updateBusinessAccountMemberRole/updateBusinessAccountMemberRole.d.ts +13 -6
- package/dist/modules/waas/businessAccounts/updateBusinessAccountMemberRole/updateBusinessAccountMemberRole.d.ts.map +1 -1
- package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
- package/dist/modules/waas/waas.types.d.ts +5 -2
- package/dist/modules/waas/waas.types.d.ts.map +1 -1
- package/dist/modules/walletOptionsCatalogue/buildWalletBookConnectionOptions/buildWalletBookConnectionOptions.d.ts +42 -0
- package/dist/modules/walletOptionsCatalogue/buildWalletBookConnectionOptions/buildWalletBookConnectionOptions.d.ts.map +1 -0
- package/dist/modules/walletOptionsCatalogue/buildWalletConnectOptions/buildWalletConnectOptions.d.ts +7 -1
- package/dist/modules/walletOptionsCatalogue/buildWalletConnectOptions/buildWalletConnectOptions.d.ts.map +1 -1
- package/dist/modules/walletOptionsCatalogue/buildWalletOption/buildWalletOption.d.ts.map +1 -1
- package/dist/modules/walletOptionsCatalogue/deriveSupportedChains/deriveSupportedChains.d.ts +27 -0
- package/dist/modules/walletOptionsCatalogue/deriveSupportedChains/deriveSupportedChains.d.ts.map +1 -0
- package/dist/modules/walletOptionsCatalogue/getWalletOptionsCatalogue/getWalletOptionsCatalogue.d.ts +4 -0
- package/dist/modules/walletOptionsCatalogue/getWalletOptionsCatalogue/getWalletOptionsCatalogue.d.ts.map +1 -1
- package/dist/modules/walletOptionsCatalogue/isWalletExtensionInstalled/index.d.ts +3 -0
- package/dist/modules/walletOptionsCatalogue/isWalletExtensionInstalled/index.d.ts.map +1 -0
- package/dist/modules/walletOptionsCatalogue/isWalletExtensionInstalled/isWalletExtensionInstalled.d.ts +35 -0
- package/dist/modules/walletOptionsCatalogue/isWalletExtensionInstalled/isWalletExtensionInstalled.d.ts.map +1 -0
- package/dist/modules/walletOptionsCatalogue/sortWalletOptions/sortWalletOptions.d.ts +1 -1
- package/dist/modules/walletOptionsCatalogue/walletOptionsCatalogue.types.d.ts +7 -0
- package/dist/modules/walletOptionsCatalogue/walletOptionsCatalogue.types.d.ts.map +1 -1
- package/dist/modules/wallets/resolveWalletConnectionOption/resolveWalletConnectionOption.d.ts.map +1 -1
- package/dist/modules/wallets/uriConnectionStarterRegistry/getUriConnectionStarterChains/getUriConnectionStarterChains.d.ts +27 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/getUriConnectionStarterChains/getUriConnectionStarterChains.d.ts.map +1 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/getUriConnectionStarterChains/index.d.ts +2 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/getUriConnectionStarterChains/index.d.ts.map +1 -0
- package/dist/modules/wallets/verifyMessageSignatureOwnership/verifyMessageSignatureOwnership.d.ts.map +1 -1
- package/dist/services/instrumentation/instrumentFunction/instrumentFunction.d.ts +6 -5
- package/dist/services/instrumentation/instrumentFunction/instrumentFunction.d.ts.map +1 -1
- package/dist/services/instrumentation/resolveInstrumentationCore/index.d.ts +2 -0
- package/dist/services/instrumentation/resolveInstrumentationCore/index.d.ts.map +1 -0
- package/dist/services/instrumentation/resolveInstrumentationCore/resolveInstrumentationCore.d.ts +19 -0
- package/dist/services/instrumentation/resolveInstrumentationCore/resolveInstrumentationCore.d.ts.map +1 -0
- package/dist/services/instrumentation/transports/createDynamicTransport/createDynamicTransport.d.ts +4 -3
- package/dist/services/instrumentation/transports/createDynamicTransport/createDynamicTransport.d.ts.map +1 -1
- package/dist/services/realtime/createRealtimeService/createRealtimeService.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/isScreeningBlockedError/index.d.ts +2 -0
- package/dist/utils/isScreeningBlockedError/index.d.ts.map +1 -0
- package/dist/utils/isScreeningBlockedError/isScreeningBlockedError.d.ts +24 -0
- package/dist/utils/isScreeningBlockedError/isScreeningBlockedError.d.ts.map +1 -0
- package/dist/{waas-WID2Fy_N.cjs → waas-C0IDCf3u.cjs} +81 -18
- package/dist/waas-C0IDCf3u.cjs.map +1 -0
- package/dist/{waas-CyUrvkQr.native.esm.js → waas-DJeW02-Y.native.esm.js} +77 -20
- package/dist/waas-DJeW02-Y.native.esm.js.map +1 -0
- package/dist/{waas-DzcYsWU8.esm.js → waas-D_alZrtb.esm.js} +77 -20
- package/dist/waas-D_alZrtb.esm.js.map +1 -0
- package/dist/waas.cjs +5 -4
- package/dist/waas.esm.js +5 -5
- package/dist/waas.native.esm.js +5 -5
- package/dist/waasCore.cjs +8 -6
- package/dist/waasCore.cjs.map +1 -1
- package/dist/waasCore.esm.js +8 -6
- package/dist/waasCore.esm.js.map +1 -1
- package/dist/waasCore.native.esm.js +8 -6
- package/dist/waasCore.native.esm.js.map +1 -1
- package/package.json +5 -4
- package/dist/apiClient-Bwd6cllS.native.esm.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-5UBZwUg2.cjs.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-DSsGkava.native.esm.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-TTqmAiJh.esm.js.map +0 -1
- package/dist/logoutWithReason-x8mE7EAy.esm.js.map +0 -1
- package/dist/logoutWithReason-yDqQ0UIt.cjs.map +0 -1
- package/dist/modules/walletOptionsCatalogue/hasInstalledProvider/hasInstalledProvider.d.ts +0 -18
- package/dist/modules/walletOptionsCatalogue/hasInstalledProvider/hasInstalledProvider.d.ts.map +0 -1
- package/dist/waas-CyUrvkQr.native.esm.js.map +0 -1
- package/dist/waas-DzcYsWU8.esm.js.map +0 -1
- package/dist/waas-WID2Fy_N.cjs.map +0 -1
package/dist/{isMfaRequiredForAction-BPEXPqSt.esm.js → isMfaRequiredForAction-BdU62usM.esm.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as createApiClient, d as instrumentFunction, gt as assertDefined, u as resolveInstrumentationCore, wt as getCore, xt as getDefaultClient } from "./logoutWithReason-I6vShLpA.esm.js";
|
|
2
2
|
|
|
3
3
|
//#region src/modules/mfa/consumeMfaToken/consumeMfaToken.ts
|
|
4
4
|
/**
|
|
@@ -23,13 +23,7 @@ const __consumeMfaToken_impl = consumeMfaToken;
|
|
|
23
23
|
const __consumeMfaToken_wrapped = instrumentFunction({
|
|
24
24
|
fn: __consumeMfaToken_impl,
|
|
25
25
|
functionName: "consumeMfaToken",
|
|
26
|
-
getCore:
|
|
27
|
-
try {
|
|
28
|
-
return getCore(getDefaultClient());
|
|
29
|
-
} catch {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
26
|
+
getCore: resolveInstrumentationCore
|
|
33
27
|
});
|
|
34
28
|
|
|
35
29
|
//#endregion
|
|
@@ -74,4 +68,4 @@ const isMfaRequiredForAction = async ({ mfaAction }, client = getDefaultClient()
|
|
|
74
68
|
|
|
75
69
|
//#endregion
|
|
76
70
|
export { getMfaMethods as n, __consumeMfaToken_wrapped as r, isMfaRequiredForAction as t };
|
|
77
|
-
//# sourceMappingURL=isMfaRequiredForAction-
|
|
71
|
+
//# sourceMappingURL=isMfaRequiredForAction-BdU62usM.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isMfaRequiredForAction-
|
|
1
|
+
{"version":3,"file":"isMfaRequiredForAction-BdU62usM.esm.js","names":[],"sources":["../src/modules/mfa/consumeMfaToken/consumeMfaToken.ts","../src/modules/mfa/getMfaMethods/getMfaMethods.ts","../src/modules/mfa/isMfaRequiredForAction/isMfaRequiredForAction.ts"],"sourcesContent":["import { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Consumes and clears the current MFA token from the client state.\n *\n * This function retrieves the MFA token obtained from a successful MFA authentication,\n * and removes it from the client, to prevent it from being used again.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The MFA token that was consumed.\n * @throws Error if no MFA token is found.\n * @instrumented\n */\nexport const consumeMfaToken = (client = getDefaultClient()): string => {\n const core = getCore(client);\n\n const mfaToken = core.state.get().mfaToken;\n\n assertDefined(mfaToken, 'No MFA token found');\n\n core.state.set({\n mfaToken: null,\n });\n\n return mfaToken;\n};\n","import { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { createApiClient } from '../../apiClient';\nimport type { MFAMethodsResponse } from '../mfa.types';\n\n/**\n * Retrieves the available MFA methods for the current user.\n *\n * This function fetches information about which multi-factor authentication\n * methods are available and configured for the user's account.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the user's MFA methods configuration.\n * @notInstrumented\n */\nexport const getMfaMethods = async (\n client = getDefaultClient()\n): Promise<MFAMethodsResponse> => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const userMfaMethods = await apiClient.getUserMfaMethods({\n environmentId: core.environmentId,\n verifiedOnly: true,\n });\n\n return userMfaMethods;\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport type { MFAAction } from '../mfa.consts';\nimport { getMfaMethods } from '../getMfaMethods';\n\ntype IsMfaRequiredForActionParams = {\n mfaAction: MFAAction;\n};\n\n/**\n * Checks if MFA is required for a specific action.\n *\n * This function determines whether multi-factor authentication is required\n * for the specified action based on project settings and user configuration.\n *\n * @param params.mfaAction - The action to check MFA requirements for.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to true if MFA is required for the action, false otherwise.\n * @notInstrumented\n */\nexport const isMfaRequiredForAction = async (\n { mfaAction }: IsMfaRequiredForActionParams,\n client = getDefaultClient()\n): Promise<boolean> => {\n const projectSettings = client.projectSettings;\n\n const isRequiredForAction = projectSettings?.security?.mfa?.actions?.some(\n (action) => action.action === mfaAction && action.required\n );\n\n // if mfa is not required for the action, return false\n // no matter if general mfa is set to required or not\n if (!isRequiredForAction) {\n return false;\n }\n\n const isMfaMethodRequired = projectSettings?.security?.mfa?.required;\n\n // if mfa is required for the action and also set as required in general, return true\n if (isMfaMethodRequired) {\n return true;\n }\n\n const mfaMethods = await getMfaMethods(client);\n // if general mfa is optional, but user has registered methods,\n // then it should be required for the action\n return mfaMethods.userHasVerifiedMfaMethods;\n};\n"],"mappings":";;;;;;;;;;;;;;;CAkBE,MAAM,OAAA,QAAe,OAAO;CAE5B,MAAA,WAAc,KAAQ,MAAM,KAAI,CAAA;AAEhC,eAAc,UAAC,qBAAA;AAEf,MAAE,MAAA,IAAA,kBAEF,CAAA;;;;;;;;;;;;;;;;;;;;;;ACXF,MAAa,gBAAgB,OAC3B,SAAS,kBAAkB,KACK;CAChC,MAAM,OAAO,QAAQ,OAAO;AAQ5B,QALuB,MAFL,gBAAgB,EAAE,EAAE,OAAO,CAEN,kBAAkB;EACvD,eAAe,KAAK;EACpB,cAAc;EACf,CAAC;;;;;;;;;;;;;;;;ACLJ,MAAa,yBAAyB,OACpC,EAAE,aACF,SAAS,kBAAkB,KACN;CACrB,MAAM,kBAAkB,OAAO;AAQ/B,KAAI,CANwB,iBAAiB,UAAU,KAAK,SAAS,MAClE,WAAW,OAAO,WAAW,aAAa,OAAO,SACnD,CAKC,QAAO;AAMT,KAH4B,iBAAiB,UAAU,KAAK,SAI1D,QAAO;AAMT,SAHmB,MAAM,cAAc,OAAO,EAG5B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ct as getCore, a as resolveInstrumentationCore, bt as getDefaultClient, ht as assertDefined, o as instrumentFunction, r as createApiClient, wt as BaseError } from "./apiClient-4r7VAsLC.native.esm.js";
|
|
2
2
|
|
|
3
3
|
//#region src/errors/NativeModuleNotLinkedError.ts
|
|
4
4
|
var NativeModuleNotLinkedError = class extends BaseError {
|
|
@@ -52,13 +52,7 @@ const __consumeMfaToken_impl = consumeMfaToken;
|
|
|
52
52
|
const __consumeMfaToken_wrapped = instrumentFunction({
|
|
53
53
|
fn: __consumeMfaToken_impl,
|
|
54
54
|
functionName: "consumeMfaToken",
|
|
55
|
-
getCore:
|
|
56
|
-
try {
|
|
57
|
-
return getCore(getDefaultClient());
|
|
58
|
-
} catch {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
55
|
+
getCore: resolveInstrumentationCore
|
|
62
56
|
});
|
|
63
57
|
|
|
64
58
|
//#endregion
|
|
@@ -103,4 +97,4 @@ const isMfaRequiredForAction = async ({ mfaAction }, client = getDefaultClient()
|
|
|
103
97
|
|
|
104
98
|
//#endregion
|
|
105
99
|
export { NativeModuleNotLinkedError as i, getMfaMethods as n, __consumeMfaToken_wrapped as r, isMfaRequiredForAction as t };
|
|
106
|
-
//# sourceMappingURL=isMfaRequiredForAction-
|
|
100
|
+
//# sourceMappingURL=isMfaRequiredForAction-DZfEkyIU.native.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isMfaRequiredForAction-
|
|
1
|
+
{"version":3,"file":"isMfaRequiredForAction-DZfEkyIU.native.esm.js","names":[],"sources":["../src/errors/NativeModuleNotLinkedError.ts","../src/modules/mfa/consumeMfaToken/consumeMfaToken.ts","../src/modules/mfa/getMfaMethods/getMfaMethods.ts","../src/modules/mfa/isMfaRequiredForAction/isMfaRequiredForAction.ts"],"sourcesContent":["import { BaseError } from './base';\n\ntype NativeModuleNotLinkedErrorParams = {\n moduleName: string;\n};\n\nexport class NativeModuleNotLinkedError extends BaseError {\n constructor({ moduleName }: NativeModuleNotLinkedErrorParams) {\n super({\n cause: null,\n code: 'native_module_not_linked_error',\n details: [\n `The \"${moduleName}\" TurboModule is not registered with React Native.`,\n 'This usually means the native module was not autolinked into the host app,',\n 'or the app binary was not rebuilt after installing the SDK.',\n '',\n 'To resolve:',\n ' 1. Ensure \"@dynamic-labs-sdk/client\" is a direct dependency of the app',\n ' and reinstall (e.g. `pnpm install`).',\n ' 2. Rebuild the native app:',\n ' iOS: `cd ios && pod install && cd .. && npx react-native run-ios`',\n ' Android: `npx react-native run-android`',\n ' Expo: `npx expo prebuild --clean` then run the app.',\n ' 3. Confirm autolinking sees the package:',\n ' `npx expo-modules-autolinking react-native-config --json`',\n ].join('\\n'),\n docsUrl: null,\n name: 'NativeModuleNotLinkedError',\n shortMessage: `Native TurboModule \"${moduleName}\" is not linked.`,\n });\n }\n}\n","import { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Consumes and clears the current MFA token from the client state.\n *\n * This function retrieves the MFA token obtained from a successful MFA authentication,\n * and removes it from the client, to prevent it from being used again.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The MFA token that was consumed.\n * @throws Error if no MFA token is found.\n * @instrumented\n */\nexport const consumeMfaToken = (client = getDefaultClient()): string => {\n const core = getCore(client);\n\n const mfaToken = core.state.get().mfaToken;\n\n assertDefined(mfaToken, 'No MFA token found');\n\n core.state.set({\n mfaToken: null,\n });\n\n return mfaToken;\n};\n","import { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { createApiClient } from '../../apiClient';\nimport type { MFAMethodsResponse } from '../mfa.types';\n\n/**\n * Retrieves the available MFA methods for the current user.\n *\n * This function fetches information about which multi-factor authentication\n * methods are available and configured for the user's account.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the user's MFA methods configuration.\n * @notInstrumented\n */\nexport const getMfaMethods = async (\n client = getDefaultClient()\n): Promise<MFAMethodsResponse> => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const userMfaMethods = await apiClient.getUserMfaMethods({\n environmentId: core.environmentId,\n verifiedOnly: true,\n });\n\n return userMfaMethods;\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport type { MFAAction } from '../mfa.consts';\nimport { getMfaMethods } from '../getMfaMethods';\n\ntype IsMfaRequiredForActionParams = {\n mfaAction: MFAAction;\n};\n\n/**\n * Checks if MFA is required for a specific action.\n *\n * This function determines whether multi-factor authentication is required\n * for the specified action based on project settings and user configuration.\n *\n * @param params.mfaAction - The action to check MFA requirements for.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to true if MFA is required for the action, false otherwise.\n * @notInstrumented\n */\nexport const isMfaRequiredForAction = async (\n { mfaAction }: IsMfaRequiredForActionParams,\n client = getDefaultClient()\n): Promise<boolean> => {\n const projectSettings = client.projectSettings;\n\n const isRequiredForAction = projectSettings?.security?.mfa?.actions?.some(\n (action) => action.action === mfaAction && action.required\n );\n\n // if mfa is not required for the action, return false\n // no matter if general mfa is set to required or not\n if (!isRequiredForAction) {\n return false;\n }\n\n const isMfaMethodRequired = projectSettings?.security?.mfa?.required;\n\n // if mfa is required for the action and also set as required in general, return true\n if (isMfaMethodRequired) {\n return true;\n }\n\n const mfaMethods = await getMfaMethods(client);\n // if general mfa is optional, but user has registered methods,\n // then it should be required for the action\n return mfaMethods.userHasVerifiedMfaMethods;\n};\n"],"mappings":";;;AAMA,IAAa,6BAAb,cAAgD,UAAU;CACxD,YAAY,EAAE,cAAgD;AAC5D,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;IACP,QAAQ,WAAW;IACnB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACD,CAAC,KAAK,KAAK;GACZ,SAAS;GACT,MAAM;GACN,cAAc,uBAAuB,WAAW;GACjD,CAAC;;;;;;;;;;;;;;;;;;CCXJ,MAAM,OAAA,QAAe,OAAO;CAE5B,MAAA,WAAc,KAAQ,MAAM,KAAI,CAAA;AAEhC,eAAc,UAAC,qBAAA;AAEf,MAAE,MAAA,IAAA,kBAEF,CAAA;;;;;;;;;;;;;;;;;;;;;;ACXF,MAAa,gBAAgB,OAC3B,SAAS,kBAAkB,KACK;CAChC,MAAM,OAAO,QAAQ,OAAO;AAQ5B,QALuB,MAFL,gBAAgB,EAAE,EAAE,OAAO,CAEN,kBAAkB;EACvD,eAAe,KAAK;EACpB,cAAc;EACf,CAAC;;;;;;;;;;;;;;;;ACLJ,MAAa,yBAAyB,OACpC,EAAE,aACF,SAAS,kBAAkB,KACN;CACrB,MAAM,kBAAkB,OAAO;AAQ/B,KAAI,CANwB,iBAAiB,UAAU,KAAK,SAAS,MAClE,WAAW,OAAO,WAAW,aAAa,OAAO,SACnD,CAKC,QAAO;AAMT,KAH4B,iBAAiB,UAAU,KAAK,SAI1D,QAAO;AAMT,SAHmB,MAAM,cAAc,OAAO,EAG5B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_logoutWithReason = require('./logoutWithReason-
|
|
1
|
+
const require_logoutWithReason = require('./logoutWithReason-B-ZF0VmN.cjs');
|
|
2
2
|
|
|
3
3
|
//#region src/modules/mfa/consumeMfaToken/consumeMfaToken.ts
|
|
4
4
|
/**
|
|
@@ -23,13 +23,7 @@ const __consumeMfaToken_impl = consumeMfaToken;
|
|
|
23
23
|
const __consumeMfaToken_wrapped = require_logoutWithReason.instrumentFunction({
|
|
24
24
|
fn: __consumeMfaToken_impl,
|
|
25
25
|
functionName: "consumeMfaToken",
|
|
26
|
-
getCore:
|
|
27
|
-
try {
|
|
28
|
-
return require_logoutWithReason.getCore(require_logoutWithReason.getDefaultClient());
|
|
29
|
-
} catch {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
26
|
+
getCore: require_logoutWithReason.resolveInstrumentationCore
|
|
33
27
|
});
|
|
34
28
|
|
|
35
29
|
//#endregion
|
|
@@ -91,4 +85,4 @@ Object.defineProperty(exports, 'isMfaRequiredForAction', {
|
|
|
91
85
|
return isMfaRequiredForAction;
|
|
92
86
|
}
|
|
93
87
|
});
|
|
94
|
-
//# sourceMappingURL=isMfaRequiredForAction-
|
|
88
|
+
//# sourceMappingURL=isMfaRequiredForAction-Djd-jkSl.cjs.map
|
package/dist/{isMfaRequiredForAction-62zh3W-2.cjs.map → isMfaRequiredForAction-Djd-jkSl.cjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isMfaRequiredForAction-
|
|
1
|
+
{"version":3,"file":"isMfaRequiredForAction-Djd-jkSl.cjs","names":["getDefaultClient","getCore","createApiClient","getDefaultClient"],"sources":["../src/modules/mfa/consumeMfaToken/consumeMfaToken.ts","../src/modules/mfa/getMfaMethods/getMfaMethods.ts","../src/modules/mfa/isMfaRequiredForAction/isMfaRequiredForAction.ts"],"sourcesContent":["import { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Consumes and clears the current MFA token from the client state.\n *\n * This function retrieves the MFA token obtained from a successful MFA authentication,\n * and removes it from the client, to prevent it from being used again.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The MFA token that was consumed.\n * @throws Error if no MFA token is found.\n * @instrumented\n */\nexport const consumeMfaToken = (client = getDefaultClient()): string => {\n const core = getCore(client);\n\n const mfaToken = core.state.get().mfaToken;\n\n assertDefined(mfaToken, 'No MFA token found');\n\n core.state.set({\n mfaToken: null,\n });\n\n return mfaToken;\n};\n","import { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { createApiClient } from '../../apiClient';\nimport type { MFAMethodsResponse } from '../mfa.types';\n\n/**\n * Retrieves the available MFA methods for the current user.\n *\n * This function fetches information about which multi-factor authentication\n * methods are available and configured for the user's account.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the user's MFA methods configuration.\n * @notInstrumented\n */\nexport const getMfaMethods = async (\n client = getDefaultClient()\n): Promise<MFAMethodsResponse> => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const userMfaMethods = await apiClient.getUserMfaMethods({\n environmentId: core.environmentId,\n verifiedOnly: true,\n });\n\n return userMfaMethods;\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport type { MFAAction } from '../mfa.consts';\nimport { getMfaMethods } from '../getMfaMethods';\n\ntype IsMfaRequiredForActionParams = {\n mfaAction: MFAAction;\n};\n\n/**\n * Checks if MFA is required for a specific action.\n *\n * This function determines whether multi-factor authentication is required\n * for the specified action based on project settings and user configuration.\n *\n * @param params.mfaAction - The action to check MFA requirements for.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to true if MFA is required for the action, false otherwise.\n * @notInstrumented\n */\nexport const isMfaRequiredForAction = async (\n { mfaAction }: IsMfaRequiredForActionParams,\n client = getDefaultClient()\n): Promise<boolean> => {\n const projectSettings = client.projectSettings;\n\n const isRequiredForAction = projectSettings?.security?.mfa?.actions?.some(\n (action) => action.action === mfaAction && action.required\n );\n\n // if mfa is not required for the action, return false\n // no matter if general mfa is set to required or not\n if (!isRequiredForAction) {\n return false;\n }\n\n const isMfaMethodRequired = projectSettings?.security?.mfa?.required;\n\n // if mfa is required for the action and also set as required in general, return true\n if (isMfaMethodRequired) {\n return true;\n }\n\n const mfaMethods = await getMfaMethods(client);\n // if general mfa is optional, but user has registered methods,\n // then it should be required for the action\n return mfaMethods.userHasVerifiedMfaMethods;\n};\n"],"mappings":";;;;;;;;;;;;;;;CAkBE,MAAM,OAAA,iCAAe,OAAO;CAE5B,MAAA,WAAc,KAAQ,MAAM,KAAI,CAAA;AAEhC,wCAAc,UAAC,qBAAA;AAEf,MAAE,MAAA,IAAA,kBAEF,CAAA;;;;;;;;;;;;;;;;;;;;;;ACXF,MAAa,gBAAgB,OAC3B,SAASA,2CAAkB,KACK;CAChC,MAAM,OAAOC,iCAAQ,OAAO;AAQ5B,QALuB,MAFLC,yCAAgB,EAAE,EAAE,OAAO,CAEN,kBAAkB;EACvD,eAAe,KAAK;EACpB,cAAc;EACf,CAAC;;;;;;;;;;;;;;;;ACLJ,MAAa,yBAAyB,OACpC,EAAE,aACF,SAASC,2CAAkB,KACN;CACrB,MAAM,kBAAkB,OAAO;AAQ/B,KAAI,CANwB,iBAAiB,UAAU,KAAK,SAAS,MAClE,WAAW,OAAO,WAAW,aAAa,OAAO,SACnD,CAKC,QAAO;AAMT,KAH4B,iBAAiB,UAAU,KAAK,SAI1D,QAAO;AAMT,SAHmB,MAAM,cAAc,OAAO,EAG5B"}
|
package/dist/{isUserOnboardingComplete-Dmck83_2.esm.js → isUserOnboardingComplete-BEZOYohA.esm.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as isDynamicWaasEnabled } from "./migrateFromFireblocks-
|
|
1
|
+
import { J as isUserMissingMfaAuth, O as DEFAULT_WAAS_BASE_API_URL, Tt as BaseError, gt as assertDefined, ht as isCookieEnabled, wt as getCore, xt as getDefaultClient } from "./logoutWithReason-I6vShLpA.esm.js";
|
|
2
|
+
import { n as isDynamicWaasEnabled } from "./migrateFromFireblocks-Dtk6t8hN.esm.js";
|
|
3
3
|
import { MfaBackupCodeAcknowledgement } from "@dynamic-labs/sdk-api-core";
|
|
4
4
|
import { preconnectWaasIframe } from "@dynamic-labs-wallet/browser-wallet-client";
|
|
5
5
|
|
|
@@ -211,4 +211,4 @@ const isUserOnboardingComplete = (client = getDefaultClient()) => {
|
|
|
211
211
|
|
|
212
212
|
//#endregion
|
|
213
213
|
export { WaasRbacStaleRetryUnsafeError as a, preconnectWaasIframe$1 as i, isPendingRecoveryCodesAcknowledgment as n, WaasOnboardingIncompleteError as o, isDeviceRegistrationRequired as r, WaasLoadFailedError as s, isUserOnboardingComplete as t };
|
|
214
|
-
//# sourceMappingURL=isUserOnboardingComplete-
|
|
214
|
+
//# sourceMappingURL=isUserOnboardingComplete-BEZOYohA.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUserOnboardingComplete-Dmck83_2.esm.js","names":["preconnectWaasIframe"],"sources":["../src/errors/WaasLoadFailedError.ts","../src/errors/WaasOnboardingIncompleteError.ts","../src/errors/WaasRbacStaleRetryUnsafeError.ts","../src/modules/waas/preconnectWaasIframe/preconnectWaasIframe.ts","../src/modules/deviceRegistration/isDeviceRegistrationRequired/isDeviceRegistrationRequired.ts","../src/modules/mfa/isPendingRecoveryCodesAcknowledgment/isPendingRecoveryCodesAcknowledgment.ts","../src/modules/user/isUserOnboardingComplete/isUserOnboardingComplete.ts"],"sourcesContent":["import { BaseError } from './base';\n\n/**\n * Why the embedded wallet load failed. Currently only retry exhaustion is\n * reported; the union exists so new reasons can be added without a breaking\n * change to consumer `instanceof` handling.\n *\n * @example\n * ```ts\n * const reason: WaasLoadFailedErrorReason = 'load_attempts_exhausted';\n * ```\n * @see WaasLoadFailedError\n * @see signMessage\n */\nexport type WaasLoadFailedErrorReason = 'load_attempts_exhausted';\n\n/**\n * Thrown when the embedded (WaaS) wallet's secure container failed to load\n * after exhausting all of its internal retry attempts.\n *\n * This failure is transient: the next wallet operation triggers a fresh load\n * cycle, so hosts can catch this error and re-attempt the operation at their\n * own cadence (for example, when connectivity returns or the app is\n * foregrounded). Other load failures (for example, a CSP block) are not\n * wrapped by this error and their shape is not guaranteed.\n *\n * @example\n * ```ts\n * try {\n * await signMessage({ message, walletAccount });\n * } catch (error) {\n * if (error instanceof WaasLoadFailedError) {\n * // transient — retry the operation at your own cadence\n * await signMessage({ message, walletAccount });\n * }\n * }\n * ```\n * @see WaasLoadFailedErrorReason\n * @see signMessage\n */\nexport class WaasLoadFailedError extends BaseError {\n readonly reason: WaasLoadFailedErrorReason;\n\n constructor({ cause }: { cause: Error }) {\n super({\n cause,\n code: 'waas_load_failed',\n docsUrl: null,\n name: 'WaasLoadFailedError',\n shortMessage:\n 'The embedded wallet failed to load after exhausting its retry attempts. Retrying the wallet operation triggers a fresh load.',\n });\n this.reason = 'load_attempts_exhausted';\n }\n}\n","import { BaseError } from './base';\n\n/**\n * Thrown when the embedded (WaaS) wallet client is requested before the user\n * has completed onboarding — i.e. the JWT has not upgraded to `user:basic`\n * because MFA, KYC, recovery-codes acknowledgment, or device registration is\n * still pending.\n *\n * The WaaS iframe's init-time room-cache pre-warm fires `createRooms` using the\n * token captured at client construction (before any per-operation token\n * resync). Building the client during this window lets that pre-warm fire with\n * a pre-`user:basic` token, get a 401, and the iframe's unauthorized handler\n * force-logs-out the user. Throwing here surfaces a clear, recoverable reason\n * instead — wait for onboarding to complete and retry.\n */\nexport class WaasOnboardingIncompleteError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'waas_onboarding_incomplete',\n docsUrl: null,\n name: 'WaasOnboardingIncompleteError',\n shortMessage:\n 'Cannot create or access the embedded wallet until onboarding is complete (pending MFA, KYC, recovery-codes acknowledgment, or device registration).',\n });\n }\n}\n","import { BaseError } from './base';\n\n/**\n * Thrown when a WaaS ceremony operation (sign, export, reshare, create\n * wallet) receives a 403 `rbac_stale` response after the attempt has already\n * spent its one-time authorization — either the legacy MFA token or a\n * single-use elevated access token.\n *\n * The SDK cannot safely retry in that case: the restarted attempt would find\n * the approval already consumed and fail deeper in the stack with an\n * unrelated \"no MFA token\" error, hiding the permission change that actually\n * caused the failure. Surfacing this error instead tells the host exactly what\n * happened. Recover by re-running the step-up/MFA flow and retrying the\n * operation; the business-account role change has already taken effect, so the\n * retry is evaluated against the caller's current permissions.\n *\n * @example\n * ```ts\n * try {\n * await signMessage({ message, walletAccount });\n * } catch (error) {\n * if (error instanceof WaasRbacStaleRetryUnsafeError) {\n * // The one-time approval was spent; re-verify before trying again.\n * await promptStepUp();\n * await signMessage({ message, walletAccount });\n * }\n * }\n * ```\n * @see WaasLoadFailedError\n * @see signMessage\n */\nexport class WaasRbacStaleRetryUnsafeError extends BaseError {\n constructor({ cause }: { cause: Error }) {\n super({\n cause,\n code: 'waas_rbac_stale_retry_unsafe',\n docsUrl: null,\n name: 'WaasRbacStaleRetryUnsafeError',\n shortMessage:\n 'The business account role change could not be retried automatically because a one-time authorization was already consumed. Re-authenticate and retry the operation.',\n });\n }\n}\n","import type { AuthMode } from '@dynamic-labs-wallet/browser-wallet-client';\nimport { preconnectWaasIframe as preconnectWaasIframeOrigin } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { isCookieEnabled } from '../../projectSettings/isCookieEnabled';\nimport { DEFAULT_WAAS_BASE_API_URL } from '../constants';\nimport { isDynamicWaasEnabled } from '../isDynamicWaasEnabled';\n\n/**\n * Warms the browser's connection (DNS + TCP + TLS) to the embedded-wallet\n * iframe origin so the iframe mounted after authentication completes loads on\n * a hot connection. Called when an auth flow starts (OTP send/verify, social\n * callback). Safe to call repeatedly; no-op on React Native / SSR and when\n * Dynamic WaaS is not enabled.\n *\n * @param client - The Dynamic client instance.\n * @notInstrumented\n */\nexport const preconnectWaasIframe = (client: DynamicClient): void => {\n const core = getCore(client);\n try {\n if (!isDynamicWaasEnabled(client)) return;\n\n preconnectWaasIframeOrigin({\n authMode: (isCookieEnabled(client) ? 'cookie' : 'header') as AuthMode,\n baseApiUrl: (core.apiBaseUrl || DEFAULT_WAAS_BASE_API_URL).replace(\n '/api/v0',\n ''\n ),\n });\n } catch (error) {\n // Best-effort: never break the auth flow (also swallows the assertion\n // from isDynamicWaasEnabled when project settings are not loaded yet).\n core.logger.warn('[preconnectWaasIframe] skipped', error);\n }\n};\n","import type { User } from '../../user/user.types';\n\n/**\n * Checks if device registration is required for the given user.\n *\n * This function determines if the user has the deviceRegistration\n * scope, indicating that device registration is required.\n *\n * @param user - The user to check.\n * @returns True if device registration is required, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when this device must be registered, updated when the user changes.\n */\nexport const isDeviceRegistrationRequired = (user: User): boolean =>\n Boolean(user.scope?.includes('device:register'));\n","import { MfaBackupCodeAcknowledgement } from '@dynamic-labs/sdk-api-core';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Checks if the user is still pending acknowledgment of their MFA recovery codes.\n *\n * This function determines whether the user has been presented with recovery\n * codes that they have not yet acknowledged as saved or backed up.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if recovery codes are pending acknowledgment, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when recovery codes await acknowledgment, updated when the user changes.\n */\nexport const isPendingRecoveryCodesAcknowledgment = (\n client = getDefaultClient()\n): boolean => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n return (\n user.mfaBackupCodeAcknowledgement === MfaBackupCodeAcknowledgement.Pending\n );\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { isDeviceRegistrationRequired } from '../../deviceRegistration/isDeviceRegistrationRequired';\nimport { isPendingRecoveryCodesAcknowledgment } from '../../mfa/isPendingRecoveryCodesAcknowledgment';\nimport { isUserMissingMfaAuth } from '../../mfa/isUserMissingMfaAuth';\n\n/**\n * Checks if the user has completed all onboarding requirements.\n *\n * This function verifies whether a user has fulfilled all necessary requirements\n * including KYC fields (Know Your Customer information), MFA setup\n * (Multi-Factor Authentication including recovery codes acknowledgment), and\n * device registration.\n *\n * A `false` result means the user still has an outstanding onboarding step, so\n * any feature that requires a fully onboarded (`user:basic`) user should hold\n * off until it returns `true`. Creating or accessing an embedded (WaaS) wallet\n * is one such feature — its backend calls reject a pre-`user:basic` token — but\n * this predicate is general and not specific to embedded wallets.\n *\n * @deprecated Use {@link checkUserScopes} instead. This function conflates\n * Dynamic-controlled requirements (MFA, device registration, required fields)\n * with the concept of \"onboarding complete\", which is app-specific. Replace\n * with `checkUserScopes({ user, scopes: ['user:basic'] })` to check whether\n * Dynamic's requirements are satisfied, and compose your own logic on top for\n * any app-specific onboarding steps.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if onboarding is complete (no pending requirements), false if there are pending requirements.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when onboarding is complete, updated when the user changes.\n */\nexport const isUserOnboardingComplete = (\n client = getDefaultClient()\n): boolean => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n const hasMissingKycFields = Boolean(user.missingFields?.length);\n const hasPendingMfaAuth = isUserMissingMfaAuth(client);\n const hasPendingRecoveryCodes = isPendingRecoveryCodesAcknowledgment(client);\n const hasPendingDeviceRegistration = isDeviceRegistrationRequired(user);\n\n const userOnboardingComplete =\n !hasMissingKycFields &&\n !hasPendingMfaAuth &&\n !hasPendingRecoveryCodes &&\n !hasPendingDeviceRegistration;\n\n return userOnboardingComplete;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,sBAAb,cAAyC,UAAU;CACjD,AAAS;CAET,YAAY,EAAE,SAA2B;AACvC,QAAM;GACJ;GACA,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;AACF,OAAK,SAAS;;;;;;;;;;;;;;;;;;;ACrClB,IAAa,gCAAb,cAAmD,UAAU;CAC3D,cAAc;AACZ,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACON,IAAa,gCAAb,cAAmD,UAAU;CAC3D,YAAY,EAAE,SAA2B;AACvC,QAAM;GACJ;GACA,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;;;;;;;;;;;;;;;;ACrBN,MAAaA,0BAAwB,WAAgC;CACnE,MAAM,OAAO,QAAQ,OAAO;AAC5B,KAAI;AACF,MAAI,CAAC,qBAAqB,OAAO,CAAE;AAEnC,uBAA2B;GACzB,UAAW,gBAAgB,OAAO,GAAG,WAAW;GAChD,aAAa,KAAK,cAAc,2BAA2B,QACzD,WACA,GACD;GACF,CAAC;UACK,OAAO;AAGd,OAAK,OAAO,KAAK,kCAAkC,MAAM;;;;;;;;;;;;;;;;;ACrB7D,MAAa,gCAAgC,SAC3C,QAAQ,KAAK,OAAO,SAAS,kBAAkB,CAAC;;;;;;;;;;;;;;;ACElD,MAAa,wCACX,SAAS,kBAAkB,KACf;CACZ,MAAM,OAAO,OAAO;AAEpB,eAAc,MAAM,qBAAqB;AAEzC,QACE,KAAK,iCAAiC,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQvE,MAAa,4BACX,SAAS,kBAAkB,KACf;CACZ,MAAM,OAAO,OAAO;AAEpB,eAAc,MAAM,qBAAqB;CAEzC,MAAM,sBAAsB,QAAQ,KAAK,eAAe,OAAO;CAC/D,MAAM,oBAAoB,qBAAqB,OAAO;CACtD,MAAM,0BAA0B,qCAAqC,OAAO;CAC5E,MAAM,+BAA+B,6BAA6B,KAAK;AAQvE,QALE,CAAC,uBACD,CAAC,qBACD,CAAC,2BACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"isUserOnboardingComplete-BEZOYohA.esm.js","names":["preconnectWaasIframe"],"sources":["../src/errors/WaasLoadFailedError.ts","../src/errors/WaasOnboardingIncompleteError.ts","../src/errors/WaasRbacStaleRetryUnsafeError.ts","../src/modules/waas/preconnectWaasIframe/preconnectWaasIframe.ts","../src/modules/deviceRegistration/isDeviceRegistrationRequired/isDeviceRegistrationRequired.ts","../src/modules/mfa/isPendingRecoveryCodesAcknowledgment/isPendingRecoveryCodesAcknowledgment.ts","../src/modules/user/isUserOnboardingComplete/isUserOnboardingComplete.ts"],"sourcesContent":["import { BaseError } from './base';\n\n/**\n * Why the embedded wallet load failed. Currently only retry exhaustion is\n * reported; the union exists so new reasons can be added without a breaking\n * change to consumer `instanceof` handling.\n *\n * @example\n * ```ts\n * const reason: WaasLoadFailedErrorReason = 'load_attempts_exhausted';\n * ```\n * @see WaasLoadFailedError\n * @see signMessage\n */\nexport type WaasLoadFailedErrorReason = 'load_attempts_exhausted';\n\n/**\n * Thrown when the embedded (WaaS) wallet's secure container failed to load\n * after exhausting all of its internal retry attempts.\n *\n * This failure is transient: the next wallet operation triggers a fresh load\n * cycle, so hosts can catch this error and re-attempt the operation at their\n * own cadence (for example, when connectivity returns or the app is\n * foregrounded). Other load failures (for example, a CSP block) are not\n * wrapped by this error and their shape is not guaranteed.\n *\n * @example\n * ```ts\n * try {\n * await signMessage({ message, walletAccount });\n * } catch (error) {\n * if (error instanceof WaasLoadFailedError) {\n * // transient — retry the operation at your own cadence\n * await signMessage({ message, walletAccount });\n * }\n * }\n * ```\n * @see WaasLoadFailedErrorReason\n * @see signMessage\n */\nexport class WaasLoadFailedError extends BaseError {\n readonly reason: WaasLoadFailedErrorReason;\n\n constructor({ cause }: { cause: Error }) {\n super({\n cause,\n code: 'waas_load_failed',\n docsUrl: null,\n name: 'WaasLoadFailedError',\n shortMessage:\n 'The embedded wallet failed to load after exhausting its retry attempts. Retrying the wallet operation triggers a fresh load.',\n });\n this.reason = 'load_attempts_exhausted';\n }\n}\n","import { BaseError } from './base';\n\n/**\n * Thrown when the embedded (WaaS) wallet client is requested before the user\n * has completed onboarding — i.e. the JWT has not upgraded to `user:basic`\n * because MFA, KYC, recovery-codes acknowledgment, or device registration is\n * still pending.\n *\n * The WaaS iframe's init-time room-cache pre-warm fires `createRooms` using the\n * token captured at client construction (before any per-operation token\n * resync). Building the client during this window lets that pre-warm fire with\n * a pre-`user:basic` token, get a 401, and the iframe's unauthorized handler\n * force-logs-out the user. Throwing here surfaces a clear, recoverable reason\n * instead — wait for onboarding to complete and retry.\n */\nexport class WaasOnboardingIncompleteError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'waas_onboarding_incomplete',\n docsUrl: null,\n name: 'WaasOnboardingIncompleteError',\n shortMessage:\n 'Cannot create or access the embedded wallet until onboarding is complete (pending MFA, KYC, recovery-codes acknowledgment, or device registration).',\n });\n }\n}\n","import { BaseError } from './base';\n\n/**\n * Thrown when a WaaS ceremony operation (sign, export, reshare, create\n * wallet) receives a 403 `rbac_stale` response after the attempt has already\n * spent its one-time authorization — either the legacy MFA token or a\n * single-use elevated access token.\n *\n * The SDK cannot safely retry in that case: the restarted attempt would find\n * the approval already consumed and fail deeper in the stack with an\n * unrelated \"no MFA token\" error, hiding the permission change that actually\n * caused the failure. Surfacing this error instead tells the host exactly what\n * happened. Recover by re-running the step-up/MFA flow and retrying the\n * operation; the business-account role change has already taken effect, so the\n * retry is evaluated against the caller's current permissions.\n *\n * @example\n * ```ts\n * try {\n * await signMessage({ message, walletAccount });\n * } catch (error) {\n * if (error instanceof WaasRbacStaleRetryUnsafeError) {\n * // The one-time approval was spent; re-verify before trying again.\n * await promptStepUp();\n * await signMessage({ message, walletAccount });\n * }\n * }\n * ```\n * @see WaasLoadFailedError\n * @see signMessage\n */\nexport class WaasRbacStaleRetryUnsafeError extends BaseError {\n constructor({ cause }: { cause: Error }) {\n super({\n cause,\n code: 'waas_rbac_stale_retry_unsafe',\n docsUrl: null,\n name: 'WaasRbacStaleRetryUnsafeError',\n shortMessage:\n 'The business account role change could not be retried automatically because a one-time authorization was already consumed. Re-authenticate and retry the operation.',\n });\n }\n}\n","import type { AuthMode } from '@dynamic-labs-wallet/browser-wallet-client';\nimport { preconnectWaasIframe as preconnectWaasIframeOrigin } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { isCookieEnabled } from '../../projectSettings/isCookieEnabled';\nimport { DEFAULT_WAAS_BASE_API_URL } from '../constants';\nimport { isDynamicWaasEnabled } from '../isDynamicWaasEnabled';\n\n/**\n * Warms the browser's connection (DNS + TCP + TLS) to the embedded-wallet\n * iframe origin so the iframe mounted after authentication completes loads on\n * a hot connection. Called when an auth flow starts (OTP send/verify, social\n * callback). Safe to call repeatedly; no-op on React Native / SSR and when\n * Dynamic WaaS is not enabled.\n *\n * @param client - The Dynamic client instance.\n * @notInstrumented\n */\nexport const preconnectWaasIframe = (client: DynamicClient): void => {\n const core = getCore(client);\n try {\n if (!isDynamicWaasEnabled(client)) return;\n\n preconnectWaasIframeOrigin({\n authMode: (isCookieEnabled(client) ? 'cookie' : 'header') as AuthMode,\n baseApiUrl: (core.apiBaseUrl || DEFAULT_WAAS_BASE_API_URL).replace(\n '/api/v0',\n ''\n ),\n });\n } catch (error) {\n // Best-effort: never break the auth flow (also swallows the assertion\n // from isDynamicWaasEnabled when project settings are not loaded yet).\n core.logger.warn('[preconnectWaasIframe] skipped', error);\n }\n};\n","import type { User } from '../../user/user.types';\n\n/**\n * Checks if device registration is required for the given user.\n *\n * This function determines if the user has the deviceRegistration\n * scope, indicating that device registration is required.\n *\n * @param user - The user to check.\n * @returns True if device registration is required, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when this device must be registered, updated when the user changes.\n */\nexport const isDeviceRegistrationRequired = (user: User): boolean =>\n Boolean(user.scope?.includes('device:register'));\n","import { MfaBackupCodeAcknowledgement } from '@dynamic-labs/sdk-api-core';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Checks if the user is still pending acknowledgment of their MFA recovery codes.\n *\n * This function determines whether the user has been presented with recovery\n * codes that they have not yet acknowledged as saved or backed up.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if recovery codes are pending acknowledgment, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when recovery codes await acknowledgment, updated when the user changes.\n */\nexport const isPendingRecoveryCodesAcknowledgment = (\n client = getDefaultClient()\n): boolean => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n return (\n user.mfaBackupCodeAcknowledgement === MfaBackupCodeAcknowledgement.Pending\n );\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { isDeviceRegistrationRequired } from '../../deviceRegistration/isDeviceRegistrationRequired';\nimport { isPendingRecoveryCodesAcknowledgment } from '../../mfa/isPendingRecoveryCodesAcknowledgment';\nimport { isUserMissingMfaAuth } from '../../mfa/isUserMissingMfaAuth';\n\n/**\n * Checks if the user has completed all onboarding requirements.\n *\n * This function verifies whether a user has fulfilled all necessary requirements\n * including KYC fields (Know Your Customer information), MFA setup\n * (Multi-Factor Authentication including recovery codes acknowledgment), and\n * device registration.\n *\n * A `false` result means the user still has an outstanding onboarding step, so\n * any feature that requires a fully onboarded (`user:basic`) user should hold\n * off until it returns `true`. Creating or accessing an embedded (WaaS) wallet\n * is one such feature — its backend calls reject a pre-`user:basic` token — but\n * this predicate is general and not specific to embedded wallets.\n *\n * @deprecated Use {@link checkUserScopes} instead. This function conflates\n * Dynamic-controlled requirements (MFA, device registration, required fields)\n * with the concept of \"onboarding complete\", which is app-specific. Replace\n * with `checkUserScopes({ user, scopes: ['user:basic'] })` to check whether\n * Dynamic's requirements are satisfied, and compose your own logic on top for\n * any app-specific onboarding steps.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if onboarding is complete (no pending requirements), false if there are pending requirements.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when onboarding is complete, updated when the user changes.\n */\nexport const isUserOnboardingComplete = (\n client = getDefaultClient()\n): boolean => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n const hasMissingKycFields = Boolean(user.missingFields?.length);\n const hasPendingMfaAuth = isUserMissingMfaAuth(client);\n const hasPendingRecoveryCodes = isPendingRecoveryCodesAcknowledgment(client);\n const hasPendingDeviceRegistration = isDeviceRegistrationRequired(user);\n\n const userOnboardingComplete =\n !hasMissingKycFields &&\n !hasPendingMfaAuth &&\n !hasPendingRecoveryCodes &&\n !hasPendingDeviceRegistration;\n\n return userOnboardingComplete;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,sBAAb,cAAyC,UAAU;CACjD,AAAS;CAET,YAAY,EAAE,SAA2B;AACvC,QAAM;GACJ;GACA,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;AACF,OAAK,SAAS;;;;;;;;;;;;;;;;;;;ACrClB,IAAa,gCAAb,cAAmD,UAAU;CAC3D,cAAc;AACZ,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACON,IAAa,gCAAb,cAAmD,UAAU;CAC3D,YAAY,EAAE,SAA2B;AACvC,QAAM;GACJ;GACA,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;;;;;;;;;;;;;;;;ACrBN,MAAaA,0BAAwB,WAAgC;CACnE,MAAM,OAAO,QAAQ,OAAO;AAC5B,KAAI;AACF,MAAI,CAAC,qBAAqB,OAAO,CAAE;AAEnC,uBAA2B;GACzB,UAAW,gBAAgB,OAAO,GAAG,WAAW;GAChD,aAAa,KAAK,cAAc,2BAA2B,QACzD,WACA,GACD;GACF,CAAC;UACK,OAAO;AAGd,OAAK,OAAO,KAAK,kCAAkC,MAAM;;;;;;;;;;;;;;;;;ACrB7D,MAAa,gCAAgC,SAC3C,QAAQ,KAAK,OAAO,SAAS,kBAAkB,CAAC;;;;;;;;;;;;;;;ACElD,MAAa,wCACX,SAAS,kBAAkB,KACf;CACZ,MAAM,OAAO,OAAO;AAEpB,eAAc,MAAM,qBAAqB;AAEzC,QACE,KAAK,iCAAiC,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQvE,MAAa,4BACX,SAAS,kBAAkB,KACf;CACZ,MAAM,OAAO,OAAO;AAEpB,eAAc,MAAM,qBAAqB;CAEzC,MAAM,sBAAsB,QAAQ,KAAK,eAAe,OAAO;CAC/D,MAAM,oBAAoB,qBAAqB,OAAO;CACtD,MAAM,0BAA0B,qCAAqC,OAAO;CAC5E,MAAM,+BAA+B,6BAA6B,KAAK;AAQvE,QALE,CAAC,uBACD,CAAC,qBACD,CAAC,2BACD,CAAC"}
|
package/dist/{isUserOnboardingComplete-DtxIznZD.cjs → isUserOnboardingComplete-Bwvv6Urs.cjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_logoutWithReason = require('./logoutWithReason-
|
|
2
|
-
const require_migrateFromFireblocks = require('./migrateFromFireblocks-
|
|
1
|
+
const require_logoutWithReason = require('./logoutWithReason-B-ZF0VmN.cjs');
|
|
2
|
+
const require_migrateFromFireblocks = require('./migrateFromFireblocks-C23-24bK.cjs');
|
|
3
3
|
let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
|
|
4
4
|
let _dynamic_labs_wallet_browser_wallet_client = require("@dynamic-labs-wallet/browser-wallet-client");
|
|
5
5
|
|
|
@@ -252,4 +252,4 @@ Object.defineProperty(exports, 'preconnectWaasIframe', {
|
|
|
252
252
|
return preconnectWaasIframe;
|
|
253
253
|
}
|
|
254
254
|
});
|
|
255
|
-
//# sourceMappingURL=isUserOnboardingComplete-
|
|
255
|
+
//# sourceMappingURL=isUserOnboardingComplete-Bwvv6Urs.cjs.map
|
package/dist/{isUserOnboardingComplete-DtxIznZD.cjs.map → isUserOnboardingComplete-Bwvv6Urs.cjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUserOnboardingComplete-DtxIznZD.cjs","names":["BaseError","BaseError","BaseError","getCore","isDynamicWaasEnabled","isCookieEnabled","DEFAULT_WAAS_BASE_API_URL","getDefaultClient","MfaBackupCodeAcknowledgement","getDefaultClient","isUserMissingMfaAuth"],"sources":["../src/errors/WaasLoadFailedError.ts","../src/errors/WaasOnboardingIncompleteError.ts","../src/errors/WaasRbacStaleRetryUnsafeError.ts","../src/modules/waas/preconnectWaasIframe/preconnectWaasIframe.ts","../src/modules/deviceRegistration/isDeviceRegistrationRequired/isDeviceRegistrationRequired.ts","../src/modules/mfa/isPendingRecoveryCodesAcknowledgment/isPendingRecoveryCodesAcknowledgment.ts","../src/modules/user/isUserOnboardingComplete/isUserOnboardingComplete.ts"],"sourcesContent":["import { BaseError } from './base';\n\n/**\n * Why the embedded wallet load failed. Currently only retry exhaustion is\n * reported; the union exists so new reasons can be added without a breaking\n * change to consumer `instanceof` handling.\n *\n * @example\n * ```ts\n * const reason: WaasLoadFailedErrorReason = 'load_attempts_exhausted';\n * ```\n * @see WaasLoadFailedError\n * @see signMessage\n */\nexport type WaasLoadFailedErrorReason = 'load_attempts_exhausted';\n\n/**\n * Thrown when the embedded (WaaS) wallet's secure container failed to load\n * after exhausting all of its internal retry attempts.\n *\n * This failure is transient: the next wallet operation triggers a fresh load\n * cycle, so hosts can catch this error and re-attempt the operation at their\n * own cadence (for example, when connectivity returns or the app is\n * foregrounded). Other load failures (for example, a CSP block) are not\n * wrapped by this error and their shape is not guaranteed.\n *\n * @example\n * ```ts\n * try {\n * await signMessage({ message, walletAccount });\n * } catch (error) {\n * if (error instanceof WaasLoadFailedError) {\n * // transient — retry the operation at your own cadence\n * await signMessage({ message, walletAccount });\n * }\n * }\n * ```\n * @see WaasLoadFailedErrorReason\n * @see signMessage\n */\nexport class WaasLoadFailedError extends BaseError {\n readonly reason: WaasLoadFailedErrorReason;\n\n constructor({ cause }: { cause: Error }) {\n super({\n cause,\n code: 'waas_load_failed',\n docsUrl: null,\n name: 'WaasLoadFailedError',\n shortMessage:\n 'The embedded wallet failed to load after exhausting its retry attempts. Retrying the wallet operation triggers a fresh load.',\n });\n this.reason = 'load_attempts_exhausted';\n }\n}\n","import { BaseError } from './base';\n\n/**\n * Thrown when the embedded (WaaS) wallet client is requested before the user\n * has completed onboarding — i.e. the JWT has not upgraded to `user:basic`\n * because MFA, KYC, recovery-codes acknowledgment, or device registration is\n * still pending.\n *\n * The WaaS iframe's init-time room-cache pre-warm fires `createRooms` using the\n * token captured at client construction (before any per-operation token\n * resync). Building the client during this window lets that pre-warm fire with\n * a pre-`user:basic` token, get a 401, and the iframe's unauthorized handler\n * force-logs-out the user. Throwing here surfaces a clear, recoverable reason\n * instead — wait for onboarding to complete and retry.\n */\nexport class WaasOnboardingIncompleteError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'waas_onboarding_incomplete',\n docsUrl: null,\n name: 'WaasOnboardingIncompleteError',\n shortMessage:\n 'Cannot create or access the embedded wallet until onboarding is complete (pending MFA, KYC, recovery-codes acknowledgment, or device registration).',\n });\n }\n}\n","import { BaseError } from './base';\n\n/**\n * Thrown when a WaaS ceremony operation (sign, export, reshare, create\n * wallet) receives a 403 `rbac_stale` response after the attempt has already\n * spent its one-time authorization — either the legacy MFA token or a\n * single-use elevated access token.\n *\n * The SDK cannot safely retry in that case: the restarted attempt would find\n * the approval already consumed and fail deeper in the stack with an\n * unrelated \"no MFA token\" error, hiding the permission change that actually\n * caused the failure. Surfacing this error instead tells the host exactly what\n * happened. Recover by re-running the step-up/MFA flow and retrying the\n * operation; the business-account role change has already taken effect, so the\n * retry is evaluated against the caller's current permissions.\n *\n * @example\n * ```ts\n * try {\n * await signMessage({ message, walletAccount });\n * } catch (error) {\n * if (error instanceof WaasRbacStaleRetryUnsafeError) {\n * // The one-time approval was spent; re-verify before trying again.\n * await promptStepUp();\n * await signMessage({ message, walletAccount });\n * }\n * }\n * ```\n * @see WaasLoadFailedError\n * @see signMessage\n */\nexport class WaasRbacStaleRetryUnsafeError extends BaseError {\n constructor({ cause }: { cause: Error }) {\n super({\n cause,\n code: 'waas_rbac_stale_retry_unsafe',\n docsUrl: null,\n name: 'WaasRbacStaleRetryUnsafeError',\n shortMessage:\n 'The business account role change could not be retried automatically because a one-time authorization was already consumed. Re-authenticate and retry the operation.',\n });\n }\n}\n","import type { AuthMode } from '@dynamic-labs-wallet/browser-wallet-client';\nimport { preconnectWaasIframe as preconnectWaasIframeOrigin } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { isCookieEnabled } from '../../projectSettings/isCookieEnabled';\nimport { DEFAULT_WAAS_BASE_API_URL } from '../constants';\nimport { isDynamicWaasEnabled } from '../isDynamicWaasEnabled';\n\n/**\n * Warms the browser's connection (DNS + TCP + TLS) to the embedded-wallet\n * iframe origin so the iframe mounted after authentication completes loads on\n * a hot connection. Called when an auth flow starts (OTP send/verify, social\n * callback). Safe to call repeatedly; no-op on React Native / SSR and when\n * Dynamic WaaS is not enabled.\n *\n * @param client - The Dynamic client instance.\n * @notInstrumented\n */\nexport const preconnectWaasIframe = (client: DynamicClient): void => {\n const core = getCore(client);\n try {\n if (!isDynamicWaasEnabled(client)) return;\n\n preconnectWaasIframeOrigin({\n authMode: (isCookieEnabled(client) ? 'cookie' : 'header') as AuthMode,\n baseApiUrl: (core.apiBaseUrl || DEFAULT_WAAS_BASE_API_URL).replace(\n '/api/v0',\n ''\n ),\n });\n } catch (error) {\n // Best-effort: never break the auth flow (also swallows the assertion\n // from isDynamicWaasEnabled when project settings are not loaded yet).\n core.logger.warn('[preconnectWaasIframe] skipped', error);\n }\n};\n","import type { User } from '../../user/user.types';\n\n/**\n * Checks if device registration is required for the given user.\n *\n * This function determines if the user has the deviceRegistration\n * scope, indicating that device registration is required.\n *\n * @param user - The user to check.\n * @returns True if device registration is required, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when this device must be registered, updated when the user changes.\n */\nexport const isDeviceRegistrationRequired = (user: User): boolean =>\n Boolean(user.scope?.includes('device:register'));\n","import { MfaBackupCodeAcknowledgement } from '@dynamic-labs/sdk-api-core';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Checks if the user is still pending acknowledgment of their MFA recovery codes.\n *\n * This function determines whether the user has been presented with recovery\n * codes that they have not yet acknowledged as saved or backed up.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if recovery codes are pending acknowledgment, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when recovery codes await acknowledgment, updated when the user changes.\n */\nexport const isPendingRecoveryCodesAcknowledgment = (\n client = getDefaultClient()\n): boolean => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n return (\n user.mfaBackupCodeAcknowledgement === MfaBackupCodeAcknowledgement.Pending\n );\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { isDeviceRegistrationRequired } from '../../deviceRegistration/isDeviceRegistrationRequired';\nimport { isPendingRecoveryCodesAcknowledgment } from '../../mfa/isPendingRecoveryCodesAcknowledgment';\nimport { isUserMissingMfaAuth } from '../../mfa/isUserMissingMfaAuth';\n\n/**\n * Checks if the user has completed all onboarding requirements.\n *\n * This function verifies whether a user has fulfilled all necessary requirements\n * including KYC fields (Know Your Customer information), MFA setup\n * (Multi-Factor Authentication including recovery codes acknowledgment), and\n * device registration.\n *\n * A `false` result means the user still has an outstanding onboarding step, so\n * any feature that requires a fully onboarded (`user:basic`) user should hold\n * off until it returns `true`. Creating or accessing an embedded (WaaS) wallet\n * is one such feature — its backend calls reject a pre-`user:basic` token — but\n * this predicate is general and not specific to embedded wallets.\n *\n * @deprecated Use {@link checkUserScopes} instead. This function conflates\n * Dynamic-controlled requirements (MFA, device registration, required fields)\n * with the concept of \"onboarding complete\", which is app-specific. Replace\n * with `checkUserScopes({ user, scopes: ['user:basic'] })` to check whether\n * Dynamic's requirements are satisfied, and compose your own logic on top for\n * any app-specific onboarding steps.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if onboarding is complete (no pending requirements), false if there are pending requirements.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when onboarding is complete, updated when the user changes.\n */\nexport const isUserOnboardingComplete = (\n client = getDefaultClient()\n): boolean => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n const hasMissingKycFields = Boolean(user.missingFields?.length);\n const hasPendingMfaAuth = isUserMissingMfaAuth(client);\n const hasPendingRecoveryCodes = isPendingRecoveryCodesAcknowledgment(client);\n const hasPendingDeviceRegistration = isDeviceRegistrationRequired(user);\n\n const userOnboardingComplete =\n !hasMissingKycFields &&\n !hasPendingMfaAuth &&\n !hasPendingRecoveryCodes &&\n !hasPendingDeviceRegistration;\n\n return userOnboardingComplete;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,sBAAb,cAAyCA,mCAAU;CACjD,AAAS;CAET,YAAY,EAAE,SAA2B;AACvC,QAAM;GACJ;GACA,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;AACF,OAAK,SAAS;;;;;;;;;;;;;;;;;;;ACrClB,IAAa,gCAAb,cAAmDC,mCAAU;CAC3D,cAAc;AACZ,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACON,IAAa,gCAAb,cAAmDC,mCAAU;CAC3D,YAAY,EAAE,SAA2B;AACvC,QAAM;GACJ;GACA,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;;;;;;;;;;;;;;;;ACrBN,MAAa,wBAAwB,WAAgC;CACnE,MAAM,OAAOC,iCAAQ,OAAO;AAC5B,KAAI;AACF,MAAI,CAACC,mDAAqB,OAAO,CAAE;AAEnC,uEAA2B;GACzB,UAAWC,yCAAgB,OAAO,GAAG,WAAW;GAChD,aAAa,KAAK,cAAcC,oDAA2B,QACzD,WACA,GACD;GACF,CAAC;UACK,OAAO;AAGd,OAAK,OAAO,KAAK,kCAAkC,MAAM;;;;;;;;;;;;;;;;;ACrB7D,MAAa,gCAAgC,SAC3C,QAAQ,KAAK,OAAO,SAAS,kBAAkB,CAAC;;;;;;;;;;;;;;;ACElD,MAAa,wCACX,SAASC,2CAAkB,KACf;CACZ,MAAM,OAAO,OAAO;AAEpB,wCAAc,MAAM,qBAAqB;AAEzC,QACE,KAAK,iCAAiCC,wDAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQvE,MAAa,4BACX,SAASC,2CAAkB,KACf;CACZ,MAAM,OAAO,OAAO;AAEpB,wCAAc,MAAM,qBAAqB;CAEzC,MAAM,sBAAsB,QAAQ,KAAK,eAAe,OAAO;CAC/D,MAAM,oBAAoBC,8CAAqB,OAAO;CACtD,MAAM,0BAA0B,qCAAqC,OAAO;CAC5E,MAAM,+BAA+B,6BAA6B,KAAK;AAQvE,QALE,CAAC,uBACD,CAAC,qBACD,CAAC,2BACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"isUserOnboardingComplete-Bwvv6Urs.cjs","names":["BaseError","BaseError","BaseError","getCore","isDynamicWaasEnabled","isCookieEnabled","DEFAULT_WAAS_BASE_API_URL","getDefaultClient","MfaBackupCodeAcknowledgement","getDefaultClient","isUserMissingMfaAuth"],"sources":["../src/errors/WaasLoadFailedError.ts","../src/errors/WaasOnboardingIncompleteError.ts","../src/errors/WaasRbacStaleRetryUnsafeError.ts","../src/modules/waas/preconnectWaasIframe/preconnectWaasIframe.ts","../src/modules/deviceRegistration/isDeviceRegistrationRequired/isDeviceRegistrationRequired.ts","../src/modules/mfa/isPendingRecoveryCodesAcknowledgment/isPendingRecoveryCodesAcknowledgment.ts","../src/modules/user/isUserOnboardingComplete/isUserOnboardingComplete.ts"],"sourcesContent":["import { BaseError } from './base';\n\n/**\n * Why the embedded wallet load failed. Currently only retry exhaustion is\n * reported; the union exists so new reasons can be added without a breaking\n * change to consumer `instanceof` handling.\n *\n * @example\n * ```ts\n * const reason: WaasLoadFailedErrorReason = 'load_attempts_exhausted';\n * ```\n * @see WaasLoadFailedError\n * @see signMessage\n */\nexport type WaasLoadFailedErrorReason = 'load_attempts_exhausted';\n\n/**\n * Thrown when the embedded (WaaS) wallet's secure container failed to load\n * after exhausting all of its internal retry attempts.\n *\n * This failure is transient: the next wallet operation triggers a fresh load\n * cycle, so hosts can catch this error and re-attempt the operation at their\n * own cadence (for example, when connectivity returns or the app is\n * foregrounded). Other load failures (for example, a CSP block) are not\n * wrapped by this error and their shape is not guaranteed.\n *\n * @example\n * ```ts\n * try {\n * await signMessage({ message, walletAccount });\n * } catch (error) {\n * if (error instanceof WaasLoadFailedError) {\n * // transient — retry the operation at your own cadence\n * await signMessage({ message, walletAccount });\n * }\n * }\n * ```\n * @see WaasLoadFailedErrorReason\n * @see signMessage\n */\nexport class WaasLoadFailedError extends BaseError {\n readonly reason: WaasLoadFailedErrorReason;\n\n constructor({ cause }: { cause: Error }) {\n super({\n cause,\n code: 'waas_load_failed',\n docsUrl: null,\n name: 'WaasLoadFailedError',\n shortMessage:\n 'The embedded wallet failed to load after exhausting its retry attempts. Retrying the wallet operation triggers a fresh load.',\n });\n this.reason = 'load_attempts_exhausted';\n }\n}\n","import { BaseError } from './base';\n\n/**\n * Thrown when the embedded (WaaS) wallet client is requested before the user\n * has completed onboarding — i.e. the JWT has not upgraded to `user:basic`\n * because MFA, KYC, recovery-codes acknowledgment, or device registration is\n * still pending.\n *\n * The WaaS iframe's init-time room-cache pre-warm fires `createRooms` using the\n * token captured at client construction (before any per-operation token\n * resync). Building the client during this window lets that pre-warm fire with\n * a pre-`user:basic` token, get a 401, and the iframe's unauthorized handler\n * force-logs-out the user. Throwing here surfaces a clear, recoverable reason\n * instead — wait for onboarding to complete and retry.\n */\nexport class WaasOnboardingIncompleteError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'waas_onboarding_incomplete',\n docsUrl: null,\n name: 'WaasOnboardingIncompleteError',\n shortMessage:\n 'Cannot create or access the embedded wallet until onboarding is complete (pending MFA, KYC, recovery-codes acknowledgment, or device registration).',\n });\n }\n}\n","import { BaseError } from './base';\n\n/**\n * Thrown when a WaaS ceremony operation (sign, export, reshare, create\n * wallet) receives a 403 `rbac_stale` response after the attempt has already\n * spent its one-time authorization — either the legacy MFA token or a\n * single-use elevated access token.\n *\n * The SDK cannot safely retry in that case: the restarted attempt would find\n * the approval already consumed and fail deeper in the stack with an\n * unrelated \"no MFA token\" error, hiding the permission change that actually\n * caused the failure. Surfacing this error instead tells the host exactly what\n * happened. Recover by re-running the step-up/MFA flow and retrying the\n * operation; the business-account role change has already taken effect, so the\n * retry is evaluated against the caller's current permissions.\n *\n * @example\n * ```ts\n * try {\n * await signMessage({ message, walletAccount });\n * } catch (error) {\n * if (error instanceof WaasRbacStaleRetryUnsafeError) {\n * // The one-time approval was spent; re-verify before trying again.\n * await promptStepUp();\n * await signMessage({ message, walletAccount });\n * }\n * }\n * ```\n * @see WaasLoadFailedError\n * @see signMessage\n */\nexport class WaasRbacStaleRetryUnsafeError extends BaseError {\n constructor({ cause }: { cause: Error }) {\n super({\n cause,\n code: 'waas_rbac_stale_retry_unsafe',\n docsUrl: null,\n name: 'WaasRbacStaleRetryUnsafeError',\n shortMessage:\n 'The business account role change could not be retried automatically because a one-time authorization was already consumed. Re-authenticate and retry the operation.',\n });\n }\n}\n","import type { AuthMode } from '@dynamic-labs-wallet/browser-wallet-client';\nimport { preconnectWaasIframe as preconnectWaasIframeOrigin } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { isCookieEnabled } from '../../projectSettings/isCookieEnabled';\nimport { DEFAULT_WAAS_BASE_API_URL } from '../constants';\nimport { isDynamicWaasEnabled } from '../isDynamicWaasEnabled';\n\n/**\n * Warms the browser's connection (DNS + TCP + TLS) to the embedded-wallet\n * iframe origin so the iframe mounted after authentication completes loads on\n * a hot connection. Called when an auth flow starts (OTP send/verify, social\n * callback). Safe to call repeatedly; no-op on React Native / SSR and when\n * Dynamic WaaS is not enabled.\n *\n * @param client - The Dynamic client instance.\n * @notInstrumented\n */\nexport const preconnectWaasIframe = (client: DynamicClient): void => {\n const core = getCore(client);\n try {\n if (!isDynamicWaasEnabled(client)) return;\n\n preconnectWaasIframeOrigin({\n authMode: (isCookieEnabled(client) ? 'cookie' : 'header') as AuthMode,\n baseApiUrl: (core.apiBaseUrl || DEFAULT_WAAS_BASE_API_URL).replace(\n '/api/v0',\n ''\n ),\n });\n } catch (error) {\n // Best-effort: never break the auth flow (also swallows the assertion\n // from isDynamicWaasEnabled when project settings are not loaded yet).\n core.logger.warn('[preconnectWaasIframe] skipped', error);\n }\n};\n","import type { User } from '../../user/user.types';\n\n/**\n * Checks if device registration is required for the given user.\n *\n * This function determines if the user has the deviceRegistration\n * scope, indicating that device registration is required.\n *\n * @param user - The user to check.\n * @returns True if device registration is required, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when this device must be registered, updated when the user changes.\n */\nexport const isDeviceRegistrationRequired = (user: User): boolean =>\n Boolean(user.scope?.includes('device:register'));\n","import { MfaBackupCodeAcknowledgement } from '@dynamic-labs/sdk-api-core';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Checks if the user is still pending acknowledgment of their MFA recovery codes.\n *\n * This function determines whether the user has been presented with recovery\n * codes that they have not yet acknowledged as saved or backed up.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if recovery codes are pending acknowledgment, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when recovery codes await acknowledgment, updated when the user changes.\n */\nexport const isPendingRecoveryCodesAcknowledgment = (\n client = getDefaultClient()\n): boolean => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n return (\n user.mfaBackupCodeAcknowledgement === MfaBackupCodeAcknowledgement.Pending\n );\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { isDeviceRegistrationRequired } from '../../deviceRegistration/isDeviceRegistrationRequired';\nimport { isPendingRecoveryCodesAcknowledgment } from '../../mfa/isPendingRecoveryCodesAcknowledgment';\nimport { isUserMissingMfaAuth } from '../../mfa/isUserMissingMfaAuth';\n\n/**\n * Checks if the user has completed all onboarding requirements.\n *\n * This function verifies whether a user has fulfilled all necessary requirements\n * including KYC fields (Know Your Customer information), MFA setup\n * (Multi-Factor Authentication including recovery codes acknowledgment), and\n * device registration.\n *\n * A `false` result means the user still has an outstanding onboarding step, so\n * any feature that requires a fully onboarded (`user:basic`) user should hold\n * off until it returns `true`. Creating or accessing an embedded (WaaS) wallet\n * is one such feature — its backend calls reject a pre-`user:basic` token — but\n * this predicate is general and not specific to embedded wallets.\n *\n * @deprecated Use {@link checkUserScopes} instead. This function conflates\n * Dynamic-controlled requirements (MFA, device registration, required fields)\n * with the concept of \"onboarding complete\", which is app-specific. Replace\n * with `checkUserScopes({ user, scopes: ['user:basic'] })` to check whether\n * Dynamic's requirements are satisfied, and compose your own logic on top for\n * any app-specific onboarding steps.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if onboarding is complete (no pending requirements), false if there are pending requirements.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when onboarding is complete, updated when the user changes.\n */\nexport const isUserOnboardingComplete = (\n client = getDefaultClient()\n): boolean => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n const hasMissingKycFields = Boolean(user.missingFields?.length);\n const hasPendingMfaAuth = isUserMissingMfaAuth(client);\n const hasPendingRecoveryCodes = isPendingRecoveryCodesAcknowledgment(client);\n const hasPendingDeviceRegistration = isDeviceRegistrationRequired(user);\n\n const userOnboardingComplete =\n !hasMissingKycFields &&\n !hasPendingMfaAuth &&\n !hasPendingRecoveryCodes &&\n !hasPendingDeviceRegistration;\n\n return userOnboardingComplete;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,sBAAb,cAAyCA,mCAAU;CACjD,AAAS;CAET,YAAY,EAAE,SAA2B;AACvC,QAAM;GACJ;GACA,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;AACF,OAAK,SAAS;;;;;;;;;;;;;;;;;;;ACrClB,IAAa,gCAAb,cAAmDC,mCAAU;CAC3D,cAAc;AACZ,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACON,IAAa,gCAAb,cAAmDC,mCAAU;CAC3D,YAAY,EAAE,SAA2B;AACvC,QAAM;GACJ;GACA,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;;;;;;;;;;;;;;;;ACrBN,MAAa,wBAAwB,WAAgC;CACnE,MAAM,OAAOC,iCAAQ,OAAO;AAC5B,KAAI;AACF,MAAI,CAACC,mDAAqB,OAAO,CAAE;AAEnC,uEAA2B;GACzB,UAAWC,yCAAgB,OAAO,GAAG,WAAW;GAChD,aAAa,KAAK,cAAcC,oDAA2B,QACzD,WACA,GACD;GACF,CAAC;UACK,OAAO;AAGd,OAAK,OAAO,KAAK,kCAAkC,MAAM;;;;;;;;;;;;;;;;;ACrB7D,MAAa,gCAAgC,SAC3C,QAAQ,KAAK,OAAO,SAAS,kBAAkB,CAAC;;;;;;;;;;;;;;;ACElD,MAAa,wCACX,SAASC,2CAAkB,KACf;CACZ,MAAM,OAAO,OAAO;AAEpB,wCAAc,MAAM,qBAAqB;AAEzC,QACE,KAAK,iCAAiCC,wDAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQvE,MAAa,4BACX,SAASC,2CAAkB,KACf;CACZ,MAAM,OAAO,OAAO;AAEpB,wCAAc,MAAM,qBAAqB;CAEzC,MAAM,sBAAsB,QAAQ,KAAK,eAAe,OAAO;CAC/D,MAAM,oBAAoBC,8CAAqB,OAAO;CACtD,MAAM,0BAA0B,qCAAqC,OAAO;CAC5E,MAAM,+BAA+B,6BAA6B,KAAK;AAQvE,QALE,CAAC,uBACD,CAAC,qBACD,CAAC,2BACD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as isDynamicWaasEnabled } from "./migrateFromFireblocks-
|
|
1
|
+
import { C as DEFAULT_WAAS_BASE_API_URL, Ct as getCore, U as isUserMissingMfaAuth, bt as getDefaultClient, ht as assertDefined, mt as isCookieEnabled, wt as BaseError } from "./apiClient-4r7VAsLC.native.esm.js";
|
|
2
|
+
import { n as isDynamicWaasEnabled } from "./migrateFromFireblocks-6I7lkraQ.native.esm.js";
|
|
3
3
|
import { MfaBackupCodeAcknowledgement } from "@dynamic-labs/sdk-api-core";
|
|
4
4
|
import { preconnectWaasIframe } from "@dynamic-labs-wallet/browser-wallet-client";
|
|
5
5
|
|
|
@@ -211,4 +211,4 @@ const isUserOnboardingComplete = (client = getDefaultClient()) => {
|
|
|
211
211
|
|
|
212
212
|
//#endregion
|
|
213
213
|
export { WaasRbacStaleRetryUnsafeError as a, preconnectWaasIframe$1 as i, isPendingRecoveryCodesAcknowledgment as n, WaasOnboardingIncompleteError as o, isDeviceRegistrationRequired as r, WaasLoadFailedError as s, isUserOnboardingComplete as t };
|
|
214
|
-
//# sourceMappingURL=isUserOnboardingComplete-
|
|
214
|
+
//# sourceMappingURL=isUserOnboardingComplete-CEUkAzCi.native.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUserOnboardingComplete-BWrCHXXO.native.esm.js","names":["preconnectWaasIframe"],"sources":["../src/errors/WaasLoadFailedError.ts","../src/errors/WaasOnboardingIncompleteError.ts","../src/errors/WaasRbacStaleRetryUnsafeError.ts","../src/modules/waas/preconnectWaasIframe/preconnectWaasIframe.ts","../src/modules/deviceRegistration/isDeviceRegistrationRequired/isDeviceRegistrationRequired.ts","../src/modules/mfa/isPendingRecoveryCodesAcknowledgment/isPendingRecoveryCodesAcknowledgment.ts","../src/modules/user/isUserOnboardingComplete/isUserOnboardingComplete.ts"],"sourcesContent":["import { BaseError } from './base';\n\n/**\n * Why the embedded wallet load failed. Currently only retry exhaustion is\n * reported; the union exists so new reasons can be added without a breaking\n * change to consumer `instanceof` handling.\n *\n * @example\n * ```ts\n * const reason: WaasLoadFailedErrorReason = 'load_attempts_exhausted';\n * ```\n * @see WaasLoadFailedError\n * @see signMessage\n */\nexport type WaasLoadFailedErrorReason = 'load_attempts_exhausted';\n\n/**\n * Thrown when the embedded (WaaS) wallet's secure container failed to load\n * after exhausting all of its internal retry attempts.\n *\n * This failure is transient: the next wallet operation triggers a fresh load\n * cycle, so hosts can catch this error and re-attempt the operation at their\n * own cadence (for example, when connectivity returns or the app is\n * foregrounded). Other load failures (for example, a CSP block) are not\n * wrapped by this error and their shape is not guaranteed.\n *\n * @example\n * ```ts\n * try {\n * await signMessage({ message, walletAccount });\n * } catch (error) {\n * if (error instanceof WaasLoadFailedError) {\n * // transient — retry the operation at your own cadence\n * await signMessage({ message, walletAccount });\n * }\n * }\n * ```\n * @see WaasLoadFailedErrorReason\n * @see signMessage\n */\nexport class WaasLoadFailedError extends BaseError {\n readonly reason: WaasLoadFailedErrorReason;\n\n constructor({ cause }: { cause: Error }) {\n super({\n cause,\n code: 'waas_load_failed',\n docsUrl: null,\n name: 'WaasLoadFailedError',\n shortMessage:\n 'The embedded wallet failed to load after exhausting its retry attempts. Retrying the wallet operation triggers a fresh load.',\n });\n this.reason = 'load_attempts_exhausted';\n }\n}\n","import { BaseError } from './base';\n\n/**\n * Thrown when the embedded (WaaS) wallet client is requested before the user\n * has completed onboarding — i.e. the JWT has not upgraded to `user:basic`\n * because MFA, KYC, recovery-codes acknowledgment, or device registration is\n * still pending.\n *\n * The WaaS iframe's init-time room-cache pre-warm fires `createRooms` using the\n * token captured at client construction (before any per-operation token\n * resync). Building the client during this window lets that pre-warm fire with\n * a pre-`user:basic` token, get a 401, and the iframe's unauthorized handler\n * force-logs-out the user. Throwing here surfaces a clear, recoverable reason\n * instead — wait for onboarding to complete and retry.\n */\nexport class WaasOnboardingIncompleteError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'waas_onboarding_incomplete',\n docsUrl: null,\n name: 'WaasOnboardingIncompleteError',\n shortMessage:\n 'Cannot create or access the embedded wallet until onboarding is complete (pending MFA, KYC, recovery-codes acknowledgment, or device registration).',\n });\n }\n}\n","import { BaseError } from './base';\n\n/**\n * Thrown when a WaaS ceremony operation (sign, export, reshare, create\n * wallet) receives a 403 `rbac_stale` response after the attempt has already\n * spent its one-time authorization — either the legacy MFA token or a\n * single-use elevated access token.\n *\n * The SDK cannot safely retry in that case: the restarted attempt would find\n * the approval already consumed and fail deeper in the stack with an\n * unrelated \"no MFA token\" error, hiding the permission change that actually\n * caused the failure. Surfacing this error instead tells the host exactly what\n * happened. Recover by re-running the step-up/MFA flow and retrying the\n * operation; the business-account role change has already taken effect, so the\n * retry is evaluated against the caller's current permissions.\n *\n * @example\n * ```ts\n * try {\n * await signMessage({ message, walletAccount });\n * } catch (error) {\n * if (error instanceof WaasRbacStaleRetryUnsafeError) {\n * // The one-time approval was spent; re-verify before trying again.\n * await promptStepUp();\n * await signMessage({ message, walletAccount });\n * }\n * }\n * ```\n * @see WaasLoadFailedError\n * @see signMessage\n */\nexport class WaasRbacStaleRetryUnsafeError extends BaseError {\n constructor({ cause }: { cause: Error }) {\n super({\n cause,\n code: 'waas_rbac_stale_retry_unsafe',\n docsUrl: null,\n name: 'WaasRbacStaleRetryUnsafeError',\n shortMessage:\n 'The business account role change could not be retried automatically because a one-time authorization was already consumed. Re-authenticate and retry the operation.',\n });\n }\n}\n","import type { AuthMode } from '@dynamic-labs-wallet/browser-wallet-client';\nimport { preconnectWaasIframe as preconnectWaasIframeOrigin } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { isCookieEnabled } from '../../projectSettings/isCookieEnabled';\nimport { DEFAULT_WAAS_BASE_API_URL } from '../constants';\nimport { isDynamicWaasEnabled } from '../isDynamicWaasEnabled';\n\n/**\n * Warms the browser's connection (DNS + TCP + TLS) to the embedded-wallet\n * iframe origin so the iframe mounted after authentication completes loads on\n * a hot connection. Called when an auth flow starts (OTP send/verify, social\n * callback). Safe to call repeatedly; no-op on React Native / SSR and when\n * Dynamic WaaS is not enabled.\n *\n * @param client - The Dynamic client instance.\n * @notInstrumented\n */\nexport const preconnectWaasIframe = (client: DynamicClient): void => {\n const core = getCore(client);\n try {\n if (!isDynamicWaasEnabled(client)) return;\n\n preconnectWaasIframeOrigin({\n authMode: (isCookieEnabled(client) ? 'cookie' : 'header') as AuthMode,\n baseApiUrl: (core.apiBaseUrl || DEFAULT_WAAS_BASE_API_URL).replace(\n '/api/v0',\n ''\n ),\n });\n } catch (error) {\n // Best-effort: never break the auth flow (also swallows the assertion\n // from isDynamicWaasEnabled when project settings are not loaded yet).\n core.logger.warn('[preconnectWaasIframe] skipped', error);\n }\n};\n","import type { User } from '../../user/user.types';\n\n/**\n * Checks if device registration is required for the given user.\n *\n * This function determines if the user has the deviceRegistration\n * scope, indicating that device registration is required.\n *\n * @param user - The user to check.\n * @returns True if device registration is required, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when this device must be registered, updated when the user changes.\n */\nexport const isDeviceRegistrationRequired = (user: User): boolean =>\n Boolean(user.scope?.includes('device:register'));\n","import { MfaBackupCodeAcknowledgement } from '@dynamic-labs/sdk-api-core';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Checks if the user is still pending acknowledgment of their MFA recovery codes.\n *\n * This function determines whether the user has been presented with recovery\n * codes that they have not yet acknowledged as saved or backed up.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if recovery codes are pending acknowledgment, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when recovery codes await acknowledgment, updated when the user changes.\n */\nexport const isPendingRecoveryCodesAcknowledgment = (\n client = getDefaultClient()\n): boolean => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n return (\n user.mfaBackupCodeAcknowledgement === MfaBackupCodeAcknowledgement.Pending\n );\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { isDeviceRegistrationRequired } from '../../deviceRegistration/isDeviceRegistrationRequired';\nimport { isPendingRecoveryCodesAcknowledgment } from '../../mfa/isPendingRecoveryCodesAcknowledgment';\nimport { isUserMissingMfaAuth } from '../../mfa/isUserMissingMfaAuth';\n\n/**\n * Checks if the user has completed all onboarding requirements.\n *\n * This function verifies whether a user has fulfilled all necessary requirements\n * including KYC fields (Know Your Customer information), MFA setup\n * (Multi-Factor Authentication including recovery codes acknowledgment), and\n * device registration.\n *\n * A `false` result means the user still has an outstanding onboarding step, so\n * any feature that requires a fully onboarded (`user:basic`) user should hold\n * off until it returns `true`. Creating or accessing an embedded (WaaS) wallet\n * is one such feature — its backend calls reject a pre-`user:basic` token — but\n * this predicate is general and not specific to embedded wallets.\n *\n * @deprecated Use {@link checkUserScopes} instead. This function conflates\n * Dynamic-controlled requirements (MFA, device registration, required fields)\n * with the concept of \"onboarding complete\", which is app-specific. Replace\n * with `checkUserScopes({ user, scopes: ['user:basic'] })` to check whether\n * Dynamic's requirements are satisfied, and compose your own logic on top for\n * any app-specific onboarding steps.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if onboarding is complete (no pending requirements), false if there are pending requirements.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when onboarding is complete, updated when the user changes.\n */\nexport const isUserOnboardingComplete = (\n client = getDefaultClient()\n): boolean => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n const hasMissingKycFields = Boolean(user.missingFields?.length);\n const hasPendingMfaAuth = isUserMissingMfaAuth(client);\n const hasPendingRecoveryCodes = isPendingRecoveryCodesAcknowledgment(client);\n const hasPendingDeviceRegistration = isDeviceRegistrationRequired(user);\n\n const userOnboardingComplete =\n !hasMissingKycFields &&\n !hasPendingMfaAuth &&\n !hasPendingRecoveryCodes &&\n !hasPendingDeviceRegistration;\n\n return userOnboardingComplete;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,sBAAb,cAAyC,UAAU;CACjD,AAAS;CAET,YAAY,EAAE,SAA2B;AACvC,QAAM;GACJ;GACA,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;AACF,OAAK,SAAS;;;;;;;;;;;;;;;;;;;ACrClB,IAAa,gCAAb,cAAmD,UAAU;CAC3D,cAAc;AACZ,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACON,IAAa,gCAAb,cAAmD,UAAU;CAC3D,YAAY,EAAE,SAA2B;AACvC,QAAM;GACJ;GACA,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;;;;;;;;;;;;;;;;ACrBN,MAAaA,0BAAwB,WAAgC;CACnE,MAAM,OAAO,QAAQ,OAAO;AAC5B,KAAI;AACF,MAAI,CAAC,qBAAqB,OAAO,CAAE;AAEnC,uBAA2B;GACzB,UAAW,gBAAgB,OAAO,GAAG,WAAW;GAChD,aAAa,KAAK,cAAc,2BAA2B,QACzD,WACA,GACD;GACF,CAAC;UACK,OAAO;AAGd,OAAK,OAAO,KAAK,kCAAkC,MAAM;;;;;;;;;;;;;;;;;ACrB7D,MAAa,gCAAgC,SAC3C,QAAQ,KAAK,OAAO,SAAS,kBAAkB,CAAC;;;;;;;;;;;;;;;ACElD,MAAa,wCACX,SAAS,kBAAkB,KACf;CACZ,MAAM,OAAO,OAAO;AAEpB,eAAc,MAAM,qBAAqB;AAEzC,QACE,KAAK,iCAAiC,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQvE,MAAa,4BACX,SAAS,kBAAkB,KACf;CACZ,MAAM,OAAO,OAAO;AAEpB,eAAc,MAAM,qBAAqB;CAEzC,MAAM,sBAAsB,QAAQ,KAAK,eAAe,OAAO;CAC/D,MAAM,oBAAoB,qBAAqB,OAAO;CACtD,MAAM,0BAA0B,qCAAqC,OAAO;CAC5E,MAAM,+BAA+B,6BAA6B,KAAK;AAQvE,QALE,CAAC,uBACD,CAAC,qBACD,CAAC,2BACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"isUserOnboardingComplete-CEUkAzCi.native.esm.js","names":["preconnectWaasIframe"],"sources":["../src/errors/WaasLoadFailedError.ts","../src/errors/WaasOnboardingIncompleteError.ts","../src/errors/WaasRbacStaleRetryUnsafeError.ts","../src/modules/waas/preconnectWaasIframe/preconnectWaasIframe.ts","../src/modules/deviceRegistration/isDeviceRegistrationRequired/isDeviceRegistrationRequired.ts","../src/modules/mfa/isPendingRecoveryCodesAcknowledgment/isPendingRecoveryCodesAcknowledgment.ts","../src/modules/user/isUserOnboardingComplete/isUserOnboardingComplete.ts"],"sourcesContent":["import { BaseError } from './base';\n\n/**\n * Why the embedded wallet load failed. Currently only retry exhaustion is\n * reported; the union exists so new reasons can be added without a breaking\n * change to consumer `instanceof` handling.\n *\n * @example\n * ```ts\n * const reason: WaasLoadFailedErrorReason = 'load_attempts_exhausted';\n * ```\n * @see WaasLoadFailedError\n * @see signMessage\n */\nexport type WaasLoadFailedErrorReason = 'load_attempts_exhausted';\n\n/**\n * Thrown when the embedded (WaaS) wallet's secure container failed to load\n * after exhausting all of its internal retry attempts.\n *\n * This failure is transient: the next wallet operation triggers a fresh load\n * cycle, so hosts can catch this error and re-attempt the operation at their\n * own cadence (for example, when connectivity returns or the app is\n * foregrounded). Other load failures (for example, a CSP block) are not\n * wrapped by this error and their shape is not guaranteed.\n *\n * @example\n * ```ts\n * try {\n * await signMessage({ message, walletAccount });\n * } catch (error) {\n * if (error instanceof WaasLoadFailedError) {\n * // transient — retry the operation at your own cadence\n * await signMessage({ message, walletAccount });\n * }\n * }\n * ```\n * @see WaasLoadFailedErrorReason\n * @see signMessage\n */\nexport class WaasLoadFailedError extends BaseError {\n readonly reason: WaasLoadFailedErrorReason;\n\n constructor({ cause }: { cause: Error }) {\n super({\n cause,\n code: 'waas_load_failed',\n docsUrl: null,\n name: 'WaasLoadFailedError',\n shortMessage:\n 'The embedded wallet failed to load after exhausting its retry attempts. Retrying the wallet operation triggers a fresh load.',\n });\n this.reason = 'load_attempts_exhausted';\n }\n}\n","import { BaseError } from './base';\n\n/**\n * Thrown when the embedded (WaaS) wallet client is requested before the user\n * has completed onboarding — i.e. the JWT has not upgraded to `user:basic`\n * because MFA, KYC, recovery-codes acknowledgment, or device registration is\n * still pending.\n *\n * The WaaS iframe's init-time room-cache pre-warm fires `createRooms` using the\n * token captured at client construction (before any per-operation token\n * resync). Building the client during this window lets that pre-warm fire with\n * a pre-`user:basic` token, get a 401, and the iframe's unauthorized handler\n * force-logs-out the user. Throwing here surfaces a clear, recoverable reason\n * instead — wait for onboarding to complete and retry.\n */\nexport class WaasOnboardingIncompleteError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'waas_onboarding_incomplete',\n docsUrl: null,\n name: 'WaasOnboardingIncompleteError',\n shortMessage:\n 'Cannot create or access the embedded wallet until onboarding is complete (pending MFA, KYC, recovery-codes acknowledgment, or device registration).',\n });\n }\n}\n","import { BaseError } from './base';\n\n/**\n * Thrown when a WaaS ceremony operation (sign, export, reshare, create\n * wallet) receives a 403 `rbac_stale` response after the attempt has already\n * spent its one-time authorization — either the legacy MFA token or a\n * single-use elevated access token.\n *\n * The SDK cannot safely retry in that case: the restarted attempt would find\n * the approval already consumed and fail deeper in the stack with an\n * unrelated \"no MFA token\" error, hiding the permission change that actually\n * caused the failure. Surfacing this error instead tells the host exactly what\n * happened. Recover by re-running the step-up/MFA flow and retrying the\n * operation; the business-account role change has already taken effect, so the\n * retry is evaluated against the caller's current permissions.\n *\n * @example\n * ```ts\n * try {\n * await signMessage({ message, walletAccount });\n * } catch (error) {\n * if (error instanceof WaasRbacStaleRetryUnsafeError) {\n * // The one-time approval was spent; re-verify before trying again.\n * await promptStepUp();\n * await signMessage({ message, walletAccount });\n * }\n * }\n * ```\n * @see WaasLoadFailedError\n * @see signMessage\n */\nexport class WaasRbacStaleRetryUnsafeError extends BaseError {\n constructor({ cause }: { cause: Error }) {\n super({\n cause,\n code: 'waas_rbac_stale_retry_unsafe',\n docsUrl: null,\n name: 'WaasRbacStaleRetryUnsafeError',\n shortMessage:\n 'The business account role change could not be retried automatically because a one-time authorization was already consumed. Re-authenticate and retry the operation.',\n });\n }\n}\n","import type { AuthMode } from '@dynamic-labs-wallet/browser-wallet-client';\nimport { preconnectWaasIframe as preconnectWaasIframeOrigin } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { isCookieEnabled } from '../../projectSettings/isCookieEnabled';\nimport { DEFAULT_WAAS_BASE_API_URL } from '../constants';\nimport { isDynamicWaasEnabled } from '../isDynamicWaasEnabled';\n\n/**\n * Warms the browser's connection (DNS + TCP + TLS) to the embedded-wallet\n * iframe origin so the iframe mounted after authentication completes loads on\n * a hot connection. Called when an auth flow starts (OTP send/verify, social\n * callback). Safe to call repeatedly; no-op on React Native / SSR and when\n * Dynamic WaaS is not enabled.\n *\n * @param client - The Dynamic client instance.\n * @notInstrumented\n */\nexport const preconnectWaasIframe = (client: DynamicClient): void => {\n const core = getCore(client);\n try {\n if (!isDynamicWaasEnabled(client)) return;\n\n preconnectWaasIframeOrigin({\n authMode: (isCookieEnabled(client) ? 'cookie' : 'header') as AuthMode,\n baseApiUrl: (core.apiBaseUrl || DEFAULT_WAAS_BASE_API_URL).replace(\n '/api/v0',\n ''\n ),\n });\n } catch (error) {\n // Best-effort: never break the auth flow (also swallows the assertion\n // from isDynamicWaasEnabled when project settings are not loaded yet).\n core.logger.warn('[preconnectWaasIframe] skipped', error);\n }\n};\n","import type { User } from '../../user/user.types';\n\n/**\n * Checks if device registration is required for the given user.\n *\n * This function determines if the user has the deviceRegistration\n * scope, indicating that device registration is required.\n *\n * @param user - The user to check.\n * @returns True if device registration is required, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when this device must be registered, updated when the user changes.\n */\nexport const isDeviceRegistrationRequired = (user: User): boolean =>\n Boolean(user.scope?.includes('device:register'));\n","import { MfaBackupCodeAcknowledgement } from '@dynamic-labs/sdk-api-core';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Checks if the user is still pending acknowledgment of their MFA recovery codes.\n *\n * This function determines whether the user has been presented with recovery\n * codes that they have not yet acknowledged as saved or backed up.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if recovery codes are pending acknowledgment, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when recovery codes await acknowledgment, updated when the user changes.\n */\nexport const isPendingRecoveryCodesAcknowledgment = (\n client = getDefaultClient()\n): boolean => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n return (\n user.mfaBackupCodeAcknowledgement === MfaBackupCodeAcknowledgement.Pending\n );\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { isDeviceRegistrationRequired } from '../../deviceRegistration/isDeviceRegistrationRequired';\nimport { isPendingRecoveryCodesAcknowledgment } from '../../mfa/isPendingRecoveryCodesAcknowledgment';\nimport { isUserMissingMfaAuth } from '../../mfa/isUserMissingMfaAuth';\n\n/**\n * Checks if the user has completed all onboarding requirements.\n *\n * This function verifies whether a user has fulfilled all necessary requirements\n * including KYC fields (Know Your Customer information), MFA setup\n * (Multi-Factor Authentication including recovery codes acknowledgment), and\n * device registration.\n *\n * A `false` result means the user still has an outstanding onboarding step, so\n * any feature that requires a fully onboarded (`user:basic`) user should hold\n * off until it returns `true`. Creating or accessing an embedded (WaaS) wallet\n * is one such feature — its backend calls reject a pre-`user:basic` token — but\n * this predicate is general and not specific to embedded wallets.\n *\n * @deprecated Use {@link checkUserScopes} instead. This function conflates\n * Dynamic-controlled requirements (MFA, device registration, required fields)\n * with the concept of \"onboarding complete\", which is app-specific. Replace\n * with `checkUserScopes({ user, scopes: ['user:basic'] })` to check whether\n * Dynamic's requirements are satisfied, and compose your own logic on top for\n * any app-specific onboarding steps.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if onboarding is complete (no pending requirements), false if there are pending requirements.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when onboarding is complete, updated when the user changes.\n */\nexport const isUserOnboardingComplete = (\n client = getDefaultClient()\n): boolean => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n const hasMissingKycFields = Boolean(user.missingFields?.length);\n const hasPendingMfaAuth = isUserMissingMfaAuth(client);\n const hasPendingRecoveryCodes = isPendingRecoveryCodesAcknowledgment(client);\n const hasPendingDeviceRegistration = isDeviceRegistrationRequired(user);\n\n const userOnboardingComplete =\n !hasMissingKycFields &&\n !hasPendingMfaAuth &&\n !hasPendingRecoveryCodes &&\n !hasPendingDeviceRegistration;\n\n return userOnboardingComplete;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,sBAAb,cAAyC,UAAU;CACjD,AAAS;CAET,YAAY,EAAE,SAA2B;AACvC,QAAM;GACJ;GACA,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;AACF,OAAK,SAAS;;;;;;;;;;;;;;;;;;;ACrClB,IAAa,gCAAb,cAAmD,UAAU;CAC3D,cAAc;AACZ,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACON,IAAa,gCAAb,cAAmD,UAAU;CAC3D,YAAY,EAAE,SAA2B;AACvC,QAAM;GACJ;GACA,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;;;;;;;;;;;;;;;;ACrBN,MAAaA,0BAAwB,WAAgC;CACnE,MAAM,OAAO,QAAQ,OAAO;AAC5B,KAAI;AACF,MAAI,CAAC,qBAAqB,OAAO,CAAE;AAEnC,uBAA2B;GACzB,UAAW,gBAAgB,OAAO,GAAG,WAAW;GAChD,aAAa,KAAK,cAAc,2BAA2B,QACzD,WACA,GACD;GACF,CAAC;UACK,OAAO;AAGd,OAAK,OAAO,KAAK,kCAAkC,MAAM;;;;;;;;;;;;;;;;;ACrB7D,MAAa,gCAAgC,SAC3C,QAAQ,KAAK,OAAO,SAAS,kBAAkB,CAAC;;;;;;;;;;;;;;;ACElD,MAAa,wCACX,SAAS,kBAAkB,KACf;CACZ,MAAM,OAAO,OAAO;AAEpB,eAAc,MAAM,qBAAqB;AAEzC,QACE,KAAK,iCAAiC,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQvE,MAAa,4BACX,SAAS,kBAAkB,KACf;CACZ,MAAM,OAAO,OAAO;AAEpB,eAAc,MAAM,qBAAqB;CAEzC,MAAM,sBAAsB,QAAQ,KAAK,eAAe,OAAO;CAC/D,MAAM,oBAAoB,qBAAqB,OAAO;CACtD,MAAM,0BAA0B,qCAAqC,OAAO;CAC5E,MAAM,+BAA+B,6BAA6B,KAAK;AAQvE,QALE,CAAC,uBACD,CAAC,qBACD,CAAC,2BACD,CAAC"}
|
|
@@ -31,7 +31,7 @@ zod_mini = __toESM(zod_mini);
|
|
|
31
31
|
|
|
32
32
|
//#region package.json
|
|
33
33
|
var name = "@dynamic-labs-sdk/client";
|
|
34
|
-
var version = "1.
|
|
34
|
+
var version = "1.33.0";
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/modules/auth/consts.ts
|
|
@@ -295,6 +295,12 @@ const dependencyCatalog = { "@dynamic-labs/sdk-api-core": "0.25.0" };
|
|
|
295
295
|
//#region src/constants.ts
|
|
296
296
|
const SDK_API_CORE_VERSION = dependencyCatalog["@dynamic-labs/sdk-api-core"];
|
|
297
297
|
const DYNAMIC_ICONIC_SPRITE_URL = "https://iconic.dynamic-static-assets.com/icons/sprite.svg";
|
|
298
|
+
/**
|
|
299
|
+
* Wire codes the SDK API returns when wallet screening blocks a request. A
|
|
300
|
+
* wallet can be blocked by any screening provider or policy, and the
|
|
301
|
+
* provider-specific code is still emitted by older backends.
|
|
302
|
+
*/
|
|
303
|
+
const SCREENING_BLOCKED_WALLET_ERROR_CODES = ["screening_blocked_wallet", "chainalysis_blocked_wallet"];
|
|
298
304
|
|
|
299
305
|
//#endregion
|
|
300
306
|
//#region src/modules/apiClient/constants.ts
|
|
@@ -1976,7 +1982,7 @@ const safeSelect = ({ functionName, logger, piiFields, selector, value }) => {
|
|
|
1976
1982
|
* const transfer = instrumentFunction({
|
|
1977
1983
|
* fn: rawTransfer,
|
|
1978
1984
|
* functionName: 'transfer',
|
|
1979
|
-
* getCore: () =>
|
|
1985
|
+
* getCore: (args) => resolveInstrumentationCore(args),
|
|
1980
1986
|
* selectors: {
|
|
1981
1987
|
* // `args` is the argument tuple the wrapped function was called with.
|
|
1982
1988
|
* started: ([{ chainId, amount }]) => ({ amount, chainId }),
|
|
@@ -2004,7 +2010,7 @@ const safeSelect = ({ functionName, logger, piiFields, selector, value }) => {
|
|
|
2004
2010
|
*/
|
|
2005
2011
|
const instrumentFunction = ({ fn, functionName, getCore: getCore$1, selectors }) => {
|
|
2006
2012
|
const wrapped = (...args) => {
|
|
2007
|
-
const core = getCore$1();
|
|
2013
|
+
const core = getCore$1(args);
|
|
2008
2014
|
if (!core?.instrumentation.config.enabled) return fn(...args);
|
|
2009
2015
|
const { instrumentation, logger } = core;
|
|
2010
2016
|
const { piiFields } = instrumentation.config;
|
|
@@ -2071,6 +2077,39 @@ const instrumentFunction = ({ fn, functionName, getCore: getCore$1, selectors })
|
|
|
2071
2077
|
return wrapped;
|
|
2072
2078
|
};
|
|
2073
2079
|
|
|
2080
|
+
//#endregion
|
|
2081
|
+
//#region src/services/instrumentation/resolveInstrumentationCore/resolveInstrumentationCore.ts
|
|
2082
|
+
const isDynamicClient = (value) => {
|
|
2083
|
+
if (typeof value !== "object" || value === null || !("__core" in value)) return false;
|
|
2084
|
+
const core = value.__core;
|
|
2085
|
+
return typeof core === "object" && core !== null && "instrumentation" in core && "state" in core;
|
|
2086
|
+
};
|
|
2087
|
+
/**
|
|
2088
|
+
* Resolves the instrumentation core from invocation arguments so telemetry is
|
|
2089
|
+
* attributed to the client actually serving the call. Returns `undefined`
|
|
2090
|
+
* when no client is initialized, such as during SSR or in unit tests, so
|
|
2091
|
+
* instrumentation is skipped rather than throwing.
|
|
2092
|
+
*
|
|
2093
|
+
* @param args - The arguments passed to the instrumented function.
|
|
2094
|
+
* @returns The core for the explicit client or the default client.
|
|
2095
|
+
* @example
|
|
2096
|
+
* ```ts
|
|
2097
|
+
* const core = resolveInstrumentationCore([params, client]);
|
|
2098
|
+
* ```
|
|
2099
|
+
* @see DynamicClient
|
|
2100
|
+
* @see instrumentFunction
|
|
2101
|
+
* @notInstrumented
|
|
2102
|
+
*/
|
|
2103
|
+
const resolveInstrumentationCore = (args) => {
|
|
2104
|
+
const clientArg = args.find(isDynamicClient);
|
|
2105
|
+
if (clientArg) return getCore(clientArg);
|
|
2106
|
+
try {
|
|
2107
|
+
return getCore(getDefaultClient());
|
|
2108
|
+
} catch {
|
|
2109
|
+
return;
|
|
2110
|
+
}
|
|
2111
|
+
};
|
|
2112
|
+
|
|
2074
2113
|
//#endregion
|
|
2075
2114
|
//#region src/modules/user/refreshAuth/refreshAuth.ts
|
|
2076
2115
|
/**
|
|
@@ -2107,13 +2146,7 @@ const __refreshAuth_impl = refreshAuth;
|
|
|
2107
2146
|
const __refreshAuth_wrapped = instrumentFunction({
|
|
2108
2147
|
fn: __refreshAuth_impl,
|
|
2109
2148
|
functionName: "refreshAuth",
|
|
2110
|
-
getCore:
|
|
2111
|
-
try {
|
|
2112
|
-
return getCore(getDefaultClient());
|
|
2113
|
-
} catch {
|
|
2114
|
-
return;
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2149
|
+
getCore: resolveInstrumentationCore
|
|
2117
2150
|
});
|
|
2118
2151
|
|
|
2119
2152
|
//#endregion
|
|
@@ -2445,13 +2478,7 @@ const __logoutWithReason_impl = logoutWithReason;
|
|
|
2445
2478
|
const __logoutWithReason_wrapped = instrumentFunction({
|
|
2446
2479
|
fn: __logoutWithReason_impl,
|
|
2447
2480
|
functionName: "logoutWithReason",
|
|
2448
|
-
getCore:
|
|
2449
|
-
try {
|
|
2450
|
-
return getCore(getDefaultClient());
|
|
2451
|
-
} catch {
|
|
2452
|
-
return;
|
|
2453
|
-
}
|
|
2454
|
-
}
|
|
2481
|
+
getCore: resolveInstrumentationCore
|
|
2455
2482
|
});
|
|
2456
2483
|
|
|
2457
2484
|
//#endregion
|
|
@@ -2563,6 +2590,12 @@ Object.defineProperty(exports, 'NoWalletProviderFoundError', {
|
|
|
2563
2590
|
return NoWalletProviderFoundError;
|
|
2564
2591
|
}
|
|
2565
2592
|
});
|
|
2593
|
+
Object.defineProperty(exports, 'SCREENING_BLOCKED_WALLET_ERROR_CODES', {
|
|
2594
|
+
enumerable: true,
|
|
2595
|
+
get: function () {
|
|
2596
|
+
return SCREENING_BLOCKED_WALLET_ERROR_CODES;
|
|
2597
|
+
}
|
|
2598
|
+
});
|
|
2566
2599
|
Object.defineProperty(exports, 'SDK_API_CORE_VERSION', {
|
|
2567
2600
|
enumerable: true,
|
|
2568
2601
|
get: function () {
|
|
@@ -2893,6 +2926,12 @@ Object.defineProperty(exports, 'randomString', {
|
|
|
2893
2926
|
return randomString;
|
|
2894
2927
|
}
|
|
2895
2928
|
});
|
|
2929
|
+
Object.defineProperty(exports, 'resolveInstrumentationCore', {
|
|
2930
|
+
enumerable: true,
|
|
2931
|
+
get: function () {
|
|
2932
|
+
return resolveInstrumentationCore;
|
|
2933
|
+
}
|
|
2934
|
+
});
|
|
2896
2935
|
Object.defineProperty(exports, 'retryOnFail', {
|
|
2897
2936
|
enumerable: true,
|
|
2898
2937
|
get: function () {
|
|
@@ -2941,4 +2980,4 @@ Object.defineProperty(exports, 'version', {
|
|
|
2941
2980
|
return version;
|
|
2942
2981
|
}
|
|
2943
2982
|
});
|
|
2944
|
-
//# sourceMappingURL=logoutWithReason-
|
|
2983
|
+
//# sourceMappingURL=logoutWithReason-B-ZF0VmN.cjs.map
|