mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
add options to request.auth method (#27373)
This commit is contained in:
parent
a43c276f2b
commit
1d4e623ccb
4
types/superagent/index.d.ts
vendored
4
types/superagent/index.d.ts
vendored
@ -5,6 +5,7 @@
|
||||
// Pap Lőrinc <https://github.com/paplorinc>
|
||||
// Shrey Jain <https://github.com/shreyjain1994>
|
||||
// Alec Zopf <https://github.com/zopf>
|
||||
// Adam Haglund <https://github.com/beeequeue>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
@ -118,7 +119,8 @@ declare namespace request {
|
||||
abort(): void;
|
||||
accept(type: string): this;
|
||||
attach(field: string, file: MultipartValueSingle, options?: string | { filename?: string; contentType?: string }): this;
|
||||
auth(user: string, name: string): this;
|
||||
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;
|
||||
|
||||
@ -230,13 +230,29 @@ const reqCookies: string = req.cookies;
|
||||
|
||||
console.log(`${reqMethod} request to ${reqUrl} cookies ${reqCookies}`);
|
||||
|
||||
// Basic authentication
|
||||
// Authentication
|
||||
request.get('http://tobi:learnboost@local').end(callback);
|
||||
|
||||
request
|
||||
.get('http://local')
|
||||
.auth('tobo', 'learnboost')
|
||||
.end(callback);
|
||||
|
||||
request
|
||||
.get('http://local')
|
||||
.auth('user', 'pass', { type: 'basic' })
|
||||
.end(callback);
|
||||
|
||||
request
|
||||
.get('http://local')
|
||||
.auth('user', 'pass', {type: 'auto'})
|
||||
.end(callback);
|
||||
|
||||
request
|
||||
.get('http://local')
|
||||
.auth('abearertoken', { type: 'bearer' })
|
||||
.end(callback);
|
||||
|
||||
// Following redirects
|
||||
request
|
||||
.get('/some.png')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user