(
handshakeDoc: HandshakeDocument,
authContext: AuthContext
)
| 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; |
nothing calls this directly
no test coverage detected