cry-synced-db-client 0.1.15 → 0.1.17
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.
|
@@ -7,6 +7,8 @@ export interface Ebus2ProxyServerUpdateNotifierConfig {
|
|
|
7
7
|
dbName: string;
|
|
8
8
|
/** Collections to subscribe to */
|
|
9
9
|
collections: string[];
|
|
10
|
+
/** API key for ebus-proxy authentication (passed as ?apikey query parameter) */
|
|
11
|
+
ebusProxyApiKey?: string;
|
|
10
12
|
/** Initial reconnect delay in ms (default: 1000) */
|
|
11
13
|
reconnectDelayMs?: number;
|
|
12
14
|
/** Maximum reconnect delay in ms (default: 30000) */
|
|
@@ -28,6 +30,7 @@ export declare class Ebus2ProxyServerUpdateNotifier implements I_ServerUpdateNot
|
|
|
28
30
|
private wsUrl;
|
|
29
31
|
private dbName;
|
|
30
32
|
private collections;
|
|
33
|
+
private ebusProxyApiKey?;
|
|
31
34
|
private reconnectDelayMs;
|
|
32
35
|
private maxReconnectDelayMs;
|
|
33
36
|
private pingIntervalMs;
|
package/dist/index.js
CHANGED
|
@@ -335,6 +335,7 @@ class SyncedDb {
|
|
|
335
335
|
}
|
|
336
336
|
if (this.serverUpdateNotifier) {
|
|
337
337
|
this.unsubscribeServerUpdates = this.serverUpdateNotifier.subscribe((payload) => this.handleServerUpdate(payload));
|
|
338
|
+
await this.serverUpdateNotifier.connect();
|
|
338
339
|
}
|
|
339
340
|
if (typeof window !== "undefined") {
|
|
340
341
|
this.beforeUnloadHandler = () => {
|
|
@@ -357,6 +358,9 @@ class SyncedDb {
|
|
|
357
358
|
this.unsubscribeServerUpdates();
|
|
358
359
|
this.unsubscribeServerUpdates = undefined;
|
|
359
360
|
}
|
|
361
|
+
if (this.serverUpdateNotifier) {
|
|
362
|
+
await this.serverUpdateNotifier.disconnect();
|
|
363
|
+
}
|
|
360
364
|
if (typeof window !== "undefined" && this.beforeUnloadHandler) {
|
|
361
365
|
window.removeEventListener("beforeunload", this.beforeUnloadHandler);
|
|
362
366
|
this.beforeUnloadHandler = undefined;
|
|
@@ -3872,6 +3876,7 @@ class Ebus2ProxyServerUpdateNotifier {
|
|
|
3872
3876
|
wsUrl;
|
|
3873
3877
|
dbName;
|
|
3874
3878
|
collections;
|
|
3879
|
+
ebusProxyApiKey;
|
|
3875
3880
|
reconnectDelayMs;
|
|
3876
3881
|
maxReconnectDelayMs;
|
|
3877
3882
|
pingIntervalMs;
|
|
@@ -3895,6 +3900,7 @@ class Ebus2ProxyServerUpdateNotifier {
|
|
|
3895
3900
|
this.wsUrl = config.wsUrl;
|
|
3896
3901
|
this.dbName = config.dbName;
|
|
3897
3902
|
this.collections = config.collections;
|
|
3903
|
+
this.ebusProxyApiKey = config.ebusProxyApiKey;
|
|
3898
3904
|
this.reconnectDelayMs = config.reconnectDelayMs ?? DEFAULT_RECONNECT_DELAY_MS;
|
|
3899
3905
|
this.maxReconnectDelayMs = config.maxReconnectDelayMs ?? DEFAULT_MAX_RECONNECT_DELAY_MS;
|
|
3900
3906
|
this.pingIntervalMs = config.pingIntervalMs ?? DEFAULT_PING_INTERVAL_MS;
|
|
@@ -3952,7 +3958,12 @@ class Ebus2ProxyServerUpdateNotifier {
|
|
|
3952
3958
|
return;
|
|
3953
3959
|
}
|
|
3954
3960
|
try {
|
|
3955
|
-
|
|
3961
|
+
let url = this.wsUrl;
|
|
3962
|
+
if (this.ebusProxyApiKey) {
|
|
3963
|
+
const separator = url.includes("?") ? "&" : "?";
|
|
3964
|
+
url = `${url}${separator}apikey=${encodeURIComponent(this.ebusProxyApiKey)}`;
|
|
3965
|
+
}
|
|
3966
|
+
this.ws = new WebSocket(url);
|
|
3956
3967
|
this.ws.binaryType = "arraybuffer";
|
|
3957
3968
|
this.ws.onopen = () => {
|
|
3958
3969
|
this.handleOpen();
|