Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions addon/mongocrypt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,11 @@ MongoCrypt::MongoCrypt(const CallbackInfo& info) : ObjectWrap(info) {
mongocrypt_setopt_bypass_query_analysis(mongo_crypt());
}

if (options.Has("keyExpirationMS")) {
mongocrypt_setopt_key_expiration(mongo_crypt(),
options.Get("keyExpirationMS").ToNumber().Int64Value());
}

mongocrypt_setopt_use_range_v2(mongo_crypt());

mongocrypt_setopt_use_need_kms_credentials_state(mongo_crypt());
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"license": "Apache-2.0",
"gypfile": true,
"mongodb:libmongocrypt": "1.13.0",
"mongodb:libmongocrypt": "1.14.0",
"dependencies": {
"node-addon-api": "^4.3.0",
"prebuild-install": "^7.1.3"
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ type MongoCryptConstructorOptions = {
cryptSharedLibSearchPaths?: string[];
cryptSharedLibPath?: string;
bypassQueryAnalysis?: boolean;
/** Configure the time to expire the DEK from the cache. */
keyExpirationMS?: number;
/** TODO(NODE-6793): remove this option and have it always set in the next major */
enableMultipleCollinfo?: boolean;
};
Expand Down
18 changes: 18 additions & 0 deletions test/unit/bindings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@ describe('MongoCryptConstructor', () => {
});
});

describe('options.keyExpirationMS', () => {
context('when the number is positive', () => {
it('does not error', () => {
expect(
new MongoCrypt({ kmsProviders: serialize({ aws: {} }), keyExpirationMS: 1000000 })
).to.be.instanceOf(MongoCrypt);
});
});

context('when the number is negative', () => {
it('throws an error', () => {
expect(() => {
new MongoCrypt({ kmsProviders: serialize({ aws: {} }), keyExpirationMS: -1000000 });
}).to.throw(TypeError);
});
});
});

describe('options.encryptedFieldsMap', () => {
it('throws when provided and not a Uint8Array', () => {
expect(
Expand Down