@wireapp/core-crypto 9.3.4 → 10.0.0-pre.10

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,2567 +0,0 @@
1
- // Generated by dts-bundle-generator v9.5.1
2
-
3
- /* tslint:disable */
4
- /* eslint-disable */
5
- /**
6
- * Get an instance of the default ciphersuite.
7
- */
8
- export function ciphersuiteDefault(): Ciphersuite;
9
- /**
10
- * Construct a ciphersuite enum instance from its discriminant.
11
- */
12
- export function ciphersuiteFromU16(discriminant: number): Ciphersuite;
13
- /**
14
- * Open or create a [Database].
15
- */
16
- export function openDatabase(name: string, key: DatabaseKey): Promise<Database>;
17
- /**
18
- * Updates the key of the CoreCrypto database.
19
- * To be used only once, when moving from CoreCrypto <= 5.x to CoreCrypto 6.x.
20
- */
21
- export function migrateDatabaseKeyTypeToBytes(path: string, old_key: string, new_key: DatabaseKey): Promise<void>;
22
- /**
23
- * Updates the key of the CoreCrypto database.
24
- */
25
- export function updateDatabaseKey(name: string, old_key: DatabaseKey, new_key: DatabaseKey): Promise<void>;
26
- /**
27
- * MLS ciphersuites.
28
- */
29
- export enum Ciphersuite {
30
- /**
31
- * DH KEM x25519 | AES-GCM 128 | SHA2-256 | Ed25519
32
- */
33
- MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519 = 1,
34
- /**
35
- * DH KEM P256 | AES-GCM 128 | SHA2-256 | EcDSA P256
36
- */
37
- MLS_128_DHKEMP256_AES128GCM_SHA256_P256 = 2,
38
- /**
39
- * DH KEM x25519 | Chacha20Poly1305 | SHA2-256 | Ed25519
40
- */
41
- MLS_128_DHKEMX25519_CHACHA20POLY1305_SHA256_Ed25519 = 3,
42
- /**
43
- * DH KEM x448 | AES-GCM 256 | SHA2-512 | Ed448
44
- */
45
- MLS_256_DHKEMX448_AES256GCM_SHA512_Ed448 = 4,
46
- /**
47
- * DH KEM P521 | AES-GCM 256 | SHA2-512 | EcDSA P521
48
- */
49
- MLS_256_DHKEMP521_AES256GCM_SHA512_P521 = 5,
50
- /**
51
- * DH KEM x448 | Chacha20Poly1305 | SHA2-512 | Ed448
52
- */
53
- MLS_256_DHKEMX448_CHACHA20POLY1305_SHA512_Ed448 = 6,
54
- /**
55
- * DH KEM P384 | AES-GCM 256 | SHA2-384 | EcDSA P384
56
- */
57
- MLS_256_DHKEMP384_AES256GCM_SHA384_P384 = 7
58
- }
59
- /**
60
- * Type of Credential
61
- */
62
- export enum CredentialType {
63
- /**
64
- * Basic credential i.e. a KeyPair
65
- */
66
- Basic = 1,
67
- /**
68
- * A x509 certificate generally obtained through e2e identity enrollment process
69
- */
70
- X509 = 2
71
- }
72
- /**
73
- * Indicates the standalone status of a device Credential in a MLS group at a moment T.
74
- *
75
- * This does not represent the states where a device is not using MLS or is not using end-to-end identity
76
- */
77
- export enum DeviceStatus {
78
- /**
79
- * All is fine
80
- */
81
- Valid = 1,
82
- /**
83
- * The Credential's certificate is expired
84
- */
85
- Expired = 2,
86
- /**
87
- * The Credential's certificate is revoked (not implemented yet)
88
- */
89
- Revoked = 3
90
- }
91
- declare enum E2eiConversationState {
92
- /**
93
- * All clients have a valid E2EI certificate
94
- */
95
- Verified = 1,
96
- /**
97
- * Some clients are either still Basic or their certificate is expired
98
- */
99
- NotVerified = 2,
100
- /**
101
- * All clients are still Basic. If all client have expired certificates, [E2eiConversationState::NotVerified] is returned.
102
- */
103
- NotEnabled = 3
104
- }
105
- declare enum MlsGroupInfoEncryptionType {
106
- /**
107
- * Unencrypted `GroupInfo`
108
- */
109
- Plaintext = 1,
110
- /**
111
- * `GroupInfo` encrypted in a JWE
112
- */
113
- JweEncrypted = 2
114
- }
115
- declare enum MlsRatchetTreeType {
116
- /**
117
- * Plain old and complete `GroupInfo`
118
- */
119
- Full = 1,
120
- /**
121
- * Contains `GroupInfo` changes since previous epoch (not yet implemented)
122
- * (see [draft](https://github.com/rohan-wire/ietf-drafts/blob/main/mahy-mls-ratchet-tree-delta/draft-mahy-mls-ratchet-tree-delta.md))
123
- */
124
- Delta = 2,
125
- ByRef = 3
126
- }
127
- /**
128
- * See [core_crypto::prelude::MlsWirePolicy]
129
- */
130
- export enum WirePolicy {
131
- /**
132
- * Handshake messages are never encrypted
133
- */
134
- Plaintext = 1,
135
- /**
136
- * Handshake messages are always encrypted
137
- */
138
- Ciphertext = 2
139
- }
140
- /**
141
- * For creating a challenge.
142
- *
143
- * - See <https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5.1>
144
- * - See [core_crypto::e2e_identity::types::E2eiAcmeChallenge]
145
- */
146
- export class AcmeChallenge {
147
- private constructor();
148
- free(): void;
149
- [Symbol.dispose](): void;
150
- /**
151
- * Contains raw JSON data of this challenge. This is parsed by the underlying Rust library hence should not be accessed
152
- */
153
- readonly delegate: Uint8Array;
154
- /**
155
- * URL of this challenge
156
- */
157
- readonly url: string;
158
- /**
159
- * Non-standard, Wire specific claim. Indicates the consumer from where it should get the challenge proof.
160
- * Either from wire-server "/access-token" endpoint in case of a DPoP challenge, or from an OAuth token endpoint for an OIDC challenge
161
- */
162
- readonly target: string;
163
- }
164
- declare class AcmeDirectory {
165
- private constructor();
166
- free(): void;
167
- [Symbol.dispose](): void;
168
- /**
169
- * URL for fetching a new nonce. Use this only for creating a new account.
170
- */
171
- readonly newNonce: string;
172
- /**
173
- * URL for creating a new account.
174
- */
175
- readonly newAccount: string;
176
- /**
177
- * URL for creating a new order.
178
- */
179
- readonly newOrder: string;
180
- /**
181
- * Revocation URL
182
- */
183
- readonly revokeCert: string;
184
- }
185
- declare class BufferedDecryptedMessage {
186
- private constructor();
187
- free(): void;
188
- [Symbol.dispose](): void;
189
- /**
190
- * Decrypted plaintext
191
- */
192
- readonly message: Uint8Array | undefined;
193
- /**
194
- * False if processing this message caused the client to be removed from the group, i.e. due to a Remove commit
195
- */
196
- readonly isActive: boolean;
197
- /**
198
- * Commit delay in seconds.
199
- *
200
- * When set, clients must delay this long before processing a commit.
201
- * This reduces load on the backend, which otherwise would receive epoch change notifications from all clients simultaneously.
202
- */
203
- readonly commitDelay: bigint | undefined;
204
- /**
205
- * [ClientId] of the sender of the message being decrypted. Only present for application messages.
206
- */
207
- readonly senderClientId: ClientId | undefined;
208
- /**
209
- * true when the decrypted message resulted in an epoch change i.e. it was a commit
210
- *
211
- * Deprecated: this member will be removed in the future. Prefer using the `EpochObserver` interface.
212
- */
213
- readonly hasEpochChanged: boolean;
214
- /**
215
- * Identity claims present in the sender credential
216
- */
217
- readonly identity: WireIdentity;
218
- /**
219
- * New CRL distribution points that appeared by the introduction of a new credential
220
- */
221
- readonly crlNewDistributionPoints: string[] | undefined;
222
- }
223
- /**
224
- * Metadata describing the conditions of the build of this software.
225
- */
226
- export class BuildMetadata {
227
- private constructor();
228
- /**
229
- ** Return copy of self without private attributes.
230
- */
231
- toJSON(): Object;
232
- /**
233
- * Return stringified version of self.
234
- */
235
- toString(): string;
236
- free(): void;
237
- [Symbol.dispose](): void;
238
- /**
239
- * Build Timestamp
240
- */
241
- readonly timestamp: string;
242
- /**
243
- * Whether this build was in Debug mode (true) or Release mode (false)
244
- */
245
- readonly cargoDebug: string;
246
- /**
247
- * Features enabled for this build
248
- */
249
- readonly cargoFeatures: string;
250
- /**
251
- * Optimization level
252
- */
253
- readonly optLevel: string;
254
- /**
255
- * Build target triple
256
- */
257
- readonly targetTriple: string;
258
- /**
259
- * Git branch
260
- */
261
- readonly gitBranch: string;
262
- /**
263
- * Output of `git describe`
264
- */
265
- readonly gitDescribe: string;
266
- /**
267
- * Hash of current git commit
268
- */
269
- readonly gitSha: string;
270
- /**
271
- * `true` when the source code differed from the commit at the most recent git hash
272
- */
273
- readonly gitDirty: string;
274
- }
275
- /**
276
- * A Client identifier
277
- *
278
- * A unique identifier for clients. A client is an identifier for each App a user is using, such as desktop,
279
- * mobile, etc. Users can have multiple clients.
280
- * More information [here](https://messaginglayersecurity.rocks/mls-architecture/draft-ietf-mls-architecture.html#name-group-members-and-clients)
281
- */
282
- export class ClientId {
283
- free(): void;
284
- [Symbol.dispose](): void;
285
- /**
286
- * Copy the id into a new byte array.
287
- */
288
- copyBytes(): Uint8Array;
289
- /**
290
- * Instantiate a client id from a byte array.
291
- */
292
- constructor(bytes: Uint8Array);
293
- }
294
- declare class ConversationConfiguration {
295
- free(): void;
296
- [Symbol.dispose](): void;
297
- /**
298
- * Construct a `ConversationConfiguration` from its parts.
299
- */
300
- constructor(ciphersuite?: Ciphersuite | null, external_senders?: ExternalSenderKey[] | null, key_rotation_span?: number | null, wire_policy?: WirePolicy | null);
301
- /**
302
- * The ciphersuite used in the group
303
- */
304
- readonly ciphersuite: Ciphersuite | undefined;
305
- /**
306
- * Delivery service public signature key and credential
307
- */
308
- readonly externalSenders: ExternalSenderKey[];
309
- /**
310
- * Implementation specific configuration
311
- */
312
- readonly custom: CustomConfiguration;
313
- }
314
- /**
315
- * r" A unique identifier for a single conversation.
316
- * r"
317
- * r" The backend provides an opaque string identifying a new conversation.
318
- * r" Construct an instance of this newtype to pass that identifier to Rust.
319
- */
320
- export class ConversationId {
321
- free(): void;
322
- [Symbol.dispose](): void;
323
- /**
324
- * Get the raw bytes from this type, transferring data from Rust to the client layer.
325
- *
326
- * This does not consume the newtype, instead copying the internal data across the FFI boundary.
327
- */
328
- copyBytes(): Uint8Array;
329
- /**
330
- * Construct a new instance, transferring data from the client layer to Rust.
331
- */
332
- constructor(bytes: Uint8Array);
333
- }
334
- declare class CoreCryptoContext {
335
- private constructor();
336
- free(): void;
337
- [Symbol.dispose](): void;
338
- /**
339
- * See [core_crypto::prelude::Session::random_bytes].
340
- */
341
- random_bytes(len: number): Promise<Uint8Array>;
342
- /**
343
- * See [core_crypto::transaction_context::TransactionContext::get_data]
344
- */
345
- get_data(): Promise<Uint8Array | undefined>;
346
- /**
347
- * See [core_crypto::transaction_context::TransactionContext::set_data]
348
- */
349
- set_data(data: Uint8Array): Promise<void>;
350
- /**
351
- * See [core_crypto::mls::conversation::Conversation::get_client_ids]
352
- */
353
- get_client_ids(conversation_id: ConversationId): Promise<ClientId[]>;
354
- /**
355
- * See [core_crypto::mls::conversation::ConversationGuard::decrypt_message]
356
- */
357
- decrypt_message(conversation_id: ConversationId, payload: Uint8Array): Promise<DecryptedMessage>;
358
- /**
359
- * See [core_crypto::mls::conversation::ConversationGuard::encrypt_message]
360
- */
361
- encrypt_message(conversation_id: ConversationId, message: Uint8Array): Promise<Uint8Array>;
362
- /**
363
- * See [core_crypto::transaction_context::TransactionContext::client_public_key]
364
- */
365
- client_public_key(ciphersuite: Ciphersuite, credential_type: CredentialType): Promise<Uint8Array>;
366
- /**
367
- * See [core_crypto::mls::conversation::Conversation::export_secret_key]
368
- */
369
- export_secret_key(conversation_id: ConversationId, key_length: number): Promise<SecretKey>;
370
- /**
371
- * See [core_crypto::mls::conversation::ConversationGuard::wipe]
372
- */
373
- wipe_conversation(conversation_id: ConversationId): Promise<void>;
374
- /**
375
- * See [core_crypto::transaction_context::TransactionContext::get_or_create_client_keypackages]
376
- */
377
- client_keypackages(ciphersuite: Ciphersuite, credential_type: CredentialType, amount_requested: number): Promise<KeyPackage[]>;
378
- /**
379
- * See [core_crypto::mls::conversation::Conversation::epoch]
380
- */
381
- conversation_epoch(conversation_id: ConversationId): Promise<bigint>;
382
- /**
383
- * See [core_crypto::prelude::Session::conversation_exists]
384
- */
385
- conversation_exists(conversation_id: ConversationId): Promise<boolean>;
386
- /**
387
- * See [core_crypto::transaction_context::TransactionContext::new_conversation]
388
- */
389
- create_conversation(conversation_id: ConversationId, creator_credential_type: CredentialType, config: ConversationConfiguration): Promise<void>;
390
- /**
391
- * See [core_crypto::mls::conversation::Conversation::get_external_sender]
392
- */
393
- get_external_sender(conversation_id: ConversationId): Promise<ExternalSenderKey>;
394
- /**
395
- * See [core_crypto::mls::conversation::ConversationGuard::enable_history_sharing]
396
- */
397
- enable_history_sharing(conversation_id: ConversationId): Promise<void>;
398
- /**
399
- * See [core_crypto::mls::conversation::ConversationGuard::update_key_material]
400
- */
401
- update_keying_material(conversation_id: ConversationId): Promise<void>;
402
- /**
403
- * See [core_crypto::mls::conversation::ConversationGuard::disable_history_sharing]
404
- */
405
- disable_history_sharing(conversation_id: ConversationId): Promise<void>;
406
- /**
407
- * See [core_crypto::transaction_context::TransactionContext::join_by_external_commit]
408
- */
409
- join_by_external_commit(group_info: GroupInfo, custom_configuration: CustomConfiguration, credential_type: CredentialType): Promise<WelcomeBundle>;
410
- /**
411
- * See [core_crypto::transaction_context::TransactionContext::process_raw_welcome_message]
412
- */
413
- process_welcome_message(welcome_message: Welcome, custom_configuration: CustomConfiguration): Promise<WelcomeBundle>;
414
- /**
415
- * See [core_crypto::mls::conversation::ConversationGuard::commit_pending_proposals]
416
- */
417
- commit_pending_proposals(conversation_id: ConversationId): Promise<void>;
418
- /**
419
- * See [core_crypto::mls::conversation::Conversation::ciphersuite]
420
- */
421
- conversation_ciphersuite(conversation_id: ConversationId): Promise<Ciphersuite>;
422
- /**
423
- * See [core_crypto::mls::conversation::ConversationGuard::add_members]
424
- */
425
- add_clients_to_conversation(conversation_id: ConversationId, key_packages: KeyPackage[]): Promise<string[] | undefined>;
426
- /**
427
- * See [core_crypto::mls::conversation::ConversationGuard::mark_as_child_of]
428
- */
429
- mark_conversation_as_child_of(child_id: ConversationId, parent_id: ConversationId): Promise<void>;
430
- /**
431
- * See [core_crypto::transaction_context::TransactionContext::client_valid_key_packages_count]
432
- */
433
- client_valid_keypackages_count(ciphersuite: Ciphersuite, credential_type: CredentialType): Promise<bigint>;
434
- /**
435
- * See [core_crypto::mls::conversation::ConversationGuard::remove_members]
436
- */
437
- remove_clients_from_conversation(conversation_id: ConversationId, clients: ClientId[]): Promise<void>;
438
- /**
439
- * See [core_crypto::transaction_context::TransactionContext::mls_init]
440
- */
441
- mls_init(client_id: ClientId, ciphersuites: any[], nb_key_package?: number | null): Promise<void>;
442
- /**
443
- * See [core_crypto::mls::conversation::ConversationGuard::e2ei_rotate]
444
- */
445
- e2ei_rotate(conversation_id: ConversationId): Promise<void>;
446
- /**
447
- * See [core_crypto::prelude::Session::e2ei_is_enabled]
448
- */
449
- e2ei_is_enabled(ciphersuite: Ciphersuite): Promise<boolean>;
450
- /**
451
- * See [core_crypto::transaction_context::TransactionContext::e2ei_register_crl]
452
- */
453
- e2ei_register_crl(crl_dp: string, crl_der: Uint8Array): Promise<CrlRegistration>;
454
- /**
455
- * See [core_crypto::transaction_context::TransactionContext::e2ei_mls_init_only]
456
- */
457
- e2ei_mls_init_only(enrollment: FfiWireE2EIdentity, certificate_chain: string, nb_key_package?: number | null): Promise<string[] | undefined>;
458
- /**
459
- * See [core_crypto::transaction_context::TransactionContext::e2ei_new_enrollment]
460
- */
461
- e2ei_new_enrollment(client_id: string, display_name: string, handle: string, team: string | null | undefined, expiry_sec: number, ciphersuite: Ciphersuite): Promise<FfiWireE2EIdentity>;
462
- /**
463
- * See [core_crypto::mls::conversation::Conversation::get_user_identities]
464
- */
465
- get_user_identities(conversation_id: ConversationId, user_ids: string[]): Promise<Map<string, WireIdentity[]>>;
466
- /**
467
- * See [core_crypto::transaction_context::TransactionContext::save_x509_credential]
468
- */
469
- save_x509_credential(enrollment: FfiWireE2EIdentity, certificate_chain: string): Promise<string[] | undefined>;
470
- /**
471
- * See [core_crypto::transaction_context::TransactionContext::e2ei_enrollment_stash]
472
- *
473
- * Note that this can only succeed if the enrollment is unique and there are no other hard refs to it.
474
- */
475
- e2ei_enrollment_stash(enrollment: FfiWireE2EIdentity): Promise<Uint8Array>;
476
- /**
477
- * See [core_crypto::prelude::Session::e2ei_is_pki_env_setup]
478
- */
479
- e2ei_is_pki_env_setup(): Promise<boolean>;
480
- /**
481
- * See [core_crypto::transaction_context::TransactionContext::e2ei_register_acme_ca]
482
- */
483
- e2ei_register_acme_ca(trust_anchor_pem: string): Promise<void>;
484
- /**
485
- * See [core_crypto::mls::conversation::Conversation::get_device_identities]
486
- */
487
- get_device_identities(conversation_id: ConversationId, device_ids: ClientId[]): Promise<WireIdentity[]>;
488
- /**
489
- * See [core_crypto::mls::conversation::Conversation::e2ei_conversation_state]
490
- */
491
- e2ei_conversation_state(conversation_id: ConversationId): Promise<E2eiConversationState>;
492
- /**
493
- * See [core_crypto::transaction_context::TransactionContext::delete_stale_key_packages]
494
- */
495
- delete_stale_key_packages(ciphersuite: Ciphersuite): Promise<void>;
496
- /**
497
- * See [core_crypto::transaction_context::TransactionContext::e2ei_enrollment_stash_pop]
498
- */
499
- e2ei_enrollment_stash_pop(handle: Uint8Array): Promise<FfiWireE2EIdentity>;
500
- /**
501
- * See [core_crypto::transaction_context::TransactionContext::e2ei_new_rotate_enrollment]
502
- */
503
- e2ei_new_rotate_enrollment(display_name: string | null | undefined, handle: string | null | undefined, team: string | null | undefined, expiry_sec: number, ciphersuite: Ciphersuite): Promise<FfiWireE2EIdentity>;
504
- /**
505
- * See [core_crypto::transaction_context::TransactionContext::e2ei_register_intermediate_ca_pem]
506
- */
507
- e2ei_register_intermediate_ca(cert_pem: string): Promise<string[] | undefined>;
508
- /**
509
- * See [core_crypto::transaction_context::TransactionContext::e2ei_new_activation_enrollment]
510
- */
511
- e2ei_new_activation_enrollment(display_name: string, handle: string, team: string | null | undefined, expiry_sec: number, ciphersuite: Ciphersuite): Promise<FfiWireE2EIdentity>;
512
- /**
513
- * See [core_crypto::proteus::ProteusCentral::try_new]
514
- */
515
- proteus_init(): Promise<void>;
516
- /**
517
- * See [core_crypto::transaction_context::TransactionContext::proteus_decrypt]
518
- */
519
- proteus_decrypt(session_id: string, ciphertext: Uint8Array): Promise<Uint8Array>;
520
- /**
521
- * See [core_crypto::transaction_context::TransactionContext::proteus_encrypt]
522
- */
523
- proteus_encrypt(session_id: string, plaintext: Uint8Array): Promise<Uint8Array>;
524
- /**
525
- * Creates a new Proteus prekey with the given id and returns the CBOR-serialized version of the prekey bundle
526
- *
527
- * Warning: The Proteus client **MUST** be initialized with `proteus_init` first or an error will be returned
528
- *
529
- * See [core_crypto::transaction_context::TransactionContext::proteus_new_prekey]
530
- */
531
- proteus_new_prekey(prekey_id: number): Promise<Uint8Array>;
532
- /**
533
- * See [core_crypto::transaction_context::TransactionContext::proteus_fingerprint]
534
- */
535
- proteus_fingerprint(): Promise<string>;
536
- /**
537
- * Decrypt a message whether or not the proteus session already exists, and saves the session.
538
- *
539
- * This is intended to replace simple usages of `proteusDecrypt`.
540
- *
541
- * However, when decrypting large numbers of messages in a single session, the existing methods
542
- * may be more efficient.
543
- */
544
- proteus_decrypt_safe(session_id: string, ciphertext: Uint8Array): Promise<Uint8Array>;
545
- /**
546
- * See [core_crypto::transaction_context::TransactionContext::proteus_session_save]
547
- *
548
- * **Note**: This isn't usually needed as persisting sessions happens automatically when
549
- * decrypting/encrypting messages and initializing Sessions
550
- */
551
- proteus_session_save(session_id: string): Promise<void>;
552
- /**
553
- * See [core_crypto::transaction_context::TransactionContext::proteus_session_delete]
554
- */
555
- proteus_session_delete(session_id: string): Promise<void>;
556
- /**
557
- * See [core_crypto::transaction_context::TransactionContext::proteus_session_exists]
558
- */
559
- proteus_session_exists(session_id: string): Promise<boolean>;
560
- /**
561
- * See [core_crypto::transaction_context::TransactionContext::proteus_encrypt_batched]
562
- */
563
- proteus_encrypt_batched(sessions: string[], plaintext: Uint8Array): Promise<Map<string, Uint8Array>>;
564
- /**
565
- * Creates a new Proteus prekey with an automatically incremented ID and returns the CBOR-serialized version of the prekey bundle
566
- *
567
- * Warning: The Proteus client **MUST** be initialized with `proteus_init` first or an error will be returned
568
- *
569
- * See [core_crypto::transaction_context::TransactionContext::proteus_new_prekey_auto]
570
- */
571
- proteus_new_prekey_auto(): Promise<ProteusAutoPrekeyBundle>;
572
- /**
573
- * See [core_crypto::transaction_context::TransactionContext::proteus_reload_sessions]
574
- */
575
- proteus_reload_sessions(): Promise<void>;
576
- /**
577
- * See [core_crypto::transaction_context::TransactionContext::proteus_fingerprint_local]
578
- */
579
- proteus_fingerprint_local(session_id: string): Promise<string>;
580
- /**
581
- * See [core_crypto::transaction_context::TransactionContext::proteus_fingerprint_remote]
582
- */
583
- proteus_fingerprint_remote(session_id: string): Promise<string>;
584
- /**
585
- * See [core_crypto::transaction_context::TransactionContext::proteus_last_resort_prekey]
586
- */
587
- proteus_last_resort_prekey(): Promise<Uint8Array>;
588
- /**
589
- * See [core_crypto::transaction_context::TransactionContext::proteus_session_from_prekey]
590
- */
591
- proteus_session_from_prekey(session_id: string, prekey: Uint8Array): Promise<void>;
592
- /**
593
- * See [core_crypto::transaction_context::TransactionContext::proteus_session_from_message]
594
- */
595
- proteus_session_from_message(session_id: string, envelope: Uint8Array): Promise<Uint8Array>;
596
- /**
597
- * See [core_crypto::proteus::ProteusCentral::last_resort_prekey_id]
598
- */
599
- static proteus_last_resort_prekey_id(): number;
600
- /**
601
- * See [core_crypto::proteus::ProteusCentral::fingerprint_prekeybundle]
602
- */
603
- static proteus_fingerprint_prekeybundle(prekey: Uint8Array): string;
604
- }
605
- declare class CrlRegistration {
606
- free(): void;
607
- [Symbol.dispose](): void;
608
- /**
609
- * Contstruct a CRL registration from its fields
610
- */
611
- constructor(dirty: boolean, expiration?: bigint | null);
612
- /**
613
- * Whether this CRL modifies the old CRL (i.e. has a different revocated cert list)
614
- */
615
- dirty: boolean;
616
- /**
617
- * Optional expiration timestamp
618
- */
619
- get expiration(): bigint | undefined;
620
- /**
621
- * Optional expiration timestamp
622
- */
623
- set expiration(value: bigint | null | undefined);
624
- }
625
- /**
626
- * see [core_crypto::prelude::MlsCustomConfiguration]
627
- */
628
- export class CustomConfiguration {
629
- free(): void;
630
- [Symbol.dispose](): void;
631
- /**
632
- * Construct a `CustomConfiguration` from its parts.
633
- */
634
- constructor(key_rotation_span?: number | null, wire_policy?: WirePolicy | null);
635
- /**
636
- * Duration in seconds after which we will automatically force a self-update commit
637
- * Note: This isn't currently implemented
638
- */
639
- get keyRotationSpan(): number | undefined;
640
- /**
641
- * Duration in seconds after which we will automatically force a self-update commit
642
- * Note: This isn't currently implemented
643
- */
644
- set keyRotationSpan(value: number | null | undefined);
645
- /**
646
- * Defines if handshake messages are encrypted or not
647
- * Note: encrypted handshake messages are not supported by wire-server
648
- */
649
- get wirePolicy(): WirePolicy | undefined;
650
- /**
651
- * Defines if handshake messages are encrypted or not
652
- * Note: encrypted handshake messages are not supported by wire-server
653
- */
654
- set wirePolicy(value: WirePolicy | null | undefined);
655
- }
656
- /**
657
- * The database acting as a core crypto keystore.
658
- */
659
- export class Database {
660
- private constructor();
661
- free(): void;
662
- [Symbol.dispose](): void;
663
- }
664
- /**
665
- * The key used to encrypt the database.
666
- */
667
- export class DatabaseKey {
668
- free(): void;
669
- [Symbol.dispose](): void;
670
- /**
671
- * Construct a new instance from a byte vector.
672
- */
673
- constructor(buf: Uint8Array);
674
- }
675
- declare class DecryptedMessage {
676
- private constructor();
677
- free(): void;
678
- [Symbol.dispose](): void;
679
- /**
680
- * Decrypted plaintext
681
- */
682
- readonly message: Uint8Array | undefined;
683
- /**
684
- * False if processing this message caused the client to be removed from the group, i.e. due to a Remove commit
685
- */
686
- readonly isActive: boolean;
687
- /**
688
- * Commit delay in seconds.
689
- *
690
- * When set, clients must delay this long before processing a commit.
691
- * This reduces load on the backend, which otherwise would receive epoch change notifications from all clients simultaneously.
692
- */
693
- readonly commitDelay: bigint | undefined;
694
- /**
695
- * [ClientId] of the sender of the message being decrypted. Only present for application messages.
696
- */
697
- readonly senderClientId: ClientId | undefined;
698
- /**
699
- * true when the decrypted message resulted in an epoch change i.e. it was a commit
700
- *
701
- * Deprecated: this member will be removed in the future. Prefer using the `EpochObserver` interface.
702
- */
703
- readonly hasEpochChanged: boolean;
704
- /**
705
- * Identity claims present in the sender credential
706
- */
707
- readonly identity: WireIdentity;
708
- /**
709
- * Only set when the decrypted message is a commit.
710
- *
711
- * Contains buffered messages for next epoch which were received before the commit creating the epoch
712
- * because the DS did not fan them out in order.
713
- */
714
- readonly bufferedMessages: BufferedDecryptedMessage[] | undefined;
715
- /**
716
- * New CRL distribution points that appeared by the introduction of a new credential
717
- */
718
- readonly crlNewDistributionPoints: string[] | undefined;
719
- }
720
- /**
721
- * r" The raw public key of an external sender.
722
- * r"
723
- * r" This can be used to initialize a subconversation.
724
- */
725
- export class ExternalSenderKey {
726
- free(): void;
727
- [Symbol.dispose](): void;
728
- /**
729
- * Get the raw bytes from this type, transferring data from Rust to the client layer.
730
- *
731
- * This does not consume the newtype, instead copying the internal data across the FFI boundary.
732
- */
733
- copyBytes(): Uint8Array;
734
- /**
735
- * Construct a new instance, transferring data from the client layer to Rust.
736
- */
737
- constructor(bytes: Uint8Array);
738
- }
739
- declare class FfiWireE2EIdentity {
740
- private constructor();
741
- free(): void;
742
- [Symbol.dispose](): void;
743
- /**
744
- * See [core_crypto::prelude::E2eiEnrollment::finalize_request]
745
- */
746
- finalize_request(previous_nonce: string): Promise<Uint8Array>;
747
- /**
748
- * See [core_crypto::e2e_identity::E2eiEnrollment::create_dpop_token]
749
- */
750
- create_dpop_token(expiry_secs: number, backend_nonce: string): Promise<string>;
751
- /**
752
- * See [core_crypto::prelude::E2eiEnrollment::finalize_response]
753
- */
754
- finalize_response(finalize: Uint8Array): Promise<string>;
755
- /**
756
- * See [core_crypto::e2e_identity::E2eiEnrollment::new_authz_request]
757
- */
758
- new_authz_request(url: string, previous_nonce: string): Promise<Uint8Array>;
759
- /**
760
- * See [core_crypto::e2e_identity::E2eiEnrollment::new_order_request]
761
- */
762
- new_order_request(previous_nonce: string): Promise<Uint8Array>;
763
- /**
764
- * See [core_crypto::e2e_identity::E2eiEnrollment::directory_response]
765
- */
766
- directory_response(directory: Uint8Array): Promise<AcmeDirectory>;
767
- /**
768
- * See [core_crypto::e2e_identity::E2eiEnrollment::new_authz_response]
769
- */
770
- new_authz_response(authz: Uint8Array): Promise<NewAcmeAuthz>;
771
- /**
772
- * See [core_crypto::e2e_identity::E2eiEnrollment::new_order_response]
773
- */
774
- new_order_response(order: Uint8Array): Promise<NewAcmeOrder>;
775
- /**
776
- * See [core_crypto::prelude::E2eiEnrollment::certificate_request]
777
- */
778
- certificate_request(previous_nonce: string): Promise<Uint8Array>;
779
- /**
780
- * See [core_crypto::e2e_identity::E2eiEnrollment::check_order_request]
781
- */
782
- check_order_request(order_url: string, previous_nonce: string): Promise<Uint8Array>;
783
- /**
784
- * See [core_crypto::e2e_identity::E2eiEnrollment::new_account_request]
785
- */
786
- new_account_request(previous_nonce: string): Promise<Uint8Array>;
787
- /**
788
- * See [core_crypto::e2e_identity::E2eiEnrollment::check_order_response]
789
- */
790
- check_order_response(order: Uint8Array): Promise<string>;
791
- /**
792
- * See [core_crypto::e2e_identity::E2eiEnrollment::new_account_response]
793
- */
794
- new_account_response(account: Uint8Array): Promise<void>;
795
- /**
796
- * See [core_crypto::e2e_identity::E2eiEnrollment::new_dpop_challenge_request]
797
- */
798
- new_dpop_challenge_request(access_token: string, previous_nonce: string): Promise<Uint8Array>;
799
- /**
800
- * See [core_crypto::e2e_identity::E2eiEnrollment::new_oidc_challenge_request]
801
- */
802
- new_oidc_challenge_request(id_token: string, previous_nonce: string): Promise<Uint8Array>;
803
- /**
804
- * See [core_crypto::e2e_identity::E2eiEnrollment::new_dpop_challenge_response]
805
- */
806
- new_dpop_challenge_response(challenge: Uint8Array): Promise<void>;
807
- /**
808
- * See [core_crypto::e2e_identity::E2eiEnrollment::new_oidc_challenge_response]
809
- */
810
- new_oidc_challenge_response(challenge: Uint8Array): Promise<void>;
811
- }
812
- /**
813
- * r" MLS Group Information
814
- * r"
815
- * r" This is used when joining by external commit.
816
- * r" It can be found within the `GroupInfoBundle` within a `CommitBundle`.
817
- */
818
- export class GroupInfo {
819
- free(): void;
820
- [Symbol.dispose](): void;
821
- /**
822
- * Get the raw bytes from this type, transferring data from Rust to the client layer.
823
- *
824
- * This does not consume the newtype, instead copying the internal data across the FFI boundary.
825
- */
826
- copyBytes(): Uint8Array;
827
- /**
828
- * Construct a new instance, transferring data from the client layer to Rust.
829
- */
830
- constructor(bytes: Uint8Array);
831
- }
832
- declare class KeyPackage {
833
- free(): void;
834
- [Symbol.dispose](): void;
835
- /**
836
- * Get the raw bytes from this type, transferring data from Rust to the client layer.
837
- *
838
- * This does not consume the newtype, instead copying the internal data across the FFI boundary.
839
- */
840
- copyBytes(): Uint8Array;
841
- /**
842
- * Construct a new instance, transferring data from the client layer to Rust.
843
- */
844
- constructor(bytes: Uint8Array);
845
- }
846
- /**
847
- * An entity / data which has been packaged by the application to be encrypted
848
- * and transmitted in an application message.
849
- */
850
- export class MlsTransportData {
851
- free(): void;
852
- [Symbol.dispose](): void;
853
- /**
854
- * Construct `MlsTransportData` by providing data
855
- */
856
- constructor(buf: Uint8Array);
857
- /**
858
- * The specific data which has been packaged to be encrypted/transmitted.
859
- */
860
- readonly data: Uint8Array;
861
- }
862
- /**
863
- * Result of an authorization creation.
864
- *
865
- * - See <https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5>
866
- * - See [core_crypto::e2e_identity::types::E2eiNewAcmeAuthz]
867
- */
868
- export class NewAcmeAuthz {
869
- private constructor();
870
- free(): void;
871
- [Symbol.dispose](): void;
872
- /**
873
- * DNS entry associated with those challenge
874
- */
875
- readonly identifier: string;
876
- /**
877
- * ACME challenge + ACME key thumbprint
878
- */
879
- readonly keyauth: string | undefined;
880
- /**
881
- * Associated ACME Challenge
882
- */
883
- readonly challenge: AcmeChallenge;
884
- }
885
- /**
886
- * Result of an order creation.
887
- *
888
- * - See <https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4>
889
- * - See [core_crypto::e2e_identity::types::E2eiNewAcmeOrder]
890
- */
891
- export class NewAcmeOrder {
892
- private constructor();
893
- free(): void;
894
- [Symbol.dispose](): void;
895
- /**
896
- * Opaque raw json value
897
- */
898
- readonly delegate: Uint8Array;
899
- /**
900
- * Authorizations to create with `new_authz_request`
901
- */
902
- readonly authorizations: string[];
903
- }
904
- declare class ProteusAutoPrekeyBundle {
905
- private constructor();
906
- free(): void;
907
- [Symbol.dispose](): void;
908
- /**
909
- * Prekey id (automatically incremented)
910
- */
911
- readonly id: number;
912
- /**
913
- * CBOR serialization of prekey
914
- */
915
- readonly pkb: Uint8Array;
916
- }
917
- /**
918
- * r" A secret key derived from the group secret.
919
- * r"
920
- * r" This is intended to be used for AVS.
921
- */
922
- export class SecretKey {
923
- free(): void;
924
- [Symbol.dispose](): void;
925
- /**
926
- * Get the raw bytes from this type, transferring data from Rust to the client layer.
927
- *
928
- * This does not consume the newtype, instead copying the internal data across the FFI boundary.
929
- */
930
- copyBytes(): Uint8Array;
931
- /**
932
- * Construct a new instance, transferring data from the client layer to Rust.
933
- */
934
- constructor(bytes: Uint8Array);
935
- }
936
- /**
937
- * r" A TLS-serialized Welcome message.
938
- * r"
939
- * r" This structure is defined in RFC 9420:
940
- * r" <https://www.rfc-editor.org/rfc/rfc9420.html#joining-via-welcome-message>.
941
- */
942
- export class Welcome {
943
- free(): void;
944
- [Symbol.dispose](): void;
945
- /**
946
- * Get the raw bytes from this type, transferring data from Rust to the client layer.
947
- *
948
- * This does not consume the newtype, instead copying the internal data across the FFI boundary.
949
- */
950
- copyBytes(): Uint8Array;
951
- /**
952
- * Construct a new instance, transferring data from the client layer to Rust.
953
- */
954
- constructor(bytes: Uint8Array);
955
- }
956
- /**
957
- * see [core_crypto::prelude::WelcomeBundle]
958
- */
959
- export class WelcomeBundle {
960
- private constructor();
961
- free(): void;
962
- [Symbol.dispose](): void;
963
- /**
964
- * Identifier of the joined conversation
965
- */
966
- readonly id: ConversationId;
967
- /**
968
- * New CRL Distribution of members of this group
969
- */
970
- readonly crlNewDistributionPoints: string[] | undefined;
971
- }
972
- /**
973
- * Represents the identity claims identifying a client
974
- * Those claims are verifiable by any member in the group
975
- */
976
- export class WireIdentity {
977
- private constructor();
978
- free(): void;
979
- [Symbol.dispose](): void;
980
- /**
981
- * Unique client identifier e.g. `T4Coy4vdRzianwfOgXpn6A:6add501bacd1d90e@whitehouse.gov`
982
- */
983
- readonly clientId: string;
984
- /**
985
- * Status of the Credential at the moment this object is created
986
- */
987
- readonly status: DeviceStatus;
988
- /**
989
- * MLS thumbprint
990
- */
991
- readonly thumbprint: string;
992
- /**
993
- * Indicates whether the credential is Basic or X509
994
- */
995
- credentialType: CredentialType;
996
- /**
997
- * In case 'credential_type' is [CredentialType::X509] this is populated
998
- */
999
- readonly x509Identity: X509Identity | undefined;
1000
- }
1001
- /**
1002
- * Represents the parts of [WireIdentity][crate::WireIdentity] that are specific to a X509 certificate (and not a Basic one).
1003
- *
1004
- * We don't use an enum here since the sole purpose of this is to be exposed through the FFI (and
1005
- * union types are impossible to carry over the FFI boundary)
1006
- */
1007
- export class X509Identity {
1008
- private constructor();
1009
- free(): void;
1010
- [Symbol.dispose](): void;
1011
- /**
1012
- * user handle e.g. `john_wire`
1013
- */
1014
- readonly handle: string;
1015
- /**
1016
- * Name as displayed in the messaging application e.g. `John Fitzgerald Kennedy`
1017
- */
1018
- readonly displayName: string;
1019
- /**
1020
- * DNS domain for which this identity proof was generated e.g. `whitehouse.gov`
1021
- */
1022
- readonly domain: string;
1023
- /**
1024
- * X509 certificate identifying this client in the MLS group ; PEM encoded
1025
- */
1026
- readonly certificate: string;
1027
- /**
1028
- * X509 certificate serial number
1029
- */
1030
- readonly serialNumber: string;
1031
- /**
1032
- * X509 certificate not before as Unix timestamp
1033
- */
1034
- readonly notBefore: bigint;
1035
- /**
1036
- * X509 certificate not after as Unix timestamp
1037
- */
1038
- readonly notAfter: bigint;
1039
- }
1040
- interface ConversationConfiguration$1 {
1041
- /**
1042
- * The ciphersuite which should be used to encrypt this conversation.
1043
- */
1044
- ciphersuite?: Ciphersuite;
1045
- /**
1046
- * List of client IDs that are allowed to be external senders
1047
- */
1048
- externalSenders?: ExternalSenderKey[];
1049
- /**
1050
- * Duration in seconds after which we will automatically force a self-update commit
1051
- * Note: This isn't currently implemented
1052
- */
1053
- keyRotationSpan?: number;
1054
- /**
1055
- * Defines if handshake messages are encrypted or not
1056
- * Note: encrypted handshake messages are not supported by wire-server
1057
- */
1058
- wirePolicy?: WirePolicy;
1059
- }
1060
- /**
1061
- * The error structure produced by our rust code.
1062
- **/
1063
- export interface CoreCryptoRichError<T extends ErrorType> {
1064
- message: string;
1065
- error_name?: string;
1066
- error_stack?: string[];
1067
- type?: T;
1068
- context?: ErrorContext[T];
1069
- }
1070
- /**
1071
- * Error wrapper that takes care of extracting rich error details across the FFI (through JSON parsing)
1072
- *
1073
- * Whenever you're supposed to get this class (that extends `Error`) you might end up with a base `Error`
1074
- * in case the parsing of the message structure fails. This is unlikely but the case is still covered and fall backs automatically.
1075
- * More information will be found in the base `Error.cause` to inform you why the parsing has failed.
1076
- *
1077
- * Please note that in this case the extra properties will not be available.
1078
- */
1079
- export declare class CoreCryptoError<T extends ErrorType> extends Error {
1080
- errorStack: string[];
1081
- context?: ErrorContext[T];
1082
- type?: T;
1083
- private constructor();
1084
- private static fallback;
1085
- static build<E extends ErrorType>(msg: string, ...params: unknown[]): CoreCryptoError<E>;
1086
- static fromStdError(e: Error): CoreCryptoError<ErrorType>;
1087
- static asyncMapErr<T, E extends ErrorType>(p: Promise<T>): Promise<T>;
1088
- }
1089
- /**
1090
- * Helper type to ensure that error contexts match their type
1091
- */
1092
- export type ErrorTypeWithContext<T> = {
1093
- [K in keyof T]: {
1094
- type: K;
1095
- context: T[K];
1096
- };
1097
- }[keyof T];
1098
- /**
1099
- * Variants of core crypto errors
1100
- */
1101
- export declare enum ErrorType {
1102
- Mls = "Mls",
1103
- Proteus = "Proteus",
1104
- E2ei = "E2ei",
1105
- TransactionFailed = "TransactionFailed",
1106
- Other = "Other"
1107
- }
1108
- export declare function isCcError<E extends ErrorType>(error: unknown, errorType: E): error is CoreCryptoError<E>;
1109
- /**
1110
- * Structured core crypto error
1111
- */
1112
- export interface ErrorContext {
1113
- [ErrorType.Mls]: ErrorTypeWithContext<MlsErrorContext>;
1114
- [ErrorType.Proteus]: ErrorTypeWithContext<ProteusErrorContext>;
1115
- [ErrorType.E2ei]: {
1116
- e2eiError: string;
1117
- };
1118
- [ErrorType.TransactionFailed]: {
1119
- error: string;
1120
- };
1121
- [ErrorType.Other]: {
1122
- msg: string;
1123
- };
1124
- }
1125
- export declare function isE2eiError(error: unknown): error is CoreCryptoError<ErrorType.E2ei>;
1126
- export declare function isTransactionFailedError(error: unknown): error is CoreCryptoError<ErrorType.TransactionFailed>;
1127
- export declare function isOtherError(error: unknown): error is CoreCryptoError<ErrorType.Other>;
1128
- /**
1129
- * Variants of core crypto mls errors
1130
- */
1131
- export declare enum MlsErrorType {
1132
- ConversationAlreadyExists = "ConversationAlreadyExists",
1133
- DuplicateMessage = "DuplicateMessage",
1134
- BufferedFutureMessage = "BufferedFutureMessage",
1135
- WrongEpoch = "WrongEpoch",
1136
- BufferedCommit = "BufferedCommit",
1137
- MessageEpochTooOld = "MessageEpochTooOld",
1138
- SelfCommitIgnored = "SelfCommitIgnored",
1139
- UnmergedPendingGroup = "UnmergedPendingGroup",
1140
- StaleProposal = "StaleProposal",
1141
- StaleCommit = "StaleCommit",
1142
- /**
1143
- * This happens when the DS cannot flag KeyPackages as claimed or not. In this scenario, a client
1144
- * requests their old KeyPackages to be deleted but one has already been claimed by another client to create a Welcome.
1145
- * In that case the only solution is that the client receiving such a Welcome tries to join the group
1146
- * with an External Commit instead
1147
- */
1148
- OrphanWelcome = "OrphanWelcome",
1149
- MessageRejected = "MessageRejected",
1150
- Other = "Other"
1151
- }
1152
- /**
1153
- * Structured core crypto mls error (embedded in a core crypto error)
1154
- */
1155
- export interface MlsErrorContext {
1156
- [MlsErrorType.ConversationAlreadyExists]: {
1157
- conversationId: Array<number>;
1158
- };
1159
- [MlsErrorType.DuplicateMessage]: Record<string, never>;
1160
- [MlsErrorType.BufferedFutureMessage]: Record<string, never>;
1161
- [MlsErrorType.WrongEpoch]: Record<string, never>;
1162
- [MlsErrorType.BufferedCommit]: Record<string, never>;
1163
- [MlsErrorType.MessageEpochTooOld]: Record<string, never>;
1164
- [MlsErrorType.SelfCommitIgnored]: Record<string, never>;
1165
- [MlsErrorType.UnmergedPendingGroup]: Record<string, never>;
1166
- [MlsErrorType.StaleProposal]: Record<string, never>;
1167
- [MlsErrorType.StaleCommit]: Record<string, never>;
1168
- [MlsErrorType.OrphanWelcome]: Record<string, never>;
1169
- [MlsErrorType.MessageRejected]: {
1170
- reason: string;
1171
- };
1172
- [MlsErrorType.Other]: {
1173
- msg: string;
1174
- };
1175
- }
1176
- export declare function isMlsError<E extends MlsErrorType>(error: unknown, errorType: E): error is CoreCryptoError<ErrorType.Mls> & {
1177
- context: Extract<ErrorContext[ErrorType.Mls], {
1178
- type: E;
1179
- }>;
1180
- };
1181
- export declare function isMlsConversationAlreadyExistsError(error: unknown): error is CoreCryptoError<ErrorType.Mls> & {
1182
- context: Extract<ErrorContext[ErrorType.Mls], {
1183
- type: MlsErrorType.ConversationAlreadyExists;
1184
- }>;
1185
- };
1186
- export declare function isMlsDuplicateMessageError(error: unknown): error is CoreCryptoError<ErrorType.Mls> & {
1187
- context: Extract<ErrorContext[ErrorType.Mls], {
1188
- type: MlsErrorType.DuplicateMessage;
1189
- }>;
1190
- };
1191
- export declare function isMlsBufferedFutureMessageError(error: unknown): error is CoreCryptoError<ErrorType.Mls> & {
1192
- context: Extract<ErrorContext[ErrorType.Mls], {
1193
- type: MlsErrorType.BufferedFutureMessage;
1194
- }>;
1195
- };
1196
- export declare function isMlsWrongEpochError(error: unknown): error is CoreCryptoError<ErrorType.Mls> & {
1197
- context: Extract<ErrorContext[ErrorType.Mls], {
1198
- type: MlsErrorType.WrongEpoch;
1199
- }>;
1200
- };
1201
- export declare function isMlsBufferedCommitError(error: unknown): error is CoreCryptoError<ErrorType.Mls> & {
1202
- context: Extract<ErrorContext[ErrorType.Mls], {
1203
- type: MlsErrorType.BufferedCommit;
1204
- }>;
1205
- };
1206
- export declare function isMlsSelfCommitIgnoredError(error: unknown): error is CoreCryptoError<ErrorType.Mls> & {
1207
- context: Extract<ErrorContext[ErrorType.Mls], {
1208
- type: MlsErrorType.SelfCommitIgnored;
1209
- }>;
1210
- };
1211
- export declare function isMlsUnmergedPendingGroupError(error: unknown): error is CoreCryptoError<ErrorType.Mls> & {
1212
- context: Extract<ErrorContext[ErrorType.Mls], {
1213
- type: MlsErrorType.UnmergedPendingGroup;
1214
- }>;
1215
- };
1216
- export declare function isMlsStaleProposalError(error: unknown): error is CoreCryptoError<ErrorType.Mls> & {
1217
- context: Extract<ErrorContext[ErrorType.Mls], {
1218
- type: MlsErrorType.StaleProposal;
1219
- }>;
1220
- };
1221
- export declare function isMlsStaleCommitError(error: unknown): error is CoreCryptoError<ErrorType.Mls> & {
1222
- context: Extract<ErrorContext[ErrorType.Mls], {
1223
- type: MlsErrorType.StaleCommit;
1224
- }>;
1225
- };
1226
- export declare function isMlsOrphanWelcomeError(error: unknown): error is CoreCryptoError<ErrorType.Mls> & {
1227
- context: Extract<ErrorContext[ErrorType.Mls], {
1228
- type: MlsErrorType.OrphanWelcome;
1229
- }>;
1230
- };
1231
- export declare function isMlsMessageRejectedError(error: unknown): error is CoreCryptoError<ErrorType.Mls> & {
1232
- context: Extract<ErrorContext[ErrorType.Mls], {
1233
- type: MlsErrorType.MessageRejected;
1234
- }>;
1235
- };
1236
- export declare function isMlsOtherError(error: unknown): error is CoreCryptoError<ErrorType.Mls> & {
1237
- context: Extract<ErrorContext[ErrorType.Mls], {
1238
- type: MlsErrorType.Other;
1239
- }>;
1240
- };
1241
- /**
1242
- * Variants of core crypto proteus errors
1243
- */
1244
- export declare enum ProteusErrorType {
1245
- SessionNotFound = "SessionNotFound",
1246
- DuplicateMessage = "DuplicateMessage",
1247
- RemoteIdentityChanged = "RemoteIdentityChanged",
1248
- Other = "Other"
1249
- }
1250
- /**
1251
- * Structured core crypto proteus error (embedded in a core crypto error)
1252
- */
1253
- export interface ProteusErrorContext {
1254
- [ProteusErrorType.SessionNotFound]: {
1255
- errorCode: number;
1256
- };
1257
- [ProteusErrorType.DuplicateMessage]: {
1258
- errorCode: number;
1259
- };
1260
- [ProteusErrorType.RemoteIdentityChanged]: {
1261
- errorCode: number;
1262
- };
1263
- [ProteusErrorType.Other]: {
1264
- errorCode: number;
1265
- };
1266
- }
1267
- export declare function isProteusError<E extends ProteusErrorType>(error: unknown, errorType: E): error is CoreCryptoError<ErrorType.Proteus> & {
1268
- context: Extract<ErrorContext[ErrorType.Proteus], {
1269
- type: E;
1270
- }>;
1271
- };
1272
- export declare function isProteusSessionNotFoundError(error: unknown): error is CoreCryptoError<ErrorType.Proteus> & {
1273
- context: Extract<ErrorContext[ErrorType.Proteus], {
1274
- type: ProteusErrorType.SessionNotFound;
1275
- }>;
1276
- };
1277
- export declare function isProteusDuplicateMessageError(error: unknown): error is CoreCryptoError<ErrorType.Proteus> & {
1278
- context: Extract<ErrorContext[ErrorType.Proteus], {
1279
- type: ProteusErrorType.DuplicateMessage;
1280
- }>;
1281
- };
1282
- export declare function isProteusRemoteIdentityChangedError(error: unknown): error is CoreCryptoError<ErrorType.Proteus> & {
1283
- context: Extract<ErrorContext[ErrorType.Proteus], {
1284
- type: ProteusErrorType.RemoteIdentityChanged;
1285
- }>;
1286
- };
1287
- export declare function isProteusOtherError(error: unknown): error is CoreCryptoError<ErrorType.Proteus> & {
1288
- context: Extract<ErrorContext[ErrorType.Proteus], {
1289
- type: ProteusErrorType.Other;
1290
- }>;
1291
- };
1292
- /**
1293
- * Alias for proposal reference. It is a byte array of size 16.
1294
- */
1295
- export type ProposalRef = Uint8Array;
1296
- /**
1297
- * A `HistorySecret` encodes sufficient client state that it can be used to instantiate an
1298
- * ephemeral client.
1299
- */
1300
- export interface HistorySecret {
1301
- clientId: ClientId;
1302
- data: Uint8Array;
1303
- }
1304
- /**
1305
- * Data shape for a MLS generic commit + optional bundle (aka stapled commit & welcome)
1306
- */
1307
- export interface CommitBundle {
1308
- /**
1309
- * TLS-serialized MLS Commit that needs to be fanned out to other (existing) members of the conversation
1310
- *
1311
- * @readonly
1312
- */
1313
- commit: Uint8Array;
1314
- /**
1315
- * Optional TLS-serialized MLS Welcome message that needs to be fanned out to the clients newly added to the conversation
1316
- *
1317
- * @readonly
1318
- */
1319
- welcome?: Welcome;
1320
- /**
1321
- * MLS GroupInfo which is required for joining a group by external commit
1322
- *
1323
- * @readonly
1324
- */
1325
- groupInfo: GroupInfoBundle;
1326
- /**
1327
- * An encrypted message to fan out to all other conversation members in the new epoch
1328
- * @readonly
1329
- */
1330
- encryptedMessage?: Uint8Array;
1331
- }
1332
- /**
1333
- * Wraps a GroupInfo in order to efficiently upload it to the Delivery Service.
1334
- * This is not part of MLS protocol but parts might be standardized at some point.
1335
- */
1336
- export interface GroupInfoBundle {
1337
- /**
1338
- * see {@link GroupInfoEncryptionType}
1339
- */
1340
- encryptionType: MlsGroupInfoEncryptionType;
1341
- /**
1342
- * see {@link RatchetTreeType}
1343
- */
1344
- ratchetTreeType: MlsRatchetTreeType;
1345
- /**
1346
- * TLS-serialized GroupInfo
1347
- */
1348
- payload: GroupInfo;
1349
- }
1350
- /**
1351
- * This is a wrapper for all the possible outcomes you can get after decrypting a message
1352
- */
1353
- interface DecryptedMessage$1 {
1354
- /**
1355
- * Raw decrypted application message, if the decrypted MLS message is an application message
1356
- */
1357
- message?: Uint8Array;
1358
- /**
1359
- * It is set to false if ingesting this MLS message has resulted in the client being removed from the group (i.e. a Remove commit)
1360
- */
1361
- isActive: boolean;
1362
- /**
1363
- * Commit delay hint (in milliseconds) to prevent clients from hammering the server with epoch changes
1364
- */
1365
- commitDelay?: number;
1366
- /**
1367
- * Client identifier of the sender of the message being decrypted. Only present for application messages.
1368
- */
1369
- senderClientId?: ClientId;
1370
- /**
1371
- * true when the decrypted message resulted in an epoch change i.e. it was a commit
1372
- */
1373
- hasEpochChanged: boolean;
1374
- /**
1375
- * Identity claims present in the sender credential
1376
- * Only present when the credential is a x509 certificate
1377
- * Present for all messages
1378
- */
1379
- identity?: WireIdentity;
1380
- /**
1381
- * Only set when the decrypted message is a commit.
1382
- * Contains buffered messages for next epoch which were received before the commit creating the epoch
1383
- * because the DS did not fan them out in order.
1384
- */
1385
- bufferedMessages?: BufferedDecryptedMessage$1[];
1386
- /**
1387
- * New CRL distribution points that appeared by the introduction of a new credential
1388
- */
1389
- crlNewDistributionPoints?: string[];
1390
- }
1391
- /**
1392
- * Almost same as {@link DecryptedMessage} but avoids recursion
1393
- */
1394
- interface BufferedDecryptedMessage$1 {
1395
- /**
1396
- * see {@link DecryptedMessage.message}
1397
- */
1398
- message?: Uint8Array;
1399
- /**
1400
- * see {@link DecryptedMessage.isActive}
1401
- */
1402
- isActive: boolean;
1403
- /**
1404
- * see {@link DecryptedMessage.commitDelay}
1405
- */
1406
- commitDelay?: number;
1407
- /**
1408
- * see {@link DecryptedMessage.senderClientId}
1409
- */
1410
- senderClientId?: ClientId;
1411
- /**
1412
- * see {@link DecryptedMessage.hasEpochChanged}
1413
- */
1414
- hasEpochChanged: boolean;
1415
- /**
1416
- * see {@link DecryptedMessage.identity}
1417
- */
1418
- identity?: WireIdentity;
1419
- /**
1420
- * see {@link DecryptedMessage.crlNewDistributionPoints}
1421
- */
1422
- crlNewDistributionPoints?: string[];
1423
- }
1424
- /**
1425
- * Returned by {@link MlsTransport} callbacks.
1426
- */
1427
- export type MlsTransportResponse = "success" | "retry" | {
1428
- /**
1429
- * The message was rejected by the delivery service and there's no recovery.
1430
- */
1431
- abort: {
1432
- reason: string;
1433
- };
1434
- };
1435
- /**
1436
- * An interface that must be implemented and provided to CoreCrypto via
1437
- * {@link CoreCrypto.provideTransport}.
1438
- */
1439
- export interface MlsTransport {
1440
- /**
1441
- * This callback is called by CoreCrypto to send a commit bundle to the delivery service.
1442
- *
1443
- * @param commitBundle - the commit bundle
1444
- * @returns a promise resolving to a {@link MlsTransportResponse}
1445
- */
1446
- sendCommitBundle: (commitBundle: CommitBundle) => Promise<MlsTransportResponse>;
1447
- /**
1448
- * This callback is called by CoreCrypto to send a regular message to the delivery service.
1449
- * @param message
1450
- * @returns a promise resolving to a {@link MlsTransportResponse}
1451
- */
1452
- sendMessage: (message: Uint8Array) => Promise<MlsTransportResponse>;
1453
- /**
1454
- * This callback is called by CoreCrypto to prepare a history secret to be sent to the delivery service.
1455
- * @param secret
1456
- * @returns a promise resolving to a {@link MlsTransportData}
1457
- */
1458
- prepareForTransport: (secret: HistorySecret) => Promise<MlsTransportData>;
1459
- }
1460
- /**
1461
- * Supporting struct for CRL registration result
1462
- */
1463
- export interface CRLRegistration {
1464
- /**
1465
- * Whether this CRL modifies the old CRL (i.e. has a different revocated cert list)
1466
- *
1467
- * @readonly
1468
- */
1469
- dirty: boolean;
1470
- /**
1471
- * Optional expiration timestamp
1472
- *
1473
- * @readonly
1474
- */
1475
- expiration?: number;
1476
- }
1477
- interface AcmeDirectory$1 {
1478
- /**
1479
- * URL for fetching a new nonce. Use this only for creating a new account.
1480
- */
1481
- newNonce: string;
1482
- /**
1483
- * URL for creating a new account.
1484
- */
1485
- newAccount: string;
1486
- /**
1487
- * URL for creating a new order.
1488
- */
1489
- newOrder: string;
1490
- /**
1491
- * Revocation URL
1492
- */
1493
- revokeCert: string;
1494
- }
1495
- /**
1496
- * Returned by APIs whose code paths potentially discover new certificate revocation list distribution URLs.
1497
- */
1498
- export type NewCrlDistributionPoints = string[] | undefined;
1499
- export type JsonRawData = Uint8Array;
1500
- export declare class E2eiEnrollment {
1501
- #private;
1502
- /** @hidden */
1503
- constructor(e2ei: FfiWireE2EIdentity);
1504
- free(): void;
1505
- /**
1506
- * Should only be used internally
1507
- */
1508
- inner(): unknown;
1509
- /**
1510
- * Parses the response from `GET /acme/{provisioner-name}/directory`.
1511
- * Use this {@link AcmeDirectory} in the next step to fetch the first nonce from the acme server. Use
1512
- * {@link AcmeDirectory.newNonce}.
1513
- *
1514
- * @param directory HTTP response body
1515
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.1.1
1516
- */
1517
- directoryResponse(directory: JsonRawData): Promise<AcmeDirectory$1>;
1518
- /**
1519
- * For creating a new acme account. This returns a signed JWS-alike request body to send to
1520
- * `POST /acme/{provisioner-name}/new-account`.
1521
- *
1522
- * @param previousNonce you got from calling `HEAD {@link AcmeDirectory.newNonce}`
1523
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.3
1524
- */
1525
- newAccountRequest(previousNonce: string): Promise<JsonRawData>;
1526
- /**
1527
- * Parses the response from `POST /acme/{provisioner-name}/new-account`.
1528
- * @param account HTTP response body
1529
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.3
1530
- */
1531
- newAccountResponse(account: JsonRawData): Promise<void>;
1532
- /**
1533
- * Creates a new acme order for the handle (userId + display name) and the clientId.
1534
- *
1535
- * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/new-account`
1536
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1537
- */
1538
- newOrderRequest(previousNonce: string): Promise<JsonRawData>;
1539
- /**
1540
- * Parses the response from `POST /acme/{provisioner-name}/new-order`.
1541
- *
1542
- * @param order HTTP response body
1543
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1544
- */
1545
- newOrderResponse(order: JsonRawData): Promise<NewAcmeOrder>;
1546
- /**
1547
- * Creates a new authorization request.
1548
- *
1549
- * @param url one of the URL in new order's authorizations from {@link newOrderResponse})
1550
- * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/new-order` (or from the
1551
- * previous to this method if you are creating the second authorization)
1552
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5
1553
- */
1554
- newAuthzRequest(url: string, previousNonce: string): Promise<JsonRawData>;
1555
- /**
1556
- * Parses the response from `POST /acme/{provisioner-name}/authz/{authz-id}`
1557
- *
1558
- * @param authz HTTP response body
1559
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5
1560
- */
1561
- newAuthzResponse(authz: JsonRawData): Promise<NewAcmeAuthz>;
1562
- /**
1563
- * Generates a new client Dpop JWT token. It demonstrates proof of possession of the nonces
1564
- * (from wire-server & acme server) and will be verified by the acme server when verifying the
1565
- * challenge (in order to deliver a certificate).
1566
- *
1567
- * Then send it to `POST /clients/{id}/access-token`
1568
- * {@link https://staging-nginz-https.zinfra.io/api/swagger-ui/#/default/post_clients__cid__access_token} on wire-server.
1569
- *
1570
- * @param expirySecs of the client Dpop JWT. This should be equal to the grace period set in Team Management
1571
- * @param backendNonce you get by calling `GET /clients/token/nonce` on wire-server as defined here {@link https://staging-nginz-https.zinfra.io/api/swagger-ui/#/default/get_clients__client__nonce}
1572
- */
1573
- createDpopToken(expirySecs: number, backendNonce: string): Promise<Uint8Array>;
1574
- /**
1575
- * Creates a new challenge request for Wire Dpop challenge.
1576
- *
1577
- * @param accessToken returned by wire-server from https://staging-nginz-https.zinfra.io/api/swagger-ui/#/default/post_clients__cid__access_token
1578
- * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/authz/{authz-id}`
1579
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5.1
1580
- */
1581
- newDpopChallengeRequest(accessToken: string, previousNonce: string): Promise<JsonRawData>;
1582
- /**
1583
- * Parses the response from `POST /acme/{provisioner-name}/challenge/{challenge-id}` for the DPoP challenge.
1584
- *
1585
- * @param challenge HTTP response body
1586
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5.1
1587
- */
1588
- newDpopChallengeResponse(challenge: JsonRawData): Promise<void>;
1589
- /**
1590
- * Creates a new challenge request for Wire Oidc challenge.
1591
- *
1592
- * @param idToken you get back from Identity Provider
1593
- * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/authz/{authz-id}`
1594
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5.1
1595
- */
1596
- newOidcChallengeRequest(idToken: string, previousNonce: string): Promise<JsonRawData>;
1597
- /**
1598
- * Parses the response from `POST /acme/{provisioner-name}/challenge/{challenge-id}` for the OIDC challenge.
1599
- *
1600
- * @param challenge HTTP response body
1601
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.5.1
1602
- */
1603
- newOidcChallengeResponse(challenge: JsonRawData): Promise<void>;
1604
- /**
1605
- * Verifies that the previous challenge has been completed.
1606
- *
1607
- * @param orderUrl `location` header from http response you got from {@link newOrderResponse}
1608
- * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/challenge/{challenge-id}`
1609
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1610
- */
1611
- checkOrderRequest(orderUrl: string, previousNonce: string): Promise<JsonRawData>;
1612
- /**
1613
- * Parses the response from `POST /acme/{provisioner-name}/order/{order-id}`.
1614
- *
1615
- * @param order HTTP response body
1616
- * @return finalize url to use with {@link finalizeRequest}
1617
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1618
- */
1619
- checkOrderResponse(order: JsonRawData): Promise<string>;
1620
- /**
1621
- * Final step before fetching the certificate.
1622
- *
1623
- * @param previousNonce - `replay-nonce` response header from `POST /acme/{provisioner-name}/order/{order-id}`
1624
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1625
- */
1626
- finalizeRequest(previousNonce: string): Promise<JsonRawData>;
1627
- /**
1628
- * Parses the response from `POST /acme/{provisioner-name}/order/{order-id}/finalize`.
1629
- *
1630
- * @param finalize HTTP response body
1631
- * @return the certificate url to use with {@link certificateRequest}
1632
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1633
- */
1634
- finalizeResponse(finalize: JsonRawData): Promise<string>;
1635
- /**
1636
- * Creates a request for finally fetching the x509 certificate.
1637
- *
1638
- * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/order/{order-id}/finalize`
1639
- * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4.2
1640
- */
1641
- certificateRequest(previousNonce: string): Promise<JsonRawData>;
1642
- }
1643
- /**
1644
- * Indicates the state of a Conversation regarding end-to-end identity.
1645
- * Note: this does not check pending state (pending commit, pending proposals) so it does not
1646
- * consider members about to be added/removed
1647
- */
1648
- declare enum E2eiConversationState$1 {
1649
- /**
1650
- * All clients have a valid E2EI certificate
1651
- */
1652
- Verified = 1,
1653
- /**
1654
- * Some clients are either still Basic or their certificate is expired
1655
- */
1656
- NotVerified = 2,
1657
- /**
1658
- * All clients are still Basic. If all client have expired certificates, NotVerified is returned.
1659
- */
1660
- NotEnabled = 3
1661
- }
1662
- /**
1663
- * Data shape for proteusNewPrekeyAuto() call returns.
1664
- */
1665
- interface ProteusAutoPrekeyBundle$1 {
1666
- /**
1667
- * Proteus PreKey id
1668
- *
1669
- * @readonly
1670
- */
1671
- id: number;
1672
- /**
1673
- * CBOR-serialized Proteus PreKeyBundle
1674
- *
1675
- * @readonly
1676
- */
1677
- pkb: Uint8Array;
1678
- }
1679
- declare class CoreCryptoContext$1 {
1680
- #private;
1681
- /** @hidden */
1682
- private constructor();
1683
- /** @hidden */
1684
- static fromFfiContext(ctx: CoreCryptoContext): CoreCryptoContext$1;
1685
- /**
1686
- * Set arbitrary data to be retrieved by {@link getData}.
1687
- * This is meant to be used as a check point at the end of a transaction.
1688
- * The data should be limited to a reasonable size.
1689
- */
1690
- setData(data: Uint8Array): Promise<void>;
1691
- /**
1692
- * Get data if it has previously been set by {@link setData}, or `undefined` otherwise.
1693
- * This is meant to be used as a check point at the end of a transaction.
1694
- */
1695
- getData(): Promise<Uint8Array | undefined>;
1696
- /**
1697
- * Use this after {@link CoreCrypto.deferredInit} when you have a clientId. It initializes MLS.
1698
- *
1699
- * @param clientId - {@link CoreCryptoParams#clientId} but required
1700
- * @param ciphersuites - All the ciphersuites supported by this MLS client
1701
- * @param nbKeyPackage - number of initial KeyPackage to create when initializing the client
1702
- */
1703
- mlsInit(clientId: ClientId, ciphersuites: Ciphersuite[], nbKeyPackage?: number): Promise<void>;
1704
- /**
1705
- * Checks if the Client is member of a given conversation and if the MLS Group is loaded up
1706
- *
1707
- * @returns Whether the given conversation ID exists
1708
- *
1709
- * @example
1710
- * ```ts
1711
- * const cc = await CoreCrypto.init({ databaseName: "test", key: "test", clientId: "test" });
1712
- * const encoder = new TextEncoder();
1713
- * if (await cc.conversationExists(encoder.encode("my super chat"))) {
1714
- * // Do something
1715
- * } else {
1716
- * // Do something else
1717
- * }
1718
- * ```
1719
- */
1720
- conversationExists(conversationId: ConversationId): Promise<boolean>;
1721
- /**
1722
- * Marks a conversation as child of another one
1723
- * This will mostly affect the behavior of the callbacks (the parentConversationClients parameter will be filled)
1724
- *
1725
- * @param childId - conversation identifier of the child conversation
1726
- * @param parentId - conversation identifier of the parent conversation
1727
- */
1728
- markConversationAsChildOf(childId: ConversationId, parentId: ConversationId): Promise<void>;
1729
- /**
1730
- * Returns the current epoch of a conversation
1731
- *
1732
- * @returns the epoch of the conversation
1733
- *
1734
- * @example
1735
- * ```ts
1736
- * const cc = await CoreCrypto.init({ databaseName: "test", key: "test", clientId: "test" });
1737
- * const encoder = new TextEncoder();
1738
- * console.log(await cc.conversationEpoch(encoder.encode("my super chat")))
1739
- * ```
1740
- */
1741
- conversationEpoch(conversationId: ConversationId): Promise<number>;
1742
- /**
1743
- * Returns the ciphersuite of a conversation
1744
- *
1745
- * @returns the ciphersuite of the conversation
1746
- */
1747
- conversationCiphersuite(conversationId: ConversationId): Promise<Ciphersuite>;
1748
- /**
1749
- * Wipes and destroys the local storage of a given conversation / MLS group
1750
- *
1751
- * @param conversationId - The ID of the conversation to remove
1752
- */
1753
- wipeConversation(conversationId: ConversationId): Promise<void>;
1754
- /**
1755
- * Creates a new conversation with the current client being the sole member
1756
- * You will want to use {@link addClientsToConversation} afterwards to add clients to this conversation
1757
- *
1758
- * @param conversationId - The conversation ID; You can either make them random or let the backend attribute MLS group IDs
1759
- * @param creatorCredentialType - kind of credential the creator wants to create the group with
1760
- * @param configuration - configuration of the MLS group
1761
- * @param configuration.ciphersuite - The {@link Ciphersuite} that is chosen to be the group's
1762
- * @param configuration.externalSenders - Array of Client IDs that are qualified as external senders within the group
1763
- */
1764
- createConversation(conversationId: ConversationId, creatorCredentialType: CredentialType, configuration?: ConversationConfiguration$1): Promise<void>;
1765
- /**
1766
- * Decrypts a message for a given conversation.
1767
- *
1768
- * Note: you should catch & ignore the following error reasons:
1769
- * * "We already decrypted this message once"
1770
- * * "You tried to join with an external commit but did not merge it yet. We will reapply this message for you when you merge your external commit"
1771
- * * "Incoming message is for a future epoch. We will buffer it until the commit for that epoch arrives"
1772
- *
1773
- * @param conversationId - The ID of the conversation
1774
- * @param payload - The encrypted message buffer
1775
- *
1776
- * @returns a {@link DecryptedMessage}. Note that {@link DecryptedMessage#message} is `undefined` when the encrypted payload contains a system message such a proposal or commit
1777
- */
1778
- decryptMessage(conversationId: ConversationId, payload: Uint8Array): Promise<DecryptedMessage$1>;
1779
- /**
1780
- * Encrypts a message for a given conversation
1781
- *
1782
- * @param conversationId - The ID of the conversation
1783
- * @param message - The plaintext message to encrypt
1784
- *
1785
- * @returns The encrypted payload for the given group. This needs to be fanned out to the other members of the group.
1786
- */
1787
- encryptMessage(conversationId: ConversationId, message: Uint8Array): Promise<Uint8Array>;
1788
- /**
1789
- * Ingest a TLS-serialized MLS welcome message to join an existing MLS group
1790
- *
1791
- * You have to catch the error with this reason "Although this Welcome seems valid, the local KeyPackage
1792
- * it references has already been deleted locally. Join this group with an external commit", ignore it and then
1793
- * join this group via {@link CoreCryptoContext.joinByExternalCommit}.
1794
- *
1795
- * @param welcomeMessage - TLS-serialized MLS Welcome message
1796
- * @param configuration - configuration of the MLS group
1797
- * @returns The conversation ID of the newly joined group. You can use the same ID to decrypt/encrypt messages
1798
- */
1799
- processWelcomeMessage(welcomeMessage: Welcome, configuration?: Partial<CustomConfiguration>): Promise<WelcomeBundle>;
1800
- /**
1801
- * Get the client's public signature key. To upload to the DS for further backend side validation
1802
- *
1803
- * @param ciphersuite - of the signature key to get
1804
- * @param credentialType - of the public key to look for
1805
- * @returns the client's public signature key
1806
- */
1807
- clientPublicKey(ciphersuite: Ciphersuite, credentialType: CredentialType): Promise<Uint8Array>;
1808
- /**
1809
- *
1810
- * @param ciphersuite - of the KeyPackages to count
1811
- * @param credentialType - of the KeyPackages to count
1812
- * @returns The amount of valid, non-expired KeyPackages that are persisted in the backing storage
1813
- */
1814
- clientValidKeypackagesCount(ciphersuite: Ciphersuite, credentialType: CredentialType): Promise<number>;
1815
- /**
1816
- * Fetches a requested amount of keypackages
1817
- *
1818
- * @param ciphersuite - of the KeyPackages to generate
1819
- * @param credentialType - of the KeyPackages to generate
1820
- * @param amountRequested - The amount of keypackages requested
1821
- * @returns An array of length `amountRequested` containing TLS-serialized KeyPackages
1822
- */
1823
- clientKeypackages(ciphersuite: Ciphersuite, credentialType: CredentialType, amountRequested: number): Promise<Array<Uint8Array>>;
1824
- /**
1825
- * Adds new clients to a conversation, assuming the current client has the right to add new clients to the conversation.
1826
- *
1827
- * Sends the corresponding commit via {@link MlsTransport.sendCommitBundle} and merges it if the call is successful.
1828
- *
1829
- * @param conversationId - The ID of the conversation
1830
- * @param keyPackages - KeyPackages of the new clients to add
1831
- *
1832
- * @returns Potentially a list of newly discovered crl distribution points
1833
- */
1834
- addClientsToConversation(conversationId: ConversationId, keyPackages: Uint8Array[]): Promise<NewCrlDistributionPoints>;
1835
- /**
1836
- * Removes the provided clients from a conversation; Assuming those clients exist and the current client is allowed
1837
- * to do so, otherwise this operation does nothing.
1838
- *
1839
- * @param conversationId - The ID of the conversation
1840
- * @param clientIds - Array of Client IDs to remove.
1841
- */
1842
- removeClientsFromConversation(conversationId: ConversationId, clientIds: ClientId[]): Promise<void>;
1843
- /**
1844
- * Update the keying material of the conversation.
1845
- *
1846
- * @param conversationId - The ID of the conversation
1847
- */
1848
- updateKeyingMaterial(conversationId: ConversationId): Promise<void>;
1849
- /**
1850
- * Commits the local pending proposals.
1851
- *
1852
- * Sends the corresponding commit via {@link MlsTransport.sendCommitBundle}
1853
- * and merges it if the call is successful.
1854
- *
1855
- * @param conversationId - The ID of the conversation
1856
- */
1857
- commitPendingProposals(conversationId: ConversationId): Promise<void>;
1858
- /**
1859
- * "Apply" to join a group through its GroupInfo.
1860
- *
1861
- * Sends the corresponding commit via {@link MlsTransport.sendCommitBundle}
1862
- * and creates the group if the call is successful.
1863
- *
1864
- * @param groupInfo - a TLS encoded GroupInfo fetched from the Delivery Service
1865
- * @param credentialType - kind of Credential to use for joining this group. If {@link CredentialType.Basic} is
1866
- * chosen and no Credential has been created yet for it, a new one will be generated.
1867
- * @param configuration - configuration of the MLS group
1868
- * When {@link CredentialType.X509} is chosen, it fails when no Credential has been created for the given {@link Ciphersuite}.
1869
- *
1870
- * @return see {@link WelcomeBundle}
1871
- */
1872
- joinByExternalCommit(groupInfo: GroupInfo, credentialType: CredentialType, configuration?: Partial<CustomConfiguration>): Promise<WelcomeBundle>;
1873
- /**
1874
- * Enable history sharing by generating a history client and adding it to the conversation.
1875
- */
1876
- enableHistorySharing(conversationId: ConversationId): Promise<void>;
1877
- /**
1878
- * Disable history sharing by removing histroy clients from the conversation.
1879
- */
1880
- disableHistorySharing(conversationId: ConversationId): Promise<void>;
1881
- /**
1882
- * Derives a new key from the group
1883
- *
1884
- * @param conversationId - The group's ID
1885
- * @param keyLength - the length of the key to be derived. If the value is higher than the
1886
- * bounds of `u16` or the context hash * 255, an error will be returned
1887
- *
1888
- * @returns A `Uint8Array` representing the derived key
1889
- */
1890
- exportSecretKey(conversationId: ConversationId, keyLength: number): Promise<SecretKey>;
1891
- /**
1892
- * Returns the raw public key of the single external sender present in this group.
1893
- * This should be used to initialize a subconversation
1894
- *
1895
- * @param conversationId - The group's ID
1896
- *
1897
- * @returns A `Uint8Array` representing the external sender raw public key
1898
- */
1899
- getExternalSender(conversationId: ConversationId): Promise<ExternalSenderKey>;
1900
- /**
1901
- * Returns all clients from group's members
1902
- *
1903
- * @param conversationId - The group's ID
1904
- *
1905
- * @returns A list of clients from the members of the group
1906
- */
1907
- getClientIds(conversationId: ConversationId): Promise<ClientId[]>;
1908
- /**
1909
- * Allows {@link CoreCryptoContext} to act as a CSPRNG provider
1910
- *
1911
- * The underlying CSPRNG algorithm is ChaCha20 and takes in account the external seed provider.
1912
- *
1913
- * @param length - The number of bytes to be returned in the `Uint8Array`
1914
- *
1915
- * @returns A `Uint8Array` buffer that contains `length` cryptographically-secure random bytes
1916
- */
1917
- randomBytes(length: number): Promise<Uint8Array>;
1918
- /**
1919
- * Initializes the proteus client
1920
- */
1921
- proteusInit(): Promise<void>;
1922
- /**
1923
- * Create a Proteus session using a prekey
1924
- *
1925
- * @param sessionId - ID of the Proteus session
1926
- * @param prekey - CBOR-encoded Proteus prekey of the other client
1927
- */
1928
- proteusSessionFromPrekey(sessionId: string, prekey: Uint8Array): Promise<void>;
1929
- /**
1930
- * Create a Proteus session from a handshake message
1931
- *
1932
- * @param sessionId - ID of the Proteus session
1933
- * @param envelope - CBOR-encoded Proteus message
1934
- *
1935
- * @returns A `Uint8Array` containing the message that was sent along with the session handshake
1936
- */
1937
- proteusSessionFromMessage(sessionId: string, envelope: Uint8Array): Promise<Uint8Array>;
1938
- /**
1939
- * Locally persists a session to the keystore
1940
- *
1941
- * **Note**: This isn't usually needed as persisting sessions happens automatically when decrypting/encrypting messages and initializing Sessions
1942
- *
1943
- * @param sessionId - ID of the Proteus session
1944
- */
1945
- proteusSessionSave(sessionId: string): Promise<void>;
1946
- /**
1947
- * Deletes a session
1948
- * Note: this also deletes the persisted data within the keystore
1949
- *
1950
- * @param sessionId - ID of the Proteus session
1951
- */
1952
- proteusSessionDelete(sessionId: string): Promise<void>;
1953
- /**
1954
- * Checks if a session exists
1955
- *
1956
- * @param sessionId - ID of the Proteus session
1957
- *
1958
- * @returns whether the session exists or not
1959
- */
1960
- proteusSessionExists(sessionId: string): Promise<boolean>;
1961
- /**
1962
- * Decrypt an incoming message for an existing Proteus session
1963
- *
1964
- * @param sessionId - ID of the Proteus session
1965
- * @param ciphertext - CBOR encoded, encrypted proteus message
1966
- * @returns The decrypted payload contained within the message
1967
- */
1968
- proteusDecrypt(sessionId: string, ciphertext: Uint8Array): Promise<Uint8Array>;
1969
- /**
1970
- * Encrypt a message for a given Proteus session
1971
- *
1972
- * @param sessionId - ID of the Proteus session
1973
- * @param plaintext - payload to encrypt
1974
- * @returns The CBOR-serialized encrypted message
1975
- */
1976
- proteusEncrypt(sessionId: string, plaintext: Uint8Array): Promise<Uint8Array>;
1977
- /**
1978
- * Batch encryption for proteus messages
1979
- * This is used to minimize FFI roundtrips when used in the context of a multi-client session (i.e. conversation)
1980
- *
1981
- * @param sessions - List of Proteus session IDs to encrypt the message for
1982
- * @param plaintext - payload to encrypt
1983
- * @returns A map indexed by each session ID and the corresponding CBOR-serialized encrypted message for this session
1984
- */
1985
- proteusEncryptBatched(sessions: string[], plaintext: Uint8Array): Promise<Map<string, Uint8Array>>;
1986
- /**
1987
- * Creates a new prekey with the requested ID.
1988
- *
1989
- * @param prekeyId - ID of the PreKey to generate. This cannot be bigger than a u16
1990
- * @returns: A CBOR-serialized version of the PreKeyBundle corresponding to the newly generated and stored PreKey
1991
- */
1992
- proteusNewPrekey(prekeyId: number): Promise<Uint8Array>;
1993
- /**
1994
- * Creates a new prekey with an automatically generated ID..
1995
- *
1996
- * @returns A CBOR-serialized version of the PreKeyBundle corresponding to the newly generated and stored PreKey accompanied by its ID
1997
- */
1998
- proteusNewPrekeyAuto(): Promise<ProteusAutoPrekeyBundle$1>;
1999
- /**
2000
- * Proteus last resort prekey stuff
2001
- *
2002
- * @returns A CBOR-serialize version of the PreKeyBundle associated with the last resort PreKey (holding the last resort prekey id)
2003
- */
2004
- proteusLastResortPrekey(): Promise<Uint8Array>;
2005
- /**
2006
- * @returns The last resort PreKey id
2007
- */
2008
- static proteusLastResortPrekeyId(): number;
2009
- /**
2010
- * Proteus public key fingerprint
2011
- * It's basically the public key encoded as an hex string
2012
- *
2013
- * @returns Hex-encoded public key string
2014
- */
2015
- proteusFingerprint(): Promise<string>;
2016
- /**
2017
- * Proteus session local fingerprint
2018
- *
2019
- * @param sessionId - ID of the Proteus session
2020
- * @returns Hex-encoded public key string
2021
- */
2022
- proteusFingerprintLocal(sessionId: string): Promise<string>;
2023
- /**
2024
- * Proteus session remote fingerprint
2025
- *
2026
- * @param sessionId - ID of the Proteus session
2027
- * @returns Hex-encoded public key string
2028
- */
2029
- proteusFingerprintRemote(sessionId: string): Promise<string>;
2030
- /**
2031
- * Hex-encoded fingerprint of the given prekey
2032
- *
2033
- * @param prekey - the prekey bundle to get the fingerprint from
2034
- * @returns Hex-encoded public key string
2035
- **/
2036
- static proteusFingerprintPrekeybundle(prekey: Uint8Array): string;
2037
- /**
2038
- * Creates an enrollment instance with private key material you can use in order to fetch
2039
- * a new x509 certificate from the acme server.
2040
- *
2041
- * @param clientId - client identifier e.g. `b7ac11a4-8f01-4527-af88-1c30885a7931:6add501bacd1d90e@example.com`
2042
- * @param displayName - human-readable name displayed in the application e.g. `Smith, Alice M (QA)`
2043
- * @param handle - user handle e.g. `alice.smith.qa@example.com`
2044
- * @param expirySec - generated x509 certificate expiry
2045
- * @param ciphersuite - for generating signing key material
2046
- * @param team - name of the Wire team a user belongs to
2047
- * @returns The new {@link E2eiEnrollment} enrollment instance to use with {@link CoreCryptoContext.e2eiMlsInitOnly}
2048
- */
2049
- e2eiNewEnrollment(clientId: string, displayName: string, handle: string, expirySec: number, ciphersuite: Ciphersuite, team?: string): Promise<E2eiEnrollment>;
2050
- /**
2051
- * Generates an E2EI enrollment instance for a "regular" client (with a Basic credential) willing to migrate to E2EI.
2052
- * Once the enrollment is finished, use {@link CoreCryptoContext.e2eiRotate} to do key rotation.
2053
- *
2054
- * @param displayName - human-readable name displayed in the application e.g. `Smith, Alice M (QA)`
2055
- * @param handle - user handle e.g. `alice.smith.qa@example.com`
2056
- * @param expirySec - generated x509 certificate expiry
2057
- * @param ciphersuite - for generating signing key material
2058
- * @param team - name of the Wire team a user belongs to
2059
- * @returns The new {@link E2eiEnrollment} enrollment instance to use with {@link CoreCryptoContext.e2eiRotate}
2060
- */
2061
- e2eiNewActivationEnrollment(displayName: string, handle: string, expirySec: number, ciphersuite: Ciphersuite, team?: string): Promise<E2eiEnrollment>;
2062
- /**
2063
- * Generates an E2EI enrollment instance for a E2EI client (with a X509 certificate credential)
2064
- * having to change/rotate their credential, either because the former one is expired or it
2065
- * has been revoked. It lets you change the DisplayName or the handle
2066
- * if you need to. Once the enrollment is finished, use {@link CoreCryptoContext.e2eiRotate}
2067
- * to do key rotation.
2068
- *
2069
- * @param expirySec - generated x509 certificate expiry
2070
- * @param ciphersuite - for generating signing key material
2071
- * @param displayName - human-readable name displayed in the application e.g. `Smith, Alice M (QA)`
2072
- * @param handle - user handle e.g. `alice.smith.qa@example.com`
2073
- * @param team - name of the Wire team a user belongs to
2074
- * @returns The new {@link E2eiEnrollment} enrollment instance to use with {@link CoreCryptoContext.e2eiRotate}
2075
- */
2076
- e2eiNewRotateEnrollment(expirySec: number, ciphersuite: Ciphersuite, displayName?: string, handle?: string, team?: string): Promise<E2eiEnrollment>;
2077
- /**
2078
- * Use this method to initialize end-to-end identity when a client signs up and the grace period is already expired ;
2079
- * that means he cannot initialize with a Basic credential
2080
- *
2081
- * @param enrollment - the enrollment instance used to fetch the certificates
2082
- * @param certificateChain - the raw response from ACME server
2083
- * @param nbKeyPackage - number of initial KeyPackage to create when initializing the client
2084
- * @returns a MlsClient initialized with only a x509 credential
2085
- */
2086
- e2eiMlsInitOnly(enrollment: E2eiEnrollment, certificateChain: string, nbKeyPackage?: number): Promise<NewCrlDistributionPoints>;
2087
- /**
2088
- * @returns whether the E2EI PKI environment is setup (i.e. Root CA, Intermediates, CRLs)
2089
- */
2090
- e2eiIsPKIEnvSetup(): Promise<boolean>;
2091
- /**
2092
- * Registers a Root Trust Anchor CA for the use in E2EI processing.
2093
- *
2094
- * Please note that without a Root Trust Anchor, all validations *will* fail;
2095
- * So this is the first step to perform after initializing your E2EI client
2096
- *
2097
- * @param trustAnchorPEM - PEM certificate to anchor as a Trust Root
2098
- */
2099
- e2eiRegisterAcmeCA(trustAnchorPEM: string): Promise<void>;
2100
- /**
2101
- * Registers an Intermediate CA for the use in E2EI processing.
2102
- *
2103
- * Please note that a Root Trust Anchor CA is needed to validate Intermediate CAs;
2104
- * You **need** to have a Root CA registered before calling this
2105
- *
2106
- * @param certPEM - PEM certificate to register as an Intermediate CA
2107
- */
2108
- e2eiRegisterIntermediateCA(certPEM: string): Promise<NewCrlDistributionPoints>;
2109
- /**
2110
- * Registers a CRL for the use in E2EI processing.
2111
- *
2112
- * Please note that a Root Trust Anchor CA is needed to validate CRLs;
2113
- * You **need** to have a Root CA registered before calling this
2114
- *
2115
- * @param crlDP - CRL Distribution Point; Basically the URL you fetched it from
2116
- * @param crlDER - DER representation of the CRL
2117
- *
2118
- * @returns a {@link CRLRegistration} with the dirty state of the new CRL (see struct) and its expiration timestamp
2119
- */
2120
- e2eiRegisterCRL(crlDP: string, crlDER: Uint8Array): Promise<CRLRegistration>;
2121
- /**
2122
- * Creates an update commit which replaces your leaf containing basic credentials with a leaf node containing x509 credentials in the conversation.
2123
- *
2124
- * NOTE: you can only call this after you've completed the enrollment for an end-to-end identity, and saved the
2125
- * resulting credential with {@link CoreCryptoContext.saveX509Credential}.
2126
- * Calling this without a valid end-to-end identity will result in an error.
2127
- *
2128
- * Sends the corresponding commit via {@link MlsTransport.sendCommitBundle} and merges it if the call is successful.
2129
- *
2130
- * @param conversationId - The ID of the conversation
2131
- */
2132
- e2eiRotate(conversationId: ConversationId): Promise<void>;
2133
- /**
2134
- * Saves a new X509 credential. Requires first
2135
- * having enrolled a new X509 certificate with either {@link CoreCryptoContext.e2eiNewActivationEnrollment}
2136
- * or {@link CoreCryptoContext.e2eiNewRotateEnrollment}
2137
- *
2138
- * # Expected actions to perform after this function (in this order)
2139
- * 1. Rotate credentials for each conversation using {@link CoreCryptoContext.e2eiRotate}
2140
- * 2. Generate new key packages with {@link CoreCryptoContext.clientKeypackages}
2141
- * 3. Use these to replace the stale ones the in the backend
2142
- * 4. Delete the stale ones locally using {@link CoreCryptoContext.deleteStaleKeyPackages}
2143
- * * This is the last step because you might still need the old key packages to avoid
2144
- * an orphan welcome message
2145
- *
2146
- * @param enrollment - the enrollment instance used to fetch the certificates
2147
- * @param certificateChain - the raw response from ACME server
2148
- * @returns Potentially a list of new crl distribution points discovered in the certificate chain
2149
- */
2150
- saveX509Credential(enrollment: E2eiEnrollment, certificateChain: string): Promise<NewCrlDistributionPoints>;
2151
- /**
2152
- * Deletes all key packages whose credential does not match the most recently
2153
- * saved x509 credential and the provided signature scheme.
2154
- * @param ciphersuite
2155
- */
2156
- deleteStaleKeyPackages(ciphersuite: Ciphersuite): Promise<void>;
2157
- /**
2158
- * Allows persisting an active enrollment (for example while redirecting the user during OAuth) in order to resume
2159
- * it later with {@link e2eiEnrollmentStashPop}
2160
- *
2161
- * @param enrollment the enrollment instance to persist
2162
- * @returns a handle to fetch the enrollment later with {@link e2eiEnrollmentStashPop}
2163
- */
2164
- e2eiEnrollmentStash(enrollment: E2eiEnrollment): Promise<Uint8Array>;
2165
- /**
2166
- * Fetches the persisted enrollment and deletes it from the keystore
2167
- *
2168
- * @param handle returned by {@link e2eiEnrollmentStash}
2169
- * @returns the persisted enrollment instance
2170
- */
2171
- e2eiEnrollmentStashPop(handle: Uint8Array): Promise<E2eiEnrollment>;
2172
- /**
2173
- * Indicates when to mark a conversation as not verified i.e. when not all its members have a X509.
2174
- * Credential generated by Wire's end-to-end identity enrollment
2175
- *
2176
- * @param conversationId The group's ID
2177
- * @returns the conversation state given current members
2178
- */
2179
- e2eiConversationState(conversationId: ConversationId): Promise<E2eiConversationState$1>;
2180
- /**
2181
- * Returns true when end-to-end-identity is enabled for the given Ciphersuite
2182
- *
2183
- * @param ciphersuite of the credential to check
2184
- * @returns true if end-to-end identity is enabled for the given ciphersuite
2185
- */
2186
- e2eiIsEnabled(ciphersuite: Ciphersuite): Promise<boolean>;
2187
- /**
2188
- * From a given conversation, get the identity of the members supplied. Identity is only present for members with a
2189
- * Certificate Credential (after turning on end-to-end identity).
2190
- *
2191
- * @param conversationId - identifier of the conversation
2192
- * @param deviceIds - identifiers of the devices
2193
- * @returns identities or if no member has a x509 certificate, it will return an empty List
2194
- */
2195
- getDeviceIdentities(conversationId: ConversationId, deviceIds: ClientId[]): Promise<WireIdentity[]>;
2196
- /**
2197
- * From a given conversation, get the identity of the users (device holders) supplied.
2198
- * Identity is only present for devices with a Certificate Credential (after turning on end-to-end identity).
2199
- * If no member has a x509 certificate, it will return an empty Vec.
2200
- *
2201
- * @param conversationId - identifier of the conversation
2202
- * @param userIds - user identifiers hyphenated UUIDv4 e.g. 'bd4c7053-1c5a-4020-9559-cd7bf7961954'
2203
- * @returns a Map with all the identities for a given users. Consumers are then recommended to reduce those identities to determine the actual status of a user.
2204
- */
2205
- getUserIdentities(conversationId: ConversationId, userIds: string[]): Promise<Map<string, WireIdentity[]>>;
2206
- }
2207
- /**
2208
- * Params for CoreCrypto deferred initialization
2209
- * Please note that the `entropySeed` parameter MUST be exactly 32 bytes
2210
- */
2211
- export interface CoreCryptoDeferredParams {
2212
- /**
2213
- * Name of the IndexedDB database
2214
- */
2215
- databaseName: string;
2216
- /**
2217
- * Encryption master key
2218
- * This should be appropriately stored in a secure location (i.e. WebCrypto private key storage)
2219
- */
2220
- key: DatabaseKey;
2221
- /**
2222
- * External PRNG entropy pool seed.
2223
- * This **must** be exactly 32 bytes
2224
- */
2225
- entropySeed?: Uint8Array;
2226
- }
2227
- /**
2228
- * Params for CoreCrypto initialization
2229
- * Please note that the `entropySeed` parameter MUST be exactly 32 bytes
2230
- */
2231
- export interface CoreCryptoParams extends CoreCryptoDeferredParams {
2232
- /**
2233
- * MLS Client ID.
2234
- * This should stay consistent as it will be verified against the stored signature & identity to validate the persisted credential
2235
- */
2236
- clientId: ClientId;
2237
- /**
2238
- * All the ciphersuites this MLS client can support
2239
- */
2240
- ciphersuites: Ciphersuite[];
2241
- /**
2242
- * Number of initial KeyPackage to create when initializing the client
2243
- */
2244
- nbKeyPackage?: number;
2245
- }
2246
- export interface EpochObserver {
2247
- epochChanged(conversationId: ConversationId, epoch: number): Promise<void>;
2248
- }
2249
- export interface HistoryObserver {
2250
- historyClientCreated(conversationId: ConversationId, secret: HistorySecret): Promise<void>;
2251
- }
2252
- /**
2253
- * Initializes the global logger for Core Crypto and registers the callback.
2254
- *
2255
- * **NOTE:** you must call this after `await CoreCrypto.init(params)` or `await CoreCrypto.deferredInit(params)`.
2256
- *
2257
- * @param logger - the interface to be called when something is going to be logged
2258
- **/
2259
- export declare function setLogger(logger: CoreCryptoLogger): void;
2260
- /**
2261
- * An interface to register a logger in CoreCrypto
2262
- **/
2263
- export interface CoreCryptoLogger {
2264
- /**
2265
- * This method will be called by Core Crypto to log messages. It is up to the implementer to decide how to handle the message and where to actually log it.
2266
- * @param level - the level of the logged message. it will also be present in the json message
2267
- * @param message - log message
2268
- * @param context - additional context captured when the log was made.
2269
- **/
2270
- log: (level: CoreCryptoLogLevel, message: string, context: string) => void;
2271
- }
2272
- /**
2273
- * Defines the maximum log level for the logs from Core Crypto
2274
- **/
2275
- export declare enum CoreCryptoLogLevel {
2276
- Off = 1,
2277
- Trace = 2,
2278
- Debug = 3,
2279
- Info = 4,
2280
- Warn = 5,
2281
- Error = 6
2282
- }
2283
- /**
2284
- * Sets maximum log level for logs forwarded to the logger, defaults to `Warn`.
2285
- *
2286
- * @param level - the max level that should be logged
2287
- */
2288
- export declare function setMaxLogLevel(level: CoreCryptoLogLevel): void;
2289
- /**
2290
- * Returns build metadata for the {@link CoreCrypto} libary.
2291
- *
2292
- * @returns varous build metadata for `core-crypto`.
2293
- */
2294
- export declare function buildMetadata(): BuildMetadata;
2295
- /**
2296
- * Returns the current version of {@link CoreCrypto}
2297
- *
2298
- * @returns the CoreCrypto version as a string (e.g. "3.1.2")
2299
- */
2300
- export declare function version(): string;
2301
- /**
2302
- * Wrapper for the WASM-compiled version of CoreCrypto
2303
- */
2304
- export declare class CoreCrypto {
2305
- #private;
2306
- /**
2307
- * Should only be used internally
2308
- */
2309
- inner(): unknown;
2310
- static setLogger(logger: CoreCryptoLogger): void;
2311
- static setMaxLogLevel(level: CoreCryptoLogLevel): void;
2312
- /**
2313
- * This is your entrypoint to initialize {@link CoreCrypto}!
2314
- *
2315
- * @param params - {@link CoreCryptoParams}
2316
- *
2317
- * @example
2318
- * ## Simple init
2319
- * ```ts
2320
- * const cc = await CoreCrypto.init({ databaseName: "test", key: "test", clientId: "test" });
2321
- * // Do the rest with `cc`
2322
- * ```
2323
- *
2324
- * ## Custom Entropy seed init
2325
- * ```ts
2326
- * // FYI, this is the IETF test vector #1
2327
- * const entropySeed = Uint32Array.from([
2328
- * 0xade0b876, 0x903df1a0, 0xe56a5d40, 0x28bd8653,
2329
- * 0xb819d2bd, 0x1aed8da0, 0xccef36a8, 0xc70d778b,
2330
- * 0x7c5941da, 0x8d485751, 0x3fe02477, 0x374ad8b8,
2331
- * 0xf4b8436a, 0x1ca11815, 0x69b687c3, 0x8665eeb2,
2332
- * ]);
2333
- *
2334
- * const cc = await CoreCrypto.init({
2335
- * databaseName: "test",
2336
- * key: "test",
2337
- * clientId: "test",
2338
- * entropySeed,
2339
- * });
2340
- * ````
2341
- */
2342
- static init({ databaseName, key, clientId, ciphersuites, entropySeed, nbKeyPackage, }: CoreCryptoParams): Promise<CoreCrypto>;
2343
- /**
2344
- * Almost identical to {@link CoreCrypto.init} but allows a 2 phase initialization of MLS.
2345
- * First, calling this will set up the keystore and will allow generating proteus prekeys.
2346
- * Then, those keys can be traded for a clientId.
2347
- * Use this clientId to initialize MLS with {@link CoreCryptoContext.mlsInit}.
2348
- * @param params - {@link CoreCryptoDeferredParams}
2349
- */
2350
- static deferredInit({ databaseName, key, entropySeed, }: CoreCryptoDeferredParams): Promise<CoreCrypto>;
2351
- /**
2352
- * Instantiate a history client.
2353
- *
2354
- * This client exposes the full interface of `CoreCrypto`, but it should only be used to decrypt messages.
2355
- * Other use is a logic error.
2356
- */
2357
- static historyClient(historySecret: HistorySecret): Promise<CoreCrypto>;
2358
- /**
2359
- * Starts a new transaction in Core Crypto. If the callback succeeds, it will be committed,
2360
- * otherwise, every operation performed with the context will be discarded.
2361
- *
2362
- * @param callback - The callback to execute within the transaction
2363
- *
2364
- * @returns the result of the callback will be returned from this call
2365
- */
2366
- transaction<R>(callback: (ctx: CoreCryptoContext$1) => Promise<R>): Promise<R>;
2367
- /** @hidden */
2368
- private constructor();
2369
- /**
2370
- * Waits for any transaction that is currently in progress, then closes this {@link CoreCrypto}
2371
- * instance and deallocates all loaded resources
2372
- *
2373
- * **CAUTION**: This {@link CoreCrypto} instance won't be usable after a call to this method,
2374
- * but there's no way to express this requirement in TypeScript, so you'll get errors instead!
2375
- */
2376
- close(): Promise<void>;
2377
- /**
2378
- * Registers the transport callbacks for core crypto to give it access to backend endpoints for sending
2379
- * a commit bundle or a message, respectively.
2380
- *
2381
- * @param transportProvider - Any implementor of the {@link MlsTransport} interface
2382
- * @param _ctx - unused
2383
- */
2384
- provideTransport(transportProvider: MlsTransport, _ctx?: unknown): Promise<void>;
2385
- /**
2386
- * See {@link CoreCryptoContext.conversationExists}.
2387
- */
2388
- conversationExists(conversationId: ConversationId): Promise<boolean>;
2389
- /**
2390
- * See {@link CoreCryptoContext.conversationEpoch}.
2391
- *
2392
- * @returns the epoch of the conversation
2393
- *
2394
- * @example
2395
- * ```ts
2396
- * const cc = await CoreCrypto.init({ databaseName: "test", key: "test", clientId: "test" });
2397
- * const encoder = new TextEncoder();
2398
- * console.log(await cc.conversationEpoch(encoder.encode("my super chat")))
2399
- * ```
2400
- */
2401
- conversationEpoch(conversationId: ConversationId): Promise<number>;
2402
- /**
2403
- * See {@link CoreCryptoContext.conversationCiphersuite}.
2404
- *
2405
- * @returns the ciphersuite of the conversation
2406
- */
2407
- conversationCiphersuite(conversationId: ConversationId): Promise<Ciphersuite>;
2408
- /**
2409
- * See {@link CoreCryptoContext.clientPublicKey}.
2410
- *
2411
- * @param ciphersuite - of the signature key to get
2412
- * @param credentialType - of the public key to look for
2413
- * @returns the client's public signature key
2414
- */
2415
- clientPublicKey(ciphersuite: Ciphersuite, credentialType: CredentialType): Promise<Uint8Array>;
2416
- /**
2417
- * See {@link CoreCryptoContext.exportSecretKey}.
2418
- *
2419
- * @param conversationId - The group's ID
2420
- * @param keyLength - the length of the key to be derived. If the value is higher than the
2421
- * bounds of `u16` or the context hash * 255, an error will be returned
2422
- *
2423
- * @returns A `Uint8Array` representing the derived key
2424
- */
2425
- exportSecretKey(conversationId: ConversationId, keyLength: number): Promise<Uint8Array>;
2426
- /**
2427
- * Check if history sharing is enabled, i.e., if any of the conversation members have a {@link ClientId} starting
2428
- * with the history client id prefix.
2429
- *
2430
- * @param conversationId - The group's ID
2431
- *
2432
- * @returns Whether history sharing is enabled
2433
- */
2434
- isHistorySharingEnabled(conversationId: ConversationId): Promise<boolean>;
2435
- /**
2436
- * See {@link CoreCryptoContext.getExternalSender}.
2437
- *
2438
- * @param conversationId - The group's ID
2439
- *
2440
- * @returns A `Uint8Array` representing the external sender raw public key
2441
- */
2442
- getExternalSender(conversationId: ConversationId): Promise<Uint8Array>;
2443
- /**
2444
- * See {@link CoreCryptoContext.getClientIds}.
2445
- *
2446
- * @param conversationId - The group's ID
2447
- *
2448
- * @returns A list of clients from the members of the group
2449
- */
2450
- getClientIds(conversationId: ConversationId): Promise<ClientId[]>;
2451
- /**
2452
- * See {@link CoreCryptoContext.randomBytes}.
2453
- *
2454
- * @param length - The number of bytes to be returned in the `Uint8Array`
2455
- *
2456
- * @returns A `Uint8Array` buffer that contains `length` cryptographically-secure random bytes
2457
- */
2458
- randomBytes(length: number): Promise<Uint8Array>;
2459
- /**
2460
- * Allows to reseed {@link CoreCrypto}'s internal CSPRNG with a new seed.
2461
- *
2462
- * @param seed - **exactly 32** bytes buffer seed
2463
- */
2464
- reseedRng(seed: Uint8Array): Promise<void>;
2465
- /**
2466
- * Checks if a session exists
2467
- *
2468
- * @param sessionId - ID of the Proteus session
2469
- *
2470
- * @returns whether the session exists or not
2471
- */
2472
- proteusSessionExists(sessionId: string): Promise<boolean>;
2473
- /**
2474
- * @returns The last resort PreKey id
2475
- */
2476
- static proteusLastResortPrekeyId(): number;
2477
- /**
2478
- * Proteus public key fingerprint
2479
- * It's basically the public key encoded as an hex string
2480
- *
2481
- * @returns Hex-encoded public key string
2482
- */
2483
- proteusFingerprint(): Promise<string>;
2484
- /**
2485
- * Proteus session local fingerprint
2486
- *
2487
- * @param sessionId - ID of the Proteus session
2488
- * @returns Hex-encoded public key string
2489
- */
2490
- proteusFingerprintLocal(sessionId: string): Promise<string>;
2491
- /**
2492
- * Proteus session remote fingerprint
2493
- *
2494
- * @param sessionId - ID of the Proteus session
2495
- * @returns Hex-encoded public key string
2496
- */
2497
- proteusFingerprintRemote(sessionId: string): Promise<string>;
2498
- /**
2499
- * Hex-encoded fingerprint of the given prekey
2500
- *
2501
- * @param prekey - the prekey bundle to get the fingerprint from
2502
- * @returns Hex-encoded public key string
2503
- **/
2504
- static proteusFingerprintPrekeybundle(prekey: Uint8Array): string;
2505
- /**
2506
- * See {@link CoreCryptoContext.e2eiIsPKIEnvSetup}.
2507
- * @returns whether the E2EI PKI environment is setup (i.e. Root CA, Intermediates, CRLs)
2508
- */
2509
- e2eiIsPKIEnvSetup(): Promise<boolean>;
2510
- /**
2511
- * See {@link CoreCryptoContext.e2eiIsEnabled}.
2512
- *
2513
- * @param ciphersuite of the credential to check
2514
- * @returns true if end-to-end identity is enabled for the given ciphersuite
2515
- */
2516
- e2eiIsEnabled(ciphersuite: Ciphersuite): Promise<boolean>;
2517
- /**
2518
- * See {@link CoreCryptoContext.getDeviceIdentities}.
2519
- *
2520
- * @param conversationId - identifier of the conversation
2521
- * @param deviceIds - identifiers of the devices
2522
- * @returns identities or if no member has a x509 certificate, it will return an empty List
2523
- */
2524
- getDeviceIdentities(conversationId: ConversationId, deviceIds: ClientId[]): Promise<WireIdentity[]>;
2525
- /**
2526
- * See {@link CoreCryptoContext.getUserIdentities}.
2527
- *
2528
- * @param conversationId - identifier of the conversation
2529
- * @param userIds - user identifiers hyphenated UUIDv4 e.g. 'bd4c7053-1c5a-4020-9559-cd7bf7961954'
2530
- * @returns a Map with all the identities for a given users. Consumers are then recommended to reduce those identities to determine the actual status of a user.
2531
- */
2532
- getUserIdentities(conversationId: ConversationId, userIds: string[]): Promise<Map<string, WireIdentity[]>>;
2533
- /**
2534
- * Registers an epoch observer, which will then be notified every time a conversation's epoch changes.
2535
- *
2536
- * @param observer must conform to the {@link EpochObserver} interface
2537
- * @returns nothing
2538
- */
2539
- registerEpochObserver(observer: EpochObserver): Promise<void>;
2540
- /**
2541
- * Registers a history observer, which will then be notified every time a history client is created.
2542
- *
2543
- * @param observer must conform to the {@link HistoryObserver} interface
2544
- * @returns nothing
2545
- */
2546
- registerHistoryObserver(observer: HistoryObserver): Promise<void>;
2547
- }
2548
- /**
2549
- * Initialises the wasm module necessary for running core crypto.
2550
- *
2551
- * @param location path where the wasm module is located. If omitted the module is assumed be located at the root of the core crypto module.
2552
- */
2553
- export declare function initWasmModule(location?: string | undefined): Promise<void>;
2554
-
2555
- export {
2556
- AcmeDirectory$1 as AcmeDirectory,
2557
- BufferedDecryptedMessage$1 as BufferedDecryptedMessage,
2558
- ConversationConfiguration$1 as ConversationConfiguration,
2559
- CoreCryptoContext$1 as CoreCryptoContext,
2560
- DecryptedMessage$1 as DecryptedMessage,
2561
- E2eiConversationState$1 as E2eiConversationState,
2562
- MlsGroupInfoEncryptionType as GroupInfoEncryptionType,
2563
- MlsRatchetTreeType as RatchetTreeType,
2564
- ProteusAutoPrekeyBundle$1 as ProteusAutoPrekeyBundle,
2565
- };
2566
-
2567
- export {};