@@ -24,14 +24,15 @@ import {
24
24
MongoCryptCreateEncryptedCollectionError ,
25
25
MongoCryptInvalidArgumentError
26
26
} from './errors' ;
27
- import { type KMSProvider , type KMSProviders , refreshKMSCredentials } from './providers/index' ;
28
27
import {
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' ;
33
33
34
34
/**
35
+ * @public
35
36
* The schema for a DataKey in the key vault collection.
36
37
*/
37
38
export interface DataKey {
@@ -46,14 +47,21 @@ export interface DataKey {
46
47
}
47
48
48
49
/**
50
+ * @public
49
51
* The public interface for explicit in-use encryption
50
52
*/
51
- export class ClientEncryption implements StateMachineExecutable {
53
+ export class ClientEncryption {
54
+ /** @internal */
52
55
_client : MongoClient ;
56
+ /** @internal */
53
57
_keyVaultNamespace : string ;
58
+ /** @internal */
54
59
_keyVaultClient : MongoClient ;
60
+ /** @internal */
55
61
_proxyOptions : ProxyOptions ;
62
+ /** @internal */
56
63
_tlsOptions : CSFLEKMSTlsOptions ;
64
+ /** @internal */
57
65
_kmsProviders : KMSProviders ;
58
66
59
67
/** @internal */
@@ -165,7 +173,7 @@ export class ClientEncryption implements StateMachineExecutable {
165
173
* ```
166
174
*/
167
175
createDataKey (
168
- provider : KMSProvider ,
176
+ provider : ClientEncryptionDataKeyProvider ,
169
177
options ?: ClientEncryptionCreateDataKeyProviderOptions ,
170
178
callback ?: Callback < DataKey >
171
179
) {
@@ -268,7 +276,10 @@ export class ClientEncryption implements StateMachineExecutable {
268
276
* }
269
277
* ```
270
278
*/
271
- async rewrapManyDataKey ( filter : Filter < DataKey > , options : RewrapManyDataKeyOptions ) {
279
+ async rewrapManyDataKey (
280
+ filter : Filter < DataKey > ,
281
+ options : ClientEncryptionRewrapManyDataKeyProviderOptions
282
+ ) {
272
283
let keyEncryptionKeyBson = undefined ;
273
284
if ( options ) {
274
285
const keyEncryptionKey = Object . assign ( { provider : options . provider } , options . masterKey ) ;
@@ -533,7 +544,7 @@ export class ClientEncryption implements StateMachineExecutable {
533
544
db : Db ,
534
545
name : string ,
535
546
options : {
536
- provider : KMSProvider ;
547
+ provider : ClientEncryptionDataKeyProvider ;
537
548
createCollectionOptions : Omit < CreateCollectionOptions , 'encryptedFields' > & {
538
549
encryptedFields : Document ;
539
550
} ;
@@ -569,7 +580,7 @@ export class ClientEncryption implements StateMachineExecutable {
569
580
( result ) : result is PromiseRejectedResult => result . status === 'rejected'
570
581
) ;
571
582
if ( rejection != null ) {
572
- throw new MongoCryptCreateDataKeyError ( { encryptedFields, cause : rejection . reason } ) ;
583
+ throw new MongoCryptCreateDataKeyError ( encryptedFields , { cause : rejection . reason } ) ;
573
584
}
574
585
}
575
586
@@ -580,7 +591,7 @@ export class ClientEncryption implements StateMachineExecutable {
580
591
} ) ;
581
592
return { collection, encryptedFields } ;
582
593
} catch ( cause ) {
583
- throw new MongoCryptCreateEncryptedCollectionError ( { encryptedFields, cause } ) ;
594
+ throw new MongoCryptCreateEncryptedCollectionError ( encryptedFields , { cause } ) ;
584
595
}
585
596
}
586
597
@@ -703,6 +714,7 @@ export class ClientEncryption implements StateMachineExecutable {
703
714
}
704
715
705
716
/**
717
+ * @internal
706
718
* Ask the user for KMS credentials.
707
719
*
708
720
* This returns anything that looks like the kmsProviders original input
@@ -718,6 +730,7 @@ export class ClientEncryption implements StateMachineExecutable {
718
730
}
719
731
720
732
/**
733
+ * @internal
721
734
* A helper that perform explicit encryption of values and expressions.
722
735
* Explicitly encrypt a provided value. Note that either `options.keyId` or `options.keyAltName` must
723
736
* be specified. Specifying both `options.keyId` and `options.keyAltName` is considered an error.
@@ -780,6 +793,7 @@ export class ClientEncryption implements StateMachineExecutable {
780
793
}
781
794
782
795
/**
796
+ * @public
783
797
* Options to provide when encrypting data.
784
798
*/
785
799
export interface ClientEncryptionEncryptOptions {
@@ -817,9 +831,12 @@ export interface ClientEncryptionEncryptOptions {
817
831
rangeOptions ?: RangeOptions ;
818
832
}
819
833
820
- /** @experimental */
821
- export interface RewrapManyDataKeyOptions {
822
- provider : KMSProvider ;
834
+ /**
835
+ * @public
836
+ * @experimental
837
+ */
838
+ export interface ClientEncryptionRewrapManyDataKeyProviderOptions {
839
+ provider : ClientEncryptionDataKeyProvider ;
823
840
masterKey ?:
824
841
| AWSEncryptionKeyOptions
825
842
| AzureEncryptionKeyOptions
@@ -828,6 +845,7 @@ export interface RewrapManyDataKeyOptions {
828
845
}
829
846
830
847
/**
848
+ * @public
831
849
* Additional settings to provide when creating a new `ClientEncryption` instance.
832
850
*/
833
851
export interface ClientEncryptionOptions {
@@ -858,6 +876,7 @@ export interface ClientEncryptionOptions {
858
876
}
859
877
860
878
/**
879
+ * @public
861
880
* Configuration options for making an AWS encryption key
862
881
*/
863
882
export interface AWSEncryptionKeyOptions {
@@ -878,6 +897,7 @@ export interface AWSEncryptionKeyOptions {
878
897
}
879
898
880
899
/**
900
+ * @public
881
901
* Configuration options for making an AWS encryption key
882
902
*/
883
903
export interface GCPEncryptionKeyOptions {
@@ -913,6 +933,7 @@ export interface GCPEncryptionKeyOptions {
913
933
}
914
934
915
935
/**
936
+ * @public
916
937
* Configuration options for making an Azure encryption key
917
938
*/
918
939
export interface AzureEncryptionKeyOptions {
@@ -933,6 +954,7 @@ export interface AzureEncryptionKeyOptions {
933
954
}
934
955
935
956
/**
957
+ * @public
936
958
* Options to provide when creating a new data key.
937
959
*/
938
960
export interface ClientEncryptionCreateDataKeyProviderOptions {
@@ -955,35 +977,43 @@ export interface ClientEncryptionCreateDataKeyProviderOptions {
955
977
keyMaterial ?: Buffer | Binary ;
956
978
}
957
979
958
- /** @experimental */
959
- export interface RewrapManyDataKeyOptions {
960
- provider : KMSProvider ;
980
+ /**
981
+ * @public
982
+ * @experimental
983
+ */
984
+ export interface ClientEncryptionRewrapManyDataKeyProviderOptions {
985
+ provider : ClientEncryptionDataKeyProvider ;
961
986
masterKey ?:
962
987
| AWSEncryptionKeyOptions
963
988
| AzureEncryptionKeyOptions
964
989
| GCPEncryptionKeyOptions
965
990
| undefined ;
966
991
}
967
992
968
- /** @experimental */
993
+ /**
994
+ * @public
995
+ * @experimental
996
+ */
969
997
export interface ClientEncryptionRewrapManyDataKeyResult {
970
998
/** The result of rewrapping data keys. If unset, no keys matched the filter. */
971
999
bulkWriteResult ?: BulkWriteResult ;
972
1000
}
973
1001
974
1002
/**
1003
+ * @public
975
1004
* RangeOptions specifies index options for a Queryable Encryption field supporting "rangePreview" queries.
976
1005
* min, max, sparsity, and range must match the values set in the encryptedFields of the destination collection.
977
1006
* For double and decimal128, min/max/precision must all be set, or all be unset.
978
1007
*/
979
- interface RangeOptions {
1008
+ export interface RangeOptions {
980
1009
min ?: any ;
981
1010
max ?: any ;
982
1011
sparsity : Long ;
983
1012
precision ?: number ;
984
1013
}
985
1014
986
1015
/**
1016
+ * @public
987
1017
* Options to provide when encrypting data.
988
1018
*/
989
1019
export interface ClientEncryptionEncryptOptions {
0 commit comments