2020-05-15 15:25:57 -04:00
|
|
|
module.exports = validateAuth;
|
2019-08-06 17:37:58 -04:00
|
|
|
|
2020-05-15 15:25:57 -04:00
|
|
|
function validateAuth(auth) {
|
|
|
|
|
if (typeof auth === "string") {
|
|
|
|
|
return;
|
2019-08-06 17:37:58 -04:00
|
|
|
}
|
|
|
|
|
|
2020-05-15 15:25:57 -04:00
|
|
|
if (typeof auth === "function") {
|
|
|
|
|
return;
|
2019-08-06 17:37:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (auth.username && auth.password) {
|
2020-05-15 15:25:57 -04:00
|
|
|
return;
|
2019-08-06 17:37:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (auth.clientId && auth.clientSecret) {
|
2020-05-15 15:25:57 -04:00
|
|
|
return;
|
2019-08-06 17:37:58 -04:00
|
|
|
}
|
|
|
|
|
|
2020-05-15 15:25:57 -04:00
|
|
|
throw new Error(`Invalid "auth" option: ${JSON.stringify(auth)}`);
|
2019-08-06 17:37:58 -04:00
|
|
|
}
|