@bitwarden/sdk-internal 0.2.0-main.137 → 0.2.0-main.139

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.
@@ -704,6 +704,13 @@ export interface CipherPermissions {
704
704
  restore: boolean;
705
705
  }
706
706
 
707
+ export interface CipherError extends Error {
708
+ name: "CipherError";
709
+ variant: "MissingFieldError" | "VaultLocked" | "CryptoError" | "AttachmentsWithoutKeys";
710
+ }
711
+
712
+ export function isCipherError(error: any): error is CipherError;
713
+
707
714
  export interface CardView {
708
715
  cardholderName: string | undefined;
709
716
  expMonth: string | undefined;
@@ -830,6 +837,20 @@ export class ClientCiphers {
830
837
  * - `Err(DecryptError)` if decryption fails
831
838
  */
832
839
  decrypt_fido2_credentials(cipher_view: CipherView): Fido2CredentialView[];
840
+ /**
841
+ * Decrypt key
842
+ *
843
+ * This method is a temporary solution to allow typescript client access to decrypted key
844
+ * values, particularly for FIDO2 credentials.
845
+ *
846
+ * # Arguments
847
+ * - `cipher_view` - Decrypted cipher containing the key
848
+ *
849
+ * # Returns
850
+ * - `Ok(String)` containing the decrypted key
851
+ * - `Err(CipherError)`
852
+ */
853
+ decrypt_fido2_private_key(cipher_view: CipherView): string;
833
854
  }
834
855
  export class ClientFolders {
835
856
  private constructor();
@@ -400,6 +400,19 @@ module.exports.isTotpError = function (error) {
400
400
  }
401
401
  };
402
402
 
403
+ /**
404
+ * @param {any} error
405
+ * @returns {boolean}
406
+ */
407
+ module.exports.isCipherError = function (error) {
408
+ try {
409
+ const ret = wasm.isCipherError(addBorrowedObject(error));
410
+ return ret !== 0;
411
+ } finally {
412
+ heap[stack_pointer++] = undefined;
413
+ }
414
+ };
415
+
403
416
  /**
404
417
  * @param {LogLevel} level
405
418
  */
@@ -522,7 +535,7 @@ function __wbg_adapter_50(arg0, arg1, arg2) {
522
535
  );
523
536
  }
524
537
 
525
- function __wbg_adapter_215(arg0, arg1, arg2, arg3) {
538
+ function __wbg_adapter_217(arg0, arg1, arg2, arg3) {
526
539
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h33defb2ea0fdb769(
527
540
  arg0,
528
541
  arg1,
@@ -940,6 +953,50 @@ class ClientCiphers {
940
953
  wasm.__wbindgen_add_to_stack_pointer(16);
941
954
  }
942
955
  }
956
+ /**
957
+ * Decrypt key
958
+ *
959
+ * This method is a temporary solution to allow typescript client access to decrypted key
960
+ * values, particularly for FIDO2 credentials.
961
+ *
962
+ * # Arguments
963
+ * - `cipher_view` - Decrypted cipher containing the key
964
+ *
965
+ * # Returns
966
+ * - `Ok(String)` containing the decrypted key
967
+ * - `Err(CipherError)`
968
+ * @param {CipherView} cipher_view
969
+ * @returns {string}
970
+ */
971
+ decrypt_fido2_private_key(cipher_view) {
972
+ let deferred2_0;
973
+ let deferred2_1;
974
+ try {
975
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
976
+ wasm.clientciphers_decrypt_fido2_private_key(
977
+ retptr,
978
+ this.__wbg_ptr,
979
+ addHeapObject(cipher_view),
980
+ );
981
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
982
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
983
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
984
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
985
+ var ptr1 = r0;
986
+ var len1 = r1;
987
+ if (r3) {
988
+ ptr1 = 0;
989
+ len1 = 0;
990
+ throw takeObject(r2);
991
+ }
992
+ deferred2_0 = ptr1;
993
+ deferred2_1 = len1;
994
+ return getStringFromWasm0(ptr1, len1);
995
+ } finally {
996
+ wasm.__wbindgen_add_to_stack_pointer(16);
997
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
998
+ }
999
+ }
943
1000
  }
944
1001
  module.exports.ClientCiphers = ClientCiphers;
945
1002
 
@@ -1806,21 +1863,21 @@ class VaultClient {
1806
1863
  * @returns {ClientCiphers}
1807
1864
  */
1808
1865
  ciphers() {
1809
- const ret = wasm.bitwardenclient_crypto(this.__wbg_ptr);
1866
+ const ret = wasm.vaultclient_ciphers(this.__wbg_ptr);
1810
1867
  return ClientCiphers.__wrap(ret);
1811
1868
  }
1812
1869
  /**
1813
1870
  * @returns {ClientFolders}
1814
1871
  */
1815
1872
  folders() {
1816
- const ret = wasm.bitwardenclient_crypto(this.__wbg_ptr);
1873
+ const ret = wasm.vaultclient_ciphers(this.__wbg_ptr);
1817
1874
  return ClientFolders.__wrap(ret);
1818
1875
  }
1819
1876
  /**
1820
1877
  * @returns {ClientTotp}
1821
1878
  */
1822
1879
  totp() {
1823
- const ret = wasm.bitwardenclient_crypto(this.__wbg_ptr);
1880
+ const ret = wasm.vaultclient_totp(this.__wbg_ptr);
1824
1881
  return ClientTotp.__wrap(ret);
1825
1882
  }
1826
1883
  }
@@ -2076,7 +2133,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function (arg0, arg1) {
2076
2133
  const a = state0.a;
2077
2134
  state0.a = 0;
2078
2135
  try {
2079
- return __wbg_adapter_215(a, state0.b, arg0, arg1);
2136
+ return __wbg_adapter_217(a, state0.b, arg0, arg1);
2080
2137
  } finally {
2081
2138
  state0.a = a;
2082
2139
  }
@@ -2445,7 +2502,7 @@ module.exports.__wbindgen_cb_drop = function (arg0) {
2445
2502
  return ret;
2446
2503
  };
2447
2504
 
2448
- module.exports.__wbindgen_closure_wrapper2552 = function (arg0, arg1, arg2) {
2505
+ module.exports.__wbindgen_closure_wrapper2563 = function (arg0, arg1, arg2) {
2449
2506
  const ret = makeMutClosure(arg0, arg1, 634, __wbg_adapter_50);
2450
2507
  return addHeapObject(ret);
2451
2508
  };
@@ -61,6 +61,7 @@ export const isEncryptFileError: (a: number) => number;
61
61
  export const isDecryptError: (a: number) => number;
62
62
  export const isEncryptError: (a: number) => number;
63
63
  export const isTotpError: (a: number) => number;
64
+ export const isCipherError: (a: number) => number;
64
65
  export const __wbg_bitwardenclient_free: (a: number, b: number) => void;
65
66
  export const bitwardenclient_new: (a: number) => number;
66
67
  export const bitwardenclient_echo: (a: number, b: number, c: number, d: number) => void;
@@ -112,10 +113,12 @@ export const purecrypto_symmetric_encrypt_to_array_buffer: (
112
113
  ) => void;
113
114
  export const generate_ssh_key: (a: number, b: number) => void;
114
115
  export const import_ssh_key: (a: number, b: number, c: number, d: number, e: number) => void;
116
+ export const __wbg_clientciphers_free: (a: number, b: number) => void;
115
117
  export const clientciphers_encrypt: (a: number, b: number, c: number) => void;
116
118
  export const clientciphers_decrypt: (a: number, b: number, c: number) => void;
117
119
  export const clientciphers_decrypt_list: (a: number, b: number, c: number, d: number) => void;
118
120
  export const clientciphers_decrypt_fido2_credentials: (a: number, b: number, c: number) => void;
121
+ export const clientciphers_decrypt_fido2_private_key: (a: number, b: number, c: number) => void;
119
122
  export const clientfolders_decrypt: (a: number, b: number, c: number) => void;
120
123
  export const clienttotp_generate_totp: (
121
124
  a: number,
@@ -125,16 +128,15 @@ export const clienttotp_generate_totp: (
125
128
  e: number,
126
129
  f: number,
127
130
  ) => void;
131
+ export const vaultclient_ciphers: (a: number) => number;
132
+ export const vaultclient_totp: (a: number) => number;
128
133
  export const isTestError: (a: number) => number;
134
+ export const bitwardenclient_vault: (a: number) => number;
135
+ export const vaultclient_folders: (a: number) => number;
136
+ export const __wbg_clienttotp_free: (a: number, b: number) => void;
129
137
  export const __wbg_cryptoclient_free: (a: number, b: number) => void;
130
- export const __wbg_clientciphers_free: (a: number, b: number) => void;
131
138
  export const __wbg_clientfolders_free: (a: number, b: number) => void;
132
- export const __wbg_clienttotp_free: (a: number, b: number) => void;
133
139
  export const __wbg_vaultclient_free: (a: number, b: number) => void;
134
- export const bitwardenclient_vault: (a: number) => number;
135
- export const vaultclient_ciphers: (a: number) => number;
136
- export const vaultclient_folders: (a: number) => number;
137
- export const vaultclient_totp: (a: number) => number;
138
140
  export const __wbindgen_malloc: (a: number, b: number) => number;
139
141
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
140
142
  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.137",
3
+ "version": "0.2.0-main.139",
4
4
  "license": "GPL-3.0",
5
5
  "files": [
6
6
  "bitwarden_wasm_internal_bg.js",