@enyo-energy/sunspec-sdk 0.0.92 → 0.0.93

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.
@@ -126,8 +126,12 @@ class SunspecModbusClient {
126
126
  * @param unitId Modbus unit ID (default 1)
127
127
  * @param secondaryHost Optional secondary host (ipAddress) for fallback during reconnection
128
128
  * @param useTls Whether to use TLS/SSL for the Modbus connection (Modbus Security, typically port 802). Defaults to false.
129
+ * @param tls Optional TLS certificate material for mutual-TLS / custom-CA connections. Only
130
+ * honoured when {@link useTls} is true. `cert`/`key` present a client certificate,
131
+ * `ca` supplies trusted CA certificate(s), and `rejectUnauthorized` controls whether an
132
+ * unverifiable server certificate is rejected.
129
133
  */
130
- async connect(host, port = 502, unitId = 1, secondaryHost, useTls) {
134
+ async connect(host, port = 502, unitId = 1, secondaryHost, useTls, tls) {
131
135
  return this.withConnectionLock(async () => {
132
136
  if (this.connectionParams) {
133
137
  if (this.connectionParams.primaryHost !== host || this.connectionParams.port !== port) {
@@ -140,9 +144,30 @@ class SunspecModbusClient {
140
144
  if (useTls !== undefined) {
141
145
  this.connectionParams.useTls = useTls;
142
146
  }
147
+ if (tls?.cert !== undefined) {
148
+ this.connectionParams.cert = tls.cert;
149
+ }
150
+ if (tls?.key !== undefined) {
151
+ this.connectionParams.key = tls.key;
152
+ }
153
+ if (tls?.ca !== undefined) {
154
+ this.connectionParams.ca = tls.ca;
155
+ }
156
+ if (tls?.rejectUnauthorized !== undefined) {
157
+ this.connectionParams.rejectUnauthorized = tls.rejectUnauthorized;
158
+ }
143
159
  }
144
160
  else {
145
- this.connectionParams = { primaryHost: host, secondaryHost, port, useTls };
161
+ this.connectionParams = {
162
+ primaryHost: host,
163
+ secondaryHost,
164
+ port,
165
+ useTls,
166
+ cert: tls?.cert,
167
+ key: tls?.key,
168
+ ca: tls?.ca,
169
+ rejectUnauthorized: tls?.rejectUnauthorized,
170
+ };
146
171
  }
147
172
  this.knownUnits.add(unitId);
148
173
  if (this.modbusInstances.has(unitId)) {
@@ -289,7 +314,11 @@ class SunspecModbusClient {
289
314
  port,
290
315
  unitId,
291
316
  timeout: 5000,
292
- useTls: this.connectionParams?.useTls
317
+ useTls: this.connectionParams?.useTls,
318
+ cert: this.connectionParams?.cert,
319
+ key: this.connectionParams?.key,
320
+ ca: this.connectionParams?.ca,
321
+ rejectUnauthorized: this.connectionParams?.rejectUnauthorized
293
322
  });
294
323
  if (!candidate) {
295
324
  throw new Error(`useModbus().connect returned null for ${host}:${port} unit ${unitId}`);
@@ -59,8 +59,17 @@ export declare class SunspecModbusClient {
59
59
  * @param unitId Modbus unit ID (default 1)
60
60
  * @param secondaryHost Optional secondary host (ipAddress) for fallback during reconnection
61
61
  * @param useTls Whether to use TLS/SSL for the Modbus connection (Modbus Security, typically port 802). Defaults to false.
62
- */
63
- connect(host: string, port?: number, unitId?: number, secondaryHost?: string, useTls?: boolean): Promise<void>;
62
+ * @param tls Optional TLS certificate material for mutual-TLS / custom-CA connections. Only
63
+ * honoured when {@link useTls} is true. `cert`/`key` present a client certificate,
64
+ * `ca` supplies trusted CA certificate(s), and `rejectUnauthorized` controls whether an
65
+ * unverifiable server certificate is rejected.
66
+ */
67
+ connect(host: string, port?: number, unitId?: number, secondaryHost?: string, useTls?: boolean, tls?: {
68
+ cert?: string | Buffer;
69
+ key?: string | Buffer;
70
+ ca?: string | Buffer | Array<string | Buffer>;
71
+ rejectUnauthorized?: boolean;
72
+ }): Promise<void>;
64
73
  /**
65
74
  * Disconnect from all units of this network device.
66
75
  *
@@ -9,7 +9,7 @@ exports.getSdkVersion = getSdkVersion;
9
9
  /**
10
10
  * Current version of the enyo Energy App SDK.
11
11
  */
12
- exports.SDK_VERSION = '0.0.92';
12
+ exports.SDK_VERSION = '0.0.93';
13
13
  /**
14
14
  * Gets the current SDK version.
15
15
  * @returns The semantic version string of the SDK
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Current version of the enyo Energy App SDK.
7
7
  */
8
- export declare const SDK_VERSION = "0.0.92";
8
+ export declare const SDK_VERSION = "0.0.93";
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
@@ -59,8 +59,17 @@ export declare class SunspecModbusClient {
59
59
  * @param unitId Modbus unit ID (default 1)
60
60
  * @param secondaryHost Optional secondary host (ipAddress) for fallback during reconnection
61
61
  * @param useTls Whether to use TLS/SSL for the Modbus connection (Modbus Security, typically port 802). Defaults to false.
62
- */
63
- connect(host: string, port?: number, unitId?: number, secondaryHost?: string, useTls?: boolean): Promise<void>;
62
+ * @param tls Optional TLS certificate material for mutual-TLS / custom-CA connections. Only
63
+ * honoured when {@link useTls} is true. `cert`/`key` present a client certificate,
64
+ * `ca` supplies trusted CA certificate(s), and `rejectUnauthorized` controls whether an
65
+ * unverifiable server certificate is rejected.
66
+ */
67
+ connect(host: string, port?: number, unitId?: number, secondaryHost?: string, useTls?: boolean, tls?: {
68
+ cert?: string | Buffer;
69
+ key?: string | Buffer;
70
+ ca?: string | Buffer | Array<string | Buffer>;
71
+ rejectUnauthorized?: boolean;
72
+ }): Promise<void>;
64
73
  /**
65
74
  * Disconnect from all units of this network device.
66
75
  *
@@ -121,8 +121,12 @@ export class SunspecModbusClient {
121
121
  * @param unitId Modbus unit ID (default 1)
122
122
  * @param secondaryHost Optional secondary host (ipAddress) for fallback during reconnection
123
123
  * @param useTls Whether to use TLS/SSL for the Modbus connection (Modbus Security, typically port 802). Defaults to false.
124
+ * @param tls Optional TLS certificate material for mutual-TLS / custom-CA connections. Only
125
+ * honoured when {@link useTls} is true. `cert`/`key` present a client certificate,
126
+ * `ca` supplies trusted CA certificate(s), and `rejectUnauthorized` controls whether an
127
+ * unverifiable server certificate is rejected.
124
128
  */
125
- async connect(host, port = 502, unitId = 1, secondaryHost, useTls) {
129
+ async connect(host, port = 502, unitId = 1, secondaryHost, useTls, tls) {
126
130
  return this.withConnectionLock(async () => {
127
131
  if (this.connectionParams) {
128
132
  if (this.connectionParams.primaryHost !== host || this.connectionParams.port !== port) {
@@ -135,9 +139,30 @@ export class SunspecModbusClient {
135
139
  if (useTls !== undefined) {
136
140
  this.connectionParams.useTls = useTls;
137
141
  }
142
+ if (tls?.cert !== undefined) {
143
+ this.connectionParams.cert = tls.cert;
144
+ }
145
+ if (tls?.key !== undefined) {
146
+ this.connectionParams.key = tls.key;
147
+ }
148
+ if (tls?.ca !== undefined) {
149
+ this.connectionParams.ca = tls.ca;
150
+ }
151
+ if (tls?.rejectUnauthorized !== undefined) {
152
+ this.connectionParams.rejectUnauthorized = tls.rejectUnauthorized;
153
+ }
138
154
  }
139
155
  else {
140
- this.connectionParams = { primaryHost: host, secondaryHost, port, useTls };
156
+ this.connectionParams = {
157
+ primaryHost: host,
158
+ secondaryHost,
159
+ port,
160
+ useTls,
161
+ cert: tls?.cert,
162
+ key: tls?.key,
163
+ ca: tls?.ca,
164
+ rejectUnauthorized: tls?.rejectUnauthorized,
165
+ };
141
166
  }
142
167
  this.knownUnits.add(unitId);
143
168
  if (this.modbusInstances.has(unitId)) {
@@ -284,7 +309,11 @@ export class SunspecModbusClient {
284
309
  port,
285
310
  unitId,
286
311
  timeout: 5000,
287
- useTls: this.connectionParams?.useTls
312
+ useTls: this.connectionParams?.useTls,
313
+ cert: this.connectionParams?.cert,
314
+ key: this.connectionParams?.key,
315
+ ca: this.connectionParams?.ca,
316
+ rejectUnauthorized: this.connectionParams?.rejectUnauthorized
288
317
  });
289
318
  if (!candidate) {
290
319
  throw new Error(`useModbus().connect returned null for ${host}:${port} unit ${unitId}`);
package/dist/version.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Current version of the enyo Energy App SDK.
7
7
  */
8
- export declare const SDK_VERSION = "0.0.92";
8
+ export declare const SDK_VERSION = "0.0.93";
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
package/dist/version.js CHANGED
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Current version of the enyo Energy App SDK.
7
7
  */
8
- export const SDK_VERSION = '0.0.92';
8
+ export const SDK_VERSION = '0.0.93';
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enyo-energy/sunspec-sdk",
3
- "version": "0.0.92",
3
+ "version": "0.0.93",
4
4
  "description": "enyo Energy Sunspec SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@enyo-energy/appliance-calibration": "0.0.2",
44
- "@enyo-energy/energy-app-sdk": "^0.0.168"
44
+ "@enyo-energy/energy-app-sdk": "^0.0.170"
45
45
  },
46
46
  "volta": {
47
47
  "node": "22.17.0"