@dynamic-labs-sdk/wallet-connect 0.23.3 → 0.24.1

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.
@@ -2,7 +2,7 @@ import { BaseError } from "@dynamic-labs-sdk/client";
2
2
 
3
3
  //#region package.json
4
4
  var name = "@dynamic-labs-sdk/wallet-connect";
5
- var version = "0.23.3";
5
+ var version = "0.24.1";
6
6
 
7
7
  //#endregion
8
8
  //#region src/errors/SessionClosedUnexpectedlyError.ts
@@ -20,4 +20,4 @@ var SessionClosedUnexpectedlyError = class extends BaseError {
20
20
 
21
21
  //#endregion
22
22
  export { name as n, version as r, SessionClosedUnexpectedlyError as t };
23
- //# sourceMappingURL=SessionClosedUnexpectedlyError-yC5QgGik.esm.js.map
23
+ //# sourceMappingURL=SessionClosedUnexpectedlyError-B20TMr3W.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SessionClosedUnexpectedlyError-yC5QgGik.esm.js","names":[],"sources":["../package.json","../src/errors/SessionClosedUnexpectedlyError.ts"],"sourcesContent":["","import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype SessionClosedUnexpectedlyErrorParams = {\n /**\n * The topic of the session that closed unexpectedly.\n */\n sessionTopic: string;\n\n /**\n * The display name of the wallet that was associated with the session that closed unexpectedly.\n */\n walletDisplayName: string | null | undefined;\n};\n\nexport class SessionClosedUnexpectedlyError extends BaseError {\n constructor({\n sessionTopic,\n walletDisplayName,\n }: SessionClosedUnexpectedlyErrorParams) {\n super({\n cause: null,\n code: 'session_closed_unexpectedly_error',\n docsUrl: null,\n name: 'SessionClosedUnexpectedlyError',\n shortMessage: walletDisplayName\n ? `WalletConnect session ${sessionTopic} closed unexpectedly. Associated wallet was ${walletDisplayName}`\n : `WalletConnect session ${sessionTopic} closed unexpectedly`,\n });\n }\n}\n"],"mappings":";;;;;;;;ACcA,IAAa,iCAAb,cAAoD,UAAU;CAC5D,YAAY,EACV,cACA,qBACuC;AACvC,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,oBACV,yBAAyB,aAAa,8CAA8C,sBACpF,yBAAyB,aAAa;GAC3C,CAAC"}
1
+ {"version":3,"file":"SessionClosedUnexpectedlyError-B20TMr3W.esm.js","names":[],"sources":["../package.json","../src/errors/SessionClosedUnexpectedlyError.ts"],"sourcesContent":["","import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype SessionClosedUnexpectedlyErrorParams = {\n /**\n * The topic of the session that closed unexpectedly.\n */\n sessionTopic: string;\n\n /**\n * The display name of the wallet that was associated with the session that closed unexpectedly.\n */\n walletDisplayName: string | null | undefined;\n};\n\nexport class SessionClosedUnexpectedlyError extends BaseError {\n constructor({\n sessionTopic,\n walletDisplayName,\n }: SessionClosedUnexpectedlyErrorParams) {\n super({\n cause: null,\n code: 'session_closed_unexpectedly_error',\n docsUrl: null,\n name: 'SessionClosedUnexpectedlyError',\n shortMessage: walletDisplayName\n ? `WalletConnect session ${sessionTopic} closed unexpectedly. Associated wallet was ${walletDisplayName}`\n : `WalletConnect session ${sessionTopic} closed unexpectedly`,\n });\n }\n}\n"],"mappings":";;;;;;;;ACcA,IAAa,iCAAb,cAAoD,UAAU;CAC5D,YAAY,EACV,cACA,qBACuC;AACvC,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,oBACV,yBAAyB,aAAa,8CAA8C,sBACpF,yBAAyB,aAAa;GAC3C,CAAC"}
@@ -3,7 +3,7 @@ let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
3
3
 
4
4
  //#region package.json
5
5
  var name = "@dynamic-labs-sdk/wallet-connect";
6
- var version = "0.23.3";
6
+ var version = "0.24.1";
7
7
 
8
8
  //#endregion
9
9
  //#region src/errors/SessionClosedUnexpectedlyError.ts
@@ -38,4 +38,4 @@ Object.defineProperty(exports, 'version', {
38
38
  return version;
39
39
  }
40
40
  });
41
- //# sourceMappingURL=SessionClosedUnexpectedlyError-CXziI2_f.cjs.js.map
41
+ //# sourceMappingURL=SessionClosedUnexpectedlyError-DImFYi-T.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SessionClosedUnexpectedlyError-CXziI2_f.cjs.js","names":["BaseError"],"sources":["../package.json","../src/errors/SessionClosedUnexpectedlyError.ts"],"sourcesContent":["","import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype SessionClosedUnexpectedlyErrorParams = {\n /**\n * The topic of the session that closed unexpectedly.\n */\n sessionTopic: string;\n\n /**\n * The display name of the wallet that was associated with the session that closed unexpectedly.\n */\n walletDisplayName: string | null | undefined;\n};\n\nexport class SessionClosedUnexpectedlyError extends BaseError {\n constructor({\n sessionTopic,\n walletDisplayName,\n }: SessionClosedUnexpectedlyErrorParams) {\n super({\n cause: null,\n code: 'session_closed_unexpectedly_error',\n docsUrl: null,\n name: 'SessionClosedUnexpectedlyError',\n shortMessage: walletDisplayName\n ? `WalletConnect session ${sessionTopic} closed unexpectedly. Associated wallet was ${walletDisplayName}`\n : `WalletConnect session ${sessionTopic} closed unexpectedly`,\n });\n }\n}\n"],"mappings":";;;;;;;;;ACcA,IAAa,iCAAb,cAAoDA,mCAAU;CAC5D,YAAY,EACV,cACA,qBACuC;AACvC,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,oBACV,yBAAyB,aAAa,8CAA8C,sBACpF,yBAAyB,aAAa;GAC3C,CAAC"}
1
+ {"version":3,"file":"SessionClosedUnexpectedlyError-DImFYi-T.cjs.js","names":["BaseError"],"sources":["../package.json","../src/errors/SessionClosedUnexpectedlyError.ts"],"sourcesContent":["","import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype SessionClosedUnexpectedlyErrorParams = {\n /**\n * The topic of the session that closed unexpectedly.\n */\n sessionTopic: string;\n\n /**\n * The display name of the wallet that was associated with the session that closed unexpectedly.\n */\n walletDisplayName: string | null | undefined;\n};\n\nexport class SessionClosedUnexpectedlyError extends BaseError {\n constructor({\n sessionTopic,\n walletDisplayName,\n }: SessionClosedUnexpectedlyErrorParams) {\n super({\n cause: null,\n code: 'session_closed_unexpectedly_error',\n docsUrl: null,\n name: 'SessionClosedUnexpectedlyError',\n shortMessage: walletDisplayName\n ? `WalletConnect session ${sessionTopic} closed unexpectedly. Associated wallet was ${walletDisplayName}`\n : `WalletConnect session ${sessionTopic} closed unexpectedly`,\n });\n }\n}\n"],"mappings":";;;;;;;;;ACcA,IAAa,iCAAb,cAAoDA,mCAAU;CAC5D,YAAY,EACV,cACA,qBACuC;AACvC,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,oBACV,yBAAyB,aAAa,8CAA8C,sBACpF,yBAAyB,aAAa;GAC3C,CAAC"}
package/dist/core.cjs.js CHANGED
@@ -25,7 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  }) : target, mod));
26
26
 
27
27
  //#endregion
28
- const require_SessionClosedUnexpectedlyError = require('./SessionClosedUnexpectedlyError-CXziI2_f.cjs.js');
28
+ const require_SessionClosedUnexpectedlyError = require('./SessionClosedUnexpectedlyError-DImFYi-T.cjs.js');
29
29
  let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
30
30
  let _walletconnect_utils = require("@walletconnect/utils");
31
31
  let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
@@ -1 +1 @@
1
- {"version":3,"file":"core.cjs.js","names":["WalletProviderPriority","unverifiedWalletAccounts: {\n isNew: boolean;\n walletAccount: WalletAccount;\n }[]","verifiedCredentialIdToWalletProviderKeyMap: Record<string, string>","lastResponse: VerifyResponse | undefined","WalletProviderEnum","walletAccounts","SignClient","name","version"],"sources":["../src/splitCaip10Token/splitCaip10Token.ts","../src/createWalletConnectSessionEventEmitter/createWalletConnectSessionEventEmitter.ts","../src/createWalletAccountsForWalletConnectWalletProvider/createWalletAccountsForWalletConnectWalletProvider.ts","../src/importWalletConnectSession/importWalletConnectSession.ts","../src/importWalletConnectAuthResponse/verifyWalletConnectAuths/verifyWalletConnectAuths.ts","../src/importWalletConnectAuthResponse/importWalletConnectAuthResponse.ts","../src/signClient/getSignClient/createSignClient/createSignClient.ts","../src/signClient/getSignClient/getSignClient.ts","../src/exports/core.ts"],"sourcesContent":["/**\n * An account in WalletConnect follows the CAIP-10 standard\n * and is formatted as follows:\n *\n * `<namespace>:<chain>:<address>`\n *\n * Where:\n * - `<namespace>` is the namespace key (e.g. \"eip155\")\n * - `<chain>` is what we refer to as a network ID (e.g. \"1\")\n * - `<address>` is the address of the account (e.g. \"0x1234567890\")\n *\n * See docs: https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md\n *\n * @returns An object with the address, namespace key, and network id\n * @not-instrumented\n */\nexport const splitCaip10Token = (caip10Token: string) => {\n const [namespaceKey, networkId, address] = caip10Token.split(':');\n return { address, namespaceKey, networkId };\n};\n","import {\n createWalletProviderEventEmitter,\n filterDuplicates,\n} from '@dynamic-labs-sdk/client/core';\nimport type SignClient from '@walletconnect/sign-client';\nimport type { SessionTypes } from '@walletconnect/types';\n\nimport { splitCaip10Token } from '../splitCaip10Token';\n\ntype CreateWalletConnectSessionEventEmitterParams = {\n /**\n * Optional function to format addresses. If not provided, addresses are used as-is.\n */\n formatAddress?: (address: string) => string;\n getSession: () => SessionTypes.Struct;\n namespaceKey: string;\n sessionTopic: string;\n signClient: SignClient;\n};\n\ntype SessionEventPayload = {\n params: {\n event: {\n data: unknown;\n name: string;\n };\n };\n topic: string;\n};\n\n/**\n * Creates a WalletConnect session event emitter with common event handling logic.\n *\n * Handles chainChanged, accountsChanged, and disconnected events from WalletConnect sessions.\n *\n * @param params.getSession - Function to get the current session\n * @param params.namespaceKey - The WalletConnect namespace key (e.g., 'eip155', 'solana')\n * @param params.sessionTopic - The session topic to listen for events\n * @param params.signClient - The WalletConnect sign client instance\n * @param params.formatAddress - Optional function to format addresses (e.g., EIP-55 for EVM)\n * @returns An object with cleanupEventEmitter and getEventEmitter functions\n * @not-instrumented\n */\nexport const createWalletConnectSessionEventEmitter = ({\n formatAddress,\n getSession,\n namespaceKey,\n sessionTopic,\n signClient,\n}: CreateWalletConnectSessionEventEmitterParams) => {\n return createWalletProviderEventEmitter<(event: SessionEventPayload) => void>(\n {\n removeEventListeners: ({ setupReturnValue: handleSessionEvent }) => {\n signClient.off('session_event', handleSessionEvent);\n },\n\n setupEventListeners: ({\n handleAccountsChanged,\n handleDisconnected,\n handleNetworkChanged,\n }) => {\n const handleSessionEvent = ({\n params: { event },\n topic,\n }: SessionEventPayload) => {\n if (topic !== sessionTopic) {\n return;\n }\n\n if (event.name === 'chainChanged') {\n const networkParam = event.data as string;\n\n // Handle potentially CAIP-2 format\n const networkId = networkParam.startsWith(`${namespaceKey}:`)\n ? networkParam.split(':')[1]\n : networkParam;\n\n handleNetworkChanged({ networkId });\n\n return;\n }\n\n if (event.name === 'accountsChanged') {\n const accountsParam = event.data as string[];\n\n const addresses = filterDuplicates(\n accountsParam.map((account) => {\n // Handle potentially CAIP-10 format\n if (account.startsWith(`${namespaceKey}:`)) {\n return splitCaip10Token(account).address;\n }\n\n return account;\n })\n ).map((address) =>\n formatAddress ? formatAddress(address) : address\n );\n\n handleAccountsChanged({ addresses });\n\n return;\n }\n\n if (event.name === 'disconnected') {\n handleDisconnected();\n\n return;\n }\n };\n\n // Assert the session is still valid\n getSession();\n\n signClient.on('session_event', handleSessionEvent);\n\n return handleSessionEvent;\n },\n }\n );\n};\n","import { type WalletAccount } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n filterDuplicates,\n formatWalletAccountId,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { WalletConnectWalletProvider } from '../walletConnectWalletProvider.types';\nimport { splitCaip10Token } from '../splitCaip10Token';\n\ntype CreateWalletAccountsForWalletConnectWalletProviderParams = {\n walletProvider: WalletConnectWalletProvider;\n};\n\n/** @not-instrumented */\nexport const createWalletAccountsForWalletConnectWalletProvider = ({\n walletProvider,\n}: CreateWalletAccountsForWalletConnectWalletProviderParams): WalletAccount[] => {\n /**\n * Since each session can have multiple namespaces, we need to find the namespace\n * that corresponds to this specific wallet provider.\n *\n * A WalletConnect namespace is the equivalent of what we refer to as a chain in the SDK,\n * and they have attributed to them the methods, events and networks that are expected\n * to be supported by the wallet application, as well as which accounts are connected.\n */\n const session = walletProvider.getSession();\n\n const namespace = session.namespaces[walletProvider.namespaceKey];\n\n assertDefined(\n namespace,\n `Namespace key ${walletProvider.namespaceKey} of wallet provider ${walletProvider.key} not found in its session ${session.topic}`\n );\n\n const accountAddresses = filterDuplicates(\n namespace.accounts.map((account) => splitCaip10Token(account).address)\n );\n\n const formatAddress =\n walletProvider.formatWalletAddress ?? (({ address }) => address);\n\n return accountAddresses.map((address) => ({\n address: formatAddress({ address }),\n chain: walletProvider.chain,\n id: formatWalletAccountId({\n address,\n chain: walletProvider.chain,\n walletProviderKey: walletProvider.key,\n }),\n lastSelectedAt: null,\n verifiedCredentialId: null,\n walletProviderKey: walletProvider.key,\n }));\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n type WalletAccount,\n getWalletAccounts,\n} from '@dynamic-labs-sdk/client';\nimport {\n WalletProviderPriority,\n createVisit,\n emitWalletAccountsChangedEvent,\n getWalletProviderRegistry,\n setUnverifiedWalletAccounts,\n updateWalletProviderKeysForVerifiedCredentials,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\nimport { createWalletAccountsForWalletConnectWalletProvider } from '../createWalletAccountsForWalletConnectWalletProvider';\n\ntype ImportWalletConnectSessionParams = {\n /**\n * Whether this session's wallet accounts should be added to the dynamic's wallet accounts.\n */\n addToDynamicWalletAccounts?: boolean;\n\n /**\n * The session topic of the WalletConnect session.\n */\n sessionTopic: string;\n\n /**\n * The function that builds the wallet provider for the session.\n */\n walletProviderBuilder: WalletProviderBuilder;\n};\n\n/**\n * This is a lower level function that is used to connect a WalletConnect session to the Dynamic SDK.\n * It will generate the wallet providers and wallet accounts for all accounts in the session.\n *\n * @param sessionTopic - The session topic of the WalletConnect session.\n * @param addToDynamicWalletAccounts - Whether to add the wallet accounts to the dynamic's wallet accounts.\n * @param client - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The wallet accounts.\n * @not-instrumented\n */\nexport const importWalletConnectSession = async (\n {\n addToDynamicWalletAccounts = true,\n sessionTopic,\n walletProviderBuilder,\n }: ImportWalletConnectSessionParams,\n client: DynamicClient\n): Promise<{ walletAccounts: WalletAccount[] }> => {\n /**\n * You would normally get the session from the signClient.connect method. It takes the optionalNamespaces as an argument.\n *\n * Each chain should build its own \"connectWithWalletConnect<chain-name>\" function.\n * Understand how to build the optionalNamespaces object:\n *\n * The namespace configurations are used at the time a wallet application receives the connection URI.\n * It will use the configurations we supply to understand which methods, events and networks it should provide.\n *\n * The wallet application will then accept the connection request and, in the session`object, provide its own namespace object\n * in return, which will contain the methods, events and networks it does in fact support, as well as\n * which accounts are available.\n *\n * WalletConnect expects namespaces defined in the following format:\n * ```typescript\n * {\n * <namespaceKey>: {\n * \"accounts\": [\"<account1>\", \"<account2>\", \"<account3>\", ...],\n * \"events\": [\"accountsChanged\", \"chainChanged\", \"disconnected\"],\n * \"methods\": [\"personal_sign\", \"eth_sendTransaction\", \"eth_accounts\", ...],\n * \"chains\": [\"<chain1>\", \"<chain2>\", \"<chain3>\", ...]\n * },\n * ...\n * }\n * ```\n *\n * Where each account is a CAIP-10 formatted string, for example: \"eip155:1:0x1234567890\"\n * — see docs: https://chainagnostic.org/CAIPs/caip-10\n *\n * Where each chain is a CAIP-2 formatted string, for example: \"eip155:1\"\n * — see docs: https://chainagnostic.org/CAIPs/caip-2\n */\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n const walletProvider = await walletProviderBuilder({ sessionTopic }, client);\n\n walletProviderRegistry.register({\n priority: WalletProviderPriority.WALLET_SDK,\n walletProvider,\n });\n\n const walletAccounts = createWalletAccountsForWalletConnectWalletProvider({\n walletProvider,\n });\n\n const existingWalletAccounts = getWalletAccounts(client);\n\n /**\n * Keep track of which of the new wallet accounts are unverified to add later.\n */\n const unverifiedWalletAccounts: {\n isNew: boolean;\n walletAccount: WalletAccount;\n }[] = [];\n\n let walletAccountsChanged = false;\n\n /**\n * For all verified wallet accounts that are tied to this session, we need to update\n * the map of verified credential to wallet provider key\n */\n const verifiedCredentialIdToWalletProviderKeyMap: Record<string, string> = {};\n\n walletAccounts.forEach((walletAccount) => {\n const matchingWalletAccount = existingWalletAccounts.find(\n (existingWalletAccount) => existingWalletAccount.id === walletAccount.id\n );\n\n const matchingVerifiedCredentialId =\n matchingWalletAccount?.verifiedCredentialId;\n\n if (!matchingVerifiedCredentialId) {\n unverifiedWalletAccounts.push({\n isNew: !matchingWalletAccount,\n walletAccount,\n });\n } else {\n // This ensures later calls to getWalletAccounts will reconstruct the wallet accounts with\n // the correct wallet provider key\n verifiedCredentialIdToWalletProviderKeyMap[matchingVerifiedCredentialId] =\n walletProvider.key;\n\n // This ensures the wallet accounts returned by this function have the correct verified credential id\n walletAccount.verifiedCredentialId = matchingVerifiedCredentialId;\n }\n });\n\n if (Object.keys(verifiedCredentialIdToWalletProviderKeyMap).length > 0) {\n updateWalletProviderKeysForVerifiedCredentials(\n { keysToUpdate: verifiedCredentialIdToWalletProviderKeyMap },\n client\n );\n\n walletAccountsChanged = true;\n }\n\n if (addToDynamicWalletAccounts && unverifiedWalletAccounts.length > 0) {\n walletAccountsChanged = true;\n\n const unverifiedWalletAccountsToUpdate = unverifiedWalletAccounts.map(\n ({ walletAccount }) => walletAccount\n );\n\n setUnverifiedWalletAccounts({ unverifiedWalletAccountsToUpdate }, client);\n\n const newWalletAccounts = unverifiedWalletAccounts\n .filter(({ isNew }) => isNew)\n .map(({ walletAccount }) => walletAccount);\n\n for (const walletAccount of newWalletAccounts) {\n void createVisit({ walletAccount }, client);\n }\n }\n\n if (walletAccountsChanged) {\n emitWalletAccountsChangedEvent(client);\n }\n\n return { walletAccounts };\n};\n","import type {\n Chain,\n DynamicClient,\n VerifyResponse,\n} from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n updateAuthFromVerifyResponse,\n verifyMessageSignatureOwnership,\n} from '@dynamic-labs-sdk/client/core';\nimport { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\nimport type { AuthTypes } from '@walletconnect/types';\nimport { formatMessage } from '@walletconnect/utils';\n\nconst getAddressFromIss = (iss: string) => iss.split(':')[4];\n\ntype VerifyWalletConnectAuthsParams = {\n auths: AuthTypes.Cacao[];\n chain: Chain;\n walletDisplayName: string;\n};\n\n/** @not-instrumented */\n// eslint-disable-next-line custom-rules/one-function-per-file\nexport const verifyWalletConnectAuths = async (\n { auths, chain, walletDisplayName }: VerifyWalletConnectAuthsParams,\n client: DynamicClient\n) => {\n /**\n * The only differences between each auth object will be the signature (auth.s.s)\n * and the iss (auth.p.iss).\n *\n * The iss is comprised of 2 WC fields that are irrelevant to us and then the CAIP-10 token\n * of the address, where the first 2 fields are also split by the \":\" character.\n *\n * Usually, there will be multiple auths if the wallet app bundles signatures for multiple\n * networks at once, so the only field that will change among auth iss will be the networkId under iss.\n *\n * Docs on Cacao: https://chainagnostic.org/CAIPs/caip-74\n */\n const visitedAddresses = new Set<string>();\n\n const authsFilteredByAddress = auths.filter((auth) => {\n const address = getAddressFromIss(auth.p.iss);\n\n if (!address || visitedAddresses.has(address)) {\n return false;\n }\n\n visitedAddresses.add(address);\n\n return true;\n });\n\n let lastResponse: VerifyResponse | undefined = undefined;\n\n /**\n * WalletConnect's auth object is what they call a \"Cacao\" object, with data on the SIWE message\n * and the signature itself.\n * By consulting how they implemented their \"validateSignedCacao\" function,\n * we are able to reconstruct the original message which can be used to verify the signature\n * in our backend.\n */\n for (const auth of authsFilteredByAddress) {\n const publicWalletAddress = getAddressFromIss(auth.p.iss);\n\n assertDefined(\n publicWalletAddress,\n `Unable to get public wallet address from WalletConnect Cacao object iss: ${auth.p.iss}`\n );\n\n const messageToSign = formatMessage(auth.p, auth.p.iss);\n\n const signature = auth.s.s;\n\n lastResponse = await verifyMessageSignatureOwnership(\n {\n chain,\n messageToSign,\n signature,\n walletAddress: publicWalletAddress,\n walletDisplayName,\n walletProviderType: WalletProviderEnum.WalletConnect,\n },\n client\n );\n }\n\n if (!lastResponse) {\n return;\n }\n\n /**\n * Adds the user with the new wallet verified credentials\n * This will add the new verified wallet accounts to the client`s state\n */\n updateAuthFromVerifyResponse({ response: lastResponse }, client);\n};\n","import type { Chain, DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n type WalletAccount,\n verifyWalletAccount,\n} from '@dynamic-labs-sdk/client';\nimport type { AuthTypes } from '@walletconnect/types';\n\nimport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\nimport { importWalletConnectSession } from '../importWalletConnectSession';\nimport { verifyWalletConnectAuths } from './verifyWalletConnectAuths';\n\ntype ImportWalletConnectAuthResponseParams = {\n /**\n * The response from the WalletConnect authenticate method.\n */\n authResponse: AuthTypes.AuthenticateResponseResult;\n\n /**\n * The chain with which the wallet account is associated.\n */\n chain: Chain;\n\n /**\n * The function that builds the wallet provider for the session.\n */\n walletProviderBuilder: WalletProviderBuilder;\n};\n\n/**\n * A low level function that is used to connect a WalletConnect authenticate response to the Dynamic SDK.\n * It will generate the wallet providers and wallet accounts for all accounts in the session.\n *\n * @see WalletConnect's docs on [session authentication](https://docs.reown.com/advanced/api/sign/dapp-usage#session-authenticate-with-recaps)\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the connected and verified wallet account.\n * @not-instrumented\n */\nexport const importWalletConnectAuthResponse = async (\n {\n authResponse,\n chain,\n walletProviderBuilder,\n }: ImportWalletConnectAuthResponseParams,\n client: DynamicClient\n): Promise<{ walletAccounts: WalletAccount[] }> => {\n const { session, auths } = authResponse;\n\n /**\n * Some wallets do not support WC's authenticate method (such as Rainbow).\n * For these wallets, the authenticate method will act as a regular connect method.\n * Therefore we must call verify individually.\n */\n if (!auths || auths.length === 0) {\n const { walletAccounts } = await importWalletConnectSession(\n {\n /**\n * Don't add the wallet accounts to the dynamic's wallet accounts while we are still verifying them.\n */\n addToDynamicWalletAccounts: false,\n sessionTopic: session.topic,\n walletProviderBuilder,\n },\n client\n );\n\n // This should not be concurrent because the first will be a verify and the rest will be a link\n for (const walletAccount of walletAccounts) {\n await verifyWalletAccount({ walletAccount }, client);\n }\n\n return { walletAccounts };\n }\n\n /**\n * This reconstructs the message that was signed by the wallet and verifies the signature\n * in the backend. It will update the user with the new verified credentials.\n */\n await verifyWalletConnectAuths(\n {\n auths,\n chain,\n walletDisplayName: session.peer.metadata.name,\n },\n client\n );\n\n const { walletAccounts } = await importWalletConnectSession(\n {\n addToDynamicWalletAccounts: true,\n sessionTopic: session.topic,\n walletProviderBuilder,\n },\n client\n );\n\n return { walletAccounts };\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { assertDefined, getCore } from '@dynamic-labs-sdk/client/core';\nimport SignClient from '@walletconnect/sign-client';\n\n/** @not-instrumented */\nexport const createSignClient = async (client: DynamicClient) => {\n const core = getCore(client);\n\n assertDefined(client.projectSettings, 'Project settings not available');\n\n const generalSettings = client.projectSettings.general;\n\n assertDefined(\n generalSettings.displayName,\n 'Please configure an app name in dashboard to use WalletConnect'\n );\n\n const projectId = client.projectSettings.sdk.walletConnect?.projectId;\n\n assertDefined(\n projectId,\n 'Please configure a project ID for WalletConnect in dashboard'\n );\n\n const customStoragePrefix = `dynamic_${core.environmentId}_walletconnect`;\n\n const displayName = core.metadata?.name ?? generalSettings.displayName;\n\n const appLogo = core.metadata?.iconUrl ?? generalSettings.appLogo;\n\n return SignClient.init({\n customStoragePrefix,\n metadata: {\n description: '',\n icons: appLogo ? [appLogo] : [],\n name: displayName,\n redirect: {\n native: core.metadata?.nativeLink,\n universal: core.metadata?.universalLink,\n },\n url: core.metadata?.universalLink ?? '',\n },\n projectId,\n });\n};\n","import { createRuntimeServiceAccessKey } from '@dynamic-labs-sdk/client/core';\n\nimport { createSignClient } from './createSignClient';\n\nexport const getSignClient = createRuntimeServiceAccessKey(\n 'walletConnectSignClient',\n (client) => createSignClient(client)\n);\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport { name, version } from '../../package.json';\n\nassertPackageVersion(name, version);\n\nexport { createWalletConnectSessionEventEmitter } from '../createWalletConnectSessionEventEmitter';\nexport { SessionClosedUnexpectedlyError } from '../errors/SessionClosedUnexpectedlyError';\nexport { importWalletConnectAuthResponse } from '../importWalletConnectAuthResponse';\nexport { importWalletConnectSession } from '../importWalletConnectSession';\nexport { getSignClient } from '../signClient/getSignClient';\nexport { splitCaip10Token } from '../splitCaip10Token';\nexport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAa,oBAAoB,gBAAwB;CACvD,MAAM,CAAC,cAAc,WAAW,WAAW,YAAY,MAAM,IAAI;AACjE,QAAO;EAAE;EAAS;EAAc;EAAW;;;;;;;;;;;;;;;;;;ACyB7C,MAAa,0CAA0C,EACrD,eACA,YACA,cACA,cACA,iBACkD;AAClD,4EACE;EACE,uBAAuB,EAAE,kBAAkB,yBAAyB;AAClE,cAAW,IAAI,iBAAiB,mBAAmB;;EAGrD,sBAAsB,EACpB,uBACA,oBACA,2BACI;GACJ,MAAM,sBAAsB,EAC1B,QAAQ,EAAE,SACV,YACyB;AACzB,QAAI,UAAU,aACZ;AAGF,QAAI,MAAM,SAAS,gBAAgB;KACjC,MAAM,eAAe,MAAM;AAO3B,0BAAqB,EAAE,WAJL,aAAa,WAAW,GAAG,aAAa,GAAG,GACzD,aAAa,MAAM,IAAI,CAAC,KACxB,cAE8B,CAAC;AAEnC;;AAGF,QAAI,MAAM,SAAS,mBAAmB;KACpC,MAAM,gBAAgB,MAAM;AAe5B,2BAAsB,EAAE,+DAZtB,cAA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AgB;AAE1D,QAAOC,mCAAW,KAAK;EACrB;EACA,UAAU;GACR,aAAa;GACb,OAAO,UAAU,CAAC,QAAQ,GAAG,EAAE;GAC/B,MAAM;GACN,UAAU;IACR,QAAQ,KAAK,UAAU;IACvB,WAAW,KAAK,UAAU;IAC3B;GACD,KAAK,KAAK,UAAU,iBAAiB;GACtC;EACD;EACD,CAAC;;;;;ACvCJ,MAAa,iFACX,4BACC,WAAW,iBAAiB,OAAO,CACrC;;;;mECHoBC,6CAAMC,+CAAQ"}
1
+ {"version":3,"file":"core.cjs.js","names":["WalletProviderPriority","unverifiedWalletAccounts: {\n isNew: boolean;\n walletAccount: WalletAccount;\n }[]","verifiedCredentialIdToWalletProviderKeyMap: Record<string, string>","lastResponse: VerifyResponse | undefined","WalletProviderEnum","walletAccounts","SignClient","name","version"],"sources":["../src/splitCaip10Token/splitCaip10Token.ts","../src/createWalletConnectSessionEventEmitter/createWalletConnectSessionEventEmitter.ts","../src/createWalletAccountsForWalletConnectWalletProvider/createWalletAccountsForWalletConnectWalletProvider.ts","../src/importWalletConnectSession/importWalletConnectSession.ts","../src/importWalletConnectAuthResponse/verifyWalletConnectAuths/verifyWalletConnectAuths.ts","../src/importWalletConnectAuthResponse/importWalletConnectAuthResponse.ts","../src/signClient/getSignClient/createSignClient/createSignClient.ts","../src/signClient/getSignClient/getSignClient.ts","../src/exports/core.ts"],"sourcesContent":["/**\n * An account in WalletConnect follows the CAIP-10 standard\n * and is formatted as follows:\n *\n * `<namespace>:<chain>:<address>`\n *\n * Where:\n * - `<namespace>` is the namespace key (e.g. \"eip155\")\n * - `<chain>` is what we refer to as a network ID (e.g. \"1\")\n * - `<address>` is the address of the account (e.g. \"0x1234567890\")\n *\n * See docs: https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md\n *\n * @returns An object with the address, namespace key, and network id\n * @not-instrumented\n */\nexport const splitCaip10Token = (caip10Token: string) => {\n const [namespaceKey, networkId, address] = caip10Token.split(':');\n return { address, namespaceKey, networkId };\n};\n","import {\n createWalletProviderEventEmitter,\n filterDuplicates,\n} from '@dynamic-labs-sdk/client/core';\nimport type SignClient from '@walletconnect/sign-client';\nimport type { SessionTypes } from '@walletconnect/types';\n\nimport { splitCaip10Token } from '../splitCaip10Token';\n\ntype CreateWalletConnectSessionEventEmitterParams = {\n /**\n * Optional function to format addresses. If not provided, addresses are used as-is.\n */\n formatAddress?: (address: string) => string;\n getSession: () => SessionTypes.Struct;\n namespaceKey: string;\n sessionTopic: string;\n signClient: SignClient;\n};\n\ntype SessionEventPayload = {\n params: {\n event: {\n data: unknown;\n name: string;\n };\n };\n topic: string;\n};\n\n/**\n * Creates a WalletConnect session event emitter with common event handling logic.\n *\n * Handles chainChanged, accountsChanged, and disconnected events from WalletConnect sessions.\n *\n * @param params.getSession - Function to get the current session\n * @param params.namespaceKey - The WalletConnect namespace key (e.g., 'eip155', 'solana')\n * @param params.sessionTopic - The session topic to listen for events\n * @param params.signClient - The WalletConnect sign client instance\n * @param params.formatAddress - Optional function to format addresses (e.g., EIP-55 for EVM)\n * @returns An object with cleanupEventEmitter and getEventEmitter functions\n * @not-instrumented\n */\nexport const createWalletConnectSessionEventEmitter = ({\n formatAddress,\n getSession,\n namespaceKey,\n sessionTopic,\n signClient,\n}: CreateWalletConnectSessionEventEmitterParams) => {\n return createWalletProviderEventEmitter<(event: SessionEventPayload) => void>(\n {\n removeEventListeners: ({ setupReturnValue: handleSessionEvent }) => {\n signClient.off('session_event', handleSessionEvent);\n },\n\n setupEventListeners: ({\n handleAccountsChanged,\n handleDisconnected,\n handleNetworkChanged,\n }) => {\n const handleSessionEvent = ({\n params: { event },\n topic,\n }: SessionEventPayload) => {\n if (topic !== sessionTopic) {\n return;\n }\n\n if (event.name === 'chainChanged') {\n const networkParam = event.data as string;\n\n // Handle potentially CAIP-2 format\n const networkId = networkParam.startsWith(`${namespaceKey}:`)\n ? networkParam.split(':')[1]\n : networkParam;\n\n handleNetworkChanged({ networkId });\n\n return;\n }\n\n if (event.name === 'accountsChanged') {\n const accountsParam = event.data as string[];\n\n const addresses = filterDuplicates(\n accountsParam.map((account) => {\n // Handle potentially CAIP-10 format\n if (account.startsWith(`${namespaceKey}:`)) {\n return splitCaip10Token(account).address;\n }\n\n return account;\n })\n ).map((address) =>\n formatAddress ? formatAddress(address) : address\n );\n\n handleAccountsChanged({ addresses });\n\n return;\n }\n\n if (event.name === 'disconnected') {\n handleDisconnected();\n\n return;\n }\n };\n\n // Assert the session is still valid\n getSession();\n\n signClient.on('session_event', handleSessionEvent);\n\n return handleSessionEvent;\n },\n }\n );\n};\n","import { type WalletAccount } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n filterDuplicates,\n formatWalletAccountId,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { WalletConnectWalletProvider } from '../walletConnectWalletProvider.types';\nimport { splitCaip10Token } from '../splitCaip10Token';\n\ntype CreateWalletAccountsForWalletConnectWalletProviderParams = {\n walletProvider: WalletConnectWalletProvider;\n};\n\n/** @not-instrumented */\nexport const createWalletAccountsForWalletConnectWalletProvider = ({\n walletProvider,\n}: CreateWalletAccountsForWalletConnectWalletProviderParams): WalletAccount[] => {\n /**\n * Since each session can have multiple namespaces, we need to find the namespace\n * that corresponds to this specific wallet provider.\n *\n * A WalletConnect namespace is the equivalent of what we refer to as a chain in the SDK,\n * and they have attributed to them the methods, events and networks that are expected\n * to be supported by the wallet application, as well as which accounts are connected.\n */\n const session = walletProvider.getSession();\n\n const namespace = session.namespaces[walletProvider.namespaceKey];\n\n assertDefined(\n namespace,\n `Namespace key ${walletProvider.namespaceKey} of wallet provider ${walletProvider.key} not found in its session ${session.topic}`\n );\n\n const accountAddresses = filterDuplicates(\n namespace.accounts.map((account) => splitCaip10Token(account).address)\n );\n\n const formatAddress =\n walletProvider.formatWalletAddress ?? (({ address }) => address);\n\n return accountAddresses.map((address) => ({\n address: formatAddress({ address }),\n chain: walletProvider.chain,\n id: formatWalletAccountId({\n address,\n chain: walletProvider.chain,\n walletProviderKey: walletProvider.key,\n }),\n lastSelectedAt: null,\n verifiedCredentialId: null,\n walletProviderKey: walletProvider.key,\n }));\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n type WalletAccount,\n getWalletAccounts,\n} from '@dynamic-labs-sdk/client';\nimport {\n WalletProviderPriority,\n createVisit,\n emitWalletAccountsChangedEvent,\n getWalletProviderRegistry,\n setUnverifiedWalletAccounts,\n updateWalletProviderKeysForVerifiedCredentials,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\nimport { createWalletAccountsForWalletConnectWalletProvider } from '../createWalletAccountsForWalletConnectWalletProvider';\n\ntype ImportWalletConnectSessionParams = {\n /**\n * Whether this session's wallet accounts should be added to the dynamic's wallet accounts.\n */\n addToDynamicWalletAccounts?: boolean;\n\n /**\n * The session topic of the WalletConnect session.\n */\n sessionTopic: string;\n\n /**\n * The function that builds the wallet provider for the session.\n */\n walletProviderBuilder: WalletProviderBuilder;\n};\n\n/**\n * This is a lower level function that is used to connect a WalletConnect session to the Dynamic SDK.\n * It will generate the wallet providers and wallet accounts for all accounts in the session.\n *\n * @param sessionTopic - The session topic of the WalletConnect session.\n * @param addToDynamicWalletAccounts - Whether to add the wallet accounts to the dynamic's wallet accounts.\n * @param client - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The wallet accounts.\n * @not-instrumented\n */\nexport const importWalletConnectSession = async (\n {\n addToDynamicWalletAccounts = true,\n sessionTopic,\n walletProviderBuilder,\n }: ImportWalletConnectSessionParams,\n client: DynamicClient\n): Promise<{ walletAccounts: WalletAccount[] }> => {\n /**\n * You would normally get the session from the signClient.connect method. It takes the optionalNamespaces as an argument.\n *\n * Each chain should build its own \"connectWithWalletConnect<chain-name>\" function.\n * Understand how to build the optionalNamespaces object:\n *\n * The namespace configurations are used at the time a wallet application receives the connection URI.\n * It will use the configurations we supply to understand which methods, events and networks it should provide.\n *\n * The wallet application will then accept the connection request and, in the session`object, provide its own namespace object\n * in return, which will contain the methods, events and networks it does in fact support, as well as\n * which accounts are available.\n *\n * WalletConnect expects namespaces defined in the following format:\n * ```typescript\n * {\n * <namespaceKey>: {\n * \"accounts\": [\"<account1>\", \"<account2>\", \"<account3>\", ...],\n * \"events\": [\"accountsChanged\", \"chainChanged\", \"disconnected\"],\n * \"methods\": [\"personal_sign\", \"eth_sendTransaction\", \"eth_accounts\", ...],\n * \"chains\": [\"<chain1>\", \"<chain2>\", \"<chain3>\", ...]\n * },\n * ...\n * }\n * ```\n *\n * Where each account is a CAIP-10 formatted string, for example: \"eip155:1:0x1234567890\"\n * — see docs: https://chainagnostic.org/CAIPs/caip-10\n *\n * Where each chain is a CAIP-2 formatted string, for example: \"eip155:1\"\n * — see docs: https://chainagnostic.org/CAIPs/caip-2\n */\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n const walletProvider = await walletProviderBuilder({ sessionTopic }, client);\n\n walletProviderRegistry.register({\n priority: WalletProviderPriority.WALLET_SDK,\n walletProvider,\n });\n\n const walletAccounts = createWalletAccountsForWalletConnectWalletProvider({\n walletProvider,\n });\n\n const existingWalletAccounts = getWalletAccounts(client);\n\n /**\n * Keep track of which of the new wallet accounts are unverified to add later.\n */\n const unverifiedWalletAccounts: {\n isNew: boolean;\n walletAccount: WalletAccount;\n }[] = [];\n\n let walletAccountsChanged = false;\n\n /**\n * For all verified wallet accounts that are tied to this session, we need to update\n * the map of verified credential to wallet provider key\n */\n const verifiedCredentialIdToWalletProviderKeyMap: Record<string, string> = {};\n\n walletAccounts.forEach((walletAccount) => {\n const matchingWalletAccount = existingWalletAccounts.find(\n (existingWalletAccount) => existingWalletAccount.id === walletAccount.id\n );\n\n const matchingVerifiedCredentialId =\n matchingWalletAccount?.verifiedCredentialId;\n\n if (!matchingVerifiedCredentialId) {\n unverifiedWalletAccounts.push({\n isNew: !matchingWalletAccount,\n walletAccount,\n });\n } else {\n // This ensures later calls to getWalletAccounts will reconstruct the wallet accounts with\n // the correct wallet provider key\n verifiedCredentialIdToWalletProviderKeyMap[matchingVerifiedCredentialId] =\n walletProvider.key;\n\n // This ensures the wallet accounts returned by this function have the correct verified credential id\n walletAccount.verifiedCredentialId = matchingVerifiedCredentialId;\n }\n });\n\n if (Object.keys(verifiedCredentialIdToWalletProviderKeyMap).length > 0) {\n updateWalletProviderKeysForVerifiedCredentials(\n { keysToUpdate: verifiedCredentialIdToWalletProviderKeyMap },\n client\n );\n\n walletAccountsChanged = true;\n }\n\n if (addToDynamicWalletAccounts && unverifiedWalletAccounts.length > 0) {\n walletAccountsChanged = true;\n\n const unverifiedWalletAccountsToUpdate = unverifiedWalletAccounts.map(\n ({ walletAccount }) => walletAccount\n );\n\n setUnverifiedWalletAccounts({ unverifiedWalletAccountsToUpdate }, client);\n\n const newWalletAccounts = unverifiedWalletAccounts\n .filter(({ isNew }) => isNew)\n .map(({ walletAccount }) => walletAccount);\n\n for (const walletAccount of newWalletAccounts) {\n void createVisit({ walletAccount }, client);\n }\n }\n\n if (walletAccountsChanged) {\n emitWalletAccountsChangedEvent(client);\n }\n\n return { walletAccounts };\n};\n","import type {\n Chain,\n DynamicClient,\n VerifyResponse,\n} from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n updateAuthFromVerifyResponse,\n verifyMessageSignatureOwnership,\n} from '@dynamic-labs-sdk/client/core';\nimport { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\nimport type { AuthTypes } from '@walletconnect/types';\nimport { formatMessage } from '@walletconnect/utils';\n\nconst getAddressFromIss = (iss: string) => iss.split(':')[4];\n\ntype VerifyWalletConnectAuthsParams = {\n auths: AuthTypes.Cacao[];\n chain: Chain;\n walletDisplayName: string;\n};\n\n/** @not-instrumented */\n \nexport const verifyWalletConnectAuths = async (\n { auths, chain, walletDisplayName }: VerifyWalletConnectAuthsParams,\n client: DynamicClient\n) => {\n /**\n * The only differences between each auth object will be the signature (auth.s.s)\n * and the iss (auth.p.iss).\n *\n * The iss is comprised of 2 WC fields that are irrelevant to us and then the CAIP-10 token\n * of the address, where the first 2 fields are also split by the \":\" character.\n *\n * Usually, there will be multiple auths if the wallet app bundles signatures for multiple\n * networks at once, so the only field that will change among auth iss will be the networkId under iss.\n *\n * Docs on Cacao: https://chainagnostic.org/CAIPs/caip-74\n */\n const visitedAddresses = new Set<string>();\n\n const authsFilteredByAddress = auths.filter((auth) => {\n const address = getAddressFromIss(auth.p.iss);\n\n if (!address || visitedAddresses.has(address)) {\n return false;\n }\n\n visitedAddresses.add(address);\n\n return true;\n });\n\n let lastResponse: VerifyResponse | undefined = undefined;\n\n /**\n * WalletConnect's auth object is what they call a \"Cacao\" object, with data on the SIWE message\n * and the signature itself.\n * By consulting how they implemented their \"validateSignedCacao\" function,\n * we are able to reconstruct the original message which can be used to verify the signature\n * in our backend.\n */\n for (const auth of authsFilteredByAddress) {\n const publicWalletAddress = getAddressFromIss(auth.p.iss);\n\n assertDefined(\n publicWalletAddress,\n `Unable to get public wallet address from WalletConnect Cacao object iss: ${auth.p.iss}`\n );\n\n const messageToSign = formatMessage(auth.p, auth.p.iss);\n\n const signature = auth.s.s;\n\n lastResponse = await verifyMessageSignatureOwnership(\n {\n chain,\n messageToSign,\n signature,\n walletAddress: publicWalletAddress,\n walletDisplayName,\n walletProviderType: WalletProviderEnum.WalletConnect,\n },\n client\n );\n }\n\n if (!lastResponse) {\n return;\n }\n\n /**\n * Adds the user with the new wallet verified credentials\n * This will add the new verified wallet accounts to the client`s state\n */\n updateAuthFromVerifyResponse({ response: lastResponse }, client);\n};\n","import type { Chain, DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n type WalletAccount,\n verifyWalletAccount,\n} from '@dynamic-labs-sdk/client';\nimport type { AuthTypes } from '@walletconnect/types';\n\nimport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\nimport { importWalletConnectSession } from '../importWalletConnectSession';\nimport { verifyWalletConnectAuths } from './verifyWalletConnectAuths';\n\ntype ImportWalletConnectAuthResponseParams = {\n /**\n * The response from the WalletConnect authenticate method.\n */\n authResponse: AuthTypes.AuthenticateResponseResult;\n\n /**\n * The chain with which the wallet account is associated.\n */\n chain: Chain;\n\n /**\n * The function that builds the wallet provider for the session.\n */\n walletProviderBuilder: WalletProviderBuilder;\n};\n\n/**\n * A low level function that is used to connect a WalletConnect authenticate response to the Dynamic SDK.\n * It will generate the wallet providers and wallet accounts for all accounts in the session.\n *\n * @see WalletConnect's docs on [session authentication](https://docs.reown.com/advanced/api/sign/dapp-usage#session-authenticate-with-recaps)\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the connected and verified wallet account.\n * @not-instrumented\n */\nexport const importWalletConnectAuthResponse = async (\n {\n authResponse,\n chain,\n walletProviderBuilder,\n }: ImportWalletConnectAuthResponseParams,\n client: DynamicClient\n): Promise<{ walletAccounts: WalletAccount[] }> => {\n const { session, auths } = authResponse;\n\n /**\n * Some wallets do not support WC's authenticate method (such as Rainbow).\n * For these wallets, the authenticate method will act as a regular connect method.\n * Therefore we must call verify individually.\n */\n if (!auths || auths.length === 0) {\n const { walletAccounts } = await importWalletConnectSession(\n {\n /**\n * Don't add the wallet accounts to the dynamic's wallet accounts while we are still verifying them.\n */\n addToDynamicWalletAccounts: false,\n sessionTopic: session.topic,\n walletProviderBuilder,\n },\n client\n );\n\n // This should not be concurrent because the first will be a verify and the rest will be a link\n for (const walletAccount of walletAccounts) {\n await verifyWalletAccount({ walletAccount }, client);\n }\n\n return { walletAccounts };\n }\n\n /**\n * This reconstructs the message that was signed by the wallet and verifies the signature\n * in the backend. It will update the user with the new verified credentials.\n */\n await verifyWalletConnectAuths(\n {\n auths,\n chain,\n walletDisplayName: session.peer.metadata.name,\n },\n client\n );\n\n const { walletAccounts } = await importWalletConnectSession(\n {\n addToDynamicWalletAccounts: true,\n sessionTopic: session.topic,\n walletProviderBuilder,\n },\n client\n );\n\n return { walletAccounts };\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { assertDefined, getCore } from '@dynamic-labs-sdk/client/core';\nimport SignClient from '@walletconnect/sign-client';\n\n/** @not-instrumented */\nexport const createSignClient = async (client: DynamicClient) => {\n const core = getCore(client);\n\n assertDefined(client.projectSettings, 'Project settings not available');\n\n const generalSettings = client.projectSettings.general;\n\n assertDefined(\n generalSettings.displayName,\n 'Please configure an app name in dashboard to use WalletConnect'\n );\n\n const projectId = client.projectSettings.sdk.walletConnect?.projectId;\n\n assertDefined(\n projectId,\n 'Please configure a project ID for WalletConnect in dashboard'\n );\n\n const customStoragePrefix = `dynamic_${core.environmentId}_walletconnect`;\n\n const displayName = core.metadata?.name ?? generalSettings.displayName;\n\n const appLogo = core.metadata?.iconUrl ?? generalSettings.appLogo;\n\n return SignClient.init({\n customStoragePrefix,\n metadata: {\n description: '',\n icons: appLogo ? [appLogo] : [],\n name: displayName,\n redirect: {\n native: core.metadata?.nativeLink,\n universal: core.metadata?.universalLink,\n },\n url: core.metadata?.universalLink ?? '',\n },\n projectId,\n });\n};\n","import { createRuntimeServiceAccessKey } from '@dynamic-labs-sdk/client/core';\n\nimport { createSignClient } from './createSignClient';\n\nexport const getSignClient = createRuntimeServiceAccessKey(\n 'walletConnectSignClient',\n (client) => createSignClient(client)\n);\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport { name, version } from '../../package.json';\n\nassertPackageVersion(name, version);\n\nexport { createWalletConnectSessionEventEmitter } from '../createWalletConnectSessionEventEmitter';\nexport { SessionClosedUnexpectedlyError } from '../errors/SessionClosedUnexpectedlyError';\nexport { importWalletConnectAuthResponse } from '../importWalletConnectAuthResponse';\nexport { importWalletConnectSession } from '../importWalletConnectSession';\nexport { getSignClient } from '../signClient/getSignClient';\nexport { splitCaip10Token } from '../splitCaip10Token';\nexport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAa,oBAAoB,gBAA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,yDAA0B,EAAE,eAAe,EAAE,OAAO;AAGtD,SAAO,EAAE,kCAAgB;;;;;;AAO3B,OAAM,yBACJ;EACE;EACA;EACA,mBAAmB,QAAQ,KAAK,SAAS;EAC1C,EACD,OACD;CAED,MAAM,EAAE,mBAAmB,MAAM,2BAC/B;EACE,4BAA4B;EAC5B,cAAc,QAAQ;EACtB;EACD,EACD,OACD;AAED,QAAO,EAAE,gBAAgB;;;;;;AC1F3B,MAAa,mBAAmB,OAAO,WAA0B;CAC/D,MAAM,kDAAe,OAAO;AAE5B,kDAAc,OAAO,iBAAiB,iCAAiC;CAEvE,MAAM,kBAAkB,OAAO,gBAAgB;AAE/C,kDACE,gBAAgB,aAChB,iEACD;CAED,MAAM,YAAY,OAAO,gBAAgB,IAAI,eAAe;AAE5D,kDACE,WACA,+DACD;CAED,MAAM,sBAAsB,WAAW,KAAK,cAAc;CAE1D,MAAM,cAAc,KAAK,UAAU,QAAQ,gBAAgB;CAE3D,MAAM,UAAU,KAAK,UAAU,WAAW,gBAAgB;AAE1D,QAAOC,mCAAW,KAAK;EACrB;EACA,UAAU;GACR,aAAa;GACb,OAAO,UAAU,CAAC,QAAQ,GAAG,EAAE;GAC/B,MAAM;GACN,UAAU;IACR,QAAQ,KAAK,UAAU;IACvB,WAAW,KAAK,UAAU;IAC3B;GACD,KAAK,KAAK,UAAU,iBAAiB;GACtC;EACD;EACD,CAAC;;;;;ACvCJ,MAAa,iFACX,4BACC,WAAW,iBAAiB,OAAO,CACrC;;;;mECHoBC,6CAAMC,+CAAQ"}
package/dist/core.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as name, r as version, t as SessionClosedUnexpectedlyError } from "./SessionClosedUnexpectedlyError-yC5QgGik.esm.js";
1
+ import { n as name, r as version, t as SessionClosedUnexpectedlyError } from "./SessionClosedUnexpectedlyError-B20TMr3W.esm.js";
2
2
  import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
3
3
  import { formatMessage } from "@walletconnect/utils";
4
4
  import { getWalletAccounts, verifyWalletAccount } from "@dynamic-labs-sdk/client";
@@ -1 +1 @@
1
- {"version":3,"file":"core.esm.js","names":["unverifiedWalletAccounts: {\n isNew: boolean;\n walletAccount: WalletAccount;\n }[]","verifiedCredentialIdToWalletProviderKeyMap: Record<string, string>","lastResponse: VerifyResponse | undefined","walletAccounts"],"sources":["../src/splitCaip10Token/splitCaip10Token.ts","../src/createWalletConnectSessionEventEmitter/createWalletConnectSessionEventEmitter.ts","../src/createWalletAccountsForWalletConnectWalletProvider/createWalletAccountsForWalletConnectWalletProvider.ts","../src/importWalletConnectSession/importWalletConnectSession.ts","../src/importWalletConnectAuthResponse/verifyWalletConnectAuths/verifyWalletConnectAuths.ts","../src/importWalletConnectAuthResponse/importWalletConnectAuthResponse.ts","../src/signClient/getSignClient/createSignClient/createSignClient.ts","../src/signClient/getSignClient/getSignClient.ts","../src/exports/core.ts"],"sourcesContent":["/**\n * An account in WalletConnect follows the CAIP-10 standard\n * and is formatted as follows:\n *\n * `<namespace>:<chain>:<address>`\n *\n * Where:\n * - `<namespace>` is the namespace key (e.g. \"eip155\")\n * - `<chain>` is what we refer to as a network ID (e.g. \"1\")\n * - `<address>` is the address of the account (e.g. \"0x1234567890\")\n *\n * See docs: https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md\n *\n * @returns An object with the address, namespace key, and network id\n * @not-instrumented\n */\nexport const splitCaip10Token = (caip10Token: string) => {\n const [namespaceKey, networkId, address] = caip10Token.split(':');\n return { address, namespaceKey, networkId };\n};\n","import {\n createWalletProviderEventEmitter,\n filterDuplicates,\n} from '@dynamic-labs-sdk/client/core';\nimport type SignClient from '@walletconnect/sign-client';\nimport type { SessionTypes } from '@walletconnect/types';\n\nimport { splitCaip10Token } from '../splitCaip10Token';\n\ntype CreateWalletConnectSessionEventEmitterParams = {\n /**\n * Optional function to format addresses. If not provided, addresses are used as-is.\n */\n formatAddress?: (address: string) => string;\n getSession: () => SessionTypes.Struct;\n namespaceKey: string;\n sessionTopic: string;\n signClient: SignClient;\n};\n\ntype SessionEventPayload = {\n params: {\n event: {\n data: unknown;\n name: string;\n };\n };\n topic: string;\n};\n\n/**\n * Creates a WalletConnect session event emitter with common event handling logic.\n *\n * Handles chainChanged, accountsChanged, and disconnected events from WalletConnect sessions.\n *\n * @param params.getSession - Function to get the current session\n * @param params.namespaceKey - The WalletConnect namespace key (e.g., 'eip155', 'solana')\n * @param params.sessionTopic - The session topic to listen for events\n * @param params.signClient - The WalletConnect sign client instance\n * @param params.formatAddress - Optional function to format addresses (e.g., EIP-55 for EVM)\n * @returns An object with cleanupEventEmitter and getEventEmitter functions\n * @not-instrumented\n */\nexport const createWalletConnectSessionEventEmitter = ({\n formatAddress,\n getSession,\n namespaceKey,\n sessionTopic,\n signClient,\n}: CreateWalletConnectSessionEventEmitterParams) => {\n return createWalletProviderEventEmitter<(event: SessionEventPayload) => void>(\n {\n removeEventListeners: ({ setupReturnValue: handleSessionEvent }) => {\n signClient.off('session_event', handleSessionEvent);\n },\n\n setupEventListeners: ({\n handleAccountsChanged,\n handleDisconnected,\n handleNetworkChanged,\n }) => {\n const handleSessionEvent = ({\n params: { event },\n topic,\n }: SessionEventPayload) => {\n if (topic !== sessionTopic) {\n return;\n }\n\n if (event.name === 'chainChanged') {\n const networkParam = event.data as string;\n\n // Handle potentially CAIP-2 format\n const networkId = networkParam.startsWith(`${namespaceKey}:`)\n ? networkParam.split(':')[1]\n : networkParam;\n\n handleNetworkChanged({ networkId });\n\n return;\n }\n\n if (event.name === 'accountsChanged') {\n const accountsParam = event.data as string[];\n\n const addresses = filterDuplicates(\n accountsParam.map((account) => {\n // Handle potentially CAIP-10 format\n if (account.startsWith(`${namespaceKey}:`)) {\n return splitCaip10Token(account).address;\n }\n\n return account;\n })\n ).map((address) =>\n formatAddress ? formatAddress(address) : address\n );\n\n handleAccountsChanged({ addresses });\n\n return;\n }\n\n if (event.name === 'disconnected') {\n handleDisconnected();\n\n return;\n }\n };\n\n // Assert the session is still valid\n getSession();\n\n signClient.on('session_event', handleSessionEvent);\n\n return handleSessionEvent;\n },\n }\n );\n};\n","import { type WalletAccount } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n filterDuplicates,\n formatWalletAccountId,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { WalletConnectWalletProvider } from '../walletConnectWalletProvider.types';\nimport { splitCaip10Token } from '../splitCaip10Token';\n\ntype CreateWalletAccountsForWalletConnectWalletProviderParams = {\n walletProvider: WalletConnectWalletProvider;\n};\n\n/** @not-instrumented */\nexport const createWalletAccountsForWalletConnectWalletProvider = ({\n walletProvider,\n}: CreateWalletAccountsForWalletConnectWalletProviderParams): WalletAccount[] => {\n /**\n * Since each session can have multiple namespaces, we need to find the namespace\n * that corresponds to this specific wallet provider.\n *\n * A WalletConnect namespace is the equivalent of what we refer to as a chain in the SDK,\n * and they have attributed to them the methods, events and networks that are expected\n * to be supported by the wallet application, as well as which accounts are connected.\n */\n const session = walletProvider.getSession();\n\n const namespace = session.namespaces[walletProvider.namespaceKey];\n\n assertDefined(\n namespace,\n `Namespace key ${walletProvider.namespaceKey} of wallet provider ${walletProvider.key} not found in its session ${session.topic}`\n );\n\n const accountAddresses = filterDuplicates(\n namespace.accounts.map((account) => splitCaip10Token(account).address)\n );\n\n const formatAddress =\n walletProvider.formatWalletAddress ?? (({ address }) => address);\n\n return accountAddresses.map((address) => ({\n address: formatAddress({ address }),\n chain: walletProvider.chain,\n id: formatWalletAccountId({\n address,\n chain: walletProvider.chain,\n walletProviderKey: walletProvider.key,\n }),\n lastSelectedAt: null,\n verifiedCredentialId: null,\n walletProviderKey: walletProvider.key,\n }));\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n type WalletAccount,\n getWalletAccounts,\n} from '@dynamic-labs-sdk/client';\nimport {\n WalletProviderPriority,\n createVisit,\n emitWalletAccountsChangedEvent,\n getWalletProviderRegistry,\n setUnverifiedWalletAccounts,\n updateWalletProviderKeysForVerifiedCredentials,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\nimport { createWalletAccountsForWalletConnectWalletProvider } from '../createWalletAccountsForWalletConnectWalletProvider';\n\ntype ImportWalletConnectSessionParams = {\n /**\n * Whether this session's wallet accounts should be added to the dynamic's wallet accounts.\n */\n addToDynamicWalletAccounts?: boolean;\n\n /**\n * The session topic of the WalletConnect session.\n */\n sessionTopic: string;\n\n /**\n * The function that builds the wallet provider for the session.\n */\n walletProviderBuilder: WalletProviderBuilder;\n};\n\n/**\n * This is a lower level function that is used to connect a WalletConnect session to the Dynamic SDK.\n * It will generate the wallet providers and wallet accounts for all accounts in the session.\n *\n * @param sessionTopic - The session topic of the WalletConnect session.\n * @param addToDynamicWalletAccounts - Whether to add the wallet accounts to the dynamic's wallet accounts.\n * @param client - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The wallet accounts.\n * @not-instrumented\n */\nexport const importWalletConnectSession = async (\n {\n addToDynamicWalletAccounts = true,\n sessionTopic,\n walletProviderBuilder,\n }: ImportWalletConnectSessionParams,\n client: DynamicClient\n): Promise<{ walletAccounts: WalletAccount[] }> => {\n /**\n * You would normally get the session from the signClient.connect method. It takes the optionalNamespaces as an argument.\n *\n * Each chain should build its own \"connectWithWalletConnect<chain-name>\" function.\n * Understand how to build the optionalNamespaces object:\n *\n * The namespace configurations are used at the time a wallet application receives the connection URI.\n * It will use the configurations we supply to understand which methods, events and networks it should provide.\n *\n * The wallet application will then accept the connection request and, in the session`object, provide its own namespace object\n * in return, which will contain the methods, events and networks it does in fact support, as well as\n * which accounts are available.\n *\n * WalletConnect expects namespaces defined in the following format:\n * ```typescript\n * {\n * <namespaceKey>: {\n * \"accounts\": [\"<account1>\", \"<account2>\", \"<account3>\", ...],\n * \"events\": [\"accountsChanged\", \"chainChanged\", \"disconnected\"],\n * \"methods\": [\"personal_sign\", \"eth_sendTransaction\", \"eth_accounts\", ...],\n * \"chains\": [\"<chain1>\", \"<chain2>\", \"<chain3>\", ...]\n * },\n * ...\n * }\n * ```\n *\n * Where each account is a CAIP-10 formatted string, for example: \"eip155:1:0x1234567890\"\n * — see docs: https://chainagnostic.org/CAIPs/caip-10\n *\n * Where each chain is a CAIP-2 formatted string, for example: \"eip155:1\"\n * — see docs: https://chainagnostic.org/CAIPs/caip-2\n */\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n const walletProvider = await walletProviderBuilder({ sessionTopic }, client);\n\n walletProviderRegistry.register({\n priority: WalletProviderPriority.WALLET_SDK,\n walletProvider,\n });\n\n const walletAccounts = createWalletAccountsForWalletConnectWalletProvider({\n walletProvider,\n });\n\n const existingWalletAccounts = getWalletAccounts(client);\n\n /**\n * Keep track of which of the new wallet accounts are unverified to add later.\n */\n const unverifiedWalletAccounts: {\n isNew: boolean;\n walletAccount: WalletAccount;\n }[] = [];\n\n let walletAccountsChanged = false;\n\n /**\n * For all verified wallet accounts that are tied to this session, we need to update\n * the map of verified credential to wallet provider key\n */\n const verifiedCredentialIdToWalletProviderKeyMap: Record<string, string> = {};\n\n walletAccounts.forEach((walletAccount) => {\n const matchingWalletAccount = existingWalletAccounts.find(\n (existingWalletAccount) => existingWalletAccount.id === walletAccount.id\n );\n\n const matchingVerifiedCredentialId =\n matchingWalletAccount?.verifiedCredentialId;\n\n if (!matchingVerifiedCredentialId) {\n unverifiedWalletAccounts.push({\n isNew: !matchingWalletAccount,\n walletAccount,\n });\n } else {\n // This ensures later calls to getWalletAccounts will reconstruct the wallet accounts with\n // the correct wallet provider key\n verifiedCredentialIdToWalletProviderKeyMap[matchingVerifiedCredentialId] =\n walletProvider.key;\n\n // This ensures the wallet accounts returned by this function have the correct verified credential id\n walletAccount.verifiedCredentialId = matchingVerifiedCredentialId;\n }\n });\n\n if (Object.keys(verifiedCredentialIdToWalletProviderKeyMap).length > 0) {\n updateWalletProviderKeysForVerifiedCredentials(\n { keysToUpdate: verifiedCredentialIdToWalletProviderKeyMap },\n client\n );\n\n walletAccountsChanged = true;\n }\n\n if (addToDynamicWalletAccounts && unverifiedWalletAccounts.length > 0) {\n walletAccountsChanged = true;\n\n const unverifiedWalletAccountsToUpdate = unverifiedWalletAccounts.map(\n ({ walletAccount }) => walletAccount\n );\n\n setUnverifiedWalletAccounts({ unverifiedWalletAccountsToUpdate }, client);\n\n const newWalletAccounts = unverifiedWalletAccounts\n .filter(({ isNew }) => isNew)\n .map(({ walletAccount }) => walletAccount);\n\n for (const walletAccount of newWalletAccounts) {\n void createVisit({ walletAccount }, client);\n }\n }\n\n if (walletAccountsChanged) {\n emitWalletAccountsChangedEvent(client);\n }\n\n return { walletAccounts };\n};\n","import type {\n Chain,\n DynamicClient,\n VerifyResponse,\n} from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n updateAuthFromVerifyResponse,\n verifyMessageSignatureOwnership,\n} from '@dynamic-labs-sdk/client/core';\nimport { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\nimport type { AuthTypes } from '@walletconnect/types';\nimport { formatMessage } from '@walletconnect/utils';\n\nconst getAddressFromIss = (iss: string) => iss.split(':')[4];\n\ntype VerifyWalletConnectAuthsParams = {\n auths: AuthTypes.Cacao[];\n chain: Chain;\n walletDisplayName: string;\n};\n\n/** @not-instrumented */\n// eslint-disable-next-line custom-rules/one-function-per-file\nexport const verifyWalletConnectAuths = async (\n { auths, chain, walletDisplayName }: VerifyWalletConnectAuthsParams,\n client: DynamicClient\n) => {\n /**\n * The only differences between each auth object will be the signature (auth.s.s)\n * and the iss (auth.p.iss).\n *\n * The iss is comprised of 2 WC fields that are irrelevant to us and then the CAIP-10 token\n * of the address, where the first 2 fields are also split by the \":\" character.\n *\n * Usually, there will be multiple auths if the wallet app bundles signatures for multiple\n * networks at once, so the only field that will change among auth iss will be the networkId under iss.\n *\n * Docs on Cacao: https://chainagnostic.org/CAIPs/caip-74\n */\n const visitedAddresses = new Set<string>();\n\n const authsFilteredByAddress = auths.filter((auth) => {\n const address = getAddressFromIss(auth.p.iss);\n\n if (!address || visitedAddresses.has(address)) {\n return false;\n }\n\n visitedAddresses.add(address);\n\n return true;\n });\n\n let lastResponse: VerifyResponse | undefined = undefined;\n\n /**\n * WalletConnect's auth object is what they call a \"Cacao\" object, with data on the SIWE message\n * and the signature itself.\n * By consulting how they implemented their \"validateSignedCacao\" function,\n * we are able to reconstruct the original message which can be used to verify the signature\n * in our backend.\n */\n for (const auth of authsFilteredByAddress) {\n const publicWalletAddress = getAddressFromIss(auth.p.iss);\n\n assertDefined(\n publicWalletAddress,\n `Unable to get public wallet address from WalletConnect Cacao object iss: ${auth.p.iss}`\n );\n\n const messageToSign = formatMessage(auth.p, auth.p.iss);\n\n const signature = auth.s.s;\n\n lastResponse = await verifyMessageSignatureOwnership(\n {\n chain,\n messageToSign,\n signature,\n walletAddress: publicWalletAddress,\n walletDisplayName,\n walletProviderType: WalletProviderEnum.WalletConnect,\n },\n client\n );\n }\n\n if (!lastResponse) {\n return;\n }\n\n /**\n * Adds the user with the new wallet verified credentials\n * This will add the new verified wallet accounts to the client`s state\n */\n updateAuthFromVerifyResponse({ response: lastResponse }, client);\n};\n","import type { Chain, DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n type WalletAccount,\n verifyWalletAccount,\n} from '@dynamic-labs-sdk/client';\nimport type { AuthTypes } from '@walletconnect/types';\n\nimport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\nimport { importWalletConnectSession } from '../importWalletConnectSession';\nimport { verifyWalletConnectAuths } from './verifyWalletConnectAuths';\n\ntype ImportWalletConnectAuthResponseParams = {\n /**\n * The response from the WalletConnect authenticate method.\n */\n authResponse: AuthTypes.AuthenticateResponseResult;\n\n /**\n * The chain with which the wallet account is associated.\n */\n chain: Chain;\n\n /**\n * The function that builds the wallet provider for the session.\n */\n walletProviderBuilder: WalletProviderBuilder;\n};\n\n/**\n * A low level function that is used to connect a WalletConnect authenticate response to the Dynamic SDK.\n * It will generate the wallet providers and wallet accounts for all accounts in the session.\n *\n * @see WalletConnect's docs on [session authentication](https://docs.reown.com/advanced/api/sign/dapp-usage#session-authenticate-with-recaps)\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the connected and verified wallet account.\n * @not-instrumented\n */\nexport const importWalletConnectAuthResponse = async (\n {\n authResponse,\n chain,\n walletProviderBuilder,\n }: ImportWalletConnectAuthResponseParams,\n client: DynamicClient\n): Promise<{ walletAccounts: WalletAccount[] }> => {\n const { session, auths } = authResponse;\n\n /**\n * Some wallets do not support WC's authenticate method (such as Rainbow).\n * For these wallets, the authenticate method will act as a regular connect method.\n * Therefore we must call verify individually.\n */\n if (!auths || auths.length === 0) {\n const { walletAccounts } = await importWalletConnectSession(\n {\n /**\n * Don't add the wallet accounts to the dynamic's wallet accounts while we are still verifying them.\n */\n addToDynamicWalletAccounts: false,\n sessionTopic: session.topic,\n walletProviderBuilder,\n },\n client\n );\n\n // This should not be concurrent because the first will be a verify and the rest will be a link\n for (const walletAccount of walletAccounts) {\n await verifyWalletAccount({ walletAccount }, client);\n }\n\n return { walletAccounts };\n }\n\n /**\n * This reconstructs the message that was signed by the wallet and verifies the signature\n * in the backend. It will update the user with the new verified credentials.\n */\n await verifyWalletConnectAuths(\n {\n auths,\n chain,\n walletDisplayName: session.peer.metadata.name,\n },\n client\n );\n\n const { walletAccounts } = await importWalletConnectSession(\n {\n addToDynamicWalletAccounts: true,\n sessionTopic: session.topic,\n walletProviderBuilder,\n },\n client\n );\n\n return { walletAccounts };\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { assertDefined, getCore } from '@dynamic-labs-sdk/client/core';\nimport SignClient from '@walletconnect/sign-client';\n\n/** @not-instrumented */\nexport const createSignClient = async (client: DynamicClient) => {\n const core = getCore(client);\n\n assertDefined(client.projectSettings, 'Project settings not available');\n\n const generalSettings = client.projectSettings.general;\n\n assertDefined(\n generalSettings.displayName,\n 'Please configure an app name in dashboard to use WalletConnect'\n );\n\n const projectId = client.projectSettings.sdk.walletConnect?.projectId;\n\n assertDefined(\n projectId,\n 'Please configure a project ID for WalletConnect in dashboard'\n );\n\n const customStoragePrefix = `dynamic_${core.environmentId}_walletconnect`;\n\n const displayName = core.metadata?.name ?? generalSettings.displayName;\n\n const appLogo = core.metadata?.iconUrl ?? generalSettings.appLogo;\n\n return SignClient.init({\n customStoragePrefix,\n metadata: {\n description: '',\n icons: appLogo ? [appLogo] : [],\n name: displayName,\n redirect: {\n native: core.metadata?.nativeLink,\n universal: core.metadata?.universalLink,\n },\n url: core.metadata?.universalLink ?? '',\n },\n projectId,\n });\n};\n","import { createRuntimeServiceAccessKey } from '@dynamic-labs-sdk/client/core';\n\nimport { createSignClient } from './createSignClient';\n\nexport const getSignClient = createRuntimeServiceAccessKey(\n 'walletConnectSignClient',\n (client) => createSignClient(client)\n);\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport { name, version } from '../../package.json';\n\nassertPackageVersion(name, version);\n\nexport { createWalletConnectSessionEventEmitter } from '../createWalletConnectSessionEventEmitter';\nexport { SessionClosedUnexpectedlyError } from '../errors/SessionClosedUnexpectedlyError';\nexport { importWalletConnectAuthResponse } from '../importWalletConnectAuthResponse';\nexport { importWalletConnectSession } from '../importWalletConnectSession';\nexport { getSignClient } from '../signClient/getSignClient';\nexport { splitCaip10Token } from '../splitCaip10Token';\nexport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAa,oBAAoB,gBAAwB;CACvD,MAAM,CAAC,cAAc,WAAW,WAAW,YAAY,MAAM,IAAI;AACjE,QAAO;EAAE;EAAS;EAAc;EAAW;;;;;;;;;;;;;;;;;;ACyB7C,MAAa,0CAA0C,EACrD,eACA,YACA,cACA,cACA,iBACkD;AAClD,QAAO,iCACL;EACE,uBAAuB,EAAE,kBAAkB,yBAAyB;AAClE,cAAW,IAAI,iBAAiB,mBAAmB;;EAGrD,sBAAsB,EACpB,uBACA,oBACA,2BACI;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D;AAED,QAAO,EAAE,gBAAgB;;;;;;AC1F3B,MAAa,mBAAmB,OAAO,WAA0B;CAC/D,MAAM,OAAO,QAAQ,OAAO;AAE5B,eAAc,OAAO,iBAAiB,iCAAiC;CAEvE,MAAM,kBAAkB,OAAO,gBAAgB;AAE/C,eACE,gBAAgB,aAChB,iEACD;CAED,MAAM,YAAY,OAAO,gBAAgB,IAAI,eAAe;AAE5D,eACE,WACA,+DACD;CAED,MAAM,sBAAsB,WAAW,KAAK,cAAc;CAE1D,MAAM,cAAc,KAAK,UAAU,QAAQ,gBAAgB;CAE3D,MAAM,UAAU,KAAK,UAAU,WAAW,gBAAgB;AAE1D,QAAO,WAAW,KAAK;EACrB;EACA,UAAU;GACR,aAAa;GACb,OAAO,UAAU,CAAC,QAAQ,GAAG,EAAE;GAC/B,MAAM;GACN,UAAU;IACR,QAAQ,KAAK,UAAU;IACvB,WAAW,KAAK,UAAU;IAC3B;GACD,KAAK,KAAK,UAAU,iBAAiB;GACtC;EACD;EACD,CAAC;;;;;ACvCJ,MAAa,gBAAgB,8BAC3B,4BACC,WAAW,iBAAiB,OAAO,CACrC;;;;ACHD,qBAAqB,MAAM,QAAQ"}
1
+ {"version":3,"file":"core.esm.js","names":["unverifiedWalletAccounts: {\n isNew: boolean;\n walletAccount: WalletAccount;\n }[]","verifiedCredentialIdToWalletProviderKeyMap: Record<string, string>","lastResponse: VerifyResponse | undefined","walletAccounts"],"sources":["../src/splitCaip10Token/splitCaip10Token.ts","../src/createWalletConnectSessionEventEmitter/createWalletConnectSessionEventEmitter.ts","../src/createWalletAccountsForWalletConnectWalletProvider/createWalletAccountsForWalletConnectWalletProvider.ts","../src/importWalletConnectSession/importWalletConnectSession.ts","../src/importWalletConnectAuthResponse/verifyWalletConnectAuths/verifyWalletConnectAuths.ts","../src/importWalletConnectAuthResponse/importWalletConnectAuthResponse.ts","../src/signClient/getSignClient/createSignClient/createSignClient.ts","../src/signClient/getSignClient/getSignClient.ts","../src/exports/core.ts"],"sourcesContent":["/**\n * An account in WalletConnect follows the CAIP-10 standard\n * and is formatted as follows:\n *\n * `<namespace>:<chain>:<address>`\n *\n * Where:\n * - `<namespace>` is the namespace key (e.g. \"eip155\")\n * - `<chain>` is what we refer to as a network ID (e.g. \"1\")\n * - `<address>` is the address of the account (e.g. \"0x1234567890\")\n *\n * See docs: https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md\n *\n * @returns An object with the address, namespace key, and network id\n * @not-instrumented\n */\nexport const splitCaip10Token = (caip10Token: string) => {\n const [namespaceKey, networkId, address] = caip10Token.split(':');\n return { address, namespaceKey, networkId };\n};\n","import {\n createWalletProviderEventEmitter,\n filterDuplicates,\n} from '@dynamic-labs-sdk/client/core';\nimport type SignClient from '@walletconnect/sign-client';\nimport type { SessionTypes } from '@walletconnect/types';\n\nimport { splitCaip10Token } from '../splitCaip10Token';\n\ntype CreateWalletConnectSessionEventEmitterParams = {\n /**\n * Optional function to format addresses. If not provided, addresses are used as-is.\n */\n formatAddress?: (address: string) => string;\n getSession: () => SessionTypes.Struct;\n namespaceKey: string;\n sessionTopic: string;\n signClient: SignClient;\n};\n\ntype SessionEventPayload = {\n params: {\n event: {\n data: unknown;\n name: string;\n };\n };\n topic: string;\n};\n\n/**\n * Creates a WalletConnect session event emitter with common event handling logic.\n *\n * Handles chainChanged, accountsChanged, and disconnected events from WalletConnect sessions.\n *\n * @param params.getSession - Function to get the current session\n * @param params.namespaceKey - The WalletConnect namespace key (e.g., 'eip155', 'solana')\n * @param params.sessionTopic - The session topic to listen for events\n * @param params.signClient - The WalletConnect sign client instance\n * @param params.formatAddress - Optional function to format addresses (e.g., EIP-55 for EVM)\n * @returns An object with cleanupEventEmitter and getEventEmitter functions\n * @not-instrumented\n */\nexport const createWalletConnectSessionEventEmitter = ({\n formatAddress,\n getSession,\n namespaceKey,\n sessionTopic,\n signClient,\n}: CreateWalletConnectSessionEventEmitterParams) => {\n return createWalletProviderEventEmitter<(event: SessionEventPayload) => void>(\n {\n removeEventListeners: ({ setupReturnValue: handleSessionEvent }) => {\n signClient.off('session_event', handleSessionEvent);\n },\n\n setupEventListeners: ({\n handleAccountsChanged,\n handleDisconnected,\n handleNetworkChanged,\n }) => {\n const handleSessionEvent = ({\n params: { event },\n topic,\n }: SessionEventPayload) => {\n if (topic !== sessionTopic) {\n return;\n }\n\n if (event.name === 'chainChanged') {\n const networkParam = event.data as string;\n\n // Handle potentially CAIP-2 format\n const networkId = networkParam.startsWith(`${namespaceKey}:`)\n ? networkParam.split(':')[1]\n : networkParam;\n\n handleNetworkChanged({ networkId });\n\n return;\n }\n\n if (event.name === 'accountsChanged') {\n const accountsParam = event.data as string[];\n\n const addresses = filterDuplicates(\n accountsParam.map((account) => {\n // Handle potentially CAIP-10 format\n if (account.startsWith(`${namespaceKey}:`)) {\n return splitCaip10Token(account).address;\n }\n\n return account;\n })\n ).map((address) =>\n formatAddress ? formatAddress(address) : address\n );\n\n handleAccountsChanged({ addresses });\n\n return;\n }\n\n if (event.name === 'disconnected') {\n handleDisconnected();\n\n return;\n }\n };\n\n // Assert the session is still valid\n getSession();\n\n signClient.on('session_event', handleSessionEvent);\n\n return handleSessionEvent;\n },\n }\n );\n};\n","import { type WalletAccount } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n filterDuplicates,\n formatWalletAccountId,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { WalletConnectWalletProvider } from '../walletConnectWalletProvider.types';\nimport { splitCaip10Token } from '../splitCaip10Token';\n\ntype CreateWalletAccountsForWalletConnectWalletProviderParams = {\n walletProvider: WalletConnectWalletProvider;\n};\n\n/** @not-instrumented */\nexport const createWalletAccountsForWalletConnectWalletProvider = ({\n walletProvider,\n}: CreateWalletAccountsForWalletConnectWalletProviderParams): WalletAccount[] => {\n /**\n * Since each session can have multiple namespaces, we need to find the namespace\n * that corresponds to this specific wallet provider.\n *\n * A WalletConnect namespace is the equivalent of what we refer to as a chain in the SDK,\n * and they have attributed to them the methods, events and networks that are expected\n * to be supported by the wallet application, as well as which accounts are connected.\n */\n const session = walletProvider.getSession();\n\n const namespace = session.namespaces[walletProvider.namespaceKey];\n\n assertDefined(\n namespace,\n `Namespace key ${walletProvider.namespaceKey} of wallet provider ${walletProvider.key} not found in its session ${session.topic}`\n );\n\n const accountAddresses = filterDuplicates(\n namespace.accounts.map((account) => splitCaip10Token(account).address)\n );\n\n const formatAddress =\n walletProvider.formatWalletAddress ?? (({ address }) => address);\n\n return accountAddresses.map((address) => ({\n address: formatAddress({ address }),\n chain: walletProvider.chain,\n id: formatWalletAccountId({\n address,\n chain: walletProvider.chain,\n walletProviderKey: walletProvider.key,\n }),\n lastSelectedAt: null,\n verifiedCredentialId: null,\n walletProviderKey: walletProvider.key,\n }));\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n type WalletAccount,\n getWalletAccounts,\n} from '@dynamic-labs-sdk/client';\nimport {\n WalletProviderPriority,\n createVisit,\n emitWalletAccountsChangedEvent,\n getWalletProviderRegistry,\n setUnverifiedWalletAccounts,\n updateWalletProviderKeysForVerifiedCredentials,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\nimport { createWalletAccountsForWalletConnectWalletProvider } from '../createWalletAccountsForWalletConnectWalletProvider';\n\ntype ImportWalletConnectSessionParams = {\n /**\n * Whether this session's wallet accounts should be added to the dynamic's wallet accounts.\n */\n addToDynamicWalletAccounts?: boolean;\n\n /**\n * The session topic of the WalletConnect session.\n */\n sessionTopic: string;\n\n /**\n * The function that builds the wallet provider for the session.\n */\n walletProviderBuilder: WalletProviderBuilder;\n};\n\n/**\n * This is a lower level function that is used to connect a WalletConnect session to the Dynamic SDK.\n * It will generate the wallet providers and wallet accounts for all accounts in the session.\n *\n * @param sessionTopic - The session topic of the WalletConnect session.\n * @param addToDynamicWalletAccounts - Whether to add the wallet accounts to the dynamic's wallet accounts.\n * @param client - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The wallet accounts.\n * @not-instrumented\n */\nexport const importWalletConnectSession = async (\n {\n addToDynamicWalletAccounts = true,\n sessionTopic,\n walletProviderBuilder,\n }: ImportWalletConnectSessionParams,\n client: DynamicClient\n): Promise<{ walletAccounts: WalletAccount[] }> => {\n /**\n * You would normally get the session from the signClient.connect method. It takes the optionalNamespaces as an argument.\n *\n * Each chain should build its own \"connectWithWalletConnect<chain-name>\" function.\n * Understand how to build the optionalNamespaces object:\n *\n * The namespace configurations are used at the time a wallet application receives the connection URI.\n * It will use the configurations we supply to understand which methods, events and networks it should provide.\n *\n * The wallet application will then accept the connection request and, in the session`object, provide its own namespace object\n * in return, which will contain the methods, events and networks it does in fact support, as well as\n * which accounts are available.\n *\n * WalletConnect expects namespaces defined in the following format:\n * ```typescript\n * {\n * <namespaceKey>: {\n * \"accounts\": [\"<account1>\", \"<account2>\", \"<account3>\", ...],\n * \"events\": [\"accountsChanged\", \"chainChanged\", \"disconnected\"],\n * \"methods\": [\"personal_sign\", \"eth_sendTransaction\", \"eth_accounts\", ...],\n * \"chains\": [\"<chain1>\", \"<chain2>\", \"<chain3>\", ...]\n * },\n * ...\n * }\n * ```\n *\n * Where each account is a CAIP-10 formatted string, for example: \"eip155:1:0x1234567890\"\n * — see docs: https://chainagnostic.org/CAIPs/caip-10\n *\n * Where each chain is a CAIP-2 formatted string, for example: \"eip155:1\"\n * — see docs: https://chainagnostic.org/CAIPs/caip-2\n */\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n const walletProvider = await walletProviderBuilder({ sessionTopic }, client);\n\n walletProviderRegistry.register({\n priority: WalletProviderPriority.WALLET_SDK,\n walletProvider,\n });\n\n const walletAccounts = createWalletAccountsForWalletConnectWalletProvider({\n walletProvider,\n });\n\n const existingWalletAccounts = getWalletAccounts(client);\n\n /**\n * Keep track of which of the new wallet accounts are unverified to add later.\n */\n const unverifiedWalletAccounts: {\n isNew: boolean;\n walletAccount: WalletAccount;\n }[] = [];\n\n let walletAccountsChanged = false;\n\n /**\n * For all verified wallet accounts that are tied to this session, we need to update\n * the map of verified credential to wallet provider key\n */\n const verifiedCredentialIdToWalletProviderKeyMap: Record<string, string> = {};\n\n walletAccounts.forEach((walletAccount) => {\n const matchingWalletAccount = existingWalletAccounts.find(\n (existingWalletAccount) => existingWalletAccount.id === walletAccount.id\n );\n\n const matchingVerifiedCredentialId =\n matchingWalletAccount?.verifiedCredentialId;\n\n if (!matchingVerifiedCredentialId) {\n unverifiedWalletAccounts.push({\n isNew: !matchingWalletAccount,\n walletAccount,\n });\n } else {\n // This ensures later calls to getWalletAccounts will reconstruct the wallet accounts with\n // the correct wallet provider key\n verifiedCredentialIdToWalletProviderKeyMap[matchingVerifiedCredentialId] =\n walletProvider.key;\n\n // This ensures the wallet accounts returned by this function have the correct verified credential id\n walletAccount.verifiedCredentialId = matchingVerifiedCredentialId;\n }\n });\n\n if (Object.keys(verifiedCredentialIdToWalletProviderKeyMap).length > 0) {\n updateWalletProviderKeysForVerifiedCredentials(\n { keysToUpdate: verifiedCredentialIdToWalletProviderKeyMap },\n client\n );\n\n walletAccountsChanged = true;\n }\n\n if (addToDynamicWalletAccounts && unverifiedWalletAccounts.length > 0) {\n walletAccountsChanged = true;\n\n const unverifiedWalletAccountsToUpdate = unverifiedWalletAccounts.map(\n ({ walletAccount }) => walletAccount\n );\n\n setUnverifiedWalletAccounts({ unverifiedWalletAccountsToUpdate }, client);\n\n const newWalletAccounts = unverifiedWalletAccounts\n .filter(({ isNew }) => isNew)\n .map(({ walletAccount }) => walletAccount);\n\n for (const walletAccount of newWalletAccounts) {\n void createVisit({ walletAccount }, client);\n }\n }\n\n if (walletAccountsChanged) {\n emitWalletAccountsChangedEvent(client);\n }\n\n return { walletAccounts };\n};\n","import type {\n Chain,\n DynamicClient,\n VerifyResponse,\n} from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n updateAuthFromVerifyResponse,\n verifyMessageSignatureOwnership,\n} from '@dynamic-labs-sdk/client/core';\nimport { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\nimport type { AuthTypes } from '@walletconnect/types';\nimport { formatMessage } from '@walletconnect/utils';\n\nconst getAddressFromIss = (iss: string) => iss.split(':')[4];\n\ntype VerifyWalletConnectAuthsParams = {\n auths: AuthTypes.Cacao[];\n chain: Chain;\n walletDisplayName: string;\n};\n\n/** @not-instrumented */\n \nexport const verifyWalletConnectAuths = async (\n { auths, chain, walletDisplayName }: VerifyWalletConnectAuthsParams,\n client: DynamicClient\n) => {\n /**\n * The only differences between each auth object will be the signature (auth.s.s)\n * and the iss (auth.p.iss).\n *\n * The iss is comprised of 2 WC fields that are irrelevant to us and then the CAIP-10 token\n * of the address, where the first 2 fields are also split by the \":\" character.\n *\n * Usually, there will be multiple auths if the wallet app bundles signatures for multiple\n * networks at once, so the only field that will change among auth iss will be the networkId under iss.\n *\n * Docs on Cacao: https://chainagnostic.org/CAIPs/caip-74\n */\n const visitedAddresses = new Set<string>();\n\n const authsFilteredByAddress = auths.filter((auth) => {\n const address = getAddressFromIss(auth.p.iss);\n\n if (!address || visitedAddresses.has(address)) {\n return false;\n }\n\n visitedAddresses.add(address);\n\n return true;\n });\n\n let lastResponse: VerifyResponse | undefined = undefined;\n\n /**\n * WalletConnect's auth object is what they call a \"Cacao\" object, with data on the SIWE message\n * and the signature itself.\n * By consulting how they implemented their \"validateSignedCacao\" function,\n * we are able to reconstruct the original message which can be used to verify the signature\n * in our backend.\n */\n for (const auth of authsFilteredByAddress) {\n const publicWalletAddress = getAddressFromIss(auth.p.iss);\n\n assertDefined(\n publicWalletAddress,\n `Unable to get public wallet address from WalletConnect Cacao object iss: ${auth.p.iss}`\n );\n\n const messageToSign = formatMessage(auth.p, auth.p.iss);\n\n const signature = auth.s.s;\n\n lastResponse = await verifyMessageSignatureOwnership(\n {\n chain,\n messageToSign,\n signature,\n walletAddress: publicWalletAddress,\n walletDisplayName,\n walletProviderType: WalletProviderEnum.WalletConnect,\n },\n client\n );\n }\n\n if (!lastResponse) {\n return;\n }\n\n /**\n * Adds the user with the new wallet verified credentials\n * This will add the new verified wallet accounts to the client`s state\n */\n updateAuthFromVerifyResponse({ response: lastResponse }, client);\n};\n","import type { Chain, DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n type WalletAccount,\n verifyWalletAccount,\n} from '@dynamic-labs-sdk/client';\nimport type { AuthTypes } from '@walletconnect/types';\n\nimport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\nimport { importWalletConnectSession } from '../importWalletConnectSession';\nimport { verifyWalletConnectAuths } from './verifyWalletConnectAuths';\n\ntype ImportWalletConnectAuthResponseParams = {\n /**\n * The response from the WalletConnect authenticate method.\n */\n authResponse: AuthTypes.AuthenticateResponseResult;\n\n /**\n * The chain with which the wallet account is associated.\n */\n chain: Chain;\n\n /**\n * The function that builds the wallet provider for the session.\n */\n walletProviderBuilder: WalletProviderBuilder;\n};\n\n/**\n * A low level function that is used to connect a WalletConnect authenticate response to the Dynamic SDK.\n * It will generate the wallet providers and wallet accounts for all accounts in the session.\n *\n * @see WalletConnect's docs on [session authentication](https://docs.reown.com/advanced/api/sign/dapp-usage#session-authenticate-with-recaps)\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the connected and verified wallet account.\n * @not-instrumented\n */\nexport const importWalletConnectAuthResponse = async (\n {\n authResponse,\n chain,\n walletProviderBuilder,\n }: ImportWalletConnectAuthResponseParams,\n client: DynamicClient\n): Promise<{ walletAccounts: WalletAccount[] }> => {\n const { session, auths } = authResponse;\n\n /**\n * Some wallets do not support WC's authenticate method (such as Rainbow).\n * For these wallets, the authenticate method will act as a regular connect method.\n * Therefore we must call verify individually.\n */\n if (!auths || auths.length === 0) {\n const { walletAccounts } = await importWalletConnectSession(\n {\n /**\n * Don't add the wallet accounts to the dynamic's wallet accounts while we are still verifying them.\n */\n addToDynamicWalletAccounts: false,\n sessionTopic: session.topic,\n walletProviderBuilder,\n },\n client\n );\n\n // This should not be concurrent because the first will be a verify and the rest will be a link\n for (const walletAccount of walletAccounts) {\n await verifyWalletAccount({ walletAccount }, client);\n }\n\n return { walletAccounts };\n }\n\n /**\n * This reconstructs the message that was signed by the wallet and verifies the signature\n * in the backend. It will update the user with the new verified credentials.\n */\n await verifyWalletConnectAuths(\n {\n auths,\n chain,\n walletDisplayName: session.peer.metadata.name,\n },\n client\n );\n\n const { walletAccounts } = await importWalletConnectSession(\n {\n addToDynamicWalletAccounts: true,\n sessionTopic: session.topic,\n walletProviderBuilder,\n },\n client\n );\n\n return { walletAccounts };\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { assertDefined, getCore } from '@dynamic-labs-sdk/client/core';\nimport SignClient from '@walletconnect/sign-client';\n\n/** @not-instrumented */\nexport const createSignClient = async (client: DynamicClient) => {\n const core = getCore(client);\n\n assertDefined(client.projectSettings, 'Project settings not available');\n\n const generalSettings = client.projectSettings.general;\n\n assertDefined(\n generalSettings.displayName,\n 'Please configure an app name in dashboard to use WalletConnect'\n );\n\n const projectId = client.projectSettings.sdk.walletConnect?.projectId;\n\n assertDefined(\n projectId,\n 'Please configure a project ID for WalletConnect in dashboard'\n );\n\n const customStoragePrefix = `dynamic_${core.environmentId}_walletconnect`;\n\n const displayName = core.metadata?.name ?? generalSettings.displayName;\n\n const appLogo = core.metadata?.iconUrl ?? generalSettings.appLogo;\n\n return SignClient.init({\n customStoragePrefix,\n metadata: {\n description: '',\n icons: appLogo ? [appLogo] : [],\n name: displayName,\n redirect: {\n native: core.metadata?.nativeLink,\n universal: core.metadata?.universalLink,\n },\n url: core.metadata?.universalLink ?? '',\n },\n projectId,\n });\n};\n","import { createRuntimeServiceAccessKey } from '@dynamic-labs-sdk/client/core';\n\nimport { createSignClient } from './createSignClient';\n\nexport const getSignClient = createRuntimeServiceAccessKey(\n 'walletConnectSignClient',\n (client) => createSignClient(client)\n);\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport { name, version } from '../../package.json';\n\nassertPackageVersion(name, version);\n\nexport { createWalletConnectSessionEventEmitter } from '../createWalletConnectSessionEventEmitter';\nexport { SessionClosedUnexpectedlyError } from '../errors/SessionClosedUnexpectedlyError';\nexport { importWalletConnectAuthResponse } from '../importWalletConnectAuthResponse';\nexport { importWalletConnectSession } from '../importWalletConnectSession';\nexport { getSignClient } from '../signClient/getSignClient';\nexport { splitCaip10Token } from '../splitCaip10Token';\nexport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAa,oBAAoB,gBAAwB;CACvD,MAAM,CAAC,cAAc,WAAW,WAAW,YAAY,MAAM,IAAI;AACjE,QAAO;EAAE;EAAS;EAAc;EAAW;;;;;;;;;;;;;;;;;;ACyB7C,MAAa,0CAA0C,EACrD,eACA,YACA,cACA,cACA,iBACkD;AAClD,QAAO,iCACL;EACE,uBAAuB,EAAE,kBAAkB,yBAAyB;AAClE,cAAW,IAAI,iBAAiB,mBAAmB;;EAGrD,sBAAsB,EACpB,uBACA,oBACA,2BACI;GACJ,MAAM,sBAAsB,EAC1B,QAAQ,EAAE,SACV,YACyB;AACzB,QAAI,UAAU,aACZ;AAGF,QAAI,MAAM,SAAS,gBAAgB;KACjC,MAAM,eAAe,MAAM;AAO3B,0BAAqB,EAAE,WAJL,aAAa,WAAW,GAAG,aAAa,GAAG,GACzD,aAAa,MAAM,IAAI,CAAC,KACxB,cAE8B,CAAC;AAEnC;;AAGF,QAAI,MAAM,SAAS,mBAAmB;KACpC,MAAM,gBAAgB,MAAM;AAe5B,2BAAsB,EAAE,WAbN,iBAChB,cAAc,KAAK,YAAY;AAE7B,UAAI,QAAQ,WAAW,GAAG,aAAa,GAAG,CACxC,QAAO,iBAAiB,QAAQ,CAAC;AAGnC,aAAO;OACP,CACH,CAAC,KAAK,YACL,gBAAgB,cAAc,QAAQ,GAAG,QAC1C,EAEkC,CAAC;AAEpC;;AAGF,QAAI,MAAM,SAAS,gBAAgB;AACjC,yBAAoB;AAEpB;;;AA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,UAAU,iBAAiB;GACtC;EACD;EACD,CAAC;;;;;ACvCJ,MAAa,gBAAgB,8BAC3B,4BACC,WAAW,iBAAiB,OAAO,CACrC;;;;ACHD,qBAAqB,MAAM,QAAQ"}
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- const require_SessionClosedUnexpectedlyError = require('./SessionClosedUnexpectedlyError-CXziI2_f.cjs.js');
1
+ const require_SessionClosedUnexpectedlyError = require('./SessionClosedUnexpectedlyError-DImFYi-T.cjs.js');
2
2
  const require_core = require('./core.cjs.js');
3
3
  let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
4
4
  let _walletconnect_utils = require("@walletconnect/utils");
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as name, r as version, t as SessionClosedUnexpectedlyError } from "./SessionClosedUnexpectedlyError-yC5QgGik.esm.js";
1
+ import { n as name, r as version, t as SessionClosedUnexpectedlyError } from "./SessionClosedUnexpectedlyError-B20TMr3W.esm.js";
2
2
  import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
3
3
  import { SDK_ERRORS as WC_ERRORS } from "@walletconnect/utils";
4
4
  import { WalletProviderEnum } from "@dynamic-labs/sdk-api-core";