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

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,10 +1127,23 @@ 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>;
1132
+ subscribe(): Promise<IpcClientSubscription>;
1133
+ }
1134
+ export class IpcClientSubscription {
1135
+ private constructor();
1136
+ free(): void;
1127
1137
  receive(): Promise<IncomingMessage>;
1128
1138
  }
1139
+ export class IpcCommunicationBackend {
1140
+ free(): void;
1141
+ constructor(sender: IpcCommunicationBackendSender);
1142
+ /**
1143
+ * JavaScript function to provide a received message to the backend/IPC framework.
1144
+ */
1145
+ deliver_message(message: IncomingMessage): void;
1146
+ }
1129
1147
  export class OutgoingMessage {
1130
1148
  free(): void;
1131
1149
  constructor(payload: Uint8Array, destination: Endpoint, topic?: string | null);
@@ -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_237(arg0, arg1, arg2, arg3) {
585
598
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h2a33b0877ef96682(
586
599
  arg0,
587
600
  arg1,
@@ -1706,10 +1719,12 @@ class IpcClient {
1706
1719
  wasm.__wbg_ipcclient_free(ptr, 0);
1707
1720
  }
1708
1721
  /**
1709
- * @param {CommunicationBackend} communication_provider
1722
+ * @param {IpcCommunicationBackend} communication_provider
1710
1723
  */
1711
1724
  constructor(communication_provider) {
1712
- const ret = wasm.ipcclient_new(addHeapObject(communication_provider));
1725
+ _assertClass(communication_provider, IpcCommunicationBackend);
1726
+ var ptr0 = communication_provider.__destroy_into_raw();
1727
+ const ret = wasm.ipcclient_new(ptr0);
1713
1728
  this.__wbg_ptr = ret >>> 0;
1714
1729
  IpcClientFinalization.register(this, this.__wbg_ptr, this);
1715
1730
  return this;
@@ -1724,15 +1739,98 @@ class IpcClient {
1724
1739
  const ret = wasm.ipcclient_send(this.__wbg_ptr, ptr0);
1725
1740
  return takeObject(ret);
1726
1741
  }
1742
+ /**
1743
+ * @returns {Promise<IpcClientSubscription>}
1744
+ */
1745
+ subscribe() {
1746
+ const ret = wasm.ipcclient_subscribe(this.__wbg_ptr);
1747
+ return takeObject(ret);
1748
+ }
1749
+ }
1750
+ module.exports.IpcClient = IpcClient;
1751
+
1752
+ const IpcClientSubscriptionFinalization =
1753
+ typeof FinalizationRegistry === "undefined"
1754
+ ? { register: () => {}, unregister: () => {} }
1755
+ : new FinalizationRegistry((ptr) => wasm.__wbg_ipcclientsubscription_free(ptr >>> 0, 1));
1756
+
1757
+ class IpcClientSubscription {
1758
+ static __wrap(ptr) {
1759
+ ptr = ptr >>> 0;
1760
+ const obj = Object.create(IpcClientSubscription.prototype);
1761
+ obj.__wbg_ptr = ptr;
1762
+ IpcClientSubscriptionFinalization.register(obj, obj.__wbg_ptr, obj);
1763
+ return obj;
1764
+ }
1765
+
1766
+ __destroy_into_raw() {
1767
+ const ptr = this.__wbg_ptr;
1768
+ this.__wbg_ptr = 0;
1769
+ IpcClientSubscriptionFinalization.unregister(this);
1770
+ return ptr;
1771
+ }
1772
+
1773
+ free() {
1774
+ const ptr = this.__destroy_into_raw();
1775
+ wasm.__wbg_ipcclientsubscription_free(ptr, 0);
1776
+ }
1727
1777
  /**
1728
1778
  * @returns {Promise<IncomingMessage>}
1729
1779
  */
1730
1780
  receive() {
1731
- const ret = wasm.ipcclient_receive(this.__wbg_ptr);
1781
+ const ret = wasm.ipcclientsubscription_receive(this.__wbg_ptr);
1732
1782
  return takeObject(ret);
1733
1783
  }
1734
1784
  }
1735
- module.exports.IpcClient = IpcClient;
1785
+ module.exports.IpcClientSubscription = IpcClientSubscription;
1786
+
1787
+ const IpcCommunicationBackendFinalization =
1788
+ typeof FinalizationRegistry === "undefined"
1789
+ ? { register: () => {}, unregister: () => {} }
1790
+ : new FinalizationRegistry((ptr) => wasm.__wbg_ipccommunicationbackend_free(ptr >>> 0, 1));
1791
+
1792
+ class IpcCommunicationBackend {
1793
+ __destroy_into_raw() {
1794
+ const ptr = this.__wbg_ptr;
1795
+ this.__wbg_ptr = 0;
1796
+ IpcCommunicationBackendFinalization.unregister(this);
1797
+ return ptr;
1798
+ }
1799
+
1800
+ free() {
1801
+ const ptr = this.__destroy_into_raw();
1802
+ wasm.__wbg_ipccommunicationbackend_free(ptr, 0);
1803
+ }
1804
+ /**
1805
+ * @param {IpcCommunicationBackendSender} sender
1806
+ */
1807
+ constructor(sender) {
1808
+ const ret = wasm.ipccommunicationbackend_new(addHeapObject(sender));
1809
+ this.__wbg_ptr = ret >>> 0;
1810
+ IpcCommunicationBackendFinalization.register(this, this.__wbg_ptr, this);
1811
+ return this;
1812
+ }
1813
+ /**
1814
+ * JavaScript function to provide a received message to the backend/IPC framework.
1815
+ * @param {IncomingMessage} message
1816
+ */
1817
+ deliver_message(message) {
1818
+ try {
1819
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1820
+ _assertClass(message, IncomingMessage);
1821
+ var ptr0 = message.__destroy_into_raw();
1822
+ wasm.ipccommunicationbackend_deliver_message(retptr, this.__wbg_ptr, ptr0);
1823
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1824
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1825
+ if (r1) {
1826
+ throw takeObject(r0);
1827
+ }
1828
+ } finally {
1829
+ wasm.__wbindgen_add_to_stack_pointer(16);
1830
+ }
1831
+ }
1832
+ }
1833
+ module.exports.IpcCommunicationBackend = IpcCommunicationBackend;
1736
1834
 
1737
1835
  const OutgoingMessageFinalization =
1738
1836
  typeof FinalizationRegistry === "undefined"
@@ -2509,6 +2607,11 @@ module.exports.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function (arg0) {
2509
2607
  return ret;
2510
2608
  };
2511
2609
 
2610
+ module.exports.__wbg_ipcclientsubscription_new = function (arg0) {
2611
+ const ret = IpcClientSubscription.__wrap(arg0);
2612
+ return addHeapObject(ret);
2613
+ };
2614
+
2512
2615
  module.exports.__wbg_isArray_a1eab7e0d067391b = function (arg0) {
2513
2616
  const ret = Array.isArray(getObject(arg0));
2514
2617
  return ret;
@@ -2562,7 +2665,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function (arg0, arg1) {
2562
2665
  const a = state0.a;
2563
2666
  state0.a = 0;
2564
2667
  try {
2565
- return __wbg_adapter_233(a, state0.b, arg0, arg1);
2668
+ return __wbg_adapter_237(a, state0.b, arg0, arg1);
2566
2669
  } finally {
2567
2670
  state0.a = a;
2568
2671
  }
@@ -2704,13 +2807,6 @@ module.exports.__wbg_randomFillSync_ac0988aba3254290 = function () {
2704
2807
  }, arguments);
2705
2808
  };
2706
2809
 
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
2810
  module.exports.__wbg_receiveerror_new = function (arg0) {
2715
2811
  const ret = ReceiveError.__wrap(arg0);
2716
2812
  return addHeapObject(ret);
@@ -2728,7 +2824,7 @@ module.exports.__wbg_resolve_4851785c9c5f573d = function (arg0) {
2728
2824
  return addHeapObject(ret);
2729
2825
  };
2730
2826
 
2731
- module.exports.__wbg_send_c9eacaae08065b18 = function () {
2827
+ module.exports.__wbg_send_9b8fc6bb517867dd = function () {
2732
2828
  return handleError(function (arg0, arg1) {
2733
2829
  const ret = getObject(arg0).send(OutgoingMessage.__wrap(arg1));
2734
2830
  return addHeapObject(ret);
@@ -2936,13 +3032,13 @@ module.exports.__wbindgen_cb_drop = function (arg0) {
2936
3032
  return ret;
2937
3033
  };
2938
3034
 
2939
- module.exports.__wbindgen_closure_wrapper2851 = function (arg0, arg1, arg2) {
2940
- const ret = makeMutClosure(arg0, arg1, 662, __wbg_adapter_50);
3035
+ module.exports.__wbindgen_closure_wrapper2876 = function (arg0, arg1, arg2) {
3036
+ const ret = makeMutClosure(arg0, arg1, 664, __wbg_adapter_50);
2941
3037
  return addHeapObject(ret);
2942
3038
  };
2943
3039
 
2944
- module.exports.__wbindgen_closure_wrapper3236 = function (arg0, arg1, arg2) {
2945
- const ret = makeMutClosure(arg0, arg1, 783, __wbg_adapter_53);
3040
+ module.exports.__wbindgen_closure_wrapper3269 = function (arg0, arg1, arg2) {
3041
+ const ret = makeMutClosure(arg0, arg1, 786, __wbg_adapter_53);
2946
3042
  return addHeapObject(ret);
2947
3043
  };
2948
3044
 
@@ -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,11 @@ 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;
63
+ export const ipcclientsubscription_receive: (a: number) => number;
59
64
  export const ipcclient_new: (a: number) => number;
60
65
  export const ipcclient_send: (a: number, b: number) => number;
61
- export const ipcclient_receive: (a: number) => number;
66
+ export const ipcclient_subscribe: (a: number) => number;
62
67
  export const outgoingmessage_new: (a: number, b: number, c: number, d: number, e: number) => number;
63
68
  export const outgoingmessage_new_json_payload: (
64
69
  a: number,
@@ -76,6 +81,7 @@ export const incomingmessage_new: (
76
81
  f: number,
77
82
  ) => number;
78
83
  export const incomingmessage_parse_payload_as_json: (a: number) => number;
84
+ export const isChannelError: (a: number) => number;
79
85
  export const isDeserializeError: (a: number) => number;
80
86
  export const __wbg_set_senderror_crypto: (a: number, b: number) => void;
81
87
  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.159",
4
4
  "license": "GPL-3.0",
5
5
  "files": [
6
6
  "bitwarden_wasm_internal_bg.js",