@kubun/store-p2p 0.19.0 → 0.20.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.
package/lib/scope.js ADDED
@@ -0,0 +1,8 @@
1
+ import { withKeyLocks } from '@kubun/db';
2
+ export const runP2PScope = Symbol('runP2PScope');
3
+ export async function withP2PKeyLocks(context, table, keys, run) {
4
+ return await withKeyLocks(context.provider, table, keys, async (provider)=>{
5
+ const store = await provider.getStore('p2p');
6
+ return await store[runP2PScope](run);
7
+ });
8
+ }
package/lib/tables.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { CreatedAtColumn, UpdatedAtColumn } from '@kubun/db-adapter';
2
2
  import type { AnchorSlot, AppOutboxEntry, CommitCursor } from '@kumiai/rpc';
3
3
  import type { ColumnType, Insertable, Selectable, Updateable } from 'kysely';
4
+ import type { CatalogCursorBounds } from './ops/catalog-sync.js';
4
5
  type DefaultedStringColumn = ColumnType<string, string | undefined, string>;
5
6
  type DefaultedNumberColumn = ColumnType<number, number | undefined, number>;
6
7
  type NullableStringColumn = ColumnType<string | null, string | null | undefined, string | null>;
@@ -86,7 +87,7 @@ export type CatalogCursorTable = {
86
87
  last_token: NullableStringColumn;
87
88
  cycle_clear: DefaultedNumberColumn;
88
89
  /** JSON object: bound-free rule key to its absolute `{ from, to }`. */
89
- bounds: string;
90
+ bounds: JSONValueColumn<Record<string, CatalogCursorBounds>>;
90
91
  };
91
92
  export type DocumentRepairTable = {
92
93
  group_id: string;
@@ -157,7 +158,7 @@ export type GroupMLSStateTable = {
157
158
  group_id: string;
158
159
  device_id: string;
159
160
  mls_state: Uint8Array;
160
- credential: string;
161
+ credential: JSONValueColumn<unknown>;
161
162
  epoch: number;
162
163
  /** Orders secret-tree mutations within one MLS epoch. */
163
164
  state_version: DefaultedNumberColumn;
@@ -171,12 +172,21 @@ export type GroupMLSStateTable = {
171
172
  * held before: without them the fold reverts to the genesis anchor alone and
172
173
  * every admin but the creator loses authority across a restart.
173
174
  */
174
- ledger_entries: DefaultedStringColumn;
175
+ ledger_entries: JSONArrayColumn<string>;
175
176
  updated_at: UpdatedAtColumn;
176
177
  };
177
- export type GroupMLSState = Selectable<GroupMLSStateTable>;
178
- export type InsertGroupMLSState = Insertable<GroupMLSStateTable>;
179
- export type UpdateGroupMLSState = Updateable<GroupMLSStateTable>;
178
+ export type GroupMLSState = Omit<Selectable<GroupMLSStateTable>, 'credential' | 'ledger_entries'> & {
179
+ credential: unknown;
180
+ ledger_entries: Array<string>;
181
+ };
182
+ export type InsertGroupMLSState = Omit<Insertable<GroupMLSStateTable>, 'credential' | 'ledger_entries'> & {
183
+ credential: string;
184
+ ledger_entries?: string;
185
+ };
186
+ export type UpdateGroupMLSState = Omit<Updateable<GroupMLSStateTable>, 'credential' | 'ledger_entries'> & {
187
+ credential?: string;
188
+ ledger_entries?: string;
189
+ };
180
190
  export type SyncPeerTable = {
181
191
  id: string;
182
192
  peer_did: string;
@@ -390,44 +400,44 @@ export type BindingEvidenceTable = {
390
400
  first_seen_at: CreatedAtColumn;
391
401
  };
392
402
  export type P2PStoreTables = {
393
- kubun_p2p_access_default_revocations: {
403
+ p2p_access_default_revocations: {
394
404
  controller_did: string;
395
405
  device_did: string;
396
406
  };
397
- kubun_p2p_binding_evidence: BindingEvidenceTable;
398
- kubun_p2p_own_agents_records: OwnAgentsRecordTable;
399
- kubun_p2p_own_agents_grants: OwnAgentsGrantTable;
400
- kubun_p2p_own_agents_join_capabilities: OwnAgentsJoinCapabilityTable;
401
- kubun_p2p_groups: GroupTable;
402
- kubun_p2p_group_members: GroupMemberTable;
403
- kubun_p2p_catalog_offers: CatalogOfferTable;
404
- kubun_p2p_catalog_routes: CatalogRouteTable;
405
- kubun_p2p_unserved_groups: UnservedGroupTable;
406
- kubun_p2p_catalog_cursors: CatalogCursorTable;
407
- kubun_p2p_document_repairs: DocumentRepairTable;
408
- kubun_p2p_document_repair_answers: DocumentRepairAnswerTable;
409
- kubun_p2p_observation_repairs: ObservationRepairScheduleTable;
410
- kubun_p2p_observation_repair_peers: ObservationRepairPeerTable;
411
- kubun_p2p_group_leave_requests: GroupLeaveRequestTable;
412
- kubun_p2p_circles: CircleTable;
413
- kubun_p2p_circle_members: CircleMemberTable;
414
- kubun_p2p_group_delegation: GroupDelegationTable;
415
- kubun_p2p_group_mls_state: GroupMLSStateTable;
416
- kubun_p2p_sync_peers: SyncPeerTable;
417
- kubun_p2p_sync_checkpoints: SyncCheckpointTable;
418
- kubun_p2p_broadcast_log: BroadcastLogTable;
419
- kubun_p2p_log_handler_completion: LogHandlerCompletionTable;
420
- kubun_p2p_control_requests: ControlRequestTable;
421
- kubun_p2p_commit_journal: CommitJournalEntryTable;
422
- kubun_p2p_group_anchor: GroupAnchorTable;
423
- kubun_p2p_app_outbox: AppOutboxTable;
424
- kubun_p2p_app_outbox_state: AppOutboxStateTable;
425
- kubun_p2p_app_cursor: AppCursorTable;
426
- kubun_p2p_app_pending: PendingAppFrameTable;
427
- kubun_p2p_hubs: HubTable;
428
- kubun_p2p_group_hubs: GroupHubTable;
429
- kubun_p2p_peer_announcements: PeerAnnouncementTable;
430
- kubun_p2p_local_peer_profile: LocalPeerProfileTable;
431
- kubun_p2p_pending_join_requests: PendingJoinRequestTable;
407
+ p2p_binding_evidence: BindingEvidenceTable;
408
+ p2p_own_agents_records: OwnAgentsRecordTable;
409
+ p2p_own_agents_grants: OwnAgentsGrantTable;
410
+ p2p_own_agents_join_capabilities: OwnAgentsJoinCapabilityTable;
411
+ p2p_groups: GroupTable;
412
+ p2p_group_members: GroupMemberTable;
413
+ p2p_catalog_offers: CatalogOfferTable;
414
+ p2p_catalog_routes: CatalogRouteTable;
415
+ p2p_unserved_groups: UnservedGroupTable;
416
+ p2p_catalog_cursors: CatalogCursorTable;
417
+ p2p_document_repairs: DocumentRepairTable;
418
+ p2p_document_repair_answers: DocumentRepairAnswerTable;
419
+ p2p_observation_repairs: ObservationRepairScheduleTable;
420
+ p2p_observation_repair_peers: ObservationRepairPeerTable;
421
+ p2p_group_leave_requests: GroupLeaveRequestTable;
422
+ p2p_circles: CircleTable;
423
+ p2p_circle_members: CircleMemberTable;
424
+ p2p_group_delegation: GroupDelegationTable;
425
+ p2p_group_mls_state: GroupMLSStateTable;
426
+ p2p_sync_peers: SyncPeerTable;
427
+ p2p_sync_checkpoints: SyncCheckpointTable;
428
+ p2p_broadcast_log: BroadcastLogTable;
429
+ p2p_log_handler_completion: LogHandlerCompletionTable;
430
+ p2p_control_requests: ControlRequestTable;
431
+ p2p_commit_journal: CommitJournalEntryTable;
432
+ p2p_group_anchor: GroupAnchorTable;
433
+ p2p_app_outbox: AppOutboxTable;
434
+ p2p_app_outbox_state: AppOutboxStateTable;
435
+ p2p_app_cursor: AppCursorTable;
436
+ p2p_app_pending: PendingAppFrameTable;
437
+ p2p_hubs: HubTable;
438
+ p2p_group_hubs: GroupHubTable;
439
+ p2p_peer_announcements: PeerAnnouncementTable;
440
+ p2p_local_peer_profile: LocalPeerProfileTable;
441
+ p2p_pending_join_requests: PendingJoinRequestTable;
432
442
  };
433
443
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubun/store-p2p",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "keywords": [],
5
5
  "license": "see LICENSE.md",
6
6
  "sideEffects": false,
@@ -15,22 +15,23 @@
15
15
  "LICENSE.md"
16
16
  ],
17
17
  "dependencies": {
18
- "@kokuin/capability": "^0.5.2",
19
- "@kokuin/controller": "^0.2.5",
20
- "@kokuin/token": "^0.6.2",
21
- "@kubun/db": "^0.19.0",
22
- "@kubun/db-adapter": "^0.19.0",
23
- "@kubun/logger": "^0.19.0",
24
- "@kubun/records": "^0.19.0",
25
- "@kumiai/rpc": "^0.12.0",
18
+ "@kokuin/capability": "^0.7.0",
19
+ "@kokuin/controller": "^0.7.0",
20
+ "@kokuin/crypto": "^0.7.0",
21
+ "@kokuin/records": "^0.7.1",
22
+ "@kokuin/token": "^0.7.0",
23
+ "@kubun/db": "^0.20.0",
24
+ "@kubun/db-adapter": "^0.20.0",
25
+ "@kubun/logger": "^0.20.0",
26
+ "@kumiai/rpc": "^0.13.1",
26
27
  "@noble/ciphers": "^2.4.0",
27
28
  "@sozai/runtime": "^0.1.0",
28
- "kysely": "^0.29.7"
29
+ "kysely": "^0.29.8"
29
30
  },
30
31
  "devDependencies": {
31
- "@kubun/db-better-sqlite": "^0.19.0",
32
- "@kubun/db-postgres": "^0.19.0",
33
- "@kubun/hlc": "^0.19.0",
32
+ "@hozon/node-sqlite": "^0.3.0",
33
+ "@hozon/postgres": "^0.2.1",
34
+ "@sozai/hlc": "^0.1.0",
34
35
  "@testcontainers/postgresql": "^12.2.1"
35
36
  },
36
37
  "publishConfig": {