@@ -27,8 +27,15 @@ import { dbg } from './dbg.js'
27
27
import { ConnectionPool } from './pool.js'
28
28
import { debug } from './middleware.js'
29
29
30
- export type DriverOptions = Omit < ChannelOptions , keyof any > & {
30
+ export type DriverOptions = {
31
+ /**
32
+ * SSL/TLS options for secure connections.
33
+ *
34
+ * @deprecated Use `secureOptions` instead.
35
+ */
31
36
ssl ?: tls . SecureContextOptions
37
+ secureOptions ?: tls . SecureContextOptions | undefined
38
+ channelOptions ?: ChannelOptions
32
39
credentialsProvider ?: CredentialsProvider
33
40
34
41
'ydb.sdk.application' ?: string
@@ -81,8 +88,9 @@ export class Driver implements Disposable {
81
88
throw new Error ( 'Invalid connection string. Must be a non-empty string' )
82
89
}
83
90
84
- this . options = Object . assign ( { } , defaultOptions , options )
85
91
this . cs = new URL ( connectionString . replace ( / ^ g r p c / , 'http' ) )
92
+ this . options = Object . assign ( { } , defaultOptions , options )
93
+ this . options . secureOptions ??= this . options . ssl
86
94
87
95
if ( [ 'grpc:' , 'grpcs:' , 'http:' , 'https:' ] . includes ( this . cs . protocol ) === false ) {
88
96
throw new Error ( 'Invalid connection string protocol. Must be one of grpc, grpcs, http, https' )
@@ -113,13 +121,13 @@ export class Driver implements Disposable {
113
121
ssl : this . isSecure ,
114
122
} )
115
123
116
- let channelCredentials = this . options . ssl
117
- ? credentials . createFromSecureContext ( tls . createSecureContext ( this . options . ssl ) )
124
+ let channelCredentials = this . options . secureOptions
125
+ ? credentials . createFromSecureContext ( tls . createSecureContext ( this . options . secureOptions ) )
118
126
: this . isSecure
119
127
? credentials . createSsl ( )
120
128
: credentials . createInsecure ( )
121
129
122
- this . #connection = new LazyConnection ( endpoint , channelCredentials , this . options )
130
+ this . #connection = new LazyConnection ( endpoint , channelCredentials , this . options . channelOptions )
123
131
124
132
this . #middleware = debug
125
133
this . #middleware = composeClientMiddleware ( this . #middleware, ( call , options ) => {
@@ -135,7 +143,7 @@ export class Driver implements Disposable {
135
143
this . #middleware = composeClientMiddleware ( this . #middleware, this . #credentialsProvider. middleware )
136
144
}
137
145
138
- this . #pool = new ConnectionPool ( channelCredentials , this . options )
146
+ this . #pool = new ConnectionPool ( channelCredentials , this . options . channelOptions )
139
147
140
148
this . #discoveryClient = createClientFactory ( )
141
149
. use ( this . #middleware)
@@ -186,7 +194,7 @@ export class Driver implements Disposable {
186
194
}
187
195
188
196
get isSecure ( ) : boolean {
189
- return this . cs . protocol === 'https:'
197
+ return this . cs . protocol === 'https:' || this . cs . protocol === 'grpcs:'
190
198
}
191
199
192
200
async #discovery( signal ?: AbortSignal ) : Promise < void > {
@@ -260,7 +268,7 @@ export class Driver implements Disposable {
260
268
} ,
261
269
} ) ,
262
270
{
263
- '*' : this . options ,
271
+ '*' : this . options . channelOptions ,
264
272
}
265
273
)
266
274
}
0 commit comments