@invisi-labs/sdk 1.1.5 → 1.1.7

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.
Files changed (68) hide show
  1. package/dist/broadcaster-preparation-DMxxZ_1Q.d.cts +587 -0
  2. package/dist/broadcaster-preparation-DMxxZ_1Q.d.ts +587 -0
  3. package/dist/broadcaster-preparation-RMWQFYNL.js +11 -0
  4. package/dist/broadcaster-preparation-UGOTO4SX.cjs +11 -0
  5. package/dist/broadcaster-preparation-UGOTO4SX.cjs.map +1 -0
  6. package/dist/chunk-7F7ZZW3L.cjs +374 -0
  7. package/dist/chunk-7F7ZZW3L.cjs.map +1 -0
  8. package/dist/chunk-EHP5TBC6.js +3565 -0
  9. package/dist/chunk-EHP5TBC6.js.map +1 -0
  10. package/dist/chunk-GTPUYPQL.js +128 -0
  11. package/dist/chunk-GTPUYPQL.js.map +1 -0
  12. package/dist/chunk-ITTGBIG2.js +1877 -0
  13. package/dist/chunk-ITTGBIG2.js.map +1 -0
  14. package/dist/chunk-J2JH6HIG.cjs +1877 -0
  15. package/dist/chunk-J2JH6HIG.cjs.map +1 -0
  16. package/dist/chunk-LOU7AP2B.cjs +128 -0
  17. package/dist/chunk-LOU7AP2B.cjs.map +1 -0
  18. package/dist/chunk-RHNIHI4P.cjs +3565 -0
  19. package/dist/chunk-RHNIHI4P.cjs.map +1 -0
  20. package/dist/{chunk-4HMM7ZKY.js → chunk-XHKQ2BO2.js} +19 -19
  21. package/dist/chunk-XHKQ2BO2.js.map +1 -0
  22. package/dist/ethers.cjs +11 -385
  23. package/dist/ethers.cjs.map +1 -1
  24. package/dist/ethers.d.cts +4 -5
  25. package/dist/ethers.d.ts +4 -5
  26. package/dist/ethers.js +1 -1
  27. package/dist/index.cjs +441 -6217
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +109 -491
  30. package/dist/index.d.ts +109 -491
  31. package/dist/index.js +518 -599
  32. package/dist/index.js.map +1 -1
  33. package/dist/receipt-logs-CvC951p7.d.cts +318 -0
  34. package/dist/receipt-logs-m0-bhaxW.d.ts +318 -0
  35. package/dist/session-support.cjs +168 -0
  36. package/dist/session-support.cjs.map +1 -0
  37. package/dist/session-support.d.cts +252 -0
  38. package/dist/session-support.d.ts +252 -0
  39. package/dist/session-support.js +168 -0
  40. package/dist/session-support.js.map +1 -0
  41. package/package.json +10 -20
  42. package/dist/chunk-4HMM7ZKY.js.map +0 -1
  43. package/dist/chunk-BE52B32Z.js +0 -5490
  44. package/dist/chunk-BE52B32Z.js.map +0 -1
  45. package/dist/indexeddb.cjs +0 -5636
  46. package/dist/indexeddb.cjs.map +0 -1
  47. package/dist/indexeddb.d.cts +0 -20
  48. package/dist/indexeddb.d.ts +0 -20
  49. package/dist/indexeddb.js +0 -70
  50. package/dist/indexeddb.js.map +0 -1
  51. package/dist/memory.cjs +0 -5644
  52. package/dist/memory.cjs.map +0 -1
  53. package/dist/memory.d.cts +0 -12
  54. package/dist/memory.d.ts +0 -12
  55. package/dist/memory.js +0 -10
  56. package/dist/operation-types-D7I405FX.d.ts +0 -275
  57. package/dist/operation-types-DIazgS2d.d.cts +0 -275
  58. package/dist/sqlite.cjs +0 -5620
  59. package/dist/sqlite.cjs.map +0 -1
  60. package/dist/sqlite.d.cts +0 -28
  61. package/dist/sqlite.d.ts +0 -28
  62. package/dist/sqlite.js +0 -54
  63. package/dist/sqlite.js.map +0 -1
  64. package/dist/state-AUnz7TG7.d.cts +0 -78
  65. package/dist/state-AUnz7TG7.d.ts +0 -78
  66. package/dist/store-BMN8kd0c.d.ts +0 -42
  67. package/dist/store-Cz75STRl.d.cts +0 -42
  68. /package/dist/{memory.js.map → broadcaster-preparation-RMWQFYNL.js.map} +0 -0
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 {\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,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K,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/index.ts","../src/disclosure/DisclosureVerifier.ts","../src/protocol/connections.ts","../src/protocol/Protocol.ts","../src/protocol/BroadcasterRegistry.ts","../src/protocol/ProtocolRpcClient.ts","../src/payment-note/PaymentNote.ts","../src/payment-note/verification.ts"],"sourcesContent":["export {\n Detector,\n Disclosure,\n MAX_MEMO_BYTES,\n MissingCapabilityError,\n NullifierCapability,\n PublicWallet,\n ViewingCapability,\n Wallet,\n WalletAuthorization,\n computeCreditNullifier,\n creditPeriods,\n creditV1,\n decodeDeliveryHeader,\n decodeMemoText,\n encodeMemo,\n fundsV1,\n} from \"@invisi-labs/core\";\nexport type {\n Address,\n CreditDataV1,\n CreditDeliveryState,\n CreditNote,\n CreditOpening,\n CreditPolicy,\n DisclosureExport,\n DisclosureOutput,\n DisclosureResult,\n FundsDataV1,\n Hex,\n Memo,\n Note,\n ReceivingKeys,\n WalletAuthorizationProvider,\n} from \"@invisi-labs/core\";\nexport { RegistrationOperation } from \"@invisi-labs/protocol\";\nexport type {\n AddressRegistryOptions,\n CanonicalBlock,\n CanonicalReceipt,\n ChainReader,\n FactoryReader,\n Membership,\n ProtocolDataProvider,\n ProtocolDataStatus,\n ProtocolOptions,\n ProtocolUpdateRange,\n ProtocolUpdates,\n RegistryContext,\n RegistryReader,\n TokenProtocol,\n TokenProtocolOptions,\n TransactionCall,\n TransactionContext,\n} from \"@invisi-labs/protocol\";\nexport type {\n AggregateMember,\n AggregatorCapability,\n ProofBundle,\n ProofStatement,\n Prover,\n ProverOptions,\n} from \"@invisi-labs/prover\";\nexport { Invisi } from \"./client/Invisi\";\nexport type { InvisiOptions, RegistrationPreparationOptions } from \"./client/Invisi\";\nexport { DisclosureVerifier } from \"./disclosure/DisclosureVerifier\";\nexport type {\n DisclosureEvidence,\n DisclosureReader,\n DisclosureReference,\n DisclosureVerifierOptions,\n VerifiedDisclosure,\n} from \"./disclosure/DisclosureVerifier\";\nexport { InvisiError } from \"./errors\";\nexport type { InvisiErrorCode, InvisiErrorDetails } from \"./errors\";\nexport { NoteOutput } from \"./notes/NoteOutput\";\nexport type { NoteOutputContext, PaymentRequest, NoteOutputRecipient } from \"./notes/NoteOutput\";\nexport { Protocol } from \"./protocol/Protocol\";\nexport type {\n CancelCreditPreparation,\n CreateCreditPreparation,\n DrawCreditPreparation,\n FundingAuthorizationVerifier,\n FundingSigner,\n FundingSource,\n FundingTypedData,\n OperationAggregateMember,\n ShieldPreparation,\n TopUpCreditPreparation,\n TransactionExecution,\n TransactionProveOptions,\n TransferPreparation,\n} from \"./transactions/operation-types\";\n\nexport { MAX_UPDATE_BLOCKS, ProtocolRpcError } from \"@invisi-labs/rpc\";\nexport type {\n ProtocolDeployment,\n ProtocolRpcChain,\n ProtocolRpcClientOptions,\n ProtocolRpcConnectionOptions,\n ProtocolRpcReader,\n RegisteredReceivingAddress,\n} from \"@invisi-labs/rpc\";\nexport { AddressRegistry } from \"./protocol/AddressRegistry\";\nexport { BroadcasterRegistry } from \"./protocol/BroadcasterRegistry\";\nexport type {\n BroadcasterRegistration,\n BroadcasterRegistryOptions,\n RegisteredBroadcaster,\n} from \"./protocol/BroadcasterRegistry\";\nexport { ProtocolRpcClient } from \"./protocol/ProtocolRpcClient\";\n\nexport { PreparedTransaction } from \"./transactions/execution/PreparedTransaction\";\nexport type {\n CreditInput,\n ExplicitCancelCreditPreparation,\n ExplicitCreateCreditPreparation,\n ExplicitDrawCreditPreparation,\n ExplicitShieldPreparation,\n ExplicitTopUpCreditPreparation,\n ExplicitTransferPreparation,\n NoteInput,\n TransactionIdentity,\n} from \"./transactions/explicit-types\";\n\nexport type {\n GasBenchmarkCircuit,\n GasBenchmarkDeployment,\n GasBenchmarkProfile,\n GasBenchmarkSample,\n GasBenchmarkShape,\n GasReference,\n} from \"./gas/gas-estimation\";\n\nexport { defineGasBenchmarks } from \"./gas/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 { decryptCandidates } from \"./discovery/discovery\";\nexport type { DeliveryEventLog, DiscoveredCredit, DiscoveredNote } from \"./discovery/discovery\";\nexport { readProtocolLogs } from \"./discovery/receipt-logs\";\n\nexport type {\n ProtocolCreditTransition,\n ProtocolOutput,\n ProtocolTransactionUpdates,\n} from \"@invisi-labs/rpc\";\n\nexport * from \"./broadcaster/index\";\n\nexport type {\n BroadcasterFeeSource,\n WithBroadcasterOptions,\n} from \"./broadcaster/broadcaster-preparation\";\n\nexport { encodePaymentRequest, decodePaymentRequest } from \"./payment-request/codec\";\nexport type { NoteOutputExecutionOptions } from \"./payment-request/types\";\n\nexport { PaymentNote, VerifiedPaymentNote, SpendablePaymentNote } from \"./payment-note/PaymentNote\";\nexport { encodePaymentNote, decodePaymentNote } from \"./payment-note/codec\";\nexport type { PaymentNoteData } from \"./payment-note/types\";\nexport type {\n PaymentNoteVerificationOptions,\n PaymentNoteVerificationSettings,\n} from \"./payment-note/verification\";\nexport { TransactionOutput } from \"./notes/TransactionOutput\";\n","import type { Hex } from \"@invisi-labs/protocol/contracts\";\nimport type { Provider } from \"ethers\";\nimport { readProtocolLogs } from \"../discovery/receipt-logs\";\nimport { EthersChainReader } from \"../integrations/ethers\";\n\nimport { Disclosure, type DisclosureOutput, type DisclosureResult } from \"@invisi-labs/core\";\nimport { TokenProtocol, type CanonicalBlock, type ChainReader } from \"@invisi-labs/protocol\";\nimport { extractDeliveryCandidates } from \"../discovery/discovery\";\n\nexport interface DisclosureReference {\n transactionHash: Hex;\n treeId: bigint;\n leafIndex: number;\n role: \"funds\" | \"owner\" | \"spender\";\n}\n\nexport type DisclosureReader = Pick<\n ChainReader,\n \"getChainId\" | \"getCode\" | \"getReceipt\" | \"getBlock\" | \"getLatestBlockNumber\"\n>;\n\nexport interface DisclosureVerifierOptions {\n protocol: TokenProtocol;\n reader: DisclosureReader;\n /** Minimum confirmations including the inclusion block; defaults to one. */\n confirmations?: number;\n}\n\nexport interface DisclosureEvidence {\n reference: Readonly<DisclosureReference>;\n block: Readonly<CanonicalBlock>;\n confirmations: bigint;\n output: Readonly<DisclosureOutput>;\n}\n\nexport interface VerifiedDisclosure {\n result: DisclosureResult;\n block: Readonly<CanonicalBlock>;\n confirmations: bigint;\n output: Readonly<DisclosureReference & { commitment: Hex }>;\n}\n\nfunction check(value: unknown, message: string): asserts value {\n if (!value) throw new Error(message);\n}\n\nfunction reference(value: DisclosureReference): DisclosureReference {\n check(/^0x[0-9a-fA-F]{64}$/.test(value.transactionHash), \"invalid disclosure transaction hash\");\n check(\n typeof value.treeId === \"bigint\" && value.treeId > 0n && value.treeId < 1n << 64n,\n \"invalid disclosure tree ID\"\n );\n check(\n Number.isSafeInteger(value.leafIndex) && value.leafIndex >= 0 && value.leafIndex < 65536,\n \"invalid disclosure leaf index\"\n );\n check([\"funds\", \"owner\", \"spender\"].includes(value.role), \"invalid disclosure reference role\");\n return {\n transactionHash: value.transactionHash.toLowerCase() as Hex,\n treeId: value.treeId,\n leafIndex: value.leafIndex,\n role: value.role,\n };\n}\n\n/** Read-only verification against a trusted RPC and authenticated protocol deployment.\n * Results establish output content/inclusion at a block, not payer identity, spent state or wallet completeness.\n */\nexport class DisclosureVerifier {\n readonly #protocol: TokenProtocol;\n readonly #reader: DisclosureReader;\n readonly #confirmations: bigint;\n\n constructor(\n options:\n | DisclosureVerifierOptions\n | (Omit<DisclosureVerifierOptions, \"reader\"> & { provider: Provider })\n ) {\n const confirmations = options.confirmations ?? 1;\n check(\n Number.isSafeInteger(confirmations) && confirmations >= 1,\n \"invalid disclosure confirmations\"\n );\n this.#protocol = options.protocol;\n this.#reader =\n \"provider\" in options ? new EthersChainReader(options.provider) : options.reader;\n this.#confirmations = BigInt(confirmations);\n Object.freeze(this);\n }\n\n private async barrier(block: Readonly<CanonicalBlock>): Promise<bigint> {\n await this.#protocol.validateDeployment(this.#reader);\n const canonical = await this.#reader.getBlock(block.number);\n check(\n canonical.number === block.number &&\n canonical.hash.toLowerCase() === block.hash.toLowerCase(),\n \"disclosure canonical block changed; reorg verification required\"\n );\n const head = await this.#reader.getLatestBlockNumber();\n check(\n head >= block.number && head - block.number + 1n >= this.#confirmations,\n \"insufficient disclosure confirmations\"\n );\n check(\n (await this.#reader.getChainId()) === this.#protocol.context.chainId,\n \"disclosure chain changed during verification\"\n );\n return head - block.number + 1n;\n }\n\n /** Resolve the exact inserted output and its delivery from a successful canonical receipt. */\n async readOutput(value: DisclosureReference): Promise<DisclosureEvidence> {\n const selected = reference(value);\n await this.#protocol.validateDeployment(this.#reader);\n const received = await this.#reader.getReceipt(selected.transactionHash);\n check(received, \"disclosure transaction receipt is unavailable\");\n const receipt = structuredClone(received);\n check(receipt.status === \"success\", \"disclosure requires a successful transaction receipt\");\n check(\n receipt.transactionHash.toLowerCase() === selected.transactionHash,\n \"disclosure receipt transaction mismatch\"\n );\n check(\n typeof receipt.block.number === \"bigint\" &&\n receipt.block.number >= 0n &&\n /^0x[0-9a-fA-F]{64}$/.test(receipt.block.hash),\n \"invalid disclosure receipt block\"\n );\n const { context } = this.#protocol;\n const logs = readProtocolLogs(receipt, context.protocolAddress);\n const candidates = extractDeliveryCandidates(logs, context, receipt.block.number).filter(\n (candidate) =>\n candidate.treeId === selected.treeId &&\n candidate.leafIndex === selected.leafIndex &&\n candidate.role === selected.role &&\n candidate.tokenAddress.toLowerCase() === context.tokenAddress.toLowerCase()\n );\n check(\n candidates.length === 1,\n \"disclosure output has no unique canonical insertion and delivery\"\n );\n const candidate = candidates[0]!;\n const confirmations = await this.barrier(receipt.block);\n return Object.freeze({\n reference: Object.freeze(selected),\n block: Object.freeze({ ...receipt.block }),\n confirmations,\n output: Object.freeze({\n chainId: context.chainId,\n protocolAddress: BigInt(context.protocolAddress),\n tokenAddress: BigInt(context.tokenAddress),\n outputCommitment: candidate.commitment,\n role: selected.role,\n ciphertext: candidate.delivery.ciphertext,\n }),\n });\n }\n\n async verify(disclosure: Disclosure, value: DisclosureReference): Promise<VerifiedDisclosure> {\n const evidence = await this.readOutput(value);\n const result = await disclosure.verify(evidence.output);\n const confirmations = await this.barrier(evidence.block);\n return Object.freeze({\n result: Object.freeze(result),\n block: evidence.block,\n confirmations,\n output: Object.freeze({\n ...evidence.reference,\n commitment: evidence.output.outputCommitment,\n }),\n });\n }\n\n toJSON() {\n return { disclosureVerifier: true, confirmations: this.#confirmations.toString() };\n }\n\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return this.toJSON();\n }\n}\n","import type { Protocol } from \"@invisi-labs/protocol\";\nimport type { ProtocolRpcClient } from \"@invisi-labs/rpc\";\nimport type { Provider } from \"ethers\";\n\n/** Public network connections only; never holds wallet keys or a signer. */\nconst connections = new WeakMap<\n Protocol,\n { provider: Provider; protocolRpc: Pick<ProtocolRpcClient, \"withReader\"> }\n>();\nexport function rememberProtocolConnection(\n protocol: Protocol,\n provider: Provider,\n protocolRpc: Pick<ProtocolRpcClient, \"withReader\">\n): void {\n connections.set(protocol, { provider, protocolRpc });\n}\nexport function protocolConnection(protocol: Protocol) {\n return connections.get(protocol);\n}\n","import { rememberProtocolConnection } from \"./connections\";\nimport { Protocol as BaseProtocol } from \"@invisi-labs/protocol\";\nimport type { ProtocolRpcClient } from \"@invisi-labs/rpc\";\nimport { getAddress, type Provider } from \"ethers\";\nimport { BroadcasterClient } from \"../broadcaster/index\";\n\nconst sources = new WeakMap<Protocol, Pick<ProtocolRpcClient, \"getBroadcasters\">>();\n\n/** Deployment operations and token-compatible broadcaster discovery. */\nexport class Protocol extends BaseProtocol {\n static override async fromRpc(\n rpc: Pick<ProtocolRpcClient, \"getDeployment\"> &\n Partial<Pick<ProtocolRpcClient, \"getBroadcasters\" | \"withReader\">>,\n provider: Provider,\n options: { signal?: AbortSignal } = {}\n ): Promise<Protocol> {\n const verified = await BaseProtocol.fromRpc(rpc, provider, options);\n const protocol = new Protocol({ deployment: verified.deployment });\n if (rpc.getBroadcasters)\n sources.set(protocol, rpc as Pick<ProtocolRpcClient, \"getBroadcasters\">);\n if (rpc.withReader)\n rememberProtocolConnection(\n protocol,\n provider,\n rpc as Pick<ProtocolRpcClient, \"withReader\">\n );\n return protocol;\n }\n\n /** Returns enabled services that answer a token fee probe; final quotes are checked by prepared. */\n async getBroadcasters(options: { tokenAddress: string }): Promise<BroadcasterClient[]> {\n const token = getAddress(options.tokenAddress);\n if (!this.deployment.broadcasterRegistry)\n throw new Error(\"broadcaster registry is not configured\");\n const rpc = sources.get(this);\n if (!rpc) throw new Error(\"broadcaster discovery requires Protocol.fromRpc\");\n const clients: BroadcasterClient[] = [];\n let after: `0x${string}` | undefined;\n let block: Awaited<ReturnType<ProtocolRpcClient[\"getBroadcasters\"]>>[\"block\"] | undefined;\n const seen = new Set<string>();\n do {\n const page = await rpc.getBroadcasters({\n enabled: true,\n limit: 100,\n ...(after ? { after } : {}),\n ...(block ? { block } : {}),\n });\n block ??= page.block;\n const compatible = await Promise.all(\n page.broadcasters.map(async (entry) => {\n if (!entry.enabled) return undefined;\n try {\n const client = new BroadcasterClient(entry);\n await client.fee(token);\n return client;\n } catch {\n return undefined;\n }\n })\n );\n clients.push(\n ...compatible.filter((client): client is BroadcasterClient => client !== undefined)\n );\n after = page.next;\n if (after && seen.has(after)) throw new Error(\"repeated broadcaster pagination cursor\");\n if (after) seen.add(after);\n } while (after);\n return clients;\n }\n}\n","import type { TransactionCall } from \"@invisi-labs/protocol\";\nimport { broadcasterRegistryAbi, type Address, type Hex } from \"@invisi-labs/protocol/contracts\";\nimport { getAddress, Interface, keccak256, type Provider } from \"ethers\";\n\nexport interface BroadcasterRegistration {\n endpoint: string;\n metadataURI?: string;\n quoteSigner: Address;\n feeRecipient: Address;\n}\n\nexport interface RegisteredBroadcaster extends Required<BroadcasterRegistration> {\n operator: Address;\n enabled: boolean;\n}\n\nexport interface BroadcasterRegistryOptions {\n provider: Provider;\n address: Address;\n chainId: bigint;\n fromBlock: number;\n runtimeCodeHash: string;\n /** Maximum blocks per getLogs request. Defaults to 2,000. */\n blockRange?: number;\n}\n\nconst abi = new Interface(broadcasterRegistryAbi);\n\nfunction address(value: string): Address {\n const normalized = getAddress(value) as Address;\n if (BigInt(normalized) === 0n) throw new Error(\"zero broadcaster address\");\n return normalized;\n}\n\n/** Optional on-chain discovery. Registry entries do not authorize spending or endorse operators. */\nexport class BroadcasterRegistry {\n readonly address: Address;\n readonly #options: Readonly<BroadcasterRegistryOptions>;\n\n constructor(options: BroadcasterRegistryOptions) {\n this.address = address(options.address);\n const blockRange = options.blockRange ?? 2_000;\n if (\n options.chainId <= 0n ||\n !Number.isSafeInteger(options.fromBlock) ||\n options.fromBlock < 0 ||\n !Number.isSafeInteger(blockRange) ||\n blockRange < 1 ||\n blockRange > 100_000 ||\n !/^0x[0-9a-fA-F]{64}$/.test(options.runtimeCodeHash)\n )\n throw new Error(\"invalid broadcaster registry configuration\");\n this.#options = Object.freeze({ ...options, blockRange });\n }\n\n prepareRegistration(registration: BroadcasterRegistration): TransactionCall {\n const { endpoint, metadataURI = \"\" } = registration;\n if (\n !endpoint.startsWith(\"https://\") ||\n endpoint.length <= 8 ||\n endpoint.length > 2048 ||\n /[^\\x21-\\x7e]/.test(endpoint)\n )\n throw new Error(\"broadcaster endpoint must be a printable HTTPS URI\");\n // Parse locally for a useful error; the registry additionally enforces its byte limits.\n const url = new URL(endpoint);\n if (!url.hostname || url.username || url.password) {\n throw new Error(\"broadcaster HTTPS endpoint must not include credentials\");\n }\n if (metadataURI.length > 2048 || /[^\\x21-\\x7e]/.test(metadataURI)) {\n throw new Error(\"invalid broadcaster metadata URI\");\n }\n return this.call(\"setBroadcaster\", [\n endpoint,\n metadataURI,\n address(registration.quoteSigner),\n address(registration.feeRecipient),\n ]);\n }\n\n prepareAvailability(enabled: boolean): TransactionCall {\n return this.call(\"setEnabled\", [enabled]);\n }\n\n private call(name: string, args: readonly unknown[]): TransactionCall {\n return { to: this.address, data: abi.encodeFunctionData(name, args) as Hex, value: 0n };\n }\n\n private async validate(): Promise<void> {\n const { provider, chainId, runtimeCodeHash } = this.#options;\n if ((await provider.getNetwork()).chainId !== chainId) {\n throw new Error(\"broadcaster registry chain mismatch\");\n }\n if (\n keccak256(await provider.getCode(this.address)).toLowerCase() !==\n runtimeCodeHash.toLowerCase()\n ) {\n throw new Error(\"broadcaster registry runtime code mismatch\");\n }\n }\n\n async get(operator: Address): Promise<RegisteredBroadcaster> {\n await this.validate();\n return this.read(address(operator));\n }\n\n private async read(operator: Address): Promise<RegisteredBroadcaster> {\n const result = await this.#options.provider.call(this.call(\"broadcasterOf\", [operator]));\n const [entry] = abi.decodeFunctionResult(\"broadcasterOf\", result);\n return {\n operator,\n endpoint: entry.endpoint,\n metadataURI: entry.metadataURI,\n quoteSigner: address(entry.quoteSigner),\n feeRecipient: address(entry.feeRecipient),\n enabled: entry.enabled,\n };\n }\n\n /** Discover event operators, then read their latest entry; disabled services remain explicit. */\n async discover(\n options: { toBlock?: number; signal?: AbortSignal } = {}\n ): Promise<RegisteredBroadcaster[]> {\n const { provider, fromBlock, blockRange } = this.#options;\n options.signal?.throwIfAborted();\n await this.validate();\n const toBlock = options.toBlock ?? (await provider.getBlockNumber());\n if (!Number.isSafeInteger(toBlock) || toBlock < fromBlock) {\n throw new Error(\"invalid broadcaster discovery block range\");\n }\n const operators = new Set<Address>();\n for (let start = fromBlock; start <= toBlock;) {\n options.signal?.throwIfAborted();\n const end = Math.min(start + blockRange! - 1, toBlock);\n const logs = await provider.getLogs({\n address: this.address,\n topics: [abi.getEvent(\"BroadcasterSet\")!.topicHash],\n fromBlock: start,\n toBlock: end,\n });\n for (const log of logs) {\n if (getAddress(log.address) !== this.address)\n throw new Error(\"registry event address mismatch\");\n const event = abi.parseLog(log);\n if (!event || event.name !== \"BroadcasterSet\")\n throw new Error(\"invalid registry event\");\n operators.add(address(event.args.operator));\n }\n start = end + 1;\n }\n const entries: RegisteredBroadcaster[] = [];\n for (const operator of operators) {\n options.signal?.throwIfAborted();\n entries.push(await this.read(operator));\n }\n return entries;\n }\n}\n","import { ProtocolRpcClient as RpcClient } from \"@invisi-labs/rpc\";\nimport type { Provider } from \"ethers\";\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 { computeNoteIdentity, computeNoteCommitment, Wallet } from \"@invisi-labs/core\";\nimport type { Protocol, Membership, CanonicalBlock } from \"@invisi-labs/protocol\";\nimport type { NoteInput } from \"../transactions/explicit-types\";\nimport { decodePaymentNote, encodePaymentNote } from \"./codec\";\nimport type { PaymentNoteData } from \"./types\";\nimport {\n verifyPaymentNote,\n verificationOptions,\n type PaymentNoteVerificationSettings,\n type PaymentNoteVerificationOptions,\n} from \"./verification\";\n\nconst verification = Symbol(\"PaymentNote verification\");\nexport class VerifiedPaymentNote {\n readonly #membership: Membership;\n readonly #checkedAt: CanonicalBlock;\n constructor(token: symbol, membership: Membership, checkedAt: CanonicalBlock) {\n if (token !== verification) throw new Error(\"Payment note verification required\");\n this.#membership = structuredClone(membership);\n this.#checkedAt = structuredClone(checkedAt);\n }\n get membership(): Membership {\n return structuredClone(this.#membership);\n }\n get checkedAt(): CanonicalBlock {\n return structuredClone(this.#checkedAt);\n }\n}\nexport class SpendablePaymentNote extends VerifiedPaymentNote {\n readonly #input: NoteInput;\n readonly #spendabilityCheckedAt: CanonicalBlock;\n constructor(\n token: symbol,\n input: NoteInput,\n membership: Membership,\n checkedAt: CanonicalBlock,\n spendabilityCheckedAt: CanonicalBlock\n ) {\n super(token, membership, checkedAt);\n this.#input = structuredClone(input);\n this.#spendabilityCheckedAt = structuredClone(spendabilityCheckedAt);\n Object.freeze(this);\n }\n get spendabilityCheckedAt(): CanonicalBlock {\n return structuredClone(this.#spendabilityCheckedAt);\n }\n toInput(): NoteInput {\n return structuredClone(this.#input);\n }\n}\n/** A validated Note opening, independent of an indexed wallet store. */\nexport class PaymentNote implements PaymentNoteData {\n readonly chainId: bigint;\n readonly protocolAddress: PaymentNoteData[\"protocolAddress\"];\n readonly tokenAddress: PaymentNoteData[\"tokenAddress\"];\n readonly amount: bigint;\n readonly ownerAddress: PaymentNoteData[\"ownerAddress\"];\n readonly nonce: bigint;\n readonly commitment: PaymentNoteData[\"commitment\"];\n readonly ipn: string;\n private constructor(data: PaymentNoteData, ipn: string) {\n this.chainId = data.chainId;\n this.protocolAddress = data.protocolAddress;\n this.tokenAddress = data.tokenAddress;\n this.amount = data.amount;\n this.ownerAddress = data.ownerAddress;\n this.nonce = data.nonce;\n this.commitment = data.commitment;\n this.ipn = ipn;\n Object.freeze(this);\n }\n static async from(ipn: string): Promise<PaymentNote> {\n const data = decodePaymentNote(ipn);\n const identity = await computeNoteIdentity(BigInt(data.ownerAddress), data.nonce);\n const commitment = await computeNoteCommitment(\n data.chainId,\n identity,\n BigInt(data.tokenAddress),\n data.amount\n );\n if (commitment !== data.commitment) throw new Error(\"Payment note commitment mismatch\");\n return new PaymentNote(data, encodePaymentNote(data));\n }\n async verify(\n protocol: Protocol,\n options: PaymentNoteVerificationOptions | PaymentNoteVerificationSettings = {}\n ): Promise<VerifiedPaymentNote> {\n const result = await verifyPaymentNote(\n this.data(),\n protocol,\n verificationOptions(protocol, options)\n );\n const verified = new VerifiedPaymentNote(verification, result.membership, result.checkedAt);\n Object.freeze(verified);\n return verified;\n }\n async verifySpendable(\n protocol: Protocol,\n wallet: Wallet,\n options: PaymentNoteVerificationOptions | PaymentNoteVerificationSettings = {}\n ): Promise<SpendablePaymentNote> {\n if (!(wallet instanceof Wallet))\n throw new Error(\"Wallet spending authorization capability required\");\n const result = await verifyPaymentNote(\n this.data(),\n protocol,\n verificationOptions(protocol, options),\n wallet\n );\n return new SpendablePaymentNote(\n verification,\n result.input,\n result.membership,\n result.checkedAt,\n result.spendabilityCheckedAt!\n );\n }\n private data(): PaymentNoteData {\n const { chainId, protocolAddress, tokenAddress, amount, ownerAddress, nonce, commitment } =\n this;\n return { chainId, protocolAddress, tokenAddress, amount, ownerAddress, nonce, commitment };\n }\n}\n","import { protocolConnection } from \"../protocol/connections\";\nimport {\n poseidonHash,\n TREE_DEPTH,\n type Wallet,\n type Note,\n computeNoteNullifier,\n} from \"@invisi-labs/core\";\nimport type { CanonicalBlock, ChainReader, Membership, Protocol } from \"@invisi-labs/protocol\";\nimport type { ProtocolRpcClient } from \"@invisi-labs/rpc\";\nimport { getAddress, type Provider } from \"ethers\";\nimport { EthersChainReader } from \"../integrations/ethers\";\nimport type { NoteInput } from \"../transactions/explicit-types\";\nimport type { PaymentNoteData } from \"./types\";\n\n/** Supply connections for manually constructed Protocols; fromRpc connections are reused. */\nexport type PaymentNoteVerificationOptions = {\n protocolRpc: Pick<ProtocolRpcClient, \"withReader\">;\n confirmations?: number;\n} & ({ provider: Provider; chainReader?: never } | { chainReader: ChainReader; provider?: never });\n\nexport type PaymentNoteVerificationSettings = { confirmations?: number };\nexport function verificationOptions(\n protocol: Protocol,\n options: PaymentNoteVerificationOptions | PaymentNoteVerificationSettings = {}\n): PaymentNoteVerificationOptions {\n const connected = protocolConnection(protocol);\n const resolved = { ...connected, ...options };\n if (\n !(\"protocolRpc\" in resolved) ||\n !resolved.protocolRpc ||\n (!(\"chainReader\" in resolved) && !(\"provider\" in resolved))\n )\n throw new Error(\n \"Payment note verification requires Protocol.fromRpc or explicit chain and Protocol RPC connections\"\n );\n return resolved as PaymentNoteVerificationOptions;\n}\n\nfunction sameBlock(a: CanonicalBlock, b: CanonicalBlock): boolean {\n return (\n a.number === b.number &&\n a.hash === b.hash &&\n a.parentHash === b.parentHash &&\n a.timestamp === b.timestamp\n );\n}\nexport function asNote(data: PaymentNoteData): Note {\n return {\n chainId: data.chainId,\n protocolAddress: BigInt(data.protocolAddress),\n tokenAddress: BigInt(data.tokenAddress),\n amount: data.amount,\n ownerAddress: data.ownerAddress,\n nonce: data.nonce,\n };\n}\nexport async function verifyPaymentNote(\n data: PaymentNoteData,\n protocol: Protocol,\n options: PaymentNoteVerificationOptions,\n wallet?: Wallet\n): Promise<{\n input: NoteInput;\n membership: Membership;\n checkedAt: CanonicalBlock;\n spendabilityCheckedAt?: CanonicalBlock;\n}> {\n if (\n data.chainId !== protocol.context.chainId ||\n getAddress(data.protocolAddress) !== getAddress(protocol.context.protocolAddress)\n )\n throw new Error(\"Payment note protocol context mismatch\");\n const confirmations = options.confirmations ?? 1;\n if (!Number.isSafeInteger(confirmations) || confirmations < 1)\n throw new RangeError(\"confirmations must be positive\");\n const reader = options.chainReader ?? new EthersChainReader(options.provider!);\n await protocol.validateDeployment(reader);\n if (wallet && getAddress(wallet.ownerAddress) !== getAddress(data.ownerAddress))\n throw new Error(\"Payment note owner mismatch\");\n if (wallet) {\n if (typeof wallet.exportAuthorization !== \"function\")\n throw new Error(\"Wallet spending authorization capability required\");\n const authorization = wallet.exportAuthorization();\n if (getAddress(authorization.ownerAddress) !== getAddress(data.ownerAddress))\n throw new Error(\"Wallet authorization owner mismatch\");\n }\n const latest = await reader.getLatestBlockNumber();\n const number = latest - BigInt(confirmations - 1);\n if (number < protocol.deployment.protocol.fromBlock)\n throw new Error(\"Insufficient confirmed blocks\");\n const rpc = options.protocolRpc.withReader(reader);\n const status = await rpc.getStatus(protocol.context);\n if (!status.indexedHead) throw new Error(\"Protocol RPC has no indexed blocks\");\n const indexedNumber = status.indexedHead.number < number ? status.indexedHead.number : number;\n if (indexedNumber < protocol.deployment.protocol.fromBlock)\n throw new Error(\"Protocol RPC has not reached the deployment\");\n const checkedAt = await reader.getBlock(indexedNumber);\n if (checkedAt.number !== indexedNumber)\n throw new Error(\"Payment note confirmation block mismatch\");\n const result = await rpc.getNote(protocol.context, data.commitment, checkedAt);\n if (!result) throw new Error(\"Payment note is not indexed at the requested confirmed block\");\n const { output, membership } = result;\n if (\n output.commitment !== data.commitment ||\n getAddress(output.tokenAddress) !== getAddress(data.tokenAddress) ||\n membership.leaf !== data.commitment ||\n membership.treeId !== output.treeId ||\n membership.leafIndex !== output.leafIndex ||\n membership.block.number > checkedAt.number ||\n output.block.number > checkedAt.number ||\n membership.path.length !== TREE_DEPTH ||\n !Number.isSafeInteger(output.leafIndex) ||\n output.leafIndex < 0 ||\n output.leafIndex >= 2 ** TREE_DEPTH\n )\n throw new Error(\"Payment note membership metadata mismatch\");\n let root = BigInt(data.commitment);\n for (let level = 0; level < membership.path.length; level++) {\n const sibling = membership.path[level]!;\n root = BigInt(\n await poseidonHash((output.leafIndex >> level) & 1 ? [sibling, root] : [root, sibling])\n );\n }\n if (\n root !== BigInt(membership.root) ||\n !(await reader.isKnownRoot(protocol.context, membership.treeId, membership.root, checkedAt))\n )\n throw new Error(\"Payment note membership root is not accepted on chain\");\n if (\n !sameBlock(output.block, await reader.getBlock(output.block.number)) ||\n !sameBlock(membership.block, await reader.getBlock(membership.block.number))\n )\n throw new Error(\"Payment note block is no longer canonical\");\n let spendabilityCheckedAt: CanonicalBlock | undefined;\n if (wallet) {\n // Spendability concerns current state, not just the confirmed historical anchor.\n const current = await reader.getBlock(await reader.getLatestBlockNumber());\n const nullifier = await computeNoteNullifier(data.chainId, data.nonce, data.commitment);\n const spent = await reader.isSpent(protocol.context, [nullifier], current);\n if (spent.length !== 1 || spent[0] !== false)\n throw new Error(\"Payment note is already spent\");\n if (\n !(await reader.isKnownRoot(\n protocol.context,\n membership.treeId,\n membership.root,\n current\n ))\n )\n throw new Error(\"Payment note membership root is no longer spendable\");\n if (!sameBlock(current, await reader.getBlock(current.number)))\n throw new Error(\"Spendability block reorganized\");\n spendabilityCheckedAt = current;\n }\n if (!sameBlock(checkedAt, await reader.getBlock(checkedAt.number)))\n throw new Error(\"Payment note verification block reorganized\");\n return {\n input: {\n note: asNote(data),\n commitment: data.commitment,\n treeId: output.treeId,\n leafIndex: output.leafIndex,\n },\n membership,\n checkedAt,\n ...(spendabilityCheckedAt ? { spendabilityCheckedAt } : {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAkBP,SAAS,6BAA6B;;;ACOtC,SAAS,MAAM,OAAgB,SAAgC;AAC3D,MAAI,CAAC,MAAO,OAAM,IAAI,MAAM,OAAO;AACvC;AAEA,SAAS,UAAU,OAAiD;AAChE,QAAM,sBAAsB,KAAK,MAAM,eAAe,GAAG,qCAAqC;AAC9F;AAAA,IACI,OAAO,MAAM,WAAW,YAAY,MAAM,SAAS,MAAM,MAAM,SAAS,MAAM;AAAA,IAC9E;AAAA,EACJ;AACA;AAAA,IACI,OAAO,cAAc,MAAM,SAAS,KAAK,MAAM,aAAa,KAAK,MAAM,YAAY;AAAA,IACnF;AAAA,EACJ;AACA,QAAM,CAAC,SAAS,SAAS,SAAS,EAAE,SAAS,MAAM,IAAI,GAAG,mCAAmC;AAC7F,SAAO;AAAA,IACH,iBAAiB,MAAM,gBAAgB,YAAY;AAAA,IACnD,QAAQ,MAAM;AAAA,IACd,WAAW,MAAM;AAAA,IACj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AI,CAAC;AAAA,EACxD;AAAA,EACA,MAAM,OACF,UACA,UAA4E,CAAC,GACjD;AAC5B,UAAM,SAAS,MAAM;AAAA,MACjB,KAAK,KAAK;AAAA,MACV;AAAA,MACA,oBAAoB,UAAU,OAAO;AAAA,IACzC;AACA,UAAM,WAAW,IAAI,oBAAoB,cAAc,OAAO,YAAY,OAAO,SAAS;AAC1F,WAAO,OAAO,QAAQ;AACtB,WAAO;AAAA,EACX;AAAA,EACA,MAAM,gBACF,UACA,QACA,UAA4E,CAAC,GAChD;AAC7B,QAAI,EAAE,kBAAkB;AACpB,YAAM,IAAI,MAAM,mDAAmD;AACvE,UAAM,SAAS,MAAM;AAAA,MACjB,KAAK,KAAK;AAAA,MACV;AAAA,MACA,oBAAoB,UAAU,OAAO;AAAA,MACrC;AAAA,IACJ;AACA,WAAO,IAAI;AAAA,MACP;AAAA,MACA,OAAO;AAAA,MACP,OAAO;AAAA,MACP,OAAO;AAAA,MACP,OAAO;AAAA,IACX;AAAA,EACJ;AAAA,EACQ,OAAwB;AAC5B,UAAM,EAAE,SAAS,iBAAiB,cAAc,QAAQ,cAAc,OAAO,WAAW,IACpF;AACJ,WAAO,EAAE,SAAS,iBAAiB,cAAc,QAAQ,cAAc,OAAO,WAAW;AAAA,EAC7F;AACJ;","names":["Wallet","candidate","getAddress","getAddress","getAddress"]}
@@ -0,0 +1,318 @@
1
+ import { m as GasBenchmarkProfile, a5 as PreparedOutput, q as NoteOutputContext, s as NoteOutputRecipient, Q as OperationStatus, M as TransactionRuntime, a1 as PreparationIntent, J as OperationPlan, t as SignedBroadcasterQuote, B as BroadcasterClient, W as WithBroadcasterOptions, p as GasReference, v as TransactionProveOptions, O as OperationAggregateMember, C as CancelCreditPreparation, h as CreateCreditPreparation, D as DrawCreditPreparation, S as ShieldPreparation, T as TopUpCreditPreparation, w as TransferPreparation, U as TransactionInfrastructure } from './broadcaster-preparation-DMxxZ_1Q.cjs';
2
+ import { TransactionCall, Protocol, RegistrationPreparation, RegistrationOperation, CanonicalReceipt } from '@invisi-labs/protocol';
3
+ import * as _invisi_labs_core from '@invisi-labs/core';
4
+ import { CreditDeliveryState, PublicWallet, Note, ViewingCapability } from '@invisi-labs/core';
5
+ import { Prover, ProofBundle } from '@invisi-labs/prover';
6
+ import { Hex, Address } from '@invisi-labs/protocol/contracts';
7
+
8
+ /** Copy trusted benchmark records; validation checks format, not their publisher's honesty. */
9
+ declare function copyGasBenchmarks(profiles: readonly GasBenchmarkProfile[]): GasBenchmarkProfile[];
10
+ /** Parse a trusted, JSON-compatible benchmark catalog. No network access or publisher authentication. */
11
+ declare function defineGasBenchmarks(input: unknown): GasBenchmarkProfile[];
12
+
13
+ /** Detached final output snapshot, including any generated change. Contains private Note data. */
14
+ declare class TransactionOutput {
15
+ #private;
16
+ constructor(output: PreparedOutput);
17
+ get context(): NoteOutputContext;
18
+ get recipient(): NoteOutputRecipient;
19
+ get amount(): bigint;
20
+ get commitment(): `0x${string}`;
21
+ get identity(): `0x${string}`;
22
+ get nonce(): bigint | undefined;
23
+ get change(): boolean;
24
+ exportPaymentNote(): string;
25
+ }
26
+
27
+ type Runtime = TransactionRuntime & {
28
+ reprepare?: (intent: PreparationIntent) => Promise<OperationPlan>;
29
+ };
30
+ /** An immutable, local transaction handle. No wallet inventory, reservations or persistence. */
31
+ declare class PreparedTransaction {
32
+ #private;
33
+ readonly status: OperationStatus;
34
+ private constructor();
35
+ static prepare(runtime: Runtime, plan: OperationPlan): PreparedTransaction;
36
+ broadcasterQuote(): SignedBroadcasterQuote | undefined;
37
+ withBroadcaster(client: BroadcasterClient, options: WithBroadcasterOptions): Promise<PreparedTransaction>;
38
+ get id(): string;
39
+ get kind(): "shield" | "transfer" | "create-credit" | "draw-credit" | "top-up-credit" | "cancel-credit";
40
+ estimateGas(): GasReference;
41
+ /** Final Note outputs, including change; Credit outputs are not exported as IPN. */
42
+ getOutputs(): readonly TransactionOutput[];
43
+ preview(): {
44
+ id: string;
45
+ kind: "shield" | "transfer" | "create-credit" | "draw-credit" | "top-up-credit" | "cancel-credit";
46
+ status: OperationStatus;
47
+ context: {
48
+ tokenAddress: _invisi_labs_core.Address;
49
+ now?: bigint;
50
+ timestamp?: bigint;
51
+ chainId: bigint;
52
+ protocolAddress: _invisi_labs_core.Address;
53
+ };
54
+ inputs: number;
55
+ inputDetails: ({
56
+ kind: "notes";
57
+ commitment: `0x${string}`;
58
+ amount: bigint;
59
+ owner: `0x${string}`;
60
+ treeId: bigint;
61
+ leafIndex: number;
62
+ } | {
63
+ kind: "credits";
64
+ commitment: `0x${string}`;
65
+ amount: bigint;
66
+ owner: `0x${string}`;
67
+ spender: `0x${string}`;
68
+ expiry: bigint;
69
+ role: "owner" | "spender";
70
+ treeId: bigint;
71
+ leafIndex: number;
72
+ })[];
73
+ funding: {
74
+ payer: `0x${string}`;
75
+ amount: bigint;
76
+ authorization: "signature" | "none" | "caller";
77
+ sigNonce: bigint;
78
+ deadline: bigint;
79
+ permit: {
80
+ deadline: bigint;
81
+ };
82
+ };
83
+ creditOutputs: {
84
+ commitment: `0x${string}`;
85
+ amount: bigint;
86
+ expiry: bigint;
87
+ owner: `0x${string}`;
88
+ spender: `0x${string}`;
89
+ ownerPayout: bigint;
90
+ spenderPayout: bigint;
91
+ }[] | undefined;
92
+ outputs: {
93
+ commitment: `0x${string}`;
94
+ to: string;
95
+ amount: bigint;
96
+ change: boolean;
97
+ }[];
98
+ capacity: number | undefined;
99
+ deadline: bigint;
100
+ feeRecipient: `0x${string}` | undefined;
101
+ feeAmount: bigint;
102
+ fundingAmount: bigint;
103
+ fundingPayer: `0x${string}` | undefined;
104
+ withdrawalAmount: bigint;
105
+ withdrawalAddress: `0x${string}` | undefined;
106
+ permissions: {
107
+ walletAuthorization: boolean;
108
+ proof: boolean;
109
+ fundingAuthorization: boolean;
110
+ };
111
+ };
112
+ /** Obtain a firm quote before signing. This intent contains no private inputs or witness. */
113
+ exportBroadcasterIntent(): Promise<{
114
+ sendable: false;
115
+ data: _invisi_labs_core.Hex;
116
+ }>;
117
+ private current;
118
+ private stage;
119
+ /** Public EIP-712 request; signing transport and key custody belong to the caller. */
120
+ exportWalletAuthorization(options?: {
121
+ signal?: AbortSignal;
122
+ }): Promise<_invisi_labs_core.SigningRequest>;
123
+ /** Attach an external EOA signature, retaining its witness only at the private proving boundary. */
124
+ withWalletSignature(signature: string, options?: {
125
+ signal?: AbortSignal;
126
+ }): Promise<PreparedTransaction>;
127
+ /** Export only after proving when the funding authorization binds an actual proof hash. */
128
+ exportFundingAuthorization(options?: {
129
+ signal?: AbortSignal;
130
+ }): Promise<_invisi_labs_core.SigningRequest>;
131
+ /** Verify an external signature against this handle's own frozen operation. */
132
+ withFundingSignature(signature: string, options?: {
133
+ signal?: AbortSignal;
134
+ }): Promise<PreparedTransaction>;
135
+ prove(options?: TransactionProveOptions): Promise<PreparedTransaction>;
136
+ prove(backend: Prover, options?: TransactionProveOptions): Promise<PreparedTransaction>;
137
+ private encode;
138
+ /** Shield caller funding needs no wallet signing or proof; this step only encodes its frozen request. */
139
+ ready(): Promise<PreparedTransaction>;
140
+ exportTransaction(): Promise<TransactionCall>;
141
+ exportProof(): ProofBundle;
142
+ exportAggregateMember(): OperationAggregateMember;
143
+ toJSON(): {
144
+ transaction: boolean;
145
+ id: string;
146
+ kind: "shield" | "transfer" | "create-credit" | "draw-credit" | "top-up-credit" | "cancel-credit";
147
+ status: OperationStatus;
148
+ };
149
+ }
150
+
151
+ interface NoteInput {
152
+ note: Note;
153
+ commitment: Hex;
154
+ treeId: bigint;
155
+ leafIndex: number;
156
+ }
157
+ interface CreditInput {
158
+ state: CreditDeliveryState;
159
+ commitment: Hex;
160
+ treeId: bigint;
161
+ leafIndex: number;
162
+ role: "owner" | "spender";
163
+ }
164
+ interface TransactionIdentity {
165
+ wallet: PublicWallet & {
166
+ getViewer?: never;
167
+ getDetector?: never;
168
+ exportAuthorization?: never;
169
+ };
170
+ protocol: Protocol;
171
+ }
172
+ interface ExplicitFunds {
173
+ inputs: readonly NoteInput[];
174
+ changeAddress?: string;
175
+ }
176
+ type ExplicitTransferPreparation = TransactionIdentity & TransferPreparation & ExplicitFunds;
177
+ type ExplicitShieldPreparation = TransactionIdentity & ShieldPreparation;
178
+ type ExplicitCreateCreditPreparation = TransactionIdentity & CreateCreditPreparation & ExplicitFunds;
179
+ type ExplicitDrawCreditPreparation = TransactionIdentity & DrawCreditPreparation & {
180
+ creditInputs: readonly CreditInput[];
181
+ };
182
+ type ExplicitTopUpCreditPreparation = TransactionIdentity & TopUpCreditPreparation & ExplicitFunds & {
183
+ creditInputs: readonly CreditInput[];
184
+ };
185
+ type ExplicitCancelCreditPreparation = TransactionIdentity & CancelCreditPreparation & {
186
+ creditInputs: readonly CreditInput[];
187
+ };
188
+
189
+ /** Compose independent Chain RPC and indexed Protocol RPC with local wallet capabilities. */
190
+ type InvisiOptions = Omit<TransactionInfrastructure, "wallet" | "protocol" | "coinSelector">;
191
+ /** Public wallet and registry-specific inputs; signing remains external. */
192
+ type RegistrationPreparationOptions = Pick<RegistrationPreparation, "update" | "deadline"> & Pick<TransactionIdentity, "wallet">;
193
+ /** Stateless transaction preparation and independent infrastructure composition. */
194
+ declare class Invisi {
195
+ #private;
196
+ constructor(options?: InvisiOptions);
197
+ /** A detached snapshot of shared infrastructure; wallet permissions and persistence stay external. */
198
+ getInfrastructure(): Readonly<InvisiOptions>;
199
+ private resolve;
200
+ /** Discover the selected chain's registry and prepare an independent signing request. */
201
+ prepareRegistration(options: RegistrationPreparationOptions): Promise<RegistrationOperation>;
202
+ private assertPublicIdentity;
203
+ private resolveExplicit;
204
+ prepareTransfer(options: ExplicitTransferPreparation): Promise<PreparedTransaction>;
205
+ prepareShield(options: ExplicitShieldPreparation): Promise<PreparedTransaction>;
206
+ prepareCreateCredit(options: ExplicitCreateCreditPreparation): Promise<PreparedTransaction>;
207
+ prepareDrawCredit(options: ExplicitDrawCreditPreparation): Promise<PreparedTransaction>;
208
+ prepareTopUpCredit(options: ExplicitTopUpCreditPreparation): Promise<PreparedTransaction>;
209
+ prepareCancelCredit(options: ExplicitCancelCreditPreparation): Promise<PreparedTransaction>;
210
+ toJSON(): {
211
+ invisi: boolean;
212
+ };
213
+ }
214
+
215
+ /** Stable codes returned by public SDK prepare* methods; inspect details instead of matching messages. */
216
+ type InvisiErrorCode =
217
+ /**
218
+ * Other preparation failure, such as invalid amounts, expired deadlines,
219
+ * or conflicting registration state. Inspect message and cause.
220
+ */
221
+ "PREPARATION_FAILED"
222
+ /**
223
+ * Required infrastructure or permissions were not supplied.
224
+ * The capability field identifies what is missing.
225
+ */
226
+ | "MISSING_CAPABILITY"
227
+ /**
228
+ * The recipient string is not a valid full 0i address or nonzero EVM owner address.
229
+ * No registration lookup is attempted for this invalid string.
230
+ */
231
+ | "INVALID_RECIPIENT"
232
+ /**
233
+ * A successful lookup found no receiving keys for this short 0x owner
234
+ * at the queried state. Indexed data may lag behind the latest chain state.
235
+ * Full 0i addresses contain receiving keys and do not require registration.
236
+ */
237
+ | "EVM_ADDRESS_NOT_REGISTERED"
238
+ /**
239
+ * Recipient lookup failed or returned invalid keys. Inspect cause.
240
+ * Registration status is unknown; this does not mean the owner is unregistered.
241
+ */
242
+ | "RECIPIENT_LOOKUP_FAILED";
243
+ interface InvisiErrorDetails {
244
+ operation?: string;
245
+ address?: string;
246
+ /** Zero-based index into the caller's outputs array, excluding automatic change. */
247
+ outputIndex?: number;
248
+ field?: string;
249
+ capability?: string;
250
+ cause?: unknown;
251
+ }
252
+ /** Stable application-facing preparation failure with the original cause. */
253
+ declare class InvisiError extends Error {
254
+ readonly code: InvisiErrorCode;
255
+ readonly operation: string | undefined;
256
+ readonly address: string | undefined;
257
+ readonly outputIndex: number | undefined;
258
+ readonly field: string | undefined;
259
+ readonly capability: string | undefined;
260
+ constructor(code: InvisiErrorCode, message: string, details?: InvisiErrorDetails);
261
+ }
262
+ /** Keep nested failures intact; do not infer business codes from English messages. */
263
+ declare function prepareWithErrors<T>(operation: string, prepare: () => Promise<T>): Promise<T>;
264
+
265
+ interface DiscoveryContext {
266
+ chainId: bigint;
267
+ protocolAddress: Address;
268
+ }
269
+ /** Decoded logs from complete canonical transaction receipts, including insertion logs. */
270
+ interface DeliveryEventLog {
271
+ address: string;
272
+ eventName: string;
273
+ args?: Record<string, unknown>;
274
+ blockNumber?: bigint | null;
275
+ blockHash?: Hex | null;
276
+ transactionHash?: Hex | null;
277
+ logIndex?: number | null;
278
+ removed?: boolean;
279
+ }
280
+ interface DeliveryCandidate {
281
+ tokenAddress: Address;
282
+ treeId: bigint;
283
+ leafIndex: number;
284
+ commitment: Hex;
285
+ role: "funds" | "owner" | "spender";
286
+ delivery: {
287
+ ciphertext: Hex;
288
+ clue: Hex;
289
+ };
290
+ blockNumber: bigint;
291
+ blockHash: Hex;
292
+ transactionHash: Hex;
293
+ }
294
+ /** Correlate deliveries with canonical insertion events, never service-supplied balances or positions.
295
+ * The caller selects a confirmed chain/deployment and supplies complete decoded receipts.
296
+ */
297
+ declare function extractDeliveryCandidates(logs: readonly DeliveryEventLog[], context: DiscoveryContext, confirmedThrough: bigint): DeliveryCandidate[];
298
+ interface DiscoveredNote extends Omit<DeliveryCandidate, "delivery" | "role"> {
299
+ note: Note;
300
+ }
301
+ interface DiscoveredCredit extends Omit<DeliveryCandidate, "delivery"> {
302
+ role: "owner" | "spender";
303
+ state: CreditDeliveryState;
304
+ }
305
+ /** Authenticate private deliveries from a single batch of canonical receipts. */
306
+ declare function decryptCandidates(logs: readonly DeliveryEventLog[], options: {
307
+ context: DiscoveryContext;
308
+ viewing: Pick<ViewingCapability, "ownerAddress" | "decryptNote" | "decryptCredit">;
309
+ confirmedThrough: bigint;
310
+ }): Promise<{
311
+ notes: DiscoveredNote[];
312
+ credits: DiscoveredCredit[];
313
+ }>;
314
+
315
+ /** Decode independently fetched canonical receipt bytes, never normalized service events. */
316
+ declare function readProtocolLogs(receipt: CanonicalReceipt, protocolAddress: Address): DeliveryEventLog[];
317
+
318
+ export { type CreditInput as C, type DeliveryEventLog as D, type ExplicitCancelCreditPreparation as E, Invisi as I, type NoteInput as N, PreparedTransaction as P, type RegistrationPreparationOptions as R, type TransactionIdentity as T, type DiscoveredCredit as a, type DiscoveredNote as b, type ExplicitCreateCreditPreparation as c, type ExplicitDrawCreditPreparation as d, type ExplicitShieldPreparation as e, type ExplicitTopUpCreditPreparation as f, type ExplicitTransferPreparation as g, InvisiError as h, type InvisiErrorCode as i, type InvisiErrorDetails as j, type InvisiOptions as k, TransactionOutput as l, decryptCandidates as m, defineGasBenchmarks as n, type DeliveryCandidate as o, type DiscoveryContext as p, copyGasBenchmarks as q, readProtocolLogs as r, extractDeliveryCandidates as s, prepareWithErrors as t };