keymaster-connect 0.1.0 → 0.1.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.
@@ -87,26 +87,6 @@ interface ChannelMessageReceivedEventData {
87
87
  */
88
88
  rawEnvelope?: Uint8Array;
89
89
  }
90
- interface PriceGetParams extends Record<string, never> {
91
- }
92
- interface PriceValue {
93
- /** 十进制金额字符串,例如 "45.12";未就绪时为 "0"。 */
94
- amount: string;
95
- /** 计价单位,例如 "USDT";未就绪时仍给出当前配置推导出的单位。 */
96
- unit: string;
97
- /** 行情快照生成的 Unix 毫秒时间;未就绪时为 0。 */
98
- updatedAtMs: number;
99
- }
100
- /** `price.get` 结果。 */
101
- type PriceGetResult = PriceValue;
102
- interface PriceSubscribeParams extends Record<string, never> {
103
- }
104
- interface PriceSubscriptionResult {
105
- /** 调用完成后该会话是否处于价格推送订阅态。 */
106
- subscribed: boolean;
107
- }
108
- /** `price.changed` 事件数据;形状与 `price.get` 结果一致。 */
109
- type PriceChangedEventData = PriceValue;
110
90
  interface StorageListParams {
111
91
  /** 目录前缀。 */
112
92
  prefix?: string;
@@ -345,9 +325,7 @@ type ProtocolErrorCode =
345
325
  /** Transport authority was revoked or belongs to another wallet/Worker generation. */
346
326
  "connection_expired" | "invalid_request" | "invalid_origin" | "user_rejected" | "active_key_unavailable" | "decrypt_failed"
347
327
  /**
348
- * 请求了当前资产但 Keymaster 设置里未开启(施工单 2026-09-18 001)。
349
- * 例如 `p2pkh.transfer` / `feepool.*` 传 `assetId: "bsv-testnet"` 而
350
- * P2PKH 设置里没有打开 testnet。accept 阶段 fail-fast,不进确认流。
328
+ * 请求资产与连接绑定的钱包网络不一致;accept 阶段拒绝,不进入业务执行。
351
329
  */
352
330
  | "asset_not_enabled"
353
331
  /** Connect v1 明确排除的方法族(新费用池签名等)。 */
@@ -386,10 +364,8 @@ interface ProtocolCancelMessage {
386
364
  * 设计缘由:
387
365
  * - `channel.message_received` 是已验签的 Channel 公开消息,只发送给
388
366
  * 当前 session 已精确订阅的频道;
389
- * - `price.changed` 是 Keymaster 当前 BSV 价格展示值变化,向所有活跃
390
- * session 推送;未就绪时也可能推送 amount "0"。
391
367
  */
392
- type ProtocolEventName = "channel.message_received" | "price.changed";
368
+ type ProtocolEventName = "channel.message_received";
393
369
  interface IdentityGetParams {
394
370
  /** 目标站点 origin;必须等于 `event.origin`,否则拒绝。 */
395
371
  aud: string;
@@ -483,9 +459,7 @@ interface PaymentChannelRegisterResult {
483
459
  * 设计缘由(施工单 2026-09-18 001 多资产硬切换):
484
460
  * - 公开命名固定 `bsv-mainnet` / `bsv-testnet`,不暴露 p2pkh 内部
485
461
  * 的 `bsv` / `bsvtest`;
486
- * - `bsv-testnet` 只属于测试网身份,
487
- * 否则 accept 阶段 fail-fast `asset_not_enabled`;
488
- * - 缺省(不传 assetId)等同 `bsv-mainnet`,旧调用方零改动。
462
+ * - 资产由连接绑定的钱包网络决定,调用方不能选择或覆盖该网络。
489
463
  */
490
464
  type P2pkhTransferAssetId = "bsv-mainnet" | "bsv-testnet";
491
465
  interface P2pkhTransferParams {
@@ -495,11 +469,11 @@ interface P2pkhTransferParams {
495
469
  recipientAddress: string;
496
470
  /** 正整数 satoshis。 */
497
471
  amountSatoshis: number;
498
- /** 可选 fee rate(sat/kB)。>= 1。 */
472
+ /** 可选费率(sat/kB),>= 1;缺省由钱包当前网络的有效费率策略决定。 */
499
473
  feeRateSatoshisPerKb?: number;
500
474
  }
501
475
  interface P2pkhTransferResult {
502
- /** 本次实际转账的资产;与 params.assetId 一致(缺省回 `bsv-mainnet`)。 */
476
+ /** 本次实际转账的资产,与连接绑定的钱包网络一致。 */
503
477
  assetId: P2pkhTransferAssetId;
504
478
  /** 已广播交易的 canonical txid。 */
505
479
  txid: string;
@@ -529,7 +503,7 @@ interface PaymentPayParams {
529
503
  businessKind: string;
530
504
  /** 业务金额(聪,不含矿工费)。 */
531
505
  amountSatoshis: number;
532
- /** 可选希望费率(sat/kB)。 */
506
+ /** 可选希望费率(sat/kB);缺省由钱包当前网络的有效费率策略决定。 */
533
507
  feeRateSatoshisPerKb?: number;
534
508
  recipient: ConnectPaymentRecipient;
535
509
  }
@@ -612,7 +586,7 @@ interface ConnectLaunchResult {
612
586
  appIdentity?: AppIdentitySnapshot;
613
587
  }
614
588
  /** 协议方法名常量集合。 */
615
- declare const PROTOCOL_METHODS: readonly ["identity.get", "intent.sign", "cipher.encrypt", "cipher.decrypt", "p2pkh.transfer", "payment.pay", "payment.status", "payment.channel.register", "connect.login", "connect.resume", "connect.logout", "connect.launch", "channel.publish", "channel.subscription_set", "price.get", "price.subscribe", "price.unsubscribe", "storage.list", "storage.directory.create", "storage.directory.delete", "storage.put", "storage.get", "storage.delete", "msfile.stat", "msfile.seed.read", "msfile.block.read"];
589
+ declare const PROTOCOL_METHODS: readonly ["identity.get", "intent.sign", "cipher.encrypt", "cipher.decrypt", "p2pkh.transfer", "payment.pay", "payment.status", "payment.channel.register", "connect.login", "connect.resume", "connect.logout", "connect.launch", "channel.publish", "channel.subscription_set", "storage.list", "storage.directory.create", "storage.directory.delete", "storage.put", "storage.get", "storage.delete", "msfile.stat", "msfile.seed.read", "msfile.block.read"];
616
590
  type ProtocolMethod = (typeof PROTOCOL_METHODS)[number];
617
591
  /**
618
592
  * 方法 -> 请求参数类型 的映射。`MethodParams<M>` 是计算出的参数类型。
@@ -633,9 +607,6 @@ interface MethodParamsMap {
633
607
  "connect.launch": ConnectLaunchParams;
634
608
  "channel.publish": ChannelPublishParams;
635
609
  "channel.subscription_set": ChannelSubscriptionSetParams;
636
- "price.get": PriceGetParams;
637
- "price.subscribe": PriceSubscribeParams;
638
- "price.unsubscribe": PriceSubscribeParams;
639
610
  "storage.list": StorageListParams;
640
611
  "storage.directory.create": StorageDirectoryParams;
641
612
  "storage.directory.delete": StorageDirectoryParams;
@@ -661,9 +632,6 @@ interface MethodResultMap {
661
632
  "connect.launch": ConnectLaunchResult;
662
633
  "channel.publish": ChannelPublishResult;
663
634
  "channel.subscription_set": ChannelSubscriptionSetResult;
664
- "price.get": PriceGetResult;
665
- "price.subscribe": PriceSubscriptionResult;
666
- "price.unsubscribe": PriceSubscriptionResult;
667
635
  "storage.list": StorageListResult;
668
636
  "storage.directory.create": StorageDirectoryResult;
669
637
  "storage.directory.delete": StorageDirectoryResult;
@@ -681,11 +649,6 @@ type ProtocolEventPayload = {
681
649
  type: "event";
682
650
  event: "channel.message_received";
683
651
  data: ChannelMessageReceivedEventData;
684
- } | {
685
- v: typeof PROTOCOL_VERSION;
686
- type: "event";
687
- event: "price.changed";
688
- data: PriceChangedEventData;
689
652
  };
690
653
  type ProtocolEventMessage = ProtocolEventPayload & {
691
654
  networkIdentity: NetworkIdentity;
@@ -716,4 +679,4 @@ type ProtocolResultMessage = {
716
679
  networkIdentity?: NetworkIdentity;
717
680
  };
718
681
 
719
- export { type AppIdentityProofV1, type AppIdentitySnapshot, type AppRequirement, type BinaryField, type BsvNetwork, type ChannelMessageReceivedEventData, type ChannelPublishParams, type ChannelPublishResult, type ChannelSubscriptionErrorCode, type ChannelSubscriptionPhase, type ChannelSubscriptionSetParams, type ChannelSubscriptionSetResult, type ChannelSubscriptionStatus, type CipherDecryptParams, type CipherDecryptResult, type CipherEncryptParams, type CipherEncryptResult, type ConnectLaunchParams, type ConnectLaunchResult, type ConnectLoginParams, type ConnectLoginResult, type ConnectLogoutParams, type ConnectLogoutResult, type ConnectPaymentRecipient, type ConnectPaymentRecipientOwnership, type ConnectPaymentStatus, type ConnectPaymentType, type ConnectResumeParams, type ConnectResumeResult, type IdentityGetParams, type IdentityGetResult, type IntentSignParams, type IntentSignResult, type JSONValue, 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, type MethodParams, type MethodParamsMap, type MethodResult, type MethodResultMap, type MsFileBlockReadParams, type MsFileLocalSourceStat, type MsFileReadResult, type MsFileRemoteSourceStat, type MsFileSatoshiAmount, type MsFileSeedReadParams, type MsFileSourceKind, type MsFileSourceStat, type MsFileStatAbsentEntry, type MsFileStatAvailableEntry, type MsFileStatDiscoveringEntry, type MsFileStatNetworkErrorEntry, type MsFileStatParams, type MsFileStatQuotedEntry, type MsFileStatResult, type MsFileSupplierStat, type NetworkIdentity, type P2pkhTransferAssetId, type P2pkhTransferParams, type P2pkhTransferResult, PROTOCOL_METHODS, PROTOCOL_VERSION, type PaymentChannelRegisterParams, type PaymentChannelRegisterResult, type PaymentPayParams, type PaymentPayResult, type PaymentReleaseSummary, type PaymentStatusParams, type PaymentStatusResult, type PriceChangedEventData, type PriceGetParams, type PriceGetResult, type PriceSubscribeParams, type PriceSubscriptionResult, type PriceValue, type ProtocolCancelMessage, type ProtocolClosingMessage, type ProtocolError, type ProtocolErrorCode, type ProtocolEventMessage, type ProtocolEventName, type ProtocolEventPayload, type ProtocolMethod, type ProtocolReadyMessage, type ProtocolRequestMessage, type ProtocolResultMessage, type ResolvedClaimValue, STORAGE_DEFAULT_LIST_LIMIT, STORAGE_MAX_LIST_LIMIT, STORAGE_MAX_PAYLOAD_BYTES, type StorageDeleteParams, type StorageDeleteResult, type StorageDirectoryParams, type StorageDirectoryResult, type StorageGetParams, type StorageGetResult, type StorageListEntry, type StorageListParams, type StorageListResult, type StoragePutParams, type StoragePutResult, type VerifiedAppIdentity, isValidMsFileSourceId, sameNetworkIdentity, validateBsvNetwork, validateNetworkIdentity };
682
+ export { type AppIdentityProofV1, type AppIdentitySnapshot, type AppRequirement, type BinaryField, type BsvNetwork, type ChannelMessageReceivedEventData, type ChannelPublishParams, type ChannelPublishResult, type ChannelSubscriptionErrorCode, type ChannelSubscriptionPhase, type ChannelSubscriptionSetParams, type ChannelSubscriptionSetResult, type ChannelSubscriptionStatus, type CipherDecryptParams, type CipherDecryptResult, type CipherEncryptParams, type CipherEncryptResult, type ConnectLaunchParams, type ConnectLaunchResult, type ConnectLoginParams, type ConnectLoginResult, type ConnectLogoutParams, type ConnectLogoutResult, type ConnectPaymentRecipient, type ConnectPaymentRecipientOwnership, type ConnectPaymentStatus, type ConnectPaymentType, type ConnectResumeParams, type ConnectResumeResult, type IdentityGetParams, type IdentityGetResult, type IntentSignParams, type IntentSignResult, type JSONValue, 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, type MethodParams, type MethodParamsMap, type MethodResult, type MethodResultMap, type MsFileBlockReadParams, type MsFileLocalSourceStat, type MsFileReadResult, type MsFileRemoteSourceStat, type MsFileSatoshiAmount, type MsFileSeedReadParams, type MsFileSourceKind, type MsFileSourceStat, type MsFileStatAbsentEntry, type MsFileStatAvailableEntry, type MsFileStatDiscoveringEntry, type MsFileStatNetworkErrorEntry, type MsFileStatParams, type MsFileStatQuotedEntry, type MsFileStatResult, type MsFileSupplierStat, type NetworkIdentity, type P2pkhTransferAssetId, type P2pkhTransferParams, type P2pkhTransferResult, PROTOCOL_METHODS, PROTOCOL_VERSION, type PaymentChannelRegisterParams, type PaymentChannelRegisterResult, type PaymentPayParams, type PaymentPayResult, type PaymentReleaseSummary, type PaymentStatusParams, type PaymentStatusResult, type ProtocolCancelMessage, type ProtocolClosingMessage, type ProtocolError, type ProtocolErrorCode, type ProtocolEventMessage, type ProtocolEventName, type ProtocolEventPayload, type ProtocolMethod, type ProtocolReadyMessage, type ProtocolRequestMessage, type ProtocolResultMessage, type ResolvedClaimValue, STORAGE_DEFAULT_LIST_LIMIT, STORAGE_MAX_LIST_LIMIT, STORAGE_MAX_PAYLOAD_BYTES, type StorageDeleteParams, type StorageDeleteResult, type StorageDirectoryParams, type StorageDirectoryResult, type StorageGetParams, type StorageGetResult, type StorageListEntry, type StorageListParams, type StorageListResult, type StoragePutParams, type StoragePutResult, type VerifiedAppIdentity, isValidMsFileSourceId, sameNetworkIdentity, validateBsvNetwork, validateNetworkIdentity };
package/dist/protocol.js CHANGED
@@ -1,3 +1,3 @@
1
- export { 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, STORAGE_DEFAULT_LIST_LIMIT, STORAGE_MAX_LIST_LIMIT, STORAGE_MAX_PAYLOAD_BYTES, isValidMsFileSourceId, sameNetworkIdentity, validateBsvNetwork, validateNetworkIdentity } from './chunk-AAVOIS5Q.js';
1
+ export { 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, STORAGE_DEFAULT_LIST_LIMIT, STORAGE_MAX_LIST_LIMIT, STORAGE_MAX_PAYLOAD_BYTES, isValidMsFileSourceId, sameNetworkIdentity, validateBsvNetwork, validateNetworkIdentity } from './chunk-JDAJD3SX.js';
2
2
  //# sourceMappingURL=protocol.js.map
3
3
  //# sourceMappingURL=protocol.js.map
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import { PROTOCOL_VERSION, PROTOCOL_METHODS, validateNetworkIdentity, sameNetworkIdentity, STORAGE_MAX_PAYLOAD_BYTES, STORAGE_DEFAULT_LIST_LIMIT, STORAGE_MAX_LIST_LIMIT, isValidMsFileSourceId } from './chunk-AAVOIS5Q.js';
1
+ import { PROTOCOL_VERSION, PROTOCOL_METHODS, validateNetworkIdentity, sameNetworkIdentity, STORAGE_MAX_PAYLOAD_BYTES, STORAGE_DEFAULT_LIST_LIMIT, STORAGE_MAX_LIST_LIMIT, isValidMsFileSourceId } from './chunk-JDAJD3SX.js';
2
2
  import { secp256k1 } from '@noble/curves/secp256k1.js';
3
3
  import { sha256 } from '@noble/hashes/sha2.js';
4
4
 
@@ -365,11 +365,6 @@ function validateChannelSubscriptionSetParams(raw) {
365
365
  }
366
366
  return { channels };
367
367
  }
368
- function validatePriceParams(raw) {
369
- const obj = expectObject(raw, "price params");
370
- requireExactKeys(obj, [], "price params");
371
- return {};
372
- }
373
368
  function validateExactChannel(value, field = "channel") {
374
369
  const channel = expectString(value, field);
375
370
  if (channel.length === 0 || channel === "*") {
@@ -761,11 +756,6 @@ function parseRequestMessage(raw, receiverIdentity) {
761
756
  case "channel.subscription_set":
762
757
  normalized = validateChannelSubscriptionSetParams(params);
763
758
  break;
764
- case "price.get":
765
- case "price.subscribe":
766
- case "price.unsubscribe":
767
- normalized = validatePriceParams(params);
768
- break;
769
759
  case "storage.list":
770
760
  normalized = validateStorageListParams(params);
771
761
  break;