Skip to content

Commit d4b7ef7

Browse files
authored
feat(NODE-6695): enable KMS retry protocol (#60)
1 parent faea384 commit d4b7ef7

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

Diff for: addon/mongocrypt.cc

+12
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,8 @@ MongoCrypt::MongoCrypt(const CallbackInfo& info) : ObjectWrap(info) {
575575

576576
mongocrypt_setopt_use_need_kms_credentials_state(mongo_crypt());
577577

578+
mongocrypt_setopt_retry_kms(mongo_crypt(), true);
579+
578580
// Initialize after all options are set.
579581
if (!mongocrypt_init(mongo_crypt())) {
580582
throw TypeError::New(Env(), errorStringFromStatus(mongo_crypt()));
@@ -947,6 +949,8 @@ Function MongoCryptKMSRequest::Init(Napi::Env env) {
947949
{InstanceMethod("addResponse", &MongoCryptKMSRequest::AddResponse),
948950
InstanceAccessor("status", &MongoCryptKMSRequest::Status, nullptr),
949951
InstanceAccessor("bytesNeeded", &MongoCryptKMSRequest::BytesNeeded, nullptr),
952+
InstanceAccessor("uSleep", &MongoCryptKMSRequest::USleep, nullptr),
953+
InstanceAccessor("fail", &MongoCryptKMSRequest::Fail, nullptr),
950954
InstanceAccessor("kmsProvider", &MongoCryptKMSRequest::KMSProvider, nullptr),
951955
InstanceAccessor("endpoint", &MongoCryptKMSRequest::Endpoint, nullptr),
952956
InstanceAccessor("message", &MongoCryptKMSRequest::Message, nullptr)});
@@ -977,6 +981,14 @@ Value MongoCryptKMSRequest::BytesNeeded(const CallbackInfo& info) {
977981
return Number::New(Env(), mongocrypt_kms_ctx_bytes_needed(_kms_context));
978982
}
979983

984+
Value MongoCryptKMSRequest::USleep(const CallbackInfo& info) {
985+
return Number::New(Env(), mongocrypt_kms_ctx_usleep(_kms_context));
986+
}
987+
988+
Value MongoCryptKMSRequest::Fail(const CallbackInfo& info) {
989+
return Boolean::New(Env(), mongocrypt_kms_ctx_fail(_kms_context));
990+
}
991+
980992
Value MongoCryptKMSRequest::KMSProvider(const CallbackInfo& info) {
981993
return String::New(Env(), mongocrypt_kms_ctx_get_kms_provider(_kms_context, nullptr));
982994
}

Diff for: addon/mongocrypt.h

+2
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ class MongoCryptKMSRequest : public Napi::ObjectWrap<MongoCryptKMSRequest> {
151151
Napi::Value Status(const Napi::CallbackInfo& info);
152152
Napi::Value Message(const Napi::CallbackInfo& info);
153153
Napi::Value BytesNeeded(const Napi::CallbackInfo& info);
154+
Napi::Value Fail(const Napi::CallbackInfo& info);
155+
Napi::Value USleep(const Napi::CallbackInfo& info);
154156
Napi::Value KMSProvider(const Napi::CallbackInfo& info);
155157
Napi::Value Endpoint(const Napi::CallbackInfo& info);
156158

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"license": "Apache-2.0",
3737
"gypfile": true,
38-
"mongodb:libmongocrypt": "1.11.0",
38+
"mongodb:libmongocrypt": "1.12.0",
3939
"dependencies": {
4040
"node-addon-api": "^4.3.0",
4141
"prebuild-install": "^7.1.2"

Diff for: src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ type MongoCryptBindings = {
2323

2424
export interface MongoCryptKMSRequest {
2525
addResponse(response: Uint8Array): void;
26+
fail(): boolean;
2627
readonly status: MongoCryptStatus;
2728
readonly bytesNeeded: number;
29+
readonly uSleep: number;
2830
readonly kmsProvider: string;
2931
readonly endpoint: string;
3032
readonly message: Buffer;

0 commit comments

Comments
 (0)