@bitwarden/sdk-internal 0.2.0-main.143 → 0.2.0-main.145

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.
@@ -672,20 +672,6 @@ export interface FolderView {
672
672
  revisionDate: DateTime<Utc>;
673
673
  }
674
674
 
675
- export interface DecryptFileError extends Error {
676
- name: "DecryptFileError";
677
- variant: "Decrypt" | "Io";
678
- }
679
-
680
- export function isDecryptFileError(error: any): error is DecryptFileError;
681
-
682
- export interface EncryptFileError extends Error {
683
- name: "EncryptFileError";
684
- variant: "Encrypt" | "Io";
685
- }
686
-
687
- export function isEncryptFileError(error: any): error is EncryptFileError;
688
-
689
675
  export interface DecryptError extends Error {
690
676
  name: "DecryptError";
691
677
  variant: "Crypto" | "VaultLocked";
@@ -840,6 +826,20 @@ export interface Card {
840
826
  number: EncString | undefined;
841
827
  }
842
828
 
829
+ export interface DecryptFileError extends Error {
830
+ name: "DecryptFileError";
831
+ variant: "Decrypt" | "Io";
832
+ }
833
+
834
+ export function isDecryptFileError(error: any): error is DecryptFileError;
835
+
836
+ export interface EncryptFileError extends Error {
837
+ name: "EncryptFileError";
838
+ variant: "Encrypt" | "Io";
839
+ }
840
+
841
+ export function isEncryptFileError(error: any): error is EncryptFileError;
842
+
843
843
  export interface AttachmentView {
844
844
  id: string | undefined;
845
845
  url: string | undefined;
@@ -905,6 +905,14 @@ export class BitwardenClient {
905
905
  */
906
906
  generator(): GeneratorClient;
907
907
  }
908
+ export class ClientAttachments {
909
+ private constructor();
910
+ free(): void;
911
+ /**
912
+ * Decrypts an attachment's encrypted content
913
+ */
914
+ decrypt_buffer(cipher: Cipher, attachment: Attachment, encrypted_buffer: Uint8Array): Uint8Array;
915
+ }
908
916
  export class ClientCiphers {
909
917
  private constructor();
910
918
  free(): void;
@@ -1112,6 +1120,7 @@ export class SendError {
1112
1120
  export class VaultClient {
1113
1121
  private constructor();
1114
1122
  free(): void;
1123
+ attachments(): ClientAttachments;
1115
1124
  ciphers(): ClientCiphers;
1116
1125
  folders(): ClientFolders;
1117
1126
  totp(): ClientTotp;
@@ -365,9 +365,9 @@ module.exports.isKeyGenerationError = function (error) {
365
365
  * @param {any} error
366
366
  * @returns {boolean}
367
367
  */
368
- module.exports.isDecryptFileError = function (error) {
368
+ module.exports.isDecryptError = function (error) {
369
369
  try {
370
- const ret = wasm.isDecryptFileError(addBorrowedObject(error));
370
+ const ret = wasm.isDecryptError(addBorrowedObject(error));
371
371
  return ret !== 0;
372
372
  } finally {
373
373
  heap[stack_pointer++] = undefined;
@@ -378,9 +378,9 @@ module.exports.isDecryptFileError = function (error) {
378
378
  * @param {any} error
379
379
  * @returns {boolean}
380
380
  */
381
- module.exports.isEncryptFileError = function (error) {
381
+ module.exports.isEncryptError = function (error) {
382
382
  try {
383
- const ret = wasm.isEncryptFileError(addBorrowedObject(error));
383
+ const ret = wasm.isEncryptError(addBorrowedObject(error));
384
384
  return ret !== 0;
385
385
  } finally {
386
386
  heap[stack_pointer++] = undefined;
@@ -391,9 +391,9 @@ module.exports.isEncryptFileError = function (error) {
391
391
  * @param {any} error
392
392
  * @returns {boolean}
393
393
  */
394
- module.exports.isDecryptError = function (error) {
394
+ module.exports.isTotpError = function (error) {
395
395
  try {
396
- const ret = wasm.isDecryptError(addBorrowedObject(error));
396
+ const ret = wasm.isTotpError(addBorrowedObject(error));
397
397
  return ret !== 0;
398
398
  } finally {
399
399
  heap[stack_pointer++] = undefined;
@@ -404,9 +404,9 @@ module.exports.isDecryptError = function (error) {
404
404
  * @param {any} error
405
405
  * @returns {boolean}
406
406
  */
407
- module.exports.isEncryptError = function (error) {
407
+ module.exports.isCipherError = function (error) {
408
408
  try {
409
- const ret = wasm.isEncryptError(addBorrowedObject(error));
409
+ const ret = wasm.isCipherError(addBorrowedObject(error));
410
410
  return ret !== 0;
411
411
  } finally {
412
412
  heap[stack_pointer++] = undefined;
@@ -417,9 +417,9 @@ module.exports.isEncryptError = function (error) {
417
417
  * @param {any} error
418
418
  * @returns {boolean}
419
419
  */
420
- module.exports.isTotpError = function (error) {
420
+ module.exports.isDecryptFileError = function (error) {
421
421
  try {
422
- const ret = wasm.isTotpError(addBorrowedObject(error));
422
+ const ret = wasm.isDecryptFileError(addBorrowedObject(error));
423
423
  return ret !== 0;
424
424
  } finally {
425
425
  heap[stack_pointer++] = undefined;
@@ -430,9 +430,9 @@ module.exports.isTotpError = function (error) {
430
430
  * @param {any} error
431
431
  * @returns {boolean}
432
432
  */
433
- module.exports.isCipherError = function (error) {
433
+ module.exports.isEncryptFileError = function (error) {
434
434
  try {
435
- const ret = wasm.isCipherError(addBorrowedObject(error));
435
+ const ret = wasm.isEncryptFileError(addBorrowedObject(error));
436
436
  return ret !== 0;
437
437
  } finally {
438
438
  heap[stack_pointer++] = undefined;
@@ -561,7 +561,7 @@ function __wbg_adapter_50(arg0, arg1, arg2) {
561
561
  );
562
562
  }
563
563
 
564
- function __wbg_adapter_222(arg0, arg1, arg2, arg3) {
564
+ function __wbg_adapter_224(arg0, arg1, arg2, arg3) {
565
565
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h33defb2ea0fdb769(
566
566
  arg0,
567
567
  arg1,
@@ -842,6 +842,68 @@ class BitwardenClient {
842
842
  }
843
843
  module.exports.BitwardenClient = BitwardenClient;
844
844
 
845
+ const ClientAttachmentsFinalization =
846
+ typeof FinalizationRegistry === "undefined"
847
+ ? { register: () => {}, unregister: () => {} }
848
+ : new FinalizationRegistry((ptr) => wasm.__wbg_clientattachments_free(ptr >>> 0, 1));
849
+
850
+ class ClientAttachments {
851
+ static __wrap(ptr) {
852
+ ptr = ptr >>> 0;
853
+ const obj = Object.create(ClientAttachments.prototype);
854
+ obj.__wbg_ptr = ptr;
855
+ ClientAttachmentsFinalization.register(obj, obj.__wbg_ptr, obj);
856
+ return obj;
857
+ }
858
+
859
+ __destroy_into_raw() {
860
+ const ptr = this.__wbg_ptr;
861
+ this.__wbg_ptr = 0;
862
+ ClientAttachmentsFinalization.unregister(this);
863
+ return ptr;
864
+ }
865
+
866
+ free() {
867
+ const ptr = this.__destroy_into_raw();
868
+ wasm.__wbg_clientattachments_free(ptr, 0);
869
+ }
870
+ /**
871
+ * Decrypts an attachment's encrypted content
872
+ * @param {Cipher} cipher
873
+ * @param {Attachment} attachment
874
+ * @param {Uint8Array} encrypted_buffer
875
+ * @returns {Uint8Array}
876
+ */
877
+ decrypt_buffer(cipher, attachment, encrypted_buffer) {
878
+ try {
879
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
880
+ const ptr0 = passArray8ToWasm0(encrypted_buffer, wasm.__wbindgen_malloc);
881
+ const len0 = WASM_VECTOR_LEN;
882
+ wasm.clientattachments_decrypt_buffer(
883
+ retptr,
884
+ this.__wbg_ptr,
885
+ addHeapObject(cipher),
886
+ addHeapObject(attachment),
887
+ ptr0,
888
+ len0,
889
+ );
890
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
891
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
892
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
893
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
894
+ if (r3) {
895
+ throw takeObject(r2);
896
+ }
897
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
898
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
899
+ return v2;
900
+ } finally {
901
+ wasm.__wbindgen_add_to_stack_pointer(16);
902
+ }
903
+ }
904
+ }
905
+ module.exports.ClientAttachments = ClientAttachments;
906
+
845
907
  const ClientCiphersFinalization =
846
908
  typeof FinalizationRegistry === "undefined"
847
909
  ? { register: () => {}, unregister: () => {} }
@@ -1995,18 +2057,25 @@ class VaultClient {
1995
2057
  const ptr = this.__destroy_into_raw();
1996
2058
  wasm.__wbg_vaultclient_free(ptr, 0);
1997
2059
  }
2060
+ /**
2061
+ * @returns {ClientAttachments}
2062
+ */
2063
+ attachments() {
2064
+ const ret = wasm.vaultclient_attachments(this.__wbg_ptr);
2065
+ return ClientAttachments.__wrap(ret);
2066
+ }
1998
2067
  /**
1999
2068
  * @returns {ClientCiphers}
2000
2069
  */
2001
2070
  ciphers() {
2002
- const ret = wasm.vaultclient_ciphers(this.__wbg_ptr);
2071
+ const ret = wasm.vaultclient_attachments(this.__wbg_ptr);
2003
2072
  return ClientCiphers.__wrap(ret);
2004
2073
  }
2005
2074
  /**
2006
2075
  * @returns {ClientFolders}
2007
2076
  */
2008
2077
  folders() {
2009
- const ret = wasm.vaultclient_ciphers(this.__wbg_ptr);
2078
+ const ret = wasm.vaultclient_attachments(this.__wbg_ptr);
2010
2079
  return ClientFolders.__wrap(ret);
2011
2080
  }
2012
2081
  /**
@@ -2269,7 +2338,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function (arg0, arg1) {
2269
2338
  const a = state0.a;
2270
2339
  state0.a = 0;
2271
2340
  try {
2272
- return __wbg_adapter_222(a, state0.b, arg0, arg1);
2341
+ return __wbg_adapter_224(a, state0.b, arg0, arg1);
2273
2342
  } finally {
2274
2343
  state0.a = a;
2275
2344
  }
@@ -2638,7 +2707,7 @@ module.exports.__wbindgen_cb_drop = function (arg0) {
2638
2707
  return ret;
2639
2708
  };
2640
2709
 
2641
- module.exports.__wbindgen_closure_wrapper2606 = function (arg0, arg1, arg2) {
2710
+ module.exports.__wbindgen_closure_wrapper2614 = function (arg0, arg1, arg2) {
2642
2711
  const ret = makeMutClosure(arg0, arg1, 642, __wbg_adapter_50);
2643
2712
  return addHeapObject(ret);
2644
2713
  };
@@ -58,12 +58,12 @@ export const __wbg_set_outgoingmessage_destination: (a: number, b: number) => vo
58
58
  export const isSshKeyExportError: (a: number) => number;
59
59
  export const isSshKeyImportError: (a: number) => number;
60
60
  export const isKeyGenerationError: (a: number) => number;
61
- export const isDecryptFileError: (a: number) => number;
62
- export const isEncryptFileError: (a: number) => number;
63
61
  export const isDecryptError: (a: number) => number;
64
62
  export const isEncryptError: (a: number) => number;
65
63
  export const isTotpError: (a: number) => number;
66
64
  export const isCipherError: (a: number) => number;
65
+ export const isDecryptFileError: (a: number) => number;
66
+ export const isEncryptFileError: (a: number) => number;
67
67
  export const __wbg_bitwardenclient_free: (a: number, b: number) => void;
68
68
  export const bitwardenclient_new: (a: number) => number;
69
69
  export const bitwardenclient_echo: (a: number, b: number, c: number, d: number) => void;
@@ -118,7 +118,15 @@ export const purecrypto_symmetric_encrypt_to_array_buffer: (
118
118
  ) => void;
119
119
  export const generate_ssh_key: (a: number, b: number) => void;
120
120
  export const import_ssh_key: (a: number, b: number, c: number, d: number, e: number) => void;
121
- export const __wbg_clientciphers_free: (a: number, b: number) => void;
121
+ export const __wbg_clientattachments_free: (a: number, b: number) => void;
122
+ export const clientattachments_decrypt_buffer: (
123
+ a: number,
124
+ b: number,
125
+ c: number,
126
+ d: number,
127
+ e: number,
128
+ f: number,
129
+ ) => void;
122
130
  export const clientciphers_encrypt: (a: number, b: number, c: number) => void;
123
131
  export const clientciphers_decrypt: (a: number, b: number, c: number) => void;
124
132
  export const clientciphers_decrypt_list: (a: number, b: number, c: number, d: number) => void;
@@ -133,15 +141,17 @@ export const clienttotp_generate_totp: (
133
141
  e: number,
134
142
  f: number,
135
143
  ) => void;
136
- export const vaultclient_ciphers: (a: number) => number;
144
+ export const vaultclient_attachments: (a: number) => number;
137
145
  export const vaultclient_totp: (a: number) => number;
138
146
  export const isTestError: (a: number) => number;
139
147
  export const bitwardenclient_vault: (a: number) => number;
148
+ export const vaultclient_ciphers: (a: number) => number;
140
149
  export const vaultclient_folders: (a: number) => number;
141
150
  export const __wbg_generatorclient_free: (a: number, b: number) => void;
142
151
  export const __wbg_vaultclient_free: (a: number, b: number) => void;
143
- export const __wbg_cryptoclient_free: (a: number, b: number) => void;
144
152
  export const __wbg_clienttotp_free: (a: number, b: number) => void;
153
+ export const __wbg_cryptoclient_free: (a: number, b: number) => void;
154
+ export const __wbg_clientciphers_free: (a: number, b: number) => void;
145
155
  export const __wbg_clientfolders_free: (a: number, b: number) => void;
146
156
  export const __wbindgen_malloc: (a: number, b: number) => number;
147
157
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitwarden/sdk-internal",
3
- "version": "0.2.0-main.143",
3
+ "version": "0.2.0-main.145",
4
4
  "license": "GPL-3.0",
5
5
  "files": [
6
6
  "bitwarden_wasm_internal_bg.js",