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

Method prepare

src/cmap/auth/scram.ts:25–48  ·  view source on GitHub ↗
(
    handshakeDoc: HandshakeDocument,
    authContext: AuthContext
  )

Source from the content-addressed store, hash-verified

23 }
24
25 override async prepare(
26 handshakeDoc: HandshakeDocument,
27 authContext: AuthContext
28 ): Promise<HandshakeDocument> {
29 const cryptoMethod = this.cryptoMethod;
30 const credentials = authContext.credentials;
31 if (!credentials) {
32 throw new MongoMissingCredentialsError('AuthContext must provide credentials.');
33 }
34
35 const nonce = await randomBytes(24);
36 // store the nonce for later use
37 authContext.nonce = nonce;
38
39 const request = {
40 ...handshakeDoc,
41 speculativeAuthenticate: {
42 ...makeFirstMessage(cryptoMethod, credentials, nonce),
43 db: credentials.source
44 }
45 };
46
47 return request;
48 }
49
50 override async auth(authContext: AuthContext) {
51 const { reauthenticating, response } = authContext;

Callers

nothing calls this directly

Calls 2

randomBytesFunction · 0.90
makeFirstMessageFunction · 0.85

Tested by

no test coverage detected