mongodb 6.7.0 → 6.8.0-dev.20240629.sha.d85f827a

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 (105) hide show
  1. package/README.md +29 -1
  2. package/lib/bson.js.map +1 -1
  3. package/lib/client-side-encryption/auto_encrypter.js +8 -61
  4. package/lib/client-side-encryption/auto_encrypter.js.map +1 -1
  5. package/lib/client-side-encryption/client_encryption.js +5 -5
  6. package/lib/client-side-encryption/client_encryption.js.map +1 -1
  7. package/lib/client-side-encryption/providers/index.js.map +1 -1
  8. package/lib/client-side-encryption/state_machine.js +15 -11
  9. package/lib/client-side-encryption/state_machine.js.map +1 -1
  10. package/lib/cmap/connection.js +22 -20
  11. package/lib/cmap/connection.js.map +1 -1
  12. package/lib/cmap/wire_protocol/constants.js +2 -2
  13. package/lib/cmap/wire_protocol/on_demand/document.js +8 -5
  14. package/lib/cmap/wire_protocol/on_demand/document.js.map +1 -1
  15. package/lib/cmap/wire_protocol/responses.js +116 -40
  16. package/lib/cmap/wire_protocol/responses.js.map +1 -1
  17. package/lib/collection.js +13 -2
  18. package/lib/collection.js.map +1 -1
  19. package/lib/constants.js +9 -1
  20. package/lib/constants.js.map +1 -1
  21. package/lib/cursor/abstract_cursor.js +231 -285
  22. package/lib/cursor/abstract_cursor.js.map +1 -1
  23. package/lib/cursor/aggregation_cursor.js +11 -19
  24. package/lib/cursor/aggregation_cursor.js.map +1 -1
  25. package/lib/cursor/change_stream_cursor.js +12 -14
  26. package/lib/cursor/change_stream_cursor.js.map +1 -1
  27. package/lib/cursor/find_cursor.js +64 -84
  28. package/lib/cursor/find_cursor.js.map +1 -1
  29. package/lib/cursor/list_collections_cursor.js +0 -1
  30. package/lib/cursor/list_collections_cursor.js.map +1 -1
  31. package/lib/cursor/list_indexes_cursor.js +0 -1
  32. package/lib/cursor/list_indexes_cursor.js.map +1 -1
  33. package/lib/cursor/run_command_cursor.js +4 -6
  34. package/lib/cursor/run_command_cursor.js.map +1 -1
  35. package/lib/error.js +10 -23
  36. package/lib/error.js.map +1 -1
  37. package/lib/index.js.map +1 -1
  38. package/lib/operations/aggregate.js +2 -2
  39. package/lib/operations/aggregate.js.map +1 -1
  40. package/lib/operations/bulk_write.js +1 -2
  41. package/lib/operations/bulk_write.js.map +1 -1
  42. package/lib/operations/command.js +2 -3
  43. package/lib/operations/command.js.map +1 -1
  44. package/lib/operations/execute_operation.js.map +1 -1
  45. package/lib/operations/find.js +2 -1
  46. package/lib/operations/find.js.map +1 -1
  47. package/lib/operations/get_more.js +1 -1
  48. package/lib/operations/get_more.js.map +1 -1
  49. package/lib/operations/indexes.js +2 -1
  50. package/lib/operations/indexes.js.map +1 -1
  51. package/lib/operations/list_collections.js +2 -1
  52. package/lib/operations/list_collections.js.map +1 -1
  53. package/lib/operations/run_command.js +1 -1
  54. package/lib/operations/run_command.js.map +1 -1
  55. package/lib/operations/update.js +2 -1
  56. package/lib/operations/update.js.map +1 -1
  57. package/lib/sdam/server.js +7 -2
  58. package/lib/sdam/server.js.map +1 -1
  59. package/lib/sessions.js +1 -1
  60. package/lib/sessions.js.map +1 -1
  61. package/lib/utils.js +45 -1
  62. package/lib/utils.js.map +1 -1
  63. package/lib/write_concern.js +17 -1
  64. package/lib/write_concern.js.map +1 -1
  65. package/mongodb.d.ts +188 -221
  66. package/package.json +3 -3
  67. package/src/bson.ts +1 -0
  68. package/src/client-side-encryption/auto_encrypter.ts +10 -149
  69. package/src/client-side-encryption/client_encryption.ts +33 -19
  70. package/src/client-side-encryption/providers/index.ts +118 -92
  71. package/src/client-side-encryption/state_machine.ts +22 -18
  72. package/src/cmap/connection.ts +46 -50
  73. package/src/cmap/wire_protocol/constants.ts +2 -2
  74. package/src/cmap/wire_protocol/on_demand/document.ts +13 -6
  75. package/src/cmap/wire_protocol/responses.ts +140 -45
  76. package/src/collection.ts +25 -5
  77. package/src/constants.ts +9 -0
  78. package/src/cursor/abstract_cursor.ts +280 -373
  79. package/src/cursor/aggregation_cursor.ts +24 -33
  80. package/src/cursor/change_stream_cursor.ts +31 -48
  81. package/src/cursor/find_cursor.ts +77 -92
  82. package/src/cursor/list_collections_cursor.ts +3 -4
  83. package/src/cursor/list_indexes_cursor.ts +3 -4
  84. package/src/cursor/run_command_cursor.ts +13 -19
  85. package/src/error.ts +20 -30
  86. package/src/index.ts +19 -10
  87. package/src/operations/aggregate.ts +12 -5
  88. package/src/operations/bulk_write.ts +1 -2
  89. package/src/operations/command.ts +17 -3
  90. package/src/operations/delete.ts +2 -2
  91. package/src/operations/execute_operation.ts +0 -13
  92. package/src/operations/find.ts +7 -3
  93. package/src/operations/find_and_modify.ts +1 -1
  94. package/src/operations/get_more.ts +6 -10
  95. package/src/operations/indexes.ts +7 -3
  96. package/src/operations/list_collections.ts +8 -3
  97. package/src/operations/run_command.ts +16 -6
  98. package/src/operations/update.ts +2 -1
  99. package/src/sdam/server.ts +7 -2
  100. package/src/sessions.ts +1 -1
  101. package/src/utils.ts +52 -2
  102. package/src/write_concern.ts +18 -0
  103. package/lib/operations/count_documents.js +0 -31
  104. package/lib/operations/count_documents.js.map +0 -1
  105. package/src/operations/count_documents.ts +0 -46
package/mongodb.d.ts CHANGED
@@ -10,20 +10,27 @@ import type { ConnectionOptions as ConnectionOptions_2 , TLSSocket , TLSSocketOp
10
10
 
11
11
  /** @public */
12
12
  export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends AbstractCursorEvents = AbstractCursorEvents> extends TypedEventEmitter<CursorEvents> {
13
- /* Excluded from this release type: [kId] */
14
- /* Excluded from this release type: [kSession] */
15
- /* Excluded from this release type: [kServer] */
16
- /* Excluded from this release type: [kNamespace] */
17
- /* Excluded from this release type: [kDocuments] */
18
- /* Excluded from this release type: [kClient] */
19
- /* Excluded from this release type: [kTransform] */
20
- /* Excluded from this release type: [kInitialized] */
21
- /* Excluded from this release type: [kClosed] */
22
- /* Excluded from this release type: [kKilled] */
23
- /* Excluded from this release type: [kOptions] */
13
+ /* Excluded from this release type: cursorId */
14
+ /* Excluded from this release type: cursorSession */
15
+ /* Excluded from this release type: selectedServer */
16
+ /* Excluded from this release type: cursorNamespace */
17
+ /* Excluded from this release type: documents */
18
+ /* Excluded from this release type: cursorClient */
19
+ /* Excluded from this release type: transform */
20
+ /* Excluded from this release type: initialized */
21
+ /* Excluded from this release type: isClosed */
22
+ /* Excluded from this release type: isKilled */
23
+ /* Excluded from this release type: cursorOptions */
24
24
  /** @event */
25
25
  static readonly CLOSE: "close";
26
26
  /* Excluded from this release type: __constructor */
27
+ /**
28
+ * The cursor has no id until it receives a response from the initial cursor creating command.
29
+ *
30
+ * It is non-zero for as long as the database has an open cursor.
31
+ *
32
+ * The initiating command may receive a zero id if the entire result is in the `firstBatch`.
33
+ */
27
34
  get id(): Long | undefined;
28
35
  /* Excluded from this release type: isDead */
29
36
  /* Excluded from this release type: client */
@@ -33,8 +40,14 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
33
40
  get readConcern(): ReadConcern | undefined;
34
41
  /* Excluded from this release type: session */
35
42
  /* Excluded from this release type: session */
36
- /* Excluded from this release type: cursorOptions */
43
+ /**
44
+ * The cursor is closed and all remaining locally buffered documents have been iterated.
45
+ */
37
46
  get closed(): boolean;
47
+ /**
48
+ * A `killCursors` command was attempted on this cursor.
49
+ * This is performed if the cursor id is non zero.
50
+ */
38
51
  get killed(): boolean;
39
52
  get loadBalanced(): boolean;
40
53
  /** Returns current buffered documents length */
@@ -153,7 +166,13 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
153
166
  abstract clone(): AbstractCursor<TSchema>;
154
167
  /* Excluded from this release type: _initialize */
155
168
  /* Excluded from this release type: getMore */
156
- /* Excluded from this release type: [kInit] */
169
+ /* Excluded from this release type: cursorInit */
170
+ /* Excluded from this release type: fetchBatch */
171
+ /* Excluded from this release type: cleanup */
172
+ /* Excluded from this release type: hasEmittedClose */
173
+ /* Excluded from this release type: emitClose */
174
+ /* Excluded from this release type: transformDocument */
175
+ /* Excluded from this release type: throwIfInitialized */
157
176
  }
158
177
 
159
178
  /** @public */
@@ -351,10 +370,9 @@ export declare interface AggregateOptions extends CommandOperationOptions {
351
370
  * @public
352
371
  */
353
372
  export declare class AggregationCursor<TSchema = any> extends AbstractCursor<TSchema> {
354
- /* Excluded from this release type: [kPipeline] */
355
- /* Excluded from this release type: [kOptions] */
373
+ readonly pipeline: Document[];
374
+ /* Excluded from this release type: aggregateOptions */
356
375
  /* Excluded from this release type: __constructor */
357
- get pipeline(): Document[];
358
376
  clone(): AggregationCursor<TSchema>;
359
377
  map<T>(transform: (doc: TSchema) => T): AggregationCursor<T>;
360
378
  /* Excluded from this release type: _initialize */
@@ -570,77 +588,7 @@ export declare interface AutoEncryptionOptions {
570
588
  /** The namespace where keys are stored in the key vault */
571
589
  keyVaultNamespace?: string;
572
590
  /** Configuration options that are used by specific KMS providers during key generation, encryption, and decryption. */
573
- kmsProviders?: {
574
- /** Configuration options for using 'aws' as your KMS provider */
575
- aws?: {
576
- /** The access key used for the AWS KMS provider */
577
- accessKeyId: string;
578
- /** The secret access key used for the AWS KMS provider */
579
- secretAccessKey: string;
580
- /**
581
- * An optional AWS session token that will be used as the
582
- * X-Amz-Security-Token header for AWS requests.
583
- */
584
- sessionToken?: string;
585
- } | Record<string, never>;
586
- /** Configuration options for using 'local' as your KMS provider */
587
- local?: {
588
- /**
589
- * The master key used to encrypt/decrypt data keys.
590
- * A 96-byte long Buffer or base64 encoded string.
591
- */
592
- key: Buffer | string;
593
- };
594
- /** Configuration options for using 'azure' as your KMS provider */
595
- azure?: {
596
- /** The tenant ID identifies the organization for the account */
597
- tenantId: string;
598
- /** The client ID to authenticate a registered application */
599
- clientId: string;
600
- /** The client secret to authenticate a registered application */
601
- clientSecret: string;
602
- /**
603
- * If present, a host with optional port. E.g. "example.com" or "example.com:443".
604
- * This is optional, and only needed if customer is using a non-commercial Azure instance
605
- * (e.g. a government or China account, which use different URLs).
606
- * Defaults to "login.microsoftonline.com"
607
- */
608
- identityPlatformEndpoint?: string | undefined;
609
- } | {
610
- /**
611
- * If present, an access token to authenticate with Azure.
612
- */
613
- accessToken: string;
614
- } | Record<string, never>;
615
- /** Configuration options for using 'gcp' as your KMS provider */
616
- gcp?: {
617
- /** The service account email to authenticate */
618
- email: string;
619
- /** A PKCS#8 encrypted key. This can either be a base64 string or a binary representation */
620
- privateKey: string | Buffer;
621
- /**
622
- * If present, a host with optional port. E.g. "example.com" or "example.com:443".
623
- * Defaults to "oauth2.googleapis.com"
624
- */
625
- endpoint?: string | undefined;
626
- } | {
627
- /**
628
- * If present, an access token to authenticate with GCP.
629
- */
630
- accessToken: string;
631
- } | Record<string, never>;
632
- /**
633
- * Configuration options for using 'kmip' as your KMS provider
634
- */
635
- kmip?: {
636
- /**
637
- * The output endpoint string.
638
- * The endpoint consists of a hostname and port separated by a colon.
639
- * E.g. "example.com:123". A port is always present.
640
- */
641
- endpoint?: string;
642
- };
643
- };
591
+ kmsProviders?: KMSProviders;
644
592
  /**
645
593
  * A map of namespaces to a local JSON schema for encryption
646
594
  *
@@ -731,6 +679,23 @@ export declare interface AWSEncryptionKeyOptions {
731
679
  endpoint?: string | undefined;
732
680
  }
733
681
 
682
+ /** @public */
683
+ export declare interface AWSKMSProviderConfiguration {
684
+ /**
685
+ * The access key used for the AWS KMS provider
686
+ */
687
+ accessKeyId: string;
688
+ /**
689
+ * The secret access key used for the AWS KMS provider
690
+ */
691
+ secretAccessKey: string;
692
+ /**
693
+ * An optional AWS session token that will be used as the
694
+ * X-Amz-Security-Token header for AWS requests.
695
+ */
696
+ sessionToken?: string;
697
+ }
698
+
734
699
  /**
735
700
  * @public
736
701
  * Configuration options for making an Azure encryption key
@@ -750,6 +715,34 @@ export declare interface AzureEncryptionKeyOptions {
750
715
  keyVersion?: string | undefined;
751
716
  }
752
717
 
718
+ /** @public */
719
+ export declare type AzureKMSProviderConfiguration = {
720
+ /**
721
+ * The tenant ID identifies the organization for the account
722
+ */
723
+ tenantId: string;
724
+ /**
725
+ * The client ID to authenticate a registered application
726
+ */
727
+ clientId: string;
728
+ /**
729
+ * The client secret to authenticate a registered application
730
+ */
731
+ clientSecret: string;
732
+ /**
733
+ * If present, a host with optional port. E.g. "example.com" or "example.com:443".
734
+ * This is optional, and only needed if customer is using a non-commercial Azure instance
735
+ * (e.g. a government or China account, which use different URLs).
736
+ * Defaults to "login.microsoftonline.com"
737
+ */
738
+ identityPlatformEndpoint?: string | undefined;
739
+ } | {
740
+ /**
741
+ * If present, an access token to authenticate with Azure.
742
+ */
743
+ accessToken: string;
744
+ };
745
+
753
746
  /**
754
747
  * Keeps the state of a unordered batch so we can rewrite the results
755
748
  * correctly after command execution
@@ -784,6 +777,7 @@ export declare type BitwiseFilter = number /** numeric bit mask */ | Binary /**
784
777
 
785
778
  export { BSON }
786
779
 
780
+ /* Excluded from this release type: BSONElement */
787
781
  export { BSONRegExp }
788
782
 
789
783
  /**
@@ -1074,8 +1068,6 @@ export declare class ChangeStream<TSchema extends Document = Document, TChange e
1074
1068
  /* Excluded from this release type: _processErrorIteratorMode */
1075
1069
  }
1076
1070
 
1077
- /* Excluded from this release type: ChangeStreamAggregateRawResult */
1078
-
1079
1071
  /**
1080
1072
  * Only present when the `showExpandedEvents` flag is enabled.
1081
1073
  * @public
@@ -1754,7 +1746,7 @@ export declare interface ClientEncryptionCreateDataKeyProviderOptions {
1754
1746
  /**
1755
1747
  * Identifies a new KMS-specific key used to encrypt the new data key
1756
1748
  */
1757
- masterKey?: AWSEncryptionKeyOptions | AzureEncryptionKeyOptions | GCPEncryptionKeyOptions | undefined;
1749
+ masterKey?: AWSEncryptionKeyOptions | AzureEncryptionKeyOptions | GCPEncryptionKeyOptions | KMIPEncryptionKeyOptions | undefined;
1758
1750
  /**
1759
1751
  * An optional list of string alternate names used to reference a key.
1760
1752
  * If a key is created with alternate names, then encryption may refer to the key by the unique alternate name instead of by _id.
@@ -1766,8 +1758,15 @@ export declare interface ClientEncryptionCreateDataKeyProviderOptions {
1766
1758
 
1767
1759
  /**
1768
1760
  * @public
1761
+ *
1762
+ * A data key provider. Allowed values:
1763
+ *
1764
+ * - aws, gcp, local, kmip or azure
1765
+ * - (`mongodb-client-encryption>=6.0.1` only) a named key, in the form of:
1766
+ * `aws:<name>`, `gcp:<name>`, `local:<name>`, `kmip:<name>`, `azure:<name>`
1767
+ * where `name` is an alphanumeric string, underscores allowed.
1769
1768
  */
1770
- export declare type ClientEncryptionDataKeyProvider = 'aws' | 'azure' | 'gcp' | 'local' | 'kmip';
1769
+ export declare type ClientEncryptionDataKeyProvider = keyof KMSProviders;
1771
1770
 
1772
1771
  /**
1773
1772
  * @public
@@ -1860,16 +1859,7 @@ export declare interface ClientEncryptionOptions {
1860
1859
  */
1861
1860
  export declare interface ClientEncryptionRewrapManyDataKeyProviderOptions {
1862
1861
  provider: ClientEncryptionDataKeyProvider;
1863
- masterKey?: AWSEncryptionKeyOptions | AzureEncryptionKeyOptions | GCPEncryptionKeyOptions | undefined;
1864
- }
1865
-
1866
- /**
1867
- * @public
1868
- * @experimental
1869
- */
1870
- export declare interface ClientEncryptionRewrapManyDataKeyProviderOptions {
1871
- provider: ClientEncryptionDataKeyProvider;
1872
- masterKey?: AWSEncryptionKeyOptions | AzureEncryptionKeyOptions | GCPEncryptionKeyOptions | undefined;
1862
+ masterKey?: AWSEncryptionKeyOptions | AzureEncryptionKeyOptions | GCPEncryptionKeyOptions | KMIPEncryptionKeyOptions | undefined;
1873
1863
  }
1874
1864
 
1875
1865
  /**
@@ -3064,7 +3054,7 @@ export declare interface ConnectOptions {
3064
3054
  export declare interface CountDocumentsOptions extends AggregateOptions {
3065
3055
  /** The number of documents to skip. */
3066
3056
  skip?: number;
3067
- /** The maximum amounts to count before aborting. */
3057
+ /** The maximum amount of documents to consider. */
3068
3058
  limit?: number;
3069
3059
  }
3070
3060
 
@@ -3168,6 +3158,7 @@ export declare type CSFLEKMSTlsOptions = {
3168
3158
  kmip?: ClientEncryptionTlsOptions;
3169
3159
  local?: ClientEncryptionTlsOptions;
3170
3160
  azure?: ClientEncryptionTlsOptions;
3161
+ [key: string]: ClientEncryptionTlsOptions | undefined;
3171
3162
  };
3172
3163
 
3173
3164
  /** @public */
@@ -3582,8 +3573,6 @@ export declare type EventEmitterWithState = {
3582
3573
  */
3583
3574
  export declare type EventsDescription = Record<string, GenericListener>;
3584
3575
 
3585
- /* Excluded from this release type: ExecutionResult */
3586
-
3587
3576
  /* Excluded from this release type: Explain */
3588
3577
 
3589
3578
  /** @public */
@@ -3662,9 +3651,9 @@ export declare interface FilterOperators<TValue> extends NonObjectIdLikeDocument
3662
3651
 
3663
3652
  /** @public */
3664
3653
  export declare class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
3665
- /* Excluded from this release type: [kFilter] */
3666
- /* Excluded from this release type: [kNumReturned] */
3667
- /* Excluded from this release type: [kBuiltOptions] */
3654
+ /* Excluded from this release type: cursorFilter */
3655
+ /* Excluded from this release type: numReturned */
3656
+ /* Excluded from this release type: findOptions */
3668
3657
  /* Excluded from this release type: __constructor */
3669
3658
  clone(): FindCursor<TSchema>;
3670
3659
  map<T>(transform: (doc: TSchema) => T): FindCursor<T>;
@@ -3990,6 +3979,28 @@ export declare interface GCPEncryptionKeyOptions {
3990
3979
  endpoint?: string | undefined;
3991
3980
  }
3992
3981
 
3982
+ /** @public */
3983
+ export declare type GCPKMSProviderConfiguration = {
3984
+ /**
3985
+ * The service account email to authenticate
3986
+ */
3987
+ email: string;
3988
+ /**
3989
+ * A PKCS#8 encrypted key. This can either be a base64 string or a binary representation
3990
+ */
3991
+ privateKey: string | Buffer;
3992
+ /**
3993
+ * If present, a host with optional port. E.g. "example.com" or "example.com:443".
3994
+ * Defaults to "oauth2.googleapis.com"
3995
+ */
3996
+ endpoint?: string | undefined;
3997
+ } | {
3998
+ /**
3999
+ * If present, an access token to authenticate with GCP.
4000
+ */
4001
+ accessToken: string;
4002
+ };
4003
+
3993
4004
  /** @public */
3994
4005
  export declare type GenericListener = (...args: any[]) => void;
3995
4006
 
@@ -4381,6 +4392,8 @@ export declare type InferIdType<TSchema> = TSchema extends {
4381
4392
  _id?: infer IdType;
4382
4393
  } ? unknown extends IdType ? ObjectId : IdType : ObjectId;
4383
4394
 
4395
+ /* Excluded from this release type: InitialCursorResponse */
4396
+
4384
4397
  /** @public */
4385
4398
  export declare interface InsertManyResult<TSchema = Document> {
4386
4399
  /** Indicates whether this write result was acknowledged. If not, then all other members of this result will be undefined */
@@ -4435,8 +4448,6 @@ export declare type Join<T extends unknown[], D extends string> = T extends [] ?
4435
4448
 
4436
4449
  /* Excluded from this release type: kBeforeHandshake */
4437
4450
 
4438
- /* Excluded from this release type: kBuiltOptions */
4439
-
4440
4451
  /* Excluded from this release type: kCancellationToken */
4441
4452
 
4442
4453
  /* Excluded from this release type: kCancellationToken_2 */
@@ -4447,12 +4458,8 @@ export declare type Join<T extends unknown[], D extends string> = T extends [] ?
4447
4458
 
4448
4459
  /* Excluded from this release type: kCheckedOut */
4449
4460
 
4450
- /* Excluded from this release type: kClient */
4451
-
4452
4461
  /* Excluded from this release type: kClosed */
4453
4462
 
4454
- /* Excluded from this release type: kClosed_2 */
4455
-
4456
4463
  /* Excluded from this release type: kConnectionCounter */
4457
4464
 
4458
4465
  /* Excluded from this release type: kConnections */
@@ -4461,8 +4468,6 @@ export declare type Join<T extends unknown[], D extends string> = T extends [] ?
4461
4468
 
4462
4469
  /* Excluded from this release type: kDecorateResult */
4463
4470
 
4464
- /* Excluded from this release type: kDocuments */
4465
-
4466
4471
  /* Excluded from this release type: kErrorLabels */
4467
4472
 
4468
4473
  /** @public */
@@ -4475,24 +4480,47 @@ export declare type KeysOfOtherType<TSchema, Type> = {
4475
4480
  [key in keyof TSchema]: NonNullable<TSchema[key]> extends Type ? never : key;
4476
4481
  }[keyof TSchema];
4477
4482
 
4478
- /* Excluded from this release type: kFilter */
4479
-
4480
4483
  /* Excluded from this release type: kGeneration */
4481
4484
 
4482
- /* Excluded from this release type: kId */
4483
-
4484
- /* Excluded from this release type: kInit */
4485
-
4486
- /* Excluded from this release type: kInitialized */
4487
-
4488
4485
  /* Excluded from this release type: kInternalClient */
4489
4486
 
4490
- /* Excluded from this release type: kKilled */
4491
-
4492
4487
  /* Excluded from this release type: kMetrics */
4493
4488
 
4494
4489
  /* Excluded from this release type: kMinPoolSizeTimer */
4495
4490
 
4491
+ /**
4492
+ * @public
4493
+ * Configuration options for making a KMIP encryption key
4494
+ */
4495
+ export declare interface KMIPEncryptionKeyOptions {
4496
+ /**
4497
+ * keyId is the KMIP Unique Identifier to a 96 byte KMIP Secret Data managed object.
4498
+ *
4499
+ * If keyId is omitted, a random 96 byte KMIP Secret Data managed object will be created.
4500
+ */
4501
+ keyId?: string;
4502
+ /**
4503
+ * Host with optional port.
4504
+ */
4505
+ endpoint?: string;
4506
+ /**
4507
+ * If true, this key should be decrypted by the KMIP server.
4508
+ *
4509
+ * Requires `mongodb-client-encryption>=6.0.1`.
4510
+ */
4511
+ delegated?: boolean;
4512
+ }
4513
+
4514
+ /** @public */
4515
+ export declare interface KMIPKMSProviderConfiguration {
4516
+ /**
4517
+ * The output endpoint string.
4518
+ * The endpoint consists of a hostname and port separated by a colon.
4519
+ * E.g. "example.com:123". A port is always present.
4520
+ */
4521
+ endpoint?: string;
4522
+ }
4523
+
4496
4524
  /* Excluded from this release type: kMode */
4497
4525
 
4498
4526
  /* Excluded from this release type: kMonitorId */
@@ -4500,117 +4528,43 @@ export declare type KeysOfOtherType<TSchema, Type> = {
4500
4528
  /**
4501
4529
  * @public
4502
4530
  * Configuration options that are used by specific KMS providers during key generation, encryption, and decryption.
4531
+ *
4532
+ * Named KMS providers _are not supported_ for automatic KMS credential fetching.
4503
4533
  */
4504
4534
  export declare interface KMSProviders {
4505
4535
  /**
4506
4536
  * Configuration options for using 'aws' as your KMS provider
4507
4537
  */
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>;
4538
+ aws?: AWSKMSProviderConfiguration | Record<string, never>;
4539
+ [key: `aws:${string}`]: AWSKMSProviderConfiguration;
4523
4540
  /**
4524
4541
  * Configuration options for using 'local' as your KMS provider
4525
4542
  */
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
- };
4543
+ local?: LocalKMSProviderConfiguration;
4544
+ [key: `local:${string}`]: LocalKMSProviderConfiguration;
4533
4545
  /**
4534
4546
  * Configuration options for using 'kmip' as your KMS provider
4535
4547
  */
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
- };
4548
+ kmip?: KMIPKMSProviderConfiguration;
4549
+ [key: `kmip:${string}`]: KMIPKMSProviderConfiguration;
4544
4550
  /**
4545
4551
  * Configuration options for using 'azure' as your KMS provider
4546
4552
  */
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>;
4553
+ azure?: AzureKMSProviderConfiguration | Record<string, never>;
4554
+ [key: `azure:${string}`]: AzureKMSProviderConfiguration;
4573
4555
  /**
4574
4556
  * Configuration options for using 'gcp' as your KMS provider
4575
4557
  */
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>;
4558
+ gcp?: GCPKMSProviderConfiguration | Record<string, never>;
4559
+ [key: `gcp:${string}`]: GCPKMSProviderConfiguration;
4596
4560
  }
4597
4561
 
4598
- /* Excluded from this release type: kNamespace */
4599
-
4600
- /* Excluded from this release type: kNumReturned */
4601
-
4602
4562
  /* Excluded from this release type: kOptions */
4603
4563
 
4604
- /* Excluded from this release type: kOptions_2 */
4605
-
4606
- /* Excluded from this release type: kOptions_3 */
4607
-
4608
4564
  /* Excluded from this release type: kPending */
4609
4565
 
4610
4566
  /* Excluded from this release type: kPinnedConnection */
4611
4567
 
4612
- /* Excluded from this release type: kPipeline */
4613
-
4614
4568
  /* Excluded from this release type: kPoolState */
4615
4569
 
4616
4570
  /* Excluded from this release type: kProcessingWaitQueue */
@@ -4619,8 +4573,6 @@ export declare interface KMSProviders {
4619
4573
 
4620
4574
  /* Excluded from this release type: kServer_2 */
4621
4575
 
4622
- /* Excluded from this release type: kServer_3 */
4623
-
4624
4576
  /* Excluded from this release type: kServerError */
4625
4577
 
4626
4578
  /* Excluded from this release type: kServerSession */
@@ -4629,14 +4581,10 @@ export declare interface KMSProviders {
4629
4581
 
4630
4582
  /* Excluded from this release type: kSession */
4631
4583
 
4632
- /* Excluded from this release type: kSession_2 */
4633
-
4634
4584
  /* Excluded from this release type: kSnapshotEnabled */
4635
4585
 
4636
4586
  /* Excluded from this release type: kSnapshotTime */
4637
4587
 
4638
- /* Excluded from this release type: kTransform */
4639
-
4640
4588
  /* Excluded from this release type: kTxnNumberIncrement */
4641
4589
 
4642
4590
  /* Excluded from this release type: kWaitQueue */
@@ -4715,6 +4663,15 @@ export declare class ListSearchIndexesCursor extends AggregationCursor<{
4715
4663
  /** @public */
4716
4664
  export declare type ListSearchIndexesOptions = Omit<AggregateOptions, 'readConcern' | 'writeConcern'>;
4717
4665
 
4666
+ /** @public */
4667
+ export declare interface LocalKMSProviderConfiguration {
4668
+ /**
4669
+ * The master key used to encrypt/decrypt data keys.
4670
+ * A 96-byte long Buffer or base64 encoded string.
4671
+ */
4672
+ key: Binary | Uint8Array | string;
4673
+ }
4674
+
4718
4675
  /* Excluded from this release type: Log */
4719
4676
 
4720
4677
  /* Excluded from this release type: LogComponentSeveritiesClientOptions */
@@ -6191,7 +6148,9 @@ export declare class MongoUnexpectedServerResponseError extends MongoRuntimeErro
6191
6148
  *
6192
6149
  * @public
6193
6150
  **/
6194
- constructor(message: string);
6151
+ constructor(message: string, options?: {
6152
+ cause?: Error;
6153
+ });
6195
6154
  get name(): string;
6196
6155
  }
6197
6156
 
@@ -6201,8 +6160,8 @@ export declare class MongoUnexpectedServerResponseError extends MongoRuntimeErro
6201
6160
  * @category Error
6202
6161
  */
6203
6162
  export declare class MongoWriteConcernError extends MongoServerError {
6204
- /** The result document (provided if ok: 1) */
6205
- result?: Document;
6163
+ /** The result document */
6164
+ result: Document;
6206
6165
  /**
6207
6166
  * **Do not use this constructor!**
6208
6167
  *
@@ -6214,7 +6173,15 @@ export declare class MongoWriteConcernError extends MongoServerError {
6214
6173
  *
6215
6174
  * @public
6216
6175
  **/
6217
- constructor(message: ErrorDescription, result?: Document);
6176
+ constructor(result: {
6177
+ writeConcernError: {
6178
+ code: number;
6179
+ errmsg: string;
6180
+ codeName?: string;
6181
+ errInfo?: Document;
6182
+ };
6183
+ errorLabels?: string[];
6184
+ });
6218
6185
  get name(): string;
6219
6186
  }
6220
6187
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongodb",
3
- "version": "6.7.0",
3
+ "version": "6.8.0-dev.20240629.sha.d85f827a",
4
4
  "description": "The official MongoDB driver for Node.js",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -98,7 +98,7 @@
98
98
  "js-yaml": "^4.1.0",
99
99
  "mocha": "^10.4.0",
100
100
  "mocha-sinon": "^2.1.2",
101
- "mongodb-client-encryption": "^6.0.0",
101
+ "mongodb-client-encryption": "^6.0.1",
102
102
  "mongodb-legacy": "^6.0.1",
103
103
  "nyc": "^15.1.0",
104
104
  "prettier": "^2.8.8",
@@ -176,4 +176,4 @@
176
176
  "moduleResolution": "node"
177
177
  }
178
178
  }
179
- }
179
+ }
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[] {