@invisi-labs/sdk 1.1.4 → 1.1.5

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/index.d.cts CHANGED
@@ -13,7 +13,7 @@ export { b as WalletStore, w as walletBalance } from './state-AUnz7TG7.cjs';
13
13
  import { Hex, Address } from '@invisi-labs/protocol/contracts';
14
14
  import { Provider, TransactionRequest, TransactionResponse } from 'ethers';
15
15
  import { ProtocolRpcClient as ProtocolRpcClient$1 } from '@invisi-labs/rpc';
16
- export { ProtocolDeployment, ProtocolOutput, ProtocolRpcChain, ProtocolRpcClientOptions, ProtocolRpcConnectionOptions, ProtocolRpcError, ProtocolRpcReader, RegisteredReceivingAddress } from '@invisi-labs/rpc';
16
+ export { ProtocolCreditTransition, ProtocolDeployment, ProtocolOutput, ProtocolRpcChain, ProtocolRpcClientOptions, ProtocolRpcConnectionOptions, ProtocolRpcError, ProtocolRpcReader, ProtocolTransactionUpdates, RegisteredReceivingAddress } from '@invisi-labs/rpc';
17
17
  import { W as WalletRecordCodec } from './store-Cz75STRl.cjs';
18
18
 
19
19
  /** Stable codes returned by public SDK prepare* methods; inspect details instead of matching messages. */
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ export { b as WalletStore, w as walletBalance } from './state-AUnz7TG7.js';
13
13
  import { Hex, Address } from '@invisi-labs/protocol/contracts';
14
14
  import { Provider, TransactionRequest, TransactionResponse } from 'ethers';
15
15
  import { ProtocolRpcClient as ProtocolRpcClient$1 } from '@invisi-labs/rpc';
16
- export { ProtocolDeployment, ProtocolOutput, ProtocolRpcChain, ProtocolRpcClientOptions, ProtocolRpcConnectionOptions, ProtocolRpcError, ProtocolRpcReader, RegisteredReceivingAddress } from '@invisi-labs/rpc';
16
+ export { ProtocolCreditTransition, ProtocolDeployment, ProtocolOutput, ProtocolRpcChain, ProtocolRpcClientOptions, ProtocolRpcConnectionOptions, ProtocolRpcError, ProtocolRpcReader, ProtocolTransactionUpdates, RegisteredReceivingAddress } from '@invisi-labs/rpc';
17
17
  import { W as WalletRecordCodec } from './store-BMN8kd0c.js';
18
18
 
19
19
  /** Stable codes returned by public SDK prepare* methods; inspect details instead of matching messages. */
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/explicit-preparation.ts","../src/PreparedTransaction.ts","../src/Invisi.ts","../src/AddressRegistry.ts","../src/index.ts","../src/ProtocolRpcClient.ts","../src/integrations/encrypted-codec.ts"],"sourcesContent":["import { getAddress } from \"ethers\";\nimport type { CreditInput, NoteInput } from \"./explicit-types\";\nimport { PreparedTransaction } from \"./PreparedTransaction\";\nimport { positiveAmount } from \"./session/prepare-common\";\nimport { TransactionPreparation } from \"./session/transaction-preparation\";\nimport type { PreparationInventory, WalletSessionOptions } from \"./session/operation-types\";\n\n/** Only explicitly supplied records participate. No store or automatic coin selection. */\nexport function explicitPreparation(\n options: WalletSessionOptions,\n data: {\n inputs?: readonly NoteInput[];\n creditInputs?: readonly CreditInput[];\n changeAddress?: string;\n },\n tokenAddress: `0x${string}`\n) {\n if (!options.chainReader) throw new Error(\"chain reader required\");\n const inputs = structuredClone(data.inputs ?? []);\n const credits = structuredClone(data.creditInputs ?? []);\n const inventory: PreparationInventory = { notes: {}, credits: {}, reservations: {} };\n const context = options.protocol.context;\n function position(input: NoteInput | CreditInput) {\n if (\n typeof input.treeId !== \"bigint\" ||\n input.treeId < 0n ||\n input.treeId >= 1n << 256n ||\n !Number.isInteger(input.leafIndex) ||\n input.leafIndex < 0 ||\n input.leafIndex >= 65536\n )\n throw new Error(\"invalid explicit input position\");\n }\n for (const input of inputs) {\n position(input);\n positiveAmount(input.note.amount);\n if (inventory.notes[input.commitment]) throw new Error(\"duplicate explicit note input\");\n if (\n input.note.chainId !== context.chainId ||\n input.note.protocolAddress !== BigInt(context.protocolAddress) ||\n input.note.walletIdentity !== options.wallet.walletIdentity\n )\n throw new Error(\"explicit note identity or deployment mismatch\");\n inventory.notes[input.commitment] = { ...input, spent: \"unspent\" };\n }\n for (const input of credits) {\n position(input);\n if (input.role !== \"owner\" && input.role !== \"spender\")\n throw new Error(\"invalid explicit Credit role\");\n const key = input.commitment + \":\" + input.role;\n if (inventory.credits[key]) throw new Error(\"duplicate explicit Credit input\");\n inventory.credits[key] = { ...input, spent: \"unspent\" };\n }\n const scope = {\n ...context,\n namespace: \"explicit\",\n walletIdentity: options.wallet.walletIdentity,\n };\n const {\n store: _store,\n coinSelector: _selector,\n authorization: _authorization,\n viewing: _viewing,\n signer: _signer,\n fundingSigner: _fundingSigner,\n ...capabilities\n } = options;\n\n if (inputs.some((input) => input.note.tokenAddress !== BigInt(getAddress(tokenAddress))))\n throw new Error(\"explicit note token mismatch\");\n const runtime = {\n options: { ...capabilities, protocol: options.protocol.forToken(tokenAddress) },\n reader: options.chainReader!,\n scope,\n };\n return new TransactionPreparation<PreparedTransaction>({\n ...runtime,\n explicitInputs: true,\n ...(data.changeAddress ? { changeAddress: data.changeAddress } : {}),\n readInventory: async () => structuredClone(inventory),\n complete: async (plan) => PreparedTransaction.prepare(runtime, plan),\n });\n}\n","import { estimateGasReference } from \"./gas-estimation\";\nimport {\n proveOperation,\n walletSigningRequest,\n acceptWalletSignature,\n fundingSigningRequest,\n acceptFundingSignature,\n} from \"./session/operation-execution\";\nimport { MissingCapabilityError, type AuthorizedStatement } from \"@invisi-labs/core\";\nimport { normalizeFunding, type TransactionCall } from \"@invisi-labs/protocol\";\nimport type { Prover, ProofBundle } from \"@invisi-labs/prover\";\nimport type {\n OperationPlan,\n OperationRuntime,\n OperationAggregateMember,\n SavedOperation,\n TransactionProveOptions,\n} from \"./session/operation-types\";\nimport type { OperationStatus } from \"./session/state\";\nimport {\n encodeOperation,\n publicProof,\n requiresAuthorization,\n statement,\n} from \"./session/operation-protocol\";\nimport { sameStatement } from \"./session/proof-integrity\";\nimport { operationPreview } from \"./session/operation-preview\";\nfunction check(ok: unknown, message: string): asserts ok {\n if (!ok) throw new Error(message);\n}\n\ntype Runtime = Omit<OperationRuntime, \"store\" | \"authorization\">;\ntype Lifecycle = { generation: number; busy: boolean };\n/** An immutable, local transaction handle. No wallet inventory, reservations or persistence. */\nexport class PreparedTransaction {\n readonly #runtime: Runtime;\n readonly #saved: SavedOperation;\n readonly #authorization: AuthorizedStatement | undefined;\n readonly #lifecycle: Lifecycle;\n readonly status: OperationStatus;\n private constructor(\n runtime: Runtime,\n saved: SavedOperation,\n status: OperationStatus,\n lifecycle: Lifecycle,\n authorization?: AuthorizedStatement\n ) {\n this.#runtime = runtime;\n this.#saved = structuredClone(saved);\n this.#lifecycle = lifecycle;\n this.#authorization = authorization;\n this.status = status;\n Object.freeze(this);\n }\n static prepare(runtime: Runtime, plan: OperationPlan): PreparedTransaction {\n return new PreparedTransaction(\n runtime,\n { plan: structuredClone(plan), generation: 0 },\n \"prepared\",\n { generation: 0, busy: false }\n );\n }\n get id() {\n return this.#saved.plan.id;\n }\n get kind() {\n return this.#saved.plan.kind;\n }\n estimateGas() {\n return estimateGasReference(\n this.#saved.plan,\n this.#runtime.options.protocol,\n this.#runtime.options.gasBenchmarks\n );\n }\n preview() {\n return operationPreview(this.#saved.plan, this.status);\n }\n private current() {\n check(\n !this.#lifecycle.busy && this.#lifecycle.generation === this.#saved.generation,\n \"stale transaction handle or active worker\"\n );\n }\n private async stage(\n stage: string,\n allowed: OperationStatus[],\n work: (\n saved: SavedOperation\n ) => Promise<{ status: OperationStatus; authorization?: AuthorizedStatement }>,\n signal?: AbortSignal\n ): Promise<PreparedTransaction> {\n signal?.throwIfAborted();\n this.current();\n check(allowed.includes(this.status), `invalid transaction stage for ${stage}`);\n this.#lifecycle.busy = true;\n const saved = structuredClone(this.#saved);\n try {\n const next = await work(saved);\n signal?.throwIfAborted();\n saved.generation++;\n this.#lifecycle.generation = saved.generation;\n return new PreparedTransaction(\n this.#runtime,\n saved,\n next.status,\n this.#lifecycle,\n next.authorization ?? this.#authorization\n );\n } finally {\n this.#lifecycle.busy = false;\n }\n }\n /** Public EIP-712 request; signing transport and key custody belong to the caller. */\n async exportWalletAuthorization(options: { signal?: AbortSignal } = {}) {\n options.signal?.throwIfAborted();\n this.current();\n check(\n requiresAuthorization(this.#saved.plan),\n \"operation does not require wallet authorization\"\n );\n check(\n [\"prepared\", \"authorized\"].includes(this.status),\n \"operation is not awaiting wallet authorization\"\n );\n return walletSigningRequest(this.#saved.plan);\n }\n\n /** Attach an external EOA signature, retaining its witness only at the private proving boundary. */\n async withWalletSignature(\n signature: string,\n options: { signal?: AbortSignal } = {}\n ): Promise<PreparedTransaction> {\n options.signal?.throwIfAborted();\n this.current();\n check(\n requiresAuthorization(this.#saved.plan),\n \"operation does not require wallet authorization\"\n );\n check(\n [\"prepared\", \"authorized\"].includes(this.status),\n \"operation is not awaiting wallet authorization\"\n );\n const authorization = await acceptWalletSignature(this.#saved.plan, signature);\n return this.stage(\n \"wallet authorization\",\n [\"prepared\", \"authorized\"],\n async () => ({ status: \"authorized\", authorization }),\n options.signal\n );\n }\n\n /** Export only after proving when the funding authorization binds an actual proof hash. */\n async exportFundingAuthorization(options: { signal?: AbortSignal } = {}) {\n options.signal?.throwIfAborted();\n this.current();\n check(\n this.status === (this.kind === \"shield\" ? \"prepared\" : \"proved\"),\n \"operation is not awaiting funding authorization or proof\"\n );\n const request = await fundingSigningRequest(this.#saved, this.#runtime);\n options.signal?.throwIfAborted();\n this.current();\n return request;\n }\n\n /** Verify an external signature against this handle's own frozen operation. */\n async withFundingSignature(\n signature: string,\n options: { signal?: AbortSignal } = {}\n ): Promise<PreparedTransaction> {\n options.signal?.throwIfAborted();\n this.current();\n check(\n this.status === (this.kind === \"shield\" ? \"prepared\" : \"proved\"),\n \"operation is not awaiting funding authorization or proof\"\n );\n const verified = await acceptFundingSignature(this.#saved, signature, this.#runtime);\n return this.stage(\n \"funding authorization\",\n this.kind === \"shield\" ? [\"prepared\"] : [\"proved\"],\n async (saved) => {\n saved.plan.funding.signature = verified;\n if (saved.plan.statement?.target !== \"noir-recursive\") {\n saved.call = await this.encode(saved);\n }\n return { status: \"ready\" };\n },\n options.signal\n );\n }\n\n async prove(options?: TransactionProveOptions): Promise<PreparedTransaction>;\n async prove(backend: Prover, options?: TransactionProveOptions): Promise<PreparedTransaction>;\n async prove(\n backendOrOptions: Prover | TransactionProveOptions = {},\n suppliedOptions: TransactionProveOptions = {}\n ): Promise<PreparedTransaction> {\n const options = { ...(\"prove\" in backendOrOptions ? suppliedOptions : backendOrOptions) };\n const plan = this.#saved.plan;\n check(plan.kind !== \"shield\", \"shield requires no proof\");\n if (requiresAuthorization(plan)) {\n check(\n this.#authorization,\n \"local wallet authorization required; authorize again after recovery\"\n );\n }\n const prover =\n \"prove\" in backendOrOptions ? backendOrOptions : this.#runtime.options.prover;\n if (!prover) {\n throw new MissingCapabilityError(\"prover\");\n }\n return this.stage(\n \"proof\",\n requiresAuthorization(plan) ? [\"authorized\"] : [\"prepared\"],\n async (saved) => {\n const p = saved.plan;\n saved.proof = await proveOperation(\n this.#runtime.options.protocol,\n p,\n this.#authorization,\n prover,\n options\n );\n if (p.fundingMode === \"signature\") {\n return { status: \"proved\" };\n }\n if (p.statement?.target !== \"noir-recursive\") {\n saved.call = await this.encode(saved);\n }\n return { status: \"ready\" };\n },\n options.signal\n );\n }\n\n private encode(saved: SavedOperation): Promise<TransactionCall> {\n return encodeOperation(saved);\n }\n\n /** Shield caller funding needs no wallet signing or proof; this step only encodes its frozen request. */\n async ready(): Promise<PreparedTransaction> {\n check(\n this.kind === \"shield\" && this.#saved.plan.fundingMode === \"caller\",\n \"operation needs authorization or proof first\"\n );\n return this.stage(\"encoding\", [\"prepared\"], async (saved) => {\n saved.call = await this.encode(saved);\n return { status: \"ready\" };\n });\n }\n\n async exportTransaction(): Promise<TransactionCall> {\n this.current();\n check(\n this.#saved.plan.statement?.target !== \"noir-recursive\",\n \"recursive operations must be exported as aggregate members\"\n );\n check(this.status === \"ready\" && this.#saved.call, \"transaction is not ready\");\n return structuredClone(this.#saved.call);\n }\n exportProof(): ProofBundle {\n this.current();\n check(this.#saved.proof, \"transaction has no proof\");\n return publicProof(this.#saved.proof);\n }\n exportAggregateMember(): OperationAggregateMember {\n this.current();\n const saved = this.#saved,\n plan = saved.plan;\n check(\n this.status === \"ready\" &&\n plan.params &&\n saved.proof &&\n plan.statement?.target === \"noir-recursive\" &&\n plan.statement.circuitName === \"transact_user_slots14\",\n \"ready recursive slots14 transaction required\"\n );\n sameStatement(saved.proof, statement(plan));\n check(\n saved.proof.proofHex.length === 2 + 458 * 64,\n \"recursive member proof must have 458 fields\"\n );\n return {\n bundle: publicProof(saved.proof),\n statement: structuredClone(plan.statement),\n context: { ...plan.context },\n request: {\n params: structuredClone(plan.params),\n deliveries: plan.outputs.map((output) => structuredClone(output.delivery)),\n funding: normalizeFunding(plan.funding),\n },\n };\n }\n toJSON() {\n return { transaction: true, id: this.id, kind: this.kind, status: this.status };\n }\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return this.toJSON();\n }\n}\n","import type { WalletSessionInfrastructure } from \"./session/operation-types\";\nimport { prepareWithErrors } from \"./errors\";\nimport { copyGasBenchmarks } from \"./gas-estimation\";\nimport { explicitPreparation } from \"./explicit-preparation\";\nimport type { PreparedTransaction } from \"./PreparedTransaction\";\nimport type {\n TransactionIdentity,\n ExplicitTransferPreparation,\n ExplicitShieldPreparation,\n ExplicitCreateCreditPreparation,\n ExplicitDrawCreditPreparation,\n ExplicitTopUpCreditPreparation,\n ExplicitCancelCreditPreparation,\n} from \"./explicit-types\";\nimport { ProtocolRpcClient } from \"@invisi-labs/rpc\";\nimport type { Provider } from \"ethers\";\nimport {\n EthersChainReader,\n EthersFundingVerifier,\n EthersAddressResolver,\n} from \"./integrations/ethers\";\nimport { MissingCapabilityError, PublicWallet, ReceivingAddress } from \"@invisi-labs/core\";\nimport { AddressRegistry } from \"./AddressRegistry\";\nimport type { RegistrationPreparation, RegistrationOperation } from \"@invisi-labs/protocol\";\nimport { Protocol, type ChainReader } from \"@invisi-labs/protocol\";\nimport { WalletSession, type WalletSessionOptions } from \"./session\";\n\n/** Compose independent Chain RPC and indexed Protocol RPC with local wallet capabilities. */\ntype InvisiInfrastructure = Omit<\n WalletSessionInfrastructure,\n | \"wallet\"\n | \"protocol\"\n | \"namespace\"\n | \"viewing\"\n | \"authorization\"\n | \"chainReader\"\n | \"signer\"\n | \"fundingSigner\"\n> & {\n /** Recipient discovery source; defaults to protocol-rpc. An explicit addressResolver takes precedence. */\n addressLookup?: \"chain\" | \"protocol-rpc\";\n provider?: Provider;\n chainReader?: ChainReader;\n};\n\nexport type InvisiOptions = InvisiInfrastructure;\n\n/** Public wallet and registry-specific inputs; signing remains external. */\nexport type RegistrationPreparationOptions = Pick<RegistrationPreparation, \"update\" | \"deadline\"> &\n Pick<TransactionIdentity, \"wallet\">;\n\n/** Wallet identity and session permissions; shared infrastructure belongs to InvisiOptions. */\nexport type ConnectionOptions = Pick<\n WalletSessionOptions,\n \"wallet\" | \"protocol\" | \"namespace\" | \"viewing\" | \"authorization\" | \"signer\" | \"fundingSigner\"\n>;\n\n/** A neutral composition entry point; every resolved instance owns an independent session. */\nexport class Invisi {\n readonly #options: InvisiInfrastructure;\n\n constructor(options: InvisiOptions = {}) {\n if (\"ciphertextCodecs\" in options || \"envelopeVersion\" in options) {\n throw new Error(\n \"SDK envelope versions are fixed; encode application payload bytes externally\"\n );\n }\n if (\"signer\" in options || \"fundingSigner\" in options) {\n throw new Error(\n \"Invisi does not accept signer defaults; export a signing request and attach the external signature\"\n );\n }\n this.#options = {\n ...options,\n ...(options.gasBenchmarks\n ? { gasBenchmarks: copyGasBenchmarks(options.gasBenchmarks) }\n : {}),\n };\n Object.freeze(this);\n }\n\n async connect(options: ConnectionOptions): Promise<WalletSession> {\n return new WalletSession(await this.resolve(options));\n }\n private async resolve(options: ConnectionOptions): Promise<WalletSessionOptions> {\n // Snapshot session permissions before the first network request.\n const allowed = [\n \"wallet\",\n \"protocol\",\n \"namespace\",\n \"viewing\",\n \"authorization\",\n \"signer\",\n \"fundingSigner\",\n ];\n for (const key of Object.keys(options)) {\n if (!allowed.includes(key))\n throw new Error(\n `Unknown connection option: ${key}; configure infrastructure on Invisi`\n );\n }\n const selected = { ...options };\n const combined = { ...this.#options, ...selected };\n const { provider, addressLookup = \"protocol-rpc\", ...runtime } = combined;\n if (\n addressLookup !== undefined &&\n addressLookup !== \"chain\" &&\n addressLookup !== \"protocol-rpc\"\n ) {\n throw new Error(\"Invalid recipient address lookup source\");\n }\n const reader =\n combined.chainReader ?? (provider ? new EthersChainReader(provider) : undefined);\n if (!reader) throw new MissingCapabilityError(\"chain reader\");\n if (provider && (await provider.getNetwork()).chainId !== selected.protocol.context.chainId)\n throw new Error(\"provider deployment chain mismatch\");\n await selected.protocol.validateDeployment(reader);\n if (runtime.protocolRpc instanceof ProtocolRpcClient) {\n runtime.protocolRpc = runtime.protocolRpc.withReader(reader);\n }\n const registry = selected.protocol.deployment.registry;\n const fundingVerifier =\n combined.fundingVerifier ??\n (provider\n ? new EthersFundingVerifier(provider, selected.protocol.context.chainId)\n : undefined);\n let addressResolver = combined.addressResolver;\n if (!addressResolver && registry) {\n if (addressLookup === \"protocol-rpc\") {\n const rpc = runtime.protocolRpc;\n addressResolver = async (identity) => {\n if (!(rpc instanceof ProtocolRpcClient)) {\n throw new MissingCapabilityError(\"Protocol RPC recipient discovery\");\n }\n const discovered = await rpc.getDeployment(selected.protocol.context.chainId);\n const expected = selected.protocol.deployment;\n if (\n discovered.protocol.address !== expected.protocol.address ||\n discovered.protocol.runtimeCodeHash !== expected.protocol.runtimeCodeHash ||\n discovered.protocol.fromBlock !== expected.protocol.fromBlock ||\n discovered.registry?.address !== registry.address ||\n discovered.registry.runtimeCodeHash !== registry.runtimeCodeHash ||\n discovered.registry.fromBlock !== registry.fromBlock\n )\n throw new Error(\"Recipient registry deployment pins mismatch\");\n const registration = await rpc.getReceivingAddress(identity);\n return registration\n ? ReceivingAddress.parse(registration.receivingAddress).getReceivingKeys()\n : null;\n };\n } else if (provider) {\n addressResolver = new EthersAddressResolver(\n provider,\n {\n chainId: selected.protocol.context.chainId,\n registryAddress: registry.address,\n },\n registry.runtimeCodeHash\n ).lookup;\n }\n }\n return {\n ...runtime,\n chainReader: reader,\n ...(fundingVerifier ? { fundingVerifier } : {}),\n ...(addressResolver ? { addressResolver } : {}),\n protocol: selected.protocol,\n } as WalletSessionOptions;\n }\n\n /** Discover the selected chain's registry and prepare an independent signing request. */\n async prepareRegistration(\n options: RegistrationPreparationOptions\n ): Promise<RegistrationOperation> {\n return prepareWithErrors(\"prepareRegistration\", async () => {\n for (const key of Object.keys(options)) {\n if (![\"wallet\", \"update\", \"deadline\"].includes(key)) {\n throw new Error(`Unknown registration option: ${key}`);\n }\n }\n this.assertPublicIdentity(options);\n const selected = { ...options };\n const { provider, protocolRpc } = this.#options;\n if (!provider) throw new MissingCapabilityError(\"ethers provider\");\n if (!(protocolRpc instanceof ProtocolRpcClient)) {\n throw new MissingCapabilityError(\"Protocol RPC deployment discovery\");\n }\n const chainId = (await provider.getNetwork()).chainId;\n const deployment = await protocolRpc.getDeployment(chainId);\n if (!deployment.registry) {\n throw new MissingCapabilityError(\"receiving-key registry deployment\");\n }\n const registry = new AddressRegistry(\n { chainId, registryAddress: deployment.registry.address },\n { expectedRuntimeCodeHash: deployment.registry.runtimeCodeHash }\n );\n return registry.prepareRegistration({ ...selected, provider });\n });\n }\n\n private assertPublicIdentity(options: Pick<TransactionIdentity, \"wallet\">): void {\n const { wallet } = options;\n if (\n !(wallet instanceof PublicWallet) ||\n [\"getViewer\", \"getDetector\", \"exportAuthorization\"].some((key) => key in wallet)\n ) {\n throw new Error(\n \"Independent preparation requires a PublicWallet without private capabilities\"\n );\n }\n for (const key of [\"authorization\", \"signer\", \"fundingSigner\", \"viewing\"]) {\n if (key in options)\n throw new Error(`Independent preparation does not accept capability: ${key}`);\n }\n }\n\n private resolveExplicit(options: TransactionIdentity): Promise<WalletSessionOptions> {\n this.assertPublicIdentity(options);\n return this.resolve({ wallet: options.wallet, protocol: options.protocol });\n }\n\n async prepareTransfer(options: ExplicitTransferPreparation): Promise<PreparedTransaction> {\n return prepareWithErrors(\"prepareTransfer\", async () => {\n const { wallet, protocol, ...input } = options;\n const request = structuredClone(input);\n const runtime = await this.resolveExplicit(options);\n const preparation = explicitPreparation(runtime, request, request.tokenAddress);\n return preparation.prepareTransfer(request);\n });\n }\n async prepareShield(options: ExplicitShieldPreparation): Promise<PreparedTransaction> {\n return prepareWithErrors(\"prepareShield\", async () => {\n const { wallet, protocol, ...input } = options;\n const request = structuredClone(input);\n const runtime = await this.resolveExplicit(options);\n const preparation = explicitPreparation(runtime, {}, request.tokenAddress);\n return preparation.prepareShield(request);\n });\n }\n async prepareCreateCredit(\n options: ExplicitCreateCreditPreparation\n ): Promise<PreparedTransaction> {\n return prepareWithErrors(\"prepareCreateCredit\", async () => {\n const { wallet, protocol, ...input } = options;\n const request = structuredClone(input);\n const runtime = await this.resolveExplicit(options);\n const preparation = explicitPreparation(runtime, request, request.tokenAddress);\n return preparation.prepareCreateCredit(request);\n });\n }\n async prepareDrawCredit(options: ExplicitDrawCreditPreparation): Promise<PreparedTransaction> {\n return prepareWithErrors(\"prepareDrawCredit\", async () => {\n const { wallet, protocol, ...input } = options;\n const request = structuredClone(input);\n const runtime = await this.resolveExplicit(options);\n const preparation = explicitPreparation(runtime, request, request.tokenAddress);\n return preparation.prepareDrawCredit(request);\n });\n }\n async prepareTopUpCredit(\n options: ExplicitTopUpCreditPreparation\n ): Promise<PreparedTransaction> {\n return prepareWithErrors(\"prepareTopUpCredit\", async () => {\n const { wallet, protocol, ...input } = options;\n const request = structuredClone(input);\n const runtime = await this.resolveExplicit(options);\n const preparation = explicitPreparation(runtime, request, request.tokenAddress);\n return preparation.prepareTopUpCredit(request);\n });\n }\n async prepareCancelCredit(\n options: ExplicitCancelCreditPreparation\n ): Promise<PreparedTransaction> {\n return prepareWithErrors(\"prepareCancelCredit\", async () => {\n const { wallet, protocol, ...input } = options;\n const request = structuredClone(input);\n const runtime = await this.resolveExplicit(options);\n const preparation = explicitPreparation(runtime, request, request.tokenAddress);\n return preparation.prepareCancelCredit(request);\n });\n }\n\n toJSON() {\n return { invisi: true };\n }\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return this.toJSON();\n }\n}\n","import { prepareWithErrors } from \"./errors\";\nimport type { Provider } from \"ethers\";\nimport { AddressRegistry as Registry, type RegistrationPreparation } from \"@invisi-labs/protocol\";\nimport { EthersChainReader } from \"./integrations/ethers\";\n\n/** Registry operations accept the application's existing ethers provider. */\nexport class AddressRegistry extends Registry {\n override prepareRegistration(\n options:\n | RegistrationPreparation\n | (Omit<RegistrationPreparation, \"reader\"> & { provider: Provider })\n ) {\n return prepareWithErrors(\"prepareRegistration\", async () => {\n if (\"provider\" in options) {\n const { provider, ...preparation } = options;\n return super.prepareRegistration({\n ...preparation,\n reader: new EthersChainReader(provider),\n });\n }\n return super.prepareRegistration(options);\n });\n }\n}\n","export { InvisiError } from \"./errors\";\nexport type { InvisiErrorCode, InvisiErrorDetails } from \"./errors\";\nexport { Invisi } from \"./Invisi\";\nexport type { InvisiOptions, ConnectionOptions, RegistrationPreparationOptions } from \"./Invisi\";\nexport {\n fundsV1,\n creditV1,\n decodeDeliveryHeader,\n Wallet,\n PublicWallet,\n ViewingCapability,\n Detector,\n NullifierCapability,\n WalletAuthorization,\n MissingCapabilityError,\n Disclosure,\n encodeMemo,\n decodeMemoText,\n MAX_MEMO_BYTES,\n computeCreditNullifier,\n creditPeriods,\n} from \"@invisi-labs/core\";\nexport type {\n Address,\n Hex,\n Memo,\n FundsDataV1,\n CreditDataV1,\n Note,\n CreditNote,\n CreditPolicy,\n CreditDeliveryState,\n ReceivingKeys,\n WalletAuthorizationProvider,\n CreditOpening,\n DisclosureOutput,\n DisclosureExport,\n DisclosureResult,\n} from \"@invisi-labs/core\";\nexport { Protocol, RegistrationOperation } from \"@invisi-labs/protocol\";\nexport type {\n ChainReader,\n ProtocolDataProvider,\n ProtocolDataStatus,\n ProtocolUpdates,\n ProtocolUpdateRange,\n TransactionCall,\n CanonicalBlock,\n CanonicalReceipt,\n Membership,\n RegistryReader,\n ProtocolOptions,\n TokenProtocol,\n TokenProtocolOptions,\n FactoryReader,\n AddressRegistryOptions,\n RegistryContext,\n TransactionContext,\n} from \"@invisi-labs/protocol\";\nexport { WalletSession, Operation, walletBalance, DisclosureVerifier } from \"./session\";\nexport type {\n WalletHistory,\n HistoryOptions,\n OutgoingHistoryEntry,\n IncomingHistoryEntry,\n RefreshOptions,\n RefreshResult,\n WalletStore,\n WalletScope,\n WalletState,\n BalanceSnapshot,\n WalletSessionOptions,\n PaymentOutput,\n TransferPreparation,\n TransactionExecution,\n TransactionProveOptions,\n ShieldPreparation,\n CreateCreditPreparation,\n DrawCreditPreparation,\n TopUpCreditPreparation,\n CancelCreditPreparation,\n FundingSigner,\n FundingAuthorizationVerifier,\n FundingTypedData,\n FundingSource,\n CoinSelector,\n OperationStatus,\n OperationAggregateMember,\n DisclosureReference,\n DisclosureReader,\n DisclosureVerifierOptions,\n DisclosureEvidence,\n VerifiedDisclosure,\n} from \"./session\";\nexport type {\n Prover,\n ProverOptions,\n ProofBundle,\n ProofStatement,\n AggregatorCapability,\n AggregateMember,\n} from \"@invisi-labs/prover\";\n\nexport { ProtocolRpcError } from \"@invisi-labs/rpc\";\nexport type { ProtocolDeployment, RegisteredReceivingAddress } from \"@invisi-labs/rpc\";\nexport { ProtocolRpcClient } from \"./ProtocolRpcClient\";\nexport { AddressRegistry } from \"./AddressRegistry\";\nexport type {\n ProtocolRpcClientOptions,\n ProtocolRpcReader,\n ProtocolRpcConnectionOptions,\n ProtocolRpcChain,\n} from \"@invisi-labs/rpc\";\n\nexport { EncryptedWalletCodec } from \"./integrations/encrypted-codec\";\n\nexport { PreparedTransaction } from \"./PreparedTransaction\";\nexport type {\n NoteInput,\n CreditInput,\n TransactionIdentity,\n ExplicitTransferPreparation,\n ExplicitShieldPreparation,\n ExplicitCreateCreditPreparation,\n ExplicitDrawCreditPreparation,\n ExplicitTopUpCreditPreparation,\n ExplicitCancelCreditPreparation,\n} from \"./explicit-types\";\n\nexport type { SessionTransactionOptions } from \"./session/WalletSession\";\n\nexport type {\n GasBenchmarkProfile,\n GasBenchmarkShape,\n GasBenchmarkDeployment,\n GasBenchmarkCircuit,\n GasBenchmarkSample,\n GasReference,\n} from \"./gas-estimation\";\n\nexport { defineGasBenchmarks } from \"./gas-estimation\";\n\nexport type { SigningRequest } from \"@invisi-labs/core\";\n\n// Stateless recovery for applications that supply canonical receipts without a wallet store.\nexport { readProtocolLogs } from \"./session/receipt-logs\";\nexport { decryptCandidates } from \"./session/discovery\";\nexport type { DeliveryEventLog, DiscoveredNote, DiscoveredCredit } from \"./session/discovery\";\n\nexport type { ProtocolOutput } from \"@invisi-labs/rpc\";\n","import type { Provider } from \"ethers\";\nimport { ProtocolRpcClient as RpcClient } from \"@invisi-labs/rpc\";\nimport { EthersChainReader } from \"./integrations/ethers\";\n\n/** Protocol RPC transport with ethers provider integration for independent chain checks. */\nexport class ProtocolRpcClient extends RpcClient {\n withProvider(provider: Provider): RpcClient {\n return this.withReader(new EthersChainReader(provider));\n }\n}\n","import {\n serializeState,\n deserializeState,\n type WalletState,\n type WalletRecordCodec,\n} from \"../session\";\n/** Caller-owned, nonextractable AES-GCM key. The SDK does not persist the key. */\nexport class EncryptedWalletCodec implements WalletRecordCodec {\n readonly #key: CryptoKey;\n private constructor(key: CryptoKey) {\n this.#key = key;\n }\n static fromKey(key: CryptoKey): EncryptedWalletCodec {\n if (\n key.type !== \"secret\" ||\n key.algorithm.name !== \"AES-GCM\" ||\n (key.algorithm as AesKeyAlgorithm).length !== 256 ||\n !key.usages.includes(\"encrypt\") ||\n !key.usages.includes(\"decrypt\")\n )\n throw new Error(\"wallet record key must support AES-256-GCM encryption and decryption\");\n return new EncryptedWalletCodec(key);\n }\n static async fromBytes(key: Uint8Array): Promise<EncryptedWalletCodec> {\n if (key.length !== 32) throw new Error(\"wallet record encryption requires 32 key bytes\");\n const copy = Uint8Array.from(key);\n try {\n return EncryptedWalletCodec.fromKey(\n await crypto.subtle.importKey(\"raw\", copy, { name: \"AES-GCM\" }, false, [\n \"encrypt\",\n \"decrypt\",\n ])\n );\n } finally {\n copy.fill(0);\n }\n }\n private aad(context: { key: string; revision: number }): Uint8Array<ArrayBuffer> {\n if (!Number.isSafeInteger(context.revision) || context.revision < 1)\n throw new Error(\"invalid encrypted record revision\");\n return new TextEncoder().encode(\n `Invisi.WalletRecord.v1\\0${context.revision}\\0${context.key}`\n );\n }\n async encode(\n state: WalletState,\n context: { key: string; revision: number }\n ): Promise<Uint8Array> {\n const iv = crypto.getRandomValues(new Uint8Array(12)),\n plain = Uint8Array.from(serializeState(state));\n try {\n const encrypted = new Uint8Array(\n await crypto.subtle.encrypt(\n { name: \"AES-GCM\", iv, additionalData: this.aad(context) },\n this.#key,\n plain\n )\n );\n const out = new Uint8Array(13 + encrypted.length);\n out[0] = 1;\n out.set(iv, 1);\n out.set(encrypted, 13);\n return out;\n } finally {\n plain.fill(0);\n }\n }\n async decode(\n data: Uint8Array,\n context: { key: string; revision: number }\n ): Promise<WalletState> {\n if (data.length < 29 || data[0] !== 1)\n throw new Error(\"wallet record authentication failed\");\n let plain: Uint8Array;\n try {\n plain = new Uint8Array(\n await crypto.subtle.decrypt(\n {\n name: \"AES-GCM\",\n iv: Uint8Array.from(data.subarray(1, 13)),\n additionalData: this.aad(context),\n },\n this.#key,\n Uint8Array.from(data.subarray(13))\n )\n );\n } catch {\n throw new Error(\"wallet record authentication failed\");\n }\n try {\n return deserializeState(plain);\n } finally {\n plain.fill(0);\n }\n }\n toJSON() {\n return { walletRecordCodec: \"AES-256-GCM\" };\n }\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return this.toJSON();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;;;ACQ3B,SAAS,8BAAwD;AACjE,SAAS,wBA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SAAS,MAAM,KAAK,CAAC,MAAM;AAChC,YAAM,IAAI,MAAM,qCAAqC;AACzD,QAAI;AACJ,QAAI;AACA,cAAQ,IAAI;AAAA,QACR,MAAM,OAAO,OAAO;AAAA,UAChB;AAAA,YACI,MAAM;AAAA,YACN,IAAI,WAAW,KAAK,KAAK,SAAS,GAAG,EAAE,CAAC;AAAA,YACxC,gBAAgB,KAAK,IAAI,OAAO;AAAA,UACpC;AAAA,UACA,KAAK;AAAA,UACL,WAAW,KAAK,KAAK,SAAS,EAAE,CAAC;AAAA,QACrC;AAAA,MACJ;AAAA,IACJ,QAAQ;AACJ,YAAM,IAAI,MAAM,qCAAqC;AAAA,IACzD;AACA,QAAI;AACA,aAAO,iBAAiB,KAAK;AAAA,IACjC,UAAE;AACE,YAAM,KAAK,CAAC;AAAA,IAChB;AAAA,EACJ;AAAA,EACA,SAAS;AACL,WAAO,EAAE,mBAAmB,cAAc;AAAA,EAC9C;AAAA,EACA,CAAC,uBAAO,IAAI,4BAA4B,CAAC,IAAI;AACzC,WAAO,KAAK,OAAO;AAAA,EACvB;AACJ;","names":["MissingCapabilityError","MissingCapabilityError","PublicWallet","MissingCapabilityError","ProtocolRpcClient"]}
1
+ {"version":3,"sources":["../src/explicit-preparation.ts","../src/PreparedTransaction.ts","../src/Invisi.ts","../src/AddressRegistry.ts","../src/index.ts","../src/ProtocolRpcClient.ts","../src/integrations/encrypted-codec.ts"],"sourcesContent":["import { getAddress } from \"ethers\";\nimport type { CreditInput, NoteInput } from \"./explicit-types\";\nimport { PreparedTransaction } from \"./PreparedTransaction\";\nimport { positiveAmount } from \"./session/prepare-common\";\nimport { TransactionPreparation } from \"./session/transaction-preparation\";\nimport type { PreparationInventory, WalletSessionOptions } from \"./session/operation-types\";\n\n/** Only explicitly supplied records participate. No store or automatic coin selection. */\nexport function explicitPreparation(\n options: WalletSessionOptions,\n data: {\n inputs?: readonly NoteInput[];\n creditInputs?: readonly CreditInput[];\n changeAddress?: string;\n },\n tokenAddress: `0x${string}`\n) {\n if (!options.chainReader) throw new Error(\"chain reader required\");\n const inputs = structuredClone(data.inputs ?? []);\n const credits = structuredClone(data.creditInputs ?? []);\n const inventory: PreparationInventory = { notes: {}, credits: {}, reservations: {} };\n const context = options.protocol.context;\n function position(input: NoteInput | CreditInput) {\n if (\n typeof input.treeId !== \"bigint\" ||\n input.treeId < 0n ||\n input.treeId >= 1n << 256n ||\n !Number.isInteger(input.leafIndex) ||\n input.leafIndex < 0 ||\n input.leafIndex >= 65536\n )\n throw new Error(\"invalid explicit input position\");\n }\n for (const input of inputs) {\n position(input);\n positiveAmount(input.note.amount);\n if (inventory.notes[input.commitment]) throw new Error(\"duplicate explicit note input\");\n if (\n input.note.chainId !== context.chainId ||\n input.note.protocolAddress !== BigInt(context.protocolAddress) ||\n input.note.walletIdentity !== options.wallet.walletIdentity\n )\n throw new Error(\"explicit note identity or deployment mismatch\");\n inventory.notes[input.commitment] = { ...input, spent: \"unspent\" };\n }\n for (const input of credits) {\n position(input);\n if (input.role !== \"owner\" && input.role !== \"spender\")\n throw new Error(\"invalid explicit Credit role\");\n const key = input.commitment + \":\" + input.role;\n if (inventory.credits[key]) throw new Error(\"duplicate explicit Credit input\");\n inventory.credits[key] = { ...input, spent: \"unspent\" };\n }\n const scope = {\n ...context,\n namespace: \"explicit\",\n walletIdentity: options.wallet.walletIdentity,\n };\n const {\n store: _store,\n coinSelector: _selector,\n authorization: _authorization,\n viewing: _viewing,\n signer: _signer,\n fundingSigner: _fundingSigner,\n ...capabilities\n } = options;\n\n if (inputs.some((input) => input.note.tokenAddress !== BigInt(getAddress(tokenAddress))))\n throw new Error(\"explicit note token mismatch\");\n const runtime = {\n options: { ...capabilities, protocol: options.protocol.forToken(tokenAddress) },\n reader: options.chainReader!,\n scope,\n };\n return new TransactionPreparation<PreparedTransaction>({\n ...runtime,\n explicitInputs: true,\n ...(data.changeAddress ? { changeAddress: data.changeAddress } : {}),\n readInventory: async () => structuredClone(inventory),\n complete: async (plan) => PreparedTransaction.prepare(runtime, plan),\n });\n}\n","import { estimateGasReference } from \"./gas-estimation\";\nimport {\n proveOperation,\n walletSigningRequest,\n acceptWalletSignature,\n fundingSigningRequest,\n acceptFundingSignature,\n} from \"./session/operation-execution\";\nimport { MissingCapabilityError, type AuthorizedStatement } from \"@invisi-labs/core\";\nimport { normalizeFunding, type TransactionCall } from \"@invisi-labs/protocol\";\nimport type { Prover, ProofBundle } from \"@invisi-labs/prover\";\nimport type {\n OperationPlan,\n OperationRuntime,\n OperationAggregateMember,\n SavedOperation,\n TransactionProveOptions,\n} from \"./session/operation-types\";\nimport type { OperationStatus } from \"./session/state\";\nimport {\n encodeOperation,\n publicProof,\n requiresAuthorization,\n statement,\n} from \"./session/operation-protocol\";\nimport { sameStatement } from \"./session/proof-integrity\";\nimport { operationPreview } from \"./session/operation-preview\";\nfunction check(ok: unknown, message: string): asserts ok {\n if (!ok) throw new Error(message);\n}\n\ntype Runtime = Omit<OperationRuntime, \"store\" | \"authorization\">;\ntype Lifecycle = { generation: number; busy: boolean };\n/** An immutable, local transaction handle. No wallet inventory, reservations or persistence. */\nexport class PreparedTransaction {\n readonly #runtime: Runtime;\n readonly #saved: SavedOperation;\n readonly #authorization: AuthorizedStatement | undefined;\n readonly #lifecycle: Lifecycle;\n readonly status: OperationStatus;\n private constructor(\n runtime: Runtime,\n saved: SavedOperation,\n status: OperationStatus,\n lifecycle: Lifecycle,\n authorization?: AuthorizedStatement\n ) {\n this.#runtime = runtime;\n this.#saved = structuredClone(saved);\n this.#lifecycle = lifecycle;\n this.#authorization = authorization;\n this.status = status;\n Object.freeze(this);\n }\n static prepare(runtime: Runtime, plan: OperationPlan): PreparedTransaction {\n return new PreparedTransaction(\n runtime,\n { plan: structuredClone(plan), generation: 0 },\n \"prepared\",\n { generation: 0, busy: false }\n );\n }\n get id() {\n return this.#saved.plan.id;\n }\n get kind() {\n return this.#saved.plan.kind;\n }\n estimateGas() {\n return estimateGasReference(\n this.#saved.plan,\n this.#runtime.options.protocol,\n this.#runtime.options.gasBenchmarks\n );\n }\n preview() {\n return operationPreview(this.#saved.plan, this.status);\n }\n private current() {\n check(\n !this.#lifecycle.busy && this.#lifecycle.generation === this.#saved.generation,\n \"stale transaction handle or active worker\"\n );\n }\n private async stage(\n stage: string,\n allowed: OperationStatus[],\n work: (\n saved: SavedOperation\n ) => Promise<{ status: OperationStatus; authorization?: AuthorizedStatement }>,\n signal?: AbortSignal\n ): Promise<PreparedTransaction> {\n signal?.throwIfAborted();\n this.current();\n check(allowed.includes(this.status), `invalid transaction stage for ${stage}`);\n this.#lifecycle.busy = true;\n const saved = structuredClone(this.#saved);\n try {\n const next = await work(saved);\n signal?.throwIfAborted();\n saved.generation++;\n this.#lifecycle.generation = saved.generation;\n return new PreparedTransaction(\n this.#runtime,\n saved,\n next.status,\n this.#lifecycle,\n next.authorization ?? this.#authorization\n );\n } finally {\n this.#lifecycle.busy = false;\n }\n }\n /** Public EIP-712 request; signing transport and key custody belong to the caller. */\n async exportWalletAuthorization(options: { signal?: AbortSignal } = {}) {\n options.signal?.throwIfAborted();\n this.current();\n check(\n requiresAuthorization(this.#saved.plan),\n \"operation does not require wallet authorization\"\n );\n check(\n [\"prepared\", \"authorized\"].includes(this.status),\n \"operation is not awaiting wallet authorization\"\n );\n return walletSigningRequest(this.#saved.plan);\n }\n\n /** Attach an external EOA signature, retaining its witness only at the private proving boundary. */\n async withWalletSignature(\n signature: string,\n options: { signal?: AbortSignal } = {}\n ): Promise<PreparedTransaction> {\n options.signal?.throwIfAborted();\n this.current();\n check(\n requiresAuthorization(this.#saved.plan),\n \"operation does not require wallet authorization\"\n );\n check(\n [\"prepared\", \"authorized\"].includes(this.status),\n \"operation is not awaiting wallet authorization\"\n );\n const authorization = await acceptWalletSignature(this.#saved.plan, signature);\n return this.stage(\n \"wallet authorization\",\n [\"prepared\", \"authorized\"],\n async () => ({ status: \"authorized\", authorization }),\n options.signal\n );\n }\n\n /** Export only after proving when the funding authorization binds an actual proof hash. */\n async exportFundingAuthorization(options: { signal?: AbortSignal } = {}) {\n options.signal?.throwIfAborted();\n this.current();\n check(\n this.status === (this.kind === \"shield\" ? \"prepared\" : \"proved\"),\n \"operation is not awaiting funding authorization or proof\"\n );\n const request = await fundingSigningRequest(this.#saved, this.#runtime);\n options.signal?.throwIfAborted();\n this.current();\n return request;\n }\n\n /** Verify an external signature against this handle's own frozen operation. */\n async withFundingSignature(\n signature: string,\n options: { signal?: AbortSignal } = {}\n ): Promise<PreparedTransaction> {\n options.signal?.throwIfAborted();\n this.current();\n check(\n this.status === (this.kind === \"shield\" ? \"prepared\" : \"proved\"),\n \"operation is not awaiting funding authorization or proof\"\n );\n const verified = await acceptFundingSignature(this.#saved, signature, this.#runtime);\n return this.stage(\n \"funding authorization\",\n this.kind === \"shield\" ? [\"prepared\"] : [\"proved\"],\n async (saved) => {\n saved.plan.funding.signature = verified;\n if (saved.plan.statement?.target !== \"noir-recursive\") {\n saved.call = await this.encode(saved);\n }\n return { status: \"ready\" };\n },\n options.signal\n );\n }\n\n async prove(options?: TransactionProveOptions): Promise<PreparedTransaction>;\n async prove(backend: Prover, options?: TransactionProveOptions): Promise<PreparedTransaction>;\n async prove(\n backendOrOptions: Prover | TransactionProveOptions = {},\n suppliedOptions: TransactionProveOptions = {}\n ): Promise<PreparedTransaction> {\n const options = { ...(\"prove\" in backendOrOptions ? suppliedOptions : backendOrOptions) };\n const plan = this.#saved.plan;\n check(plan.kind !== \"shield\", \"shield requires no proof\");\n if (requiresAuthorization(plan)) {\n check(\n this.#authorization,\n \"local wallet authorization required; authorize again after recovery\"\n );\n }\n const prover =\n \"prove\" in backendOrOptions ? backendOrOptions : this.#runtime.options.prover;\n if (!prover) {\n throw new MissingCapabilityError(\"prover\");\n }\n return this.stage(\n \"proof\",\n requiresAuthorization(plan) ? [\"authorized\"] : [\"prepared\"],\n async (saved) => {\n const p = saved.plan;\n saved.proof = await proveOperation(\n this.#runtime.options.protocol,\n p,\n this.#authorization,\n prover,\n options\n );\n if (p.fundingMode === \"signature\") {\n return { status: \"proved\" };\n }\n if (p.statement?.target !== \"noir-recursive\") {\n saved.call = await this.encode(saved);\n }\n return { status: \"ready\" };\n },\n options.signal\n );\n }\n\n private encode(saved: SavedOperation): Promise<TransactionCall> {\n return encodeOperation(saved);\n }\n\n /** Shield caller funding needs no wallet signing or proof; this step only encodes its frozen request. */\n async ready(): Promise<PreparedTransaction> {\n check(\n this.kind === \"shield\" && this.#saved.plan.fundingMode === \"caller\",\n \"operation needs authorization or proof first\"\n );\n return this.stage(\"encoding\", [\"prepared\"], async (saved) => {\n saved.call = await this.encode(saved);\n return { status: \"ready\" };\n });\n }\n\n async exportTransaction(): Promise<TransactionCall> {\n this.current();\n check(\n this.#saved.plan.statement?.target !== \"noir-recursive\",\n \"recursive operations must be exported as aggregate members\"\n );\n check(this.status === \"ready\" && this.#saved.call, \"transaction is not ready\");\n return structuredClone(this.#saved.call);\n }\n exportProof(): ProofBundle {\n this.current();\n check(this.#saved.proof, \"transaction has no proof\");\n return publicProof(this.#saved.proof);\n }\n exportAggregateMember(): OperationAggregateMember {\n this.current();\n const saved = this.#saved,\n plan = saved.plan;\n check(\n this.status === \"ready\" &&\n plan.params &&\n saved.proof &&\n plan.statement?.target === \"noir-recursive\" &&\n plan.statement.circuitName === \"transact_user_slots14\",\n \"ready recursive slots14 transaction required\"\n );\n sameStatement(saved.proof, statement(plan));\n check(\n saved.proof.proofHex.length === 2 + 458 * 64,\n \"recursive member proof must have 458 fields\"\n );\n return {\n bundle: publicProof(saved.proof),\n statement: structuredClone(plan.statement),\n context: { ...plan.context },\n request: {\n params: structuredClone(plan.params),\n deliveries: plan.outputs.map((output) => structuredClone(output.delivery)),\n funding: normalizeFunding(plan.funding),\n },\n };\n }\n toJSON() {\n return { transaction: true, id: this.id, kind: this.kind, status: this.status };\n }\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return this.toJSON();\n }\n}\n","import type { WalletSessionInfrastructure } from \"./session/operation-types\";\nimport { prepareWithErrors } from \"./errors\";\nimport { copyGasBenchmarks } from \"./gas-estimation\";\nimport { explicitPreparation } from \"./explicit-preparation\";\nimport type { PreparedTransaction } from \"./PreparedTransaction\";\nimport type {\n TransactionIdentity,\n ExplicitTransferPreparation,\n ExplicitShieldPreparation,\n ExplicitCreateCreditPreparation,\n ExplicitDrawCreditPreparation,\n ExplicitTopUpCreditPreparation,\n ExplicitCancelCreditPreparation,\n} from \"./explicit-types\";\nimport { ProtocolRpcClient } from \"@invisi-labs/rpc\";\nimport type { Provider } from \"ethers\";\nimport {\n EthersChainReader,\n EthersFundingVerifier,\n EthersAddressResolver,\n} from \"./integrations/ethers\";\nimport { MissingCapabilityError, PublicWallet, ReceivingAddress } from \"@invisi-labs/core\";\nimport { AddressRegistry } from \"./AddressRegistry\";\nimport type { RegistrationPreparation, RegistrationOperation } from \"@invisi-labs/protocol\";\nimport { Protocol, type ChainReader } from \"@invisi-labs/protocol\";\nimport { WalletSession, type WalletSessionOptions } from \"./session\";\n\n/** Compose independent Chain RPC and indexed Protocol RPC with local wallet capabilities. */\ntype InvisiInfrastructure = Omit<\n WalletSessionInfrastructure,\n | \"wallet\"\n | \"protocol\"\n | \"namespace\"\n | \"viewing\"\n | \"authorization\"\n | \"chainReader\"\n | \"signer\"\n | \"fundingSigner\"\n> & {\n /** Recipient discovery source; defaults to protocol-rpc. An explicit addressResolver takes precedence. */\n addressLookup?: \"chain\" | \"protocol-rpc\";\n provider?: Provider;\n chainReader?: ChainReader;\n};\n\nexport type InvisiOptions = InvisiInfrastructure;\n\n/** Public wallet and registry-specific inputs; signing remains external. */\nexport type RegistrationPreparationOptions = Pick<RegistrationPreparation, \"update\" | \"deadline\"> &\n Pick<TransactionIdentity, \"wallet\">;\n\n/** Wallet identity and session permissions; shared infrastructure belongs to InvisiOptions. */\nexport type ConnectionOptions = Pick<\n WalletSessionOptions,\n \"wallet\" | \"protocol\" | \"namespace\" | \"viewing\" | \"authorization\" | \"signer\" | \"fundingSigner\"\n>;\n\n/** A neutral composition entry point; every resolved instance owns an independent session. */\nexport class Invisi {\n readonly #options: InvisiInfrastructure;\n\n constructor(options: InvisiOptions = {}) {\n if (\"ciphertextCodecs\" in options || \"envelopeVersion\" in options) {\n throw new Error(\n \"SDK envelope versions are fixed; encode application payload bytes externally\"\n );\n }\n if (\"signer\" in options || \"fundingSigner\" in options) {\n throw new Error(\n \"Invisi does not accept signer defaults; export a signing request and attach the external signature\"\n );\n }\n this.#options = {\n ...options,\n ...(options.gasBenchmarks\n ? { gasBenchmarks: copyGasBenchmarks(options.gasBenchmarks) }\n : {}),\n };\n Object.freeze(this);\n }\n\n async connect(options: ConnectionOptions): Promise<WalletSession> {\n return new WalletSession(await this.resolve(options));\n }\n private async resolve(options: ConnectionOptions): Promise<WalletSessionOptions> {\n // Snapshot session permissions before the first network request.\n const allowed = [\n \"wallet\",\n \"protocol\",\n \"namespace\",\n \"viewing\",\n \"authorization\",\n \"signer\",\n \"fundingSigner\",\n ];\n for (const key of Object.keys(options)) {\n if (!allowed.includes(key))\n throw new Error(\n `Unknown connection option: ${key}; configure infrastructure on Invisi`\n );\n }\n const selected = { ...options };\n const combined = { ...this.#options, ...selected };\n const { provider, addressLookup = \"protocol-rpc\", ...runtime } = combined;\n if (\n addressLookup !== undefined &&\n addressLookup !== \"chain\" &&\n addressLookup !== \"protocol-rpc\"\n ) {\n throw new Error(\"Invalid recipient address lookup source\");\n }\n const reader =\n combined.chainReader ?? (provider ? new EthersChainReader(provider) : undefined);\n if (!reader) throw new MissingCapabilityError(\"chain reader\");\n if (provider && (await provider.getNetwork()).chainId !== selected.protocol.context.chainId)\n throw new Error(\"provider deployment chain mismatch\");\n await selected.protocol.validateDeployment(reader);\n if (runtime.protocolRpc instanceof ProtocolRpcClient) {\n runtime.protocolRpc = runtime.protocolRpc.withReader(reader);\n }\n const registry = selected.protocol.deployment.registry;\n const fundingVerifier =\n combined.fundingVerifier ??\n (provider\n ? new EthersFundingVerifier(provider, selected.protocol.context.chainId)\n : undefined);\n let addressResolver = combined.addressResolver;\n if (!addressResolver && registry) {\n if (addressLookup === \"protocol-rpc\") {\n const rpc = runtime.protocolRpc;\n addressResolver = async (identity) => {\n if (!(rpc instanceof ProtocolRpcClient)) {\n throw new MissingCapabilityError(\"Protocol RPC recipient discovery\");\n }\n const discovered = await rpc.getDeployment(selected.protocol.context.chainId);\n const expected = selected.protocol.deployment;\n if (\n discovered.protocol.address !== expected.protocol.address ||\n discovered.protocol.runtimeCodeHash !== expected.protocol.runtimeCodeHash ||\n discovered.protocol.fromBlock !== expected.protocol.fromBlock ||\n discovered.registry?.address !== registry.address ||\n discovered.registry.runtimeCodeHash !== registry.runtimeCodeHash ||\n discovered.registry.fromBlock !== registry.fromBlock\n )\n throw new Error(\"Recipient registry deployment pins mismatch\");\n const registration = await rpc.getReceivingAddress(identity);\n return registration\n ? ReceivingAddress.parse(registration.receivingAddress).getReceivingKeys()\n : null;\n };\n } else if (provider) {\n addressResolver = new EthersAddressResolver(\n provider,\n {\n chainId: selected.protocol.context.chainId,\n registryAddress: registry.address,\n },\n registry.runtimeCodeHash\n ).lookup;\n }\n }\n return {\n ...runtime,\n chainReader: reader,\n ...(fundingVerifier ? { fundingVerifier } : {}),\n ...(addressResolver ? { addressResolver } : {}),\n protocol: selected.protocol,\n } as WalletSessionOptions;\n }\n\n /** Discover the selected chain's registry and prepare an independent signing request. */\n async prepareRegistration(\n options: RegistrationPreparationOptions\n ): Promise<RegistrationOperation> {\n return prepareWithErrors(\"prepareRegistration\", async () => {\n for (const key of Object.keys(options)) {\n if (![\"wallet\", \"update\", \"deadline\"].includes(key)) {\n throw new Error(`Unknown registration option: ${key}`);\n }\n }\n this.assertPublicIdentity(options);\n const selected = { ...options };\n const { provider, protocolRpc } = this.#options;\n if (!provider) throw new MissingCapabilityError(\"ethers provider\");\n if (!(protocolRpc instanceof ProtocolRpcClient)) {\n throw new MissingCapabilityError(\"Protocol RPC deployment discovery\");\n }\n const chainId = (await provider.getNetwork()).chainId;\n const deployment = await protocolRpc.getDeployment(chainId);\n if (!deployment.registry) {\n throw new MissingCapabilityError(\"receiving-key registry deployment\");\n }\n const registry = new AddressRegistry(\n { chainId, registryAddress: deployment.registry.address },\n { expectedRuntimeCodeHash: deployment.registry.runtimeCodeHash }\n );\n return registry.prepareRegistration({ ...selected, provider });\n });\n }\n\n private assertPublicIdentity(options: Pick<TransactionIdentity, \"wallet\">): void {\n const { wallet } = options;\n if (\n !(wallet instanceof PublicWallet) ||\n [\"getViewer\", \"getDetector\", \"exportAuthorization\"].some((key) => key in wallet)\n ) {\n throw new Error(\n \"Independent preparation requires a PublicWallet without private capabilities\"\n );\n }\n for (const key of [\"authorization\", \"signer\", \"fundingSigner\", \"viewing\"]) {\n if (key in options)\n throw new Error(`Independent preparation does not accept capability: ${key}`);\n }\n }\n\n private resolveExplicit(options: TransactionIdentity): Promise<WalletSessionOptions> {\n this.assertPublicIdentity(options);\n return this.resolve({ wallet: options.wallet, protocol: options.protocol });\n }\n\n async prepareTransfer(options: ExplicitTransferPreparation): Promise<PreparedTransaction> {\n return prepareWithErrors(\"prepareTransfer\", async () => {\n const { wallet, protocol, ...input } = options;\n const request = structuredClone(input);\n const runtime = await this.resolveExplicit(options);\n const preparation = explicitPreparation(runtime, request, request.tokenAddress);\n return preparation.prepareTransfer(request);\n });\n }\n async prepareShield(options: ExplicitShieldPreparation): Promise<PreparedTransaction> {\n return prepareWithErrors(\"prepareShield\", async () => {\n const { wallet, protocol, ...input } = options;\n const request = structuredClone(input);\n const runtime = await this.resolveExplicit(options);\n const preparation = explicitPreparation(runtime, {}, request.tokenAddress);\n return preparation.prepareShield(request);\n });\n }\n async prepareCreateCredit(\n options: ExplicitCreateCreditPreparation\n ): Promise<PreparedTransaction> {\n return prepareWithErrors(\"prepareCreateCredit\", async () => {\n const { wallet, protocol, ...input } = options;\n const request = structuredClone(input);\n const runtime = await this.resolveExplicit(options);\n const preparation = explicitPreparation(runtime, request, request.tokenAddress);\n return preparation.prepareCreateCredit(request);\n });\n }\n async prepareDrawCredit(options: ExplicitDrawCreditPreparation): Promise<PreparedTransaction> {\n return prepareWithErrors(\"prepareDrawCredit\", async () => {\n const { wallet, protocol, ...input } = options;\n const request = structuredClone(input);\n const runtime = await this.resolveExplicit(options);\n const preparation = explicitPreparation(runtime, request, request.tokenAddress);\n return preparation.prepareDrawCredit(request);\n });\n }\n async prepareTopUpCredit(\n options: ExplicitTopUpCreditPreparation\n ): Promise<PreparedTransaction> {\n return prepareWithErrors(\"prepareTopUpCredit\", async () => {\n const { wallet, protocol, ...input } = options;\n const request = structuredClone(input);\n const runtime = await this.resolveExplicit(options);\n const preparation = explicitPreparation(runtime, request, request.tokenAddress);\n return preparation.prepareTopUpCredit(request);\n });\n }\n async prepareCancelCredit(\n options: ExplicitCancelCreditPreparation\n ): Promise<PreparedTransaction> {\n return prepareWithErrors(\"prepareCancelCredit\", async () => {\n const { wallet, protocol, ...input } = options;\n const request = structuredClone(input);\n const runtime = await this.resolveExplicit(options);\n const preparation = explicitPreparation(runtime, request, request.tokenAddress);\n return preparation.prepareCancelCredit(request);\n });\n }\n\n toJSON() {\n return { invisi: true };\n }\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return this.toJSON();\n }\n}\n","import { prepareWithErrors } from \"./errors\";\nimport type { Provider } from \"ethers\";\nimport { AddressRegistry as Registry, type RegistrationPreparation } from \"@invisi-labs/protocol\";\nimport { EthersChainReader } from \"./integrations/ethers\";\n\n/** Registry operations accept the application's existing ethers provider. */\nexport class AddressRegistry extends Registry {\n override prepareRegistration(\n options:\n | RegistrationPreparation\n | (Omit<RegistrationPreparation, \"reader\"> & { provider: Provider })\n ) {\n return prepareWithErrors(\"prepareRegistration\", async () => {\n if (\"provider\" in options) {\n const { provider, ...preparation } = options;\n return super.prepareRegistration({\n ...preparation,\n reader: new EthersChainReader(provider),\n });\n }\n return super.prepareRegistration(options);\n });\n }\n}\n","export { InvisiError } from \"./errors\";\nexport type { InvisiErrorCode, InvisiErrorDetails } from \"./errors\";\nexport { Invisi } from \"./Invisi\";\nexport type { InvisiOptions, ConnectionOptions, RegistrationPreparationOptions } from \"./Invisi\";\nexport {\n fundsV1,\n creditV1,\n decodeDeliveryHeader,\n Wallet,\n PublicWallet,\n ViewingCapability,\n Detector,\n NullifierCapability,\n WalletAuthorization,\n MissingCapabilityError,\n Disclosure,\n encodeMemo,\n decodeMemoText,\n MAX_MEMO_BYTES,\n computeCreditNullifier,\n creditPeriods,\n} from \"@invisi-labs/core\";\nexport type {\n Address,\n Hex,\n Memo,\n FundsDataV1,\n CreditDataV1,\n Note,\n CreditNote,\n CreditPolicy,\n CreditDeliveryState,\n ReceivingKeys,\n WalletAuthorizationProvider,\n CreditOpening,\n DisclosureOutput,\n DisclosureExport,\n DisclosureResult,\n} from \"@invisi-labs/core\";\nexport { Protocol, RegistrationOperation } from \"@invisi-labs/protocol\";\nexport type {\n ChainReader,\n ProtocolDataProvider,\n ProtocolDataStatus,\n ProtocolUpdates,\n ProtocolUpdateRange,\n TransactionCall,\n CanonicalBlock,\n CanonicalReceipt,\n Membership,\n RegistryReader,\n ProtocolOptions,\n TokenProtocol,\n TokenProtocolOptions,\n FactoryReader,\n AddressRegistryOptions,\n RegistryContext,\n TransactionContext,\n} from \"@invisi-labs/protocol\";\nexport { WalletSession, Operation, walletBalance, DisclosureVerifier } from \"./session\";\nexport type {\n WalletHistory,\n HistoryOptions,\n OutgoingHistoryEntry,\n IncomingHistoryEntry,\n RefreshOptions,\n RefreshResult,\n WalletStore,\n WalletScope,\n WalletState,\n BalanceSnapshot,\n WalletSessionOptions,\n PaymentOutput,\n TransferPreparation,\n TransactionExecution,\n TransactionProveOptions,\n ShieldPreparation,\n CreateCreditPreparation,\n DrawCreditPreparation,\n TopUpCreditPreparation,\n CancelCreditPreparation,\n FundingSigner,\n FundingAuthorizationVerifier,\n FundingTypedData,\n FundingSource,\n CoinSelector,\n OperationStatus,\n OperationAggregateMember,\n DisclosureReference,\n DisclosureReader,\n DisclosureVerifierOptions,\n DisclosureEvidence,\n VerifiedDisclosure,\n} from \"./session\";\nexport type {\n Prover,\n ProverOptions,\n ProofBundle,\n ProofStatement,\n AggregatorCapability,\n AggregateMember,\n} from \"@invisi-labs/prover\";\n\nexport { ProtocolRpcError } from \"@invisi-labs/rpc\";\nexport type { ProtocolDeployment, RegisteredReceivingAddress } from \"@invisi-labs/rpc\";\nexport { ProtocolRpcClient } from \"./ProtocolRpcClient\";\nexport { AddressRegistry } from \"./AddressRegistry\";\nexport type {\n ProtocolRpcClientOptions,\n ProtocolRpcReader,\n ProtocolRpcConnectionOptions,\n ProtocolRpcChain,\n} from \"@invisi-labs/rpc\";\n\nexport { EncryptedWalletCodec } from \"./integrations/encrypted-codec\";\n\nexport { PreparedTransaction } from \"./PreparedTransaction\";\nexport type {\n NoteInput,\n CreditInput,\n TransactionIdentity,\n ExplicitTransferPreparation,\n ExplicitShieldPreparation,\n ExplicitCreateCreditPreparation,\n ExplicitDrawCreditPreparation,\n ExplicitTopUpCreditPreparation,\n ExplicitCancelCreditPreparation,\n} from \"./explicit-types\";\n\nexport type { SessionTransactionOptions } from \"./session/WalletSession\";\n\nexport type {\n GasBenchmarkProfile,\n GasBenchmarkShape,\n GasBenchmarkDeployment,\n GasBenchmarkCircuit,\n GasBenchmarkSample,\n GasReference,\n} from \"./gas-estimation\";\n\nexport { defineGasBenchmarks } from \"./gas-estimation\";\n\nexport type { SigningRequest } from \"@invisi-labs/core\";\n\n// Stateless recovery for applications that supply canonical receipts without a wallet store.\nexport { readProtocolLogs } from \"./session/receipt-logs\";\nexport { decryptCandidates } from \"./session/discovery\";\nexport type { DeliveryEventLog, DiscoveredNote, DiscoveredCredit } from \"./session/discovery\";\n\nexport type {\n ProtocolOutput,\n ProtocolTransactionUpdates,\n ProtocolCreditTransition,\n} from \"@invisi-labs/rpc\";\n","import type { Provider } from \"ethers\";\nimport { ProtocolRpcClient as RpcClient } from \"@invisi-labs/rpc\";\nimport { EthersChainReader } from \"./integrations/ethers\";\n\n/** Protocol RPC transport with ethers provider integration for independent chain checks. */\nexport class ProtocolRpcClient extends RpcClient {\n withProvider(provider: Provider): RpcClient {\n return this.withReader(new EthersChainReader(provider));\n }\n}\n","import {\n serializeState,\n deserializeState,\n type WalletState,\n type WalletRecordCodec,\n} from \"../session\";\n/** Caller-owned, nonextractable AES-GCM key. The SDK does not persist the key. */\nexport class EncryptedWalletCodec implements WalletRecordCodec {\n readonly #key: CryptoKey;\n private constructor(key: CryptoKey) {\n this.#key = key;\n }\n static fromKey(key: CryptoKey): EncryptedWalletCodec {\n if (\n key.type !== \"secret\" ||\n key.algorithm.name !== \"AES-GCM\" ||\n (key.algorithm as AesKeyAlgorithm).length !== 256 ||\n !key.usages.includes(\"encrypt\") ||\n !key.usages.includes(\"decrypt\")\n )\n throw new Error(\"wallet record key must support AES-256-GCM encryption and decryption\");\n return new EncryptedWalletCodec(key);\n }\n static async fromBytes(key: Uint8Array): Promise<EncryptedWalletCodec> {\n if (key.length !== 32) throw new Error(\"wallet record encryption requires 32 key bytes\");\n const copy = Uint8Array.from(key);\n try {\n return EncryptedWalletCodec.fromKey(\n await crypto.subtle.importKey(\"raw\", copy, { name: \"AES-GCM\" }, false, [\n \"encrypt\",\n \"decrypt\",\n ])\n );\n } finally {\n copy.fill(0);\n }\n }\n private aad(context: { key: string; revision: number }): Uint8Array<ArrayBuffer> {\n if (!Number.isSafeInteger(context.revision) || context.revision < 1)\n throw new Error(\"invalid encrypted record revision\");\n return new TextEncoder().encode(\n `Invisi.WalletRecord.v1\\0${context.revision}\\0${context.key}`\n );\n }\n async encode(\n state: WalletState,\n context: { key: string; revision: number }\n ): Promise<Uint8Array> {\n const iv = crypto.getRandomValues(new Uint8Array(12)),\n plain = Uint8Array.from(serializeState(state));\n try {\n const encrypted = new Uint8Array(\n await crypto.subtle.encrypt(\n { name: \"AES-GCM\", iv, additionalData: this.aad(context) },\n this.#key,\n plain\n )\n );\n const out = new Uint8Array(13 + encrypted.length);\n out[0] = 1;\n out.set(iv, 1);\n out.set(encrypted, 13);\n return out;\n } finally {\n plain.fill(0);\n }\n }\n async decode(\n data: Uint8Array,\n context: { key: string; revision: number }\n ): Promise<WalletState> {\n if (data.length < 29 || data[0] !== 1)\n throw new Error(\"wallet record authentication failed\");\n let plain: Uint8Array;\n try {\n plain = new Uint8Array(\n await crypto.subtle.decrypt(\n {\n name: \"AES-GCM\",\n iv: Uint8Array.from(data.subarray(1, 13)),\n additionalData: this.aad(context),\n },\n this.#key,\n Uint8Array.from(data.subarray(13))\n )\n );\n } catch {\n throw new Error(\"wallet record authentication failed\");\n }\n try {\n return deserializeState(plain);\n } finally {\n plain.fill(0);\n }\n }\n toJSON() {\n return { walletRecordCodec: \"AES-256-GCM\" };\n }\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return this.toJSON();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;;;ACQ3B,SAAS,8BAAwD;AACjE,SAAS,wBAA8C;AAkBvD,SAAS,MAAM,IAAa,SAA6B;AACrD,MAAI,CAAC,GAAI,OAAM,IAAI,MAAM,OAAO;AACpC;AAKO,IAAM,sBAAN,MAAM,qBAAoB;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACD,YACJ,SACA,OACA,QACA,WACA,eACF;AACE,SAAK,WAAW;AAChB,SAAK,SAAS,gBAAgB,KAAK;AACnC,SAAK,aAAa;AAClB,SAAK,iBAAiB;AACtB,SAAK,SAAS;AACd,WAAO,OAAO,IAAI;AAAA,EACtB;AAAA,EACA,OAAO,QAAQ,SAAkB,MAA0C;AACvE,WAAO,IAAI;AAAA,MACP;AAAA,MACA,EAAE,MAAM,gBAAgB,IAAI,GAAG,YAAY,EAAE;AAAA,MAC7C;AAAA,MACA,EAAE,YAAY,GAAG,MAAM,MAAM;AAAA,IACjC;AAAA,EACJ;AAAA,EACA,IAAI,KAAK;AACL,WAAO,KAAK,OAAO,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IAAI,4BAA4B,CAAC,IAAI;AACzC,WAAO,KAAK,OAAO;AAAA,EACvB;AACJ;","names":["MissingCapabilityError","MissingCapabilityError","PublicWallet","MissingCapabilityError","ProtocolRpcClient"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@invisi-labs/sdk",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Invisi client wallet sessions, operations and infrastructure integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -36,10 +36,10 @@
36
36
  "dependencies": {
37
37
  "ethers": "^6.17.0",
38
38
  "@noble/hashes": "1.8.0",
39
- "@invisi-labs/protocol": "1.1.4",
40
- "@invisi-labs/prover": "1.1.4",
41
- "@invisi-labs/rpc": "1.1.4",
42
- "@invisi-labs/core": "1.1.4"
39
+ "@invisi-labs/core": "1.1.5",
40
+ "@invisi-labs/protocol": "1.1.5",
41
+ "@invisi-labs/prover": "1.1.5",
42
+ "@invisi-labs/rpc": "1.1.5"
43
43
  },
44
44
  "devDependencies": {
45
45
  "tsup": "^8.0.0",