Skip to content

feat(NODE-6695): enable KMS retry protocol #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions addon/mongocrypt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ MongoCrypt::MongoCrypt(const CallbackInfo& info) : ObjectWrap(info) {

mongocrypt_setopt_use_need_kms_credentials_state(mongo_crypt());

mongocrypt_setopt_retry_kms(mongo_crypt(), true);

// Initialize after all options are set.
if (!mongocrypt_init(mongo_crypt())) {
throw TypeError::New(Env(), errorStringFromStatus(mongo_crypt()));
Expand Down Expand Up @@ -947,6 +949,8 @@ Function MongoCryptKMSRequest::Init(Napi::Env env) {
{InstanceMethod("addResponse", &MongoCryptKMSRequest::AddResponse),
InstanceAccessor("status", &MongoCryptKMSRequest::Status, nullptr),
InstanceAccessor("bytesNeeded", &MongoCryptKMSRequest::BytesNeeded, nullptr),
InstanceAccessor("uSleep", &MongoCryptKMSRequest::USleep, nullptr),
InstanceAccessor("fail", &MongoCryptKMSRequest::Fail, nullptr),
InstanceAccessor("kmsProvider", &MongoCryptKMSRequest::KMSProvider, nullptr),
InstanceAccessor("endpoint", &MongoCryptKMSRequest::Endpoint, nullptr),
InstanceAccessor("message", &MongoCryptKMSRequest::Message, nullptr)});
Expand Down Expand Up @@ -977,6 +981,14 @@ Value MongoCryptKMSRequest::BytesNeeded(const CallbackInfo& info) {
return Number::New(Env(), mongocrypt_kms_ctx_bytes_needed(_kms_context));
}

Value MongoCryptKMSRequest::USleep(const CallbackInfo& info) {
return Number::New(Env(), mongocrypt_kms_ctx_usleep(_kms_context));
}

Value MongoCryptKMSRequest::Fail(const CallbackInfo& info) {
return Boolean::New(Env(), mongocrypt_kms_ctx_fail(_kms_context));
}

Value MongoCryptKMSRequest::KMSProvider(const CallbackInfo& info) {
return String::New(Env(), mongocrypt_kms_ctx_get_kms_provider(_kms_context, nullptr));
}
Expand Down
2 changes: 2 additions & 0 deletions addon/mongocrypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ class MongoCryptKMSRequest : public Napi::ObjectWrap<MongoCryptKMSRequest> {
Napi::Value Status(const Napi::CallbackInfo& info);
Napi::Value Message(const Napi::CallbackInfo& info);
Napi::Value BytesNeeded(const Napi::CallbackInfo& info);
Napi::Value Fail(const Napi::CallbackInfo& info);
Napi::Value USleep(const Napi::CallbackInfo& info);
Napi::Value KMSProvider(const Napi::CallbackInfo& info);
Napi::Value Endpoint(const Napi::CallbackInfo& info);

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.11.0",
"mongodb:libmongocrypt": "1.12.0",
"dependencies": {
"node-addon-api": "^4.3.0",
"prebuild-install": "^7.1.2"
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ type MongoCryptBindings = {

export interface MongoCryptKMSRequest {
addResponse(response: Uint8Array): void;
fail(): boolean;
readonly status: MongoCryptStatus;
readonly bytesNeeded: number;
readonly uSleep: number;
readonly kmsProvider: string;
readonly endpoint: string;
readonly message: Buffer;
Expand Down