validate.js 355 B

123456789101112131415161718192021
  1. module.exports = validateAuth;
  2. function validateAuth(auth) {
  3. if (typeof auth === "string") {
  4. return;
  5. }
  6. if (typeof auth === "function") {
  7. return;
  8. }
  9. if (auth.username && auth.password) {
  10. return;
  11. }
  12. if (auth.clientId && auth.clientSecret) {
  13. return;
  14. }
  15. throw new Error(`Invalid "auth" option: ${JSON.stringify(auth)}`);
  16. }