@tdengine/websocket 3.1.4 → 3.1.5
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/lib/example/logs/.007e668bb78549e9a304b8466671945ab2a1553e-audit.json +3 -3
- package/lib/example/logs/app-2025-03-18.log +742 -0
- package/lib/src/client/wsClient.d.ts.map +1 -1
- package/lib/src/client/wsClient.js +3 -2
- package/lib/src/common/utils.d.ts +1 -0
- package/lib/src/common/utils.d.ts.map +1 -1
- package/lib/src/common/utils.js +12 -0
- package/lib/test/bulkPulling/sql.test.js +30 -0
- package/package.json +1 -1
- package/lib/example/logs/app-2025-01-24.log +0 -5580
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsClient.d.ts","sourceRoot":"","sources":["../../../src/client/wsClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,eAAe,EAClB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"wsClient.d.ts","sourceRoot":"","sources":["../../../src/client/wsClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,eAAe,EAClB,MAAM,cAAc,CAAC;AAMtB,qBAAa,QAAQ;IACjB,OAAO,CAAC,YAAY,CAAC,CAAqB;IAC1C,OAAO,CAAC,QAAQ,CAAC,CAA2B;IAC5C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAK;gBAEd,GAAG,EAAE,GAAG,EAAE,OAAQ,CAAC,EAAC,MAAM,GAAG,SAAS,GAAG,IAAI;IAOnD,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAqC5D,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3C,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAC,OAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IAuB9D,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,GAAC,OAAc,EAAE,aAAa,GAAE,OAAe,GAAG,OAAO,CAAC,GAAG,CAAC;IA0B/I,QAAQ;IAQF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAetB,OAAO,CAAC,GAAG,EAAC,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAajC,UAAU,CAAC,GAAG,EAAE,eAAe;IAqB/B,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IA4B1B,KAAK,IAAG,OAAO,CAAC,IAAI,CAAC;IAS3B,QAAQ,CAAC,GAAG,EAAE,GAAG;CASpB"}
|
|
@@ -10,6 +10,7 @@ const wsError_1 = require("../common/wsError");
|
|
|
10
10
|
const wsResponse_1 = require("./wsResponse");
|
|
11
11
|
const reqid_1 = require("../common/reqid");
|
|
12
12
|
const log_1 = __importDefault(require("../common/log"));
|
|
13
|
+
const utils_1 = require("../common/utils");
|
|
13
14
|
class WsClient {
|
|
14
15
|
constructor(url, timeout) {
|
|
15
16
|
this.checkURL(url);
|
|
@@ -25,8 +26,8 @@ class WsClient {
|
|
|
25
26
|
action: 'conn',
|
|
26
27
|
args: {
|
|
27
28
|
req_id: reqid_1.ReqId.getReqID(),
|
|
28
|
-
user: this._url.username,
|
|
29
|
-
password: this._url.password,
|
|
29
|
+
user: (0, utils_1.safeDecodeURIComponent)(this._url.username),
|
|
30
|
+
password: (0, utils_1.safeDecodeURIComponent)(this._url.password),
|
|
30
31
|
db: _db,
|
|
31
32
|
},
|
|
32
33
|
};
|
|
@@ -3,4 +3,5 @@ export declare function getUrl(wsConfig: WSConfig): URL;
|
|
|
3
3
|
export declare function isEmpty(value: any): boolean;
|
|
4
4
|
export declare function getBinarySql(action: bigint, reqId: bigint, resultId: bigint, sql?: string): ArrayBuffer;
|
|
5
5
|
export declare function zigzagDecode(n: number): number;
|
|
6
|
+
export declare function safeDecodeURIComponent(str: string): string;
|
|
6
7
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,wBAAgB,MAAM,CAAC,QAAQ,EAAC,QAAQ,GAAE,GAAG,CAe5C;AAGD,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAM3C;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,EAAE,GAAG,CAAC,EAAC,MAAM,GAAG,WAAW,CA6BnG;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,UAQjD"}
|
package/lib/src/common/utils.js
CHANGED
|
@@ -4,6 +4,8 @@ exports.getUrl = getUrl;
|
|
|
4
4
|
exports.isEmpty = isEmpty;
|
|
5
5
|
exports.getBinarySql = getBinarySql;
|
|
6
6
|
exports.zigzagDecode = zigzagDecode;
|
|
7
|
+
exports.safeDecodeURIComponent = safeDecodeURIComponent;
|
|
8
|
+
const wsError_1 = require("./wsError");
|
|
7
9
|
function getUrl(wsConfig) {
|
|
8
10
|
let url = new URL(wsConfig.getUrl());
|
|
9
11
|
if (wsConfig.getUser()) {
|
|
@@ -59,3 +61,13 @@ function getBinarySql(action, reqId, resultId, sql) {
|
|
|
59
61
|
function zigzagDecode(n) {
|
|
60
62
|
return (n >> 1) ^ (-(n & 1));
|
|
61
63
|
}
|
|
64
|
+
function safeDecodeURIComponent(str) {
|
|
65
|
+
// Replace invalid "%" not followed by two hex characters with "%25"
|
|
66
|
+
const cleaned = str.replace(/%(?![0-9A-Fa-f]{2})/g, '%25');
|
|
67
|
+
try {
|
|
68
|
+
return decodeURIComponent(cleaned);
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
throw (new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_INVALID_URL, `Decoding ${str} error: ${e}`));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -5,11 +5,15 @@ const config_1 = require("../../src/common/config");
|
|
|
5
5
|
const wsSql_1 = require("../../src/sql/wsSql");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
7
|
let dns = 'ws://localhost:6041';
|
|
8
|
+
let password1 = 'Ab1!@#$%,.:?<>;~';
|
|
9
|
+
let password2 = 'Bc%^&*()-_+=[]{}';
|
|
8
10
|
beforeAll(async () => {
|
|
9
11
|
let conf = new config_1.WSConfig(dns);
|
|
10
12
|
conf.setUser('root');
|
|
11
13
|
conf.setPwd('taosdata');
|
|
12
14
|
let wsSql = await wsSql_1.WsSql.open(conf);
|
|
15
|
+
await wsSql.exec(`CREATE USER user1 PASS '${password1}'`);
|
|
16
|
+
await wsSql.exec(`CREATE USER user2 PASS '${password2}'`);
|
|
13
17
|
await wsSql.exec('create database if not exists power KEEP 3650 DURATION 10 BUFFER 16 WAL_LEVEL 1;');
|
|
14
18
|
await (0, utils_1.Sleep)(100);
|
|
15
19
|
await wsSql.exec('use power');
|
|
@@ -28,6 +32,30 @@ describe('TDWebSocket.WsSql()', () => {
|
|
|
28
32
|
expect(wsSql.state()).toBeGreaterThan(0);
|
|
29
33
|
await wsSql.close();
|
|
30
34
|
});
|
|
35
|
+
test('special characters connect1', async () => {
|
|
36
|
+
let wsSql = null;
|
|
37
|
+
let conf = new config_1.WSConfig(dns);
|
|
38
|
+
conf.setUser('user1');
|
|
39
|
+
conf.setPwd(password1);
|
|
40
|
+
wsSql = await wsSql_1.WsSql.open(conf);
|
|
41
|
+
expect(wsSql.state()).toBeGreaterThan(0);
|
|
42
|
+
let version = await wsSql.version();
|
|
43
|
+
expect(version).not.toBeNull();
|
|
44
|
+
expect(version).not.toBeUndefined();
|
|
45
|
+
await wsSql.close();
|
|
46
|
+
});
|
|
47
|
+
test('special characters connect2', async () => {
|
|
48
|
+
let wsSql = null;
|
|
49
|
+
let conf = new config_1.WSConfig(dns);
|
|
50
|
+
conf.setUser('user2');
|
|
51
|
+
conf.setPwd(password2);
|
|
52
|
+
wsSql = await wsSql_1.WsSql.open(conf);
|
|
53
|
+
expect(wsSql.state()).toBeGreaterThan(0);
|
|
54
|
+
let version = await wsSql.version();
|
|
55
|
+
expect(version).not.toBeNull();
|
|
56
|
+
expect(version).not.toBeUndefined();
|
|
57
|
+
await wsSql.close();
|
|
58
|
+
});
|
|
31
59
|
test('connect db with error', async () => {
|
|
32
60
|
expect.assertions(1);
|
|
33
61
|
let wsSql = null;
|
|
@@ -147,6 +175,8 @@ afterAll(async () => {
|
|
|
147
175
|
conf.setPwd('taosdata');
|
|
148
176
|
let wsSql = await wsSql_1.WsSql.open(conf);
|
|
149
177
|
await wsSql.exec('drop database power');
|
|
178
|
+
await wsSql.exec('DROP USER user1;');
|
|
179
|
+
await wsSql.exec('DROP USER user2;');
|
|
150
180
|
await wsSql.close();
|
|
151
181
|
wsConnectorPool_1.WebSocketConnectionPool.instance().destroyed();
|
|
152
182
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tdengine/websocket",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
4
4
|
"description": "The websocket Node.js connector for TDengine. TDengine versions 3.3.2.0 and above are recommended to use this connector.",
|
|
5
5
|
"source": "index.ts",
|
|
6
6
|
"main": "lib/index.js",
|