@@ -11,6 +11,7 @@ import { kDecorateResult } from '../constants';
11
11
import { getMongoDBClientEncryption } from '../deps' ;
12
12
import { MongoRuntimeError } from '../error' ;
13
13
import { MongoClient , type MongoClientOptions } from '../mongo_client' ;
14
+ import { type Abortable } from '../mongo_types' ;
14
15
import { MongoDBCollectionNamespace } from '../utils' ;
15
16
import { autoSelectSocketOptions } from './client_encryption' ;
16
17
import * as cryptoCallbacks from './crypto_callbacks' ;
@@ -372,8 +373,10 @@ export class AutoEncrypter {
372
373
async encrypt (
373
374
ns : string ,
374
375
cmd : Document ,
375
- options : CommandOptions = { }
376
+ options : CommandOptions & Abortable = { }
376
377
) : Promise < Document | Uint8Array > {
378
+ options . signal ?. throwIfAborted ( ) ;
379
+
377
380
if ( this . _bypassEncryption ) {
378
381
// If `bypassAutoEncryption` has been specified, don't encrypt
379
382
return cmd ;
@@ -407,7 +410,12 @@ export class AutoEncrypter {
407
410
/**
408
411
* Decrypt a command response
409
412
*/
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
+
411
419
const context = this . _mongocrypt . makeDecryptionContext ( response ) ;
412
420
413
421
context . id = this . _contextCounter ++ ;
0 commit comments