@keyhive/keyhive 0.0.0-alpha.4 → 0.0.0-alpha.41

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/README.md CHANGED
@@ -3,12 +3,7 @@
3
3
  ## Build package
4
4
 
5
5
  ```
6
- wasm-pack build --target web --out-dir pkg -- --features web-sys
7
- ```
8
-
9
- To build with the `ingest_static` feature:
10
- ```
11
- wasm-pack build --target web --out-dir pkg -- --features web-sys,ingest_static
6
+ pnpm install && pnpm build
12
7
  ```
13
8
 
14
9
  ## Run tests
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keyhive/keyhive",
3
- "version": "0.0.0-alpha.4",
3
+ "version": "0.0.0-alpha.41",
4
4
  "description": "",
5
5
  "main": "pkg/keyhive_wasm.js",
6
6
  "keywords": [],
@@ -39,6 +39,7 @@
39
39
  "@playwright/test": "^1.55.0",
40
40
  "@types/node": "^22.17.2",
41
41
  "html-webpack-plugin": "^5.6.4",
42
+ "http-server": "^14.1.1",
42
43
  "ts-loader": "^9.5.2",
43
44
  "typescript": "^5.9.2",
44
45
  "vite": "^5.4.19",
@@ -50,8 +51,10 @@
50
51
  },
51
52
  "scripts": {
52
53
  "build": "pnpm run build-node && pnpm run build-bundler && pnpm run build-slim",
53
- "build-node": "wasm-pack build --out-dir pkg-node --target nodejs --release -- --features ingest_static",
54
- "build-bundler": "wasm-pack build --out-dir pkg --target bundler --release -- --features ingest_static",
55
- "build-slim": "node build_slim.js"
54
+ "build-node": "wasm-pack build --out-dir pkg-node --target nodejs --release",
55
+ "build-bundler": "wasm-pack build --out-dir pkg --target bundler --release",
56
+ "build-web": "wasm-pack build --out-dir pkg-web --target web --release",
57
+ "build-slim": "node build_slim.js",
58
+ "copy-e2e": "cp -r pkg-slim/* e2e/server/pkg/"
56
59
  }
57
60
  }
package/pkg/README.md CHANGED
@@ -3,12 +3,7 @@
3
3
  ## Build package
4
4
 
5
5
  ```
6
- wasm-pack build --target web --out-dir pkg -- --features web-sys
7
- ```
8
-
9
- To build with the `ingest_static` feature:
10
- ```
11
- wasm-pack build --target web --out-dir pkg -- --features web-sys,ingest_static
6
+ pnpm install && pnpm build
12
7
  ```
13
8
 
14
9
  ## Run tests
@@ -14,12 +14,6 @@ export class Access {
14
14
  static tryFromString(s: string): Access | undefined;
15
15
  toString(): string;
16
16
  }
17
- export class AddMemberError {
18
- private constructor();
19
- free(): void;
20
- [Symbol.dispose](): void;
21
- message(): string;
22
- }
23
17
  export class Agent {
24
18
  private constructor();
25
19
  free(): void;
@@ -35,7 +29,7 @@ export class Archive {
35
29
  [Symbol.dispose](): void;
36
30
  constructor(bytes: Uint8Array);
37
31
  toBytes(): Uint8Array;
38
- tryToKeyhive(ciphertext_store: CiphertextStore, signer: Signer, event_handler: Function): Keyhive;
32
+ tryToKeyhive(ciphertext_store: CiphertextStore, signer: Signer, event_handler: Function): Promise<Keyhive>;
39
33
  }
40
34
  export class CannotParseEd25519SigningKey {
41
35
  private constructor();
@@ -61,10 +55,14 @@ export class CgkaOperation {
61
55
  [Symbol.dispose](): void;
62
56
  readonly variant: string;
63
57
  }
64
- export class ChangeRef {
58
+ export class ChangeId {
65
59
  free(): void;
66
60
  [Symbol.dispose](): void;
67
61
  constructor(bytes: Uint8Array);
62
+ /**
63
+ * r" Upcasts to the JS-import type for [`#ty_ident`].
64
+ */
65
+ __wasm_refgen_toChangeId(): ChangeId;
68
66
  readonly bytes: Uint8Array;
69
67
  }
70
68
  export class CiphertextStore {
@@ -79,6 +77,7 @@ export class ContactCard {
79
77
  free(): void;
80
78
  [Symbol.dispose](): void;
81
79
  signature(): Uint8Array;
80
+ toAgent(): Agent;
82
81
  static fromJson(json: string): ContactCard;
83
82
  toJson(): string;
84
83
  readonly id: IndividualId;
@@ -93,18 +92,13 @@ export class Delegation {
93
92
  readonly proof: SignedDelegation | undefined;
94
93
  readonly after: History;
95
94
  }
96
- export class DelegationError {
97
- private constructor();
98
- free(): void;
99
- [Symbol.dispose](): void;
100
- }
101
95
  export class DocContentRefs {
102
96
  free(): void;
103
97
  [Symbol.dispose](): void;
104
- constructor(doc_id: DocumentId, change_hashes: ChangeRef[]);
105
- addChangeRef(hash: ChangeRef): void;
98
+ constructor(doc_id: DocumentId, change_hashes: ChangeId[]);
99
+ addChangeId(hash: ChangeId): Promise<void>;
106
100
  readonly docId: DocumentId;
107
- readonly change_hashes: ChangeRef[];
101
+ readonly change_hashes: Promise<ChangeId[]>;
108
102
  }
109
103
  export class Document {
110
104
  private constructor();
@@ -112,6 +106,11 @@ export class Document {
112
106
  [Symbol.dispose](): void;
113
107
  toPeer(): Peer;
114
108
  toAgent(): Agent;
109
+ toMembered(): Membered;
110
+ /**
111
+ * r" Upcasts to the JS-import type for [`#ty_ident`].
112
+ */
113
+ __wasm_refgen_toDocument(): Document;
115
114
  readonly id: Identifier;
116
115
  readonly doc_id: DocumentId;
117
116
  }
@@ -119,7 +118,7 @@ export class DocumentId {
119
118
  free(): void;
120
119
  [Symbol.dispose](): void;
121
120
  constructor(bytes: Uint8Array);
122
- fromString(): string;
121
+ toString(): string;
123
122
  toJsValue(): any;
124
123
  toBytes(): Uint8Array;
125
124
  }
@@ -147,38 +146,35 @@ export class Event {
147
146
  [Symbol.dispose](): void;
148
147
  tryIntoSignedDelegation(): SignedDelegation | undefined;
149
148
  tryIntoSignedRevocation(): SignedRevocation | undefined;
149
+ /**
150
+ * Converts the underlying [`Event`] to a [`StaticEvent`] and then
151
+ * serializes it.
152
+ */
153
+ toBytes(): Uint8Array;
150
154
  readonly variant: string;
151
155
  readonly isDelegated: boolean;
152
156
  readonly isRevoked: boolean;
153
157
  }
154
- export class GenerateDocError {
155
- private constructor();
156
- free(): void;
157
- [Symbol.dispose](): void;
158
- message(): string;
159
- }
160
158
  export class GenerateWebCryptoError {
161
159
  private constructor();
162
160
  free(): void;
163
161
  [Symbol.dispose](): void;
164
162
  message(): string;
165
163
  }
166
- export class GetCiphertextError {
167
- private constructor();
168
- free(): void;
169
- [Symbol.dispose](): void;
170
- readonly message: string;
171
- }
172
164
  export class Group {
173
165
  private constructor();
174
166
  free(): void;
175
167
  [Symbol.dispose](): void;
168
+ members(): Promise<Capability[]>;
176
169
  toPeer(): Peer;
177
170
  toAgent(): Agent;
178
171
  toMembered(): Membered;
172
+ /**
173
+ * r" Upcasts to the JS-import type for [`#ty_ident`].
174
+ */
175
+ __wasm_refgen_toGroup(): Group;
179
176
  readonly id: Identifier;
180
177
  readonly groupId: GroupId;
181
- readonly members: Capability[];
182
178
  }
183
179
  export class GroupId {
184
180
  private constructor();
@@ -206,7 +202,7 @@ export class Individual {
206
202
  [Symbol.dispose](): void;
207
203
  toPeer(): Peer;
208
204
  toAgent(): Agent;
209
- pickPrekey(doc_id: DocumentId): ShareKey;
205
+ pickPrekey(doc_id: DocumentId): Promise<ShareKey>;
210
206
  readonly id: Identifier;
211
207
  readonly individualId: IndividualId;
212
208
  }
@@ -221,54 +217,38 @@ export class Invocation {
221
217
  free(): void;
222
218
  [Symbol.dispose](): void;
223
219
  }
224
- export class JsDecryptError {
225
- private constructor();
226
- free(): void;
227
- [Symbol.dispose](): void;
228
- }
229
- export class JsEncryptError {
230
- private constructor();
231
- free(): void;
232
- [Symbol.dispose](): void;
233
- }
234
- export class JsReceivePreKeyOpError {
235
- private constructor();
236
- free(): void;
237
- [Symbol.dispose](): void;
238
- }
239
- export class JsReceiveStaticEventError {
240
- private constructor();
241
- free(): void;
242
- [Symbol.dispose](): void;
243
- }
244
220
  export class Keyhive {
245
221
  private constructor();
246
222
  free(): void;
247
223
  [Symbol.dispose](): void;
248
224
  static init(signer: Signer, ciphertext_store: CiphertextStore, event_handler: Function): Promise<Keyhive>;
249
- generateGroup(coparents: Peer[]): Promise<Group>;
250
- generateDocument(coparents: Peer[], initial_content_ref_head: ChangeRef, more_initial_content_refs: ChangeRef[]): Promise<Document>;
225
+ generateGroup(js_coparents: Peer[]): Promise<Group>;
226
+ generateDocument(coparents: Peer[], initial_content_ref_head: ChangeId, more_initial_content_refs: ChangeId[]): Promise<Document>;
251
227
  trySign(data: Uint8Array): Promise<Signed>;
252
- tryEncrypt(doc: Document, content_ref: ChangeRef, pred_refs: ChangeRef[], content: Uint8Array): Promise<EncryptedContentWithUpdate>;
253
- tryEncryptArchive(doc: Document, content_ref: ChangeRef, pred_refs: ChangeRef[], content: Uint8Array): Promise<EncryptedContentWithUpdate>;
254
- tryDecrypt(doc: Document, encrypted: Encrypted): Uint8Array;
228
+ tryEncrypt(doc: Document, content_ref: ChangeId, js_pred_refs: ChangeId[], content: Uint8Array): Promise<EncryptedContentWithUpdate>;
229
+ tryEncryptArchive(doc: Document, content_ref: ChangeId, pred_refs: ChangeId[], content: Uint8Array): Promise<EncryptedContentWithUpdate>;
230
+ tryDecrypt(doc: Document, encrypted: Encrypted): Promise<Uint8Array>;
255
231
  addMember(to_add: Agent, membered: Membered, access: Access, other_relevant_docs: Document[]): Promise<SignedDelegation>;
256
232
  revokeMember(to_revoke: Agent, retain_all_other_members: boolean, membered: Membered): Promise<SignedRevocation[]>;
257
- reachableDocs(): Summary[];
233
+ reachableDocs(): Promise<Summary[]>;
258
234
  forcePcsUpdate(doc: Document): Promise<void>;
259
235
  rotatePrekey(prekey: ShareKey): Promise<ShareKey>;
260
236
  expandPrekeys(): Promise<ShareKey>;
261
237
  contactCard(): Promise<ContactCard>;
262
- receiveContactCard(contact_card: ContactCard): Individual;
263
- getAgent(id: Identifier): Agent | undefined;
264
- getGroup(id: Identifier): Group | undefined;
265
- docMemberCapabilities(doc_id: DocumentId): SimpleCapability[];
266
- accessForDoc(id: Identifier, doc_id: DocumentId): Access | undefined;
267
- intoArchive(): Archive;
268
- toArchive(): Archive;
238
+ receiveContactCard(contact_card: ContactCard): Promise<Individual>;
239
+ getAgent(id: Identifier): Promise<Agent | undefined>;
240
+ getGroup(group_id: GroupId): Promise<Group | undefined>;
241
+ getDocument(doc_id: DocumentId): Promise<Document | undefined>;
242
+ docMemberCapabilities(doc_id: DocumentId): Promise<Membership[]>;
243
+ accessForDoc(id: Identifier, doc_id: DocumentId): Promise<Access | undefined>;
244
+ intoArchive(): Promise<Archive>;
245
+ toArchive(): Promise<Archive>;
269
246
  ingestArchive(archive: Archive): Promise<void>;
247
+ ingestEventsBytes(events_bytes_array: Array<any>): Promise<Array<any>>;
248
+ stats(): Promise<Stats>;
270
249
  readonly id: IndividualId;
271
250
  readonly whoami: IndividualId;
251
+ readonly individual: Promise<Individual>;
272
252
  readonly idString: string;
273
253
  }
274
254
  export class Membered {
@@ -276,6 +256,13 @@ export class Membered {
276
256
  free(): void;
277
257
  [Symbol.dispose](): void;
278
258
  }
259
+ export class Membership {
260
+ private constructor();
261
+ free(): void;
262
+ [Symbol.dispose](): void;
263
+ readonly who: Agent;
264
+ readonly can: Access;
265
+ }
279
266
  export class Peer {
280
267
  private constructor();
281
268
  free(): void;
@@ -284,11 +271,11 @@ export class Peer {
284
271
  isIndividual(): boolean;
285
272
  isGroup(): boolean;
286
273
  isDocument(): boolean;
287
- }
288
- export class RemoveCiphertextError {
289
- private constructor();
290
- free(): void;
291
- [Symbol.dispose](): void;
274
+ /**
275
+ * r" Upcasts to the JS-import type for [`#ty_ident`].
276
+ */
277
+ __wasm_refgen_toPeer(): Peer;
278
+ readonly id: Identifier;
292
279
  }
293
280
  export class Revocation {
294
281
  private constructor();
@@ -299,18 +286,6 @@ export class Revocation {
299
286
  readonly proof: SignedDelegation | undefined;
300
287
  readonly after: History;
301
288
  }
302
- export class RevokeMemberError {
303
- private constructor();
304
- free(): void;
305
- [Symbol.dispose](): void;
306
- readonly message: string;
307
- }
308
- export class SerializationError {
309
- private constructor();
310
- free(): void;
311
- [Symbol.dispose](): void;
312
- toError(): any;
313
- }
314
289
  export class ShareKey {
315
290
  private constructor();
316
291
  free(): void;
@@ -373,18 +348,15 @@ export class Signer {
373
348
  readonly variant: string;
374
349
  readonly verifyingKey: Uint8Array;
375
350
  }
376
- export class SigningError {
351
+ export class Stats {
377
352
  private constructor();
378
353
  free(): void;
379
354
  [Symbol.dispose](): void;
380
- message(): string;
381
- }
382
- export class SimpleCapability {
383
- private constructor();
384
- free(): void;
385
- [Symbol.dispose](): void;
386
- readonly who: Agent;
387
- readonly can: Access;
355
+ readonly individuals: bigint;
356
+ readonly groups: bigint;
357
+ readonly docs: bigint;
358
+ readonly delegations: bigint;
359
+ readonly revocations: bigint;
388
360
  }
389
361
  export class Summary {
390
362
  private constructor();
@@ -393,9 +365,3 @@ export class Summary {
393
365
  readonly doc: Document;
394
366
  readonly access: Access;
395
367
  }
396
- export class TryFromArchiveError {
397
- private constructor();
398
- free(): void;
399
- [Symbol.dispose](): void;
400
- toError(): any;
401
- }