mongodb 6.9.0-dev.20240913.sha.8b0f3541 → 6.9.0-dev.20240918.sha.643a8755

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,38 +0,0 @@
1
- import * as crypto from 'crypto';
2
-
3
- import { MongoMissingCredentialsError } from '../../error';
4
- import { ns } from '../../utils';
5
- import { type AuthContext, AuthProvider } from './auth_provider';
6
-
7
- export class MongoCR extends AuthProvider {
8
- override async auth(authContext: AuthContext): Promise<void> {
9
- const { connection, credentials } = authContext;
10
- if (!credentials) {
11
- throw new MongoMissingCredentialsError('AuthContext must provide credentials.');
12
- }
13
-
14
- const { username, password, source } = credentials;
15
-
16
- const { nonce } = await connection.command(ns(`${source}.$cmd`), { getnonce: 1 }, undefined);
17
-
18
- const hashPassword = crypto
19
- .createHash('md5')
20
- .update(`${username}:mongo:${password}`, 'utf8')
21
- .digest('hex');
22
-
23
- // Final key
24
- const key = crypto
25
- .createHash('md5')
26
- .update(`${nonce}${username}${hashPassword}`, 'utf8')
27
- .digest('hex');
28
-
29
- const authenticateCommand = {
30
- authenticate: 1,
31
- user: username,
32
- nonce,
33
- key
34
- };
35
-
36
- await connection.command(ns(`${source}.$cmd`), authenticateCommand, undefined);
37
- }
38
- }