Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 400x 400x 400x 400x 400x 9x 9x 9x 9x 9x 9x | import { Binary } from '../../bson'; import { MongoMissingCredentialsError } from '../../error'; import { ns } from '../../utils'; import { type AuthContext, AuthProvider } from './auth_provider'; export class Plain extends AuthProvider { override async auth(authContext: AuthContext): Promise<void> { const { connection, credentials } = authContext; Iif (!credentials) { throw new MongoMissingCredentialsError('AuthContext must provide credentials.'); } const { username, password } = credentials; const payload = new Binary(Buffer.from(`\x00${username}\x00${password}`)); const command = { saslStart: 1, mechanism: 'PLAIN', payload: payload, autoAuthorize: 1 }; await connection.command(ns('$external.$cmd'), command, undefined); } } |