@dynamic-labs-sdk/wallet-connect 1.49.1 → 1.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 = "1.49.1";
6
+ var version = "1.51.0";
7
7
 
8
8
  //#endregion
9
9
  //#region src/errors/SessionClosedUnexpectedlyError.ts
@@ -79,4 +79,4 @@ Object.defineProperty(exports, 'version', {
79
79
  return version;
80
80
  }
81
81
  });
82
- //# sourceMappingURL=WalletConnectRelayUnavailableError-Cx0pTzGd.cjs.map
82
+ //# sourceMappingURL=WalletConnectRelayUnavailableError-3Bpg3Ort.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"WalletConnectRelayUnavailableError-Cx0pTzGd.cjs","names":["BaseError","BaseError"],"sources":["../package.json","../src/errors/SessionClosedUnexpectedlyError.ts","../src/errors/WalletConnectRelayUnavailableError.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","import { BaseError } from '@dynamic-labs-sdk/client';\n\n/**\n * Thrown when a WalletConnect connection can't start because the WalletConnect\n * relay can't be reached.\n *\n * Usually the device is offline. In an iOS or Android app, the relay also\n * refuses apps whose bundle id isn't on the WalletConnect project's allowlist.\n *\n * @example\n * ```ts\n * try {\n * await connectWalletOption({ onConnectionUri, walletKey: 'trust' });\n * } catch (error) {\n * if (error instanceof WalletConnectRelayUnavailableError) {\n * showMessage('Couldn’t reach WalletConnect. Check your connection and try again.');\n * }\n * }\n * ```\n * @see withRelayConnectionTimeout\n * @see connectWalletOption\n */\nexport class WalletConnectRelayUnavailableError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'wallet_connect_relay_unavailable',\n details:\n 'Check the device is online. In an iOS or Android app, make sure the app’s bundle id is on your WalletConnect project’s allowlist.',\n docsUrl:\n 'https://docs.walletconnect.com/wallets/react-native/cloud/relay#allowlist',\n name: 'WalletConnectRelayUnavailableError',\n shortMessage: 'Couldn’t reach the WalletConnect relay.',\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;;;;;;;;;;;;;;;;;;;;;;;;;;ACLN,IAAa,qCAAb,cAAwDC,mCAAU;CAChE,cAAc;AACZ,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SACE;GACF,SACE;GACF,MAAM;GACN,cAAc;GACf,CAAC"}
1
+ {"version":3,"file":"WalletConnectRelayUnavailableError-3Bpg3Ort.cjs","names":["BaseError","BaseError"],"sources":["../package.json","../src/errors/SessionClosedUnexpectedlyError.ts","../src/errors/WalletConnectRelayUnavailableError.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","import { BaseError } from '@dynamic-labs-sdk/client';\n\n/**\n * Thrown when a WalletConnect connection can't start because the WalletConnect\n * relay can't be reached.\n *\n * Usually the device is offline. In an iOS or Android app, the relay also\n * refuses apps whose bundle id isn't on the WalletConnect project's allowlist.\n *\n * @example\n * ```ts\n * try {\n * await connectWalletOption({ onConnectionUri, walletKey: 'trust' });\n * } catch (error) {\n * if (error instanceof WalletConnectRelayUnavailableError) {\n * showMessage('Couldn’t reach WalletConnect. Check your connection and try again.');\n * }\n * }\n * ```\n * @see withRelayConnectionTimeout\n * @see connectWalletOption\n */\nexport class WalletConnectRelayUnavailableError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'wallet_connect_relay_unavailable',\n details:\n 'Check the device is online. In an iOS or Android app, make sure the app’s bundle id is on your WalletConnect project’s allowlist.',\n docsUrl:\n 'https://docs.walletconnect.com/wallets/react-native/cloud/relay#allowlist',\n name: 'WalletConnectRelayUnavailableError',\n shortMessage: 'Couldn’t reach the WalletConnect relay.',\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;;;;;;;;;;;;;;;;;;;;;;;;;;ACLN,IAAa,qCAAb,cAAwDC,mCAAU;CAChE,cAAc;AACZ,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SACE;GACF,SACE;GACF,MAAM;GACN,cAAc;GACf,CAAC"}
@@ -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 = "1.49.1";
5
+ var version = "1.51.0";
6
6
 
7
7
  //#endregion
8
8
  //#region src/errors/SessionClosedUnexpectedlyError.ts
@@ -55,4 +55,4 @@ var WalletConnectRelayUnavailableError = class extends BaseError {
55
55
 
56
56
  //#endregion
57
57
  export { version as i, SessionClosedUnexpectedlyError as n, name as r, WalletConnectRelayUnavailableError as t };
58
- //# sourceMappingURL=WalletConnectRelayUnavailableError-BJbTDsHQ.esm.js.map
58
+ //# sourceMappingURL=WalletConnectRelayUnavailableError-Co3EhG2c.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WalletConnectRelayUnavailableError-BJbTDsHQ.esm.js","names":[],"sources":["../package.json","../src/errors/SessionClosedUnexpectedlyError.ts","../src/errors/WalletConnectRelayUnavailableError.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","import { BaseError } from '@dynamic-labs-sdk/client';\n\n/**\n * Thrown when a WalletConnect connection can't start because the WalletConnect\n * relay can't be reached.\n *\n * Usually the device is offline. In an iOS or Android app, the relay also\n * refuses apps whose bundle id isn't on the WalletConnect project's allowlist.\n *\n * @example\n * ```ts\n * try {\n * await connectWalletOption({ onConnectionUri, walletKey: 'trust' });\n * } catch (error) {\n * if (error instanceof WalletConnectRelayUnavailableError) {\n * showMessage('Couldn’t reach WalletConnect. Check your connection and try again.');\n * }\n * }\n * ```\n * @see withRelayConnectionTimeout\n * @see connectWalletOption\n */\nexport class WalletConnectRelayUnavailableError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'wallet_connect_relay_unavailable',\n details:\n 'Check the device is online. In an iOS or Android app, make sure the app’s bundle id is on your WalletConnect project’s allowlist.',\n docsUrl:\n 'https://docs.walletconnect.com/wallets/react-native/cloud/relay#allowlist',\n name: 'WalletConnectRelayUnavailableError',\n shortMessage: 'Couldn’t reach the WalletConnect relay.',\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;;;;;;;;;;;;;;;;;;;;;;;;;;ACLN,IAAa,qCAAb,cAAwD,UAAU;CAChE,cAAc;AACZ,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SACE;GACF,SACE;GACF,MAAM;GACN,cAAc;GACf,CAAC"}
1
+ {"version":3,"file":"WalletConnectRelayUnavailableError-Co3EhG2c.esm.js","names":[],"sources":["../package.json","../src/errors/SessionClosedUnexpectedlyError.ts","../src/errors/WalletConnectRelayUnavailableError.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","import { BaseError } from '@dynamic-labs-sdk/client';\n\n/**\n * Thrown when a WalletConnect connection can't start because the WalletConnect\n * relay can't be reached.\n *\n * Usually the device is offline. In an iOS or Android app, the relay also\n * refuses apps whose bundle id isn't on the WalletConnect project's allowlist.\n *\n * @example\n * ```ts\n * try {\n * await connectWalletOption({ onConnectionUri, walletKey: 'trust' });\n * } catch (error) {\n * if (error instanceof WalletConnectRelayUnavailableError) {\n * showMessage('Couldn’t reach WalletConnect. Check your connection and try again.');\n * }\n * }\n * ```\n * @see withRelayConnectionTimeout\n * @see connectWalletOption\n */\nexport class WalletConnectRelayUnavailableError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'wallet_connect_relay_unavailable',\n details:\n 'Check the device is online. In an iOS or Android app, make sure the app’s bundle id is on your WalletConnect project’s allowlist.',\n docsUrl:\n 'https://docs.walletconnect.com/wallets/react-native/cloud/relay#allowlist',\n name: 'WalletConnectRelayUnavailableError',\n shortMessage: 'Couldn’t reach the WalletConnect relay.',\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;;;;;;;;;;;;;;;;;;;;;;;;;;ACLN,IAAa,qCAAb,cAAwD,UAAU;CAChE,cAAc;AACZ,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SACE;GACF,SACE;GACF,MAAM;GACN,cAAc;GACf,CAAC"}
package/dist/core.cjs 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_WalletConnectRelayUnavailableError = require('./WalletConnectRelayUnavailableError-Cx0pTzGd.cjs');
28
+ const require_WalletConnectRelayUnavailableError = require('./WalletConnectRelayUnavailableError-3Bpg3Ort.cjs');
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");
@@ -52,9 +52,9 @@ _walletconnect_sign_client = __toESM(_walletconnect_sign_client);
52
52
  * @notInstrumented
53
53
  */
54
54
  const splitCaip10Token = (caip10Token) => {
55
- const [namespaceKey, networkId, address] = caip10Token.split(":");
55
+ const [namespaceKey, networkId, ...addressParts] = caip10Token.split(":");
56
56
  return {
57
- address,
57
+ address: addressParts.join(":"),
58
58
  namespaceKey,
59
59
  networkId
60
60
  };
package/dist/core.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"core.cjs","names":["WalletProviderPriority","lastResponse: VerifyResponse | undefined","WalletProviderEnum","walletAccounts","BaseError","version","request: IDBOpenDBRequest","SignClient","timeoutId: ReturnType<typeof setTimeout> | undefined","topic: string","WalletConnectRelayUnavailableError","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/errors/WalletConnectStoreUpgradeBlockedError.ts","../src/signClient/getSignClient/createSignClient/ensureWalletConnectStore/ensureWalletConnectStore.ts","../src/signClient/getSignClient/createSignClient/createSignClient.ts","../src/signClient/getSignClient/getSignClient.ts","../src/withRelayConnectionTimeout/withRelayConnectionTimeout.ts","../src/exports/core.ts"],"sourcesContent":["type SplitCaip10TokenResult = {\n address: string;\n namespaceKey: string;\n networkId: string;\n};\n\n/**\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 * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param\nexport const splitCaip10Token = (\n caip10Token: string\n): SplitCaip10TokenResult => {\n const [namespaceKey, networkId, address] = caip10Token.split(':');\n return { address, namespaceKey, networkId };\n};\n","import {\n type WalletProvider,\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\ntype WalletConnectSessionEventEmitter = {\n cleanupEventEmitter: () => void;\n getEventEmitter: () => WalletProvider['events'];\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 * @notInstrumented\n */\nexport const createWalletConnectSessionEventEmitter = ({\n formatAddress,\n getSession,\n namespaceKey,\n sessionTopic,\n signClient,\n}: CreateWalletConnectSessionEventEmitterParams): WalletConnectSessionEventEmitter => {\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/** @notInstrumented */\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, WalletAccount } from '@dynamic-labs-sdk/client';\nimport {\n WalletProviderPriority,\n getWalletProviderRegistry,\n reconcileWalletAccountsAgainstClient,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { createWalletAccountsForWalletConnectWalletProvider } from '../createWalletAccountsForWalletConnectWalletProvider';\nimport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\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\ntype ImportWalletConnectSessionResult = { walletAccounts: WalletAccount[] };\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 * @notInstrumented\n */\nexport const importWalletConnectSession = async (\n {\n addToDynamicWalletAccounts = true,\n sessionTopic,\n walletProviderBuilder,\n }: ImportWalletConnectSessionParams,\n client: DynamicClient\n): Promise<ImportWalletConnectSessionResult> => {\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 reconciledWalletAccounts = reconcileWalletAccountsAgainstClient(\n {\n addToDynamicWalletAccounts,\n walletAccounts,\n walletProviderKey: walletProvider.key,\n },\n client\n );\n\n return { walletAccounts: reconciledWalletAccounts };\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): string => iss.split(':')[4];\n\ntype VerifyWalletConnectAuthsParams = {\n auths: AuthTypes.Cacao[];\n chain: Chain;\n walletDisplayName: string;\n};\n\n/** @notInstrumented */\n\nexport const verifyWalletConnectAuths = async (\n { auths, chain, walletDisplayName }: VerifyWalletConnectAuthsParams,\n client: DynamicClient\n): Promise<void> => {\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\ntype ImportWalletConnectAuthResponseResult = {\n walletAccounts: WalletAccount[];\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 * @notInstrumented\n */\nexport const importWalletConnectAuthResponse = async (\n {\n authResponse,\n chain,\n walletProviderBuilder,\n }: ImportWalletConnectAuthResponseParams,\n client: DynamicClient\n): Promise<ImportWalletConnectAuthResponseResult> => {\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 { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class WalletConnectStoreUpgradeBlockedError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'wallet_connect_store_upgrade_blocked_error',\n docsUrl: null,\n name: 'WalletConnectStoreUpgradeBlockedError',\n shortMessage:\n 'WalletConnect IndexedDB store upgrade was blocked by another open connection',\n });\n }\n}\n","import { WalletConnectStoreUpgradeBlockedError } from '../../../../errors/WalletConnectStoreUpgradeBlockedError';\n\n// WalletConnect persists its pairing and session data in this IndexedDB\n// database and object store (see the browser build of\n// @walletconnect/keyvaluestorage). We reference them here so we can repair a\n// missing object store before SignClient opens the connection.\nconst WALLET_CONNECT_DB_NAME = 'WALLET_CONNECT_V2_INDEXED_DB';\nconst WALLET_CONNECT_STORE_NAME = 'keyvaluestorage';\n\n// WalletConnect's storage uses an out-of-line object store (idb-keyval's\n// createObjectStore with no keyPath). We must recreate it with the same shape\n// so WalletConnect keeps reading and writing it exactly as before.\nconst createStoreIfMissing = (db: IDBDatabase): void => {\n if (!db.objectStoreNames.contains(WALLET_CONNECT_STORE_NAME)) {\n db.createObjectStore(WALLET_CONNECT_STORE_NAME);\n }\n};\n\n/** @notInstrumented */\nconst openConnection = (version?: number): Promise<IDBDatabase> =>\n new Promise((resolve, reject) => {\n const shouldUseCurrentVersion = version === undefined;\n\n let request: IDBOpenDBRequest;\n if (shouldUseCurrentVersion) {\n request = indexedDB.open(WALLET_CONNECT_DB_NAME);\n } else {\n request = indexedDB.open(WALLET_CONNECT_DB_NAME, version);\n }\n\n request.onupgradeneeded = () => createStoreIfMissing(request.result);\n request.onsuccess = () => resolve(request.result);\n request.onerror = () => reject(request.error as Error);\n // A version-bump upgrade is blocked when another connection (another tab, or\n // WalletConnect's own cached idb-keyval connection) still holds the database\n // open. IndexedDB then fires neither success nor error, so we reject to keep\n // the promise from hanging; the caller swallows it and lets SignClient.init\n // proceed exactly as it would without this repair step.\n request.onblocked = () =>\n reject(new WalletConnectStoreUpgradeBlockedError() as Error);\n });\n\n// eslint-disable-next-line custom-rules/one-function-per-file\nconst repairMissingStore = async (): Promise<void> => {\n const db = await openConnection();\n const hasStore = db.objectStoreNames.contains(WALLET_CONNECT_STORE_NAME);\n const currentVersion = db.version;\n db.close();\n\n if (hasStore) {\n return;\n }\n\n // Reopening at the same version won't re-run onupgradeneeded, so the store\n // would stay missing. Bumping the version triggers an upgrade that recreates\n // only the missing store, leaving any other stored data intact.\n const upgradedDb = await openConnection(currentVersion + 1);\n upgradedDb.close();\n};\n\n/**\n * Ensures WalletConnect's IndexedDB object store exists before SignClient opens\n * the connection. On iOS WebKit an upgrade interrupted by a webview reload can\n * leave the `WALLET_CONNECT_V2_INDEXED_DB` database committed at its version\n * with the object store never created; every subsequent WalletConnect read or\n * write then throws NotFoundError (\"one of the specified object stores was not\n * found\") until the store is recreated.\n *\n * The store is recreated with a version bump — the database is never deleted,\n * so no session data is lost. This is a best-effort no-op for healthy databases\n * and for environments without IndexedDB (SSR, React Native), so it cannot\n * regress the default WalletConnect behaviour: on any failure SignClient.init\n * proceeds exactly as it would without this step.\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/one-function-per-file\nexport const ensureWalletConnectStore = async (): Promise<void> => {\n if (typeof indexedDB === 'undefined') {\n return;\n }\n\n try {\n await repairMissingStore();\n } catch {\n // Best-effort pre-flight repair. Swallowing lets SignClient.init proceed as\n // it would without this step, so WalletConnect is never left worse off.\n }\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n getAppMetadata,\n getCore,\n getCurrentPageUrl,\n} from '@dynamic-labs-sdk/client/core';\nimport SignClient from '@walletconnect/sign-client';\n\nimport { ensureWalletConnectStore } from './ensureWalletConnectStore';\n\n/** @notInstrumented */\nexport const createSignClient = async (\n client: DynamicClient\n): Promise<SignClient> => {\n const core = getCore(client);\n\n assertDefined(client.projectSettings, 'Project settings not available');\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 { appName, appLogoUrl, appNativeLink, appUniversalLink } =\n getAppMetadata(client);\n\n assertDefined(\n appName,\n 'Please configure an app name in dashboard or DynamicClient metadata to use WalletConnect'\n );\n\n const customStoragePrefix = `dynamic_${core.environmentId}_walletconnect`;\n\n // Recreate WalletConnect's IndexedDB object store if a webview reload left it\n // missing, otherwise SignClient.init would throw NotFoundError on iOS WebKit.\n await ensureWalletConnectStore();\n\n // Some wallets (e.g. Backpack) return the user through this `redirect`\n // metadata; without it they open the dapp in the system browser. Default to\n // the current page on web, stripped of query/fragment which may carry auth\n // credentials.\n const fallbackUniversalLink = getCurrentPageUrl()?.split(/[?#]/)[0];\n\n return SignClient.init({\n customStoragePrefix,\n metadata: {\n description: '',\n icons: appLogoUrl ? [appLogoUrl] : [],\n name: appName,\n redirect: {\n native: appNativeLink,\n universal: appUniversalLink ?? fallbackUniversalLink,\n },\n url: appUniversalLink ?? fallbackUniversalLink ?? '',\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 type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getCore } from '@dynamic-labs-sdk/client/core';\nimport type SignClient from '@walletconnect/sign-client';\nimport { parseUri } from '@walletconnect/utils';\n\nimport { WalletConnectRelayUnavailableError } from '../errors/WalletConnectRelayUnavailableError';\n\n/** How long creating a pairing may wait for the relay before giving up. */\nexport const RELAY_CONNECTION_TIMEOUT_MS = 10_000;\n\ntype WithRelayConnectionTimeoutParams<T extends { uri?: string }> = {\n /** The Dynamic client instance, for logging. */\n client: DynamicClient;\n /** Creates the pairing, e.g. `signClient.connect(...)`. */\n createPairing: () => Promise<T>;\n /** The client the pairing is created on. */\n signClient: SignClient;\n /** Overrides {@link RELAY_CONNECTION_TIMEOUT_MS}. */\n timeoutMs?: number;\n};\n\n/**\n * Creates a WalletConnect pairing, failing with\n * `WalletConnectRelayUnavailableError` when the relay can't be reached in time.\n *\n * Pairing waits for the relay connection with no timeout of its own, so an\n * offline device or a refused app would otherwise wait forever. A pairing that\n * lands after the timeout is disconnected, so nothing is left for a wallet to\n * approve.\n *\n * @example\n * ```ts\n * const { approval, uri } = await withRelayConnectionTimeout({\n * client,\n * createPairing: () => signClient.connect({ optionalNamespaces }),\n * signClient,\n * });\n * ```\n *\n * @param params.client - The Dynamic client instance, for logging.\n * @param params.createPairing - Creates the pairing.\n * @param params.signClient - The client the pairing is created on.\n * @param [params.timeoutMs] - How long to wait for the relay.\n * @returns What `createPairing` resolved with.\n * @throws WalletConnectRelayUnavailableError If pairing creation outlasts the timeout.\n * @see getSignClient\n * @see WalletConnectRelayUnavailableError\n * @notInstrumented\n */\nexport const withRelayConnectionTimeout = async <T extends { uri?: string }>({\n client,\n createPairing,\n signClient,\n timeoutMs = RELAY_CONNECTION_TIMEOUT_MS,\n}: WithRelayConnectionTimeoutParams<T>): Promise<T> => {\n const { logger } = getCore(client);\n let timedOut = false;\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n\n const pairing = createPairing();\n\n // Best effort: a failure here must not surface after the caller has already\n // been told the relay is unavailable.\n void pairing.then(async ({ uri }) => {\n if (!timedOut || !uri) return;\n\n let topic: string;\n try {\n ({ topic } = parseUri(uri));\n } catch (error) {\n logger.error(\n '[withRelayConnectionTimeout] Failed to parse URI for cleanup',\n { error, uri }\n );\n return;\n }\n\n try {\n await signClient.core.pairing.disconnect({ topic });\n } catch (error) {\n logger.error(\n '[withRelayConnectionTimeout] Failed to disconnect a pairing that landed after the relay timeout',\n { error, topic }\n );\n }\n }, () => undefined);\n\n const timeout = new Promise<void>((resolve) => {\n timeoutId = setTimeout(resolve, timeoutMs);\n }).then(() => {\n timedOut = true;\n logger.warn(\n `[withRelayConnectionTimeout] Relay unreachable after ${timeoutMs}ms`\n );\n throw new WalletConnectRelayUnavailableError();\n });\n\n try {\n return await Promise.race([pairing, timeout]);\n } finally {\n clearTimeout(timeoutId);\n }\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 { WalletConnectRelayUnavailableError } from '../errors/WalletConnectRelayUnavailableError';\nexport { importWalletConnectAuthResponse } from '../importWalletConnectAuthResponse';\nexport { importWalletConnectSession } from '../importWalletConnectSession';\nexport { getSignClient } from '../signClient/getSignClient';\nexport { splitCaip10Token } from '../splitCaip10Token';\nexport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\nexport { withRelayConnectionTimeout } from '../withRelayConnectionTimeout';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,oBACX,gBAC2B;CAC3B,MAAM,CAAC,cAAc,WAAW,WAAW,YAAY,MAAM,IAAI;AACjE,QAAO;EAAE;EAAS;EAAc;EAAW;;;;;;;;;;;;;;;;;;ACsB7C,MAAa,0CAA0C,EACrD,eACA,YACA,cACA,cACA,iBACoF;AACpF,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,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;;;AAKJ,eAAY;AAEZ,c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AAC,WAAW,GAAG,EAAE;GACrC,MAAM;GACN,UAAU;IACR,QAAQ;IACR,WAAW,oBAAoB;IAChC;GACD,KAAK,oBAAoB,yBAAyB;GACnD;EACD;EACD,CAAC;;;;;ACvDJ,MAAa,iFACX,4BACC,WAAW,iBAAiB,OAAO,CACrC;;;;;ACCD,MAAa,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyC3C,MAAa,6BAA6B,OAAmC,EAC3E,QACA,eACA,YACA,YAAY,kCACyC;CACrD,MAAM,EAAE,sDAAmB,OAAO;CAClC,IAAI,WAAW;CACf,IAAIC;CAEJ,MAAM,UAAU,eAAe;AAI/B,CAAK,QAAQ,KAAK,OAAO,EAAE,UAAU;AACnC,MAAI,CAAC,YAAY,CAAC,IAAK;EAEvB,IAAIC;AACJ,MAAI;AACF,IAAC,CAAE,4CAAmB,IAAI;WACnB,OAAO;AACd,UAAO,MACL,gEACA;IAAE;IAAO;IAAK,CACf;AACD;;AAGF,MAAI;AACF,SAAM,WAAW,KAAK,QAAQ,WAAW,EAAE,OAAO,CAAC;WAC5C,OAAO;AACd,UAAO,MACL,mGACA;IAAE;IAAO;IAAO,CACjB;;UAEI,OAAU;CAEnB,MAAM,UAAU,IAAI,SAAe,YAAY;AAC7C,cAAY,WAAW,SAAS,UAAU;GAC1C,CAAC,WAAW;AACZ,aAAW;AACX,SAAO,KACL,wDAAwD,UAAU,IACnE;AACD,QAAM,IAAIC,+EAAoC;GAC9C;AAEF,KAAI;AACF,SAAO,MAAM,QAAQ,KAAK,CAAC,SAAS,QAAQ,CAAC;WACrC;AACR,eAAa,UAAU;;;;;;mEChGNC,iDAAMC,mDAAQ"}
1
+ {"version":3,"file":"core.cjs","names":["WalletProviderPriority","lastResponse: VerifyResponse | undefined","WalletProviderEnum","walletAccounts","BaseError","version","request: IDBOpenDBRequest","SignClient","timeoutId: ReturnType<typeof setTimeout> | undefined","topic: string","WalletConnectRelayUnavailableError","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/errors/WalletConnectStoreUpgradeBlockedError.ts","../src/signClient/getSignClient/createSignClient/ensureWalletConnectStore/ensureWalletConnectStore.ts","../src/signClient/getSignClient/createSignClient/createSignClient.ts","../src/signClient/getSignClient/getSignClient.ts","../src/withRelayConnectionTimeout/withRelayConnectionTimeout.ts","../src/exports/core.ts"],"sourcesContent":["type SplitCaip10TokenResult = {\n address: string;\n namespaceKey: string;\n networkId: string;\n};\n\n/**\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 * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param\nexport const splitCaip10Token = (\n caip10Token: string\n): SplitCaip10TokenResult => {\n const [namespaceKey, networkId, ...addressParts] =\n caip10Token.split(':');\n // Some chains (e.g. TON raw `workchain:hash` addresses) carry colons in\n // the address itself, so everything after the network id is the address.\n const address = addressParts.join(':');\n return { address, namespaceKey, networkId };\n};\n","import {\n type WalletProvider,\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\ntype WalletConnectSessionEventEmitter = {\n cleanupEventEmitter: () => void;\n getEventEmitter: () => WalletProvider['events'];\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 * @notInstrumented\n */\nexport const createWalletConnectSessionEventEmitter = ({\n formatAddress,\n getSession,\n namespaceKey,\n sessionTopic,\n signClient,\n}: CreateWalletConnectSessionEventEmitterParams): WalletConnectSessionEventEmitter => {\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/** @notInstrumented */\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, WalletAccount } from '@dynamic-labs-sdk/client';\nimport {\n WalletProviderPriority,\n getWalletProviderRegistry,\n reconcileWalletAccountsAgainstClient,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { createWalletAccountsForWalletConnectWalletProvider } from '../createWalletAccountsForWalletConnectWalletProvider';\nimport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\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\ntype ImportWalletConnectSessionResult = { walletAccounts: WalletAccount[] };\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 * @notInstrumented\n */\nexport const importWalletConnectSession = async (\n {\n addToDynamicWalletAccounts = true,\n sessionTopic,\n walletProviderBuilder,\n }: ImportWalletConnectSessionParams,\n client: DynamicClient\n): Promise<ImportWalletConnectSessionResult> => {\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 reconciledWalletAccounts = reconcileWalletAccountsAgainstClient(\n {\n addToDynamicWalletAccounts,\n walletAccounts,\n walletProviderKey: walletProvider.key,\n },\n client\n );\n\n return { walletAccounts: reconciledWalletAccounts };\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): string => iss.split(':')[4];\n\ntype VerifyWalletConnectAuthsParams = {\n auths: AuthTypes.Cacao[];\n chain: Chain;\n walletDisplayName: string;\n};\n\n/** @notInstrumented */\n\nexport const verifyWalletConnectAuths = async (\n { auths, chain, walletDisplayName }: VerifyWalletConnectAuthsParams,\n client: DynamicClient\n): Promise<void> => {\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\ntype ImportWalletConnectAuthResponseResult = {\n walletAccounts: WalletAccount[];\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 * @notInstrumented\n */\nexport const importWalletConnectAuthResponse = async (\n {\n authResponse,\n chain,\n walletProviderBuilder,\n }: ImportWalletConnectAuthResponseParams,\n client: DynamicClient\n): Promise<ImportWalletConnectAuthResponseResult> => {\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 { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class WalletConnectStoreUpgradeBlockedError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'wallet_connect_store_upgrade_blocked_error',\n docsUrl: null,\n name: 'WalletConnectStoreUpgradeBlockedError',\n shortMessage:\n 'WalletConnect IndexedDB store upgrade was blocked by another open connection',\n });\n }\n}\n","import { WalletConnectStoreUpgradeBlockedError } from '../../../../errors/WalletConnectStoreUpgradeBlockedError';\n\n// WalletConnect persists its pairing and session data in this IndexedDB\n// database and object store (see the browser build of\n// @walletconnect/keyvaluestorage). We reference them here so we can repair a\n// missing object store before SignClient opens the connection.\nconst WALLET_CONNECT_DB_NAME = 'WALLET_CONNECT_V2_INDEXED_DB';\nconst WALLET_CONNECT_STORE_NAME = 'keyvaluestorage';\n\n// WalletConnect's storage uses an out-of-line object store (idb-keyval's\n// createObjectStore with no keyPath). We must recreate it with the same shape\n// so WalletConnect keeps reading and writing it exactly as before.\nconst createStoreIfMissing = (db: IDBDatabase): void => {\n if (!db.objectStoreNames.contains(WALLET_CONNECT_STORE_NAME)) {\n db.createObjectStore(WALLET_CONNECT_STORE_NAME);\n }\n};\n\n/** @notInstrumented */\nconst openConnection = (version?: number): Promise<IDBDatabase> =>\n new Promise((resolve, reject) => {\n const shouldUseCurrentVersion = version === undefined;\n\n let request: IDBOpenDBRequest;\n if (shouldUseCurrentVersion) {\n request = indexedDB.open(WALLET_CONNECT_DB_NAME);\n } else {\n request = indexedDB.open(WALLET_CONNECT_DB_NAME, version);\n }\n\n request.onupgradeneeded = () => createStoreIfMissing(request.result);\n request.onsuccess = () => resolve(request.result);\n request.onerror = () => reject(request.error as Error);\n // A version-bump upgrade is blocked when another connection (another tab, or\n // WalletConnect's own cached idb-keyval connection) still holds the database\n // open. IndexedDB then fires neither success nor error, so we reject to keep\n // the promise from hanging; the caller swallows it and lets SignClient.init\n // proceed exactly as it would without this repair step.\n request.onblocked = () =>\n reject(new WalletConnectStoreUpgradeBlockedError() as Error);\n });\n\n// eslint-disable-next-line custom-rules/one-function-per-file\nconst repairMissingStore = async (): Promise<void> => {\n const db = await openConnection();\n const hasStore = db.objectStoreNames.contains(WALLET_CONNECT_STORE_NAME);\n const currentVersion = db.version;\n db.close();\n\n if (hasStore) {\n return;\n }\n\n // Reopening at the same version won't re-run onupgradeneeded, so the store\n // would stay missing. Bumping the version triggers an upgrade that recreates\n // only the missing store, leaving any other stored data intact.\n const upgradedDb = await openConnection(currentVersion + 1);\n upgradedDb.close();\n};\n\n/**\n * Ensures WalletConnect's IndexedDB object store exists before SignClient opens\n * the connection. On iOS WebKit an upgrade interrupted by a webview reload can\n * leave the `WALLET_CONNECT_V2_INDEXED_DB` database committed at its version\n * with the object store never created; every subsequent WalletConnect read or\n * write then throws NotFoundError (\"one of the specified object stores was not\n * found\") until the store is recreated.\n *\n * The store is recreated with a version bump — the database is never deleted,\n * so no session data is lost. This is a best-effort no-op for healthy databases\n * and for environments without IndexedDB (SSR, React Native), so it cannot\n * regress the default WalletConnect behaviour: on any failure SignClient.init\n * proceeds exactly as it would without this step.\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/one-function-per-file\nexport const ensureWalletConnectStore = async (): Promise<void> => {\n if (typeof indexedDB === 'undefined') {\n return;\n }\n\n try {\n await repairMissingStore();\n } catch {\n // Best-effort pre-flight repair. Swallowing lets SignClient.init proceed as\n // it would without this step, so WalletConnect is never left worse off.\n }\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n getAppMetadata,\n getCore,\n getCurrentPageUrl,\n} from '@dynamic-labs-sdk/client/core';\nimport SignClient from '@walletconnect/sign-client';\n\nimport { ensureWalletConnectStore } from './ensureWalletConnectStore';\n\n/** @notInstrumented */\nexport const createSignClient = async (\n client: DynamicClient\n): Promise<SignClient> => {\n const core = getCore(client);\n\n assertDefined(client.projectSettings, 'Project settings not available');\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 { appName, appLogoUrl, appNativeLink, appUniversalLink } =\n getAppMetadata(client);\n\n assertDefined(\n appName,\n 'Please configure an app name in dashboard or DynamicClient metadata to use WalletConnect'\n );\n\n const customStoragePrefix = `dynamic_${core.environmentId}_walletconnect`;\n\n // Recreate WalletConnect's IndexedDB object store if a webview reload left it\n // missing, otherwise SignClient.init would throw NotFoundError on iOS WebKit.\n await ensureWalletConnectStore();\n\n // Some wallets (e.g. Backpack) return the user through this `redirect`\n // metadata; without it they open the dapp in the system browser. Default to\n // the current page on web, stripped of query/fragment which may carry auth\n // credentials.\n const fallbackUniversalLink = getCurrentPageUrl()?.split(/[?#]/)[0];\n\n return SignClient.init({\n customStoragePrefix,\n metadata: {\n description: '',\n icons: appLogoUrl ? [appLogoUrl] : [],\n name: appName,\n redirect: {\n native: appNativeLink,\n universal: appUniversalLink ?? fallbackUniversalLink,\n },\n url: appUniversalLink ?? fallbackUniversalLink ?? '',\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 type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getCore } from '@dynamic-labs-sdk/client/core';\nimport type SignClient from '@walletconnect/sign-client';\nimport { parseUri } from '@walletconnect/utils';\n\nimport { WalletConnectRelayUnavailableError } from '../errors/WalletConnectRelayUnavailableError';\n\n/** How long creating a pairing may wait for the relay before giving up. */\nexport const RELAY_CONNECTION_TIMEOUT_MS = 10_000;\n\ntype WithRelayConnectionTimeoutParams<T extends { uri?: string }> = {\n /** The Dynamic client instance, for logging. */\n client: DynamicClient;\n /** Creates the pairing, e.g. `signClient.connect(...)`. */\n createPairing: () => Promise<T>;\n /** The client the pairing is created on. */\n signClient: SignClient;\n /** Overrides {@link RELAY_CONNECTION_TIMEOUT_MS}. */\n timeoutMs?: number;\n};\n\n/**\n * Creates a WalletConnect pairing, failing with\n * `WalletConnectRelayUnavailableError` when the relay can't be reached in time.\n *\n * Pairing waits for the relay connection with no timeout of its own, so an\n * offline device or a refused app would otherwise wait forever. A pairing that\n * lands after the timeout is disconnected, so nothing is left for a wallet to\n * approve.\n *\n * @example\n * ```ts\n * const { approval, uri } = await withRelayConnectionTimeout({\n * client,\n * createPairing: () => signClient.connect({ optionalNamespaces }),\n * signClient,\n * });\n * ```\n *\n * @param params.client - The Dynamic client instance, for logging.\n * @param params.createPairing - Creates the pairing.\n * @param params.signClient - The client the pairing is created on.\n * @param [params.timeoutMs] - How long to wait for the relay.\n * @returns What `createPairing` resolved with.\n * @throws WalletConnectRelayUnavailableError If pairing creation outlasts the timeout.\n * @see getSignClient\n * @see WalletConnectRelayUnavailableError\n * @notInstrumented\n */\nexport const withRelayConnectionTimeout = async <T extends { uri?: string }>({\n client,\n createPairing,\n signClient,\n timeoutMs = RELAY_CONNECTION_TIMEOUT_MS,\n}: WithRelayConnectionTimeoutParams<T>): Promise<T> => {\n const { logger } = getCore(client);\n let timedOut = false;\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n\n const pairing = createPairing();\n\n // Best effort: a failure here must not surface after the caller has already\n // been told the relay is unavailable.\n void pairing.then(async ({ uri }) => {\n if (!timedOut || !uri) return;\n\n let topic: string;\n try {\n ({ topic } = parseUri(uri));\n } catch (error) {\n logger.error(\n '[withRelayConnectionTimeout] Failed to parse URI for cleanup',\n { error, uri }\n );\n return;\n }\n\n try {\n await signClient.core.pairing.disconnect({ topic });\n } catch (error) {\n logger.error(\n '[withRelayConnectionTimeout] Failed to disconnect a pairing that landed after the relay timeout',\n { error, topic }\n );\n }\n }, () => undefined);\n\n const timeout = new Promise<void>((resolve) => {\n timeoutId = setTimeout(resolve, timeoutMs);\n }).then(() => {\n timedOut = true;\n logger.warn(\n `[withRelayConnectionTimeout] Relay unreachable after ${timeoutMs}ms`\n );\n throw new WalletConnectRelayUnavailableError();\n });\n\n try {\n return await Promise.race([pairing, timeout]);\n } finally {\n clearTimeout(timeoutId);\n }\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 { WalletConnectRelayUnavailableError } from '../errors/WalletConnectRelayUnavailableError';\nexport { importWalletConnectAuthResponse } from '../importWalletConnectAuthResponse';\nexport { importWalletConnectSession } from '../importWalletConnectSession';\nexport { getSignClient } from '../signClient/getSignClient';\nexport { splitCaip10Token } from '../splitCaip10Token';\nexport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\nexport { withRelayConnectionTimeout } from '../withRelayConnectionTimeout';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,oBACX,gBAC2B;CAC3B,MAAM,CAAC,cAAc,WAAW,GAAG,gBACjC,YAAY,MAAM,IAAI;AAIxB,QAAO;EAAE,SADO,aAAa,KAAK,IAAI;EACpB;EAAc;EAAW;;;;;;;;;;;;;;;;;;ACkB7C,MAAa,0CAA0C,EACrD,eACA,YACA,cACA,cACA,iBACoF;AACpF,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,SAA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,+EAAoC;GAC9C;AAEF,KAAI;AACF,SAAO,MAAM,QAAQ,KAAK,CAAC,SAAS,QAAQ,CAAC;WACrC;AACR,eAAa,UAAU;;;;;;mEChGNC,iDAAMC,mDAAQ"}
package/dist/core.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { i as version, n as SessionClosedUnexpectedlyError, r as name, t as WalletConnectRelayUnavailableError } from "./WalletConnectRelayUnavailableError-BJbTDsHQ.esm.js";
1
+ import { i as version, n as SessionClosedUnexpectedlyError, r as name, t as WalletConnectRelayUnavailableError } from "./WalletConnectRelayUnavailableError-Co3EhG2c.esm.js";
2
2
  import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
3
3
  import { formatMessage, parseUri } from "@walletconnect/utils";
4
4
  import { BaseError, verifyWalletAccount } from "@dynamic-labs-sdk/client";
@@ -24,9 +24,9 @@ import SignClient from "@walletconnect/sign-client";
24
24
  * @notInstrumented
25
25
  */
26
26
  const splitCaip10Token = (caip10Token) => {
27
- const [namespaceKey, networkId, address] = caip10Token.split(":");
27
+ const [namespaceKey, networkId, ...addressParts] = caip10Token.split(":");
28
28
  return {
29
- address,
29
+ address: addressParts.join(":"),
30
30
  namespaceKey,
31
31
  networkId
32
32
  };
@@ -1 +1 @@
1
- {"version":3,"file":"core.esm.js","names":["lastResponse: VerifyResponse | undefined","walletAccounts","version","request: IDBOpenDBRequest","timeoutId: ReturnType<typeof setTimeout> | undefined","topic: string"],"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/errors/WalletConnectStoreUpgradeBlockedError.ts","../src/signClient/getSignClient/createSignClient/ensureWalletConnectStore/ensureWalletConnectStore.ts","../src/signClient/getSignClient/createSignClient/createSignClient.ts","../src/signClient/getSignClient/getSignClient.ts","../src/withRelayConnectionTimeout/withRelayConnectionTimeout.ts","../src/exports/core.ts"],"sourcesContent":["type SplitCaip10TokenResult = {\n address: string;\n namespaceKey: string;\n networkId: string;\n};\n\n/**\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 * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param\nexport const splitCaip10Token = (\n caip10Token: string\n): SplitCaip10TokenResult => {\n const [namespaceKey, networkId, address] = caip10Token.split(':');\n return { address, namespaceKey, networkId };\n};\n","import {\n type WalletProvider,\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\ntype WalletConnectSessionEventEmitter = {\n cleanupEventEmitter: () => void;\n getEventEmitter: () => WalletProvider['events'];\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 * @notInstrumented\n */\nexport const createWalletConnectSessionEventEmitter = ({\n formatAddress,\n getSession,\n namespaceKey,\n sessionTopic,\n signClient,\n}: CreateWalletConnectSessionEventEmitterParams): WalletConnectSessionEventEmitter => {\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/** @notInstrumented */\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, WalletAccount } from '@dynamic-labs-sdk/client';\nimport {\n WalletProviderPriority,\n getWalletProviderRegistry,\n reconcileWalletAccountsAgainstClient,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { createWalletAccountsForWalletConnectWalletProvider } from '../createWalletAccountsForWalletConnectWalletProvider';\nimport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\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\ntype ImportWalletConnectSessionResult = { walletAccounts: WalletAccount[] };\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 * @notInstrumented\n */\nexport const importWalletConnectSession = async (\n {\n addToDynamicWalletAccounts = true,\n sessionTopic,\n walletProviderBuilder,\n }: ImportWalletConnectSessionParams,\n client: DynamicClient\n): Promise<ImportWalletConnectSessionResult> => {\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 reconciledWalletAccounts = reconcileWalletAccountsAgainstClient(\n {\n addToDynamicWalletAccounts,\n walletAccounts,\n walletProviderKey: walletProvider.key,\n },\n client\n );\n\n return { walletAccounts: reconciledWalletAccounts };\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): string => iss.split(':')[4];\n\ntype VerifyWalletConnectAuthsParams = {\n auths: AuthTypes.Cacao[];\n chain: Chain;\n walletDisplayName: string;\n};\n\n/** @notInstrumented */\n\nexport const verifyWalletConnectAuths = async (\n { auths, chain, walletDisplayName }: VerifyWalletConnectAuthsParams,\n client: DynamicClient\n): Promise<void> => {\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\ntype ImportWalletConnectAuthResponseResult = {\n walletAccounts: WalletAccount[];\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 * @notInstrumented\n */\nexport const importWalletConnectAuthResponse = async (\n {\n authResponse,\n chain,\n walletProviderBuilder,\n }: ImportWalletConnectAuthResponseParams,\n client: DynamicClient\n): Promise<ImportWalletConnectAuthResponseResult> => {\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 { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class WalletConnectStoreUpgradeBlockedError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'wallet_connect_store_upgrade_blocked_error',\n docsUrl: null,\n name: 'WalletConnectStoreUpgradeBlockedError',\n shortMessage:\n 'WalletConnect IndexedDB store upgrade was blocked by another open connection',\n });\n }\n}\n","import { WalletConnectStoreUpgradeBlockedError } from '../../../../errors/WalletConnectStoreUpgradeBlockedError';\n\n// WalletConnect persists its pairing and session data in this IndexedDB\n// database and object store (see the browser build of\n// @walletconnect/keyvaluestorage). We reference them here so we can repair a\n// missing object store before SignClient opens the connection.\nconst WALLET_CONNECT_DB_NAME = 'WALLET_CONNECT_V2_INDEXED_DB';\nconst WALLET_CONNECT_STORE_NAME = 'keyvaluestorage';\n\n// WalletConnect's storage uses an out-of-line object store (idb-keyval's\n// createObjectStore with no keyPath). We must recreate it with the same shape\n// so WalletConnect keeps reading and writing it exactly as before.\nconst createStoreIfMissing = (db: IDBDatabase): void => {\n if (!db.objectStoreNames.contains(WALLET_CONNECT_STORE_NAME)) {\n db.createObjectStore(WALLET_CONNECT_STORE_NAME);\n }\n};\n\n/** @notInstrumented */\nconst openConnection = (version?: number): Promise<IDBDatabase> =>\n new Promise((resolve, reject) => {\n const shouldUseCurrentVersion = version === undefined;\n\n let request: IDBOpenDBRequest;\n if (shouldUseCurrentVersion) {\n request = indexedDB.open(WALLET_CONNECT_DB_NAME);\n } else {\n request = indexedDB.open(WALLET_CONNECT_DB_NAME, version);\n }\n\n request.onupgradeneeded = () => createStoreIfMissing(request.result);\n request.onsuccess = () => resolve(request.result);\n request.onerror = () => reject(request.error as Error);\n // A version-bump upgrade is blocked when another connection (another tab, or\n // WalletConnect's own cached idb-keyval connection) still holds the database\n // open. IndexedDB then fires neither success nor error, so we reject to keep\n // the promise from hanging; the caller swallows it and lets SignClient.init\n // proceed exactly as it would without this repair step.\n request.onblocked = () =>\n reject(new WalletConnectStoreUpgradeBlockedError() as Error);\n });\n\n// eslint-disable-next-line custom-rules/one-function-per-file\nconst repairMissingStore = async (): Promise<void> => {\n const db = await openConnection();\n const hasStore = db.objectStoreNames.contains(WALLET_CONNECT_STORE_NAME);\n const currentVersion = db.version;\n db.close();\n\n if (hasStore) {\n return;\n }\n\n // Reopening at the same version won't re-run onupgradeneeded, so the store\n // would stay missing. Bumping the version triggers an upgrade that recreates\n // only the missing store, leaving any other stored data intact.\n const upgradedDb = await openConnection(currentVersion + 1);\n upgradedDb.close();\n};\n\n/**\n * Ensures WalletConnect's IndexedDB object store exists before SignClient opens\n * the connection. On iOS WebKit an upgrade interrupted by a webview reload can\n * leave the `WALLET_CONNECT_V2_INDEXED_DB` database committed at its version\n * with the object store never created; every subsequent WalletConnect read or\n * write then throws NotFoundError (\"one of the specified object stores was not\n * found\") until the store is recreated.\n *\n * The store is recreated with a version bump — the database is never deleted,\n * so no session data is lost. This is a best-effort no-op for healthy databases\n * and for environments without IndexedDB (SSR, React Native), so it cannot\n * regress the default WalletConnect behaviour: on any failure SignClient.init\n * proceeds exactly as it would without this step.\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/one-function-per-file\nexport const ensureWalletConnectStore = async (): Promise<void> => {\n if (typeof indexedDB === 'undefined') {\n return;\n }\n\n try {\n await repairMissingStore();\n } catch {\n // Best-effort pre-flight repair. Swallowing lets SignClient.init proceed as\n // it would without this step, so WalletConnect is never left worse off.\n }\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n getAppMetadata,\n getCore,\n getCurrentPageUrl,\n} from '@dynamic-labs-sdk/client/core';\nimport SignClient from '@walletconnect/sign-client';\n\nimport { ensureWalletConnectStore } from './ensureWalletConnectStore';\n\n/** @notInstrumented */\nexport const createSignClient = async (\n client: DynamicClient\n): Promise<SignClient> => {\n const core = getCore(client);\n\n assertDefined(client.projectSettings, 'Project settings not available');\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 { appName, appLogoUrl, appNativeLink, appUniversalLink } =\n getAppMetadata(client);\n\n assertDefined(\n appName,\n 'Please configure an app name in dashboard or DynamicClient metadata to use WalletConnect'\n );\n\n const customStoragePrefix = `dynamic_${core.environmentId}_walletconnect`;\n\n // Recreate WalletConnect's IndexedDB object store if a webview reload left it\n // missing, otherwise SignClient.init would throw NotFoundError on iOS WebKit.\n await ensureWalletConnectStore();\n\n // Some wallets (e.g. Backpack) return the user through this `redirect`\n // metadata; without it they open the dapp in the system browser. Default to\n // the current page on web, stripped of query/fragment which may carry auth\n // credentials.\n const fallbackUniversalLink = getCurrentPageUrl()?.split(/[?#]/)[0];\n\n return SignClient.init({\n customStoragePrefix,\n metadata: {\n description: '',\n icons: appLogoUrl ? [appLogoUrl] : [],\n name: appName,\n redirect: {\n native: appNativeLink,\n universal: appUniversalLink ?? fallbackUniversalLink,\n },\n url: appUniversalLink ?? fallbackUniversalLink ?? '',\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 type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getCore } from '@dynamic-labs-sdk/client/core';\nimport type SignClient from '@walletconnect/sign-client';\nimport { parseUri } from '@walletconnect/utils';\n\nimport { WalletConnectRelayUnavailableError } from '../errors/WalletConnectRelayUnavailableError';\n\n/** How long creating a pairing may wait for the relay before giving up. */\nexport const RELAY_CONNECTION_TIMEOUT_MS = 10_000;\n\ntype WithRelayConnectionTimeoutParams<T extends { uri?: string }> = {\n /** The Dynamic client instance, for logging. */\n client: DynamicClient;\n /** Creates the pairing, e.g. `signClient.connect(...)`. */\n createPairing: () => Promise<T>;\n /** The client the pairing is created on. */\n signClient: SignClient;\n /** Overrides {@link RELAY_CONNECTION_TIMEOUT_MS}. */\n timeoutMs?: number;\n};\n\n/**\n * Creates a WalletConnect pairing, failing with\n * `WalletConnectRelayUnavailableError` when the relay can't be reached in time.\n *\n * Pairing waits for the relay connection with no timeout of its own, so an\n * offline device or a refused app would otherwise wait forever. A pairing that\n * lands after the timeout is disconnected, so nothing is left for a wallet to\n * approve.\n *\n * @example\n * ```ts\n * const { approval, uri } = await withRelayConnectionTimeout({\n * client,\n * createPairing: () => signClient.connect({ optionalNamespaces }),\n * signClient,\n * });\n * ```\n *\n * @param params.client - The Dynamic client instance, for logging.\n * @param params.createPairing - Creates the pairing.\n * @param params.signClient - The client the pairing is created on.\n * @param [params.timeoutMs] - How long to wait for the relay.\n * @returns What `createPairing` resolved with.\n * @throws WalletConnectRelayUnavailableError If pairing creation outlasts the timeout.\n * @see getSignClient\n * @see WalletConnectRelayUnavailableError\n * @notInstrumented\n */\nexport const withRelayConnectionTimeout = async <T extends { uri?: string }>({\n client,\n createPairing,\n signClient,\n timeoutMs = RELAY_CONNECTION_TIMEOUT_MS,\n}: WithRelayConnectionTimeoutParams<T>): Promise<T> => {\n const { logger } = getCore(client);\n let timedOut = false;\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n\n const pairing = createPairing();\n\n // Best effort: a failure here must not surface after the caller has already\n // been told the relay is unavailable.\n void pairing.then(async ({ uri }) => {\n if (!timedOut || !uri) return;\n\n let topic: string;\n try {\n ({ topic } = parseUri(uri));\n } catch (error) {\n logger.error(\n '[withRelayConnectionTimeout] Failed to parse URI for cleanup',\n { error, uri }\n );\n return;\n }\n\n try {\n await signClient.core.pairing.disconnect({ topic });\n } catch (error) {\n logger.error(\n '[withRelayConnectionTimeout] Failed to disconnect a pairing that landed after the relay timeout',\n { error, topic }\n );\n }\n }, () => undefined);\n\n const timeout = new Promise<void>((resolve) => {\n timeoutId = setTimeout(resolve, timeoutMs);\n }).then(() => {\n timedOut = true;\n logger.warn(\n `[withRelayConnectionTimeout] Relay unreachable after ${timeoutMs}ms`\n );\n throw new WalletConnectRelayUnavailableError();\n });\n\n try {\n return await Promise.race([pairing, timeout]);\n } finally {\n clearTimeout(timeoutId);\n }\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 { WalletConnectRelayUnavailableError } from '../errors/WalletConnectRelayUnavailableError';\nexport { importWalletConnectAuthResponse } from '../importWalletConnectAuthResponse';\nexport { importWalletConnectSession } from '../importWalletConnectSession';\nexport { getSignClient } from '../signClient/getSignClient';\nexport { splitCaip10Token } from '../splitCaip10Token';\nexport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\nexport { withRelayConnectionTimeout } from '../withRelayConnectionTimeout';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,oBACX,gBAC2B;CAC3B,MAAM,CAAC,cAAc,WAAW,WAAW,YAAY,MAAM,IAAI;AACjE,QAAO;EAAE;EAAS;EAAc;EAAW;;;;;;;;;;;;;;;;;;ACsB7C,MAAa,0CAA0C,EACrD,eACA,YACA,cACA,cACA,iBACoF;AACpF,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;;;AAKJ,eAAY;AAEZ,cAAW,GAAG,iBAAiB,mBAAmB;AAElD,UAAO;;EAEV,CACF;;;;;;AC7GH,MAAa,sDAAsD,EACjE,qBAC+E;;;;;;;;;CAS/E,MAAM,UA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ACR,WAAW,oBAAoB;IAChC;GACD,KAAK,oBAAoB,yBAAyB;GACnD;EACD;EACD,CAAC;;;;;ACvDJ,MAAa,gBAAgB,8BAC3B,4BACC,WAAW,iBAAiB,OAAO,CACrC;;;;;ACCD,MAAa,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyC3C,MAAa,6BAA6B,OAAmC,EAC3E,QACA,eACA,YACA,YAAY,kCACyC;CACrD,MAAM,EAAE,WAAW,QAAQ,OAAO;CAClC,IAAI,WAAW;CACf,IAAIE;CAEJ,MAAM,UAAU,eAAe;AAI/B,CAAK,QAAQ,KAAK,OAAO,EAAE,UAAU;AACnC,MAAI,CAAC,YAAY,CAAC,IAAK;EAEvB,IAAIC;AACJ,MAAI;AACF,IAAC,CAAE,SAAU,SAAS,IAAI;WACnB,OAAO;AACd,UAAO,MACL,gEACA;IAAE;IAAO;IAAK,CACf;AACD;;AAGF,MAAI;AACF,SAAM,WAAW,KAAK,QAAQ,WAAW,EAAE,OAAO,CAAC;WAC5C,OAAO;AACd,UAAO,MACL,mGACA;IAAE;IAAO;IAAO,CACjB;;UAEI,OAAU;CAEnB,MAAM,UAAU,IAAI,SAAe,YAAY;AAC7C,cAAY,WAAW,SAAS,UAAU;GAC1C,CAAC,WAAW;AACZ,aAAW;AACX,SAAO,KACL,wDAAwD,UAAU,IACnE;AACD,QAAM,IAAI,oCAAoC;GAC9C;AAEF,KAAI;AACF,SAAO,MAAM,QAAQ,KAAK,CAAC,SAAS,QAAQ,CAAC;WACrC;AACR,eAAa,UAAU;;;;;;AChG3B,qBAAqB,MAAM,QAAQ"}
1
+ {"version":3,"file":"core.esm.js","names":["lastResponse: VerifyResponse | undefined","walletAccounts","version","request: IDBOpenDBRequest","timeoutId: ReturnType<typeof setTimeout> | undefined","topic: string"],"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/errors/WalletConnectStoreUpgradeBlockedError.ts","../src/signClient/getSignClient/createSignClient/ensureWalletConnectStore/ensureWalletConnectStore.ts","../src/signClient/getSignClient/createSignClient/createSignClient.ts","../src/signClient/getSignClient/getSignClient.ts","../src/withRelayConnectionTimeout/withRelayConnectionTimeout.ts","../src/exports/core.ts"],"sourcesContent":["type SplitCaip10TokenResult = {\n address: string;\n namespaceKey: string;\n networkId: string;\n};\n\n/**\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 * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param\nexport const splitCaip10Token = (\n caip10Token: string\n): SplitCaip10TokenResult => {\n const [namespaceKey, networkId, ...addressParts] =\n caip10Token.split(':');\n // Some chains (e.g. TON raw `workchain:hash` addresses) carry colons in\n // the address itself, so everything after the network id is the address.\n const address = addressParts.join(':');\n return { address, namespaceKey, networkId };\n};\n","import {\n type WalletProvider,\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\ntype WalletConnectSessionEventEmitter = {\n cleanupEventEmitter: () => void;\n getEventEmitter: () => WalletProvider['events'];\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 * @notInstrumented\n */\nexport const createWalletConnectSessionEventEmitter = ({\n formatAddress,\n getSession,\n namespaceKey,\n sessionTopic,\n signClient,\n}: CreateWalletConnectSessionEventEmitterParams): WalletConnectSessionEventEmitter => {\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/** @notInstrumented */\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, WalletAccount } from '@dynamic-labs-sdk/client';\nimport {\n WalletProviderPriority,\n getWalletProviderRegistry,\n reconcileWalletAccountsAgainstClient,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { createWalletAccountsForWalletConnectWalletProvider } from '../createWalletAccountsForWalletConnectWalletProvider';\nimport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\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\ntype ImportWalletConnectSessionResult = { walletAccounts: WalletAccount[] };\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 * @notInstrumented\n */\nexport const importWalletConnectSession = async (\n {\n addToDynamicWalletAccounts = true,\n sessionTopic,\n walletProviderBuilder,\n }: ImportWalletConnectSessionParams,\n client: DynamicClient\n): Promise<ImportWalletConnectSessionResult> => {\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 reconciledWalletAccounts = reconcileWalletAccountsAgainstClient(\n {\n addToDynamicWalletAccounts,\n walletAccounts,\n walletProviderKey: walletProvider.key,\n },\n client\n );\n\n return { walletAccounts: reconciledWalletAccounts };\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): string => iss.split(':')[4];\n\ntype VerifyWalletConnectAuthsParams = {\n auths: AuthTypes.Cacao[];\n chain: Chain;\n walletDisplayName: string;\n};\n\n/** @notInstrumented */\n\nexport const verifyWalletConnectAuths = async (\n { auths, chain, walletDisplayName }: VerifyWalletConnectAuthsParams,\n client: DynamicClient\n): Promise<void> => {\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\ntype ImportWalletConnectAuthResponseResult = {\n walletAccounts: WalletAccount[];\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 * @notInstrumented\n */\nexport const importWalletConnectAuthResponse = async (\n {\n authResponse,\n chain,\n walletProviderBuilder,\n }: ImportWalletConnectAuthResponseParams,\n client: DynamicClient\n): Promise<ImportWalletConnectAuthResponseResult> => {\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 { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class WalletConnectStoreUpgradeBlockedError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'wallet_connect_store_upgrade_blocked_error',\n docsUrl: null,\n name: 'WalletConnectStoreUpgradeBlockedError',\n shortMessage:\n 'WalletConnect IndexedDB store upgrade was blocked by another open connection',\n });\n }\n}\n","import { WalletConnectStoreUpgradeBlockedError } from '../../../../errors/WalletConnectStoreUpgradeBlockedError';\n\n// WalletConnect persists its pairing and session data in this IndexedDB\n// database and object store (see the browser build of\n// @walletconnect/keyvaluestorage). We reference them here so we can repair a\n// missing object store before SignClient opens the connection.\nconst WALLET_CONNECT_DB_NAME = 'WALLET_CONNECT_V2_INDEXED_DB';\nconst WALLET_CONNECT_STORE_NAME = 'keyvaluestorage';\n\n// WalletConnect's storage uses an out-of-line object store (idb-keyval's\n// createObjectStore with no keyPath). We must recreate it with the same shape\n// so WalletConnect keeps reading and writing it exactly as before.\nconst createStoreIfMissing = (db: IDBDatabase): void => {\n if (!db.objectStoreNames.contains(WALLET_CONNECT_STORE_NAME)) {\n db.createObjectStore(WALLET_CONNECT_STORE_NAME);\n }\n};\n\n/** @notInstrumented */\nconst openConnection = (version?: number): Promise<IDBDatabase> =>\n new Promise((resolve, reject) => {\n const shouldUseCurrentVersion = version === undefined;\n\n let request: IDBOpenDBRequest;\n if (shouldUseCurrentVersion) {\n request = indexedDB.open(WALLET_CONNECT_DB_NAME);\n } else {\n request = indexedDB.open(WALLET_CONNECT_DB_NAME, version);\n }\n\n request.onupgradeneeded = () => createStoreIfMissing(request.result);\n request.onsuccess = () => resolve(request.result);\n request.onerror = () => reject(request.error as Error);\n // A version-bump upgrade is blocked when another connection (another tab, or\n // WalletConnect's own cached idb-keyval connection) still holds the database\n // open. IndexedDB then fires neither success nor error, so we reject to keep\n // the promise from hanging; the caller swallows it and lets SignClient.init\n // proceed exactly as it would without this repair step.\n request.onblocked = () =>\n reject(new WalletConnectStoreUpgradeBlockedError() as Error);\n });\n\n// eslint-disable-next-line custom-rules/one-function-per-file\nconst repairMissingStore = async (): Promise<void> => {\n const db = await openConnection();\n const hasStore = db.objectStoreNames.contains(WALLET_CONNECT_STORE_NAME);\n const currentVersion = db.version;\n db.close();\n\n if (hasStore) {\n return;\n }\n\n // Reopening at the same version won't re-run onupgradeneeded, so the store\n // would stay missing. Bumping the version triggers an upgrade that recreates\n // only the missing store, leaving any other stored data intact.\n const upgradedDb = await openConnection(currentVersion + 1);\n upgradedDb.close();\n};\n\n/**\n * Ensures WalletConnect's IndexedDB object store exists before SignClient opens\n * the connection. On iOS WebKit an upgrade interrupted by a webview reload can\n * leave the `WALLET_CONNECT_V2_INDEXED_DB` database committed at its version\n * with the object store never created; every subsequent WalletConnect read or\n * write then throws NotFoundError (\"one of the specified object stores was not\n * found\") until the store is recreated.\n *\n * The store is recreated with a version bump — the database is never deleted,\n * so no session data is lost. This is a best-effort no-op for healthy databases\n * and for environments without IndexedDB (SSR, React Native), so it cannot\n * regress the default WalletConnect behaviour: on any failure SignClient.init\n * proceeds exactly as it would without this step.\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/one-function-per-file\nexport const ensureWalletConnectStore = async (): Promise<void> => {\n if (typeof indexedDB === 'undefined') {\n return;\n }\n\n try {\n await repairMissingStore();\n } catch {\n // Best-effort pre-flight repair. Swallowing lets SignClient.init proceed as\n // it would without this step, so WalletConnect is never left worse off.\n }\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n getAppMetadata,\n getCore,\n getCurrentPageUrl,\n} from '@dynamic-labs-sdk/client/core';\nimport SignClient from '@walletconnect/sign-client';\n\nimport { ensureWalletConnectStore } from './ensureWalletConnectStore';\n\n/** @notInstrumented */\nexport const createSignClient = async (\n client: DynamicClient\n): Promise<SignClient> => {\n const core = getCore(client);\n\n assertDefined(client.projectSettings, 'Project settings not available');\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 { appName, appLogoUrl, appNativeLink, appUniversalLink } =\n getAppMetadata(client);\n\n assertDefined(\n appName,\n 'Please configure an app name in dashboard or DynamicClient metadata to use WalletConnect'\n );\n\n const customStoragePrefix = `dynamic_${core.environmentId}_walletconnect`;\n\n // Recreate WalletConnect's IndexedDB object store if a webview reload left it\n // missing, otherwise SignClient.init would throw NotFoundError on iOS WebKit.\n await ensureWalletConnectStore();\n\n // Some wallets (e.g. Backpack) return the user through this `redirect`\n // metadata; without it they open the dapp in the system browser. Default to\n // the current page on web, stripped of query/fragment which may carry auth\n // credentials.\n const fallbackUniversalLink = getCurrentPageUrl()?.split(/[?#]/)[0];\n\n return SignClient.init({\n customStoragePrefix,\n metadata: {\n description: '',\n icons: appLogoUrl ? [appLogoUrl] : [],\n name: appName,\n redirect: {\n native: appNativeLink,\n universal: appUniversalLink ?? fallbackUniversalLink,\n },\n url: appUniversalLink ?? fallbackUniversalLink ?? '',\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 type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getCore } from '@dynamic-labs-sdk/client/core';\nimport type SignClient from '@walletconnect/sign-client';\nimport { parseUri } from '@walletconnect/utils';\n\nimport { WalletConnectRelayUnavailableError } from '../errors/WalletConnectRelayUnavailableError';\n\n/** How long creating a pairing may wait for the relay before giving up. */\nexport const RELAY_CONNECTION_TIMEOUT_MS = 10_000;\n\ntype WithRelayConnectionTimeoutParams<T extends { uri?: string }> = {\n /** The Dynamic client instance, for logging. */\n client: DynamicClient;\n /** Creates the pairing, e.g. `signClient.connect(...)`. */\n createPairing: () => Promise<T>;\n /** The client the pairing is created on. */\n signClient: SignClient;\n /** Overrides {@link RELAY_CONNECTION_TIMEOUT_MS}. */\n timeoutMs?: number;\n};\n\n/**\n * Creates a WalletConnect pairing, failing with\n * `WalletConnectRelayUnavailableError` when the relay can't be reached in time.\n *\n * Pairing waits for the relay connection with no timeout of its own, so an\n * offline device or a refused app would otherwise wait forever. A pairing that\n * lands after the timeout is disconnected, so nothing is left for a wallet to\n * approve.\n *\n * @example\n * ```ts\n * const { approval, uri } = await withRelayConnectionTimeout({\n * client,\n * createPairing: () => signClient.connect({ optionalNamespaces }),\n * signClient,\n * });\n * ```\n *\n * @param params.client - The Dynamic client instance, for logging.\n * @param params.createPairing - Creates the pairing.\n * @param params.signClient - The client the pairing is created on.\n * @param [params.timeoutMs] - How long to wait for the relay.\n * @returns What `createPairing` resolved with.\n * @throws WalletConnectRelayUnavailableError If pairing creation outlasts the timeout.\n * @see getSignClient\n * @see WalletConnectRelayUnavailableError\n * @notInstrumented\n */\nexport const withRelayConnectionTimeout = async <T extends { uri?: string }>({\n client,\n createPairing,\n signClient,\n timeoutMs = RELAY_CONNECTION_TIMEOUT_MS,\n}: WithRelayConnectionTimeoutParams<T>): Promise<T> => {\n const { logger } = getCore(client);\n let timedOut = false;\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n\n const pairing = createPairing();\n\n // Best effort: a failure here must not surface after the caller has already\n // been told the relay is unavailable.\n void pairing.then(async ({ uri }) => {\n if (!timedOut || !uri) return;\n\n let topic: string;\n try {\n ({ topic } = parseUri(uri));\n } catch (error) {\n logger.error(\n '[withRelayConnectionTimeout] Failed to parse URI for cleanup',\n { error, uri }\n );\n return;\n }\n\n try {\n await signClient.core.pairing.disconnect({ topic });\n } catch (error) {\n logger.error(\n '[withRelayConnectionTimeout] Failed to disconnect a pairing that landed after the relay timeout',\n { error, topic }\n );\n }\n }, () => undefined);\n\n const timeout = new Promise<void>((resolve) => {\n timeoutId = setTimeout(resolve, timeoutMs);\n }).then(() => {\n timedOut = true;\n logger.warn(\n `[withRelayConnectionTimeout] Relay unreachable after ${timeoutMs}ms`\n );\n throw new WalletConnectRelayUnavailableError();\n });\n\n try {\n return await Promise.race([pairing, timeout]);\n } finally {\n clearTimeout(timeoutId);\n }\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 { WalletConnectRelayUnavailableError } from '../errors/WalletConnectRelayUnavailableError';\nexport { importWalletConnectAuthResponse } from '../importWalletConnectAuthResponse';\nexport { importWalletConnectSession } from '../importWalletConnectSession';\nexport { getSignClient } from '../signClient/getSignClient';\nexport { splitCaip10Token } from '../splitCaip10Token';\nexport type { WalletProviderBuilder } from '../walletConnectWalletProvider.types';\nexport { withRelayConnectionTimeout } from '../withRelayConnectionTimeout';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,oBACX,gBAC2B;CAC3B,MAAM,CAAC,cAAc,WAAW,GAAG,gBACjC,YAAY,MAAM,IAAI;AAIxB,QAAO;EAAE,SADO,aAAa,KAAK,IAAI;EACpB;EAAc;EAAW;;;;;;;;;;;;;;;;;;ACkB7C,MAAa,0CAA0C,EACrD,eACA,YACA,cACA,cACA,iBACoF;AACpF,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,a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AAM,QAAQ,KAAK,CAAC,SAAS,QAAQ,CAAC;WACrC;AACR,eAAa,UAAU;;;;;;AChG3B,qBAAqB,MAAM,QAAQ"}
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_WalletConnectRelayUnavailableError = require('./WalletConnectRelayUnavailableError-Cx0pTzGd.cjs');
1
+ const require_WalletConnectRelayUnavailableError = require('./WalletConnectRelayUnavailableError-3Bpg3Ort.cjs');
2
2
  const require_core = require('./core.cjs');
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 { i as version, n as SessionClosedUnexpectedlyError, r as name, t as WalletConnectRelayUnavailableError } from "./WalletConnectRelayUnavailableError-BJbTDsHQ.esm.js";
1
+ import { i as version, n as SessionClosedUnexpectedlyError, r as name, t as WalletConnectRelayUnavailableError } from "./WalletConnectRelayUnavailableError-Co3EhG2c.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 { appendConnectionUriToDeeplink, getPreferredWalletDeepLink } from "@dynamic-labs-sdk/client";
@@ -1 +1 @@
1
- {"version":3,"file":"splitCaip10Token.d.ts","sourceRoot":"","sources":["../../src/splitCaip10Token/splitCaip10Token.ts"],"names":[],"mappings":"AAAA,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,gBAAgB,gBACd,MAAM,KAClB,sBAGF,CAAC"}
1
+ {"version":3,"file":"splitCaip10Token.d.ts","sourceRoot":"","sources":["../../src/splitCaip10Token/splitCaip10Token.ts"],"names":[],"mappings":"AAAA,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,gBAAgB,gBACd,MAAM,KAClB,sBAOF,CAAC"}