mongodb 6.7.0-dev.20240608.sha.0655c730 → 6.7.0-dev.20240614.sha.3ed6a2ad

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 (96) hide show
  1. package/lib/bson.js.map +1 -1
  2. package/lib/client-side-encryption/auto_encrypter.js +8 -61
  3. package/lib/client-side-encryption/auto_encrypter.js.map +1 -1
  4. package/lib/client-side-encryption/client_encryption.js +5 -5
  5. package/lib/client-side-encryption/client_encryption.js.map +1 -1
  6. package/lib/client-side-encryption/providers/index.js.map +1 -1
  7. package/lib/client-side-encryption/state_machine.js +15 -11
  8. package/lib/client-side-encryption/state_machine.js.map +1 -1
  9. package/lib/cmap/connection.js +22 -20
  10. package/lib/cmap/connection.js.map +1 -1
  11. package/lib/cmap/wire_protocol/on_demand/document.js +8 -5
  12. package/lib/cmap/wire_protocol/on_demand/document.js.map +1 -1
  13. package/lib/cmap/wire_protocol/responses.js +116 -40
  14. package/lib/cmap/wire_protocol/responses.js.map +1 -1
  15. package/lib/constants.js +9 -1
  16. package/lib/constants.js.map +1 -1
  17. package/lib/cursor/abstract_cursor.js +24 -60
  18. package/lib/cursor/abstract_cursor.js.map +1 -1
  19. package/lib/cursor/aggregation_cursor.js +2 -3
  20. package/lib/cursor/aggregation_cursor.js.map +1 -1
  21. package/lib/cursor/change_stream_cursor.js +6 -8
  22. package/lib/cursor/change_stream_cursor.js.map +1 -1
  23. package/lib/cursor/find_cursor.js +5 -17
  24. package/lib/cursor/find_cursor.js.map +1 -1
  25. package/lib/cursor/list_collections_cursor.js +0 -1
  26. package/lib/cursor/list_collections_cursor.js.map +1 -1
  27. package/lib/cursor/list_indexes_cursor.js +0 -1
  28. package/lib/cursor/list_indexes_cursor.js.map +1 -1
  29. package/lib/cursor/run_command_cursor.js +4 -6
  30. package/lib/cursor/run_command_cursor.js.map +1 -1
  31. package/lib/error.js +6 -21
  32. package/lib/error.js.map +1 -1
  33. package/lib/index.js.map +1 -1
  34. package/lib/operations/aggregate.js +2 -2
  35. package/lib/operations/aggregate.js.map +1 -1
  36. package/lib/operations/bulk_write.js +1 -2
  37. package/lib/operations/bulk_write.js.map +1 -1
  38. package/lib/operations/command.js +2 -3
  39. package/lib/operations/command.js.map +1 -1
  40. package/lib/operations/count_documents.js +1 -7
  41. package/lib/operations/count_documents.js.map +1 -1
  42. package/lib/operations/execute_operation.js.map +1 -1
  43. package/lib/operations/find.js +2 -1
  44. package/lib/operations/find.js.map +1 -1
  45. package/lib/operations/get_more.js +1 -1
  46. package/lib/operations/get_more.js.map +1 -1
  47. package/lib/operations/indexes.js +2 -1
  48. package/lib/operations/indexes.js.map +1 -1
  49. package/lib/operations/list_collections.js +2 -1
  50. package/lib/operations/list_collections.js.map +1 -1
  51. package/lib/operations/run_command.js +1 -1
  52. package/lib/operations/run_command.js.map +1 -1
  53. package/lib/operations/update.js +2 -1
  54. package/lib/operations/update.js.map +1 -1
  55. package/lib/sdam/server.js +7 -2
  56. package/lib/sdam/server.js.map +1 -1
  57. package/lib/utils.js +45 -1
  58. package/lib/utils.js.map +1 -1
  59. package/lib/write_concern.js +17 -1
  60. package/lib/write_concern.js.map +1 -1
  61. package/mongodb.d.ts +120 -85
  62. package/package.json +1 -1
  63. package/src/bson.ts +1 -0
  64. package/src/client-side-encryption/auto_encrypter.ts +9 -70
  65. package/src/client-side-encryption/client_encryption.ts +6 -6
  66. package/src/client-side-encryption/providers/index.ts +120 -92
  67. package/src/client-side-encryption/state_machine.ts +22 -18
  68. package/src/cmap/connection.ts +46 -50
  69. package/src/cmap/wire_protocol/on_demand/document.ts +13 -6
  70. package/src/cmap/wire_protocol/responses.ts +140 -45
  71. package/src/constants.ts +9 -0
  72. package/src/cursor/abstract_cursor.ts +51 -71
  73. package/src/cursor/aggregation_cursor.ts +13 -12
  74. package/src/cursor/change_stream_cursor.ts +20 -34
  75. package/src/cursor/find_cursor.ts +17 -25
  76. package/src/cursor/list_collections_cursor.ts +3 -4
  77. package/src/cursor/list_indexes_cursor.ts +3 -4
  78. package/src/cursor/run_command_cursor.ts +13 -19
  79. package/src/error.ts +16 -28
  80. package/src/index.ts +12 -8
  81. package/src/operations/aggregate.ts +12 -5
  82. package/src/operations/bulk_write.ts +1 -2
  83. package/src/operations/command.ts +17 -3
  84. package/src/operations/count_documents.ts +7 -11
  85. package/src/operations/delete.ts +2 -2
  86. package/src/operations/execute_operation.ts +0 -13
  87. package/src/operations/find.ts +7 -3
  88. package/src/operations/find_and_modify.ts +1 -1
  89. package/src/operations/get_more.ts +6 -10
  90. package/src/operations/indexes.ts +7 -3
  91. package/src/operations/list_collections.ts +8 -3
  92. package/src/operations/run_command.ts +16 -6
  93. package/src/operations/update.ts +2 -1
  94. package/src/sdam/server.ts +7 -2
  95. package/src/utils.ts +52 -2
  96. package/src/write_concern.ts +18 -0
package/mongodb.d.ts CHANGED
@@ -735,6 +735,23 @@ export declare interface AWSEncryptionKeyOptions {
735
735
  endpoint?: string | undefined;
736
736
  }
737
737
 
738
+ /** @public */
739
+ export declare interface AWSKMSProviderConfiguration {
740
+ /**
741
+ * The access key used for the AWS KMS provider
742
+ */
743
+ accessKeyId: string;
744
+ /**
745
+ * The secret access key used for the AWS KMS provider
746
+ */
747
+ secretAccessKey: string;
748
+ /**
749
+ * An optional AWS session token that will be used as the
750
+ * X-Amz-Security-Token header for AWS requests.
751
+ */
752
+ sessionToken?: string;
753
+ }
754
+
738
755
  /**
739
756
  * @public
740
757
  * Configuration options for making an Azure encryption key
@@ -754,6 +771,34 @@ export declare interface AzureEncryptionKeyOptions {
754
771
  keyVersion?: string | undefined;
755
772
  }
756
773
 
774
+ /** @public */
775
+ export declare type AzureKMSProviderConfiguration = {
776
+ /**
777
+ * The tenant ID identifies the organization for the account
778
+ */
779
+ tenantId: string;
780
+ /**
781
+ * The client ID to authenticate a registered application
782
+ */
783
+ clientId: string;
784
+ /**
785
+ * The client secret to authenticate a registered application
786
+ */
787
+ clientSecret: string;
788
+ /**
789
+ * If present, a host with optional port. E.g. "example.com" or "example.com:443".
790
+ * This is optional, and only needed if customer is using a non-commercial Azure instance
791
+ * (e.g. a government or China account, which use different URLs).
792
+ * Defaults to "login.microsoftonline.com"
793
+ */
794
+ identityPlatformEndpoint?: string | undefined;
795
+ } | {
796
+ /**
797
+ * If present, an access token to authenticate with Azure.
798
+ */
799
+ accessToken: string;
800
+ };
801
+
757
802
  /**
758
803
  * Keeps the state of a unordered batch so we can rewrite the results
759
804
  * correctly after command execution
@@ -788,6 +833,7 @@ export declare type BitwiseFilter = number /** numeric bit mask */ | Binary /**
788
833
 
789
834
  export { BSON }
790
835
 
836
+ /* Excluded from this release type: BSONElement */
791
837
  export { BSONRegExp }
792
838
 
793
839
  /**
@@ -1078,8 +1124,6 @@ export declare class ChangeStream<TSchema extends Document = Document, TChange e
1078
1124
  /* Excluded from this release type: _processErrorIteratorMode */
1079
1125
  }
1080
1126
 
1081
- /* Excluded from this release type: ChangeStreamAggregateRawResult */
1082
-
1083
1127
  /**
1084
1128
  * Only present when the `showExpandedEvents` flag is enabled.
1085
1129
  * @public
@@ -1770,8 +1814,15 @@ export declare interface ClientEncryptionCreateDataKeyProviderOptions {
1770
1814
 
1771
1815
  /**
1772
1816
  * @public
1817
+ *
1818
+ * A data key provider. Allowed values:
1819
+ *
1820
+ * - aws, gcp, local, kmip or azure
1821
+ * - (`mongodb-client-encryption>=6.0.1` only) a named key, in the form of:
1822
+ * `aws:<name>`, `gcp:<name>`, `local:<name>`, `kmip:<name>`, `azure:<name>`
1823
+ * where `name` is an alphanumeric string, underscores allowed.
1773
1824
  */
1774
- export declare type ClientEncryptionDataKeyProvider = 'aws' | 'azure' | 'gcp' | 'local' | 'kmip';
1825
+ export declare type ClientEncryptionDataKeyProvider = string;
1775
1826
 
1776
1827
  /**
1777
1828
  * @public
@@ -3163,6 +3214,7 @@ export declare type CSFLEKMSTlsOptions = {
3163
3214
  kmip?: ClientEncryptionTlsOptions;
3164
3215
  local?: ClientEncryptionTlsOptions;
3165
3216
  azure?: ClientEncryptionTlsOptions;
3217
+ [key: string]: ClientEncryptionTlsOptions | undefined;
3166
3218
  };
3167
3219
 
3168
3220
  /** @public */
@@ -3577,8 +3629,6 @@ export declare type EventEmitterWithState = {
3577
3629
  */
3578
3630
  export declare type EventsDescription = Record<string, GenericListener>;
3579
3631
 
3580
- /* Excluded from this release type: ExecutionResult */
3581
-
3582
3632
  /* Excluded from this release type: Explain */
3583
3633
 
3584
3634
  /** @public */
@@ -3985,6 +4035,28 @@ export declare interface GCPEncryptionKeyOptions {
3985
4035
  endpoint?: string | undefined;
3986
4036
  }
3987
4037
 
4038
+ /** @public */
4039
+ export declare type GCPKMSProviderConfiguration = {
4040
+ /**
4041
+ * The service account email to authenticate
4042
+ */
4043
+ email: string;
4044
+ /**
4045
+ * A PKCS#8 encrypted key. This can either be a base64 string or a binary representation
4046
+ */
4047
+ privateKey: string | Buffer;
4048
+ /**
4049
+ * If present, a host with optional port. E.g. "example.com" or "example.com:443".
4050
+ * Defaults to "oauth2.googleapis.com"
4051
+ */
4052
+ endpoint?: string | undefined;
4053
+ } | {
4054
+ /**
4055
+ * If present, an access token to authenticate with GCP.
4056
+ */
4057
+ accessToken: string;
4058
+ };
4059
+
3988
4060
  /** @public */
3989
4061
  export declare type GenericListener = (...args: any[]) => void;
3990
4062
 
@@ -4376,6 +4448,8 @@ export declare type InferIdType<TSchema> = TSchema extends {
4376
4448
  _id?: infer IdType;
4377
4449
  } ? unknown extends IdType ? ObjectId : IdType : ObjectId;
4378
4450
 
4451
+ /* Excluded from this release type: InitialCursorResponse */
4452
+
4379
4453
  /** @public */
4380
4454
  export declare interface InsertManyResult<TSchema = Document> {
4381
4455
  /** Indicates whether this write result was acknowledged. If not, then all other members of this result will be undefined */
@@ -4493,6 +4567,16 @@ export declare interface KMIPEncryptionKeyOptions {
4493
4567
  delegated?: boolean;
4494
4568
  }
4495
4569
 
4570
+ /** @public */
4571
+ export declare interface KMIPKMSProviderConfiguration {
4572
+ /**
4573
+ * The output endpoint string.
4574
+ * The endpoint consists of a hostname and port separated by a colon.
4575
+ * E.g. "example.com:123". A port is always present.
4576
+ */
4577
+ endpoint?: string;
4578
+ }
4579
+
4496
4580
  /* Excluded from this release type: kMode */
4497
4581
 
4498
4582
  /* Excluded from this release type: kMonitorId */
@@ -4500,99 +4584,31 @@ export declare interface KMIPEncryptionKeyOptions {
4500
4584
  /**
4501
4585
  * @public
4502
4586
  * Configuration options that are used by specific KMS providers during key generation, encryption, and decryption.
4587
+ *
4588
+ * Named KMS providers _are not supported_ for automatic KMS credential fetching.
4503
4589
  */
4504
4590
  export declare interface KMSProviders {
4505
4591
  /**
4506
4592
  * Configuration options for using 'aws' as your KMS provider
4507
4593
  */
4508
- aws?: {
4509
- /**
4510
- * The access key used for the AWS KMS provider
4511
- */
4512
- accessKeyId: string;
4513
- /**
4514
- * The secret access key used for the AWS KMS provider
4515
- */
4516
- secretAccessKey: string;
4517
- /**
4518
- * An optional AWS session token that will be used as the
4519
- * X-Amz-Security-Token header for AWS requests.
4520
- */
4521
- sessionToken?: string;
4522
- } | Record<string, never>;
4594
+ aws?: AWSKMSProviderConfiguration | Record<string, never>;
4523
4595
  /**
4524
4596
  * Configuration options for using 'local' as your KMS provider
4525
4597
  */
4526
- local?: {
4527
- /**
4528
- * The master key used to encrypt/decrypt data keys.
4529
- * A 96-byte long Buffer or base64 encoded string.
4530
- */
4531
- key: Buffer | string;
4532
- };
4598
+ local?: LocalKMSProviderConfiguration;
4533
4599
  /**
4534
4600
  * Configuration options for using 'kmip' as your KMS provider
4535
4601
  */
4536
- kmip?: {
4537
- /**
4538
- * The output endpoint string.
4539
- * The endpoint consists of a hostname and port separated by a colon.
4540
- * E.g. "example.com:123". A port is always present.
4541
- */
4542
- endpoint?: string;
4543
- };
4602
+ kmip?: KMIPKMSProviderConfiguration;
4544
4603
  /**
4545
4604
  * Configuration options for using 'azure' as your KMS provider
4546
4605
  */
4547
- azure?: {
4548
- /**
4549
- * The tenant ID identifies the organization for the account
4550
- */
4551
- tenantId: string;
4552
- /**
4553
- * The client ID to authenticate a registered application
4554
- */
4555
- clientId: string;
4556
- /**
4557
- * The client secret to authenticate a registered application
4558
- */
4559
- clientSecret: string;
4560
- /**
4561
- * If present, a host with optional port. E.g. "example.com" or "example.com:443".
4562
- * This is optional, and only needed if customer is using a non-commercial Azure instance
4563
- * (e.g. a government or China account, which use different URLs).
4564
- * Defaults to "login.microsoftonline.com"
4565
- */
4566
- identityPlatformEndpoint?: string | undefined;
4567
- } | {
4568
- /**
4569
- * If present, an access token to authenticate with Azure.
4570
- */
4571
- accessToken: string;
4572
- } | Record<string, never>;
4606
+ azure?: AzureKMSProviderConfiguration | Record<string, never>;
4573
4607
  /**
4574
4608
  * Configuration options for using 'gcp' as your KMS provider
4575
4609
  */
4576
- gcp?: {
4577
- /**
4578
- * The service account email to authenticate
4579
- */
4580
- email: string;
4581
- /**
4582
- * A PKCS#8 encrypted key. This can either be a base64 string or a binary representation
4583
- */
4584
- privateKey: string | Buffer;
4585
- /**
4586
- * If present, a host with optional port. E.g. "example.com" or "example.com:443".
4587
- * Defaults to "oauth2.googleapis.com"
4588
- */
4589
- endpoint?: string | undefined;
4590
- } | {
4591
- /**
4592
- * If present, an access token to authenticate with GCP.
4593
- */
4594
- accessToken: string;
4595
- } | Record<string, never>;
4610
+ gcp?: GCPKMSProviderConfiguration | Record<string, never>;
4611
+ [key: string]: AWSKMSProviderConfiguration | LocalKMSProviderConfiguration | KMIPKMSProviderConfiguration | AzureKMSProviderConfiguration | GCPKMSProviderConfiguration | undefined;
4596
4612
  }
4597
4613
 
4598
4614
  /* Excluded from this release type: kOptions */
@@ -4699,6 +4715,15 @@ export declare class ListSearchIndexesCursor extends AggregationCursor<{
4699
4715
  /** @public */
4700
4716
  export declare type ListSearchIndexesOptions = Omit<AggregateOptions, 'readConcern' | 'writeConcern'>;
4701
4717
 
4718
+ /** @public */
4719
+ export declare interface LocalKMSProviderConfiguration {
4720
+ /**
4721
+ * The master key used to encrypt/decrypt data keys.
4722
+ * A 96-byte long Buffer or base64 encoded string.
4723
+ */
4724
+ key: Buffer | string;
4725
+ }
4726
+
4702
4727
  /* Excluded from this release type: Log */
4703
4728
 
4704
4729
  /* Excluded from this release type: LogComponentSeveritiesClientOptions */
@@ -6175,7 +6200,9 @@ export declare class MongoUnexpectedServerResponseError extends MongoRuntimeErro
6175
6200
  *
6176
6201
  * @public
6177
6202
  **/
6178
- constructor(message: string);
6203
+ constructor(message: string, options?: {
6204
+ cause?: Error;
6205
+ });
6179
6206
  get name(): string;
6180
6207
  }
6181
6208
 
@@ -6185,8 +6212,8 @@ export declare class MongoUnexpectedServerResponseError extends MongoRuntimeErro
6185
6212
  * @category Error
6186
6213
  */
6187
6214
  export declare class MongoWriteConcernError extends MongoServerError {
6188
- /** The result document (provided if ok: 1) */
6189
- result?: Document;
6215
+ /** The result document */
6216
+ result: Document;
6190
6217
  /**
6191
6218
  * **Do not use this constructor!**
6192
6219
  *
@@ -6198,7 +6225,15 @@ export declare class MongoWriteConcernError extends MongoServerError {
6198
6225
  *
6199
6226
  * @public
6200
6227
  **/
6201
- constructor(message: ErrorDescription, result?: Document);
6228
+ constructor(result: {
6229
+ writeConcernError: {
6230
+ code: number;
6231
+ errmsg: string;
6232
+ codeName?: string;
6233
+ errInfo?: Document;
6234
+ };
6235
+ errorLabels?: string[];
6236
+ });
6202
6237
  get name(): string;
6203
6238
  }
6204
6239
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongodb",
3
- "version": "6.7.0-dev.20240608.sha.0655c730",
3
+ "version": "6.7.0-dev.20240614.sha.3ed6a2ad",
4
4
  "description": "The official MongoDB driver for Node.js",
5
5
  "main": "lib/index.js",
6
6
  "files": [
package/src/bson.ts CHANGED
@@ -27,6 +27,7 @@ export {
27
27
  UUID
28
28
  } from 'bson';
29
29
 
30
+ /** @internal */
30
31
  export type BSONElement = BSON.OnDemand['BSONElement'];
31
32
 
32
33
  export function parseToElementsToArray(bytes: Uint8Array, offset?: number): BSONElement[] {
@@ -6,6 +6,7 @@ import {
6
6
 
7
7
  import { deserialize, type Document, serialize } from '../bson';
8
8
  import { type CommandOptions, type ProxyOptions } from '../cmap/connection';
9
+ import { kDecorateResult } from '../constants';
9
10
  import { getMongoDBClientEncryption } from '../deps';
10
11
  import { MongoRuntimeError } from '../error';
11
12
  import { MongoClient, type MongoClientOptions } from '../mongo_client';
@@ -212,15 +213,6 @@ export const AutoEncryptionLoggerLevel = Object.freeze({
212
213
  export type AutoEncryptionLoggerLevel =
213
214
  (typeof AutoEncryptionLoggerLevel)[keyof typeof AutoEncryptionLoggerLevel];
214
215
 
215
- // Typescript errors if we index objects with `Symbol.for(...)`, so
216
- // to avoid TS errors we pull them out into variables. Then we can type
217
- // the objects (and class) that we expect to see them on and prevent TS
218
- // errors.
219
- /** @internal */
220
- const kDecorateResult = Symbol.for('@@mdb.decorateDecryptionResult');
221
- /** @internal */
222
- const kDecoratedKeys = Symbol.for('@@mdb.decryptedKeys');
223
-
224
216
  /**
225
217
  * @internal An internal class to be used by the driver for auto encryption
226
218
  * **NOTE**: Not meant to be instantiated directly, this is for internal use only.
@@ -467,16 +459,18 @@ export class AutoEncrypter {
467
459
  proxyOptions: this._proxyOptions,
468
460
  tlsOptions: this._tlsOptions
469
461
  });
470
- return await stateMachine.execute<Document>(this, context);
462
+
463
+ return deserialize(await stateMachine.execute(this, context), {
464
+ promoteValues: false,
465
+ promoteLongs: false
466
+ });
471
467
  }
472
468
 
473
469
  /**
474
470
  * Decrypt a command response
475
471
  */
476
- async decrypt(response: Uint8Array | Document, options: CommandOptions = {}): Promise<Document> {
477
- const buffer = Buffer.isBuffer(response) ? response : serialize(response, options);
478
-
479
- const context = this._mongocrypt.makeDecryptionContext(buffer);
472
+ async decrypt(response: Uint8Array, options: CommandOptions = {}): Promise<Uint8Array> {
473
+ const context = this._mongocrypt.makeDecryptionContext(response);
480
474
 
481
475
  context.id = this._contextCounter++;
482
476
 
@@ -486,12 +480,7 @@ export class AutoEncrypter {
486
480
  tlsOptions: this._tlsOptions
487
481
  });
488
482
 
489
- const decorateResult = this[kDecorateResult];
490
- const result = await stateMachine.execute<Document>(this, context);
491
- if (decorateResult) {
492
- decorateDecryptionResult(result, response);
493
- }
494
- return result;
483
+ return await stateMachine.execute(this, context);
495
484
  }
496
485
 
497
486
  /**
@@ -518,53 +507,3 @@ export class AutoEncrypter {
518
507
  return AutoEncrypter.getMongoCrypt().libmongocryptVersion;
519
508
  }
520
509
  }
521
-
522
- /**
523
- * Recurse through the (identically-shaped) `decrypted` and `original`
524
- * objects and attach a `decryptedKeys` property on each sub-object that
525
- * contained encrypted fields. Because we only call this on BSON responses,
526
- * we do not need to worry about circular references.
527
- *
528
- * @internal
529
- */
530
- function decorateDecryptionResult(
531
- decrypted: Document & { [kDecoratedKeys]?: Array<string> },
532
- original: Document,
533
- isTopLevelDecorateCall = true
534
- ): void {
535
- if (isTopLevelDecorateCall) {
536
- // The original value could have been either a JS object or a BSON buffer
537
- if (Buffer.isBuffer(original)) {
538
- original = deserialize(original);
539
- }
540
- if (Buffer.isBuffer(decrypted)) {
541
- throw new MongoRuntimeError('Expected result of decryption to be deserialized BSON object');
542
- }
543
- }
544
-
545
- if (!decrypted || typeof decrypted !== 'object') return;
546
- for (const k of Object.keys(decrypted)) {
547
- const originalValue = original[k];
548
-
549
- // An object was decrypted by libmongocrypt if and only if it was
550
- // a BSON Binary object with subtype 6.
551
- if (originalValue && originalValue._bsontype === 'Binary' && originalValue.sub_type === 6) {
552
- if (!decrypted[kDecoratedKeys]) {
553
- Object.defineProperty(decrypted, kDecoratedKeys, {
554
- value: [],
555
- configurable: true,
556
- enumerable: false,
557
- writable: false
558
- });
559
- }
560
- // this is defined in the preceding if-statement
561
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
562
- decrypted[kDecoratedKeys]!.push(k);
563
- // Do not recurse into this decrypted value. It could be a sub-document/array,
564
- // in which case there is no original value associated with its subfields.
565
- continue;
566
- }
567
-
568
- decorateDecryptionResult(decrypted[k], originalValue, false);
569
- }
570
- }
@@ -5,7 +5,7 @@ import type {
5
5
  MongoCryptOptions
6
6
  } from 'mongodb-client-encryption';
7
7
 
8
- import { type Binary, type Document, type Long, serialize, type UUID } from '../bson';
8
+ import { type Binary, deserialize, type Document, type Long, serialize, type UUID } from '../bson';
9
9
  import { type AnyBulkWriteOperation, type BulkWriteResult } from '../bulk/common';
10
10
  import { type ProxyOptions } from '../cmap/connection';
11
11
  import { type Collection } from '../collection';
@@ -202,7 +202,7 @@ export class ClientEncryption {
202
202
  tlsOptions: this._tlsOptions
203
203
  });
204
204
 
205
- const dataKey = await stateMachine.execute<DataKey>(this, context);
205
+ const dataKey = deserialize(await stateMachine.execute(this, context)) as DataKey;
206
206
 
207
207
  const { db: dbName, collection: collectionName } = MongoDBCollectionNamespace.fromString(
208
208
  this._keyVaultNamespace
@@ -259,7 +259,7 @@ export class ClientEncryption {
259
259
  tlsOptions: this._tlsOptions
260
260
  });
261
261
 
262
- const { v: dataKeys } = await stateMachine.execute<{ v: DataKey[] }>(this, context);
262
+ const { v: dataKeys } = deserialize(await stateMachine.execute(this, context));
263
263
  if (dataKeys.length === 0) {
264
264
  return {};
265
265
  }
@@ -640,7 +640,7 @@ export class ClientEncryption {
640
640
  tlsOptions: this._tlsOptions
641
641
  });
642
642
 
643
- const { v } = await stateMachine.execute<{ v: T }>(this, context);
643
+ const { v } = deserialize(await stateMachine.execute(this, context));
644
644
 
645
645
  return v;
646
646
  }
@@ -719,8 +719,8 @@ export class ClientEncryption {
719
719
  });
720
720
  const context = this._mongoCrypt.makeExplicitEncryptionContext(valueBuffer, contextOptions);
721
721
 
722
- const result = await stateMachine.execute<{ v: Binary }>(this, context);
723
- return result.v;
722
+ const { v } = deserialize(await stateMachine.execute(this, context));
723
+ return v;
724
724
  }
725
725
  }
726
726