agntcy-dir 0.5.0-rc.2 → 0.5.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/agntcy-dir.d.ts +26 -3
- package/dist/index.cjs +51 -8
- package/dist/index.mjs +52 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/agntcy-dir.d.ts
CHANGED
|
@@ -86,6 +86,7 @@ export declare class Client {
|
|
|
86
86
|
static createGRPCTransport(config: Config): Promise<Transport>;
|
|
87
87
|
private static createX509Transport;
|
|
88
88
|
private static createJWTTransport;
|
|
89
|
+
private static createTLSTransport;
|
|
89
90
|
/**
|
|
90
91
|
* Request generator helper function for streaming requests.
|
|
91
92
|
*/
|
|
@@ -476,21 +477,27 @@ export declare class Config {
|
|
|
476
477
|
static DEFAULT_SPIFFE_ENDPOINT_SOCKET: string;
|
|
477
478
|
static DEFAULT_AUTH_MODE: string;
|
|
478
479
|
static DEFAULT_JWT_AUDIENCE: string;
|
|
480
|
+
static DEFAULT_TLS_CA_FILE: string;
|
|
481
|
+
static DEFAULT_TLS_CERT_FILE: string;
|
|
482
|
+
static DEFAULT_TLS_KEY_FILE: string;
|
|
479
483
|
serverAddress: string;
|
|
480
484
|
dirctlPath: string;
|
|
481
485
|
spiffeEndpointSocket: string;
|
|
482
|
-
authMode: '
|
|
486
|
+
authMode: '' | 'x509' | 'jwt' | 'tls';
|
|
483
487
|
jwtAudience: string;
|
|
488
|
+
tlsCaFile: string;
|
|
489
|
+
tlsCertFile: string;
|
|
490
|
+
tlsKeyFile: string;
|
|
484
491
|
/**
|
|
485
492
|
* Creates a new Config instance.
|
|
486
493
|
*
|
|
487
494
|
* @param serverAddress - The server address to connect to. Defaults to '127.0.0.1:8888'
|
|
488
495
|
* @param dirctlPath - Path to the dirctl executable. Defaults to 'dirctl'
|
|
489
496
|
* @param spiffeEndpointSocket - Path to the spire server socket. Defaults to empty string.
|
|
490
|
-
* @param authMode - Authentication mode: 'insecure
|
|
497
|
+
* @param authMode - Authentication mode: '' for insecure, 'x509', 'jwt' or 'tls'. Defaults to ''
|
|
491
498
|
* @param jwtAudience - JWT audience for JWT authentication. Required when authMode is 'jwt'
|
|
492
499
|
*/
|
|
493
|
-
constructor(serverAddress?: string, dirctlPath?: string, spiffeEndpointSocket?: string, authMode?: '
|
|
500
|
+
constructor(serverAddress?: string, dirctlPath?: string, spiffeEndpointSocket?: string, authMode?: '' | 'x509' | 'jwt' | 'tls', jwtAudience?: string, tlsCaFile?: string, tlsCertFile?: string, tlsKeyFile?: string);
|
|
494
501
|
/**
|
|
495
502
|
* Load configuration from environment variables.
|
|
496
503
|
*
|
|
@@ -1575,6 +1582,22 @@ declare enum RecordQueryType {
|
|
|
1575
1582
|
* @generated from enum value: RECORD_QUERY_TYPE_MODULE = 6;
|
|
1576
1583
|
*/
|
|
1577
1584
|
MODULE = 6,
|
|
1585
|
+
|
|
1586
|
+
/**
|
|
1587
|
+
* Query for a domain ID.
|
|
1588
|
+
* Numeric field - exact match only, no wildcard support.
|
|
1589
|
+
*
|
|
1590
|
+
* @generated from enum value: RECORD_QUERY_TYPE_DOMAIN_ID = 7;
|
|
1591
|
+
*/
|
|
1592
|
+
DOMAIN_ID = 7,
|
|
1593
|
+
|
|
1594
|
+
/**
|
|
1595
|
+
* Query for a domain name.
|
|
1596
|
+
* Supports wildcard patterns: "*education*", "healthcare/*", "*technology"
|
|
1597
|
+
*
|
|
1598
|
+
* @generated from enum value: RECORD_QUERY_TYPE_DOMAIN_NAME = 8;
|
|
1599
|
+
*/
|
|
1600
|
+
DOMAIN_NAME = 8,
|
|
1578
1601
|
}
|
|
1579
1602
|
|
|
1580
1603
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -9662,7 +9662,7 @@ const RecordQueryType$1 = /*@__PURE__*/
|
|
|
9662
9662
|
* Describes the file agntcy/dir/search/v1/record_query.proto.
|
|
9663
9663
|
*/
|
|
9664
9664
|
const file_agntcy_dir_search_v1_record_query = /*@__PURE__*/
|
|
9665
|
-
fileDesc("
|
|
9665
|
+
fileDesc("CidhZ250Y3kvZGlyL3NlYXJjaC92MS9yZWNvcmRfcXVlcnkucHJvdG8SFGFnbnRjeS5kaXIuc2VhcmNoLnYxIlEKC1JlY29yZFF1ZXJ5EjMKBHR5cGUYASABKA4yJS5hZ250Y3kuZGlyLnNlYXJjaC52MS5SZWNvcmRRdWVyeVR5cGUSDQoFdmFsdWUYAiABKAkqsgIKD1JlY29yZFF1ZXJ5VHlwZRIhCh1SRUNPUkRfUVVFUllfVFlQRV9VTlNQRUNJRklFRBAAEhoKFlJFQ09SRF9RVUVSWV9UWVBFX05BTUUQARIdChlSRUNPUkRfUVVFUllfVFlQRV9WRVJTSU9OEAISHgoaUkVDT1JEX1FVRVJZX1RZUEVfU0tJTExfSUQQAxIgChxSRUNPUkRfUVVFUllfVFlQRV9TS0lMTF9OQU1FEAQSHQoZUkVDT1JEX1FVRVJZX1RZUEVfTE9DQVRPUhAFEhwKGFJFQ09SRF9RVUVSWV9UWVBFX01PRFVMRRAGEh8KG1JFQ09SRF9RVUVSWV9UWVBFX0RPTUFJTl9JRBAHEiEKHVJFQ09SRF9RVUVSWV9UWVBFX0RPTUFJTl9OQU1FEAhCxAEKGGNvbS5hZ250Y3kuZGlyLnNlYXJjaC52MUIQUmVjb3JkUXVlcnlQcm90b1ABWiNnaXRodWIuY29tL2FnbnRjeS9kaXIvYXBpL3NlYXJjaC92MaICA0FEU6oCFEFnbnRjeS5EaXIuU2VhcmNoLlYxygIUQWdudGN5XERpclxTZWFyY2hcVjHiAiBBZ250Y3lcRGlyXFNlYXJjaFxWMVxHUEJNZXRhZGF0YeoCF0FnbnRjeTo6RGlyOjpTZWFyY2g6OlYxYgZwcm90bzM");
|
|
9666
9666
|
|
|
9667
9667
|
/**
|
|
9668
9668
|
* Describes the message agntcy.dir.search.v1.RecordQuery.
|
|
@@ -10274,16 +10274,16 @@ class Config {
|
|
|
10274
10274
|
* @param serverAddress - The server address to connect to. Defaults to '127.0.0.1:8888'
|
|
10275
10275
|
* @param dirctlPath - Path to the dirctl executable. Defaults to 'dirctl'
|
|
10276
10276
|
* @param spiffeEndpointSocket - Path to the spire server socket. Defaults to empty string.
|
|
10277
|
-
* @param authMode - Authentication mode: 'insecure
|
|
10277
|
+
* @param authMode - Authentication mode: '' for insecure, 'x509', 'jwt' or 'tls'. Defaults to ''
|
|
10278
10278
|
* @param jwtAudience - JWT audience for JWT authentication. Required when authMode is 'jwt'
|
|
10279
10279
|
*/
|
|
10280
|
-
constructor(serverAddress = Config.DEFAULT_SERVER_ADDRESS, dirctlPath = Config.DEFAULT_DIRCTL_PATH, spiffeEndpointSocket = Config.DEFAULT_SPIFFE_ENDPOINT_SOCKET, authMode = Config.DEFAULT_AUTH_MODE, jwtAudience = Config.DEFAULT_JWT_AUDIENCE) {
|
|
10280
|
+
constructor(serverAddress = Config.DEFAULT_SERVER_ADDRESS, dirctlPath = Config.DEFAULT_DIRCTL_PATH, spiffeEndpointSocket = Config.DEFAULT_SPIFFE_ENDPOINT_SOCKET, authMode = Config.DEFAULT_AUTH_MODE, jwtAudience = Config.DEFAULT_JWT_AUDIENCE, tlsCaFile = Config.DEFAULT_TLS_CA_FILE, tlsCertFile = Config.DEFAULT_TLS_CERT_FILE, tlsKeyFile = Config.DEFAULT_TLS_KEY_FILE) {
|
|
10281
10281
|
// add protocol prefix if not set
|
|
10282
10282
|
// use unsafe http unless spire/auth is used
|
|
10283
10283
|
if (!serverAddress.startsWith('http://') &&
|
|
10284
10284
|
!serverAddress.startsWith('https://')) {
|
|
10285
|
-
// use https protocol when X.509 or
|
|
10286
|
-
if (authMode === 'x509' || authMode === 'jwt') {
|
|
10285
|
+
// use https protocol when X.509, JWT, or TLS auth is used
|
|
10286
|
+
if (authMode === 'x509' || authMode === 'jwt' || authMode === 'tls') {
|
|
10287
10287
|
serverAddress = `https://${serverAddress}`;
|
|
10288
10288
|
}
|
|
10289
10289
|
else {
|
|
@@ -10295,6 +10295,9 @@ class Config {
|
|
|
10295
10295
|
this.spiffeEndpointSocket = spiffeEndpointSocket;
|
|
10296
10296
|
this.authMode = authMode;
|
|
10297
10297
|
this.jwtAudience = jwtAudience;
|
|
10298
|
+
this.tlsCaFile = tlsCaFile;
|
|
10299
|
+
this.tlsCertFile = tlsCertFile;
|
|
10300
|
+
this.tlsKeyFile = tlsKeyFile;
|
|
10298
10301
|
}
|
|
10299
10302
|
/**
|
|
10300
10303
|
* Load configuration from environment variables.
|
|
@@ -10319,14 +10322,20 @@ class Config {
|
|
|
10319
10322
|
const spiffeEndpointSocketPath = node_process.env[`${prefix}SPIFFE_SOCKET_PATH`] || Config.DEFAULT_SPIFFE_ENDPOINT_SOCKET;
|
|
10320
10323
|
const authMode = (node_process.env[`${prefix}AUTH_MODE`] || Config.DEFAULT_AUTH_MODE);
|
|
10321
10324
|
const jwtAudience = node_process.env[`${prefix}JWT_AUDIENCE`] || Config.DEFAULT_JWT_AUDIENCE;
|
|
10322
|
-
|
|
10325
|
+
const tlsCaFile = node_process.env[`${prefix}TLS_CA_FILE`] || Config.DEFAULT_TLS_CA_FILE;
|
|
10326
|
+
const tlsCertFile = node_process.env[`${prefix}TLS_CERT_FILE`] || Config.DEFAULT_TLS_CERT_FILE;
|
|
10327
|
+
const tlsKeyFile = node_process.env[`${prefix}TLS_KEY_FILE`] || Config.DEFAULT_TLS_KEY_FILE;
|
|
10328
|
+
return new Config(serverAddress, dirctlPath, spiffeEndpointSocketPath, authMode, jwtAudience, tlsCaFile, tlsCertFile, tlsKeyFile);
|
|
10323
10329
|
}
|
|
10324
10330
|
}
|
|
10325
10331
|
Config.DEFAULT_SERVER_ADDRESS = '127.0.0.1:8888';
|
|
10326
10332
|
Config.DEFAULT_DIRCTL_PATH = 'dirctl';
|
|
10327
10333
|
Config.DEFAULT_SPIFFE_ENDPOINT_SOCKET = '';
|
|
10328
|
-
Config.DEFAULT_AUTH_MODE = '
|
|
10334
|
+
Config.DEFAULT_AUTH_MODE = '';
|
|
10329
10335
|
Config.DEFAULT_JWT_AUDIENCE = '';
|
|
10336
|
+
Config.DEFAULT_TLS_CA_FILE = '';
|
|
10337
|
+
Config.DEFAULT_TLS_CERT_FILE = '';
|
|
10338
|
+
Config.DEFAULT_TLS_KEY_FILE = '';
|
|
10330
10339
|
/**
|
|
10331
10340
|
* High-level client for interacting with AGNTCY Directory services.
|
|
10332
10341
|
*
|
|
@@ -10388,7 +10397,7 @@ class Client {
|
|
|
10388
10397
|
static async createGRPCTransport(config) {
|
|
10389
10398
|
// Handle different authentication modes
|
|
10390
10399
|
switch (config.authMode) {
|
|
10391
|
-
case '
|
|
10400
|
+
case '':
|
|
10392
10401
|
return createGrpcTransport({
|
|
10393
10402
|
baseUrl: config.serverAddress,
|
|
10394
10403
|
});
|
|
@@ -10396,6 +10405,8 @@ class Client {
|
|
|
10396
10405
|
return await this.createJWTTransport(config);
|
|
10397
10406
|
case 'x509':
|
|
10398
10407
|
return await this.createX509Transport(config);
|
|
10408
|
+
case 'tls':
|
|
10409
|
+
return await this.createTLSTransport(config);
|
|
10399
10410
|
default:
|
|
10400
10411
|
throw new Error(`Unsupported auth mode: ${config.authMode}`);
|
|
10401
10412
|
}
|
|
@@ -10487,6 +10498,38 @@ class Client {
|
|
|
10487
10498
|
});
|
|
10488
10499
|
return transport;
|
|
10489
10500
|
}
|
|
10501
|
+
static async createTLSTransport(config) {
|
|
10502
|
+
if (config.tlsCaFile === '') {
|
|
10503
|
+
throw new Error('TLS CA file is required for TLS authentication');
|
|
10504
|
+
}
|
|
10505
|
+
if (config.tlsCertFile === '') {
|
|
10506
|
+
throw new Error('TLS certificate file is required for TLS authentication');
|
|
10507
|
+
}
|
|
10508
|
+
if (config.tlsKeyFile === '') {
|
|
10509
|
+
throw new Error('TLS key file is required for TLS authentication');
|
|
10510
|
+
}
|
|
10511
|
+
let root_ca;
|
|
10512
|
+
let cert_chain;
|
|
10513
|
+
let private_key;
|
|
10514
|
+
try {
|
|
10515
|
+
root_ca = node_fs.readFileSync(config.tlsCaFile).toString();
|
|
10516
|
+
cert_chain = node_fs.readFileSync(config.tlsCertFile).toString();
|
|
10517
|
+
private_key = node_fs.readFileSync(config.tlsKeyFile).toString();
|
|
10518
|
+
}
|
|
10519
|
+
catch (e) {
|
|
10520
|
+
console.error('Error reading file:', e.message);
|
|
10521
|
+
throw e;
|
|
10522
|
+
}
|
|
10523
|
+
const transport = createGrpcTransport({
|
|
10524
|
+
baseUrl: config.serverAddress,
|
|
10525
|
+
nodeOptions: {
|
|
10526
|
+
ca: root_ca,
|
|
10527
|
+
cert: cert_chain,
|
|
10528
|
+
key: private_key,
|
|
10529
|
+
},
|
|
10530
|
+
});
|
|
10531
|
+
return transport;
|
|
10532
|
+
}
|
|
10490
10533
|
/**
|
|
10491
10534
|
* Request generator helper function for streaming requests.
|
|
10492
10535
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { tmpdir } from 'node:os';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { env } from 'node:process';
|
|
4
|
-
import { writeFileSync } from 'node:fs';
|
|
4
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
5
5
|
import { spawnSync } from 'node:child_process';
|
|
6
6
|
import { createClient as createClient$1 } from 'spiffe';
|
|
7
7
|
import * as zlib from 'node:zlib';
|
|
@@ -9638,7 +9638,7 @@ const RecordQueryType$1 = /*@__PURE__*/
|
|
|
9638
9638
|
* Describes the file agntcy/dir/search/v1/record_query.proto.
|
|
9639
9639
|
*/
|
|
9640
9640
|
const file_agntcy_dir_search_v1_record_query = /*@__PURE__*/
|
|
9641
|
-
fileDesc("
|
|
9641
|
+
fileDesc("CidhZ250Y3kvZGlyL3NlYXJjaC92MS9yZWNvcmRfcXVlcnkucHJvdG8SFGFnbnRjeS5kaXIuc2VhcmNoLnYxIlEKC1JlY29yZFF1ZXJ5EjMKBHR5cGUYASABKA4yJS5hZ250Y3kuZGlyLnNlYXJjaC52MS5SZWNvcmRRdWVyeVR5cGUSDQoFdmFsdWUYAiABKAkqsgIKD1JlY29yZFF1ZXJ5VHlwZRIhCh1SRUNPUkRfUVVFUllfVFlQRV9VTlNQRUNJRklFRBAAEhoKFlJFQ09SRF9RVUVSWV9UWVBFX05BTUUQARIdChlSRUNPUkRfUVVFUllfVFlQRV9WRVJTSU9OEAISHgoaUkVDT1JEX1FVRVJZX1RZUEVfU0tJTExfSUQQAxIgChxSRUNPUkRfUVVFUllfVFlQRV9TS0lMTF9OQU1FEAQSHQoZUkVDT1JEX1FVRVJZX1RZUEVfTE9DQVRPUhAFEhwKGFJFQ09SRF9RVUVSWV9UWVBFX01PRFVMRRAGEh8KG1JFQ09SRF9RVUVSWV9UWVBFX0RPTUFJTl9JRBAHEiEKHVJFQ09SRF9RVUVSWV9UWVBFX0RPTUFJTl9OQU1FEAhCxAEKGGNvbS5hZ250Y3kuZGlyLnNlYXJjaC52MUIQUmVjb3JkUXVlcnlQcm90b1ABWiNnaXRodWIuY29tL2FnbnRjeS9kaXIvYXBpL3NlYXJjaC92MaICA0FEU6oCFEFnbnRjeS5EaXIuU2VhcmNoLlYxygIUQWdudGN5XERpclxTZWFyY2hcVjHiAiBBZ250Y3lcRGlyXFNlYXJjaFxWMVxHUEJNZXRhZGF0YeoCF0FnbnRjeTo6RGlyOjpTZWFyY2g6OlYxYgZwcm90bzM");
|
|
9642
9642
|
|
|
9643
9643
|
/**
|
|
9644
9644
|
* Describes the message agntcy.dir.search.v1.RecordQuery.
|
|
@@ -10250,16 +10250,16 @@ class Config {
|
|
|
10250
10250
|
* @param serverAddress - The server address to connect to. Defaults to '127.0.0.1:8888'
|
|
10251
10251
|
* @param dirctlPath - Path to the dirctl executable. Defaults to 'dirctl'
|
|
10252
10252
|
* @param spiffeEndpointSocket - Path to the spire server socket. Defaults to empty string.
|
|
10253
|
-
* @param authMode - Authentication mode: 'insecure
|
|
10253
|
+
* @param authMode - Authentication mode: '' for insecure, 'x509', 'jwt' or 'tls'. Defaults to ''
|
|
10254
10254
|
* @param jwtAudience - JWT audience for JWT authentication. Required when authMode is 'jwt'
|
|
10255
10255
|
*/
|
|
10256
|
-
constructor(serverAddress = Config.DEFAULT_SERVER_ADDRESS, dirctlPath = Config.DEFAULT_DIRCTL_PATH, spiffeEndpointSocket = Config.DEFAULT_SPIFFE_ENDPOINT_SOCKET, authMode = Config.DEFAULT_AUTH_MODE, jwtAudience = Config.DEFAULT_JWT_AUDIENCE) {
|
|
10256
|
+
constructor(serverAddress = Config.DEFAULT_SERVER_ADDRESS, dirctlPath = Config.DEFAULT_DIRCTL_PATH, spiffeEndpointSocket = Config.DEFAULT_SPIFFE_ENDPOINT_SOCKET, authMode = Config.DEFAULT_AUTH_MODE, jwtAudience = Config.DEFAULT_JWT_AUDIENCE, tlsCaFile = Config.DEFAULT_TLS_CA_FILE, tlsCertFile = Config.DEFAULT_TLS_CERT_FILE, tlsKeyFile = Config.DEFAULT_TLS_KEY_FILE) {
|
|
10257
10257
|
// add protocol prefix if not set
|
|
10258
10258
|
// use unsafe http unless spire/auth is used
|
|
10259
10259
|
if (!serverAddress.startsWith('http://') &&
|
|
10260
10260
|
!serverAddress.startsWith('https://')) {
|
|
10261
|
-
// use https protocol when X.509 or
|
|
10262
|
-
if (authMode === 'x509' || authMode === 'jwt') {
|
|
10261
|
+
// use https protocol when X.509, JWT, or TLS auth is used
|
|
10262
|
+
if (authMode === 'x509' || authMode === 'jwt' || authMode === 'tls') {
|
|
10263
10263
|
serverAddress = `https://${serverAddress}`;
|
|
10264
10264
|
}
|
|
10265
10265
|
else {
|
|
@@ -10271,6 +10271,9 @@ class Config {
|
|
|
10271
10271
|
this.spiffeEndpointSocket = spiffeEndpointSocket;
|
|
10272
10272
|
this.authMode = authMode;
|
|
10273
10273
|
this.jwtAudience = jwtAudience;
|
|
10274
|
+
this.tlsCaFile = tlsCaFile;
|
|
10275
|
+
this.tlsCertFile = tlsCertFile;
|
|
10276
|
+
this.tlsKeyFile = tlsKeyFile;
|
|
10274
10277
|
}
|
|
10275
10278
|
/**
|
|
10276
10279
|
* Load configuration from environment variables.
|
|
@@ -10295,14 +10298,20 @@ class Config {
|
|
|
10295
10298
|
const spiffeEndpointSocketPath = env[`${prefix}SPIFFE_SOCKET_PATH`] || Config.DEFAULT_SPIFFE_ENDPOINT_SOCKET;
|
|
10296
10299
|
const authMode = (env[`${prefix}AUTH_MODE`] || Config.DEFAULT_AUTH_MODE);
|
|
10297
10300
|
const jwtAudience = env[`${prefix}JWT_AUDIENCE`] || Config.DEFAULT_JWT_AUDIENCE;
|
|
10298
|
-
|
|
10301
|
+
const tlsCaFile = env[`${prefix}TLS_CA_FILE`] || Config.DEFAULT_TLS_CA_FILE;
|
|
10302
|
+
const tlsCertFile = env[`${prefix}TLS_CERT_FILE`] || Config.DEFAULT_TLS_CERT_FILE;
|
|
10303
|
+
const tlsKeyFile = env[`${prefix}TLS_KEY_FILE`] || Config.DEFAULT_TLS_KEY_FILE;
|
|
10304
|
+
return new Config(serverAddress, dirctlPath, spiffeEndpointSocketPath, authMode, jwtAudience, tlsCaFile, tlsCertFile, tlsKeyFile);
|
|
10299
10305
|
}
|
|
10300
10306
|
}
|
|
10301
10307
|
Config.DEFAULT_SERVER_ADDRESS = '127.0.0.1:8888';
|
|
10302
10308
|
Config.DEFAULT_DIRCTL_PATH = 'dirctl';
|
|
10303
10309
|
Config.DEFAULT_SPIFFE_ENDPOINT_SOCKET = '';
|
|
10304
|
-
Config.DEFAULT_AUTH_MODE = '
|
|
10310
|
+
Config.DEFAULT_AUTH_MODE = '';
|
|
10305
10311
|
Config.DEFAULT_JWT_AUDIENCE = '';
|
|
10312
|
+
Config.DEFAULT_TLS_CA_FILE = '';
|
|
10313
|
+
Config.DEFAULT_TLS_CERT_FILE = '';
|
|
10314
|
+
Config.DEFAULT_TLS_KEY_FILE = '';
|
|
10306
10315
|
/**
|
|
10307
10316
|
* High-level client for interacting with AGNTCY Directory services.
|
|
10308
10317
|
*
|
|
@@ -10364,7 +10373,7 @@ class Client {
|
|
|
10364
10373
|
static async createGRPCTransport(config) {
|
|
10365
10374
|
// Handle different authentication modes
|
|
10366
10375
|
switch (config.authMode) {
|
|
10367
|
-
case '
|
|
10376
|
+
case '':
|
|
10368
10377
|
return createGrpcTransport({
|
|
10369
10378
|
baseUrl: config.serverAddress,
|
|
10370
10379
|
});
|
|
@@ -10372,6 +10381,8 @@ class Client {
|
|
|
10372
10381
|
return await this.createJWTTransport(config);
|
|
10373
10382
|
case 'x509':
|
|
10374
10383
|
return await this.createX509Transport(config);
|
|
10384
|
+
case 'tls':
|
|
10385
|
+
return await this.createTLSTransport(config);
|
|
10375
10386
|
default:
|
|
10376
10387
|
throw new Error(`Unsupported auth mode: ${config.authMode}`);
|
|
10377
10388
|
}
|
|
@@ -10463,6 +10474,38 @@ class Client {
|
|
|
10463
10474
|
});
|
|
10464
10475
|
return transport;
|
|
10465
10476
|
}
|
|
10477
|
+
static async createTLSTransport(config) {
|
|
10478
|
+
if (config.tlsCaFile === '') {
|
|
10479
|
+
throw new Error('TLS CA file is required for TLS authentication');
|
|
10480
|
+
}
|
|
10481
|
+
if (config.tlsCertFile === '') {
|
|
10482
|
+
throw new Error('TLS certificate file is required for TLS authentication');
|
|
10483
|
+
}
|
|
10484
|
+
if (config.tlsKeyFile === '') {
|
|
10485
|
+
throw new Error('TLS key file is required for TLS authentication');
|
|
10486
|
+
}
|
|
10487
|
+
let root_ca;
|
|
10488
|
+
let cert_chain;
|
|
10489
|
+
let private_key;
|
|
10490
|
+
try {
|
|
10491
|
+
root_ca = readFileSync(config.tlsCaFile).toString();
|
|
10492
|
+
cert_chain = readFileSync(config.tlsCertFile).toString();
|
|
10493
|
+
private_key = readFileSync(config.tlsKeyFile).toString();
|
|
10494
|
+
}
|
|
10495
|
+
catch (e) {
|
|
10496
|
+
console.error('Error reading file:', e.message);
|
|
10497
|
+
throw e;
|
|
10498
|
+
}
|
|
10499
|
+
const transport = createGrpcTransport({
|
|
10500
|
+
baseUrl: config.serverAddress,
|
|
10501
|
+
nodeOptions: {
|
|
10502
|
+
ca: root_ca,
|
|
10503
|
+
cert: cert_chain,
|
|
10504
|
+
key: private_key,
|
|
10505
|
+
},
|
|
10506
|
+
});
|
|
10507
|
+
return transport;
|
|
10508
|
+
}
|
|
10466
10509
|
/**
|
|
10467
10510
|
* Request generator helper function for streaming requests.
|
|
10468
10511
|
*/
|