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