1
- import * as crypto from 'crypto' ;
2
1
import * as process from 'process' ;
3
- import { promisify } from 'util' ;
4
2
5
3
import type { Binary , BSONSerializeOptions } from '../../bson' ;
6
4
import * as BSON from '../../bson' ;
@@ -11,7 +9,7 @@ import {
11
9
MongoMissingCredentialsError ,
12
10
MongoRuntimeError
13
11
} from '../../error' ;
14
- import { ByteUtils , maxWireVersion , ns , request } from '../../utils' ;
12
+ import { ByteUtils , maxWireVersion , ns , randomBytes , request } from '../../utils' ;
15
13
import { type AuthContext , AuthProvider } from './auth_provider' ;
16
14
import { MongoCredentials } from './mongo_credentials' ;
17
15
import { AuthMechanism } from './providers' ;
@@ -59,11 +57,9 @@ interface AWSSaslContinuePayload {
59
57
export class MongoDBAWS extends AuthProvider {
60
58
static credentialProvider : ReturnType < typeof getAwsCredentialProvider > ;
61
59
provider ?: ( ) => Promise < AWSCredentials > ;
62
- randomBytesAsync : ( size : number ) => Promise < Buffer > ;
63
60
64
61
constructor ( ) {
65
62
super ( ) ;
66
- this . randomBytesAsync = promisify ( crypto . randomBytes ) ;
67
63
MongoDBAWS . credentialProvider ??= getAwsCredentialProvider ( ) ;
68
64
69
65
let { AWS_STS_REGIONAL_ENDPOINTS = '' , AWS_REGION = '' } = process . env ;
@@ -131,7 +127,7 @@ export class MongoDBAWS extends AuthProvider {
131
127
: undefined ;
132
128
133
129
const db = credentials . source ;
134
- const nonce = await this . randomBytesAsync ( 32 ) ;
130
+ const nonce = await randomBytes ( 32 ) ;
135
131
136
132
const saslStart = {
137
133
saslStart : 1 ,
0 commit comments