@bitwarden/sdk-internal 0.2.0-main.136 → 0.2.0-main.138

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
 
@@ -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_wrapper2559 = 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;
@@ -116,6 +117,7 @@ export const clientciphers_encrypt: (a: number, b: number, c: number) => void;
116
117
  export const clientciphers_decrypt: (a: number, b: number, c: number) => void;
117
118
  export const clientciphers_decrypt_list: (a: number, b: number, c: number, d: number) => void;
118
119
  export const clientciphers_decrypt_fido2_credentials: (a: number, b: number, c: number) => void;
120
+ export const clientciphers_decrypt_fido2_private_key: (a: number, b: number, c: number) => void;
119
121
  export const clientfolders_decrypt: (a: number, b: number, c: number) => void;
120
122
  export const clienttotp_generate_totp: (
121
123
  a: number,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitwarden/sdk-internal",
3
- "version": "0.2.0-main.136",
3
+ "version": "0.2.0-main.138",
4
4
  "license": "GPL-3.0",
5
5
  "files": [
6
6
  "bitwarden_wasm_internal_bg.js",