@kubun/plugin-p2p 0.10.0 → 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.
Files changed (136) hide show
  1. package/lib/context/delegation.js +130 -1
  2. package/lib/context/group.js +1319 -1
  3. package/lib/context/hub.js +150 -1
  4. package/lib/context/join.js +80 -1
  5. package/lib/context/sync.js +19 -1
  6. package/lib/context/types.d.ts +12 -3
  7. package/lib/context/types.js +28 -1
  8. package/lib/groups/admin-roster.d.ts +130 -0
  9. package/lib/groups/admin-roster.js +184 -0
  10. package/lib/groups/broadcast-codec.js +6 -1
  11. package/lib/groups/broadcast.d.ts +122 -38
  12. package/lib/groups/broadcast.js +627 -1
  13. package/lib/groups/circle-projection.d.ts +122 -0
  14. package/lib/groups/circle-projection.js +288 -0
  15. package/lib/groups/circle-reducers.d.ts +178 -0
  16. package/lib/groups/circle-reducers.js +198 -0
  17. package/lib/groups/events.d.ts +7 -2
  18. package/lib/groups/events.js +10 -1
  19. package/lib/groups/group-anchor.d.ts +63 -0
  20. package/lib/groups/group-anchor.js +107 -0
  21. package/lib/groups/group-crypto.d.ts +19 -0
  22. package/lib/groups/group-crypto.js +85 -0
  23. package/lib/groups/group-handle-registry.d.ts +69 -2
  24. package/lib/groups/group-handle-registry.js +243 -1
  25. package/lib/groups/group-handlers.d.ts +29 -0
  26. package/lib/groups/group-handlers.js +92 -0
  27. package/lib/groups/group-health-monitor.d.ts +56 -0
  28. package/lib/groups/group-health-monitor.js +139 -0
  29. package/lib/groups/group-mls.d.ts +35 -0
  30. package/lib/groups/group-mls.js +164 -0
  31. package/lib/groups/group-peer-manager.d.ts +108 -0
  32. package/lib/groups/group-peer-manager.js +344 -0
  33. package/lib/groups/group-protocols.d.ts +297 -0
  34. package/lib/groups/group-protocols.js +174 -0
  35. package/lib/groups/invite-payload.d.ts +1 -1
  36. package/lib/groups/invite-payload.js +26 -1
  37. package/lib/groups/join-utils.d.ts +1 -0
  38. package/lib/groups/join-utils.js +104 -1
  39. package/lib/groups/ledger-affected-events.d.ts +15 -0
  40. package/lib/groups/ledger-affected-events.js +96 -0
  41. package/lib/groups/ledger-entry.d.ts +37 -0
  42. package/lib/groups/ledger-entry.js +56 -0
  43. package/lib/groups/ledger-fold.d.ts +56 -0
  44. package/lib/groups/ledger-fold.js +53 -0
  45. package/lib/groups/manager.d.ts +29 -71
  46. package/lib/groups/manager.js +281 -1
  47. package/lib/groups/mls-codec.d.ts +1 -1
  48. package/lib/groups/mls-codec.js +18 -1
  49. package/lib/groups/mls-encryptor.d.ts +2 -2
  50. package/lib/groups/mls-encryptor.js +30 -1
  51. package/lib/groups/mls-group-handle.d.ts +1 -1
  52. package/lib/groups/mls-group-handle.js +10 -1
  53. package/lib/groups/mls-json.js +17 -1
  54. package/lib/groups/mls-receive-errors.d.ts +29 -0
  55. package/lib/groups/mls-receive-errors.js +42 -0
  56. package/lib/groups/mls-state.d.ts +1 -1
  57. package/lib/groups/mls-state.js +56 -1
  58. package/lib/groups/store-received-grant.d.ts +4 -1
  59. package/lib/groups/store-received-grant.js +116 -1
  60. package/lib/groups/store-received-revocation.d.ts +3 -3
  61. package/lib/groups/store-received-revocation.js +82 -1
  62. package/lib/hub/ack-backoff.d.ts +22 -0
  63. package/lib/hub/ack-backoff.js +88 -0
  64. package/lib/hub/did-observing-transport.d.ts +13 -2
  65. package/lib/hub/did-observing-transport.js +126 -1
  66. package/lib/hub/errors.d.ts +4 -8
  67. package/lib/hub/errors.js +33 -1
  68. package/lib/hub/http-client.d.ts +28 -3
  69. package/lib/hub/http-client.js +32 -1
  70. package/lib/hub/hub-like.d.ts +24 -0
  71. package/lib/hub/hub-like.js +535 -0
  72. package/lib/hub/manager.d.ts +5 -4
  73. package/lib/hub/manager.js +198 -1
  74. package/lib/hub/wiring.d.ts +28 -41
  75. package/lib/hub/wiring.js +132 -1
  76. package/lib/index.d.ts +29 -13
  77. package/lib/index.js +392 -1
  78. package/lib/protocol.d.ts +8 -1
  79. package/lib/protocol.js +251 -1
  80. package/lib/schema.d.ts +2 -1
  81. package/lib/schema.js +471 -2
  82. package/lib/sync/authorize.d.ts +25 -0
  83. package/lib/sync/authorize.js +73 -0
  84. package/lib/sync/broadcast-queue.js +183 -1
  85. package/lib/sync/broadcast-sender.js +179 -1
  86. package/lib/sync/catalog-scope.js +68 -1
  87. package/lib/sync/errors.d.ts +12 -0
  88. package/lib/sync/errors.js +19 -0
  89. package/lib/sync/forwarder.js +277 -1
  90. package/lib/sync/handlers.d.ts +3 -22
  91. package/lib/sync/handlers.js +160 -1
  92. package/lib/sync/hub-tunnel-sync-listener.d.ts +9 -3
  93. package/lib/sync/hub-tunnel-sync-listener.js +172 -1
  94. package/lib/sync/hub-tunnel-sync-provider.d.ts +14 -14
  95. package/lib/sync/hub-tunnel-sync-provider.js +64 -1
  96. package/lib/sync/merkle-apply.d.ts +5 -0
  97. package/lib/sync/merkle-apply.js +194 -1
  98. package/lib/sync/merkle-channel.d.ts +19 -0
  99. package/lib/sync/merkle-channel.js +182 -1
  100. package/lib/sync/merkle-tree.js +120 -1
  101. package/lib/sync/peer-registry.d.ts +8 -1
  102. package/lib/sync/peer-registry.js +107 -1
  103. package/lib/sync/receive-access-gate.js +24 -1
  104. package/lib/sync/scope-resolver.js +41 -1
  105. package/lib/sync/sync-client.d.ts +5 -3
  106. package/lib/sync/sync-client.js +192 -1
  107. package/lib/sync/sync-manager.d.ts +2 -2
  108. package/lib/sync/sync-manager.js +272 -1
  109. package/lib/types.d.ts +41 -0
  110. package/lib/types.js +2 -1
  111. package/lib/util/mutex.js +10 -1
  112. package/lib/utils.d.ts +5 -0
  113. package/lib/utils.js +21 -0
  114. package/package.json +48 -41
  115. package/lib/groups/broadcast-service.d.ts +0 -189
  116. package/lib/groups/broadcast-service.js +0 -1
  117. package/lib/groups/wire-frame.d.ts +0 -32
  118. package/lib/groups/wire-frame.js +0 -1
  119. package/lib/hub/connection-pool.d.ts +0 -43
  120. package/lib/hub/connection-pool.js +0 -1
  121. package/lib/hub/forward-remote-broadcast.d.ts +0 -15
  122. package/lib/hub/forward-remote-broadcast.js +0 -1
  123. package/lib/hub/group-channel.d.ts +0 -67
  124. package/lib/hub/group-channel.js +0 -1
  125. package/lib/hub/hub-connection.d.ts +0 -96
  126. package/lib/hub/hub-connection.js +0 -1
  127. package/lib/hub/receive-handler.d.ts +0 -33
  128. package/lib/hub/receive-handler.js +0 -1
  129. package/lib/hub/relay-manager.d.ts +0 -127
  130. package/lib/hub/relay-manager.js +0 -1
  131. package/lib/hub/send-handler.d.ts +0 -40
  132. package/lib/hub/send-handler.js +0 -1
  133. package/lib/hub/tunnel-inbox.d.ts +0 -20
  134. package/lib/hub/tunnel-inbox.js +0 -1
  135. package/lib/hub/wait-for-gate.d.ts +0 -14
  136. package/lib/hub/wait-for-gate.js +0 -1
package/lib/protocol.js CHANGED
@@ -1 +1,251 @@
1
- export const syncProtocol={"sync/negotiate":{type:"request",param:{type:"object",properties:{scopes:{type:"array",items:{type:"object",properties:{modelID:{type:"string"},ownerDID:{type:"string"}},required:["modelID","ownerDID"],additionalProperties:!1},description:"Requested sync scopes as (model, owner) pairs"},delegationTokens:{type:"array",items:{type:"string"},description:"JWT delegation tokens for authorization"},catalogIDs:{type:"array",items:{type:"string"},description:"Catalog IDs to resolve sync scope from criteria"},knownModelIDs:{type:"array",items:{type:"string"},description:"Model IDs the requester already has — used to identify missing clusters"},direction:{type:"string",enum:["push","pull","both"]}},required:["delegationTokens"],additionalProperties:!1},result:{type:"object",properties:{direction:{type:"string",enum:["push","pull","both"]},acceptedScopes:{type:"array",items:{type:"object",properties:{modelID:{type:"string"},ownerDID:{type:"string"}},required:["modelID","ownerDID"],additionalProperties:!1}},excludedDocumentIDs:{type:"array",items:{type:"string"}},missingClusters:{type:"object",description:"Cluster definitions for models the requester does not have yet",additionalProperties:!0}},required:["acceptedScopes","excludedDocumentIDs"],additionalProperties:!1}},"sync/merkle-sync":{type:"channel",param:{type:"object",properties:{scopes:{type:"array",items:{type:"object",properties:{modelID:{type:"string"},ownerDID:{type:"string"}},required:["modelID","ownerDID"],additionalProperties:!1}},excludedDocumentIDs:{type:"array",items:{type:"string"}},tree:{type:"object",description:"Merkle tree bucket hashes from requester",additionalProperties:{type:"string"}},direction:{type:"string",enum:["push","pull","both"]}},required:["scopes","excludedDocumentIDs","tree","direction"],additionalProperties:!1},send:{type:"object",properties:{type:{type:"string",enum:["mutations","complete"]},mutationJWTs:{type:"array",items:{type:"string"},description:"Signed mutation JWTs for divergent time buckets"}},required:["type"],additionalProperties:!1},receive:{type:"object",properties:{type:{type:"string",enum:["tree","mutations","complete"]},tree:{type:"object",description:"Responder merkle tree bucket hashes",additionalProperties:{type:"string"}},mutationJWTs:{type:"array",items:{type:"string"},description:"Signed mutation JWTs for divergent time buckets"}},required:["type"],additionalProperties:!1},result:{type:"object",properties:{success:{type:"boolean"},divergentBuckets:{type:"number"},mutationsSent:{type:"number"},mutationsReceived:{type:"number"}},required:["success","divergentBuckets","mutationsSent","mutationsReceived"],additionalProperties:!1}}};
1
+ export const syncProtocol = {
2
+ 'sync/negotiate': {
3
+ type: 'request',
4
+ param: {
5
+ type: 'object',
6
+ properties: {
7
+ scopes: {
8
+ type: 'array',
9
+ items: {
10
+ type: 'object',
11
+ properties: {
12
+ modelID: {
13
+ type: 'string'
14
+ },
15
+ ownerDID: {
16
+ type: 'string'
17
+ }
18
+ },
19
+ required: [
20
+ 'modelID',
21
+ 'ownerDID'
22
+ ],
23
+ additionalProperties: false
24
+ },
25
+ description: 'Requested sync scopes as (model, owner) pairs'
26
+ },
27
+ delegationTokens: {
28
+ type: 'array',
29
+ items: {
30
+ type: 'string'
31
+ },
32
+ description: 'JWT delegation tokens for authorization'
33
+ },
34
+ catalogIDs: {
35
+ type: 'array',
36
+ items: {
37
+ type: 'string'
38
+ },
39
+ description: 'Catalog IDs to resolve sync scope from criteria'
40
+ },
41
+ knownModelIDs: {
42
+ type: 'array',
43
+ items: {
44
+ type: 'string'
45
+ },
46
+ description: 'Model IDs the requester already has — used to identify missing clusters'
47
+ },
48
+ direction: {
49
+ type: 'string',
50
+ enum: [
51
+ 'push',
52
+ 'pull',
53
+ 'both'
54
+ ]
55
+ }
56
+ },
57
+ required: [
58
+ 'delegationTokens'
59
+ ],
60
+ additionalProperties: false
61
+ },
62
+ result: {
63
+ type: 'object',
64
+ properties: {
65
+ direction: {
66
+ type: 'string',
67
+ enum: [
68
+ 'push',
69
+ 'pull',
70
+ 'both'
71
+ ]
72
+ },
73
+ acceptedScopes: {
74
+ type: 'array',
75
+ items: {
76
+ type: 'object',
77
+ properties: {
78
+ modelID: {
79
+ type: 'string'
80
+ },
81
+ ownerDID: {
82
+ type: 'string'
83
+ }
84
+ },
85
+ required: [
86
+ 'modelID',
87
+ 'ownerDID'
88
+ ],
89
+ additionalProperties: false
90
+ }
91
+ },
92
+ excludedDocumentIDs: {
93
+ type: 'array',
94
+ items: {
95
+ type: 'string'
96
+ }
97
+ },
98
+ missingClusters: {
99
+ type: 'object',
100
+ description: 'Cluster definitions for models the requester does not have yet',
101
+ additionalProperties: true
102
+ }
103
+ },
104
+ required: [
105
+ 'acceptedScopes',
106
+ 'excludedDocumentIDs'
107
+ ],
108
+ additionalProperties: false
109
+ }
110
+ },
111
+ 'sync/merkle-sync': {
112
+ type: 'channel',
113
+ param: {
114
+ type: 'object',
115
+ properties: {
116
+ scopes: {
117
+ type: 'array',
118
+ items: {
119
+ type: 'object',
120
+ properties: {
121
+ modelID: {
122
+ type: 'string'
123
+ },
124
+ ownerDID: {
125
+ type: 'string'
126
+ }
127
+ },
128
+ required: [
129
+ 'modelID',
130
+ 'ownerDID'
131
+ ],
132
+ additionalProperties: false
133
+ }
134
+ },
135
+ excludedDocumentIDs: {
136
+ type: 'array',
137
+ items: {
138
+ type: 'string'
139
+ }
140
+ },
141
+ tree: {
142
+ type: 'object',
143
+ description: 'Merkle tree bucket hashes from requester',
144
+ additionalProperties: {
145
+ type: 'string'
146
+ }
147
+ },
148
+ direction: {
149
+ type: 'string',
150
+ enum: [
151
+ 'push',
152
+ 'pull',
153
+ 'both'
154
+ ]
155
+ },
156
+ delegationTokens: {
157
+ type: 'array',
158
+ items: {
159
+ type: 'string'
160
+ },
161
+ description: 'Delegation JWTs authorizing the caller for non-owned scopes'
162
+ }
163
+ },
164
+ required: [
165
+ 'scopes',
166
+ 'excludedDocumentIDs',
167
+ 'tree',
168
+ 'direction'
169
+ ],
170
+ additionalProperties: false
171
+ },
172
+ send: {
173
+ type: 'object',
174
+ properties: {
175
+ type: {
176
+ type: 'string',
177
+ enum: [
178
+ 'mutations',
179
+ 'complete'
180
+ ]
181
+ },
182
+ mutationJWTs: {
183
+ type: 'array',
184
+ items: {
185
+ type: 'string'
186
+ },
187
+ description: 'Signed mutation JWTs for divergent time buckets'
188
+ }
189
+ },
190
+ required: [
191
+ 'type'
192
+ ],
193
+ additionalProperties: false
194
+ },
195
+ receive: {
196
+ type: 'object',
197
+ properties: {
198
+ type: {
199
+ type: 'string',
200
+ enum: [
201
+ 'tree',
202
+ 'mutations',
203
+ 'complete'
204
+ ]
205
+ },
206
+ tree: {
207
+ type: 'object',
208
+ description: 'Responder merkle tree bucket hashes',
209
+ additionalProperties: {
210
+ type: 'string'
211
+ }
212
+ },
213
+ mutationJWTs: {
214
+ type: 'array',
215
+ items: {
216
+ type: 'string'
217
+ },
218
+ description: 'Signed mutation JWTs for divergent time buckets'
219
+ }
220
+ },
221
+ required: [
222
+ 'type'
223
+ ],
224
+ additionalProperties: false
225
+ },
226
+ result: {
227
+ type: 'object',
228
+ properties: {
229
+ success: {
230
+ type: 'boolean'
231
+ },
232
+ divergentBuckets: {
233
+ type: 'number'
234
+ },
235
+ mutationsSent: {
236
+ type: 'number'
237
+ },
238
+ mutationsReceived: {
239
+ type: 'number'
240
+ }
241
+ },
242
+ required: [
243
+ 'success',
244
+ 'divergentBuckets',
245
+ 'mutationsSent',
246
+ 'mutationsReceived'
247
+ ],
248
+ additionalProperties: false
249
+ }
250
+ }
251
+ };
package/lib/schema.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import type { SchemaExtension } from '@kubun/engine';
2
+ import { type Logger } from '@kubun/logger';
2
3
  import { type P2PEventEmitter } from './groups/events.js';
3
- export declare function createP2PSchemaExtension(emitter: P2PEventEmitter): SchemaExtension;
4
+ export declare function createP2PSchemaExtension(emitter: P2PEventEmitter, logger?: Logger): SchemaExtension;