@bitwarden/sdk-internal 0.2.0-main.201 → 0.2.0-main.202

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.
@@ -117,6 +117,10 @@ export interface InitUserCryptoRequest {
117
117
  * The user\'s encrypted private key
118
118
  */
119
119
  privateKey: EncString;
120
+ /**
121
+ * The user\'s signing key
122
+ */
123
+ signingKey: EncString | undefined;
120
124
  /**
121
125
  * The initialization method to use
122
126
  */
@@ -253,6 +257,24 @@ export interface VerifyAsymmetricKeysResponse {
253
257
  validPrivateKey: boolean;
254
258
  }
255
259
 
260
+ /**
261
+ * A new signing key pair along with the signed public key
262
+ */
263
+ export interface MakeUserSigningKeysResponse {
264
+ /**
265
+ * Base64 encoded verifying key
266
+ */
267
+ verifyingKey: string;
268
+ /**
269
+ * Signing key, encrypted with the user\'s symmetric key
270
+ */
271
+ signingKey: EncString;
272
+ /**
273
+ * The user\'s public key, signed by the signing key
274
+ */
275
+ signedPublicKey: SignedPublicKey;
276
+ }
277
+
256
278
  /**
257
279
  * NewType wrapper for `OrganizationId`
258
280
  */
@@ -360,6 +382,13 @@ export type UnsignedSharedKey = string;
360
382
 
361
383
  export type EncString = string;
362
384
 
385
+ export type SignedPublicKey = string;
386
+
387
+ /**
388
+ * The type of key / signature scheme used for signing and verifying.
389
+ */
390
+ export type SignatureAlgorithm = "ed25519";
391
+
363
392
  /**
364
393
  * Key Derivation Function for Bitwarden Account
365
394
  *
@@ -391,7 +420,10 @@ export interface CryptoError extends Error {
391
420
  | "ZeroNumber"
392
421
  | "OperationNotSupported"
393
422
  | "WrongKeyType"
394
- | "InvalidNonceLength";
423
+ | "WrongCoseKeyId"
424
+ | "InvalidNonceLength"
425
+ | "SignatureError"
426
+ | "EncodingError";
395
427
  }
396
428
 
397
429
  export function isCryptoError(error: any): error is CryptoError;
@@ -1167,6 +1199,10 @@ export class CryptoClient {
1167
1199
  * Crypto initialization not required.
1168
1200
  */
1169
1201
  verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
1202
+ /**
1203
+ * Makes a new signing key pair and signs the public key for the user
1204
+ */
1205
+ make_user_signing_keys_for_enrollment(): MakeUserSigningKeysResponse;
1170
1206
  }
1171
1207
  export class ExporterClient {
1172
1208
  private constructor();
@@ -1411,6 +1447,25 @@ export class PureCrypto {
1411
1447
  encapsulated_key: string,
1412
1448
  decapsulation_key: Uint8Array,
1413
1449
  ): Uint8Array;
1450
+ /**
1451
+ * Given a wrapped signing key and the symmetric key it is wrapped with, this returns
1452
+ * the corresponding verifying key.
1453
+ */
1454
+ static verifying_key_for_signing_key(signing_key: string, wrapping_key: Uint8Array): Uint8Array;
1455
+ /**
1456
+ * Returns the algorithm used for the given verifying key.
1457
+ */
1458
+ static key_algorithm_for_verifying_key(verifying_key: Uint8Array): SignatureAlgorithm;
1459
+ /**
1460
+ * For a given signing identity (verifying key), this function verifies that the signing
1461
+ * identity claimed ownership of the public key. This is a one-sided claim and merely shows
1462
+ * that the signing identity has the intent to receive messages encrypted to the public
1463
+ * key.
1464
+ */
1465
+ static verify_and_unwrap_signed_public_key(
1466
+ signed_public_key: Uint8Array,
1467
+ verifying_key: Uint8Array,
1468
+ ): Uint8Array;
1414
1469
  }
1415
1470
  export class TotpClient {
1416
1471
  private constructor();
@@ -705,7 +705,7 @@ function __wbg_adapter_56(arg0, arg1, arg2) {
705
705
  );
706
706
  }
707
707
 
708
- function __wbg_adapter_256(arg0, arg1, arg2, arg3) {
708
+ function __wbg_adapter_260(arg0, arg1, arg2, arg3) {
709
709
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h334034c47a371f71(
710
710
  arg0,
711
711
  arg1,
@@ -1320,6 +1320,25 @@ class CryptoClient {
1320
1320
  wasm.__wbindgen_add_to_stack_pointer(16);
1321
1321
  }
1322
1322
  }
1323
+ /**
1324
+ * Makes a new signing key pair and signs the public key for the user
1325
+ * @returns {MakeUserSigningKeysResponse}
1326
+ */
1327
+ make_user_signing_keys_for_enrollment() {
1328
+ try {
1329
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1330
+ wasm.cryptoclient_make_user_signing_keys_for_enrollment(retptr, this.__wbg_ptr);
1331
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1332
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1333
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1334
+ if (r2) {
1335
+ throw takeObject(r1);
1336
+ }
1337
+ return takeObject(r0);
1338
+ } finally {
1339
+ wasm.__wbindgen_add_to_stack_pointer(16);
1340
+ }
1341
+ }
1323
1342
  }
1324
1343
  module.exports.CryptoClient = CryptoClient;
1325
1344
 
@@ -2837,6 +2856,88 @@ class PureCrypto {
2837
2856
  wasm.__wbindgen_add_to_stack_pointer(16);
2838
2857
  }
2839
2858
  }
2859
+ /**
2860
+ * Given a wrapped signing key and the symmetric key it is wrapped with, this returns
2861
+ * the corresponding verifying key.
2862
+ * @param {string} signing_key
2863
+ * @param {Uint8Array} wrapping_key
2864
+ * @returns {Uint8Array}
2865
+ */
2866
+ static verifying_key_for_signing_key(signing_key, wrapping_key) {
2867
+ try {
2868
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2869
+ const ptr0 = passStringToWasm0(signing_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2870
+ const len0 = WASM_VECTOR_LEN;
2871
+ const ptr1 = passArray8ToWasm0(wrapping_key, wasm.__wbindgen_malloc);
2872
+ const len1 = WASM_VECTOR_LEN;
2873
+ wasm.purecrypto_verifying_key_for_signing_key(retptr, ptr0, len0, ptr1, len1);
2874
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2875
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2876
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2877
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2878
+ if (r3) {
2879
+ throw takeObject(r2);
2880
+ }
2881
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
2882
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
2883
+ return v3;
2884
+ } finally {
2885
+ wasm.__wbindgen_add_to_stack_pointer(16);
2886
+ }
2887
+ }
2888
+ /**
2889
+ * Returns the algorithm used for the given verifying key.
2890
+ * @param {Uint8Array} verifying_key
2891
+ * @returns {SignatureAlgorithm}
2892
+ */
2893
+ static key_algorithm_for_verifying_key(verifying_key) {
2894
+ try {
2895
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2896
+ const ptr0 = passArray8ToWasm0(verifying_key, wasm.__wbindgen_malloc);
2897
+ const len0 = WASM_VECTOR_LEN;
2898
+ wasm.purecrypto_key_algorithm_for_verifying_key(retptr, ptr0, len0);
2899
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2900
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2901
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2902
+ if (r2) {
2903
+ throw takeObject(r1);
2904
+ }
2905
+ return takeObject(r0);
2906
+ } finally {
2907
+ wasm.__wbindgen_add_to_stack_pointer(16);
2908
+ }
2909
+ }
2910
+ /**
2911
+ * For a given signing identity (verifying key), this function verifies that the signing
2912
+ * identity claimed ownership of the public key. This is a one-sided claim and merely shows
2913
+ * that the signing identity has the intent to receive messages encrypted to the public
2914
+ * key.
2915
+ * @param {Uint8Array} signed_public_key
2916
+ * @param {Uint8Array} verifying_key
2917
+ * @returns {Uint8Array}
2918
+ */
2919
+ static verify_and_unwrap_signed_public_key(signed_public_key, verifying_key) {
2920
+ try {
2921
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2922
+ const ptr0 = passArray8ToWasm0(signed_public_key, wasm.__wbindgen_malloc);
2923
+ const len0 = WASM_VECTOR_LEN;
2924
+ const ptr1 = passArray8ToWasm0(verifying_key, wasm.__wbindgen_malloc);
2925
+ const len1 = WASM_VECTOR_LEN;
2926
+ wasm.purecrypto_verify_and_unwrap_signed_public_key(retptr, ptr0, len0, ptr1, len1);
2927
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2928
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2929
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2930
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2931
+ if (r3) {
2932
+ throw takeObject(r2);
2933
+ }
2934
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
2935
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
2936
+ return v3;
2937
+ } finally {
2938
+ wasm.__wbindgen_add_to_stack_pointer(16);
2939
+ }
2940
+ }
2840
2941
  }
2841
2942
  module.exports.PureCrypto = PureCrypto;
2842
2943
 
@@ -3239,7 +3340,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function (arg0, arg1) {
3239
3340
  const a = state0.a;
3240
3341
  state0.a = 0;
3241
3342
  try {
3242
- return __wbg_adapter_256(a, state0.b, arg0, arg1);
3343
+ return __wbg_adapter_260(a, state0.b, arg0, arg1);
3243
3344
  } finally {
3244
3345
  state0.a = a;
3245
3346
  }
@@ -3596,18 +3697,18 @@ module.exports.__wbindgen_cb_drop = function (arg0) {
3596
3697
  return ret;
3597
3698
  };
3598
3699
 
3599
- module.exports.__wbindgen_closure_wrapper2339 = function (arg0, arg1, arg2) {
3600
- const ret = makeMutClosure(arg0, arg1, 669, __wbg_adapter_50);
3700
+ module.exports.__wbindgen_closure_wrapper2472 = function (arg0, arg1, arg2) {
3701
+ const ret = makeMutClosure(arg0, arg1, 709, __wbg_adapter_50);
3601
3702
  return addHeapObject(ret);
3602
3703
  };
3603
3704
 
3604
- module.exports.__wbindgen_closure_wrapper3178 = function (arg0, arg1, arg2) {
3605
- const ret = makeMutClosure(arg0, arg1, 753, __wbg_adapter_53);
3705
+ module.exports.__wbindgen_closure_wrapper3311 = function (arg0, arg1, arg2) {
3706
+ const ret = makeMutClosure(arg0, arg1, 793, __wbg_adapter_53);
3606
3707
  return addHeapObject(ret);
3607
3708
  };
3608
3709
 
3609
- module.exports.__wbindgen_closure_wrapper3588 = function (arg0, arg1, arg2) {
3610
- const ret = makeMutClosure(arg0, arg1, 875, __wbg_adapter_56);
3710
+ module.exports.__wbindgen_closure_wrapper3724 = function (arg0, arg1, arg2) {
3711
+ const ret = makeMutClosure(arg0, arg1, 916, __wbg_adapter_56);
3611
3712
  return addHeapObject(ret);
3612
3713
  };
3613
3714
 
@@ -6,6 +6,7 @@ export const cryptoclient_initialize_user_crypto: (a: number, b: number) => numb
6
6
  export const cryptoclient_initialize_org_crypto: (a: number, b: number) => number;
7
7
  export const cryptoclient_make_key_pair: (a: number, b: number, c: number, d: number) => void;
8
8
  export const cryptoclient_verify_asymmetric_keys: (a: number, b: number, c: number) => void;
9
+ export const cryptoclient_make_user_signing_keys_for_enrollment: (a: number, b: number) => void;
9
10
  export const isDeriveKeyConnectorError: (a: number) => number;
10
11
  export const isEnrollAdminPasswordResetError: (a: number) => number;
11
12
  export const isCryptoClientError: (a: number) => number;
@@ -273,6 +274,21 @@ export const purecrypto_decapsulate_key_unsigned: (
273
274
  d: number,
274
275
  e: number,
275
276
  ) => void;
277
+ export const purecrypto_verifying_key_for_signing_key: (
278
+ a: number,
279
+ b: number,
280
+ c: number,
281
+ d: number,
282
+ e: number,
283
+ ) => void;
284
+ export const purecrypto_key_algorithm_for_verifying_key: (a: number, b: number, c: number) => void;
285
+ export const purecrypto_verify_and_unwrap_signed_public_key: (
286
+ a: number,
287
+ b: number,
288
+ c: number,
289
+ d: number,
290
+ e: number,
291
+ ) => void;
276
292
  export const generate_ssh_key: (a: number, b: number) => void;
277
293
  export const import_ssh_key: (a: number, b: number, c: number, d: number, e: number) => void;
278
294
  export const isTestError: (a: number) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitwarden/sdk-internal",
3
- "version": "0.2.0-main.201",
3
+ "version": "0.2.0-main.202",
4
4
  "license": "GPL-3.0",
5
5
  "files": [
6
6
  "bitwarden_wasm_internal_bg.js",