@bitwarden/sdk-internal 0.2.0-main.45 → 0.2.0-main.47

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,6 +1,32 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function generate_ssh_key(key_algorithm: KeyAlgorithm): GenerateSshKeyResult;
3
+ /**
4
+ * Generate a new SSH key pair
5
+ *
6
+ * # Arguments
7
+ * - `key_algorithm` - The algorithm to use for the key pair
8
+ *
9
+ * # Returns
10
+ * - `Ok(SshKey)` if the key was successfully generated
11
+ * - `Err(KeyGenerationError)` if the key could not be generated
12
+ */
13
+ export function generate_ssh_key(key_algorithm: KeyAlgorithm): SshKey;
14
+ /**
15
+ * Convert a PCKS8 or OpenSSH encrypted or unencrypted private key
16
+ * to an OpenSSH private key with public key and fingerprint
17
+ *
18
+ * # Arguments
19
+ * - `imported_key` - The private key to convert
20
+ * - `password` - The password to use for decrypting the key
21
+ *
22
+ * # Returns
23
+ * - `Ok(SshKey)` if the key was successfully coneverted
24
+ * - `Err(PasswordRequired)` if the key is encrypted and no password was provided
25
+ * - `Err(WrongPassword)` if the password provided is incorrect
26
+ * - `Err(ParsingError)` if the key could not be parsed
27
+ * - `Err(UnsupportedKeyType)` if the key type is not supported
28
+ */
29
+ export function import_ssh_key(imported_key: string, password?: string): SshKey;
4
30
  export enum LogLevel {
5
31
  Trace = 0,
6
32
  Debug = 1,
@@ -199,7 +225,10 @@ export type Kdf =
199
225
  | { pBKDF2: { iterations: NonZeroU32 } }
200
226
  | { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
201
227
 
202
- export interface GenerateSshKeyResult {
228
+ export interface SshKey {
229
+ /**
230
+ * The private key in OpenSSH format
231
+ */
203
232
  private_key: string;
204
233
  public_key: string;
205
234
  key_fingerprint: string;
@@ -207,6 +236,20 @@ export interface GenerateSshKeyResult {
207
236
 
208
237
  export type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
209
238
 
239
+ export interface SshKeyExportError extends Error {
240
+ name: "SshKeyExportError";
241
+ variant: "KeyConversionError";
242
+ }
243
+
244
+ export function isSshKeyExportError(error: any): error is SshKeyExportError;
245
+
246
+ export interface SshKeyImportError extends Error {
247
+ name: "SshKeyImportError";
248
+ variant: "ParsingError" | "PasswordRequired" | "WrongPassword" | "UnsupportedKeyType";
249
+ }
250
+
251
+ export function isSshKeyImportError(error: any): error is SshKeyImportError;
252
+
210
253
  export interface KeyGenerationError extends Error {
211
254
  name: "KeyGenerationError";
212
255
  variant: "KeyGenerationError" | "KeyConversionError";
@@ -263,10 +306,18 @@ export class BitwardenClient {
263
306
  * Test method, calls http endpoint
264
307
  */
265
308
  http_get(url: string): Promise<string>;
266
- crypto(): ClientCrypto;
267
- vault(): ClientVault;
309
+ crypto(): CryptoClient;
310
+ vault(): VaultClient;
268
311
  }
269
- export class ClientCrypto {
312
+ export class ClientFolders {
313
+ private constructor();
314
+ free(): void;
315
+ /**
316
+ * Decrypt folder
317
+ */
318
+ decrypt(folder: Folder): FolderView;
319
+ }
320
+ export class CryptoClient {
270
321
  private constructor();
271
322
  free(): void;
272
323
  /**
@@ -291,15 +342,7 @@ export class ClientCrypto {
291
342
  */
292
343
  verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
293
344
  }
294
- export class ClientFolders {
295
- private constructor();
296
- free(): void;
297
- /**
298
- * Decrypt folder
299
- */
300
- decrypt(folder: Folder): FolderView;
301
- }
302
- export class ClientVault {
345
+ export class VaultClient {
303
346
  private constructor();
304
347
  free(): void;
305
348
  folders(): ClientFolders;
@@ -266,6 +266,32 @@ module.exports.isEncryptionSettingsError = function (error) {
266
266
  }
267
267
  };
268
268
 
269
+ /**
270
+ * @param {any} error
271
+ * @returns {boolean}
272
+ */
273
+ module.exports.isSshKeyExportError = function (error) {
274
+ try {
275
+ const ret = wasm.isSshKeyExportError(addBorrowedObject(error));
276
+ return ret !== 0;
277
+ } finally {
278
+ heap[stack_pointer++] = undefined;
279
+ }
280
+ };
281
+
282
+ /**
283
+ * @param {any} error
284
+ * @returns {boolean}
285
+ */
286
+ module.exports.isSshKeyImportError = function (error) {
287
+ try {
288
+ const ret = wasm.isSshKeyImportError(addBorrowedObject(error));
289
+ return ret !== 0;
290
+ } finally {
291
+ heap[stack_pointer++] = undefined;
292
+ }
293
+ };
294
+
269
295
  /**
270
296
  * @param {any} error
271
297
  * @returns {boolean}
@@ -293,8 +319,16 @@ module.exports.isTestError = function (error) {
293
319
  };
294
320
 
295
321
  /**
322
+ * Generate a new SSH key pair
323
+ *
324
+ * # Arguments
325
+ * - `key_algorithm` - The algorithm to use for the key pair
326
+ *
327
+ * # Returns
328
+ * - `Ok(SshKey)` if the key was successfully generated
329
+ * - `Err(KeyGenerationError)` if the key could not be generated
296
330
  * @param {KeyAlgorithm} key_algorithm
297
- * @returns {GenerateSshKeyResult}
331
+ * @returns {SshKey}
298
332
  */
299
333
  module.exports.generate_ssh_key = function (key_algorithm) {
300
334
  try {
@@ -312,6 +346,46 @@ module.exports.generate_ssh_key = function (key_algorithm) {
312
346
  }
313
347
  };
314
348
 
349
+ /**
350
+ * Convert a PCKS8 or OpenSSH encrypted or unencrypted private key
351
+ * to an OpenSSH private key with public key and fingerprint
352
+ *
353
+ * # Arguments
354
+ * - `imported_key` - The private key to convert
355
+ * - `password` - The password to use for decrypting the key
356
+ *
357
+ * # Returns
358
+ * - `Ok(SshKey)` if the key was successfully coneverted
359
+ * - `Err(PasswordRequired)` if the key is encrypted and no password was provided
360
+ * - `Err(WrongPassword)` if the password provided is incorrect
361
+ * - `Err(ParsingError)` if the key could not be parsed
362
+ * - `Err(UnsupportedKeyType)` if the key type is not supported
363
+ * @param {string} imported_key
364
+ * @param {string | undefined} [password]
365
+ * @returns {SshKey}
366
+ */
367
+ module.exports.import_ssh_key = function (imported_key, password) {
368
+ try {
369
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
370
+ const ptr0 = passStringToWasm0(imported_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
371
+ const len0 = WASM_VECTOR_LEN;
372
+ var ptr1 = isLikeNone(password)
373
+ ? 0
374
+ : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
375
+ var len1 = WASM_VECTOR_LEN;
376
+ wasm.import_ssh_key(retptr, ptr0, len0, ptr1, len1);
377
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
378
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
379
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
380
+ if (r2) {
381
+ throw takeObject(r1);
382
+ }
383
+ return takeObject(r0);
384
+ } finally {
385
+ wasm.__wbindgen_add_to_stack_pointer(16);
386
+ }
387
+ };
388
+
315
389
  function __wbg_adapter_38(arg0, arg1, arg2) {
316
390
  wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb80710307d9edf75(
317
391
  arg0,
@@ -320,7 +394,7 @@ function __wbg_adapter_38(arg0, arg1, arg2) {
320
394
  );
321
395
  }
322
396
 
323
- function __wbg_adapter_127(arg0, arg1, arg2, arg3) {
397
+ function __wbg_adapter_130(arg0, arg1, arg2, arg3) {
324
398
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h1aea760ed40205bc(
325
399
  arg0,
326
400
  arg1,
@@ -451,46 +525,94 @@ class BitwardenClient {
451
525
  return takeObject(ret);
452
526
  }
453
527
  /**
454
- * @returns {ClientCrypto}
528
+ * @returns {CryptoClient}
455
529
  */
456
530
  crypto() {
457
531
  const ret = wasm.bitwardenclient_crypto(this.__wbg_ptr);
458
- return ClientCrypto.__wrap(ret);
532
+ return CryptoClient.__wrap(ret);
459
533
  }
460
534
  /**
461
- * @returns {ClientVault}
535
+ * @returns {VaultClient}
462
536
  */
463
537
  vault() {
464
538
  const ret = wasm.bitwardenclient_crypto(this.__wbg_ptr);
465
- return ClientVault.__wrap(ret);
539
+ return VaultClient.__wrap(ret);
466
540
  }
467
541
  }
468
542
  module.exports.BitwardenClient = BitwardenClient;
469
543
 
470
- const ClientCryptoFinalization =
544
+ const ClientFoldersFinalization =
471
545
  typeof FinalizationRegistry === "undefined"
472
546
  ? { register: () => {}, unregister: () => {} }
473
- : new FinalizationRegistry((ptr) => wasm.__wbg_clientcrypto_free(ptr >>> 0, 1));
547
+ : new FinalizationRegistry((ptr) => wasm.__wbg_clientfolders_free(ptr >>> 0, 1));
474
548
 
475
- class ClientCrypto {
549
+ class ClientFolders {
476
550
  static __wrap(ptr) {
477
551
  ptr = ptr >>> 0;
478
- const obj = Object.create(ClientCrypto.prototype);
552
+ const obj = Object.create(ClientFolders.prototype);
479
553
  obj.__wbg_ptr = ptr;
480
- ClientCryptoFinalization.register(obj, obj.__wbg_ptr, obj);
554
+ ClientFoldersFinalization.register(obj, obj.__wbg_ptr, obj);
481
555
  return obj;
482
556
  }
483
557
 
484
558
  __destroy_into_raw() {
485
559
  const ptr = this.__wbg_ptr;
486
560
  this.__wbg_ptr = 0;
487
- ClientCryptoFinalization.unregister(this);
561
+ ClientFoldersFinalization.unregister(this);
488
562
  return ptr;
489
563
  }
490
564
 
491
565
  free() {
492
566
  const ptr = this.__destroy_into_raw();
493
- wasm.__wbg_clientcrypto_free(ptr, 0);
567
+ wasm.__wbg_clientfolders_free(ptr, 0);
568
+ }
569
+ /**
570
+ * Decrypt folder
571
+ * @param {Folder} folder
572
+ * @returns {FolderView}
573
+ */
574
+ decrypt(folder) {
575
+ try {
576
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
577
+ wasm.clientfolders_decrypt(retptr, this.__wbg_ptr, addHeapObject(folder));
578
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
579
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
580
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
581
+ if (r2) {
582
+ throw takeObject(r1);
583
+ }
584
+ return takeObject(r0);
585
+ } finally {
586
+ wasm.__wbindgen_add_to_stack_pointer(16);
587
+ }
588
+ }
589
+ }
590
+ module.exports.ClientFolders = ClientFolders;
591
+
592
+ const CryptoClientFinalization =
593
+ typeof FinalizationRegistry === "undefined"
594
+ ? { register: () => {}, unregister: () => {} }
595
+ : new FinalizationRegistry((ptr) => wasm.__wbg_cryptoclient_free(ptr >>> 0, 1));
596
+
597
+ class CryptoClient {
598
+ static __wrap(ptr) {
599
+ ptr = ptr >>> 0;
600
+ const obj = Object.create(CryptoClient.prototype);
601
+ obj.__wbg_ptr = ptr;
602
+ CryptoClientFinalization.register(obj, obj.__wbg_ptr, obj);
603
+ return obj;
604
+ }
605
+
606
+ __destroy_into_raw() {
607
+ const ptr = this.__wbg_ptr;
608
+ this.__wbg_ptr = 0;
609
+ CryptoClientFinalization.unregister(this);
610
+ return ptr;
611
+ }
612
+
613
+ free() {
614
+ const ptr = this.__destroy_into_raw();
615
+ wasm.__wbg_cryptoclient_free(ptr, 0);
494
616
  }
495
617
  /**
496
618
  * Initialization method for the user crypto. Needs to be called before any other crypto
@@ -499,7 +621,7 @@ class ClientCrypto {
499
621
  * @returns {Promise<void>}
500
622
  */
501
623
  initialize_user_crypto(req) {
502
- const ret = wasm.clientcrypto_initialize_user_crypto(this.__wbg_ptr, addHeapObject(req));
624
+ const ret = wasm.cryptoclient_initialize_user_crypto(this.__wbg_ptr, addHeapObject(req));
503
625
  return takeObject(ret);
504
626
  }
505
627
  /**
@@ -509,7 +631,7 @@ class ClientCrypto {
509
631
  * @returns {Promise<void>}
510
632
  */
511
633
  initialize_org_crypto(req) {
512
- const ret = wasm.clientcrypto_initialize_org_crypto(this.__wbg_ptr, addHeapObject(req));
634
+ const ret = wasm.cryptoclient_initialize_org_crypto(this.__wbg_ptr, addHeapObject(req));
513
635
  return takeObject(ret);
514
636
  }
515
637
  /**
@@ -523,7 +645,7 @@ class ClientCrypto {
523
645
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
524
646
  const ptr0 = passStringToWasm0(user_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
525
647
  const len0 = WASM_VECTOR_LEN;
526
- wasm.clientcrypto_make_key_pair(retptr, this.__wbg_ptr, ptr0, len0);
648
+ wasm.cryptoclient_make_key_pair(retptr, this.__wbg_ptr, ptr0, len0);
527
649
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
528
650
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
529
651
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -545,7 +667,7 @@ class ClientCrypto {
545
667
  verify_asymmetric_keys(request) {
546
668
  try {
547
669
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
548
- wasm.clientcrypto_verify_asymmetric_keys(retptr, this.__wbg_ptr, addHeapObject(request));
670
+ wasm.cryptoclient_verify_asymmetric_keys(retptr, this.__wbg_ptr, addHeapObject(request));
549
671
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
550
672
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
551
673
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -558,80 +680,32 @@ class ClientCrypto {
558
680
  }
559
681
  }
560
682
  }
561
- module.exports.ClientCrypto = ClientCrypto;
562
-
563
- const ClientFoldersFinalization =
564
- typeof FinalizationRegistry === "undefined"
565
- ? { register: () => {}, unregister: () => {} }
566
- : new FinalizationRegistry((ptr) => wasm.__wbg_clientfolders_free(ptr >>> 0, 1));
567
-
568
- class ClientFolders {
569
- static __wrap(ptr) {
570
- ptr = ptr >>> 0;
571
- const obj = Object.create(ClientFolders.prototype);
572
- obj.__wbg_ptr = ptr;
573
- ClientFoldersFinalization.register(obj, obj.__wbg_ptr, obj);
574
- return obj;
575
- }
576
-
577
- __destroy_into_raw() {
578
- const ptr = this.__wbg_ptr;
579
- this.__wbg_ptr = 0;
580
- ClientFoldersFinalization.unregister(this);
581
- return ptr;
582
- }
583
-
584
- free() {
585
- const ptr = this.__destroy_into_raw();
586
- wasm.__wbg_clientfolders_free(ptr, 0);
587
- }
588
- /**
589
- * Decrypt folder
590
- * @param {Folder} folder
591
- * @returns {FolderView}
592
- */
593
- decrypt(folder) {
594
- try {
595
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
596
- wasm.clientfolders_decrypt(retptr, this.__wbg_ptr, addHeapObject(folder));
597
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
598
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
599
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
600
- if (r2) {
601
- throw takeObject(r1);
602
- }
603
- return takeObject(r0);
604
- } finally {
605
- wasm.__wbindgen_add_to_stack_pointer(16);
606
- }
607
- }
608
- }
609
- module.exports.ClientFolders = ClientFolders;
683
+ module.exports.CryptoClient = CryptoClient;
610
684
 
611
- const ClientVaultFinalization =
685
+ const VaultClientFinalization =
612
686
  typeof FinalizationRegistry === "undefined"
613
687
  ? { register: () => {}, unregister: () => {} }
614
- : new FinalizationRegistry((ptr) => wasm.__wbg_clientvault_free(ptr >>> 0, 1));
688
+ : new FinalizationRegistry((ptr) => wasm.__wbg_vaultclient_free(ptr >>> 0, 1));
615
689
 
616
- class ClientVault {
690
+ class VaultClient {
617
691
  static __wrap(ptr) {
618
692
  ptr = ptr >>> 0;
619
- const obj = Object.create(ClientVault.prototype);
693
+ const obj = Object.create(VaultClient.prototype);
620
694
  obj.__wbg_ptr = ptr;
621
- ClientVaultFinalization.register(obj, obj.__wbg_ptr, obj);
695
+ VaultClientFinalization.register(obj, obj.__wbg_ptr, obj);
622
696
  return obj;
623
697
  }
624
698
 
625
699
  __destroy_into_raw() {
626
700
  const ptr = this.__wbg_ptr;
627
701
  this.__wbg_ptr = 0;
628
- ClientVaultFinalization.unregister(this);
702
+ VaultClientFinalization.unregister(this);
629
703
  return ptr;
630
704
  }
631
705
 
632
706
  free() {
633
707
  const ptr = this.__destroy_into_raw();
634
- wasm.__wbg_clientvault_free(ptr, 0);
708
+ wasm.__wbg_vaultclient_free(ptr, 0);
635
709
  }
636
710
  /**
637
711
  * @returns {ClientFolders}
@@ -641,7 +715,7 @@ class ClientVault {
641
715
  return ClientFolders.__wrap(ret);
642
716
  }
643
717
  }
644
- module.exports.ClientVault = ClientVault;
718
+ module.exports.VaultClient = VaultClient;
645
719
 
646
720
  module.exports.__wbg_String_8f0eb39a4a4c2f66 = function (arg0, arg1) {
647
721
  const ret = String(getObject(arg1));
@@ -874,7 +948,7 @@ module.exports.__wbg_new_3d446df9155128ef = function (arg0, arg1) {
874
948
  const a = state0.a;
875
949
  state0.a = 0;
876
950
  try {
877
- return __wbg_adapter_127(a, state0.b, arg0, arg1);
951
+ return __wbg_adapter_130(a, state0.b, arg0, arg1);
878
952
  } finally {
879
953
  state0.a = a;
880
954
  }
@@ -1179,8 +1253,8 @@ module.exports.__wbindgen_cb_drop = function (arg0) {
1179
1253
  return ret;
1180
1254
  };
1181
1255
 
1182
- module.exports.__wbindgen_closure_wrapper1929 = function (arg0, arg1, arg2) {
1183
- const ret = makeMutClosure(arg0, arg1, 545, __wbg_adapter_38);
1256
+ module.exports.__wbindgen_closure_wrapper2041 = function (arg0, arg1, arg2) {
1257
+ const ret = makeMutClosure(arg0, arg1, 546, __wbg_adapter_38);
1184
1258
  return addHeapObject(ret);
1185
1259
  };
1186
1260
 
@@ -3,6 +3,8 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const isCoreError: (a: number) => number;
5
5
  export const isEncryptionSettingsError: (a: number) => number;
6
+ export const isSshKeyExportError: (a: number) => number;
7
+ export const isSshKeyImportError: (a: number) => number;
6
8
  export const isKeyGenerationError: (a: number) => number;
7
9
  export const __wbg_bitwardenclient_free: (a: number, b: number) => void;
8
10
  export const bitwardenclient_new: (a: number, b: number) => number;
@@ -12,17 +14,18 @@ export const bitwardenclient_throw: (a: number, b: number, c: number, d: number)
12
14
  export const bitwardenclient_http_get: (a: number, b: number, c: number) => number;
13
15
  export const bitwardenclient_crypto: (a: number) => number;
14
16
  export const isTestError: (a: number) => number;
15
- export const clientcrypto_initialize_user_crypto: (a: number, b: number) => number;
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
+ export const cryptoclient_initialize_user_crypto: (a: number, b: number) => number;
18
+ export const cryptoclient_initialize_org_crypto: (a: number, b: number) => number;
19
+ export const cryptoclient_make_key_pair: (a: number, b: number, c: number, d: number) => void;
20
+ export const cryptoclient_verify_asymmetric_keys: (a: number, b: number, c: number) => void;
19
21
  export const generate_ssh_key: (a: number, b: number) => void;
22
+ export const import_ssh_key: (a: number, b: number, c: number, d: number, e: number) => void;
20
23
  export const clientfolders_decrypt: (a: number, b: number, c: number) => void;
21
- export const __wbg_clientcrypto_free: (a: number, b: number) => void;
24
+ export const __wbg_cryptoclient_free: (a: number, b: number) => void;
22
25
  export const __wbg_clientfolders_free: (a: number, b: number) => void;
23
- export const __wbg_clientvault_free: (a: number, b: number) => void;
26
+ export const __wbg_vaultclient_free: (a: number, b: number) => void;
24
27
  export const bitwardenclient_vault: (a: number) => number;
25
- export const clientvault_folders: (a: number) => number;
28
+ export const vaultclient_folders: (a: number) => number;
26
29
  export const __wbindgen_malloc: (a: number, b: number) => number;
27
30
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
28
31
  export const __wbindgen_exn_store: (a: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitwarden/sdk-internal",
3
- "version": "0.2.0-main.45",
3
+ "version": "0.2.0-main.47",
4
4
  "license": "GPL-3.0",
5
5
  "files": [
6
6
  "bitwarden_wasm_internal_bg.js",