Add support for bearer auth (#1488)

This commit is contained in:
Tomas Della Vedova
2021-07-13 09:39:10 +02:00
committed by GitHub
parent f2d8cf7d34
commit 101a13f63e
6 changed files with 65 additions and 3 deletions

View File

@ -331,6 +331,8 @@ function prepareHeaders (headers = {}, auth) {
} else {
headers.authorization = `ApiKey ${auth.apiKey}`
}
} else if (auth.bearer) {
headers.authorization = `Bearer ${auth.bearer}`
} else if (auth.username && auth.password) {
headers.authorization = 'Basic ' + Buffer.from(`${auth.username}:${auth.password}`).toString('base64')
}

5
lib/pool/index.d.ts vendored
View File

@ -61,6 +61,10 @@ interface BasicAuth {
password: string;
}
interface BearerAuth {
bearer: string
}
interface resurrectOptions {
now?: number;
requestId: string;
@ -204,6 +208,7 @@ export {
getConnectionOptions,
ApiKeyAuth,
BasicAuth,
BearerAuth,
internals,
resurrectOptions,
ResurrectEvent,