@thzero/library_server_service_grpc 0.19.8 → 0.19.9

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/README.md CHANGED
@@ -86,7 +86,7 @@ A missing `grpc` block or `grpc.port` fails at boot.
86
86
  * **`host`**: the address to bind. Defaults to `0.0.0.0`.
87
87
  * **`auth.apiKey`**: the key callers must send. A list is accepted, so a key can be rotated without downtime. Set `auth.required` to `false` to allow unauthenticated calls.
88
88
  * **`tls`**: `key` and `cert` are required. Each of `key`, `cert` and `ca` is a file path or a PEM string. With `ca` set, `clientCertificateRequired` turns on mutual TLS.
89
- * **`insecure`**: without `tls`, the server refuses to start unless `insecure` is `true`. Use it only on a trusted network or behind a proxy that terminates TLS.
89
+ * **`secure`**: without `tls`, the server refuses to start unless `secure` is `false`. Use that only on a trusted network or behind a proxy that terminates TLS. Setting both `tls` and `secure: false` fails at startup. The same value is advertised to service discovery, so discovered clients dial the way the server listens.
90
90
 
91
91
  ### Client
92
92
 
package/SECURITY.md CHANGED
@@ -24,6 +24,6 @@ You should get an acknowledgment within 7 days. Once a fix is released the advis
24
24
  ## Deployment notes
25
25
 
26
26
  - Configure `grpc.auth.apiKey` on the server. With no key, every call is rejected. Setting `grpc.auth.required` to `false` disables the check; do that only on a trusted private network.
27
- - Configure `grpc.tls` on the server. Without it the server refuses to start unless `grpc.insecure` is `true`, which belongs only behind a proxy that terminates TLS.
27
+ - Configure `grpc.tls` on the server. Without it the server refuses to start unless `grpc.secure` is `false`, which belongs only behind a proxy that terminates TLS.
28
28
  - Clients use TLS unless a backend sets `secure: false`.
29
29
  - Treat `apiKey` values as secrets: keep them in environment variables or a secret store.
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@thzero/library_server_service_grpc",
3
3
  "type": "module",
4
- "version": "0.19.8",
4
+ "version": "0.19.9",
5
5
  "version_major": 0,
6
6
  "version_minor": 19,
7
- "version_patch": 8,
7
+ "version_patch": 9,
8
8
  "version_date": "11/30/2026",
9
9
  "description": "",
10
10
  "author": "thZero",
package/server.js CHANGED
@@ -142,6 +142,10 @@ class BaseServerGrpcService extends Service {
142
142
 
143
143
  _serverCredentials(correlationId) {
144
144
  const tls = this._configGrpc.tls;
145
+ const secure = this._configGrpc.secure !== false;
146
+ if (tls && !secure)
147
+ throw Error('config.grpc.tls is set but config.grpc.secure is false; remove one.');
148
+
145
149
  if (tls) {
146
150
  this._enforceNotEmpty('BaseServerGrpcService', '_serverCredentials', tls.key, 'config.grpc.tls.key', correlationId);
147
151
  this._enforceNotEmpty('BaseServerGrpcService', '_serverCredentials', tls.cert, 'config.grpc.tls.cert', correlationId);
@@ -150,10 +154,10 @@ class BaseServerGrpcService extends Service {
150
154
  return grpc.ServerCredentials.createSsl(ca, [ { private_key: pem(tls.key), cert_chain: pem(tls.cert) } ], ca ? (tls.clientCertificateRequired === true) : false);
151
155
  }
152
156
 
153
- if (this._configGrpc.insecure === true)
157
+ if (!secure)
154
158
  return grpc.ServerCredentials.createInsecure();
155
159
 
156
- throw Error('config.grpc.tls is required; set config.grpc.insecure to true to run without TLS.');
160
+ throw Error('config.grpc.tls is required; set config.grpc.secure to false to run without TLS.');
157
161
  }
158
162
  }
159
163
 
@@ -125,13 +125,20 @@ describe('_start', () => {
125
125
  });
126
126
 
127
127
  describe('_serverCredentials', () => {
128
- it('refuses to run without TLS unless insecure is explicit', () => {
128
+ it('refuses to run without TLS unless secure is false', () => {
129
129
  service._configGrpc = { port: 1 };
130
130
  assert.throws(() => service._serverCredentials('cid'), /config.grpc.tls is required/);
131
- service._configGrpc = { port: 1, insecure: true };
131
+ service._configGrpc = { port: 1, secure: true };
132
+ assert.throws(() => service._serverCredentials('cid'), /config.grpc.tls is required/);
133
+ service._configGrpc = { port: 1, secure: false };
132
134
  assert.equal(service._serverCredentials('cid')._isSecure(), false);
133
135
  });
134
136
 
137
+ it('rejects tls combined with secure false', () => {
138
+ service._configGrpc = { port: 1, secure: false, tls: { key: 'x', cert: 'x' } };
139
+ assert.throws(() => service._serverCredentials('cid'), /config.grpc.secure is false/);
140
+ });
141
+
135
142
  it('requires a key and cert when tls is configured', () => {
136
143
  service._configGrpc = { port: 1, tls: { cert: 'x' } };
137
144
  assert.throws(() => service._serverCredentials('cid'), /config.grpc.tls.key is empty/);