@interncom/diplomatic 0.0.18 → 0.0.21

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/dist/client.d.ts CHANGED
@@ -26,6 +26,8 @@ export default class DiplomaticClient {
26
26
  setSeed(seed: Uint8Array): Promise<void>;
27
27
  loadHost(): Promise<void>;
28
28
  register(hostURL: string): Promise<void>;
29
+ disconnect: () => void;
30
+ registerAndConnect(hostURL: string): Promise<void>;
29
31
  emitUpdate(): Promise<void>;
30
32
  getState(): Promise<IDiplomaticClientState>;
31
33
  processOps(): Promise<void>;
package/dist/index.mjs CHANGED
@@ -8889,6 +8889,18 @@ var DiplomaticClient = class {
8889
8889
  await this.store.setHostID(hostID);
8890
8890
  this.emitUpdate();
8891
8891
  }
8892
+ disconnect = () => {
8893
+ this.hostURL = void 0;
8894
+ this.hostKeyPair = void 0;
8895
+ this.websocket?.close();
8896
+ this.websocket = void 0;
8897
+ this.emitUpdate();
8898
+ };
8899
+ async registerAndConnect(hostURL) {
8900
+ await this.register(hostURL);
8901
+ await this.connect(new URL(hostURL));
8902
+ await this.sync();
8903
+ }
8892
8904
  async emitUpdate() {
8893
8905
  const state = await this.getState();
8894
8906
  this.listener?.(state);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interncom/diplomatic",
3
- "version": "0.0.18",
3
+ "version": "0.0.21",
4
4
  "type": "module",
5
5
  "description": "Secure sync layer",
6
6
  "main": "dist/index.mjs",