* Validates authentication provider and credentials. * @param {ClientOptions} options * @private
(options)
| 259 | * @private |
| 260 | */ |
| 261 | function validateAuthenticationOptions(options) { |
| 262 | if (!options.authProvider) { |
| 263 | const credentials = options.credentials; |
| 264 | if (credentials) { |
| 265 | if (typeof credentials.username !== 'string' || typeof credentials.password !== 'string') { |
| 266 | throw new TypeError('credentials username and password must be a string'); |
| 267 | } |
| 268 | |
| 269 | options.authProvider = new auth.PlainTextAuthProvider(credentials.username, credentials.password); |
| 270 | } else { |
| 271 | options.authProvider = new auth.NoAuthProvider(); |
| 272 | } |
| 273 | } else if (!(options.authProvider instanceof auth.AuthProvider)) { |
| 274 | throw new TypeError('options.authProvider must be an instance of AuthProvider'); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | /** |
| 279 | * Validates the encoding options. |