apache-iggy 0.7.0 → 0.8.0
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/client/client.socket.js +1 -1
- package/dist/e2e/tls.system.e2e.d.ts +20 -0
- package/dist/e2e/tls.system.e2e.js +117 -0
- package/dist/wire/client/client.utils.js +2 -2
- package/dist/wire/command.code.js +1 -1
- package/dist/wire/message/header.utils.js +1 -1
- package/dist/wire/message/poll.utils.js +1 -1
- package/package.json +5 -1
|
@@ -214,7 +214,7 @@ export class CommandResponseStream extends EventEmitter {
|
|
|
214
214
|
return;
|
|
215
215
|
this.heartbeatIntervalHandler = setInterval(async () => {
|
|
216
216
|
if (this.connection.connected) {
|
|
217
|
-
debug(`sending
|
|
217
|
+
debug(`sending heartbeat ping (interval: ${interval} ms)`);
|
|
218
218
|
await this.ping();
|
|
219
219
|
}
|
|
220
220
|
}, interval);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=tls.system.e2e.d.ts.map
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
// TLS integration tests for the Node.js SDK.
|
|
20
|
+
//
|
|
21
|
+
// These tests require a TLS-enabled Iggy server and are skipped by default.
|
|
22
|
+
// To run them locally:
|
|
23
|
+
//
|
|
24
|
+
// 1. Start the server with TLS:
|
|
25
|
+
// IGGY_ROOT_USERNAME=iggy IGGY_ROOT_PASSWORD=iggy \
|
|
26
|
+
// IGGY_TCP_TLS_ENABLED=true \
|
|
27
|
+
// IGGY_TCP_TLS_CERT_FILE=core/certs/iggy_cert.pem \
|
|
28
|
+
// IGGY_TCP_TLS_KEY_FILE=core/certs/iggy_key.pem \
|
|
29
|
+
// cargo r --bin iggy-server
|
|
30
|
+
//
|
|
31
|
+
// 2. Run the tests:
|
|
32
|
+
// cd foreign/node
|
|
33
|
+
// IGGY_TCP_TLS_ENABLED=true IGGY_TCP_ADDRESS=127.0.0.1:8090 \
|
|
34
|
+
// node --import @swc-node/register/esm-register --test src/e2e/tls.system.e2e.ts
|
|
35
|
+
import { readFileSync } from 'node:fs';
|
|
36
|
+
import { resolve } from 'node:path';
|
|
37
|
+
import { after, describe, it } from 'node:test';
|
|
38
|
+
import assert from 'node:assert/strict';
|
|
39
|
+
import { Client } from '../client/client.js';
|
|
40
|
+
import { Partitioning, Consumer, PollingStrategy } from '../wire/index.js';
|
|
41
|
+
import { getIggyAddress } from '../tcp.sm.utils.js';
|
|
42
|
+
const tlsEnabled = process.env.IGGY_TCP_TLS_ENABLED === 'true';
|
|
43
|
+
// Path to the CA certificate. Override with E2E_ROOT_CA_CERT env var,
|
|
44
|
+
// otherwise fall back to the default relative path from the repo root.
|
|
45
|
+
const caCertPath = process.env.E2E_ROOT_CA_CERT
|
|
46
|
+
|| resolve(process.cwd(), '../../core/certs/iggy_ca_cert.pem');
|
|
47
|
+
const getTlsClient = () => {
|
|
48
|
+
const [, port] = getIggyAddress();
|
|
49
|
+
const caCert = readFileSync(caCertPath);
|
|
50
|
+
// The server certificate SAN is DNS:localhost, so we connect via 'localhost'
|
|
51
|
+
// for proper hostname verification (consistent with Python and C# TLS tests).
|
|
52
|
+
return new Client({
|
|
53
|
+
transport: 'TLS',
|
|
54
|
+
options: {
|
|
55
|
+
port,
|
|
56
|
+
host: 'localhost',
|
|
57
|
+
ca: caCert,
|
|
58
|
+
},
|
|
59
|
+
credentials: { username: 'iggy', password: 'iggy' },
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
describe('e2e -> tls', { skip: !tlsEnabled && 'IGGY_TCP_TLS_ENABLED is not set' }, async () => {
|
|
63
|
+
const c = getTlsClient();
|
|
64
|
+
const credentials = { username: 'iggy', password: 'iggy' };
|
|
65
|
+
it('e2e -> tls::ping', async () => {
|
|
66
|
+
assert.ok(await c.system.ping());
|
|
67
|
+
});
|
|
68
|
+
it('e2e -> tls::login', async () => {
|
|
69
|
+
assert.deepEqual(await c.session.login(credentials), { userId: 0 });
|
|
70
|
+
});
|
|
71
|
+
it('e2e -> tls::getStats', async () => {
|
|
72
|
+
const stats = await c.system.getStats();
|
|
73
|
+
assert.ok(stats);
|
|
74
|
+
assert.ok('processId' in stats);
|
|
75
|
+
assert.ok('hostname' in stats);
|
|
76
|
+
});
|
|
77
|
+
it('e2e -> tls::send and poll messages', async () => {
|
|
78
|
+
const streamName = 'tls-e2e-stream';
|
|
79
|
+
const topicName = 'tls-e2e-topic';
|
|
80
|
+
await c.stream.create({ name: streamName });
|
|
81
|
+
await c.topic.create({
|
|
82
|
+
streamId: streamName,
|
|
83
|
+
name: topicName,
|
|
84
|
+
partitionCount: 1,
|
|
85
|
+
compressionAlgorithm: 1,
|
|
86
|
+
});
|
|
87
|
+
const messages = [
|
|
88
|
+
{ id: 1, headers: [], payload: 'tls-message-1' },
|
|
89
|
+
{ id: 2, headers: [], payload: 'tls-message-2' },
|
|
90
|
+
{ id: 3, headers: [], payload: 'tls-message-3' },
|
|
91
|
+
];
|
|
92
|
+
await c.message.send({
|
|
93
|
+
streamId: streamName,
|
|
94
|
+
topicId: topicName,
|
|
95
|
+
messages,
|
|
96
|
+
partition: Partitioning.PartitionId(0),
|
|
97
|
+
});
|
|
98
|
+
const polled = await c.message.poll({
|
|
99
|
+
streamId: streamName,
|
|
100
|
+
topicId: topicName,
|
|
101
|
+
consumer: Consumer.Single,
|
|
102
|
+
partitionId: 0,
|
|
103
|
+
pollingStrategy: PollingStrategy.First,
|
|
104
|
+
count: 10,
|
|
105
|
+
autocommit: false,
|
|
106
|
+
});
|
|
107
|
+
assert.equal(polled.messages.length, 3);
|
|
108
|
+
await c.stream.delete({ streamId: streamName });
|
|
109
|
+
});
|
|
110
|
+
it('e2e -> tls::logout', async () => {
|
|
111
|
+
assert.ok(await c.session.logout());
|
|
112
|
+
});
|
|
113
|
+
after(() => {
|
|
114
|
+
c.destroy();
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
//# sourceMappingURL=tls.system.e2e.js.map
|
|
@@ -29,8 +29,8 @@ export const deserializeClient = (r, pos = 0) => {
|
|
|
29
29
|
* 0 - 4 u32 - client_id
|
|
30
30
|
* 4 - 8 u32 - user_id
|
|
31
31
|
* 8 - 9 u8 - transport
|
|
32
|
-
* 9 - 13 u32 -
|
|
33
|
-
* 13 - x string -
|
|
32
|
+
* 9 - 13 u32 - address length x
|
|
33
|
+
* 13 - x string - address
|
|
34
34
|
* x - x+4 u32 - consumerGroupCount
|
|
35
35
|
*/
|
|
36
36
|
if (r.length < 17)
|
|
@@ -68,6 +68,6 @@ export const COMMAND_CODE = {
|
|
|
68
68
|
};
|
|
69
69
|
const reverseCommandCodeMap = reverseRecord(COMMAND_CODE);
|
|
70
70
|
export const translateCommandCode = (code) => {
|
|
71
|
-
return reverseCommandCodeMap[code] || `
|
|
71
|
+
return reverseCommandCodeMap[code] || `unknown_command_code_${code}`;
|
|
72
72
|
};
|
|
73
73
|
//# sourceMappingURL=command.code.js.map
|
|
@@ -126,7 +126,7 @@ export const serializeHeaders = (headers) => {
|
|
|
126
126
|
*/
|
|
127
127
|
export const mapHeaderKind = (k) => {
|
|
128
128
|
if (!ReverseHeaderKind[k])
|
|
129
|
-
throw new Error(`
|
|
129
|
+
throw new Error(`unknown header kind: ${k}`);
|
|
130
130
|
return ReverseHeaderKind[k];
|
|
131
131
|
};
|
|
132
132
|
/**
|
|
@@ -129,7 +129,7 @@ const ReverseMessageState = reverseRecord(MessageState);
|
|
|
129
129
|
*/
|
|
130
130
|
export const mapMessageState = (k) => {
|
|
131
131
|
if (!ReverseMessageState[k])
|
|
132
|
-
throw new Error(`
|
|
132
|
+
throw new Error(`unknown message state: ${k}`);
|
|
133
133
|
return ReverseMessageState[k];
|
|
134
134
|
};
|
|
135
135
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apache-iggy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"description": "Official Apache Iggy NodeJS SDK",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"iggy",
|
|
@@ -58,10 +58,14 @@
|
|
|
58
58
|
"@swc-node/register": "1.11.1",
|
|
59
59
|
"@types/debug": "4.1.12",
|
|
60
60
|
"@types/node": "24.10.1",
|
|
61
|
+
"c8": "^10.1.0",
|
|
61
62
|
"husky": "9.1.7",
|
|
62
63
|
"typescript": "5.9.3",
|
|
63
64
|
"typescript-eslint": "^8.47.0"
|
|
64
65
|
},
|
|
66
|
+
"overrides": {
|
|
67
|
+
"flatted": "^3.4.2"
|
|
68
|
+
},
|
|
65
69
|
"optionalDependencies": {
|
|
66
70
|
"@swc/core-darwin-arm64": "^1.15.3",
|
|
67
71
|
"@swc/core-darwin-x64": "^1.15.3",
|