@toon-protocol/client 0.29.3 → 0.29.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +334 -252
- package/dist/index.js +110 -11
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1437,6 +1437,265 @@ declare function encodeEnvelope(envelope: Envelope): Uint8Array;
|
|
|
1437
1437
|
*/
|
|
1438
1438
|
declare function decodeEnvelope(buf: Uint8Array, direction: 'request' | 'response'): Envelope;
|
|
1439
1439
|
|
|
1440
|
+
/**
|
|
1441
|
+
* The gift wrap (ADR 0018) and the fulfilment a shared secret derives (ADR
|
|
1442
|
+
* 0019): the seal around the {@link ./envelope.js | envelope}, so a packet
|
|
1443
|
+
* payload is readable only by the connector that terminates it and the
|
|
1444
|
+
* preimage that pays for it needs no app participation.
|
|
1445
|
+
*
|
|
1446
|
+
* A faithful port of `connector_signer::giftwrap`
|
|
1447
|
+
* (`crates/connector-signer/src/giftwrap.rs` on toon-protocol/connector `main`)
|
|
1448
|
+
* and of `connector_domain::condition::derive_condition`
|
|
1449
|
+
* (`crates/connector-domain/src/condition.rs:27`). `vectors/wire-vectors.json`'s
|
|
1450
|
+
* `giftwrap` and `fulfilment` sections are the contract, replayed byte-for-byte
|
|
1451
|
+
* in `wire-vectors.test.ts`; the prose here describes the same thing but the
|
|
1452
|
+
* bytes decide.
|
|
1453
|
+
*
|
|
1454
|
+
* ─── The mechanism, as read off the Rust ────────────────────────────────────
|
|
1455
|
+
* Recorded here because it cannot be inferred from the vector file's field
|
|
1456
|
+
* names, and because the acceptance criterion for toon-client#449 asks for it
|
|
1457
|
+
* in writing. Every line below is cited to
|
|
1458
|
+
* `crates/connector-signer/src/giftwrap.rs` unless stated otherwise.
|
|
1459
|
+
*
|
|
1460
|
+
* - **Curve and ECDH.** The receiver's identity key is secp256k1; the value a
|
|
1461
|
+
* real connector reports from `GET /ilp/identity` is its 65-byte
|
|
1462
|
+
* uncompressed form (`0x04 ‖ X ‖ Y`). The sender ECDHs a fresh, per-packet
|
|
1463
|
+
* ephemeral key against it and uses the **raw X-coordinate** of the
|
|
1464
|
+
* resulting point — `crypto.rs`'s `ecdh_x_coordinate` does
|
|
1465
|
+
* `tweak_mul_assign` then `serialize_compressed()[1..]`, deliberately *not*
|
|
1466
|
+
* `libsecp256k1::SharedSecret`'s digest-mixing variant. So: not hashed, and
|
|
1467
|
+
* not the 33-byte compressed point.
|
|
1468
|
+
* - **Key derivation.** `HKDF-SHA256`, **no salt** (`Hkdf::new(None, ikm)`,
|
|
1469
|
+
* i.e. HKDF-Extract with an all-zero salt), expanded to 32 bytes under one
|
|
1470
|
+
* of three fixed ASCII `info` strings — `giftwrap.rs`'s `hkdf_key`:
|
|
1471
|
+
* - `toon-giftwrap-request` — the request AEAD key, over the ECDH X.
|
|
1472
|
+
* - `toon-giftwrap-response` — the response AEAD key, over the shared secret.
|
|
1473
|
+
* - `toon-giftwrap-fulfillment` — the fulfilment, over the shared secret.
|
|
1474
|
+
* (American spelling on the wire; the vector *section* is `fulfilment`.)
|
|
1475
|
+
* These three strings are the only domain separation between two AEAD keys
|
|
1476
|
+
* and a payment preimage all derived from the same input, so one wrong
|
|
1477
|
+
* character silently yields bytes that decrypt nothing and satisfy no
|
|
1478
|
+
* condition.
|
|
1479
|
+
* - **AEAD.** ChaCha20-Poly1305 (RFC 8439), 12-byte nonce, **no** additional
|
|
1480
|
+
* authenticated data.
|
|
1481
|
+
* - **Request framing.** `0x01 ‖ ephemeral_public(65) ‖ nonce(12) ‖
|
|
1482
|
+
* ciphertext`, where the encrypted plaintext is `shared_secret(32) ‖
|
|
1483
|
+
* encoded_envelope`. The secret rides *inside* the sealed request, which is
|
|
1484
|
+
* what lets the response be sealed with no second key exchange.
|
|
1485
|
+
* - **Response framing.** `0x02 ‖ nonce(12) ‖ ciphertext`, the plaintext being
|
|
1486
|
+
* just the encoded envelope. Sealed directly with the request's shared
|
|
1487
|
+
* secret.
|
|
1488
|
+
* - **Fulfilment and condition.** `fulfilment = HKDF-SHA256(shared_secret,
|
|
1489
|
+
* "toon-giftwrap-fulfillment")`; the condition a sender mints is
|
|
1490
|
+
* `sha256(fulfilment)` — `condition.rs`'s `derive_condition`. A sender knows
|
|
1491
|
+
* the secret before it seals, so it can mint the condition first; the
|
|
1492
|
+
* terminating connector recovers the secret by opening the wrap and derives
|
|
1493
|
+
* the preimage without asking the app anything.
|
|
1494
|
+
* - **Telling a sealed reject from a plaintext one.** The leading type byte,
|
|
1495
|
+
* and only that (`looks_like_sealed_response`). A reject raised short of the
|
|
1496
|
+
* termination shares no secret with the sender and carries empty `data`; an
|
|
1497
|
+
* empty `data` is never sealed, so a sealed reject is positive proof that
|
|
1498
|
+
* the destination itself said no.
|
|
1499
|
+
*
|
|
1500
|
+
* ─── Two failure modes, two types ───────────────────────────────────────────
|
|
1501
|
+
* A wrap that cannot be OPENED throws {@link GiftWrapError}. A wrap that opens
|
|
1502
|
+
* cleanly but whose recovered plaintext is not a valid envelope throws
|
|
1503
|
+
* `EnvelopeError`, from `envelope.ts` — a different class entirely, raised
|
|
1504
|
+
* above this module rather than by it. The Rust keeps the same separation
|
|
1505
|
+
* (`GiftWrapError` vs `connector_domain::EnvelopeError`) for the same reason:
|
|
1506
|
+
* "I could not read this" and "I read this and it was malformed" are different
|
|
1507
|
+
* facts about a peer, and collapsing them loses the distinction at every call
|
|
1508
|
+
* site.
|
|
1509
|
+
*
|
|
1510
|
+
* ─── Callers ────────────────────────────────────────────────────────────────
|
|
1511
|
+
* `ToonClient.publishEvent` (toon-client#450) seals to a connector that
|
|
1512
|
+
* TERMINATES the destination and lets it derive the fulfilment (ADR 0019),
|
|
1513
|
+
* via `wire/sealed-exchange.ts`. `serve-job.ts`'s `createJobMessageHandler`
|
|
1514
|
+
* (toon-client#537) is the other direction: THIS client is the destination,
|
|
1515
|
+
* so it opens a request addressed to its own {@link giftWrapPublicKey} and
|
|
1516
|
+
* seals the answer back — never a connector-derived fulfilment, since the
|
|
1517
|
+
* hashlock preimage there comes from `hashlock-delivery.ts` instead.
|
|
1518
|
+
*/
|
|
1519
|
+
/** ChaCha20-Poly1305 nonce length. */
|
|
1520
|
+
declare const GIFTWRAP_NONCE_LENGTH = 12;
|
|
1521
|
+
/** The shared secret carried inside a sealed request, and the fulfilment. */
|
|
1522
|
+
declare const GIFTWRAP_SECRET_LENGTH = 32;
|
|
1523
|
+
/** The uncompressed secp256k1 public key a sealed request carries. */
|
|
1524
|
+
declare const GIFTWRAP_PUBLIC_KEY_LENGTH = 65;
|
|
1525
|
+
/** `TYPE_GIFTWRAP_REQUEST` — the leading byte of a sealed request. */
|
|
1526
|
+
declare const GIFTWRAP_TYPE_REQUEST = 1;
|
|
1527
|
+
/** `TYPE_GIFTWRAP_RESPONSE` — the leading byte of a sealed response. */
|
|
1528
|
+
declare const GIFTWRAP_TYPE_RESPONSE = 2;
|
|
1529
|
+
/**
|
|
1530
|
+
* Every distinguishable way a wrap can fail to open — the four variants of
|
|
1531
|
+
* `GiftWrapError` in `giftwrap.rs:57-71`, named the same way. There is
|
|
1532
|
+
* deliberately no catch-all: this module must never be able to fail "somehow".
|
|
1533
|
+
*
|
|
1534
|
+
* None of these ever carries decrypted plaintext, matching the Rust's own
|
|
1535
|
+
* guarantee.
|
|
1536
|
+
*/
|
|
1537
|
+
declare enum GiftWrapErrorKind {
|
|
1538
|
+
/** The leading byte is not the one this direction requires. */
|
|
1539
|
+
InvalidType = "invalid_type",
|
|
1540
|
+
/** The bytes end before the framing does. */
|
|
1541
|
+
Truncated = "truncated",
|
|
1542
|
+
/** An ephemeral or receiver public key that is not a usable curve point. */
|
|
1543
|
+
InvalidKey = "invalid_key",
|
|
1544
|
+
/** The AEAD refused: wrong key, wrong nonce, or a tampered ciphertext. */
|
|
1545
|
+
OpenFailed = "open_failed"
|
|
1546
|
+
}
|
|
1547
|
+
/**
|
|
1548
|
+
* A refusal to open a wrap. `kind` is the machine-readable reason;
|
|
1549
|
+
* `expectedType` names the type byte that was required, for
|
|
1550
|
+
* {@link GiftWrapErrorKind.InvalidType} — mirroring
|
|
1551
|
+
* `GiftWrapError::InvalidType(u8)`.
|
|
1552
|
+
*/
|
|
1553
|
+
declare class GiftWrapError extends Error {
|
|
1554
|
+
readonly kind: GiftWrapErrorKind;
|
|
1555
|
+
readonly expectedType?: number | undefined;
|
|
1556
|
+
constructor(kind: GiftWrapErrorKind, expectedType?: number | undefined);
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* What sealing a request produces: the bytes to carry as `Prepare.data`, and
|
|
1560
|
+
* the shared secret that both derives this packet's fulfilment and opens the
|
|
1561
|
+
* answer. The sender must keep the secret — it is the only thing that opens
|
|
1562
|
+
* the response, and the only thing that proves the fulfilment it is paid
|
|
1563
|
+
* against was earned rather than guessed.
|
|
1564
|
+
*/
|
|
1565
|
+
interface SealedRequest {
|
|
1566
|
+
/** `0x01 ‖ ephemeral_public(65) ‖ nonce(12) ‖ ciphertext`. */
|
|
1567
|
+
readonly wrapped: Uint8Array;
|
|
1568
|
+
/** The 32 random bytes sealed inside `wrapped`. */
|
|
1569
|
+
readonly sharedSecret: Uint8Array;
|
|
1570
|
+
}
|
|
1571
|
+
/** What opening a sealed request recovers. */
|
|
1572
|
+
interface OpenedRequest {
|
|
1573
|
+
/** The encoded envelope — feed to `decodeEnvelopeRequest`. */
|
|
1574
|
+
readonly envelopeBytes: Uint8Array;
|
|
1575
|
+
/** The 32-byte secret the sender chose, for the fulfilment and the answer. */
|
|
1576
|
+
readonly sharedSecret: Uint8Array;
|
|
1577
|
+
}
|
|
1578
|
+
/**
|
|
1579
|
+
* A key agreement that never hands out secret key material — the TypeScript
|
|
1580
|
+
* counterpart of `giftwrap.rs`'s dependency on `Signer::ecdh`, and the reason
|
|
1581
|
+
* {@link openRequest} takes this rather than a raw private key: a remote or
|
|
1582
|
+
* hardware-backed identity can open a wrap without its key leaving its own
|
|
1583
|
+
* boundary.
|
|
1584
|
+
*
|
|
1585
|
+
* Returns the raw 32-byte ECDH X-coordinate, or throws.
|
|
1586
|
+
*/
|
|
1587
|
+
interface GiftWrapEcdh {
|
|
1588
|
+
ecdh(ephemeralPublicKey: Uint8Array): Uint8Array;
|
|
1589
|
+
}
|
|
1590
|
+
/**
|
|
1591
|
+
* The ordinary local case of {@link GiftWrapEcdh}: a 32-byte secp256k1 secret
|
|
1592
|
+
* key held in this process. `openRequest` accepts a bare key too and wraps it
|
|
1593
|
+
* in this.
|
|
1594
|
+
*/
|
|
1595
|
+
declare function localGiftWrapEcdh(secretKey: Uint8Array): GiftWrapEcdh;
|
|
1596
|
+
/**
|
|
1597
|
+
* The 65-byte uncompressed secp256k1 public key a `secretKey` opens gift
|
|
1598
|
+
* wraps under — the counterpart {@link openRequest}/{@link localGiftWrapEcdh}
|
|
1599
|
+
* derive their ECDH from, and the same format a real connector reports from
|
|
1600
|
+
* `GET /ilp/identity` (`ConnectorIdentity.publicKey`). A caller publishes
|
|
1601
|
+
* this as a `kind:31990` advertisement's `seal_pubkey` tag (toon-meta#266
|
|
1602
|
+
* §3.1) so a buyer can seal a job's PREPARE `data` to it directly, without a
|
|
1603
|
+
* `GET /identity` this client cannot serve (ADR 0022).
|
|
1604
|
+
*/
|
|
1605
|
+
declare function giftWrapPublicKey(secretKey: Uint8Array): Uint8Array;
|
|
1606
|
+
/**
|
|
1607
|
+
* The deterministic core of {@link sealRequest}, parameterized on every value
|
|
1608
|
+
* a real seal draws at random — the counterpart of the Rust's
|
|
1609
|
+
* `seal_request_with_randomness`, which that crate gates behind a `test-util`
|
|
1610
|
+
* feature for a reason worth repeating: **reusing a (key, nonce) pair under
|
|
1611
|
+
* ChaCha20-Poly1305 is catastrophic**, so caller-supplied randomness is a
|
|
1612
|
+
* footgun, not a convenience. Use {@link sealRequest} unless you are replaying
|
|
1613
|
+
* a fixed vector.
|
|
1614
|
+
*
|
|
1615
|
+
* `receiverPublicKey` may be the 65-byte uncompressed form a connector's
|
|
1616
|
+
* `GET /ilp/identity` reports, or the 33-byte compressed form; the ECDH result
|
|
1617
|
+
* is the same point either way. The ephemeral key is always emitted
|
|
1618
|
+
* uncompressed, because that is what the framing pins.
|
|
1619
|
+
*/
|
|
1620
|
+
declare function sealRequestWithRandomness(plaintext: Uint8Array, receiverPublicKey: Uint8Array, ephemeralSecretKey: Uint8Array, sharedSecret: Uint8Array, nonce: Uint8Array): Uint8Array;
|
|
1621
|
+
/**
|
|
1622
|
+
* Seal `plaintext` (an encoded envelope) to `receiverPublicKey`. A fresh
|
|
1623
|
+
* ephemeral key pair, shared secret and nonce are drawn for this call alone,
|
|
1624
|
+
* so no two sealed requests — even to the same receiver, even with the same
|
|
1625
|
+
* plaintext — share any of the three.
|
|
1626
|
+
*
|
|
1627
|
+
* Returns the wire bytes and the shared secret. Mint the packet's execution
|
|
1628
|
+
* condition as {@link deriveCondition}({@link deriveFulfillment}(secret))
|
|
1629
|
+
* before sending: the terminating connector recovers the same secret by
|
|
1630
|
+
* opening this wrap, so the preimage it is paid against is one it derived, not
|
|
1631
|
+
* one anybody handed it.
|
|
1632
|
+
*/
|
|
1633
|
+
declare function sealRequest(plaintext: Uint8Array, receiverPublicKey: Uint8Array): SealedRequest;
|
|
1634
|
+
/**
|
|
1635
|
+
* Open a sealed request addressed to `identity`, recovering the encoded
|
|
1636
|
+
* envelope and the shared secret carried alongside it.
|
|
1637
|
+
*
|
|
1638
|
+
* `identity` is either a 32-byte secp256k1 secret key or a {@link GiftWrapEcdh}
|
|
1639
|
+
* that never exposes one. `serve-job.ts` calls this for real (toon-client#537):
|
|
1640
|
+
* when this client is itself the BTP destination, it is the party that opens
|
|
1641
|
+
* the wrap. It also makes the seal testable from both ends — and the vectors'
|
|
1642
|
+
* "opening it with the fixture's secret key must recover the envelope and the
|
|
1643
|
+
* secret exactly" a check this repo can actually run.
|
|
1644
|
+
*/
|
|
1645
|
+
declare function openRequest(bytes: Uint8Array, identity: Uint8Array | GiftWrapEcdh): OpenedRequest;
|
|
1646
|
+
/**
|
|
1647
|
+
* The deterministic core of {@link sealResponse}, parameterized on the nonce.
|
|
1648
|
+
* Same footgun, same warning as {@link sealRequestWithRandomness}: a nonce
|
|
1649
|
+
* reused under one shared secret destroys the confidentiality of both
|
|
1650
|
+
* responses sealed with it.
|
|
1651
|
+
*/
|
|
1652
|
+
declare function sealResponseWithRandomness(sharedSecret: Uint8Array, plaintext: Uint8Array, nonce: Uint8Array): Uint8Array;
|
|
1653
|
+
/**
|
|
1654
|
+
* Seal `plaintext` — an encoded response envelope, or a reject's diagnostic
|
|
1655
|
+
* bytes — with the request's own `sharedSecret`. No second key exchange: the
|
|
1656
|
+
* secret is bidirectional by construction, which is also why a sealed reject
|
|
1657
|
+
* can only have come from the termination.
|
|
1658
|
+
*/
|
|
1659
|
+
declare function sealResponse(sharedSecret: Uint8Array, plaintext: Uint8Array): Uint8Array;
|
|
1660
|
+
/**
|
|
1661
|
+
* Open a sealed response with the shared secret {@link sealRequest} returned
|
|
1662
|
+
* for the request it answers. No signer, no key exchange, no identity key.
|
|
1663
|
+
*/
|
|
1664
|
+
declare function openResponse(sharedSecret: Uint8Array, bytes: Uint8Array): Uint8Array;
|
|
1665
|
+
/**
|
|
1666
|
+
* Whether `bytes` is shaped like a sealed response — the leading type byte and
|
|
1667
|
+
* nothing else, exactly as `looks_like_sealed_response` does it. This is how a
|
|
1668
|
+
* sender tells a reject raised BY the destination from one raised on the way
|
|
1669
|
+
* to it, without holding the secret to try opening it.
|
|
1670
|
+
*
|
|
1671
|
+
* Empty `data`, which every reject raised short of a termination carries, is
|
|
1672
|
+
* never sealed.
|
|
1673
|
+
*/
|
|
1674
|
+
declare function looksLikeSealedResponse(bytes: Uint8Array): boolean;
|
|
1675
|
+
/**
|
|
1676
|
+
* The fulfilment a request's shared secret derives (ADR 0019):
|
|
1677
|
+
* `HKDF-SHA256(shared_secret, "toon-giftwrap-fulfillment")`, 32 bytes.
|
|
1678
|
+
* Domain-separated by its own `info` string from both AEAD keys the same
|
|
1679
|
+
* secret also derives, so it can never collide with either.
|
|
1680
|
+
*/
|
|
1681
|
+
declare function deriveFulfillment(sharedSecret: Uint8Array): Uint8Array;
|
|
1682
|
+
/**
|
|
1683
|
+
* The condition a `fulfillment` satisfies: `sha256(fulfillment)` —
|
|
1684
|
+
* `connector_domain::condition::derive_condition`. Hashing only ever runs in
|
|
1685
|
+
* this direction; there is deliberately no function here that goes from a
|
|
1686
|
+
* condition back to a fulfilment.
|
|
1687
|
+
*
|
|
1688
|
+
* The hash is the same one `utils/condition.ts` already uses; what ADR 0019
|
|
1689
|
+
* changes is where the preimage comes from. `mintExecutionCondition` there
|
|
1690
|
+
* draws a random preimage the sender must then carry to the FULFILL itself;
|
|
1691
|
+
* here the preimage is DERIVED from the secret sealed inside the packet, so
|
|
1692
|
+
* the terminating connector can produce it without the sender or the app
|
|
1693
|
+
* handing it over. Checking a returned fulfilment against a condition is
|
|
1694
|
+
* unchanged either way — use `fulfillmentMatchesCondition` from
|
|
1695
|
+
* `utils/condition.ts` for that rather than a second copy of it here.
|
|
1696
|
+
*/
|
|
1697
|
+
declare function deriveCondition(fulfillment: Uint8Array): Uint8Array;
|
|
1698
|
+
|
|
1440
1699
|
/**
|
|
1441
1700
|
* Serve-side job handling (toon-client#494, toon-meta#262 "agents earning").
|
|
1442
1701
|
*
|
|
@@ -1456,6 +1715,15 @@ declare function decodeEnvelope(buf: Uint8Array, direction: 'request' | 'respons
|
|
|
1456
1715
|
* verifies the handler's answer against the PREPARE's own condition before
|
|
1457
1716
|
* it goes on the wire.
|
|
1458
1717
|
*
|
|
1718
|
+
* Sealing at a client destination (toon-client#537, toon-meta#266 §7): under
|
|
1719
|
+
* epic decision 6 THIS client — the BTP session terminating the PREPARE, not
|
|
1720
|
+
* any connector — is the destination a buyer sealed to (ADR 0018). Passing
|
|
1721
|
+
* `identity` opens `job.data` as a gift wrap addressed to it before the
|
|
1722
|
+
* handler ever runs, and seals the handler's answer back with the same
|
|
1723
|
+
* shared secret (ADR 0018's bidirectional rule) before it goes on the FULFILL.
|
|
1724
|
+
* Additive: omitting `identity` reproduces the pre-#537 behaviour exactly —
|
|
1725
|
+
* `data` passes through unexamined in both directions, unchanged.
|
|
1726
|
+
*
|
|
1459
1727
|
* Error policy (ADR 0020 "you pay for an answer, not the answer you
|
|
1460
1728
|
* wanted", RFC-0027 F99 "Application Error — the terminating app declined
|
|
1461
1729
|
* the delivery, or supplied no fulfilment matching the execution
|
|
@@ -1464,10 +1732,14 @@ declare function decodeEnvelope(buf: Uint8Array, direction: 'request' | 'respons
|
|
|
1464
1732
|
* own F99 gloss already names together. An already-expired PREPARE is
|
|
1465
1733
|
* refused R00 without ever invoking the handler, so a provider is never
|
|
1466
1734
|
* asked to do paid work for a packet that can no longer be honored. An
|
|
1467
|
-
* undecodable PREPARE is refused F00
|
|
1468
|
-
*
|
|
1469
|
-
*
|
|
1470
|
-
*
|
|
1735
|
+
* undecodable PREPARE is refused F00, and so is a PREPARE whose `data` will
|
|
1736
|
+
* not open under `identity` — distinct from F00's decode failure only in its
|
|
1737
|
+
* message, since RFC-0027 has no dedicated "wrong destination key" code, but
|
|
1738
|
+
* never conflated with F99: a wrap that never opened is not something the
|
|
1739
|
+
* handler ever saw or had a chance to decline. None of these paths ever
|
|
1740
|
+
* throw back into the BTP transport — every outcome is an answer (a
|
|
1741
|
+
* RESPONSE frame carrying FULFILL or REJECT), matching the symmetric
|
|
1742
|
+
* grammar's "every request gets an answer" contract.
|
|
1471
1743
|
*/
|
|
1472
1744
|
|
|
1473
1745
|
/** One connector-originated job PREPARE, decoded and ready for a handler. */
|
|
@@ -1480,7 +1752,13 @@ interface JobRequest {
|
|
|
1480
1752
|
executionCondition: Uint8Array;
|
|
1481
1753
|
/** When this PREPARE can no longer be honored. */
|
|
1482
1754
|
expiresAt: Date;
|
|
1483
|
-
/**
|
|
1755
|
+
/**
|
|
1756
|
+
* The application payload. When {@link createJobMessageHandler} is given
|
|
1757
|
+
* `identity`, the PREPARE's `data` is a gift wrap addressed to this client
|
|
1758
|
+
* (ADR 0018, toon-client#537) and this is already the OPENED plaintext —
|
|
1759
|
+
* never the raw wrap. Without `identity`, this is the raw `data` bytes,
|
|
1760
|
+
* passed through unexamined, exactly as before (additive).
|
|
1761
|
+
*/
|
|
1484
1762
|
data: Uint8Array;
|
|
1485
1763
|
}
|
|
1486
1764
|
/** What a {@link JobHandler} answers a job with. */
|
|
@@ -1492,7 +1770,13 @@ interface JobAnswer {
|
|
|
1492
1770
|
* site that should ever produce this value.
|
|
1493
1771
|
*/
|
|
1494
1772
|
fulfillment: Uint8Array;
|
|
1495
|
-
/**
|
|
1773
|
+
/**
|
|
1774
|
+
* Answer payload. Defaults to empty. When `identity` was supplied to
|
|
1775
|
+
* {@link createJobMessageHandler}, this plaintext is sealed with the
|
|
1776
|
+
* request's own shared secret (ADR 0018's bidirectional rule) before it
|
|
1777
|
+
* goes on the FULFILL's `data` field; without `identity` it rides
|
|
1778
|
+
* unexamined, exactly as before.
|
|
1779
|
+
*/
|
|
1496
1780
|
data?: Uint8Array;
|
|
1497
1781
|
}
|
|
1498
1782
|
/**
|
|
@@ -1512,8 +1796,17 @@ type JobHandler = (job: JobRequest) => Promise<JobAnswer> | JobAnswer;
|
|
|
1512
1796
|
* A server-originated MESSAGE that carries no PREPARE at all (§1.9 step 1's
|
|
1513
1797
|
* auth MESSAGE, or a claim-only standalone MESSAGE) is not a job; it is
|
|
1514
1798
|
* answered with an empty RESPONSE, unchanged from the pre-#494 default.
|
|
1799
|
+
*
|
|
1800
|
+
* @param identity This client's own ADR 0018 secret key (or a
|
|
1801
|
+
* {@link GiftWrapEcdh} for a remote/hardware-backed one) — the counterpart
|
|
1802
|
+
* to `ToonClient.getSealingPublicKey()`. When supplied, a PREPARE whose
|
|
1803
|
+
* `data` does not open as a gift wrap addressed to it is refused before
|
|
1804
|
+
* `handler` ever runs, `job.data` is the opened plaintext, and the
|
|
1805
|
+
* handler's answer is sealed back with the same shared secret. Omit it to
|
|
1806
|
+
* reproduce the pre-#537 behaviour exactly: `data` passes through
|
|
1807
|
+
* unsealed in both directions (toon-client#537, toon-meta#266 §7).
|
|
1515
1808
|
*/
|
|
1516
|
-
declare function createJobMessageHandler(handler: JobHandler): BtpMessageHandler;
|
|
1809
|
+
declare function createJobMessageHandler(handler: JobHandler, identity?: Uint8Array | GiftWrapEcdh): BtpMessageHandler;
|
|
1517
1810
|
|
|
1518
1811
|
/**
|
|
1519
1812
|
* Solana payment-channel parameters supplied via `ToonClientConfig.solanaChannel`.
|
|
@@ -1844,6 +2137,21 @@ interface ToonClientConfig {
|
|
|
1844
2137
|
* answers a connector-originated job, unchanged from the pre-#494 default.
|
|
1845
2138
|
*/
|
|
1846
2139
|
jobHandler?: JobHandler;
|
|
2140
|
+
/**
|
|
2141
|
+
* Serve `jobHandler` jobs at a CLIENT destination (toon-client#537,
|
|
2142
|
+
* toon-meta#266 §7): unseal an inbound PREPARE's `data` as a gift wrap
|
|
2143
|
+
* addressed to this client's own {@link ToonClientConfig.secretKey}
|
|
2144
|
+
* (`ToonClient.getSealingPublicKey()`) before `jobHandler` runs, and seal
|
|
2145
|
+
* its answer back with the same shared secret. Has no effect when
|
|
2146
|
+
* `jobHandler` is unset.
|
|
2147
|
+
*
|
|
2148
|
+
* Default `false` — a `jobHandler` keeps receiving `data` unsealed,
|
|
2149
|
+
* exactly as before #537 (devnet's existing factory-job dialect does not
|
|
2150
|
+
* seal to this client, and must keep working unchanged). Set `true` only
|
|
2151
|
+
* for a seller that advertised its sealing key in a `kind:31990` (toon-
|
|
2152
|
+
* meta#266 §3.1) and expects buyers to seal to it.
|
|
2153
|
+
*/
|
|
2154
|
+
jobHandlerSealed?: boolean;
|
|
1847
2155
|
/**
|
|
1848
2156
|
* ILP destination address for event publishing.
|
|
1849
2157
|
* Defaults to the connector's local address (derived from connectorUrl host).
|
|
@@ -2780,6 +3088,24 @@ declare class ToonClient {
|
|
|
2780
3088
|
* Works before start() is called.
|
|
2781
3089
|
*/
|
|
2782
3090
|
getPublicKey(): string;
|
|
3091
|
+
/**
|
|
3092
|
+
* This client's own ADR 0018 sealing public key — the 65-byte uncompressed
|
|
3093
|
+
* secp256k1 identity a buyer seals a job PREPARE's `data` to when this
|
|
3094
|
+
* client IS the destination (toon-client#537, toon-meta#266 §3.1/§7), in
|
|
3095
|
+
* the same format a real connector reports from `GET /ilp/identity`
|
|
3096
|
+
* (`ConnectorIdentity.publicKey`). Publish it as a `kind:31990`
|
|
3097
|
+
* advertisement's `seal_pubkey` tag ({@link getSealingPublicKeyHex}) so a
|
|
3098
|
+
* buyer can address this client without a `GET /identity` it cannot serve
|
|
3099
|
+
* behind NAT (ADR 0022).
|
|
3100
|
+
*
|
|
3101
|
+
* Derived from the same `secretKey` as {@link getPublicKey}'s Nostr
|
|
3102
|
+
* identity — stable across daemon restarts and reconnects, never a fresh
|
|
3103
|
+
* key per call, so a durable advertisement stays valid. Works before
|
|
3104
|
+
* `start()` is called.
|
|
3105
|
+
*/
|
|
3106
|
+
getSealingPublicKey(): Uint8Array;
|
|
3107
|
+
/** {@link getSealingPublicKey}, hex-encoded — the exact `seal_pubkey` tag value. */
|
|
3108
|
+
getSealingPublicKeyHex(): string;
|
|
2783
3109
|
/**
|
|
2784
3110
|
* Sign an unsigned Nostr event template with the client's Nostr secret key,
|
|
2785
3111
|
* returning a fully-signed event (id + pubkey + sig).
|
|
@@ -6524,250 +6850,6 @@ declare function encodeVarOctetString(data: Uint8Array): Uint8Array;
|
|
|
6524
6850
|
*/
|
|
6525
6851
|
declare function decodeVarOctetString(buf: Uint8Array, offset: number): Decoded<Uint8Array>;
|
|
6526
6852
|
|
|
6527
|
-
/**
|
|
6528
|
-
* The gift wrap (ADR 0018) and the fulfilment a shared secret derives (ADR
|
|
6529
|
-
* 0019): the seal around the {@link ./envelope.js | envelope}, so a packet
|
|
6530
|
-
* payload is readable only by the connector that terminates it and the
|
|
6531
|
-
* preimage that pays for it needs no app participation.
|
|
6532
|
-
*
|
|
6533
|
-
* A faithful port of `connector_signer::giftwrap`
|
|
6534
|
-
* (`crates/connector-signer/src/giftwrap.rs` on toon-protocol/connector `main`)
|
|
6535
|
-
* and of `connector_domain::condition::derive_condition`
|
|
6536
|
-
* (`crates/connector-domain/src/condition.rs:27`). `vectors/wire-vectors.json`'s
|
|
6537
|
-
* `giftwrap` and `fulfilment` sections are the contract, replayed byte-for-byte
|
|
6538
|
-
* in `wire-vectors.test.ts`; the prose here describes the same thing but the
|
|
6539
|
-
* bytes decide.
|
|
6540
|
-
*
|
|
6541
|
-
* ─── The mechanism, as read off the Rust ────────────────────────────────────
|
|
6542
|
-
* Recorded here because it cannot be inferred from the vector file's field
|
|
6543
|
-
* names, and because the acceptance criterion for toon-client#449 asks for it
|
|
6544
|
-
* in writing. Every line below is cited to
|
|
6545
|
-
* `crates/connector-signer/src/giftwrap.rs` unless stated otherwise.
|
|
6546
|
-
*
|
|
6547
|
-
* - **Curve and ECDH.** The receiver's identity key is secp256k1; the value a
|
|
6548
|
-
* real connector reports from `GET /ilp/identity` is its 65-byte
|
|
6549
|
-
* uncompressed form (`0x04 ‖ X ‖ Y`). The sender ECDHs a fresh, per-packet
|
|
6550
|
-
* ephemeral key against it and uses the **raw X-coordinate** of the
|
|
6551
|
-
* resulting point — `crypto.rs`'s `ecdh_x_coordinate` does
|
|
6552
|
-
* `tweak_mul_assign` then `serialize_compressed()[1..]`, deliberately *not*
|
|
6553
|
-
* `libsecp256k1::SharedSecret`'s digest-mixing variant. So: not hashed, and
|
|
6554
|
-
* not the 33-byte compressed point.
|
|
6555
|
-
* - **Key derivation.** `HKDF-SHA256`, **no salt** (`Hkdf::new(None, ikm)`,
|
|
6556
|
-
* i.e. HKDF-Extract with an all-zero salt), expanded to 32 bytes under one
|
|
6557
|
-
* of three fixed ASCII `info` strings — `giftwrap.rs`'s `hkdf_key`:
|
|
6558
|
-
* - `toon-giftwrap-request` — the request AEAD key, over the ECDH X.
|
|
6559
|
-
* - `toon-giftwrap-response` — the response AEAD key, over the shared secret.
|
|
6560
|
-
* - `toon-giftwrap-fulfillment` — the fulfilment, over the shared secret.
|
|
6561
|
-
* (American spelling on the wire; the vector *section* is `fulfilment`.)
|
|
6562
|
-
* These three strings are the only domain separation between two AEAD keys
|
|
6563
|
-
* and a payment preimage all derived from the same input, so one wrong
|
|
6564
|
-
* character silently yields bytes that decrypt nothing and satisfy no
|
|
6565
|
-
* condition.
|
|
6566
|
-
* - **AEAD.** ChaCha20-Poly1305 (RFC 8439), 12-byte nonce, **no** additional
|
|
6567
|
-
* authenticated data.
|
|
6568
|
-
* - **Request framing.** `0x01 ‖ ephemeral_public(65) ‖ nonce(12) ‖
|
|
6569
|
-
* ciphertext`, where the encrypted plaintext is `shared_secret(32) ‖
|
|
6570
|
-
* encoded_envelope`. The secret rides *inside* the sealed request, which is
|
|
6571
|
-
* what lets the response be sealed with no second key exchange.
|
|
6572
|
-
* - **Response framing.** `0x02 ‖ nonce(12) ‖ ciphertext`, the plaintext being
|
|
6573
|
-
* just the encoded envelope. Sealed directly with the request's shared
|
|
6574
|
-
* secret.
|
|
6575
|
-
* - **Fulfilment and condition.** `fulfilment = HKDF-SHA256(shared_secret,
|
|
6576
|
-
* "toon-giftwrap-fulfillment")`; the condition a sender mints is
|
|
6577
|
-
* `sha256(fulfilment)` — `condition.rs`'s `derive_condition`. A sender knows
|
|
6578
|
-
* the secret before it seals, so it can mint the condition first; the
|
|
6579
|
-
* terminating connector recovers the secret by opening the wrap and derives
|
|
6580
|
-
* the preimage without asking the app anything.
|
|
6581
|
-
* - **Telling a sealed reject from a plaintext one.** The leading type byte,
|
|
6582
|
-
* and only that (`looks_like_sealed_response`). A reject raised short of the
|
|
6583
|
-
* termination shares no secret with the sender and carries empty `data`; an
|
|
6584
|
-
* empty `data` is never sealed, so a sealed reject is positive proof that
|
|
6585
|
-
* the destination itself said no.
|
|
6586
|
-
*
|
|
6587
|
-
* ─── Two failure modes, two types ───────────────────────────────────────────
|
|
6588
|
-
* A wrap that cannot be OPENED throws {@link GiftWrapError}. A wrap that opens
|
|
6589
|
-
* cleanly but whose recovered plaintext is not a valid envelope throws
|
|
6590
|
-
* `EnvelopeError`, from `envelope.ts` — a different class entirely, raised
|
|
6591
|
-
* above this module rather than by it. The Rust keeps the same separation
|
|
6592
|
-
* (`GiftWrapError` vs `connector_domain::EnvelopeError`) for the same reason:
|
|
6593
|
-
* "I could not read this" and "I read this and it was malformed" are different
|
|
6594
|
-
* facts about a peer, and collapsing them loses the distinction at every call
|
|
6595
|
-
* site.
|
|
6596
|
-
*
|
|
6597
|
-
* ─── Additive ───────────────────────────────────────────────────────────────
|
|
6598
|
-
* Nothing in this client's live send path calls this yet — `publishEvent` is
|
|
6599
|
-
* still the latin1 HTTP framing in `utils/store-envelope.ts`. Rewiring it is a
|
|
6600
|
-
* later child (toon-client#450).
|
|
6601
|
-
*/
|
|
6602
|
-
/** ChaCha20-Poly1305 nonce length. */
|
|
6603
|
-
declare const GIFTWRAP_NONCE_LENGTH = 12;
|
|
6604
|
-
/** The shared secret carried inside a sealed request, and the fulfilment. */
|
|
6605
|
-
declare const GIFTWRAP_SECRET_LENGTH = 32;
|
|
6606
|
-
/** The uncompressed secp256k1 public key a sealed request carries. */
|
|
6607
|
-
declare const GIFTWRAP_PUBLIC_KEY_LENGTH = 65;
|
|
6608
|
-
/** `TYPE_GIFTWRAP_REQUEST` — the leading byte of a sealed request. */
|
|
6609
|
-
declare const GIFTWRAP_TYPE_REQUEST = 1;
|
|
6610
|
-
/** `TYPE_GIFTWRAP_RESPONSE` — the leading byte of a sealed response. */
|
|
6611
|
-
declare const GIFTWRAP_TYPE_RESPONSE = 2;
|
|
6612
|
-
/**
|
|
6613
|
-
* Every distinguishable way a wrap can fail to open — the four variants of
|
|
6614
|
-
* `GiftWrapError` in `giftwrap.rs:57-71`, named the same way. There is
|
|
6615
|
-
* deliberately no catch-all: this module must never be able to fail "somehow".
|
|
6616
|
-
*
|
|
6617
|
-
* None of these ever carries decrypted plaintext, matching the Rust's own
|
|
6618
|
-
* guarantee.
|
|
6619
|
-
*/
|
|
6620
|
-
declare enum GiftWrapErrorKind {
|
|
6621
|
-
/** The leading byte is not the one this direction requires. */
|
|
6622
|
-
InvalidType = "invalid_type",
|
|
6623
|
-
/** The bytes end before the framing does. */
|
|
6624
|
-
Truncated = "truncated",
|
|
6625
|
-
/** An ephemeral or receiver public key that is not a usable curve point. */
|
|
6626
|
-
InvalidKey = "invalid_key",
|
|
6627
|
-
/** The AEAD refused: wrong key, wrong nonce, or a tampered ciphertext. */
|
|
6628
|
-
OpenFailed = "open_failed"
|
|
6629
|
-
}
|
|
6630
|
-
/**
|
|
6631
|
-
* A refusal to open a wrap. `kind` is the machine-readable reason;
|
|
6632
|
-
* `expectedType` names the type byte that was required, for
|
|
6633
|
-
* {@link GiftWrapErrorKind.InvalidType} — mirroring
|
|
6634
|
-
* `GiftWrapError::InvalidType(u8)`.
|
|
6635
|
-
*/
|
|
6636
|
-
declare class GiftWrapError extends Error {
|
|
6637
|
-
readonly kind: GiftWrapErrorKind;
|
|
6638
|
-
readonly expectedType?: number | undefined;
|
|
6639
|
-
constructor(kind: GiftWrapErrorKind, expectedType?: number | undefined);
|
|
6640
|
-
}
|
|
6641
|
-
/**
|
|
6642
|
-
* What sealing a request produces: the bytes to carry as `Prepare.data`, and
|
|
6643
|
-
* the shared secret that both derives this packet's fulfilment and opens the
|
|
6644
|
-
* answer. The sender must keep the secret — it is the only thing that opens
|
|
6645
|
-
* the response, and the only thing that proves the fulfilment it is paid
|
|
6646
|
-
* against was earned rather than guessed.
|
|
6647
|
-
*/
|
|
6648
|
-
interface SealedRequest {
|
|
6649
|
-
/** `0x01 ‖ ephemeral_public(65) ‖ nonce(12) ‖ ciphertext`. */
|
|
6650
|
-
readonly wrapped: Uint8Array;
|
|
6651
|
-
/** The 32 random bytes sealed inside `wrapped`. */
|
|
6652
|
-
readonly sharedSecret: Uint8Array;
|
|
6653
|
-
}
|
|
6654
|
-
/** What opening a sealed request recovers. */
|
|
6655
|
-
interface OpenedRequest {
|
|
6656
|
-
/** The encoded envelope — feed to `decodeEnvelopeRequest`. */
|
|
6657
|
-
readonly envelopeBytes: Uint8Array;
|
|
6658
|
-
/** The 32-byte secret the sender chose, for the fulfilment and the answer. */
|
|
6659
|
-
readonly sharedSecret: Uint8Array;
|
|
6660
|
-
}
|
|
6661
|
-
/**
|
|
6662
|
-
* A key agreement that never hands out secret key material — the TypeScript
|
|
6663
|
-
* counterpart of `giftwrap.rs`'s dependency on `Signer::ecdh`, and the reason
|
|
6664
|
-
* {@link openRequest} takes this rather than a raw private key: a remote or
|
|
6665
|
-
* hardware-backed identity can open a wrap without its key leaving its own
|
|
6666
|
-
* boundary.
|
|
6667
|
-
*
|
|
6668
|
-
* Returns the raw 32-byte ECDH X-coordinate, or throws.
|
|
6669
|
-
*/
|
|
6670
|
-
interface GiftWrapEcdh {
|
|
6671
|
-
ecdh(ephemeralPublicKey: Uint8Array): Uint8Array;
|
|
6672
|
-
}
|
|
6673
|
-
/**
|
|
6674
|
-
* The ordinary local case of {@link GiftWrapEcdh}: a 32-byte secp256k1 secret
|
|
6675
|
-
* key held in this process. `openRequest` accepts a bare key too and wraps it
|
|
6676
|
-
* in this.
|
|
6677
|
-
*/
|
|
6678
|
-
declare function localGiftWrapEcdh(secretKey: Uint8Array): GiftWrapEcdh;
|
|
6679
|
-
/**
|
|
6680
|
-
* The deterministic core of {@link sealRequest}, parameterized on every value
|
|
6681
|
-
* a real seal draws at random — the counterpart of the Rust's
|
|
6682
|
-
* `seal_request_with_randomness`, which that crate gates behind a `test-util`
|
|
6683
|
-
* feature for a reason worth repeating: **reusing a (key, nonce) pair under
|
|
6684
|
-
* ChaCha20-Poly1305 is catastrophic**, so caller-supplied randomness is a
|
|
6685
|
-
* footgun, not a convenience. Use {@link sealRequest} unless you are replaying
|
|
6686
|
-
* a fixed vector.
|
|
6687
|
-
*
|
|
6688
|
-
* `receiverPublicKey` may be the 65-byte uncompressed form a connector's
|
|
6689
|
-
* `GET /ilp/identity` reports, or the 33-byte compressed form; the ECDH result
|
|
6690
|
-
* is the same point either way. The ephemeral key is always emitted
|
|
6691
|
-
* uncompressed, because that is what the framing pins.
|
|
6692
|
-
*/
|
|
6693
|
-
declare function sealRequestWithRandomness(plaintext: Uint8Array, receiverPublicKey: Uint8Array, ephemeralSecretKey: Uint8Array, sharedSecret: Uint8Array, nonce: Uint8Array): Uint8Array;
|
|
6694
|
-
/**
|
|
6695
|
-
* Seal `plaintext` (an encoded envelope) to `receiverPublicKey`. A fresh
|
|
6696
|
-
* ephemeral key pair, shared secret and nonce are drawn for this call alone,
|
|
6697
|
-
* so no two sealed requests — even to the same receiver, even with the same
|
|
6698
|
-
* plaintext — share any of the three.
|
|
6699
|
-
*
|
|
6700
|
-
* Returns the wire bytes and the shared secret. Mint the packet's execution
|
|
6701
|
-
* condition as {@link deriveCondition}({@link deriveFulfillment}(secret))
|
|
6702
|
-
* before sending: the terminating connector recovers the same secret by
|
|
6703
|
-
* opening this wrap, so the preimage it is paid against is one it derived, not
|
|
6704
|
-
* one anybody handed it.
|
|
6705
|
-
*/
|
|
6706
|
-
declare function sealRequest(plaintext: Uint8Array, receiverPublicKey: Uint8Array): SealedRequest;
|
|
6707
|
-
/**
|
|
6708
|
-
* Open a sealed request addressed to `identity`, recovering the encoded
|
|
6709
|
-
* envelope and the shared secret carried alongside it.
|
|
6710
|
-
*
|
|
6711
|
-
* `identity` is either a 32-byte secp256k1 secret key or a {@link GiftWrapEcdh}
|
|
6712
|
-
* that never exposes one. Nothing in this client terminates packets today, so
|
|
6713
|
-
* this exists to make the seal testable from both ends — and to make the
|
|
6714
|
-
* vectors' "opening it with the fixture's secret key must recover the envelope
|
|
6715
|
-
* and the secret exactly" a check this repo can actually run.
|
|
6716
|
-
*/
|
|
6717
|
-
declare function openRequest(bytes: Uint8Array, identity: Uint8Array | GiftWrapEcdh): OpenedRequest;
|
|
6718
|
-
/**
|
|
6719
|
-
* The deterministic core of {@link sealResponse}, parameterized on the nonce.
|
|
6720
|
-
* Same footgun, same warning as {@link sealRequestWithRandomness}: a nonce
|
|
6721
|
-
* reused under one shared secret destroys the confidentiality of both
|
|
6722
|
-
* responses sealed with it.
|
|
6723
|
-
*/
|
|
6724
|
-
declare function sealResponseWithRandomness(sharedSecret: Uint8Array, plaintext: Uint8Array, nonce: Uint8Array): Uint8Array;
|
|
6725
|
-
/**
|
|
6726
|
-
* Seal `plaintext` — an encoded response envelope, or a reject's diagnostic
|
|
6727
|
-
* bytes — with the request's own `sharedSecret`. No second key exchange: the
|
|
6728
|
-
* secret is bidirectional by construction, which is also why a sealed reject
|
|
6729
|
-
* can only have come from the termination.
|
|
6730
|
-
*/
|
|
6731
|
-
declare function sealResponse(sharedSecret: Uint8Array, plaintext: Uint8Array): Uint8Array;
|
|
6732
|
-
/**
|
|
6733
|
-
* Open a sealed response with the shared secret {@link sealRequest} returned
|
|
6734
|
-
* for the request it answers. No signer, no key exchange, no identity key.
|
|
6735
|
-
*/
|
|
6736
|
-
declare function openResponse(sharedSecret: Uint8Array, bytes: Uint8Array): Uint8Array;
|
|
6737
|
-
/**
|
|
6738
|
-
* Whether `bytes` is shaped like a sealed response — the leading type byte and
|
|
6739
|
-
* nothing else, exactly as `looks_like_sealed_response` does it. This is how a
|
|
6740
|
-
* sender tells a reject raised BY the destination from one raised on the way
|
|
6741
|
-
* to it, without holding the secret to try opening it.
|
|
6742
|
-
*
|
|
6743
|
-
* Empty `data`, which every reject raised short of a termination carries, is
|
|
6744
|
-
* never sealed.
|
|
6745
|
-
*/
|
|
6746
|
-
declare function looksLikeSealedResponse(bytes: Uint8Array): boolean;
|
|
6747
|
-
/**
|
|
6748
|
-
* The fulfilment a request's shared secret derives (ADR 0019):
|
|
6749
|
-
* `HKDF-SHA256(shared_secret, "toon-giftwrap-fulfillment")`, 32 bytes.
|
|
6750
|
-
* Domain-separated by its own `info` string from both AEAD keys the same
|
|
6751
|
-
* secret also derives, so it can never collide with either.
|
|
6752
|
-
*/
|
|
6753
|
-
declare function deriveFulfillment(sharedSecret: Uint8Array): Uint8Array;
|
|
6754
|
-
/**
|
|
6755
|
-
* The condition a `fulfillment` satisfies: `sha256(fulfillment)` —
|
|
6756
|
-
* `connector_domain::condition::derive_condition`. Hashing only ever runs in
|
|
6757
|
-
* this direction; there is deliberately no function here that goes from a
|
|
6758
|
-
* condition back to a fulfilment.
|
|
6759
|
-
*
|
|
6760
|
-
* The hash is the same one `utils/condition.ts` already uses; what ADR 0019
|
|
6761
|
-
* changes is where the preimage comes from. `mintExecutionCondition` there
|
|
6762
|
-
* draws a random preimage the sender must then carry to the FULFILL itself;
|
|
6763
|
-
* here the preimage is DERIVED from the secret sealed inside the packet, so
|
|
6764
|
-
* the terminating connector can produce it without the sender or the app
|
|
6765
|
-
* handing it over. Checking a returned fulfilment against a condition is
|
|
6766
|
-
* unchanged either way — use `fulfillmentMatchesCondition` from
|
|
6767
|
-
* `utils/condition.ts` for that rather than a second copy of it here.
|
|
6768
|
-
*/
|
|
6769
|
-
declare function deriveCondition(fulfillment: Uint8Array): Uint8Array;
|
|
6770
|
-
|
|
6771
6853
|
/**
|
|
6772
6854
|
* One sealed request/answer exchange with a terminating connector (ADR 0018,
|
|
6773
6855
|
* ADR 0019, ADR 0020) — the whole shape of a packet's payload, from the
|
|
@@ -6928,4 +7010,4 @@ declare function readExchangeOutcome(result: {
|
|
|
6928
7010
|
/** Read a response header, case-insensitively; the first match wins. */
|
|
6929
7011
|
declare function envelopeHeader(response: EnvelopeResponse, name: string): string | undefined;
|
|
6930
7012
|
|
|
6931
|
-
export { type BackupPayload, type BalanceProofParams, type BtpChannelDeclaration, BtpPaidWriteTransport, type BtpPaidWriteTransportConfig, BtpRuntimeClient, type BtpRuntimeClientConfig, type BuildSwapSettlementsParams, CLAIM_TYPEHASH, CONDITION_LENGTH, COOP_CLOSE_TYPEHASH, type ChainMetadata, type ChainSigner, type ChallengeHandler, type ChannelBinding, type ChannelBindingContext, ChannelFundingError, ChannelManager, ChannelResumeError, type ChannelStore, type ChannelStoreEntry, type ClaimMessage, type ClaimResolver, type ClaimSendingTransport, type ClaimSignature, type ClaimStateFailed, type ClaimStateOk, type ClaimStateRequestEntry, type ClaimStateResult, type ConnectorChainSettlementTerms, ConnectorEdgeClient, type ConnectorEdgeClientConfig, ConnectorEdgeError, type ConnectorEdgeErrorCode, ConnectorError, type ConnectorIdentity, type ConnectorRoutePrice, type ConnectorRouteTerms, type ConnectorSettlementTerms, type ConnectorSolanaSettlementTerms, type Decoded, type DeployMinaZkAppParams, type DiscoveredIlpPeer, type EVMClaimMessage, type EncryptedArtifact, type EncryptedKeystore, type EnsureOwnedMinaZkAppParams, type EnsureOwnedMinaZkAppResult, type Envelope, EnvelopeError, EnvelopeErrorKind, type EnvelopeHeader, type EnvelopeRequest, type EnvelopeResponse, type EvmClaimDomainContext, type EvmClaimMessage, type EvmClaimVerifyResult, type EvmCooperativeCloseMessage, type EvmReadConsistencyConfig, EvmSigner, type EvmTransferConfig, type ExchangeOutcome, type ExecutionConditionPair, 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, GIFT_WRAP_KIND, GiftWrapAddressError, GiftWrapDecryptError, type GiftWrapEcdh, GiftWrapError, GiftWrapErrorKind, type H402FetchOptions, HashlockConditionMismatchError, HashlockDecryptError, Http402Client, type Http402ClientConfig, HttpConnectorAdmin, type HttpConnectorAdminConfig, HttpIlpClient, type HttpIlpClientConfig, type HttpIlpClientFactory, HttpRuntimeClient, type HttpRuntimeClientConfig, ILP_CLAIM_HEADER, ILP_PEER_ID_HEADER, type IlpSendParams, type IlpSendResultWithFulfillment, type IlpTransportChoice, InMemoryChannelStore, InMemoryPreimageRetentionStore, InMemoryReceivedClaimStore, type IncrementOfferTags, type IncrementPrepare, type IngestAndRevealParams, type IngestAndRevealResult, type IngestReceivedClaimsParams, type IngestReceivedClaimsResult, InsufficientBalanceError, InvalidAddressError, type JobAnswer, type JobHandler, type JobRequest, JsonFileChannelStore, JsonFileReceivedClaimStore, KeyManager, type KeyManagerConfig, MINA_CHANNEL_STATE, type MinaChannelStateReader, type MinaClaimMessage, type MinaClaimSubmitArgs, type MinaClaimSubmitter, type MinaCoSignInputs, type MinaCoSignedClaim, type MinaDepositReader, type MinaOnChainChannelState, type MinaSettlementContext, MinaSettlementError, type MinaSettlementErrorCode, type MinaSettlementResult, type MinaSignaturePair, MinaSigner, type MinaSignerOptions, type MinaTransferConfig, type MinaZkAppDeployRecord, NetworkError, OerError, OerErrorKind, OnChainChannelClient, type OnChainChannelClientConfig, type OpenedRequest, type OrderedBtpSession, type ParsedX402Challenge, type PasskeyInfo, type PreimageRetentionStore, type PublishEventResult, ROLLING_SWAP_DOMAIN_NAME, ROLLING_SWAP_DOMAIN_VERSION, type ReceivedClaimEntry, type ReceivedClaimRejection, type ReceivedClaimRejectionCode, type ReceivedClaimStore, type RequestBlobStorageParams, type RequestBlobStorageResult, type RetainedPreimage, type RetryOptions, type RevealDecision, type RevealFn, type RevealResult, type RevealedClaim, type RolledBackClaim, SEAL_KIND, type SealedExchange, type SealedRequest, SealedResponseError, type SealedResponseErrorKind, type SelectIlpTransportOptions, type SendTransferParams, type SendTransferResult, type SignedBalanceProof, type SolanaChannelClientOptions, type SolanaClaimMessage, SolanaSigner, type SolanaTransferConfig, StaleRpcReadError, type SubmitEvmSettlementParams, type SubmitEvmSettlementResult, type SwapSettlementBuild, type ToonChannelAccept, ToonClient, type ToonClientConfig, ToonClientError, type ToonIdentity, type ToonSigners, type ToonStartResult, type TransferAssetKind, type TransferChain, type TransferConfig, TransferNotDeliveredError, TransferUnsupportedError, UnknownChainError, type UnwrappedGiftWrap, ValidationError, type VaultData, type VerifiedReceivedClaim, type WalletBalance, type WalletBalanceSources, type WalletChainBalances, type WalletTokenAmount, type X402ChannelExtra, applyDefaults, applyNetworkPresets, assertValidCondition, buildBackupEvent, buildBackupFilter, buildIncrementPrepare, buildMinaCoSignedClaim, buildSettlementInfo, buildSwapSettlements, connectorEdgeBaseUrl, createJobMessageHandler, createO1jsMinaClaimSubmitter, decodeConnectorPublicKey, decodeEnvelope, decodeEnvelopeRequest, decodeEnvelopeResponse, decodeEvmSettlementTx, decodeVarOctetString, decodeVarUint, decryptArtifact, decryptMnemonic, defaultFaucetTimeout, deployMinaChannelZkApp, deriveCondition, deriveFromNsec, deriveFulfillment, deriveFullIdentity, deriveNostrKeyFromMnemonic, encodeEnvelope, encodeEnvelopeRequest, encodeEnvelopeResponse, encodeVarOctetString, encodeVarUint, encryptArtifact, encryptMnemonic, ensureOwnedMinaZkApp, entryToAccumulatedClaim, envelopeHeader, evmClaimDigest, evmCooperativeCloseDigest, extractArweaveTxId, fulfillIncrement, fulfillmentMatchesCondition, fundWallet, generateKeystore, generateMnemonic, generateRandomIdentity, getNetworkStatus, hasSettlementMetadata, httpEndpointToBtpUrl, importKeystore, ingestAndReveal, ingestReceivedClaims, isInsufficientGasError, isPrfSupported, isZeroCondition, loadKeystore, localGiftWrapEcdh, looksLikeSealedResponse, mintExecutionCondition, openRequest, openResponse, parseBackupPayload, parseClaimStateResponse, parseConnectorIdentity, parseConnectorRoutePrice, parseConnectorRouteTerms, parseEvmChainId, parseX402Body, parseX402Challenge, proxyIlpEndpoint, readDiscoveredIlpPeer, readEvmNativeBalance, readEvmTokenBalance, readExchangeOutcome, readMinaBalance, readMinaChannelState, readMinaDepositTotal, readSolanaNativeBalance, readSolanaTokenBalance, readWalletBalances, recoverEvmClaimSigner, requestBlobStorage, sealExchange, sealRequest, sealRequestWithRandomness, sealResponse, sealResponseWithRandomness, selectIlpTransport, sendTransfer, submitEvmSettlement, submitMinaSettlement, unwrapGiftWrapWithKey, validateConfig, validateMnemonic, verifyEvmClaimSignature, withRetry, writeKeystoreFile };
|
|
7013
|
+
export { type BackupPayload, type BalanceProofParams, type BtpChannelDeclaration, BtpPaidWriteTransport, type BtpPaidWriteTransportConfig, BtpRuntimeClient, type BtpRuntimeClientConfig, type BuildSwapSettlementsParams, CLAIM_TYPEHASH, CONDITION_LENGTH, COOP_CLOSE_TYPEHASH, type ChainMetadata, type ChainSigner, type ChallengeHandler, type ChannelBinding, type ChannelBindingContext, ChannelFundingError, ChannelManager, ChannelResumeError, type ChannelStore, type ChannelStoreEntry, type ClaimMessage, type ClaimResolver, type ClaimSendingTransport, type ClaimSignature, type ClaimStateFailed, type ClaimStateOk, type ClaimStateRequestEntry, type ClaimStateResult, type ConnectorChainSettlementTerms, ConnectorEdgeClient, type ConnectorEdgeClientConfig, ConnectorEdgeError, type ConnectorEdgeErrorCode, ConnectorError, type ConnectorIdentity, type ConnectorRoutePrice, type ConnectorRouteTerms, type ConnectorSettlementTerms, type ConnectorSolanaSettlementTerms, type Decoded, type DeployMinaZkAppParams, type DiscoveredIlpPeer, type EVMClaimMessage, type EncryptedArtifact, type EncryptedKeystore, type EnsureOwnedMinaZkAppParams, type EnsureOwnedMinaZkAppResult, type Envelope, EnvelopeError, EnvelopeErrorKind, type EnvelopeHeader, type EnvelopeRequest, type EnvelopeResponse, type EvmClaimDomainContext, type EvmClaimMessage, type EvmClaimVerifyResult, type EvmCooperativeCloseMessage, type EvmReadConsistencyConfig, EvmSigner, type EvmTransferConfig, type ExchangeOutcome, type ExecutionConditionPair, 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, GIFT_WRAP_KIND, GiftWrapAddressError, GiftWrapDecryptError, type GiftWrapEcdh, GiftWrapError, GiftWrapErrorKind, type H402FetchOptions, HashlockConditionMismatchError, HashlockDecryptError, Http402Client, type Http402ClientConfig, HttpConnectorAdmin, type HttpConnectorAdminConfig, HttpIlpClient, type HttpIlpClientConfig, type HttpIlpClientFactory, HttpRuntimeClient, type HttpRuntimeClientConfig, ILP_CLAIM_HEADER, ILP_PEER_ID_HEADER, type IlpSendParams, type IlpSendResultWithFulfillment, type IlpTransportChoice, InMemoryChannelStore, InMemoryPreimageRetentionStore, InMemoryReceivedClaimStore, type IncrementOfferTags, type IncrementPrepare, type IngestAndRevealParams, type IngestAndRevealResult, type IngestReceivedClaimsParams, type IngestReceivedClaimsResult, InsufficientBalanceError, InvalidAddressError, type JobAnswer, type JobHandler, type JobRequest, JsonFileChannelStore, JsonFileReceivedClaimStore, KeyManager, type KeyManagerConfig, MINA_CHANNEL_STATE, type MinaChannelStateReader, type MinaClaimMessage, type MinaClaimSubmitArgs, type MinaClaimSubmitter, type MinaCoSignInputs, type MinaCoSignedClaim, type MinaDepositReader, type MinaOnChainChannelState, type MinaSettlementContext, MinaSettlementError, type MinaSettlementErrorCode, type MinaSettlementResult, type MinaSignaturePair, MinaSigner, type MinaSignerOptions, type MinaTransferConfig, type MinaZkAppDeployRecord, NetworkError, OerError, OerErrorKind, OnChainChannelClient, type OnChainChannelClientConfig, type OpenedRequest, type OrderedBtpSession, type ParsedX402Challenge, type PasskeyInfo, type PreimageRetentionStore, type PublishEventResult, ROLLING_SWAP_DOMAIN_NAME, ROLLING_SWAP_DOMAIN_VERSION, type ReceivedClaimEntry, type ReceivedClaimRejection, type ReceivedClaimRejectionCode, type ReceivedClaimStore, type RequestBlobStorageParams, type RequestBlobStorageResult, type RetainedPreimage, type RetryOptions, type RevealDecision, type RevealFn, type RevealResult, type RevealedClaim, type RolledBackClaim, SEAL_KIND, type SealedExchange, type SealedRequest, SealedResponseError, type SealedResponseErrorKind, type SelectIlpTransportOptions, type SendTransferParams, type SendTransferResult, type SignedBalanceProof, type SolanaChannelClientOptions, type SolanaClaimMessage, SolanaSigner, type SolanaTransferConfig, StaleRpcReadError, type SubmitEvmSettlementParams, type SubmitEvmSettlementResult, type SwapSettlementBuild, type ToonChannelAccept, ToonClient, type ToonClientConfig, ToonClientError, type ToonIdentity, type ToonSigners, type ToonStartResult, type TransferAssetKind, type TransferChain, type TransferConfig, TransferNotDeliveredError, TransferUnsupportedError, UnknownChainError, type UnwrappedGiftWrap, ValidationError, type VaultData, type VerifiedReceivedClaim, type WalletBalance, type WalletBalanceSources, type WalletChainBalances, type WalletTokenAmount, type X402ChannelExtra, applyDefaults, applyNetworkPresets, assertValidCondition, buildBackupEvent, buildBackupFilter, buildIncrementPrepare, buildMinaCoSignedClaim, buildSettlementInfo, buildSwapSettlements, connectorEdgeBaseUrl, createJobMessageHandler, createO1jsMinaClaimSubmitter, decodeConnectorPublicKey, decodeEnvelope, decodeEnvelopeRequest, decodeEnvelopeResponse, decodeEvmSettlementTx, decodeVarOctetString, decodeVarUint, decryptArtifact, decryptMnemonic, defaultFaucetTimeout, deployMinaChannelZkApp, deriveCondition, deriveFromNsec, deriveFulfillment, deriveFullIdentity, deriveNostrKeyFromMnemonic, encodeEnvelope, encodeEnvelopeRequest, encodeEnvelopeResponse, encodeVarOctetString, encodeVarUint, encryptArtifact, encryptMnemonic, ensureOwnedMinaZkApp, entryToAccumulatedClaim, envelopeHeader, evmClaimDigest, evmCooperativeCloseDigest, extractArweaveTxId, fulfillIncrement, fulfillmentMatchesCondition, fundWallet, generateKeystore, generateMnemonic, generateRandomIdentity, getNetworkStatus, giftWrapPublicKey, hasSettlementMetadata, httpEndpointToBtpUrl, importKeystore, ingestAndReveal, ingestReceivedClaims, isInsufficientGasError, isPrfSupported, isZeroCondition, loadKeystore, localGiftWrapEcdh, looksLikeSealedResponse, mintExecutionCondition, openRequest, openResponse, parseBackupPayload, parseClaimStateResponse, parseConnectorIdentity, parseConnectorRoutePrice, parseConnectorRouteTerms, parseEvmChainId, parseX402Body, parseX402Challenge, proxyIlpEndpoint, readDiscoveredIlpPeer, readEvmNativeBalance, readEvmTokenBalance, readExchangeOutcome, readMinaBalance, readMinaChannelState, readMinaDepositTotal, readSolanaNativeBalance, readSolanaTokenBalance, readWalletBalances, recoverEvmClaimSigner, requestBlobStorage, sealExchange, sealRequest, sealRequestWithRandomness, sealResponse, sealResponseWithRandomness, selectIlpTransport, sendTransfer, submitEvmSettlement, submitMinaSettlement, unwrapGiftWrapWithKey, validateConfig, validateMnemonic, verifyEvmClaimSignature, withRetry, writeKeystoreFile };
|