@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
@@ -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.js';
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 };
@@ -0,0 +1,168 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+ var _chunkRHNIHI4Pcjs = require('./chunk-RHNIHI4P.cjs');
40
+
41
+
42
+
43
+ var _chunkLOU7AP2Bcjs = require('./chunk-LOU7AP2B.cjs');
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+ var _chunkJ2JH6HIGcjs = require('./chunk-J2JH6HIG.cjs');
59
+ require('./chunk-7F7ZZW3L.cjs');
60
+
61
+ // src/transactions/proving/aggregate-receipt.ts
62
+ var _ethers = require('ethers');
63
+ var _protocol = require('@invisi-labs/protocol');
64
+ var _contracts = require('@invisi-labs/protocol/contracts');
65
+ var aggregateAbi = _contracts.invisiProtocolAbi.filter(
66
+ (item) => item.type === "function" && item.name === "transact" && item.inputs.length === 2 && _optionalChain([item, 'access', _ => _.inputs, 'access', _2 => _2[1], 'optionalAccess', _3 => _3.type]) === "tuple[]"
67
+ );
68
+ function matchesAggregateTransaction(saved, transaction) {
69
+ const plan = saved.plan;
70
+ if (_optionalChain([plan, 'access', _4 => _4.statement, 'optionalAccess', _5 => _5.target]) !== "noir-recursive" || !plan.params || !saved.externalized || transaction.to.toLowerCase() !== plan.context.protocolAddress.toLowerCase() || transaction.value !== 0n)
71
+ return false;
72
+ try {
73
+ const decoded = new (0, _ethers.Interface)(aggregateAbi).parseTransaction({ data: transaction.data }), requests = decoded.args[1].map((request) => {
74
+ const member = request.toObject(true);
75
+ member.params.sources = request.params.sources.map(
76
+ (source) => source.toObject(true)
77
+ );
78
+ member.params.nullifiers = request.params.nullifiers.toArray(true);
79
+ member.params.outputCommitments = request.params.outputCommitments.toArray(true);
80
+ member.deliveries = request.deliveries.map(
81
+ (delivery) => delivery.toObject(true)
82
+ );
83
+ member.funding.permit.v = Number(member.funding.permit.v);
84
+ return {
85
+ params: member.params,
86
+ deliveries: member.deliveries,
87
+ funding: member.funding
88
+ };
89
+ });
90
+ if (decoded.name !== "transact" || !Array.isArray(requests) || ![4, 8, 12].includes(requests.length))
91
+ return false;
92
+ const canonical = (request) => _protocol.buildTransactCalldata.call(void 0, {
93
+ context: { ...plan.context, tokenAddress: request.params.token },
94
+ proof: "0x00",
95
+ params: request.params,
96
+ deliveries: request.deliveries,
97
+ funding: request.funding,
98
+ caller: transaction.from
99
+ }).data.toLowerCase();
100
+ const expected = _protocol.buildTransactCalldata.call(void 0, {
101
+ context: plan.context,
102
+ proof: "0x00",
103
+ params: plan.params,
104
+ deliveries: plan.outputs.map((output) => output.delivery),
105
+ funding: plan.funding,
106
+ caller: transaction.from
107
+ }).data.toLowerCase();
108
+ return requests.filter((request) => canonical(request) === expected).length === 1;
109
+ } catch (e) {
110
+ return false;
111
+ }
112
+ }
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+ exports.BroadcasterClient = _chunkRHNIHI4Pcjs.BroadcasterClient; exports.BroadcasterRpcError = _chunkRHNIHI4Pcjs.BroadcasterRpcError; exports.Invisi = _chunkRHNIHI4Pcjs.Invisi; exports.InvisiError = _chunkJ2JH6HIGcjs.InvisiError; exports.NoteOutput = _chunkJ2JH6HIGcjs.NoteOutput; exports.TransactionOutput = _chunkRHNIHI4Pcjs.TransactionOutput; exports.TransactionPreparation = _chunkJ2JH6HIGcjs.TransactionPreparation; exports.acceptFundingSignature = _chunkRHNIHI4Pcjs.acceptFundingSignature; exports.acceptWalletSignature = _chunkRHNIHI4Pcjs.acceptWalletSignature; exports.authorizationRequest = _chunkJ2JH6HIGcjs.authorizationRequest; exports.authorizeOperation = _chunkRHNIHI4Pcjs.authorizeOperation; exports.broadcasterQuoteDomain = _chunkRHNIHI4Pcjs.broadcasterQuoteDomain; exports.broadcasterQuoteTypes = _chunkRHNIHI4Pcjs.broadcasterQuoteTypes; exports.broadcasterRequestHash = _chunkRHNIHI4Pcjs.broadcasterRequestHash; exports.broadcasterTransactInterface = _chunkRHNIHI4Pcjs.broadcasterTransactInterface; exports.configureRecipientInfrastructure = _chunkJ2JH6HIGcjs.configureRecipientInfrastructure; exports.configureTransactionInfrastructure = _chunkRHNIHI4Pcjs.configureTransactionInfrastructure; exports.copyGasBenchmarks = _chunkRHNIHI4Pcjs.copyGasBenchmarks; exports.creditLeaf = _chunkJ2JH6HIGcjs.creditLeaf; exports.creditReservationKey = _chunkRHNIHI4Pcjs.creditReservationKey; exports.decodeBroadcasterIntent = _chunkRHNIHI4Pcjs.decodeBroadcasterIntent; exports.decodeProtocolEvent = _chunkRHNIHI4Pcjs.decodeProtocolEvent; exports.decryptCandidates = _chunkRHNIHI4Pcjs.decryptCandidates; exports.defineGasBenchmarks = _chunkRHNIHI4Pcjs.defineGasBenchmarks; exports.encodeOperation = _chunkRHNIHI4Pcjs.encodeOperation; exports.estimateBenchmarkGas = _chunkRHNIHI4Pcjs.estimateBenchmarkGas; exports.estimateGasReference = _chunkRHNIHI4Pcjs.estimateGasReference; exports.estimateShapeGas = _chunkRHNIHI4Pcjs.estimateShapeGas; exports.exportBroadcasterIntent = _chunkJ2JH6HIGcjs.exportBroadcasterIntent; exports.extractDeliveryCandidates = _chunkRHNIHI4Pcjs.extractDeliveryCandidates; exports.fundingSigningRequest = _chunkRHNIHI4Pcjs.fundingSigningRequest; exports.fundingTypedData = _chunkRHNIHI4Pcjs.fundingTypedData; exports.inputFacts = _chunkRHNIHI4Pcjs.inputFacts; exports.matchesAggregateTransaction = matchesAggregateTransaction; exports.operationExpired = _chunkJ2JH6HIGcjs.operationExpired; exports.operationPreview = _chunkRHNIHI4Pcjs.operationPreview; exports.operationSources = _chunkRHNIHI4Pcjs.operationSources; exports.prepareBroadcasterPlan = _chunkLOU7AP2Bcjs.prepareBroadcasterPlan; exports.prepareIntent = _chunkLOU7AP2Bcjs.prepareIntent; exports.prepareWithErrors = _chunkJ2JH6HIGcjs.prepareWithErrors; exports.proveOperation = _chunkRHNIHI4Pcjs.proveOperation; exports.publicProof = _chunkRHNIHI4Pcjs.publicProof; exports.readProtocolLogs = _chunkRHNIHI4Pcjs.readProtocolLogs; exports.recipientLookup = _chunkJ2JH6HIGcjs.recipientLookup; exports.requiresAuthorization = _chunkJ2JH6HIGcjs.requiresAuthorization; exports.sameStatement = _chunkRHNIHI4Pcjs.sameStatement; exports.signOperationFunding = _chunkRHNIHI4Pcjs.signOperationFunding; exports.statement = _chunkJ2JH6HIGcjs.statement; exports.validateTransactionInfrastructure = _chunkRHNIHI4Pcjs.validateTransactionInfrastructure; exports.verifyBroadcasterQuote = _chunkRHNIHI4Pcjs.verifyBroadcasterQuote; exports.verifyMembership = _chunkJ2JH6HIGcjs.verifyMembership; exports.walletSigningRequest = _chunkRHNIHI4Pcjs.walletSigningRequest; exports.witnessFor = _chunkRHNIHI4Pcjs.witnessFor;
168
+ //# sourceMappingURL=session-support.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/invisi-sdk-ts/invisi-sdk-ts/packages/sdk/dist/session-support.cjs","../src/transactions/proving/aggregate-receipt.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACA;AC3DA,gCAAuC;AAEvC,iDAA4D;AAC5D,4DAAwD;AAExD,IAAM,aAAA,EAAe,4BAAA,CAAkB,MAAA;AAAA,EACnC,CAAC,IAAA,EAAA,GACG,IAAA,CAAK,KAAA,IAAS,WAAA,GACd,IAAA,CAAK,KAAA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AAA,MACP,MAAA,EAAQ,IAAA,CAAK,MAAA;AAAA,MACb,UAAA,EAAY,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,CAAC,MAAA,EAAA,GAAW,MAAA,CAAO,QAAQ,CAAA;AAAA,MACxD,OAAA,EAAS,IAAA,CAAK,OAAA;AAAA,MACd,MAAA,EAAQ,WAAA,CAAY;AAAA,IACxB,CAAC,CAAA,CAAE,IAAA,CAAK,WAAA,CAAY,CAAA;AACpB,IAAA,OAAO,QAAA,CAAS,MAAA,CAAO,CAAC,OAAA,EAAA,GAAY,SAAA,CAAU,OAAO,EAAA,IAAM,QAAQ,CAAA,CAAE,OAAA,IAAW,CAAA;AAAA,EACpF,EAAA,UAAQ;AACJ,IAAA,OAAO,KAAA;AAAA,EACX;AACJ;ADuCA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,ggHAAC","file":"/home/runner/work/invisi-sdk-ts/invisi-sdk-ts/packages/sdk/dist/session-support.cjs","sourcesContent":[null,"import type { Address } from \"@invisi-labs/protocol/contracts\";\nimport { Interface, type Result } from \"ethers\";\n\nimport { buildTransactCalldata, type TransactionCall } from \"@invisi-labs/protocol\";\nimport { invisiProtocolAbi, type TransactRequest } from \"@invisi-labs/protocol/contracts\";\nimport type { SavedOperation } from \"../operation-types\";\nconst aggregateAbi = invisiProtocolAbi.filter(\n (item) =>\n item.type === \"function\" &&\n item.name === \"transact\" &&\n item.inputs.length === 2 &&\n item.inputs[1]?.type === \"tuple[]\"\n);\n/** Match the whole frozen member, including funding nonce, signature and permit, in one successful aggregate. */\nexport function matchesAggregateTransaction(\n saved: SavedOperation,\n transaction: TransactionCall & { from: Address }\n): boolean {\n const plan = saved.plan;\n if (\n plan.statement?.target !== \"noir-recursive\" ||\n !plan.params ||\n !saved.externalized ||\n transaction.to.toLowerCase() !== plan.context.protocolAddress.toLowerCase() ||\n transaction.value !== 0n\n )\n return false;\n try {\n const decoded = new Interface(aggregateAbi).parseTransaction({ data: transaction.data })!,\n requests = (decoded.args[1] as Result[]).map((request) => {\n const member = request.toObject(true);\n member.params.sources = request.params.sources.map((source: Result) =>\n source.toObject(true)\n );\n member.params.nullifiers = request.params.nullifiers.toArray(true);\n member.params.outputCommitments = request.params.outputCommitments.toArray(true);\n member.deliveries = request.deliveries.map((delivery: Result) =>\n delivery.toObject(true)\n );\n member.funding.permit.v = Number(member.funding.permit.v);\n return {\n params: member.params,\n deliveries: member.deliveries,\n funding: member.funding,\n };\n }) as readonly TransactRequest[];\n if (\n decoded.name !== \"transact\" ||\n !Array.isArray(requests) ||\n ![4, 8, 12].includes(requests.length)\n )\n return false;\n const canonical = (request: TransactRequest) =>\n buildTransactCalldata({\n context: { ...plan.context, tokenAddress: request.params.token },\n proof: \"0x00\",\n params: request.params,\n deliveries: request.deliveries,\n funding: request.funding,\n caller: transaction.from,\n }).data.toLowerCase();\n const expected = buildTransactCalldata({\n context: plan.context,\n proof: \"0x00\",\n params: plan.params,\n deliveries: plan.outputs.map((output) => output.delivery),\n funding: plan.funding,\n caller: transaction.from,\n }).data.toLowerCase();\n return requests.filter((request) => canonical(request) === expected).length === 1;\n } catch {\n return false;\n }\n}\n"]}