@keyhive/keyhive 0.0.0-alpha.8 → 0.1.0-alpha.2

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