@toon-protocol/client 0.29.2 → 0.29.4

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 CHANGED
@@ -1,7 +1,6 @@
1
- import * as _toon_protocol_core from '@toon-protocol/core';
2
- import { IlpSendResult, IlpClient, IlpPeerInfo, SwapPair, NetworkFamilyStatus, ConnectorAdminClient, ConnectorChannelClient, OpenChannelParams, OpenChannelResult, ChannelState } from '@toon-protocol/core';
3
- export { UI_RENDERER_KIND, UI_TAG, UiCoordinate, buildUiCoordinate, getUiCoordinate, parseUiCoordinate, selectLatestAddressable } from '@toon-protocol/core';
4
1
  import { UnsignedEvent, NostrEvent, EventTemplate } from 'nostr-tools/pure';
2
+ import { IlpSendResult, IlpClient, IlpPeerInfo, SwapPair, NetworkFamilyStatus, DiscoveredPeer, ConnectorAdminClient, ConnectorChannelClient, OpenChannelParams, OpenChannelResult, ChannelState } from '@toon-protocol/core';
3
+ export { UI_RENDERER_KIND, UI_TAG, UiCoordinate, buildUiCoordinate, getUiCoordinate, parseUiCoordinate, selectLatestAddressable } from '@toon-protocol/core';
5
4
  import { PrivateKeyAccount } from 'viem/accounts';
6
5
  import { MinaSignerClientLike, SettlementBundle } from '@toon-protocol/sdk';
7
6
  import { AccumulatedClaim } from '@toon-protocol/sdk/swap';
@@ -765,9 +764,14 @@ declare function parseX402Body(body: unknown, baseUrl?: string): ParsedX402Chall
765
764
  * precondition of forming a packet: `Prepare.data` is sealed to that key, and
766
765
  * sealing to the wrong one is a confidentiality failure, not a delivery
767
766
  * failure. ADR 0022 says the connector *answers* — it never announces — so
768
- * both facts are fetched from the connector's own client edge, on the same
769
- * origin this client already POSTs `/ilp` to
770
- * (`docs/protocol/client-edge-spec.md` §1.7):
767
+ * both facts are fetched from the connector's own client edge
768
+ * (`docs/protocol/client-edge-spec.md` §1.7). That edge is OFTEN the same
769
+ * origin this client already POSTs `/ilp` to, but never assume it: for a
770
+ * forwarded ILP prefix the posting edge and the terminating connector are
771
+ * different machines, and asking the posting edge seals to the wrong key
772
+ * (toon-client#526). Resolving `destination` to the terminator's own client
773
+ * edge — via discovery, before calling into this module — is the caller's
774
+ * job; see `ToonClient.resolveTerminatorEndpoint`.
771
775
  *
772
776
  * - `GET /ilp/identity` → `{ "keyId": "...", "publicKey": "0x04..." }` — the
773
777
  * uncompressed secp256k1 key, 65 bytes, `0x`-prefixed hex.
@@ -1038,7 +1042,16 @@ declare class ConnectorEdgeClient {
1038
1042
  /**
1039
1043
  * The terminating connector's public key, fetched once per endpoint.
1040
1044
  *
1041
- * @param endpoint any client-edge URL (`https://apex`, `https://apex/ilp`).
1045
+ * `endpoint` MUST already be the TERMINATING connector's client edge, not
1046
+ * merely whatever origin a caller is about to POST an ILP packet to —
1047
+ * those are the same machine for most routes today, but never for a
1048
+ * forwarded prefix (ADR 0022, toon-client#526). This method trusts
1049
+ * `endpoint` and fetches exactly that origin's `/ilp/identity`; resolving
1050
+ * a destination address to its terminator first is the caller's job.
1051
+ *
1052
+ * @param endpoint the TERMINATING connector's client-edge URL
1053
+ * (`https://apex`, `https://apex/ilp`) — already resolved from the
1054
+ * destination, never assumed to be the posting edge.
1042
1055
  * @param options `forceRefresh` bypasses (and replaces) the cache entry.
1043
1056
  */
1044
1057
  getIdentity(endpoint: string, options?: {
@@ -1424,6 +1437,265 @@ declare function encodeEnvelope(envelope: Envelope): Uint8Array;
1424
1437
  */
1425
1438
  declare function decodeEnvelope(buf: Uint8Array, direction: 'request' | 'response'): Envelope;
1426
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
+
1427
1699
  /**
1428
1700
  * Serve-side job handling (toon-client#494, toon-meta#262 "agents earning").
1429
1701
  *
@@ -1443,6 +1715,15 @@ declare function decodeEnvelope(buf: Uint8Array, direction: 'request' | 'respons
1443
1715
  * verifies the handler's answer against the PREPARE's own condition before
1444
1716
  * it goes on the wire.
1445
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
+ *
1446
1727
  * Error policy (ADR 0020 "you pay for an answer, not the answer you
1447
1728
  * wanted", RFC-0027 F99 "Application Error — the terminating app declined
1448
1729
  * the delivery, or supplied no fulfilment matching the execution
@@ -1451,10 +1732,14 @@ declare function decodeEnvelope(buf: Uint8Array, direction: 'request' | 'respons
1451
1732
  * own F99 gloss already names together. An already-expired PREPARE is
1452
1733
  * refused R00 without ever invoking the handler, so a provider is never
1453
1734
  * asked to do paid work for a packet that can no longer be honored. An
1454
- * undecodable PREPARE is refused F00. None of these paths ever throw back
1455
- * into the BTP transport — every outcome is an answer (a RESPONSE frame
1456
- * carrying FULFILL or REJECT), matching the symmetric grammar's "every
1457
- * request gets an answer" contract.
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.
1458
1743
  */
1459
1744
 
1460
1745
  /** One connector-originated job PREPARE, decoded and ready for a handler. */
@@ -1467,7 +1752,13 @@ interface JobRequest {
1467
1752
  executionCondition: Uint8Array;
1468
1753
  /** When this PREPARE can no longer be honored. */
1469
1754
  expiresAt: Date;
1470
- /** Opaque application payload — passed through unexamined (ADR 0018). */
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
+ */
1471
1762
  data: Uint8Array;
1472
1763
  }
1473
1764
  /** What a {@link JobHandler} answers a job with. */
@@ -1479,7 +1770,13 @@ interface JobAnswer {
1479
1770
  * site that should ever produce this value.
1480
1771
  */
1481
1772
  fulfillment: Uint8Array;
1482
- /** Answer payload returned in the FULFILL's `data` field. Defaults to empty. */
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
+ */
1483
1780
  data?: Uint8Array;
1484
1781
  }
1485
1782
  /**
@@ -1499,8 +1796,17 @@ type JobHandler = (job: JobRequest) => Promise<JobAnswer> | JobAnswer;
1499
1796
  * A server-originated MESSAGE that carries no PREPARE at all (§1.9 step 1's
1500
1797
  * auth MESSAGE, or a claim-only standalone MESSAGE) is not a job; it is
1501
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).
1502
1808
  */
1503
- declare function createJobMessageHandler(handler: JobHandler): BtpMessageHandler;
1809
+ declare function createJobMessageHandler(handler: JobHandler, identity?: Uint8Array | GiftWrapEcdh): BtpMessageHandler;
1504
1810
 
1505
1811
  /**
1506
1812
  * Solana payment-channel parameters supplied via `ToonClientConfig.solanaChannel`.
@@ -1831,6 +2137,21 @@ interface ToonClientConfig {
1831
2137
  * answers a connector-originated job, unchanged from the pre-#494 default.
1832
2138
  */
1833
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;
1834
2155
  /**
1835
2156
  * ILP destination address for event publishing.
1836
2157
  * Defaults to the connector's local address (derived from connectorUrl host).
@@ -2767,6 +3088,24 @@ declare class ToonClient {
2767
3088
  * Works before start() is called.
2768
3089
  */
2769
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;
2770
3109
  /**
2771
3110
  * Sign an unsigned Nostr event template with the client's Nostr secret key,
2772
3111
  * returning a fully-signed event (id + pubkey + sig).
@@ -2945,6 +3284,45 @@ declare class ToonClient {
2945
3284
  * @throws {ToonClientError} NO_CONNECTOR_EDGE when no origin is known.
2946
3285
  */
2947
3286
  private resolveClientEdgeEndpoint;
3287
+ /**
3288
+ * The client edge to fetch `destination`'s identity from — the connector
3289
+ * that TERMINATES it, not the one this client happens to be posting to
3290
+ * (issue #526). ADR 0022 makes identity answered-not-announced, so it is
3291
+ * fetched from the terminator's own `/ilp/identity`; discovery is only
3292
+ * used to find WHICH origin that is.
3293
+ *
3294
+ * Matches `destination` against every peer this client has discovered
3295
+ * announcing itself via kind:10032 — including ones never peered with,
3296
+ * since a forwarded prefix's terminator need not be a direct peer at all
3297
+ * (that is precisely the shape a forwarded prefix has). Falls back to the
3298
+ * posting edge only when there is no discovery tracker wired up AT ALL —
3299
+ * preserving the (still-common) same-node case where the posting node
3300
+ * terminates its own destination, and the only case that worked before
3301
+ * #526.
3302
+ *
3303
+ * Once a tracker exists, silence — whether zero peers discovered at all,
3304
+ * or peers discovered but none of them claiming `destination` — is treated
3305
+ * as a refusal, not a green light (toon-client#533): zero peers is not
3306
+ * evidence the posting edge terminates the destination, only the absence
3307
+ * of evidence that anything does, and that absence is exactly what
3308
+ * fail-closed exists for. It is also a live production window, not a
3309
+ * theoretical one: `discoveryTracker` is always constructed for a started
3310
+ * client, so a tracker reporting zero peers is what the startup race looks
3311
+ * like before the first announce lands. Likewise, an ancestor-only claim
3312
+ * (a router legitimately owning `g.toon`, which is not the same as owning
3313
+ * everything under it) used to slip through here and get treated as
3314
+ * coverage once a competing announce expired. `resolveTerminatorHttpEndpoint`'s
3315
+ * own claim-gating fixes that; the caller-visible half of the fix is this —
3316
+ * refusing to publish beats sealing to a key that cannot open the wrap,
3317
+ * for a defect whose symptom is "money spent, write lost".
3318
+ *
3319
+ * @throws {ToonClientError} NO_CONNECTOR_EDGE when no origin is known at
3320
+ * all (propagated from {@link resolveClientEdgeEndpoint}).
3321
+ * @throws {ToonClientError} TERMINATOR_UNRESOLVED when a discovery tracker
3322
+ * is present but no discovered announce claims `destination` — including
3323
+ * when it has discovered no peers at all yet.
3324
+ */
3325
+ private resolveTerminatorEndpoint;
2948
3326
  /**
2949
3327
  * Payment-aware HTTP fetch over TOON (issue #50). A `fetch()`-like method that
2950
3328
  * makes paying for an HTTP resource transparent:
@@ -3509,7 +3887,7 @@ declare class ToonClient {
3509
3887
  * @returns Array of discovered peer objects
3510
3888
  * @throws {ToonClientError} If client is not started
3511
3889
  */
3512
- getDiscoveredPeers(): _toon_protocol_core.DiscoveredPeer[];
3890
+ getDiscoveredPeers(): DiscoveredPeer[];
3513
3891
  }
3514
3892
 
3515
3893
  /**
@@ -6472,250 +6850,6 @@ declare function encodeVarOctetString(data: Uint8Array): Uint8Array;
6472
6850
  */
6473
6851
  declare function decodeVarOctetString(buf: Uint8Array, offset: number): Decoded<Uint8Array>;
6474
6852
 
6475
- /**
6476
- * The gift wrap (ADR 0018) and the fulfilment a shared secret derives (ADR
6477
- * 0019): the seal around the {@link ./envelope.js | envelope}, so a packet
6478
- * payload is readable only by the connector that terminates it and the
6479
- * preimage that pays for it needs no app participation.
6480
- *
6481
- * A faithful port of `connector_signer::giftwrap`
6482
- * (`crates/connector-signer/src/giftwrap.rs` on toon-protocol/connector `main`)
6483
- * and of `connector_domain::condition::derive_condition`
6484
- * (`crates/connector-domain/src/condition.rs:27`). `vectors/wire-vectors.json`'s
6485
- * `giftwrap` and `fulfilment` sections are the contract, replayed byte-for-byte
6486
- * in `wire-vectors.test.ts`; the prose here describes the same thing but the
6487
- * bytes decide.
6488
- *
6489
- * ─── The mechanism, as read off the Rust ────────────────────────────────────
6490
- * Recorded here because it cannot be inferred from the vector file's field
6491
- * names, and because the acceptance criterion for toon-client#449 asks for it
6492
- * in writing. Every line below is cited to
6493
- * `crates/connector-signer/src/giftwrap.rs` unless stated otherwise.
6494
- *
6495
- * - **Curve and ECDH.** The receiver's identity key is secp256k1; the value a
6496
- * real connector reports from `GET /ilp/identity` is its 65-byte
6497
- * uncompressed form (`0x04 ‖ X ‖ Y`). The sender ECDHs a fresh, per-packet
6498
- * ephemeral key against it and uses the **raw X-coordinate** of the
6499
- * resulting point — `crypto.rs`'s `ecdh_x_coordinate` does
6500
- * `tweak_mul_assign` then `serialize_compressed()[1..]`, deliberately *not*
6501
- * `libsecp256k1::SharedSecret`'s digest-mixing variant. So: not hashed, and
6502
- * not the 33-byte compressed point.
6503
- * - **Key derivation.** `HKDF-SHA256`, **no salt** (`Hkdf::new(None, ikm)`,
6504
- * i.e. HKDF-Extract with an all-zero salt), expanded to 32 bytes under one
6505
- * of three fixed ASCII `info` strings — `giftwrap.rs`'s `hkdf_key`:
6506
- * - `toon-giftwrap-request` — the request AEAD key, over the ECDH X.
6507
- * - `toon-giftwrap-response` — the response AEAD key, over the shared secret.
6508
- * - `toon-giftwrap-fulfillment` — the fulfilment, over the shared secret.
6509
- * (American spelling on the wire; the vector *section* is `fulfilment`.)
6510
- * These three strings are the only domain separation between two AEAD keys
6511
- * and a payment preimage all derived from the same input, so one wrong
6512
- * character silently yields bytes that decrypt nothing and satisfy no
6513
- * condition.
6514
- * - **AEAD.** ChaCha20-Poly1305 (RFC 8439), 12-byte nonce, **no** additional
6515
- * authenticated data.
6516
- * - **Request framing.** `0x01 ‖ ephemeral_public(65) ‖ nonce(12) ‖
6517
- * ciphertext`, where the encrypted plaintext is `shared_secret(32) ‖
6518
- * encoded_envelope`. The secret rides *inside* the sealed request, which is
6519
- * what lets the response be sealed with no second key exchange.
6520
- * - **Response framing.** `0x02 ‖ nonce(12) ‖ ciphertext`, the plaintext being
6521
- * just the encoded envelope. Sealed directly with the request's shared
6522
- * secret.
6523
- * - **Fulfilment and condition.** `fulfilment = HKDF-SHA256(shared_secret,
6524
- * "toon-giftwrap-fulfillment")`; the condition a sender mints is
6525
- * `sha256(fulfilment)` — `condition.rs`'s `derive_condition`. A sender knows
6526
- * the secret before it seals, so it can mint the condition first; the
6527
- * terminating connector recovers the secret by opening the wrap and derives
6528
- * the preimage without asking the app anything.
6529
- * - **Telling a sealed reject from a plaintext one.** The leading type byte,
6530
- * and only that (`looks_like_sealed_response`). A reject raised short of the
6531
- * termination shares no secret with the sender and carries empty `data`; an
6532
- * empty `data` is never sealed, so a sealed reject is positive proof that
6533
- * the destination itself said no.
6534
- *
6535
- * ─── Two failure modes, two types ───────────────────────────────────────────
6536
- * A wrap that cannot be OPENED throws {@link GiftWrapError}. A wrap that opens
6537
- * cleanly but whose recovered plaintext is not a valid envelope throws
6538
- * `EnvelopeError`, from `envelope.ts` — a different class entirely, raised
6539
- * above this module rather than by it. The Rust keeps the same separation
6540
- * (`GiftWrapError` vs `connector_domain::EnvelopeError`) for the same reason:
6541
- * "I could not read this" and "I read this and it was malformed" are different
6542
- * facts about a peer, and collapsing them loses the distinction at every call
6543
- * site.
6544
- *
6545
- * ─── Additive ───────────────────────────────────────────────────────────────
6546
- * Nothing in this client's live send path calls this yet — `publishEvent` is
6547
- * still the latin1 HTTP framing in `utils/store-envelope.ts`. Rewiring it is a
6548
- * later child (toon-client#450).
6549
- */
6550
- /** ChaCha20-Poly1305 nonce length. */
6551
- declare const GIFTWRAP_NONCE_LENGTH = 12;
6552
- /** The shared secret carried inside a sealed request, and the fulfilment. */
6553
- declare const GIFTWRAP_SECRET_LENGTH = 32;
6554
- /** The uncompressed secp256k1 public key a sealed request carries. */
6555
- declare const GIFTWRAP_PUBLIC_KEY_LENGTH = 65;
6556
- /** `TYPE_GIFTWRAP_REQUEST` — the leading byte of a sealed request. */
6557
- declare const GIFTWRAP_TYPE_REQUEST = 1;
6558
- /** `TYPE_GIFTWRAP_RESPONSE` — the leading byte of a sealed response. */
6559
- declare const GIFTWRAP_TYPE_RESPONSE = 2;
6560
- /**
6561
- * Every distinguishable way a wrap can fail to open — the four variants of
6562
- * `GiftWrapError` in `giftwrap.rs:57-71`, named the same way. There is
6563
- * deliberately no catch-all: this module must never be able to fail "somehow".
6564
- *
6565
- * None of these ever carries decrypted plaintext, matching the Rust's own
6566
- * guarantee.
6567
- */
6568
- declare enum GiftWrapErrorKind {
6569
- /** The leading byte is not the one this direction requires. */
6570
- InvalidType = "invalid_type",
6571
- /** The bytes end before the framing does. */
6572
- Truncated = "truncated",
6573
- /** An ephemeral or receiver public key that is not a usable curve point. */
6574
- InvalidKey = "invalid_key",
6575
- /** The AEAD refused: wrong key, wrong nonce, or a tampered ciphertext. */
6576
- OpenFailed = "open_failed"
6577
- }
6578
- /**
6579
- * A refusal to open a wrap. `kind` is the machine-readable reason;
6580
- * `expectedType` names the type byte that was required, for
6581
- * {@link GiftWrapErrorKind.InvalidType} — mirroring
6582
- * `GiftWrapError::InvalidType(u8)`.
6583
- */
6584
- declare class GiftWrapError extends Error {
6585
- readonly kind: GiftWrapErrorKind;
6586
- readonly expectedType?: number | undefined;
6587
- constructor(kind: GiftWrapErrorKind, expectedType?: number | undefined);
6588
- }
6589
- /**
6590
- * What sealing a request produces: the bytes to carry as `Prepare.data`, and
6591
- * the shared secret that both derives this packet's fulfilment and opens the
6592
- * answer. The sender must keep the secret — it is the only thing that opens
6593
- * the response, and the only thing that proves the fulfilment it is paid
6594
- * against was earned rather than guessed.
6595
- */
6596
- interface SealedRequest {
6597
- /** `0x01 ‖ ephemeral_public(65) ‖ nonce(12) ‖ ciphertext`. */
6598
- readonly wrapped: Uint8Array;
6599
- /** The 32 random bytes sealed inside `wrapped`. */
6600
- readonly sharedSecret: Uint8Array;
6601
- }
6602
- /** What opening a sealed request recovers. */
6603
- interface OpenedRequest {
6604
- /** The encoded envelope — feed to `decodeEnvelopeRequest`. */
6605
- readonly envelopeBytes: Uint8Array;
6606
- /** The 32-byte secret the sender chose, for the fulfilment and the answer. */
6607
- readonly sharedSecret: Uint8Array;
6608
- }
6609
- /**
6610
- * A key agreement that never hands out secret key material — the TypeScript
6611
- * counterpart of `giftwrap.rs`'s dependency on `Signer::ecdh`, and the reason
6612
- * {@link openRequest} takes this rather than a raw private key: a remote or
6613
- * hardware-backed identity can open a wrap without its key leaving its own
6614
- * boundary.
6615
- *
6616
- * Returns the raw 32-byte ECDH X-coordinate, or throws.
6617
- */
6618
- interface GiftWrapEcdh {
6619
- ecdh(ephemeralPublicKey: Uint8Array): Uint8Array;
6620
- }
6621
- /**
6622
- * The ordinary local case of {@link GiftWrapEcdh}: a 32-byte secp256k1 secret
6623
- * key held in this process. `openRequest` accepts a bare key too and wraps it
6624
- * in this.
6625
- */
6626
- declare function localGiftWrapEcdh(secretKey: Uint8Array): GiftWrapEcdh;
6627
- /**
6628
- * The deterministic core of {@link sealRequest}, parameterized on every value
6629
- * a real seal draws at random — the counterpart of the Rust's
6630
- * `seal_request_with_randomness`, which that crate gates behind a `test-util`
6631
- * feature for a reason worth repeating: **reusing a (key, nonce) pair under
6632
- * ChaCha20-Poly1305 is catastrophic**, so caller-supplied randomness is a
6633
- * footgun, not a convenience. Use {@link sealRequest} unless you are replaying
6634
- * a fixed vector.
6635
- *
6636
- * `receiverPublicKey` may be the 65-byte uncompressed form a connector's
6637
- * `GET /ilp/identity` reports, or the 33-byte compressed form; the ECDH result
6638
- * is the same point either way. The ephemeral key is always emitted
6639
- * uncompressed, because that is what the framing pins.
6640
- */
6641
- declare function sealRequestWithRandomness(plaintext: Uint8Array, receiverPublicKey: Uint8Array, ephemeralSecretKey: Uint8Array, sharedSecret: Uint8Array, nonce: Uint8Array): Uint8Array;
6642
- /**
6643
- * Seal `plaintext` (an encoded envelope) to `receiverPublicKey`. A fresh
6644
- * ephemeral key pair, shared secret and nonce are drawn for this call alone,
6645
- * so no two sealed requests — even to the same receiver, even with the same
6646
- * plaintext — share any of the three.
6647
- *
6648
- * Returns the wire bytes and the shared secret. Mint the packet's execution
6649
- * condition as {@link deriveCondition}({@link deriveFulfillment}(secret))
6650
- * before sending: the terminating connector recovers the same secret by
6651
- * opening this wrap, so the preimage it is paid against is one it derived, not
6652
- * one anybody handed it.
6653
- */
6654
- declare function sealRequest(plaintext: Uint8Array, receiverPublicKey: Uint8Array): SealedRequest;
6655
- /**
6656
- * Open a sealed request addressed to `identity`, recovering the encoded
6657
- * envelope and the shared secret carried alongside it.
6658
- *
6659
- * `identity` is either a 32-byte secp256k1 secret key or a {@link GiftWrapEcdh}
6660
- * that never exposes one. Nothing in this client terminates packets today, so
6661
- * this exists to make the seal testable from both ends — and to make the
6662
- * vectors' "opening it with the fixture's secret key must recover the envelope
6663
- * and the secret exactly" a check this repo can actually run.
6664
- */
6665
- declare function openRequest(bytes: Uint8Array, identity: Uint8Array | GiftWrapEcdh): OpenedRequest;
6666
- /**
6667
- * The deterministic core of {@link sealResponse}, parameterized on the nonce.
6668
- * Same footgun, same warning as {@link sealRequestWithRandomness}: a nonce
6669
- * reused under one shared secret destroys the confidentiality of both
6670
- * responses sealed with it.
6671
- */
6672
- declare function sealResponseWithRandomness(sharedSecret: Uint8Array, plaintext: Uint8Array, nonce: Uint8Array): Uint8Array;
6673
- /**
6674
- * Seal `plaintext` — an encoded response envelope, or a reject's diagnostic
6675
- * bytes — with the request's own `sharedSecret`. No second key exchange: the
6676
- * secret is bidirectional by construction, which is also why a sealed reject
6677
- * can only have come from the termination.
6678
- */
6679
- declare function sealResponse(sharedSecret: Uint8Array, plaintext: Uint8Array): Uint8Array;
6680
- /**
6681
- * Open a sealed response with the shared secret {@link sealRequest} returned
6682
- * for the request it answers. No signer, no key exchange, no identity key.
6683
- */
6684
- declare function openResponse(sharedSecret: Uint8Array, bytes: Uint8Array): Uint8Array;
6685
- /**
6686
- * Whether `bytes` is shaped like a sealed response — the leading type byte and
6687
- * nothing else, exactly as `looks_like_sealed_response` does it. This is how a
6688
- * sender tells a reject raised BY the destination from one raised on the way
6689
- * to it, without holding the secret to try opening it.
6690
- *
6691
- * Empty `data`, which every reject raised short of a termination carries, is
6692
- * never sealed.
6693
- */
6694
- declare function looksLikeSealedResponse(bytes: Uint8Array): boolean;
6695
- /**
6696
- * The fulfilment a request's shared secret derives (ADR 0019):
6697
- * `HKDF-SHA256(shared_secret, "toon-giftwrap-fulfillment")`, 32 bytes.
6698
- * Domain-separated by its own `info` string from both AEAD keys the same
6699
- * secret also derives, so it can never collide with either.
6700
- */
6701
- declare function deriveFulfillment(sharedSecret: Uint8Array): Uint8Array;
6702
- /**
6703
- * The condition a `fulfillment` satisfies: `sha256(fulfillment)` —
6704
- * `connector_domain::condition::derive_condition`. Hashing only ever runs in
6705
- * this direction; there is deliberately no function here that goes from a
6706
- * condition back to a fulfilment.
6707
- *
6708
- * The hash is the same one `utils/condition.ts` already uses; what ADR 0019
6709
- * changes is where the preimage comes from. `mintExecutionCondition` there
6710
- * draws a random preimage the sender must then carry to the FULFILL itself;
6711
- * here the preimage is DERIVED from the secret sealed inside the packet, so
6712
- * the terminating connector can produce it without the sender or the app
6713
- * handing it over. Checking a returned fulfilment against a condition is
6714
- * unchanged either way — use `fulfillmentMatchesCondition` from
6715
- * `utils/condition.ts` for that rather than a second copy of it here.
6716
- */
6717
- declare function deriveCondition(fulfillment: Uint8Array): Uint8Array;
6718
-
6719
6853
  /**
6720
6854
  * One sealed request/answer exchange with a terminating connector (ADR 0018,
6721
6855
  * ADR 0019, ADR 0020) — the whole shape of a packet's payload, from the
@@ -6876,4 +7010,4 @@ declare function readExchangeOutcome(result: {
6876
7010
  /** Read a response header, case-insensitively; the first match wins. */
6877
7011
  declare function envelopeHeader(response: EnvelopeResponse, name: string): string | undefined;
6878
7012
 
6879
- 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 };