@toon-protocol/client 0.9.2 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _toon_protocol_core from '@toon-protocol/core';
2
- import { IlpPeerInfo, NetworkFamilyStatus, IlpSendResult, IlpClient, ConnectorAdminClient, ConnectorChannelClient, OpenChannelParams, OpenChannelResult, ChannelState } from '@toon-protocol/core';
3
- import { NostrEvent } from 'nostr-tools/pure';
2
+ import { IlpPeerInfo, IlpClient, IlpSendResult, NetworkFamilyStatus, ConnectorAdminClient, ConnectorChannelClient, OpenChannelParams, OpenChannelResult, ChannelState } from '@toon-protocol/core';
3
+ import { NostrEvent, EventTemplate } from 'nostr-tools/pure';
4
4
  import { PrivateKeyAccount } from 'viem/accounts';
5
5
 
6
6
  /**
@@ -199,6 +199,27 @@ interface ToonClientConfig {
199
199
  btpAuthToken?: string;
200
200
  /** Peer ID for BTP connection (used in connector env var BTP_PEER_{ID}_SECRET) */
201
201
  btpPeerId?: string;
202
+ /**
203
+ * ILP-over-HTTP one-shot endpoint of the uplink connector (the `POST /ilp`
204
+ * URL, e.g. "http://localhost:3000/ilp"). When set, the client prefers the
205
+ * stateless {@link HttpIlpClient} transport for one-shot writes instead of
206
+ * opening a persistent BTP WebSocket.
207
+ *
208
+ * This mirrors the `httpEndpoint` field a peer advertises in discovery
209
+ * (`IlpPeerInfo`, toon PR #29). It is surfaced here as explicit config so the
210
+ * default runtime can opt into ILP-over-HTTP before connectors advertise the
211
+ * field on-wire. Leave unset to keep the existing BTP-only behavior (the safe
212
+ * default — no connector advertises an httpEndpoint until the connector + a
213
+ * core release with these fields ship).
214
+ */
215
+ connectorHttpEndpoint?: string;
216
+ /**
217
+ * Whether the uplink connector accepts a BTP `Upgrade` over its HTTP endpoint
218
+ * (mirrors `IlpPeerInfo.supportsUpgrade`, toon PR #29). Only consulted when
219
+ * `connectorHttpEndpoint` is set and a duplex session is required. Defaults to
220
+ * false (no upgrade) when omitted.
221
+ */
222
+ connectorSupportsUpgrade?: boolean;
202
223
  /**
203
224
  * ILP destination address for event publishing.
204
225
  * Defaults to the connector's local address (derived from connectorUrl host).
@@ -391,6 +412,514 @@ type ClientTransportConfig = {
391
412
  gatewayUrl: string;
392
413
  };
393
414
 
415
+ /**
416
+ * Client-side helper for kind:5094 Arweave blob storage DVM requests.
417
+ *
418
+ * This composes the three steps a caller previously had to wire by hand:
419
+ * 1. Build the kind:5094 event via `buildBlobStorageRequest()` (@toon-protocol/core).
420
+ * 2. Publish it to the DVM destination over ILP via `ToonClient.publishEvent()`
421
+ * (reusing the existing claim / channel plumbing).
422
+ * 3. Decode the FULFILL `data` field into the Arweave transaction ID.
423
+ *
424
+ * ## FULFILL data contract
425
+ *
426
+ * For a successful single-packet (non-chunked) blob upload, the DVM provider
427
+ * returns the Arweave transaction ID as a **UTF-8 string, base64-encoded** in
428
+ * the ILP FULFILL `data` field (the connector validates that FULFILL data is
429
+ * base64). An Arweave tx ID is a 43-character base64url string (32 raw bytes).
430
+ *
431
+ * So the decode is:
432
+ * `txId = utf8(base64decode(result.data))`
433
+ *
434
+ * See `packages/sdk/src/arweave/arweave-dvm-handler.ts` for the server side and
435
+ * `packages/client/tests/e2e/docker-arweave-dvm-e2e.test.ts` for the reference
436
+ * end-to-end flow this helper mirrors.
437
+ *
438
+ * Chunked uploads (multi-packet, via `uploadId` / `chunkIndex` / `totalChunks`
439
+ * params) are intentionally out of scope for this single-packet helper — the
440
+ * provider returns `ack:<n>` for intermediate chunks and the tx ID only on the
441
+ * final chunk. Callers needing chunking should drive `publishEvent()` directly
442
+ * (see the chunked case in the reference E2E test). Tracked as a follow-up.
443
+ */
444
+
445
+ /**
446
+ * Parameters for {@link requestBlobStorage}.
447
+ */
448
+ interface RequestBlobStorageParams {
449
+ /** The raw blob data to store on Arweave. */
450
+ blobData: Uint8Array;
451
+ /**
452
+ * MIME type of the blob. Defaults to `'application/octet-stream'`
453
+ * (matching `buildBlobStorageRequest`).
454
+ */
455
+ contentType?: string;
456
+ /**
457
+ * Bid amount in USDC micro-units, as a string (declared in the event's
458
+ * `bid` tag). Defaults to the stringified `ilpAmount` when omitted.
459
+ *
460
+ * At least one of `bid` / `ilpAmount` should be provided so the declared
461
+ * bid and the paid ILP amount agree.
462
+ */
463
+ bid?: string;
464
+ /**
465
+ * ILP destination address of the DVM that performs the upload
466
+ * (e.g. `'g.toon.peer1'`). Falls back to the client's configured
467
+ * `destinationAddress` when omitted.
468
+ */
469
+ destination?: string;
470
+ /**
471
+ * Pre-signed balance proof claim for this packet. When omitted, the
472
+ * client's channel manager auto-opens a channel and auto-signs a claim
473
+ * (same lazy-channel behavior as `publishEvent`).
474
+ */
475
+ claim?: SignedBalanceProof;
476
+ /**
477
+ * Explicit ILP payment amount (bigint micro-units). When omitted,
478
+ * `publishEvent` computes it from the encoded event size. When `bid`
479
+ * is omitted, this value is stringified to populate the event's bid tag.
480
+ */
481
+ ilpAmount?: bigint;
482
+ }
483
+ /**
484
+ * Typed result of {@link requestBlobStorage}.
485
+ */
486
+ interface RequestBlobStorageResult {
487
+ /** Whether the upload succeeded and a tx ID was decoded. */
488
+ success: boolean;
489
+ /** The Arweave transaction ID (43-char base64url) when `success` is true. */
490
+ txId?: string;
491
+ /** The id of the kind:5094 event that was published. */
492
+ eventId?: string;
493
+ /** Error message when `success` is false. */
494
+ error?: string;
495
+ }
496
+ /**
497
+ * Requests permanent Arweave blob storage from a DVM in a single ILP packet.
498
+ *
499
+ * Mirrors the single-packet flow in
500
+ * `packages/client/tests/e2e/docker-arweave-dvm-e2e.test.ts`: builds a signed
501
+ * kind:5094 event, publishes it through the supplied {@link ToonClient}
502
+ * (reusing its claim/channel plumbing), and decodes the FULFILL `data` field
503
+ * into an Arweave transaction ID.
504
+ *
505
+ * @param client - A started `ToonClient` (call `client.start()` first).
506
+ * @param secretKey - The Nostr secret key used to sign the kind:5094 event.
507
+ * @param params - Blob, content type, bid, destination, and payment options.
508
+ * @returns `{ success, txId?, eventId?, error? }`.
509
+ */
510
+ declare function requestBlobStorage(client: ToonClient, secretKey: Uint8Array, params: RequestBlobStorageParams): Promise<RequestBlobStorageResult>;
511
+
512
+ interface BtpRuntimeClientConfig {
513
+ btpUrl: string;
514
+ peerId: string;
515
+ authToken: string;
516
+ /** Max reconnection attempts on send failure (default: 3) */
517
+ maxRetries?: number;
518
+ /** Delay between reconnection attempts in ms (default: 1000) */
519
+ retryDelay?: number;
520
+ /** Custom WebSocket constructor (for SOCKS5 proxy support). */
521
+ createWebSocket?: (url: string) => WebSocket;
522
+ }
523
+ /**
524
+ * BTP transport implementing IlpClient.
525
+ * Uses IsomorphicBtpClient (browser-native, no Node.js dependencies).
526
+ */
527
+ declare class BtpRuntimeClient implements IlpClient {
528
+ private btpClient;
529
+ private readonly config;
530
+ private _isConnected;
531
+ constructor(config: BtpRuntimeClientConfig);
532
+ /**
533
+ * Connects to the BTP peer via WebSocket.
534
+ */
535
+ connect(): Promise<void>;
536
+ /**
537
+ * Attempts to reconnect by creating a fresh client and connecting.
538
+ */
539
+ reconnect(): Promise<void>;
540
+ /**
541
+ * Disconnects from the BTP peer.
542
+ */
543
+ disconnect(): Promise<void>;
544
+ get isConnected(): boolean;
545
+ /**
546
+ * Sends an ILP packet via BTP with auto-reconnect on connection errors.
547
+ * Satisfies IlpClient interface.
548
+ */
549
+ sendIlpPacket(params: {
550
+ destination: string;
551
+ amount: string;
552
+ data: string;
553
+ timeout?: number;
554
+ }): Promise<IlpSendResult>;
555
+ /**
556
+ * Sends a balance proof claim via BTP protocol data, then sends an ILP packet.
557
+ * Auto-reconnects on connection errors.
558
+ */
559
+ sendIlpPacketWithClaim(params: {
560
+ destination: string;
561
+ amount: string;
562
+ data: string;
563
+ timeout?: number;
564
+ }, claim: Record<string, unknown>): Promise<IlpSendResult>;
565
+ /**
566
+ * Send a standalone `payment-channel-claim` BTP MESSAGE (no ILP packet
567
+ * attached). The connector's ClaimReceiver consumes this fire-and-forget
568
+ * to register cumulative claim state independently of the per-packet
569
+ * forwarding path. Auto-reconnects on connection errors.
570
+ */
571
+ sendClaimMessage(claim: Record<string, unknown>): Promise<void>;
572
+ private _sendClaimMessageOnce;
573
+ /**
574
+ * Single-attempt ILP packet send. Reconnects if not connected.
575
+ */
576
+ private _sendIlpPacketOnce;
577
+ /**
578
+ * Single-attempt claim + ILP packet send. Reconnects if not connected.
579
+ */
580
+ private _sendIlpPacketWithClaimOnce;
581
+ }
582
+
583
+ /**
584
+ * ILP-over-HTTP (RFC-0035) transport for the TOON client.
585
+ *
586
+ * The connector now serves ILP-over-HTTP on the SAME port as BTP (connector
587
+ * PR #181). This adapter lets a client do stateless one-shot writes over HTTP
588
+ * (`POST /ilp`) and upgrade to a duplex BTP session when it needs to receive
589
+ * server-initiated packets or act as a peer.
590
+ *
591
+ * Wire contract (targets connector PR #181's `/ilp`):
592
+ * - One-shot write: `POST /ilp`
593
+ * body: OER-encoded ILP PREPARE (`application/octet-stream`)
594
+ * header: `ILP-Payment-Channel-Claim: base64(JSON of the claim)` — the
595
+ * SAME claim JSON the BTP path attaches as the
596
+ * `payment-channel-claim` protocolData entry.
597
+ * optional: `ILP-Peer-Id` + `Authorization: Bearer <secret>` identity.
598
+ * response: `200 OK` with an OER FULFILL or REJECT body. HTTP non-2xx is
599
+ * reserved for TRANSPORT errors (400/401/413/5xx); ILP-level
600
+ * rejects come back as a 200 + REJECT body.
601
+ * - Upgrade to BTP: standard HTTP `Upgrade` with `Sec-WebSocket-Protocol: btp`
602
+ * plus the same `ILP-Peer-Id` + `Authorization` headers. The connector
603
+ * pre-authenticates the BTP session from those headers (continuity), so
604
+ * after `101` we send BTP frames WITHOUT a separate in-band auth frame.
605
+ * Omitting the auth headers falls back to the normal BTP auth-frame flow.
606
+ *
607
+ * Reuses `serializeIlpPrepare`/`deserializeIlpPacket` from `btp/protocol.ts` —
608
+ * the SAME OER codec the BTP path uses. Claim signing/construction is owned by
609
+ * the caller (BootstrapService); this transport never builds or signs claims.
610
+ */
611
+
612
+ /** Header carrying the base64(JSON) payment-channel claim. */
613
+ declare const ILP_CLAIM_HEADER = "ILP-Payment-Channel-Claim";
614
+ /** Header carrying a NIP-59 wrapped (gift-wrapped) claim. */
615
+ declare const ILP_CLAIM_WRAPPED_HEADER = "ILP-Payment-Channel-Claim-Wrapped";
616
+ /** Header carrying the peer identity. */
617
+ declare const ILP_PEER_ID_HEADER = "ILP-Peer-Id";
618
+ interface HttpIlpClientConfig {
619
+ /** The peer's `POST /ilp` URL (the `httpEndpoint` from discovery). */
620
+ httpEndpoint: string;
621
+ /**
622
+ * Optional peer identity. With no `peerId`/`authToken` the connector treats
623
+ * the request as an anonymous no-auth peer (permissionless default) and
624
+ * derives an ephemeral id from the claim signer.
625
+ */
626
+ peerId?: string;
627
+ /** Bearer secret for `Authorization`. Omit for the no-auth peer path. */
628
+ authToken?: string;
629
+ /** Request timeout in milliseconds (default: 30000). */
630
+ timeout?: number;
631
+ /** Max retry attempts for transport-level network failures (default: 3). */
632
+ maxRetries?: number;
633
+ /** Initial retry delay in milliseconds (default: 1000). */
634
+ retryDelay?: number;
635
+ /** Custom fetch implementation (SOCKS5 mode / testing). */
636
+ httpClient?: typeof fetch;
637
+ /**
638
+ * Custom WebSocket constructor for the BTP upgrade path (SOCKS5 mode).
639
+ * Forwarded to the underlying BtpRuntimeClient.
640
+ */
641
+ createWebSocket?: (url: string) => WebSocket;
642
+ }
643
+ /**
644
+ * Stateless ILP-over-HTTP transport implementing `IlpClient`.
645
+ *
646
+ * Use this for pure one-shot consumers (publish-and-forget writes). When the
647
+ * client needs a duplex session — to receive server-initiated packets or to act
648
+ * as a peer — call {@link upgradeToBtp} to obtain a connected BtpRuntimeClient
649
+ * that reuses the existing BTP code path.
650
+ */
651
+ declare class HttpIlpClient implements IlpClient {
652
+ private readonly httpEndpoint;
653
+ private readonly peerId;
654
+ private readonly authToken;
655
+ private readonly timeout;
656
+ private readonly retryConfig;
657
+ private readonly httpClient;
658
+ private readonly createWebSocket;
659
+ constructor(config: HttpIlpClientConfig);
660
+ /**
661
+ * Send an ILP PREPARE via `POST /ilp` WITHOUT a claim. The connector accepts
662
+ * this only on free/zero-amount routes; paid writes must use
663
+ * {@link sendIlpPacketWithClaim}. Satisfies the IlpClient interface.
664
+ */
665
+ sendIlpPacket(params: {
666
+ destination: string;
667
+ amount: string;
668
+ data: string;
669
+ timeout?: number;
670
+ }): Promise<IlpSendResult>;
671
+ /**
672
+ * Send an ILP PREPARE via `POST /ilp` with the payment-channel claim attached
673
+ * as the `ILP-Payment-Channel-Claim` header. `claim` is the SAME JSON object
674
+ * the BTP path attaches as the `payment-channel-claim` protocolData entry —
675
+ * we base64(JSON.stringify(claim)) it, byte-for-byte identical to BTP.
676
+ */
677
+ sendIlpPacketWithClaim(params: {
678
+ destination: string;
679
+ amount: string;
680
+ data: string;
681
+ timeout?: number;
682
+ }, claim: unknown): Promise<IlpSendResult>;
683
+ /**
684
+ * Upgrade to a duplex BTP session over the SAME endpoint.
685
+ *
686
+ * Derives the `ws(s)://` URL from `httpEndpoint`, opens a WebSocket with
687
+ * `Sec-WebSocket-Protocol: btp` and the same `ILP-Peer-Id` + `Authorization`
688
+ * headers, and returns a connected {@link BtpRuntimeClient}. When auth headers
689
+ * are present the connector pre-authenticates the session (no in-band auth
690
+ * frame); without them the BtpRuntimeClient falls back to the normal BTP
691
+ * auth-frame flow.
692
+ *
693
+ * NOTE: passing per-connection headers + a subprotocol to a WebSocket is
694
+ * Node-only (the `ws` package). Browsers cannot set arbitrary request headers
695
+ * on a WebSocket handshake, so a browser consumer must use the gateway
696
+ * transport or BTP-with-auth-frame instead.
697
+ */
698
+ upgradeToBtp(): Promise<BtpRuntimeClient>;
699
+ private authHeaders;
700
+ /**
701
+ * Single attempt: serialize the PREPARE, POST it, and map the response.
702
+ * @throws {NetworkError} On connection/timeout failures (retried).
703
+ * @throws {ConnectorError} On non-retryable transport errors (5xx / unexpected).
704
+ */
705
+ private postPrepare;
706
+ /**
707
+ * Map a `200 OK` body (OER FULFILL/REJECT) to an IlpSendResult; map a non-2xx
708
+ * to a transport error. Per the wire contract, ILP-level rejects arrive as a
709
+ * 200 + REJECT body — only HTTP non-2xx means a transport-layer failure.
710
+ */
711
+ private mapResponse;
712
+ private mapTransportError;
713
+ }
714
+ /**
715
+ * Derive the BTP WebSocket URL from a `POST /ilp` HTTP endpoint. The connector
716
+ * serves BTP on the SAME path, so we only swap the scheme (http→ws, https→wss).
717
+ */
718
+ declare function httpEndpointToBtpUrl(httpEndpoint: string): string;
719
+
720
+ /**
721
+ * Payment-aware HTTP fetch over TOON (the "h402" flow).
722
+ *
723
+ * This adapter makes paying for an HTTP resource transparent: it issues an
724
+ * ordinary HTTP request, and when the origin answers `402 Payment Required`
725
+ * with an x402-style challenge that offers a `toon-channel` payment option, it
726
+ * opens/reuses a payment channel, signs a balance-proof claim, and re-sends the
727
+ * SAME HTTP request as a "transparent HTTP-in-ILP" packet to the connector's
728
+ * `POST /ilp` endpoint (via {@link HttpIlpClient}). The connector terminates the
729
+ * payment, forwards the request to the origin, and returns the origin's HTTP
730
+ * response inside the ILP FULFILL `data`. We reconstruct a normal Web `Response`
731
+ * from those bytes — the caller never sees ILP.
732
+ *
733
+ * ─── x402 wire contract (the 402 challenge body) ────────────────────────────
734
+ * The connector side (the 402 greeting + the `accepts` entries) is a separate,
735
+ * NOT-YET-BUILT dependency, so we parse DEFENSIVELY (mirroring
736
+ * `readDiscoveredIlpPeer` in selectIlpTransport.ts): a slightly different
737
+ * connector shape should degrade gracefully (fall back to the vanilla 402)
738
+ * rather than throw.
739
+ *
740
+ * Expected 402 JSON body (x402 v1-ish):
741
+ * ```jsonc
742
+ * {
743
+ * "x402Version": 1,
744
+ * "accepts": [
745
+ * {
746
+ * "scheme": "toon-channel", // REQUIRED — selects the TOON option.
747
+ * "network": "evm:base:8453", // optional — chain key (informational).
748
+ * "destination": "g.toon.apex", // ILP destination address to pay (the
749
+ * // connector route that fronts the URL).
750
+ * "amount": "1000", // price in ILP base units (string|number).
751
+ * "httpEndpoint": "https://apex/ilp", // the connector's POST /ilp URL.
752
+ * "supportsUpgrade": true // optional — host accepts the BTP upgrade.
753
+ * }
754
+ * ]
755
+ * }
756
+ * ```
757
+ *
758
+ * Field aliases read defensively (first present wins):
759
+ * - destination: `destination` | `ilpAddress` | `payTo` | `maxAmountRequired`'s
760
+ * sibling `payTo`. (We do NOT invent a value — a missing destination makes
761
+ * the entry unusable and we fall back to the vanilla 402.)
762
+ * - amount: `amount` | `price` | `maxAmountRequired`.
763
+ * - httpEndpoint:`httpEndpoint` | `ilpEndpoint` | `endpoint`.
764
+ * - upgrade: `supportsUpgrade` | `upgradable`.
765
+ *
766
+ * ─── HTTP-in-ILP framing ────────────────────────────────────────────────────
767
+ * The raw HTTP request/response is serialized as minimal HTTP/1.1 wire bytes
768
+ * (request-line / status-line + headers + CRLFCRLF + body) and carried as the
769
+ * ILP packet `data` (base64). See {@link serializeHttpRequest} /
770
+ * {@link parseHttpResponse}. This keeps the connector free to forward the bytes
771
+ * verbatim and lets us rebuild a standard `Response`.
772
+ *
773
+ * Claim signing/construction is owned by the CALLER (ToonClient wires the live
774
+ * ChannelManager + signer). This adapter never builds or validates claims —
775
+ * payment-claim validation lives ONLY in the connector.
776
+ */
777
+
778
+ /** A single parsed `accepts` entry that offers the `toon-channel` scheme. */
779
+ interface ToonChannelAccept {
780
+ /** Always `'toon-channel'` for a matched entry. */
781
+ scheme: 'toon-channel';
782
+ /** Optional chain key, e.g. `evm:base:8453` — informational. */
783
+ network?: string;
784
+ /** ILP destination address to pay (the connector route fronting the URL). */
785
+ destination: string;
786
+ /** Price in ILP base units. */
787
+ amount: bigint;
788
+ /** The connector's `POST /ilp` URL. */
789
+ httpEndpoint: string;
790
+ /** Whether the host accepts the BTP upgrade over the HTTP endpoint. */
791
+ supportsUpgrade: boolean;
792
+ }
793
+ /** The parsed x402 402 body, with the selected `toon-channel` entry (if any). */
794
+ interface ParsedX402Challenge {
795
+ x402Version?: number;
796
+ /** The first usable `toon-channel` accepts entry, or `undefined`. */
797
+ toonChannel?: ToonChannelAccept;
798
+ }
799
+ /** Options for {@link Http402Client.fetch} / `ToonClient.h402Fetch`. */
800
+ interface H402FetchOptions {
801
+ /** HTTP method. Default `'GET'`. */
802
+ method?: string;
803
+ /** Request headers. */
804
+ headers?: Record<string, string>;
805
+ /** Request body. */
806
+ body?: string | Uint8Array;
807
+ /** Request timeout in milliseconds. */
808
+ timeout?: number;
809
+ /** Optional explicit ILP destination override (else the x402 entry's value). */
810
+ destination?: string;
811
+ }
812
+ /**
813
+ * Caller-supplied hook that signs a balance-proof claim for `(destination,
814
+ * amount)` and returns the chain-appropriate claim message to attach to the ILP
815
+ * PREPARE. ToonClient wires this to its ChannelManager + per-chain signer (the
816
+ * exact same plumbing as `publishEvent`). The returned value is forwarded
817
+ * opaquely as the `ILP-Payment-Channel-Claim` header by {@link HttpIlpClient}.
818
+ */
819
+ type ClaimResolver = (destination: string, amount: bigint) => Promise<unknown>;
820
+ /** Factory for an {@link HttpIlpClient} given a resolved `POST /ilp` endpoint. */
821
+ type HttpIlpClientFactory = (httpEndpoint: string) => HttpIlpClient;
822
+ interface Http402ClientConfig {
823
+ /**
824
+ * Underlying HTTP fetch for the INITIAL (un-paid) request that probes for a
825
+ * 402. Default: global `fetch`.
826
+ */
827
+ fetch?: typeof fetch;
828
+ /**
829
+ * Resolves + signs the payment-channel claim. REQUIRED to pay; if omitted,
830
+ * a 402 with a `toon-channel` offer is surfaced unchanged (vanilla challenge).
831
+ */
832
+ resolveClaim?: ClaimResolver;
833
+ /**
834
+ * Builds the {@link HttpIlpClient} for a resolved endpoint. Default: construct
835
+ * a new `HttpIlpClient({ httpEndpoint })`. Injectable for tests / SOCKS5.
836
+ */
837
+ createIlpClient?: HttpIlpClientFactory;
838
+ /**
839
+ * AC4: request a duplex transport for the paid send. When `true` and the
840
+ * toon-channel entry advertises `supportsUpgrade`, {@link selectIlpTransport}
841
+ * returns `http-upgradable` and the send path calls
842
+ * {@link HttpIlpClient.upgradeToBtp} before writing — the wiring for
843
+ * large/streaming responses. Default `false` (stateless one-shot HTTP).
844
+ *
845
+ * NOTE (v1 limitation): even on the upgrade path the actual write is still a
846
+ * one-shot `sendIlpPacketWithClaim`; full duplex body streaming over the BTP
847
+ * session is a documented follow-up. The selection + upgrade CALL PATH is
848
+ * wired and exercised here so the streaming consumer can take over the
849
+ * returned session in a later iteration.
850
+ */
851
+ needsDuplex?: boolean;
852
+ }
853
+ /**
854
+ * Reusable h402 fetch engine. `ToonClient.h402Fetch` is a thin wrapper that
855
+ * constructs this with the live claim/channel plumbing.
856
+ */
857
+ declare class Http402Client {
858
+ private readonly fetchImpl;
859
+ private readonly resolveClaim?;
860
+ private readonly createIlpClient;
861
+ private readonly needsDuplex;
862
+ constructor(config?: Http402ClientConfig);
863
+ /**
864
+ * `fetch()`-like entry point. Issues the request; on `402` parses the x402
865
+ * challenge and — when a usable `toon-channel` offer is present and a claim
866
+ * resolver is configured — pays over TOON and returns the reconstructed
867
+ * `Response`. Otherwise returns the original 402 unchanged (AC5).
868
+ */
869
+ fetch(url: string, opts?: H402FetchOptions): Promise<Response>;
870
+ /**
871
+ * Open/reuse a channel (via the injected claim resolver), serialize the HTTP
872
+ * request into the ILP packet `data`, send it to `POST /ilp` with the claim,
873
+ * and reconstruct the origin `Response` from the FULFILL `data`.
874
+ */
875
+ private payOverToon;
876
+ /**
877
+ * Send the serialized HTTP-in-ILP PREPARE over the selected transport.
878
+ *
879
+ * - `http` / `http-upgradable`: stateless one-shot `POST /ilp` with the claim.
880
+ * - `http-upgradable` additionally exercises {@link HttpIlpClient.upgradeToBtp}
881
+ * for the duplex/streaming path (AC4). v1 still drives the actual write over
882
+ * the one-shot HTTP method even after upgrading — full duplex body streaming
883
+ * is a documented follow-up — but the upgrade call path is wired here.
884
+ * - `btp`: not reachable from h402 (the x402 offer only carries an
885
+ * `httpEndpoint`); guarded for completeness.
886
+ */
887
+ private sendOverChoice;
888
+ }
889
+ /**
890
+ * Parse a 402 `Response` body into a {@link ParsedX402Challenge}, selecting the
891
+ * first usable `toon-channel` entry. Reads every field defensively; a malformed
892
+ * body, a non-JSON body, or an entry missing its `destination`/`httpEndpoint`
893
+ * yields `{ toonChannel: undefined }` so the caller falls back to the vanilla
894
+ * 402 rather than throwing.
895
+ */
896
+ declare function parseX402Challenge(response: Response): Promise<ParsedX402Challenge>;
897
+ /** Pure parser over an already-decoded x402 body (testable without a Response). */
898
+ declare function parseX402Body(body: unknown): ParsedX402Challenge;
899
+ /**
900
+ * Serialize a raw HTTP request to HTTP/1.1 wire bytes:
901
+ * `METHOD path HTTP/1.1\r\n` + `Host:` + headers + `\r\n\r\n` + body.
902
+ *
903
+ * The request-line target is the URL's path+query (origin-form); we add a
904
+ * `Host` header from the URL authority and a `Content-Length` when there's a
905
+ * body, unless the caller already supplied them. Header names are matched
906
+ * case-insensitively so we never duplicate `Host`/`Content-Length`.
907
+ */
908
+ declare function serializeHttpRequest(req: {
909
+ method: string;
910
+ url: string;
911
+ headers?: Record<string, string>;
912
+ body?: string | Uint8Array;
913
+ }): Uint8Array;
914
+ /**
915
+ * Parse HTTP/1.1 wire bytes (status-line + headers + CRLFCRLF + body) into a
916
+ * standard Web `Response`. Used to reconstruct the origin response from the ILP
917
+ * FULFILL `data`.
918
+ *
919
+ * @throws {ConnectorError} If the bytes are not a parseable HTTP/1.1 response.
920
+ */
921
+ declare function parseHttpResponse(bytes: Uint8Array): Response;
922
+
394
923
  /**
395
924
  * ToonClient - High-level client for interacting with TOON network.
396
925
  *
@@ -469,6 +998,30 @@ declare class ToonClient {
469
998
  * Works before start() is called.
470
999
  */
471
1000
  getPublicKey(): string;
1001
+ /**
1002
+ * Sign an unsigned Nostr event template with the client's Nostr secret key,
1003
+ * returning a fully-signed event (id + pubkey + sig).
1004
+ *
1005
+ * This is the key primitive behind the daemon's sign-and-publish path: a UI
1006
+ * or agent supplies only `{ kind, content, tags, created_at }` and never holds
1007
+ * the private key — signing happens here, inside the key owner.
1008
+ */
1009
+ signEvent(template: EventTemplate): NostrEvent;
1010
+ /**
1011
+ * Upload bytes to Arweave via the kind:5094 blob-storage DVM (single-packet),
1012
+ * signing the request with this client's Nostr key and paying through its
1013
+ * existing channel. Returns the Arweave tx id on success.
1014
+ *
1015
+ * Backs the daemon's `upload-media` path: the key and claim/channel plumbing
1016
+ * stay inside the client; callers pass only the bytes.
1017
+ */
1018
+ uploadBlob(params: {
1019
+ blobData: Uint8Array;
1020
+ contentType?: string;
1021
+ bid?: string;
1022
+ destination?: string;
1023
+ ilpAmount?: bigint;
1024
+ }): Promise<RequestBlobStorageResult>;
472
1025
  /**
473
1026
  * Per-chain settlement readiness for the configured `network` tier, mirroring
474
1027
  * the townhouse node's status. Returns `undefined` when no named `network` is
@@ -526,6 +1079,33 @@ declare class ToonClient {
526
1079
  claim?: SignedBalanceProof;
527
1080
  ilpAmount?: bigint;
528
1081
  }): Promise<PublishEventResult>;
1082
+ /**
1083
+ * Payment-aware HTTP fetch over TOON (issue #50). A `fetch()`-like method that
1084
+ * makes paying for an HTTP resource transparent:
1085
+ *
1086
+ * 1. Issues the HTTP request to `url`.
1087
+ * 2. On `402`, parses the x402 `accepts` array and selects the
1088
+ * `toon-channel` entry (see {@link Http402Client} for the wire shape).
1089
+ * 3. Opens/reuses a payment channel for the entry's ILP destination (via
1090
+ * ChannelManager), signs a balance proof for the demanded price, and
1091
+ * re-sends the SAME HTTP request as a transparent HTTP-in-ILP packet to
1092
+ * the connector's `POST /ilp` (via {@link HttpIlpClient}), with the claim
1093
+ * in the `ILP-Payment-Channel-Claim` header.
1094
+ * 4. Reconstructs and returns a standard Web `Response` from the FULFILL
1095
+ * `data`. The caller never sees ILP.
1096
+ *
1097
+ * If the origin offers no `toon-channel` entry, the original `402` Response is
1098
+ * returned unchanged (the caller sees the vanilla x402 challenge).
1099
+ *
1100
+ * The channel/claim plumbing is wired to the live ChannelManager + per-chain
1101
+ * signer via `resolveClaimForDestination` — identical to `publishEvent`. The
1102
+ * `amount` paid comes from the selected x402 entry (the resource's price).
1103
+ *
1104
+ * @throws {ToonClientError} If the client is not started.
1105
+ * @throws {ConnectorError} If the connector rejects the payment or returns no
1106
+ * HTTP payload.
1107
+ */
1108
+ h402Fetch(url: string, opts?: H402FetchOptions): Promise<Response>;
529
1109
  /**
530
1110
  * Sends a raw swap ILP packet (Story 12.5) to a Mill peer with an attached
531
1111
  * balance-proof claim. This is a lower-level surface than `publishEvent`:
@@ -1041,76 +1621,78 @@ declare class HttpConnectorAdmin implements ConnectorAdminClient {
1041
1621
  private handleErrorResponse;
1042
1622
  }
1043
1623
 
1044
- interface BtpRuntimeClientConfig {
1045
- btpUrl: string;
1046
- peerId: string;
1047
- authToken: string;
1048
- /** Max reconnection attempts on send failure (default: 3) */
1049
- maxRetries?: number;
1050
- /** Delay between reconnection attempts in ms (default: 1000) */
1051
- retryDelay?: number;
1052
- /** Custom WebSocket constructor (for SOCKS5 proxy support). */
1053
- createWebSocket?: (url: string) => WebSocket;
1054
- }
1055
1624
  /**
1056
- * BTP transport implementing IlpClient.
1057
- * Uses IsomorphicBtpClient (browser-native, no Node.js dependencies).
1058
- */
1059
- declare class BtpRuntimeClient implements IlpClient {
1060
- private btpClient;
1061
- private readonly config;
1062
- private _isConnected;
1063
- constructor(config: BtpRuntimeClientConfig);
1064
- /**
1065
- * Connects to the BTP peer via WebSocket.
1066
- */
1067
- connect(): Promise<void>;
1068
- /**
1069
- * Attempts to reconnect by creating a fresh client and connecting.
1070
- */
1071
- reconnect(): Promise<void>;
1072
- /**
1073
- * Disconnects from the BTP peer.
1074
- */
1075
- disconnect(): Promise<void>;
1076
- get isConnected(): boolean;
1077
- /**
1078
- * Sends an ILP packet via BTP with auto-reconnect on connection errors.
1079
- * Satisfies IlpClient interface.
1080
- */
1081
- sendIlpPacket(params: {
1082
- destination: string;
1083
- amount: string;
1084
- data: string;
1085
- timeout?: number;
1086
- }): Promise<IlpSendResult>;
1087
- /**
1088
- * Sends a balance proof claim via BTP protocol data, then sends an ILP packet.
1089
- * Auto-reconnects on connection errors.
1090
- */
1091
- sendIlpPacketWithClaim(params: {
1092
- destination: string;
1093
- amount: string;
1094
- data: string;
1095
- timeout?: number;
1096
- }, claim: Record<string, unknown>): Promise<IlpSendResult>;
1097
- /**
1098
- * Send a standalone `payment-channel-claim` BTP MESSAGE (no ILP packet
1099
- * attached). The connector's ClaimReceiver consumes this fire-and-forget
1100
- * to register cumulative claim state independently of the per-packet
1101
- * forwarding path. Auto-reconnects on connection errors.
1102
- */
1103
- sendClaimMessage(claim: Record<string, unknown>): Promise<void>;
1104
- private _sendClaimMessageOnce;
1105
- /**
1106
- * Single-attempt ILP packet send. Reconnects if not connected.
1107
- */
1108
- private _sendIlpPacketOnce;
1625
+ * Transport selection policy for the client ILP layer.
1626
+ *
1627
+ * The connector serves ILP-over-HTTP (`POST /ilp`) and BTP on the SAME port
1628
+ * (connector PR #181). A peer advertises this in discovery via the toon-core
1629
+ * `IlpPeerInfo` fields added in toon PR #29:
1630
+ * - `httpEndpoint?: string` — the `POST /ilp` URL.
1631
+ * - `supportsUpgrade?: boolean` — whether the host accepts the BTP upgrade.
1632
+ *
1633
+ * Those fields may not yet exist on the installed `@toon-protocol/core`
1634
+ * `IlpPeerInfo` type, so we read them defensively here (see `DiscoveredIlpPeer`).
1635
+ *
1636
+ * Policy:
1637
+ * - Pure one-shot consumers (`needsDuplex: false`) prefer HTTP when the peer
1638
+ * advertises an `httpEndpoint` stateless, no persistent socket.
1639
+ * - Clients that must receive server-initiated packets or act as a peer
1640
+ * (`needsDuplex: true`) use BTP. If the peer only exposes `httpEndpoint`
1641
+ * and `supportsUpgrade` is true, we go HTTP-then-upgrade; otherwise we
1642
+ * connect to the BTP endpoint directly.
1643
+ */
1644
+ /**
1645
+ * The subset of discovery fields this policy reads. Structurally compatible with
1646
+ * core's `IlpPeerInfo`; `httpEndpoint`/`supportsUpgrade` are optional so a
1647
+ * pre-PR-#29 `IlpPeerInfo` can be passed through a cast.
1648
+ */
1649
+ interface DiscoveredIlpPeer {
1650
+ /** BTP WebSocket endpoint (always present on a TOON peer). */
1651
+ btpEndpoint?: string;
1652
+ /** `POST /ilp` URL (toon PR #29). */
1653
+ httpEndpoint?: string;
1654
+ /** Whether the host accepts the BTP upgrade over the HTTP endpoint (toon PR #29). */
1655
+ supportsUpgrade?: boolean;
1656
+ }
1657
+ type IlpTransportChoice =
1658
+ /** Stateless one-shot writes via `POST /ilp`. */
1659
+ {
1660
+ kind: 'http';
1661
+ httpEndpoint: string;
1662
+ canUpgrade: boolean;
1663
+ }
1664
+ /** Duplex BTP session via the WebSocket endpoint. */
1665
+ | {
1666
+ kind: 'btp';
1667
+ btpEndpoint: string;
1668
+ }
1669
+ /**
1670
+ * Open HTTP first (one-shot writes) but upgrade to BTP when duplex is needed.
1671
+ * Only chosen when the peer exposes `httpEndpoint` + `supportsUpgrade` and no
1672
+ * separate `btpEndpoint`.
1673
+ */
1674
+ | {
1675
+ kind: 'http-upgradable';
1676
+ httpEndpoint: string;
1677
+ };
1678
+ interface SelectIlpTransportOptions {
1109
1679
  /**
1110
- * Single-attempt claim + ILP packet send. Reconnects if not connected.
1680
+ * Whether the client needs a duplex session (receive server-initiated
1681
+ * packets / act as a peer). Default: false (pure one-shot consumer).
1111
1682
  */
1112
- private _sendIlpPacketWithClaimOnce;
1683
+ needsDuplex?: boolean;
1113
1684
  }
1685
+ /**
1686
+ * Read discovery fields defensively from a (possibly pre-PR-#29) peer info
1687
+ * object. Accepts core's `IlpPeerInfo` or any structurally-compatible shape.
1688
+ */
1689
+ declare function readDiscoveredIlpPeer(peer: unknown): DiscoveredIlpPeer;
1690
+ /**
1691
+ * Choose the ILP transport for a discovered peer given the consumer's needs.
1692
+ *
1693
+ * @throws {Error} If the peer advertises no usable endpoint at all.
1694
+ */
1695
+ declare function selectIlpTransport(peer: DiscoveredIlpPeer, options?: SelectIlpTransportOptions): IlpTransportChoice;
1114
1696
 
1115
1697
  /**
1116
1698
  * Chain-specific metadata (discriminated union).
@@ -1918,7 +2500,7 @@ declare function validateConfig(config: ToonClientConfig): void;
1918
2500
  * The resolved config type after defaults are applied.
1919
2501
  * secretKey is guaranteed to be present (auto-generated if omitted).
1920
2502
  */
1921
- type ResolvedConfig = Required<Omit<ToonClientConfig, 'connector' | 'mnemonic' | 'mnemonicAccountIndex' | 'evmPrivateKey' | 'network' | 'supportedChains' | 'settlementAddresses' | 'preferredTokens' | 'tokenNetworks' | 'btpUrl' | 'btpAuthToken' | 'btpPeerId' | 'chainRpcUrls' | 'initialDeposit' | 'settlementTimeout' | 'solanaChannel' | 'minaChannel' | 'channelStorePath' | 'knownPeers' | 'destinationAddress' | 'transport' | 'managedAnonProxy' | 'managedAnonSocksPort'>> & {
2503
+ type ResolvedConfig = Required<Omit<ToonClientConfig, 'connector' | 'mnemonic' | 'mnemonicAccountIndex' | 'evmPrivateKey' | 'network' | 'supportedChains' | 'settlementAddresses' | 'preferredTokens' | 'tokenNetworks' | 'btpUrl' | 'btpAuthToken' | 'btpPeerId' | 'connectorHttpEndpoint' | 'connectorSupportsUpgrade' | 'chainRpcUrls' | 'initialDeposit' | 'settlementTimeout' | 'solanaChannel' | 'minaChannel' | 'channelStorePath' | 'knownPeers' | 'destinationAddress' | 'transport' | 'managedAnonProxy' | 'managedAnonSocksPort'>> & {
1922
2504
  connector?: unknown;
1923
2505
  /** Always present after applyDefaults() — derived from secretKey if not explicitly provided */
1924
2506
  evmPrivateKey: string | Uint8Array;
@@ -1949,6 +2531,8 @@ type ResolvedConfig = Required<Omit<ToonClientConfig, 'connector' | 'mnemonic' |
1949
2531
  btpUrl?: string;
1950
2532
  btpAuthToken?: string;
1951
2533
  btpPeerId?: string;
2534
+ connectorHttpEndpoint?: string;
2535
+ connectorSupportsUpgrade?: boolean;
1952
2536
  chainRpcUrls?: Record<string, string>;
1953
2537
  initialDeposit?: string;
1954
2538
  settlementTimeout?: number;
@@ -2374,103 +2958,6 @@ declare function filterPetListings(events: NostrEventLike[], options?: PetListin
2374
2958
  */
2375
2959
  declare function buildPetPurchaseRequest(params: PetPurchaseRequestParams): UnsignedNostrEvent;
2376
2960
 
2377
- /**
2378
- * Client-side helper for kind:5094 Arweave blob storage DVM requests.
2379
- *
2380
- * This composes the three steps a caller previously had to wire by hand:
2381
- * 1. Build the kind:5094 event via `buildBlobStorageRequest()` (@toon-protocol/core).
2382
- * 2. Publish it to the DVM destination over ILP via `ToonClient.publishEvent()`
2383
- * (reusing the existing claim / channel plumbing).
2384
- * 3. Decode the FULFILL `data` field into the Arweave transaction ID.
2385
- *
2386
- * ## FULFILL data contract
2387
- *
2388
- * For a successful single-packet (non-chunked) blob upload, the DVM provider
2389
- * returns the Arweave transaction ID as a **UTF-8 string, base64-encoded** in
2390
- * the ILP FULFILL `data` field (the connector validates that FULFILL data is
2391
- * base64). An Arweave tx ID is a 43-character base64url string (32 raw bytes).
2392
- *
2393
- * So the decode is:
2394
- * `txId = utf8(base64decode(result.data))`
2395
- *
2396
- * See `packages/sdk/src/arweave/arweave-dvm-handler.ts` for the server side and
2397
- * `packages/client/tests/e2e/docker-arweave-dvm-e2e.test.ts` for the reference
2398
- * end-to-end flow this helper mirrors.
2399
- *
2400
- * Chunked uploads (multi-packet, via `uploadId` / `chunkIndex` / `totalChunks`
2401
- * params) are intentionally out of scope for this single-packet helper — the
2402
- * provider returns `ack:<n>` for intermediate chunks and the tx ID only on the
2403
- * final chunk. Callers needing chunking should drive `publishEvent()` directly
2404
- * (see the chunked case in the reference E2E test). Tracked as a follow-up.
2405
- */
2406
-
2407
- /**
2408
- * Parameters for {@link requestBlobStorage}.
2409
- */
2410
- interface RequestBlobStorageParams {
2411
- /** The raw blob data to store on Arweave. */
2412
- blobData: Uint8Array;
2413
- /**
2414
- * MIME type of the blob. Defaults to `'application/octet-stream'`
2415
- * (matching `buildBlobStorageRequest`).
2416
- */
2417
- contentType?: string;
2418
- /**
2419
- * Bid amount in USDC micro-units, as a string (declared in the event's
2420
- * `bid` tag). Defaults to the stringified `ilpAmount` when omitted.
2421
- *
2422
- * At least one of `bid` / `ilpAmount` should be provided so the declared
2423
- * bid and the paid ILP amount agree.
2424
- */
2425
- bid?: string;
2426
- /**
2427
- * ILP destination address of the DVM that performs the upload
2428
- * (e.g. `'g.toon.peer1'`). Falls back to the client's configured
2429
- * `destinationAddress` when omitted.
2430
- */
2431
- destination?: string;
2432
- /**
2433
- * Pre-signed balance proof claim for this packet. When omitted, the
2434
- * client's channel manager auto-opens a channel and auto-signs a claim
2435
- * (same lazy-channel behavior as `publishEvent`).
2436
- */
2437
- claim?: SignedBalanceProof;
2438
- /**
2439
- * Explicit ILP payment amount (bigint micro-units). When omitted,
2440
- * `publishEvent` computes it from the encoded event size. When `bid`
2441
- * is omitted, this value is stringified to populate the event's bid tag.
2442
- */
2443
- ilpAmount?: bigint;
2444
- }
2445
- /**
2446
- * Typed result of {@link requestBlobStorage}.
2447
- */
2448
- interface RequestBlobStorageResult {
2449
- /** Whether the upload succeeded and a tx ID was decoded. */
2450
- success: boolean;
2451
- /** The Arweave transaction ID (43-char base64url) when `success` is true. */
2452
- txId?: string;
2453
- /** The id of the kind:5094 event that was published. */
2454
- eventId?: string;
2455
- /** Error message when `success` is false. */
2456
- error?: string;
2457
- }
2458
- /**
2459
- * Requests permanent Arweave blob storage from a DVM in a single ILP packet.
2460
- *
2461
- * Mirrors the single-packet flow in
2462
- * `packages/client/tests/e2e/docker-arweave-dvm-e2e.test.ts`: builds a signed
2463
- * kind:5094 event, publishes it through the supplied {@link ToonClient}
2464
- * (reusing its claim/channel plumbing), and decodes the FULFILL `data` field
2465
- * into an Arweave transaction ID.
2466
- *
2467
- * @param client - A started `ToonClient` (call `client.start()` first).
2468
- * @param secretKey - The Nostr secret key used to sign the kind:5094 event.
2469
- * @param params - Blob, content type, bid, destination, and payment options.
2470
- * @returns `{ success, txId?, eventId?, error? }`.
2471
- */
2472
- declare function requestBlobStorage(client: ToonClient, secretKey: Uint8Array, params: RequestBlobStorageParams): Promise<RequestBlobStorageResult>;
2473
-
2474
2961
  /**
2475
2962
  * Full multi-chain identity derived from a single BIP-39 mnemonic.
2476
2963
  */
@@ -2820,4 +3307,4 @@ declare function loadKeystore(path: string, password: string): string;
2820
3307
  */
2821
3308
  declare function writeKeystoreFile(path: string, keystore: EncryptedKeystore): void;
2822
3309
 
2823
- export { ANON_ASSETS, ANON_VERSION, type AnonAsset, type BackupPayload, type BalanceProofParams, BtpRuntimeClient, type BtpRuntimeClientConfig, type ChainMetadata, type ChainSigner, ChannelManager, type ClaimMessage, type ClientTransportConfig, ConnectorError, type EVMClaimMessage, type EncryptedKeystore, EvmSigner, HS_HOSTNAME_MAX_LENGTH, HS_HOSTNAME_REGEX, HttpConnectorAdmin, type HttpConnectorAdminConfig, HttpRuntimeClient, type HttpRuntimeClientConfig, type InteractionResultContent, KeyManager, type KeyManagerConfig, type ManagedAnonProxy, type MinaClaimMessage, type MinaDepositReader, MinaSigner, type MinaSignerOptions, NetworkError, OnChainChannelClient, type OnChainChannelClientConfig, type PasskeyInfo, type PetDvmProvider, type PetInteractionEventData, type PetInteractionRequestParams, type PetInteractionResultData, type PetListing, type PetListingFilterOptions, type PetListingParams, type PetPurchaseRequestParams, type ProofStatus, type PublishEventResult, type RequestBlobStorageParams, type RequestBlobStorageResult, type RetryOptions, type SignedBalanceProof, type SolanaChannelClientOptions, type SolanaClaimMessage, SolanaSigner, type StartManagedAnonProxyOptions, type StatValues, ToonClient, type ToonClientConfig, ToonClientError, type ToonIdentity, type ToonSigners, type ToonStartResult, type UnsignedNostrEvent, ValidationError, type VaultData, applyDefaults, applyNetworkPresets, assertRoutableHsHostname, buildBackupEvent, buildBackupFilter, buildPetInteractionRequest, buildPetListingEvent, buildPetPurchaseRequest, buildSettlementInfo, decryptMnemonic, deriveFromNsec, deriveFullIdentity, deriveNostrKeyFromMnemonic, encryptMnemonic, filterPetDvmProviders, filterPetListings, generateKeystore, generateMnemonic, generateRandomIdentity, getNetworkStatus, importKeystore, isPrfSupported, isRoutableHsHostname, loadKeystore, parseBackupPayload, parsePetInteractionEvent, parsePetInteractionResult, parsePetListing, readMinaDepositTotal, requestBlobStorage, selectAnonAsset, startManagedAnonProxy, validateConfig, validateMnemonic, withRetry, writeKeystoreFile };
3310
+ export { ANON_ASSETS, ANON_VERSION, type AnonAsset, type BackupPayload, type BalanceProofParams, BtpRuntimeClient, type BtpRuntimeClientConfig, type ChainMetadata, type ChainSigner, ChannelManager, type ClaimMessage, type ClaimResolver, type ClientTransportConfig, ConnectorError, type DiscoveredIlpPeer, type EVMClaimMessage, type EncryptedKeystore, EvmSigner, type H402FetchOptions, HS_HOSTNAME_MAX_LENGTH, HS_HOSTNAME_REGEX, Http402Client, type Http402ClientConfig, HttpConnectorAdmin, type HttpConnectorAdminConfig, HttpIlpClient, type HttpIlpClientConfig, type HttpIlpClientFactory, HttpRuntimeClient, type HttpRuntimeClientConfig, ILP_CLAIM_HEADER, ILP_CLAIM_WRAPPED_HEADER, ILP_PEER_ID_HEADER, type IlpTransportChoice, type InteractionResultContent, KeyManager, type KeyManagerConfig, type ManagedAnonProxy, type MinaClaimMessage, type MinaDepositReader, MinaSigner, type MinaSignerOptions, NetworkError, OnChainChannelClient, type OnChainChannelClientConfig, type ParsedX402Challenge, type PasskeyInfo, type PetDvmProvider, type PetInteractionEventData, type PetInteractionRequestParams, type PetInteractionResultData, type PetListing, type PetListingFilterOptions, type PetListingParams, type PetPurchaseRequestParams, type ProofStatus, type PublishEventResult, type RequestBlobStorageParams, type RequestBlobStorageResult, type RetryOptions, type SelectIlpTransportOptions, type SignedBalanceProof, type SolanaChannelClientOptions, type SolanaClaimMessage, SolanaSigner, type StartManagedAnonProxyOptions, type StatValues, type ToonChannelAccept, ToonClient, type ToonClientConfig, ToonClientError, type ToonIdentity, type ToonSigners, type ToonStartResult, type UnsignedNostrEvent, ValidationError, type VaultData, applyDefaults, applyNetworkPresets, assertRoutableHsHostname, buildBackupEvent, buildBackupFilter, buildPetInteractionRequest, buildPetListingEvent, buildPetPurchaseRequest, buildSettlementInfo, decryptMnemonic, deriveFromNsec, deriveFullIdentity, deriveNostrKeyFromMnemonic, encryptMnemonic, filterPetDvmProviders, filterPetListings, generateKeystore, generateMnemonic, generateRandomIdentity, getNetworkStatus, httpEndpointToBtpUrl, importKeystore, isPrfSupported, isRoutableHsHostname, loadKeystore, parseBackupPayload, parseHttpResponse, parsePetInteractionEvent, parsePetInteractionResult, parsePetListing, parseX402Body, parseX402Challenge, readDiscoveredIlpPeer, readMinaDepositTotal, requestBlobStorage, selectAnonAsset, selectIlpTransport, serializeHttpRequest, startManagedAnonProxy, validateConfig, validateMnemonic, withRetry, writeKeystoreFile };