@toon-protocol/client 0.13.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-QEMD5EAI.js +441 -0
- package/dist/chunk-QEMD5EAI.js.map +1 -0
- package/dist/index.d.ts +75 -7
- package/dist/index.js +157 -9
- package/dist/index.js.map +1 -1
- package/dist/render/index.d.ts +807 -0
- package/dist/render/index.js +55 -0
- package/dist/render/index.js.map +1 -0
- package/package.json +13 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as _toon_protocol_core from '@toon-protocol/core';
|
|
2
2
|
import { IlpPeerInfo, IlpClient, IlpSendResult, 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';
|
|
3
4
|
import { NostrEvent, EventTemplate } from 'nostr-tools/pure';
|
|
4
5
|
import { PrivateKeyAccount } from 'viem/accounts';
|
|
6
|
+
export { A2uiDecision, ConsentDecision, ConsentRequest, DispatchGuardInfo, DispatchInput, GenerateContext, GeneratedRenderer, GenerativeDecision, GenerativeFallbackOptions, GenerativeFallbackRenderer, GenerativeFallbackResult, GuardedDispatchInput, IntentClassification, KindRegistry, MIME_A2UI, MIME_MCP_APP, McpUiDecision, NativeDecision, PublishBackOptions, RenderBranch, RenderDecision, RenderTrust, RendererGenerator, RendererPin, RendererPinStore, RendererPublisher, RendererSigner, ResolvedCoordinate, SwapApproval, SwapDecision, SwapRejection, SwapRejectionReason, UiResource, VerifyRendererInput, WidgetIntent, buildConsentRequest, buildRendererEventTemplate, classifyIntent, deterministicGenerator, extractUiResource, guardedRenderDispatch, isTrustDowngrade, publishBackCoordinate, renderDeterministicHtml, renderDispatch, resolveRendererMime, resolveUiCoordinate, resolveUiRenderer, verifyRendererTrust } from './render/index.js';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Solana payment-channel parameters supplied via `ToonClientConfig.solanaChannel`.
|
|
@@ -402,13 +404,21 @@ interface SignedBalanceProof extends BalanceProofParams {
|
|
|
402
404
|
*
|
|
403
405
|
* ## FULFILL data contract
|
|
404
406
|
*
|
|
405
|
-
*
|
|
406
|
-
* returns the
|
|
407
|
-
*
|
|
408
|
-
*
|
|
407
|
+
* The deployed connector is a payment-proxy (HTTP-in-ILP): a successful blob
|
|
408
|
+
* upload returns the DVM's verbatim **HTTP/1.1 response message** in the ILP
|
|
409
|
+
* FULFILL `data` field. For a single-packet (non-chunked) upload the body is a
|
|
410
|
+
* JSON object:
|
|
409
411
|
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
+
* HTTP/1.1 200 OK\r\n
|
|
413
|
+
* content-length: 189\r\n
|
|
414
|
+
* \r\n
|
|
415
|
+
* {"accept":true,"txId":"<43-char base64url>","data":"<base64 of txId>",...}
|
|
416
|
+
*
|
|
417
|
+
* We parse the HTTP envelope, fail on a non-2xx status (or `accept:false`), and
|
|
418
|
+
* read the Arweave tx ID from `txId` (falling back to base64-decoding `data`).
|
|
419
|
+
* An Arweave tx ID is a 43-character base64url string (32 raw bytes). A legacy
|
|
420
|
+
* fallback still accepts a bare `base64(utf8(txId))` FULFILL (no HTTP envelope)
|
|
421
|
+
* so non-proxy providers do not regress. See {@link extractArweaveTxId}.
|
|
412
422
|
*
|
|
413
423
|
* See `packages/sdk/src/arweave/arweave-dvm-handler.ts` for the server side and
|
|
414
424
|
* `packages/client/tests/e2e/docker-arweave-dvm-e2e.test.ts` for the reference
|
|
@@ -2366,6 +2376,64 @@ declare function withRetry<T>(operation: () => Promise<T>, options: RetryOptions
|
|
|
2366
2376
|
*/
|
|
2367
2377
|
declare function buildStoreWriteEnvelope(event: NostrEvent): Uint8Array;
|
|
2368
2378
|
|
|
2379
|
+
/**
|
|
2380
|
+
* Shared parser for the HTTP-over-ILP response carried in an ILP **FULFILL**
|
|
2381
|
+
* packet's `data` field.
|
|
2382
|
+
*
|
|
2383
|
+
* The deployed connector is a payment-proxy (HTTP-in-ILP): a paid write/upload
|
|
2384
|
+
* is reverse-proxied to the relay/DVM origin and the origin's reply is returned
|
|
2385
|
+
* **verbatim as a full HTTP/1.1 response message** inside the FULFILL `data`:
|
|
2386
|
+
*
|
|
2387
|
+
* HTTP/1.1 200 OK\r\n
|
|
2388
|
+
* content-length: 189\r\n
|
|
2389
|
+
* \r\n
|
|
2390
|
+
* {"accept":true,"txId":"4QcRav...","data":"<base64-txid>",...}
|
|
2391
|
+
*
|
|
2392
|
+
* Callers (`ToonClient.publishEvent`, `requestBlobStorage`) previously treated
|
|
2393
|
+
* this `data` as opaque success bytes — `publishEvent` reported success on ANY
|
|
2394
|
+
* FULFILL even when the embedded HTTP status was `404 Not Found`, and
|
|
2395
|
+
* `requestBlobStorage` base64-decoded the WHOLE response as if it were the bare
|
|
2396
|
+
* Arweave tx id. This module makes the HTTP envelope first-class so both paths
|
|
2397
|
+
* can read the real status and body.
|
|
2398
|
+
*
|
|
2399
|
+
* The full Web-`Response` reconstruction used by the h402 fetch path lives in
|
|
2400
|
+
* `adapters/Http402Client.ts` (`parseHttpResponse`); this is a smaller,
|
|
2401
|
+
* dependency-free helper that returns the status code + raw body string, which
|
|
2402
|
+
* is all the publish/upload paths need.
|
|
2403
|
+
*
|
|
2404
|
+
* DEFENSIVE: not every FULFILL is HTTP-enveloped (e.g. Mill-swap raw-TOON
|
|
2405
|
+
* FULFILLs go through `sendSwapPacket`, not these paths). If the decoded data
|
|
2406
|
+
* does not begin with an `HTTP/<v>` status line, `isHttp` is `false` and the
|
|
2407
|
+
* caller should fall back to its prior (non-HTTP) interpretation rather than
|
|
2408
|
+
* fail. This keeps non-HTTP FULFILLs from regressing.
|
|
2409
|
+
*/
|
|
2410
|
+
/** Result of parsing FULFILL `data` as an HTTP/1.1 response. */
|
|
2411
|
+
interface ParsedFulfillHttp {
|
|
2412
|
+
/** Whether the data looked like an HTTP/1.1 response (status line present). */
|
|
2413
|
+
isHttp: boolean;
|
|
2414
|
+
/** HTTP status code (e.g. 200, 404). Only meaningful when `isHttp` is true. */
|
|
2415
|
+
status: number;
|
|
2416
|
+
/** Reason phrase from the status line (may be empty). */
|
|
2417
|
+
statusText: string;
|
|
2418
|
+
/** Decoded response body as a UTF-8 string (empty when none). */
|
|
2419
|
+
body: string;
|
|
2420
|
+
}
|
|
2421
|
+
/**
|
|
2422
|
+
* Parse FULFILL `data` bytes as an HTTP/1.1 response.
|
|
2423
|
+
*
|
|
2424
|
+
* Returns `{ isHttp: false, ... }` (without throwing) when the payload does not
|
|
2425
|
+
* start with an `HTTP/<v>` status line, so callers can fall back to their
|
|
2426
|
+
* legacy non-HTTP interpretation. When it IS an HTTP response, the status code
|
|
2427
|
+
* and body are extracted; a present-but-malformed status line yields
|
|
2428
|
+
* `isHttp: false` as well (treated as non-HTTP rather than throwing).
|
|
2429
|
+
*/
|
|
2430
|
+
declare function parseFulfillHttpBytes(bytes: Uint8Array): ParsedFulfillHttp;
|
|
2431
|
+
/**
|
|
2432
|
+
* Convenience wrapper: decode a base64 FULFILL `data` string (the shape carried
|
|
2433
|
+
* on `IlpSendResult.data`) and parse it as an HTTP/1.1 response.
|
|
2434
|
+
*/
|
|
2435
|
+
declare function parseFulfillHttp(base64Data: string): ParsedFulfillHttp;
|
|
2436
|
+
|
|
2369
2437
|
/**
|
|
2370
2438
|
* Settlement info produced by buildSettlementInfo().
|
|
2371
2439
|
* Extends the core SettlementConfig shape with ilpAddress for client use.
|
|
@@ -3268,4 +3336,4 @@ declare function loadKeystore(path: string, password: string): string;
|
|
|
3268
3336
|
*/
|
|
3269
3337
|
declare function writeKeystoreFile(path: string, keystore: EncryptedKeystore): void;
|
|
3270
3338
|
|
|
3271
|
-
export { type BackupPayload, type BalanceProofParams, BtpRuntimeClient, type BtpRuntimeClientConfig, type ChainMetadata, type ChainSigner, ChannelManager, type ClaimMessage, type ClaimResolver, ConnectorError, type DiscoveredIlpPeer, type EVMClaimMessage, type EncryptedKeystore, EvmSigner, type FaucetChain, type FundWalletOptions, type FundWalletResult, type H402FetchOptions, 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 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 StatValues, type ToonChannelAccept, ToonClient, type ToonClientConfig, ToonClientError, type ToonIdentity, type ToonSigners, type ToonStartResult, type UnsignedNostrEvent, ValidationError, type VaultData, applyDefaults, applyNetworkPresets, buildBackupEvent, buildBackupFilter, buildPetInteractionRequest, buildPetListingEvent, buildPetPurchaseRequest, buildSettlementInfo, buildStoreWriteEnvelope, decryptMnemonic, deriveFromNsec, deriveFullIdentity, deriveNostrKeyFromMnemonic, encryptMnemonic, filterPetDvmProviders, filterPetListings, fundWallet, generateKeystore, generateMnemonic, generateRandomIdentity, getNetworkStatus, httpEndpointToBtpUrl, importKeystore, isPrfSupported, loadKeystore, parseBackupPayload, parseHttpResponse, parsePetInteractionEvent, parsePetInteractionResult, parsePetListing, parseX402Body, parseX402Challenge, proxyIlpEndpoint, readDiscoveredIlpPeer, readMinaDepositTotal, requestBlobStorage, selectIlpTransport, serializeHttpRequest, validateConfig, validateMnemonic, withRetry, writeKeystoreFile };
|
|
3339
|
+
export { type BackupPayload, type BalanceProofParams, BtpRuntimeClient, type BtpRuntimeClientConfig, type ChainMetadata, type ChainSigner, ChannelManager, type ClaimMessage, type ClaimResolver, ConnectorError, type DiscoveredIlpPeer, type EVMClaimMessage, type EncryptedKeystore, EvmSigner, type FaucetChain, type FundWalletOptions, type FundWalletResult, type H402FetchOptions, 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 MinaClaimMessage, type MinaDepositReader, MinaSigner, type MinaSignerOptions, NetworkError, OnChainChannelClient, type OnChainChannelClientConfig, type ParsedFulfillHttp, 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 StatValues, type ToonChannelAccept, ToonClient, type ToonClientConfig, ToonClientError, type ToonIdentity, type ToonSigners, type ToonStartResult, type UnsignedNostrEvent, ValidationError, type VaultData, applyDefaults, applyNetworkPresets, buildBackupEvent, buildBackupFilter, buildPetInteractionRequest, buildPetListingEvent, buildPetPurchaseRequest, buildSettlementInfo, buildStoreWriteEnvelope, decryptMnemonic, deriveFromNsec, deriveFullIdentity, deriveNostrKeyFromMnemonic, encryptMnemonic, filterPetDvmProviders, filterPetListings, fundWallet, generateKeystore, generateMnemonic, generateRandomIdentity, getNetworkStatus, httpEndpointToBtpUrl, importKeystore, isPrfSupported, loadKeystore, parseBackupPayload, parseFulfillHttp, parseFulfillHttpBytes, parseHttpResponse, parsePetInteractionEvent, parsePetInteractionResult, parsePetListing, parseX402Body, parseX402Challenge, proxyIlpEndpoint, readDiscoveredIlpPeer, readMinaDepositTotal, requestBlobStorage, selectIlpTransport, serializeHttpRequest, validateConfig, validateMnemonic, withRetry, writeKeystoreFile };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GenerativeFallbackRenderer,
|
|
3
|
+
KindRegistry,
|
|
4
|
+
MIME_A2UI,
|
|
5
|
+
MIME_MCP_APP,
|
|
6
|
+
RendererPinStore,
|
|
7
|
+
UI_RENDERER_KIND,
|
|
8
|
+
UI_TAG,
|
|
9
|
+
buildConsentRequest,
|
|
10
|
+
buildRendererEventTemplate,
|
|
11
|
+
buildUiCoordinate,
|
|
12
|
+
classifyIntent,
|
|
13
|
+
deterministicGenerator,
|
|
14
|
+
extractUiResource,
|
|
15
|
+
getUiCoordinate,
|
|
16
|
+
guardedRenderDispatch,
|
|
17
|
+
isTrustDowngrade,
|
|
18
|
+
parseUiCoordinate,
|
|
19
|
+
publishBackCoordinate,
|
|
20
|
+
renderDeterministicHtml,
|
|
21
|
+
renderDispatch,
|
|
22
|
+
resolveRendererMime,
|
|
23
|
+
resolveUiCoordinate,
|
|
24
|
+
resolveUiRenderer,
|
|
25
|
+
selectLatestAddressable,
|
|
26
|
+
verifyRendererTrust
|
|
27
|
+
} from "./chunk-QEMD5EAI.js";
|
|
28
|
+
|
|
1
29
|
// src/ToonClient.ts
|
|
2
30
|
import { generateSecretKey as generateSecretKey3, getPublicKey as getPublicKey2, finalizeEvent } from "nostr-tools/pure";
|
|
3
31
|
|
|
@@ -490,6 +518,44 @@ function buildStoreWriteEnvelope(event) {
|
|
|
490
518
|
return encodeUtf8(head + "\r\n\r\n" + body);
|
|
491
519
|
}
|
|
492
520
|
|
|
521
|
+
// src/utils/fulfill-http.ts
|
|
522
|
+
var CRLF = "\r\n";
|
|
523
|
+
function findHeaderEnd(bytes) {
|
|
524
|
+
for (let i = 0; i + 3 < bytes.length; i++) {
|
|
525
|
+
if (bytes[i] === 13 && bytes[i + 1] === 10 && bytes[i + 2] === 13 && bytes[i + 3] === 10) {
|
|
526
|
+
return i + 4;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return -1;
|
|
530
|
+
}
|
|
531
|
+
function parseFulfillHttpBytes(bytes) {
|
|
532
|
+
const notHttp = {
|
|
533
|
+
isHttp: false,
|
|
534
|
+
status: 0,
|
|
535
|
+
statusText: "",
|
|
536
|
+
body: ""
|
|
537
|
+
};
|
|
538
|
+
const headerEnd = findHeaderEnd(bytes);
|
|
539
|
+
const headBytes = headerEnd === -1 ? bytes : bytes.subarray(0, headerEnd - 2);
|
|
540
|
+
const bodyBytes = headerEnd === -1 ? new Uint8Array(0) : bytes.subarray(headerEnd);
|
|
541
|
+
const headText = decodeUtf8(headBytes);
|
|
542
|
+
const lines = headText.split(CRLF).filter((l) => l.length > 0);
|
|
543
|
+
const statusLine = lines.shift();
|
|
544
|
+
if (!statusLine) return notHttp;
|
|
545
|
+
if (!statusLine.trimStart().startsWith("HTTP/")) return notHttp;
|
|
546
|
+
const match = /^HTTP\/\d\.\d\s+(\d{3})(?:\s+(.*))?$/.exec(statusLine.trim());
|
|
547
|
+
if (!match) return notHttp;
|
|
548
|
+
return {
|
|
549
|
+
isHttp: true,
|
|
550
|
+
status: parseInt(match[1], 10),
|
|
551
|
+
statusText: match[2] ?? "",
|
|
552
|
+
body: decodeUtf8(bodyBytes)
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
function parseFulfillHttp(base64Data) {
|
|
556
|
+
return parseFulfillHttpBytes(fromBase64(base64Data));
|
|
557
|
+
}
|
|
558
|
+
|
|
493
559
|
// src/modes/http.ts
|
|
494
560
|
import { BootstrapService, createDiscoveryTracker } from "@toon-protocol/core";
|
|
495
561
|
|
|
@@ -3529,15 +3595,17 @@ async function requestBlobStorage(client, secretKey, params) {
|
|
|
3529
3595
|
return {
|
|
3530
3596
|
success: false,
|
|
3531
3597
|
eventId: event.id,
|
|
3532
|
-
error: "FULFILL contained no data; expected
|
|
3598
|
+
error: "FULFILL contained no data; expected an HTTP response with the Arweave tx ID"
|
|
3533
3599
|
};
|
|
3534
3600
|
}
|
|
3535
|
-
|
|
3536
|
-
|
|
3601
|
+
let txId;
|
|
3602
|
+
try {
|
|
3603
|
+
txId = extractArweaveTxId(result.data);
|
|
3604
|
+
} catch (error) {
|
|
3537
3605
|
return {
|
|
3538
3606
|
success: false,
|
|
3539
3607
|
eventId: event.id,
|
|
3540
|
-
error:
|
|
3608
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3541
3609
|
};
|
|
3542
3610
|
}
|
|
3543
3611
|
return {
|
|
@@ -3546,6 +3614,49 @@ async function requestBlobStorage(client, secretKey, params) {
|
|
|
3546
3614
|
eventId: event.id
|
|
3547
3615
|
};
|
|
3548
3616
|
}
|
|
3617
|
+
function extractArweaveTxId(base64Data) {
|
|
3618
|
+
const http2 = parseFulfillHttp(base64Data);
|
|
3619
|
+
if (!http2.isHttp) {
|
|
3620
|
+
const legacy = decodeUtf8(fromBase64(base64Data));
|
|
3621
|
+
if (!ARWEAVE_TX_ID_REGEX.test(legacy)) {
|
|
3622
|
+
throw new Error(
|
|
3623
|
+
`Decoded FULFILL data is not a valid Arweave tx ID: "${legacy}"`
|
|
3624
|
+
);
|
|
3625
|
+
}
|
|
3626
|
+
return legacy;
|
|
3627
|
+
}
|
|
3628
|
+
if (http2.status < 200 || http2.status >= 300) {
|
|
3629
|
+
const detail = http2.body ? ` - ${http2.body}` : "";
|
|
3630
|
+
throw new Error(
|
|
3631
|
+
`Blob upload failed: DVM returned HTTP ${http2.status} ${http2.statusText}`.trimEnd() + detail
|
|
3632
|
+
);
|
|
3633
|
+
}
|
|
3634
|
+
let parsed;
|
|
3635
|
+
try {
|
|
3636
|
+
parsed = JSON.parse(http2.body);
|
|
3637
|
+
} catch {
|
|
3638
|
+
throw new Error(
|
|
3639
|
+
`Blob upload response body was not valid JSON: "${http2.body}"`
|
|
3640
|
+
);
|
|
3641
|
+
}
|
|
3642
|
+
const body = parsed;
|
|
3643
|
+
if (body.accept === false) {
|
|
3644
|
+
const reason = typeof body.error === "string" ? `: ${body.error}` : "";
|
|
3645
|
+
throw new Error(`Blob upload rejected by DVM (accept:false)${reason}`);
|
|
3646
|
+
}
|
|
3647
|
+
if (typeof body.txId === "string" && ARWEAVE_TX_ID_REGEX.test(body.txId)) {
|
|
3648
|
+
return body.txId;
|
|
3649
|
+
}
|
|
3650
|
+
if (typeof body.data === "string" && body.data.length > 0) {
|
|
3651
|
+
const decoded = decodeUtf8(fromBase64(body.data));
|
|
3652
|
+
if (ARWEAVE_TX_ID_REGEX.test(decoded)) {
|
|
3653
|
+
return decoded;
|
|
3654
|
+
}
|
|
3655
|
+
}
|
|
3656
|
+
throw new Error(
|
|
3657
|
+
`Blob upload response did not contain a valid Arweave tx ID: "${http2.body}"`
|
|
3658
|
+
);
|
|
3659
|
+
}
|
|
3549
3660
|
|
|
3550
3661
|
// src/adapters/Http402Client.ts
|
|
3551
3662
|
var Http402Client = class {
|
|
@@ -3720,7 +3831,7 @@ function parseX402Body(body) {
|
|
|
3720
3831
|
}
|
|
3721
3832
|
return version !== void 0 ? { x402Version: version } : {};
|
|
3722
3833
|
}
|
|
3723
|
-
var
|
|
3834
|
+
var CRLF2 = "\r\n";
|
|
3724
3835
|
function concatHeadAndBody(head, body) {
|
|
3725
3836
|
const headBytes = encodeUtf8(head);
|
|
3726
3837
|
const out = new Uint8Array(headBytes.length + body.length);
|
|
@@ -3750,10 +3861,10 @@ function serializeHttpRequest(req) {
|
|
|
3750
3861
|
`${req.method.toUpperCase()} ${target} HTTP/1.1`,
|
|
3751
3862
|
...headers.values()
|
|
3752
3863
|
];
|
|
3753
|
-
const head = lines.join(
|
|
3864
|
+
const head = lines.join(CRLF2) + CRLF2 + CRLF2;
|
|
3754
3865
|
return concatHeadAndBody(head, bodyBytes);
|
|
3755
3866
|
}
|
|
3756
|
-
function
|
|
3867
|
+
function findHeaderEnd2(bytes) {
|
|
3757
3868
|
for (let i = 0; i + 3 < bytes.length; i++) {
|
|
3758
3869
|
if (bytes[i] === 13 && bytes[i + 1] === 10 && bytes[i + 2] === 13 && bytes[i + 3] === 10) {
|
|
3759
3870
|
return i + 4;
|
|
@@ -3762,11 +3873,11 @@ function findHeaderEnd(bytes) {
|
|
|
3762
3873
|
return -1;
|
|
3763
3874
|
}
|
|
3764
3875
|
function parseHttpResponse(bytes) {
|
|
3765
|
-
const headerEnd =
|
|
3876
|
+
const headerEnd = findHeaderEnd2(bytes);
|
|
3766
3877
|
const headBytes = headerEnd === -1 ? bytes : bytes.subarray(0, headerEnd - 2);
|
|
3767
3878
|
const body = headerEnd === -1 ? new Uint8Array(0) : bytes.subarray(headerEnd);
|
|
3768
3879
|
const headText = decodeUtf8(headBytes);
|
|
3769
|
-
const lines = headText.split(
|
|
3880
|
+
const lines = headText.split(CRLF2).filter((l) => l.length > 0);
|
|
3770
3881
|
const statusLine = lines.shift();
|
|
3771
3882
|
if (!statusLine) {
|
|
3772
3883
|
throw new ConnectorError(
|
|
@@ -4123,6 +4234,16 @@ var ToonClient = class {
|
|
|
4123
4234
|
error: `Event rejected: ${response.code} - ${response.message}`
|
|
4124
4235
|
};
|
|
4125
4236
|
}
|
|
4237
|
+
if (response.data) {
|
|
4238
|
+
const httpResult = parseFulfillHttp(response.data);
|
|
4239
|
+
if (httpResult.isHttp && (httpResult.status < 200 || httpResult.status >= 300)) {
|
|
4240
|
+
const detail = httpResult.body ? ` - ${httpResult.body}` : "";
|
|
4241
|
+
return {
|
|
4242
|
+
success: false,
|
|
4243
|
+
error: `Write failed: relay returned HTTP ${httpResult.status} ${httpResult.statusText}`.trimEnd() + detail
|
|
4244
|
+
};
|
|
4245
|
+
}
|
|
4246
|
+
}
|
|
4126
4247
|
return {
|
|
4127
4248
|
success: true,
|
|
4128
4249
|
eventId: event.id,
|
|
@@ -6398,6 +6519,7 @@ export {
|
|
|
6398
6519
|
ChannelManager,
|
|
6399
6520
|
ConnectorError,
|
|
6400
6521
|
EvmSigner,
|
|
6522
|
+
GenerativeFallbackRenderer,
|
|
6401
6523
|
Http402Client,
|
|
6402
6524
|
HttpConnectorAdmin,
|
|
6403
6525
|
HttpIlpClient,
|
|
@@ -6406,27 +6528,39 @@ export {
|
|
|
6406
6528
|
ILP_CLAIM_WRAPPED_HEADER,
|
|
6407
6529
|
ILP_PEER_ID_HEADER,
|
|
6408
6530
|
KeyManager,
|
|
6531
|
+
KindRegistry,
|
|
6532
|
+
MIME_A2UI,
|
|
6533
|
+
MIME_MCP_APP,
|
|
6409
6534
|
MinaSigner,
|
|
6410
6535
|
NetworkError,
|
|
6411
6536
|
OnChainChannelClient,
|
|
6537
|
+
RendererPinStore,
|
|
6412
6538
|
SolanaSigner,
|
|
6413
6539
|
ToonClient,
|
|
6414
6540
|
ToonClientError,
|
|
6541
|
+
UI_RENDERER_KIND,
|
|
6542
|
+
UI_TAG,
|
|
6415
6543
|
ValidationError,
|
|
6416
6544
|
applyDefaults,
|
|
6417
6545
|
applyNetworkPresets,
|
|
6418
6546
|
buildBackupEvent,
|
|
6419
6547
|
buildBackupFilter,
|
|
6548
|
+
buildConsentRequest,
|
|
6420
6549
|
buildPetInteractionRequest,
|
|
6421
6550
|
buildPetListingEvent,
|
|
6422
6551
|
buildPetPurchaseRequest,
|
|
6552
|
+
buildRendererEventTemplate,
|
|
6423
6553
|
buildSettlementInfo,
|
|
6424
6554
|
buildStoreWriteEnvelope,
|
|
6555
|
+
buildUiCoordinate,
|
|
6556
|
+
classifyIntent,
|
|
6425
6557
|
decryptMnemonic2 as decryptMnemonic,
|
|
6426
6558
|
deriveFromNsec,
|
|
6427
6559
|
deriveFullIdentity,
|
|
6428
6560
|
deriveNostrKeyFromMnemonic,
|
|
6561
|
+
deterministicGenerator,
|
|
6429
6562
|
encryptMnemonic2 as encryptMnemonic,
|
|
6563
|
+
extractUiResource,
|
|
6430
6564
|
filterPetDvmProviders,
|
|
6431
6565
|
filterPetListings,
|
|
6432
6566
|
fundWallet,
|
|
@@ -6434,25 +6568,39 @@ export {
|
|
|
6434
6568
|
generateMnemonic,
|
|
6435
6569
|
generateRandomIdentity,
|
|
6436
6570
|
getNetworkStatus,
|
|
6571
|
+
getUiCoordinate,
|
|
6572
|
+
guardedRenderDispatch,
|
|
6437
6573
|
httpEndpointToBtpUrl,
|
|
6438
6574
|
importKeystore,
|
|
6439
6575
|
isPrfSupported,
|
|
6576
|
+
isTrustDowngrade,
|
|
6440
6577
|
loadKeystore,
|
|
6441
6578
|
parseBackupPayload,
|
|
6579
|
+
parseFulfillHttp,
|
|
6580
|
+
parseFulfillHttpBytes,
|
|
6442
6581
|
parseHttpResponse,
|
|
6443
6582
|
parsePetInteractionEvent,
|
|
6444
6583
|
parsePetInteractionResult,
|
|
6445
6584
|
parsePetListing,
|
|
6585
|
+
parseUiCoordinate,
|
|
6446
6586
|
parseX402Body,
|
|
6447
6587
|
parseX402Challenge,
|
|
6448
6588
|
proxyIlpEndpoint,
|
|
6589
|
+
publishBackCoordinate,
|
|
6449
6590
|
readDiscoveredIlpPeer,
|
|
6450
6591
|
readMinaDepositTotal,
|
|
6592
|
+
renderDeterministicHtml,
|
|
6593
|
+
renderDispatch,
|
|
6451
6594
|
requestBlobStorage,
|
|
6595
|
+
resolveRendererMime,
|
|
6596
|
+
resolveUiCoordinate,
|
|
6597
|
+
resolveUiRenderer,
|
|
6452
6598
|
selectIlpTransport,
|
|
6599
|
+
selectLatestAddressable,
|
|
6453
6600
|
serializeHttpRequest,
|
|
6454
6601
|
validateConfig,
|
|
6455
6602
|
validateMnemonic,
|
|
6603
|
+
verifyRendererTrust,
|
|
6456
6604
|
withRetry,
|
|
6457
6605
|
writeKeystoreFile
|
|
6458
6606
|
};
|