diff --git a/types/superagent/index.d.ts b/types/superagent/index.d.ts index c07d2fff1c..ffedf346ff 100644 --- a/types/superagent/index.d.ts +++ b/types/superagent/index.d.ts @@ -5,6 +5,7 @@ // Pap Lőrinc // Shrey Jain // Alec Zopf +// Adam Haglund // 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; diff --git a/types/superagent/superagent-tests.ts b/types/superagent/superagent-tests.ts index 0c4b51f31e..c063c819be 100644 --- a/types/superagent/superagent-tests.ts +++ b/types/superagent/superagent-tests.ts @@ -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')