Skip to content

Commit a0ecf05

Browse files
authored
Merge branch 'main' into NODE-6340
2 parents 94b5292 + 73def18 commit a0ecf05

39 files changed

+2434
-408
lines changed

.evergreen/config.yml

Lines changed: 0 additions & 54 deletions
Large diffs are not rendered by default.

.evergreen/generate_evergreen_tasks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function makeTask({ mongoVersion, topology, tags = [], auth = 'auth' }) {
7070
name: `test-${mongoVersion}-${topology}${auth === 'noauth' ? '-noauth' : ''}`,
7171
tags: [mongoVersion, topology, ...tags],
7272
commands: [
73-
updateExpansions({ NPM_VERSION: 9, VERSION: mongoVersion, TOPOLOGY: topology, AUTH: auth }),
73+
updateExpansions({ VERSION: mongoVersion, TOPOLOGY: topology, AUTH: auth }),
7474
{ func: 'install dependencies' },
7575
{ func: 'bootstrap mongo-orchestration' },
7676
{ func: 'bootstrap kms servers' },

.evergreen/install-dependencies.sh

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,8 @@ set -o errexit # Exit the script with error if any of the commands fail
77
## a full nodejs version, in the format v<major>.<minor>.patch
88
export NODE_LTS_VERSION=${NODE_LTS_VERSION:-16}
99
# npm version can be defined in the environment for cases where we need to install
10-
# a version lower than latest to support EOL Node versions.
11-
12-
# If NODE_LTS_VERSION is numeric and less than 18, default to 9, if less than 20, default to 10.
13-
# Do not override if it is already set.
14-
if [[ "$NODE_LTS_VERSION" =~ ^[0-9]+$ && "$NODE_LTS_VERSION" -lt 18 ]]; then
15-
export NPM_VERSION=${NPM_VERSION:-9}
16-
elif [[ "$NODE_LTS_VERSION" =~ ^[0-9]+$ && "$NODE_LTS_VERSION" -lt 20 ]]; then
17-
export NPM_VERSION=${NPM_VERSION:-10}
18-
else
19-
export NPM_VERSION=${NPM_VERSION:-latest}
20-
fi
21-
10+
# a version lower than latest to support EOL Node versions. When not provided will
11+
# be handled by this script in drivers tools.
2212
source $DRIVERS_TOOLS/.evergreen/install-node.sh
2313

2414
npm install "${NPM_OPTIONS}"

src/client-side-encryption/auto_encrypter.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { kDecorateResult } from '../constants';
1111
import { getMongoDBClientEncryption } from '../deps';
1212
import { MongoRuntimeError } from '../error';
1313
import { MongoClient, type MongoClientOptions } from '../mongo_client';
14+
import { type Abortable } from '../mongo_types';
1415
import { MongoDBCollectionNamespace } from '../utils';
1516
import { autoSelectSocketOptions } from './client_encryption';
1617
import * as cryptoCallbacks from './crypto_callbacks';
@@ -372,8 +373,10 @@ export class AutoEncrypter {
372373
async encrypt(
373374
ns: string,
374375
cmd: Document,
375-
options: CommandOptions = {}
376+
options: CommandOptions & Abortable = {}
376377
): Promise<Document | Uint8Array> {
378+
options.signal?.throwIfAborted();
379+
377380
if (this._bypassEncryption) {
378381
// If `bypassAutoEncryption` has been specified, don't encrypt
379382
return cmd;
@@ -398,7 +401,7 @@ export class AutoEncrypter {
398401
socketOptions: autoSelectSocketOptions(this._client.s.options)
399402
});
400403

401-
return deserialize(await stateMachine.execute(this, context, options.timeoutContext), {
404+
return deserialize(await stateMachine.execute(this, context, options), {
402405
promoteValues: false,
403406
promoteLongs: false
404407
});
@@ -407,7 +410,12 @@ export class AutoEncrypter {
407410
/**
408411
* Decrypt a command response
409412
*/
410-
async decrypt(response: Uint8Array, options: CommandOptions = {}): Promise<Uint8Array> {
413+
async decrypt(
414+
response: Uint8Array,
415+
options: CommandOptions & Abortable = {}
416+
): Promise<Uint8Array> {
417+
options.signal?.throwIfAborted();
418+
411419
const context = this._mongocrypt.makeDecryptionContext(response);
412420

413421
context.id = this._contextCounter++;
@@ -419,11 +427,7 @@ export class AutoEncrypter {
419427
socketOptions: autoSelectSocketOptions(this._client.s.options)
420428
});
421429

422-
return await stateMachine.execute(
423-
this,
424-
context,
425-
options.timeoutContext?.csotEnabled() ? options.timeoutContext : undefined
426-
);
430+
return await stateMachine.execute(this, context, options);
427431
}
428432

429433
/**

src/client-side-encryption/client_encryption.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export class ClientEncryption {
225225
TimeoutContext.create(resolveTimeoutOptions(this._client, { timeoutMS: this._timeoutMS }));
226226

227227
const dataKey = deserialize(
228-
await stateMachine.execute(this, context, timeoutContext)
228+
await stateMachine.execute(this, context, { timeoutContext })
229229
) as DataKey;
230230

231231
const { db: dbName, collection: collectionName } = MongoDBCollectionNamespace.fromString(
@@ -293,7 +293,9 @@ export class ClientEncryption {
293293
resolveTimeoutOptions(this._client, { timeoutMS: this._timeoutMS })
294294
);
295295

296-
const { v: dataKeys } = deserialize(await stateMachine.execute(this, context, timeoutContext));
296+
const { v: dataKeys } = deserialize(
297+
await stateMachine.execute(this, context, { timeoutContext })
298+
);
297299
if (dataKeys.length === 0) {
298300
return {};
299301
}
@@ -696,7 +698,7 @@ export class ClientEncryption {
696698
? TimeoutContext.create(resolveTimeoutOptions(this._client, { timeoutMS: this._timeoutMS }))
697699
: undefined;
698700

699-
const { v } = deserialize(await stateMachine.execute(this, context, timeoutContext));
701+
const { v } = deserialize(await stateMachine.execute(this, context, { timeoutContext }));
700702

701703
return v;
702704
}
@@ -780,7 +782,7 @@ export class ClientEncryption {
780782
this._timeoutMS != null
781783
? TimeoutContext.create(resolveTimeoutOptions(this._client, { timeoutMS: this._timeoutMS }))
782784
: undefined;
783-
const { v } = deserialize(await stateMachine.execute(this, context, timeoutContext));
785+
const { v } = deserialize(await stateMachine.execute(this, context, { timeoutContext }));
784786
return v;
785787
}
786788
}

0 commit comments

Comments
 (0)