keymaster-connect 0.3.0 → 0.4.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.
@@ -175,6 +175,53 @@ declare function isValidMsFileSourceId(input: unknown): input is string;
175
175
  interface MsFileStatParams {
176
176
  seedHashHex: string;
177
177
  }
178
+ interface MsFileContentReadParams extends MsFileStatParams {
179
+ clientRequestId?: string;
180
+ /** 本次下载任务的完整数据块单价上限,单位聪。 */
181
+ maxFullBlockPriceSatoshis?: string;
182
+ }
183
+ interface MsFileReadStatusParams {
184
+ clientRequestId: string;
185
+ }
186
+ type MsFileContentOpenParams = MsFileContentReadParams & MsFileReadStatusParams;
187
+ /** 查询钱包允许的块价范围,或按读取编号修改当前任务的手动块价。 */
188
+ interface MsFileDownloadPriceParams {
189
+ clientRequestId?: string;
190
+ maxFullBlockPriceSatoshis?: string;
191
+ }
192
+ interface MsFileDownloadPriceResult {
193
+ /** 钱包允许应用设置的最大完整块单价,单位聪。 */
194
+ walletMaxFullBlockPriceSatoshis: string;
195
+ }
196
+ interface MsFileContentRangeParams extends MsFileReadStatusParams {
197
+ offset: number;
198
+ length: number;
199
+ }
200
+ interface MsFileContentRangeResult {
201
+ fileSizeBytes?: number;
202
+ mediaType?: string;
203
+ content?: BinaryField;
204
+ }
205
+ interface MsFileReadStatusDetails {
206
+ clientRequestId: string;
207
+ seedHashHex: string;
208
+ taskId?: string;
209
+ verifiedBlockCount?: number;
210
+ totalBlockCount?: number;
211
+ funds?: "none" | "pending" | "settled" | "problem";
212
+ /** 此读取记录有权调整关联下载任务的手动块价。 */
213
+ priceAdjustable?: true;
214
+ /** 当前任务的完整数据块单价上限,单位聪。 */
215
+ currentMaxFullBlockPriceSatoshis?: string;
216
+ }
217
+ /** Action for the caller: wait for content, read the complete file, or stop waiting. */
218
+ type MsFileReadStatus = MsFileReadStatusDetails & ({
219
+ phase: "pending" | "available";
220
+ error?: never;
221
+ } | {
222
+ phase: "stopped";
223
+ error: ProtocolError;
224
+ });
178
225
  interface MsFileStatAvailableEntry {
179
226
  supplierPublicKeyHex: string;
180
227
  status: "available";
@@ -288,8 +335,8 @@ type ProtocolErrorCode =
288
335
  | "hardware_connect_payment_unsupported" | "payment_not_found"
289
336
  /** Too many non-terminal Connect payment responsibilities. */
290
337
  | "payment_pending_limit"
291
- /** Same stable payment key with different frozen facts. */
292
- | "id_conflict" | "name_not_found" | "invalid_name" | "invalid_public_key" | "primary_name_required" | "domain_service_not_configured" | "domain_service_unavailable" | "domain_network_mismatch" | "msfile_not_configured" | "msfile_unavailable" | "msfile_identity_required" | "msfile_supplier_not_found" | "msfile_supplier_disabled" | "msfile_invalid_hash" | "msfile_price_limit_exceeded" | "msfile_integrity_error" | "msfile_content_not_found" | "msfile_rate_limited" | "msfile_supplier_error" | "msfile_transport_error" | "msfile_protocol_error" | "internal_error";
338
+ /** Same stable request key with different facts, or a resumable MSFile read failure. */
339
+ | "id_conflict" | "msfile_read_not_found" | "msfile_read_interrupted" | "msfile_read_cancelled" | "msfile_range_timeout" | "name_not_found" | "invalid_name" | "invalid_public_key" | "primary_name_required" | "domain_service_not_configured" | "domain_service_unavailable" | "domain_network_mismatch" | "msfile_not_configured" | "msfile_unavailable" | "msfile_identity_required" | "msfile_supplier_not_found" | "msfile_supplier_disabled" | "msfile_invalid_hash" | "msfile_price_limit_exceeded" | "msfile_integrity_error" | "msfile_content_not_found" | "msfile_rate_limited" | "msfile_supplier_error" | "msfile_transport_error" | "msfile_protocol_error" | "internal_error";
293
340
  interface ProtocolError {
294
341
  code: ProtocolErrorCode;
295
342
  message: string;
@@ -316,8 +363,15 @@ interface ProtocolCancelMessage {
316
363
  * 设计缘由:
317
364
  * - `channel.message_received` 是已验签的 Channel 公开消息,只发送给
318
365
  * 当前 session 已精确订阅的频道;
366
+ * - `chain.height_changed` 是当前连接钱包已同步的链尖快照;
319
367
  */
320
- type ProtocolEventName = "channel.message_received";
368
+ type ProtocolEventName = "channel.message_received" | "chain.height_changed";
369
+ /** 钱包同一次同步取得的链尖高度和哈希。 */
370
+ interface ChainHeightResult {
371
+ height: number;
372
+ /** 64 位小写十六进制区块哈希。 */
373
+ blockHash: string;
374
+ }
321
375
  interface IdentityGetParams {
322
376
  /** 目标站点 origin;必须等于 `event.origin`,否则拒绝。 */
323
377
  aud: string;
@@ -495,6 +549,27 @@ type ChainTransactionResult = {
495
549
  blockHash: string;
496
550
  index: number;
497
551
  };
552
+ type ChainTransactionBatchParams = {
553
+ txids: string[];
554
+ mode: "raw" | "status";
555
+ };
556
+ type ChainTransactionBatchEntry = {
557
+ txid: string;
558
+ } & ({
559
+ state: "not_observed";
560
+ } | {
561
+ state: "unconfirmed";
562
+ rawTxHex?: string;
563
+ } | {
564
+ state: "confirmed";
565
+ height: number;
566
+ blockHash: string;
567
+ rawTxHex?: string;
568
+ });
569
+ interface ChainTransactionBatchResult {
570
+ /** Missing IDs have no usable observation in this response and can be retried. */
571
+ entries: ChainTransactionBatchEntry[];
572
+ }
498
573
  interface ChainBroadcastResult {
499
574
  state: "accepted" | "rejected" | "unknown";
500
575
  txid: string;
@@ -514,7 +589,14 @@ interface MsFileContentResult {
514
589
  seed: BinaryField;
515
590
  content: BinaryField;
516
591
  }
592
+ /** Signed by the connected wallet over the canonical login-proof envelope. */
593
+ interface ConnectLoginProof {
594
+ envelope: BinaryField;
595
+ signature: BinaryField;
596
+ }
517
597
  interface ConnectLoginParams {
598
+ /** One-time challenge issued by the application backend (32 bytes, lowercase hex). */
599
+ loginChallenge?: string;
518
600
  /** 人类可读确认文案。 */
519
601
  text: string;
520
602
  /**
@@ -531,6 +613,8 @@ interface ConnectLoginParams {
531
613
  publicationProof?: string;
532
614
  }
533
615
  interface ConnectLoginResult {
616
+ /** Present when the request includes loginChallenge. */
617
+ loginProof?: ConnectLoginProof;
534
618
  /** 不透明恢复凭据,绑定原钱包和精确来源;不得写入日志或 URL。 */
535
619
  authorizationId: string;
536
620
  networkIdentity: NetworkIdentity;
@@ -546,6 +630,8 @@ interface ConnectLogoutResult {
546
630
  revokedAt: number;
547
631
  }
548
632
  interface ConnectLaunchParams {
633
+ /** One-time challenge issued by the application backend (32 bytes, lowercase hex). */
634
+ loginChallenge?: string;
549
635
  /** 由 launcher 写入 client app 启动 URL 的 launchToken。一次性消费。 */
550
636
  launchToken: string;
551
637
  /**
@@ -555,6 +641,8 @@ interface ConnectLaunchParams {
555
641
  publicationProof?: string;
556
642
  }
557
643
  interface ConnectLaunchResult {
644
+ /** Present when the request includes loginChallenge. */
645
+ loginProof?: ConnectLoginProof;
558
646
  authorizationId: string;
559
647
  networkIdentity: NetworkIdentity;
560
648
  resolvedClaims: Record<string, ResolvedClaimValue>;
@@ -594,7 +682,7 @@ interface DomainGetPublicKeyParams {
594
682
  domain: string;
595
683
  serviceId?: string;
596
684
  }
597
- declare const PROTOCOL_METHODS: readonly ["identity.get", "intent.sign", "cipher.encrypt", "cipher.decrypt", "payment.pay", "payment.status", "payment.prepare", "payment.commit", "payment.cancel", "chain.get_height", "chain.list_script_history", "chain.get_transaction", "chain.list_script_unspent", "chain.broadcast", "application.key", "application.sign_message", "application.sign_payment", "msfile.seller.status", "msfile.import", "msfile.content.read", "domain.profiles", "domain.get_public_key", "connect.login", "connect.logout", "connect.launch", "channel.publish", "channel.subscription_set", "msfile.stat", "msfile.seed.read", "msfile.block.read"];
685
+ declare const PROTOCOL_METHODS: readonly ["identity.get", "intent.sign", "cipher.encrypt", "cipher.decrypt", "payment.pay", "payment.status", "payment.prepare", "payment.commit", "payment.cancel", "chain.get_height", "chain.list_script_history", "chain.get_transaction", "chain.get_transactions", "chain.list_script_unspent", "chain.broadcast", "application.key", "application.sign_message", "application.sign_payment", "msfile.seller.status", "msfile.import", "msfile.content.read", "msfile.content.status", "msfile.content.open", "msfile.content.price", "msfile.content.range", "domain.profiles", "domain.get_public_key", "connect.login", "connect.logout", "connect.launch", "channel.publish", "channel.subscription_set", "msfile.stat", "msfile.seed.read", "msfile.block.read"];
598
686
  type ProtocolMethod = (typeof PROTOCOL_METHODS)[number];
599
687
  /**
600
688
  * 方法 -> 请求参数类型 的映射。`MethodParams<M>` 是计算出的参数类型。
@@ -616,6 +704,7 @@ interface MethodParamsMap {
616
704
  txid: string;
617
705
  observedRawTxHex?: string;
618
706
  };
707
+ "chain.get_transactions": ChainTransactionBatchParams;
619
708
  "chain.list_script_unspent": {
620
709
  script: string;
621
710
  };
@@ -632,7 +721,11 @@ interface MethodParamsMap {
632
721
  "application.sign_payment": ApplicationPaymentParams;
633
722
  "msfile.seller.status": {};
634
723
  "msfile.import": MsFileImportParams;
635
- "msfile.content.read": MsFileStatParams;
724
+ "msfile.content.read": MsFileContentReadParams;
725
+ "msfile.content.status": MsFileReadStatusParams;
726
+ "msfile.content.open": MsFileContentOpenParams;
727
+ "msfile.content.price": MsFileDownloadPriceParams;
728
+ "msfile.content.range": MsFileContentRangeParams;
636
729
  "domain.profiles": DomainProfilesParams;
637
730
  "domain.get_public_key": DomainGetPublicKeyParams;
638
731
  "connect.login": ConnectLoginParams;
@@ -654,11 +747,10 @@ interface MethodResultMap {
654
747
  "payment.prepare": PaymentPrepareResult;
655
748
  "payment.commit": PaymentPayResult;
656
749
  "payment.cancel": PaymentPayResult;
657
- "chain.get_height": {
658
- height: number;
659
- };
750
+ "chain.get_height": ChainHeightResult;
660
751
  "chain.list_script_history": ChainScriptHistoryResult;
661
752
  "chain.get_transaction": ChainTransactionResult;
753
+ "chain.get_transactions": ChainTransactionBatchResult;
662
754
  "chain.list_script_unspent": {
663
755
  outputs: Array<ChainOutpoint & {
664
756
  satoshis: number;
@@ -682,6 +774,10 @@ interface MethodResultMap {
682
774
  seedHashHex: string;
683
775
  };
684
776
  "msfile.content.read": MsFileContentResult;
777
+ "msfile.content.status": MsFileReadStatus;
778
+ "msfile.content.open": MsFileReadStatus;
779
+ "msfile.content.price": MsFileDownloadPriceResult;
780
+ "msfile.content.range": MsFileContentRangeResult;
685
781
  "domain.profiles": DomainProfilesResult;
686
782
  "domain.get_public_key": {
687
783
  publicKeyHex: string;
@@ -702,6 +798,11 @@ type ProtocolEventPayload = {
702
798
  type: "event";
703
799
  event: "channel.message_received";
704
800
  data: ChannelMessageReceivedEventData;
801
+ } | {
802
+ v: typeof PROTOCOL_VERSION;
803
+ type: "event";
804
+ event: "chain.height_changed";
805
+ data: ChainHeightResult;
705
806
  };
706
807
  type ProtocolEventMessage = ProtocolEventPayload & {
707
808
  networkIdentity: NetworkIdentity;
@@ -732,4 +833,4 @@ type ProtocolResultMessage = {
732
833
  networkIdentity?: NetworkIdentity;
733
834
  };
734
835
 
735
- export { type ChannelSubscriptionStatus as $, type AiTool as A, type BinaryField as B, type ConnectLoginParams as C, type DomainProfile as D, type MsFileSeedReadParams as E, type MsFileReadResult as F, type MsFileBlockReadParams as G, type PaymentStatusResult as H, type IdentityGetParams as I, type ChannelPublishParams as J, type ChannelPublishResult as K, type ChannelSubscriptionSetParams as L, type MethodParams as M, type NetworkIdentity as N, type ChannelSubscriptionSetResult as O, type ProtocolEventMessage as P, type ProtocolErrorCode as Q, AI_TOOLS_MAX_JSON_CHARS as R, type AiToolDefinition as S, type AiToolMessage as T, type AiToolSchema as U, type ApplicationPaymentParams as V, type BsvNetwork as W, type ChainScriptHistoryParams as X, type ChannelMessageReceivedEventData as Y, type ChannelSubscriptionErrorCode as Z, type ChannelSubscriptionPhase as _, type DomainProfilesResult as a, type ConnectLogoutParams as a0, type ConnectPaymentStatus as a1, DOMAIN_MAX_PROFILES as a2, type DomainGetPublicKeyParams as a3, type DomainProfilesParams as a4, type JSONValue as a5, MSFILE_BLOCK_SIZE_BYTES as a6, MSFILE_DIGEST_SIZE_BYTES as a7, MSFILE_LOCAL_SOURCE_ID as a8, MSFILE_MAX_BLOCK_BYTES as a9, type PaymentReleaseSummary as aA, type PaymentReservationParams as aB, type ProfileResult as aC, type ProtocolCancelMessage as aD, type ProtocolClosingMessage as aE, type ProtocolError as aF, type ProtocolEventName as aG, type ProtocolEventPayload as aH, type ProtocolReadyMessage as aI, type ProtocolRequestMessage as aJ, type ProtocolResultMessage as aK, type ResolvedClaimValue as aL, assertToolJson as aM, assertToolPayload as aN, isAiToolMessage as aO, isValidMsFileSourceId as aP, parseToolDefinitions as aQ, sameNetworkIdentity as aR, validateBsvNetwork as aS, validateNetworkIdentity as aT, validateToolArguments as aU, MSFILE_MAX_CONTENT_BYTES as aa, MSFILE_MAX_ERROR_MESSAGE_BYTES as ab, MSFILE_MAX_HEADER_BYTES as ac, MSFILE_MAX_SEED_BYTES as ad, MSFILE_PROTOCOL_ID as ae, type MethodParamsMap as af, type MethodResultMap as ag, type MsFileImportParams as ah, type MsFileLocalSourceStat as ai, type MsFileRemoteSourceStat as aj, type MsFileSatoshiAmount as ak, type MsFileSourceKind as al, type MsFileSourceStat as am, type MsFileStatAbsentEntry as an, type MsFileStatAvailableEntry as ao, type MsFileStatDiscoveringEntry as ap, type MsFileStatNetworkErrorEntry as aq, type MsFileStatQuotedEntry as ar, type MsFileSupplierStat as as, type P2pkhTransferAssetId as at, PROTOCOL_METHODS as au, PROTOCOL_VERSION as av, type PaymentCommitParams as aw, type PaymentDataSignature as ax, type PaymentOutput as ay, type PaymentPrepareParams as az, type AiToolsRegistered as b, type ProtocolMethod as c, type MethodResult as d, type ConnectLoginResult as e, type ConnectLogoutResult as f, type ConnectLaunchParams as g, type ConnectLaunchResult as h, type IdentityGetResult as i, type IntentSignParams as j, type IntentSignResult as k, type CipherEncryptParams as l, type CipherEncryptResult as m, type CipherDecryptParams as n, type CipherDecryptResult as o, type PaymentPayParams as p, type PaymentPayResult as q, type PaymentPrepareResult as r, type PaymentStatusParams as s, type ChainScriptHistoryResult as t, type ChainTransactionResult as u, type ChainOutpoint as v, type ChainBroadcastResult as w, type MsFileContentResult as x, type MsFileStatParams as y, type MsFileStatResult as z };
836
+ export { type BsvNetwork as $, type AiTool as A, type BinaryField as B, type ConnectLoginParams as C, type DomainProfile as D, type MsFileReadStatus as E, type MsFileDownloadPriceResult as F, type MsFileContentRangeResult as G, type MsFileStatParams as H, type IdentityGetParams as I, type MsFileStatResult as J, type MsFileSeedReadParams as K, type MsFileReadResult as L, type MethodParams as M, type NetworkIdentity as N, type MsFileBlockReadParams as O, type ProtocolEventMessage as P, type PaymentStatusResult as Q, type ChannelPublishParams as R, type ChannelPublishResult as S, type ChannelSubscriptionSetParams as T, type ChannelSubscriptionSetResult as U, type ProtocolErrorCode as V, AI_TOOLS_MAX_JSON_CHARS as W, type AiToolDefinition as X, type AiToolMessage as Y, type AiToolSchema as Z, type ApplicationPaymentParams as _, type DomainProfilesResult as a, isAiToolMessage as a$, type ChainScriptHistoryParams as a0, type ChainTransactionBatchEntry as a1, type ChainTransactionBatchParams as a2, type ChannelMessageReceivedEventData as a3, type ChannelSubscriptionErrorCode as a4, type ChannelSubscriptionPhase as a5, type ChannelSubscriptionStatus as a6, type ConnectLoginProof as a7, type ConnectLogoutParams as a8, type ConnectPaymentStatus as a9, type MsFileStatAbsentEntry as aA, type MsFileStatAvailableEntry as aB, type MsFileStatDiscoveringEntry as aC, type MsFileStatNetworkErrorEntry as aD, type MsFileStatQuotedEntry as aE, type MsFileSupplierStat as aF, type P2pkhTransferAssetId as aG, PROTOCOL_METHODS as aH, PROTOCOL_VERSION as aI, type PaymentCommitParams as aJ, type PaymentDataSignature as aK, type PaymentOutput as aL, type PaymentPrepareParams as aM, type PaymentReleaseSummary as aN, type PaymentReservationParams as aO, type ProfileResult as aP, type ProtocolCancelMessage as aQ, type ProtocolClosingMessage as aR, type ProtocolError as aS, type ProtocolEventName as aT, type ProtocolEventPayload as aU, type ProtocolReadyMessage as aV, type ProtocolRequestMessage as aW, type ProtocolResultMessage as aX, type ResolvedClaimValue as aY, assertToolJson as aZ, assertToolPayload as a_, DOMAIN_MAX_PROFILES as aa, type DomainGetPublicKeyParams as ab, type DomainProfilesParams as ac, type JSONValue as ad, MSFILE_BLOCK_SIZE_BYTES as ae, MSFILE_DIGEST_SIZE_BYTES as af, MSFILE_LOCAL_SOURCE_ID as ag, MSFILE_MAX_BLOCK_BYTES as ah, MSFILE_MAX_CONTENT_BYTES as ai, MSFILE_MAX_ERROR_MESSAGE_BYTES as aj, MSFILE_MAX_HEADER_BYTES as ak, MSFILE_MAX_SEED_BYTES as al, MSFILE_PROTOCOL_ID as am, type MethodParamsMap as an, type MethodResultMap as ao, type MsFileContentOpenParams as ap, type MsFileContentRangeParams as aq, type MsFileContentReadParams as ar, type MsFileDownloadPriceParams as as, type MsFileImportParams as at, type MsFileLocalSourceStat as au, type MsFileReadStatusParams as av, type MsFileRemoteSourceStat as aw, type MsFileSatoshiAmount as ax, type MsFileSourceKind as ay, type MsFileSourceStat as az, type AiToolsRegistered as b, isValidMsFileSourceId as b0, parseToolDefinitions as b1, sameNetworkIdentity as b2, validateBsvNetwork as b3, validateNetworkIdentity as b4, validateToolArguments as b5, type ProtocolMethod as c, type MethodResult as d, type ConnectLoginResult as e, type ConnectLogoutResult as f, type ConnectLaunchParams as g, type ConnectLaunchResult as h, type IdentityGetResult as i, type IntentSignParams as j, type IntentSignResult as k, type CipherEncryptParams as l, type CipherEncryptResult as m, type CipherDecryptParams as n, type CipherDecryptResult as o, type PaymentPayParams as p, type PaymentPayResult as q, type PaymentPrepareResult as r, type PaymentStatusParams as s, type ChainHeightResult as t, type ChainScriptHistoryResult as u, type ChainTransactionResult as v, type ChainTransactionBatchResult as w, type ChainOutpoint as x, type ChainBroadcastResult as y, type MsFileContentResult as z };
@@ -1 +1 @@
1
- export { S as AiToolDefinition, T as AiToolMessage, U as AiToolSchema, b as AiToolsRegistered, V as ApplicationPaymentParams, B as BinaryField, W as BsvNetwork, w as ChainBroadcastResult, v as ChainOutpoint, X as ChainScriptHistoryParams, t as ChainScriptHistoryResult, u as ChainTransactionResult, Y as ChannelMessageReceivedEventData, J as ChannelPublishParams, K as ChannelPublishResult, Z as ChannelSubscriptionErrorCode, _ as ChannelSubscriptionPhase, L as ChannelSubscriptionSetParams, O as ChannelSubscriptionSetResult, $ as ChannelSubscriptionStatus, n as CipherDecryptParams, o as CipherDecryptResult, l as CipherEncryptParams, m as CipherEncryptResult, g as ConnectLaunchParams, h as ConnectLaunchResult, C as ConnectLoginParams, e as ConnectLoginResult, a0 as ConnectLogoutParams, f as ConnectLogoutResult, a1 as ConnectPaymentStatus, a2 as DOMAIN_MAX_PROFILES, a3 as DomainGetPublicKeyParams, D as DomainProfile, a4 as DomainProfilesParams, a as DomainProfilesResult, I as IdentityGetParams, i as IdentityGetResult, j as IntentSignParams, k as IntentSignResult, a5 as JSONValue, a6 as MSFILE_BLOCK_SIZE_BYTES, a7 as MSFILE_DIGEST_SIZE_BYTES, a8 as MSFILE_LOCAL_SOURCE_ID, a9 as MSFILE_MAX_BLOCK_BYTES, aa as MSFILE_MAX_CONTENT_BYTES, ab as MSFILE_MAX_ERROR_MESSAGE_BYTES, ac as MSFILE_MAX_HEADER_BYTES, ad as MSFILE_MAX_SEED_BYTES, ae as MSFILE_PROTOCOL_ID, M as MethodParams, af as MethodParamsMap, d as MethodResult, ag as MethodResultMap, G as MsFileBlockReadParams, x as MsFileContentResult, ah as MsFileImportParams, ai as MsFileLocalSourceStat, F as MsFileReadResult, aj as MsFileRemoteSourceStat, ak as MsFileSatoshiAmount, E as MsFileSeedReadParams, al as MsFileSourceKind, am as MsFileSourceStat, an as MsFileStatAbsentEntry, ao as MsFileStatAvailableEntry, ap as MsFileStatDiscoveringEntry, aq as MsFileStatNetworkErrorEntry, y as MsFileStatParams, ar as MsFileStatQuotedEntry, z as MsFileStatResult, as as MsFileSupplierStat, N as NetworkIdentity, at as P2pkhTransferAssetId, au as PROTOCOL_METHODS, av as PROTOCOL_VERSION, aw as PaymentCommitParams, ax as PaymentDataSignature, ay as PaymentOutput, p as PaymentPayParams, q as PaymentPayResult, az as PaymentPrepareParams, r as PaymentPrepareResult, aA as PaymentReleaseSummary, aB as PaymentReservationParams, s as PaymentStatusParams, H as PaymentStatusResult, aC as ProfileResult, aD as ProtocolCancelMessage, aE as ProtocolClosingMessage, aF as ProtocolError, Q as ProtocolErrorCode, P as ProtocolEventMessage, aG as ProtocolEventName, aH as ProtocolEventPayload, c as ProtocolMethod, aI as ProtocolReadyMessage, aJ as ProtocolRequestMessage, aK as ProtocolResultMessage, aL as ResolvedClaimValue, aP as isValidMsFileSourceId, aR as sameNetworkIdentity, aS as validateBsvNetwork, aT as validateNetworkIdentity } from './protocol-Dfo305R9.js';
1
+ export { X as AiToolDefinition, Y as AiToolMessage, Z as AiToolSchema, b as AiToolsRegistered, _ as ApplicationPaymentParams, B as BinaryField, $ as BsvNetwork, y as ChainBroadcastResult, t as ChainHeightResult, x as ChainOutpoint, a0 as ChainScriptHistoryParams, u as ChainScriptHistoryResult, a1 as ChainTransactionBatchEntry, a2 as ChainTransactionBatchParams, w as ChainTransactionBatchResult, v as ChainTransactionResult, a3 as ChannelMessageReceivedEventData, R as ChannelPublishParams, S as ChannelPublishResult, a4 as ChannelSubscriptionErrorCode, a5 as ChannelSubscriptionPhase, T as ChannelSubscriptionSetParams, U as ChannelSubscriptionSetResult, a6 as ChannelSubscriptionStatus, n as CipherDecryptParams, o as CipherDecryptResult, l as CipherEncryptParams, m as CipherEncryptResult, g as ConnectLaunchParams, h as ConnectLaunchResult, C as ConnectLoginParams, a7 as ConnectLoginProof, e as ConnectLoginResult, a8 as ConnectLogoutParams, f as ConnectLogoutResult, a9 as ConnectPaymentStatus, aa as DOMAIN_MAX_PROFILES, ab as DomainGetPublicKeyParams, D as DomainProfile, ac as DomainProfilesParams, a as DomainProfilesResult, I as IdentityGetParams, i as IdentityGetResult, j as IntentSignParams, k as IntentSignResult, ad as JSONValue, ae as MSFILE_BLOCK_SIZE_BYTES, af as MSFILE_DIGEST_SIZE_BYTES, ag as MSFILE_LOCAL_SOURCE_ID, ah as MSFILE_MAX_BLOCK_BYTES, ai as MSFILE_MAX_CONTENT_BYTES, aj as MSFILE_MAX_ERROR_MESSAGE_BYTES, ak as MSFILE_MAX_HEADER_BYTES, al as MSFILE_MAX_SEED_BYTES, am as MSFILE_PROTOCOL_ID, M as MethodParams, an as MethodParamsMap, d as MethodResult, ao as MethodResultMap, O as MsFileBlockReadParams, ap as MsFileContentOpenParams, aq as MsFileContentRangeParams, G as MsFileContentRangeResult, ar as MsFileContentReadParams, z as MsFileContentResult, as as MsFileDownloadPriceParams, F as MsFileDownloadPriceResult, at as MsFileImportParams, au as MsFileLocalSourceStat, L as MsFileReadResult, E as MsFileReadStatus, av as MsFileReadStatusParams, aw as MsFileRemoteSourceStat, ax as MsFileSatoshiAmount, K as MsFileSeedReadParams, ay as MsFileSourceKind, az as MsFileSourceStat, aA as MsFileStatAbsentEntry, aB as MsFileStatAvailableEntry, aC as MsFileStatDiscoveringEntry, aD as MsFileStatNetworkErrorEntry, H as MsFileStatParams, aE as MsFileStatQuotedEntry, J as MsFileStatResult, aF as MsFileSupplierStat, N as NetworkIdentity, aG as P2pkhTransferAssetId, aH as PROTOCOL_METHODS, aI as PROTOCOL_VERSION, aJ as PaymentCommitParams, aK as PaymentDataSignature, aL as PaymentOutput, p as PaymentPayParams, q as PaymentPayResult, aM as PaymentPrepareParams, r as PaymentPrepareResult, aN as PaymentReleaseSummary, aO as PaymentReservationParams, s as PaymentStatusParams, Q as PaymentStatusResult, aP as ProfileResult, aQ as ProtocolCancelMessage, aR as ProtocolClosingMessage, aS as ProtocolError, V as ProtocolErrorCode, P as ProtocolEventMessage, aT as ProtocolEventName, aU as ProtocolEventPayload, c as ProtocolMethod, aV as ProtocolReadyMessage, aW as ProtocolRequestMessage, aX as ProtocolResultMessage, aY as ResolvedClaimValue, b0 as isValidMsFileSourceId, b2 as sameNetworkIdentity, b3 as validateBsvNetwork, b4 as validateNetworkIdentity } from './protocol-Czc3NgOD.js';
package/dist/protocol.js CHANGED
@@ -1,3 +1,3 @@
1
- export { DOMAIN_MAX_PROFILES, MSFILE_BLOCK_SIZE_BYTES, MSFILE_DIGEST_SIZE_BYTES, MSFILE_LOCAL_SOURCE_ID, MSFILE_MAX_BLOCK_BYTES, MSFILE_MAX_CONTENT_BYTES, MSFILE_MAX_ERROR_MESSAGE_BYTES, MSFILE_MAX_HEADER_BYTES, MSFILE_MAX_SEED_BYTES, MSFILE_PROTOCOL_ID, PROTOCOL_METHODS, PROTOCOL_VERSION, isValidMsFileSourceId, sameNetworkIdentity, validateBsvNetwork, validateNetworkIdentity } from './chunk-A4VCQSB5.js';
1
+ export { DOMAIN_MAX_PROFILES, MSFILE_BLOCK_SIZE_BYTES, MSFILE_DIGEST_SIZE_BYTES, MSFILE_LOCAL_SOURCE_ID, MSFILE_MAX_BLOCK_BYTES, MSFILE_MAX_CONTENT_BYTES, MSFILE_MAX_ERROR_MESSAGE_BYTES, MSFILE_MAX_HEADER_BYTES, MSFILE_MAX_SEED_BYTES, MSFILE_PROTOCOL_ID, PROTOCOL_METHODS, PROTOCOL_VERSION, isValidMsFileSourceId, sameNetworkIdentity, validateBsvNetwork, validateNetworkIdentity } from './chunk-QUZZ2OXO.js';
2
2
  //# sourceMappingURL=protocol.js.map
3
3
  //# sourceMappingURL=protocol.js.map
package/dist/script.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ay as PaymentOutput } from './protocol-Dfo305R9.js';
1
+ import { aL as PaymentOutput } from './protocol-Czc3NgOD.js';
2
2
 
3
3
  type PaymentScriptKind = "p2pkh" | "p2pk" | "multisig" | "op_return" | "unknown";
4
4
  interface PaymentScriptP2pkh {
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Q as ProtocolErrorCode, at as P2pkhTransferAssetId, aJ as ProtocolRequestMessage, N as NetworkIdentity, c as ProtocolMethod, M as MethodParams, T as AiToolMessage, S as AiToolDefinition, a5 as JSONValue, aK as ProtocolResultMessage, aI as ProtocolReadyMessage, aE as ProtocolClosingMessage, d as MethodResult, aF as ProtocolError, aH as ProtocolEventPayload } from './protocol-Dfo305R9.js';
2
- export { R as AI_TOOLS_MAX_JSON_CHARS, A as AiTool, U as AiToolSchema, b as AiToolsRegistered, aM as assertToolJson, aN as assertToolPayload, aO as isAiToolMessage, aQ as parseToolDefinitions, aU as validateToolArguments } from './protocol-Dfo305R9.js';
1
+ import { V as ProtocolErrorCode, aG as P2pkhTransferAssetId, aW as ProtocolRequestMessage, N as NetworkIdentity, c as ProtocolMethod, M as MethodParams, Y as AiToolMessage, X as AiToolDefinition, ad as JSONValue, aX as ProtocolResultMessage, aV as ProtocolReadyMessage, aR as ProtocolClosingMessage, d as MethodResult, aS as ProtocolError, aU as ProtocolEventPayload } from './protocol-Czc3NgOD.js';
2
+ export { W as AI_TOOLS_MAX_JSON_CHARS, A as AiTool, Z as AiToolSchema, b as AiToolsRegistered, aZ as assertToolJson, a_ as assertToolPayload, a$ as isAiToolMessage, b1 as parseToolDefinitions, b5 as validateToolArguments } from './protocol-Czc3NgOD.js';
3
3
 
4
4
  /** 校验失败:抛出的对象。service 会捕获并组装 ProtocolError。 */
5
5
  declare class ProtocolValidationError extends Error {
package/dist/server.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { isAiToolMessage, parseToolDefinitions, validateToolArguments, assertToolPayload } from './chunk-VVOTW5ZT.js';
2
2
  export { AI_TOOLS_MAX_JSON_CHARS, assertToolJson, assertToolPayload, isAiToolMessage, parseToolDefinitions, validateToolArguments } from './chunk-VVOTW5ZT.js';
3
- import { PROTOCOL_VERSION, PROTOCOL_METHODS, validateNetworkIdentity, sameNetworkIdentity, DOMAIN_MAX_PROFILES, isValidMsFileSourceId } from './chunk-A4VCQSB5.js';
3
+ import { PROTOCOL_VERSION, PROTOCOL_METHODS, validateNetworkIdentity, sameNetworkIdentity, DOMAIN_MAX_PROFILES, isValidMsFileSourceId } from './chunk-QUZZ2OXO.js';
4
4
  import { validateApplicationPurpose, assertPaymentSignatureSlot } from './chunk-7ZOCLB2S.js';
5
5
 
6
6
  // src/validation.ts
@@ -128,6 +128,12 @@ function keys(obj, allowed) {
128
128
  throw new ProtocolValidationError("invalid_request", "Unexpected request field");
129
129
  }
130
130
  }
131
+ function msfileBlockPrice(value) {
132
+ if (value === void 0) return void 0;
133
+ if (typeof value !== "string" || !/^[1-9][0-9]{0,15}$/u.test(value))
134
+ throw new ProtocolValidationError("invalid_request", "Invalid MSFile full block price limit");
135
+ return value;
136
+ }
131
137
  function hex(value, field, pattern = /^(?:[0-9a-f]{2})+$/iu) {
132
138
  const str = expectString(value, field);
133
139
  if (!pattern.test(str)) throw new ProtocolValidationError("invalid_request", `Invalid ${field}`);
@@ -204,7 +210,7 @@ function validateApplicationPayment(obj) {
204
210
  function validateConnectLoginParams(raw) {
205
211
  const obj = expectObject(raw, "connect.login params");
206
212
  for (const key of Object.keys(obj))
207
- if (key !== "text" && key !== "claims" && key !== "publicationProof")
213
+ if (key !== "text" && key !== "claims" && key !== "publicationProof" && key !== "loginChallenge")
208
214
  throw new ProtocolValidationError("invalid_request", "connect.login contains an unsupported field");
209
215
  const text = expectString(obj.text, "text");
210
216
  let claims;
@@ -217,7 +223,12 @@ function validateConnectLoginParams(raw) {
217
223
  claims = [...obj.claims];
218
224
  }
219
225
  const publicationProof = expectPublicationRecordString(obj.publicationProof);
220
- return publicationProof === void 0 ? { text, claims } : { text, claims, publicationProof };
226
+ return {
227
+ text,
228
+ claims,
229
+ ...publicationProof === void 0 ? {} : { publicationProof },
230
+ ...validateLoginChallenge(obj.loginChallenge)
231
+ };
221
232
  }
222
233
  function validateConnectLogoutParams(raw) {
223
234
  expectObject(raw, "connect.logout params");
@@ -225,12 +236,23 @@ function validateConnectLogoutParams(raw) {
225
236
  }
226
237
  function validateConnectLaunchParams(raw) {
227
238
  const obj = expectObject(raw, "connect.launch params");
228
- if (Object.keys(obj).some((key) => key !== "launchToken" && key !== "publicationProof")) {
239
+ if (Object.keys(obj).some((key) => key !== "launchToken" && key !== "publicationProof" && key !== "loginChallenge")) {
229
240
  throw new ProtocolValidationError("invalid_request", "connect.launch contains an unsupported field");
230
241
  }
231
242
  const launchToken = expectNonEmptyString(obj.launchToken, "launchToken");
232
243
  const publicationProof = expectPublicationRecordString(obj.publicationProof);
233
- return publicationProof === void 0 ? { launchToken } : { launchToken, publicationProof };
244
+ return {
245
+ launchToken,
246
+ ...publicationProof === void 0 ? {} : { publicationProof },
247
+ ...validateLoginChallenge(obj.loginChallenge)
248
+ };
249
+ }
250
+ function validateLoginChallenge(value) {
251
+ if (value === void 0) return {};
252
+ if (typeof value !== "string" || !/^[0-9a-f]{64}$/u.test(value)) {
253
+ throw new ProtocolValidationError("invalid_request", "loginChallenge must be 32 bytes in lowercase hex");
254
+ }
255
+ return { loginChallenge: value };
234
256
  }
235
257
  function expectPublicationRecordString(value) {
236
258
  if (value === void 0) return void 0;
@@ -564,6 +586,17 @@ function parseRequestMessage(raw, receiverIdentity) {
564
586
  observedRawTxHex: params.observedRawTxHex === void 0 ? void 0 : hex(params.observedRawTxHex, "observedRawTxHex")
565
587
  };
566
588
  break;
589
+ case "chain.get_transactions": {
590
+ keys(params, ["txids", "mode"]);
591
+ const { txids, mode } = params;
592
+ if (!Array.isArray(txids) || !txids.length || txids.length > 20 || mode !== "raw" && mode !== "status") {
593
+ throw new ProtocolValidationError("invalid_request", "Expected 1 to 20 transaction IDs and a valid query mode");
594
+ }
595
+ const ids = Array.from(txids, (txid) => hex(txid, "txid", /^[0-9a-f]{64}$/iu));
596
+ if (new Set(ids).size !== ids.length) throw new ProtocolValidationError("invalid_request", "Duplicate transaction ID");
597
+ normalized = { txids: ids, mode };
598
+ break;
599
+ }
567
600
  case "chain.list_script_unspent":
568
601
  keys(params, ["script"]);
569
602
  normalized = { script: hex(params.script, "script") };
@@ -588,9 +621,40 @@ function parseRequestMessage(raw, receiverIdentity) {
588
621
  normalized = { fileName: expectNonEmptyString(params.fileName, "fileName"), content: parseBinaryField(params.content, "content") };
589
622
  break;
590
623
  case "msfile.content.read":
591
- keys(params, ["seedHashHex"]);
592
- normalized = validateMsFileStatParams(params);
624
+ case "msfile.content.open": {
625
+ keys(params, ["seedHashHex", "clientRequestId", "maxFullBlockPriceSatoshis"]);
626
+ const price = msfileBlockPrice(params.maxFullBlockPriceSatoshis);
627
+ const needsId = method === "msfile.content.open" || price !== void 0 || params.clientRequestId !== void 0;
628
+ normalized = {
629
+ ...validateMsFileStatParams(params),
630
+ ...needsId ? validatePaymentStatusParams({ clientRequestId: params.clientRequestId }) : {},
631
+ ...price === void 0 ? {} : { maxFullBlockPriceSatoshis: price }
632
+ };
633
+ break;
634
+ }
635
+ case "msfile.content.status":
636
+ normalized = validatePaymentStatusParams(params);
593
637
  break;
638
+ case "msfile.content.price": {
639
+ keys(params, ["clientRequestId", "maxFullBlockPriceSatoshis"]);
640
+ const price = msfileBlockPrice(params.maxFullBlockPriceSatoshis);
641
+ normalized = price === void 0 && params.clientRequestId === void 0 ? {} : {
642
+ ...validatePaymentStatusParams({ clientRequestId: params.clientRequestId }),
643
+ ...price === void 0 ? {} : { maxFullBlockPriceSatoshis: price }
644
+ };
645
+ if (price === void 0 && params.clientRequestId !== void 0)
646
+ throw new ProtocolValidationError("invalid_request", "Expected a full block price limit");
647
+ break;
648
+ }
649
+ case "msfile.content.range": {
650
+ keys(params, ["clientRequestId", "offset", "length"]);
651
+ const { offset, length } = params;
652
+ if (typeof offset !== "number" || !Number.isSafeInteger(offset) || offset < 0 || typeof length !== "number" || !Number.isSafeInteger(length) || length < 0 || length > 256 * 1024 || !Number.isSafeInteger(offset + length)) {
653
+ throw new ProtocolValidationError("invalid_request", "Invalid MSFile byte range");
654
+ }
655
+ normalized = { ...validatePaymentStatusParams({ clientRequestId: params.clientRequestId }), offset, length };
656
+ break;
657
+ }
594
658
  case "domain.profiles":
595
659
  normalized = validateDomainProfilesParams(params);
596
660
  break;