@dynamic-labs-sdk/client 1.33.1 → 1.33.3
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-BbjPoAwE.native.esm.js → apiClient-CpfEx6Uc.native.esm.js} +3 -3
- package/dist/{apiClient-BbjPoAwE.native.esm.js.map → apiClient-CpfEx6Uc.native.esm.js.map} +1 -1
- package/dist/core.cjs +5 -78
- package/dist/core.cjs.map +1 -1
- package/dist/core.esm.js +8 -79
- package/dist/core.esm.js.map +1 -1
- package/dist/core.native.esm.js +6 -77
- package/dist/core.native.esm.js.map +1 -1
- package/dist/exports/core.d.ts +0 -2
- package/dist/exports/core.d.ts.map +1 -1
- package/dist/exports/waas.d.ts +13 -1
- package/dist/exports/waas.d.ts.map +1 -1
- package/dist/{getNetworkProviderFromNetworkId-BXoTukxv.cjs → getNetworkProviderFromNetworkId-Cez8TM-n.cjs} +9 -2
- package/dist/getNetworkProviderFromNetworkId-Cez8TM-n.cjs.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-D_Hg6kP7.esm.js → getNetworkProviderFromNetworkId-Cf-CfYM4.esm.js} +9 -8
- package/dist/getNetworkProviderFromNetworkId-Cf-CfYM4.esm.js.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-Cs3hLqBS.native.esm.js → getNetworkProviderFromNetworkId-CuTEQ9dg.native.esm.js} +5 -4
- package/dist/getNetworkProviderFromNetworkId-CuTEQ9dg.native.esm.js.map +1 -0
- package/dist/{getSignedSessionId-Bk-8is5J.native.esm.js → getSignedSessionId-Bt4obN3w.native.esm.js} +3 -3
- package/dist/{getSignedSessionId-Bk-8is5J.native.esm.js.map → getSignedSessionId-Bt4obN3w.native.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-D_TknHwX.esm.js → getSignedSessionId-Cx7WP4ZJ.esm.js} +3 -3
- package/dist/{getSignedSessionId-D_TknHwX.esm.js.map → getSignedSessionId-Cx7WP4ZJ.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-2O_cJtIV.cjs → getSignedSessionId-DiVxv0qz.cjs} +3 -3
- package/dist/{getSignedSessionId-2O_cJtIV.cjs.map → getSignedSessionId-DiVxv0qz.cjs.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-BmsHgXbj.esm.js → getVerifiedCredentialForWalletAccount-DfKRbqco.esm.js} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-BmsHgXbj.esm.js.map → getVerifiedCredentialForWalletAccount-DfKRbqco.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-upiwolAi.cjs → getVerifiedCredentialForWalletAccount-UIcOv7IN.cjs} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-upiwolAi.cjs.map → getVerifiedCredentialForWalletAccount-UIcOv7IN.cjs.map} +1 -1
- package/dist/index.cjs +56 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +50 -63
- package/dist/index.esm.js.map +1 -1
- package/dist/index.native.esm.js +48 -61
- package/dist/index.native.esm.js.map +1 -1
- package/dist/{isMfaRequiredForAction-D7b7mUT9.native.esm.js → isMfaRequiredForAction-CxYft5KR.native.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-D7b7mUT9.native.esm.js.map → isMfaRequiredForAction-CxYft5KR.native.esm.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-DF65MJNN.cjs → isMfaRequiredForAction-Czx-uPFY.cjs} +2 -2
- package/dist/{isMfaRequiredForAction-DF65MJNN.cjs.map → isMfaRequiredForAction-Czx-uPFY.cjs.map} +1 -1
- package/dist/{isMfaRequiredForAction-CHqeZeTS.esm.js → isMfaRequiredForAction-DS8fcwxO.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-CHqeZeTS.esm.js.map → isMfaRequiredForAction-DS8fcwxO.esm.js.map} +1 -1
- package/dist/{isUserOnboardingComplete-CpHVw8ee.esm.js → isUserOnboardingComplete-COmYFW26.esm.js} +3 -3
- package/dist/{isUserOnboardingComplete-CpHVw8ee.esm.js.map → isUserOnboardingComplete-COmYFW26.esm.js.map} +1 -1
- package/dist/{isUserOnboardingComplete-CYpgo52t.native.esm.js → isUserOnboardingComplete-DYnRDLep.native.esm.js} +3 -3
- package/dist/{isUserOnboardingComplete-CYpgo52t.native.esm.js.map → isUserOnboardingComplete-DYnRDLep.native.esm.js.map} +1 -1
- package/dist/{isUserOnboardingComplete-BAL-3zu7.cjs → isUserOnboardingComplete-FbjleMQm.cjs} +3 -3
- package/dist/{isUserOnboardingComplete-BAL-3zu7.cjs.map → isUserOnboardingComplete-FbjleMQm.cjs.map} +1 -1
- package/dist/{logoutWithReason-CFjm8dbR.cjs → logoutWithReason-BKwWBsCT.cjs} +73 -55
- package/dist/logoutWithReason-BKwWBsCT.cjs.map +1 -0
- package/dist/{logoutWithReason-CX9hGTPw.esm.js → logoutWithReason-DO0kP7nf.esm.js} +62 -50
- package/dist/logoutWithReason-DO0kP7nf.esm.js.map +1 -0
- package/dist/{logoutWithReason-Bd1qUh7l.native.esm.js → logoutWithReason-DWkIKoLk.native.esm.js} +61 -49
- package/dist/logoutWithReason-DWkIKoLk.native.esm.js.map +1 -0
- package/dist/{migrateFromFireblocks-BLz9aHOY.native.esm.js → migrateFromFireblocks-BwYnNAAh.native.esm.js} +2 -2
- package/dist/{migrateFromFireblocks-BLz9aHOY.native.esm.js.map → migrateFromFireblocks-BwYnNAAh.native.esm.js.map} +1 -1
- package/dist/{migrateFromFireblocks-C8KXMXk-.esm.js → migrateFromFireblocks-C_cap--b.esm.js} +2 -2
- package/dist/{migrateFromFireblocks-C8KXMXk-.esm.js.map → migrateFromFireblocks-C_cap--b.esm.js.map} +1 -1
- package/dist/{migrateFromFireblocks-BiZmnKp9.cjs → migrateFromFireblocks-ycJIYcrm.cjs} +2 -2
- package/dist/{migrateFromFireblocks-BiZmnKp9.cjs.map → migrateFromFireblocks-ycJIYcrm.cjs.map} +1 -1
- package/dist/modules/initializeClient/consts.d.ts +1 -0
- package/dist/modules/initializeClient/consts.d.ts.map +1 -1
- package/dist/modules/initializeClient/initializeClient.d.ts.map +1 -1
- package/dist/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.d.ts +4 -5
- package/dist/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.d.ts.map +1 -1
- package/dist/modules/sessionKeys/canonicalizeJson/canonicalizeJson.d.ts +20 -0
- package/dist/modules/sessionKeys/canonicalizeJson/canonicalizeJson.d.ts.map +1 -0
- package/dist/modules/sessionKeys/canonicalizeJson/index.d.ts +2 -0
- package/dist/modules/sessionKeys/canonicalizeJson/index.d.ts.map +1 -0
- package/dist/modules/sessionKeys/signBusinessAccountIntent/signBusinessAccountIntent.d.ts +39 -6
- package/dist/modules/sessionKeys/signBusinessAccountIntent/signBusinessAccountIntent.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.d.ts +9 -3
- package/dist/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.d.ts +10 -3
- package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/approveBusinessAccountProposal/approveBusinessAccountProposal.d.ts +43 -0
- package/dist/modules/waas/businessAccounts/approveBusinessAccountProposal/approveBusinessAccountProposal.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/approveBusinessAccountProposal/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/approveBusinessAccountProposal/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/businessAccounts.types.d.ts +249 -0
- package/dist/modules/waas/businessAccounts/businessAccounts.types.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/defineBusinessAccountRole/defineBusinessAccountRole.d.ts +45 -0
- package/dist/modules/waas/businessAccounts/defineBusinessAccountRole/defineBusinessAccountRole.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/defineBusinessAccountRole/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/defineBusinessAccountRole/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/deleteBusinessAccountRole/deleteBusinessAccountRole.d.ts +41 -0
- package/dist/modules/waas/businessAccounts/deleteBusinessAccountRole/deleteBusinessAccountRole.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/deleteBusinessAccountRole/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/deleteBusinessAccountRole/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/executeBusinessAccountProposal/executeBusinessAccountProposal.d.ts +39 -0
- package/dist/modules/waas/businessAccounts/executeBusinessAccountProposal/executeBusinessAccountProposal.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/executeBusinessAccountProposal/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/executeBusinessAccountProposal/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/getBusinessAccountGovernance/getBusinessAccountGovernance.d.ts +30 -0
- package/dist/modules/waas/businessAccounts/getBusinessAccountGovernance/getBusinessAccountGovernance.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/getBusinessAccountGovernance/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/getBusinessAccountGovernance/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccountProposals/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccountProposals/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccountProposals/listBusinessAccountProposals.d.ts +26 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccountProposals/listBusinessAccountProposals.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccountProposalsAwaitingMyApproval/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccountProposalsAwaitingMyApproval/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccountProposalsAwaitingMyApproval/listBusinessAccountProposalsAwaitingMyApproval.d.ts +21 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccountProposalsAwaitingMyApproval/listBusinessAccountProposalsAwaitingMyApproval.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccountRoles/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccountRoles/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccountRoles/listBusinessAccountRoles.d.ts +26 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccountRoles/listBusinessAccountRoles.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/removeBusinessAccountMember.d.ts +11 -2
- package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/removeBusinessAccountMember.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/removeBusinessAccountSigner.d.ts +11 -2
- package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/removeBusinessAccountSigner.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/removeBusinessAccountWallet/removeBusinessAccountWallet.d.ts +12 -4
- package/dist/modules/waas/businessAccounts/removeBusinessAccountWallet/removeBusinessAccountWallet.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/resendFields.d.ts +39 -0
- package/dist/modules/waas/businessAccounts/resendFields.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/setBusinessAccountGovernance/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/setBusinessAccountGovernance/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/setBusinessAccountGovernance/setBusinessAccountGovernance.d.ts +49 -0
- package/dist/modules/waas/businessAccounts/setBusinessAccountGovernance/setBusinessAccountGovernance.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/transferBusinessAccountOwnership/transferBusinessAccountOwnership.d.ts +11 -2
- package/dist/modules/waas/businessAccounts/transferBusinessAccountOwnership/transferBusinessAccountOwnership.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/updateBusinessAccountMemberRole/updateBusinessAccountMemberRole.d.ts +11 -2
- package/dist/modules/waas/businessAccounts/updateBusinessAccountMemberRole/updateBusinessAccountMemberRole.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/vetoBusinessAccountProposal/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/vetoBusinessAccountProposal/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/vetoBusinessAccountProposal/vetoBusinessAccountProposal.d.ts +29 -0
- package/dist/modules/waas/businessAccounts/vetoBusinessAccountProposal/vetoBusinessAccountProposal.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/withdrawBusinessAccountProposalApproval/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/withdrawBusinessAccountProposalApproval/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/withdrawBusinessAccountProposalApproval/withdrawBusinessAccountProposalApproval.d.ts +29 -0
- package/dist/modules/waas/businessAccounts/withdrawBusinessAccountProposalApproval/withdrawBusinessAccountProposalApproval.d.ts.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/{waas-oKD6ZDP9.native.esm.js → waas-C4jtRxx1.native.esm.js} +688 -26
- package/dist/waas-C4jtRxx1.native.esm.js.map +1 -0
- package/dist/{waas-G-4JvdgJ.cjs → waas-CioG-_yp.cjs} +764 -24
- package/dist/waas-CioG-_yp.cjs.map +1 -0
- package/dist/{waas-DjgZ-ghV.esm.js → waas-DjivkzyT.esm.js} +688 -26
- package/dist/waas-DjivkzyT.esm.js.map +1 -0
- package/dist/waas.cjs +18 -5
- package/dist/waas.esm.js +5 -5
- package/dist/waas.native.esm.js +5 -5
- package/dist/waasCore.cjs +5 -5
- package/dist/waasCore.esm.js +5 -5
- package/dist/waasCore.native.esm.js +5 -5
- package/package.json +3 -4
- package/dist/getNetworkProviderFromNetworkId-BXoTukxv.cjs.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-Cs3hLqBS.native.esm.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-D_Hg6kP7.esm.js.map +0 -1
- package/dist/logoutWithReason-Bd1qUh7l.native.esm.js.map +0 -1
- package/dist/logoutWithReason-CFjm8dbR.cjs.map +0 -1
- package/dist/logoutWithReason-CX9hGTPw.esm.js.map +0 -1
- package/dist/modules/projectSettings/fetchProjectSettings/projectSettingsExpirationScheme.d.ts +0 -5
- package/dist/modules/projectSettings/fetchProjectSettings/projectSettingsExpirationScheme.d.ts.map +0 -1
- package/dist/waas-DjgZ-ghV.esm.js.map +0 -1
- package/dist/waas-G-4JvdgJ.cjs.map +0 -1
- package/dist/waas-oKD6ZDP9.native.esm.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-CpfEx6Uc.native.esm.js";
|
|
2
2
|
|
|
3
3
|
//#region src/errors/NativeModuleNotLinkedError.ts
|
|
4
4
|
var NativeModuleNotLinkedError = class extends BaseError {
|
|
@@ -97,4 +97,4 @@ const isMfaRequiredForAction = async ({ mfaAction }, client = getDefaultClient()
|
|
|
97
97
|
|
|
98
98
|
//#endregion
|
|
99
99
|
export { NativeModuleNotLinkedError as i, getMfaMethods as n, __consumeMfaToken_wrapped as r, isMfaRequiredForAction as t };
|
|
100
|
-
//# sourceMappingURL=isMfaRequiredForAction-
|
|
100
|
+
//# sourceMappingURL=isMfaRequiredForAction-CxYft5KR.native.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isMfaRequiredForAction-
|
|
1
|
+
{"version":3,"file":"isMfaRequiredForAction-CxYft5KR.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-BKwWBsCT.cjs');
|
|
2
2
|
|
|
3
3
|
//#region src/modules/mfa/consumeMfaToken/consumeMfaToken.ts
|
|
4
4
|
/**
|
|
@@ -85,4 +85,4 @@ Object.defineProperty(exports, 'isMfaRequiredForAction', {
|
|
|
85
85
|
return isMfaRequiredForAction;
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
|
-
//# sourceMappingURL=isMfaRequiredForAction-
|
|
88
|
+
//# sourceMappingURL=isMfaRequiredForAction-Czx-uPFY.cjs.map
|
package/dist/{isMfaRequiredForAction-DF65MJNN.cjs.map → isMfaRequiredForAction-Czx-uPFY.cjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isMfaRequiredForAction-
|
|
1
|
+
{"version":3,"file":"isMfaRequiredForAction-Czx-uPFY.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/{isMfaRequiredForAction-CHqeZeTS.esm.js → isMfaRequiredForAction-DS8fcwxO.esm.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { St as getDefaultClient, Tt as getCore, _t as assertDefined, d as resolveInstrumentationCore, f as instrumentFunction, l as createApiClient } from "./logoutWithReason-DO0kP7nf.esm.js";
|
|
2
2
|
|
|
3
3
|
//#region src/modules/mfa/consumeMfaToken/consumeMfaToken.ts
|
|
4
4
|
/**
|
|
@@ -68,4 +68,4 @@ const isMfaRequiredForAction = async ({ mfaAction }, client = getDefaultClient()
|
|
|
68
68
|
|
|
69
69
|
//#endregion
|
|
70
70
|
export { getMfaMethods as n, __consumeMfaToken_wrapped as r, isMfaRequiredForAction as t };
|
|
71
|
-
//# sourceMappingURL=isMfaRequiredForAction-
|
|
71
|
+
//# sourceMappingURL=isMfaRequiredForAction-DS8fcwxO.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isMfaRequiredForAction-
|
|
1
|
+
{"version":3,"file":"isMfaRequiredForAction-DS8fcwxO.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"}
|
package/dist/{isUserOnboardingComplete-CpHVw8ee.esm.js → isUserOnboardingComplete-COmYFW26.esm.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as isDynamicWaasEnabled } from "./migrateFromFireblocks-
|
|
1
|
+
import { Et as BaseError, St as getDefaultClient, Tt as getCore, Y as isUserMissingMfaAuth, _t as assertDefined, gt as isCookieEnabled, k as DEFAULT_WAAS_BASE_API_URL } from "./logoutWithReason-DO0kP7nf.esm.js";
|
|
2
|
+
import { n as isDynamicWaasEnabled } from "./migrateFromFireblocks-C_cap--b.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-COmYFW26.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUserOnboardingComplete-CpHVw8ee.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-COmYFW26.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,5 +1,5 @@
|
|
|
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-
|
|
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-CpfEx6Uc.native.esm.js";
|
|
2
|
+
import { n as isDynamicWaasEnabled } from "./migrateFromFireblocks-BwYnNAAh.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-DYnRDLep.native.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUserOnboardingComplete-CYpgo52t.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-DYnRDLep.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"}
|
package/dist/{isUserOnboardingComplete-BAL-3zu7.cjs → isUserOnboardingComplete-FbjleMQm.cjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_logoutWithReason = require('./logoutWithReason-
|
|
2
|
-
const require_migrateFromFireblocks = require('./migrateFromFireblocks-
|
|
1
|
+
const require_logoutWithReason = require('./logoutWithReason-BKwWBsCT.cjs');
|
|
2
|
+
const require_migrateFromFireblocks = require('./migrateFromFireblocks-ycJIYcrm.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-FbjleMQm.cjs.map
|
package/dist/{isUserOnboardingComplete-BAL-3zu7.cjs.map → isUserOnboardingComplete-FbjleMQm.cjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUserOnboardingComplete-BAL-3zu7.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-FbjleMQm.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"}
|
|
@@ -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.33.
|
|
34
|
+
var version = "1.33.3";
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/modules/auth/consts.ts
|
|
@@ -289,7 +289,7 @@ const getSessionKeys = (client) => {
|
|
|
289
289
|
|
|
290
290
|
//#endregion
|
|
291
291
|
//#region src/generated/dependencyCatalog.ts
|
|
292
|
-
const dependencyCatalog = { "@dynamic-labs/sdk-api-core": "0.
|
|
292
|
+
const dependencyCatalog = { "@dynamic-labs/sdk-api-core": "0.40.0" };
|
|
293
293
|
|
|
294
294
|
//#endregion
|
|
295
295
|
//#region src/constants.ts
|
|
@@ -2263,60 +2263,66 @@ const retryOnFail = async ({ delay = 0, fn, maxRetries }) => {
|
|
|
2263
2263
|
};
|
|
2264
2264
|
|
|
2265
2265
|
//#endregion
|
|
2266
|
-
//#region src/modules/
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
* "Check if signed in" guide:
|
|
2281
|
-
* https://www.dynamic.xyz/docs/javascript/user-session-management
|
|
2282
|
-
*
|
|
2283
|
-
* @example
|
|
2284
|
-
* ```ts
|
|
2285
|
-
* if (isSignedIn()) {
|
|
2286
|
-
* console.log('User is authenticated or has a wallet connected');
|
|
2287
|
-
* }
|
|
2288
|
-
* ```
|
|
2289
|
-
*
|
|
2290
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2291
|
-
* @returns True if the user is signed in, false otherwise.
|
|
2292
|
-
* @see logout
|
|
2293
|
-
* @see isAnyWalletAccountConnected
|
|
2294
|
-
* @notInstrumented
|
|
2295
|
-
*/
|
|
2296
|
-
const isSignedIn = (client = getDefaultClient()) => Boolean(client.user || getWalletAccounts(client).length > 0);
|
|
2266
|
+
//#region src/modules/wallets/unverifiedWalletAccounts/schema.ts
|
|
2267
|
+
const unverifiedWalletAccountSchema = zod_mini.object({
|
|
2268
|
+
address: zod_mini.string(),
|
|
2269
|
+
addressesWithTypes: zod_mini.optional(zod_mini.array(zod_mini.object({
|
|
2270
|
+
address: zod_mini.string(),
|
|
2271
|
+
publicKey: zod_mini.optional(zod_mini.string()),
|
|
2272
|
+
type: zod_mini.custom((val) => typeof val === "string")
|
|
2273
|
+
}))),
|
|
2274
|
+
chain: zod_mini.custom((val) => typeof val === "string"),
|
|
2275
|
+
hardwareWalletVendor: zod_mini.optional(zod_mini.custom((val) => typeof val === "string")),
|
|
2276
|
+
id: zod_mini.string(),
|
|
2277
|
+
lastSelectedAt: zod_mini.nullable(zod_mini.date()),
|
|
2278
|
+
walletProviderKey: zod_mini.string()
|
|
2279
|
+
});
|
|
2297
2280
|
|
|
2298
2281
|
//#endregion
|
|
2299
|
-
//#region src/modules/
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2282
|
+
//#region src/modules/wallets/walletProvider/walletProviderKeyMap/schema.ts
|
|
2283
|
+
const walletProviderKeyMapSchema = zod_mini.record(zod_mini.string(), zod_mini.string());
|
|
2284
|
+
|
|
2285
|
+
//#endregion
|
|
2286
|
+
//#region src/modules/storageSync/schema.ts
|
|
2287
|
+
const stateStorageKeySchema = createStorageKeySchema({
|
|
2288
|
+
key: "state",
|
|
2289
|
+
schema: zod_mini.object({
|
|
2290
|
+
apiVersion: zod_mini.string(),
|
|
2291
|
+
projectSettings: zod_mini.custom(),
|
|
2292
|
+
unverifiedWalletAccounts: zod_mini.array(unverifiedWalletAccountSchema),
|
|
2293
|
+
user: zod_mini.custom(),
|
|
2294
|
+
walletProviderKeyMap: walletProviderKeyMapSchema
|
|
2295
|
+
})
|
|
2296
|
+
});
|
|
2297
|
+
const sessionStorageKeySchema = createStorageKeySchema({
|
|
2298
|
+
config: { storageTier: "secure" },
|
|
2299
|
+
key: "session",
|
|
2300
|
+
schema: zod_mini.object({
|
|
2301
|
+
captchaToken: zod_mini.nullable(zod_mini.string()),
|
|
2302
|
+
elevatedAccessTokens: zod_mini.array(zod_mini.object({
|
|
2303
|
+
expiresAt: zod_mini.number(),
|
|
2304
|
+
scopes: zod_mini.array(zod_mini.string()),
|
|
2305
|
+
singleUse: zod_mini.nullable(zod_mini.boolean()),
|
|
2306
|
+
token: zod_mini.string()
|
|
2307
|
+
})),
|
|
2308
|
+
legacyToken: zod_mini.nullable(zod_mini.string()),
|
|
2309
|
+
mfaToken: zod_mini.nullable(zod_mini.string()),
|
|
2310
|
+
sessionExpiration: zod_mini.number(),
|
|
2311
|
+
sessionKeys: zod_mini.nullable(zod_mini.string()),
|
|
2312
|
+
token: zod_mini.nullable(zod_mini.string())
|
|
2313
|
+
})
|
|
2306
2314
|
});
|
|
2307
2315
|
|
|
2308
2316
|
//#endregion
|
|
2309
2317
|
//#region src/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.ts
|
|
2310
2318
|
/**
|
|
2311
|
-
* Expiration time of the project settings in milliseconds.
|
|
2312
|
-
*/
|
|
2313
|
-
const PROJECT_SETTINGS_EXPIRATION_TIME = 1e3 * 60 * 5;
|
|
2314
|
-
/**
|
|
2315
2319
|
* Fetches and updates the project settings from the API.
|
|
2316
2320
|
*
|
|
2317
2321
|
* This function retrieves the latest project configuration settings
|
|
2318
2322
|
* from Dynamic's servers, including authentication options, enabled chains,
|
|
2319
|
-
* and security configurations.
|
|
2323
|
+
* and security configurations. It always performs a live fetch. If the API
|
|
2324
|
+
* call fails, it falls back to the last known-good settings from storage,
|
|
2325
|
+
* provided they were saved by a matching SDK API version.
|
|
2320
2326
|
*
|
|
2321
2327
|
* @example
|
|
2322
2328
|
* ```ts
|
|
@@ -2326,6 +2332,7 @@ const PROJECT_SETTINGS_EXPIRATION_TIME = 1e3 * 60 * 5;
|
|
|
2326
2332
|
*
|
|
2327
2333
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2328
2334
|
* @returns A promise that resolves to the updated project settings.
|
|
2335
|
+
* @throws {Error} Rethrows the original fetch error when no matching-version cached settings exist.
|
|
2329
2336
|
* @see createDynamicClient
|
|
2330
2337
|
* @see initializeClient
|
|
2331
2338
|
* @notInstrumented
|
|
@@ -2333,8 +2340,6 @@ const PROJECT_SETTINGS_EXPIRATION_TIME = 1e3 * 60 * 5;
|
|
|
2333
2340
|
*/
|
|
2334
2341
|
const fetchProjectSettings = async (client = getDefaultClient()) => {
|
|
2335
2342
|
const core = getCore(client);
|
|
2336
|
-
const currentExpiration = await core.storage.getItem(projectSettingsExpirationStorageKeySchema);
|
|
2337
|
-
if (Boolean(client.projectSettings) && !(currentExpiration && currentExpiration < Date.now()) && isSignedIn(client)) return client.projectSettings;
|
|
2338
2343
|
const apiClient = createApiClient({}, client);
|
|
2339
2344
|
core.logger.debug("[fetchProjectSettings] Fetching project settings...");
|
|
2340
2345
|
const doFetch = async () => apiClient.getEnvironmentSettings({
|
|
@@ -2344,9 +2349,16 @@ const fetchProjectSettings = async (client = getDefaultClient()) => {
|
|
|
2344
2349
|
const projectSettings = await retryOnFail({
|
|
2345
2350
|
fn: doFetch,
|
|
2346
2351
|
maxRetries: 2
|
|
2352
|
+
}).catch(async (error) => {
|
|
2353
|
+
const cachedState = await core.storage.getItem(stateStorageKeySchema).catch(() => null);
|
|
2354
|
+
if (cachedState?.apiVersion === SDK_API_CORE_VERSION && cachedState.projectSettings) {
|
|
2355
|
+
core.logger.error("[fetchProjectSettings] Failed to fetch project settings, falling back to cached settings", error);
|
|
2356
|
+
return cachedState.projectSettings;
|
|
2357
|
+
}
|
|
2358
|
+
core.logger.error("[fetchProjectSettings] Failed to fetch project settings and no cached settings are available", error);
|
|
2359
|
+
throw error;
|
|
2347
2360
|
});
|
|
2348
2361
|
core.state.set({ projectSettings: projectSettings ?? null });
|
|
2349
|
-
await core.storage.setItem(projectSettingsExpirationStorageKeySchema, Date.now() + PROJECT_SETTINGS_EXPIRATION_TIME);
|
|
2350
2362
|
return projectSettings;
|
|
2351
2363
|
};
|
|
2352
2364
|
|
|
@@ -2854,12 +2866,6 @@ Object.defineProperty(exports, 'isCookieEnabled', {
|
|
|
2854
2866
|
return isCookieEnabled;
|
|
2855
2867
|
}
|
|
2856
2868
|
});
|
|
2857
|
-
Object.defineProperty(exports, 'isSignedIn', {
|
|
2858
|
-
enumerable: true,
|
|
2859
|
-
get: function () {
|
|
2860
|
-
return isSignedIn;
|
|
2861
|
-
}
|
|
2862
|
-
});
|
|
2863
2869
|
Object.defineProperty(exports, 'isUserMissingMfaAuth', {
|
|
2864
2870
|
enumerable: true,
|
|
2865
2871
|
get: function () {
|
|
@@ -2944,6 +2950,12 @@ Object.defineProperty(exports, 'scrubParameters', {
|
|
|
2944
2950
|
return scrubParameters;
|
|
2945
2951
|
}
|
|
2946
2952
|
});
|
|
2953
|
+
Object.defineProperty(exports, 'sessionStorageKeySchema', {
|
|
2954
|
+
enumerable: true,
|
|
2955
|
+
get: function () {
|
|
2956
|
+
return sessionStorageKeySchema;
|
|
2957
|
+
}
|
|
2958
|
+
});
|
|
2947
2959
|
Object.defineProperty(exports, 'setDefaultClient', {
|
|
2948
2960
|
enumerable: true,
|
|
2949
2961
|
get: function () {
|
|
@@ -2956,6 +2968,12 @@ Object.defineProperty(exports, 'splitWalletProviderKey', {
|
|
|
2956
2968
|
return splitWalletProviderKey;
|
|
2957
2969
|
}
|
|
2958
2970
|
});
|
|
2971
|
+
Object.defineProperty(exports, 'stateStorageKeySchema', {
|
|
2972
|
+
enumerable: true,
|
|
2973
|
+
get: function () {
|
|
2974
|
+
return stateStorageKeySchema;
|
|
2975
|
+
}
|
|
2976
|
+
});
|
|
2959
2977
|
Object.defineProperty(exports, 'updateAuthFromVerifyResponse', {
|
|
2960
2978
|
enumerable: true,
|
|
2961
2979
|
get: function () {
|
|
@@ -2980,4 +2998,4 @@ Object.defineProperty(exports, 'version', {
|
|
|
2980
2998
|
return version;
|
|
2981
2999
|
}
|
|
2982
3000
|
});
|
|
2983
|
-
//# sourceMappingURL=logoutWithReason-
|
|
3001
|
+
//# sourceMappingURL=logoutWithReason-BKwWBsCT.cjs.map
|