mongodb 5.0.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +25 -22
  2. package/lib/bson.js +3 -1
  3. package/lib/bson.js.map +1 -1
  4. package/lib/change_stream.js +3 -2
  5. package/lib/change_stream.js.map +1 -1
  6. package/lib/cmap/auth/auth_provider.js +21 -10
  7. package/lib/cmap/auth/auth_provider.js.map +1 -1
  8. package/lib/cmap/auth/gssapi.js +71 -116
  9. package/lib/cmap/auth/gssapi.js.map +1 -1
  10. package/lib/cmap/auth/mongo_credentials.js +17 -0
  11. package/lib/cmap/auth/mongo_credentials.js.map +1 -1
  12. package/lib/cmap/auth/mongocr.js +20 -29
  13. package/lib/cmap/auth/mongocr.js.map +1 -1
  14. package/lib/cmap/auth/mongodb_aws.js +126 -140
  15. package/lib/cmap/auth/mongodb_aws.js.map +1 -1
  16. package/lib/cmap/auth/mongodb_oidc/aws_service_workflow.js +28 -0
  17. package/lib/cmap/auth/mongodb_oidc/aws_service_workflow.js.map +1 -0
  18. package/lib/cmap/auth/mongodb_oidc/callback_workflow.js +178 -0
  19. package/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -0
  20. package/lib/cmap/auth/mongodb_oidc/service_workflow.js +41 -0
  21. package/lib/cmap/auth/mongodb_oidc/service_workflow.js.map +1 -0
  22. package/lib/cmap/auth/mongodb_oidc/token_entry_cache.js +115 -0
  23. package/lib/cmap/auth/mongodb_oidc/token_entry_cache.js.map +1 -0
  24. package/lib/cmap/auth/mongodb_oidc/workflow.js +3 -0
  25. package/lib/cmap/auth/mongodb_oidc/workflow.js.map +1 -0
  26. package/lib/cmap/auth/mongodb_oidc.js +62 -0
  27. package/lib/cmap/auth/mongodb_oidc.js.map +1 -0
  28. package/lib/cmap/auth/plain.js +4 -5
  29. package/lib/cmap/auth/plain.js.map +1 -1
  30. package/lib/cmap/auth/providers.js +4 -1
  31. package/lib/cmap/auth/providers.js.map +1 -1
  32. package/lib/cmap/auth/scram.js +45 -73
  33. package/lib/cmap/auth/scram.js.map +1 -1
  34. package/lib/cmap/auth/x509.js +8 -11
  35. package/lib/cmap/auth/x509.js.map +1 -1
  36. package/lib/cmap/command_monitoring_events.js +8 -5
  37. package/lib/cmap/command_monitoring_events.js.map +1 -1
  38. package/lib/cmap/commands.js +9 -1
  39. package/lib/cmap/commands.js.map +1 -1
  40. package/lib/cmap/connect.js +72 -86
  41. package/lib/cmap/connect.js.map +1 -1
  42. package/lib/cmap/connection.js +68 -74
  43. package/lib/cmap/connection.js.map +1 -1
  44. package/lib/cmap/connection_pool.js +51 -13
  45. package/lib/cmap/connection_pool.js.map +1 -1
  46. package/lib/cmap/message_stream.js.map +1 -1
  47. package/lib/cmap/wire_protocol/shared.js +1 -16
  48. package/lib/cmap/wire_protocol/shared.js.map +1 -1
  49. package/lib/collection.js +10 -10
  50. package/lib/connection_string.js +47 -33
  51. package/lib/connection_string.js.map +1 -1
  52. package/lib/cursor/abstract_cursor.js +13 -7
  53. package/lib/cursor/abstract_cursor.js.map +1 -1
  54. package/lib/cursor/find_cursor.js +1 -1
  55. package/lib/db.js +3 -2
  56. package/lib/db.js.map +1 -1
  57. package/lib/error.js +2 -1
  58. package/lib/error.js.map +1 -1
  59. package/lib/mongo_client.js +22 -2
  60. package/lib/mongo_client.js.map +1 -1
  61. package/lib/mongo_logger.js +17 -1
  62. package/lib/mongo_logger.js.map +1 -1
  63. package/lib/operations/aggregate.js +4 -1
  64. package/lib/operations/aggregate.js.map +1 -1
  65. package/lib/operations/create_collection.js +1 -0
  66. package/lib/operations/create_collection.js.map +1 -1
  67. package/lib/operations/execute_operation.js +8 -27
  68. package/lib/operations/execute_operation.js.map +1 -1
  69. package/lib/operations/find.js +3 -2
  70. package/lib/operations/find.js.map +1 -1
  71. package/lib/operations/indexes.js +2 -1
  72. package/lib/operations/indexes.js.map +1 -1
  73. package/lib/operations/list_collections.js +2 -1
  74. package/lib/operations/list_collections.js.map +1 -1
  75. package/lib/read_concern.js +1 -1
  76. package/lib/read_preference.js +2 -2
  77. package/lib/sdam/monitor.js +1 -0
  78. package/lib/sdam/monitor.js.map +1 -1
  79. package/lib/sdam/server.js +4 -2
  80. package/lib/sdam/server.js.map +1 -1
  81. package/lib/sdam/topology.js +3 -26
  82. package/lib/sdam/topology.js.map +1 -1
  83. package/lib/sessions.js +2 -1
  84. package/lib/sessions.js.map +1 -1
  85. package/lib/utils.js +15 -70
  86. package/lib/utils.js.map +1 -1
  87. package/lib/write_concern.js +1 -1
  88. package/mongodb.d.ts +137 -68
  89. package/package.json +30 -30
  90. package/src/bson.ts +3 -1
  91. package/src/bulk/common.ts +1 -1
  92. package/src/change_stream.ts +16 -8
  93. package/src/cmap/auth/auth_provider.ts +29 -16
  94. package/src/cmap/auth/gssapi.ts +102 -149
  95. package/src/cmap/auth/mongo_credentials.ts +47 -1
  96. package/src/cmap/auth/mongocr.ts +31 -36
  97. package/src/cmap/auth/mongodb_aws.ts +167 -189
  98. package/src/cmap/auth/mongodb_oidc/aws_service_workflow.ts +26 -0
  99. package/src/cmap/auth/mongodb_oidc/callback_workflow.ts +259 -0
  100. package/src/cmap/auth/mongodb_oidc/service_workflow.ts +47 -0
  101. package/src/cmap/auth/mongodb_oidc/token_entry_cache.ts +166 -0
  102. package/src/cmap/auth/mongodb_oidc/workflow.ts +21 -0
  103. package/src/cmap/auth/mongodb_oidc.ts +123 -0
  104. package/src/cmap/auth/plain.ts +6 -6
  105. package/src/cmap/auth/providers.ts +5 -2
  106. package/src/cmap/auth/scram.ts +56 -90
  107. package/src/cmap/auth/x509.ts +12 -18
  108. package/src/cmap/command_monitoring_events.ts +5 -2
  109. package/src/cmap/commands.ts +11 -1
  110. package/src/cmap/connect.ts +90 -114
  111. package/src/cmap/connection.ts +92 -90
  112. package/src/cmap/connection_pool.ts +77 -16
  113. package/src/cmap/message_stream.ts +0 -2
  114. package/src/cmap/wire_protocol/compression.ts +1 -1
  115. package/src/cmap/wire_protocol/shared.ts +1 -23
  116. package/src/collection.ts +11 -11
  117. package/src/connection_string.ts +52 -35
  118. package/src/cursor/abstract_cursor.ts +13 -6
  119. package/src/cursor/change_stream_cursor.ts +5 -5
  120. package/src/cursor/find_cursor.ts +1 -1
  121. package/src/db.ts +3 -2
  122. package/src/deps.ts +56 -38
  123. package/src/error.ts +3 -2
  124. package/src/index.ts +7 -0
  125. package/src/mongo_client.ts +35 -10
  126. package/src/mongo_logger.ts +20 -2
  127. package/src/mongo_types.ts +4 -3
  128. package/src/operations/aggregate.ts +4 -2
  129. package/src/operations/create_collection.ts +2 -1
  130. package/src/operations/execute_operation.ts +8 -25
  131. package/src/operations/find.ts +13 -4
  132. package/src/operations/find_and_modify.ts +4 -4
  133. package/src/operations/indexes.ts +12 -4
  134. package/src/operations/list_collections.ts +11 -3
  135. package/src/operations/set_profiling_level.ts +1 -1
  136. package/src/operations/stats.ts +1 -1
  137. package/src/read_concern.ts +2 -2
  138. package/src/read_preference.ts +3 -3
  139. package/src/sdam/common.ts +2 -2
  140. package/src/sdam/monitor.ts +1 -0
  141. package/src/sdam/server.ts +4 -1
  142. package/src/sdam/topology.ts +4 -33
  143. package/src/sessions.ts +2 -1
  144. package/src/transactions.ts +1 -1
  145. package/src/utils.ts +24 -98
  146. package/src/write_concern.ts +1 -1
@@ -1,15 +1,14 @@
1
1
  import * as crypto from 'crypto';
2
+ import { promisify } from 'util';
2
3
 
3
4
  import { Binary, Document } from '../../bson';
4
5
  import { saslprep } from '../../deps';
5
6
  import {
6
- AnyError,
7
7
  MongoInvalidArgumentError,
8
8
  MongoMissingCredentialsError,
9
- MongoRuntimeError,
10
- MongoServerError
9
+ MongoRuntimeError
11
10
  } from '../../error';
12
- import { Callback, emitWarning, ns } from '../../utils';
11
+ import { emitWarning, ns } from '../../utils';
13
12
  import type { HandshakeDocument } from '../connect';
14
13
  import { AuthContext, AuthProvider } from './auth_provider';
15
14
  import type { MongoCredentials } from './mongo_credentials';
@@ -19,53 +18,51 @@ type CryptoMethod = 'sha1' | 'sha256';
19
18
 
20
19
  class ScramSHA extends AuthProvider {
21
20
  cryptoMethod: CryptoMethod;
21
+ randomBytesAsync: (size: number) => Promise<Buffer>;
22
22
  constructor(cryptoMethod: CryptoMethod) {
23
23
  super();
24
24
  this.cryptoMethod = cryptoMethod || 'sha1';
25
+ this.randomBytesAsync = promisify(crypto.randomBytes);
25
26
  }
26
27
 
27
- override prepare(handshakeDoc: HandshakeDocument, authContext: AuthContext, callback: Callback) {
28
+ override async prepare(
29
+ handshakeDoc: HandshakeDocument,
30
+ authContext: AuthContext
31
+ ): Promise<HandshakeDocument> {
28
32
  const cryptoMethod = this.cryptoMethod;
29
33
  const credentials = authContext.credentials;
30
34
  if (!credentials) {
31
- return callback(new MongoMissingCredentialsError('AuthContext must provide credentials.'));
35
+ throw new MongoMissingCredentialsError('AuthContext must provide credentials.');
32
36
  }
33
37
  if (cryptoMethod === 'sha256' && saslprep == null) {
34
38
  emitWarning('Warning: no saslprep library specified. Passwords will not be sanitized');
35
39
  }
36
40
 
37
- crypto.randomBytes(24, (err, nonce) => {
38
- if (err) {
39
- return callback(err);
40
- }
41
-
42
- // store the nonce for later use
43
- Object.assign(authContext, { nonce });
41
+ const nonce = await this.randomBytesAsync(24);
42
+ // store the nonce for later use
43
+ authContext.nonce = nonce;
44
44
 
45
- const request = Object.assign({}, handshakeDoc, {
46
- speculativeAuthenticate: Object.assign(makeFirstMessage(cryptoMethod, credentials, nonce), {
47
- db: credentials.source
48
- })
49
- });
45
+ const request = {
46
+ ...handshakeDoc,
47
+ speculativeAuthenticate: {
48
+ ...makeFirstMessage(cryptoMethod, credentials, nonce),
49
+ db: credentials.source
50
+ }
51
+ };
50
52
 
51
- callback(undefined, request);
52
- });
53
+ return request;
53
54
  }
54
55
 
55
- override auth(authContext: AuthContext, callback: Callback) {
56
- const response = authContext.response;
57
- if (response && response.speculativeAuthenticate) {
58
- continueScramConversation(
56
+ override async auth(authContext: AuthContext) {
57
+ const { reauthenticating, response } = authContext;
58
+ if (response?.speculativeAuthenticate && !reauthenticating) {
59
+ return continueScramConversation(
59
60
  this.cryptoMethod,
60
61
  response.speculativeAuthenticate,
61
- authContext,
62
- callback
62
+ authContext
63
63
  );
64
-
65
- return;
66
64
  }
67
-
68
- executeScram(this.cryptoMethod, authContext, callback);
65
+ return executeScram(this.cryptoMethod, authContext);
69
66
  }
70
67
  }
71
68
 
@@ -106,43 +103,34 @@ function makeFirstMessage(
106
103
  };
107
104
  }
108
105
 
109
- function executeScram(cryptoMethod: CryptoMethod, authContext: AuthContext, callback: Callback) {
106
+ async function executeScram(cryptoMethod: CryptoMethod, authContext: AuthContext): Promise<void> {
110
107
  const { connection, credentials } = authContext;
111
108
  if (!credentials) {
112
- return callback(new MongoMissingCredentialsError('AuthContext must provide credentials.'));
109
+ throw new MongoMissingCredentialsError('AuthContext must provide credentials.');
113
110
  }
114
111
  if (!authContext.nonce) {
115
- return callback(
116
- new MongoInvalidArgumentError('AuthContext must contain a valid nonce property')
117
- );
112
+ throw new MongoInvalidArgumentError('AuthContext must contain a valid nonce property');
118
113
  }
119
114
  const nonce = authContext.nonce;
120
115
  const db = credentials.source;
121
116
 
122
117
  const saslStartCmd = makeFirstMessage(cryptoMethod, credentials, nonce);
123
- connection.command(ns(`${db}.$cmd`), saslStartCmd, undefined, (_err, result) => {
124
- const err = resolveError(_err, result);
125
- if (err) {
126
- return callback(err);
127
- }
128
-
129
- continueScramConversation(cryptoMethod, result, authContext, callback);
130
- });
118
+ const response = await connection.commandAsync(ns(`${db}.$cmd`), saslStartCmd, undefined);
119
+ await continueScramConversation(cryptoMethod, response, authContext);
131
120
  }
132
121
 
133
- function continueScramConversation(
122
+ async function continueScramConversation(
134
123
  cryptoMethod: CryptoMethod,
135
124
  response: Document,
136
- authContext: AuthContext,
137
- callback: Callback
138
- ) {
125
+ authContext: AuthContext
126
+ ): Promise<void> {
139
127
  const connection = authContext.connection;
140
128
  const credentials = authContext.credentials;
141
129
  if (!credentials) {
142
- return callback(new MongoMissingCredentialsError('AuthContext must provide credentials.'));
130
+ throw new MongoMissingCredentialsError('AuthContext must provide credentials.');
143
131
  }
144
132
  if (!authContext.nonce) {
145
- return callback(new MongoInvalidArgumentError('Unable to continue SCRAM without valid nonce'));
133
+ throw new MongoInvalidArgumentError('Unable to continue SCRAM without valid nonce');
146
134
  }
147
135
  const nonce = authContext.nonce;
148
136
 
@@ -154,11 +142,7 @@ function continueScramConversation(
154
142
  if (cryptoMethod === 'sha256') {
155
143
  processedPassword = 'kModuleError' in saslprep ? password : saslprep(password);
156
144
  } else {
157
- try {
158
- processedPassword = passwordDigest(username, password);
159
- } catch (e) {
160
- return callback(e);
161
- }
145
+ processedPassword = passwordDigest(username, password);
162
146
  }
163
147
 
164
148
  const payload = Buffer.isBuffer(response.payload)
@@ -168,20 +152,15 @@ function continueScramConversation(
168
152
 
169
153
  const iterations = parseInt(dict.i, 10);
170
154
  if (iterations && iterations < 4096) {
171
- callback(
172
- // TODO(NODE-3483)
173
- new MongoRuntimeError(`Server returned an invalid iteration count ${iterations}`),
174
- false
175
- );
176
- return;
155
+ // TODO(NODE-3483)
156
+ throw new MongoRuntimeError(`Server returned an invalid iteration count ${iterations}`);
177
157
  }
178
158
 
179
159
  const salt = dict.s;
180
160
  const rnonce = dict.r;
181
161
  if (rnonce.startsWith('nonce')) {
182
162
  // TODO(NODE-3483)
183
- callback(new MongoRuntimeError(`Server returned an invalid nonce: ${rnonce}`), false);
184
- return;
163
+ throw new MongoRuntimeError(`Server returned an invalid nonce: ${rnonce}`);
185
164
  }
186
165
 
187
166
  // Set up start of proof
@@ -211,30 +190,25 @@ function continueScramConversation(
211
190
  payload: new Binary(Buffer.from(clientFinal))
212
191
  };
213
192
 
214
- connection.command(ns(`${db}.$cmd`), saslContinueCmd, undefined, (_err, r) => {
215
- const err = resolveError(_err, r);
216
- if (err) {
217
- return callback(err);
218
- }
193
+ const r = await connection.commandAsync(ns(`${db}.$cmd`), saslContinueCmd, undefined);
194
+ const parsedResponse = parsePayload(r.payload.value());
219
195
 
220
- const parsedResponse = parsePayload(r.payload.value());
221
- if (!compareDigest(Buffer.from(parsedResponse.v, 'base64'), serverSignature)) {
222
- callback(new MongoRuntimeError('Server returned an invalid signature'));
223
- return;
224
- }
196
+ if (!compareDigest(Buffer.from(parsedResponse.v, 'base64'), serverSignature)) {
197
+ throw new MongoRuntimeError('Server returned an invalid signature');
198
+ }
225
199
 
226
- if (!r || r.done !== false) {
227
- return callback(err, r);
228
- }
200
+ if (r.done !== false) {
201
+ // If the server sends r.done === true we can save one RTT
202
+ return;
203
+ }
229
204
 
230
- const retrySaslContinueCmd = {
231
- saslContinue: 1,
232
- conversationId: r.conversationId,
233
- payload: Buffer.alloc(0)
234
- };
205
+ const retrySaslContinueCmd = {
206
+ saslContinue: 1,
207
+ conversationId: r.conversationId,
208
+ payload: Buffer.alloc(0)
209
+ };
235
210
 
236
- connection.command(ns(`${db}.$cmd`), retrySaslContinueCmd, undefined, callback);
237
- });
211
+ await connection.commandAsync(ns(`${db}.$cmd`), retrySaslContinueCmd, undefined);
238
212
  }
239
213
 
240
214
  function parsePayload(payload: string) {
@@ -363,14 +337,6 @@ function compareDigest(lhs: Buffer, rhs: Uint8Array) {
363
337
  return result === 0;
364
338
  }
365
339
 
366
- function resolveError(err?: AnyError, result?: Document) {
367
- if (err) return err;
368
- if (result) {
369
- if (result.$err || result.errmsg) return new MongoServerError(result);
370
- }
371
- return;
372
- }
373
-
374
340
  export class ScramSHA1 extends ScramSHA {
375
341
  constructor() {
376
342
  super('sha1');
@@ -1,44 +1,38 @@
1
1
  import type { Document } from '../../bson';
2
2
  import { MongoMissingCredentialsError } from '../../error';
3
- import { Callback, ns } from '../../utils';
3
+ import { ns } from '../../utils';
4
4
  import type { HandshakeDocument } from '../connect';
5
5
  import { AuthContext, AuthProvider } from './auth_provider';
6
6
  import type { MongoCredentials } from './mongo_credentials';
7
7
 
8
8
  export class X509 extends AuthProvider {
9
- override prepare(
9
+ override async prepare(
10
10
  handshakeDoc: HandshakeDocument,
11
- authContext: AuthContext,
12
- callback: Callback
13
- ): void {
11
+ authContext: AuthContext
12
+ ): Promise<HandshakeDocument> {
14
13
  const { credentials } = authContext;
15
14
  if (!credentials) {
16
- return callback(new MongoMissingCredentialsError('AuthContext must provide credentials.'));
15
+ throw new MongoMissingCredentialsError('AuthContext must provide credentials.');
17
16
  }
18
- Object.assign(handshakeDoc, {
19
- speculativeAuthenticate: x509AuthenticateCommand(credentials)
20
- });
21
-
22
- callback(undefined, handshakeDoc);
17
+ return { ...handshakeDoc, speculativeAuthenticate: x509AuthenticateCommand(credentials) };
23
18
  }
24
19
 
25
- override auth(authContext: AuthContext, callback: Callback): void {
20
+ override async auth(authContext: AuthContext) {
26
21
  const connection = authContext.connection;
27
22
  const credentials = authContext.credentials;
28
23
  if (!credentials) {
29
- return callback(new MongoMissingCredentialsError('AuthContext must provide credentials.'));
24
+ throw new MongoMissingCredentialsError('AuthContext must provide credentials.');
30
25
  }
31
26
  const response = authContext.response;
32
27
 
33
- if (response && response.speculativeAuthenticate) {
34
- return callback();
28
+ if (response?.speculativeAuthenticate) {
29
+ return;
35
30
  }
36
31
 
37
- connection.command(
32
+ await connection.commandAsync(
38
33
  ns('$external.$cmd'),
39
34
  x509AuthenticateCommand(credentials),
40
- undefined,
41
- callback
35
+ undefined
42
36
  );
43
37
  }
44
38
  }
@@ -149,8 +149,11 @@ export class CommandFailedEvent {
149
149
  }
150
150
  }
151
151
 
152
- /** Commands that we want to redact because of the sensitive nature of their contents */
153
- const SENSITIVE_COMMANDS = new Set([
152
+ /**
153
+ * Commands that we want to redact because of the sensitive nature of their contents
154
+ * @internal
155
+ */
156
+ export const SENSITIVE_COMMANDS = new Set([
154
157
  'authenticate',
155
158
  'saslStart',
156
159
  'saslContinue',
@@ -304,6 +304,7 @@ export class Response {
304
304
  queryFailure?: boolean;
305
305
  shardConfigStale?: boolean;
306
306
  awaitCapable?: boolean;
307
+ useBigInt64: boolean;
307
308
  promoteLongs: boolean;
308
309
  promoteValues: boolean;
309
310
  promoteBuffers: boolean;
@@ -320,6 +321,7 @@ export class Response {
320
321
  this.raw = message;
321
322
  this.data = msgBody;
322
323
  this.opts = opts ?? {
324
+ useBigInt64: false,
323
325
  promoteLongs: true,
324
326
  promoteValues: true,
325
327
  promoteBuffers: false,
@@ -334,6 +336,7 @@ export class Response {
334
336
  this.fromCompressed = msgHeader.fromCompressed;
335
337
 
336
338
  // Flag values
339
+ this.useBigInt64 = typeof this.opts.useBigInt64 === 'boolean' ? this.opts.useBigInt64 : false;
337
340
  this.promoteLongs = typeof this.opts.promoteLongs === 'boolean' ? this.opts.promoteLongs : true;
338
341
  this.promoteValues =
339
342
  typeof this.opts.promoteValues === 'boolean' ? this.opts.promoteValues : true;
@@ -354,6 +357,7 @@ export class Response {
354
357
  // Allow the return of raw documents instead of parsing
355
358
  const raw = options.raw || false;
356
359
  const documentsReturnedIn = options.documentsReturnedIn || null;
360
+ const useBigInt64 = options.useBigInt64 ?? this.opts.useBigInt64;
357
361
  const promoteLongs = options.promoteLongs ?? this.opts.promoteLongs;
358
362
  const promoteValues = options.promoteValues ?? this.opts.promoteValues;
359
363
  const promoteBuffers = options.promoteBuffers ?? this.opts.promoteBuffers;
@@ -362,6 +366,7 @@ export class Response {
362
366
 
363
367
  // Set up the options
364
368
  const _options: BSONSerializeOptions = {
369
+ useBigInt64,
365
370
  promoteLongs,
366
371
  promoteValues,
367
372
  promoteBuffers,
@@ -369,7 +374,7 @@ export class Response {
369
374
  };
370
375
 
371
376
  // Position within OP_REPLY at which documents start
372
- // (See https://docs.mongodb.com/manual/reference/mongodb-wire-protocol/#wire-op-reply)
377
+ // (See https://www.mongodb.com/docs/manual/reference/mongodb-wire-protocol/#wire-op-reply)
373
378
  this.index = 20;
374
379
 
375
380
  // Read the message body
@@ -590,6 +595,7 @@ export class BinMsg {
590
595
  checksumPresent: boolean;
591
596
  moreToCome: boolean;
592
597
  exhaustAllowed: boolean;
598
+ useBigInt64: boolean;
593
599
  promoteLongs: boolean;
594
600
  promoteValues: boolean;
595
601
  promoteBuffers: boolean;
@@ -607,6 +613,7 @@ export class BinMsg {
607
613
  this.raw = message;
608
614
  this.data = msgBody;
609
615
  this.opts = opts ?? {
616
+ useBigInt64: false,
610
617
  promoteLongs: true,
611
618
  promoteValues: true,
612
619
  promoteBuffers: false,
@@ -625,6 +632,7 @@ export class BinMsg {
625
632
  this.checksumPresent = (this.responseFlags & OPTS_CHECKSUM_PRESENT) !== 0;
626
633
  this.moreToCome = (this.responseFlags & OPTS_MORE_TO_COME) !== 0;
627
634
  this.exhaustAllowed = (this.responseFlags & OPTS_EXHAUST_ALLOWED) !== 0;
635
+ this.useBigInt64 = typeof this.opts.useBigInt64 === 'boolean' ? this.opts.useBigInt64 : false;
628
636
  this.promoteLongs = typeof this.opts.promoteLongs === 'boolean' ? this.opts.promoteLongs : true;
629
637
  this.promoteValues =
630
638
  typeof this.opts.promoteValues === 'boolean' ? this.opts.promoteValues : true;
@@ -648,6 +656,7 @@ export class BinMsg {
648
656
  // Allow the return of raw documents instead of parsing
649
657
  const raw = options.raw || false;
650
658
  const documentsReturnedIn = options.documentsReturnedIn || null;
659
+ const useBigInt64 = options.useBigInt64 ?? this.opts.useBigInt64;
651
660
  const promoteLongs = options.promoteLongs ?? this.opts.promoteLongs;
652
661
  const promoteValues = options.promoteValues ?? this.opts.promoteValues;
653
662
  const promoteBuffers = options.promoteBuffers ?? this.opts.promoteBuffers;
@@ -656,6 +665,7 @@ export class BinMsg {
656
665
 
657
666
  // Set up the options
658
667
  const bsonOptions: BSONSerializeOptions = {
668
+ useBigInt64,
659
669
  promoteLongs,
660
670
  promoteValues,
661
671
  promoteBuffers,