@bitwarden/sdk-internal 0.2.0-main.7 → 0.2.0-main.9

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.
@@ -51,6 +51,38 @@ export interface InitOrgCryptoRequest {
51
51
  organizationKeys: Map<Uuid, AsymmetricEncString>;
52
52
  }
53
53
 
54
+ export interface CoreError extends Error {
55
+ name: "CoreError";
56
+ variant:
57
+ | "MissingFieldError"
58
+ | "VaultLocked"
59
+ | "NotAuthenticated"
60
+ | "AccessTokenInvalid"
61
+ | "InvalidResponse"
62
+ | "Crypto"
63
+ | "IdentityFail"
64
+ | "Reqwest"
65
+ | "Serde"
66
+ | "Io"
67
+ | "InvalidBase64"
68
+ | "Chrono"
69
+ | "ResponseContent"
70
+ | "ValidationError"
71
+ | "InvalidStateFileVersion"
72
+ | "InvalidStateFile"
73
+ | "Internal"
74
+ | "EncryptionSettings";
75
+ }
76
+
77
+ export function isCoreError(error: any): error is CoreError;
78
+
79
+ export interface EncryptionSettingsError extends Error {
80
+ name: "EncryptionSettingsError";
81
+ variant: "Crypto" | "InvalidBase64" | "VaultLocked" | "InvalidPrivateKey" | "MissingPrivateKey";
82
+ }
83
+
84
+ export function isEncryptionSettingsError(error: any): error is EncryptionSettingsError;
85
+
54
86
  export type DeviceType =
55
87
  | "Android"
56
88
  | "iOS"
@@ -141,6 +173,12 @@ export interface FolderView {
141
173
  revisionDate: DateTime<Utc>;
142
174
  }
143
175
 
176
+ export interface TestError extends Error {
177
+ name: "TestError";
178
+ }
179
+
180
+ export function isTestError(error: any): error is TestError;
181
+
144
182
  export type Uuid = string;
145
183
 
146
184
  /**
@@ -178,8 +216,9 @@ export class BitwardenClient {
178
216
  version(): string;
179
217
  /**
180
218
  * @param {string} msg
219
+ * @returns {Promise<void>}
181
220
  */
182
- throw(msg: string): void;
221
+ throw(msg: string): Promise<void>;
183
222
  /**
184
223
  * Test method, calls http endpoint
185
224
  * @param {string} url
@@ -3,15 +3,12 @@ export function __wbg_set_wasm(val) {
3
3
  wasm = val;
4
4
  }
5
5
 
6
- const heap = new Array(128).fill(undefined);
7
-
8
- heap.push(undefined, null, true, false);
6
+ const lTextDecoder =
7
+ typeof TextDecoder === "undefined" ? (0, module.require)("util").TextDecoder : TextDecoder;
9
8
 
10
- function getObject(idx) {
11
- return heap[idx];
12
- }
9
+ let cachedTextDecoder = new lTextDecoder("utf-8", { ignoreBOM: true, fatal: true });
13
10
 
14
- let WASM_VECTOR_LEN = 0;
11
+ cachedTextDecoder.decode();
15
12
 
16
13
  let cachedUint8ArrayMemory0 = null;
17
14
 
@@ -22,6 +19,44 @@ function getUint8ArrayMemory0() {
22
19
  return cachedUint8ArrayMemory0;
23
20
  }
24
21
 
22
+ function getStringFromWasm0(ptr, len) {
23
+ ptr = ptr >>> 0;
24
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
25
+ }
26
+
27
+ const heap = new Array(128).fill(undefined);
28
+
29
+ heap.push(undefined, null, true, false);
30
+
31
+ let heap_next = heap.length;
32
+
33
+ function addHeapObject(obj) {
34
+ if (heap_next === heap.length) heap.push(heap.length + 1);
35
+ const idx = heap_next;
36
+ heap_next = heap[idx];
37
+
38
+ heap[idx] = obj;
39
+ return idx;
40
+ }
41
+
42
+ function getObject(idx) {
43
+ return heap[idx];
44
+ }
45
+
46
+ function dropObject(idx) {
47
+ if (idx < 132) return;
48
+ heap[idx] = heap_next;
49
+ heap_next = idx;
50
+ }
51
+
52
+ function takeObject(idx) {
53
+ const ret = getObject(idx);
54
+ dropObject(idx);
55
+ return ret;
56
+ }
57
+
58
+ let WASM_VECTOR_LEN = 0;
59
+
25
60
  const lTextEncoder =
26
61
  typeof TextEncoder === "undefined" ? (0, module.require)("util").TextEncoder : TextEncoder;
27
62
 
@@ -99,41 +134,6 @@ function getDataViewMemory0() {
99
134
  return cachedDataViewMemory0;
100
135
  }
101
136
 
102
- let heap_next = heap.length;
103
-
104
- function dropObject(idx) {
105
- if (idx < 132) return;
106
- heap[idx] = heap_next;
107
- heap_next = idx;
108
- }
109
-
110
- function takeObject(idx) {
111
- const ret = getObject(idx);
112
- dropObject(idx);
113
- return ret;
114
- }
115
-
116
- function addHeapObject(obj) {
117
- if (heap_next === heap.length) heap.push(heap.length + 1);
118
- const idx = heap_next;
119
- heap_next = heap[idx];
120
-
121
- heap[idx] = obj;
122
- return idx;
123
- }
124
-
125
- const lTextDecoder =
126
- typeof TextDecoder === "undefined" ? (0, module.require)("util").TextDecoder : TextDecoder;
127
-
128
- let cachedTextDecoder = new lTextDecoder("utf-8", { ignoreBOM: true, fatal: true });
129
-
130
- cachedTextDecoder.decode();
131
-
132
- function getStringFromWasm0(ptr, len) {
133
- ptr = ptr >>> 0;
134
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
135
- }
136
-
137
137
  function debugString(val) {
138
138
  // primitive types
139
139
  const type = typeof val;
@@ -231,13 +231,59 @@ function makeMutClosure(arg0, arg1, dtor, f) {
231
231
  return real;
232
232
  }
233
233
  function __wbg_adapter_38(arg0, arg1, arg2) {
234
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hec6c9a85ed863308(
234
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hcab43b83560065d8(
235
235
  arg0,
236
236
  arg1,
237
237
  addHeapObject(arg2),
238
238
  );
239
239
  }
240
240
 
241
+ let stack_pointer = 128;
242
+
243
+ function addBorrowedObject(obj) {
244
+ if (stack_pointer == 1) throw new Error("out of js stack");
245
+ heap[--stack_pointer] = obj;
246
+ return stack_pointer;
247
+ }
248
+ /**
249
+ * @param {any} error
250
+ * @returns {boolean}
251
+ */
252
+ export function isCoreError(error) {
253
+ try {
254
+ const ret = wasm.isCoreError(addBorrowedObject(error));
255
+ return ret !== 0;
256
+ } finally {
257
+ heap[stack_pointer++] = undefined;
258
+ }
259
+ }
260
+
261
+ /**
262
+ * @param {any} error
263
+ * @returns {boolean}
264
+ */
265
+ export function isEncryptionSettingsError(error) {
266
+ try {
267
+ const ret = wasm.isEncryptionSettingsError(addBorrowedObject(error));
268
+ return ret !== 0;
269
+ } finally {
270
+ heap[stack_pointer++] = undefined;
271
+ }
272
+ }
273
+
274
+ /**
275
+ * @param {any} error
276
+ * @returns {boolean}
277
+ */
278
+ export function isTestError(error) {
279
+ try {
280
+ const ret = wasm.isTestError(addBorrowedObject(error));
281
+ return ret !== 0;
282
+ } finally {
283
+ heap[stack_pointer++] = undefined;
284
+ }
285
+ }
286
+
241
287
  function handleError(f, args) {
242
288
  try {
243
289
  return f.apply(this, args);
@@ -245,8 +291,8 @@ function handleError(f, args) {
245
291
  wasm.__wbindgen_exn_store(addHeapObject(e));
246
292
  }
247
293
  }
248
- function __wbg_adapter_100(arg0, arg1, arg2, arg3) {
249
- wasm.wasm_bindgen__convert__closures__invoke2_mut__h29c3505e35b3c82d(
294
+ function __wbg_adapter_107(arg0, arg1, arg2, arg3) {
295
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h7363c1bfa226a55d(
250
296
  arg0,
251
297
  arg1,
252
298
  addHeapObject(arg2),
@@ -345,21 +391,13 @@ export class BitwardenClient {
345
391
  }
346
392
  /**
347
393
  * @param {string} msg
394
+ * @returns {Promise<void>}
348
395
  */
349
396
  throw(msg) {
350
- try {
351
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
352
- const ptr0 = passStringToWasm0(msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
353
- const len0 = WASM_VECTOR_LEN;
354
- wasm.bitwardenclient_throw(retptr, this.__wbg_ptr, ptr0, len0);
355
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
356
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
357
- if (r1) {
358
- throw takeObject(r0);
359
- }
360
- } finally {
361
- wasm.__wbindgen_add_to_stack_pointer(16);
362
- }
397
+ const ptr0 = passStringToWasm0(msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
398
+ const len0 = WASM_VECTOR_LEN;
399
+ const ret = wasm.bitwardenclient_throw(this.__wbg_ptr, ptr0, len0);
400
+ return takeObject(ret);
363
401
  }
364
402
  /**
365
403
  * Test method, calls http endpoint
@@ -516,6 +554,59 @@ export class ClientVault {
516
554
  }
517
555
  }
518
556
 
557
+ export function __wbg_new_fe19e4f3db5c3999(arg0, arg1) {
558
+ let deferred0_0;
559
+ let deferred0_1;
560
+ try {
561
+ deferred0_0 = arg0;
562
+ deferred0_1 = arg1;
563
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
564
+ return addHeapObject(ret);
565
+ } finally {
566
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
567
+ }
568
+ }
569
+
570
+ export function __wbg_setname_46d623c31ae39910(arg0, arg1, arg2) {
571
+ let deferred0_0;
572
+ let deferred0_1;
573
+ try {
574
+ deferred0_0 = arg1;
575
+ deferred0_1 = arg2;
576
+ getObject(arg0).name = getStringFromWasm0(arg1, arg2);
577
+ } finally {
578
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
579
+ }
580
+ }
581
+
582
+ export function __wbg_setvariant_262a12673324f71b(arg0, arg1, arg2) {
583
+ let deferred0_0;
584
+ let deferred0_1;
585
+ try {
586
+ deferred0_0 = arg1;
587
+ deferred0_1 = arg2;
588
+ getObject(arg0).variant = getStringFromWasm0(arg1, arg2);
589
+ } finally {
590
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
591
+ }
592
+ }
593
+
594
+ export function __wbindgen_string_new(arg0, arg1) {
595
+ const ret = getStringFromWasm0(arg0, arg1);
596
+ return addHeapObject(ret);
597
+ }
598
+
599
+ export function __wbg_get_ef828680c64da212() {
600
+ return handleError(function (arg0, arg1) {
601
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
602
+ return addHeapObject(ret);
603
+ }, arguments);
604
+ }
605
+
606
+ export function __wbindgen_object_drop_ref(arg0) {
607
+ takeObject(arg0);
608
+ }
609
+
519
610
  export function __wbindgen_string_get(arg0, arg1) {
520
611
  const obj = getObject(arg1);
521
612
  const ret = typeof obj === "string" ? obj : undefined;
@@ -527,10 +618,6 @@ export function __wbindgen_string_get(arg0, arg1) {
527
618
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
528
619
  }
529
620
 
530
- export function __wbindgen_object_drop_ref(arg0) {
531
- takeObject(arg0);
532
- }
533
-
534
621
  export function __wbindgen_is_object(arg0) {
535
622
  const val = getObject(arg0);
536
623
  const ret = typeof val === "object" && val !== null;
@@ -582,6 +669,13 @@ export function __wbg_get_5419cf6b954aa11d(arg0, arg1) {
582
669
  return addHeapObject(ret);
583
670
  }
584
671
 
672
+ export function __wbg_call_3bfa248576352471() {
673
+ return handleError(function (arg0, arg1, arg2) {
674
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
675
+ return addHeapObject(ret);
676
+ }, arguments);
677
+ }
678
+
585
679
  export function __wbindgen_object_clone_ref(arg0) {
586
680
  const ret = getObject(arg0);
587
681
  return addHeapObject(ret);
@@ -604,26 +698,6 @@ export function __wbg_value_2ab8a198c834c26a(arg0) {
604
698
  return addHeapObject(ret);
605
699
  }
606
700
 
607
- export function __wbg_new_dd011eb1c3a5a053(arg0, arg1) {
608
- let deferred0_0;
609
- let deferred0_1;
610
- try {
611
- deferred0_0 = arg0;
612
- deferred0_1 = arg1;
613
- const ret = new Error(getStringFromWasm0(arg0, arg1));
614
- return addHeapObject(ret);
615
- } finally {
616
- wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
617
- }
618
- }
619
-
620
- export function __wbg_call_3bfa248576352471() {
621
- return handleError(function (arg0, arg1, arg2) {
622
- const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
623
- return addHeapObject(ret);
624
- }, arguments);
625
- }
626
-
627
701
  export function __wbg_new_e69b5f66fda8f13c() {
628
702
  const ret = new Object();
629
703
  return addHeapObject(ret);
@@ -718,11 +792,6 @@ export function __wbg_text_ebeee8b31af4c919() {
718
792
  }, arguments);
719
793
  }
720
794
 
721
- export function __wbindgen_string_new(arg0, arg1) {
722
- const ret = getStringFromWasm0(arg0, arg1);
723
- return addHeapObject(ret);
724
- }
725
-
726
795
  export function __wbindgen_jsval_loose_eq(arg0, arg1) {
727
796
  const ret = getObject(arg0) == getObject(arg1);
728
797
  return ret;
@@ -750,7 +819,7 @@ export function __wbg_new_1073970097e5a420(arg0, arg1) {
750
819
  const a = state0.a;
751
820
  state0.a = 0;
752
821
  try {
753
- return __wbg_adapter_100(a, state0.b, arg0, arg1);
822
+ return __wbg_adapter_107(a, state0.b, arg0, arg1);
754
823
  } finally {
755
824
  state0.a = a;
756
825
  }
@@ -836,13 +905,6 @@ export function __wbg_iterator_695d699a44d6234c() {
836
905
  return addHeapObject(ret);
837
906
  }
838
907
 
839
- export function __wbg_get_ef828680c64da212() {
840
- return handleError(function (arg0, arg1) {
841
- const ret = Reflect.get(getObject(arg0), getObject(arg1));
842
- return addHeapObject(ret);
843
- }, arguments);
844
- }
845
-
846
908
  export function __wbindgen_is_function(arg0) {
847
909
  const ret = typeof getObject(arg0) === "function";
848
910
  return ret;
@@ -1067,7 +1129,7 @@ export function __wbg_warn_2e2787d40aad9a81(arg0, arg1, arg2, arg3) {
1067
1129
  console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
1068
1130
  }
1069
1131
 
1070
- export function __wbindgen_closure_wrapper1610(arg0, arg1, arg2) {
1071
- const ret = makeMutClosure(arg0, arg1, 425, __wbg_adapter_38);
1132
+ export function __wbindgen_closure_wrapper1630(arg0, arg1, arg2) {
1133
+ const ret = makeMutClosure(arg0, arg1, 434, __wbg_adapter_38);
1072
1134
  return addHeapObject(ret);
1073
1135
  }
Binary file
@@ -1,13 +1,16 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
+ export function isCoreError(a: number): number;
5
+ export function isEncryptionSettingsError(a: number): number;
4
6
  export function __wbg_bitwardenclient_free(a: number, b: number): void;
5
7
  export function bitwardenclient_new(a: number, b: number): number;
6
8
  export function bitwardenclient_echo(a: number, b: number, c: number, d: number): void;
7
9
  export function bitwardenclient_version(a: number, b: number): void;
8
- export function bitwardenclient_throw(a: number, b: number, c: number, d: number): void;
10
+ export function bitwardenclient_throw(a: number, b: number, c: number): number;
9
11
  export function bitwardenclient_http_get(a: number, b: number, c: number): number;
10
12
  export function bitwardenclient_crypto(a: number): number;
13
+ export function isTestError(a: number): number;
11
14
  export function clientcrypto_initialize_user_crypto(a: number, b: number): number;
12
15
  export function clientcrypto_initialize_org_crypto(a: number, b: number): number;
13
16
  export function clientfolders_decrypt(a: number, b: number, c: number): void;
@@ -19,15 +22,15 @@ export function clientvault_folders(a: number): number;
19
22
  export function __wbindgen_malloc(a: number, b: number): number;
20
23
  export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
21
24
  export const __wbindgen_export_2: WebAssembly.Table;
22
- export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hec6c9a85ed863308(
25
+ export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hcab43b83560065d8(
23
26
  a: number,
24
27
  b: number,
25
28
  c: number,
26
29
  ): void;
27
- export function __wbindgen_add_to_stack_pointer(a: number): number;
28
30
  export function __wbindgen_free(a: number, b: number, c: number): void;
31
+ export function __wbindgen_add_to_stack_pointer(a: number): number;
29
32
  export function __wbindgen_exn_store(a: number): void;
30
- export function wasm_bindgen__convert__closures__invoke2_mut__h29c3505e35b3c82d(
33
+ export function wasm_bindgen__convert__closures__invoke2_mut__h7363c1bfa226a55d(
31
34
  a: number,
32
35
  b: number,
33
36
  c: number,