@kubun/plugin-p2p 0.10.1 → 0.12.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 (201) hide show
  1. package/lib/context/delegation.js +130 -1
  2. package/lib/context/group.js +1646 -1
  3. package/lib/context/hub.js +151 -1
  4. package/lib/context/join.js +115 -1
  5. package/lib/context/peer.d.ts +92 -0
  6. package/lib/context/peer.js +1216 -0
  7. package/lib/context/require-admin.d.ts +57 -0
  8. package/lib/context/require-admin.js +57 -0
  9. package/lib/context/sync.d.ts +12 -0
  10. package/lib/context/sync.js +252 -1
  11. package/lib/context/types.d.ts +58 -22
  12. package/lib/context/types.js +48 -1
  13. package/lib/groups/access-default-token.d.ts +44 -0
  14. package/lib/groups/access-default-token.js +103 -0
  15. package/lib/groups/admin-roster.d.ts +55 -0
  16. package/lib/groups/admin-roster.js +69 -0
  17. package/lib/groups/anchor-store.d.ts +15 -0
  18. package/lib/groups/anchor-store.js +37 -0
  19. package/lib/groups/app-cursor-store.d.ts +17 -0
  20. package/lib/groups/app-cursor-store.js +34 -0
  21. package/lib/groups/broadcast-codec.js +6 -1
  22. package/lib/groups/broadcast.d.ts +238 -106
  23. package/lib/groups/broadcast.js +702 -1
  24. package/lib/groups/catalog-token.d.ts +50 -0
  25. package/lib/groups/catalog-token.js +96 -0
  26. package/lib/groups/circle-projection.d.ts +90 -0
  27. package/lib/groups/circle-projection.js +202 -0
  28. package/lib/groups/circle-reducers.d.ts +139 -0
  29. package/lib/groups/circle-reducers.js +128 -0
  30. package/lib/groups/commit-adoption.d.ts +77 -0
  31. package/lib/groups/commit-adoption.js +108 -0
  32. package/lib/groups/commit-journal.d.ts +14 -0
  33. package/lib/groups/commit-journal.js +65 -0
  34. package/lib/groups/control-request.d.ts +66 -0
  35. package/lib/groups/control-request.js +101 -0
  36. package/lib/groups/events.d.ts +19 -2
  37. package/lib/groups/events.js +10 -1
  38. package/lib/groups/group-anchor.d.ts +24 -0
  39. package/lib/groups/group-anchor.js +22 -0
  40. package/lib/groups/group-crypto.d.ts +42 -0
  41. package/lib/groups/group-crypto.js +159 -0
  42. package/lib/groups/group-handle-registry.d.ts +138 -9
  43. package/lib/groups/group-handle-registry.js +533 -1
  44. package/lib/groups/group-handlers.d.ts +30 -0
  45. package/lib/groups/group-handlers.js +218 -0
  46. package/lib/groups/group-health-monitor.d.ts +11 -0
  47. package/lib/groups/group-health-monitor.js +139 -1
  48. package/lib/groups/group-mls.d.ts +66 -0
  49. package/lib/groups/group-mls.js +696 -0
  50. package/lib/groups/group-peer-manager.d.ts +301 -0
  51. package/lib/groups/group-peer-manager.js +1336 -0
  52. package/lib/groups/group-protocols.d.ts +754 -0
  53. package/lib/groups/group-protocols.js +448 -0
  54. package/lib/groups/invite-payload.d.ts +49 -1
  55. package/lib/groups/invite-payload.js +26 -1
  56. package/lib/groups/join-request-identity.d.ts +21 -0
  57. package/lib/groups/join-request-identity.js +43 -0
  58. package/lib/groups/join-utils.d.ts +61 -0
  59. package/lib/groups/join-utils.js +366 -1
  60. package/lib/groups/ledger-affected-events.d.ts +20 -0
  61. package/lib/groups/ledger-affected-events.js +85 -0
  62. package/lib/groups/ledger-commit-fold.d.ts +107 -0
  63. package/lib/groups/ledger-commit-fold.js +167 -0
  64. package/lib/groups/ledger-ingest.d.ts +124 -0
  65. package/lib/groups/ledger-ingest.js +212 -0
  66. package/lib/groups/ledger.d.ts +44 -0
  67. package/lib/groups/ledger.js +30 -0
  68. package/lib/groups/manager.d.ts +217 -85
  69. package/lib/groups/manager.js +798 -1
  70. package/lib/groups/mls-codec.d.ts +28 -7
  71. package/lib/groups/mls-codec.js +33 -1
  72. package/lib/groups/mls-encryptor.d.ts +2 -2
  73. package/lib/groups/mls-encryptor.js +33 -1
  74. package/lib/groups/mls-group-handle.d.ts +37 -2
  75. package/lib/groups/mls-group-handle.js +18 -1
  76. package/lib/groups/mls-json.js +17 -1
  77. package/lib/groups/mls-receive-errors.d.ts +27 -0
  78. package/lib/groups/mls-receive-errors.js +39 -0
  79. package/lib/groups/mls-state.d.ts +6 -4
  80. package/lib/groups/mls-state.js +79 -1
  81. package/lib/groups/peer-presence.d.ts +90 -0
  82. package/lib/groups/peer-presence.js +295 -0
  83. package/lib/groups/peer-selection.d.ts +37 -0
  84. package/lib/groups/peer-selection.js +72 -0
  85. package/lib/groups/roster-projection.d.ts +53 -0
  86. package/lib/groups/roster-projection.js +65 -0
  87. package/lib/groups/store-received-grant.d.ts +7 -3
  88. package/lib/groups/store-received-grant.js +161 -1
  89. package/lib/groups/store-received-revocation.d.ts +19 -16
  90. package/lib/groups/store-received-revocation.js +83 -1
  91. package/lib/hub/ack-backoff.d.ts +22 -0
  92. package/lib/hub/ack-backoff.js +88 -0
  93. package/lib/hub/http-client.d.ts +18 -10
  94. package/lib/hub/http-client.js +15 -1
  95. package/lib/hub/hub-like.d.ts +75 -0
  96. package/lib/hub/hub-like.js +1022 -0
  97. package/lib/hub/loopback-log-hub.d.ts +20 -0
  98. package/lib/hub/loopback-log-hub.js +178 -0
  99. package/lib/hub/manager.d.ts +25 -40
  100. package/lib/hub/manager.js +155 -1
  101. package/lib/hub/peer-scoped-hub-view.d.ts +35 -0
  102. package/lib/hub/peer-scoped-hub-view.js +92 -0
  103. package/lib/hub/sender-scoped-hub-view.d.ts +41 -0
  104. package/lib/hub/sender-scoped-hub-view.js +59 -0
  105. package/lib/hub/server-did.d.ts +67 -0
  106. package/lib/hub/server-did.js +131 -0
  107. package/lib/hub/wiring.d.ts +77 -51
  108. package/lib/hub/wiring.js +189 -1
  109. package/lib/index.d.ts +58 -22
  110. package/lib/index.js +563 -1
  111. package/lib/peer/connection-registry.d.ts +45 -0
  112. package/lib/peer/connection-registry.js +52 -0
  113. package/lib/peer/handlers.d.ts +69 -0
  114. package/lib/peer/handlers.js +110 -0
  115. package/lib/protocol.d.ts +214 -1
  116. package/lib/protocol.js +519 -1
  117. package/lib/schema.d.ts +3 -1
  118. package/lib/schema.js +1150 -39
  119. package/lib/sync/access-default-sender.d.ts +23 -0
  120. package/lib/sync/access-default-sender.js +80 -0
  121. package/lib/sync/authorize.d.ts +58 -4
  122. package/lib/sync/authorize.js +114 -1
  123. package/lib/sync/broadcast-queue.d.ts +3 -4
  124. package/lib/sync/broadcast-queue.js +182 -1
  125. package/lib/sync/broadcast-sender.js +179 -1
  126. package/lib/sync/catalog-scope.d.ts +8 -7
  127. package/lib/sync/catalog-scope.js +84 -1
  128. package/lib/sync/errors.d.ts +12 -2
  129. package/lib/sync/errors.js +29 -1
  130. package/lib/sync/forwarder.d.ts +13 -19
  131. package/lib/sync/forwarder.js +271 -1
  132. package/lib/sync/handlers.js +200 -1
  133. package/lib/sync/hub-tunnel-sync-listener.d.ts +19 -5
  134. package/lib/sync/hub-tunnel-sync-listener.js +261 -1
  135. package/lib/sync/hub-tunnel-sync-provider.d.ts +34 -14
  136. package/lib/sync/hub-tunnel-sync-provider.js +113 -1
  137. package/lib/sync/merkle-apply.d.ts +5 -0
  138. package/lib/sync/merkle-apply.js +194 -1
  139. package/lib/sync/merkle-channel.d.ts +11 -3
  140. package/lib/sync/merkle-channel.js +0 -0
  141. package/lib/sync/merkle-tree.js +120 -1
  142. package/lib/sync/peer-registry.d.ts +15 -11
  143. package/lib/sync/peer-registry.js +82 -1
  144. package/lib/sync/receive-access-gate.js +24 -1
  145. package/lib/sync/scope-resolver.js +41 -1
  146. package/lib/sync/sync-client.d.ts +14 -4
  147. package/lib/sync/sync-client.js +254 -1
  148. package/lib/sync/sync-manager.d.ts +24 -6
  149. package/lib/sync/sync-manager.js +301 -1
  150. package/lib/sync/tunnel-listeners.d.ts +52 -0
  151. package/lib/sync/tunnel-listeners.js +175 -0
  152. package/lib/sync/tunnel-observability.d.ts +25 -0
  153. package/lib/sync/tunnel-observability.js +63 -0
  154. package/lib/sync/tunnel-topics.d.ts +20 -0
  155. package/lib/sync/tunnel-topics.js +28 -0
  156. package/lib/types.d.ts +704 -22
  157. package/lib/types.js +1 -1
  158. package/lib/util/handler-error.d.ts +16 -0
  159. package/lib/util/handler-error.js +64 -0
  160. package/lib/util/mutex.d.ts +14 -1
  161. package/lib/util/mutex.js +44 -1
  162. package/lib/utils.js +21 -1
  163. package/package.json +58 -47
  164. package/lib/groups/broadcast-service.d.ts +0 -263
  165. package/lib/groups/broadcast-service.js +0 -1
  166. package/lib/groups/rejoin-codec.d.ts +0 -14
  167. package/lib/groups/rejoin-codec.js +0 -1
  168. package/lib/groups/wire-frame.d.ts +0 -34
  169. package/lib/groups/wire-frame.js +0 -1
  170. package/lib/hub/circle-catchup-requester.d.ts +0 -58
  171. package/lib/hub/circle-catchup-requester.js +0 -1
  172. package/lib/hub/circle-catchup-responder.d.ts +0 -50
  173. package/lib/hub/circle-catchup-responder.js +0 -1
  174. package/lib/hub/connection-pool.d.ts +0 -43
  175. package/lib/hub/connection-pool.js +0 -1
  176. package/lib/hub/did-observing-transport.d.ts +0 -64
  177. package/lib/hub/did-observing-transport.js +0 -1
  178. package/lib/hub/epoch-stale-detector.d.ts +0 -18
  179. package/lib/hub/epoch-stale-detector.js +0 -1
  180. package/lib/hub/errors.d.ts +0 -30
  181. package/lib/hub/errors.js +0 -1
  182. package/lib/hub/forward-remote-broadcast.d.ts +0 -15
  183. package/lib/hub/forward-remote-broadcast.js +0 -1
  184. package/lib/hub/group-channel.d.ts +0 -89
  185. package/lib/hub/group-channel.js +0 -1
  186. package/lib/hub/hub-connection.d.ts +0 -96
  187. package/lib/hub/hub-connection.js +0 -1
  188. package/lib/hub/receive-handler.d.ts +0 -51
  189. package/lib/hub/receive-handler.js +0 -1
  190. package/lib/hub/rejoin-manager.d.ts +0 -78
  191. package/lib/hub/rejoin-manager.js +0 -1
  192. package/lib/hub/rejoin-responder.d.ts +0 -32
  193. package/lib/hub/rejoin-responder.js +0 -1
  194. package/lib/hub/relay-manager.d.ts +0 -142
  195. package/lib/hub/relay-manager.js +0 -1
  196. package/lib/hub/send-handler.d.ts +0 -40
  197. package/lib/hub/send-handler.js +0 -1
  198. package/lib/hub/tunnel-inbox.d.ts +0 -20
  199. package/lib/hub/tunnel-inbox.js +0 -1
  200. package/lib/hub/wait-for-gate.d.ts +0 -14
  201. package/lib/hub/wait-for-gate.js +0 -1
package/lib/protocol.js CHANGED
@@ -1 +1,519 @@
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"]},delegationTokens:{type:"array",items:{type:"string"},description:"Delegation JWTs authorizing the caller for non-owned scopes"}},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
+ };
252
+ /**
253
+ * Peer protocol — the wire leg of the high-level peer ops. Served as a sibling
254
+ * to {@link syncProtocol} and advertised in `/info` under its own name so a
255
+ * connecting device can discover it independently of the data-sync protocol.
256
+ *
257
+ * The GraphQL mutations remain the app-facing surface; these procedures are the
258
+ * device-to-device leg the mutations dispatch to. `peer/groups` returns the
259
+ * serving device's DID and its groups for the `connectPeer` payload. The MLS
260
+ * dance procedures (`group/prepare-join`, `group/invite`, `group/complete-join`)
261
+ * extend this same protocol in later work.
262
+ */ export const peerProtocol = {
263
+ 'peer/groups': {
264
+ type: 'request',
265
+ param: {
266
+ type: 'object',
267
+ properties: {},
268
+ additionalProperties: false
269
+ },
270
+ result: {
271
+ type: 'object',
272
+ properties: {
273
+ did: {
274
+ type: 'string',
275
+ description: 'DID of the serving device'
276
+ },
277
+ groups: {
278
+ type: 'array',
279
+ items: {
280
+ type: 'object',
281
+ properties: {
282
+ id: {
283
+ type: 'string'
284
+ },
285
+ name: {
286
+ type: 'string'
287
+ }
288
+ },
289
+ required: [
290
+ 'id',
291
+ 'name'
292
+ ],
293
+ additionalProperties: false
294
+ },
295
+ description: "The serving device's groups (id + name)"
296
+ }
297
+ },
298
+ required: [
299
+ 'did',
300
+ 'groups'
301
+ ],
302
+ additionalProperties: false
303
+ }
304
+ },
305
+ // The peer leg of the MLS invite dance. `group/prepare-join` and
306
+ // `group/complete-join` wrap the SAME context ops as the `prepareJoinRequest`
307
+ // and `completeJoin` GraphQL mutations — the serving (joining) device mints
308
+ // its KeyPackage bundle, then processes the Welcome the caller returns. Gated
309
+ // exactly like `peer/groups` (forged-`sub` rejection + `checkPeerAccess`).
310
+ 'group/prepare-join': {
311
+ type: 'request',
312
+ param: {
313
+ type: 'object',
314
+ properties: {},
315
+ additionalProperties: false
316
+ },
317
+ result: {
318
+ type: 'object',
319
+ properties: {
320
+ joinRequest: {
321
+ type: 'string',
322
+ description: "The serving device's encoded join request (its KeyPackage)"
323
+ }
324
+ },
325
+ required: [
326
+ 'joinRequest'
327
+ ],
328
+ additionalProperties: false
329
+ }
330
+ },
331
+ 'group/complete-join': {
332
+ type: 'request',
333
+ param: {
334
+ type: 'object',
335
+ properties: {
336
+ invitePayload: {
337
+ type: 'string',
338
+ description: 'The invite payload (Welcome + seeds) minted by the caller'
339
+ }
340
+ },
341
+ required: [
342
+ 'invitePayload'
343
+ ],
344
+ additionalProperties: false
345
+ },
346
+ result: {
347
+ type: 'object',
348
+ properties: {
349
+ groupID: {
350
+ type: [
351
+ 'string',
352
+ 'null'
353
+ ],
354
+ description: 'The joined group ID, or null when the group row was not found'
355
+ }
356
+ },
357
+ required: [
358
+ 'groupID'
359
+ ],
360
+ additionalProperties: false
361
+ }
362
+ },
363
+ // The inviter leg of the inbound dance (`joinPeerGroup`). The caller (joiner)
364
+ // sends the group it wants to join plus its KeyPackage bundle; the serving
365
+ // device (inviter) adds the caller to the group's share circles, runs the
366
+ // invite as ITSELF, and returns the Welcome + invite payload. Gated exactly
367
+ // like the other peer procedures (forged-`sub` rejection + `checkPeerAccess`
368
+ // against the inviter's `autoAcceptPeers`), so only a trusted caller can pull
369
+ // an invite from this device.
370
+ 'group/invite': {
371
+ type: 'request',
372
+ param: {
373
+ type: 'object',
374
+ properties: {
375
+ groupID: {
376
+ type: 'string',
377
+ description: 'The group the caller wants to join'
378
+ },
379
+ joinRequest: {
380
+ type: 'string',
381
+ description: "The caller's encoded join request (its KeyPackage)"
382
+ }
383
+ },
384
+ required: [
385
+ 'groupID',
386
+ 'joinRequest'
387
+ ],
388
+ additionalProperties: false
389
+ },
390
+ result: {
391
+ type: 'object',
392
+ properties: {
393
+ invitePayload: {
394
+ type: 'string',
395
+ description: 'The invite payload (Welcome + seeds) for the caller to complete the join'
396
+ }
397
+ },
398
+ required: [
399
+ 'invitePayload'
400
+ ],
401
+ additionalProperties: false
402
+ }
403
+ },
404
+ // The caller hands the serving device its own access-default rows over the
405
+ // held connection, so the serving device applies them without waiting on hub
406
+ // fan-out (which is dropped for a group with no live binding). The source is
407
+ // UNTRUSTED: access-default rows are sender-bound (owner must equal the
408
+ // verified token issuer AND the authenticated caller). Gated exactly like
409
+ // `group/invite` (forged-`sub` rejection + `checkPeerAccess`).
410
+ 'group/push-control': {
411
+ type: 'request',
412
+ param: {
413
+ type: 'object',
414
+ properties: {
415
+ groupID: {
416
+ type: 'string',
417
+ description: 'The group whose control state is being pushed'
418
+ },
419
+ accessDefaults: {
420
+ type: 'array',
421
+ items: {
422
+ type: 'object',
423
+ properties: {
424
+ ownerDID: {
425
+ type: 'string'
426
+ },
427
+ modelID: {
428
+ type: 'string'
429
+ },
430
+ permissionType: {
431
+ type: 'string',
432
+ enum: [
433
+ 'read',
434
+ 'write'
435
+ ]
436
+ },
437
+ rule: {
438
+ type: 'object',
439
+ properties: {
440
+ level: {
441
+ type: 'string'
442
+ },
443
+ allowedDIDs: {
444
+ type: [
445
+ 'array',
446
+ 'null'
447
+ ],
448
+ items: {
449
+ type: 'string'
450
+ }
451
+ },
452
+ allowedCircles: {
453
+ type: [
454
+ 'array',
455
+ 'null'
456
+ ],
457
+ items: {
458
+ type: 'string'
459
+ }
460
+ },
461
+ allowedGroups: {
462
+ type: [
463
+ 'array',
464
+ 'null'
465
+ ],
466
+ items: {
467
+ type: 'string'
468
+ }
469
+ }
470
+ },
471
+ required: [
472
+ 'level',
473
+ 'allowedDIDs',
474
+ 'allowedCircles',
475
+ 'allowedGroups'
476
+ ],
477
+ additionalProperties: false
478
+ },
479
+ hlc: {
480
+ type: 'string'
481
+ },
482
+ auth: {
483
+ type: 'string'
484
+ }
485
+ },
486
+ required: [
487
+ 'ownerDID',
488
+ 'modelID',
489
+ 'permissionType',
490
+ 'rule',
491
+ 'hlc',
492
+ 'auth'
493
+ ],
494
+ additionalProperties: false
495
+ },
496
+ description: "The caller's own signed access-default rows (sender-bound on apply)"
497
+ }
498
+ },
499
+ required: [
500
+ 'groupID',
501
+ 'accessDefaults'
502
+ ],
503
+ additionalProperties: false
504
+ },
505
+ result: {
506
+ type: 'object',
507
+ properties: {
508
+ accessDefaultsApplied: {
509
+ type: 'number',
510
+ description: 'Count of pushed access-default rows applied (sender-bound, LWW)'
511
+ }
512
+ },
513
+ required: [
514
+ 'accessDefaultsApplied'
515
+ ],
516
+ additionalProperties: false
517
+ }
518
+ }
519
+ };
package/lib/schema.d.ts CHANGED
@@ -1,3 +1,5 @@
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
+ import type { SyncManager } from './sync/sync-manager.js';
5
+ export declare function createP2PSchemaExtension(emitter: P2PEventEmitter, syncManager: SyncManager, logger?: Logger): SchemaExtension;