@wireapp/core-crypto 1.1.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -36,6 +36,13 @@ brew install gnu-sed
36
36
  ```
37
37
  and add an alias to your shell configuration file: `alias sed=gsed` (e.g. to `~/.zshenv` if you're using zsh).
38
38
 
39
+ ### Development Requirements
40
+
41
+ #### Pre-commit
42
+
43
+ - Install the [`pre-commit` framework](https://pre-commit.com/)
44
+ - Run `pre-commit install` to initialize the pre-commit hooks
45
+
39
46
  ### Android
40
47
 
41
48
  Install Android SDK and Build-Tools for API level 30+
@@ -48,7 +55,7 @@ Install Android SDK and Build-Tools for API level 30+
48
55
 
49
56
  Install android rust targets:
50
57
  ```ignore
51
- rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi i686-linux-android
58
+ rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi
52
59
  ```
53
60
  Build:
54
61
  ```ignore
@@ -137,11 +144,11 @@ cargo install cargo-nextest
137
144
  cargo nextest run
138
145
  ```
139
146
 
140
- #### Run core crypto tests on WASM target
147
+ ### Run core crypto internal tests on WASM target
141
148
 
142
149
  If you haven't already, install the target and wasm-pack:
143
150
 
144
- ```ignore
151
+ ```sh
145
152
  rustup target add wasm32-unknown-unknown
146
153
  cargo install wasm-pack
147
154
  ```
@@ -164,28 +171,63 @@ wasm-pack test --headless --chrome ./<crate-folder-to-test>
164
171
  cargo nextest run --features test-all-cipher
165
172
  ```
166
173
 
167
- ### Platform-specific testing
174
+ ### Platform-specific tests for Kotlin/JVM
168
175
 
169
- ### Kotlin/Android
176
+ Build the JVM target every timee the Rust code changes:
170
177
 
171
- * Take the steps to compile for Kotlin/Android
172
- * Then:
173
- ```ignore
174
- cd crypto-ffi/bindings
175
- ./gradlew test
178
+ ```sh
179
+ # substitute with `jvm-darwin` on OSX
180
+ core-crypto/crypto-ffi$ cargo make jvm-linux
181
+ ```
182
+
183
+ Then run the tests each time the wrapper or wrapper tests change
184
+
185
+ ```sh
186
+ core-crypto/crypto-ffi/bindings$ ./gradlew jvm:build -x lint -x lintRelease
187
+ ```
188
+
189
+ ### Platform-specific tests for Android
190
+
191
+ Build the Android target every timee the Rust code changes:
192
+
193
+ ```sh
194
+ core-crypto/crypto-ffi$ cargo make android
195
+ ```
196
+
197
+ Then run the tests each time the wrapper or wrapper tests change
198
+
199
+ ```sh
200
+ core-crypto/crypto-ffi/bindings$ ./gradlew android:build -x lint -x lintRelease
176
201
  ```
177
202
 
178
203
  ### Swift/iOS
179
204
 
180
205
  *No E2E testing is available as of now on Swift.*
181
206
 
182
- ### WASM/Web
207
+ ### Platform-spcecific tests for WASM/Web
183
208
 
184
- * Take the steps to compile for WASM/Web
185
- * Then:
186
- ```ignore
187
- cd crypto-ffi
188
- bun test
209
+ Install TS dependencies on first go, and each time they change:
210
+
211
+ ```sh
212
+ bun install
213
+ ```
214
+
215
+ Build the WASM target every timee the Rust code changes:
216
+
217
+ ```sh
218
+ core-crypto/crypto-ffi$ cargo make wasm
219
+ ```
220
+
221
+ Then run the tests each time the wrapper or wrapper tests change
222
+
223
+ ```sh
224
+ core-crypto/crypto-ffi$ bun run test
225
+ ```
226
+
227
+ Note that CI will fail if it doesn't like your formatting. This can typically be automtically adjusted with
228
+
229
+ ```sh
230
+ core-crypto/crypto-ffi$ bun eslinst bindings/js --max-warnings=0 --fix
189
231
  ```
190
232
 
191
233
  ## Benchmarks
@@ -276,4 +318,4 @@ cd crypto-ffi/bindings/android
276
318
  Publishing JS / WASM bindings happens automatically by a github workflow when a release tag is pushed.
277
319
 
278
320
  If you would like to publish to `@wireapp/core-crypto` manually, log into NPM and
279
- just run `npm publish`.
321
+ just run `bun publish`.
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@wireapp/core-crypto",
3
- "version": "1.1.2",
3
+ "version": "2.0.0",
4
4
  "description": "CoreCrypto bindings for the Web",
5
5
  "type": "module",
6
6
  "module": "platforms/web/corecrypto.js",
7
7
  "types": "platforms/web/corecrypto.d.ts",
8
8
  "scripts": {
9
- "clean": "rm -f ./platforms/web/*.{js,ts,wasm,html} && rm -rf ./platforms/web/assets"
9
+ "clean": "rm -f ./platforms/web/*.{js,ts,wasm,html} && rm -rf ./platforms/web/assets",
10
+ "test": "[ \"$(basename $PWD)\" != \"crypto-ffi\" ] && echo \"Error: Not in crypto-ffi directory, do:\" && echo cd crypto-ffi && exit 1 || bun run build_ts.ts && wdio run bindings/js/wdio.conf.ts --spec bindings/js/test/**/*.test.ts",
11
+ "bench": "[ \"$(basename $PWD)\" != \"crypto-ffi\" ] && echo \"Error: Not in crypto-ffi directory, do:\" && echo cd crypto-ffi && exit 1 ||bun run build_ts.ts && wdio run bindings/js/wdio.conf.ts --spec bindings/js/benches/**/*.bench.ts --log-level warn"
10
12
  },
11
13
  "publishConfig": {
12
14
  "access": "public"
@@ -32,14 +34,22 @@
32
34
  "url": "https://github.com/wireapp/core-crypto/issues"
33
35
  },
34
36
  "devDependencies": {
37
+ "@types/bun": "^1.1.13",
38
+ "@types/mocha": "^10.0.9",
35
39
  "@typescript-eslint/eslint-plugin": "^7.0.2",
36
40
  "@typescript-eslint/parser": "^7.0.2",
41
+ "@wdio/browser-runner": "^9.2.12",
42
+ "@wdio/cli": "^9.2.12",
43
+ "@wdio/logger": "^9.1.3",
44
+ "@wdio/mocha-framework": "^9.2.8",
45
+ "@wdio/spec-reporter": "^9.2.14",
46
+ "@wdio/static-server-service": "^9.2.2",
37
47
  "bun-plugin-dts": "^0.2.1",
38
48
  "eslint": "^8.56.0",
39
49
  "eslint-config-prettier": "^9.1.0",
40
50
  "eslint-plugin-prettier": "^5.1.3",
51
+ "eslint-plugin-wdio": "^9.2.11",
41
52
  "prettier": "^3.2.5",
42
- "puppeteer": "^22.2.0",
43
53
  "ts-loader": "^9.5.1",
44
54
  "typescript": "^5.3.3"
45
55
  }
@@ -1,13 +1,3 @@
1
- declare enum WirePolicy {
2
- /**
3
- * Handshake messages are never encrypted
4
- */
5
- Plaintext = 1,
6
- /**
7
- * Handshake messages are always encrypted
8
- */
9
- Ciphertext = 2
10
- }
11
1
  declare enum Ciphersuite {
12
2
  /**
13
3
  * DH KEM x25519 | AES-GCM 128 | SHA2-256 | Ed25519
@@ -38,6 +28,16 @@ declare enum Ciphersuite {
38
28
  */
39
29
  MLS_256_DHKEMP384_AES256GCM_SHA384_P384 = 7
40
30
  }
31
+ declare enum WirePolicy {
32
+ /**
33
+ * Handshake messages are never encrypted
34
+ */
35
+ Plaintext = 1,
36
+ /**
37
+ * Handshake messages are always encrypted
38
+ */
39
+ Ciphertext = 2
40
+ }
41
41
  declare enum CredentialType {
42
42
  /**
43
43
  * Just a KeyPair
@@ -68,6 +68,53 @@ export class AcmeChallenge {
68
68
  */
69
69
  readonly url: string;
70
70
  }
71
+ declare class BuildMetadata {
72
+ /**
73
+ ** Return copy of self without private attributes.
74
+ */
75
+ toJSON(): Object;
76
+ /**
77
+ * Return stringified version of self.
78
+ */
79
+ toString(): string;
80
+ free(): void;
81
+ /**
82
+ * Whether this build was in Debug mode (true) or Release mode (false)
83
+ */
84
+ readonly cargoDebug: string;
85
+ /**
86
+ * Features enabled for this build
87
+ */
88
+ readonly cargoFeatures: string;
89
+ /**
90
+ * Git branch
91
+ */
92
+ readonly gitBranch: string;
93
+ /**
94
+ * Output of `git describe`
95
+ */
96
+ readonly gitDescribe: string;
97
+ /**
98
+ * `true` when the source code differed from the commit at the most recent git hash
99
+ */
100
+ readonly gitDirty: string;
101
+ /**
102
+ * Hash of current git commit
103
+ */
104
+ readonly gitSha: string;
105
+ /**
106
+ * Optimization level
107
+ */
108
+ readonly optLevel: string;
109
+ /**
110
+ * Build target triple
111
+ */
112
+ readonly targetTriple: string;
113
+ /**
114
+ * Build Timestamp
115
+ */
116
+ readonly timestamp: string;
117
+ }
71
118
  /**
72
119
  * see [core_crypto::prelude::MlsConversationConfiguration]
73
120
  */
@@ -609,6 +656,7 @@ declare class CoreCryptoContext {
609
656
  e2ei_mls_init_only(enrollment: FfiWireE2EIdentity, certificate_chain: string, nb_key_package?: number): Promise<any>;
610
657
  /**
611
658
  * Returns: [`WasmCryptoResult<CommitBundle>`]
659
+ *
612
660
  * see [core_crypto::context::CentralContext::e2ei_rotate]
613
661
  * @param {Uint8Array} conversation_id
614
662
  * @returns {Promise<any>}
@@ -1533,6 +1581,12 @@ declare class CoreCryptoContext$1 {
1533
1581
  */
1534
1582
  getCredentialInUse(groupInfo: Uint8Array, credentialType?: CredentialType$1): Promise<E2eiConversationState>;
1535
1583
  }
1584
+ export interface CoreCryptoRichError {
1585
+ message: string;
1586
+ error_name?: string;
1587
+ error_stack?: string[];
1588
+ proteus_error_code?: number;
1589
+ }
1536
1590
  /**
1537
1591
  * Error wrapper that takes care of extracting rich error details across the FFI (through JSON parsing)
1538
1592
  *
@@ -1543,8 +1597,8 @@ declare class CoreCryptoContext$1 {
1543
1597
  * Please note that in this case the extra properties will not be available.
1544
1598
  */
1545
1599
  export declare class CoreCryptoError extends Error {
1546
- rustStackTrace: string;
1547
- proteusErrorCode: number;
1600
+ errorStack: string[];
1601
+ proteusErrorCode: number | null;
1548
1602
  private constructor();
1549
1603
  private static fallback;
1550
1604
  static build(msg: string, ...params: unknown[]): CoreCryptoError | Error;
@@ -2218,9 +2272,10 @@ export interface CoreCryptoLogger {
2218
2272
  /**
2219
2273
  * 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.
2220
2274
  * @param level - the level of the logged message. it will also be present in the json message
2221
- * @param json_msg - message to log in json format
2275
+ * @param message - log message
2276
+ * @param context - additional context captured when the log was made.
2222
2277
  **/
2223
- log: (level: CoreCryptoLogLevel, json_msg: string) => void;
2278
+ log: (level: CoreCryptoLogLevel, message: string, context: string) => void;
2224
2279
  }
2225
2280
  /**
2226
2281
  * Defines the maximum log level for the logs from Core Crypto
@@ -2234,13 +2289,30 @@ export declare enum CoreCryptoLogLevel {
2234
2289
  Error = 6
2235
2290
  }
2236
2291
  /**
2237
- * Initializes the global logger for Core Crypto and registers the callback. Can be called only once
2292
+ * Initializes the global logger for Core Crypto and registers the callback.
2293
+ *
2294
+ * **NOTE:** you must call this after `await CoreCrypto.init(params)` or `await CoreCrypto.deferredInit(params)`.
2295
+ *
2296
+ * @deprecated use {@link CoreCrypto.setLogger} instead.
2297
+ *
2238
2298
  * @param logger - the interface to be called when something is going to be logged
2239
2299
  * @param level - the max level that should be logged
2240
- *
2241
- * NOTE: you must call this after `await CoreCrypto.init(params)` or `await CoreCrypto.deferredInit(params)`.
2242
2300
  **/
2243
2301
  export declare function initLogger(logger: CoreCryptoLogger, level: CoreCryptoLogLevel, ctx?: unknown): void;
2302
+ /**
2303
+ * Initializes the global logger for Core Crypto and registers the callback.
2304
+ *
2305
+ * **NOTE:** you must call this after `await CoreCrypto.init(params)` or `await CoreCrypto.deferredInit(params)`.
2306
+ *
2307
+ * @param logger - the interface to be called when something is going to be logged
2308
+ **/
2309
+ export declare function setLogger(logger: CoreCryptoLogger, ctx?: unknown): void;
2310
+ /**
2311
+ * Sets maximum log level for logs forwarded to the logger, defaults to `Warn`.
2312
+ *
2313
+ * @param level - the max level that should be logged
2314
+ */
2315
+ export declare function setMaxLogLevel(level: CoreCryptoLogLevel): void;
2244
2316
  /**
2245
2317
  * Wrapper for the WASM-compiled version of CoreCrypto
2246
2318
  */
@@ -2250,7 +2322,8 @@ export declare class CoreCrypto {
2250
2322
  * Should only be used internally
2251
2323
  */
2252
2324
  inner(): unknown;
2253
- static setLogger(logger: CoreCryptoWasmLogger, level: CoreCryptoLogLevel): void;
2325
+ static setLogger(logger: CoreCryptoWasmLogger): void;
2326
+ static setMaxLogLevel(level: CoreCryptoLogLevel): void;
2254
2327
  /**
2255
2328
  * This is your entrypoint to initialize {@link CoreCrypto}!
2256
2329
  *
@@ -2873,6 +2946,12 @@ export declare class CoreCrypto {
2873
2946
  * @returns The `core-crypto-ffi` version as defined in its `Cargo.toml` file
2874
2947
  */
2875
2948
  static version(): string;
2949
+ /**
2950
+ * Returns build metadata for the {@link CoreCrypto} libary.
2951
+ *
2952
+ * @returns varous build metadata for `core-crypto`.
2953
+ */
2954
+ static buildMetadata(): BuildMetadata;
2876
2955
  }
2877
2956
  type JsonRawData = Uint8Array;
2878
2957
  export declare class E2eiEnrollment {
@@ -184,13 +184,13 @@ function makeMutClosure(arg0, arg1, dtor, f) {
184
184
  return real;
185
185
  }
186
186
  function __wbg_adapter_54(arg0, arg1, arg2) {
187
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h04c8e12eab94d8e7(arg0, arg1, addHeapObject(arg2));
187
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5286e98832f56995(arg0, arg1, addHeapObject(arg2));
188
188
  }
189
189
  function __wbg_adapter_57(arg0, arg1, arg2) {
190
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h07cca67d94fc484f(arg0, arg1, addHeapObject(arg2));
190
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h4499f6ce9f25a86a(arg0, arg1, addHeapObject(arg2));
191
191
  }
192
192
  function __wbg_adapter_60(arg0, arg1, arg2) {
193
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hec7f3798e268a664(arg0, arg1, addHeapObject(arg2));
193
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2e1bdf8eee89b946(arg0, arg1, addHeapObject(arg2));
194
194
  }
195
195
  function getArrayJsValueFromWasm0(ptr, len) {
196
196
  ptr = ptr >>> 0;
@@ -242,23 +242,9 @@ function handleError(f, args) {
242
242
  wasm.__wbindgen_exn_store(addHeapObject(e));
243
243
  }
244
244
  }
245
- function __wbg_adapter_497(arg0, arg1, arg2, arg3) {
246
- wasm.wasm_bindgen__convert__closures__invoke2_mut__h5053bb07030a5de3(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
245
+ function __wbg_adapter_512(arg0, arg1, arg2, arg3) {
246
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h5d1db9fa3036c038(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
247
247
  }
248
- var WirePolicy = Object.freeze({
249
- Plaintext: 1,
250
- "1": "Plaintext",
251
- Ciphertext: 2,
252
- "2": "Ciphertext"
253
- });
254
- var DeviceStatus = Object.freeze({
255
- Valid: 1,
256
- "1": "Valid",
257
- Expired: 2,
258
- "2": "Expired",
259
- Revoked: 3,
260
- "3": "Revoked"
261
- });
262
248
  var Ciphersuite = Object.freeze({
263
249
  MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519: 1,
264
250
  "1": "MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519",
@@ -275,7 +261,21 @@ var Ciphersuite = Object.freeze({
275
261
  MLS_256_DHKEMP384_AES256GCM_SHA384_P384: 7,
276
262
  "7": "MLS_256_DHKEMP384_AES256GCM_SHA384_P384"
277
263
  });
264
+ var DeviceStatus = Object.freeze({
265
+ Valid: 1,
266
+ "1": "Valid",
267
+ Expired: 2,
268
+ "2": "Expired",
269
+ Revoked: 3,
270
+ "3": "Revoked"
271
+ });
278
272
  var CoreCryptoLogLevel = Object.freeze({ Off: 1, "1": "Off", Trace: 2, "2": "Trace", Debug: 3, "3": "Debug", Info: 4, "4": "Info", Warn: 5, "5": "Warn", Error: 6, "6": "Error" });
273
+ var WirePolicy = Object.freeze({
274
+ Plaintext: 1,
275
+ "1": "Plaintext",
276
+ Ciphertext: 2,
277
+ "2": "Ciphertext"
278
+ });
279
279
  var CredentialType = Object.freeze({
280
280
  Basic: 1,
281
281
  "1": "Basic",
@@ -499,6 +499,144 @@ class BufferedDecryptedMessage {
499
499
  return takeObject(ret);
500
500
  }
501
501
  }
502
+ var BuildMetadataFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
503
+ }, unregister: () => {
504
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_buildmetadata_free(ptr >>> 0, 1));
505
+
506
+ class BuildMetadata {
507
+ static __wrap(ptr) {
508
+ ptr = ptr >>> 0;
509
+ const obj = Object.create(BuildMetadata.prototype);
510
+ obj.__wbg_ptr = ptr;
511
+ BuildMetadataFinalization.register(obj, obj.__wbg_ptr, obj);
512
+ return obj;
513
+ }
514
+ toJSON() {
515
+ return {
516
+ timestamp: this.timestamp,
517
+ cargoDebug: this.cargoDebug,
518
+ cargoFeatures: this.cargoFeatures,
519
+ optLevel: this.optLevel,
520
+ targetTriple: this.targetTriple,
521
+ gitBranch: this.gitBranch,
522
+ gitDescribe: this.gitDescribe,
523
+ gitSha: this.gitSha,
524
+ gitDirty: this.gitDirty
525
+ };
526
+ }
527
+ toString() {
528
+ return JSON.stringify(this);
529
+ }
530
+ __destroy_into_raw() {
531
+ const ptr = this.__wbg_ptr;
532
+ this.__wbg_ptr = 0;
533
+ BuildMetadataFinalization.unregister(this);
534
+ return ptr;
535
+ }
536
+ free() {
537
+ const ptr = this.__destroy_into_raw();
538
+ wasm.__wbg_buildmetadata_free(ptr, 0);
539
+ }
540
+ get timestamp() {
541
+ try {
542
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
543
+ wasm.__wbg_get_buildmetadata_timestamp(retptr, this.__wbg_ptr);
544
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
545
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
546
+ return getStringFromWasm0(r0, r1);
547
+ } finally {
548
+ wasm.__wbindgen_add_to_stack_pointer(16);
549
+ }
550
+ }
551
+ get cargoDebug() {
552
+ try {
553
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
554
+ wasm.__wbg_get_buildmetadata_cargoDebug(retptr, this.__wbg_ptr);
555
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
556
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
557
+ return getStringFromWasm0(r0, r1);
558
+ } finally {
559
+ wasm.__wbindgen_add_to_stack_pointer(16);
560
+ }
561
+ }
562
+ get cargoFeatures() {
563
+ try {
564
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
565
+ wasm.__wbg_get_buildmetadata_cargoFeatures(retptr, this.__wbg_ptr);
566
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
567
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
568
+ return getStringFromWasm0(r0, r1);
569
+ } finally {
570
+ wasm.__wbindgen_add_to_stack_pointer(16);
571
+ }
572
+ }
573
+ get optLevel() {
574
+ try {
575
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
576
+ wasm.__wbg_get_buildmetadata_optLevel(retptr, this.__wbg_ptr);
577
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
578
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
579
+ return getStringFromWasm0(r0, r1);
580
+ } finally {
581
+ wasm.__wbindgen_add_to_stack_pointer(16);
582
+ }
583
+ }
584
+ get targetTriple() {
585
+ try {
586
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
587
+ wasm.__wbg_get_buildmetadata_targetTriple(retptr, this.__wbg_ptr);
588
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
589
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
590
+ return getStringFromWasm0(r0, r1);
591
+ } finally {
592
+ wasm.__wbindgen_add_to_stack_pointer(16);
593
+ }
594
+ }
595
+ get gitBranch() {
596
+ try {
597
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
598
+ wasm.__wbg_get_buildmetadata_gitBranch(retptr, this.__wbg_ptr);
599
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
600
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
601
+ return getStringFromWasm0(r0, r1);
602
+ } finally {
603
+ wasm.__wbindgen_add_to_stack_pointer(16);
604
+ }
605
+ }
606
+ get gitDescribe() {
607
+ try {
608
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
609
+ wasm.__wbg_get_buildmetadata_gitDescribe(retptr, this.__wbg_ptr);
610
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
611
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
612
+ return getStringFromWasm0(r0, r1);
613
+ } finally {
614
+ wasm.__wbindgen_add_to_stack_pointer(16);
615
+ }
616
+ }
617
+ get gitSha() {
618
+ try {
619
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
620
+ wasm.__wbg_get_buildmetadata_gitSha(retptr, this.__wbg_ptr);
621
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
622
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
623
+ return getStringFromWasm0(r0, r1);
624
+ } finally {
625
+ wasm.__wbindgen_add_to_stack_pointer(16);
626
+ }
627
+ }
628
+ get gitDirty() {
629
+ try {
630
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
631
+ wasm.__wbg_get_buildmetadata_gitDirty(retptr, this.__wbg_ptr);
632
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
633
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
634
+ return getStringFromWasm0(r0, r1);
635
+ } finally {
636
+ wasm.__wbindgen_add_to_stack_pointer(16);
637
+ }
638
+ }
639
+ }
502
640
  var CommitBundleFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
503
641
  }, unregister: () => {
504
642
  } } : new FinalizationRegistry((ptr) => wasm.__wbg_commitbundle_free(ptr >>> 0, 1));
@@ -644,6 +782,10 @@ class CoreCrypto {
644
782
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
645
783
  }
646
784
  }
785
+ static build_metadata() {
786
+ const ret = wasm.corecrypto_build_metadata();
787
+ return BuildMetadata.__wrap(ret);
788
+ }
647
789
  static _internal_new(path, key, client_id, ciphersuites, entropy_seed, nb_key_package) {
648
790
  const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
649
791
  const len0 = WASM_VECTOR_LEN;
@@ -682,10 +824,13 @@ class CoreCrypto {
682
824
  const ret = wasm.corecrypto_wipe(ptr);
683
825
  return takeObject(ret);
684
826
  }
685
- static set_logger(logger, level) {
827
+ static set_logger(logger) {
686
828
  _assertClass(logger, CoreCryptoWasmLogger);
687
829
  var ptr0 = logger.__destroy_into_raw();
688
- wasm.corecrypto_set_logger(ptr0, level);
830
+ wasm.corecrypto_set_logger(ptr0);
831
+ }
832
+ static set_max_log_level(level) {
833
+ wasm.corecrypto_set_max_log_level(level);
689
834
  }
690
835
  set_callbacks(callbacks) {
691
836
  _assertClass(callbacks, CoreCryptoWasmCallbacks);
@@ -2033,48 +2178,52 @@ function __wbg_get_imports() {
2033
2178
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
2034
2179
  takeObject(arg0);
2035
2180
  };
2036
- imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
2037
- const ret = BigInt.asUintN(64, arg0);
2038
- return addHeapObject(ret);
2039
- };
2040
- imports.wbg.__wbindgen_number_new = function(arg0) {
2041
- const ret = arg0;
2181
+ imports.wbg.__wbg_newacmeauthz_new = function(arg0) {
2182
+ const ret = NewAcmeAuthz.__wrap(arg0);
2042
2183
  return addHeapObject(ret);
2043
2184
  };
2044
2185
  imports.wbg.__wbg_ffiwiree2eidentity_new = function(arg0) {
2045
2186
  const ret = FfiWireE2EIdentity.__wrap(arg0);
2046
2187
  return addHeapObject(ret);
2047
2188
  };
2048
- imports.wbg.__wbg_execute_1168d8ced41f5786 = function() {
2049
- return handleError(function(arg0, arg1) {
2050
- const ret = getObject(arg0).execute(CoreCryptoContext.__wrap(arg1));
2051
- return addHeapObject(ret);
2052
- }, arguments);
2189
+ imports.wbg.__wbindgen_number_new = function(arg0) {
2190
+ const ret = arg0;
2191
+ return addHeapObject(ret);
2053
2192
  };
2054
2193
  imports.wbg.__wbg_newacmeorder_new = function(arg0) {
2055
2194
  const ret = NewAcmeOrder.__wrap(arg0);
2056
2195
  return addHeapObject(ret);
2057
2196
  };
2058
- imports.wbg.__wbg_newacmeauthz_new = function(arg0) {
2059
- const ret = NewAcmeAuthz.__wrap(arg0);
2197
+ imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
2198
+ const ret = BigInt.asUintN(64, arg0);
2060
2199
  return addHeapObject(ret);
2061
2200
  };
2201
+ imports.wbg.__wbg_execute_0b146cfd7fac1205 = function() {
2202
+ return handleError(function(arg0, arg1) {
2203
+ const ret = getObject(arg0).execute(CoreCryptoContext.__wrap(arg1));
2204
+ return addHeapObject(ret);
2205
+ }, arguments);
2206
+ };
2062
2207
  imports.wbg.__wbg_proteusautoprekeybundle_new = function(arg0) {
2063
2208
  const ret = ProteusAutoPrekeyBundle.__wrap(arg0);
2064
2209
  return addHeapObject(ret);
2065
2210
  };
2066
- imports.wbg.__wbg_acmedirectory_new = function(arg0) {
2067
- const ret = AcmeDirectory.__wrap(arg0);
2068
- return addHeapObject(ret);
2069
- };
2070
2211
  imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
2071
2212
  const ret = getStringFromWasm0(arg0, arg1);
2072
2213
  return addHeapObject(ret);
2073
2214
  };
2215
+ imports.wbg.__wbg_acmedirectory_new = function(arg0) {
2216
+ const ret = AcmeDirectory.__wrap(arg0);
2217
+ return addHeapObject(ret);
2218
+ };
2074
2219
  imports.wbg.__wbg_buffereddecryptedmessage_new = function(arg0) {
2075
2220
  const ret = BufferedDecryptedMessage.__wrap(arg0);
2076
2221
  return addHeapObject(ret);
2077
2222
  };
2223
+ imports.wbg.__wbg_commitbundle_new = function(arg0) {
2224
+ const ret = CommitBundle.__wrap(arg0);
2225
+ return addHeapObject(ret);
2226
+ };
2078
2227
  imports.wbg.__wbg_corecrypto_new = function(arg0) {
2079
2228
  const ret = CoreCrypto.__wrap(arg0);
2080
2229
  return addHeapObject(ret);
@@ -2083,10 +2232,6 @@ function __wbg_get_imports() {
2083
2232
  const ret = ProposalBundle.__wrap(arg0);
2084
2233
  return addHeapObject(ret);
2085
2234
  };
2086
- imports.wbg.__wbg_commitbundle_new = function(arg0) {
2087
- const ret = CommitBundle.__wrap(arg0);
2088
- return addHeapObject(ret);
2089
- };
2090
2235
  imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
2091
2236
  const ret = getObject(arg0);
2092
2237
  return addHeapObject(ret);
@@ -2099,6 +2244,14 @@ function __wbg_get_imports() {
2099
2244
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2100
2245
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2101
2246
  };
2247
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
2248
+ const ret = getObject(arg0) === undefined;
2249
+ return ret;
2250
+ };
2251
+ imports.wbg.__wbindgen_in = function(arg0, arg1) {
2252
+ const ret = getObject(arg0) in getObject(arg1);
2253
+ return ret;
2254
+ };
2102
2255
  imports.wbg.__wbindgen_boolean_get = function(arg0) {
2103
2256
  const v = getObject(arg0);
2104
2257
  const ret = typeof v === "boolean" ? v ? 1 : 0 : 2;
@@ -2127,10 +2280,6 @@ function __wbg_get_imports() {
2127
2280
  const ret = typeof val === "object" && val !== null;
2128
2281
  return ret;
2129
2282
  };
2130
- imports.wbg.__wbindgen_in = function(arg0, arg1) {
2131
- const ret = getObject(arg0) in getObject(arg1);
2132
- return ret;
2133
- };
2134
2283
  imports.wbg.__wbg_queueMicrotask_48421b3cc9052b68 = function(arg0) {
2135
2284
  const ret = getObject(arg0).queueMicrotask;
2136
2285
  return addHeapObject(ret);
@@ -2163,10 +2312,6 @@ function __wbg_get_imports() {
2163
2312
  const ret = getObject(arg0) === null;
2164
2313
  return ret;
2165
2314
  };
2166
- imports.wbg.__wbindgen_is_undefined = function(arg0) {
2167
- const ret = getObject(arg0) === undefined;
2168
- return ret;
2169
- };
2170
2315
  imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
2171
2316
  const ret = getObject(arg0) == getObject(arg1);
2172
2317
  return ret;
@@ -2665,6 +2810,12 @@ function __wbg_get_imports() {
2665
2810
  const ret = new Error(getStringFromWasm0(arg0, arg1));
2666
2811
  return addHeapObject(ret);
2667
2812
  };
2813
+ imports.wbg.__wbg_setcause_95acfe0bd827ffdb = function(arg0, arg1) {
2814
+ getObject(arg0).cause = getObject(arg1);
2815
+ };
2816
+ imports.wbg.__wbg_setname_ef058a4c6ff7e6d4 = function(arg0, arg1, arg2) {
2817
+ getObject(arg0).name = getStringFromWasm0(arg1, arg2);
2818
+ };
2668
2819
  imports.wbg.__wbg_apply_353f4c9ca391d52b = function() {
2669
2820
  return handleError(function(arg0, arg1, arg2) {
2670
2821
  const ret = getObject(arg0).apply(getObject(arg1), getObject(arg2));
@@ -2748,7 +2899,7 @@ function __wbg_get_imports() {
2748
2899
  const a = state0.a;
2749
2900
  state0.a = 0;
2750
2901
  try {
2751
- return __wbg_adapter_497(a, state0.b, arg02, arg12);
2902
+ return __wbg_adapter_512(a, state0.b, arg02, arg12);
2752
2903
  } finally {
2753
2904
  state0.a = a;
2754
2905
  }
@@ -2834,16 +2985,16 @@ function __wbg_get_imports() {
2834
2985
  const ret = v0;
2835
2986
  return addHeapObject(ret);
2836
2987
  };
2837
- imports.wbg.__wbindgen_closure_wrapper3447 = function(arg0, arg1, arg2) {
2838
- const ret = makeMutClosure(arg0, arg1, 751, __wbg_adapter_54);
2988
+ imports.wbg.__wbindgen_closure_wrapper3708 = function(arg0, arg1, arg2) {
2989
+ const ret = makeMutClosure(arg0, arg1, 899, __wbg_adapter_54);
2839
2990
  return addHeapObject(ret);
2840
2991
  };
2841
- imports.wbg.__wbindgen_closure_wrapper13040 = function(arg0, arg1, arg2) {
2842
- const ret = makeMutClosure(arg0, arg1, 2019, __wbg_adapter_57);
2992
+ imports.wbg.__wbindgen_closure_wrapper13412 = function(arg0, arg1, arg2) {
2993
+ const ret = makeMutClosure(arg0, arg1, 2169, __wbg_adapter_57);
2843
2994
  return addHeapObject(ret);
2844
2995
  };
2845
- imports.wbg.__wbindgen_closure_wrapper15217 = function(arg0, arg1, arg2) {
2846
- const ret = makeMutClosure(arg0, arg1, 2263, __wbg_adapter_60);
2996
+ imports.wbg.__wbindgen_closure_wrapper15388 = function(arg0, arg1, arg2) {
2997
+ const ret = makeMutClosure(arg0, arg1, 2396, __wbg_adapter_60);
2847
2998
  return addHeapObject(ret);
2848
2999
  };
2849
3000
  return imports;
@@ -3298,33 +3449,35 @@ class CoreCryptoContext2 {
3298
3449
 
3299
3450
  // bindings/js/CoreCrypto.ts
3300
3451
  class CoreCryptoError extends Error {
3301
- rustStackTrace;
3452
+ errorStack;
3302
3453
  proteusErrorCode;
3303
- constructor(msg, richError, ...params) {
3304
- super(msg, ...params);
3454
+ constructor(richError, ...params) {
3455
+ super(richError.message, ...params);
3305
3456
  Object.setPrototypeOf(this, new.target.prototype);
3306
- this.name = richError.errorName;
3307
- this.rustStackTrace = richError.rustStackTrace;
3308
- this.proteusErrorCode = richError.proteusErrorCode;
3457
+ if (richError.error_name) {
3458
+ this.name = richError.error_name;
3459
+ }
3460
+ if (richError.error_stack) {
3461
+ this.errorStack = richError.error_stack;
3462
+ } else {
3463
+ this.errorStack = [];
3464
+ }
3465
+ if (richError.proteus_error_code) {
3466
+ this.proteusErrorCode = richError.proteus_error_code;
3467
+ } else {
3468
+ this.proteusErrorCode = null;
3469
+ }
3309
3470
  }
3310
3471
  static fallback(msg, ...params) {
3311
3472
  console.warn(`Cannot build CoreCryptoError, falling back to standard Error! ctx: ${msg}`);
3312
3473
  return new Error(msg, ...params);
3313
3474
  }
3314
3475
  static build(msg, ...params) {
3315
- const parts = msg.split(`
3316
-
3317
- `);
3318
- if (parts.length < 2) {
3319
- const cause = new Error("CoreCrypto WASM FFI Error doesn't have enough elements to build a rich error");
3320
- return this.fallback(msg, { cause }, ...params);
3321
- }
3322
- const [errMsg, richErrorJSON] = parts;
3323
3476
  try {
3324
- const richError = JSON.parse(richErrorJSON);
3325
- return new this(errMsg, richError, ...params);
3477
+ const richError = JSON.parse(msg);
3478
+ return new this(richError, ...params);
3326
3479
  } catch (cause) {
3327
- return this.fallback(msg, { cause }, ...params);
3480
+ return this.fallback(msg, ...params);
3328
3481
  }
3329
3482
  }
3330
3483
  static fromStdError(e) {
@@ -3434,7 +3587,15 @@ var CoreCryptoLogLevel2;
3434
3587
  })(CoreCryptoLogLevel2 ||= {});
3435
3588
  function initLogger(logger, level, ctx = null) {
3436
3589
  const wasmLogger = new CoreCryptoWasmLogger(logger.log, ctx);
3437
- CoreCrypto2.setLogger(wasmLogger, level);
3590
+ CoreCrypto2.setLogger(wasmLogger);
3591
+ CoreCrypto2.setMaxLogLevel(level);
3592
+ }
3593
+ function setLogger(logger, ctx = null) {
3594
+ const wasmLogger = new CoreCryptoWasmLogger(logger.log, ctx);
3595
+ CoreCrypto2.setLogger(wasmLogger);
3596
+ }
3597
+ function setMaxLogLevel(level) {
3598
+ CoreCrypto2.setMaxLogLevel(level);
3438
3599
  }
3439
3600
 
3440
3601
  class CoreCrypto2 {
@@ -3453,9 +3614,13 @@ class CoreCrypto2 {
3453
3614
  this.#module = await core_crypto_ffi_default(wasmFilePath);
3454
3615
  }
3455
3616
  }
3456
- static setLogger(logger, level) {
3617
+ static setLogger(logger) {
3618
+ this.#assertModuleLoaded();
3619
+ CoreCrypto.set_logger(logger);
3620
+ }
3621
+ static setMaxLogLevel(level) {
3457
3622
  this.#assertModuleLoaded();
3458
- CoreCrypto.set_logger(logger, level);
3623
+ CoreCrypto.set_max_log_level(level);
3459
3624
  }
3460
3625
  static async init({
3461
3626
  databaseName,
@@ -3758,6 +3923,10 @@ class CoreCrypto2 {
3758
3923
  this.#assertModuleLoaded();
3759
3924
  return CoreCrypto.version();
3760
3925
  }
3926
+ static buildMetadata() {
3927
+ this.#assertModuleLoaded();
3928
+ return CoreCrypto.build_metadata();
3929
+ }
3761
3930
  }
3762
3931
 
3763
3932
  class E2eiEnrollment {
@@ -3836,6 +4005,8 @@ var E2eiConversationState;
3836
4005
  E2eiConversationState2[E2eiConversationState2["NotEnabled"] = 3] = "NotEnabled";
3837
4006
  })(E2eiConversationState ||= {});
3838
4007
  export {
4008
+ setMaxLogLevel,
4009
+ setLogger,
3839
4010
  normalizeEnum,
3840
4011
  mapWireIdentity,
3841
4012
  initLogger,