@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;
@@ -272,6 +272,32 @@ export function isEncryptionSettingsError(error) {
272
272
  }
273
273
  }
274
274
 
275
+ /**
276
+ * @param {any} error
277
+ * @returns {boolean}
278
+ */
279
+ export function isSshKeyExportError(error) {
280
+ try {
281
+ const ret = wasm.isSshKeyExportError(addBorrowedObject(error));
282
+ return ret !== 0;
283
+ } finally {
284
+ heap[stack_pointer++] = undefined;
285
+ }
286
+ }
287
+
288
+ /**
289
+ * @param {any} error
290
+ * @returns {boolean}
291
+ */
292
+ export function isSshKeyImportError(error) {
293
+ try {
294
+ const ret = wasm.isSshKeyImportError(addBorrowedObject(error));
295
+ return ret !== 0;
296
+ } finally {
297
+ heap[stack_pointer++] = undefined;
298
+ }
299
+ }
300
+
275
301
  /**
276
302
  * @param {any} error
277
303
  * @returns {boolean}
@@ -299,8 +325,16 @@ export function isTestError(error) {
299
325
  }
300
326
 
301
327
  /**
328
+ * Generate a new SSH key pair
329
+ *
330
+ * # Arguments
331
+ * - `key_algorithm` - The algorithm to use for the key pair
332
+ *
333
+ * # Returns
334
+ * - `Ok(SshKey)` if the key was successfully generated
335
+ * - `Err(KeyGenerationError)` if the key could not be generated
302
336
  * @param {KeyAlgorithm} key_algorithm
303
- * @returns {GenerateSshKeyResult}
337
+ * @returns {SshKey}
304
338
  */
305
339
  export function generate_ssh_key(key_algorithm) {
306
340
  try {
@@ -318,6 +352,46 @@ export function generate_ssh_key(key_algorithm) {
318
352
  }
319
353
  }
320
354
 
355
+ /**
356
+ * Convert a PCKS8 or OpenSSH encrypted or unencrypted private key
357
+ * to an OpenSSH private key with public key and fingerprint
358
+ *
359
+ * # Arguments
360
+ * - `imported_key` - The private key to convert
361
+ * - `password` - The password to use for decrypting the key
362
+ *
363
+ * # Returns
364
+ * - `Ok(SshKey)` if the key was successfully coneverted
365
+ * - `Err(PasswordRequired)` if the key is encrypted and no password was provided
366
+ * - `Err(WrongPassword)` if the password provided is incorrect
367
+ * - `Err(ParsingError)` if the key could not be parsed
368
+ * - `Err(UnsupportedKeyType)` if the key type is not supported
369
+ * @param {string} imported_key
370
+ * @param {string | undefined} [password]
371
+ * @returns {SshKey}
372
+ */
373
+ export function import_ssh_key(imported_key, password) {
374
+ try {
375
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
376
+ const ptr0 = passStringToWasm0(imported_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
377
+ const len0 = WASM_VECTOR_LEN;
378
+ var ptr1 = isLikeNone(password)
379
+ ? 0
380
+ : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
381
+ var len1 = WASM_VECTOR_LEN;
382
+ wasm.import_ssh_key(retptr, ptr0, len0, ptr1, len1);
383
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
384
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
385
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
386
+ if (r2) {
387
+ throw takeObject(r1);
388
+ }
389
+ return takeObject(r0);
390
+ } finally {
391
+ wasm.__wbindgen_add_to_stack_pointer(16);
392
+ }
393
+ }
394
+
321
395
  function __wbg_adapter_38(arg0, arg1, arg2) {
322
396
  wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb80710307d9edf75(
323
397
  arg0,
@@ -326,7 +400,7 @@ function __wbg_adapter_38(arg0, arg1, arg2) {
326
400
  );
327
401
  }
328
402
 
329
- function __wbg_adapter_127(arg0, arg1, arg2, arg3) {
403
+ function __wbg_adapter_130(arg0, arg1, arg2, arg3) {
330
404
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h1aea760ed40205bc(
331
405
  arg0,
332
406
  arg1,
@@ -457,45 +531,92 @@ export class BitwardenClient {
457
531
  return takeObject(ret);
458
532
  }
459
533
  /**
460
- * @returns {ClientCrypto}
534
+ * @returns {CryptoClient}
461
535
  */
462
536
  crypto() {
463
537
  const ret = wasm.bitwardenclient_crypto(this.__wbg_ptr);
464
- return ClientCrypto.__wrap(ret);
538
+ return CryptoClient.__wrap(ret);
465
539
  }
466
540
  /**
467
- * @returns {ClientVault}
541
+ * @returns {VaultClient}
468
542
  */
469
543
  vault() {
470
544
  const ret = wasm.bitwardenclient_crypto(this.__wbg_ptr);
471
- return ClientVault.__wrap(ret);
545
+ return VaultClient.__wrap(ret);
472
546
  }
473
547
  }
474
548
 
475
- const ClientCryptoFinalization =
549
+ const ClientFoldersFinalization =
476
550
  typeof FinalizationRegistry === "undefined"
477
551
  ? { register: () => {}, unregister: () => {} }
478
- : new FinalizationRegistry((ptr) => wasm.__wbg_clientcrypto_free(ptr >>> 0, 1));
552
+ : new FinalizationRegistry((ptr) => wasm.__wbg_clientfolders_free(ptr >>> 0, 1));
479
553
 
480
- export class ClientCrypto {
554
+ export class ClientFolders {
481
555
  static __wrap(ptr) {
482
556
  ptr = ptr >>> 0;
483
- const obj = Object.create(ClientCrypto.prototype);
557
+ const obj = Object.create(ClientFolders.prototype);
484
558
  obj.__wbg_ptr = ptr;
485
- ClientCryptoFinalization.register(obj, obj.__wbg_ptr, obj);
559
+ ClientFoldersFinalization.register(obj, obj.__wbg_ptr, obj);
486
560
  return obj;
487
561
  }
488
562
 
489
563
  __destroy_into_raw() {
490
564
  const ptr = this.__wbg_ptr;
491
565
  this.__wbg_ptr = 0;
492
- ClientCryptoFinalization.unregister(this);
566
+ ClientFoldersFinalization.unregister(this);
493
567
  return ptr;
494
568
  }
495
569
 
496
570
  free() {
497
571
  const ptr = this.__destroy_into_raw();
498
- wasm.__wbg_clientcrypto_free(ptr, 0);
572
+ wasm.__wbg_clientfolders_free(ptr, 0);
573
+ }
574
+ /**
575
+ * Decrypt folder
576
+ * @param {Folder} folder
577
+ * @returns {FolderView}
578
+ */
579
+ decrypt(folder) {
580
+ try {
581
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
582
+ wasm.clientfolders_decrypt(retptr, this.__wbg_ptr, addHeapObject(folder));
583
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
584
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
585
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
586
+ if (r2) {
587
+ throw takeObject(r1);
588
+ }
589
+ return takeObject(r0);
590
+ } finally {
591
+ wasm.__wbindgen_add_to_stack_pointer(16);
592
+ }
593
+ }
594
+ }
595
+
596
+ const CryptoClientFinalization =
597
+ typeof FinalizationRegistry === "undefined"
598
+ ? { register: () => {}, unregister: () => {} }
599
+ : new FinalizationRegistry((ptr) => wasm.__wbg_cryptoclient_free(ptr >>> 0, 1));
600
+
601
+ export class CryptoClient {
602
+ static __wrap(ptr) {
603
+ ptr = ptr >>> 0;
604
+ const obj = Object.create(CryptoClient.prototype);
605
+ obj.__wbg_ptr = ptr;
606
+ CryptoClientFinalization.register(obj, obj.__wbg_ptr, obj);
607
+ return obj;
608
+ }
609
+
610
+ __destroy_into_raw() {
611
+ const ptr = this.__wbg_ptr;
612
+ this.__wbg_ptr = 0;
613
+ CryptoClientFinalization.unregister(this);
614
+ return ptr;
615
+ }
616
+
617
+ free() {
618
+ const ptr = this.__destroy_into_raw();
619
+ wasm.__wbg_cryptoclient_free(ptr, 0);
499
620
  }
500
621
  /**
501
622
  * Initialization method for the user crypto. Needs to be called before any other crypto
@@ -504,7 +625,7 @@ export class ClientCrypto {
504
625
  * @returns {Promise<void>}
505
626
  */
506
627
  initialize_user_crypto(req) {
507
- const ret = wasm.clientcrypto_initialize_user_crypto(this.__wbg_ptr, addHeapObject(req));
628
+ const ret = wasm.cryptoclient_initialize_user_crypto(this.__wbg_ptr, addHeapObject(req));
508
629
  return takeObject(ret);
509
630
  }
510
631
  /**
@@ -514,7 +635,7 @@ export class ClientCrypto {
514
635
  * @returns {Promise<void>}
515
636
  */
516
637
  initialize_org_crypto(req) {
517
- const ret = wasm.clientcrypto_initialize_org_crypto(this.__wbg_ptr, addHeapObject(req));
638
+ const ret = wasm.cryptoclient_initialize_org_crypto(this.__wbg_ptr, addHeapObject(req));
518
639
  return takeObject(ret);
519
640
  }
520
641
  /**
@@ -528,7 +649,7 @@ export class ClientCrypto {
528
649
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
529
650
  const ptr0 = passStringToWasm0(user_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
530
651
  const len0 = WASM_VECTOR_LEN;
531
- wasm.clientcrypto_make_key_pair(retptr, this.__wbg_ptr, ptr0, len0);
652
+ wasm.cryptoclient_make_key_pair(retptr, this.__wbg_ptr, ptr0, len0);
532
653
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
533
654
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
534
655
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -550,54 +671,7 @@ export class ClientCrypto {
550
671
  verify_asymmetric_keys(request) {
551
672
  try {
552
673
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
553
- wasm.clientcrypto_verify_asymmetric_keys(retptr, this.__wbg_ptr, addHeapObject(request));
554
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
555
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
556
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
557
- if (r2) {
558
- throw takeObject(r1);
559
- }
560
- return takeObject(r0);
561
- } finally {
562
- wasm.__wbindgen_add_to_stack_pointer(16);
563
- }
564
- }
565
- }
566
-
567
- const ClientFoldersFinalization =
568
- typeof FinalizationRegistry === "undefined"
569
- ? { register: () => {}, unregister: () => {} }
570
- : new FinalizationRegistry((ptr) => wasm.__wbg_clientfolders_free(ptr >>> 0, 1));
571
-
572
- export class ClientFolders {
573
- static __wrap(ptr) {
574
- ptr = ptr >>> 0;
575
- const obj = Object.create(ClientFolders.prototype);
576
- obj.__wbg_ptr = ptr;
577
- ClientFoldersFinalization.register(obj, obj.__wbg_ptr, obj);
578
- return obj;
579
- }
580
-
581
- __destroy_into_raw() {
582
- const ptr = this.__wbg_ptr;
583
- this.__wbg_ptr = 0;
584
- ClientFoldersFinalization.unregister(this);
585
- return ptr;
586
- }
587
-
588
- free() {
589
- const ptr = this.__destroy_into_raw();
590
- wasm.__wbg_clientfolders_free(ptr, 0);
591
- }
592
- /**
593
- * Decrypt folder
594
- * @param {Folder} folder
595
- * @returns {FolderView}
596
- */
597
- decrypt(folder) {
598
- try {
599
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
600
- wasm.clientfolders_decrypt(retptr, this.__wbg_ptr, addHeapObject(folder));
674
+ wasm.cryptoclient_verify_asymmetric_keys(retptr, this.__wbg_ptr, addHeapObject(request));
601
675
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
602
676
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
603
677
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -611,30 +685,30 @@ export class ClientFolders {
611
685
  }
612
686
  }
613
687
 
614
- const ClientVaultFinalization =
688
+ const VaultClientFinalization =
615
689
  typeof FinalizationRegistry === "undefined"
616
690
  ? { register: () => {}, unregister: () => {} }
617
- : new FinalizationRegistry((ptr) => wasm.__wbg_clientvault_free(ptr >>> 0, 1));
691
+ : new FinalizationRegistry((ptr) => wasm.__wbg_vaultclient_free(ptr >>> 0, 1));
618
692
 
619
- export class ClientVault {
693
+ export class VaultClient {
620
694
  static __wrap(ptr) {
621
695
  ptr = ptr >>> 0;
622
- const obj = Object.create(ClientVault.prototype);
696
+ const obj = Object.create(VaultClient.prototype);
623
697
  obj.__wbg_ptr = ptr;
624
- ClientVaultFinalization.register(obj, obj.__wbg_ptr, obj);
698
+ VaultClientFinalization.register(obj, obj.__wbg_ptr, obj);
625
699
  return obj;
626
700
  }
627
701
 
628
702
  __destroy_into_raw() {
629
703
  const ptr = this.__wbg_ptr;
630
704
  this.__wbg_ptr = 0;
631
- ClientVaultFinalization.unregister(this);
705
+ VaultClientFinalization.unregister(this);
632
706
  return ptr;
633
707
  }
634
708
 
635
709
  free() {
636
710
  const ptr = this.__destroy_into_raw();
637
- wasm.__wbg_clientvault_free(ptr, 0);
711
+ wasm.__wbg_vaultclient_free(ptr, 0);
638
712
  }
639
713
  /**
640
714
  * @returns {ClientFolders}
@@ -876,7 +950,7 @@ export function __wbg_new_3d446df9155128ef(arg0, arg1) {
876
950
  const a = state0.a;
877
951
  state0.a = 0;
878
952
  try {
879
- return __wbg_adapter_127(a, state0.b, arg0, arg1);
953
+ return __wbg_adapter_130(a, state0.b, arg0, arg1);
880
954
  } finally {
881
955
  state0.a = a;
882
956
  }
@@ -1181,8 +1255,8 @@ export function __wbindgen_cb_drop(arg0) {
1181
1255
  return ret;
1182
1256
  }
1183
1257
 
1184
- export function __wbindgen_closure_wrapper1929(arg0, arg1, arg2) {
1185
- const ret = makeMutClosure(arg0, arg1, 545, __wbg_adapter_38);
1258
+ export function __wbindgen_closure_wrapper2041(arg0, arg1, arg2) {
1259
+ const ret = makeMutClosure(arg0, arg1, 546, __wbg_adapter_38);
1186
1260
  return addHeapObject(ret);
1187
1261
  }
1188
1262
 
Binary file
@@ -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;