@steve02081504/fount-p2p 0.0.26 → 0.0.27

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.
Files changed (99) hide show
  1. package/README.md +1 -0
  2. package/core/bytes_codec.mjs +5 -6
  3. package/core/composite_key.mjs +0 -79
  4. package/core/entity_id_parse.mjs +2 -3
  5. package/core/evfs_logical_path.mjs +2 -3
  6. package/core/hexIds.mjs +5 -5
  7. package/core/logical_entity.mjs +3 -4
  8. package/crypto/channel.mjs +2 -25
  9. package/crypto/checkpoint_sign.mjs +5 -4
  10. package/crypto/crypto.mjs +0 -8
  11. package/crypto/key.mjs +9 -10
  12. package/dag/canonicalize_row.mjs +1 -1
  13. package/discovery/advert_peer_hints.mjs +1 -1
  14. package/discovery/adverts.mjs +7 -12
  15. package/discovery/bt/index.mjs +3 -11
  16. package/discovery/bt/peer_hints.mjs +2 -3
  17. package/discovery/bt/runtime.mjs +1 -1
  18. package/discovery/index.mjs +14 -14
  19. package/discovery/lan.mjs +3 -3
  20. package/discovery/lan_interfaces.mjs +2 -2
  21. package/discovery/lan_peer_hints.mjs +1 -1
  22. package/discovery/nostr.mjs +16 -21
  23. package/federation/entity_key_chain.mjs +5 -24
  24. package/federation/message_rate_limit.mjs +3 -2
  25. package/federation/part_query/runtime.mjs +9 -20
  26. package/files/assemble.mjs +3 -3
  27. package/files/assemble_stream.mjs +1 -1
  28. package/files/chunk/fetch.mjs +1 -2
  29. package/files/chunk/responder.mjs +4 -41
  30. package/files/chunk/store.mjs +2 -3
  31. package/files/chunk/verify.mjs +2 -3
  32. package/files/evfs.mjs +1 -1
  33. package/files/evfs_ref.mjs +3 -4
  34. package/files/fetch_fanout.mjs +3 -3
  35. package/files/manifest/fetch.mjs +2 -3
  36. package/files/manifest/normalize.mjs +9 -9
  37. package/files/manifest/pending.mjs +1 -4
  38. package/files/manifest/public.mjs +8 -8
  39. package/files/transfer_key.mjs +3 -3
  40. package/files/transfer_key_registry.mjs +6 -6
  41. package/governance/branch.mjs +2 -1
  42. package/governance/join_pow.mjs +7 -5
  43. package/governance/owner_succession_ballot.mjs +6 -6
  44. package/index.mjs +2 -2
  45. package/infra/default_node_dir.mjs +2 -2
  46. package/infra/priority.mjs +2 -2
  47. package/link/frame.mjs +2 -3
  48. package/link/handshake.mjs +6 -6
  49. package/link/pipe.mjs +1 -2
  50. package/link/providers/ble_gatt.mjs +1 -9
  51. package/link/providers/index.mjs +2 -2
  52. package/link/providers/nostr.mjs +1 -3
  53. package/link/providers/webrtc.mjs +1 -1
  54. package/link/rtc/ice_local_hostname.mjs +6 -5
  55. package/link/rtc/w3c_bridge.mjs +1 -1
  56. package/link/sdp_fingerprint.mjs +1 -1
  57. package/mailbox/consumer_registry.mjs +2 -2
  58. package/mailbox/deliver_or_store.mjs +4 -4
  59. package/mailbox/parse.mjs +1 -1
  60. package/mailbox/prune.mjs +2 -2
  61. package/mailbox/rate.mjs +3 -10
  62. package/mailbox/store.mjs +7 -7
  63. package/node/denylist.mjs +38 -38
  64. package/node/entity_store.mjs +5 -5
  65. package/node/identity.mjs +7 -8
  66. package/node/instance.mjs +1 -1
  67. package/node/log.mjs +1 -1
  68. package/node/network.mjs +14 -16
  69. package/node/personal_block.mjs +22 -20
  70. package/node/reputation_store.mjs +11 -19
  71. package/node/reputation_sync.mjs +0 -7
  72. package/node/signaling_config.mjs +1 -1
  73. package/node/storage_plugins.mjs +2 -2
  74. package/overlay/index.mjs +1 -1
  75. package/package.json +1 -1
  76. package/registries/event_type.mjs +2 -2
  77. package/registries/room_provider.mjs +2 -2
  78. package/reputation/engine.mjs +17 -15
  79. package/schemas/discovery.mjs +5 -5
  80. package/schemas/federation_pull.mjs +16 -24
  81. package/schemas/part_query.mjs +4 -4
  82. package/timeline/verify_remote.mjs +4 -4
  83. package/transport/group_link_set.mjs +2 -2
  84. package/transport/ice_servers.mjs +2 -2
  85. package/transport/link_registry.mjs +6 -18
  86. package/transport/mesh_keepalive.mjs +1 -1
  87. package/transport/node_scope/wire.mjs +1 -1
  88. package/transport/remote_user_room.mjs +13 -15
  89. package/transport/rtc_connection_budget.mjs +6 -6
  90. package/transport/runtime_bootstrap.mjs +12 -12
  91. package/trust_graph/cache.mjs +2 -3
  92. package/trust_graph/engine.mjs +1 -1
  93. package/trust_graph/registry.mjs +2 -2
  94. package/trust_graph/send.mjs +1 -1
  95. package/utils/async_mutex.mjs +1 -1
  96. package/wire/ingress.mjs +1 -1
  97. package/wire/part/ingress.mjs +6 -6
  98. package/wire/part/query.mjs +3 -3
  99. package/wire/volatile_signature.mjs +4 -9
@@ -20,7 +20,7 @@ import trustGraphTunables from './tunables.json' with { type: 'json' }
20
20
  * @returns {Promise<boolean>} 是否已发送
21
21
  */
22
22
  export async function sendToNode(username, targetNodeHash, actionName, payload, graph) {
23
- const target = normalizeHex64(targetNodeHash) || String(targetNodeHash || '').trim().toLowerCase()
23
+ const target = normalizeHex64(targetNodeHash)
24
24
  if (!isHex64(target)) return false
25
25
 
26
26
  // 已直连 peer 不经 trust-graph scope 也应能收发 node scope action(非成员 CAS chunk / follow hint 等)
@@ -39,7 +39,7 @@ function releaseMutex(lockKey, state) {
39
39
  * @template T
40
40
  */
41
41
  export async function withAsyncMutex(key, criticalSection) {
42
- const lockKey = String(key)
42
+ const lockKey = key
43
43
  const state = mutexState(lockKey)
44
44
  return new Promise((resolve, reject) => {
45
45
  /**
package/wire/ingress.mjs CHANGED
@@ -46,6 +46,6 @@ export function isSignedDagEventRow(event) {
46
46
  */
47
47
  export function extractInboundSignedEvent(payload, groupId) {
48
48
  if (!isSignedDagEventRow(payload)) return null
49
- if (payload.groupId && String(payload.groupId) !== groupId) return null
49
+ if (payload.groupId && payload.groupId !== groupId) return null
50
50
  return payload
51
51
  }
@@ -21,15 +21,15 @@ import { handleIncomingPartInvokeResponse } from './pending.mjs'
21
21
  * @returns {object | null} 白名单字段
22
22
  */
23
23
  function parsePartTimelinePut(data, partpath) {
24
- const timelineEntityHash = String(data.timelineEntityHash || '').trim().toLowerCase()
24
+ const timelineEntityHash = String(data.timelineEntityHash || '')
25
25
  if (!timelineEntityHash || !isPlainObject(data.event)) return null
26
26
  return {
27
27
  type: 'part_timeline_put',
28
28
  partpath,
29
29
  timelineEntityHash,
30
30
  event: data.event,
31
- ...data.nodeHash ? { nodeHash: String(data.nodeHash).trim() } : {},
32
- ...data.groupId ? { groupId: String(data.groupId).trim() } : {},
31
+ ...data.nodeHash ? { nodeHash: String(data.nodeHash) } : {},
32
+ ...data.groupId ? { groupId: String(data.groupId) } : {},
33
33
  }
34
34
  }
35
35
 
@@ -60,8 +60,8 @@ async function dispatchPartInvoke(wireContext, payload) {
60
60
  if (!partpath || !isPlainObject(invoke)) return null
61
61
  return dispatchRpcInbound({
62
62
  replicaUsername: wireContext.replicaUsername,
63
- requesterNodeHash: payload.peerId ? String(payload.peerId).trim() : null,
64
- groupId: payload.groupId ? String(payload.groupId).trim() : undefined,
63
+ requesterNodeHash: payload.peerId || null,
64
+ groupId: payload.groupId || undefined,
65
65
  peerId: payload.peerId,
66
66
  }, {
67
67
  type: 'part_invoke',
@@ -93,7 +93,7 @@ export function attachPartWire(wireContext, wire, options = {}) {
93
93
  if (!message) return
94
94
  void dispatchDeliveryInbound({
95
95
  replicaUsername: wireContext.replicaUsername,
96
- requesterNodeHash: peerId ? String(peerId).trim() : null,
96
+ requesterNodeHash: peerId || null,
97
97
  }, message)
98
98
  },
99
99
  /**
@@ -48,11 +48,11 @@ export function attachPartQueryWire(wireContext, wire, dependencies = {}) {
48
48
  const request = parsePartQueryReq(data)
49
49
  if (!request) return
50
50
  if (!state.takeDedupe(request.requestId)) return
51
- const source = String(peerId || request.originNodeHash || '').trim().toLowerCase()
51
+ const source = peerId || request.originNodeHash
52
52
  if (source && !consumeWireRateBucket(`part_query:${source}`, {
53
53
  maxCount: partQueryTunables.ratePerSourcePerMin,
54
54
  })) return
55
- void processIncomingPartQueryRequest(wireContext, wire, request, String(peerId || ''), deps)
55
+ void processIncomingPartQueryRequest(wireContext, wire, request, peerId, deps)
56
56
  },
57
57
  /**
58
58
  * @param {unknown} data part_query_res 载荷
@@ -61,7 +61,7 @@ export function attachPartQueryWire(wireContext, wire, dependencies = {}) {
61
61
  part_query_res(data, peerId) {
62
62
  const response = parsePartQueryRes(data)
63
63
  if (!response) return
64
- handleIncomingPartQueryResponse(response, String(peerId || ''), deps)
64
+ handleIncomingPartQueryResponse(response, peerId, deps)
65
65
  },
66
66
  })
67
67
  }
@@ -28,10 +28,9 @@ export function boundStreamSlices(slices) {
28
28
  * @returns {Uint8Array} 验签消息字节
29
29
  */
30
30
  export function streamChunkSignBytes(pendingStreamId, chunkSeq, slices) {
31
- const streamId = String(pendingStreamId ?? '')
32
31
  const sequence = Number.isFinite(Number(chunkSeq)) ? String(chunkSeq) : '0'
33
32
  const body = JSON.stringify(slices ?? [])
34
- return new TextEncoder().encode(`${CHUNK_DOMAIN}\0${streamId}\0${sequence}\0${body}`)
33
+ return new TextEncoder().encode(`${CHUNK_DOMAIN}\0${pendingStreamId}\0${sequence}\0${body}`)
35
34
  }
36
35
 
37
36
  /**
@@ -51,11 +50,9 @@ export async function signStreamSignatureHex(bytes, secretKey) {
51
50
  * @returns {Promise<boolean>} 验签是否通过
52
51
  */
53
52
  export async function verifyStreamSignatureHex(bytes, signatureHex, publicKeyHex) {
54
- const signature = String(signatureHex || '').trim().toLowerCase()
55
- const publicKey = String(publicKeyHex || '').trim().toLowerCase()
56
- if (!isSignatureHex128(signature) || !isHex64(publicKey)) return false
53
+ if (!isSignatureHex128(signatureHex) || !isHex64(publicKeyHex)) return false
57
54
  try {
58
- return await verify(Buffer.from(signature, 'hex'), bytes, Buffer.from(publicKey, 'hex'))
55
+ return await verify(Buffer.from(signatureHex, 'hex'), bytes, Buffer.from(publicKeyHex, 'hex'))
59
56
  }
60
57
  catch {
61
58
  return false
@@ -69,8 +66,6 @@ export async function verifyStreamSignatureHex(bytes, signatureHex, publicKeyHex
69
66
  * @returns {{ publicKey: Uint8Array, secretKey: Uint8Array }} 密钥对
70
67
  */
71
68
  export function streamKeyPairFromUserSeed(username, seedMaterial) {
72
- const user = String(username ?? '')
73
- const material = String(seedMaterial ?? '')
74
- const seed = createHash('sha256').update(`fount-stream-sign\0${user}\0${material}`).digest()
69
+ const seed = createHash('sha256').update(`fount-stream-sign\0${username}\0${seedMaterial}`).digest()
75
70
  return keyPairFromSeed(seed)
76
71
  }