@vaiftechnologies/vaif-client 0.2.0 → 0.2.1
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/index.cjs +19 -11
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -605,17 +605,19 @@ var VaifRealtime = class {
|
|
|
605
605
|
return;
|
|
606
606
|
}
|
|
607
607
|
const config = this.client.getConfig();
|
|
608
|
-
|
|
609
|
-
url.searchParams.set("apikey", config.apiKey);
|
|
610
|
-
url.searchParams.set("project", config.projectId);
|
|
611
|
-
const token = this.client.getAccessToken();
|
|
612
|
-
if (token) {
|
|
613
|
-
url.searchParams.set("token", token);
|
|
614
|
-
}
|
|
615
|
-
this.socket = new WebSocket(url.toString());
|
|
608
|
+
this.socket = new WebSocket(config.realtimeUrl);
|
|
616
609
|
this.socket.onopen = () => {
|
|
617
610
|
this.client.debug("Realtime connected");
|
|
618
611
|
this.reconnectAttempts = 0;
|
|
612
|
+
this.send({
|
|
613
|
+
topic: "phoenix",
|
|
614
|
+
event: "auth",
|
|
615
|
+
payload: {
|
|
616
|
+
apikey: config.apiKey,
|
|
617
|
+
project: config.projectId,
|
|
618
|
+
token: this.client.getAccessToken() ?? void 0
|
|
619
|
+
}
|
|
620
|
+
});
|
|
619
621
|
if (options.heartbeat !== false) {
|
|
620
622
|
this.startHeartbeat(options.heartbeatInterval ?? 3e4);
|
|
621
623
|
}
|
|
@@ -2689,7 +2691,7 @@ var VaifAdmin = class {
|
|
|
2689
2691
|
const response = await fetch(url, {
|
|
2690
2692
|
...options,
|
|
2691
2693
|
headers,
|
|
2692
|
-
credentials: "
|
|
2694
|
+
credentials: "same-origin"
|
|
2693
2695
|
});
|
|
2694
2696
|
if (!response.ok) {
|
|
2695
2697
|
const error = await response.json().catch(() => ({ message: "Request failed" }));
|
|
@@ -3803,10 +3805,16 @@ var VaifClient = class {
|
|
|
3803
3805
|
} catch {
|
|
3804
3806
|
}
|
|
3805
3807
|
}
|
|
3806
|
-
/** Log debug messages */
|
|
3808
|
+
/** Log debug messages (sanitised to avoid leaking tokens) */
|
|
3807
3809
|
debug(...args) {
|
|
3808
3810
|
if (this.config.debug) {
|
|
3809
|
-
|
|
3811
|
+
const safe = args.map((arg) => {
|
|
3812
|
+
if (arg instanceof Error) return arg.message;
|
|
3813
|
+
if (typeof arg === "string") return arg;
|
|
3814
|
+
if (typeof arg === "number" || typeof arg === "boolean") return arg;
|
|
3815
|
+
return "[object]";
|
|
3816
|
+
});
|
|
3817
|
+
console.log("[VAIF]", ...safe);
|
|
3810
3818
|
}
|
|
3811
3819
|
}
|
|
3812
3820
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -4179,7 +4179,7 @@ declare class VaifClient {
|
|
|
4179
4179
|
request<T = unknown>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
4180
4180
|
/** Restore session from storage */
|
|
4181
4181
|
private restoreSession;
|
|
4182
|
-
/** Log debug messages */
|
|
4182
|
+
/** Log debug messages (sanitised to avoid leaking tokens) */
|
|
4183
4183
|
debug(...args: unknown[]): void;
|
|
4184
4184
|
}
|
|
4185
4185
|
|
package/dist/index.d.ts
CHANGED
|
@@ -4179,7 +4179,7 @@ declare class VaifClient {
|
|
|
4179
4179
|
request<T = unknown>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
4180
4180
|
/** Restore session from storage */
|
|
4181
4181
|
private restoreSession;
|
|
4182
|
-
/** Log debug messages */
|
|
4182
|
+
/** Log debug messages (sanitised to avoid leaking tokens) */
|
|
4183
4183
|
debug(...args: unknown[]): void;
|
|
4184
4184
|
}
|
|
4185
4185
|
|
package/dist/index.js
CHANGED
|
@@ -547,17 +547,19 @@ var VaifRealtime = class {
|
|
|
547
547
|
return;
|
|
548
548
|
}
|
|
549
549
|
const config = this.client.getConfig();
|
|
550
|
-
|
|
551
|
-
url.searchParams.set("apikey", config.apiKey);
|
|
552
|
-
url.searchParams.set("project", config.projectId);
|
|
553
|
-
const token = this.client.getAccessToken();
|
|
554
|
-
if (token) {
|
|
555
|
-
url.searchParams.set("token", token);
|
|
556
|
-
}
|
|
557
|
-
this.socket = new WebSocket(url.toString());
|
|
550
|
+
this.socket = new WebSocket(config.realtimeUrl);
|
|
558
551
|
this.socket.onopen = () => {
|
|
559
552
|
this.client.debug("Realtime connected");
|
|
560
553
|
this.reconnectAttempts = 0;
|
|
554
|
+
this.send({
|
|
555
|
+
topic: "phoenix",
|
|
556
|
+
event: "auth",
|
|
557
|
+
payload: {
|
|
558
|
+
apikey: config.apiKey,
|
|
559
|
+
project: config.projectId,
|
|
560
|
+
token: this.client.getAccessToken() ?? void 0
|
|
561
|
+
}
|
|
562
|
+
});
|
|
561
563
|
if (options.heartbeat !== false) {
|
|
562
564
|
this.startHeartbeat(options.heartbeatInterval ?? 3e4);
|
|
563
565
|
}
|
|
@@ -2631,7 +2633,7 @@ var VaifAdmin = class {
|
|
|
2631
2633
|
const response = await fetch(url, {
|
|
2632
2634
|
...options,
|
|
2633
2635
|
headers,
|
|
2634
|
-
credentials: "
|
|
2636
|
+
credentials: "same-origin"
|
|
2635
2637
|
});
|
|
2636
2638
|
if (!response.ok) {
|
|
2637
2639
|
const error = await response.json().catch(() => ({ message: "Request failed" }));
|
|
@@ -3745,10 +3747,16 @@ var VaifClient = class {
|
|
|
3745
3747
|
} catch {
|
|
3746
3748
|
}
|
|
3747
3749
|
}
|
|
3748
|
-
/** Log debug messages */
|
|
3750
|
+
/** Log debug messages (sanitised to avoid leaking tokens) */
|
|
3749
3751
|
debug(...args) {
|
|
3750
3752
|
if (this.config.debug) {
|
|
3751
|
-
|
|
3753
|
+
const safe = args.map((arg) => {
|
|
3754
|
+
if (arg instanceof Error) return arg.message;
|
|
3755
|
+
if (typeof arg === "string") return arg;
|
|
3756
|
+
if (typeof arg === "number" || typeof arg === "boolean") return arg;
|
|
3757
|
+
return "[object]";
|
|
3758
|
+
});
|
|
3759
|
+
console.log("[VAIF]", ...safe);
|
|
3752
3760
|
}
|
|
3753
3761
|
}
|
|
3754
3762
|
};
|