@naculus/connect-appkit-react 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +33 -1
- package/dist/client.d.ts +33 -1
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -4
- package/dist/index.d.ts +41 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/dist/client.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var W=Object.create;var w=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var _=(a,c)=>{for(var t in c)w(a,t,{get:c[t],enumerable:!0})},h=(a,c,t,l)=>{if(c&&typeof c=="object"||typeof c=="function")for(let u of k(c))!E.call(a,u)&&u!==t&&w(a,u,{get:()=>c[u],enumerable:!(l=T(c,u))||l.enumerable});return a};var f=(a,c,t)=>(t=a!=null?W(U(a)):{},h(c||!a||!a.__esModule?w(t,"default",{value:a,enumerable:!0}):t,a)),I=a=>h(w({},"__esModule",{value:!0}),a);var x={};_(x,{clearClient:()=>R,createClient:()=>A,getClient:()=>j});module.exports=I(x);var i=require("@naculus/connect-core"),d=require("@naculus/connector-evm-injected"),P=require("@naculus/connect-core"),S=require("@naculus/connector-walletconnect"),g=null;function A(a){let c=null,t=(0,S.createWalletConnectConnector)({projectId:a.projectId,metadata:a.metadata,...a.walletConnect?.client?{client:a.walletConnect.client}:{},...a.walletConnect?.openUrl?{openUrl:a.walletConnect.openUrl}:{}}),l=null,u=null,r=null,y=null,m=a.passphrasePrompt&&a.enableEmbedded&&!a.embeddedConfig?.encryptionPassphrase?new P.PassphraseGate:null;a.enableEmbedded&&(u=import("@naculus/connector-embedded").then(e=>{let n={...a.embeddedConfig};m&&(n.encryptionPassphrase=m.request),a.enablePasskeys&&n.encryptionPassphrase&&!n.prfUnlock&&(n.prfUnlock={async derive(C){y&&await y;let v=r;return v?.hasCredential()?v.derivePrfKey(C):null}}),l=e.createPocketConnector(n),c?._setEmbeddedConnector(l)}).catch(e=>{i.logger.warn("react/client","Embedded wallet connector not available:",e),l=null})),a.enablePasskeys&&(y=import("@naculus/connector-passkeys").then(e=>{r=e.createPasskeysConnector(),c?._setPasskeysConnector(r)}).catch(e=>{i.logger.warn("react/client","Passkeys connector not available:",e),r=null}));let o=null,p=null;a.enableSolana&&(p=import("@naculus/connector-solana").then(e=>{let n=e.solanaConnector;a.solanaDefaultChain&&"configure"in n&&n.configure({defaultChain:a.solanaDefaultChain}),o=n,typeof window<"u"&&"startDiscovery"in n&&n.startDiscovery();for(let s of a.solanaWallets??[])n.registerWallet?.(s);c?._setSolanaConnector(o)}).catch(e=>{i.logger.warn("react/client","Solana connector not available:",e),o=null})),typeof window<"u"&&d.eip6963Connector.startDiscovery();for(let{info:e,provider:n}of a.injectedProviders??[])d.eip6963Connector.registerProvider(e,n);let b={connector:t,get embeddedConnector(){return l},getEmbeddedConnector:async()=>(u&&await u,l),get passkeysConnector(){return r},passphraseGate:m,solanaRpcUrl:a.solanaRpcUrl??null,get solanaConnector(){return o},connect:()=>t.connect(),connectInjected:async e=>d.eip6963Connector.connect(e),connectEmbedded:async()=>{if(u&&await u,!l)throw new Error("Embedded wallet not enabled. Set enableEmbedded: true in config.");return l.connect()},connectPasskeys:async()=>{if(y&&await y,!r)throw new Error("Passkeys connector not enabled. Set enablePasskeys: true in config.");return r.connect()},startPairing:()=>t.startPairing(),completePairing:()=>t.completePairing(),cancelPairing:()=>t.cancelPairing?.(),signMessage:async(e,n)=>{if(e.id?.startsWith("eip6963-"))return d.eip6963Connector.signMessage(e,n);if(e.walletType==="passkeys"&&r)return r.signMessage(e,n);if(e.walletType==="embedded"){if(!l)throw new i.WalletError("wallet_unavailable","Embedded wallet connector not available.");return l.signMessage(e,n)}if(e.walletType==="solana"){if(p&&await p,o)return o.signMessage(e,n);throw new i.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return t.signMessage(e,n)},signTransaction:async(e,n)=>{if(e.id?.startsWith("eip6963-"))return d.eip6963Connector.signTransaction(e,n);if(e.walletType==="embedded"){if(!l)throw new i.WalletError("wallet_unavailable","Embedded wallet connector not available.");return l.signTransaction(e,n)}if(e.walletType==="solana"){if(p&&await p,o)return o.signTransaction(e,n);throw new i.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return t.signTransaction(e,n)},sendTransaction:async(e,n)=>{if(e.id?.startsWith("eip6963-"))return d.eip6963Connector.sendTransaction(e,n);if(e.walletType==="passkeys"&&r)return r.sendTransaction(e,n);if(e.walletType==="embedded"){if(!l)throw new i.WalletError("wallet_unavailable","Embedded wallet connector not available.");return l.sendTransaction(e,n)}if(e.walletType==="solana"){if(p&&await p,o)return o.sendTransaction(e,n);throw new i.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return t.sendTransaction(e,n)},onAccountsChanged:(e,n)=>{let s=()=>{};return e.id?.startsWith("eip6963-")?d.eip6963Connector.onAccountsChanged?.(e,n)??s:e.walletType==="embedded"?l?.onAccountsChanged?.(e,n)??s:e.walletType==="passkeys"?s:e.walletType==="solana"?o?.onAccountsChanged?.(e,n)??s:t.onAccountsChanged?.(e,n)??s},onChainChanged:(e,n)=>{let s=()=>{};return e.id?.startsWith("eip6963-")?d.eip6963Connector.onChainChanged?.(e,n)??s:e.walletType==="passkeys"||e.walletType==="embedded"?s:e.walletType==="solana"?o?.onChainChanged?.(e,n)??s:t.onChainChanged?.(e,n)??s},getCapabilities:e=>e.id?.startsWith("eip6963-")?d.eip6963Connector.getCapabilities?.(e):e.walletType==="passkeys"?r?.getCapabilities?.(e):e.walletType==="solana"?o?.getCapabilities?.(e):e.walletType==="embedded"?l?.getCapabilities?.(e):t.getCapabilities?.(e),sendCalls:async(e,n,s,C)=>{if(e.id?.startsWith("eip6963-"))return d.eip6963Connector.sendCalls(e,n,s,C);if(e.walletType==="passkeys"&&r)return r.sendCalls(e,n,s,C);if(e.walletType==="solana"){if(p&&await p,o)return o.sendCalls(e,n,s,C);throw new i.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}if(e.walletType==="embedded"){if(!l?.sendCalls)throw new i.WalletError("method_not_allowed","Embedded wallet does not support sendCalls");return l.sendCalls(e,n,s,C)}if(!t.sendCalls)throw new i.WalletError("method_not_allowed","sendCalls not supported by this connector");return t.sendCalls(e,n,s,C)},showCallsStatus:async(e,n)=>{if(e.id?.startsWith("eip6963-"))return d.eip6963Connector.showCallsStatus(e,n);if(e.walletType==="passkeys"||e.walletType==="embedded")throw new i.WalletError("method_unsupported",`${e.walletType} wallets have no UI to display a call bundle.`);if(!t.showCallsStatus)throw new i.WalletError("method_unsupported","This connector cannot display call status.");return t.showCallsStatus(e,n)},getCallsStatus:async(e,n)=>{if(e.id?.startsWith("eip6963-")&&d.eip6963Connector.getCallsStatus)return d.eip6963Connector.getCallsStatus(e,n);if(e.walletType==="passkeys"&&r?.getCallsStatus)return r.getCallsStatus(e,n);if(e.walletType==="embedded")throw new i.WalletError("method_not_allowed","Embedded wallet does not support getCallsStatus");if(!t.getCallsStatus)throw new i.WalletError("method_not_allowed","getCallsStatus not supported by this connector");return t.getCallsStatus(e,n)},reconnect:async e=>e.walletType==="eip6963"?d.eip6963Connector.reconnect(e):e.walletType==="embedded"?l?l.reconnect(e):e:e.walletType==="solana"?e:t.reconnect(e),disconnect:async e=>{if(e.id?.startsWith("eip6963-")||e.walletType==="eip6963")return d.eip6963Connector.disconnect(e);if(e.walletType==="embedded"&&l)return l.disconnect();if(e.walletType==="passkeys"&&r)return r.disconnect(e);if(e.walletType==="solana"){if(p&&await p,o)return o.disconnect(e);throw new i.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return t.disconnect(e)},getAllConnectors:()=>{let e=[t];return l&&e.push(l),r&&e.push(r),o&&e.push(o),e},_setEmbeddedConnector:e=>{l=e},_setPasskeysConnector:e=>{r=e},_setSolanaConnector:e=>{o=e}};return c=b,g=b,b}function j(){return g}function R(){g=null}0&&(module.exports={clearClient,createClient,getClient});
|
|
2
2
|
//# sourceMappingURL=client.cjs.map
|
package/dist/client.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts"],"sourcesContent":["import type {\n BatchCall,\n CallsStatus,\n SendCallsOptions,\n UniversalConnector,\n UniversalWalletSession,\n WalletCapabilities,\n} from \"@naculus/connect-core\";\nimport { logger, WalletError } from \"@naculus/connect-core\";\nimport type {\n PocketConnectorClass as EmbeddedWalletConnector,\n PocketConfig,\n} from \"@naculus/connector-embedded\";\nimport { eip6963Connector } from \"@naculus/connector-evm-injected\";\nimport type PasskeysConnectorImpl from \"@naculus/connector-passkeys\";\nimport { PassphraseGate } from \"@naculus/connect-core\";\nimport {\n createWalletConnectConnector,\n type WalletConnectConnector,\n} from \"@naculus/connector-walletconnect\";\n\nexport type ClientConfig = {\n projectId: string;\n metadata: {\n name: string;\n description: string;\n url: string;\n icons: string[];\n };\n /** Enable embedded (self-custodial) wallet */\n enableEmbedded?: boolean;\n /** Configuration forwarded to the embedded wallet engine. */\n embeddedConfig?: PocketConfig;\n\n /**\n * Ask the user for the storage passphrase through the UI instead of\n * supplying `embeddedConfig.encryptionPassphrase` yourself.\n *\n * Creates a `PassphraseGate` on the client and wires it in. Mount\n * `<PassphraseDialog />` from `@naculus/connect-appkit-ui` — or drive\n * `usePassphraseGate()` yourself — and the wallet's encrypted storage has\n * somewhere to ask.\n *\n * A callback you supply in `embeddedConfig` wins: your own prompt is a\n * deliberate choice, not something to override.\n */\n passphrasePrompt?: boolean;\n\n /** Enable passkeys (WebAuthn) connector */\n enablePasskeys?: boolean;\n\n /** Enable Solana injected wallet connector (Phantom, Solflare) */\n enableSolana?: boolean;\n /** Default Solana chain (e.g. \"solana:0\"). Only used when enableSolana is true. */\n solanaDefaultChain?: string;\n /**\n * Solana JSON-RPC endpoint, for reading balances and submitting\n * transactions.\n *\n * Kept separate from any EVM endpoint: pointing Solana traffic at an\n * EIP-155 node fails with an error that blames the request.\n */\n solanaRpcUrl?: string;\n};\n\n/**\n * What a transaction looks like on the way in.\n *\n * An EVM transaction is a set of named fields the wallet assembles; a Solana\n * one is bytes the application has already built and serialized. Typing this\n * as `Record<string, unknown>` made the second impossible to express, so a\n * Solana transaction could not be sent through the client even once the\n * connector below it knew how.\n */\nexport type TransactionInput = {\n transaction: Record<string, unknown> | Uint8Array | string;\n chainId?: string;\n};\n\nexport interface Web3Client {\n connector: WalletConnectConnector;\n embeddedConnector: EmbeddedWalletConnector | null;\n /** Wait for the lazily imported embedded connector to become available. */\n getEmbeddedConnector: () => Promise<EmbeddedWalletConnector | null>;\n /** The Passkeys connector if enabled */\n passkeysConnector: PasskeysConnectorImpl | null;\n /**\n * Where encrypted storage asks for a passphrase, when `passphrasePrompt` is\n * on. Null otherwise, including when the app supplies its own callback.\n */\n passphraseGate: PassphraseGate | null;\n /** Solana JSON-RPC endpoint from config, or null when none was given. */\n solanaRpcUrl: string | null;\n /** The Solana injected wallet connector if enabled */\n solanaConnector: UniversalConnector | null;\n connect: () => Promise<UniversalWalletSession>;\n /** Connect via EIP-6963 injected wallet */\n connectInjected: (walletId?: string) => Promise<UniversalWalletSession>;\n connectEmbedded: () => Promise<UniversalWalletSession>;\n /** Connect via passkeys (WebAuthn) */\n connectPasskeys: () => Promise<UniversalWalletSession>;\n reconnect: (\n session: UniversalWalletSession,\n ) => Promise<UniversalWalletSession>;\n disconnect: (session: UniversalWalletSession) => Promise<void>;\n /** Sign a message via the appropriate connector for the session */\n signMessage: (\n session: UniversalWalletSession,\n input: { message: string; address?: string; chainId?: string },\n ) => Promise<unknown>;\n /** Send a transaction via the appropriate connector for the session */\n sendTransaction: (\n session: UniversalWalletSession,\n input: TransactionInput,\n ) => Promise<unknown>;\n /**\n * Sign without broadcasting.\n *\n * Present because a Solana application routinely signs a transaction it\n * submits itself, or hands to a relayer. There was no way to ask for that\n * through the client at all.\n */\n signTransaction: (\n session: UniversalWalletSession,\n input: TransactionInput,\n ) => Promise<unknown>;\n /** Send batched calls (EIP-5792 wallet_sendCalls) via the appropriate connector */\n sendCalls: (\n session: UniversalWalletSession,\n calls: BatchCall[],\n chainId?: string,\n options?: SendCallsOptions,\n ) => Promise<string>;\n /**\n * Ask the wallet what the account can do, keyed by CAIP-2 chain.\n *\n * Undefined when the active connector has no way to answer, which is a\n * different fact from \"the account supports nothing\" — see\n * getAccountCapabilities in @naculus/connect-core.\n */\n getCapabilities?: (\n session: UniversalWalletSession,\n ) => Promise<Record<string, WalletCapabilities>> | undefined;\n /**\n * Subscribe to in-wallet account switches, whatever the namespace.\n *\n * Dispatches to the connector carrying the session, so a consumer never has\n * to know whether the wallet reports EIP-1193 `accountsChanged`, Solana's\n * `accountChanged`, or a WalletConnect session update. Returns an\n * unsubscribe function; returns a no-op when the connector cannot report.\n */\n onAccountsChanged?: (\n session: UniversalWalletSession,\n handler: (accounts: string[]) => void,\n ) => () => void;\n /** Counterpart to onAccountsChanged for in-wallet chain switches. */\n onChainChanged?: (\n session: UniversalWalletSession,\n handler: (chainId: string) => void,\n ) => () => void;\n /**\n * EIP-5792 `wallet_showCallsStatus`: ask the wallet to display a bundle.\n *\n * Optional because most wallets do not implement it, and a refusal is\n * cosmetic — the bundle is unaffected.\n */\n showCallsStatus?: (\n session: UniversalWalletSession,\n bundleHash: string,\n ) => Promise<void>;\n getCallsStatus: (\n session: UniversalWalletSession,\n bundleHash: string,\n ) => Promise<CallsStatus>;\n startPairing: () => Promise<string>;\n completePairing: () => Promise<UniversalWalletSession>;\n /** Abandon an in-flight pairing; a session that still arrives is torn down. */\n cancelPairing: () => void;\n getAllConnectors: () => UniversalConnector[];\n /** @internal set embedded connector after lazy init */\n _setEmbeddedConnector: (conn: EmbeddedWalletConnector) => void;\n /** @internal set passkeys connector after lazy init */\n _setPasskeysConnector: (conn: PasskeysConnectorImpl) => void;\n /** @internal set solana connector after lazy init */\n _setSolanaConnector: (conn: UniversalConnector) => void;\n}\n\nlet clientInstance: Web3Client | null = null;\n\nexport function createClient(config: ClientConfig): Web3Client {\n // A provider owns its client. Keeping a process-wide singleton here causes\n // the first provider's projectId, metadata, and feature flags to leak into\n // every later provider. `getClient()` remains as a legacy last-created\n // accessor; provider hooks use the client carried by context.\n let clientRef: Web3Client | null = null;\n\n const connector = createWalletConnectConnector({\n projectId: config.projectId,\n metadata: config.metadata,\n });\n\n let _embeddedConnector: EmbeddedWalletConnector | null = null;\n let embeddedInit: Promise<void> | null = null;\n\n // Declared before the passkeys connector exists, because the embedded\n // wallet is constructed from it and the two load independently.\n let _passkeysConnector: PasskeysConnectorImpl | null = null;\n let passkeysInit: Promise<void> | null = null;\n\n // Only when asked for, and never over a callback the app already supplied.\n const _passphraseGate =\n config.passphrasePrompt && config.enableEmbedded &&\n !config.embeddedConfig?.encryptionPassphrase\n ? new PassphraseGate()\n : null;\n\n if (config.enableEmbedded) {\n embeddedInit = import(\"@naculus/connector-embedded\")\n .then((mod) => {\n const embeddedConfig: PocketConfig = { ...config.embeddedConfig };\n if (_passphraseGate) {\n embeddedConfig.encryptionPassphrase = _passphraseGate.request;\n }\n // Passkey unlock turns itself on where the platform supports it: a\n // protection that has to be switched on protects only the people who\n // already knew to look for it. Where the authenticator cannot answer\n // this returns null and the record stays passphrase-only, which is\n // why it is safe to wire without asking.\n //\n // Requires encryption to be on at all — there is no key to wrap\n // otherwise — and never replaces a provider the app supplied.\n if (\n config.enablePasskeys &&\n embeddedConfig.encryptionPassphrase &&\n !embeddedConfig.prfUnlock\n ) {\n embeddedConfig.prfUnlock = {\n async derive(salt: Uint8Array) {\n if (passkeysInit) await passkeysInit;\n const passkeys = _passkeysConnector;\n if (!passkeys?.hasCredential()) return null;\n return passkeys.derivePrfKey(salt);\n },\n };\n }\n const conn = mod.createPocketConnector(embeddedConfig);\n _embeddedConnector = conn;\n clientRef?._setEmbeddedConnector(_embeddedConnector);\n })\n .catch((err) => {\n logger.warn(\n \"react/client\",\n \"Embedded wallet connector not available:\",\n err,\n );\n _embeddedConnector = null;\n });\n }\n\n if (config.enablePasskeys) {\n passkeysInit = import(\"@naculus/connector-passkeys\")\n .then((mod) => {\n const conn = mod.createPasskeysConnector();\n _passkeysConnector = conn;\n clientRef?._setPasskeysConnector(_passkeysConnector);\n })\n .catch((err) => {\n logger.warn(\"react/client\", \"Passkeys connector not available:\", err);\n _passkeysConnector = null;\n });\n }\n\n let _solanaConnector: UniversalConnector | null = null;\n let solanaInit: Promise<void> | null = null;\n\n if (config.enableSolana) {\n solanaInit = import(\"@naculus/connector-solana\")\n .then((mod: any) => {\n // Use the singleton instance so hooks (useSolanaAccount, etc.) and\n // the client routing share the same activeSession state.\n const conn = mod.solanaConnector as UniversalConnector;\n if (config.solanaDefaultChain && \"configure\" in conn) {\n (conn as any).configure({ defaultChain: config.solanaDefaultChain });\n }\n _solanaConnector = conn;\n if (typeof window !== \"undefined\" && \"startDiscovery\" in conn) {\n (conn as any).startDiscovery();\n }\n clientRef?._setSolanaConnector(_solanaConnector);\n })\n .catch((err) => {\n logger.warn(\"react/client\", \"Solana connector not available:\", err);\n _solanaConnector = null;\n });\n }\n\n // Start EIP-6963 discovery eagerly so wallets are available when user clicks connect\n if (typeof window !== \"undefined\") {\n eip6963Connector.startDiscovery();\n }\n\n const client: Web3Client = {\n connector,\n get embeddedConnector() {\n return _embeddedConnector;\n },\n getEmbeddedConnector: async () => {\n if (embeddedInit) await embeddedInit;\n return _embeddedConnector;\n },\n get passkeysConnector() {\n return _passkeysConnector;\n },\n passphraseGate: _passphraseGate,\n solanaRpcUrl: config.solanaRpcUrl ?? null,\n get solanaConnector() {\n return _solanaConnector;\n },\n connect: () => connector.connect(),\n connectInjected: async (walletId?: string) => {\n return eip6963Connector.connect(walletId);\n },\n connectEmbedded: async () => {\n if (embeddedInit) await embeddedInit;\n if (!_embeddedConnector) {\n throw new Error(\n \"Embedded wallet not enabled. Set enableEmbedded: true in config.\",\n );\n }\n return _embeddedConnector.connect();\n },\n connectPasskeys: async () => {\n if (passkeysInit) await passkeysInit;\n if (!_passkeysConnector) {\n throw new Error(\n \"Passkeys connector not enabled. Set enablePasskeys: true in config.\",\n );\n }\n return _passkeysConnector.connect();\n },\n startPairing: () => connector.startPairing(),\n completePairing: () => connector.completePairing(),\n cancelPairing: () => connector.cancelPairing?.(),\n signMessage: async (session, input) => {\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.signMessage(session as any, input);\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.signMessage(session as any, input);\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector) {\n throw new WalletError(\n \"wallet_unavailable\",\n \"Embedded wallet connector not available.\",\n );\n }\n return _embeddedConnector.signMessage(session as any, input);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).signMessage(session as any, input);\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.signMessage(session, input);\n },\n signTransaction: async (session, input) => {\n // Same dispatch as sendTransaction; only the connector method differs.\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.signTransaction(session as any, input);\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector) {\n throw new WalletError(\n \"wallet_unavailable\",\n \"Embedded wallet connector not available.\",\n );\n }\n return _embeddedConnector.signTransaction(session as any, input);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).signTransaction(\n session as any,\n input,\n );\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.signTransaction(session as any, input);\n },\n sendTransaction: async (session, input) => {\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.sendTransaction(session as any, input);\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.sendTransaction(session as any, input);\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector) {\n throw new WalletError(\n \"wallet_unavailable\",\n \"Embedded wallet connector not available.\",\n );\n }\n return _embeddedConnector.sendTransaction(session as any, input);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).sendTransaction(\n session as any,\n input,\n );\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.sendTransaction(session, input);\n },\n onAccountsChanged: (session, handler) => {\n // Same dispatch as every other session-routed call.\n const noop = () => {};\n if (session.id?.startsWith(\"eip6963-\")) {\n return (\n eip6963Connector.onAccountsChanged?.(session as never, handler) ??\n noop\n );\n }\n if (session.walletType === \"embedded\") {\n // The embedded wallet does rotate its active account, through\n // `setActiveNamespace` and `backfillAccounts`. This used to return a\n // no-op on the reasoning that a local key \"only rotates through an\n // explicit call\" — which is exactly the case that now exists, and\n // left the provider publishing the connect-time account while a\n // different key signed.\n return (\n _embeddedConnector?.onAccountsChanged?.(session, handler) ?? noop\n );\n }\n if (session.walletType === \"passkeys\") {\n // A passkey connector holds no account to rotate: it cannot even\n // produce an address without a deployed smart account.\n return noop;\n }\n if (session.walletType === \"solana\") {\n return (\n (_solanaConnector as UniversalConnector | null)?.onAccountsChanged?.(\n session,\n handler,\n ) ?? noop\n );\n }\n return connector.onAccountsChanged?.(session, handler) ?? noop;\n },\n onChainChanged: (session, handler) => {\n const noop = () => {};\n if (session.id?.startsWith(\"eip6963-\")) {\n return (\n eip6963Connector.onChainChanged?.(session as never, handler) ?? noop\n );\n }\n if (\n session.walletType === \"passkeys\" ||\n session.walletType === \"embedded\"\n ) {\n return noop;\n }\n if (session.walletType === \"solana\") {\n return (\n (_solanaConnector as UniversalConnector | null)?.onChainChanged?.(\n session,\n handler,\n ) ?? noop\n );\n }\n return connector.onChainChanged?.(session, handler) ?? noop;\n },\n getCapabilities: (session) => {\n // Same dispatch as sendCalls, so the capability answer always comes from\n // the connector that would carry out the send. Asking one connector and\n // sending through another is how a caller ends up promised atomicity\n // that the executing wallet never claimed.\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.getCapabilities?.(session as never);\n }\n if (session.walletType === \"passkeys\") {\n return _passkeysConnector?.getCapabilities?.(session as never);\n }\n if (session.walletType === \"solana\") {\n // The Solana connector answers nothing today. Returning undefined\n // reports that rather than a fabricated \"no support\".\n return (\n _solanaConnector as UniversalConnector | null\n )?.getCapabilities?.(session);\n }\n if (session.walletType === \"embedded\") {\n return _embeddedConnector?.getCapabilities?.(session as never);\n }\n // Undefined rather than an empty object: \"cannot be asked\" has to stay\n // distinguishable from \"asked, and answered nothing\".\n return connector.getCapabilities?.(session);\n },\n sendCalls: async (session, calls, chainId, options) => {\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.sendCalls!(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.sendCalls!(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).sendCalls(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector?.sendCalls) {\n throw new WalletError(\n \"method_not_allowed\",\n \"Embedded wallet does not support sendCalls\",\n );\n }\n return _embeddedConnector.sendCalls!(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n if (!connector.sendCalls) {\n throw new WalletError(\n \"method_not_allowed\",\n \"sendCalls not supported by this connector\",\n );\n }\n return connector.sendCalls(session, calls, chainId, options);\n },\n showCallsStatus: async (session, bundleHash) => {\n // Same dispatch as sendCalls, so the wallet asked to display the bundle\n // is the one that sent it.\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.showCallsStatus!(session as never, bundleHash);\n }\n if (\n session.walletType === \"passkeys\" ||\n session.walletType === \"embedded\"\n ) {\n throw new WalletError(\n \"method_unsupported\",\n `${session.walletType} wallets have no UI to display a call bundle.`,\n );\n }\n if (!connector.showCallsStatus) {\n throw new WalletError(\n \"method_unsupported\",\n \"This connector cannot display call status.\",\n );\n }\n return connector.showCallsStatus(session, bundleHash);\n },\n getCallsStatus: async (session, bundleHash) => {\n if (\n session.id?.startsWith(\"eip6963-\") &&\n eip6963Connector.getCallsStatus\n ) {\n return eip6963Connector.getCallsStatus(session as any, bundleHash);\n }\n if (\n session.walletType === \"passkeys\" &&\n _passkeysConnector?.getCallsStatus\n ) {\n return _passkeysConnector.getCallsStatus(session as any, bundleHash);\n }\n if (session.walletType === \"embedded\") {\n throw new WalletError(\n \"method_not_allowed\",\n \"Embedded wallet does not support getCallsStatus\",\n );\n }\n if (!connector.getCallsStatus) {\n throw new WalletError(\n \"method_not_allowed\",\n \"getCallsStatus not supported by this connector\",\n );\n }\n return connector.getCallsStatus(session, bundleHash);\n },\n reconnect: async (session) => {\n if (session.walletType === \"eip6963\") {\n return eip6963Connector.reconnect(session);\n }\n if (session.walletType === \"embedded\") {\n if (_embeddedConnector) {\n return _embeddedConnector.reconnect(session);\n }\n return session;\n }\n if (session.walletType === \"solana\") {\n // Solana injected wallet doesn't support reconnect (no persisted session).\n // Return the saved session as-is; signing ops require wallet reconnection.\n return session;\n }\n return connector.reconnect(session);\n },\n disconnect: async (session) => {\n if (\n session.id?.startsWith(\"eip6963-\") ||\n session.walletType === \"eip6963\"\n ) {\n return eip6963Connector.disconnect(session as any);\n }\n if (session.walletType === \"embedded\" && _embeddedConnector) {\n return _embeddedConnector.disconnect();\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.disconnect(session as any);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return _solanaConnector.disconnect(session);\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.disconnect(session);\n },\n getAllConnectors: () => {\n const connectors: UniversalConnector[] = [connector];\n if (_embeddedConnector) connectors.push(_embeddedConnector);\n if (_passkeysConnector) connectors.push(_passkeysConnector);\n if (_solanaConnector) connectors.push(_solanaConnector);\n return connectors;\n },\n _setEmbeddedConnector: (conn: EmbeddedWalletConnector) => {\n _embeddedConnector = conn;\n },\n _setPasskeysConnector: (conn: PasskeysConnectorImpl) => {\n _passkeysConnector = conn;\n },\n _setSolanaConnector: (conn: UniversalConnector) => {\n _solanaConnector = conn;\n },\n };\n\n clientRef = client;\n clientInstance = client;\n return client;\n}\n\nexport function getClient(): Web3Client | null {\n return clientInstance;\n}\n\nexport function clearClient(): void {\n clientInstance = null;\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,iBAAAC,EAAA,cAAAC,IAAA,eAAAC,EAAAL,GAQA,IAAAM,EAAoC,iCAKpCC,EAAiC,2CAEjCD,EAA+B,iCAC/BE,EAGO,4CAwKHC,EAAoC,KAEjC,SAASN,EAAaO,EAAkC,CAK7D,IAAIC,EAA+B,KAE7BC,KAAY,gCAA6B,CAC7C,UAAWF,EAAO,UAClB,SAAUA,EAAO,QACnB,CAAC,EAEGG,EAAqD,KACrDC,EAAqC,KAIrCC,EAAmD,KACnDC,EAAqC,KAGnCC,EACJ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,EAAiB,WAAWK,CAAO,EAE5C,MAAM,IAAI,cACR,qBACA,yGACF,CACF,CACA,OAAOhB,EAAU,WAAWgB,CAAO,CACrC,EACA,iBAAkB,IAAM,CACtB,IAAMQ,EAAmC,CAACxB,CAAS,EACnD,OAAIC,GAAoBuB,EAAW,KAAKvB,CAAkB,EACtDE,GAAoBqB,EAAW,KAAKrB,CAAkB,EACtDQ,GAAkBa,EAAW,KAAKb,CAAgB,EAC/Ca,CACT,EACA,sBAAwBX,GAAkC,CACxDZ,EAAqBY,CACvB,EACA,sBAAwBA,GAAgC,CACtDV,EAAqBU,CACvB,EACA,oBAAsBA,GAA6B,CACjDF,EAAmBE,CACrB,CACF,EAEA,OAAAd,EAAYe,EACZjB,EAAiBiB,EACVA,CACT,CAEO,SAAStB,GAA+B,CAC7C,OAAOK,CACT,CAEO,SAASP,GAAoB,CAClCO,EAAiB,IACnB","names":["client_exports","__export","clearClient","createClient","getClient","__toCommonJS","import_connect_core","import_connector_evm_injected","import_connector_walletconnect","clientInstance","config","clientRef","connector","_embeddedConnector","embeddedInit","_passkeysConnector","passkeysInit","_passphraseGate","mod","embeddedConfig","salt","passkeys","err","_solanaConnector","solanaInit","conn","client","walletId","session","input","handler","noop","calls","chainId","options","bundleHash","connectors"]}
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"sourcesContent":["import type {\n BatchCall,\n CallsStatus,\n SendCallsOptions,\n UniversalConnector,\n UniversalWalletSession,\n WalletCapabilities,\n} from \"@naculus/connect-core\";\nimport { logger, WalletError } from \"@naculus/connect-core\";\nimport type {\n PocketConnectorClass as EmbeddedWalletConnector,\n PocketConfig,\n} from \"@naculus/connector-embedded\";\nimport { eip6963Connector } from \"@naculus/connector-evm-injected\";\nimport type PasskeysConnectorImpl from \"@naculus/connector-passkeys\";\nimport { PassphraseGate } from \"@naculus/connect-core\";\nimport {\n createWalletConnectConnector,\n type WalletConnectConnector,\n} from \"@naculus/connector-walletconnect\";\n\n/** App-supplied WalletConnect pieces (see `ClientConfig.walletConnect`). */\nexport type NativeWalletConnectOptions = {\n /** A pre-built `@walletconnect/sign-client` SignClient. */\n client?: unknown;\n openUrl?: (url: string) => void | Promise<void>;\n};\n\n/** An EIP-1193 provider announced to the injected-wallet connector. */\nexport type InjectedProviderRegistration = {\n info: { uuid: string; name: string; icon: string; rdns: string };\n provider: unknown;\n};\n\nexport type ClientConfig = {\n projectId: string;\n metadata: {\n name: string;\n description: string;\n url: string;\n icons: string[];\n };\n /** Enable embedded (self-custodial) wallet */\n enableEmbedded?: boolean;\n /** Configuration forwarded to the embedded wallet engine. */\n embeddedConfig?: PocketConfig;\n\n /**\n * Ask the user for the storage passphrase through the UI instead of\n * supplying `embeddedConfig.encryptionPassphrase` yourself.\n *\n * Creates a `PassphraseGate` on the client and wires it in. Mount\n * `<PassphraseDialog />` from `@naculus/connect-appkit-ui` — or drive\n * `usePassphraseGate()` yourself — and the wallet's encrypted storage has\n * somewhere to ask.\n *\n * A callback you supply in `embeddedConfig` wins: your own prompt is a\n * deliberate choice, not something to override.\n */\n passphrasePrompt?: boolean;\n\n /** Enable passkeys (WebAuthn) connector */\n enablePasskeys?: boolean;\n\n /** Enable Solana injected wallet connector (Phantom, Solflare) */\n enableSolana?: boolean;\n /** Default Solana chain (e.g. \"solana:0\"). Only used when enableSolana is true. */\n solanaDefaultChain?: string;\n /**\n * WalletConnect wiring the app supplies — on React Native, a SignClient\n * built with native storage and `Linking.openURL` for deep links.\n */\n walletConnect?: NativeWalletConnectOptions;\n /**\n * Wallet Standard wallets to register with the Solana connector (React\n * Native's Mobile Wallet Adapter wallet). Needs `enableSolana`.\n */\n solanaWallets?: readonly unknown[];\n /**\n * EIP-1193 providers to register as injected wallets (React Native's\n * Coinbase Mobile Wallet Protocol provider); connect with\n * `connectInjected(info.uuid)`.\n */\n injectedProviders?: readonly InjectedProviderRegistration[];\n /**\n * Solana JSON-RPC endpoint, for reading balances and submitting\n * transactions.\n *\n * Kept separate from any EVM endpoint: pointing Solana traffic at an\n * EIP-155 node fails with an error that blames the request.\n */\n solanaRpcUrl?: string;\n};\n\n/**\n * What a transaction looks like on the way in.\n *\n * An EVM transaction is a set of named fields the wallet assembles; a Solana\n * one is bytes the application has already built and serialized. Typing this\n * as `Record<string, unknown>` made the second impossible to express, so a\n * Solana transaction could not be sent through the client even once the\n * connector below it knew how.\n */\nexport type TransactionInput = {\n transaction: Record<string, unknown> | Uint8Array | string;\n chainId?: string;\n};\n\nexport interface Web3Client {\n connector: WalletConnectConnector;\n embeddedConnector: EmbeddedWalletConnector | null;\n /** Wait for the lazily imported embedded connector to become available. */\n getEmbeddedConnector: () => Promise<EmbeddedWalletConnector | null>;\n /** The Passkeys connector if enabled */\n passkeysConnector: PasskeysConnectorImpl | null;\n /**\n * Where encrypted storage asks for a passphrase, when `passphrasePrompt` is\n * on. Null otherwise, including when the app supplies its own callback.\n */\n passphraseGate: PassphraseGate | null;\n /** Solana JSON-RPC endpoint from config, or null when none was given. */\n solanaRpcUrl: string | null;\n /** The Solana injected wallet connector if enabled */\n solanaConnector: UniversalConnector | null;\n connect: () => Promise<UniversalWalletSession>;\n /** Connect via EIP-6963 injected wallet */\n connectInjected: (walletId?: string) => Promise<UniversalWalletSession>;\n connectEmbedded: () => Promise<UniversalWalletSession>;\n /** Connect via passkeys (WebAuthn) */\n connectPasskeys: () => Promise<UniversalWalletSession>;\n reconnect: (\n session: UniversalWalletSession,\n ) => Promise<UniversalWalletSession>;\n disconnect: (session: UniversalWalletSession) => Promise<void>;\n /** Sign a message via the appropriate connector for the session */\n signMessage: (\n session: UniversalWalletSession,\n input: { message: string; address?: string; chainId?: string },\n ) => Promise<unknown>;\n /** Send a transaction via the appropriate connector for the session */\n sendTransaction: (\n session: UniversalWalletSession,\n input: TransactionInput,\n ) => Promise<unknown>;\n /**\n * Sign without broadcasting.\n *\n * Present because a Solana application routinely signs a transaction it\n * submits itself, or hands to a relayer. There was no way to ask for that\n * through the client at all.\n */\n signTransaction: (\n session: UniversalWalletSession,\n input: TransactionInput,\n ) => Promise<unknown>;\n /** Send batched calls (EIP-5792 wallet_sendCalls) via the appropriate connector */\n sendCalls: (\n session: UniversalWalletSession,\n calls: BatchCall[],\n chainId?: string,\n options?: SendCallsOptions,\n ) => Promise<string>;\n /**\n * Ask the wallet what the account can do, keyed by CAIP-2 chain.\n *\n * Undefined when the active connector has no way to answer, which is a\n * different fact from \"the account supports nothing\" — see\n * getAccountCapabilities in @naculus/connect-core.\n */\n getCapabilities?: (\n session: UniversalWalletSession,\n ) => Promise<Record<string, WalletCapabilities>> | undefined;\n /**\n * Subscribe to in-wallet account switches, whatever the namespace.\n *\n * Dispatches to the connector carrying the session, so a consumer never has\n * to know whether the wallet reports EIP-1193 `accountsChanged`, Solana's\n * `accountChanged`, or a WalletConnect session update. Returns an\n * unsubscribe function; returns a no-op when the connector cannot report.\n */\n onAccountsChanged?: (\n session: UniversalWalletSession,\n handler: (accounts: string[]) => void,\n ) => () => void;\n /** Counterpart to onAccountsChanged for in-wallet chain switches. */\n onChainChanged?: (\n session: UniversalWalletSession,\n handler: (chainId: string) => void,\n ) => () => void;\n /**\n * EIP-5792 `wallet_showCallsStatus`: ask the wallet to display a bundle.\n *\n * Optional because most wallets do not implement it, and a refusal is\n * cosmetic — the bundle is unaffected.\n */\n showCallsStatus?: (\n session: UniversalWalletSession,\n bundleHash: string,\n ) => Promise<void>;\n getCallsStatus: (\n session: UniversalWalletSession,\n bundleHash: string,\n ) => Promise<CallsStatus>;\n startPairing: () => Promise<string>;\n completePairing: () => Promise<UniversalWalletSession>;\n /** Abandon an in-flight pairing; a session that still arrives is torn down. */\n cancelPairing: () => void;\n getAllConnectors: () => UniversalConnector[];\n /** @internal set embedded connector after lazy init */\n _setEmbeddedConnector: (conn: EmbeddedWalletConnector) => void;\n /** @internal set passkeys connector after lazy init */\n _setPasskeysConnector: (conn: PasskeysConnectorImpl) => void;\n /** @internal set solana connector after lazy init */\n _setSolanaConnector: (conn: UniversalConnector) => void;\n}\n\nlet clientInstance: Web3Client | null = null;\n\nexport function createClient(config: ClientConfig): Web3Client {\n // A provider owns its client. Keeping a process-wide singleton here causes\n // the first provider's projectId, metadata, and feature flags to leak into\n // every later provider. `getClient()` remains as a legacy last-created\n // accessor; provider hooks use the client carried by context.\n let clientRef: Web3Client | null = null;\n\n const connector = createWalletConnectConnector({\n projectId: config.projectId,\n metadata: config.metadata,\n ...(config.walletConnect?.client\n ? { client: config.walletConnect.client as never }\n : {}),\n ...(config.walletConnect?.openUrl\n ? { openUrl: config.walletConnect.openUrl }\n : {}),\n });\n\n let _embeddedConnector: EmbeddedWalletConnector | null = null;\n let embeddedInit: Promise<void> | null = null;\n\n // Declared before the passkeys connector exists, because the embedded\n // wallet is constructed from it and the two load independently.\n let _passkeysConnector: PasskeysConnectorImpl | null = null;\n let passkeysInit: Promise<void> | null = null;\n\n // Only when asked for, and never over a callback the app already supplied.\n const _passphraseGate =\n config.passphrasePrompt &&\n config.enableEmbedded &&\n !config.embeddedConfig?.encryptionPassphrase\n ? new PassphraseGate()\n : null;\n\n if (config.enableEmbedded) {\n embeddedInit = import(\"@naculus/connector-embedded\")\n .then((mod) => {\n const embeddedConfig: PocketConfig = { ...config.embeddedConfig };\n if (_passphraseGate) {\n embeddedConfig.encryptionPassphrase = _passphraseGate.request;\n }\n // Passkey unlock turns itself on where the platform supports it: a\n // protection that has to be switched on protects only the people who\n // already knew to look for it. Where the authenticator cannot answer\n // this returns null and the record stays passphrase-only, which is\n // why it is safe to wire without asking.\n //\n // Requires encryption to be on at all — there is no key to wrap\n // otherwise — and never replaces a provider the app supplied.\n if (\n config.enablePasskeys &&\n embeddedConfig.encryptionPassphrase &&\n !embeddedConfig.prfUnlock\n ) {\n embeddedConfig.prfUnlock = {\n async derive(salt: Uint8Array) {\n if (passkeysInit) await passkeysInit;\n const passkeys = _passkeysConnector;\n if (!passkeys?.hasCredential()) return null;\n return passkeys.derivePrfKey(salt);\n },\n };\n }\n const conn = mod.createPocketConnector(embeddedConfig);\n _embeddedConnector = conn;\n clientRef?._setEmbeddedConnector(_embeddedConnector);\n })\n .catch((err) => {\n logger.warn(\n \"react/client\",\n \"Embedded wallet connector not available:\",\n err,\n );\n _embeddedConnector = null;\n });\n }\n\n if (config.enablePasskeys) {\n passkeysInit = import(\"@naculus/connector-passkeys\")\n .then((mod) => {\n const conn = mod.createPasskeysConnector();\n _passkeysConnector = conn;\n clientRef?._setPasskeysConnector(_passkeysConnector);\n })\n .catch((err) => {\n logger.warn(\"react/client\", \"Passkeys connector not available:\", err);\n _passkeysConnector = null;\n });\n }\n\n let _solanaConnector: UniversalConnector | null = null;\n let solanaInit: Promise<void> | null = null;\n\n if (config.enableSolana) {\n solanaInit = import(\"@naculus/connector-solana\")\n .then((mod: any) => {\n // Use the singleton instance so hooks (useSolanaAccount, etc.) and\n // the client routing share the same activeSession state.\n const conn = mod.solanaConnector as UniversalConnector;\n if (config.solanaDefaultChain && \"configure\" in conn) {\n (conn as any).configure({ defaultChain: config.solanaDefaultChain });\n }\n _solanaConnector = conn;\n if (typeof window !== \"undefined\" && \"startDiscovery\" in conn) {\n (conn as any).startDiscovery();\n }\n for (const wallet of config.solanaWallets ?? []) {\n (conn as any).registerWallet?.(wallet);\n }\n clientRef?._setSolanaConnector(_solanaConnector);\n })\n .catch((err) => {\n logger.warn(\"react/client\", \"Solana connector not available:\", err);\n _solanaConnector = null;\n });\n }\n\n // Start EIP-6963 discovery eagerly so wallets are available when user clicks connect\n if (typeof window !== \"undefined\") {\n eip6963Connector.startDiscovery();\n }\n for (const { info, provider } of config.injectedProviders ?? []) {\n eip6963Connector.registerProvider(info, provider as never);\n }\n\n const client: Web3Client = {\n connector,\n get embeddedConnector() {\n return _embeddedConnector;\n },\n getEmbeddedConnector: async () => {\n if (embeddedInit) await embeddedInit;\n return _embeddedConnector;\n },\n get passkeysConnector() {\n return _passkeysConnector;\n },\n passphraseGate: _passphraseGate,\n solanaRpcUrl: config.solanaRpcUrl ?? null,\n get solanaConnector() {\n return _solanaConnector;\n },\n connect: () => connector.connect(),\n connectInjected: async (walletId?: string) => {\n return eip6963Connector.connect(walletId);\n },\n connectEmbedded: async () => {\n if (embeddedInit) await embeddedInit;\n if (!_embeddedConnector) {\n throw new Error(\n \"Embedded wallet not enabled. Set enableEmbedded: true in config.\",\n );\n }\n return _embeddedConnector.connect();\n },\n connectPasskeys: async () => {\n if (passkeysInit) await passkeysInit;\n if (!_passkeysConnector) {\n throw new Error(\n \"Passkeys connector not enabled. Set enablePasskeys: true in config.\",\n );\n }\n return _passkeysConnector.connect();\n },\n startPairing: () => connector.startPairing(),\n completePairing: () => connector.completePairing(),\n cancelPairing: () => connector.cancelPairing?.(),\n signMessage: async (session, input) => {\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.signMessage(session as any, input);\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.signMessage(session as any, input);\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector) {\n throw new WalletError(\n \"wallet_unavailable\",\n \"Embedded wallet connector not available.\",\n );\n }\n return _embeddedConnector.signMessage(session as any, input);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).signMessage(session as any, input);\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.signMessage(session, input);\n },\n signTransaction: async (session, input) => {\n // Same dispatch as sendTransaction; only the connector method differs.\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.signTransaction(session as any, input);\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector) {\n throw new WalletError(\n \"wallet_unavailable\",\n \"Embedded wallet connector not available.\",\n );\n }\n return _embeddedConnector.signTransaction(session as any, input);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).signTransaction(\n session as any,\n input,\n );\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.signTransaction(session as any, input);\n },\n sendTransaction: async (session, input) => {\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.sendTransaction(session as any, input);\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.sendTransaction(session as any, input);\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector) {\n throw new WalletError(\n \"wallet_unavailable\",\n \"Embedded wallet connector not available.\",\n );\n }\n return _embeddedConnector.sendTransaction(session as any, input);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).sendTransaction(\n session as any,\n input,\n );\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.sendTransaction(session, input);\n },\n onAccountsChanged: (session, handler) => {\n // Same dispatch as every other session-routed call.\n const noop = () => {};\n if (session.id?.startsWith(\"eip6963-\")) {\n return (\n eip6963Connector.onAccountsChanged?.(session as never, handler) ??\n noop\n );\n }\n if (session.walletType === \"embedded\") {\n // The embedded wallet does rotate its active account, through\n // `setActiveNamespace` and `backfillAccounts`. This used to return a\n // no-op on the reasoning that a local key \"only rotates through an\n // explicit call\" — which is exactly the case that now exists, and\n // left the provider publishing the connect-time account while a\n // different key signed.\n return (\n _embeddedConnector?.onAccountsChanged?.(session, handler) ?? noop\n );\n }\n if (session.walletType === \"passkeys\") {\n // A passkey connector holds no account to rotate: it cannot even\n // produce an address without a deployed smart account.\n return noop;\n }\n if (session.walletType === \"solana\") {\n return (\n (_solanaConnector as UniversalConnector | null)?.onAccountsChanged?.(\n session,\n handler,\n ) ?? noop\n );\n }\n return connector.onAccountsChanged?.(session, handler) ?? noop;\n },\n onChainChanged: (session, handler) => {\n const noop = () => {};\n if (session.id?.startsWith(\"eip6963-\")) {\n return (\n eip6963Connector.onChainChanged?.(session as never, handler) ?? noop\n );\n }\n if (\n session.walletType === \"passkeys\" ||\n session.walletType === \"embedded\"\n ) {\n return noop;\n }\n if (session.walletType === \"solana\") {\n return (\n (_solanaConnector as UniversalConnector | null)?.onChainChanged?.(\n session,\n handler,\n ) ?? noop\n );\n }\n return connector.onChainChanged?.(session, handler) ?? noop;\n },\n getCapabilities: (session) => {\n // Same dispatch as sendCalls, so the capability answer always comes from\n // the connector that would carry out the send. Asking one connector and\n // sending through another is how a caller ends up promised atomicity\n // that the executing wallet never claimed.\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.getCapabilities?.(session as never);\n }\n if (session.walletType === \"passkeys\") {\n return _passkeysConnector?.getCapabilities?.(session as never);\n }\n if (session.walletType === \"solana\") {\n // The Solana connector answers nothing today. Returning undefined\n // reports that rather than a fabricated \"no support\".\n return (\n _solanaConnector as UniversalConnector | null\n )?.getCapabilities?.(session);\n }\n if (session.walletType === \"embedded\") {\n return _embeddedConnector?.getCapabilities?.(session as never);\n }\n // Undefined rather than an empty object: \"cannot be asked\" has to stay\n // distinguishable from \"asked, and answered nothing\".\n return connector.getCapabilities?.(session);\n },\n sendCalls: async (session, calls, chainId, options) => {\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.sendCalls!(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.sendCalls!(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).sendCalls(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector?.sendCalls) {\n throw new WalletError(\n \"method_not_allowed\",\n \"Embedded wallet does not support sendCalls\",\n );\n }\n return _embeddedConnector.sendCalls!(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n if (!connector.sendCalls) {\n throw new WalletError(\n \"method_not_allowed\",\n \"sendCalls not supported by this connector\",\n );\n }\n return connector.sendCalls(session, calls, chainId, options);\n },\n showCallsStatus: async (session, bundleHash) => {\n // Same dispatch as sendCalls, so the wallet asked to display the bundle\n // is the one that sent it.\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.showCallsStatus!(session as never, bundleHash);\n }\n if (\n session.walletType === \"passkeys\" ||\n session.walletType === \"embedded\"\n ) {\n throw new WalletError(\n \"method_unsupported\",\n `${session.walletType} wallets have no UI to display a call bundle.`,\n );\n }\n if (!connector.showCallsStatus) {\n throw new WalletError(\n \"method_unsupported\",\n \"This connector cannot display call status.\",\n );\n }\n return connector.showCallsStatus(session, bundleHash);\n },\n getCallsStatus: async (session, bundleHash) => {\n if (\n session.id?.startsWith(\"eip6963-\") &&\n eip6963Connector.getCallsStatus\n ) {\n return eip6963Connector.getCallsStatus(session as any, bundleHash);\n }\n if (\n session.walletType === \"passkeys\" &&\n _passkeysConnector?.getCallsStatus\n ) {\n return _passkeysConnector.getCallsStatus(session as any, bundleHash);\n }\n if (session.walletType === \"embedded\") {\n throw new WalletError(\n \"method_not_allowed\",\n \"Embedded wallet does not support getCallsStatus\",\n );\n }\n if (!connector.getCallsStatus) {\n throw new WalletError(\n \"method_not_allowed\",\n \"getCallsStatus not supported by this connector\",\n );\n }\n return connector.getCallsStatus(session, bundleHash);\n },\n reconnect: async (session) => {\n if (session.walletType === \"eip6963\") {\n return eip6963Connector.reconnect(session);\n }\n if (session.walletType === \"embedded\") {\n if (_embeddedConnector) {\n return _embeddedConnector.reconnect(session);\n }\n return session;\n }\n if (session.walletType === \"solana\") {\n // Solana injected wallet doesn't support reconnect (no persisted session).\n // Return the saved session as-is; signing ops require wallet reconnection.\n return session;\n }\n return connector.reconnect(session);\n },\n disconnect: async (session) => {\n if (\n session.id?.startsWith(\"eip6963-\") ||\n session.walletType === \"eip6963\"\n ) {\n return eip6963Connector.disconnect(session as any);\n }\n if (session.walletType === \"embedded\" && _embeddedConnector) {\n return _embeddedConnector.disconnect();\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.disconnect(session as any);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return _solanaConnector.disconnect(session);\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.disconnect(session);\n },\n getAllConnectors: () => {\n const connectors: UniversalConnector[] = [connector];\n if (_embeddedConnector) connectors.push(_embeddedConnector);\n if (_passkeysConnector) connectors.push(_passkeysConnector);\n if (_solanaConnector) connectors.push(_solanaConnector);\n return connectors;\n },\n _setEmbeddedConnector: (conn: EmbeddedWalletConnector) => {\n _embeddedConnector = conn;\n },\n _setPasskeysConnector: (conn: PasskeysConnectorImpl) => {\n _passkeysConnector = conn;\n },\n _setSolanaConnector: (conn: UniversalConnector) => {\n _solanaConnector = conn;\n },\n };\n\n clientRef = client;\n clientInstance = client;\n return client;\n}\n\nexport function getClient(): Web3Client | null {\n return clientInstance;\n}\n\nexport function clearClient(): void {\n clientInstance = null;\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,iBAAAC,EAAA,cAAAC,IAAA,eAAAC,EAAAL,GAQA,IAAAM,EAAoC,iCAKpCC,EAAiC,2CAEjCD,EAA+B,iCAC/BE,EAGO,4CAqMHC,EAAoC,KAEjC,SAASN,EAAaO,EAAkC,CAK7D,IAAIC,EAA+B,KAE7BC,KAAY,gCAA6B,CAC7C,UAAWF,EAAO,UAClB,SAAUA,EAAO,SACjB,GAAIA,EAAO,eAAe,OACtB,CAAE,OAAQA,EAAO,cAAc,MAAgB,EAC/C,CAAC,EACL,GAAIA,EAAO,eAAe,QACtB,CAAE,QAASA,EA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EpC,WAAY,MAAOA,GAAY,CAC7B,GACEA,EAAQ,IAAI,WAAW,UAAU,GACjCA,EAAQ,aAAe,UAEvB,OAAO,mBAAiB,WAAWA,CAAc,EAEnD,GAAIA,EAAQ,aAAe,YAAclB,EACvC,OAAOA,EAAmB,WAAW,EAEvC,GAAIkB,EAAQ,aAAe,YAAchB,EACvC,OAAOA,EAAmB,WAAWgB,CAAc,EAErD,GAAIA,EAAQ,aAAe,SAAU,CAEnC,GADIP,GAAY,MAAMA,EAClBD,EACF,OAAOA,EAAiB,WAAWQ,CAAO,EAE5C,MAAM,IAAI,cACR,qBACA,yGACF,CACF,CACA,OAAOnB,EAAU,WAAWmB,CAAO,CACrC,EACA,iBAAkB,IAAM,CACtB,IAAMQ,EAAmC,CAAC3B,CAAS,EACnD,OAAIC,GAAoB0B,EAAW,KAAK1B,CAAkB,EACtDE,GAAoBwB,EAAW,KAAKxB,CAAkB,EACtDQ,GAAkBgB,EAAW,KAAKhB,CAAgB,EAC/CgB,CACT,EACA,sBAAwBd,GAAkC,CACxDZ,EAAqBY,CACvB,EACA,sBAAwBA,GAAgC,CACtDV,EAAqBU,CACvB,EACA,oBAAsBA,GAA6B,CACjDF,EAAmBE,CACrB,CACF,EAEA,OAAAd,EAAYkB,EACZpB,EAAiBoB,EACVA,CACT,CAEO,SAASzB,GAA+B,CAC7C,OAAOK,CACT,CAEO,SAASP,GAAoB,CAClCO,EAAiB,IACnB","names":["client_exports","__export","clearClient","createClient","getClient","__toCommonJS","import_connect_core","import_connector_evm_injected","import_connector_walletconnect","clientInstance","config","clientRef","connector","_embeddedConnector","embeddedInit","_passkeysConnector","passkeysInit","_passphraseGate","mod","embeddedConfig","salt","passkeys","err","_solanaConnector","solanaInit","conn","wallet","info","provider","client","walletId","session","input","handler","noop","calls","chainId","options","bundleHash","connectors"]}
|
package/dist/client.d.cts
CHANGED
|
@@ -3,6 +3,22 @@ import { PocketConfig, PocketConnectorClass } from '@naculus/connector-embedded'
|
|
|
3
3
|
import PasskeysConnectorImpl from '@naculus/connector-passkeys';
|
|
4
4
|
import { WalletConnectConnector } from '@naculus/connector-walletconnect';
|
|
5
5
|
|
|
6
|
+
/** App-supplied WalletConnect pieces (see `ClientConfig.walletConnect`). */
|
|
7
|
+
type NativeWalletConnectOptions = {
|
|
8
|
+
/** A pre-built `@walletconnect/sign-client` SignClient. */
|
|
9
|
+
client?: unknown;
|
|
10
|
+
openUrl?: (url: string) => void | Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
/** An EIP-1193 provider announced to the injected-wallet connector. */
|
|
13
|
+
type InjectedProviderRegistration = {
|
|
14
|
+
info: {
|
|
15
|
+
uuid: string;
|
|
16
|
+
name: string;
|
|
17
|
+
icon: string;
|
|
18
|
+
rdns: string;
|
|
19
|
+
};
|
|
20
|
+
provider: unknown;
|
|
21
|
+
};
|
|
6
22
|
type ClientConfig = {
|
|
7
23
|
projectId: string;
|
|
8
24
|
metadata: {
|
|
@@ -34,6 +50,22 @@ type ClientConfig = {
|
|
|
34
50
|
enableSolana?: boolean;
|
|
35
51
|
/** Default Solana chain (e.g. "solana:0"). Only used when enableSolana is true. */
|
|
36
52
|
solanaDefaultChain?: string;
|
|
53
|
+
/**
|
|
54
|
+
* WalletConnect wiring the app supplies — on React Native, a SignClient
|
|
55
|
+
* built with native storage and `Linking.openURL` for deep links.
|
|
56
|
+
*/
|
|
57
|
+
walletConnect?: NativeWalletConnectOptions;
|
|
58
|
+
/**
|
|
59
|
+
* Wallet Standard wallets to register with the Solana connector (React
|
|
60
|
+
* Native's Mobile Wallet Adapter wallet). Needs `enableSolana`.
|
|
61
|
+
*/
|
|
62
|
+
solanaWallets?: readonly unknown[];
|
|
63
|
+
/**
|
|
64
|
+
* EIP-1193 providers to register as injected wallets (React Native's
|
|
65
|
+
* Coinbase Mobile Wallet Protocol provider); connect with
|
|
66
|
+
* `connectInjected(info.uuid)`.
|
|
67
|
+
*/
|
|
68
|
+
injectedProviders?: readonly InjectedProviderRegistration[];
|
|
37
69
|
/**
|
|
38
70
|
* Solana JSON-RPC endpoint, for reading balances and submitting
|
|
39
71
|
* transactions.
|
|
@@ -141,4 +173,4 @@ declare function createClient(config: ClientConfig): Web3Client;
|
|
|
141
173
|
declare function getClient(): Web3Client | null;
|
|
142
174
|
declare function clearClient(): void;
|
|
143
175
|
|
|
144
|
-
export { type ClientConfig, type TransactionInput, type Web3Client, clearClient, createClient, getClient };
|
|
176
|
+
export { type ClientConfig, type InjectedProviderRegistration, type NativeWalletConnectOptions, type TransactionInput, type Web3Client, clearClient, createClient, getClient };
|
package/dist/client.d.ts
CHANGED
|
@@ -3,6 +3,22 @@ import { PocketConfig, PocketConnectorClass } from '@naculus/connector-embedded'
|
|
|
3
3
|
import PasskeysConnectorImpl from '@naculus/connector-passkeys';
|
|
4
4
|
import { WalletConnectConnector } from '@naculus/connector-walletconnect';
|
|
5
5
|
|
|
6
|
+
/** App-supplied WalletConnect pieces (see `ClientConfig.walletConnect`). */
|
|
7
|
+
type NativeWalletConnectOptions = {
|
|
8
|
+
/** A pre-built `@walletconnect/sign-client` SignClient. */
|
|
9
|
+
client?: unknown;
|
|
10
|
+
openUrl?: (url: string) => void | Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
/** An EIP-1193 provider announced to the injected-wallet connector. */
|
|
13
|
+
type InjectedProviderRegistration = {
|
|
14
|
+
info: {
|
|
15
|
+
uuid: string;
|
|
16
|
+
name: string;
|
|
17
|
+
icon: string;
|
|
18
|
+
rdns: string;
|
|
19
|
+
};
|
|
20
|
+
provider: unknown;
|
|
21
|
+
};
|
|
6
22
|
type ClientConfig = {
|
|
7
23
|
projectId: string;
|
|
8
24
|
metadata: {
|
|
@@ -34,6 +50,22 @@ type ClientConfig = {
|
|
|
34
50
|
enableSolana?: boolean;
|
|
35
51
|
/** Default Solana chain (e.g. "solana:0"). Only used when enableSolana is true. */
|
|
36
52
|
solanaDefaultChain?: string;
|
|
53
|
+
/**
|
|
54
|
+
* WalletConnect wiring the app supplies — on React Native, a SignClient
|
|
55
|
+
* built with native storage and `Linking.openURL` for deep links.
|
|
56
|
+
*/
|
|
57
|
+
walletConnect?: NativeWalletConnectOptions;
|
|
58
|
+
/**
|
|
59
|
+
* Wallet Standard wallets to register with the Solana connector (React
|
|
60
|
+
* Native's Mobile Wallet Adapter wallet). Needs `enableSolana`.
|
|
61
|
+
*/
|
|
62
|
+
solanaWallets?: readonly unknown[];
|
|
63
|
+
/**
|
|
64
|
+
* EIP-1193 providers to register as injected wallets (React Native's
|
|
65
|
+
* Coinbase Mobile Wallet Protocol provider); connect with
|
|
66
|
+
* `connectInjected(info.uuid)`.
|
|
67
|
+
*/
|
|
68
|
+
injectedProviders?: readonly InjectedProviderRegistration[];
|
|
37
69
|
/**
|
|
38
70
|
* Solana JSON-RPC endpoint, for reading balances and submitting
|
|
39
71
|
* transactions.
|
|
@@ -141,4 +173,4 @@ declare function createClient(config: ClientConfig): Web3Client;
|
|
|
141
173
|
declare function getClient(): Web3Client | null;
|
|
142
174
|
declare function clearClient(): void;
|
|
143
175
|
|
|
144
|
-
export { type ClientConfig, type TransactionInput, type Web3Client, clearClient, createClient, getClient };
|
|
176
|
+
export { type ClientConfig, type InjectedProviderRegistration, type NativeWalletConnectOptions, type TransactionInput, type Web3Client, clearClient, createClient, getClient };
|
package/dist/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{logger as
|
|
1
|
+
import{logger as b,WalletError as c}from"@naculus/connect-core";import{eip6963Connector as i}from"@naculus/connector-evm-injected";import{PassphraseGate as v}from"@naculus/connect-core";import{createWalletConnectConnector as h}from"@naculus/connector-walletconnect";var f=null;function k(o){let y=null,l=h({projectId:o.projectId,metadata:o.metadata,...o.walletConnect?.client?{client:o.walletConnect.client}:{},...o.walletConnect?.openUrl?{openUrl:o.walletConnect.openUrl}:{}}),a=null,p=null,t=null,C=null,w=o.passphrasePrompt&&o.enableEmbedded&&!o.embeddedConfig?.encryptionPassphrase?new v:null;o.enableEmbedded&&(p=import("@naculus/connector-embedded").then(e=>{let n={...o.embeddedConfig};w&&(n.encryptionPassphrase=w.request),o.enablePasskeys&&n.encryptionPassphrase&&!n.prfUnlock&&(n.prfUnlock={async derive(u){C&&await C;let g=t;return g?.hasCredential()?g.derivePrfKey(u):null}}),a=e.createPocketConnector(n),y?._setEmbeddedConnector(a)}).catch(e=>{b.warn("react/client","Embedded wallet connector not available:",e),a=null})),o.enablePasskeys&&(C=import("@naculus/connector-passkeys").then(e=>{t=e.createPasskeysConnector(),y?._setPasskeysConnector(t)}).catch(e=>{b.warn("react/client","Passkeys connector not available:",e),t=null}));let r=null,d=null;o.enableSolana&&(d=import("@naculus/connector-solana").then(e=>{let n=e.solanaConnector;o.solanaDefaultChain&&"configure"in n&&n.configure({defaultChain:o.solanaDefaultChain}),r=n,typeof window<"u"&&"startDiscovery"in n&&n.startDiscovery();for(let s of o.solanaWallets??[])n.registerWallet?.(s);y?._setSolanaConnector(r)}).catch(e=>{b.warn("react/client","Solana connector not available:",e),r=null})),typeof window<"u"&&i.startDiscovery();for(let{info:e,provider:n}of o.injectedProviders??[])i.registerProvider(e,n);let m={connector:l,get embeddedConnector(){return a},getEmbeddedConnector:async()=>(p&&await p,a),get passkeysConnector(){return t},passphraseGate:w,solanaRpcUrl:o.solanaRpcUrl??null,get solanaConnector(){return r},connect:()=>l.connect(),connectInjected:async e=>i.connect(e),connectEmbedded:async()=>{if(p&&await p,!a)throw new Error("Embedded wallet not enabled. Set enableEmbedded: true in config.");return a.connect()},connectPasskeys:async()=>{if(C&&await C,!t)throw new Error("Passkeys connector not enabled. Set enablePasskeys: true in config.");return t.connect()},startPairing:()=>l.startPairing(),completePairing:()=>l.completePairing(),cancelPairing:()=>l.cancelPairing?.(),signMessage:async(e,n)=>{if(e.id?.startsWith("eip6963-"))return i.signMessage(e,n);if(e.walletType==="passkeys"&&t)return t.signMessage(e,n);if(e.walletType==="embedded"){if(!a)throw new c("wallet_unavailable","Embedded wallet connector not available.");return a.signMessage(e,n)}if(e.walletType==="solana"){if(d&&await d,r)return r.signMessage(e,n);throw new c("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return l.signMessage(e,n)},signTransaction:async(e,n)=>{if(e.id?.startsWith("eip6963-"))return i.signTransaction(e,n);if(e.walletType==="embedded"){if(!a)throw new c("wallet_unavailable","Embedded wallet connector not available.");return a.signTransaction(e,n)}if(e.walletType==="solana"){if(d&&await d,r)return r.signTransaction(e,n);throw new c("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return l.signTransaction(e,n)},sendTransaction:async(e,n)=>{if(e.id?.startsWith("eip6963-"))return i.sendTransaction(e,n);if(e.walletType==="passkeys"&&t)return t.sendTransaction(e,n);if(e.walletType==="embedded"){if(!a)throw new c("wallet_unavailable","Embedded wallet connector not available.");return a.sendTransaction(e,n)}if(e.walletType==="solana"){if(d&&await d,r)return r.sendTransaction(e,n);throw new c("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return l.sendTransaction(e,n)},onAccountsChanged:(e,n)=>{let s=()=>{};return e.id?.startsWith("eip6963-")?i.onAccountsChanged?.(e,n)??s:e.walletType==="embedded"?a?.onAccountsChanged?.(e,n)??s:e.walletType==="passkeys"?s:e.walletType==="solana"?r?.onAccountsChanged?.(e,n)??s:l.onAccountsChanged?.(e,n)??s},onChainChanged:(e,n)=>{let s=()=>{};return e.id?.startsWith("eip6963-")?i.onChainChanged?.(e,n)??s:e.walletType==="passkeys"||e.walletType==="embedded"?s:e.walletType==="solana"?r?.onChainChanged?.(e,n)??s:l.onChainChanged?.(e,n)??s},getCapabilities:e=>e.id?.startsWith("eip6963-")?i.getCapabilities?.(e):e.walletType==="passkeys"?t?.getCapabilities?.(e):e.walletType==="solana"?r?.getCapabilities?.(e):e.walletType==="embedded"?a?.getCapabilities?.(e):l.getCapabilities?.(e),sendCalls:async(e,n,s,u)=>{if(e.id?.startsWith("eip6963-"))return i.sendCalls(e,n,s,u);if(e.walletType==="passkeys"&&t)return t.sendCalls(e,n,s,u);if(e.walletType==="solana"){if(d&&await d,r)return r.sendCalls(e,n,s,u);throw new c("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}if(e.walletType==="embedded"){if(!a?.sendCalls)throw new c("method_not_allowed","Embedded wallet does not support sendCalls");return a.sendCalls(e,n,s,u)}if(!l.sendCalls)throw new c("method_not_allowed","sendCalls not supported by this connector");return l.sendCalls(e,n,s,u)},showCallsStatus:async(e,n)=>{if(e.id?.startsWith("eip6963-"))return i.showCallsStatus(e,n);if(e.walletType==="passkeys"||e.walletType==="embedded")throw new c("method_unsupported",`${e.walletType} wallets have no UI to display a call bundle.`);if(!l.showCallsStatus)throw new c("method_unsupported","This connector cannot display call status.");return l.showCallsStatus(e,n)},getCallsStatus:async(e,n)=>{if(e.id?.startsWith("eip6963-")&&i.getCallsStatus)return i.getCallsStatus(e,n);if(e.walletType==="passkeys"&&t?.getCallsStatus)return t.getCallsStatus(e,n);if(e.walletType==="embedded")throw new c("method_not_allowed","Embedded wallet does not support getCallsStatus");if(!l.getCallsStatus)throw new c("method_not_allowed","getCallsStatus not supported by this connector");return l.getCallsStatus(e,n)},reconnect:async e=>e.walletType==="eip6963"?i.reconnect(e):e.walletType==="embedded"?a?a.reconnect(e):e:e.walletType==="solana"?e:l.reconnect(e),disconnect:async e=>{if(e.id?.startsWith("eip6963-")||e.walletType==="eip6963")return i.disconnect(e);if(e.walletType==="embedded"&&a)return a.disconnect();if(e.walletType==="passkeys"&&t)return t.disconnect(e);if(e.walletType==="solana"){if(d&&await d,r)return r.disconnect(e);throw new c("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return l.disconnect(e)},getAllConnectors:()=>{let e=[l];return a&&e.push(a),t&&e.push(t),r&&e.push(r),e},_setEmbeddedConnector:e=>{a=e},_setPasskeysConnector:e=>{t=e},_setSolanaConnector:e=>{r=e}};return y=m,f=m,m}function U(){return f}function E(){f=null}export{E as clearClient,k as createClient,U as getClient};
|
|
2
2
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts"],"sourcesContent":["import type {\n BatchCall,\n CallsStatus,\n SendCallsOptions,\n UniversalConnector,\n UniversalWalletSession,\n WalletCapabilities,\n} from \"@naculus/connect-core\";\nimport { logger, WalletError } from \"@naculus/connect-core\";\nimport type {\n PocketConnectorClass as EmbeddedWalletConnector,\n PocketConfig,\n} from \"@naculus/connector-embedded\";\nimport { eip6963Connector } from \"@naculus/connector-evm-injected\";\nimport type PasskeysConnectorImpl from \"@naculus/connector-passkeys\";\nimport { PassphraseGate } from \"@naculus/connect-core\";\nimport {\n createWalletConnectConnector,\n type WalletConnectConnector,\n} from \"@naculus/connector-walletconnect\";\n\nexport type ClientConfig = {\n projectId: string;\n metadata: {\n name: string;\n description: string;\n url: string;\n icons: string[];\n };\n /** Enable embedded (self-custodial) wallet */\n enableEmbedded?: boolean;\n /** Configuration forwarded to the embedded wallet engine. */\n embeddedConfig?: PocketConfig;\n\n /**\n * Ask the user for the storage passphrase through the UI instead of\n * supplying `embeddedConfig.encryptionPassphrase` yourself.\n *\n * Creates a `PassphraseGate` on the client and wires it in. Mount\n * `<PassphraseDialog />` from `@naculus/connect-appkit-ui` — or drive\n * `usePassphraseGate()` yourself — and the wallet's encrypted storage has\n * somewhere to ask.\n *\n * A callback you supply in `embeddedConfig` wins: your own prompt is a\n * deliberate choice, not something to override.\n */\n passphrasePrompt?: boolean;\n\n /** Enable passkeys (WebAuthn) connector */\n enablePasskeys?: boolean;\n\n /** Enable Solana injected wallet connector (Phantom, Solflare) */\n enableSolana?: boolean;\n /** Default Solana chain (e.g. \"solana:0\"). Only used when enableSolana is true. */\n solanaDefaultChain?: string;\n /**\n * Solana JSON-RPC endpoint, for reading balances and submitting\n * transactions.\n *\n * Kept separate from any EVM endpoint: pointing Solana traffic at an\n * EIP-155 node fails with an error that blames the request.\n */\n solanaRpcUrl?: string;\n};\n\n/**\n * What a transaction looks like on the way in.\n *\n * An EVM transaction is a set of named fields the wallet assembles; a Solana\n * one is bytes the application has already built and serialized. Typing this\n * as `Record<string, unknown>` made the second impossible to express, so a\n * Solana transaction could not be sent through the client even once the\n * connector below it knew how.\n */\nexport type TransactionInput = {\n transaction: Record<string, unknown> | Uint8Array | string;\n chainId?: string;\n};\n\nexport interface Web3Client {\n connector: WalletConnectConnector;\n embeddedConnector: EmbeddedWalletConnector | null;\n /** Wait for the lazily imported embedded connector to become available. */\n getEmbeddedConnector: () => Promise<EmbeddedWalletConnector | null>;\n /** The Passkeys connector if enabled */\n passkeysConnector: PasskeysConnectorImpl | null;\n /**\n * Where encrypted storage asks for a passphrase, when `passphrasePrompt` is\n * on. Null otherwise, including when the app supplies its own callback.\n */\n passphraseGate: PassphraseGate | null;\n /** Solana JSON-RPC endpoint from config, or null when none was given. */\n solanaRpcUrl: string | null;\n /** The Solana injected wallet connector if enabled */\n solanaConnector: UniversalConnector | null;\n connect: () => Promise<UniversalWalletSession>;\n /** Connect via EIP-6963 injected wallet */\n connectInjected: (walletId?: string) => Promise<UniversalWalletSession>;\n connectEmbedded: () => Promise<UniversalWalletSession>;\n /** Connect via passkeys (WebAuthn) */\n connectPasskeys: () => Promise<UniversalWalletSession>;\n reconnect: (\n session: UniversalWalletSession,\n ) => Promise<UniversalWalletSession>;\n disconnect: (session: UniversalWalletSession) => Promise<void>;\n /** Sign a message via the appropriate connector for the session */\n signMessage: (\n session: UniversalWalletSession,\n input: { message: string; address?: string; chainId?: string },\n ) => Promise<unknown>;\n /** Send a transaction via the appropriate connector for the session */\n sendTransaction: (\n session: UniversalWalletSession,\n input: TransactionInput,\n ) => Promise<unknown>;\n /**\n * Sign without broadcasting.\n *\n * Present because a Solana application routinely signs a transaction it\n * submits itself, or hands to a relayer. There was no way to ask for that\n * through the client at all.\n */\n signTransaction: (\n session: UniversalWalletSession,\n input: TransactionInput,\n ) => Promise<unknown>;\n /** Send batched calls (EIP-5792 wallet_sendCalls) via the appropriate connector */\n sendCalls: (\n session: UniversalWalletSession,\n calls: BatchCall[],\n chainId?: string,\n options?: SendCallsOptions,\n ) => Promise<string>;\n /**\n * Ask the wallet what the account can do, keyed by CAIP-2 chain.\n *\n * Undefined when the active connector has no way to answer, which is a\n * different fact from \"the account supports nothing\" — see\n * getAccountCapabilities in @naculus/connect-core.\n */\n getCapabilities?: (\n session: UniversalWalletSession,\n ) => Promise<Record<string, WalletCapabilities>> | undefined;\n /**\n * Subscribe to in-wallet account switches, whatever the namespace.\n *\n * Dispatches to the connector carrying the session, so a consumer never has\n * to know whether the wallet reports EIP-1193 `accountsChanged`, Solana's\n * `accountChanged`, or a WalletConnect session update. Returns an\n * unsubscribe function; returns a no-op when the connector cannot report.\n */\n onAccountsChanged?: (\n session: UniversalWalletSession,\n handler: (accounts: string[]) => void,\n ) => () => void;\n /** Counterpart to onAccountsChanged for in-wallet chain switches. */\n onChainChanged?: (\n session: UniversalWalletSession,\n handler: (chainId: string) => void,\n ) => () => void;\n /**\n * EIP-5792 `wallet_showCallsStatus`: ask the wallet to display a bundle.\n *\n * Optional because most wallets do not implement it, and a refusal is\n * cosmetic — the bundle is unaffected.\n */\n showCallsStatus?: (\n session: UniversalWalletSession,\n bundleHash: string,\n ) => Promise<void>;\n getCallsStatus: (\n session: UniversalWalletSession,\n bundleHash: string,\n ) => Promise<CallsStatus>;\n startPairing: () => Promise<string>;\n completePairing: () => Promise<UniversalWalletSession>;\n /** Abandon an in-flight pairing; a session that still arrives is torn down. */\n cancelPairing: () => void;\n getAllConnectors: () => UniversalConnector[];\n /** @internal set embedded connector after lazy init */\n _setEmbeddedConnector: (conn: EmbeddedWalletConnector) => void;\n /** @internal set passkeys connector after lazy init */\n _setPasskeysConnector: (conn: PasskeysConnectorImpl) => void;\n /** @internal set solana connector after lazy init */\n _setSolanaConnector: (conn: UniversalConnector) => void;\n}\n\nlet clientInstance: Web3Client | null = null;\n\nexport function createClient(config: ClientConfig): Web3Client {\n // A provider owns its client. Keeping a process-wide singleton here causes\n // the first provider's projectId, metadata, and feature flags to leak into\n // every later provider. `getClient()` remains as a legacy last-created\n // accessor; provider hooks use the client carried by context.\n let clientRef: Web3Client | null = null;\n\n const connector = createWalletConnectConnector({\n projectId: config.projectId,\n metadata: config.metadata,\n });\n\n let _embeddedConnector: EmbeddedWalletConnector | null = null;\n let embeddedInit: Promise<void> | null = null;\n\n // Declared before the passkeys connector exists, because the embedded\n // wallet is constructed from it and the two load independently.\n let _passkeysConnector: PasskeysConnectorImpl | null = null;\n let passkeysInit: Promise<void> | null = null;\n\n // Only when asked for, and never over a callback the app already supplied.\n const _passphraseGate =\n config.passphrasePrompt && config.enableEmbedded &&\n !config.embeddedConfig?.encryptionPassphrase\n ? new PassphraseGate()\n : null;\n\n if (config.enableEmbedded) {\n embeddedInit = import(\"@naculus/connector-embedded\")\n .then((mod) => {\n const embeddedConfig: PocketConfig = { ...config.embeddedConfig };\n if (_passphraseGate) {\n embeddedConfig.encryptionPassphrase = _passphraseGate.request;\n }\n // Passkey unlock turns itself on where the platform supports it: a\n // protection that has to be switched on protects only the people who\n // already knew to look for it. Where the authenticator cannot answer\n // this returns null and the record stays passphrase-only, which is\n // why it is safe to wire without asking.\n //\n // Requires encryption to be on at all — there is no key to wrap\n // otherwise — and never replaces a provider the app supplied.\n if (\n config.enablePasskeys &&\n embeddedConfig.encryptionPassphrase &&\n !embeddedConfig.prfUnlock\n ) {\n embeddedConfig.prfUnlock = {\n async derive(salt: Uint8Array) {\n if (passkeysInit) await passkeysInit;\n const passkeys = _passkeysConnector;\n if (!passkeys?.hasCredential()) return null;\n return passkeys.derivePrfKey(salt);\n },\n };\n }\n const conn = mod.createPocketConnector(embeddedConfig);\n _embeddedConnector = conn;\n clientRef?._setEmbeddedConnector(_embeddedConnector);\n })\n .catch((err) => {\n logger.warn(\n \"react/client\",\n \"Embedded wallet connector not available:\",\n err,\n );\n _embeddedConnector = null;\n });\n }\n\n if (config.enablePasskeys) {\n passkeysInit = import(\"@naculus/connector-passkeys\")\n .then((mod) => {\n const conn = mod.createPasskeysConnector();\n _passkeysConnector = conn;\n clientRef?._setPasskeysConnector(_passkeysConnector);\n })\n .catch((err) => {\n logger.warn(\"react/client\", \"Passkeys connector not available:\", err);\n _passkeysConnector = null;\n });\n }\n\n let _solanaConnector: UniversalConnector | null = null;\n let solanaInit: Promise<void> | null = null;\n\n if (config.enableSolana) {\n solanaInit = import(\"@naculus/connector-solana\")\n .then((mod: any) => {\n // Use the singleton instance so hooks (useSolanaAccount, etc.) and\n // the client routing share the same activeSession state.\n const conn = mod.solanaConnector as UniversalConnector;\n if (config.solanaDefaultChain && \"configure\" in conn) {\n (conn as any).configure({ defaultChain: config.solanaDefaultChain });\n }\n _solanaConnector = conn;\n if (typeof window !== \"undefined\" && \"startDiscovery\" in conn) {\n (conn as any).startDiscovery();\n }\n clientRef?._setSolanaConnector(_solanaConnector);\n })\n .catch((err) => {\n logger.warn(\"react/client\", \"Solana connector not available:\", err);\n _solanaConnector = null;\n });\n }\n\n // Start EIP-6963 discovery eagerly so wallets are available when user clicks connect\n if (typeof window !== \"undefined\") {\n eip6963Connector.startDiscovery();\n }\n\n const client: Web3Client = {\n connector,\n get embeddedConnector() {\n return _embeddedConnector;\n },\n getEmbeddedConnector: async () => {\n if (embeddedInit) await embeddedInit;\n return _embeddedConnector;\n },\n get passkeysConnector() {\n return _passkeysConnector;\n },\n passphraseGate: _passphraseGate,\n solanaRpcUrl: config.solanaRpcUrl ?? null,\n get solanaConnector() {\n return _solanaConnector;\n },\n connect: () => connector.connect(),\n connectInjected: async (walletId?: string) => {\n return eip6963Connector.connect(walletId);\n },\n connectEmbedded: async () => {\n if (embeddedInit) await embeddedInit;\n if (!_embeddedConnector) {\n throw new Error(\n \"Embedded wallet not enabled. Set enableEmbedded: true in config.\",\n );\n }\n return _embeddedConnector.connect();\n },\n connectPasskeys: async () => {\n if (passkeysInit) await passkeysInit;\n if (!_passkeysConnector) {\n throw new Error(\n \"Passkeys connector not enabled. Set enablePasskeys: true in config.\",\n );\n }\n return _passkeysConnector.connect();\n },\n startPairing: () => connector.startPairing(),\n completePairing: () => connector.completePairing(),\n cancelPairing: () => connector.cancelPairing?.(),\n signMessage: async (session, input) => {\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.signMessage(session as any, input);\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.signMessage(session as any, input);\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector) {\n throw new WalletError(\n \"wallet_unavailable\",\n \"Embedded wallet connector not available.\",\n );\n }\n return _embeddedConnector.signMessage(session as any, input);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).signMessage(session as any, input);\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.signMessage(session, input);\n },\n signTransaction: async (session, input) => {\n // Same dispatch as sendTransaction; only the connector method differs.\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.signTransaction(session as any, input);\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector) {\n throw new WalletError(\n \"wallet_unavailable\",\n \"Embedded wallet connector not available.\",\n );\n }\n return _embeddedConnector.signTransaction(session as any, input);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).signTransaction(\n session as any,\n input,\n );\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.signTransaction(session as any, input);\n },\n sendTransaction: async (session, input) => {\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.sendTransaction(session as any, input);\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.sendTransaction(session as any, input);\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector) {\n throw new WalletError(\n \"wallet_unavailable\",\n \"Embedded wallet connector not available.\",\n );\n }\n return _embeddedConnector.sendTransaction(session as any, input);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).sendTransaction(\n session as any,\n input,\n );\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.sendTransaction(session, input);\n },\n onAccountsChanged: (session, handler) => {\n // Same dispatch as every other session-routed call.\n const noop = () => {};\n if (session.id?.startsWith(\"eip6963-\")) {\n return (\n eip6963Connector.onAccountsChanged?.(session as never, handler) ??\n noop\n );\n }\n if (session.walletType === \"embedded\") {\n // The embedded wallet does rotate its active account, through\n // `setActiveNamespace` and `backfillAccounts`. This used to return a\n // no-op on the reasoning that a local key \"only rotates through an\n // explicit call\" — which is exactly the case that now exists, and\n // left the provider publishing the connect-time account while a\n // different key signed.\n return (\n _embeddedConnector?.onAccountsChanged?.(session, handler) ?? noop\n );\n }\n if (session.walletType === \"passkeys\") {\n // A passkey connector holds no account to rotate: it cannot even\n // produce an address without a deployed smart account.\n return noop;\n }\n if (session.walletType === \"solana\") {\n return (\n (_solanaConnector as UniversalConnector | null)?.onAccountsChanged?.(\n session,\n handler,\n ) ?? noop\n );\n }\n return connector.onAccountsChanged?.(session, handler) ?? noop;\n },\n onChainChanged: (session, handler) => {\n const noop = () => {};\n if (session.id?.startsWith(\"eip6963-\")) {\n return (\n eip6963Connector.onChainChanged?.(session as never, handler) ?? noop\n );\n }\n if (\n session.walletType === \"passkeys\" ||\n session.walletType === \"embedded\"\n ) {\n return noop;\n }\n if (session.walletType === \"solana\") {\n return (\n (_solanaConnector as UniversalConnector | null)?.onChainChanged?.(\n session,\n handler,\n ) ?? noop\n );\n }\n return connector.onChainChanged?.(session, handler) ?? noop;\n },\n getCapabilities: (session) => {\n // Same dispatch as sendCalls, so the capability answer always comes from\n // the connector that would carry out the send. Asking one connector and\n // sending through another is how a caller ends up promised atomicity\n // that the executing wallet never claimed.\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.getCapabilities?.(session as never);\n }\n if (session.walletType === \"passkeys\") {\n return _passkeysConnector?.getCapabilities?.(session as never);\n }\n if (session.walletType === \"solana\") {\n // The Solana connector answers nothing today. Returning undefined\n // reports that rather than a fabricated \"no support\".\n return (\n _solanaConnector as UniversalConnector | null\n )?.getCapabilities?.(session);\n }\n if (session.walletType === \"embedded\") {\n return _embeddedConnector?.getCapabilities?.(session as never);\n }\n // Undefined rather than an empty object: \"cannot be asked\" has to stay\n // distinguishable from \"asked, and answered nothing\".\n return connector.getCapabilities?.(session);\n },\n sendCalls: async (session, calls, chainId, options) => {\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.sendCalls!(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.sendCalls!(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).sendCalls(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector?.sendCalls) {\n throw new WalletError(\n \"method_not_allowed\",\n \"Embedded wallet does not support sendCalls\",\n );\n }\n return _embeddedConnector.sendCalls!(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n if (!connector.sendCalls) {\n throw new WalletError(\n \"method_not_allowed\",\n \"sendCalls not supported by this connector\",\n );\n }\n return connector.sendCalls(session, calls, chainId, options);\n },\n showCallsStatus: async (session, bundleHash) => {\n // Same dispatch as sendCalls, so the wallet asked to display the bundle\n // is the one that sent it.\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.showCallsStatus!(session as never, bundleHash);\n }\n if (\n session.walletType === \"passkeys\" ||\n session.walletType === \"embedded\"\n ) {\n throw new WalletError(\n \"method_unsupported\",\n `${session.walletType} wallets have no UI to display a call bundle.`,\n );\n }\n if (!connector.showCallsStatus) {\n throw new WalletError(\n \"method_unsupported\",\n \"This connector cannot display call status.\",\n );\n }\n return connector.showCallsStatus(session, bundleHash);\n },\n getCallsStatus: async (session, bundleHash) => {\n if (\n session.id?.startsWith(\"eip6963-\") &&\n eip6963Connector.getCallsStatus\n ) {\n return eip6963Connector.getCallsStatus(session as any, bundleHash);\n }\n if (\n session.walletType === \"passkeys\" &&\n _passkeysConnector?.getCallsStatus\n ) {\n return _passkeysConnector.getCallsStatus(session as any, bundleHash);\n }\n if (session.walletType === \"embedded\") {\n throw new WalletError(\n \"method_not_allowed\",\n \"Embedded wallet does not support getCallsStatus\",\n );\n }\n if (!connector.getCallsStatus) {\n throw new WalletError(\n \"method_not_allowed\",\n \"getCallsStatus not supported by this connector\",\n );\n }\n return connector.getCallsStatus(session, bundleHash);\n },\n reconnect: async (session) => {\n if (session.walletType === \"eip6963\") {\n return eip6963Connector.reconnect(session);\n }\n if (session.walletType === \"embedded\") {\n if (_embeddedConnector) {\n return _embeddedConnector.reconnect(session);\n }\n return session;\n }\n if (session.walletType === \"solana\") {\n // Solana injected wallet doesn't support reconnect (no persisted session).\n // Return the saved session as-is; signing ops require wallet reconnection.\n return session;\n }\n return connector.reconnect(session);\n },\n disconnect: async (session) => {\n if (\n session.id?.startsWith(\"eip6963-\") ||\n session.walletType === \"eip6963\"\n ) {\n return eip6963Connector.disconnect(session as any);\n }\n if (session.walletType === \"embedded\" && _embeddedConnector) {\n return _embeddedConnector.disconnect();\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.disconnect(session as any);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return _solanaConnector.disconnect(session);\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.disconnect(session);\n },\n getAllConnectors: () => {\n const connectors: UniversalConnector[] = [connector];\n if (_embeddedConnector) connectors.push(_embeddedConnector);\n if (_passkeysConnector) connectors.push(_passkeysConnector);\n if (_solanaConnector) connectors.push(_solanaConnector);\n return connectors;\n },\n _setEmbeddedConnector: (conn: EmbeddedWalletConnector) => {\n _embeddedConnector = conn;\n },\n _setPasskeysConnector: (conn: PasskeysConnectorImpl) => {\n _passkeysConnector = conn;\n },\n _setSolanaConnector: (conn: UniversalConnector) => {\n _solanaConnector = conn;\n },\n };\n\n clientRef = client;\n clientInstance = client;\n return client;\n}\n\nexport function getClient(): Web3Client | null {\n return clientInstance;\n}\n\nexport function clearClient(): void {\n clientInstance = null;\n}\n"],"mappings":"AAQA,OAAS,UAAAA,EAAQ,eAAAC,MAAmB,wBAKpC,OAAS,oBAAAC,MAAwB,kCAEjC,OAAS,kBAAAC,MAAsB,wBAC/B,OACE,gCAAAC,MAEK,mCAwKP,IAAIC,EAAoC,KAEjC,SAASC,EAAaC,EAAkC,CAK7D,IAAIC,EAA+B,KAE7BC,EAAYL,EAA6B,CAC7C,UAAWG,EAAO,UAClB,SAAUA,EAAO,QACnB,CAAC,EAEGG,EAAqD,KACrDC,EAAqC,KAIrCC,EAAmD,KACnDC,EAAqC,KAGnCC,EACJP,EAAO,kBAAoBA,EAAO,gBAClC,CAACA,EAAO,gBAAgB,qBACpB,IAAIJ,EACJ,KAEFI,EAAO,iBACTI,EAAe,OAAO,6BAA6B,EAChD,KAAMI,GAAQ,CACb,IAAMC,EAA+B,CAAE,GAAGT,EAAO,cAAe,EAC5DO,IACFE,EAAe,qBAAuBF,EAAgB,SAWtDP,EAAO,gBACPS,EAAe,sBACf,CAACA,EAAe,YAEhBA,EAAe,UAAY,CACzB,MAAM,OAAOC,E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B,CAAkB,EACtDQ,GAAkBa,EAAW,KAAKb,CAAgB,EAC/Ca,CACT,EACA,sBAAwBX,GAAkC,CACxDZ,EAAqBY,CACvB,EACA,sBAAwBA,GAAgC,CACtDV,EAAqBU,CACvB,EACA,oBAAsBA,GAA6B,CACjDF,EAAmBE,CACrB,CACF,EAEA,OAAAd,EAAYe,EACZlB,EAAiBkB,EACVA,CACT,CAEO,SAASW,GAA+B,CAC7C,OAAO7B,CACT,CAEO,SAAS8B,GAAoB,CAClC9B,EAAiB,IACnB","names":["logger","WalletError","eip6963Connector","PassphraseGate","createWalletConnectConnector","clientInstance","createClient","config","clientRef","connector","_embeddedConnector","embeddedInit","_passkeysConnector","passkeysInit","_passphraseGate","mod","embeddedConfig","salt","passkeys","err","_solanaConnector","solanaInit","conn","client","walletId","session","input","handler","noop","calls","chainId","options","bundleHash","connectors","getClient","clearClient"]}
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"sourcesContent":["import type {\n BatchCall,\n CallsStatus,\n SendCallsOptions,\n UniversalConnector,\n UniversalWalletSession,\n WalletCapabilities,\n} from \"@naculus/connect-core\";\nimport { logger, WalletError } from \"@naculus/connect-core\";\nimport type {\n PocketConnectorClass as EmbeddedWalletConnector,\n PocketConfig,\n} from \"@naculus/connector-embedded\";\nimport { eip6963Connector } from \"@naculus/connector-evm-injected\";\nimport type PasskeysConnectorImpl from \"@naculus/connector-passkeys\";\nimport { PassphraseGate } from \"@naculus/connect-core\";\nimport {\n createWalletConnectConnector,\n type WalletConnectConnector,\n} from \"@naculus/connector-walletconnect\";\n\n/** App-supplied WalletConnect pieces (see `ClientConfig.walletConnect`). */\nexport type NativeWalletConnectOptions = {\n /** A pre-built `@walletconnect/sign-client` SignClient. */\n client?: unknown;\n openUrl?: (url: string) => void | Promise<void>;\n};\n\n/** An EIP-1193 provider announced to the injected-wallet connector. */\nexport type InjectedProviderRegistration = {\n info: { uuid: string; name: string; icon: string; rdns: string };\n provider: unknown;\n};\n\nexport type ClientConfig = {\n projectId: string;\n metadata: {\n name: string;\n description: string;\n url: string;\n icons: string[];\n };\n /** Enable embedded (self-custodial) wallet */\n enableEmbedded?: boolean;\n /** Configuration forwarded to the embedded wallet engine. */\n embeddedConfig?: PocketConfig;\n\n /**\n * Ask the user for the storage passphrase through the UI instead of\n * supplying `embeddedConfig.encryptionPassphrase` yourself.\n *\n * Creates a `PassphraseGate` on the client and wires it in. Mount\n * `<PassphraseDialog />` from `@naculus/connect-appkit-ui` — or drive\n * `usePassphraseGate()` yourself — and the wallet's encrypted storage has\n * somewhere to ask.\n *\n * A callback you supply in `embeddedConfig` wins: your own prompt is a\n * deliberate choice, not something to override.\n */\n passphrasePrompt?: boolean;\n\n /** Enable passkeys (WebAuthn) connector */\n enablePasskeys?: boolean;\n\n /** Enable Solana injected wallet connector (Phantom, Solflare) */\n enableSolana?: boolean;\n /** Default Solana chain (e.g. \"solana:0\"). Only used when enableSolana is true. */\n solanaDefaultChain?: string;\n /**\n * WalletConnect wiring the app supplies — on React Native, a SignClient\n * built with native storage and `Linking.openURL` for deep links.\n */\n walletConnect?: NativeWalletConnectOptions;\n /**\n * Wallet Standard wallets to register with the Solana connector (React\n * Native's Mobile Wallet Adapter wallet). Needs `enableSolana`.\n */\n solanaWallets?: readonly unknown[];\n /**\n * EIP-1193 providers to register as injected wallets (React Native's\n * Coinbase Mobile Wallet Protocol provider); connect with\n * `connectInjected(info.uuid)`.\n */\n injectedProviders?: readonly InjectedProviderRegistration[];\n /**\n * Solana JSON-RPC endpoint, for reading balances and submitting\n * transactions.\n *\n * Kept separate from any EVM endpoint: pointing Solana traffic at an\n * EIP-155 node fails with an error that blames the request.\n */\n solanaRpcUrl?: string;\n};\n\n/**\n * What a transaction looks like on the way in.\n *\n * An EVM transaction is a set of named fields the wallet assembles; a Solana\n * one is bytes the application has already built and serialized. Typing this\n * as `Record<string, unknown>` made the second impossible to express, so a\n * Solana transaction could not be sent through the client even once the\n * connector below it knew how.\n */\nexport type TransactionInput = {\n transaction: Record<string, unknown> | Uint8Array | string;\n chainId?: string;\n};\n\nexport interface Web3Client {\n connector: WalletConnectConnector;\n embeddedConnector: EmbeddedWalletConnector | null;\n /** Wait for the lazily imported embedded connector to become available. */\n getEmbeddedConnector: () => Promise<EmbeddedWalletConnector | null>;\n /** The Passkeys connector if enabled */\n passkeysConnector: PasskeysConnectorImpl | null;\n /**\n * Where encrypted storage asks for a passphrase, when `passphrasePrompt` is\n * on. Null otherwise, including when the app supplies its own callback.\n */\n passphraseGate: PassphraseGate | null;\n /** Solana JSON-RPC endpoint from config, or null when none was given. */\n solanaRpcUrl: string | null;\n /** The Solana injected wallet connector if enabled */\n solanaConnector: UniversalConnector | null;\n connect: () => Promise<UniversalWalletSession>;\n /** Connect via EIP-6963 injected wallet */\n connectInjected: (walletId?: string) => Promise<UniversalWalletSession>;\n connectEmbedded: () => Promise<UniversalWalletSession>;\n /** Connect via passkeys (WebAuthn) */\n connectPasskeys: () => Promise<UniversalWalletSession>;\n reconnect: (\n session: UniversalWalletSession,\n ) => Promise<UniversalWalletSession>;\n disconnect: (session: UniversalWalletSession) => Promise<void>;\n /** Sign a message via the appropriate connector for the session */\n signMessage: (\n session: UniversalWalletSession,\n input: { message: string; address?: string; chainId?: string },\n ) => Promise<unknown>;\n /** Send a transaction via the appropriate connector for the session */\n sendTransaction: (\n session: UniversalWalletSession,\n input: TransactionInput,\n ) => Promise<unknown>;\n /**\n * Sign without broadcasting.\n *\n * Present because a Solana application routinely signs a transaction it\n * submits itself, or hands to a relayer. There was no way to ask for that\n * through the client at all.\n */\n signTransaction: (\n session: UniversalWalletSession,\n input: TransactionInput,\n ) => Promise<unknown>;\n /** Send batched calls (EIP-5792 wallet_sendCalls) via the appropriate connector */\n sendCalls: (\n session: UniversalWalletSession,\n calls: BatchCall[],\n chainId?: string,\n options?: SendCallsOptions,\n ) => Promise<string>;\n /**\n * Ask the wallet what the account can do, keyed by CAIP-2 chain.\n *\n * Undefined when the active connector has no way to answer, which is a\n * different fact from \"the account supports nothing\" — see\n * getAccountCapabilities in @naculus/connect-core.\n */\n getCapabilities?: (\n session: UniversalWalletSession,\n ) => Promise<Record<string, WalletCapabilities>> | undefined;\n /**\n * Subscribe to in-wallet account switches, whatever the namespace.\n *\n * Dispatches to the connector carrying the session, so a consumer never has\n * to know whether the wallet reports EIP-1193 `accountsChanged`, Solana's\n * `accountChanged`, or a WalletConnect session update. Returns an\n * unsubscribe function; returns a no-op when the connector cannot report.\n */\n onAccountsChanged?: (\n session: UniversalWalletSession,\n handler: (accounts: string[]) => void,\n ) => () => void;\n /** Counterpart to onAccountsChanged for in-wallet chain switches. */\n onChainChanged?: (\n session: UniversalWalletSession,\n handler: (chainId: string) => void,\n ) => () => void;\n /**\n * EIP-5792 `wallet_showCallsStatus`: ask the wallet to display a bundle.\n *\n * Optional because most wallets do not implement it, and a refusal is\n * cosmetic — the bundle is unaffected.\n */\n showCallsStatus?: (\n session: UniversalWalletSession,\n bundleHash: string,\n ) => Promise<void>;\n getCallsStatus: (\n session: UniversalWalletSession,\n bundleHash: string,\n ) => Promise<CallsStatus>;\n startPairing: () => Promise<string>;\n completePairing: () => Promise<UniversalWalletSession>;\n /** Abandon an in-flight pairing; a session that still arrives is torn down. */\n cancelPairing: () => void;\n getAllConnectors: () => UniversalConnector[];\n /** @internal set embedded connector after lazy init */\n _setEmbeddedConnector: (conn: EmbeddedWalletConnector) => void;\n /** @internal set passkeys connector after lazy init */\n _setPasskeysConnector: (conn: PasskeysConnectorImpl) => void;\n /** @internal set solana connector after lazy init */\n _setSolanaConnector: (conn: UniversalConnector) => void;\n}\n\nlet clientInstance: Web3Client | null = null;\n\nexport function createClient(config: ClientConfig): Web3Client {\n // A provider owns its client. Keeping a process-wide singleton here causes\n // the first provider's projectId, metadata, and feature flags to leak into\n // every later provider. `getClient()` remains as a legacy last-created\n // accessor; provider hooks use the client carried by context.\n let clientRef: Web3Client | null = null;\n\n const connector = createWalletConnectConnector({\n projectId: config.projectId,\n metadata: config.metadata,\n ...(config.walletConnect?.client\n ? { client: config.walletConnect.client as never }\n : {}),\n ...(config.walletConnect?.openUrl\n ? { openUrl: config.walletConnect.openUrl }\n : {}),\n });\n\n let _embeddedConnector: EmbeddedWalletConnector | null = null;\n let embeddedInit: Promise<void> | null = null;\n\n // Declared before the passkeys connector exists, because the embedded\n // wallet is constructed from it and the two load independently.\n let _passkeysConnector: PasskeysConnectorImpl | null = null;\n let passkeysInit: Promise<void> | null = null;\n\n // Only when asked for, and never over a callback the app already supplied.\n const _passphraseGate =\n config.passphrasePrompt &&\n config.enableEmbedded &&\n !config.embeddedConfig?.encryptionPassphrase\n ? new PassphraseGate()\n : null;\n\n if (config.enableEmbedded) {\n embeddedInit = import(\"@naculus/connector-embedded\")\n .then((mod) => {\n const embeddedConfig: PocketConfig = { ...config.embeddedConfig };\n if (_passphraseGate) {\n embeddedConfig.encryptionPassphrase = _passphraseGate.request;\n }\n // Passkey unlock turns itself on where the platform supports it: a\n // protection that has to be switched on protects only the people who\n // already knew to look for it. Where the authenticator cannot answer\n // this returns null and the record stays passphrase-only, which is\n // why it is safe to wire without asking.\n //\n // Requires encryption to be on at all — there is no key to wrap\n // otherwise — and never replaces a provider the app supplied.\n if (\n config.enablePasskeys &&\n embeddedConfig.encryptionPassphrase &&\n !embeddedConfig.prfUnlock\n ) {\n embeddedConfig.prfUnlock = {\n async derive(salt: Uint8Array) {\n if (passkeysInit) await passkeysInit;\n const passkeys = _passkeysConnector;\n if (!passkeys?.hasCredential()) return null;\n return passkeys.derivePrfKey(salt);\n },\n };\n }\n const conn = mod.createPocketConnector(embeddedConfig);\n _embeddedConnector = conn;\n clientRef?._setEmbeddedConnector(_embeddedConnector);\n })\n .catch((err) => {\n logger.warn(\n \"react/client\",\n \"Embedded wallet connector not available:\",\n err,\n );\n _embeddedConnector = null;\n });\n }\n\n if (config.enablePasskeys) {\n passkeysInit = import(\"@naculus/connector-passkeys\")\n .then((mod) => {\n const conn = mod.createPasskeysConnector();\n _passkeysConnector = conn;\n clientRef?._setPasskeysConnector(_passkeysConnector);\n })\n .catch((err) => {\n logger.warn(\"react/client\", \"Passkeys connector not available:\", err);\n _passkeysConnector = null;\n });\n }\n\n let _solanaConnector: UniversalConnector | null = null;\n let solanaInit: Promise<void> | null = null;\n\n if (config.enableSolana) {\n solanaInit = import(\"@naculus/connector-solana\")\n .then((mod: any) => {\n // Use the singleton instance so hooks (useSolanaAccount, etc.) and\n // the client routing share the same activeSession state.\n const conn = mod.solanaConnector as UniversalConnector;\n if (config.solanaDefaultChain && \"configure\" in conn) {\n (conn as any).configure({ defaultChain: config.solanaDefaultChain });\n }\n _solanaConnector = conn;\n if (typeof window !== \"undefined\" && \"startDiscovery\" in conn) {\n (conn as any).startDiscovery();\n }\n for (const wallet of config.solanaWallets ?? []) {\n (conn as any).registerWallet?.(wallet);\n }\n clientRef?._setSolanaConnector(_solanaConnector);\n })\n .catch((err) => {\n logger.warn(\"react/client\", \"Solana connector not available:\", err);\n _solanaConnector = null;\n });\n }\n\n // Start EIP-6963 discovery eagerly so wallets are available when user clicks connect\n if (typeof window !== \"undefined\") {\n eip6963Connector.startDiscovery();\n }\n for (const { info, provider } of config.injectedProviders ?? []) {\n eip6963Connector.registerProvider(info, provider as never);\n }\n\n const client: Web3Client = {\n connector,\n get embeddedConnector() {\n return _embeddedConnector;\n },\n getEmbeddedConnector: async () => {\n if (embeddedInit) await embeddedInit;\n return _embeddedConnector;\n },\n get passkeysConnector() {\n return _passkeysConnector;\n },\n passphraseGate: _passphraseGate,\n solanaRpcUrl: config.solanaRpcUrl ?? null,\n get solanaConnector() {\n return _solanaConnector;\n },\n connect: () => connector.connect(),\n connectInjected: async (walletId?: string) => {\n return eip6963Connector.connect(walletId);\n },\n connectEmbedded: async () => {\n if (embeddedInit) await embeddedInit;\n if (!_embeddedConnector) {\n throw new Error(\n \"Embedded wallet not enabled. Set enableEmbedded: true in config.\",\n );\n }\n return _embeddedConnector.connect();\n },\n connectPasskeys: async () => {\n if (passkeysInit) await passkeysInit;\n if (!_passkeysConnector) {\n throw new Error(\n \"Passkeys connector not enabled. Set enablePasskeys: true in config.\",\n );\n }\n return _passkeysConnector.connect();\n },\n startPairing: () => connector.startPairing(),\n completePairing: () => connector.completePairing(),\n cancelPairing: () => connector.cancelPairing?.(),\n signMessage: async (session, input) => {\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.signMessage(session as any, input);\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.signMessage(session as any, input);\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector) {\n throw new WalletError(\n \"wallet_unavailable\",\n \"Embedded wallet connector not available.\",\n );\n }\n return _embeddedConnector.signMessage(session as any, input);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).signMessage(session as any, input);\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.signMessage(session, input);\n },\n signTransaction: async (session, input) => {\n // Same dispatch as sendTransaction; only the connector method differs.\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.signTransaction(session as any, input);\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector) {\n throw new WalletError(\n \"wallet_unavailable\",\n \"Embedded wallet connector not available.\",\n );\n }\n return _embeddedConnector.signTransaction(session as any, input);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).signTransaction(\n session as any,\n input,\n );\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.signTransaction(session as any, input);\n },\n sendTransaction: async (session, input) => {\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.sendTransaction(session as any, input);\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.sendTransaction(session as any, input);\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector) {\n throw new WalletError(\n \"wallet_unavailable\",\n \"Embedded wallet connector not available.\",\n );\n }\n return _embeddedConnector.sendTransaction(session as any, input);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).sendTransaction(\n session as any,\n input,\n );\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.sendTransaction(session, input);\n },\n onAccountsChanged: (session, handler) => {\n // Same dispatch as every other session-routed call.\n const noop = () => {};\n if (session.id?.startsWith(\"eip6963-\")) {\n return (\n eip6963Connector.onAccountsChanged?.(session as never, handler) ??\n noop\n );\n }\n if (session.walletType === \"embedded\") {\n // The embedded wallet does rotate its active account, through\n // `setActiveNamespace` and `backfillAccounts`. This used to return a\n // no-op on the reasoning that a local key \"only rotates through an\n // explicit call\" — which is exactly the case that now exists, and\n // left the provider publishing the connect-time account while a\n // different key signed.\n return (\n _embeddedConnector?.onAccountsChanged?.(session, handler) ?? noop\n );\n }\n if (session.walletType === \"passkeys\") {\n // A passkey connector holds no account to rotate: it cannot even\n // produce an address without a deployed smart account.\n return noop;\n }\n if (session.walletType === \"solana\") {\n return (\n (_solanaConnector as UniversalConnector | null)?.onAccountsChanged?.(\n session,\n handler,\n ) ?? noop\n );\n }\n return connector.onAccountsChanged?.(session, handler) ?? noop;\n },\n onChainChanged: (session, handler) => {\n const noop = () => {};\n if (session.id?.startsWith(\"eip6963-\")) {\n return (\n eip6963Connector.onChainChanged?.(session as never, handler) ?? noop\n );\n }\n if (\n session.walletType === \"passkeys\" ||\n session.walletType === \"embedded\"\n ) {\n return noop;\n }\n if (session.walletType === \"solana\") {\n return (\n (_solanaConnector as UniversalConnector | null)?.onChainChanged?.(\n session,\n handler,\n ) ?? noop\n );\n }\n return connector.onChainChanged?.(session, handler) ?? noop;\n },\n getCapabilities: (session) => {\n // Same dispatch as sendCalls, so the capability answer always comes from\n // the connector that would carry out the send. Asking one connector and\n // sending through another is how a caller ends up promised atomicity\n // that the executing wallet never claimed.\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.getCapabilities?.(session as never);\n }\n if (session.walletType === \"passkeys\") {\n return _passkeysConnector?.getCapabilities?.(session as never);\n }\n if (session.walletType === \"solana\") {\n // The Solana connector answers nothing today. Returning undefined\n // reports that rather than a fabricated \"no support\".\n return (\n _solanaConnector as UniversalConnector | null\n )?.getCapabilities?.(session);\n }\n if (session.walletType === \"embedded\") {\n return _embeddedConnector?.getCapabilities?.(session as never);\n }\n // Undefined rather than an empty object: \"cannot be asked\" has to stay\n // distinguishable from \"asked, and answered nothing\".\n return connector.getCapabilities?.(session);\n },\n sendCalls: async (session, calls, chainId, options) => {\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.sendCalls!(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.sendCalls!(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return (_solanaConnector as any).sendCalls(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n if (session.walletType === \"embedded\") {\n if (!_embeddedConnector?.sendCalls) {\n throw new WalletError(\n \"method_not_allowed\",\n \"Embedded wallet does not support sendCalls\",\n );\n }\n return _embeddedConnector.sendCalls!(\n session as any,\n calls,\n chainId,\n options,\n );\n }\n if (!connector.sendCalls) {\n throw new WalletError(\n \"method_not_allowed\",\n \"sendCalls not supported by this connector\",\n );\n }\n return connector.sendCalls(session, calls, chainId, options);\n },\n showCallsStatus: async (session, bundleHash) => {\n // Same dispatch as sendCalls, so the wallet asked to display the bundle\n // is the one that sent it.\n if (session.id?.startsWith(\"eip6963-\")) {\n return eip6963Connector.showCallsStatus!(session as never, bundleHash);\n }\n if (\n session.walletType === \"passkeys\" ||\n session.walletType === \"embedded\"\n ) {\n throw new WalletError(\n \"method_unsupported\",\n `${session.walletType} wallets have no UI to display a call bundle.`,\n );\n }\n if (!connector.showCallsStatus) {\n throw new WalletError(\n \"method_unsupported\",\n \"This connector cannot display call status.\",\n );\n }\n return connector.showCallsStatus(session, bundleHash);\n },\n getCallsStatus: async (session, bundleHash) => {\n if (\n session.id?.startsWith(\"eip6963-\") &&\n eip6963Connector.getCallsStatus\n ) {\n return eip6963Connector.getCallsStatus(session as any, bundleHash);\n }\n if (\n session.walletType === \"passkeys\" &&\n _passkeysConnector?.getCallsStatus\n ) {\n return _passkeysConnector.getCallsStatus(session as any, bundleHash);\n }\n if (session.walletType === \"embedded\") {\n throw new WalletError(\n \"method_not_allowed\",\n \"Embedded wallet does not support getCallsStatus\",\n );\n }\n if (!connector.getCallsStatus) {\n throw new WalletError(\n \"method_not_allowed\",\n \"getCallsStatus not supported by this connector\",\n );\n }\n return connector.getCallsStatus(session, bundleHash);\n },\n reconnect: async (session) => {\n if (session.walletType === \"eip6963\") {\n return eip6963Connector.reconnect(session);\n }\n if (session.walletType === \"embedded\") {\n if (_embeddedConnector) {\n return _embeddedConnector.reconnect(session);\n }\n return session;\n }\n if (session.walletType === \"solana\") {\n // Solana injected wallet doesn't support reconnect (no persisted session).\n // Return the saved session as-is; signing ops require wallet reconnection.\n return session;\n }\n return connector.reconnect(session);\n },\n disconnect: async (session) => {\n if (\n session.id?.startsWith(\"eip6963-\") ||\n session.walletType === \"eip6963\"\n ) {\n return eip6963Connector.disconnect(session as any);\n }\n if (session.walletType === \"embedded\" && _embeddedConnector) {\n return _embeddedConnector.disconnect();\n }\n if (session.walletType === \"passkeys\" && _passkeysConnector) {\n return _passkeysConnector.disconnect(session as any);\n }\n if (session.walletType === \"solana\") {\n if (solanaInit) await solanaInit;\n if (_solanaConnector) {\n return _solanaConnector.disconnect(session);\n }\n throw new WalletError(\n \"wallet_unavailable\",\n \"Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.\",\n );\n }\n return connector.disconnect(session);\n },\n getAllConnectors: () => {\n const connectors: UniversalConnector[] = [connector];\n if (_embeddedConnector) connectors.push(_embeddedConnector);\n if (_passkeysConnector) connectors.push(_passkeysConnector);\n if (_solanaConnector) connectors.push(_solanaConnector);\n return connectors;\n },\n _setEmbeddedConnector: (conn: EmbeddedWalletConnector) => {\n _embeddedConnector = conn;\n },\n _setPasskeysConnector: (conn: PasskeysConnectorImpl) => {\n _passkeysConnector = conn;\n },\n _setSolanaConnector: (conn: UniversalConnector) => {\n _solanaConnector = conn;\n },\n };\n\n clientRef = client;\n clientInstance = client;\n return client;\n}\n\nexport function getClient(): Web3Client | null {\n return clientInstance;\n}\n\nexport function clearClient(): void {\n clientInstance = null;\n}\n"],"mappings":"AAQA,OAAS,UAAAA,EAAQ,eAAAC,MAAmB,wBAKpC,OAAS,oBAAAC,MAAwB,kCAEjC,OAAS,kBAAAC,MAAsB,wBAC/B,OACE,gCAAAC,MAEK,mCAqMP,IAAIC,EAAoC,KAEjC,SAASC,EAAaC,EAAkC,CAK7D,IAAIC,EAA+B,KAE7BC,EAAYL,EAA6B,CAC7C,UAAWG,EAAO,UAClB,SAAUA,EAAO,SACjB,GAAIA,EAAO,eAAe,OACtB,CAAE,OAAQA,EAAO,cAAc,MAAgB,EAC/C,CAAC,EACL,GAAIA,EAAO,eAAe,QACtB,CAAE,QAASA,EAAO,cAAc,OAAQ,EACxC,CAAC,CACP,CAAC,EAEGG,EAAqD,KACrDC,EAAqC,KAIrCC,EAAmD,KACnDC,EAAqC,KAGnCC,EACJP,EAAO,kBACPA,EAAO,gBACP,CAACA,EAAO,gBAAgB,qBACpB,IAAIJ,EACJ,KAEFI,EAAO,iBACTI,EAAe,OAAO,6BAA6B,EAChD,KAAMI,GAAQ,CACb,IAAMC,EAA+B,CAAE,GAAG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,aAAe,YAAchB,EACvC,OAAOA,EAAmB,WAAWgB,CAAc,EAErD,GAAIA,EAAQ,aAAe,SAAU,CAEnC,GADIP,GAAY,MAAMA,EAClBD,EACF,OAAOA,EAAiB,WAAWQ,CAAO,EAE5C,MAAM,IAAI3B,EACR,qBACA,yGACF,CACF,CACA,OAAOQ,EAAU,WAAWmB,CAAO,CACrC,EACA,iBAAkB,IAAM,CACtB,IAAMQ,EAAmC,CAAC3B,CAAS,EACnD,OAAIC,GAAoB0B,EAAW,KAAK1B,CAAkB,EACtDE,GAAoBwB,EAAW,KAAKxB,CAAkB,EACtDQ,GAAkBgB,EAAW,KAAKhB,CAAgB,EAC/CgB,CACT,EACA,sBAAwBd,GAAkC,CACxDZ,EAAqBY,CACvB,EACA,sBAAwBA,GAAgC,CACtDV,EAAqBU,CACvB,EACA,oBAAsBA,GAA6B,CACjDF,EAAmBE,CACrB,CACF,EAEA,OAAAd,EAAYkB,EACZrB,EAAiBqB,EACVA,CACT,CAEO,SAASW,GAA+B,CAC7C,OAAOhC,CACT,CAEO,SAASiC,GAAoB,CAClCjC,EAAiB,IACnB","names":["logger","WalletError","eip6963Connector","PassphraseGate","createWalletConnectConnector","clientInstance","createClient","config","clientRef","connector","_embeddedConnector","embeddedInit","_passkeysConnector","passkeysInit","_passphraseGate","mod","embeddedConfig","salt","passkeys","err","_solanaConnector","solanaInit","conn","wallet","info","provider","client","walletId","session","input","handler","noop","calls","chainId","options","bundleHash","connectors","getClient","clearClient"]}
|