MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / validateAuthenticationOptions

Function validateAuthenticationOptions

lib/client-options.js:261–276  ·  view source on GitHub ↗

* Validates authentication provider and credentials. * @param {ClientOptions} options * @private

(options)

Source from the content-addressed store, hash-verified

259 * @private
260 */
261function 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.

Callers 1

extendFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected