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

Function executeScram

src/cmap/auth/scram.ts:100–114  ·  view source on GitHub ↗
(cryptoMethod: CryptoMethod, authContext: AuthContext)

Source from the content-addressed store, hash-verified

98}
99
100async function executeScram(cryptoMethod: CryptoMethod, authContext: AuthContext): Promise<void> {
101 const { connection, credentials } = authContext;
102 if (!credentials) {
103 throw new MongoMissingCredentialsError('AuthContext must provide credentials.');
104 }
105 if (!authContext.nonce) {
106 throw new MongoInvalidArgumentError('AuthContext must contain a valid nonce property');
107 }
108 const nonce = authContext.nonce;
109 const db = credentials.source;
110
111 const saslStartCmd = makeFirstMessage(cryptoMethod, credentials, nonce);
112 const response = await connection.command(ns(`${db}.$cmd`), saslStartCmd, undefined);
113 await continueScramConversation(cryptoMethod, response, authContext);
114}
115
116async function continueScramConversation(
117 cryptoMethod: CryptoMethod,

Callers 1

authMethod · 0.85

Calls 4

nsFunction · 0.90
makeFirstMessageFunction · 0.85
commandMethod · 0.45

Tested by

no test coverage detected