@bitwarden/sdk-internal 0.2.0-main.157 → 0.2.0-main.158

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.
@@ -435,11 +435,16 @@ export type Endpoint =
435
435
  | "DesktopRenderer"
436
436
  | "DesktopMain";
437
437
 
438
- export interface CommunicationBackend {
438
+ export interface IpcCommunicationBackendSender {
439
439
  send(message: OutgoingMessage): Promise<void>;
440
- receive(): Promise<IncomingMessage>;
441
440
  }
442
441
 
442
+ export interface ChannelError extends Error {
443
+ name: "ChannelError";
444
+ }
445
+
446
+ export function isChannelError(error: any): error is ChannelError;
447
+
443
448
  export interface DeserializeError extends Error {
444
449
  name: "DeserializeError";
445
450
  }
@@ -1122,9 +1127,21 @@ export class IncomingMessage {
1122
1127
  }
1123
1128
  export class IpcClient {
1124
1129
  free(): void;
1125
- constructor(communication_provider: CommunicationBackend);
1130
+ constructor(communication_provider: IpcCommunicationBackend);
1126
1131
  send(message: OutgoingMessage): Promise<void>;
1127
- receive(): Promise<IncomingMessage>;
1132
+ subscribe(): Promise<IpcClientSubscription>;
1133
+ }
1134
+ export class IpcClientSubscription {
1135
+ private constructor();
1136
+ free(): void;
1137
+ }
1138
+ export class IpcCommunicationBackend {
1139
+ free(): void;
1140
+ constructor(sender: IpcCommunicationBackendSender);
1141
+ /**
1142
+ * JavaScript function to provide a received message to the backend/IPC framework.
1143
+ */
1144
+ deliver_message(message: IncomingMessage): void;
1128
1145
  }
1129
1146
  export class OutgoingMessage {
1130
1147
  free(): void;
@@ -341,6 +341,19 @@ function _assertClass(instance, klass) {
341
341
  throw new Error(`expected instance of ${klass.name}`);
342
342
  }
343
343
  }
344
+ /**
345
+ * @param {any} error
346
+ * @returns {boolean}
347
+ */
348
+ module.exports.isChannelError = function (error) {
349
+ try {
350
+ const ret = wasm.isChannelError(addBorrowedObject(error));
351
+ return ret !== 0;
352
+ } finally {
353
+ heap[stack_pointer++] = undefined;
354
+ }
355
+ };
356
+
344
357
  /**
345
358
  * @param {any} error
346
359
  * @returns {boolean}
@@ -581,7 +594,7 @@ function __wbg_adapter_53(arg0, arg1, arg2) {
581
594
  );
582
595
  }
583
596
 
584
- function __wbg_adapter_233(arg0, arg1, arg2, arg3) {
597
+ function __wbg_adapter_232(arg0, arg1, arg2, arg3) {
585
598
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h2a33b0877ef96682(
586
599
  arg0,
587
600
  arg1,
@@ -1554,14 +1567,6 @@ const IncomingMessageFinalization =
1554
1567
  : new FinalizationRegistry((ptr) => wasm.__wbg_incomingmessage_free(ptr >>> 0, 1));
1555
1568
 
1556
1569
  class IncomingMessage {
1557
- static __wrap(ptr) {
1558
- ptr = ptr >>> 0;
1559
- const obj = Object.create(IncomingMessage.prototype);
1560
- obj.__wbg_ptr = ptr;
1561
- IncomingMessageFinalization.register(obj, obj.__wbg_ptr, obj);
1562
- return obj;
1563
- }
1564
-
1565
1570
  __destroy_into_raw() {
1566
1571
  const ptr = this.__wbg_ptr;
1567
1572
  this.__wbg_ptr = 0;
@@ -1706,10 +1711,12 @@ class IpcClient {
1706
1711
  wasm.__wbg_ipcclient_free(ptr, 0);
1707
1712
  }
1708
1713
  /**
1709
- * @param {CommunicationBackend} communication_provider
1714
+ * @param {IpcCommunicationBackend} communication_provider
1710
1715
  */
1711
1716
  constructor(communication_provider) {
1712
- const ret = wasm.ipcclient_new(addHeapObject(communication_provider));
1717
+ _assertClass(communication_provider, IpcCommunicationBackend);
1718
+ var ptr0 = communication_provider.__destroy_into_raw();
1719
+ const ret = wasm.ipcclient_new(ptr0);
1713
1720
  this.__wbg_ptr = ret >>> 0;
1714
1721
  IpcClientFinalization.register(this, this.__wbg_ptr, this);
1715
1722
  return this;
@@ -1725,15 +1732,91 @@ class IpcClient {
1725
1732
  return takeObject(ret);
1726
1733
  }
1727
1734
  /**
1728
- * @returns {Promise<IncomingMessage>}
1735
+ * @returns {Promise<IpcClientSubscription>}
1729
1736
  */
1730
- receive() {
1731
- const ret = wasm.ipcclient_receive(this.__wbg_ptr);
1737
+ subscribe() {
1738
+ const ret = wasm.ipcclient_subscribe(this.__wbg_ptr);
1732
1739
  return takeObject(ret);
1733
1740
  }
1734
1741
  }
1735
1742
  module.exports.IpcClient = IpcClient;
1736
1743
 
1744
+ const IpcClientSubscriptionFinalization =
1745
+ typeof FinalizationRegistry === "undefined"
1746
+ ? { register: () => {}, unregister: () => {} }
1747
+ : new FinalizationRegistry((ptr) => wasm.__wbg_ipcclientsubscription_free(ptr >>> 0, 1));
1748
+
1749
+ class IpcClientSubscription {
1750
+ static __wrap(ptr) {
1751
+ ptr = ptr >>> 0;
1752
+ const obj = Object.create(IpcClientSubscription.prototype);
1753
+ obj.__wbg_ptr = ptr;
1754
+ IpcClientSubscriptionFinalization.register(obj, obj.__wbg_ptr, obj);
1755
+ return obj;
1756
+ }
1757
+
1758
+ __destroy_into_raw() {
1759
+ const ptr = this.__wbg_ptr;
1760
+ this.__wbg_ptr = 0;
1761
+ IpcClientSubscriptionFinalization.unregister(this);
1762
+ return ptr;
1763
+ }
1764
+
1765
+ free() {
1766
+ const ptr = this.__destroy_into_raw();
1767
+ wasm.__wbg_ipcclientsubscription_free(ptr, 0);
1768
+ }
1769
+ }
1770
+ module.exports.IpcClientSubscription = IpcClientSubscription;
1771
+
1772
+ const IpcCommunicationBackendFinalization =
1773
+ typeof FinalizationRegistry === "undefined"
1774
+ ? { register: () => {}, unregister: () => {} }
1775
+ : new FinalizationRegistry((ptr) => wasm.__wbg_ipccommunicationbackend_free(ptr >>> 0, 1));
1776
+
1777
+ class IpcCommunicationBackend {
1778
+ __destroy_into_raw() {
1779
+ const ptr = this.__wbg_ptr;
1780
+ this.__wbg_ptr = 0;
1781
+ IpcCommunicationBackendFinalization.unregister(this);
1782
+ return ptr;
1783
+ }
1784
+
1785
+ free() {
1786
+ const ptr = this.__destroy_into_raw();
1787
+ wasm.__wbg_ipccommunicationbackend_free(ptr, 0);
1788
+ }
1789
+ /**
1790
+ * @param {IpcCommunicationBackendSender} sender
1791
+ */
1792
+ constructor(sender) {
1793
+ const ret = wasm.ipccommunicationbackend_new(addHeapObject(sender));
1794
+ this.__wbg_ptr = ret >>> 0;
1795
+ IpcCommunicationBackendFinalization.register(this, this.__wbg_ptr, this);
1796
+ return this;
1797
+ }
1798
+ /**
1799
+ * JavaScript function to provide a received message to the backend/IPC framework.
1800
+ * @param {IncomingMessage} message
1801
+ */
1802
+ deliver_message(message) {
1803
+ try {
1804
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1805
+ _assertClass(message, IncomingMessage);
1806
+ var ptr0 = message.__destroy_into_raw();
1807
+ wasm.ipccommunicationbackend_deliver_message(retptr, this.__wbg_ptr, ptr0);
1808
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1809
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1810
+ if (r1) {
1811
+ throw takeObject(r0);
1812
+ }
1813
+ } finally {
1814
+ wasm.__wbindgen_add_to_stack_pointer(16);
1815
+ }
1816
+ }
1817
+ }
1818
+ module.exports.IpcCommunicationBackend = IpcCommunicationBackend;
1819
+
1737
1820
  const OutgoingMessageFinalization =
1738
1821
  typeof FinalizationRegistry === "undefined"
1739
1822
  ? { register: () => {}, unregister: () => {} }
@@ -2057,14 +2140,6 @@ const ReceiveErrorFinalization =
2057
2140
  : new FinalizationRegistry((ptr) => wasm.__wbg_receiveerror_free(ptr >>> 0, 1));
2058
2141
 
2059
2142
  class ReceiveError {
2060
- static __wrap(ptr) {
2061
- ptr = ptr >>> 0;
2062
- const obj = Object.create(ReceiveError.prototype);
2063
- obj.__wbg_ptr = ptr;
2064
- ReceiveErrorFinalization.register(obj, obj.__wbg_ptr, obj);
2065
- return obj;
2066
- }
2067
-
2068
2143
  __destroy_into_raw() {
2069
2144
  const ptr = this.__wbg_ptr;
2070
2145
  this.__wbg_ptr = 0;
@@ -2456,11 +2531,6 @@ module.exports.__wbg_headers_9cb51cfd2ac780a4 = function (arg0) {
2456
2531
  return addHeapObject(ret);
2457
2532
  };
2458
2533
 
2459
- module.exports.__wbg_incomingmessage_new = function (arg0) {
2460
- const ret = IncomingMessage.__wrap(arg0);
2461
- return addHeapObject(ret);
2462
- };
2463
-
2464
2534
  module.exports.__wbg_info_033d8b8a0838f1d3 = function (arg0, arg1, arg2, arg3) {
2465
2535
  console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
2466
2536
  };
@@ -2509,6 +2579,11 @@ module.exports.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function (arg0) {
2509
2579
  return ret;
2510
2580
  };
2511
2581
 
2582
+ module.exports.__wbg_ipcclientsubscription_new = function (arg0) {
2583
+ const ret = IpcClientSubscription.__wrap(arg0);
2584
+ return addHeapObject(ret);
2585
+ };
2586
+
2512
2587
  module.exports.__wbg_isArray_a1eab7e0d067391b = function (arg0) {
2513
2588
  const ret = Array.isArray(getObject(arg0));
2514
2589
  return ret;
@@ -2562,7 +2637,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function (arg0, arg1) {
2562
2637
  const a = state0.a;
2563
2638
  state0.a = 0;
2564
2639
  try {
2565
- return __wbg_adapter_233(a, state0.b, arg0, arg1);
2640
+ return __wbg_adapter_232(a, state0.b, arg0, arg1);
2566
2641
  } finally {
2567
2642
  state0.a = a;
2568
2643
  }
@@ -2704,18 +2779,6 @@ module.exports.__wbg_randomFillSync_ac0988aba3254290 = function () {
2704
2779
  }, arguments);
2705
2780
  };
2706
2781
 
2707
- module.exports.__wbg_receive_9512d555fb8b5130 = function () {
2708
- return handleError(function (arg0) {
2709
- const ret = getObject(arg0).receive();
2710
- return addHeapObject(ret);
2711
- }, arguments);
2712
- };
2713
-
2714
- module.exports.__wbg_receiveerror_new = function (arg0) {
2715
- const ret = ReceiveError.__wrap(arg0);
2716
- return addHeapObject(ret);
2717
- };
2718
-
2719
2782
  module.exports.__wbg_require_60cc747a6bc5215a = function () {
2720
2783
  return handleError(function () {
2721
2784
  const ret = module.require;
@@ -2728,7 +2791,7 @@ module.exports.__wbg_resolve_4851785c9c5f573d = function (arg0) {
2728
2791
  return addHeapObject(ret);
2729
2792
  };
2730
2793
 
2731
- module.exports.__wbg_send_c9eacaae08065b18 = function () {
2794
+ module.exports.__wbg_send_9b8fc6bb517867dd = function () {
2732
2795
  return handleError(function (arg0, arg1) {
2733
2796
  const ret = getObject(arg0).send(OutgoingMessage.__wrap(arg1));
2734
2797
  return addHeapObject(ret);
@@ -2936,13 +2999,13 @@ module.exports.__wbindgen_cb_drop = function (arg0) {
2936
2999
  return ret;
2937
3000
  };
2938
3001
 
2939
- module.exports.__wbindgen_closure_wrapper2851 = function (arg0, arg1, arg2) {
2940
- const ret = makeMutClosure(arg0, arg1, 662, __wbg_adapter_50);
3002
+ module.exports.__wbindgen_closure_wrapper2861 = function (arg0, arg1, arg2) {
3003
+ const ret = makeMutClosure(arg0, arg1, 658, __wbg_adapter_50);
2941
3004
  return addHeapObject(ret);
2942
3005
  };
2943
3006
 
2944
- module.exports.__wbindgen_closure_wrapper3236 = function (arg0, arg1, arg2) {
2945
- const ret = makeMutClosure(arg0, arg1, 783, __wbg_adapter_53);
3007
+ module.exports.__wbindgen_closure_wrapper3246 = function (arg0, arg1, arg2) {
3008
+ const ret = makeMutClosure(arg0, arg1, 779, __wbg_adapter_53);
2946
3009
  return addHeapObject(ret);
2947
3010
  };
2948
3011
 
@@ -47,6 +47,9 @@ export const __wbg_get_incomingmessage_source: (a: number) => number;
47
47
  export const __wbg_set_incomingmessage_source: (a: number, b: number) => void;
48
48
  export const __wbg_get_incomingmessage_topic: (a: number, b: number) => void;
49
49
  export const __wbg_set_incomingmessage_topic: (a: number, b: number, c: number) => void;
50
+ export const __wbg_ipccommunicationbackend_free: (a: number, b: number) => void;
51
+ export const ipccommunicationbackend_new: (a: number) => number;
52
+ export const ipccommunicationbackend_deliver_message: (a: number, b: number, c: number) => void;
50
53
  export const __wbg_senderror_free: (a: number, b: number) => void;
51
54
  export const __wbg_receiveerror_free: (a: number, b: number) => void;
52
55
  export const __wbg_get_receiveerror_timeout: (a: number) => number;
@@ -56,9 +59,10 @@ export const __wbg_set_receiveerror_crypto: (a: number, b: number) => void;
56
59
  export const __wbg_get_receiveerror_communication: (a: number) => number;
57
60
  export const __wbg_set_receiveerror_communication: (a: number, b: number) => void;
58
61
  export const __wbg_ipcclient_free: (a: number, b: number) => void;
62
+ export const __wbg_ipcclientsubscription_free: (a: number, b: number) => void;
59
63
  export const ipcclient_new: (a: number) => number;
60
64
  export const ipcclient_send: (a: number, b: number) => number;
61
- export const ipcclient_receive: (a: number) => number;
65
+ export const ipcclient_subscribe: (a: number) => number;
62
66
  export const outgoingmessage_new: (a: number, b: number, c: number, d: number, e: number) => number;
63
67
  export const outgoingmessage_new_json_payload: (
64
68
  a: number,
@@ -76,6 +80,7 @@ export const incomingmessage_new: (
76
80
  f: number,
77
81
  ) => number;
78
82
  export const incomingmessage_parse_payload_as_json: (a: number) => number;
83
+ export const isChannelError: (a: number) => number;
79
84
  export const isDeserializeError: (a: number) => number;
80
85
  export const __wbg_set_senderror_crypto: (a: number, b: number) => void;
81
86
  export const __wbg_set_senderror_communication: (a: number, b: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitwarden/sdk-internal",
3
- "version": "0.2.0-main.157",
3
+ "version": "0.2.0-main.158",
4
4
  "license": "GPL-3.0",
5
5
  "files": [
6
6
  "bitwarden_wasm_internal_bg.js",