66 ClientServerChannel ,
77 Serializable ,
88 SerializedProxyConfig ,
9- serializeProxyConfig
9+ serializeProxyConfig ,
10+ serializeBuffer
1011} from "../../serialization/serialization" ;
1112
1213import { Explainable , Headers } from "../../types" ;
@@ -52,6 +53,7 @@ export interface SerializedPassThroughWebSocketData {
5253 proxyConfig ?: SerializedProxyConfig ;
5354 ignoreHostCertificateErrors ?: string [ ] | boolean ; // Doesn't match option name, backward compat
5455 extraCACertificates ?: Array < { cert : string } | { certPath : string } > ;
56+ clientCertificateHostMap ?: { [ host : string ] : { pfx : string , passphrase ?: string } } ;
5557}
5658
5759export class PassThroughWebSocketHandlerDefinition extends Serializable implements WebSocketHandlerDefinition {
@@ -63,17 +65,15 @@ export class PassThroughWebSocketHandlerDefinition extends Serializable implemen
6365
6466 public readonly forwarding ?: ForwardingOptions ;
6567 public readonly ignoreHostHttpsErrors : string [ ] | boolean = [ ] ;
68+ public readonly clientCertificateHostMap : {
69+ [ host : string ] : { pfx : Buffer , passphrase ?: string }
70+ } ;
6671
6772 public readonly extraCACertificates : Array < { cert : string | Buffer } | { certPath : string } > = [ ] ;
6873
6974 constructor ( options : PassThroughWebSocketHandlerOptions = { } ) {
7075 super ( ) ;
7176
72- this . ignoreHostHttpsErrors = options . ignoreHostHttpsErrors || [ ] ;
73- if ( ! Array . isArray ( this . ignoreHostHttpsErrors ) && typeof this . ignoreHostHttpsErrors !== 'boolean' ) {
74- throw new Error ( "ignoreHostHttpsErrors must be an array or a boolean" ) ;
75- }
76-
7777 // If a location is provided, and it's not a bare hostname, it must be parseable
7878 const { forwarding } = options ;
7979 if ( forwarding && forwarding . targetHost . includes ( '/' ) ) {
@@ -87,10 +87,19 @@ export class PassThroughWebSocketHandlerDefinition extends Serializable implemen
8787 ` ) ;
8888 }
8989 }
90+
9091 this . forwarding = options . forwarding ;
9192
93+ this . ignoreHostHttpsErrors = options . ignoreHostHttpsErrors || [ ] ;
94+ if ( ! Array . isArray ( this . ignoreHostHttpsErrors ) && typeof this . ignoreHostHttpsErrors !== 'boolean' ) {
95+ throw new Error ( "ignoreHostHttpsErrors must be an array or a boolean" ) ;
96+ }
97+
9298 this . lookupOptions = options . lookupOptions ;
9399 this . proxyConfig = options . proxyConfig ;
100+
101+ this . extraCACertificates = options . trustAdditionalCAs || [ ] ;
102+ this . clientCertificateHostMap = options . clientCertificateHostMap || { } ;
94103 }
95104
96105 explain ( ) {
@@ -120,6 +129,9 @@ export class PassThroughWebSocketHandlerDefinition extends Serializable implemen
120129 return certObject ;
121130 }
122131 } ) ,
132+ clientCertificateHostMap : _ . mapValues ( this . clientCertificateHostMap ,
133+ ( { pfx, passphrase } ) => ( { pfx : serializeBuffer ( pfx ) , passphrase } )
134+ )
123135 } ;
124136 }
125137}
0 commit comments