| 12 | * @constructor |
| 13 | */ |
| 14 | export class ClientSSLSecurityPFX implements ISecurity { |
| 15 | private pfx: Buffer; |
| 16 | private defaults; |
| 17 | private passphrase: string; |
| 18 | |
| 19 | constructor(pfx: string | Buffer, defaults?: any); |
| 20 | constructor(pfx: string | Buffer, passphrase: string, defaults?: any); |
| 21 | constructor(pfx: string | Buffer, passphrase: string, defaults?: any) { |
| 22 | if (typeof passphrase === 'object') { |
| 23 | defaults = passphrase; |
| 24 | } |
| 25 | if (pfx) { |
| 26 | if (Buffer.isBuffer(pfx)) { |
| 27 | this.pfx = pfx; |
| 28 | } else if (typeof pfx === 'string') { |
| 29 | this.pfx = fs.readFileSync(pfx); |
| 30 | } else { |
| 31 | throw new Error('supplied pfx file should be a buffer or a file location'); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | if (passphrase) { |
| 36 | if (typeof passphrase === 'string') { |
| 37 | this.passphrase = passphrase; |
| 38 | } |
| 39 | } |
| 40 | this.defaults = {}; |
| 41 | merge(this.defaults, defaults); |
| 42 | } |
| 43 | |
| 44 | public toXML(): string { |
| 45 | return ''; |
| 46 | } |
| 47 | |
| 48 | public addOptions(options: any): void { |
| 49 | options.pfx = this.pfx; |
| 50 | if (this.passphrase) { |
| 51 | options.passphrase = this.passphrase; |
| 52 | } |
| 53 | merge(options, this.defaults); |
| 54 | options.httpsAgent = new https.Agent(options); |
| 55 | } |
| 56 | } |
nothing calls this directly
no outgoing calls
no test coverage detected