@bitwarden/sdk-internal 0.2.0-main.37 → 0.2.0-main.39

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.
@@ -52,6 +52,43 @@ export interface InitOrgCryptoRequest {
52
52
  organizationKeys: Map<Uuid, AsymmetricEncString>;
53
53
  }
54
54
 
55
+ export interface MakeKeyPairResponse {
56
+ /**
57
+ * The user\'s public key
58
+ */
59
+ userPublicKey: string;
60
+ /**
61
+ * User\'s private key, encrypted with the user key
62
+ */
63
+ userKeyEncryptedPrivateKey: EncString;
64
+ }
65
+
66
+ export interface VerifyAsymmetricKeysRequest {
67
+ /**
68
+ * The user\'s user key
69
+ */
70
+ userKey: string;
71
+ /**
72
+ * The user\'s public key
73
+ */
74
+ userPublicKey: string;
75
+ /**
76
+ * User\'s private key, encrypted with the user key
77
+ */
78
+ userKeyEncryptedPrivateKey: EncString;
79
+ }
80
+
81
+ export interface VerifyAsymmetricKeysResponse {
82
+ /**
83
+ * Whether the user\'s private key was decryptable by the user key.
84
+ */
85
+ privateKeyDecryptable: boolean;
86
+ /**
87
+ * Whether the user\'s private key was a valid RSA key and matched the public key provided.
88
+ */
89
+ validPrivateKey: boolean;
90
+ }
91
+
55
92
  export interface CoreError extends Error {
56
93
  name: "CoreError";
57
94
  variant:
@@ -242,6 +279,17 @@ export class ClientCrypto {
242
279
  * `initialize_user_crypto` but before any other crypto operations.
243
280
  */
244
281
  initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
282
+ /**
283
+ * Generates a new key pair and encrypts the private key with the provided user key.
284
+ * Crypto initialization not required.
285
+ */
286
+ make_key_pair(user_key: string): MakeKeyPairResponse;
287
+ /**
288
+ * Verifies a user's asymmetric keys by decrypting the private key with the provided user
289
+ * key. Returns if the private key is decryptable and if it is a valid matching key.
290
+ * Crypto initialization not required.
291
+ */
292
+ verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
245
293
  }
246
294
  export class ClientFolders {
247
295
  private constructor();
@@ -326,7 +326,7 @@ function __wbg_adapter_38(arg0, arg1, arg2) {
326
326
  );
327
327
  }
328
328
 
329
- function __wbg_adapter_125(arg0, arg1, arg2, arg3) {
329
+ function __wbg_adapter_127(arg0, arg1, arg2, arg3) {
330
330
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h1aea760ed40205bc(
331
331
  arg0,
332
332
  arg1,
@@ -509,6 +509,51 @@ export class ClientCrypto {
509
509
  const ret = wasm.clientcrypto_initialize_org_crypto(this.__wbg_ptr, addHeapObject(req));
510
510
  return takeObject(ret);
511
511
  }
512
+ /**
513
+ * Generates a new key pair and encrypts the private key with the provided user key.
514
+ * Crypto initialization not required.
515
+ * @param {string} user_key
516
+ * @returns {MakeKeyPairResponse}
517
+ */
518
+ make_key_pair(user_key) {
519
+ try {
520
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
521
+ const ptr0 = passStringToWasm0(user_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
522
+ const len0 = WASM_VECTOR_LEN;
523
+ wasm.clientcrypto_make_key_pair(retptr, this.__wbg_ptr, ptr0, len0);
524
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
525
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
526
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
527
+ if (r2) {
528
+ throw takeObject(r1);
529
+ }
530
+ return takeObject(r0);
531
+ } finally {
532
+ wasm.__wbindgen_add_to_stack_pointer(16);
533
+ }
534
+ }
535
+ /**
536
+ * Verifies a user's asymmetric keys by decrypting the private key with the provided user
537
+ * key. Returns if the private key is decryptable and if it is a valid matching key.
538
+ * Crypto initialization not required.
539
+ * @param {VerifyAsymmetricKeysRequest} request
540
+ * @returns {VerifyAsymmetricKeysResponse}
541
+ */
542
+ verify_asymmetric_keys(request) {
543
+ try {
544
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
545
+ wasm.clientcrypto_verify_asymmetric_keys(retptr, this.__wbg_ptr, addHeapObject(request));
546
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
547
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
548
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
549
+ if (r2) {
550
+ throw takeObject(r1);
551
+ }
552
+ return takeObject(r0);
553
+ } finally {
554
+ wasm.__wbindgen_add_to_stack_pointer(16);
555
+ }
556
+ }
512
557
  }
513
558
 
514
559
  const ClientFoldersFinalization =
@@ -823,7 +868,7 @@ export function __wbg_new_3d446df9155128ef(arg0, arg1) {
823
868
  const a = state0.a;
824
869
  state0.a = 0;
825
870
  try {
826
- return __wbg_adapter_125(a, state0.b, arg0, arg1);
871
+ return __wbg_adapter_127(a, state0.b, arg0, arg1);
827
872
  } finally {
828
873
  state0.a = a;
829
874
  }
@@ -1128,8 +1173,8 @@ export function __wbindgen_cb_drop(arg0) {
1128
1173
  return ret;
1129
1174
  }
1130
1175
 
1131
- export function __wbindgen_closure_wrapper1832(arg0, arg1, arg2) {
1132
- const ret = makeMutClosure(arg0, arg1, 491, __wbg_adapter_38);
1176
+ export function __wbindgen_closure_wrapper1933(arg0, arg1, arg2) {
1177
+ const ret = makeMutClosure(arg0, arg1, 549, __wbg_adapter_38);
1133
1178
  return addHeapObject(ret);
1134
1179
  }
1135
1180
 
Binary file
@@ -14,6 +14,8 @@ export const bitwardenclient_crypto: (a: number) => number;
14
14
  export const isTestError: (a: number) => number;
15
15
  export const clientcrypto_initialize_user_crypto: (a: number, b: number) => number;
16
16
  export const clientcrypto_initialize_org_crypto: (a: number, b: number) => number;
17
+ export const clientcrypto_make_key_pair: (a: number, b: number, c: number, d: number) => void;
18
+ export const clientcrypto_verify_asymmetric_keys: (a: number, b: number, c: number) => void;
17
19
  export const generate_ssh_key: (a: number, b: number) => void;
18
20
  export const clientfolders_decrypt: (a: number, b: number, c: number) => void;
19
21
  export const __wbg_clientcrypto_free: (a: number, b: number) => void;