mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Update HTTPS config options for superagent (#36627)
* add tls configuration types superagent passes the ca, cert, and key parameters to `tls.createSecureContext`: https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options * add `response` event to superagent types
This commit is contained in:
parent
fa70abd6c1
commit
60e431da4a
9
types/superagent/index.d.ts
vendored
9
types/superagent/index.d.ts
vendored
@ -129,21 +129,22 @@ declare namespace request {
|
||||
auth(user: string, pass: string, options?: { type: 'basic' | 'auto' }): this;
|
||||
auth(token: string, options: { type: 'bearer' }): this;
|
||||
buffer(val?: boolean): this;
|
||||
ca(cert: Buffer): this;
|
||||
cert(cert: Buffer | string): this;
|
||||
ca(cert: string | string[] | Buffer | Buffer[]): this;
|
||||
cert(cert: string | string[] | Buffer | Buffer[]): this;
|
||||
clearTimeout(): this;
|
||||
end(callback?: CallbackHandler): void;
|
||||
field(name: string, val: MultipartValue): this;
|
||||
field(fields: { [fieldName: string]: MultipartValue }): this;
|
||||
get(field: string): string;
|
||||
key(cert: Buffer | string): this;
|
||||
key(cert: string | string[] | Buffer | Buffer[]): this;
|
||||
ok(callback: (res: Response) => boolean): this;
|
||||
on(name: 'error', handler: (err: any) => void): this;
|
||||
on(name: 'progress', handler: (event: ProgressEvent) => void): this;
|
||||
on(name: 'response', handler: (response: Response) => void): this;
|
||||
on(name: string, handler: (event: any) => void): this;
|
||||
parse(parser: Parser): this;
|
||||
part(): this;
|
||||
pfx(cert: Buffer | string | { pfx: Buffer, passphrase: string }): this;
|
||||
pfx(cert: string | string[] | Buffer | Buffer[] | { pfx: string | Buffer, passphrase: string }): this;
|
||||
pipe(stream: NodeJS.WritableStream, options?: object): stream.Writable;
|
||||
query(val: object | string): this;
|
||||
redirects(n: number): this;
|
||||
|
||||
@ -418,6 +418,53 @@ request
|
||||
})
|
||||
.end(callback);
|
||||
|
||||
// HTTPS request with string, Buffer, and arrays of strings and Buffers, from: https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options
|
||||
request
|
||||
.post('/secure')
|
||||
.ca('ca')
|
||||
.key('key')
|
||||
.cert('cert')
|
||||
.end(callback);
|
||||
|
||||
request
|
||||
.post('/secure')
|
||||
.ca(['ca'])
|
||||
.key(['key'])
|
||||
.cert(['cert'])
|
||||
.end(callback);
|
||||
|
||||
request
|
||||
.post('/secure')
|
||||
.ca([ca])
|
||||
.key([key])
|
||||
.cert([cert])
|
||||
.end(callback);
|
||||
|
||||
request
|
||||
.post('/secure')
|
||||
.pfx('cert.pfx')
|
||||
.end(callback);
|
||||
|
||||
request
|
||||
.post('/secure')
|
||||
.pfx(['cert.pfx'])
|
||||
.end(callback);
|
||||
|
||||
request
|
||||
.post('/secure')
|
||||
.pfx([pfx])
|
||||
.end(callback);
|
||||
|
||||
// 'response' event, adapted from: https://visionmedia.github.io/superagent/docs/test.html
|
||||
request
|
||||
.get('/user/1')
|
||||
.on('response', res => {
|
||||
try {
|
||||
assert.equal('bar', res.body.foo);
|
||||
} catch (e) { /* ignore */ }
|
||||
})
|
||||
.end();
|
||||
|
||||
// ok, from: https://github.com/visionmedia/superagent/commit/34533bbc29833889090847c45a82b0ea81b2f06d
|
||||
request
|
||||
.get('/404')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user