wapi-client 0.6.11 → 0.6.15
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.
|
@@ -350,33 +350,30 @@ var require_buffer_util = __commonJS({
|
|
|
350
350
|
}
|
|
351
351
|
return buf;
|
|
352
352
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
353
|
+
module2.exports = {
|
|
354
|
+
concat,
|
|
355
|
+
mask: _mask,
|
|
356
|
+
toArrayBuffer,
|
|
357
|
+
toBuffer,
|
|
358
|
+
unmask: _unmask
|
|
359
|
+
};
|
|
360
|
+
if (!process.env.WS_NO_BUFFER_UTIL) {
|
|
361
|
+
try {
|
|
362
|
+
const bufferUtil = require_bufferutil();
|
|
363
|
+
module2.exports.mask = function(source, mask, output, offset, length) {
|
|
358
364
|
if (length < 48)
|
|
359
365
|
_mask(source, mask, output, offset, length);
|
|
360
366
|
else
|
|
361
367
|
bufferUtil.mask(source, mask, output, offset, length);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
toBuffer,
|
|
365
|
-
unmask(buffer, mask) {
|
|
368
|
+
};
|
|
369
|
+
module2.exports.unmask = function(buffer, mask) {
|
|
366
370
|
if (buffer.length < 32)
|
|
367
371
|
_unmask(buffer, mask);
|
|
368
372
|
else
|
|
369
373
|
bufferUtil.unmask(buffer, mask);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
module2.exports = {
|
|
374
|
-
concat,
|
|
375
|
-
mask: _mask,
|
|
376
|
-
toArrayBuffer,
|
|
377
|
-
toBuffer,
|
|
378
|
-
unmask: _unmask
|
|
379
|
-
};
|
|
374
|
+
};
|
|
375
|
+
} catch (e) {
|
|
376
|
+
}
|
|
380
377
|
}
|
|
381
378
|
}
|
|
382
379
|
});
|
|
@@ -884,21 +881,19 @@ var require_validation = __commonJS({
|
|
|
884
881
|
}
|
|
885
882
|
return true;
|
|
886
883
|
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
884
|
+
module2.exports = {
|
|
885
|
+
isValidStatusCode,
|
|
886
|
+
isValidUTF8: _isValidUTF8,
|
|
887
|
+
tokenChars
|
|
888
|
+
};
|
|
889
|
+
if (!process.env.WS_NO_UTF_8_VALIDATE) {
|
|
890
|
+
try {
|
|
891
|
+
const isValidUTF8 = require_utf_8_validate();
|
|
892
|
+
module2.exports.isValidUTF8 = function(buf) {
|
|
892
893
|
return buf.length < 150 ? _isValidUTF8(buf) : isValidUTF8(buf);
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
}
|
|
896
|
-
} catch (e) {
|
|
897
|
-
module2.exports = {
|
|
898
|
-
isValidStatusCode,
|
|
899
|
-
isValidUTF8: _isValidUTF8,
|
|
900
|
-
tokenChars
|
|
901
|
-
};
|
|
894
|
+
};
|
|
895
|
+
} catch (e) {
|
|
896
|
+
}
|
|
902
897
|
}
|
|
903
898
|
}
|
|
904
899
|
});
|
|
@@ -2278,6 +2273,7 @@ var require_websocket = __commonJS({
|
|
|
2278
2273
|
let req;
|
|
2279
2274
|
if (opts.followRedirects) {
|
|
2280
2275
|
if (websocket._redirects === 0) {
|
|
2276
|
+
websocket._originalSecure = isSecure;
|
|
2281
2277
|
websocket._originalHost = parsedUrl.host;
|
|
2282
2278
|
const headers = options && options.headers;
|
|
2283
2279
|
options = __spreadProps(__spreadValues({}, options), { headers: {} });
|
|
@@ -2286,11 +2282,15 @@ var require_websocket = __commonJS({
|
|
|
2286
2282
|
options.headers[key2.toLowerCase()] = value;
|
|
2287
2283
|
}
|
|
2288
2284
|
}
|
|
2289
|
-
} else if (websocket.listenerCount("redirect") === 0
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2285
|
+
} else if (websocket.listenerCount("redirect") === 0) {
|
|
2286
|
+
const isSameHost = parsedUrl.host === websocket._originalHost;
|
|
2287
|
+
if (!isSameHost || websocket._originalSecure && !isSecure) {
|
|
2288
|
+
delete opts.headers.authorization;
|
|
2289
|
+
delete opts.headers.cookie;
|
|
2290
|
+
if (!isSameHost)
|
|
2291
|
+
delete opts.headers.host;
|
|
2292
|
+
opts.auth = void 0;
|
|
2293
|
+
}
|
|
2294
2294
|
}
|
|
2295
2295
|
if (opts.auth && !options.headers.authorization) {
|
|
2296
2296
|
options.headers.authorization = "Basic " + Buffer.from(opts.auth).toString("base64");
|
|
@@ -2340,6 +2340,10 @@ var require_websocket = __commonJS({
|
|
|
2340
2340
|
if (websocket.readyState !== WebSocket2.CONNECTING)
|
|
2341
2341
|
return;
|
|
2342
2342
|
req = websocket._req = null;
|
|
2343
|
+
if (res.headers.upgrade.toLowerCase() !== "websocket") {
|
|
2344
|
+
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
2345
|
+
return;
|
|
2346
|
+
}
|
|
2343
2347
|
const digest = createHash("sha1").update(key + GUID).digest("base64");
|
|
2344
2348
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
2345
2349
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
@@ -2815,10 +2819,31 @@ var require_websocket_server = __commonJS({
|
|
|
2815
2819
|
}
|
|
2816
2820
|
handleUpgrade(req, socket, head, cb) {
|
|
2817
2821
|
socket.on("error", socketOnError);
|
|
2818
|
-
const key = req.headers["sec-websocket-key"]
|
|
2822
|
+
const key = req.headers["sec-websocket-key"];
|
|
2819
2823
|
const version2 = +req.headers["sec-websocket-version"];
|
|
2820
|
-
if (req.method !== "GET"
|
|
2821
|
-
|
|
2824
|
+
if (req.method !== "GET") {
|
|
2825
|
+
const message = "Invalid HTTP method";
|
|
2826
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 405, message);
|
|
2827
|
+
return;
|
|
2828
|
+
}
|
|
2829
|
+
if (req.headers.upgrade.toLowerCase() !== "websocket") {
|
|
2830
|
+
const message = "Invalid Upgrade header";
|
|
2831
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
2832
|
+
return;
|
|
2833
|
+
}
|
|
2834
|
+
if (!key || !keyRegex.test(key)) {
|
|
2835
|
+
const message = "Missing or invalid Sec-WebSocket-Key header";
|
|
2836
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
2837
|
+
return;
|
|
2838
|
+
}
|
|
2839
|
+
if (version2 !== 8 && version2 !== 13) {
|
|
2840
|
+
const message = "Missing or invalid Sec-WebSocket-Version header";
|
|
2841
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
2842
|
+
return;
|
|
2843
|
+
}
|
|
2844
|
+
if (!this.shouldHandle(req)) {
|
|
2845
|
+
abortHandshake(socket, 400);
|
|
2846
|
+
return;
|
|
2822
2847
|
}
|
|
2823
2848
|
const secWebSocketProtocol = req.headers["sec-websocket-protocol"];
|
|
2824
2849
|
let protocols = /* @__PURE__ */ new Set();
|
|
@@ -2826,7 +2851,9 @@ var require_websocket_server = __commonJS({
|
|
|
2826
2851
|
try {
|
|
2827
2852
|
protocols = subprotocol.parse(secWebSocketProtocol);
|
|
2828
2853
|
} catch (err) {
|
|
2829
|
-
|
|
2854
|
+
const message = "Invalid Sec-WebSocket-Protocol header";
|
|
2855
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
2856
|
+
return;
|
|
2830
2857
|
}
|
|
2831
2858
|
}
|
|
2832
2859
|
const secWebSocketExtensions = req.headers["sec-websocket-extensions"];
|
|
@@ -2840,7 +2867,9 @@ var require_websocket_server = __commonJS({
|
|
|
2840
2867
|
extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
|
|
2841
2868
|
}
|
|
2842
2869
|
} catch (err) {
|
|
2843
|
-
|
|
2870
|
+
const message = "Invalid or unacceptable Sec-WebSocket-Extensions header";
|
|
2871
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
2872
|
+
return;
|
|
2844
2873
|
}
|
|
2845
2874
|
}
|
|
2846
2875
|
if (this.options.verifyClient) {
|
|
@@ -2931,18 +2960,24 @@ var require_websocket_server = __commonJS({
|
|
|
2931
2960
|
this.destroy();
|
|
2932
2961
|
}
|
|
2933
2962
|
function abortHandshake(socket, code, message, headers) {
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2963
|
+
message = message || http.STATUS_CODES[code];
|
|
2964
|
+
headers = __spreadValues({
|
|
2965
|
+
Connection: "close",
|
|
2966
|
+
"Content-Type": "text/html",
|
|
2967
|
+
"Content-Length": Buffer.byteLength(message)
|
|
2968
|
+
}, headers);
|
|
2969
|
+
socket.once("finish", socket.destroy);
|
|
2970
|
+
socket.end(`HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r
|
|
2942
2971
|
` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message);
|
|
2972
|
+
}
|
|
2973
|
+
function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
|
|
2974
|
+
if (server.listenerCount("wsClientError")) {
|
|
2975
|
+
const err = new Error(message);
|
|
2976
|
+
Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
|
|
2977
|
+
server.emit("wsClientError", err, socket, req);
|
|
2978
|
+
} else {
|
|
2979
|
+
abortHandshake(socket, code, message);
|
|
2943
2980
|
}
|
|
2944
|
-
socket.removeListener("error", socketOnError);
|
|
2945
|
-
socket.destroy();
|
|
2946
2981
|
}
|
|
2947
2982
|
}
|
|
2948
2983
|
});
|
|
@@ -13645,10 +13680,7 @@ function toQueryString(obj) {
|
|
|
13645
13680
|
return Object.keys(obj).filter((key) => obj[key] !== void 0).map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join("&");
|
|
13646
13681
|
}
|
|
13647
13682
|
function getConnectionUrl(config) {
|
|
13648
|
-
|
|
13649
|
-
if (typeof window !== "undefined") {
|
|
13650
|
-
url = config.host.replace(/^https:/, "wss:");
|
|
13651
|
-
}
|
|
13683
|
+
const url = config.host.replace(/^https:/, "wss:");
|
|
13652
13684
|
return url + "?" + toQueryString({
|
|
13653
13685
|
apikey: config.apikey,
|
|
13654
13686
|
apisecret: config.apisecret,
|
|
@@ -29959,7 +29991,7 @@ var BaseClient = class {
|
|
|
29959
29991
|
};
|
|
29960
29992
|
|
|
29961
29993
|
// package.json
|
|
29962
|
-
var version = "0.6.
|
|
29994
|
+
var version = "0.6.15";
|
|
29963
29995
|
|
|
29964
29996
|
// src/api/ws-client.ts
|
|
29965
29997
|
function createClient(opts) {
|
|
@@ -30151,6 +30183,7 @@ function createClient2(opts) {
|
|
|
30151
30183
|
return new HttpClient(initialConnection, opts);
|
|
30152
30184
|
}
|
|
30153
30185
|
function createConnection2(opts) {
|
|
30186
|
+
const url = opts.host.replace(/^wss:/, "https:");
|
|
30154
30187
|
function onmessage(body) {
|
|
30155
30188
|
return __async(this, null, function* () {
|
|
30156
30189
|
debugLog(`http_createConnection>message(body:${body})`);
|
|
@@ -30171,7 +30204,7 @@ function createConnection2(opts) {
|
|
|
30171
30204
|
this.onmessage(__spreadProps(__spreadValues({}, responseBody), { id: jsonBody.id }));
|
|
30172
30205
|
});
|
|
30173
30206
|
}
|
|
30174
|
-
const $connect = (0, import_node_ponyfill.default)(`${
|
|
30207
|
+
const $connect = (0, import_node_ponyfill.default)(`${url}/api`, {
|
|
30175
30208
|
method: "POST",
|
|
30176
30209
|
headers: {
|
|
30177
30210
|
Authorization: `Bearer ${opts.jwt}`
|