Skip to content
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

feat(NODE-4986)!: remove callbacks from ClientEncryption encrypt, decrypt, and createDataKey #3797

Merged
merged 8 commits into from
Aug 8, 2023

Conversation

nbbeeken
Copy link
Contributor

@nbbeeken nbbeeken commented Aug 4, 2023

Description

What is changing?

  • removed callbacks from encrypt, decrypt, and createDataKey
  • Changed return type createDataKey to Binary which lines up with the runtime return value
Is there new documentation needed for these changes?

Release highlights

What is the motivation for this change?

We do not offer callbacks APIs anymore

Release Highlight

Callbacks removed from ClientEncryption's encrypt, decrypt, and createDataKey methods

Driver v5 dropped support for callbacks in asynchronous functions in favor of returning promises. We are now removing support for callbacks from the ClientEncryption class.

createDataKey return type fix

The Typescript for createDataKey incorrectly declared the result to be a DataKey but the method actually returns the DataKey's insertedId.

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@nbbeeken nbbeeken force-pushed the NODE-5513-public-fle-async branch 5 times, most recently from 3eaf05b to ca05650 Compare August 4, 2023 21:11
@nbbeeken nbbeeken force-pushed the NODE-5513-public-fle-async branch 2 times, most recently from af4d12f to e33cf69 Compare August 7, 2023 17:33
@nbbeeken nbbeeken force-pushed the NODE-5513-public-fle-async branch from e33cf69 to 1e7d89a Compare August 7, 2023 18:24
@nbbeeken nbbeeken marked this pull request as ready for review August 7, 2023 18:24
@nbbeeken nbbeeken requested a review from baileympearson August 7, 2023 18:25
@nbbeeken nbbeeken added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Aug 7, 2023
@nbbeeken nbbeeken changed the title feat(NODE-5513)!: remove callbacks from ClientEncryption encrypt, decrypt, and createDataKey feat(NODE-4986)!: remove callbacks from ClientEncryption encrypt, decrypt, and createDataKey Aug 7, 2023
cb(err, null);
return;
}
const updatedDataKey = await stateMachine.executeAsync<DataKey>(this, context);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to choose another name here because we were shadowing. Up for any suggestions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just remove the first declaration and name this dataKey? it's not proving much value imo and it actually makes this more confusing, because the data key is created by stateMachine.execute.

    const dataKeyBson = serialize({ provider, masterKey: options.masterKey });

cb(err, null);
return;
}
const updatedDataKey = await stateMachine.executeAsync<DataKey>(this, context);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just remove the first declaration and name this dataKey? it's not proving much value imo and it actually makes this more confusing, because the data key is created by stateMachine.execute.

    const dataKeyBson = serialize({ provider, masterKey: options.masterKey });


beforeEach(function () {
if (SKIP_AWS_TESTS) {
this.currentTest?.skip();
return;
}

sandbox.restore();
sandbox = sinon.createSandbox();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to stub the whole object in one go?

sandbox.spy(cryptoCallbacks)

@nbbeeken nbbeeken requested a review from baileympearson August 7, 2023 19:34
@@ -98,7 +98,7 @@
"js-yaml": "^4.1.0",
"mocha": "^10.2.0",
"mocha-sinon": "^2.1.2",
"mongodb-client-encryption": "^6.0.0-alpha.1",
"mongodb-client-encryption": "6.0.0-alpha.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we bump this to alpha 2 now that it's out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alpha.2 introduced the bug that's making the CI red, rolling back fixes it locally but all of EVG disagrees 😅 I'm not sure how the code is getting a hold of the alpha.2 version, I thought we only installed from devDeps now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context: https://jira.mongodb.org/browse/NODE-5516

Now that we track the package in our devDeps we can get rid of the peppering of manual installations. cc @baileympearson

Copy link
Contributor

@baileympearson baileympearson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failing tests are either unrelated or expected. LGTM

@baileympearson baileympearson merged commit 51a573f into main Aug 8, 2023
@baileympearson baileympearson deleted the NODE-5513-public-fle-async branch August 8, 2023 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Primary Review In Review with primary reviewer, not yet ready for team's eyes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants