(cryptoMethod: CryptoMethod, authContext: AuthContext)
| 98 | } |
| 99 | |
| 100 | async 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 | |
| 116 | async function continueScramConversation( |
| 117 | cryptoMethod: CryptoMethod, |
no test coverage detected