@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.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 6a9ca8ce0d1559c52dacd21225c32528dedabf44
1
+ c6835e59d5abdd50a117729dd718a23029a71ad8
@@ -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);
@@ -347,6 +347,19 @@ function _assertClass(instance, klass) {
347
347
  throw new Error(`expected instance of ${klass.name}`);
348
348
  }
349
349
  }
350
+ /**
351
+ * @param {any} error
352
+ * @returns {boolean}
353
+ */
354
+ export function isChannelError(error) {
355
+ try {
356
+ const ret = wasm.isChannelError(addBorrowedObject(error));
357
+ return ret !== 0;
358
+ } finally {
359
+ heap[stack_pointer++] = undefined;
360
+ }
361
+ }
362
+
350
363
  /**
351
364
  * @param {any} error
352
365
  * @returns {boolean}
@@ -587,7 +600,7 @@ function __wbg_adapter_53(arg0, arg1, arg2) {
587
600
  );
588
601
  }
589
602
 
590
- function __wbg_adapter_233(arg0, arg1, arg2, arg3) {
603
+ function __wbg_adapter_237(arg0, arg1, arg2, arg3) {
591
604
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h2a33b0877ef96682(
592
605
  arg0,
593
606
  arg1,
@@ -1704,10 +1717,12 @@ export class IpcClient {
1704
1717
  wasm.__wbg_ipcclient_free(ptr, 0);
1705
1718
  }
1706
1719
  /**
1707
- * @param {CommunicationBackend} communication_provider
1720
+ * @param {IpcCommunicationBackend} communication_provider
1708
1721
  */
1709
1722
  constructor(communication_provider) {
1710
- const ret = wasm.ipcclient_new(addHeapObject(communication_provider));
1723
+ _assertClass(communication_provider, IpcCommunicationBackend);
1724
+ var ptr0 = communication_provider.__destroy_into_raw();
1725
+ const ret = wasm.ipcclient_new(ptr0);
1711
1726
  this.__wbg_ptr = ret >>> 0;
1712
1727
  IpcClientFinalization.register(this, this.__wbg_ptr, this);
1713
1728
  return this;
@@ -1722,15 +1737,96 @@ export class IpcClient {
1722
1737
  const ret = wasm.ipcclient_send(this.__wbg_ptr, ptr0);
1723
1738
  return takeObject(ret);
1724
1739
  }
1740
+ /**
1741
+ * @returns {Promise<IpcClientSubscription>}
1742
+ */
1743
+ subscribe() {
1744
+ const ret = wasm.ipcclient_subscribe(this.__wbg_ptr);
1745
+ return takeObject(ret);
1746
+ }
1747
+ }
1748
+
1749
+ const IpcClientSubscriptionFinalization =
1750
+ typeof FinalizationRegistry === "undefined"
1751
+ ? { register: () => {}, unregister: () => {} }
1752
+ : new FinalizationRegistry((ptr) => wasm.__wbg_ipcclientsubscription_free(ptr >>> 0, 1));
1753
+
1754
+ export class IpcClientSubscription {
1755
+ static __wrap(ptr) {
1756
+ ptr = ptr >>> 0;
1757
+ const obj = Object.create(IpcClientSubscription.prototype);
1758
+ obj.__wbg_ptr = ptr;
1759
+ IpcClientSubscriptionFinalization.register(obj, obj.__wbg_ptr, obj);
1760
+ return obj;
1761
+ }
1762
+
1763
+ __destroy_into_raw() {
1764
+ const ptr = this.__wbg_ptr;
1765
+ this.__wbg_ptr = 0;
1766
+ IpcClientSubscriptionFinalization.unregister(this);
1767
+ return ptr;
1768
+ }
1769
+
1770
+ free() {
1771
+ const ptr = this.__destroy_into_raw();
1772
+ wasm.__wbg_ipcclientsubscription_free(ptr, 0);
1773
+ }
1725
1774
  /**
1726
1775
  * @returns {Promise<IncomingMessage>}
1727
1776
  */
1728
1777
  receive() {
1729
- const ret = wasm.ipcclient_receive(this.__wbg_ptr);
1778
+ const ret = wasm.ipcclientsubscription_receive(this.__wbg_ptr);
1730
1779
  return takeObject(ret);
1731
1780
  }
1732
1781
  }
1733
1782
 
1783
+ const IpcCommunicationBackendFinalization =
1784
+ typeof FinalizationRegistry === "undefined"
1785
+ ? { register: () => {}, unregister: () => {} }
1786
+ : new FinalizationRegistry((ptr) => wasm.__wbg_ipccommunicationbackend_free(ptr >>> 0, 1));
1787
+
1788
+ export class IpcCommunicationBackend {
1789
+ __destroy_into_raw() {
1790
+ const ptr = this.__wbg_ptr;
1791
+ this.__wbg_ptr = 0;
1792
+ IpcCommunicationBackendFinalization.unregister(this);
1793
+ return ptr;
1794
+ }
1795
+
1796
+ free() {
1797
+ const ptr = this.__destroy_into_raw();
1798
+ wasm.__wbg_ipccommunicationbackend_free(ptr, 0);
1799
+ }
1800
+ /**
1801
+ * @param {IpcCommunicationBackendSender} sender
1802
+ */
1803
+ constructor(sender) {
1804
+ const ret = wasm.ipccommunicationbackend_new(addHeapObject(sender));
1805
+ this.__wbg_ptr = ret >>> 0;
1806
+ IpcCommunicationBackendFinalization.register(this, this.__wbg_ptr, this);
1807
+ return this;
1808
+ }
1809
+ /**
1810
+ * JavaScript function to provide a received message to the backend/IPC framework.
1811
+ * @param {IncomingMessage} message
1812
+ */
1813
+ deliver_message(message) {
1814
+ try {
1815
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1816
+ _assertClass(message, IncomingMessage);
1817
+ var ptr0 = message.__destroy_into_raw();
1818
+ wasm.ipccommunicationbackend_deliver_message(retptr, this.__wbg_ptr, ptr0);
1819
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1820
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1821
+ if (r1) {
1822
+ throw takeObject(r0);
1823
+ }
1824
+ } finally {
1825
+ wasm.__wbindgen_add_to_stack_pointer(16);
1826
+ }
1827
+ }
1828
+ }
1829
+
1734
1830
  const OutgoingMessageFinalization =
1735
1831
  typeof FinalizationRegistry === "undefined"
1736
1832
  ? { register: () => {}, unregister: () => {} }
@@ -2500,6 +2596,11 @@ export function __wbg_instanceof_Uint8Array_17156bcf118086a9(arg0) {
2500
2596
  return ret;
2501
2597
  }
2502
2598
 
2599
+ export function __wbg_ipcclientsubscription_new(arg0) {
2600
+ const ret = IpcClientSubscription.__wrap(arg0);
2601
+ return addHeapObject(ret);
2602
+ }
2603
+
2503
2604
  export function __wbg_isArray_a1eab7e0d067391b(arg0) {
2504
2605
  const ret = Array.isArray(getObject(arg0));
2505
2606
  return ret;
@@ -2553,7 +2654,7 @@ export function __wbg_new_23a2665fac83c611(arg0, arg1) {
2553
2654
  const a = state0.a;
2554
2655
  state0.a = 0;
2555
2656
  try {
2556
- return __wbg_adapter_233(a, state0.b, arg0, arg1);
2657
+ return __wbg_adapter_237(a, state0.b, arg0, arg1);
2557
2658
  } finally {
2558
2659
  state0.a = a;
2559
2660
  }
@@ -2695,13 +2796,6 @@ export function __wbg_randomFillSync_ac0988aba3254290() {
2695
2796
  }, arguments);
2696
2797
  }
2697
2798
 
2698
- export function __wbg_receive_9512d555fb8b5130() {
2699
- return handleError(function (arg0) {
2700
- const ret = getObject(arg0).receive();
2701
- return addHeapObject(ret);
2702
- }, arguments);
2703
- }
2704
-
2705
2799
  export function __wbg_receiveerror_new(arg0) {
2706
2800
  const ret = ReceiveError.__wrap(arg0);
2707
2801
  return addHeapObject(ret);
@@ -2719,7 +2813,7 @@ export function __wbg_resolve_4851785c9c5f573d(arg0) {
2719
2813
  return addHeapObject(ret);
2720
2814
  }
2721
2815
 
2722
- export function __wbg_send_c9eacaae08065b18() {
2816
+ export function __wbg_send_9b8fc6bb517867dd() {
2723
2817
  return handleError(function (arg0, arg1) {
2724
2818
  const ret = getObject(arg0).send(OutgoingMessage.__wrap(arg1));
2725
2819
  return addHeapObject(ret);
@@ -2927,13 +3021,13 @@ export function __wbindgen_cb_drop(arg0) {
2927
3021
  return ret;
2928
3022
  }
2929
3023
 
2930
- export function __wbindgen_closure_wrapper2851(arg0, arg1, arg2) {
2931
- const ret = makeMutClosure(arg0, arg1, 662, __wbg_adapter_50);
3024
+ export function __wbindgen_closure_wrapper2876(arg0, arg1, arg2) {
3025
+ const ret = makeMutClosure(arg0, arg1, 664, __wbg_adapter_50);
2932
3026
  return addHeapObject(ret);
2933
3027
  }
2934
3028
 
2935
- export function __wbindgen_closure_wrapper3236(arg0, arg1, arg2) {
2936
- const ret = makeMutClosure(arg0, arg1, 783, __wbg_adapter_53);
3029
+ export function __wbindgen_closure_wrapper3269(arg0, arg1, arg2) {
3030
+ const ret = makeMutClosure(arg0, arg1, 786, __wbg_adapter_53);
2937
3031
  return addHeapObject(ret);
2938
3032
  }
2939
3033
 
Binary file
@@ -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;