@toon-protocol/client 2.2.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-A3JKQOWQ.js → chunk-GDWZ736I.js} +93 -101
- package/dist/chunk-GDWZ736I.js.map +1 -0
- package/dist/cli/main.js +1 -1
- package/dist/{client-VA4727SQ.js → client-TEP26FMO.js} +2 -2
- package/dist/index.d.ts +135 -125
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-A3JKQOWQ.js.map +0 -1
- /package/dist/{client-VA4727SQ.js.map → client-TEP26FMO.js.map} +0 -0
package/dist/cli/main.js
CHANGED
|
@@ -542,7 +542,7 @@ function buildClientConfig(settings, keys) {
|
|
|
542
542
|
};
|
|
543
543
|
}
|
|
544
544
|
async function defaultCreateClient(config) {
|
|
545
|
-
const module = await import("../client-
|
|
545
|
+
const module = await import("../client-TEP26FMO.js");
|
|
546
546
|
const factory = module.ToonClient;
|
|
547
547
|
if (factory === void 0) {
|
|
548
548
|
throw new Error(
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
send,
|
|
31
31
|
settlementToTerms,
|
|
32
32
|
toEnvelopeRequest
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-GDWZ736I.js";
|
|
34
34
|
import "./chunk-7MPONJW5.js";
|
|
35
35
|
import "./chunk-32MD3CXE.js";
|
|
36
36
|
export {
|
|
@@ -66,4 +66,4 @@ export {
|
|
|
66
66
|
settlementToTerms,
|
|
67
67
|
toEnvelopeRequest
|
|
68
68
|
};
|
|
69
|
-
//# sourceMappingURL=client-
|
|
69
|
+
//# sourceMappingURL=client-TEP26FMO.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -237,16 +237,30 @@ interface ILPPreparePacket {
|
|
|
237
237
|
type: typeof ILPPacketType.PREPARE;
|
|
238
238
|
amount: bigint;
|
|
239
239
|
destination: string;
|
|
240
|
-
|
|
240
|
+
/**
|
|
241
|
+
* Whether this PREPARE declares itself a bootstrap/greeting probe rather
|
|
242
|
+
* than a real payment attempt (connector ADR 0069, issue #1269). One byte
|
|
243
|
+
* on the wire, where a 32-byte `executionCondition` used to sit.
|
|
244
|
+
*
|
|
245
|
+
* The connector's client edge consults it only when no claim rides with
|
|
246
|
+
* the packet: an unclaimed `greeting` PREPARE is never routed, never
|
|
247
|
+
* priced and never fulfilled — it is answered with the x402 terms instead
|
|
248
|
+
* (`client-edge-spec.md` §1.4). A claim header suppresses the greeting
|
|
249
|
+
* unconditionally, so setting this on a paid packet cannot make it free.
|
|
250
|
+
*/
|
|
251
|
+
greeting: boolean;
|
|
241
252
|
expiresAt: Date;
|
|
242
253
|
data: Uint8Array;
|
|
243
254
|
}
|
|
244
255
|
interface ILPFulfillPacket {
|
|
245
256
|
type: typeof ILPPacketType.FULFILL;
|
|
246
257
|
/**
|
|
247
|
-
* The 32-byte fulfillment preimage from the wire
|
|
248
|
-
*
|
|
249
|
-
* the
|
|
258
|
+
* The 32-byte fulfillment preimage from the wire — the one thing ADR 0069
|
|
259
|
+
* left in the return direction untouched. A termination derives it from
|
|
260
|
+
* the shared secret sealed inside the request (ADR 0019), so a sender that
|
|
261
|
+
* kept that secret checks a delivery end to end by comparing these bytes
|
|
262
|
+
* against its own `deriveFulfillment(sharedSecret)`. There is no condition
|
|
263
|
+
* on the wire to check it against any more.
|
|
250
264
|
*/
|
|
251
265
|
fulfillment: Uint8Array;
|
|
252
266
|
data: Uint8Array;
|
|
@@ -260,6 +274,12 @@ interface ILPRejectPacket {
|
|
|
260
274
|
data: Uint8Array;
|
|
261
275
|
}
|
|
262
276
|
type ILPResponsePacket = ILPFulfillPacket | ILPRejectPacket;
|
|
277
|
+
/**
|
|
278
|
+
* Encode a PREPARE. The `greeting` flag is a single `0x00`/`0x01` octet
|
|
279
|
+
* between `expiresAt` and `destination` — `connector-domain::Prepare::encode`
|
|
280
|
+
* writes `u8::from(self.greeting)` there, and writes nothing else in its
|
|
281
|
+
* place (connector ADR 0069).
|
|
282
|
+
*/
|
|
263
283
|
declare function serializeIlpPrepare(packet: ILPPreparePacket): Uint8Array;
|
|
264
284
|
/**
|
|
265
285
|
* Decode an inbound PREPARE — the server-role mirror of {@link serializeIlpPrepare}
|
|
@@ -300,27 +320,28 @@ declare function serializeBtpMessage(message: BTPMessage): Uint8Array;
|
|
|
300
320
|
declare function parseBtpMessage(buf: Uint8Array): BTPMessage;
|
|
301
321
|
|
|
302
322
|
/**
|
|
303
|
-
* Shared sender-side plumbing for
|
|
304
|
-
*
|
|
305
|
-
*
|
|
323
|
+
* Shared sender-side plumbing for both ILP carriages: how a PREPARE's
|
|
324
|
+
* non-routing fields are resolved, and how the answer is read.
|
|
325
|
+
*
|
|
326
|
+
* Connector ADR 0069 (issue #1269) removed the execution condition from the
|
|
327
|
+
* wire. Two things changed here and nothing else did:
|
|
306
328
|
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
329
|
+
* - the PREPARE carries a one-byte `greeting` flag where a 32-byte
|
|
330
|
+
* condition used to sit — see {@link IlpSendParams.greeting};
|
|
331
|
+
* - the sender's delivery check compares a FULFILL's preimage directly
|
|
332
|
+
* against the fulfilment its own sealed secret derives
|
|
333
|
+
* ({@link IlpSendParams.expectedFulfillment}), rather than hashing it back
|
|
334
|
+
* to a condition that no longer exists.
|
|
310
335
|
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
* FAILED result (never a silent accept, never retried).
|
|
336
|
+
* Both transports (HTTP `POST /ilp` and BTP) take the SAME params and map
|
|
337
|
+
* FULFILL/REJECT through the SAME verifier, so the two paths cannot drift.
|
|
338
|
+
* Omitting `expectedFulfillment` keeps a FULFILL unverified — the right shape
|
|
339
|
+
* for a caller that never sealed anything and so has nothing to compare
|
|
340
|
+
* against.
|
|
317
341
|
*/
|
|
318
342
|
|
|
319
343
|
/**
|
|
320
|
-
* Send parameters accepted by both ILP transports.
|
|
321
|
-
* `@toon-protocol/core` `IlpClient` param shape with the sender-chosen
|
|
322
|
-
* condition and an explicit expiry — plain `IlpClient` callers keep working
|
|
323
|
-
* unchanged (both extras are optional; omitting them is the legacy path).
|
|
344
|
+
* Send parameters accepted by both ILP transports.
|
|
324
345
|
*/
|
|
325
346
|
interface IlpSendParams {
|
|
326
347
|
destination: string;
|
|
@@ -330,40 +351,48 @@ interface IlpSendParams {
|
|
|
330
351
|
/** Transport timeout in ms; also the default expiry window. */
|
|
331
352
|
timeout?: number;
|
|
332
353
|
/**
|
|
333
|
-
*
|
|
334
|
-
* Absent or all-zero = legacy unverified packet (default — ordinary
|
|
335
|
-
* publish/upload writes MUST keep this default).
|
|
354
|
+
* Declare this PREPARE a bootstrap/greeting probe (connector ADR 0069).
|
|
336
355
|
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
|
|
344
|
-
|
|
356
|
+
* Defaults to `false`, which is what every real send wants: a greeting is
|
|
357
|
+
* never routed, never priced and never fulfilled — the connector answers
|
|
358
|
+
* the x402 terms instead. Set it only to ASK for those terms without a
|
|
359
|
+
* route match, the shape `ConnectorEdgeClient` uses for bootstrap. A claim
|
|
360
|
+
* riding with the packet suppresses the greeting either way, so this can
|
|
361
|
+
* never turn a paid packet into a free one.
|
|
362
|
+
*/
|
|
363
|
+
greeting?: boolean;
|
|
364
|
+
/**
|
|
365
|
+
* The 32 bytes an honest FULFILL must carry: `deriveFulfillment(sharedSecret)`
|
|
366
|
+
* for the secret sealed inside this packet's gift wrap (ADR 0019), which
|
|
367
|
+
* `sealExchange` returns as `SealedExchange.fulfillment`.
|
|
368
|
+
*
|
|
369
|
+
* Present = verify; absent = accept a FULFILL unchecked, which is the only
|
|
370
|
+
* honest option for a caller that sealed nothing and therefore knows no
|
|
371
|
+
* secret. This is the sender's own end-to-end check and the ONLY fulfilment
|
|
372
|
+
* check left anywhere on the path (ADR 0069) — no hop performs one.
|
|
373
|
+
*
|
|
374
|
+
* Accepts the raw 32 bytes or their base64 encoding; normalize with
|
|
375
|
+
* {@link resolveExpectedFulfillment} before touching the bytes.
|
|
345
376
|
*/
|
|
346
|
-
|
|
377
|
+
expectedFulfillment?: Uint8Array | string;
|
|
347
378
|
/**
|
|
348
|
-
* Explicit PREPARE `expiresAt
|
|
349
|
-
*
|
|
350
|
-
* `@toon-protocol/core` ≥2.1.0's `IlpClient` passes the string form.
|
|
379
|
+
* Explicit PREPARE `expiresAt`. Defaults to `now + timeout` plus
|
|
380
|
+
* {@link PACKET_EXPIRY_HEADROOM_MS}. Accepts a `Date` or an ISO 8601 string.
|
|
351
381
|
*/
|
|
352
382
|
expiresAt?: Date | string;
|
|
353
383
|
}
|
|
354
384
|
/**
|
|
355
|
-
* Normalize an `IlpSendParams.
|
|
385
|
+
* Normalize an `IlpSendParams.expectedFulfillment` to raw bytes.
|
|
356
386
|
*
|
|
357
387
|
* The two representations are the two callers: this package's own senders
|
|
358
|
-
* pass the bytes
|
|
359
|
-
*
|
|
360
|
-
* string that port declares. Both mean the same 32 bytes.
|
|
388
|
+
* pass the bytes `sealExchange` derived, while a caller typed against the
|
|
389
|
+
* JSON-shaped port passes their base64 spelling. Both mean the same 32 bytes.
|
|
361
390
|
*
|
|
362
|
-
* Length is NOT validated here — that stays with `
|
|
363
|
-
* the transports, so a malformed
|
|
364
|
-
*
|
|
391
|
+
* Length is NOT validated here — that stays with `assertValidFulfillment` at
|
|
392
|
+
* the transports, so a malformed value fails with the same message on both
|
|
393
|
+
* paths regardless of which representation it arrived in.
|
|
365
394
|
*/
|
|
366
|
-
declare function
|
|
395
|
+
declare function resolveExpectedFulfillment(fulfillment: Uint8Array | string | undefined): Uint8Array | undefined;
|
|
367
396
|
/**
|
|
368
397
|
* How much longer a packet lives on the wire than the sender is prepared to wait.
|
|
369
398
|
*
|
|
@@ -392,12 +421,11 @@ declare const PACKET_EXPIRY_HEADROOM_MS = 15000;
|
|
|
392
421
|
*/
|
|
393
422
|
declare function resolveExpiresAt(expiresAt: Date | string | undefined, timeoutMs: number): Date;
|
|
394
423
|
/**
|
|
395
|
-
* `IlpSendResult` plus the FULFILL preimage when
|
|
396
|
-
*
|
|
397
|
-
* objects stay byte-identical.
|
|
424
|
+
* `IlpSendResult` plus the FULFILL preimage, populated only when the sender
|
|
425
|
+
* knew what to expect and the bytes matched.
|
|
398
426
|
*/
|
|
399
427
|
interface IlpSendResultWithFulfillment extends IlpSendResult {
|
|
400
|
-
/** Base64 32-byte fulfillment preimage (verified
|
|
428
|
+
/** Base64 32-byte fulfillment preimage (verified against the expected one). */
|
|
401
429
|
fulfillment?: string;
|
|
402
430
|
}
|
|
403
431
|
/** ILP code used for a client-side fulfillment-verification failure. */
|
|
@@ -406,16 +434,20 @@ declare const FULFILLMENT_MISMATCH_CODE = "F99";
|
|
|
406
434
|
declare const FULFILLMENT_MISMATCH_MESSAGE: string;
|
|
407
435
|
/**
|
|
408
436
|
* Map a parsed ILP response packet to an `IlpSendResult`, enforcing the
|
|
409
|
-
* sender-
|
|
437
|
+
* sender's end-to-end delivery check when it knows what to expect.
|
|
438
|
+
*
|
|
439
|
+
* Verification is fail-closed: when `expectedFulfillment` is given, a FULFILL
|
|
440
|
+
* whose preimage is absent, not exactly 32 bytes, or simply different yields
|
|
441
|
+
* `accepted: false` (code F99). The result shape — not a thrown error — is
|
|
442
|
+
* deliberate: transports only retry thrown `NetworkError`s, so a forged or
|
|
443
|
+
* wrong FULFILL is never retried, because re-sending would re-spend the
|
|
444
|
+
* attached claim.
|
|
410
445
|
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
* not a thrown error — is deliberate: transports only retry thrown
|
|
415
|
-
* `NetworkError`s, so a forged/wrong FULFILL is never retried — re-sending
|
|
416
|
-
* would re-spend the attached claim.
|
|
446
|
+
* Since ADR 0069 this is the only fulfilment check anywhere on the path. A
|
|
447
|
+
* candidate FULFILL rides home through every hop unexamined, which is exactly
|
|
448
|
+
* why the sender must still make it.
|
|
417
449
|
*/
|
|
418
|
-
declare function mapIlpResponse(packet: ILPResponsePacket,
|
|
450
|
+
declare function mapIlpResponse(packet: ILPResponsePacket, expectedFulfillment?: Uint8Array): IlpSendResultWithFulfillment;
|
|
419
451
|
|
|
420
452
|
/**
|
|
421
453
|
* The ILP transport port: what a carriage must be able to do, and what it
|
|
@@ -4304,19 +4336,18 @@ declare class BtpRuntimeClient implements IlpClient {
|
|
|
4304
4336
|
* Sends an ILP packet via BTP with auto-reconnect on connection errors.
|
|
4305
4337
|
* Satisfies IlpClient interface.
|
|
4306
4338
|
*
|
|
4307
|
-
* `params` may carry
|
|
4308
|
-
* `
|
|
4309
|
-
*
|
|
4310
|
-
*
|
|
4311
|
-
* as a failed result — see `mapIlpResponse`.
|
|
4339
|
+
* `params` may carry an `expectedFulfillment` (the sender's end-to-end
|
|
4340
|
+
* check, ADR 0069), a `greeting` flag and an explicit `expiresAt`. With an
|
|
4341
|
+
* expected fulfilment the FULFILL preimage is compared against it and a
|
|
4342
|
+
* mismatch is surfaced as a failed result — see `mapIlpResponse`.
|
|
4312
4343
|
*/
|
|
4313
4344
|
sendIlpPacket(params: IlpSendParams): Promise<IlpSendResult>;
|
|
4314
4345
|
/**
|
|
4315
4346
|
* Sends a balance proof claim via BTP protocol data, then sends an ILP packet.
|
|
4316
4347
|
* Auto-reconnects on connection errors.
|
|
4317
4348
|
*
|
|
4318
|
-
*
|
|
4319
|
-
*
|
|
4349
|
+
* `expectedFulfillment` / `greeting` / `expiresAt` semantics are identical
|
|
4350
|
+
* to {@link sendIlpPacket}.
|
|
4320
4351
|
*/
|
|
4321
4352
|
sendIlpPacketWithClaim(params: IlpSendParams, claim: Record<string, unknown>): Promise<IlpSendResult>;
|
|
4322
4353
|
/**
|
|
@@ -4328,11 +4359,11 @@ declare class BtpRuntimeClient implements IlpClient {
|
|
|
4328
4359
|
sendClaimMessage(claim: Record<string, unknown>): Promise<void>;
|
|
4329
4360
|
private _sendClaimMessageOnce;
|
|
4330
4361
|
/**
|
|
4331
|
-
* Build the ILP PREPARE for a send, applying the
|
|
4332
|
-
* explicit expiry when provided
|
|
4333
|
-
*
|
|
4334
|
-
*
|
|
4335
|
-
*
|
|
4362
|
+
* Build the ILP PREPARE for a send, applying the
|
|
4363
|
+
* explicit expiry when provided, carrying the `greeting` flag ADR 0069 put
|
|
4364
|
+
* where the execution condition used to be, and validating that an expected
|
|
4365
|
+
* fulfilment is exactly 32 bytes (a wrong-length one could never match a
|
|
4366
|
+
* real FULFILL, so every delivery would be counted failed).
|
|
4336
4367
|
*/
|
|
4337
4368
|
private buildPrepare;
|
|
4338
4369
|
/**
|
|
@@ -4477,11 +4508,10 @@ declare class HttpIlpClient implements IlpClient {
|
|
|
4477
4508
|
* this only on free/zero-amount routes; paid writes must use
|
|
4478
4509
|
* {@link sendIlpPacketWithClaim}. Satisfies the IlpClient interface.
|
|
4479
4510
|
*
|
|
4480
|
-
* `params` may carry
|
|
4481
|
-
* `
|
|
4482
|
-
*
|
|
4483
|
-
*
|
|
4484
|
-
* as a failed result — see {@link mapIlpResponse}.
|
|
4511
|
+
* `params` may carry an `expectedFulfillment` (the sender's end-to-end
|
|
4512
|
+
* check, ADR 0069), a `greeting` flag and an explicit `expiresAt`. With an
|
|
4513
|
+
* expected fulfilment the FULFILL preimage is compared against it and a
|
|
4514
|
+
* mismatch is surfaced as a failed result — see {@link mapIlpResponse}.
|
|
4485
4515
|
*/
|
|
4486
4516
|
sendIlpPacket(params: IlpSendParams): Promise<IlpSendResult>;
|
|
4487
4517
|
/**
|
|
@@ -4490,8 +4520,8 @@ declare class HttpIlpClient implements IlpClient {
|
|
|
4490
4520
|
* the BTP path attaches as the `payment-channel-claim` protocolData entry —
|
|
4491
4521
|
* we base64(JSON.stringify(claim)) it, byte-for-byte identical to BTP.
|
|
4492
4522
|
*
|
|
4493
|
-
*
|
|
4494
|
-
*
|
|
4523
|
+
* `expectedFulfillment` / `greeting` / `expiresAt` semantics are identical
|
|
4524
|
+
* to {@link sendIlpPacket}.
|
|
4495
4525
|
*/
|
|
4496
4526
|
sendIlpPacketWithClaim(params: IlpSendParams, claim: unknown): Promise<IlpSendResult>;
|
|
4497
4527
|
/**
|
|
@@ -4546,9 +4576,9 @@ declare class HttpIlpClient implements IlpClient {
|
|
|
4546
4576
|
* to a transport error. Per the wire contract, ILP-level rejects arrive as a
|
|
4547
4577
|
* 200 + REJECT body — only HTTP non-2xx means a transport-layer failure.
|
|
4548
4578
|
*
|
|
4549
|
-
* When `
|
|
4550
|
-
* it; a mismatch yields `accepted: false` (shared `mapIlpResponse`
|
|
4551
|
-
* identical to the BTP path).
|
|
4579
|
+
* When `expectedFulfillment` is given the FULFILL preimage is compared
|
|
4580
|
+
* against it; a mismatch yields `accepted: false` (shared `mapIlpResponse`
|
|
4581
|
+
* logic, identical to the BTP path).
|
|
4552
4582
|
*/
|
|
4553
4583
|
private mapResponse;
|
|
4554
4584
|
private mapTransportError;
|
|
@@ -4880,12 +4910,13 @@ declare function decodeVarOctetString(buf: Uint8Array, offset: number): Decoded<
|
|
|
4880
4910
|
* - **Response framing.** `0x02 ‖ nonce(12) ‖ ciphertext`, the plaintext being
|
|
4881
4911
|
* just the encoded envelope. Sealed directly with the request's shared
|
|
4882
4912
|
* secret.
|
|
4883
|
-
* - **Fulfilment
|
|
4884
|
-
* "toon-giftwrap-fulfillment")
|
|
4885
|
-
*
|
|
4886
|
-
*
|
|
4887
|
-
*
|
|
4888
|
-
*
|
|
4913
|
+
* - **Fulfilment.** `fulfilment = HKDF-SHA256(shared_secret,
|
|
4914
|
+
* "toon-giftwrap-fulfillment")`. The terminating connector recovers the
|
|
4915
|
+
* secret by opening the wrap and derives the preimage without asking the
|
|
4916
|
+
* app anything; the sender, which drew that secret, derives the same bytes
|
|
4917
|
+
* and so can check a delivery end to end. Nothing is minted onto the
|
|
4918
|
+
* PREPARE from it — connector ADR 0069 took the execution condition off the
|
|
4919
|
+
* wire entirely.
|
|
4889
4920
|
* - **Telling a sealed reject from a plaintext one.** The leading type byte,
|
|
4890
4921
|
* and only that (`looks_like_sealed_response`). A reject raised short of the
|
|
4891
4922
|
* termination shares no secret with the sender and carries empty `data`; an
|
|
@@ -5019,11 +5050,11 @@ declare function sealRequestWithRandomness(plaintext: Uint8Array, receiverPublic
|
|
|
5019
5050
|
* so no two sealed requests — even to the same receiver, even with the same
|
|
5020
5051
|
* plaintext — share any of the three.
|
|
5021
5052
|
*
|
|
5022
|
-
* Returns the wire bytes and the shared secret.
|
|
5023
|
-
*
|
|
5024
|
-
*
|
|
5025
|
-
*
|
|
5026
|
-
*
|
|
5053
|
+
* Returns the wire bytes and the shared secret. Keep that secret: the
|
|
5054
|
+
* terminating connector recovers the same one by opening this wrap, so
|
|
5055
|
+
* {@link deriveFulfillment} of it is the preimage an honest FULFILL will
|
|
5056
|
+
* carry — the sender's only way to check a delivery end to end now that no
|
|
5057
|
+
* condition rides on the wire (connector ADR 0069).
|
|
5027
5058
|
*/
|
|
5028
5059
|
declare function sealRequest(plaintext: Uint8Array, receiverPublicKey: Uint8Array): SealedRequest;
|
|
5029
5060
|
/**
|
|
@@ -5074,22 +5105,6 @@ declare function looksLikeSealedResponse(bytes: Uint8Array): boolean;
|
|
|
5074
5105
|
* secret also derives, so it can never collide with either.
|
|
5075
5106
|
*/
|
|
5076
5107
|
declare function deriveFulfillment(sharedSecret: Uint8Array): Uint8Array;
|
|
5077
|
-
/**
|
|
5078
|
-
* The condition a `fulfillment` satisfies: `sha256(fulfillment)` —
|
|
5079
|
-
* `connector_domain::condition::derive_condition`. Hashing only ever runs in
|
|
5080
|
-
* this direction; there is deliberately no function here that goes from a
|
|
5081
|
-
* condition back to a fulfilment.
|
|
5082
|
-
*
|
|
5083
|
-
* The hash is the same one `utils/condition.ts` already uses; what ADR 0019
|
|
5084
|
-
* changes is where the preimage comes from. `mintExecutionCondition` there
|
|
5085
|
-
* draws a random preimage the sender must then carry to the FULFILL itself;
|
|
5086
|
-
* here the preimage is DERIVED from the secret sealed inside the packet, so
|
|
5087
|
-
* the terminating connector can produce it without the sender or the app
|
|
5088
|
-
* handing it over. Checking a returned fulfilment against a condition is
|
|
5089
|
-
* unchanged either way — use `fulfillmentMatchesCondition` from
|
|
5090
|
-
* `utils/condition.ts` for that rather than a second copy of it here.
|
|
5091
|
-
*/
|
|
5092
|
-
declare function deriveCondition(fulfillment: Uint8Array): Uint8Array;
|
|
5093
5108
|
|
|
5094
5109
|
/**
|
|
5095
5110
|
* One sealed request/answer exchange with a terminating connector (ADR 0018,
|
|
@@ -5101,11 +5116,11 @@ declare function deriveCondition(fulfillment: Uint8Array): Uint8Array;
|
|
|
5101
5116
|
*
|
|
5102
5117
|
* - The `data` is a gift wrap addressed to the connector that TERMINATES the
|
|
5103
5118
|
* route, around an OER envelope — never HTTP text, never a bare payload.
|
|
5104
|
-
* - The
|
|
5105
|
-
*
|
|
5106
|
-
*
|
|
5107
|
-
*
|
|
5108
|
-
* path
|
|
5119
|
+
* - The fulfilment an honest answer carries is DERIVED from the very secret
|
|
5120
|
+
* that wrap carries (ADR 0019). Since ADR 0069 took the execution condition
|
|
5121
|
+
* off the wire, comparing a returned preimage against that derivation is
|
|
5122
|
+
* the sender's only delivery check — and the only one made anywhere on the
|
|
5123
|
+
* path, since no hop verifies a FULFILL any more.
|
|
5109
5124
|
* - The answer is sealed with that same secret, so opening it requires having
|
|
5110
5125
|
* kept it from the seal.
|
|
5111
5126
|
*
|
|
@@ -5133,23 +5148,16 @@ declare function deriveCondition(fulfillment: Uint8Array): Uint8Array;
|
|
|
5133
5148
|
*/
|
|
5134
5149
|
|
|
5135
5150
|
/**
|
|
5136
|
-
* A sealed request, ready to become a PREPARE: what goes in `data`,
|
|
5137
|
-
*
|
|
5151
|
+
* A sealed request, ready to become a PREPARE: what goes in `data`, the secret
|
|
5152
|
+
* needed to read the answer, and the fulfilment that answer must carry.
|
|
5138
5153
|
*
|
|
5139
|
-
* The three are produced together and belong together
|
|
5140
|
-
*
|
|
5141
|
-
*
|
|
5154
|
+
* The three are produced together and belong together: opening the answer with
|
|
5155
|
+
* any other secret fails, and checking a FULFILL against any other fulfilment
|
|
5156
|
+
* rejects a delivery that was genuine.
|
|
5142
5157
|
*/
|
|
5143
5158
|
interface SealedExchange {
|
|
5144
5159
|
/** The gift wrap to carry as the PREPARE's `data`. */
|
|
5145
5160
|
readonly data: Uint8Array;
|
|
5146
|
-
/**
|
|
5147
|
-
* The PREPARE's `executionCondition`: `sha256(deriveFulfillment(secret))`.
|
|
5148
|
-
* Derived, never random and never caller-supplied — the terminating
|
|
5149
|
-
* connector recovers the same secret and derives the same fulfilment
|
|
5150
|
-
* without the app participating (ADR 0019).
|
|
5151
|
-
*/
|
|
5152
|
-
readonly condition: Uint8Array;
|
|
5153
5161
|
/**
|
|
5154
5162
|
* The 32-byte secret sealed inside the wrap. Keep it until the answer is
|
|
5155
5163
|
* read; it is the only thing that opens the response. Never send it
|
|
@@ -5157,9 +5165,11 @@ interface SealedExchange {
|
|
|
5157
5165
|
*/
|
|
5158
5166
|
readonly sharedSecret: Uint8Array;
|
|
5159
5167
|
/**
|
|
5160
|
-
* The fulfilment the terminating connector will return
|
|
5161
|
-
*
|
|
5162
|
-
*
|
|
5168
|
+
* The fulfilment the terminating connector will return —
|
|
5169
|
+
* `deriveFulfillment(sharedSecret)`. Pass it to a transport as
|
|
5170
|
+
* `expectedFulfillment`: comparing a FULFILL's preimage against this is the
|
|
5171
|
+
* sender's end-to-end check, and since ADR 0069 the only fulfilment check
|
|
5172
|
+
* made anywhere on the path.
|
|
5163
5173
|
*/
|
|
5164
5174
|
readonly fulfillment: Uint8Array;
|
|
5165
5175
|
}
|
|
@@ -6684,4 +6694,4 @@ interface RetryOptions {
|
|
|
6684
6694
|
*/
|
|
6685
6695
|
declare function withRetry<T>(operation: () => Promise<T>, options: RetryOptions): Promise<T>;
|
|
6686
6696
|
|
|
6687
|
-
export { ACCUMULATED_COST_HEADER, ACCUMULATED_COST_PROTOCOL, ARNS_KIND, type AntSpawnOutcome, type AntSpawnParams, type AntSpawnRefused, type AntSpawnStep, type AntSpawned, type ArnsAntPrepareReceipt, type ArnsBuyOutcome, type ArnsBuyParams, type ArnsBuyReceipt, type ArnsNameType, type ArnsNameWithAntOutcome, type ArnsNetwork, type BTPMessage, BTPMessageType, type BTPProtocolData, type BalanceProofParams, BtpAuthError, type BtpChannelDeclaration, BtpConnectionError, type BtpPacketResponse, BtpPaidWriteTransport, type BtpPaidWriteTransportConfig, BtpRuntimeClient, type BtpRuntimeClientConfig, CLAIM_ACK_HEADER, CLAIM_ACK_PROTOCOL, CLAIM_REJECT_CODE, CLAIM_REJECT_REASONS, type ChainKind, type ChainMetadata, type ChainSigner, ChainUnavailableError, type ChannelBinding, type ChannelBindingContext, type ChannelClient, type ChannelFacade, type ChannelFacadeDeps, ChannelFundingError, ChannelManager, type ChannelManagerConfig, ChannelNotOpenError, ChannelResumeError, type ChannelState, type ChannelStatus, type ChannelStore, type ChannelStoreEntry, type ChannelTerms, type ClaimAck, type ClaimMessage, type ClaimSendingTransport$1 as ClaimSendingTransport, type ClaimStateFailed, type ClaimStateOk, type ClaimStateRequestEntry, type ClaimStateResult, type ClaimSummary, ClientChannelFacade, ClientWalletFacade, ConfigError, type ConnectorChainSettlementTerms, ConnectorEdgeClient, type ConnectorEdgeClientConfig, ConnectorEdgeError, type ConnectorEdgeErrorCode, ConnectorError, type ConnectorIdentity, type ConnectorRoutePrice, type ConnectorRouteTerms, type ConnectorSettlementTerms, type ConnectorSolanaSettlementTerms, type CounterpartyVerdict, DEFAULT_DEPOSIT, DEFAULT_SETTLEMENT_TIMEOUT, DEFAULT_TIMEOUT_MS, DEVNET, type Decoded, type DeriveIdentityOptions, type DerivedIdentity, type DevnetNode, ERC20_ABI, type EVMClaimMessage, type EdgeIdentity, type EncryptedKeystore, type EnsureChannelOptions, type Envelope, EnvelopeError, EnvelopeErrorKind, type EnvelopeHeader, type EnvelopeRequest, type EnvelopeResponse, type EvmChannelRecord, type EvmReadConsistencyConfig, EvmSigner, type ExchangeOutcome, FULFILLMENT_MISMATCH_CODE, FULFILLMENT_MISMATCH_MESSAGE, type FaucetChain, type FundWalletOptions, type FundWalletResult, GIFTWRAP_NONCE_LENGTH, GIFTWRAP_PUBLIC_KEY_LENGTH, GIFTWRAP_SECRET_LENGTH, GIFTWRAP_TYPE_REQUEST, GIFTWRAP_TYPE_RESPONSE, type GasStationExecuteReceipt, type GasStationFailureReason, type GasStationFailureReceipt, type GasStationQuoteReceipt, type GasStationReceipt, type GiftWrapEcdh, GiftWrapError, GiftWrapErrorKind, HS_HOSTNAME_MAX_LENGTH, HS_HOSTNAME_REGEX, HttpIlpClient, type HttpIlpClientConfig, type ILPFulfillPacket, ILPPacketType, type ILPPreparePacket, type ILPRejectPacket, type ILPResponsePacket, ILP_CLAIM_HEADER, ILP_PEER_ID_HEADER, type IlpClient, type IlpResponseMeta, type IlpSendParams, type IlpSendResult, type IlpSendResultWithFulfillment, InMemoryChannelStore, InsufficientBalanceError, InvalidAddressError, IsomorphicBtpClient, type JobAnswer, type JobEndpoint, type JobEvent, type JobEventParams, type JobSender, JsonFileChannelStore, KEYSTORE_VERSION, type KeyDerivationScheme, MIN_SETTLEMENT_TIMEOUT_SECONDS, NetworkError, type NodeSelfDescription, OerError, OerErrorKind, OnChainChannelClient, type OnChainChannelClientConfig, type OnChainChannelStatus, type OpenChannelOptions, type OpenChannelParams, type OpenChannelResult, type OpenOrAdoptParams, type OpenedKeystore, type OpenedRequest, PACKET_EXPIRY_HEADROOM_MS, PAYMENT_REQUIRED_HEADER, PAYMENT_REQUIRED_PROTOCOL, type PaidWriteTransport, type ParsedX402Challenge, PaymentRequiredError, type PaymentTerms, type RequiredTransport, type ResolvedConfig, type ResolvedIdentity, type ResponseHeaderSource, type RetryOptions, type RouteCharge, RouteNotPricedError, type RoutePrice, type RpcTransportOptions, SOLANA_GAS_KIND, type SealedExchange, type SealedRequest, SealedResponseError, type SealedResponseErrorKind, type SendContext, type SendFulfilled, type SendOptions, type SendRefused, type SendRequest, type SendResult, type SendTransferParams, type SendTransferResult, type SignedBalanceProof, type SolanaChannelConfig, type SolanaClaimMessage, type Signer as SolanaKeypair, type SolanaNetwork, SolanaSigner, type SolanaWireTransaction, StaleRpcReadError, TOKEN_NETWORK_ABI, TOKEN_NETWORK_REGISTRY_ABI, TokenNetworkClient, type TokenNetworkClientConfig, type ToonChannelAccept, ToonClient, type ToonClientConfig, ToonClientError, type ToonClientLike, type ToonIdentity, type TransferConfig, TransferNotDeliveredError, TransferUnsupportedError, type TransportChoice, type TransportPreference, TransportRequiredError, type TxRef, UnknownChainError, ValidationError, type WalletBalance, type WalletBalanceSources, type WalletChainBalances, type WalletFacade, type WalletFacadeDeps, type WalletTokenAmount, type WriteKeystoreOptions, type X402ChannelExtra, addressFor, assertRoutableHsHostname, buildJobEvent, buildResponseMeta, buyArnsName, buyArnsNameWithNewAnt, chainUnavailableMessage, chargeFor, connectorEdgeBaseUrl, counterpartyMatch, decodeAccumulatedCost, decodeBase64Text, decodeClaimAck, decodeEnvelope, decodeEnvelopeRequest, decodeEnvelopeResponse, decodePaymentRequired, decodeVarOctetString, decodeVarUint, decryptMnemonic, defaultDestinationFor, defaultFaucetTimeout, defaultRpcUrl,
|
|
6697
|
+
export { ACCUMULATED_COST_HEADER, ACCUMULATED_COST_PROTOCOL, ARNS_KIND, type AntSpawnOutcome, type AntSpawnParams, type AntSpawnRefused, type AntSpawnStep, type AntSpawned, type ArnsAntPrepareReceipt, type ArnsBuyOutcome, type ArnsBuyParams, type ArnsBuyReceipt, type ArnsNameType, type ArnsNameWithAntOutcome, type ArnsNetwork, type BTPMessage, BTPMessageType, type BTPProtocolData, type BalanceProofParams, BtpAuthError, type BtpChannelDeclaration, BtpConnectionError, type BtpPacketResponse, BtpPaidWriteTransport, type BtpPaidWriteTransportConfig, BtpRuntimeClient, type BtpRuntimeClientConfig, CLAIM_ACK_HEADER, CLAIM_ACK_PROTOCOL, CLAIM_REJECT_CODE, CLAIM_REJECT_REASONS, type ChainKind, type ChainMetadata, type ChainSigner, ChainUnavailableError, type ChannelBinding, type ChannelBindingContext, type ChannelClient, type ChannelFacade, type ChannelFacadeDeps, ChannelFundingError, ChannelManager, type ChannelManagerConfig, ChannelNotOpenError, ChannelResumeError, type ChannelState, type ChannelStatus, type ChannelStore, type ChannelStoreEntry, type ChannelTerms, type ClaimAck, type ClaimMessage, type ClaimSendingTransport$1 as ClaimSendingTransport, type ClaimStateFailed, type ClaimStateOk, type ClaimStateRequestEntry, type ClaimStateResult, type ClaimSummary, ClientChannelFacade, ClientWalletFacade, ConfigError, type ConnectorChainSettlementTerms, ConnectorEdgeClient, type ConnectorEdgeClientConfig, ConnectorEdgeError, type ConnectorEdgeErrorCode, ConnectorError, type ConnectorIdentity, type ConnectorRoutePrice, type ConnectorRouteTerms, type ConnectorSettlementTerms, type ConnectorSolanaSettlementTerms, type CounterpartyVerdict, DEFAULT_DEPOSIT, DEFAULT_SETTLEMENT_TIMEOUT, DEFAULT_TIMEOUT_MS, DEVNET, type Decoded, type DeriveIdentityOptions, type DerivedIdentity, type DevnetNode, ERC20_ABI, type EVMClaimMessage, type EdgeIdentity, type EncryptedKeystore, type EnsureChannelOptions, type Envelope, EnvelopeError, EnvelopeErrorKind, type EnvelopeHeader, type EnvelopeRequest, type EnvelopeResponse, type EvmChannelRecord, type EvmReadConsistencyConfig, EvmSigner, type ExchangeOutcome, FULFILLMENT_MISMATCH_CODE, FULFILLMENT_MISMATCH_MESSAGE, type FaucetChain, type FundWalletOptions, type FundWalletResult, GIFTWRAP_NONCE_LENGTH, GIFTWRAP_PUBLIC_KEY_LENGTH, GIFTWRAP_SECRET_LENGTH, GIFTWRAP_TYPE_REQUEST, GIFTWRAP_TYPE_RESPONSE, type GasStationExecuteReceipt, type GasStationFailureReason, type GasStationFailureReceipt, type GasStationQuoteReceipt, type GasStationReceipt, type GiftWrapEcdh, GiftWrapError, GiftWrapErrorKind, HS_HOSTNAME_MAX_LENGTH, HS_HOSTNAME_REGEX, HttpIlpClient, type HttpIlpClientConfig, type ILPFulfillPacket, ILPPacketType, type ILPPreparePacket, type ILPRejectPacket, type ILPResponsePacket, ILP_CLAIM_HEADER, ILP_PEER_ID_HEADER, type IlpClient, type IlpResponseMeta, type IlpSendParams, type IlpSendResult, type IlpSendResultWithFulfillment, InMemoryChannelStore, InsufficientBalanceError, InvalidAddressError, IsomorphicBtpClient, type JobAnswer, type JobEndpoint, type JobEvent, type JobEventParams, type JobSender, JsonFileChannelStore, KEYSTORE_VERSION, type KeyDerivationScheme, MIN_SETTLEMENT_TIMEOUT_SECONDS, NetworkError, type NodeSelfDescription, OerError, OerErrorKind, OnChainChannelClient, type OnChainChannelClientConfig, type OnChainChannelStatus, type OpenChannelOptions, type OpenChannelParams, type OpenChannelResult, type OpenOrAdoptParams, type OpenedKeystore, type OpenedRequest, PACKET_EXPIRY_HEADROOM_MS, PAYMENT_REQUIRED_HEADER, PAYMENT_REQUIRED_PROTOCOL, type PaidWriteTransport, type ParsedX402Challenge, PaymentRequiredError, type PaymentTerms, type RequiredTransport, type ResolvedConfig, type ResolvedIdentity, type ResponseHeaderSource, type RetryOptions, type RouteCharge, RouteNotPricedError, type RoutePrice, type RpcTransportOptions, SOLANA_GAS_KIND, type SealedExchange, type SealedRequest, SealedResponseError, type SealedResponseErrorKind, type SendContext, type SendFulfilled, type SendOptions, type SendRefused, type SendRequest, type SendResult, type SendTransferParams, type SendTransferResult, type SignedBalanceProof, type SolanaChannelConfig, type SolanaClaimMessage, type Signer as SolanaKeypair, type SolanaNetwork, SolanaSigner, type SolanaWireTransaction, StaleRpcReadError, TOKEN_NETWORK_ABI, TOKEN_NETWORK_REGISTRY_ABI, TokenNetworkClient, type TokenNetworkClientConfig, type ToonChannelAccept, ToonClient, type ToonClientConfig, ToonClientError, type ToonClientLike, type ToonIdentity, type TransferConfig, TransferNotDeliveredError, TransferUnsupportedError, type TransportChoice, type TransportPreference, TransportRequiredError, type TxRef, UnknownChainError, ValidationError, type WalletBalance, type WalletBalanceSources, type WalletChainBalances, type WalletFacade, type WalletFacadeDeps, type WalletTokenAmount, type WriteKeystoreOptions, type X402ChannelExtra, addressFor, assertRoutableHsHostname, buildJobEvent, buildResponseMeta, buyArnsName, buyArnsNameWithNewAnt, chainUnavailableMessage, chargeFor, connectorEdgeBaseUrl, counterpartyMatch, decodeAccumulatedCost, decodeBase64Text, decodeClaimAck, decodeEnvelope, decodeEnvelopeRequest, decodeEnvelopeResponse, decodePaymentRequired, decodeVarOctetString, decodeVarUint, decryptMnemonic, defaultDestinationFor, defaultFaucetTimeout, defaultRpcUrl, deriveEvmChannelId, deriveFulfillment, deriveFullIdentity, deserializeIlpPacket, deserializeIlpPrepare, encodeEnvelope, encodeEnvelopeRequest, encodeEnvelopeResponse, encodeVarOctetString, encodeVarUint, encryptMnemonic, envelopeHeader, evmDerivationPath, evmIdentityFromKey, fundWallet, generateKeystore, generateMnemonic, generateRandomIdentity, generateSolanaKeypair, giftWrapPublicKey, httpEndpointToBtpUrl, importKeystore, isGasStationFailure, isHiddenServiceUrl, isInsufficientGasError, isRoutableHsHostname, isUnknownChannelReject, jobEventParam, keystoreDerivation, loadKeystore, localGiftWrapEcdh, looksLikeSealedResponse, mapIlpResponse, openKeystore, openRequest, openResponse, parseBtpMessage, parseEvmChainId, parsePaymentTerms, parseSelfDescription, parseSettlementEntry, parseSolanaWireTransaction, parseX402Body, parseX402Challenge, patchSolanaRecentBlockhash, readBaseUnits, readResponseMeta$1 as readBtpResponseMeta, readEvmNativeBalance, readEvmTokenBalance, readExchangeOutcome, readResponseMeta, readSolanaNativeBalance, readSolanaTokenBalance, readWalletBalances, rejectNamesChannel, resolveConfig, resolveExpectedFulfillment, resolveExpiresAt, routeFor, routePriceFor, rpcFetch, rpcTransport, sameSettlementAddress, sealExchange, sealRequest, sealRequestWithRandomness, sealResponse, sealResponseWithRandomness, selectTransport, send, sendJob, sendTransfer, serializeBtpMessage, serializeIlpFulfill, serializeIlpPrepare, serializeIlpReject, settlementToTerms, signSolanaWireTransaction, solanaKeypair, sortParticipants, spawnAnt, toEnvelopeRequest, trimTrailingSlashes, validateMnemonic, withRetry, writeKeystoreFile };
|
package/dist/index.js
CHANGED
|
@@ -98,7 +98,6 @@ import {
|
|
|
98
98
|
decodeVarUint,
|
|
99
99
|
defaultDestinationFor,
|
|
100
100
|
defaultFaucetTimeout,
|
|
101
|
-
deriveCondition,
|
|
102
101
|
deriveEvmChannelId,
|
|
103
102
|
deriveFulfillment,
|
|
104
103
|
deserializeIlpPacket,
|
|
@@ -139,7 +138,7 @@ import {
|
|
|
139
138
|
readWalletBalances,
|
|
140
139
|
rejectNamesChannel,
|
|
141
140
|
resolveConfig,
|
|
142
|
-
|
|
141
|
+
resolveExpectedFulfillment,
|
|
143
142
|
resolveExpiresAt,
|
|
144
143
|
routeFor,
|
|
145
144
|
routePriceFor,
|
|
@@ -165,7 +164,7 @@ import {
|
|
|
165
164
|
toHex,
|
|
166
165
|
trimTrailingSlashes,
|
|
167
166
|
withRetry
|
|
168
|
-
} from "./chunk-
|
|
167
|
+
} from "./chunk-GDWZ736I.js";
|
|
169
168
|
import {
|
|
170
169
|
DEVNET,
|
|
171
170
|
HS_HOSTNAME_MAX_LENGTH,
|
|
@@ -775,7 +774,6 @@ export {
|
|
|
775
774
|
defaultDestinationFor,
|
|
776
775
|
defaultFaucetTimeout,
|
|
777
776
|
defaultRpcUrl,
|
|
778
|
-
deriveCondition,
|
|
779
777
|
deriveEvmChannelId,
|
|
780
778
|
deriveFulfillment,
|
|
781
779
|
deriveFullIdentity,
|
|
@@ -832,7 +830,7 @@ export {
|
|
|
832
830
|
readWalletBalances,
|
|
833
831
|
rejectNamesChannel,
|
|
834
832
|
resolveConfig,
|
|
835
|
-
|
|
833
|
+
resolveExpectedFulfillment,
|
|
836
834
|
resolveExpiresAt,
|
|
837
835
|
routeFor,
|
|
838
836
|
routePriceFor,
|