@keyhive/keyhive 0.0.0-alpha.58 → 0.0.0-alpha.58b

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.
@@ -0,0 +1,476 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class Access {
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ toString(): string;
9
+ static tryFromString(s: string): Access | undefined;
10
+ }
11
+
12
+ export class Agent {
13
+ private constructor();
14
+ free(): void;
15
+ [Symbol.dispose](): void;
16
+ isDocument(): boolean;
17
+ isGroup(): boolean;
18
+ isIndividual(): boolean;
19
+ /**
20
+ * Returns prekey operation hashes for this [`Agent`] as an array of hash bytes.
21
+ */
22
+ keyOpHashes(): Promise<Uint8Array[]>;
23
+ /**
24
+ * Returns prekey operations for this agent as a Map of hash -> serialized bytes for [`StaticEvent`]
25
+ */
26
+ keyOps(): Promise<Map<any, any>>;
27
+ toString(): string;
28
+ readonly id: Identifier;
29
+ }
30
+
31
+ /**
32
+ * Result of [`JsKeyhive::all_agent_events`], containing all events for all agents
33
+ * with deduplicated storage and two-tier indirection for membership, prekey, and CGKA ops.
34
+ *
35
+ * The consumer follows: agent -> source IDs -> hashes -> event bytes.
36
+ */
37
+ export class AllAgentEvents {
38
+ private constructor();
39
+ free(): void;
40
+ [Symbol.dispose](): void;
41
+ readonly agentCgkaSources: Map<any, any>;
42
+ readonly agentMembershipSources: Map<any, any>;
43
+ readonly agentPrekeySources: Map<any, any>;
44
+ readonly cgkaSources: Map<any, any>;
45
+ readonly events: Map<any, any>;
46
+ readonly membershipSources: Map<any, any>;
47
+ readonly prekeySources: Map<any, any>;
48
+ }
49
+
50
+ export class Archive {
51
+ free(): void;
52
+ [Symbol.dispose](): void;
53
+ toBytes(): Uint8Array;
54
+ tryToKeyhive(ciphertext_store: CiphertextStore, signer: Signer, event_handler: Function): Promise<Keyhive>;
55
+ constructor(bytes: Uint8Array);
56
+ }
57
+
58
+ export class CannotParseEd25519SigningKey {
59
+ private constructor();
60
+ free(): void;
61
+ [Symbol.dispose](): void;
62
+ }
63
+
64
+ export class CannotParseIdentifier {
65
+ private constructor();
66
+ free(): void;
67
+ [Symbol.dispose](): void;
68
+ }
69
+
70
+ export class Capability {
71
+ private constructor();
72
+ free(): void;
73
+ [Symbol.dispose](): void;
74
+ readonly can: Access;
75
+ readonly proof: SignedDelegation;
76
+ readonly who: Agent;
77
+ }
78
+
79
+ export class CgkaOperation {
80
+ private constructor();
81
+ free(): void;
82
+ [Symbol.dispose](): void;
83
+ readonly variant: string;
84
+ }
85
+
86
+ export class ChangeId {
87
+ free(): void;
88
+ [Symbol.dispose](): void;
89
+ /**
90
+ * Upcasts; to the JS-import type for [`JsChangeId`].
91
+ */
92
+ __wasm_refgen_toJsChangeId(): ChangeId;
93
+ constructor(bytes: Uint8Array);
94
+ readonly bytes: Uint8Array;
95
+ }
96
+
97
+ export class CiphertextStore {
98
+ private constructor();
99
+ free(): void;
100
+ [Symbol.dispose](): void;
101
+ static newFromWebStorage(storage: Storage): CiphertextStore;
102
+ static newInMemory(): CiphertextStore;
103
+ }
104
+
105
+ export class ContactCard {
106
+ private constructor();
107
+ free(): void;
108
+ [Symbol.dispose](): void;
109
+ static fromJson(json: string): ContactCard;
110
+ signature(): Uint8Array;
111
+ toJson(): string;
112
+ readonly id: Identifier;
113
+ readonly individualId: IndividualId;
114
+ readonly op: Event;
115
+ readonly shareKey: ShareKey;
116
+ }
117
+
118
+ export class Delegation {
119
+ private constructor();
120
+ free(): void;
121
+ [Symbol.dispose](): void;
122
+ readonly after: History;
123
+ readonly can: Access;
124
+ readonly delegate: Agent;
125
+ readonly proof: SignedDelegation | undefined;
126
+ }
127
+
128
+ export class DocContentRefs {
129
+ free(): void;
130
+ [Symbol.dispose](): void;
131
+ addChangeId(hash: ChangeId): Promise<void>;
132
+ constructor(doc_id: DocumentId, change_hashes: ChangeId[]);
133
+ readonly change_hashes: Promise<ChangeId[]>;
134
+ readonly docId: DocumentId;
135
+ }
136
+
137
+ export class Document {
138
+ private constructor();
139
+ free(): void;
140
+ [Symbol.dispose](): void;
141
+ /**
142
+ * Upcasts; to the JS-import type for [`JsDocument`].
143
+ */
144
+ __wasm_refgen_toJsDocument(): Document;
145
+ members(): Promise<Capability[]>;
146
+ toAgent(): Agent;
147
+ toMembered(): Membered;
148
+ toPeer(): Peer;
149
+ readonly doc_id: DocumentId;
150
+ readonly id: Identifier;
151
+ }
152
+
153
+ export class DocumentId {
154
+ free(): void;
155
+ [Symbol.dispose](): void;
156
+ constructor(bytes: Uint8Array);
157
+ toBytes(): Uint8Array;
158
+ toJsValue(): any;
159
+ toString(): string;
160
+ }
161
+
162
+ export class Encrypted {
163
+ private constructor();
164
+ free(): void;
165
+ [Symbol.dispose](): void;
166
+ static fromBytes(bytes: Uint8Array): Encrypted;
167
+ serialize(): Uint8Array;
168
+ toBytes(): Uint8Array;
169
+ readonly ciphertext: Uint8Array;
170
+ readonly content_ref: Uint8Array;
171
+ readonly nonce: Uint8Array;
172
+ readonly pcs_key_hash: Uint8Array;
173
+ readonly pred_refs: Uint8Array;
174
+ }
175
+
176
+ export class EncryptedContentWithUpdate {
177
+ private constructor();
178
+ free(): void;
179
+ [Symbol.dispose](): void;
180
+ encrypted_content(): Encrypted;
181
+ update_op(): SignedCgkaOperation | undefined;
182
+ }
183
+
184
+ export class Event {
185
+ private constructor();
186
+ free(): void;
187
+ [Symbol.dispose](): void;
188
+ /**
189
+ * Converts the underlying [`Event`] to a [`StaticEvent`] and then
190
+ * serializes it.
191
+ */
192
+ toBytes(): Uint8Array;
193
+ tryIntoSignedDelegation(): SignedDelegation | undefined;
194
+ tryIntoSignedRevocation(): SignedRevocation | undefined;
195
+ readonly isDelegated: boolean;
196
+ readonly isRevoked: boolean;
197
+ readonly variant: string;
198
+ }
199
+
200
+ export class GenerateWebCryptoError {
201
+ private constructor();
202
+ free(): void;
203
+ [Symbol.dispose](): void;
204
+ message(): string;
205
+ }
206
+
207
+ export class Group {
208
+ private constructor();
209
+ free(): void;
210
+ [Symbol.dispose](): void;
211
+ /**
212
+ * Upcasts; to the JS-import type for [`JsGroup`].
213
+ */
214
+ __wasm_refgen_toJsGroup(): Group;
215
+ members(): Promise<Capability[]>;
216
+ toAgent(): Agent;
217
+ toMembered(): Membered;
218
+ toPeer(): Peer;
219
+ readonly groupId: GroupId;
220
+ readonly id: Identifier;
221
+ }
222
+
223
+ export class GroupId {
224
+ private constructor();
225
+ free(): void;
226
+ [Symbol.dispose](): void;
227
+ toString(): string;
228
+ }
229
+
230
+ export class History {
231
+ private constructor();
232
+ free(): void;
233
+ [Symbol.dispose](): void;
234
+ contentRefs(): DocContentRefs[];
235
+ delegations(): SignedDelegation[];
236
+ revocations(): SignedRevocation[];
237
+ }
238
+
239
+ export class Identifier {
240
+ free(): void;
241
+ [Symbol.dispose](): void;
242
+ constructor(bytes: Uint8Array);
243
+ static publicId(): Identifier;
244
+ toBytes(): Uint8Array;
245
+ }
246
+
247
+ export class Individual {
248
+ private constructor();
249
+ free(): void;
250
+ [Symbol.dispose](): void;
251
+ pickPrekey(doc_id: DocumentId): Promise<ShareKey>;
252
+ toAgent(): Agent;
253
+ toPeer(): Peer;
254
+ readonly id: Identifier;
255
+ readonly individualId: IndividualId;
256
+ }
257
+
258
+ export class IndividualId {
259
+ private constructor();
260
+ free(): void;
261
+ [Symbol.dispose](): void;
262
+ readonly bytes: Uint8Array;
263
+ }
264
+
265
+ export class Invocation {
266
+ private constructor();
267
+ free(): void;
268
+ [Symbol.dispose](): void;
269
+ }
270
+
271
+ export class Keyhive {
272
+ private constructor();
273
+ free(): void;
274
+ [Symbol.dispose](): void;
275
+ accessForDoc(id: Identifier, doc_id: DocumentId): Promise<Access | undefined>;
276
+ addMember(to_add: Agent, membered: Membered, access: Access, other_relevant_docs: Document[]): Promise<SignedDelegation>;
277
+ /**
278
+ * Returns all agent events with deduplicated storage and two-tier indirection
279
+ * for membership, prekey, and CGKA ops.
280
+ */
281
+ allAgentEvents(): Promise<AllAgentEvents>;
282
+ contactCard(): Promise<ContactCard>;
283
+ docMemberCapabilities(doc_id: DocumentId): Promise<Membership[]>;
284
+ /**
285
+ * Returns event hashes for provided [`JsAgent`] as an array of hash bytes.
286
+ */
287
+ eventHashesForAgent(agent: Agent): Promise<Array<any>>;
288
+ /**
289
+ * Returns events for provided [`Agent`] as a map from hash to serialized [`StaticEvent`] bytes.
290
+ */
291
+ eventsForAgent(agent: Agent): Promise<Map<any, any>>;
292
+ expandPrekeys(): Promise<ShareKey>;
293
+ exportPrekeySecrets(): Promise<Uint8Array>;
294
+ forcePcsUpdate(doc: Document): Promise<void>;
295
+ generateDocument(coparents: Peer[], initial_content_ref_head: ChangeId, more_initial_content_refs: ChangeId[]): Promise<Document>;
296
+ generateGroup(js_coparents: Peer[]): Promise<Group>;
297
+ getAgent(id: Identifier): Promise<Agent | undefined>;
298
+ getDocument(doc_id: DocumentId): Promise<Document | undefined>;
299
+ getExistingContactCard(): Promise<ContactCard>;
300
+ getGroup(group_id: GroupId): Promise<Group | undefined>;
301
+ getIndividual(id: IndividualId): Promise<Individual | undefined>;
302
+ importPrekeySecrets(bytes: Uint8Array): Promise<void>;
303
+ ingestArchive(archive: Archive): Promise<void>;
304
+ ingestEventsBytes(events_bytes_array: Array<any>): Promise<Array<any>>;
305
+ static init(signer: Signer, ciphertext_store: CiphertextStore, event_handler: Function): Promise<Keyhive>;
306
+ intoArchive(): Promise<Archive>;
307
+ membershipOpsForAgent(agent: Agent): Promise<Map<any, any>>;
308
+ pendingEventHashes(): Promise<Set<any>>;
309
+ reachableDocs(): Promise<Summary[]>;
310
+ receiveContactCard(contact_card: ContactCard): Promise<Individual>;
311
+ revokeMember(to_revoke: Agent, retain_all_other_members: boolean, membered: Membered): Promise<SignedRevocation[]>;
312
+ revokedMembersForDoc(doc_id: DocumentId): Promise<Membership[]>;
313
+ rotatePrekey(prekey: ShareKey): Promise<ShareKey>;
314
+ stats(): Promise<Stats>;
315
+ toArchive(): Promise<Archive>;
316
+ tryDecrypt(doc: Document, encrypted: Encrypted): Promise<Uint8Array>;
317
+ tryEncrypt(doc: Document, content_ref: ChangeId, js_pred_refs: ChangeId[], content: Uint8Array): Promise<EncryptedContentWithUpdate>;
318
+ tryEncryptArchive(doc: Document, content_ref: ChangeId, pred_refs: ChangeId[], content: Uint8Array): Promise<EncryptedContentWithUpdate>;
319
+ trySign(data: Uint8Array): Promise<Signed>;
320
+ readonly id: IndividualId;
321
+ readonly idString: string;
322
+ readonly individual: Promise<Individual>;
323
+ readonly whoami: IndividualId;
324
+ }
325
+
326
+ export class Membered {
327
+ private constructor();
328
+ free(): void;
329
+ [Symbol.dispose](): void;
330
+ }
331
+
332
+ export class Membership {
333
+ private constructor();
334
+ free(): void;
335
+ [Symbol.dispose](): void;
336
+ readonly can: Access;
337
+ readonly who: Agent;
338
+ }
339
+
340
+ export class Peer {
341
+ private constructor();
342
+ free(): void;
343
+ [Symbol.dispose](): void;
344
+ /**
345
+ * Upcasts; to the JS-import type for [`JsPeer`].
346
+ */
347
+ __wasm_refgen_toJsPeer(): Peer;
348
+ isDocument(): boolean;
349
+ isGroup(): boolean;
350
+ isIndividual(): boolean;
351
+ toString(): string;
352
+ readonly id: Identifier;
353
+ }
354
+
355
+ export class Revocation {
356
+ private constructor();
357
+ free(): void;
358
+ [Symbol.dispose](): void;
359
+ readonly after: History;
360
+ readonly proof: SignedDelegation | undefined;
361
+ readonly revoked: SignedDelegation;
362
+ readonly subject_id: Identifier;
363
+ }
364
+
365
+ export class ShareKey {
366
+ private constructor();
367
+ free(): void;
368
+ [Symbol.dispose](): void;
369
+ }
370
+
371
+ export class Signed {
372
+ private constructor();
373
+ free(): void;
374
+ [Symbol.dispose](): void;
375
+ static fromBytes(bytes: Uint8Array): Signed;
376
+ toBytes(): Uint8Array;
377
+ verify(): boolean;
378
+ readonly payload: Uint8Array;
379
+ readonly signature: Uint8Array;
380
+ readonly verifyingKey: Uint8Array;
381
+ }
382
+
383
+ export class SignedCgkaOperation {
384
+ private constructor();
385
+ free(): void;
386
+ [Symbol.dispose](): void;
387
+ verify(): boolean;
388
+ readonly delegation: CgkaOperation;
389
+ readonly signature: Uint8Array;
390
+ readonly verifyingKey: Uint8Array;
391
+ }
392
+
393
+ export class SignedDelegation {
394
+ private constructor();
395
+ free(): void;
396
+ [Symbol.dispose](): void;
397
+ verify(): boolean;
398
+ readonly delegation: Delegation;
399
+ readonly signature: Uint8Array;
400
+ readonly subjectId: Identifier;
401
+ readonly verifyingKey: Uint8Array;
402
+ }
403
+
404
+ export class SignedInvocation {
405
+ private constructor();
406
+ free(): void;
407
+ [Symbol.dispose](): void;
408
+ }
409
+
410
+ export class SignedRevocation {
411
+ private constructor();
412
+ free(): void;
413
+ [Symbol.dispose](): void;
414
+ verify(): boolean;
415
+ readonly delegation: Revocation;
416
+ readonly signature: Uint8Array;
417
+ readonly verifyingKey: Uint8Array;
418
+ }
419
+
420
+ export class Signer {
421
+ private constructor();
422
+ free(): void;
423
+ [Symbol.dispose](): void;
424
+ clone(): Signer;
425
+ static generate(): Promise<Signer>;
426
+ static generateMemory(): Signer;
427
+ static generateWebCrypto(): Promise<Signer>;
428
+ static memorySignerFromBytes(bytes: Uint8Array): Signer;
429
+ trySign(bytes: Uint8Array): Promise<Signed>;
430
+ static webCryptoSigner(keypair: any): Promise<Signer>;
431
+ readonly variant: string;
432
+ readonly verifyingKey: Uint8Array;
433
+ }
434
+
435
+ export class Stats {
436
+ private constructor();
437
+ free(): void;
438
+ [Symbol.dispose](): void;
439
+ readonly activePrekeyCount: bigint;
440
+ readonly cgkaOperations: bigint;
441
+ readonly delegations: bigint;
442
+ readonly docs: bigint;
443
+ readonly groups: bigint;
444
+ readonly individuals: bigint;
445
+ readonly pendingCgkaOperation: bigint;
446
+ readonly pendingCgkaOperationByActive: bigint;
447
+ readonly pendingDelegated: bigint;
448
+ readonly pendingDelegatedByActive: bigint;
449
+ readonly pendingPrekeyRotated: bigint;
450
+ readonly pendingPrekeyRotatedByActive: bigint;
451
+ readonly pendingPrekeysExpanded: bigint;
452
+ readonly pendingPrekeysExpandedByActive: bigint;
453
+ readonly pendingRevoked: bigint;
454
+ readonly pendingRevokedByActive: bigint;
455
+ readonly prekeyRotations: bigint;
456
+ readonly prekeysExpanded: bigint;
457
+ readonly revocations: bigint;
458
+ readonly totalOps: bigint;
459
+ readonly totalPendingOps: bigint;
460
+ }
461
+
462
+ export class Summary {
463
+ private constructor();
464
+ free(): void;
465
+ [Symbol.dispose](): void;
466
+ readonly access: Access;
467
+ readonly doc: Document;
468
+ }
469
+
470
+ /**
471
+ * Panic hook lets us get better error messages if our Rust code ever panics.
472
+ *
473
+ * This function needs to be called at least once during initialisation.
474
+ * https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/template-deep-dive/src-utils-rs.html#2-what-is-console_error_panic_hook
475
+ */
476
+ export function setPanicHook(): void;