@sandbox-engine/sdk 0.2.2 → 0.2.3
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.js +3 -2
- package/dist/index.mjs +3 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -131,10 +131,10 @@ var HttpClient = class {
|
|
|
131
131
|
// CF Workers: uses fetch() with Upgrade header (supports Authorization).
|
|
132
132
|
// Node.js: uses the ws package (installed as an optional dependency).
|
|
133
133
|
async openWebSocket(path) {
|
|
134
|
-
const wsUrl = this.baseUrl.replace(/^http/, "ws") + path;
|
|
135
134
|
const authHeader = `Bearer ${this.apiKey}`;
|
|
136
135
|
if (IS_CF_WORKERS) {
|
|
137
|
-
const
|
|
136
|
+
const httpUrl = this.baseUrl + path;
|
|
137
|
+
const resp = await fetch(httpUrl, {
|
|
138
138
|
headers: {
|
|
139
139
|
Upgrade: "websocket",
|
|
140
140
|
Connection: "Upgrade",
|
|
@@ -145,6 +145,7 @@ var HttpClient = class {
|
|
|
145
145
|
if (!cfWs) throw new Error("WebSocket upgrade failed \u2014 server did not accept");
|
|
146
146
|
return new WsEmitterAdapter(cfWs);
|
|
147
147
|
}
|
|
148
|
+
const wsUrl = this.baseUrl.replace(/^http/, "ws") + path;
|
|
148
149
|
const { default: WS } = await import("ws");
|
|
149
150
|
return new WS(wsUrl, { headers: { authorization: authHeader } });
|
|
150
151
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -90,10 +90,10 @@ var HttpClient = class {
|
|
|
90
90
|
// CF Workers: uses fetch() with Upgrade header (supports Authorization).
|
|
91
91
|
// Node.js: uses the ws package (installed as an optional dependency).
|
|
92
92
|
async openWebSocket(path) {
|
|
93
|
-
const wsUrl = this.baseUrl.replace(/^http/, "ws") + path;
|
|
94
93
|
const authHeader = `Bearer ${this.apiKey}`;
|
|
95
94
|
if (IS_CF_WORKERS) {
|
|
96
|
-
const
|
|
95
|
+
const httpUrl = this.baseUrl + path;
|
|
96
|
+
const resp = await fetch(httpUrl, {
|
|
97
97
|
headers: {
|
|
98
98
|
Upgrade: "websocket",
|
|
99
99
|
Connection: "Upgrade",
|
|
@@ -104,6 +104,7 @@ var HttpClient = class {
|
|
|
104
104
|
if (!cfWs) throw new Error("WebSocket upgrade failed \u2014 server did not accept");
|
|
105
105
|
return new WsEmitterAdapter(cfWs);
|
|
106
106
|
}
|
|
107
|
+
const wsUrl = this.baseUrl.replace(/^http/, "ws") + path;
|
|
107
108
|
const { default: WS } = await import("ws");
|
|
108
109
|
return new WS(wsUrl, { headers: { authorization: authHeader } });
|
|
109
110
|
}
|