@@ -24,14 +24,15 @@ import {
2424 MongoCryptCreateEncryptedCollectionError ,
2525 MongoCryptInvalidArgumentError
2626} from './errors' ;
27- import { type KMSProvider , type KMSProviders , refreshKMSCredentials } from './providers/index' ;
2827import {
29- type CSFLEKMSTlsOptions ,
30- StateMachine ,
31- type StateMachineExecutable
32- } from './state_machine' ;
28+ type ClientEncryptionDataKeyProvider ,
29+ type KMSProviders ,
30+ refreshKMSCredentials
31+ } from './providers/index' ;
32+ import { type CSFLEKMSTlsOptions , StateMachine } from './state_machine' ;
3333
3434/**
35+ * @public
3536 * The schema for a DataKey in the key vault collection.
3637 */
3738export interface DataKey {
@@ -46,14 +47,21 @@ export interface DataKey {
4647}
4748
4849/**
50+ * @public
4951 * The public interface for explicit in-use encryption
5052 */
51- export class ClientEncryption implements StateMachineExecutable {
53+ export class ClientEncryption {
54+ /** @internal */
5255 _client : MongoClient ;
56+ /** @internal */
5357 _keyVaultNamespace : string ;
58+ /** @internal */
5459 _keyVaultClient : MongoClient ;
60+ /** @internal */
5561 _proxyOptions : ProxyOptions ;
62+ /** @internal */
5663 _tlsOptions : CSFLEKMSTlsOptions ;
64+ /** @internal */
5765 _kmsProviders : KMSProviders ;
5866
5967 /** @internal */
@@ -165,7 +173,7 @@ export class ClientEncryption implements StateMachineExecutable {
165173 * ```
166174 */
167175 createDataKey (
168- provider : KMSProvider ,
176+ provider : ClientEncryptionDataKeyProvider ,
169177 options ?: ClientEncryptionCreateDataKeyProviderOptions ,
170178 callback ?: Callback < DataKey >
171179 ) {
@@ -268,7 +276,10 @@ export class ClientEncryption implements StateMachineExecutable {
268276 * }
269277 * ```
270278 */
271- async rewrapManyDataKey ( filter : Filter < DataKey > , options : RewrapManyDataKeyOptions ) {
279+ async rewrapManyDataKey (
280+ filter : Filter < DataKey > ,
281+ options : ClientEncryptionRewrapManyDataKeyProviderOptions
282+ ) {
272283 let keyEncryptionKeyBson = undefined ;
273284 if ( options ) {
274285 const keyEncryptionKey = Object . assign ( { provider : options . provider } , options . masterKey ) ;
@@ -533,7 +544,7 @@ export class ClientEncryption implements StateMachineExecutable {
533544 db : Db ,
534545 name : string ,
535546 options : {
536- provider : KMSProvider ;
547+ provider : ClientEncryptionDataKeyProvider ;
537548 createCollectionOptions : Omit < CreateCollectionOptions , 'encryptedFields' > & {
538549 encryptedFields : Document ;
539550 } ;
@@ -569,7 +580,7 @@ export class ClientEncryption implements StateMachineExecutable {
569580 ( result ) : result is PromiseRejectedResult => result . status === 'rejected'
570581 ) ;
571582 if ( rejection != null ) {
572- throw new MongoCryptCreateDataKeyError ( { encryptedFields, cause : rejection . reason } ) ;
583+ throw new MongoCryptCreateDataKeyError ( encryptedFields , { cause : rejection . reason } ) ;
573584 }
574585 }
575586
@@ -580,7 +591,7 @@ export class ClientEncryption implements StateMachineExecutable {
580591 } ) ;
581592 return { collection, encryptedFields } ;
582593 } catch ( cause ) {
583- throw new MongoCryptCreateEncryptedCollectionError ( { encryptedFields, cause } ) ;
594+ throw new MongoCryptCreateEncryptedCollectionError ( encryptedFields , { cause } ) ;
584595 }
585596 }
586597
@@ -703,6 +714,7 @@ export class ClientEncryption implements StateMachineExecutable {
703714 }
704715
705716 /**
717+ * @internal
706718 * Ask the user for KMS credentials.
707719 *
708720 * This returns anything that looks like the kmsProviders original input
@@ -718,6 +730,7 @@ export class ClientEncryption implements StateMachineExecutable {
718730 }
719731
720732 /**
733+ * @internal
721734 * A helper that perform explicit encryption of values and expressions.
722735 * Explicitly encrypt a provided value. Note that either `options.keyId` or `options.keyAltName` must
723736 * be specified. Specifying both `options.keyId` and `options.keyAltName` is considered an error.
@@ -780,6 +793,7 @@ export class ClientEncryption implements StateMachineExecutable {
780793}
781794
782795/**
796+ * @public
783797 * Options to provide when encrypting data.
784798 */
785799export interface ClientEncryptionEncryptOptions {
@@ -817,9 +831,12 @@ export interface ClientEncryptionEncryptOptions {
817831 rangeOptions ?: RangeOptions ;
818832}
819833
820- /** @experimental */
821- export interface RewrapManyDataKeyOptions {
822- provider : KMSProvider ;
834+ /**
835+ * @public
836+ * @experimental
837+ */
838+ export interface ClientEncryptionRewrapManyDataKeyProviderOptions {
839+ provider : ClientEncryptionDataKeyProvider ;
823840 masterKey ?:
824841 | AWSEncryptionKeyOptions
825842 | AzureEncryptionKeyOptions
@@ -828,6 +845,7 @@ export interface RewrapManyDataKeyOptions {
828845}
829846
830847/**
848+ * @public
831849 * Additional settings to provide when creating a new `ClientEncryption` instance.
832850 */
833851export interface ClientEncryptionOptions {
@@ -858,6 +876,7 @@ export interface ClientEncryptionOptions {
858876}
859877
860878/**
879+ * @public
861880 * Configuration options for making an AWS encryption key
862881 */
863882export interface AWSEncryptionKeyOptions {
@@ -878,6 +897,7 @@ export interface AWSEncryptionKeyOptions {
878897}
879898
880899/**
900+ * @public
881901 * Configuration options for making an AWS encryption key
882902 */
883903export interface GCPEncryptionKeyOptions {
@@ -913,6 +933,7 @@ export interface GCPEncryptionKeyOptions {
913933}
914934
915935/**
936+ * @public
916937 * Configuration options for making an Azure encryption key
917938 */
918939export interface AzureEncryptionKeyOptions {
@@ -933,6 +954,7 @@ export interface AzureEncryptionKeyOptions {
933954}
934955
935956/**
957+ * @public
936958 * Options to provide when creating a new data key.
937959 */
938960export interface ClientEncryptionCreateDataKeyProviderOptions {
@@ -955,35 +977,43 @@ export interface ClientEncryptionCreateDataKeyProviderOptions {
955977 keyMaterial ?: Buffer | Binary ;
956978}
957979
958- /** @experimental */
959- export interface RewrapManyDataKeyOptions {
960- provider : KMSProvider ;
980+ /**
981+ * @public
982+ * @experimental
983+ */
984+ export interface ClientEncryptionRewrapManyDataKeyProviderOptions {
985+ provider : ClientEncryptionDataKeyProvider ;
961986 masterKey ?:
962987 | AWSEncryptionKeyOptions
963988 | AzureEncryptionKeyOptions
964989 | GCPEncryptionKeyOptions
965990 | undefined ;
966991}
967992
968- /** @experimental */
993+ /**
994+ * @public
995+ * @experimental
996+ */
969997export interface ClientEncryptionRewrapManyDataKeyResult {
970998 /** The result of rewrapping data keys. If unset, no keys matched the filter. */
971999 bulkWriteResult ?: BulkWriteResult ;
9721000}
9731001
9741002/**
1003+ * @public
9751004 * RangeOptions specifies index options for a Queryable Encryption field supporting "rangePreview" queries.
9761005 * min, max, sparsity, and range must match the values set in the encryptedFields of the destination collection.
9771006 * For double and decimal128, min/max/precision must all be set, or all be unset.
9781007 */
979- interface RangeOptions {
1008+ export interface RangeOptions {
9801009 min ?: any ;
9811010 max ?: any ;
9821011 sparsity : Long ;
9831012 precision ?: number ;
9841013}
9851014
9861015/**
1016+ * @public
9871017 * Options to provide when encrypting data.
9881018 */
9891019export interface ClientEncryptionEncryptOptions {
0 commit comments