11import axios , { AxiosRequestConfig , RawAxiosRequestHeaders } from 'axios' ;
2- import * as https from 'https'
2+ import * as https from 'https' ;
3+ import * as tls from 'tls' ;
34
45const DEFAULT_SERVER = 'http://localhost:8080' ;
56const DEFAULT_SOURCE = 'trino-js-client' ;
67const DEFAULT_USER = process . env . USER ;
7- const DEFAULT_VERIFY_SSL_CERT = true ;
88
99// Trino headers
1010const TRINO_HEADER_PREFIX = 'X-Trino-' ;
@@ -45,6 +45,10 @@ const encodeAsString = (obj: {[key: string]: string}) => {
4545 . join ( ',' ) ;
4646} ;
4747
48+ export type SecureContextOptions = tls . SecureContextOptions & {
49+ readonly rejectUnauthorized ?: boolean ;
50+ } ;
51+
4852export type ConnectionOptions = {
4953 readonly server ?: string ;
5054 readonly source ?: string ;
@@ -53,7 +57,7 @@ export type ConnectionOptions = {
5357 readonly auth ?: Auth ;
5458 readonly session ?: Session ;
5559 readonly extraCredential ?: ExtraCredential ;
56- readonly verifySSLCert ?: boolean ;
60+ readonly ssl ?: SecureContextOptions ;
5761} ;
5862
5963export type QueryStage = {
@@ -167,9 +171,7 @@ class Client {
167171 ) { }
168172
169173 static create ( options : ConnectionOptions ) : Client {
170- const agent = new https . Agent ( {
171- rejectUnauthorized : options . verifySSLCert ?? DEFAULT_VERIFY_SSL_CERT
172- } ) ;
174+ const agent = new https . Agent ( options . ssl ?? { } ) ;
173175
174176 const clientConfig : AxiosRequestConfig = {
175177 baseURL : options . server ?? DEFAULT_SERVER ,
0 commit comments