@dynamic-labs-sdk/client 1.21.2 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{NativeModuleNotLinkedError-Duh8DMLT.native.esm.js → NativeModuleNotLinkedError-BK7v1pWC.native.esm.js} +4 -3
- package/dist/NativeModuleNotLinkedError-BK7v1pWC.native.esm.js.map +1 -0
- package/dist/{consumeMfaTokenIfRequiredForAction-CJxVqCmj.esm.js → consumeMfaTokenIfRequiredForAction-BIgGN1OX.esm.js} +2 -2
- package/dist/{consumeMfaTokenIfRequiredForAction-CJxVqCmj.esm.js.map → consumeMfaTokenIfRequiredForAction-BIgGN1OX.esm.js.map} +1 -1
- package/dist/{consumeMfaTokenIfRequiredForAction-B2zzOTIn.cjs → consumeMfaTokenIfRequiredForAction-csagEe9v.cjs} +2 -2
- package/dist/{consumeMfaTokenIfRequiredForAction-B2zzOTIn.cjs.map → consumeMfaTokenIfRequiredForAction-csagEe9v.cjs.map} +1 -1
- package/dist/core.cjs +6 -6
- package/dist/core.esm.js +6 -6
- package/dist/core.native.esm.js +5 -5
- package/dist/exports/waas.d.ts +2 -3
- package/dist/exports/waas.d.ts.map +1 -1
- package/dist/{getNetworkProviderFromNetworkId-_2e6e2Ro.esm.js → getNetworkProviderFromNetworkId-4Xoiy8NQ.esm.js} +2 -2
- package/dist/{getNetworkProviderFromNetworkId-_2e6e2Ro.esm.js.map → getNetworkProviderFromNetworkId-4Xoiy8NQ.esm.js.map} +1 -1
- package/dist/{getNetworkProviderFromNetworkId-h1eFbUp8.cjs → getNetworkProviderFromNetworkId-BAbc7qAr.cjs} +2 -2
- package/dist/{getNetworkProviderFromNetworkId-h1eFbUp8.cjs.map → getNetworkProviderFromNetworkId-BAbc7qAr.cjs.map} +1 -1
- package/dist/{getNetworkProviderFromNetworkId-C0FLeQ5n.native.esm.js → getNetworkProviderFromNetworkId-BZJXSy5b.native.esm.js} +2 -2
- package/dist/{getNetworkProviderFromNetworkId-C0FLeQ5n.native.esm.js.map → getNetworkProviderFromNetworkId-BZJXSy5b.native.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-BZO5AD86.native.esm.js → getSignedSessionId-C9EFdGfb.native.esm.js} +3 -3
- package/dist/{getSignedSessionId-BZO5AD86.native.esm.js.map → getSignedSessionId-C9EFdGfb.native.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-DPh7vAKs.cjs → getSignedSessionId-DpZexHsP.cjs} +2 -2
- package/dist/{getSignedSessionId-DPh7vAKs.cjs.map → getSignedSessionId-DpZexHsP.cjs.map} +1 -1
- package/dist/{getSignedSessionId-BhWiqoE7.esm.js → getSignedSessionId-bbTK-sA0.esm.js} +2 -2
- package/dist/{getSignedSessionId-BhWiqoE7.esm.js.map → getSignedSessionId-bbTK-sA0.esm.js.map} +1 -1
- package/dist/{getWalletProviderByKey-V57IQFGI.cjs → getWalletProviderByKey-Bmqc0Duc.cjs} +2 -2
- package/dist/{getWalletProviderByKey-V57IQFGI.cjs.map → getWalletProviderByKey-Bmqc0Duc.cjs.map} +1 -1
- package/dist/{getWalletProviderByKey-CHwDF-wB.native.esm.js → getWalletProviderByKey-DVBZq2sg.native.esm.js} +2 -2
- package/dist/{getWalletProviderByKey-CHwDF-wB.native.esm.js.map → getWalletProviderByKey-DVBZq2sg.native.esm.js.map} +1 -1
- package/dist/{getWalletProviderByKey-CjaJQ7fI.esm.js → getWalletProviderByKey-D_TZdpYc.esm.js} +2 -2
- package/dist/{getWalletProviderByKey-CjaJQ7fI.esm.js.map → getWalletProviderByKey-D_TZdpYc.esm.js.map} +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.esm.js +6 -6
- package/dist/index.native.esm.js +6 -6
- package/dist/{isDynamicWaasEnabled-DON8Wgtw.esm.js → isDynamicWaasEnabled-BJimir8s.esm.js} +2 -2
- package/dist/{isDynamicWaasEnabled-DON8Wgtw.esm.js.map → isDynamicWaasEnabled-BJimir8s.esm.js.map} +1 -1
- package/dist/{isDynamicWaasEnabled-DcvyqHqI.cjs → isDynamicWaasEnabled-Bfd-h02Q.cjs} +2 -2
- package/dist/{isDynamicWaasEnabled-DcvyqHqI.cjs.map → isDynamicWaasEnabled-Bfd-h02Q.cjs.map} +1 -1
- package/dist/{isDynamicWaasEnabled-SALOnUiM.native.esm.js → isDynamicWaasEnabled-NC2_jndd.native.esm.js} +2 -2
- package/dist/{isDynamicWaasEnabled-SALOnUiM.native.esm.js.map → isDynamicWaasEnabled-NC2_jndd.native.esm.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-Bde90-Y6.esm.js → isMfaRequiredForAction-DMB9vA5-.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-Bde90-Y6.esm.js.map → isMfaRequiredForAction-DMB9vA5-.esm.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-BUupsHJw.native.esm.js → isMfaRequiredForAction-MdS-yMQf.native.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-BUupsHJw.native.esm.js.map → isMfaRequiredForAction-MdS-yMQf.native.esm.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-GI_7_DG1.cjs → isMfaRequiredForAction-W1y6oe6Y.cjs} +2 -2
- package/dist/{isMfaRequiredForAction-GI_7_DG1.cjs.map → isMfaRequiredForAction-W1y6oe6Y.cjs.map} +1 -1
- package/dist/{isUserOnboardingComplete-bsAUasR2.native.esm.js → isUserOnboardingComplete-Bj0ClaGP.native.esm.js} +3 -3
- package/dist/{isUserOnboardingComplete-bsAUasR2.native.esm.js.map → isUserOnboardingComplete-Bj0ClaGP.native.esm.js.map} +1 -1
- package/dist/{isUserOnboardingComplete-BTQbWpvO.cjs → isUserOnboardingComplete-BmGd69SF.cjs} +3 -3
- package/dist/{isUserOnboardingComplete-BTQbWpvO.cjs.map → isUserOnboardingComplete-BmGd69SF.cjs.map} +1 -1
- package/dist/{isUserOnboardingComplete-CDMV5llq.esm.js → isUserOnboardingComplete-Cm2VLmIH.esm.js} +3 -3
- package/dist/{isUserOnboardingComplete-CDMV5llq.esm.js.map → isUserOnboardingComplete-Cm2VLmIH.esm.js.map} +1 -1
- package/dist/{migrateFromFireblocks-CuKYRnBI.esm.js → migrateFromFireblocks-BUuulRx2.esm.js} +4 -4
- package/dist/{migrateFromFireblocks-CuKYRnBI.esm.js.map → migrateFromFireblocks-BUuulRx2.esm.js.map} +1 -1
- package/dist/{migrateFromFireblocks-BKQe7GHD.cjs → migrateFromFireblocks-rQkE9cQa.cjs} +4 -4
- package/dist/{migrateFromFireblocks-BKQe7GHD.cjs.map → migrateFromFireblocks-rQkE9cQa.cjs.map} +1 -1
- package/dist/{migrateFromFireblocks-CdacJXcs.native.esm.js → migrateFromFireblocks-rs5CZz-4.native.esm.js} +3 -3
- package/dist/{migrateFromFireblocks-CdacJXcs.native.esm.js.map → migrateFromFireblocks-rs5CZz-4.native.esm.js.map} +1 -1
- package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/addBusinessAccountSigner.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/createWalletForBusinessAccount/createWalletForBusinessAccount.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/transferBusinessAccountOwnership/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/transferBusinessAccountOwnership/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/transferBusinessAccountOwnership/transferBusinessAccountOwnership.d.ts +32 -0
- package/dist/modules/waas/businessAccounts/transferBusinessAccountOwnership/transferBusinessAccountOwnership.d.ts.map +1 -0
- package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
- package/dist/modules/waas/delegateWaasKeyShares/delegateWaasKeyShares.d.ts +4 -1
- package/dist/modules/waas/delegateWaasKeyShares/delegateWaasKeyShares.d.ts.map +1 -1
- package/dist/modules/waas/waas.types.d.ts +2 -1
- package/dist/modules/waas/waas.types.d.ts.map +1 -1
- package/dist/modules/wallets/utils/convertVerifiedCredentialToWalletAccount/convertVerifiedCredentialToWalletAccount.d.ts.map +1 -1
- package/dist/modules/wallets/walletAccount/walletAccount.types.d.ts +2 -0
- package/dist/modules/wallets/walletAccount/walletAccount.types.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/{updateAuthFromVerifyResponse-U7zoE0b1.esm.js → updateAuthFromVerifyResponse-85pmbAH4.esm.js} +4 -3
- package/dist/updateAuthFromVerifyResponse-85pmbAH4.esm.js.map +1 -0
- package/dist/{updateAuthFromVerifyResponse-Bm6bI0ds.cjs → updateAuthFromVerifyResponse-CNfUcLNC.cjs} +4 -3
- package/dist/updateAuthFromVerifyResponse-CNfUcLNC.cjs.map +1 -0
- package/dist/waas.cjs +56 -77
- package/dist/waas.cjs.map +1 -1
- package/dist/waas.esm.js +56 -76
- package/dist/waas.esm.js.map +1 -1
- package/dist/waas.native.esm.js +55 -75
- package/dist/waas.native.esm.js.map +1 -1
- package/dist/waasCore.cjs +9 -8
- package/dist/waasCore.cjs.map +1 -1
- package/dist/waasCore.esm.js +9 -8
- package/dist/waasCore.esm.js.map +1 -1
- package/dist/waasCore.native.esm.js +8 -7
- package/dist/waasCore.native.esm.js.map +1 -1
- package/package.json +4 -4
- package/dist/NativeModuleNotLinkedError-Duh8DMLT.native.esm.js.map +0 -1
- package/dist/modules/waas/getEmbeddedWalletsRequiringUpgrade/getEmbeddedWalletsRequiringUpgrade.d.ts +0 -30
- package/dist/modules/waas/getEmbeddedWalletsRequiringUpgrade/getEmbeddedWalletsRequiringUpgrade.d.ts.map +0 -1
- package/dist/modules/waas/getEmbeddedWalletsRequiringUpgrade/index.d.ts +0 -2
- package/dist/modules/waas/getEmbeddedWalletsRequiringUpgrade/index.d.ts.map +0 -1
- package/dist/modules/waas/hasEmbeddedWalletsRequiringUpgrade/hasEmbeddedWalletsRequiringUpgrade.d.ts +0 -23
- package/dist/modules/waas/hasEmbeddedWalletsRequiringUpgrade/hasEmbeddedWalletsRequiringUpgrade.d.ts.map +0 -1
- package/dist/modules/waas/hasEmbeddedWalletsRequiringUpgrade/index.d.ts +0 -2
- package/dist/modules/waas/hasEmbeddedWalletsRequiringUpgrade/index.d.ts.map +0 -1
- package/dist/updateAuthFromVerifyResponse-Bm6bI0ds.cjs.map +0 -1
- package/dist/updateAuthFromVerifyResponse-U7zoE0b1.esm.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waas.native.esm.js","names":["requirement: WalletCreationRequirement","refreshAuth","refreshAuth","refreshAuth","packageName","packageVersion"],"sources":["../src/modules/waas/businessAccounts/getBusinessAccountsClient/getBusinessAccountsClient.ts","../src/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.ts","../src/modules/waas/getWaasWalletProviderByChain/getWaasWalletProviderByChain.ts","../src/modules/waas/businessAccounts/addBusinessAccountSigner/addBusinessAccountSigner.ts","../src/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.ts","../src/modules/waas/backupWaasKeySharesToGoogleDrive/backupWaasKeySharesToGoogleDrive.ts","../src/modules/waas/businessAccounts/createBusinessAccount/createBusinessAccount.ts","../src/modules/waas/isWalletCreationRequirement/isWalletCreationRequirement.ts","../src/modules/waas/normalizeWalletRequirements/normalizeWalletRequirements.ts","../src/modules/waas/createWaasWalletAccounts/createWaasWalletAccounts.ts","../src/modules/waas/businessAccounts/createWalletForBusinessAccount/createWalletForBusinessAccount.ts","../src/modules/waas/delegateWaasKeyShares/delegateWaasKeyShares.ts","../src/modules/waas/exportWaasClientKeyshares/exportWaasClientKeyshares.ts","../src/modules/waas/exportWaasPrivateKey/exportWaasPrivateKey.ts","../src/modules/waas/businessAccounts/getBusinessAccount/getBusinessAccount.ts","../src/modules/wallets/userHasEmbeddedWalletForChain/userHasEmbeddedWalletForChain.ts","../src/modules/waas/getChainsMissingWaasWalletAccounts/getChainsMissingWaasWalletAccounts.ts","../src/modules/waas/getEmbeddedWalletsRequiringUpgrade/getEmbeddedWalletsRequiringUpgrade.ts","../src/modules/waas/getWalletRecoveryState/getWalletRecoveryState.ts","../src/modules/waas/hasDelegatedAccess/hasDelegatedAccess.ts","../src/modules/waas/hasEmbeddedWalletsRequiringUpgrade/hasEmbeddedWalletsRequiringUpgrade.ts","../src/modules/waas/importWaasPrivateKey/importWaasPrivateKey.ts","../src/modules/waas/isPasswordRequiredForWaasWallets/isPasswordRequiredForWaasWallets.ts","../src/modules/waas/businessAccounts/listBusinessAccounts/listBusinessAccounts.ts","../src/modules/waas/refreshWaasWalletAccountShares/refreshWaasWalletAccountShares.ts","../src/modules/waas/businessAccounts/removeBusinessAccountMember/removeBusinessAccountMember.ts","../src/modules/waas/businessAccounts/removeBusinessAccountSigner/removeBusinessAccountSigner.ts","../src/modules/waas/revokeWaasDelegation/revokeWaasDelegation.ts","../src/modules/waas/setWaasWalletAccountPassword/setWaasWalletAccountPassword.ts","../src/modules/wallets/userHasExternalWallet/userHasExternalWallet.ts","../src/modules/waas/shouldAutoCreateWalletForChain/shouldAutoCreateWalletForChain.ts","../src/modules/waas/unlockWallet/unlockWallet.ts","../src/modules/waas/updateWaasPassword/updateWaasPassword.ts","../src/exports/waas.ts"],"sourcesContent":["import type { DynamicClient } from '../../../../client/types/DynamicClient';\nimport { InvalidParamError } from '../../../../errors/InvalidParamError';\nimport { assertDefined } from '../../../../utils/assertDefined';\nimport type { Chain } from '../../../chain';\nimport { createWaasClient } from '../../createWaasClient';\nimport { getWaasChainNameFromChain } from '../../getWaasChainNameFromChain';\nimport type { BusinessAccountsApi } from '../businessAccounts.types';\n\n/**\n * Returns the business accounts API client for the first enabled WaaS chain.\n *\n * @param client - The Dynamic client instance.\n * @returns The business accounts API client.\n * @throws {InvalidParamError} When no WaaS chain configuration is enabled for the project.\n * @notInstrumented\n */\nexport const getBusinessAccountsClient = (\n client: DynamicClient\n): BusinessAccountsApi => {\n const projectSettings = client.projectSettings;\n\n assertDefined(projectSettings, 'Project settings are not available');\n\n const chainConfig =\n projectSettings.sdk.embeddedWallets?.chainConfigurations?.find(\n (chain) => chain.enabled\n );\n\n if (!chainConfig) {\n throw new InvalidParamError('No WaaS chain is enabled for this project');\n }\n\n // Normalize the project chain to the WaaS chain name (e.g. SOL -> SVM), the\n // same mapping every other createWaasClient caller applies, so the wallet\n // service is addressed under the identifier it expects.\n const waasClient = createWaasClient(\n { chainName: getWaasChainNameFromChain(chainConfig.name as Chain) },\n client\n ) as unknown as {\n businessAccounts: BusinessAccountsApi;\n };\n\n return waasClient.businessAccounts;\n};\n","import { getDefaultClient } from '../../../../client/defaultClient';\nimport type {\n BusinessAccountMember,\n BusinessAccountMemberRole,\n BusinessAccountSignerIdentifierType,\n} from '../businessAccounts.types';\nimport { getBusinessAccountsClient } from '../getBusinessAccountsClient';\n\ntype AddMemberParams = {\n businessAccountId: string;\n identifier?: string;\n identifierType?: BusinessAccountSignerIdentifierType;\n role?: BusinessAccountMemberRole;\n userId?: string;\n};\n\n/**\n * Adds a member to an existing business account. Identify the target by a known\n * `userId`, or by `identifier` + `identifierType` (e.g. an email — the user is\n * created if absent).\n *\n * @param params.businessAccountId - The ID of the business account.\n * @param [params.userId] - The ID of the user to add as a member.\n * @param [params.identifier] - The identifier value (e.g. an email address).\n * @param [params.identifierType] - The identifier type (e.g. `email`).\n * @param [params.role] - The member role (`admin` or `viewer`). Defaults server-side.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The created business account member.\n * @notInstrumented\n */\nexport const addBusinessAccountMember = async (\n {\n businessAccountId,\n userId,\n identifier,\n identifierType,\n role,\n }: AddMemberParams,\n client = getDefaultClient()\n): Promise<BusinessAccountMember> => {\n const businessAccounts = getBusinessAccountsClient(client);\n\n return businessAccounts.addMember({\n businessAccountId,\n identifier,\n identifierType,\n role,\n userId,\n });\n};\n","import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../client/types/DynamicClient';\nimport { NoWalletProviderFoundError } from '../../../errors/NoWalletProviderFoundError';\nimport type { Chain } from '../../chain';\nimport { formatWalletProviderKey } from '../../wallets/utils/formatWalletProviderKey';\nimport { DYNAMIC_WAAS_METADATA } from '../constants';\nimport type { WaasWalletProvider } from '../waas.types';\nimport { findWaasWalletProviderByChain } from '../findWaasWalletProviderByChain/findWaasWalletProviderByChain';\n\ntype GetWaasWalletProviderByChainParams = {\n chain: Chain;\n};\n\n/** @notInstrumented */\nexport const getWaasWalletProviderByChain = (\n { chain }: GetWaasWalletProviderByChainParams,\n client: DynamicClient\n): WaasWalletProvider => {\n const waasProvider = findWaasWalletProviderByChain({ chain }, client);\n\n if (!waasProvider) {\n const waasProviderKey = formatWalletProviderKey({\n chain,\n displayName: DYNAMIC_WAAS_METADATA.displayName,\n walletProviderType: WalletProviderEnum.EmbeddedWallet,\n });\n\n throw new NoWalletProviderFoundError({\n walletProviderKey: waasProviderKey,\n });\n }\n\n return waasProvider;\n};\n","import { getDefaultClient } from '../../../../client/defaultClient';\nimport { InvalidParamError } from '../../../../errors/InvalidParamError';\nimport type { WalletAccount } from '../../../wallets/walletAccount';\nimport { getWaasWalletProviderByChain } from '../../getWaasWalletProviderByChain';\nimport type {\n BusinessAccountSignerType,\n TargetSignerIdentity,\n} from '../businessAccounts.types';\nimport { getBusinessAccountsClient } from '../getBusinessAccountsClient';\n\ntype AddSignerParams = {\n businessAccountId?: string;\n password?: string;\n signerType?: BusinessAccountSignerType;\n targetSignerIdentity: TargetSignerIdentity;\n walletAccount: WalletAccount;\n walletId?: string;\n};\n\n/**\n * Adds a signer to a business-account wallet via the reshare ceremony, minting\n * the new signer's share set. Identify the target by `userId`, or `identifier`\n * + `identifierType` (the user is created if absent).\n *\n * Omit `businessAccountId` to add a signer to a wallet that isn't in a business\n * account yet: the wallet's per-account is found-or-created first (idempotent —\n * converts the personal wallet, seating its owner as the first signer), then\n * the new signer is reshared in.\n *\n * @param params.walletAccount - The wallet account to add the signer to.\n * @param [params.businessAccountId] - The business account; found-or-created when omitted.\n * @param [params.walletId] - The wallet UUID to link when finding-or-creating; defaults to `walletAccount.verifiedCredentialId`.\n * @param params.targetSignerIdentity - The signer to add (userId, or identifier + identifierType).\n * @param [params.signerType] - `endUser` (default) or `server`.\n * @param [params.password] - Password for the reshare, if the wallet is password-encrypted.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The new signer's share set id.\n * @notInstrumented\n */\nexport const addBusinessAccountSigner = async (\n {\n walletAccount,\n businessAccountId,\n walletId,\n targetSignerIdentity,\n signerType,\n password,\n }: AddSignerParams,\n client = getDefaultClient()\n): Promise<{ shareSetId: string }> => {\n // Require a resolvable target: a userId, or an identifier + its type.\n const hasUserId = Boolean(targetSignerIdentity.userId);\n const hasIdentifier = Boolean(\n targetSignerIdentity.identifier && targetSignerIdentity.identifierType\n );\n if (!hasUserId && !hasIdentifier) {\n throw new InvalidParamError(\n 'addBusinessAccountSigner: targetSignerIdentity must provide a userId, or an identifier with its identifierType'\n );\n }\n\n // No account yet: find-or-create the per-wallet business account first\n // (idempotent), then reshare the signer into it.\n let resolvedBusinessAccountId = businessAccountId;\n if (!resolvedBusinessAccountId) {\n // The link endpoint wants the wallet's UUID. WalletAccount.id is a\n // composite (`walletProviderKey:address`), so use verifiedCredentialId —\n // the VC id, which is the walletId redcoast keys wallets by.\n const linkWalletId = walletId ?? walletAccount.verifiedCredentialId;\n if (!linkWalletId) {\n throw new InvalidParamError(\n 'addBusinessAccountSigner: cannot resolve a wallet id to link — pass walletId, or use a verified wallet account'\n );\n }\n const businessAccounts = getBusinessAccountsClient(client);\n const account = await businessAccounts.addWalletToBusinessAccount({\n walletId: linkWalletId,\n });\n resolvedBusinessAccountId = account.id;\n }\n\n // Resolve the provider by chain (not by the wallet's provider key) so the\n // reshare works for any business-account wallet the caller can sign — it need\n // not be one of the session's own `getWalletAccounts()`. The reshare only\n // uses the wallet's address; the local key share is keyed by that address.\n const provider = getWaasWalletProviderByChain(\n { chain: walletAccount.chain },\n client\n );\n\n return provider.reshareToNewSignerShareSet({\n businessAccountId: resolvedBusinessAccountId,\n password,\n signerType,\n targetSignerIdentity,\n walletAccount,\n });\n};\n","import { getDefaultClient } from '../../../../client/defaultClient';\nimport type { BusinessAccountDetail } from '../businessAccounts.types';\nimport { getBusinessAccountsClient } from '../getBusinessAccountsClient';\n\ntype AddWalletParams = {\n businessAccountId?: string;\n walletId: string;\n};\n\n/**\n * Links an existing wallet to a business account. Omit `businessAccountId` to\n * find-or-create the per-wallet business account (the server seats the wallet's\n * owner as the first member/signer).\n *\n * @param [params.businessAccountId] - The business account to link to; found-or-created when omitted.\n * @param params.walletId - The ID of the wallet to link.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The updated business account detail.\n * @notInstrumented\n */\nexport const addWalletToBusinessAccount = async (\n { businessAccountId, walletId }: AddWalletParams,\n client = getDefaultClient()\n): Promise<BusinessAccountDetail> => {\n const businessAccounts = getBusinessAccountsClient(client);\n\n return businessAccounts.addWalletToBusinessAccount({\n businessAccountId,\n walletId,\n });\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype BackupWaasKeySharesToGoogleDriveParams = {\n /**\n * Optional consumer-supplied Google Drive access token. When provided (and\n * already granted Drive scopes), the SDK uses it directly instead of falling\n * back to the stored OAuth token — avoiding a second Google consent prompt.\n *\n * Especially useful for consumers using external auth: the user's Google\n * account isn't linked in Dynamic, so there's no stored OAuth token to fall\n * back on — they obtain a Drive-scoped token themselves and pass it here.\n */\n googleDriveAccessToken?: string;\n password?: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Backs up WaaS wallet key shares to Google Drive for secure recovery.\n *\n * This function creates a backup of the wallet's cryptographic key shares\n * to Google Drive, allowing users to recover their wallet later.\n *\n * @param params.walletAccount - The WaaS wallet account to backup.\n * @param [params.password] - Optional password to encrypt the backup.\n * @param [params.googleDriveAccessToken] - Optional consumer-supplied Drive-scoped access token; used directly instead of the stored OAuth token (avoids a second Google consent). Useful for external-auth setups.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the backup process is complete.\n * @notInstrumented\n */\nexport const backupWaasKeySharesToGoogleDrive = async (\n {\n googleDriveAccessToken,\n password,\n walletAccount,\n }: BackupWaasKeySharesToGoogleDriveParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.backupKeySharesToGoogleDrive({\n googleDriveAccessToken,\n password,\n walletAccount,\n });\n};\n","import { getDefaultClient } from '../../../../client/defaultClient';\nimport type { BusinessAccount } from '../businessAccounts.types';\nimport { getBusinessAccountsClient } from '../getBusinessAccountsClient';\n\ntype CreateBusinessAccountParams = {\n name?: string;\n};\n\n/**\n * Creates a new business account.\n *\n * @param [params] - Optional parameters for the business account.\n * @param [params.name] - Optional name for the business account.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The created business account.\n * @notInstrumented\n */\nexport const createBusinessAccount = async (\n params?: CreateBusinessAccountParams,\n client = getDefaultClient()\n): Promise<BusinessAccount> => {\n const businessAccounts = getBusinessAccountsClient(client);\n\n return businessAccounts.createBusinessAccount({\n request: { name: params?.name },\n });\n};\n","import type { Chain } from '../../chain';\nimport type { WalletCreationRequirement } from '../waas.types';\n\n/**\n * Type guard to check if an item is a WalletCreationRequirement object.\n * Chain values are strings, so we can distinguish by checking if it's an object with a 'chain' property.\n *\n * @param item - The item to check, either a WalletCreationRequirement or Chain string\n * @returns True if the item is a WalletCreationRequirement object\n * @notInstrumented\n */\nexport const isWalletCreationRequirement = (\n item: WalletCreationRequirement | Chain\n): item is WalletCreationRequirement =>\n typeof item === 'object' && item !== null && 'chain' in item;\n","import type { Chain } from '../../chain';\nimport { isWalletCreationRequirement } from '../isWalletCreationRequirement/isWalletCreationRequirement';\nimport type {\n WalletCreationBitcoinConfig,\n WalletCreationRequirement,\n} from '../waas.types';\n\nconst DEFAULT_BITCOIN_ADDRESS_TYPE = 'native_segwit' as const;\n\ntype NormalizeWalletRequirementsParams = {\n defaultBitcoinConfig?: WalletCreationBitcoinConfig;\n input: WalletCreationRequirement[] | Chain[];\n};\n\n/**\n * Normalizes wallet creation input from either legacy Chain[] format\n * or new WalletCreationRequirement[] format to WalletCreationRequirement[].\n *\n * For BTC chains without explicit bitcoinConfig, defaults to native_segwit.\n *\n * @param params.input - Either an array of Chain strings or WalletCreationRequirement objects\n * @param params.defaultBitcoinConfig - Optional default bitcoin config to use for BTC chains when converting from legacy format\n * @returns Array of WalletCreationRequirement objects\n * @notInstrumented\n */\nexport const normalizeWalletRequirements = ({\n defaultBitcoinConfig,\n input,\n}: NormalizeWalletRequirementsParams): WalletCreationRequirement[] => {\n if (input.length === 0) {\n return [];\n }\n\n const [firstItem] = input;\n\n if (isWalletCreationRequirement(firstItem)) {\n return (input as WalletCreationRequirement[]).map((requirement) => {\n if (requirement.chain === 'BTC' && !requirement.bitcoinConfig) {\n return {\n ...requirement,\n bitcoinConfig: { addressType: DEFAULT_BITCOIN_ADDRESS_TYPE },\n };\n }\n\n return requirement;\n });\n }\n\n return (input as Chain[]).map((chain) => {\n const requirement: WalletCreationRequirement = { chain };\n\n if (chain === 'BTC') {\n requirement.bitcoinConfig = defaultBitcoinConfig ?? {\n addressType: DEFAULT_BITCOIN_ADDRESS_TYPE,\n };\n }\n\n return requirement;\n });\n};\n","import type { ThresholdSignatureScheme } from '@dynamic-labs-wallet/browser-wallet-client';\nimport { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { NotWaasWalletProviderError } from '../../../errors/NotWaasWalletProviderError';\nimport { NoWalletProviderFoundError } from '../../../errors/NoWalletProviderFoundError';\nimport type { Chain } from '../../chain';\nimport { refreshAuth } from '../../user/refreshAuth';\nimport { getWalletProviderByKey } from '../../wallets/getWalletProviderByKey';\nimport { formatWalletProviderKey } from '../../wallets/utils/formatWalletProviderKey';\nimport { DYNAMIC_WAAS_METADATA } from '../constants';\nimport { isWaasWalletProvider } from '../isWaasWalletProvider';\nimport { normalizeWalletRequirements } from '../normalizeWalletRequirements/normalizeWalletRequirements';\nimport type { WalletCreationRequirement } from '../waas.types';\n\ntype CreateWaasWalletAccountsParams = {\n /**\n * For which chains to create wallet accounts.\n * Accepts either an array of chain strings (legacy format) or an array of\n * WalletCreationRequirement objects for chain-specific configuration.\n *\n * For Bitcoin, you can specify the address type ('native_segwit' or 'taproot').\n * If not specified, defaults to 'native_segwit'.\n *\n * If a chain is passed multiple times, just as many wallet accounts will be created\n * for that chain.\n * @notInstrumented\n */\n chains: Chain[] | WalletCreationRequirement[];\n /**\n * The optional password to use for the wallet accounts.\n * It's used to encrypt the user shares.\n * The same password must be used for all waas wallet accounts created for the same user.\n */\n password?: string;\n /**\n * The threshold signature scheme to use for the wallet accounts.\n * If not provided, TWO_OF_TWO will be used.\n */\n thresholdSignatureScheme?: ThresholdSignatureScheme;\n};\n\n/**\n * Creates wallet accounts for the specified chains.\n *\n * This function creates wallet accounts for the specified chains.\n * If the same chain is passed multiple times, just as many wallet accounts will be created\n * for that chain.\n *\n * @example\n * ```ts\n * // Legacy format - will create wallet accounts for EVM and SOL, BTC defaults to native_segwit\n * await createWaasWalletAccounts({ chains: ['EVM', 'SOL', 'BTC'] });\n *\n * // New format with chain-specific config\n * await createWaasWalletAccounts({\n * chains: [\n * { chain: 'BTC', bitcoinConfig: { addressType: 'taproot' } },\n * { chain: 'EVM' },\n * ]\n * });\n *\n * // Create both BTC address types\n * await createWaasWalletAccounts({\n * chains: [\n * { chain: 'BTC', bitcoinConfig: { addressType: 'native_segwit' } },\n * { chain: 'BTC', bitcoinConfig: { addressType: 'taproot' } },\n * ]\n * });\n * ```\n *\n * @param params.chains - The chains to create wallet accounts for.\n * @param params.password - The optional password to use for the wallet accounts.\n * @param params.thresholdSignatureScheme - The threshold signature scheme to use for the wallet accounts. (Default: TWO_OF_TWO)\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when all wallet accounts are created.\n * @notInstrumented\n */\nexport const createWaasWalletAccounts = async (\n {\n chains,\n password,\n thresholdSignatureScheme,\n }: CreateWaasWalletAccountsParams,\n client = getDefaultClient()\n): Promise<void> => {\n const normalizedRequirements = normalizeWalletRequirements({ input: chains });\n\n // we need this right now so we don't try to create wallet accounts for chains\n // that we don't support Dynamic Waas yet in the JS SDK\n const supportedChains = ['BTC', 'EVM', 'SOL', 'SUI', 'TON', 'TRON'];\n\n const filteredRequirements = normalizedRequirements.filter((requirement) =>\n supportedChains.includes(requirement.chain)\n );\n\n if (filteredRequirements.length === 0) {\n return;\n }\n\n const walletProviderMap = new Map<\n string,\n ReturnType<typeof getWalletProviderByKey>\n >();\n\n for (const requirement of filteredRequirements) {\n const walletProviderKey = formatWalletProviderKey({\n chain: requirement.chain,\n displayName: DYNAMIC_WAAS_METADATA.displayName,\n walletProviderType: WalletProviderEnum.EmbeddedWallet,\n });\n\n if (!walletProviderMap.has(walletProviderKey)) {\n const walletProvider = getWalletProviderByKey(\n { walletProviderKey },\n client\n );\n\n if (!walletProvider) {\n throw new NoWalletProviderFoundError({\n walletProviderKey,\n });\n }\n\n if (!isWaasWalletProvider(walletProvider)) {\n throw new NotWaasWalletProviderError({\n walletProviderKey,\n });\n }\n\n walletProviderMap.set(walletProviderKey, walletProvider);\n }\n }\n\n await Promise.all(\n filteredRequirements.map((requirement) => {\n const walletProviderKey = formatWalletProviderKey({\n chain: requirement.chain,\n displayName: DYNAMIC_WAAS_METADATA.displayName,\n walletProviderType: WalletProviderEnum.EmbeddedWallet,\n });\n\n const walletProvider = walletProviderMap.get(walletProviderKey);\n\n if (!walletProvider || !isWaasWalletProvider(walletProvider)) {\n return Promise.resolve();\n }\n\n return walletProvider.createWalletAccount({\n bitcoinConfig: requirement.bitcoinConfig,\n password,\n thresholdSignatureScheme,\n });\n })\n );\n\n await refreshAuth(client);\n};\n","import { getDefaultClient } from '../../../../client/defaultClient';\nimport type { Chain } from '../../../chain';\nimport { getWaasWalletProviderByChain } from '../../getWaasWalletProviderByChain';\nimport type { ThresholdSignatureScheme } from '../../waas.types';\n\ntype CreateWalletForBusinessAccountParams = {\n businessAccountId: string;\n chain: Chain;\n password?: string;\n thresholdSignatureScheme?: ThresholdSignatureScheme;\n};\n\n/**\n * Creates a WaaS wallet account owned directly by a business account, in one\n * step — the server seats the wallet's signer row against the business account\n * as it is minted, so no separate link call is needed.\n *\n * @example\n * ```ts\n * const wallet = await createWalletForBusinessAccount({\n * businessAccountId: 'ba-1',\n * chain: 'EVM',\n * });\n * ```\n *\n * @param params.businessAccountId - The business account that will own the wallet.\n * @param params.chain - The chain to create the wallet account for.\n * @param [params.password] - Optional password used to encrypt the user share.\n * @param [params.thresholdSignatureScheme] - The threshold signature scheme to use. (Default: TWO_OF_TWO)\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The created wallet account.\n * @notInstrumented\n */\nexport const createWalletForBusinessAccount = async (\n {\n businessAccountId,\n chain,\n password,\n thresholdSignatureScheme,\n }: CreateWalletForBusinessAccountParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderByChain({ chain }, client);\n\n return provider.createWalletAccount({\n businessAccountId,\n password,\n thresholdSignatureScheme,\n });\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { refreshAuth } from '../../user/refreshAuth';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype DelegateWaasKeySharesParams = {\n password?: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Delegates cryptographic key shares for a WaaS wallet account.\n *\n * This function allows the delegation of key management responsibilities,\n * enabling distributed key management for enhanced security.\n *\n * @param params.walletAccount - The WaaS wallet account to delegate shares for.\n * @param [params.password] - Optional password for key share operations.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the key delegation is complete.\n * @notInstrumented\n */\nexport const delegateWaasKeyShares = async (\n { password, walletAccount }: DelegateWaasKeySharesParams,\n client = getDefaultClient()\n): Promise<void> => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n await provider.delegateKeyShares({\n password,\n walletAccount,\n });\n\n await refreshAuth(client);\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype ExportWaasClientKeysharesParams = {\n password?: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Exports the client-side key shares for a WaaS wallet account.\n *\n * This function retrieves the cryptographic key shares that are stored\n * on the client side for backup or migration purposes.\n *\n * @param params.walletAccount - The WaaS wallet account to export shares from.\n * @param [params.password] - Optional password to encrypt the exported shares.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the exported key shares.\n * @notInstrumented\n */\nexport const exportWaasClientKeyshares = async (\n { password, walletAccount }: ExportWaasClientKeysharesParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.exportClientKeyshares({\n password,\n walletAccount,\n });\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype ExportWaasPrivateKeyParams = {\n displayContainer: HTMLElement;\n password?: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Exports the private key for a WaaS wallet account with secure display.\n *\n * This function reveals the private key for a WaaS wallet and displays it\n * securely within an iframe dynamically inserted into the specified HTML container element.\n *\n * @param params.walletAccount - The WaaS wallet account to export the private key from.\n * @param params.displayContainer - The HTML element where the iframe will be injected.\n * @param [params.password] - Optional password to decrypt the private key.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the private key export is complete.\n * @notInstrumented\n */\nexport const exportWaasPrivateKey = async (\n { displayContainer, password, walletAccount }: ExportWaasPrivateKeyParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.exportPrivateKey({\n displayContainer,\n password,\n walletAccount,\n });\n};\n","import { getDefaultClient } from '../../../../client/defaultClient';\nimport type { BusinessAccountDetail } from '../businessAccounts.types';\nimport { getBusinessAccountsClient } from '../getBusinessAccountsClient';\n\ntype GetBusinessAccountParams = {\n businessAccountId: string;\n};\n\n/**\n * Retrieves a business account by ID, including its members, signers, and wallets.\n *\n * @param params.businessAccountId - The ID of the business account to retrieve.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The business account with its members, signers, and wallets.\n * @notInstrumented\n */\nexport const getBusinessAccount = async (\n { businessAccountId }: GetBusinessAccountParams,\n client = getDefaultClient()\n): Promise<BusinessAccountDetail> => {\n const businessAccounts = getBusinessAccountsClient(client);\n\n return businessAccounts.getBusinessAccount({ businessAccountId });\n};\n","import { type SdkUser, WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport { getChainFromVerifiedCredentialChain } from '../../../utils/getChainFromVerifiedCredentialChain';\nimport type { Chain } from '../../chain/chain.types';\n\ntype UserHasEmbeddedWalletForChainProps = {\n chain: Chain;\n user: SdkUser;\n};\n\n/** @notInstrumented */\nexport const userHasEmbeddedWalletForChain = ({\n user,\n chain,\n}: UserHasEmbeddedWalletForChainProps): boolean => {\n const hasEmbeddedWalletForChain = user.verifiedCredentials.some(\n (vc) =>\n vc.walletProvider === WalletProviderEnum.EmbeddedWallet &&\n vc.chain &&\n getChainFromVerifiedCredentialChain(vc.chain) === chain\n );\n\n return hasEmbeddedWalletForChain;\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport type { Chain } from '../../chain/chain.types';\nimport { userHasEmbeddedWalletForChain } from '../../wallets/userHasEmbeddedWalletForChain';\nimport { isDynamicWaasEnabled } from '../isDynamicWaasEnabled';\n\n/**\n * Gets all chains missing a waas wallet account for the current user.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An array of all chains that have waas wallet accounts enabled\n * but for which the current user does not yet have an embedded wallet account.\n * @notInstrumented\n */\nexport const getChainsMissingWaasWalletAccounts = (\n client = getDefaultClient()\n): Chain[] => {\n const projectSettings = client.projectSettings;\n\n assertDefined(projectSettings, 'Project settings are not available');\n\n const embeddedWalletSettings = projectSettings.sdk.embeddedWallets;\n\n const isWaasEnabled = isDynamicWaasEnabled(client);\n\n const user = client.user;\n\n if (!user || !isWaasEnabled) {\n return [];\n }\n\n const enabledChainForWaas: Chain[] = (\n embeddedWalletSettings?.chainConfigurations?.filter(\n (chain) => chain.enabled\n ) ?? []\n ).map((chain) => chain.name as Chain);\n\n // For each enabled chain, if user does NOT have an embedded wallet, add to missing\n return enabledChainForWaas.filter(\n (chain) => !userHasEmbeddedWalletForChain({ chain, user })\n );\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { getWalletAccounts } from '../../wallets/getWalletAccounts';\nimport type { WalletAccount } from '../../wallets/walletAccount';\n\n/**\n * Provider-key substring shared by every Dynamic embedded wallet that predates\n * Dynamic WaaS and can therefore be upgraded to it (via the Dynamic WaaS\n * upgrade flow). A wallet account's `walletProviderKey` is a composite value\n * (e.g. `turnkeyevm:embeddedWallet`, `turnkeyhdsolana:embeddedWallet`), so it\n * is matched as a substring. Both the standard and HD variants contain this\n * key, so it alone identifies all of them.\n */\nconst LEGACY_EMBEDDED_WALLET_PROVIDER_KEY = 'turnkey';\n\n/**\n * Returns the current session's wallet accounts that are legacy Dynamic\n * embedded wallets requiring an upgrade to Dynamic WaaS.\n *\n * These are earlier-generation Dynamic embedded wallets that predate Dynamic\n * WaaS (the current TSS-MPC embedded wallet) and can be migrated to it. Use\n * this when you need the accounts themselves — for example to show how many\n * wallets can be upgraded and let the user act on them. It never returns\n * already-upgraded Dynamic WaaS accounts. For a simple boolean \"does this user\n * have anything to upgrade?\" check, use `hasEmbeddedWalletsRequiringUpgrade`\n * instead.\n *\n * @example\n * ```ts\n * const walletsRequiringUpgrade = getEmbeddedWalletsRequiringUpgrade();\n * if (walletsRequiringUpgrade.length > 0) {\n * showUpgradePrompt(\n * `You have ${walletsRequiringUpgrade.length} wallet(s) that can be upgraded. Upgrade now?`\n * );\n * }\n * ```\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The wallet accounts requiring an upgrade to Dynamic WaaS (empty when none).\n * @see hasEmbeddedWalletsRequiringUpgrade\n * @see isWaasWalletAccount\n * @notInstrumented\n */\nexport const getEmbeddedWalletsRequiringUpgrade = (\n client = getDefaultClient()\n): WalletAccount[] =>\n getWalletAccounts(client).filter((walletAccount) =>\n walletAccount.walletProviderKey.includes(LEGACY_EMBEDDED_WALLET_PROVIDER_KEY)\n );\n","import type { WalletRecoveryState } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport type { DynamicClient } from '../../../client/types/DynamicClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype GetWalletRecoveryStateParams = {\n walletAccount: WalletAccount;\n};\n\n/**\n * Retrieves the recovery state of a WaaS wallet account.\n *\n * @param params.walletAccount - The WaaS wallet account to get the recovery state for.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves with the wallet recovery state.\n * @notInstrumented\n */\nexport const getWalletRecoveryState = async (\n { walletAccount }: GetWalletRecoveryStateParams,\n client: DynamicClient = getDefaultClient()\n): Promise<WalletRecoveryState> => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.getWalletRecoveryState({\n walletAccount,\n });\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { getVerifiedCredentialForWalletAccount } from '../../wallets/utils/getVerifiedCredentialForWalletAccount';\nimport type { WalletAccount } from '../../wallets/walletAccount';\n\ntype HasDelegatedAccessParams = {\n walletAccount: WalletAccount;\n};\n\n/**\n * Checks if a WaaS wallet account has delegated access.\n *\n * @param params.walletAccount - The WaaS wallet account to check for delegated access.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if the wallet account has delegated access, false otherwise.\n * @notInstrumented\n */\nexport const hasDelegatedAccess = (\n { walletAccount }: HasDelegatedAccessParams,\n client = getDefaultClient()\n): boolean => {\n const verifiedCredential = getVerifiedCredentialForWalletAccount(\n { walletAccount },\n client\n );\n\n assertDefined(\n verifiedCredential,\n 'Verified credential not found for Waas wallet account'\n );\n\n const hasDelegatedKeyShare =\n verifiedCredential.walletProperties?.keyShares?.some(\n (keyShare) => keyShare.backupLocation === 'delegated'\n );\n\n return !!hasDelegatedKeyShare;\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { getEmbeddedWalletsRequiringUpgrade } from '../getEmbeddedWalletsRequiringUpgrade';\n\n/**\n * Returns whether the current session has any legacy Dynamic embedded wallet\n * that requires an upgrade to Dynamic WaaS.\n *\n * This is a boolean convenience over {@link getEmbeddedWalletsRequiringUpgrade}\n * for the common case where you only need to decide whether to trigger the\n * upgrade flow (e.g. show a prompt or redirect to a migration app) rather than\n * act on the specific accounts.\n *\n * @example\n * ```ts\n * if (hasEmbeddedWalletsRequiringUpgrade()) {\n * showUpgradeToWaasBanner();\n * }\n * ```\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True when at least one wallet account requires an upgrade to Dynamic WaaS, false otherwise.\n * @see getEmbeddedWalletsRequiringUpgrade\n * @see isWaasWalletAccount\n * @notInstrumented\n */\nexport const hasEmbeddedWalletsRequiringUpgrade = (\n client = getDefaultClient()\n): boolean => getEmbeddedWalletsRequiringUpgrade(client).length > 0;\n","import type { ThresholdSignatureScheme } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport type { Chain } from '../../chain';\nimport { getWaasWalletProviderByChain } from '../getWaasWalletProviderByChain';\n\ntype ImportWaasPrivateKeyParams = {\n chain: Chain;\n privateKey: string;\n thresholdSignatureScheme?: ThresholdSignatureScheme;\n};\n\n/**\n * Imports an existing private key to create a new WaaS wallet account.\n *\n * This function allows users to import their existing private key into\n * Dynamic's WaaS infrastructure for secure management.\n *\n * @param params.chain - The chain for the imported wallet.\n * @param params.privateKey - The private key to import.\n * @param [params.thresholdSignatureScheme] - Optional threshold signature scheme configuration. Default is TWO_OF_TWO.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the private key is successfully imported.\n * @notInstrumented\n */\nexport const importWaasPrivateKey = async (\n { chain, privateKey, thresholdSignatureScheme }: ImportWaasPrivateKeyParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderByChain({ chain }, client);\n\n return provider.importPrivateKey({\n privateKey,\n thresholdSignatureScheme,\n });\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Checks if the user Waas wallets are password protected.\n *\n * If the user's Waas wallets are password protected, it means that user's will have to be prompted for a\n * password for the first wallet action that happens on each session.\n * The password is also required for creating any new Waas wallets.\n *\n * @param client - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if the user has any password protected Waas wallets, false otherwise\n * @notInstrumented\n */\nexport const isPasswordRequiredForWaasWallets = (\n client = getDefaultClient()\n): boolean => {\n const { user } = client;\n\n assertDefined(user, 'User is not authenticated');\n\n return user.verifiedCredentials.some((credential) =>\n credential.walletProperties?.keyShares?.some(\n (keyShare) => keyShare.passwordEncrypted\n )\n );\n};\n","import { getDefaultClient } from '../../../../client/defaultClient';\nimport type { BusinessAccountList } from '../businessAccounts.types';\nimport { getBusinessAccountsClient } from '../getBusinessAccountsClient';\n\n/**\n * Lists all business accounts for the current project environment.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A paginated list of business accounts.\n * @notInstrumented\n */\nexport const listBusinessAccounts = async (\n client = getDefaultClient()\n): Promise<BusinessAccountList> => {\n const businessAccounts = getBusinessAccountsClient(client);\n\n return businessAccounts.listBusinessAccounts();\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype RefreshWaasWalletAccountSharesParams = {\n password?: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Refreshes the cryptographic key shares for a WaaS wallet account.\n *\n * This function generates new key shares for the wallet while maintaining\n * the same threshold signature scheme.\n *\n * @param params.walletAccount - The WaaS wallet account to refresh shares for.\n * @param [params.password] - Optional password for key share operations.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the key shares are refreshed.\n * @notInstrumented\n */\nexport const refreshWaasWalletAccountShares = async (\n { walletAccount, password }: RefreshWaasWalletAccountSharesParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.refreshWalletAccountShares({\n password,\n walletAccount,\n });\n};\n","import { getCore } from '../../../../client/core/getCore';\nimport { getDefaultClient } from '../../../../client/defaultClient';\nimport type { DynamicClient } from '../../../../client/types';\nimport { createApiClient } from '../../../apiClient/createApiClient';\nimport type { BusinessAccountMember } from '../businessAccounts.types';\n\ntype RemoveMemberParams = {\n businessAccountId: string;\n userId: string;\n};\n\n/**\n * Removes a member from a business account. Any signer rows the member held on\n * the account's wallets are torn down as part of the removal. The backend\n * refuses to remove the account's last owner.\n *\n * @param params.businessAccountId - The business account to remove the member from.\n * @param params.userId - The id of the user to remove.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The removed member.\n *\n * @example\n * ```ts\n * const detail = await getBusinessAccount({ businessAccountId });\n * const member = detail.members[0];\n * await removeBusinessAccountMember({\n * businessAccountId,\n * userId: member.userId,\n * });\n * ```\n *\n * @see addBusinessAccountMember\n * @see getBusinessAccount\n * @notInstrumented\n */\nexport const removeBusinessAccountMember = async (\n { businessAccountId, userId }: RemoveMemberParams,\n client: DynamicClient = getDefaultClient()\n): Promise<BusinessAccountMember> => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const { member } = await apiClient.sdkRemoveBusinessAccountMember({\n businessAccountId,\n environmentId: core.environmentId,\n userId,\n });\n\n return member as BusinessAccountMember;\n};\n","import { getCore } from '../../../../client/core/getCore';\nimport { getDefaultClient } from '../../../../client/defaultClient';\nimport type { DynamicClient } from '../../../../client/types';\nimport { createApiClient } from '../../../apiClient/createApiClient';\nimport type { BusinessAccountSigner } from '../businessAccounts.types';\n\ntype RemoveSignerParams = {\n businessAccountId: string;\n signerId: string;\n walletId: string;\n};\n\n/**\n * Removes a signer from a business-account wallet. This detaches the signer's\n * share set from the wallet — it does not run an MPC ceremony — so the removed\n * identity can no longer sign for that wallet. The backend refuses to remove\n * the last remaining signer on a wallet.\n *\n * @param params.businessAccountId - The business account the wallet belongs to.\n * @param params.walletId - The wallet the signer is attached to.\n * @param params.signerId - The id of the signer to remove (`BusinessAccountSigner.id`).\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The removed signer.\n *\n * @example\n * ```ts\n * const detail = await getBusinessAccount({ businessAccountId });\n * const signer = detail.signers[0];\n * await removeBusinessAccountSigner({\n * businessAccountId,\n * walletId: signer.walletId,\n * signerId: signer.id,\n * });\n * ```\n *\n * @see addBusinessAccountSigner\n * @see getBusinessAccount\n * @notInstrumented\n */\nexport const removeBusinessAccountSigner = async (\n { businessAccountId, walletId, signerId }: RemoveSignerParams,\n client: DynamicClient = getDefaultClient()\n): Promise<BusinessAccountSigner> => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const { signer } = await apiClient.sdkRemoveBusinessAccountSigner({\n businessAccountId,\n environmentId: core.environmentId,\n signerId,\n walletId,\n });\n\n return signer as BusinessAccountSigner;\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { refreshAuth } from '../../user/refreshAuth';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype RevokeWaasDelegationParams = {\n password?: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Revokes the delegation of a WaaS wallet account.\n *\n * @param params.walletAccount - The WaaS wallet account to revoke delegation for.\n * @param [params.password] - Optional password for delegation operations.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the delegation is revoked.\n * @notInstrumented\n */\nexport const revokeWaasDelegation = async (\n { password, walletAccount }: RevokeWaasDelegationParams,\n client = getDefaultClient()\n): Promise<void> => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n await provider.revokeDelegation({\n password,\n walletAccount,\n });\n\n await refreshAuth(client);\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype SetWaasWalletAccountPasswordParams = {\n password: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Sets a password for a WaaS wallet account.\n *\n * @param params.walletAccount - The WaaS wallet account to set the password for.\n * @param params.password - The password to set for the wallet.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the password is successfully set.\n * @notInstrumented\n */\nexport const setWaasWalletAccountPassword = async (\n { password, walletAccount }: SetWaasWalletAccountPasswordParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.setWaasWalletAccountPassword({\n password,\n walletAccount,\n });\n};\n","import {\n JwtVerifiedCredentialFormatEnum,\n type SdkUser,\n WalletProviderEnum,\n} from '@dynamic-labs/sdk-api-core';\n\n/** @notInstrumented */\nexport const userHasExternalWallet = (user: SdkUser) => {\n const hasExternalWallet = user?.verifiedCredentials.some(\n (vc) =>\n vc.format === JwtVerifiedCredentialFormatEnum.Blockchain &&\n vc.walletProvider !== WalletProviderEnum.EmbeddedWallet\n );\n\n return hasExternalWallet;\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport type { Chain } from '../../chain';\nimport { userHasExternalWallet } from '../../wallets/userHasExternalWallet';\nimport { getChainsMissingWaasWalletAccounts } from '../getChainsMissingWaasWalletAccounts';\n\ntype ShouldAutoCreateWalletForChainParams = {\n chain: Chain;\n};\n\n/**\n * Checks if a WaaS wallet should be automatically created for the specified blockchain.\n *\n * This function determines whether the current user configuration and project\n * settings require automatic wallet creation for the given chain, considering\n * whether the user already has an embedded wallet for the enabled chains or an external wallet.\n *\n * @param params.chain - The blockchain network to check.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if a wallet should be auto-created for the chain, false otherwise.\n * @notInstrumented\n */\nexport const shouldAutoCreateWalletForChain = (\n { chain }: ShouldAutoCreateWalletForChainParams,\n client = getDefaultClient()\n) => {\n assertDefined(client.projectSettings, 'Project settings are not available');\n\n const embeddedWalletSettings = client.projectSettings.sdk.embeddedWallets;\n\n const automaticEmbeddedWalletCreationEnabled =\n embeddedWalletSettings?.automaticEmbeddedWalletCreation;\n\n if (!automaticEmbeddedWalletCreationEnabled || !client.user) {\n return false;\n }\n\n const automaticEmbeddedWalletCreationForExternalEnabled =\n embeddedWalletSettings?.automaticEmbeddedWalletCreationForExternal;\n\n // If user has an external wallet (e.g metamask, phantom, etc), should only\n // create if automaticEmbeddedWalletCreationForExternalEnabled is true\n const shouldCreateDynamicWaasWallet =\n !userHasExternalWallet(client.user) ||\n automaticEmbeddedWalletCreationForExternalEnabled;\n\n if (!shouldCreateDynamicWaasWallet) {\n return false;\n }\n\n const chainsMissingAutoCreatedWallet =\n getChainsMissingWaasWalletAccounts(client);\n\n return chainsMissingAutoCreatedWallet.includes(chain);\n};\n","import type { GetWalletResponse } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype UnlockWalletParams = {\n password: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Unlocks a WaaS wallet account.\n *\n * @param params.walletAccount - The WaaS wallet account to unlock.\n * @param params.password - The password to unlock the wallet.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves with the wallet information.\n * @notInstrumented\n */\nexport const unlockWallet = async (\n { password, walletAccount }: UnlockWalletParams,\n client = getDefaultClient()\n): Promise<GetWalletResponse> => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.unlockWallet({\n password,\n walletAccount,\n });\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype UpdateWaasPasswordParams = {\n currentPassword: string;\n newPassword: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Updates the password for a WaaS wallet account.\n *\n * This function changes the password used to encrypt and protect the\n * cryptographic key shares for the specified wallet account.\n *\n * @param params.walletAccount - The WaaS wallet account to update the password for.\n * @param params.currentPassword - The current password for the wallet.\n * @param params.newPassword - The new password to set for the wallet.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the password is successfully updated.\n * @notInstrumented\n */\nexport const updateWaasPassword = async (\n { currentPassword, newPassword, walletAccount }: UpdateWaasPasswordParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.updatePassword({\n currentPassword,\n newPassword,\n walletAccount,\n });\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport type {\n GetWalletResponse,\n MigrateFromFireblocksResponse,\n WalletRecoveryState,\n} from '@dynamic-labs-wallet/browser-wallet-client';\nexport { NotWaasWalletProviderError } from '../errors/NotWaasWalletProviderError';\nexport type {\n BusinessAccount,\n BusinessAccountDetail,\n BusinessAccountList,\n BusinessAccountMember,\n BusinessAccountSigner,\n BusinessAccountWalletSummary,\n} from '../modules/waas/businessAccounts/businessAccounts.types';\nexport { addBusinessAccountMember } from '../modules/waas/businessAccounts/addBusinessAccountMember';\nexport { addBusinessAccountSigner } from '../modules/waas/businessAccounts/addBusinessAccountSigner';\nexport { addWalletToBusinessAccount } from '../modules/waas/businessAccounts/addWalletToBusinessAccount';\nexport { backupWaasKeySharesToGoogleDrive } from '../modules/waas/backupWaasKeySharesToGoogleDrive';\nexport { createBusinessAccount } from '../modules/waas/businessAccounts/createBusinessAccount';\nexport { createWaasWalletAccounts } from '../modules/waas/createWaasWalletAccounts';\nexport { createWalletForBusinessAccount } from '../modules/waas/businessAccounts/createWalletForBusinessAccount';\nexport { delegateWaasKeyShares } from '../modules/waas/delegateWaasKeyShares';\nexport { exportWaasClientKeyshares } from '../modules/waas/exportWaasClientKeyshares';\nexport { exportWaasPrivateKey } from '../modules/waas/exportWaasPrivateKey';\nexport { getBusinessAccount } from '../modules/waas/businessAccounts/getBusinessAccount';\nexport { getChainsMissingWaasWalletAccounts } from '../modules/waas/getChainsMissingWaasWalletAccounts';\nexport { getEmbeddedWalletsRequiringUpgrade } from '../modules/waas/getEmbeddedWalletsRequiringUpgrade';\nexport { getWalletRecoveryState } from '../modules/waas/getWalletRecoveryState';\nexport { hasDelegatedAccess } from '../modules/waas/hasDelegatedAccess';\nexport { hasEmbeddedWalletsRequiringUpgrade } from '../modules/waas/hasEmbeddedWalletsRequiringUpgrade';\nexport { importWaasPrivateKey } from '../modules/waas/importWaasPrivateKey';\nexport { isDynamicWaasEnabled } from '../modules/waas/isDynamicWaasEnabled';\nexport { isPasswordRequiredForWaasWallets } from '../modules/waas/isPasswordRequiredForWaasWallets';\nexport { isWaasWalletAccount } from '../modules/waas/isWaasWalletAccount';\nexport { isWalletCreationRequirement } from '../modules/waas/isWalletCreationRequirement/isWalletCreationRequirement';\nexport { listBusinessAccounts } from '../modules/waas/businessAccounts/listBusinessAccounts';\nexport { migrateFromFireblocks } from '../modules/waas/migrateFromFireblocks';\nexport { normalizeWalletRequirements } from '../modules/waas/normalizeWalletRequirements/normalizeWalletRequirements';\nexport { refreshWaasWalletAccountShares } from '../modules/waas/refreshWaasWalletAccountShares';\nexport { removeBusinessAccountMember } from '../modules/waas/businessAccounts/removeBusinessAccountMember';\nexport { removeBusinessAccountSigner } from '../modules/waas/businessAccounts/removeBusinessAccountSigner';\nexport { revokeWaasDelegation } from '../modules/waas/revokeWaasDelegation';\nexport { setWaasWalletAccountPassword } from '../modules/waas/setWaasWalletAccountPassword';\nexport { shouldAutoCreateWalletForChain } from '../modules/waas/shouldAutoCreateWalletForChain';\nexport { unlockWallet } from '../modules/waas/unlockWallet';\nexport { updateWaasPassword } from '../modules/waas/updateWaasPassword';\nexport type {\n WalletCreationBitcoinConfig,\n WalletCreationRequirement,\n} from '../modules/waas/waas.types';\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAa,6BACX,WACwB;CACxB,MAAM,kBAAkB,OAAO;AAE/B,eAAc,iBAAiB,qCAAqC;CAEpE,MAAM,cACJ,gBAAgB,IAAI,iBAAiB,qBAAqB,MACvD,UAAU,MAAM,QAClB;AAEH,KAAI,CAAC,YACH,OAAM,IAAI,kBAAkB,4CAA4C;AA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;;;;;;ACjCvD,MAAa,eAAe,OAC1B,EAAE,UAAU,iBACZ,SAAS,kBAAkB,KACI;AAM/B,QALiB,uCACf,EAAE,eAAe,EACjB,OACD,CAEe,aAAa;EAC3B;EACA;EACD,CAAC;;;;;;;;;;;;;;;;;;ACTJ,MAAa,qBAAqB,OAChC,EAAE,iBAAiB,aAAa,iBAChC,SAAS,kBAAkB,KACxB;AAMH,QALiB,uCACf,EAAE,eAAe,EACjB,OACD,CAEe,eAAe;EAC7B;EACA;EACA;EACD,CAAC;;;;;AC9BJ,qBAAqBC,MAAaC,QAAe"}
|
|
1
|
+
{"version":3,"file":"waas.native.esm.js","names":["refreshAuth","refreshAuth","requirement: WalletCreationRequirement","refreshAuth","refreshAuth","refreshAuth","refreshAuth","refreshAuth","packageName","packageVersion"],"sources":["../src/modules/waas/businessAccounts/getBusinessAccountsClient/getBusinessAccountsClient.ts","../src/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.ts","../src/modules/waas/getWaasWalletProviderByChain/getWaasWalletProviderByChain.ts","../src/modules/waas/businessAccounts/addBusinessAccountSigner/addBusinessAccountSigner.ts","../src/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.ts","../src/modules/waas/backupWaasKeySharesToGoogleDrive/backupWaasKeySharesToGoogleDrive.ts","../src/modules/waas/businessAccounts/createBusinessAccount/createBusinessAccount.ts","../src/modules/waas/isWalletCreationRequirement/isWalletCreationRequirement.ts","../src/modules/waas/normalizeWalletRequirements/normalizeWalletRequirements.ts","../src/modules/waas/createWaasWalletAccounts/createWaasWalletAccounts.ts","../src/modules/waas/businessAccounts/createWalletForBusinessAccount/createWalletForBusinessAccount.ts","../src/modules/waas/delegateWaasKeyShares/delegateWaasKeyShares.ts","../src/modules/waas/exportWaasClientKeyshares/exportWaasClientKeyshares.ts","../src/modules/waas/exportWaasPrivateKey/exportWaasPrivateKey.ts","../src/modules/waas/businessAccounts/getBusinessAccount/getBusinessAccount.ts","../src/modules/wallets/userHasEmbeddedWalletForChain/userHasEmbeddedWalletForChain.ts","../src/modules/waas/getChainsMissingWaasWalletAccounts/getChainsMissingWaasWalletAccounts.ts","../src/modules/waas/getWalletRecoveryState/getWalletRecoveryState.ts","../src/modules/waas/hasDelegatedAccess/hasDelegatedAccess.ts","../src/modules/waas/importWaasPrivateKey/importWaasPrivateKey.ts","../src/modules/waas/isPasswordRequiredForWaasWallets/isPasswordRequiredForWaasWallets.ts","../src/modules/waas/businessAccounts/listBusinessAccounts/listBusinessAccounts.ts","../src/modules/waas/refreshWaasWalletAccountShares/refreshWaasWalletAccountShares.ts","../src/modules/waas/businessAccounts/removeBusinessAccountMember/removeBusinessAccountMember.ts","../src/modules/waas/businessAccounts/removeBusinessAccountSigner/removeBusinessAccountSigner.ts","../src/modules/waas/revokeWaasDelegation/revokeWaasDelegation.ts","../src/modules/waas/setWaasWalletAccountPassword/setWaasWalletAccountPassword.ts","../src/modules/wallets/userHasExternalWallet/userHasExternalWallet.ts","../src/modules/waas/shouldAutoCreateWalletForChain/shouldAutoCreateWalletForChain.ts","../src/modules/waas/businessAccounts/transferBusinessAccountOwnership/transferBusinessAccountOwnership.ts","../src/modules/waas/unlockWallet/unlockWallet.ts","../src/modules/waas/updateWaasPassword/updateWaasPassword.ts","../src/exports/waas.ts"],"sourcesContent":["import type { DynamicClient } from '../../../../client/types/DynamicClient';\nimport { InvalidParamError } from '../../../../errors/InvalidParamError';\nimport { assertDefined } from '../../../../utils/assertDefined';\nimport type { Chain } from '../../../chain';\nimport { createWaasClient } from '../../createWaasClient';\nimport { getWaasChainNameFromChain } from '../../getWaasChainNameFromChain';\nimport type { BusinessAccountsApi } from '../businessAccounts.types';\n\n/**\n * Returns the business accounts API client for the first enabled WaaS chain.\n *\n * @param client - The Dynamic client instance.\n * @returns The business accounts API client.\n * @throws {InvalidParamError} When no WaaS chain configuration is enabled for the project.\n * @notInstrumented\n */\nexport const getBusinessAccountsClient = (\n client: DynamicClient\n): BusinessAccountsApi => {\n const projectSettings = client.projectSettings;\n\n assertDefined(projectSettings, 'Project settings are not available');\n\n const chainConfig =\n projectSettings.sdk.embeddedWallets?.chainConfigurations?.find(\n (chain) => chain.enabled\n );\n\n if (!chainConfig) {\n throw new InvalidParamError('No WaaS chain is enabled for this project');\n }\n\n // Normalize the project chain to the WaaS chain name (e.g. SOL -> SVM), the\n // same mapping every other createWaasClient caller applies, so the wallet\n // service is addressed under the identifier it expects.\n const waasClient = createWaasClient(\n { chainName: getWaasChainNameFromChain(chainConfig.name as Chain) },\n client\n ) as unknown as {\n businessAccounts: BusinessAccountsApi;\n };\n\n return waasClient.businessAccounts;\n};\n","import { getDefaultClient } from '../../../../client/defaultClient';\nimport type {\n BusinessAccountMember,\n BusinessAccountMemberRole,\n BusinessAccountSignerIdentifierType,\n} from '../businessAccounts.types';\nimport { getBusinessAccountsClient } from '../getBusinessAccountsClient';\n\ntype AddMemberParams = {\n businessAccountId: string;\n identifier?: string;\n identifierType?: BusinessAccountSignerIdentifierType;\n role?: BusinessAccountMemberRole;\n userId?: string;\n};\n\n/**\n * Adds a member to an existing business account. Identify the target by a known\n * `userId`, or by `identifier` + `identifierType` (e.g. an email — the user is\n * created if absent).\n *\n * @param params.businessAccountId - The ID of the business account.\n * @param [params.userId] - The ID of the user to add as a member.\n * @param [params.identifier] - The identifier value (e.g. an email address).\n * @param [params.identifierType] - The identifier type (e.g. `email`).\n * @param [params.role] - The member role (`admin` or `viewer`). Defaults server-side.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The created business account member.\n * @notInstrumented\n */\nexport const addBusinessAccountMember = async (\n {\n businessAccountId,\n userId,\n identifier,\n identifierType,\n role,\n }: AddMemberParams,\n client = getDefaultClient()\n): Promise<BusinessAccountMember> => {\n const businessAccounts = getBusinessAccountsClient(client);\n\n return businessAccounts.addMember({\n businessAccountId,\n identifier,\n identifierType,\n role,\n userId,\n });\n};\n","import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../client/types/DynamicClient';\nimport { NoWalletProviderFoundError } from '../../../errors/NoWalletProviderFoundError';\nimport type { Chain } from '../../chain';\nimport { formatWalletProviderKey } from '../../wallets/utils/formatWalletProviderKey';\nimport { DYNAMIC_WAAS_METADATA } from '../constants';\nimport type { WaasWalletProvider } from '../waas.types';\nimport { findWaasWalletProviderByChain } from '../findWaasWalletProviderByChain/findWaasWalletProviderByChain';\n\ntype GetWaasWalletProviderByChainParams = {\n chain: Chain;\n};\n\n/** @notInstrumented */\nexport const getWaasWalletProviderByChain = (\n { chain }: GetWaasWalletProviderByChainParams,\n client: DynamicClient\n): WaasWalletProvider => {\n const waasProvider = findWaasWalletProviderByChain({ chain }, client);\n\n if (!waasProvider) {\n const waasProviderKey = formatWalletProviderKey({\n chain,\n displayName: DYNAMIC_WAAS_METADATA.displayName,\n walletProviderType: WalletProviderEnum.EmbeddedWallet,\n });\n\n throw new NoWalletProviderFoundError({\n walletProviderKey: waasProviderKey,\n });\n }\n\n return waasProvider;\n};\n","import { getDefaultClient } from '../../../../client/defaultClient';\nimport { InvalidParamError } from '../../../../errors/InvalidParamError';\nimport { assertDefined } from '../../../../utils/assertDefined';\nimport { refreshAuth } from '../../../user/refreshAuth';\nimport type { WalletAccount } from '../../../wallets/walletAccount';\nimport { getWaasWalletProviderByChain } from '../../getWaasWalletProviderByChain';\nimport type {\n BusinessAccountSignerType,\n TargetSignerIdentity,\n} from '../businessAccounts.types';\nimport { getBusinessAccountsClient } from '../getBusinessAccountsClient';\n\ntype AddSignerParams = {\n businessAccountId?: string;\n password?: string;\n signerType?: BusinessAccountSignerType;\n targetSignerIdentity: TargetSignerIdentity;\n walletAccount: WalletAccount;\n walletId?: string;\n};\n\n/**\n * Adds a signer to a business-account wallet via the reshare ceremony, minting\n * the new signer's share set. Identify the target by `userId`, or `identifier`\n * + `identifierType` (the user is created if absent).\n *\n * Omit `businessAccountId` to add a signer to a wallet that isn't in a business\n * account yet: the wallet's per-account is found-or-created first (idempotent —\n * converts the personal wallet, seating its owner as the first signer), then\n * the new signer is reshared in.\n *\n * @param params.walletAccount - The wallet account to add the signer to.\n * @param [params.businessAccountId] - The business account; found-or-created when omitted.\n * @param [params.walletId] - The wallet UUID to link when finding-or-creating; defaults to `walletAccount.verifiedCredentialId`.\n * @param params.targetSignerIdentity - The signer to add (userId, or identifier + identifierType).\n * @param [params.signerType] - `endUser` (default) or `server`.\n * @param [params.password] - Password for the reshare, if the wallet is password-encrypted.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The new signer's share set id.\n * @notInstrumented\n */\nexport const addBusinessAccountSigner = async (\n {\n walletAccount,\n businessAccountId,\n walletId,\n targetSignerIdentity,\n signerType,\n password,\n }: AddSignerParams,\n client = getDefaultClient()\n): Promise<{ shareSetId: string }> => {\n // Require a resolvable target: a userId, or an identifier + its type.\n const hasUserId = Boolean(targetSignerIdentity.userId);\n const hasIdentifier = Boolean(\n targetSignerIdentity.identifier && targetSignerIdentity.identifierType\n );\n if (!hasUserId && !hasIdentifier) {\n throw new InvalidParamError(\n 'addBusinessAccountSigner: targetSignerIdentity must provide a userId, or an identifier with its identifierType'\n );\n }\n\n // A wallet already owned by a business account can't be found-or-created into\n // one — require the caller to name that account explicitly.\n if (walletAccount.businessAccountId) {\n assertDefined(\n businessAccountId,\n 'addBusinessAccountSigner: this wallet is already part of a business account'\n );\n }\n\n // No account yet: find-or-create the per-wallet business account first\n // (idempotent), then reshare the signer into it.\n let resolvedBusinessAccountId = businessAccountId;\n if (!resolvedBusinessAccountId) {\n // The link endpoint wants the wallet's UUID. WalletAccount.id is a\n // composite (`walletProviderKey:address`), so use verifiedCredentialId —\n // the VC id, which is the walletId redcoast keys wallets by.\n const linkWalletId = walletId ?? walletAccount.verifiedCredentialId;\n assertDefined(\n linkWalletId,\n 'addBusinessAccountSigner: cannot resolve a wallet id to link — pass walletId, or use a verified wallet account'\n );\n const businessAccounts = getBusinessAccountsClient(client);\n const account = await businessAccounts.addWalletToBusinessAccount({\n walletId: linkWalletId,\n });\n resolvedBusinessAccountId = account.id;\n }\n\n // Resolve the provider by chain (not by the wallet's provider key) so the\n // reshare works for any business-account wallet the caller can sign — it need\n // not be one of the session's own `getWalletAccounts()`. The reshare only\n // uses the wallet's address; the local key share is keyed by that address.\n const provider = getWaasWalletProviderByChain(\n { chain: walletAccount.chain },\n client\n );\n\n const result = await provider.reshareToNewSignerShareSet({\n businessAccountId: resolvedBusinessAccountId,\n password,\n signerType,\n targetSignerIdentity,\n walletAccount,\n });\n\n // The find-or-create link above can bind the caller's wallet to the business\n // account (changing its verifiedCredential); refresh local auth so the\n // caller's wallet state doesn't go stale.\n await refreshAuth(client);\n\n return result;\n};\n","import { getDefaultClient } from '../../../../client/defaultClient';\nimport { refreshAuth } from '../../../user/refreshAuth';\nimport type { BusinessAccountDetail } from '../businessAccounts.types';\nimport { getBusinessAccountsClient } from '../getBusinessAccountsClient';\n\ntype AddWalletParams = {\n businessAccountId?: string;\n walletId: string;\n};\n\n/**\n * Links an existing wallet to a business account. Omit `businessAccountId` to\n * find-or-create the per-wallet business account (the server seats the wallet's\n * owner as the first member/signer).\n *\n * @param [params.businessAccountId] - The business account to link to; found-or-created when omitted.\n * @param params.walletId - The ID of the wallet to link.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The updated business account detail.\n * @notInstrumented\n */\nexport const addWalletToBusinessAccount = async (\n { businessAccountId, walletId }: AddWalletParams,\n client = getDefaultClient()\n): Promise<BusinessAccountDetail> => {\n const businessAccounts = getBusinessAccountsClient(client);\n\n const detail = await businessAccounts.addWalletToBusinessAccount({\n businessAccountId,\n walletId,\n });\n\n // Linking mutates the wallet's businessAccount binding on its\n // verifiedCredential; refresh local auth so the change is reflected.\n await refreshAuth(client);\n\n return detail;\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype BackupWaasKeySharesToGoogleDriveParams = {\n /**\n * Optional consumer-supplied Google Drive access token. When provided (and\n * already granted Drive scopes), the SDK uses it directly instead of falling\n * back to the stored OAuth token — avoiding a second Google consent prompt.\n *\n * Especially useful for consumers using external auth: the user's Google\n * account isn't linked in Dynamic, so there's no stored OAuth token to fall\n * back on — they obtain a Drive-scoped token themselves and pass it here.\n */\n googleDriveAccessToken?: string;\n password?: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Backs up WaaS wallet key shares to Google Drive for secure recovery.\n *\n * This function creates a backup of the wallet's cryptographic key shares\n * to Google Drive, allowing users to recover their wallet later.\n *\n * @param params.walletAccount - The WaaS wallet account to backup.\n * @param [params.password] - Optional password to encrypt the backup.\n * @param [params.googleDriveAccessToken] - Optional consumer-supplied Drive-scoped access token; used directly instead of the stored OAuth token (avoids a second Google consent). Useful for external-auth setups.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the backup process is complete.\n * @notInstrumented\n */\nexport const backupWaasKeySharesToGoogleDrive = async (\n {\n googleDriveAccessToken,\n password,\n walletAccount,\n }: BackupWaasKeySharesToGoogleDriveParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.backupKeySharesToGoogleDrive({\n googleDriveAccessToken,\n password,\n walletAccount,\n });\n};\n","import { getDefaultClient } from '../../../../client/defaultClient';\nimport type { BusinessAccount } from '../businessAccounts.types';\nimport { getBusinessAccountsClient } from '../getBusinessAccountsClient';\n\ntype CreateBusinessAccountParams = {\n name?: string;\n};\n\n/**\n * Creates a new business account.\n *\n * @param [params] - Optional parameters for the business account.\n * @param [params.name] - Optional name for the business account.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The created business account.\n * @notInstrumented\n */\nexport const createBusinessAccount = async (\n params?: CreateBusinessAccountParams,\n client = getDefaultClient()\n): Promise<BusinessAccount> => {\n const businessAccounts = getBusinessAccountsClient(client);\n\n return businessAccounts.createBusinessAccount({\n request: { name: params?.name },\n });\n};\n","import type { Chain } from '../../chain';\nimport type { WalletCreationRequirement } from '../waas.types';\n\n/**\n * Type guard to check if an item is a WalletCreationRequirement object.\n * Chain values are strings, so we can distinguish by checking if it's an object with a 'chain' property.\n *\n * @param item - The item to check, either a WalletCreationRequirement or Chain string\n * @returns True if the item is a WalletCreationRequirement object\n * @notInstrumented\n */\nexport const isWalletCreationRequirement = (\n item: WalletCreationRequirement | Chain\n): item is WalletCreationRequirement =>\n typeof item === 'object' && item !== null && 'chain' in item;\n","import type { Chain } from '../../chain';\nimport { isWalletCreationRequirement } from '../isWalletCreationRequirement/isWalletCreationRequirement';\nimport type {\n WalletCreationBitcoinConfig,\n WalletCreationRequirement,\n} from '../waas.types';\n\nconst DEFAULT_BITCOIN_ADDRESS_TYPE = 'native_segwit' as const;\n\ntype NormalizeWalletRequirementsParams = {\n defaultBitcoinConfig?: WalletCreationBitcoinConfig;\n input: WalletCreationRequirement[] | Chain[];\n};\n\n/**\n * Normalizes wallet creation input from either legacy Chain[] format\n * or new WalletCreationRequirement[] format to WalletCreationRequirement[].\n *\n * For BTC chains without explicit bitcoinConfig, defaults to native_segwit.\n *\n * @param params.input - Either an array of Chain strings or WalletCreationRequirement objects\n * @param params.defaultBitcoinConfig - Optional default bitcoin config to use for BTC chains when converting from legacy format\n * @returns Array of WalletCreationRequirement objects\n * @notInstrumented\n */\nexport const normalizeWalletRequirements = ({\n defaultBitcoinConfig,\n input,\n}: NormalizeWalletRequirementsParams): WalletCreationRequirement[] => {\n if (input.length === 0) {\n return [];\n }\n\n const [firstItem] = input;\n\n if (isWalletCreationRequirement(firstItem)) {\n return (input as WalletCreationRequirement[]).map((requirement) => {\n if (requirement.chain === 'BTC' && !requirement.bitcoinConfig) {\n return {\n ...requirement,\n bitcoinConfig: { addressType: DEFAULT_BITCOIN_ADDRESS_TYPE },\n };\n }\n\n return requirement;\n });\n }\n\n return (input as Chain[]).map((chain) => {\n const requirement: WalletCreationRequirement = { chain };\n\n if (chain === 'BTC') {\n requirement.bitcoinConfig = defaultBitcoinConfig ?? {\n addressType: DEFAULT_BITCOIN_ADDRESS_TYPE,\n };\n }\n\n return requirement;\n });\n};\n","import type { ThresholdSignatureScheme } from '@dynamic-labs-wallet/browser-wallet-client';\nimport { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { NotWaasWalletProviderError } from '../../../errors/NotWaasWalletProviderError';\nimport { NoWalletProviderFoundError } from '../../../errors/NoWalletProviderFoundError';\nimport type { Chain } from '../../chain';\nimport { refreshAuth } from '../../user/refreshAuth';\nimport { getWalletProviderByKey } from '../../wallets/getWalletProviderByKey';\nimport { formatWalletProviderKey } from '../../wallets/utils/formatWalletProviderKey';\nimport { DYNAMIC_WAAS_METADATA } from '../constants';\nimport { isWaasWalletProvider } from '../isWaasWalletProvider';\nimport { normalizeWalletRequirements } from '../normalizeWalletRequirements/normalizeWalletRequirements';\nimport type { WalletCreationRequirement } from '../waas.types';\n\ntype CreateWaasWalletAccountsParams = {\n /**\n * For which chains to create wallet accounts.\n * Accepts either an array of chain strings (legacy format) or an array of\n * WalletCreationRequirement objects for chain-specific configuration.\n *\n * For Bitcoin, you can specify the address type ('native_segwit' or 'taproot').\n * If not specified, defaults to 'native_segwit'.\n *\n * If a chain is passed multiple times, just as many wallet accounts will be created\n * for that chain.\n * @notInstrumented\n */\n chains: Chain[] | WalletCreationRequirement[];\n /**\n * The optional password to use for the wallet accounts.\n * It's used to encrypt the user shares.\n * The same password must be used for all waas wallet accounts created for the same user.\n */\n password?: string;\n /**\n * The threshold signature scheme to use for the wallet accounts.\n * If not provided, TWO_OF_TWO will be used.\n */\n thresholdSignatureScheme?: ThresholdSignatureScheme;\n};\n\n/**\n * Creates wallet accounts for the specified chains.\n *\n * This function creates wallet accounts for the specified chains.\n * If the same chain is passed multiple times, just as many wallet accounts will be created\n * for that chain.\n *\n * @example\n * ```ts\n * // Legacy format - will create wallet accounts for EVM and SOL, BTC defaults to native_segwit\n * await createWaasWalletAccounts({ chains: ['EVM', 'SOL', 'BTC'] });\n *\n * // New format with chain-specific config\n * await createWaasWalletAccounts({\n * chains: [\n * { chain: 'BTC', bitcoinConfig: { addressType: 'taproot' } },\n * { chain: 'EVM' },\n * ]\n * });\n *\n * // Create both BTC address types\n * await createWaasWalletAccounts({\n * chains: [\n * { chain: 'BTC', bitcoinConfig: { addressType: 'native_segwit' } },\n * { chain: 'BTC', bitcoinConfig: { addressType: 'taproot' } },\n * ]\n * });\n * ```\n *\n * @param params.chains - The chains to create wallet accounts for.\n * @param params.password - The optional password to use for the wallet accounts.\n * @param params.thresholdSignatureScheme - The threshold signature scheme to use for the wallet accounts. (Default: TWO_OF_TWO)\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when all wallet accounts are created.\n * @notInstrumented\n */\nexport const createWaasWalletAccounts = async (\n {\n chains,\n password,\n thresholdSignatureScheme,\n }: CreateWaasWalletAccountsParams,\n client = getDefaultClient()\n): Promise<void> => {\n const normalizedRequirements = normalizeWalletRequirements({ input: chains });\n\n // we need this right now so we don't try to create wallet accounts for chains\n // that we don't support Dynamic Waas yet in the JS SDK\n const supportedChains = ['BTC', 'EVM', 'SOL', 'SUI', 'TON', 'TRON'];\n\n const filteredRequirements = normalizedRequirements.filter((requirement) =>\n supportedChains.includes(requirement.chain)\n );\n\n if (filteredRequirements.length === 0) {\n return;\n }\n\n const walletProviderMap = new Map<\n string,\n ReturnType<typeof getWalletProviderByKey>\n >();\n\n for (const requirement of filteredRequirements) {\n const walletProviderKey = formatWalletProviderKey({\n chain: requirement.chain,\n displayName: DYNAMIC_WAAS_METADATA.displayName,\n walletProviderType: WalletProviderEnum.EmbeddedWallet,\n });\n\n if (!walletProviderMap.has(walletProviderKey)) {\n const walletProvider = getWalletProviderByKey(\n { walletProviderKey },\n client\n );\n\n if (!walletProvider) {\n throw new NoWalletProviderFoundError({\n walletProviderKey,\n });\n }\n\n if (!isWaasWalletProvider(walletProvider)) {\n throw new NotWaasWalletProviderError({\n walletProviderKey,\n });\n }\n\n walletProviderMap.set(walletProviderKey, walletProvider);\n }\n }\n\n await Promise.all(\n filteredRequirements.map((requirement) => {\n const walletProviderKey = formatWalletProviderKey({\n chain: requirement.chain,\n displayName: DYNAMIC_WAAS_METADATA.displayName,\n walletProviderType: WalletProviderEnum.EmbeddedWallet,\n });\n\n const walletProvider = walletProviderMap.get(walletProviderKey);\n\n if (!walletProvider || !isWaasWalletProvider(walletProvider)) {\n return Promise.resolve();\n }\n\n return walletProvider.createWalletAccount({\n bitcoinConfig: requirement.bitcoinConfig,\n password,\n thresholdSignatureScheme,\n });\n })\n );\n\n await refreshAuth(client);\n};\n","import { getDefaultClient } from '../../../../client/defaultClient';\nimport type { Chain } from '../../../chain';\nimport { refreshAuth } from '../../../user/refreshAuth';\nimport { getWaasWalletProviderByChain } from '../../getWaasWalletProviderByChain';\nimport type { ThresholdSignatureScheme } from '../../waas.types';\n\ntype CreateWalletForBusinessAccountParams = {\n businessAccountId: string;\n chain: Chain;\n password?: string;\n thresholdSignatureScheme?: ThresholdSignatureScheme;\n};\n\n/**\n * Creates a WaaS wallet account owned directly by a business account, in one\n * step — the server seats the wallet's signer row against the business account\n * as it is minted, so no separate link call is needed.\n *\n * @example\n * ```ts\n * const wallet = await createWalletForBusinessAccount({\n * businessAccountId: 'ba-1',\n * chain: 'EVM',\n * });\n * ```\n *\n * @param params.businessAccountId - The business account that will own the wallet.\n * @param params.chain - The chain to create the wallet account for.\n * @param [params.password] - Optional password used to encrypt the user share.\n * @param [params.thresholdSignatureScheme] - The threshold signature scheme to use. (Default: TWO_OF_TWO)\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The created wallet account.\n * @notInstrumented\n */\nexport const createWalletForBusinessAccount = async (\n {\n businessAccountId,\n chain,\n password,\n thresholdSignatureScheme,\n }: CreateWalletForBusinessAccountParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderByChain({ chain }, client);\n\n const wallet = await provider.createWalletAccount({\n businessAccountId,\n password,\n thresholdSignatureScheme,\n });\n\n // Re-hydrate local auth so the new wallet's verifiedCredential is present —\n // mirrors createWaasWalletAccounts. Without it the wallet list goes stale\n // (wallets vanish until the next refresh).\n await refreshAuth(client);\n\n return wallet;\n};\n","import type { WaasPolicyRule } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { refreshAuth } from '../../user/refreshAuth';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype DelegateWaasKeySharesParams = {\n initialSignerRules?: WaasPolicyRule[];\n password?: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Delegates cryptographic key shares for a WaaS wallet account.\n *\n * This function allows the delegation of key management responsibilities,\n * enabling distributed key management for enhanced security.\n *\n * @param params.walletAccount - The WaaS wallet account to delegate shares for.\n * @param [params.password] - Optional password for key share operations.\n * @param [params.initialSignerRules] - Optional policy rules used to seed the delegated signer's policy layer at delegation time.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the key delegation is complete.\n * @notInstrumented\n */\nexport const delegateWaasKeyShares = async (\n { initialSignerRules, password, walletAccount }: DelegateWaasKeySharesParams,\n client = getDefaultClient()\n): Promise<void> => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n await provider.delegateKeyShares({\n initialSignerRules,\n password,\n walletAccount,\n });\n\n await refreshAuth(client);\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype ExportWaasClientKeysharesParams = {\n password?: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Exports the client-side key shares for a WaaS wallet account.\n *\n * This function retrieves the cryptographic key shares that are stored\n * on the client side for backup or migration purposes.\n *\n * @param params.walletAccount - The WaaS wallet account to export shares from.\n * @param [params.password] - Optional password to encrypt the exported shares.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the exported key shares.\n * @notInstrumented\n */\nexport const exportWaasClientKeyshares = async (\n { password, walletAccount }: ExportWaasClientKeysharesParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.exportClientKeyshares({\n password,\n walletAccount,\n });\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype ExportWaasPrivateKeyParams = {\n displayContainer: HTMLElement;\n password?: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Exports the private key for a WaaS wallet account with secure display.\n *\n * This function reveals the private key for a WaaS wallet and displays it\n * securely within an iframe dynamically inserted into the specified HTML container element.\n *\n * @param params.walletAccount - The WaaS wallet account to export the private key from.\n * @param params.displayContainer - The HTML element where the iframe will be injected.\n * @param [params.password] - Optional password to decrypt the private key.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the private key export is complete.\n * @notInstrumented\n */\nexport const exportWaasPrivateKey = async (\n { displayContainer, password, walletAccount }: ExportWaasPrivateKeyParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.exportPrivateKey({\n displayContainer,\n password,\n walletAccount,\n });\n};\n","import { getDefaultClient } from '../../../../client/defaultClient';\nimport type { BusinessAccountDetail } from '../businessAccounts.types';\nimport { getBusinessAccountsClient } from '../getBusinessAccountsClient';\n\ntype GetBusinessAccountParams = {\n businessAccountId: string;\n};\n\n/**\n * Retrieves a business account by ID, including its members, signers, and wallets.\n *\n * @param params.businessAccountId - The ID of the business account to retrieve.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The business account with its members, signers, and wallets.\n * @notInstrumented\n */\nexport const getBusinessAccount = async (\n { businessAccountId }: GetBusinessAccountParams,\n client = getDefaultClient()\n): Promise<BusinessAccountDetail> => {\n const businessAccounts = getBusinessAccountsClient(client);\n\n return businessAccounts.getBusinessAccount({ businessAccountId });\n};\n","import { type SdkUser, WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport { getChainFromVerifiedCredentialChain } from '../../../utils/getChainFromVerifiedCredentialChain';\nimport type { Chain } from '../../chain/chain.types';\n\ntype UserHasEmbeddedWalletForChainProps = {\n chain: Chain;\n user: SdkUser;\n};\n\n/** @notInstrumented */\nexport const userHasEmbeddedWalletForChain = ({\n user,\n chain,\n}: UserHasEmbeddedWalletForChainProps): boolean => {\n const hasEmbeddedWalletForChain = user.verifiedCredentials.some(\n (vc) =>\n vc.walletProvider === WalletProviderEnum.EmbeddedWallet &&\n vc.chain &&\n getChainFromVerifiedCredentialChain(vc.chain) === chain\n );\n\n return hasEmbeddedWalletForChain;\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport type { Chain } from '../../chain/chain.types';\nimport { userHasEmbeddedWalletForChain } from '../../wallets/userHasEmbeddedWalletForChain';\nimport { isDynamicWaasEnabled } from '../isDynamicWaasEnabled';\n\n/**\n * Gets all chains missing a waas wallet account for the current user.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An array of all chains that have waas wallet accounts enabled\n * but for which the current user does not yet have an embedded wallet account.\n * @notInstrumented\n */\nexport const getChainsMissingWaasWalletAccounts = (\n client = getDefaultClient()\n): Chain[] => {\n const projectSettings = client.projectSettings;\n\n assertDefined(projectSettings, 'Project settings are not available');\n\n const embeddedWalletSettings = projectSettings.sdk.embeddedWallets;\n\n const isWaasEnabled = isDynamicWaasEnabled(client);\n\n const user = client.user;\n\n if (!user || !isWaasEnabled) {\n return [];\n }\n\n const enabledChainForWaas: Chain[] = (\n embeddedWalletSettings?.chainConfigurations?.filter(\n (chain) => chain.enabled\n ) ?? []\n ).map((chain) => chain.name as Chain);\n\n // For each enabled chain, if user does NOT have an embedded wallet, add to missing\n return enabledChainForWaas.filter(\n (chain) => !userHasEmbeddedWalletForChain({ chain, user })\n );\n};\n","import type { WalletRecoveryState } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport type { DynamicClient } from '../../../client/types/DynamicClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype GetWalletRecoveryStateParams = {\n walletAccount: WalletAccount;\n};\n\n/**\n * Retrieves the recovery state of a WaaS wallet account.\n *\n * @param params.walletAccount - The WaaS wallet account to get the recovery state for.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves with the wallet recovery state.\n * @notInstrumented\n */\nexport const getWalletRecoveryState = async (\n { walletAccount }: GetWalletRecoveryStateParams,\n client: DynamicClient = getDefaultClient()\n): Promise<WalletRecoveryState> => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.getWalletRecoveryState({\n walletAccount,\n });\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { getVerifiedCredentialForWalletAccount } from '../../wallets/utils/getVerifiedCredentialForWalletAccount';\nimport type { WalletAccount } from '../../wallets/walletAccount';\n\ntype HasDelegatedAccessParams = {\n walletAccount: WalletAccount;\n};\n\n/**\n * Checks if a WaaS wallet account has delegated access.\n *\n * @param params.walletAccount - The WaaS wallet account to check for delegated access.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if the wallet account has delegated access, false otherwise.\n * @notInstrumented\n */\nexport const hasDelegatedAccess = (\n { walletAccount }: HasDelegatedAccessParams,\n client = getDefaultClient()\n): boolean => {\n const verifiedCredential = getVerifiedCredentialForWalletAccount(\n { walletAccount },\n client\n );\n\n assertDefined(\n verifiedCredential,\n 'Verified credential not found for Waas wallet account'\n );\n\n const hasDelegatedKeyShare =\n verifiedCredential.walletProperties?.keyShares?.some(\n (keyShare) => keyShare.backupLocation === 'delegated'\n );\n\n return !!hasDelegatedKeyShare;\n};\n","import type { ThresholdSignatureScheme } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport type { Chain } from '../../chain';\nimport { getWaasWalletProviderByChain } from '../getWaasWalletProviderByChain';\n\ntype ImportWaasPrivateKeyParams = {\n chain: Chain;\n privateKey: string;\n thresholdSignatureScheme?: ThresholdSignatureScheme;\n};\n\n/**\n * Imports an existing private key to create a new WaaS wallet account.\n *\n * This function allows users to import their existing private key into\n * Dynamic's WaaS infrastructure for secure management.\n *\n * @param params.chain - The chain for the imported wallet.\n * @param params.privateKey - The private key to import.\n * @param [params.thresholdSignatureScheme] - Optional threshold signature scheme configuration. Default is TWO_OF_TWO.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the private key is successfully imported.\n * @notInstrumented\n */\nexport const importWaasPrivateKey = async (\n { chain, privateKey, thresholdSignatureScheme }: ImportWaasPrivateKeyParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderByChain({ chain }, client);\n\n return provider.importPrivateKey({\n privateKey,\n thresholdSignatureScheme,\n });\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Checks if the user Waas wallets are password protected.\n *\n * If the user's Waas wallets are password protected, it means that user's will have to be prompted for a\n * password for the first wallet action that happens on each session.\n * The password is also required for creating any new Waas wallets.\n *\n * @param client - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if the user has any password protected Waas wallets, false otherwise\n * @notInstrumented\n */\nexport const isPasswordRequiredForWaasWallets = (\n client = getDefaultClient()\n): boolean => {\n const { user } = client;\n\n assertDefined(user, 'User is not authenticated');\n\n return user.verifiedCredentials.some((credential) =>\n credential.walletProperties?.keyShares?.some(\n (keyShare) => keyShare.passwordEncrypted\n )\n );\n};\n","import { getDefaultClient } from '../../../../client/defaultClient';\nimport type { BusinessAccountList } from '../businessAccounts.types';\nimport { getBusinessAccountsClient } from '../getBusinessAccountsClient';\n\n/**\n * Lists all business accounts for the current project environment.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A paginated list of business accounts.\n * @notInstrumented\n */\nexport const listBusinessAccounts = async (\n client = getDefaultClient()\n): Promise<BusinessAccountList> => {\n const businessAccounts = getBusinessAccountsClient(client);\n\n return businessAccounts.listBusinessAccounts();\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype RefreshWaasWalletAccountSharesParams = {\n password?: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Refreshes the cryptographic key shares for a WaaS wallet account.\n *\n * This function generates new key shares for the wallet while maintaining\n * the same threshold signature scheme.\n *\n * @param params.walletAccount - The WaaS wallet account to refresh shares for.\n * @param [params.password] - Optional password for key share operations.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the key shares are refreshed.\n * @notInstrumented\n */\nexport const refreshWaasWalletAccountShares = async (\n { walletAccount, password }: RefreshWaasWalletAccountSharesParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.refreshWalletAccountShares({\n password,\n walletAccount,\n });\n};\n","import { getCore } from '../../../../client/core/getCore';\nimport { getDefaultClient } from '../../../../client/defaultClient';\nimport type { DynamicClient } from '../../../../client/types';\nimport { createApiClient } from '../../../apiClient/createApiClient';\nimport type { BusinessAccountMember } from '../businessAccounts.types';\n\ntype RemoveMemberParams = {\n businessAccountId: string;\n userId: string;\n};\n\n/**\n * Removes a member from a business account. Any signer rows the member held on\n * the account's wallets are torn down as part of the removal. The backend\n * refuses to remove the account's last owner.\n *\n * @param params.businessAccountId - The business account to remove the member from.\n * @param params.userId - The id of the user to remove.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The removed member.\n *\n * @example\n * ```ts\n * const detail = await getBusinessAccount({ businessAccountId });\n * const member = detail.members[0];\n * await removeBusinessAccountMember({\n * businessAccountId,\n * userId: member.userId,\n * });\n * ```\n *\n * @see addBusinessAccountMember\n * @see getBusinessAccount\n * @notInstrumented\n */\nexport const removeBusinessAccountMember = async (\n { businessAccountId, userId }: RemoveMemberParams,\n client: DynamicClient = getDefaultClient()\n): Promise<BusinessAccountMember> => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const { member } = await apiClient.sdkRemoveBusinessAccountMember({\n businessAccountId,\n environmentId: core.environmentId,\n userId,\n });\n\n return member as BusinessAccountMember;\n};\n","import { getCore } from '../../../../client/core/getCore';\nimport { getDefaultClient } from '../../../../client/defaultClient';\nimport type { DynamicClient } from '../../../../client/types';\nimport { createApiClient } from '../../../apiClient/createApiClient';\nimport type { BusinessAccountSigner } from '../businessAccounts.types';\n\ntype RemoveSignerParams = {\n businessAccountId: string;\n signerId: string;\n walletId: string;\n};\n\n/**\n * Removes a signer from a business-account wallet. This detaches the signer's\n * share set from the wallet — it does not run an MPC ceremony — so the removed\n * identity can no longer sign for that wallet. The backend refuses to remove\n * the last remaining signer on a wallet.\n *\n * @param params.businessAccountId - The business account the wallet belongs to.\n * @param params.walletId - The wallet the signer is attached to.\n * @param params.signerId - The id of the signer to remove (`BusinessAccountSigner.id`).\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The removed signer.\n *\n * @example\n * ```ts\n * const detail = await getBusinessAccount({ businessAccountId });\n * const signer = detail.signers[0];\n * await removeBusinessAccountSigner({\n * businessAccountId,\n * walletId: signer.walletId,\n * signerId: signer.id,\n * });\n * ```\n *\n * @see addBusinessAccountSigner\n * @see getBusinessAccount\n * @notInstrumented\n */\nexport const removeBusinessAccountSigner = async (\n { businessAccountId, walletId, signerId }: RemoveSignerParams,\n client: DynamicClient = getDefaultClient()\n): Promise<BusinessAccountSigner> => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const { signer } = await apiClient.sdkRemoveBusinessAccountSigner({\n businessAccountId,\n environmentId: core.environmentId,\n signerId,\n walletId,\n });\n\n return signer as BusinessAccountSigner;\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { refreshAuth } from '../../user/refreshAuth';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype RevokeWaasDelegationParams = {\n password?: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Revokes the delegation of a WaaS wallet account.\n *\n * @param params.walletAccount - The WaaS wallet account to revoke delegation for.\n * @param [params.password] - Optional password for delegation operations.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the delegation is revoked.\n * @notInstrumented\n */\nexport const revokeWaasDelegation = async (\n { password, walletAccount }: RevokeWaasDelegationParams,\n client = getDefaultClient()\n): Promise<void> => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n await provider.revokeDelegation({\n password,\n walletAccount,\n });\n\n await refreshAuth(client);\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype SetWaasWalletAccountPasswordParams = {\n password: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Sets a password for a WaaS wallet account.\n *\n * @param params.walletAccount - The WaaS wallet account to set the password for.\n * @param params.password - The password to set for the wallet.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the password is successfully set.\n * @notInstrumented\n */\nexport const setWaasWalletAccountPassword = async (\n { password, walletAccount }: SetWaasWalletAccountPasswordParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.setWaasWalletAccountPassword({\n password,\n walletAccount,\n });\n};\n","import {\n JwtVerifiedCredentialFormatEnum,\n type SdkUser,\n WalletProviderEnum,\n} from '@dynamic-labs/sdk-api-core';\n\n/** @notInstrumented */\nexport const userHasExternalWallet = (user: SdkUser) => {\n const hasExternalWallet = user?.verifiedCredentials.some(\n (vc) =>\n vc.format === JwtVerifiedCredentialFormatEnum.Blockchain &&\n vc.walletProvider !== WalletProviderEnum.EmbeddedWallet\n );\n\n return hasExternalWallet;\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport type { Chain } from '../../chain';\nimport { userHasExternalWallet } from '../../wallets/userHasExternalWallet';\nimport { getChainsMissingWaasWalletAccounts } from '../getChainsMissingWaasWalletAccounts';\n\ntype ShouldAutoCreateWalletForChainParams = {\n chain: Chain;\n};\n\n/**\n * Checks if a WaaS wallet should be automatically created for the specified blockchain.\n *\n * This function determines whether the current user configuration and project\n * settings require automatic wallet creation for the given chain, considering\n * whether the user already has an embedded wallet for the enabled chains or an external wallet.\n *\n * @param params.chain - The blockchain network to check.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if a wallet should be auto-created for the chain, false otherwise.\n * @notInstrumented\n */\nexport const shouldAutoCreateWalletForChain = (\n { chain }: ShouldAutoCreateWalletForChainParams,\n client = getDefaultClient()\n) => {\n assertDefined(client.projectSettings, 'Project settings are not available');\n\n const embeddedWalletSettings = client.projectSettings.sdk.embeddedWallets;\n\n const automaticEmbeddedWalletCreationEnabled =\n embeddedWalletSettings?.automaticEmbeddedWalletCreation;\n\n if (!automaticEmbeddedWalletCreationEnabled || !client.user) {\n return false;\n }\n\n const automaticEmbeddedWalletCreationForExternalEnabled =\n embeddedWalletSettings?.automaticEmbeddedWalletCreationForExternal;\n\n // If user has an external wallet (e.g metamask, phantom, etc), should only\n // create if automaticEmbeddedWalletCreationForExternalEnabled is true\n const shouldCreateDynamicWaasWallet =\n !userHasExternalWallet(client.user) ||\n automaticEmbeddedWalletCreationForExternalEnabled;\n\n if (!shouldCreateDynamicWaasWallet) {\n return false;\n }\n\n const chainsMissingAutoCreatedWallet =\n getChainsMissingWaasWalletAccounts(client);\n\n return chainsMissingAutoCreatedWallet.includes(chain);\n};\n","import { getCore } from '../../../../client/core/getCore';\nimport { getDefaultClient } from '../../../../client/defaultClient';\nimport type { DynamicClient } from '../../../../client/types';\nimport { createApiClient } from '../../../apiClient/createApiClient';\nimport { refreshAuth } from '../../../user/refreshAuth';\nimport type { BusinessAccountDetail } from '../businessAccounts.types';\n\ntype TransferBusinessAccountOwnershipParams = {\n businessAccountId: string;\n newOwnerUserId: string;\n};\n\n/**\n * Transfers ownership of a business account to another member. Owner-only: the\n * `newOwnerUserId` must already be a member, is promoted to owner, and the\n * current owner is atomically demoted to admin.\n *\n * @param params.businessAccountId - The business account whose ownership moves.\n * @param params.newOwnerUserId - The member to promote to owner.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The updated business account detail.\n *\n * @example\n * ```ts\n * const detail = await getBusinessAccount({ businessAccountId });\n * const target = detail.members.find((m) => m.role === 'admin');\n * await transferBusinessAccountOwnership({\n * businessAccountId,\n * newOwnerUserId: target.userId,\n * });\n * ```\n *\n * @see getBusinessAccount\n * @notInstrumented\n */\nexport const transferBusinessAccountOwnership = async (\n { businessAccountId, newOwnerUserId }: TransferBusinessAccountOwnershipParams,\n client: DynamicClient = getDefaultClient()\n): Promise<BusinessAccountDetail> => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const detail = await apiClient.sdkTransferBusinessAccountOwnership({\n businessAccountId,\n environmentId: core.environmentId,\n transferBusinessAccountOwnershipSdkRequest: { newOwnerUserId },\n });\n\n // Ownership transfer demotes the caller (owner -> admin) and revokes sessions\n // server-side; refresh local auth so the caller's role/session state stays\n // consistent instead of going stale.\n await refreshAuth(client);\n\n return detail as BusinessAccountDetail;\n};\n","import type { GetWalletResponse } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype UnlockWalletParams = {\n password: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Unlocks a WaaS wallet account.\n *\n * @param params.walletAccount - The WaaS wallet account to unlock.\n * @param params.password - The password to unlock the wallet.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves with the wallet information.\n * @notInstrumented\n */\nexport const unlockWallet = async (\n { password, walletAccount }: UnlockWalletParams,\n client = getDefaultClient()\n): Promise<GetWalletResponse> => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.unlockWallet({\n password,\n walletAccount,\n });\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype UpdateWaasPasswordParams = {\n currentPassword: string;\n newPassword: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Updates the password for a WaaS wallet account.\n *\n * This function changes the password used to encrypt and protect the\n * cryptographic key shares for the specified wallet account.\n *\n * @param params.walletAccount - The WaaS wallet account to update the password for.\n * @param params.currentPassword - The current password for the wallet.\n * @param params.newPassword - The new password to set for the wallet.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves when the password is successfully updated.\n * @notInstrumented\n */\nexport const updateWaasPassword = async (\n { currentPassword, newPassword, walletAccount }: UpdateWaasPasswordParams,\n client = getDefaultClient()\n) => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.updatePassword({\n currentPassword,\n newPassword,\n walletAccount,\n });\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport type {\n GetWalletResponse,\n MigrateFromFireblocksResponse,\n WaasPolicyRule,\n WalletRecoveryState,\n} from '@dynamic-labs-wallet/browser-wallet-client';\nexport { NotWaasWalletProviderError } from '../errors/NotWaasWalletProviderError';\nexport type {\n BusinessAccount,\n BusinessAccountDetail,\n BusinessAccountList,\n BusinessAccountMember,\n BusinessAccountSigner,\n BusinessAccountWalletSummary,\n} from '../modules/waas/businessAccounts/businessAccounts.types';\nexport { addBusinessAccountMember } from '../modules/waas/businessAccounts/addBusinessAccountMember';\nexport { addBusinessAccountSigner } from '../modules/waas/businessAccounts/addBusinessAccountSigner';\nexport { addWalletToBusinessAccount } from '../modules/waas/businessAccounts/addWalletToBusinessAccount';\nexport { backupWaasKeySharesToGoogleDrive } from '../modules/waas/backupWaasKeySharesToGoogleDrive';\nexport { createBusinessAccount } from '../modules/waas/businessAccounts/createBusinessAccount';\nexport { createWaasWalletAccounts } from '../modules/waas/createWaasWalletAccounts';\nexport { createWalletForBusinessAccount } from '../modules/waas/businessAccounts/createWalletForBusinessAccount';\nexport { delegateWaasKeyShares } from '../modules/waas/delegateWaasKeyShares';\nexport { exportWaasClientKeyshares } from '../modules/waas/exportWaasClientKeyshares';\nexport { exportWaasPrivateKey } from '../modules/waas/exportWaasPrivateKey';\nexport { getBusinessAccount } from '../modules/waas/businessAccounts/getBusinessAccount';\nexport { getChainsMissingWaasWalletAccounts } from '../modules/waas/getChainsMissingWaasWalletAccounts';\nexport { getWalletRecoveryState } from '../modules/waas/getWalletRecoveryState';\nexport { hasDelegatedAccess } from '../modules/waas/hasDelegatedAccess';\nexport { importWaasPrivateKey } from '../modules/waas/importWaasPrivateKey';\nexport { isDynamicWaasEnabled } from '../modules/waas/isDynamicWaasEnabled';\nexport { isPasswordRequiredForWaasWallets } from '../modules/waas/isPasswordRequiredForWaasWallets';\nexport { isWaasWalletAccount } from '../modules/waas/isWaasWalletAccount';\nexport { isWalletCreationRequirement } from '../modules/waas/isWalletCreationRequirement/isWalletCreationRequirement';\nexport { listBusinessAccounts } from '../modules/waas/businessAccounts/listBusinessAccounts';\nexport { migrateFromFireblocks } from '../modules/waas/migrateFromFireblocks';\nexport { normalizeWalletRequirements } from '../modules/waas/normalizeWalletRequirements/normalizeWalletRequirements';\nexport { refreshWaasWalletAccountShares } from '../modules/waas/refreshWaasWalletAccountShares';\nexport { removeBusinessAccountMember } from '../modules/waas/businessAccounts/removeBusinessAccountMember';\nexport { removeBusinessAccountSigner } from '../modules/waas/businessAccounts/removeBusinessAccountSigner';\nexport { revokeWaasDelegation } from '../modules/waas/revokeWaasDelegation';\nexport { setWaasWalletAccountPassword } from '../modules/waas/setWaasWalletAccountPassword';\nexport { shouldAutoCreateWalletForChain } from '../modules/waas/shouldAutoCreateWalletForChain';\nexport { transferBusinessAccountOwnership } from '../modules/waas/businessAccounts/transferBusinessAccountOwnership';\nexport { unlockWallet } from '../modules/waas/unlockWallet';\nexport { updateWaasPassword } from '../modules/waas/updateWaasPassword';\nexport type {\n WalletCreationBitcoinConfig,\n WalletCreationRequirement,\n} from '../modules/waas/waas.types';\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAa,6BACX,WACwB;CACxB,MAAM,kBAAkB,OAAO;AAE/B,eAAc,iBAAiB,qCAAqC;CAEpE,MAAM,cACJ,gBAAgB,IAAI,iBAAiB,qBAAqB,MACvD,UAAU,MAAM,QAClB;AAEH,KAAI,CAAC,YACH,OAAM,IAAI,kBAAkB,4CAA4C;AAa1E,QAPmB,iBACjB,EAAE,WAAW,0BAA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CAG5B,MAAM,SAAS,MAFG,gBAAgB,EAAE,EAAE,OAAO,CAEd,oCAAoC;EACjE;EACA,eAAe,KAAK;EACpB,4CAA4C,EAAE,gBAAgB;EAC/D,CAAC;AAKF,OAAMC,sBAAY,OAAO;AAEzB,QAAO;;;;;;;;;;;;;;ACjCT,MAAa,eAAe,OAC1B,EAAE,UAAU,iBACZ,SAAS,kBAAkB,KACI;AAM/B,QALiB,uCACf,EAAE,eAAe,EACjB,OACD,CAEe,aAAa;EAC3B;EACA;EACD,CAAC;;;;;;;;;;;;;;;;;;ACTJ,MAAa,qBAAqB,OAChC,EAAE,iBAAiB,aAAa,iBAChC,SAAS,kBAAkB,KACxB;AAMH,QALiB,uCACf,EAAE,eAAe,EACjB,OACD,CAEe,eAAe;EAC7B;EACA;EACA;EACD,CAAC;;;;;AC9BJ,qBAAqBC,MAAaC,QAAe"}
|
package/dist/waasCore.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const require_updateAuthFromVerifyResponse = require('./updateAuthFromVerifyResponse-
|
|
2
|
-
require('./isDynamicWaasEnabled-
|
|
3
|
-
const require_isUserOnboardingComplete = require('./isUserOnboardingComplete-
|
|
4
|
-
require('./isMfaRequiredForAction-
|
|
5
|
-
const require_consumeMfaTokenIfRequiredForAction = require('./consumeMfaTokenIfRequiredForAction-
|
|
6
|
-
const require_getSignedSessionId = require('./getSignedSessionId-
|
|
7
|
-
const require_migrateFromFireblocks = require('./migrateFromFireblocks-
|
|
1
|
+
const require_updateAuthFromVerifyResponse = require('./updateAuthFromVerifyResponse-CNfUcLNC.cjs');
|
|
2
|
+
require('./isDynamicWaasEnabled-Bfd-h02Q.cjs');
|
|
3
|
+
const require_isUserOnboardingComplete = require('./isUserOnboardingComplete-BmGd69SF.cjs');
|
|
4
|
+
require('./isMfaRequiredForAction-W1y6oe6Y.cjs');
|
|
5
|
+
const require_consumeMfaTokenIfRequiredForAction = require('./consumeMfaTokenIfRequiredForAction-csagEe9v.cjs');
|
|
6
|
+
const require_getSignedSessionId = require('./getSignedSessionId-DpZexHsP.cjs');
|
|
7
|
+
const require_migrateFromFireblocks = require('./migrateFromFireblocks-rQkE9cQa.cjs');
|
|
8
8
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
9
9
|
let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
|
|
10
10
|
let _dynamic_labs_wallet_browser_wallet_client = require("@dynamic-labs-wallet/browser-wallet-client");
|
|
@@ -127,13 +127,14 @@ const createWaasProvider = ({ sdkClient, chain }) => {
|
|
|
127
127
|
waasClient
|
|
128
128
|
});
|
|
129
129
|
};
|
|
130
|
-
const delegateKeyShares = async ({ password, walletAccount }) => {
|
|
130
|
+
const delegateKeyShares = async ({ initialSignerRules, password, walletAccount }) => {
|
|
131
131
|
const { signature: signedSessionId } = await require_getSignedSessionId.getSignedSessionId(sdkClient);
|
|
132
132
|
const waasClient = await getWaasClient();
|
|
133
133
|
return discardClientOnLoadFailure({
|
|
134
134
|
operation: () => waasClient.delegateKeyShares({
|
|
135
135
|
accountAddress: walletAccount.address,
|
|
136
136
|
authToken: sdkClient.token ?? void 0,
|
|
137
|
+
initialSignerRules,
|
|
137
138
|
password,
|
|
138
139
|
signedSessionId
|
|
139
140
|
}),
|
package/dist/waasCore.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waasCore.cjs","names":["getCore","_waasClient: DynamicWalletClient | undefined","_waasClientSessionId: string | undefined","getWaasClient: WaasProvider['getWaasClient']","isUserOnboardingComplete","WaasOnboardingIncompleteError","createWaasClient","getWaasChainNameFromChain","backupKeySharesToGoogleDrive: WaasProvider['backupKeySharesToGoogleDrive']","getSignedSessionId","createWalletAccount: WaasProvider['createWalletAccount']","ThresholdSignatureScheme","delegateKeyShares: WaasProvider['delegateKeyShares']","exportClientKeyshares: WaasProvider['exportClientKeyshares']","exportPrivateKey: WaasProvider['exportPrivateKey']","consumeMfaTokenIfRequiredForAction","MFAAction","getElevatedAccessToken","TokenScope","restoreUserShareForWalletAccount: WaasProvider['restoreUserShareForWalletAccount']","WalletOperation","importPrivateKey: WaasProvider['importPrivateKey']","migrateFromFireblocks: WaasProvider['migrateFromFireblocks']","refreshWalletAccountShares: WaasProvider['refreshWalletAccountShares']","reshareToNewSignerShareSet: WaasProvider['reshareToNewSignerShareSet']","revokeDelegation: WaasProvider['revokeDelegation']","setWaasWalletAccountPassword: WaasProvider['setWaasWalletAccountPassword']","signRawMessage: WaasProvider['signRawMessage']","InvalidParamError","destroy: WaasProvider['destroy']","updatePassword: WaasProvider['updatePassword']","signMessage: WaasProvider['signMessage']","signSerializedTransaction: WaasProvider['signSerializedTransaction']","getWalletRecoveryState: WaasProvider['getWalletRecoveryState']","unlockWallet: WaasProvider['unlockWallet']","WaasLoadFailedError","migrateFromFireblocks","getWaasWalletProviderFromWalletAccount","WalletProviderEnum","DYNAMIC_WAAS_METADATA","getChainFromVerifiedCredentialChain","packageName","packageVersion"],"sources":["../src/utils/createTranslateRejection/createTranslateRejection.ts","../src/modules/waas/createWaasProvider/isWaasLoadExhaustionError.ts","../src/modules/waas/createWaasProvider/createWaasProvider.ts","../src/modules/waas/exportWaasPrivateKeyToContainer/exportWaasPrivateKeyToContainer.ts","../src/modules/waas/getAllUserWaasAddressesForChain/getAllUserWaasAddressesForChain.ts","../src/exports/waasCore.ts"],"sourcesContent":["export type CreateTranslateRejectionParams<TMatched> = {\n /**\n * Builds the error thrown in place of a matched rejection.\n */\n mapTo: (error: TMatched) => Error;\n /**\n * Type guard selecting which rejections to translate. Anything it does not\n * match is rethrown untouched, so callers only translate the errors they\n * own. Narrowing to `TMatched` lets {@link CreateTranslateRejectionParams.mapTo}\n * receive a typed error without a cast.\n */\n match: (error: unknown) => error is TMatched;\n};\n\n/**\n * Builds a reusable decorator, bound once to a `match`/`mapTo` pair, that wraps\n * any async function so a matching rejection is rethrown as `mapTo(error)`\n * while every other rejection — and every resolved value — passes through\n * untouched. Unmatched errors are rethrown by reference, so the decorator can\n * never swallow or reshape an error it was not asked to translate.\n *\n * Binding `match`/`mapTo` up front keeps the generic wrapping machinery here\n * instead of at the call site: consumers get a plain `(fn) => wrappedFn`\n * decorator they can apply to many functions of differing signatures, each of\n * which keeps its own argument and return types.\n *\n * @notInstrumented\n */\nexport const createTranslateRejection =\n <TMatched>({ match, mapTo }: CreateTranslateRejectionParams<TMatched>) =>\n <TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => Promise<TReturn>) =>\n async (...args: TArgs): Promise<TReturn> => {\n try {\n return await fn(...args);\n } catch (error) {\n if (match(error)) {\n throw mapTo(error);\n }\n throw error;\n }\n };\n","/**\n * Exact message prefix of the rejection thrown by\n * `@dynamic-labs-wallet/browser-wallet-client` when the secure container load\n * exhausts all retry attempts. The upstream library throws a plain `Error`\n * with no code, so message matching is the only detection mechanism available;\n * the dependency is pinned to an exact version and the spec pins this string\n * so drift is caught at upgrade time.\n */\nconst UPSTREAM_LOAD_EXHAUSTION_MESSAGE_PREFIX =\n 'Failed to load iframe after all retry attempts';\n\n/**\n * True when `error` is the upstream \"load retry attempts exhausted\" rejection\n * from the embedded (WaaS) wallet's secure container load. Narrows to `Error`\n * so the matched value can be forwarded as a typed error cause without a cast,\n * and guards `instanceof Error` before reading `.message` so a non-`Error`\n * rejection never throws during detection.\n *\n * @notInstrumented\n */\nexport const isWaasLoadExhaustionError = (error: unknown): error is Error =>\n error instanceof Error &&\n error.message.startsWith(UPSTREAM_LOAD_EXHAUSTION_MESSAGE_PREFIX);\n","import {\n type BitcoinConfig,\n type DynamicWalletClient,\n ThresholdSignatureScheme,\n WalletOperation,\n} from '@dynamic-labs-wallet/browser-wallet-client';\nimport { MFAAction, TokenScope } from '@dynamic-labs/sdk-api-core';\n\nimport { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types/DynamicClient';\nimport { InvalidParamError } from '../../../errors/InvalidParamError';\nimport { WaasLoadFailedError } from '../../../errors/WaasLoadFailedError';\nimport { WaasOnboardingIncompleteError } from '../../../errors/WaasOnboardingIncompleteError';\nimport { createTranslateRejection } from '../../../utils/createTranslateRejection';\nimport { getElevatedAccessToken } from '../../auth/getElevatedAccessToken';\nimport type { Chain } from '../../chain';\nimport { consumeMfaTokenIfRequiredForAction } from '../../mfa/consumeMfaTokenIfRequiredForAction';\nimport { getSignedSessionId } from '../../sessionKeys/getSignedSessionId';\nimport { isUserOnboardingComplete } from '../../user/isUserOnboardingComplete';\nimport { createWaasClient } from '../createWaasClient';\nimport { getWaasChainNameFromChain } from '../getWaasChainNameFromChain';\nimport type { WaasProvider } from '../waas.types';\nimport { isWaasLoadExhaustionError } from './isWaasLoadExhaustionError';\n\nconst RAW_MESSAGE_MESSAGE_REQUIRED_LENGTH = 64;\n\ntype CreateWaasProviderParams = {\n chain: Chain;\n sdkClient: DynamicClient;\n};\n\n/** @notInstrumented */\nexport const createWaasProvider = ({\n sdkClient,\n chain,\n}: CreateWaasProviderParams): WaasProvider => {\n const logger = getCore(sdkClient).logger;\n\n let _waasClient: DynamicWalletClient | undefined;\n // The session the cached client was built against. A step-up reauth mints a\n // NEW session (new sessionId + token); see the rebuild guard below.\n let _waasClientSessionId: string | undefined;\n\n // Drops the cached client only when it still points at `client`. Guarding on\n // identity matters because a step-up reauth can mint a new session and rebuild\n // a healthy client (via the session-change reset in getWaasClient) while an\n // older client's initialize()/operation is still failing in flight. Clearing\n // in that case would orphan the healthy replacement, since nothing would\n // release its upstream shared-container reference. _waasClientSessionId is\n // cleared alongside to keep the pair consistent.\n const resetClientIfCurrent = (client: DynamicWalletClient): void => {\n if (_waasClient === client) {\n _waasClient = undefined;\n _waasClientSessionId = undefined;\n }\n };\n\n // because the waas client needs the authToken to be set, we can only create it\n // the first time it's needed, which is after the user has logged in\n const getWaasClient: WaasProvider['getWaasClient'] = async () => {\n // After a step-up reauthentication a new session is minted. In header auth\n // mode (native webview) the iframe has no cookie jar to fall back on, so a\n // client cached against the previous session keeps presenting the stale\n // token — its next backend call (createRooms/users) 401s and trips the\n // iframe's onUnauthorized → forced logout. Drop the cached client when the\n // session changes so it rebuilds + re-initializes with the fresh token and\n // signed session id. Key shares stay in storage (only client auth resets);\n // routine token refresh keeps the same sessionId, so it does not rebuild.\n const currentSessionId = getCore(sdkClient).state.get().user?.sessionId;\n if (_waasClient && currentSessionId !== _waasClientSessionId) {\n _waasClient = undefined;\n }\n\n if (!_waasClient) {\n // Chokepoint: don't build + initialize the iframe client until onboarding\n // is complete. The iframe's init-time room-cache pre-warm fires\n // `createRooms` using the token captured at construction — before any\n // per-operation token resync exists to correct it. Built while the token\n // is still pre-`user:basic` (MFA / KYC / recovery codes / device\n // registration pending), that pre-warm 401s and trips the iframe's\n // onUnauthorized → forced-logout. This is the single gateway to\n // createWaasClient (web and native), so it covers every WaaS caller.\n if (!isUserOnboardingComplete(sdkClient)) {\n throw new WaasOnboardingIncompleteError();\n }\n\n const builtClient = createWaasClient(\n { chainName: getWaasChainNameFromChain(chain) },\n sdkClient\n );\n _waasClient = builtClient;\n _waasClientSessionId = currentSessionId;\n try {\n await builtClient.initialize();\n } catch (error) {\n // A failed load (e.g. iframe retry exhaustion) leaves an unusable,\n // never-initialized client cached. Drop it so the next getWaasClient()\n // rebuilds and re-initializes — the fresh load cycle WaasLoadFailedError\n // documents — instead of returning the dead client for the rest of the\n // session. Identity-guarded (see resetClientIfCurrent).\n resetClientIfCurrent(builtClient);\n throw error;\n }\n }\n // Read the shared var, not the locally-built client: if a concurrent\n // session-change rebuilt a fresh client while this initialize() was pending,\n // the caller should get that current healthy client, not this now-superseded\n // instance built against the old session.\n return _waasClient;\n };\n\n // Runs an operation against an already-fetched client and, if it fails because\n // the container's load was exhausted mid-flight (the client built and\n // initialized fine, then its iframe died — e.g. tab backgrounding, relogin —\n // and its own recovery could not reload), drops the cached client so the next\n // operation rebuilds and re-initializes. This covers the post-initialization\n // path that getWaasClient's own load-failure reset cannot see, so the\n // fresh-load cycle WaasLoadFailedError documents holds for every operation,\n // not just the first load. Identity-guarded (see resetClientIfCurrent).\n const discardClientOnLoadFailure = async <TReturn>({\n waasClient,\n operation,\n }: {\n operation: () => Promise<TReturn>;\n waasClient: DynamicWalletClient;\n }): Promise<TReturn> => {\n try {\n return await operation();\n } catch (error) {\n if (isWaasLoadExhaustionError(error)) {\n resetClientIfCurrent(waasClient);\n }\n throw error;\n }\n };\n\n const backupKeySharesToGoogleDrive: WaasProvider['backupKeySharesToGoogleDrive'] =\n async ({ googleDriveAccessToken, password, walletAccount }) => {\n const { signature: signedSessionId } = await getSignedSessionId(\n sdkClient\n );\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.backupKeySharesToGoogleDrive({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n googleDriveAccessToken,\n password,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const createWalletAccount: WaasProvider['createWalletAccount'] = async (\n args = {}\n ) => {\n logger.debug('[createWaasProvider] createWalletAccount', {\n bitcoinConfig: args.bitcoinConfig,\n thresholdSignatureScheme: args.thresholdSignatureScheme,\n });\n\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const waasClient = await getWaasClient();\n\n const waasWallet = await discardClientOnLoadFailure({\n operation: () =>\n waasClient.createWalletAccount({\n authToken: sdkClient.token ?? undefined,\n bitcoinConfig: args.bitcoinConfig as BitcoinConfig | undefined,\n businessAccountId: args.businessAccountId,\n password: args.password,\n signedSessionId,\n thresholdSignatureScheme:\n args.thresholdSignatureScheme ??\n ThresholdSignatureScheme.TWO_OF_TWO,\n }),\n waasClient,\n });\n\n return waasWallet;\n };\n\n const delegateKeyShares: WaasProvider['delegateKeyShares'] = async ({\n password,\n walletAccount,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.delegateKeyShares({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n password,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const exportClientKeyshares: WaasProvider['exportClientKeyshares'] = async ({\n password,\n walletAccount,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const waasClient = await getWaasClient();\n\n await discardClientOnLoadFailure({\n operation: () =>\n waasClient.exportClientKeyshares({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n password,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const exportPrivateKey: WaasProvider['exportPrivateKey'] = async ({\n container,\n displayContainer,\n walletAccount,\n password,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const waasClient = await getWaasClient();\n\n const mfaToken = await consumeMfaTokenIfRequiredForAction(\n { mfaAction: MFAAction.WalletWaasExport },\n sdkClient\n );\n\n // Forward any elevated access token previously obtained via step-up\n // (e.g. requestExternalAuthElevatedToken) so the backend authorizes\n // the export under the wallet:export scope.\n const elevatedAccessToken = getElevatedAccessToken(\n { scope: TokenScope.Walletexport },\n sdkClient\n );\n\n await discardClientOnLoadFailure({\n operation: () =>\n waasClient.exportPrivateKey({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n // Exactly one display surface is forwarded: `container` (a\n // WaasSDKContainer, e.g. a React Native visible WebView) or\n // `displayContainer` (a DOM element, web). The upstream client enforces\n // the \"exactly one\" invariant and renders the key inside the surface's\n // own sandboxed document — it never crosses back to the host.\n container,\n displayContainer,\n elevatedAccessToken,\n mfaToken,\n password,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const restoreUserShareForWalletAccount: WaasProvider['restoreUserShareForWalletAccount'] =\n async ({ walletAccount }) => {\n const { signature: signedSessionId } = await getSignedSessionId(\n sdkClient\n );\n\n const waasClient = await getWaasClient();\n\n await discardClientOnLoadFailure({\n operation: () =>\n waasClient.getWallet({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n signedSessionId,\n walletOperation: WalletOperation.SIGN_MESSAGE,\n }),\n waasClient,\n });\n };\n\n const importPrivateKey: WaasProvider['importPrivateKey'] = async ({\n privateKey,\n thresholdSignatureScheme = ThresholdSignatureScheme.TWO_OF_TWO,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const walletClient = await getWaasClient();\n\n await discardClientOnLoadFailure({\n operation: () =>\n walletClient.importPrivateKey({\n authToken: sdkClient.token ?? undefined,\n privateKey,\n signedSessionId,\n thresholdSignatureScheme,\n }),\n waasClient: walletClient,\n });\n };\n\n const migrateFromFireblocks: WaasProvider['migrateFromFireblocks'] = async ({\n coinTypes,\n deviceId,\n expectedAddresses,\n jwt,\n password,\n storage,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const walletClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n walletClient.migrateFromFireblocks({\n authToken: sdkClient.token ?? undefined,\n fireblocks: {\n deviceId,\n expectedAddresses,\n jwt,\n ncwStorage: storage,\n walletPassword: password,\n ...(coinTypes ? { coinTypes } : {}),\n },\n signedSessionId,\n }),\n waasClient: walletClient,\n });\n };\n\n const refreshWalletAccountShares: WaasProvider['refreshWalletAccountShares'] =\n async ({ password, walletAccount }) => {\n const { signature: signedSessionId } = await getSignedSessionId(\n sdkClient\n );\n\n const walletClient = await getWaasClient();\n\n const mfaToken = await consumeMfaTokenIfRequiredForAction(\n { mfaAction: MFAAction.WalletWaasRefresh },\n sdkClient\n );\n\n return discardClientOnLoadFailure({\n operation: () =>\n walletClient.refreshWalletAccountShares({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n mfaToken,\n password,\n signedSessionId,\n }),\n waasClient: walletClient,\n });\n };\n\n const reshareToNewSignerShareSet: WaasProvider['reshareToNewSignerShareSet'] =\n async ({\n businessAccountId,\n password,\n signerType,\n targetSignerIdentity,\n walletAccount,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(\n sdkClient\n );\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.reshareToNewSignerShareSet({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n businessAccountId,\n password,\n signedSessionId,\n // Public API uses a string union; the client expects the core enum\n // (identical values). Cast at this single boundary.\n signerType: signerType as Parameters<\n typeof waasClient.reshareToNewSignerShareSet\n >[0]['signerType'],\n targetSignerIdentity,\n }),\n waasClient,\n });\n };\n\n const revokeDelegation: WaasProvider['revokeDelegation'] = async ({\n password,\n walletAccount,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.revokeDelegation({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n password,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const setWaasWalletAccountPassword: WaasProvider['setWaasWalletAccountPassword'] =\n async ({ password, walletAccount }) => {\n const { signature: signedSessionId } = await getSignedSessionId(\n sdkClient\n );\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.setPassword({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n newPassword: password,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const signRawMessage: WaasProvider['signRawMessage'] = async ({\n message,\n password,\n walletAccount,\n }) => {\n if (message.length !== RAW_MESSAGE_MESSAGE_REQUIRED_LENGTH) {\n throw new InvalidParamError(\n `Message must be ${RAW_MESSAGE_MESSAGE_REQUIRED_LENGTH} characters long`\n );\n }\n\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const mfaToken = await consumeMfaTokenIfRequiredForAction(\n { mfaAction: MFAAction.WalletWaasSign },\n sdkClient\n );\n\n const elevatedAccessToken = getElevatedAccessToken(\n { scope: TokenScope.Walletsign },\n sdkClient\n );\n\n const walletClient = await getWaasClient();\n\n const signature = await discardClientOnLoadFailure({\n operation: () =>\n walletClient.signRawMessage({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n elevatedAccessToken,\n message,\n mfaToken,\n password,\n signedSessionId,\n }),\n waasClient: walletClient,\n });\n\n return { signature };\n };\n\n const destroy: WaasProvider['destroy'] = async (args) => {\n if (!_waasClient) {\n return;\n }\n\n const waasClient = await getWaasClient();\n // When a session token expires, we preserve key shares in storage instead\n // of clearing them. Customers with short-lived sessions (minutes) were\n // hitting excessive server-side share recovery on every re-login, which\n // also forced users to re-enter their wallet password since the unlocked\n // share only lives for the duration of the session.\n //\n // This is safe because the waas-sdk separately fingerprints the user\n // (sub + environment_id) and clears all storage if a different user logs\n // in. On explicit user-initiated logout, shares are always cleared for\n // security.\n if (args?.reason !== 'token-expired') {\n await waasClient.cleanup();\n }\n _waasClient = undefined;\n };\n\n const updatePassword: WaasProvider['updatePassword'] = async ({\n walletAccount,\n currentPassword,\n newPassword,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.updatePassword({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n existingPassword: currentPassword,\n newPassword,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const signMessage: WaasProvider['signMessage'] = async ({\n message,\n walletAccount,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const mfaToken = await consumeMfaTokenIfRequiredForAction(\n { mfaAction: MFAAction.WalletWaasSign },\n sdkClient\n );\n\n const elevatedAccessToken = getElevatedAccessToken(\n { scope: TokenScope.Walletsign },\n sdkClient\n );\n\n const waasClient = await getWaasClient();\n\n const signature = await discardClientOnLoadFailure({\n operation: () =>\n waasClient.signMessage({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n elevatedAccessToken,\n message,\n mfaToken,\n signedSessionId,\n }),\n waasClient,\n });\n\n return { signature };\n };\n\n const signSerializedTransaction: WaasProvider['signSerializedTransaction'] =\n async ({ chainId, serializedTransaction, walletAccount }) => {\n const { signature: signedSessionId } = await getSignedSessionId(\n sdkClient\n );\n\n const mfaToken = await consumeMfaTokenIfRequiredForAction(\n { mfaAction: MFAAction.WalletWaasSign },\n sdkClient\n );\n\n const elevatedAccessToken = getElevatedAccessToken(\n { scope: TokenScope.Walletsign },\n sdkClient\n );\n\n const waasClient = await getWaasClient();\n\n const signature = await discardClientOnLoadFailure({\n operation: () =>\n waasClient.signTransaction({\n authToken: sdkClient.token ?? undefined,\n chainId,\n elevatedAccessToken,\n mfaToken,\n senderAddress: walletAccount.address,\n signedSessionId,\n transaction: serializedTransaction,\n }),\n waasClient,\n });\n\n return { signature };\n };\n\n const getWalletRecoveryState: WaasProvider['getWalletRecoveryState'] =\n async ({ walletAccount }) => {\n const { signature: signedSessionId } = await getSignedSessionId(\n sdkClient\n );\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.getWalletRecoveryState({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const unlockWallet: WaasProvider['unlockWallet'] = async ({\n password,\n walletAccount,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.unlockWallet({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n password,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n // Every operation is wrapped so an exhausted container load surfaces as a\n // typed WaasLoadFailedError no matter which call triggers it — the initial\n // load or a mid-operation recovery. Wrapped at the operation itself (rather\n // than a separate whole-provider pass) so the translation is visible right\n // where the provider is assembled.\n const translateLoadFailure = createTranslateRejection({\n mapTo: (error) => new WaasLoadFailedError({ cause: error }),\n match: isWaasLoadExhaustionError,\n });\n\n const provider: WaasProvider = {\n backupKeySharesToGoogleDrive: translateLoadFailure(\n backupKeySharesToGoogleDrive\n ),\n createWalletAccount: translateLoadFailure(createWalletAccount),\n delegateKeyShares: translateLoadFailure(delegateKeyShares),\n destroy: translateLoadFailure(destroy),\n exportClientKeyshares: translateLoadFailure(exportClientKeyshares),\n exportPrivateKey: translateLoadFailure(exportPrivateKey),\n getWaasClient: translateLoadFailure(getWaasClient),\n getWalletRecoveryState: translateLoadFailure(getWalletRecoveryState),\n importPrivateKey: translateLoadFailure(importPrivateKey),\n migrateFromFireblocks: translateLoadFailure(migrateFromFireblocks),\n refreshWalletAccountShares: translateLoadFailure(\n refreshWalletAccountShares\n ),\n reshareToNewSignerShareSet: translateLoadFailure(\n reshareToNewSignerShareSet\n ),\n restoreUserShareForWalletAccount: translateLoadFailure(\n restoreUserShareForWalletAccount\n ),\n revokeDelegation: translateLoadFailure(revokeDelegation),\n setWaasWalletAccountPassword: translateLoadFailure(\n setWaasWalletAccountPassword\n ),\n signMessage: translateLoadFailure(signMessage),\n signRawMessage: translateLoadFailure(signRawMessage),\n signSerializedTransaction: translateLoadFailure(signSerializedTransaction),\n unlockWallet: translateLoadFailure(unlockWallet),\n updatePassword: translateLoadFailure(updatePassword),\n };\n\n return provider;\n};\n","import type { WaasSDKContainer } from '@dynamic-labs-wallet/core';\n\nimport type { DynamicClient } from '../../../client/types/DynamicClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype ExportWaasPrivateKeyToContainerParams = {\n container: WaasSDKContainer;\n password?: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Exports the private key for a WaaS wallet account into a caller-provided\n * {@link WaasSDKContainer} (e.g. a visible React Native WebView) instead of a\n * DOM element.\n *\n * This is the container-based counterpart to `exportWaasPrivateKey` (which\n * injects an iframe into a DOM `displayContainer` on web). The export ceremony\n * runs — and the private key is rendered — entirely inside the container's own\n * sandboxed document; the key is never exposed to the host JS layer. The caller\n * owns the container's lifecycle and must call `container.destroy()` when the\n * display is dismissed.\n *\n * @param params.walletAccount - The WaaS wallet account to export the private key from.\n * @param params.container - The container that hosts the secure key display.\n * @param [params.password] - Optional password to decrypt the private key.\n * @param client - The Dynamic client instance. This is an internal API (exposed\n * only via `@dynamic-labs-sdk/client/waas/core`), so the client is passed\n * explicitly rather than defaulted — callers resolve it (e.g. via\n * `getDefaultClient()`) and thread it in.\n * @returns A promise that resolves when the private key export is complete.\n * @notInstrumented\n */\nexport const exportWaasPrivateKeyToContainer = async (\n { container, password, walletAccount }: ExportWaasPrivateKeyToContainerParams,\n client: DynamicClient\n) => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.exportPrivateKey({\n container,\n password,\n walletAccount,\n });\n};\n","import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../client/types';\nimport { getChainFromVerifiedCredentialChain } from '../../../utils/getChainFromVerifiedCredentialChain';\nimport type { Chain } from '../../chain';\nimport { DYNAMIC_WAAS_METADATA } from '../constants';\n\ntype GetAllUserWaasAddressesForChainParams = {\n chain: Chain;\n};\n\n/** @notInstrumented */\nexport const getAllUserWaasAddressesForChain = (\n { chain }: GetAllUserWaasAddressesForChainParams,\n client: DynamicClient\n): string[] => {\n if (!client.user) {\n return [];\n }\n\n const waasWalletCredentials =\n client.user.verifiedCredentials.filter(\n (credential) =>\n credential.walletProvider === WalletProviderEnum.EmbeddedWallet &&\n credential.walletName\n ?.toLowerCase()\n .startsWith(DYNAMIC_WAAS_METADATA.normalizedWalletName) &&\n credential.address &&\n credential.chain &&\n getChainFromVerifiedCredentialChain(credential.chain) === chain\n ) ?? [];\n\n const waasAddresses: string[] = waasWalletCredentials.map(\n // casting because we're already filtering out credentials without an address\n (credential) => credential.address as string\n );\n\n return waasAddresses;\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport type {\n BitcoinNetwork,\n DynamicWalletClient,\n MigrateFromFireblocksResponse,\n ThresholdSignatureScheme,\n} from '@dynamic-labs-wallet/browser-wallet-client';\nexport type { WaasSDKContainer } from '@dynamic-labs-wallet/core';\nexport { DYNAMIC_WAAS_METADATA } from '../modules/waas/constants';\nexport { createWaasClient } from '../modules/waas/createWaasClient';\nexport { createWaasProvider } from '../modules/waas/createWaasProvider';\nexport { exportWaasPrivateKeyToContainer } from '../modules/waas/exportWaasPrivateKeyToContainer';\nexport { getAllUserWaasAddressesForChain } from '../modules/waas/getAllUserWaasAddressesForChain';\nexport { getWaasChainNameFromChain } from '../modules/waas/getWaasChainNameFromChain';\nexport { migrateFromFireblocks } from '../modules/waas/migrateFromFireblocks';\nexport { preconnectWaasIframe } from '../modules/waas/preconnectWaasIframe';\nexport type {\n WaasProvider,\n WaasWalletProvider,\n} from '../modules/waas/waas.types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,4BACA,EAAE,OAAO,aACe,OACnC,OAAO,GAAG,SAAkC;AAC1C,KAAI;AACF,SAAO,MAAM,GAAG,GAAG,KAAK;UACjB,OAAO;AACd,MAAI,MAAM,MAAM,CACd,OAAM,MAAM,MAAM;AAEpB,QAAM;;;;;;;;;;;;;;AC9BZ,MAAM,0CACJ;;;;;;;;;;AAWF,MAAa,6BAA6B,UACxC,iBAAiB,SACjB,MAAM,QAAQ,WAAW,wCAAwC;;;;ACEnE,MAAM,sCAAsC;;AAQ5C,MAAa,sBAAsB,EACjC,WACA,YAC4C;CAC5C,MAAM,SAASA,6CAAQ,UAAU,CAAC;CAElC,IAAIC;CAGJ,IAAIC;CASJ,MAAM,wBAAwB,WAAsC;AAClE,MAAI,gBAAgB,QAAQ;AAC1B,iBAAc;AACd,0BAAuB;;;CAM3B,MAAMC,gBAA+C,YAAY;EAS/D,MAAM,mBAAmBH,6CAAQ,UAAU,CAAC,MAAM,KAAK,CAAC,MAAM;AAC9D,MAAI,eAAe,qBAAqB,qBACt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G;AAMH,QALiBC,qEACf,EAAE,eAAe,EACjB,OACD,CAEe,iBAAiB;EAC/B;EACA;EACA;EACD,CAAC;;;;;;ACnCJ,MAAa,mCACX,EAAE,SACF,WACa;AACb,KAAI,CAAC,OAAO,KACV,QAAO,EAAE;AAoBX,SAhBE,OAAO,KAAK,oBAAoB,QAC7B,eACC,WAAW,mBAAmBC,8CAAmB,kBACjD,WAAW,YACP,aAAa,CACd,WAAWC,2DAAsB,qBAAqB,IACzD,WAAW,WACX,WAAW,SACXC,yEAAoC,WAAW,MAAM,KAAK,MAC7D,IAAI,EAAE,EAE6C,KAEnD,eAAe,WAAW,QAC5B;;;;;mEC7BkBC,2CAAaC,6CAAe"}
|
|
1
|
+
{"version":3,"file":"waasCore.cjs","names":["getCore","_waasClient: DynamicWalletClient | undefined","_waasClientSessionId: string | undefined","getWaasClient: WaasProvider['getWaasClient']","isUserOnboardingComplete","WaasOnboardingIncompleteError","createWaasClient","getWaasChainNameFromChain","backupKeySharesToGoogleDrive: WaasProvider['backupKeySharesToGoogleDrive']","getSignedSessionId","createWalletAccount: WaasProvider['createWalletAccount']","ThresholdSignatureScheme","delegateKeyShares: WaasProvider['delegateKeyShares']","exportClientKeyshares: WaasProvider['exportClientKeyshares']","exportPrivateKey: WaasProvider['exportPrivateKey']","consumeMfaTokenIfRequiredForAction","MFAAction","getElevatedAccessToken","TokenScope","restoreUserShareForWalletAccount: WaasProvider['restoreUserShareForWalletAccount']","WalletOperation","importPrivateKey: WaasProvider['importPrivateKey']","migrateFromFireblocks: WaasProvider['migrateFromFireblocks']","refreshWalletAccountShares: WaasProvider['refreshWalletAccountShares']","reshareToNewSignerShareSet: WaasProvider['reshareToNewSignerShareSet']","revokeDelegation: WaasProvider['revokeDelegation']","setWaasWalletAccountPassword: WaasProvider['setWaasWalletAccountPassword']","signRawMessage: WaasProvider['signRawMessage']","InvalidParamError","destroy: WaasProvider['destroy']","updatePassword: WaasProvider['updatePassword']","signMessage: WaasProvider['signMessage']","signSerializedTransaction: WaasProvider['signSerializedTransaction']","getWalletRecoveryState: WaasProvider['getWalletRecoveryState']","unlockWallet: WaasProvider['unlockWallet']","WaasLoadFailedError","migrateFromFireblocks","getWaasWalletProviderFromWalletAccount","WalletProviderEnum","DYNAMIC_WAAS_METADATA","getChainFromVerifiedCredentialChain","packageName","packageVersion"],"sources":["../src/utils/createTranslateRejection/createTranslateRejection.ts","../src/modules/waas/createWaasProvider/isWaasLoadExhaustionError.ts","../src/modules/waas/createWaasProvider/createWaasProvider.ts","../src/modules/waas/exportWaasPrivateKeyToContainer/exportWaasPrivateKeyToContainer.ts","../src/modules/waas/getAllUserWaasAddressesForChain/getAllUserWaasAddressesForChain.ts","../src/exports/waasCore.ts"],"sourcesContent":["export type CreateTranslateRejectionParams<TMatched> = {\n /**\n * Builds the error thrown in place of a matched rejection.\n */\n mapTo: (error: TMatched) => Error;\n /**\n * Type guard selecting which rejections to translate. Anything it does not\n * match is rethrown untouched, so callers only translate the errors they\n * own. Narrowing to `TMatched` lets {@link CreateTranslateRejectionParams.mapTo}\n * receive a typed error without a cast.\n */\n match: (error: unknown) => error is TMatched;\n};\n\n/**\n * Builds a reusable decorator, bound once to a `match`/`mapTo` pair, that wraps\n * any async function so a matching rejection is rethrown as `mapTo(error)`\n * while every other rejection — and every resolved value — passes through\n * untouched. Unmatched errors are rethrown by reference, so the decorator can\n * never swallow or reshape an error it was not asked to translate.\n *\n * Binding `match`/`mapTo` up front keeps the generic wrapping machinery here\n * instead of at the call site: consumers get a plain `(fn) => wrappedFn`\n * decorator they can apply to many functions of differing signatures, each of\n * which keeps its own argument and return types.\n *\n * @notInstrumented\n */\nexport const createTranslateRejection =\n <TMatched>({ match, mapTo }: CreateTranslateRejectionParams<TMatched>) =>\n <TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => Promise<TReturn>) =>\n async (...args: TArgs): Promise<TReturn> => {\n try {\n return await fn(...args);\n } catch (error) {\n if (match(error)) {\n throw mapTo(error);\n }\n throw error;\n }\n };\n","/**\n * Exact message prefix of the rejection thrown by\n * `@dynamic-labs-wallet/browser-wallet-client` when the secure container load\n * exhausts all retry attempts. The upstream library throws a plain `Error`\n * with no code, so message matching is the only detection mechanism available;\n * the dependency is pinned to an exact version and the spec pins this string\n * so drift is caught at upgrade time.\n */\nconst UPSTREAM_LOAD_EXHAUSTION_MESSAGE_PREFIX =\n 'Failed to load iframe after all retry attempts';\n\n/**\n * True when `error` is the upstream \"load retry attempts exhausted\" rejection\n * from the embedded (WaaS) wallet's secure container load. Narrows to `Error`\n * so the matched value can be forwarded as a typed error cause without a cast,\n * and guards `instanceof Error` before reading `.message` so a non-`Error`\n * rejection never throws during detection.\n *\n * @notInstrumented\n */\nexport const isWaasLoadExhaustionError = (error: unknown): error is Error =>\n error instanceof Error &&\n error.message.startsWith(UPSTREAM_LOAD_EXHAUSTION_MESSAGE_PREFIX);\n","import {\n type BitcoinConfig,\n type DynamicWalletClient,\n ThresholdSignatureScheme,\n WalletOperation,\n} from '@dynamic-labs-wallet/browser-wallet-client';\nimport { MFAAction, TokenScope } from '@dynamic-labs/sdk-api-core';\n\nimport { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types/DynamicClient';\nimport { InvalidParamError } from '../../../errors/InvalidParamError';\nimport { WaasLoadFailedError } from '../../../errors/WaasLoadFailedError';\nimport { WaasOnboardingIncompleteError } from '../../../errors/WaasOnboardingIncompleteError';\nimport { createTranslateRejection } from '../../../utils/createTranslateRejection';\nimport { getElevatedAccessToken } from '../../auth/getElevatedAccessToken';\nimport type { Chain } from '../../chain';\nimport { consumeMfaTokenIfRequiredForAction } from '../../mfa/consumeMfaTokenIfRequiredForAction';\nimport { getSignedSessionId } from '../../sessionKeys/getSignedSessionId';\nimport { isUserOnboardingComplete } from '../../user/isUserOnboardingComplete';\nimport { createWaasClient } from '../createWaasClient';\nimport { getWaasChainNameFromChain } from '../getWaasChainNameFromChain';\nimport type { WaasProvider } from '../waas.types';\nimport { isWaasLoadExhaustionError } from './isWaasLoadExhaustionError';\n\nconst RAW_MESSAGE_MESSAGE_REQUIRED_LENGTH = 64;\n\ntype CreateWaasProviderParams = {\n chain: Chain;\n sdkClient: DynamicClient;\n};\n\n/** @notInstrumented */\nexport const createWaasProvider = ({\n sdkClient,\n chain,\n}: CreateWaasProviderParams): WaasProvider => {\n const logger = getCore(sdkClient).logger;\n\n let _waasClient: DynamicWalletClient | undefined;\n // The session the cached client was built against. A step-up reauth mints a\n // NEW session (new sessionId + token); see the rebuild guard below.\n let _waasClientSessionId: string | undefined;\n\n // Drops the cached client only when it still points at `client`. Guarding on\n // identity matters because a step-up reauth can mint a new session and rebuild\n // a healthy client (via the session-change reset in getWaasClient) while an\n // older client's initialize()/operation is still failing in flight. Clearing\n // in that case would orphan the healthy replacement, since nothing would\n // release its upstream shared-container reference. _waasClientSessionId is\n // cleared alongside to keep the pair consistent.\n const resetClientIfCurrent = (client: DynamicWalletClient): void => {\n if (_waasClient === client) {\n _waasClient = undefined;\n _waasClientSessionId = undefined;\n }\n };\n\n // because the waas client needs the authToken to be set, we can only create it\n // the first time it's needed, which is after the user has logged in\n const getWaasClient: WaasProvider['getWaasClient'] = async () => {\n // After a step-up reauthentication a new session is minted. In header auth\n // mode (native webview) the iframe has no cookie jar to fall back on, so a\n // client cached against the previous session keeps presenting the stale\n // token — its next backend call (createRooms/users) 401s and trips the\n // iframe's onUnauthorized → forced logout. Drop the cached client when the\n // session changes so it rebuilds + re-initializes with the fresh token and\n // signed session id. Key shares stay in storage (only client auth resets);\n // routine token refresh keeps the same sessionId, so it does not rebuild.\n const currentSessionId = getCore(sdkClient).state.get().user?.sessionId;\n if (_waasClient && currentSessionId !== _waasClientSessionId) {\n _waasClient = undefined;\n }\n\n if (!_waasClient) {\n // Chokepoint: don't build + initialize the iframe client until onboarding\n // is complete. The iframe's init-time room-cache pre-warm fires\n // `createRooms` using the token captured at construction — before any\n // per-operation token resync exists to correct it. Built while the token\n // is still pre-`user:basic` (MFA / KYC / recovery codes / device\n // registration pending), that pre-warm 401s and trips the iframe's\n // onUnauthorized → forced-logout. This is the single gateway to\n // createWaasClient (web and native), so it covers every WaaS caller.\n if (!isUserOnboardingComplete(sdkClient)) {\n throw new WaasOnboardingIncompleteError();\n }\n\n const builtClient = createWaasClient(\n { chainName: getWaasChainNameFromChain(chain) },\n sdkClient\n );\n _waasClient = builtClient;\n _waasClientSessionId = currentSessionId;\n try {\n await builtClient.initialize();\n } catch (error) {\n // A failed load (e.g. iframe retry exhaustion) leaves an unusable,\n // never-initialized client cached. Drop it so the next getWaasClient()\n // rebuilds and re-initializes — the fresh load cycle WaasLoadFailedError\n // documents — instead of returning the dead client for the rest of the\n // session. Identity-guarded (see resetClientIfCurrent).\n resetClientIfCurrent(builtClient);\n throw error;\n }\n }\n // Read the shared var, not the locally-built client: if a concurrent\n // session-change rebuilt a fresh client while this initialize() was pending,\n // the caller should get that current healthy client, not this now-superseded\n // instance built against the old session.\n return _waasClient;\n };\n\n // Runs an operation against an already-fetched client and, if it fails because\n // the container's load was exhausted mid-flight (the client built and\n // initialized fine, then its iframe died — e.g. tab backgrounding, relogin —\n // and its own recovery could not reload), drops the cached client so the next\n // operation rebuilds and re-initializes. This covers the post-initialization\n // path that getWaasClient's own load-failure reset cannot see, so the\n // fresh-load cycle WaasLoadFailedError documents holds for every operation,\n // not just the first load. Identity-guarded (see resetClientIfCurrent).\n const discardClientOnLoadFailure = async <TReturn>({\n waasClient,\n operation,\n }: {\n operation: () => Promise<TReturn>;\n waasClient: DynamicWalletClient;\n }): Promise<TReturn> => {\n try {\n return await operation();\n } catch (error) {\n if (isWaasLoadExhaustionError(error)) {\n resetClientIfCurrent(waasClient);\n }\n throw error;\n }\n };\n\n const backupKeySharesToGoogleDrive: WaasProvider['backupKeySharesToGoogleDrive'] =\n async ({ googleDriveAccessToken, password, walletAccount }) => {\n const { signature: signedSessionId } = await getSignedSessionId(\n sdkClient\n );\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.backupKeySharesToGoogleDrive({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n googleDriveAccessToken,\n password,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const createWalletAccount: WaasProvider['createWalletAccount'] = async (\n args = {}\n ) => {\n logger.debug('[createWaasProvider] createWalletAccount', {\n bitcoinConfig: args.bitcoinConfig,\n thresholdSignatureScheme: args.thresholdSignatureScheme,\n });\n\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const waasClient = await getWaasClient();\n\n const waasWallet = await discardClientOnLoadFailure({\n operation: () =>\n waasClient.createWalletAccount({\n authToken: sdkClient.token ?? undefined,\n bitcoinConfig: args.bitcoinConfig as BitcoinConfig | undefined,\n businessAccountId: args.businessAccountId,\n password: args.password,\n signedSessionId,\n thresholdSignatureScheme:\n args.thresholdSignatureScheme ??\n ThresholdSignatureScheme.TWO_OF_TWO,\n }),\n waasClient,\n });\n\n return waasWallet;\n };\n\n const delegateKeyShares: WaasProvider['delegateKeyShares'] = async ({\n initialSignerRules,\n password,\n walletAccount,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.delegateKeyShares({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n initialSignerRules,\n password,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const exportClientKeyshares: WaasProvider['exportClientKeyshares'] = async ({\n password,\n walletAccount,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const waasClient = await getWaasClient();\n\n await discardClientOnLoadFailure({\n operation: () =>\n waasClient.exportClientKeyshares({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n password,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const exportPrivateKey: WaasProvider['exportPrivateKey'] = async ({\n container,\n displayContainer,\n walletAccount,\n password,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const waasClient = await getWaasClient();\n\n const mfaToken = await consumeMfaTokenIfRequiredForAction(\n { mfaAction: MFAAction.WalletWaasExport },\n sdkClient\n );\n\n // Forward any elevated access token previously obtained via step-up\n // (e.g. requestExternalAuthElevatedToken) so the backend authorizes\n // the export under the wallet:export scope.\n const elevatedAccessToken = getElevatedAccessToken(\n { scope: TokenScope.Walletexport },\n sdkClient\n );\n\n await discardClientOnLoadFailure({\n operation: () =>\n waasClient.exportPrivateKey({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n // Exactly one display surface is forwarded: `container` (a\n // WaasSDKContainer, e.g. a React Native visible WebView) or\n // `displayContainer` (a DOM element, web). The upstream client enforces\n // the \"exactly one\" invariant and renders the key inside the surface's\n // own sandboxed document — it never crosses back to the host.\n container,\n displayContainer,\n elevatedAccessToken,\n mfaToken,\n password,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const restoreUserShareForWalletAccount: WaasProvider['restoreUserShareForWalletAccount'] =\n async ({ walletAccount }) => {\n const { signature: signedSessionId } = await getSignedSessionId(\n sdkClient\n );\n\n const waasClient = await getWaasClient();\n\n await discardClientOnLoadFailure({\n operation: () =>\n waasClient.getWallet({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n signedSessionId,\n walletOperation: WalletOperation.SIGN_MESSAGE,\n }),\n waasClient,\n });\n };\n\n const importPrivateKey: WaasProvider['importPrivateKey'] = async ({\n privateKey,\n thresholdSignatureScheme = ThresholdSignatureScheme.TWO_OF_TWO,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const walletClient = await getWaasClient();\n\n await discardClientOnLoadFailure({\n operation: () =>\n walletClient.importPrivateKey({\n authToken: sdkClient.token ?? undefined,\n privateKey,\n signedSessionId,\n thresholdSignatureScheme,\n }),\n waasClient: walletClient,\n });\n };\n\n const migrateFromFireblocks: WaasProvider['migrateFromFireblocks'] = async ({\n coinTypes,\n deviceId,\n expectedAddresses,\n jwt,\n password,\n storage,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const walletClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n walletClient.migrateFromFireblocks({\n authToken: sdkClient.token ?? undefined,\n fireblocks: {\n deviceId,\n expectedAddresses,\n jwt,\n ncwStorage: storage,\n walletPassword: password,\n ...(coinTypes ? { coinTypes } : {}),\n },\n signedSessionId,\n }),\n waasClient: walletClient,\n });\n };\n\n const refreshWalletAccountShares: WaasProvider['refreshWalletAccountShares'] =\n async ({ password, walletAccount }) => {\n const { signature: signedSessionId } = await getSignedSessionId(\n sdkClient\n );\n\n const walletClient = await getWaasClient();\n\n const mfaToken = await consumeMfaTokenIfRequiredForAction(\n { mfaAction: MFAAction.WalletWaasRefresh },\n sdkClient\n );\n\n return discardClientOnLoadFailure({\n operation: () =>\n walletClient.refreshWalletAccountShares({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n mfaToken,\n password,\n signedSessionId,\n }),\n waasClient: walletClient,\n });\n };\n\n const reshareToNewSignerShareSet: WaasProvider['reshareToNewSignerShareSet'] =\n async ({\n businessAccountId,\n password,\n signerType,\n targetSignerIdentity,\n walletAccount,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(\n sdkClient\n );\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.reshareToNewSignerShareSet({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n businessAccountId,\n password,\n signedSessionId,\n // Public API uses a string union; the client expects the core enum\n // (identical values). Cast at this single boundary.\n signerType: signerType as Parameters<\n typeof waasClient.reshareToNewSignerShareSet\n >[0]['signerType'],\n targetSignerIdentity,\n }),\n waasClient,\n });\n };\n\n const revokeDelegation: WaasProvider['revokeDelegation'] = async ({\n password,\n walletAccount,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.revokeDelegation({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n password,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const setWaasWalletAccountPassword: WaasProvider['setWaasWalletAccountPassword'] =\n async ({ password, walletAccount }) => {\n const { signature: signedSessionId } = await getSignedSessionId(\n sdkClient\n );\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.setPassword({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n newPassword: password,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const signRawMessage: WaasProvider['signRawMessage'] = async ({\n message,\n password,\n walletAccount,\n }) => {\n if (message.length !== RAW_MESSAGE_MESSAGE_REQUIRED_LENGTH) {\n throw new InvalidParamError(\n `Message must be ${RAW_MESSAGE_MESSAGE_REQUIRED_LENGTH} characters long`\n );\n }\n\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const mfaToken = await consumeMfaTokenIfRequiredForAction(\n { mfaAction: MFAAction.WalletWaasSign },\n sdkClient\n );\n\n const elevatedAccessToken = getElevatedAccessToken(\n { scope: TokenScope.Walletsign },\n sdkClient\n );\n\n const walletClient = await getWaasClient();\n\n const signature = await discardClientOnLoadFailure({\n operation: () =>\n walletClient.signRawMessage({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n elevatedAccessToken,\n message,\n mfaToken,\n password,\n signedSessionId,\n }),\n waasClient: walletClient,\n });\n\n return { signature };\n };\n\n const destroy: WaasProvider['destroy'] = async (args) => {\n if (!_waasClient) {\n return;\n }\n\n const waasClient = await getWaasClient();\n // When a session token expires, we preserve key shares in storage instead\n // of clearing them. Customers with short-lived sessions (minutes) were\n // hitting excessive server-side share recovery on every re-login, which\n // also forced users to re-enter their wallet password since the unlocked\n // share only lives for the duration of the session.\n //\n // This is safe because the waas-sdk separately fingerprints the user\n // (sub + environment_id) and clears all storage if a different user logs\n // in. On explicit user-initiated logout, shares are always cleared for\n // security.\n if (args?.reason !== 'token-expired') {\n await waasClient.cleanup();\n }\n _waasClient = undefined;\n };\n\n const updatePassword: WaasProvider['updatePassword'] = async ({\n walletAccount,\n currentPassword,\n newPassword,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.updatePassword({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n existingPassword: currentPassword,\n newPassword,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const signMessage: WaasProvider['signMessage'] = async ({\n message,\n walletAccount,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const mfaToken = await consumeMfaTokenIfRequiredForAction(\n { mfaAction: MFAAction.WalletWaasSign },\n sdkClient\n );\n\n const elevatedAccessToken = getElevatedAccessToken(\n { scope: TokenScope.Walletsign },\n sdkClient\n );\n\n const waasClient = await getWaasClient();\n\n const signature = await discardClientOnLoadFailure({\n operation: () =>\n waasClient.signMessage({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n elevatedAccessToken,\n message,\n mfaToken,\n signedSessionId,\n }),\n waasClient,\n });\n\n return { signature };\n };\n\n const signSerializedTransaction: WaasProvider['signSerializedTransaction'] =\n async ({ chainId, serializedTransaction, walletAccount }) => {\n const { signature: signedSessionId } = await getSignedSessionId(\n sdkClient\n );\n\n const mfaToken = await consumeMfaTokenIfRequiredForAction(\n { mfaAction: MFAAction.WalletWaasSign },\n sdkClient\n );\n\n const elevatedAccessToken = getElevatedAccessToken(\n { scope: TokenScope.Walletsign },\n sdkClient\n );\n\n const waasClient = await getWaasClient();\n\n const signature = await discardClientOnLoadFailure({\n operation: () =>\n waasClient.signTransaction({\n authToken: sdkClient.token ?? undefined,\n chainId,\n elevatedAccessToken,\n mfaToken,\n senderAddress: walletAccount.address,\n signedSessionId,\n transaction: serializedTransaction,\n }),\n waasClient,\n });\n\n return { signature };\n };\n\n const getWalletRecoveryState: WaasProvider['getWalletRecoveryState'] =\n async ({ walletAccount }) => {\n const { signature: signedSessionId } = await getSignedSessionId(\n sdkClient\n );\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.getWalletRecoveryState({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n const unlockWallet: WaasProvider['unlockWallet'] = async ({\n password,\n walletAccount,\n }) => {\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const waasClient = await getWaasClient();\n\n return discardClientOnLoadFailure({\n operation: () =>\n waasClient.unlockWallet({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n password,\n signedSessionId,\n }),\n waasClient,\n });\n };\n\n // Every operation is wrapped so an exhausted container load surfaces as a\n // typed WaasLoadFailedError no matter which call triggers it — the initial\n // load or a mid-operation recovery. Wrapped at the operation itself (rather\n // than a separate whole-provider pass) so the translation is visible right\n // where the provider is assembled.\n const translateLoadFailure = createTranslateRejection({\n mapTo: (error) => new WaasLoadFailedError({ cause: error }),\n match: isWaasLoadExhaustionError,\n });\n\n const provider: WaasProvider = {\n backupKeySharesToGoogleDrive: translateLoadFailure(\n backupKeySharesToGoogleDrive\n ),\n createWalletAccount: translateLoadFailure(createWalletAccount),\n delegateKeyShares: translateLoadFailure(delegateKeyShares),\n destroy: translateLoadFailure(destroy),\n exportClientKeyshares: translateLoadFailure(exportClientKeyshares),\n exportPrivateKey: translateLoadFailure(exportPrivateKey),\n getWaasClient: translateLoadFailure(getWaasClient),\n getWalletRecoveryState: translateLoadFailure(getWalletRecoveryState),\n importPrivateKey: translateLoadFailure(importPrivateKey),\n migrateFromFireblocks: translateLoadFailure(migrateFromFireblocks),\n refreshWalletAccountShares: translateLoadFailure(\n refreshWalletAccountShares\n ),\n reshareToNewSignerShareSet: translateLoadFailure(\n reshareToNewSignerShareSet\n ),\n restoreUserShareForWalletAccount: translateLoadFailure(\n restoreUserShareForWalletAccount\n ),\n revokeDelegation: translateLoadFailure(revokeDelegation),\n setWaasWalletAccountPassword: translateLoadFailure(\n setWaasWalletAccountPassword\n ),\n signMessage: translateLoadFailure(signMessage),\n signRawMessage: translateLoadFailure(signRawMessage),\n signSerializedTransaction: translateLoadFailure(signSerializedTransaction),\n unlockWallet: translateLoadFailure(unlockWallet),\n updatePassword: translateLoadFailure(updatePassword),\n };\n\n return provider;\n};\n","import type { WaasSDKContainer } from '@dynamic-labs-wallet/core';\n\nimport type { DynamicClient } from '../../../client/types/DynamicClient';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { getWaasWalletProviderFromWalletAccount } from '../getWaasWalletProviderFromWalletAccount';\n\ntype ExportWaasPrivateKeyToContainerParams = {\n container: WaasSDKContainer;\n password?: string;\n walletAccount: WalletAccount;\n};\n\n/**\n * Exports the private key for a WaaS wallet account into a caller-provided\n * {@link WaasSDKContainer} (e.g. a visible React Native WebView) instead of a\n * DOM element.\n *\n * This is the container-based counterpart to `exportWaasPrivateKey` (which\n * injects an iframe into a DOM `displayContainer` on web). The export ceremony\n * runs — and the private key is rendered — entirely inside the container's own\n * sandboxed document; the key is never exposed to the host JS layer. The caller\n * owns the container's lifecycle and must call `container.destroy()` when the\n * display is dismissed.\n *\n * @param params.walletAccount - The WaaS wallet account to export the private key from.\n * @param params.container - The container that hosts the secure key display.\n * @param [params.password] - Optional password to decrypt the private key.\n * @param client - The Dynamic client instance. This is an internal API (exposed\n * only via `@dynamic-labs-sdk/client/waas/core`), so the client is passed\n * explicitly rather than defaulted — callers resolve it (e.g. via\n * `getDefaultClient()`) and thread it in.\n * @returns A promise that resolves when the private key export is complete.\n * @notInstrumented\n */\nexport const exportWaasPrivateKeyToContainer = async (\n { container, password, walletAccount }: ExportWaasPrivateKeyToContainerParams,\n client: DynamicClient\n) => {\n const provider = getWaasWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n return provider.exportPrivateKey({\n container,\n password,\n walletAccount,\n });\n};\n","import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../client/types';\nimport { getChainFromVerifiedCredentialChain } from '../../../utils/getChainFromVerifiedCredentialChain';\nimport type { Chain } from '../../chain';\nimport { DYNAMIC_WAAS_METADATA } from '../constants';\n\ntype GetAllUserWaasAddressesForChainParams = {\n chain: Chain;\n};\n\n/** @notInstrumented */\nexport const getAllUserWaasAddressesForChain = (\n { chain }: GetAllUserWaasAddressesForChainParams,\n client: DynamicClient\n): string[] => {\n if (!client.user) {\n return [];\n }\n\n const waasWalletCredentials =\n client.user.verifiedCredentials.filter(\n (credential) =>\n credential.walletProvider === WalletProviderEnum.EmbeddedWallet &&\n credential.walletName\n ?.toLowerCase()\n .startsWith(DYNAMIC_WAAS_METADATA.normalizedWalletName) &&\n credential.address &&\n credential.chain &&\n getChainFromVerifiedCredentialChain(credential.chain) === chain\n ) ?? [];\n\n const waasAddresses: string[] = waasWalletCredentials.map(\n // casting because we're already filtering out credentials without an address\n (credential) => credential.address as string\n );\n\n return waasAddresses;\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport type {\n BitcoinNetwork,\n DynamicWalletClient,\n MigrateFromFireblocksResponse,\n ThresholdSignatureScheme,\n} from '@dynamic-labs-wallet/browser-wallet-client';\nexport type { WaasSDKContainer } from '@dynamic-labs-wallet/core';\nexport { DYNAMIC_WAAS_METADATA } from '../modules/waas/constants';\nexport { createWaasClient } from '../modules/waas/createWaasClient';\nexport { createWaasProvider } from '../modules/waas/createWaasProvider';\nexport { exportWaasPrivateKeyToContainer } from '../modules/waas/exportWaasPrivateKeyToContainer';\nexport { getAllUserWaasAddressesForChain } from '../modules/waas/getAllUserWaasAddressesForChain';\nexport { getWaasChainNameFromChain } from '../modules/waas/getWaasChainNameFromChain';\nexport { migrateFromFireblocks } from '../modules/waas/migrateFromFireblocks';\nexport { preconnectWaasIframe } from '../modules/waas/preconnectWaasIframe';\nexport type {\n WaasProvider,\n WaasWalletProvider,\n} from '../modules/waas/waas.types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,4BACA,EAAE,OAAO,aACe,OACnC,OAAO,GAAG,SAAkC;AAC1C,KAAI;AACF,SAAO,MAAM,GAAG,GAAG,KAAK;UACjB,OAAO;AACd,MAAI,MAAM,MAAM,CACd,OAAM,MAAM,MAAM;AAEpB,QAAM;;;;;;;;;;;;;;AC9BZ,MAAM,0CACJ;;;;;;;;;;AAWF,MAAa,6BAA6B,UACxC,iBAAiB,SACjB,MAAM,QAAQ,WAAW,wCAAwC;;;;ACEnE,MAAM,sCAAsC;;AAQ5C,MAAa,sBAAsB,EACjC,WACA,YAC4C;CAC5C,MAAM,SAASA,6CAAQ,UAAU,CAAC;CAElC,IAAIC;CAGJ,IAAIC;CASJ,MAAM,wBAAwB,WAAsC;AAClE,MAAI,gBAAgB,QAAQ;AAC1B,iBAAc;AACd,0BAAuB;;;CAM3B,MAAMC,gBAA+C,YAAY;EAS/D,MAAM,mBAAmBH,6CAAQ,UAAU,CAAC,MAAM,KAAK,CAAC,MAAM;AAC9D,MAAI,eAAe,qBAAqB,qBACtC,eAAc;AAGhB,MAAI,CAAC,aAAa;AAShB,OAAI,CAACI,0DAAyB,UAAU,CACtC,OAAM,IAAIC,gEAA+B;GAG3C,MAAM,cAAcC,+CAClB,EAAE,WAAWC,wDAA0B,MAAM,EAAE,EAC/C,UACD;AACD,iBAAc;AACd,0BAAuB;AACvB,OAAI;AACF,UAAM,YAAY,YAAY;YACvB,OAAO;AAMd,yBAAqB,YAAY;AACjC,UAAM;;;AAOV,SAAO;;CAWT,MAAM,6BAA6B,OAAgB,EACjD,YACA,gBAIsB;AACtB,MAAI;AACF,UAAO,MAAM,WAAW;WACjB,OAAO;AACd,OAAI,0BAA0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