@bitwarden/sdk-internal 0.2.0-main.131 → 0.2.0-main.133

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.
@@ -227,6 +227,35 @@ export interface CryptoError extends Error {
227
227
 
228
228
  export function isCryptoError(error: any): error is CryptoError;
229
229
 
230
+ export type Endpoint =
231
+ | { Web: { id: number } }
232
+ | "BrowserForeground"
233
+ | "BrowserBackground"
234
+ | "DesktopRenderer"
235
+ | "DesktopMain";
236
+
237
+ export interface OutgoingMessage {
238
+ data: number[];
239
+ destination: Endpoint;
240
+ }
241
+
242
+ export interface IncomingMessage {
243
+ data: number[];
244
+ destination: Endpoint;
245
+ source: Endpoint;
246
+ }
247
+
248
+ export interface CommunicationBackend {
249
+ send(message: OutgoingMessage): Promise<void>;
250
+ receive(): Promise<IncomingMessage>;
251
+ }
252
+
253
+ export interface DeserializeError extends Error {
254
+ name: "DeserializeError";
255
+ }
256
+
257
+ export function isDeserializeError(error: any): error is DeserializeError;
258
+
230
259
  export type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
231
260
 
232
261
  export interface SshKeyExportError extends Error {
@@ -415,6 +444,12 @@ export class CryptoClient {
415
444
  */
416
445
  verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
417
446
  }
447
+ export class IpcClient {
448
+ free(): void;
449
+ constructor(communication_provider: CommunicationBackend);
450
+ send(message: OutgoingMessage): Promise<void>;
451
+ receive(): Promise<IncomingMessage>;
452
+ }
418
453
  /**
419
454
  * This module represents a stopgap solution to provide access to primitive crypto functions for JS
420
455
  * clients. It is not intended to be used outside of the JS clients and this pattern should not be
@@ -430,6 +465,18 @@ export class PureCrypto {
430
465
  static symmetric_encrypt(plain: string, key: Uint8Array): string;
431
466
  static symmetric_encrypt_to_array_buffer(plain: Uint8Array, key: Uint8Array): Uint8Array;
432
467
  }
468
+ export class ReceiveError {
469
+ private constructor();
470
+ free(): void;
471
+ crypto_error: any;
472
+ communication_error: any;
473
+ }
474
+ export class SendError {
475
+ private constructor();
476
+ free(): void;
477
+ crypto_error: any;
478
+ communication_error: any;
479
+ }
433
480
  export class VaultClient {
434
481
  private constructor();
435
482
  free(): void;
@@ -266,6 +266,19 @@ module.exports.isCryptoError = function (error) {
266
266
  }
267
267
  };
268
268
 
269
+ /**
270
+ * @param {any} error
271
+ * @returns {boolean}
272
+ */
273
+ module.exports.isDeserializeError = function (error) {
274
+ try {
275
+ const ret = wasm.isDeserializeError(addBorrowedObject(error));
276
+ return ret !== 0;
277
+ } finally {
278
+ heap[stack_pointer++] = undefined;
279
+ }
280
+ };
281
+
269
282
  /**
270
283
  * @param {any} error
271
284
  * @returns {boolean}
@@ -484,7 +497,7 @@ function __wbg_adapter_40(arg0, arg1, arg2) {
484
497
  );
485
498
  }
486
499
 
487
- function __wbg_adapter_150(arg0, arg1, arg2, arg3) {
500
+ function __wbg_adapter_174(arg0, arg1, arg2, arg3) {
488
501
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h33defb2ea0fdb769(
489
502
  arg0,
490
503
  arg1,
@@ -837,6 +850,50 @@ class CryptoClient {
837
850
  }
838
851
  module.exports.CryptoClient = CryptoClient;
839
852
 
853
+ const IpcClientFinalization =
854
+ typeof FinalizationRegistry === "undefined"
855
+ ? { register: () => {}, unregister: () => {} }
856
+ : new FinalizationRegistry((ptr) => wasm.__wbg_ipcclient_free(ptr >>> 0, 1));
857
+
858
+ class IpcClient {
859
+ __destroy_into_raw() {
860
+ const ptr = this.__wbg_ptr;
861
+ this.__wbg_ptr = 0;
862
+ IpcClientFinalization.unregister(this);
863
+ return ptr;
864
+ }
865
+
866
+ free() {
867
+ const ptr = this.__destroy_into_raw();
868
+ wasm.__wbg_ipcclient_free(ptr, 0);
869
+ }
870
+ /**
871
+ * @param {CommunicationBackend} communication_provider
872
+ */
873
+ constructor(communication_provider) {
874
+ const ret = wasm.ipcclient_new(addHeapObject(communication_provider));
875
+ this.__wbg_ptr = ret >>> 0;
876
+ IpcClientFinalization.register(this, this.__wbg_ptr, this);
877
+ return this;
878
+ }
879
+ /**
880
+ * @param {OutgoingMessage} message
881
+ * @returns {Promise<void>}
882
+ */
883
+ send(message) {
884
+ const ret = wasm.ipcclient_send(this.__wbg_ptr, addHeapObject(message));
885
+ return takeObject(ret);
886
+ }
887
+ /**
888
+ * @returns {Promise<IncomingMessage>}
889
+ */
890
+ receive() {
891
+ const ret = wasm.ipcclient_receive(this.__wbg_ptr);
892
+ return takeObject(ret);
893
+ }
894
+ }
895
+ module.exports.IpcClient = IpcClient;
896
+
840
897
  const PureCryptoFinalization =
841
898
  typeof FinalizationRegistry === "undefined"
842
899
  ? { register: () => {}, unregister: () => {} }
@@ -1011,6 +1068,114 @@ class PureCrypto {
1011
1068
  }
1012
1069
  module.exports.PureCrypto = PureCrypto;
1013
1070
 
1071
+ const ReceiveErrorFinalization =
1072
+ typeof FinalizationRegistry === "undefined"
1073
+ ? { register: () => {}, unregister: () => {} }
1074
+ : new FinalizationRegistry((ptr) => wasm.__wbg_receiveerror_free(ptr >>> 0, 1));
1075
+
1076
+ class ReceiveError {
1077
+ static __wrap(ptr) {
1078
+ ptr = ptr >>> 0;
1079
+ const obj = Object.create(ReceiveError.prototype);
1080
+ obj.__wbg_ptr = ptr;
1081
+ ReceiveErrorFinalization.register(obj, obj.__wbg_ptr, obj);
1082
+ return obj;
1083
+ }
1084
+
1085
+ __destroy_into_raw() {
1086
+ const ptr = this.__wbg_ptr;
1087
+ this.__wbg_ptr = 0;
1088
+ ReceiveErrorFinalization.unregister(this);
1089
+ return ptr;
1090
+ }
1091
+
1092
+ free() {
1093
+ const ptr = this.__destroy_into_raw();
1094
+ wasm.__wbg_receiveerror_free(ptr, 0);
1095
+ }
1096
+ /**
1097
+ * @returns {any}
1098
+ */
1099
+ get crypto_error() {
1100
+ const ret = wasm.__wbg_get_receiveerror_crypto_error(this.__wbg_ptr);
1101
+ return takeObject(ret);
1102
+ }
1103
+ /**
1104
+ * @param {any} arg0
1105
+ */
1106
+ set crypto_error(arg0) {
1107
+ wasm.__wbg_set_receiveerror_crypto_error(this.__wbg_ptr, addHeapObject(arg0));
1108
+ }
1109
+ /**
1110
+ * @returns {any}
1111
+ */
1112
+ get communication_error() {
1113
+ const ret = wasm.__wbg_get_receiveerror_communication_error(this.__wbg_ptr);
1114
+ return takeObject(ret);
1115
+ }
1116
+ /**
1117
+ * @param {any} arg0
1118
+ */
1119
+ set communication_error(arg0) {
1120
+ wasm.__wbg_set_receiveerror_communication_error(this.__wbg_ptr, addHeapObject(arg0));
1121
+ }
1122
+ }
1123
+ module.exports.ReceiveError = ReceiveError;
1124
+
1125
+ const SendErrorFinalization =
1126
+ typeof FinalizationRegistry === "undefined"
1127
+ ? { register: () => {}, unregister: () => {} }
1128
+ : new FinalizationRegistry((ptr) => wasm.__wbg_senderror_free(ptr >>> 0, 1));
1129
+
1130
+ class SendError {
1131
+ static __wrap(ptr) {
1132
+ ptr = ptr >>> 0;
1133
+ const obj = Object.create(SendError.prototype);
1134
+ obj.__wbg_ptr = ptr;
1135
+ SendErrorFinalization.register(obj, obj.__wbg_ptr, obj);
1136
+ return obj;
1137
+ }
1138
+
1139
+ __destroy_into_raw() {
1140
+ const ptr = this.__wbg_ptr;
1141
+ this.__wbg_ptr = 0;
1142
+ SendErrorFinalization.unregister(this);
1143
+ return ptr;
1144
+ }
1145
+
1146
+ free() {
1147
+ const ptr = this.__destroy_into_raw();
1148
+ wasm.__wbg_senderror_free(ptr, 0);
1149
+ }
1150
+ /**
1151
+ * @returns {any}
1152
+ */
1153
+ get crypto_error() {
1154
+ const ret = wasm.__wbg_get_receiveerror_crypto_error(this.__wbg_ptr);
1155
+ return takeObject(ret);
1156
+ }
1157
+ /**
1158
+ * @param {any} arg0
1159
+ */
1160
+ set crypto_error(arg0) {
1161
+ wasm.__wbg_set_receiveerror_crypto_error(this.__wbg_ptr, addHeapObject(arg0));
1162
+ }
1163
+ /**
1164
+ * @returns {any}
1165
+ */
1166
+ get communication_error() {
1167
+ const ret = wasm.__wbg_get_receiveerror_communication_error(this.__wbg_ptr);
1168
+ return takeObject(ret);
1169
+ }
1170
+ /**
1171
+ * @param {any} arg0
1172
+ */
1173
+ set communication_error(arg0) {
1174
+ wasm.__wbg_set_receiveerror_communication_error(this.__wbg_ptr, addHeapObject(arg0));
1175
+ }
1176
+ }
1177
+ module.exports.SendError = SendError;
1178
+
1014
1179
  const VaultClientFinalization =
1015
1180
  typeof FinalizationRegistry === "undefined"
1016
1181
  ? { register: () => {}, unregister: () => {} }
@@ -1234,6 +1399,11 @@ module.exports.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function (arg0) {
1234
1399
  return ret;
1235
1400
  };
1236
1401
 
1402
+ module.exports.__wbg_isArray_a1eab7e0d067391b = function (arg0) {
1403
+ const ret = Array.isArray(getObject(arg0));
1404
+ return ret;
1405
+ };
1406
+
1237
1407
  module.exports.__wbg_isSafeInteger_343e2beeeece1bb0 = function (arg0) {
1238
1408
  const ret = Number.isSafeInteger(getObject(arg0));
1239
1409
  return ret;
@@ -1282,7 +1452,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function (arg0, arg1) {
1282
1452
  const a = state0.a;
1283
1453
  state0.a = 0;
1284
1454
  try {
1285
- return __wbg_adapter_150(a, state0.b, arg0, arg1);
1455
+ return __wbg_adapter_174(a, state0.b, arg0, arg1);
1286
1456
  } finally {
1287
1457
  state0.a = a;
1288
1458
  }
@@ -1417,6 +1587,18 @@ module.exports.__wbg_randomFillSync_ab2cfe79ebbf2740 = function () {
1417
1587
  }, arguments);
1418
1588
  };
1419
1589
 
1590
+ module.exports.__wbg_receive_9512d555fb8b5130 = function () {
1591
+ return handleError(function (arg0) {
1592
+ const ret = getObject(arg0).receive();
1593
+ return addHeapObject(ret);
1594
+ }, arguments);
1595
+ };
1596
+
1597
+ module.exports.__wbg_receiveerror_new = function (arg0) {
1598
+ const ret = ReceiveError.__wrap(arg0);
1599
+ return addHeapObject(ret);
1600
+ };
1601
+
1420
1602
  module.exports.__wbg_require_79b1e9274cde3c87 = function () {
1421
1603
  return handleError(function () {
1422
1604
  const ret = module.require;
@@ -1429,6 +1611,22 @@ module.exports.__wbg_resolve_4851785c9c5f573d = function (arg0) {
1429
1611
  return addHeapObject(ret);
1430
1612
  };
1431
1613
 
1614
+ module.exports.__wbg_send_c9eacaae08065b18 = function () {
1615
+ return handleError(function (arg0, arg1) {
1616
+ const ret = getObject(arg0).send(takeObject(arg1));
1617
+ return addHeapObject(ret);
1618
+ }, arguments);
1619
+ };
1620
+
1621
+ module.exports.__wbg_senderror_new = function (arg0) {
1622
+ const ret = SendError.__wrap(arg0);
1623
+ return addHeapObject(ret);
1624
+ };
1625
+
1626
+ module.exports.__wbg_set_37837023f3d740e8 = function (arg0, arg1, arg2) {
1627
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
1628
+ };
1629
+
1432
1630
  module.exports.__wbg_set_3f1d0b984ed272ed = function (arg0, arg1, arg2) {
1433
1631
  getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
1434
1632
  };
@@ -1599,8 +1797,8 @@ module.exports.__wbindgen_cb_drop = function (arg0) {
1599
1797
  return ret;
1600
1798
  };
1601
1799
 
1602
- module.exports.__wbindgen_closure_wrapper2148 = function (arg0, arg1, arg2) {
1603
- const ret = makeMutClosure(arg0, arg1, 548, __wbg_adapter_40);
1800
+ module.exports.__wbindgen_closure_wrapper2219 = function (arg0, arg1, arg2) {
1801
+ const ret = makeMutClosure(arg0, arg1, 574, __wbg_adapter_40);
1604
1802
  return addHeapObject(ret);
1605
1803
  };
1606
1804
 
@@ -3,6 +3,21 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const isEncryptionSettingsError: (a: number) => number;
5
5
  export const isCryptoError: (a: number) => number;
6
+ export const __wbg_receiveerror_free: (a: number, b: number) => void;
7
+ export const __wbg_get_receiveerror_crypto_error: (a: number) => number;
8
+ export const __wbg_set_receiveerror_crypto_error: (a: number, b: number) => void;
9
+ export const __wbg_get_receiveerror_communication_error: (a: number) => number;
10
+ export const __wbg_set_receiveerror_communication_error: (a: number, b: number) => void;
11
+ export const __wbg_ipcclient_free: (a: number, b: number) => void;
12
+ export const ipcclient_new: (a: number) => number;
13
+ export const ipcclient_send: (a: number, b: number) => number;
14
+ export const ipcclient_receive: (a: number) => number;
15
+ export const isDeserializeError: (a: number) => number;
16
+ export const __wbg_set_senderror_crypto_error: (a: number, b: number) => void;
17
+ export const __wbg_set_senderror_communication_error: (a: number, b: number) => void;
18
+ export const __wbg_get_senderror_crypto_error: (a: number) => number;
19
+ export const __wbg_get_senderror_communication_error: (a: number) => number;
20
+ export const __wbg_senderror_free: (a: number, b: number) => void;
6
21
  export const isSshKeyExportError: (a: number) => number;
7
22
  export const isSshKeyImportError: (a: number) => number;
8
23
  export const isKeyGenerationError: (a: number) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitwarden/sdk-internal",
3
- "version": "0.2.0-main.131",
3
+ "version": "0.2.0-main.133",
4
4
  "license": "GPL-3.0",
5
5
  "files": [
6
6
  "bitwarden_wasm_internal_bg.js",