MCPcopy
hub / github.com/mongodb/node-mongodb-native / auth

Method auth

src/cmap/auth/plain.ts:7–24  ·  view source on GitHub ↗
(authContext: AuthContext)

Source from the content-addressed store, hash-verified

5
6export class Plain extends AuthProvider {
7 override async auth(authContext: AuthContext): Promise<void> {
8 const { connection, credentials } = authContext;
9 if (!credentials) {
10 throw new MongoMissingCredentialsError('AuthContext must provide credentials.');
11 }
12
13 const { username, password } = credentials;
14
15 const payload = new Binary(ByteUtils.fromUTF8(`\x00${username}\x00${password}`));
16 const command = {
17 saslStart: 1,
18 mechanism: 'PLAIN',
19 payload: payload,
20 autoAuthorize: 1
21 };
22
23 await connection.command(ns('$external.$cmd'), command, undefined);
24 }
25}

Callers

nothing calls this directly

Calls 2

nsFunction · 0.90
commandMethod · 0.45

Tested by

no test coverage detected