add handling for superagent pfx with passphrase

This commit is contained in:
Alec Zopf
2018-05-16 15:48:29 -04:00
parent c0fe97a75b
commit c7139f6cd6
2 changed files with 12 additions and 1 deletions

View File

@@ -4,6 +4,7 @@
// Michael Ledin <https://github.com/mxl>
// Pap Lőrinc <https://github.com/paplorinc>
// Shrey Jain <https://github.com/shreyjain1994>
// Alec Zopf <https://github.com/zopf>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -131,7 +132,7 @@ declare namespace request {
on(name: string, handler: (event: any) => void): this;
parse(parser: Parser): this;
part(): this;
pfx(cert: Buffer | string): this;
pfx(cert: Buffer | string | { pfx: Buffer, passphrase: string }): this;
pipe(stream: NodeJS.WritableStream, options?: object): stream.Writable;
query(val: object | string): this;
redirects(n: number): this;

View File

@@ -373,6 +373,16 @@ request
.pfx(pfx)
.end(callback);
// pfx with passphrase, from: https://github.com/visionmedia/superagent/pull/1230/commits/96af65ffc6256df633f893095d1dc828694bbfbc
const passpfx = fs.readFileSync('passcert.pfx');
request
.post('/secure')
.pfx({
pfx: passpfx,
passphrase: 'test'
})
.end(callback);
// ok, from: https://github.com/visionmedia/superagent/commit/34533bbc29833889090847c45a82b0ea81b2f06d
request
.get('/404')