galileo-generated 0.2.7 → 0.2.8
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/.release-please-manifest.json +1 -1
- package/dist/commonjs/hooks/cert-management.d.ts +73 -0
- package/dist/commonjs/hooks/cert-management.d.ts.map +1 -0
- package/dist/commonjs/hooks/cert-management.js +258 -0
- package/dist/commonjs/hooks/cert-management.js.map +1 -0
- package/dist/commonjs/hooks/registration.d.ts.map +1 -1
- package/dist/commonjs/hooks/registration.js +4 -0
- package/dist/commonjs/hooks/registration.js.map +1 -1
- package/dist/commonjs/lib/galileo-config.d.ts +101 -12
- package/dist/commonjs/lib/galileo-config.d.ts.map +1 -1
- package/dist/commonjs/lib/galileo-config.js +153 -12
- package/dist/commonjs/lib/galileo-config.js.map +1 -1
- package/dist/commonjs/tests/hooks/cert-management.test.d.ts +2 -0
- package/dist/commonjs/tests/hooks/cert-management.test.d.ts.map +1 -0
- package/dist/commonjs/tests/hooks/cert-management.test.js +794 -0
- package/dist/commonjs/tests/hooks/cert-management.test.js.map +1 -0
- package/dist/commonjs/tests/lib/galileo-config.test.js +101 -0
- package/dist/commonjs/tests/lib/galileo-config.test.js.map +1 -1
- package/dist/esm/hooks/cert-management.d.ts +73 -0
- package/dist/esm/hooks/cert-management.d.ts.map +1 -0
- package/dist/esm/hooks/cert-management.js +254 -0
- package/dist/esm/hooks/cert-management.js.map +1 -0
- package/dist/esm/hooks/registration.d.ts.map +1 -1
- package/dist/esm/hooks/registration.js +4 -0
- package/dist/esm/hooks/registration.js.map +1 -1
- package/dist/esm/lib/galileo-config.d.ts +101 -12
- package/dist/esm/lib/galileo-config.d.ts.map +1 -1
- package/dist/esm/lib/galileo-config.js +153 -12
- package/dist/esm/lib/galileo-config.js.map +1 -1
- package/dist/esm/tests/hooks/cert-management.test.d.ts +2 -0
- package/dist/esm/tests/hooks/cert-management.test.d.ts.map +1 -0
- package/dist/esm/tests/hooks/cert-management.test.js +792 -0
- package/dist/esm/tests/hooks/cert-management.test.js.map +1 -0
- package/dist/esm/tests/lib/galileo-config.test.js +101 -0
- package/dist/esm/tests/lib/galileo-config.test.js.map +1 -1
- package/package.json +5 -3
- package/src/hooks/cert-management.ts +288 -0
- package/src/hooks/registration.ts +5 -0
- package/src/lib/galileo-config.ts +214 -15
- package/src/tests/hooks/cert-management.test.ts +958 -0
- package/src/tests/lib/galileo-config.test.ts +110 -0
|
@@ -13,6 +13,11 @@ const ENV_KEYS = [
|
|
|
13
13
|
'GALILEO_PROJECT_NAME',
|
|
14
14
|
'GALILEO_LOG_STREAM',
|
|
15
15
|
'GALILEO_LOG_STREAM_NAME',
|
|
16
|
+
'GALILEO_CA_CERT_PATH',
|
|
17
|
+
'GALILEO_CA_CERT_CONTENT',
|
|
18
|
+
'GALILEO_CLIENT_CERT_PATH',
|
|
19
|
+
'GALILEO_CLIENT_KEY_PATH',
|
|
20
|
+
'GALILEO_REJECT_UNAUTHORIZED',
|
|
16
21
|
] as const;
|
|
17
22
|
|
|
18
23
|
function clearGalileoEnv(): void {
|
|
@@ -233,4 +238,109 @@ describe('GalileoConfig', () => {
|
|
|
233
238
|
expect(() => config.logConfig()).not.toThrow();
|
|
234
239
|
spy.mockRestore();
|
|
235
240
|
});
|
|
241
|
+
|
|
242
|
+
test('test getCertConfig returns cert fields from overrides', () => {
|
|
243
|
+
GalileoConfig.reset();
|
|
244
|
+
const config = GalileoConfig.get({
|
|
245
|
+
apiKey: 'key',
|
|
246
|
+
apiUrl: 'https://api.example.com',
|
|
247
|
+
caCertPath: '/path/to/ca.pem',
|
|
248
|
+
caCertContent: '-----BEGIN CERTIFICATE-----',
|
|
249
|
+
clientCertPath: '/path/to/client.pem',
|
|
250
|
+
clientKeyPath: '/path/to/key.pem',
|
|
251
|
+
rejectUnauthorized: false,
|
|
252
|
+
});
|
|
253
|
+
const cert = config.getCertConfig();
|
|
254
|
+
expect(cert).not.toBeNull();
|
|
255
|
+
if (!cert) throw new Error("unreachable");
|
|
256
|
+
expect(cert.caCertPath).toBe('/path/to/ca.pem');
|
|
257
|
+
expect(cert.caCertContent).toBe('-----BEGIN CERTIFICATE-----');
|
|
258
|
+
expect(cert.clientCertPath).toBe('/path/to/client.pem');
|
|
259
|
+
expect(cert.clientKeyPath).toBe('/path/to/key.pem');
|
|
260
|
+
expect(cert.rejectUnauthorized).toBe(false);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test('test getCertConfig empty when no cert set', () => {
|
|
264
|
+
GalileoConfig.reset();
|
|
265
|
+
const config = GalileoConfig.get({
|
|
266
|
+
apiKey: 'key',
|
|
267
|
+
apiUrl: 'https://api.example.com',
|
|
268
|
+
});
|
|
269
|
+
const cert = config.getCertConfig();
|
|
270
|
+
expect(cert).toBeNull();
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
test('test snapshot includes cert when set', () => {
|
|
274
|
+
GalileoConfig.reset();
|
|
275
|
+
const config = GalileoConfig.get({
|
|
276
|
+
apiKey: 'key',
|
|
277
|
+
apiUrl: 'https://api.example.com',
|
|
278
|
+
caCertPath: '/ca.pem',
|
|
279
|
+
rejectUnauthorized: true,
|
|
280
|
+
});
|
|
281
|
+
expect(config.snapshot.cert).toEqual({
|
|
282
|
+
caCertPath: '/ca.pem',
|
|
283
|
+
rejectUnauthorized: true,
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
test('test cert from env', () => {
|
|
288
|
+
GalileoConfig.reset();
|
|
289
|
+
process.env['GALILEO_API_KEY'] = 'env-key';
|
|
290
|
+
process.env['GALILEO_CA_CERT_PATH'] = '/env/ca.pem';
|
|
291
|
+
process.env['GALILEO_REJECT_UNAUTHORIZED'] = 'false';
|
|
292
|
+
const config = GalileoConfig.get({});
|
|
293
|
+
const cert = config.getCertConfig();
|
|
294
|
+
expect(cert).not.toBeNull();
|
|
295
|
+
if (!cert) throw new Error("unreachable");
|
|
296
|
+
expect(cert.caCertPath).toBe('/env/ca.pem');
|
|
297
|
+
expect(cert.rejectUnauthorized).toBe(false);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
test('test empty GALILEO_REJECT_UNAUTHORIZED treated as undefined', () => {
|
|
301
|
+
GalileoConfig.reset();
|
|
302
|
+
process.env['GALILEO_API_KEY'] = 'env-key';
|
|
303
|
+
process.env['GALILEO_REJECT_UNAUTHORIZED'] = '';
|
|
304
|
+
const config = GalileoConfig.get({});
|
|
305
|
+
const cert = config.getCertConfig();
|
|
306
|
+
expect(cert).toBeNull();
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
test('test empty NODE_TLS_REJECT_UNAUTHORIZED treated as undefined', () => {
|
|
310
|
+
GalileoConfig.reset();
|
|
311
|
+
process.env['GALILEO_API_KEY'] = 'env-key';
|
|
312
|
+
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '';
|
|
313
|
+
const config = GalileoConfig.get({});
|
|
314
|
+
const cert = config.getCertConfig();
|
|
315
|
+
expect(cert).toBeNull();
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
test('test explicit rejectUnauthorized values', () => {
|
|
319
|
+
GalileoConfig.reset();
|
|
320
|
+
process.env['GALILEO_API_KEY'] = 'env-key';
|
|
321
|
+
|
|
322
|
+
// Test "true" string
|
|
323
|
+
process.env['GALILEO_REJECT_UNAUTHORIZED'] = 'true';
|
|
324
|
+
let config = GalileoConfig.get({});
|
|
325
|
+
let cert = config.getCertConfig();
|
|
326
|
+
expect(cert?.rejectUnauthorized).toBe(true);
|
|
327
|
+
|
|
328
|
+
GalileoConfig.reset();
|
|
329
|
+
process.env['GALILEO_REJECT_UNAUTHORIZED'] = '1';
|
|
330
|
+
config = GalileoConfig.get({});
|
|
331
|
+
cert = config.getCertConfig();
|
|
332
|
+
expect(cert?.rejectUnauthorized).toBe(true);
|
|
333
|
+
|
|
334
|
+
GalileoConfig.reset();
|
|
335
|
+
process.env['GALILEO_REJECT_UNAUTHORIZED'] = 'false';
|
|
336
|
+
config = GalileoConfig.get({});
|
|
337
|
+
cert = config.getCertConfig();
|
|
338
|
+
expect(cert?.rejectUnauthorized).toBe(false);
|
|
339
|
+
|
|
340
|
+
GalileoConfig.reset();
|
|
341
|
+
process.env['GALILEO_REJECT_UNAUTHORIZED'] = '0';
|
|
342
|
+
config = GalileoConfig.get({});
|
|
343
|
+
cert = config.getCertConfig();
|
|
344
|
+
expect(cert?.rejectUnauthorized).toBe(false);
|
|
345
|
+
});
|
|
236
346
|
});
|