@@ -34,6 +34,7 @@ export interface TLSOpts {
3434export interface DDPConnectorOptions {
3535 host : string
3636 port : number
37+ headers ?: { [ header : string ] : string }
3738 path ?: string
3839 ssl ?: boolean
3940 debug ?: boolean
@@ -343,6 +344,10 @@ export class DDPClient extends EventEmitter<DDPClientEvents> {
343344 public get port ( ) : number {
344345 return this . portInt
345346 }
347+ private headersInt : { [ header : string ] : string } = { }
348+ public get headers ( ) : { [ header : string ] : string } {
349+ return this . headersInt
350+ }
346351 private pathInt ?: string
347352 public get path ( ) : string | undefined {
348353 return this . pathInt
@@ -410,6 +415,7 @@ export class DDPClient extends EventEmitter<DDPClientEvents> {
410415 // console.log(opts)
411416 this . hostInt = opts . host || '127.0.0.1'
412417 this . portInt = opts . port || 3000
418+ this . headersInt = opts . headers || { }
413419 this . pathInt = opts . path
414420 this . sslInt = opts . ssl || this . port === 443
415421 this . tlsOpts = opts . tlsOpts || { }
@@ -722,6 +728,7 @@ export class DDPClient extends EventEmitter<DDPClientEvents> {
722728
723729 try {
724730 const response = await got ( url , {
731+ headers : this . headers ,
725732 https : {
726733 certificateAuthority : this . tlsOpts . ca ,
727734 key : this . tlsOpts . key ,
@@ -762,7 +769,7 @@ export class DDPClient extends EventEmitter<DDPClientEvents> {
762769
763770 private makeWebSocketConnection ( url : string ) : void {
764771 // console.log('About to create WebSocket client')
765- this . socket = new WebSocket . Client ( url , null , { tls : this . tlsOpts } )
772+ this . socket = new WebSocket . Client ( url , null , { tls : this . tlsOpts , headers : this . headers } )
766773
767774 this . socket . on ( 'open' , ( ) => {
768775 // just go ahead and open the connection on connect
0 commit comments