@bitwarden/sdk-internal 0.2.0-main.200 → 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.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 4f00e70056a75092997d555f641fc1f0b52eba80
1
+ e147b4d566abe533e0a72eff8f4bc15d6b7b5751
@@ -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
  */
@@ -157,6 +161,56 @@ export interface InitOrgCryptoRequest {
157
161
  organizationKeys: Map<Uuid, UnsignedSharedKey>;
158
162
  }
159
163
 
164
+ /**
165
+ * Response from the `update_password` function
166
+ */
167
+ export interface UpdatePasswordResponse {
168
+ /**
169
+ * Hash of the new password
170
+ */
171
+ passwordHash: string;
172
+ /**
173
+ * User key, encrypted with the new password
174
+ */
175
+ newKey: EncString;
176
+ }
177
+
178
+ /**
179
+ * Request for deriving a pin protected user key
180
+ */
181
+ export interface DerivePinKeyResponse {
182
+ /**
183
+ * [UserKey] protected by PIN
184
+ */
185
+ pinProtectedUserKey: EncString;
186
+ /**
187
+ * PIN protected by [UserKey]
188
+ */
189
+ encryptedPin: EncString;
190
+ }
191
+
192
+ /**
193
+ * Request for migrating an account from password to key connector.
194
+ */
195
+ export interface DeriveKeyConnectorRequest {
196
+ /**
197
+ * Encrypted user key, used to validate the master key
198
+ */
199
+ userKeyEncrypted: EncString;
200
+ /**
201
+ * The user\'s master password
202
+ */
203
+ password: string;
204
+ /**
205
+ * The KDF parameters used to derive the master key
206
+ */
207
+ kdf: Kdf;
208
+ /**
209
+ * The user\'s email address
210
+ */
211
+ email: string;
212
+ }
213
+
160
214
  /**
161
215
  * Response from the `make_key_pair` function
162
216
  */
@@ -203,11 +257,50 @@ export interface VerifyAsymmetricKeysResponse {
203
257
  validPrivateKey: boolean;
204
258
  }
205
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
+
206
278
  /**
207
279
  * NewType wrapper for `OrganizationId`
208
280
  */
209
281
  export type OrganizationId = Tagged<Uuid, "OrganizationId">;
210
282
 
283
+ export interface DeriveKeyConnectorError extends Error {
284
+ name: "DeriveKeyConnectorError";
285
+ variant: "WrongPassword" | "Crypto";
286
+ }
287
+
288
+ export function isDeriveKeyConnectorError(error: any): error is DeriveKeyConnectorError;
289
+
290
+ export interface EnrollAdminPasswordResetError extends Error {
291
+ name: "EnrollAdminPasswordResetError";
292
+ variant: "VaultLocked" | "Crypto" | "InvalidBase64";
293
+ }
294
+
295
+ export function isEnrollAdminPasswordResetError(error: any): error is EnrollAdminPasswordResetError;
296
+
297
+ export interface CryptoClientError extends Error {
298
+ name: "CryptoClientError";
299
+ variant: "NotAuthenticated" | "VaultLocked" | "Crypto";
300
+ }
301
+
302
+ export function isCryptoClientError(error: any): error is CryptoClientError;
303
+
211
304
  export interface EncryptionSettingsError extends Error {
212
305
  name: "EncryptionSettingsError";
213
306
  variant:
@@ -289,6 +382,13 @@ export type UnsignedSharedKey = string;
289
382
 
290
383
  export type EncString = string;
291
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
+
292
392
  /**
293
393
  * Key Derivation Function for Bitwarden Account
294
394
  *
@@ -320,7 +420,10 @@ export interface CryptoError extends Error {
320
420
  | "ZeroNumber"
321
421
  | "OperationNotSupported"
322
422
  | "WrongKeyType"
323
- | "InvalidNonceLength";
423
+ | "WrongCoseKeyId"
424
+ | "InvalidNonceLength"
425
+ | "SignatureError"
426
+ | "EncodingError";
324
427
  }
325
428
 
326
429
  export function isCryptoError(error: any): error is CryptoError;
@@ -1069,6 +1172,9 @@ export class CiphersClient {
1069
1172
  move_to_organization(cipher_view: CipherView, organization_id: OrganizationId): CipherView;
1070
1173
  decrypt_fido2_private_key(cipher_view: CipherView): string;
1071
1174
  }
1175
+ /**
1176
+ * A client for the crypto operations.
1177
+ */
1072
1178
  export class CryptoClient {
1073
1179
  private constructor();
1074
1180
  free(): void;
@@ -1093,6 +1199,10 @@ export class CryptoClient {
1093
1199
  * Crypto initialization not required.
1094
1200
  */
1095
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;
1096
1206
  }
1097
1207
  export class ExporterClient {
1098
1208
  private constructor();
@@ -1337,6 +1447,25 @@ export class PureCrypto {
1337
1447
  encapsulated_key: string,
1338
1448
  decapsulation_key: Uint8Array,
1339
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;
1340
1469
  }
1341
1470
  export class TotpClient {
1342
1471
  private constructor();
@@ -251,6 +251,45 @@ function addBorrowedObject(obj) {
251
251
  heap[--stack_pointer] = obj;
252
252
  return stack_pointer;
253
253
  }
254
+ /**
255
+ * @param {any} error
256
+ * @returns {boolean}
257
+ */
258
+ export function isDeriveKeyConnectorError(error) {
259
+ try {
260
+ const ret = wasm.isDeriveKeyConnectorError(addBorrowedObject(error));
261
+ return ret !== 0;
262
+ } finally {
263
+ heap[stack_pointer++] = undefined;
264
+ }
265
+ }
266
+
267
+ /**
268
+ * @param {any} error
269
+ * @returns {boolean}
270
+ */
271
+ export function isEnrollAdminPasswordResetError(error) {
272
+ try {
273
+ const ret = wasm.isEnrollAdminPasswordResetError(addBorrowedObject(error));
274
+ return ret !== 0;
275
+ } finally {
276
+ heap[stack_pointer++] = undefined;
277
+ }
278
+ }
279
+
280
+ /**
281
+ * @param {any} error
282
+ * @returns {boolean}
283
+ */
284
+ export function isCryptoClientError(error) {
285
+ try {
286
+ const ret = wasm.isCryptoClientError(addBorrowedObject(error));
287
+ return ret !== 0;
288
+ } finally {
289
+ heap[stack_pointer++] = undefined;
290
+ }
291
+ }
292
+
254
293
  /**
255
294
  * @param {any} error
256
295
  * @returns {boolean}
@@ -672,7 +711,7 @@ function __wbg_adapter_56(arg0, arg1, arg2) {
672
711
  );
673
712
  }
674
713
 
675
- function __wbg_adapter_253(arg0, arg1, arg2, arg3) {
714
+ function __wbg_adapter_260(arg0, arg1, arg2, arg3) {
676
715
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h334034c47a371f71(
677
716
  arg0,
678
717
  arg1,
@@ -1196,7 +1235,9 @@ const CryptoClientFinalization =
1196
1235
  typeof FinalizationRegistry === "undefined"
1197
1236
  ? { register: () => {}, unregister: () => {} }
1198
1237
  : new FinalizationRegistry((ptr) => wasm.__wbg_cryptoclient_free(ptr >>> 0, 1));
1199
-
1238
+ /**
1239
+ * A client for the crypto operations.
1240
+ */
1200
1241
  export class CryptoClient {
1201
1242
  static __wrap(ptr) {
1202
1243
  ptr = ptr >>> 0;
@@ -1282,6 +1323,25 @@ export class CryptoClient {
1282
1323
  wasm.__wbindgen_add_to_stack_pointer(16);
1283
1324
  }
1284
1325
  }
1326
+ /**
1327
+ * Makes a new signing key pair and signs the public key for the user
1328
+ * @returns {MakeUserSigningKeysResponse}
1329
+ */
1330
+ make_user_signing_keys_for_enrollment() {
1331
+ try {
1332
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1333
+ wasm.cryptoclient_make_user_signing_keys_for_enrollment(retptr, this.__wbg_ptr);
1334
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1335
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1336
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1337
+ if (r2) {
1338
+ throw takeObject(r1);
1339
+ }
1340
+ return takeObject(r0);
1341
+ } finally {
1342
+ wasm.__wbindgen_add_to_stack_pointer(16);
1343
+ }
1344
+ }
1285
1345
  }
1286
1346
 
1287
1347
  const ExporterClientFinalization =
@@ -2790,6 +2850,88 @@ export class PureCrypto {
2790
2850
  wasm.__wbindgen_add_to_stack_pointer(16);
2791
2851
  }
2792
2852
  }
2853
+ /**
2854
+ * Given a wrapped signing key and the symmetric key it is wrapped with, this returns
2855
+ * the corresponding verifying key.
2856
+ * @param {string} signing_key
2857
+ * @param {Uint8Array} wrapping_key
2858
+ * @returns {Uint8Array}
2859
+ */
2860
+ static verifying_key_for_signing_key(signing_key, wrapping_key) {
2861
+ try {
2862
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2863
+ const ptr0 = passStringToWasm0(signing_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2864
+ const len0 = WASM_VECTOR_LEN;
2865
+ const ptr1 = passArray8ToWasm0(wrapping_key, wasm.__wbindgen_malloc);
2866
+ const len1 = WASM_VECTOR_LEN;
2867
+ wasm.purecrypto_verifying_key_for_signing_key(retptr, ptr0, len0, ptr1, len1);
2868
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2869
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2870
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2871
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2872
+ if (r3) {
2873
+ throw takeObject(r2);
2874
+ }
2875
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
2876
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
2877
+ return v3;
2878
+ } finally {
2879
+ wasm.__wbindgen_add_to_stack_pointer(16);
2880
+ }
2881
+ }
2882
+ /**
2883
+ * Returns the algorithm used for the given verifying key.
2884
+ * @param {Uint8Array} verifying_key
2885
+ * @returns {SignatureAlgorithm}
2886
+ */
2887
+ static key_algorithm_for_verifying_key(verifying_key) {
2888
+ try {
2889
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2890
+ const ptr0 = passArray8ToWasm0(verifying_key, wasm.__wbindgen_malloc);
2891
+ const len0 = WASM_VECTOR_LEN;
2892
+ wasm.purecrypto_key_algorithm_for_verifying_key(retptr, ptr0, len0);
2893
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2894
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2895
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2896
+ if (r2) {
2897
+ throw takeObject(r1);
2898
+ }
2899
+ return takeObject(r0);
2900
+ } finally {
2901
+ wasm.__wbindgen_add_to_stack_pointer(16);
2902
+ }
2903
+ }
2904
+ /**
2905
+ * For a given signing identity (verifying key), this function verifies that the signing
2906
+ * identity claimed ownership of the public key. This is a one-sided claim and merely shows
2907
+ * that the signing identity has the intent to receive messages encrypted to the public
2908
+ * key.
2909
+ * @param {Uint8Array} signed_public_key
2910
+ * @param {Uint8Array} verifying_key
2911
+ * @returns {Uint8Array}
2912
+ */
2913
+ static verify_and_unwrap_signed_public_key(signed_public_key, verifying_key) {
2914
+ try {
2915
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2916
+ const ptr0 = passArray8ToWasm0(signed_public_key, wasm.__wbindgen_malloc);
2917
+ const len0 = WASM_VECTOR_LEN;
2918
+ const ptr1 = passArray8ToWasm0(verifying_key, wasm.__wbindgen_malloc);
2919
+ const len1 = WASM_VECTOR_LEN;
2920
+ wasm.purecrypto_verify_and_unwrap_signed_public_key(retptr, ptr0, len0, ptr1, len1);
2921
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2922
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2923
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2924
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2925
+ if (r3) {
2926
+ throw takeObject(r2);
2927
+ }
2928
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
2929
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
2930
+ return v3;
2931
+ } finally {
2932
+ wasm.__wbindgen_add_to_stack_pointer(16);
2933
+ }
2934
+ }
2793
2935
  }
2794
2936
 
2795
2937
  const TotpClientFinalization =
@@ -3189,7 +3331,7 @@ export function __wbg_new_23a2665fac83c611(arg0, arg1) {
3189
3331
  const a = state0.a;
3190
3332
  state0.a = 0;
3191
3333
  try {
3192
- return __wbg_adapter_253(a, state0.b, arg0, arg1);
3334
+ return __wbg_adapter_260(a, state0.b, arg0, arg1);
3193
3335
  } finally {
3194
3336
  state0.a = a;
3195
3337
  }
@@ -3546,18 +3688,18 @@ export function __wbindgen_cb_drop(arg0) {
3546
3688
  return ret;
3547
3689
  }
3548
3690
 
3549
- export function __wbindgen_closure_wrapper2349(arg0, arg1, arg2) {
3550
- const ret = makeMutClosure(arg0, arg1, 674, __wbg_adapter_50);
3691
+ export function __wbindgen_closure_wrapper2472(arg0, arg1, arg2) {
3692
+ const ret = makeMutClosure(arg0, arg1, 709, __wbg_adapter_50);
3551
3693
  return addHeapObject(ret);
3552
3694
  }
3553
3695
 
3554
- export function __wbindgen_closure_wrapper3188(arg0, arg1, arg2) {
3555
- const ret = makeMutClosure(arg0, arg1, 758, __wbg_adapter_53);
3696
+ export function __wbindgen_closure_wrapper3311(arg0, arg1, arg2) {
3697
+ const ret = makeMutClosure(arg0, arg1, 793, __wbg_adapter_53);
3556
3698
  return addHeapObject(ret);
3557
3699
  }
3558
3700
 
3559
- export function __wbindgen_closure_wrapper3598(arg0, arg1, arg2) {
3560
- const ret = makeMutClosure(arg0, arg1, 880, __wbg_adapter_56);
3701
+ export function __wbindgen_closure_wrapper3724(arg0, arg1, arg2) {
3702
+ const ret = makeMutClosure(arg0, arg1, 916, __wbg_adapter_56);
3561
3703
  return addHeapObject(ret);
3562
3704
  }
3563
3705
 
Binary file
@@ -1,6 +1,15 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
+ export const __wbg_cryptoclient_free: (a: number, b: number) => void;
5
+ export const cryptoclient_initialize_user_crypto: (a: number, b: number) => number;
6
+ export const cryptoclient_initialize_org_crypto: (a: number, b: number) => number;
7
+ export const cryptoclient_make_key_pair: (a: number, b: number, c: number, d: number) => void;
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;
10
+ export const isDeriveKeyConnectorError: (a: number) => number;
11
+ export const isEnrollAdminPasswordResetError: (a: number) => number;
12
+ export const isCryptoClientError: (a: number) => number;
4
13
  export const isEncryptionSettingsError: (a: number) => number;
5
14
  export const isCryptoError: (a: number) => number;
6
15
  export const __wbg_exporterclient_free: (a: number, b: number) => void;
@@ -142,11 +151,6 @@ export const bitwardenclient_version: (a: number, b: number) => void;
142
151
  export const bitwardenclient_throw: (a: number, b: number, c: number, d: number) => void;
143
152
  export const bitwardenclient_http_get: (a: number, b: number, c: number) => number;
144
153
  export const bitwardenclient_crypto: (a: number) => number;
145
- export const __wbg_cryptoclient_free: (a: number, b: number) => void;
146
- export const cryptoclient_initialize_user_crypto: (a: number, b: number) => number;
147
- export const cryptoclient_initialize_org_crypto: (a: number, b: number) => number;
148
- export const cryptoclient_make_key_pair: (a: number, b: number, c: number, d: number) => void;
149
- export const cryptoclient_verify_asymmetric_keys: (a: number, b: number, c: number) => void;
150
154
  export const set_log_level: (a: number) => void;
151
155
  export const init_sdk: (a: number) => void;
152
156
  export const __wbg_purecrypto_free: (a: number, b: number) => void;
@@ -270,6 +274,21 @@ export const purecrypto_decapsulate_key_unsigned: (
270
274
  d: number,
271
275
  e: number,
272
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;
273
292
  export const generate_ssh_key: (a: number, b: number) => void;
274
293
  export const import_ssh_key: (a: number, b: number, c: number, d: number, e: number) => void;
275
294
  export const isTestError: (a: number) => number;