Skip to content

Commit 00cf2cd

Browse files
feat(NODE-7043)!: remove crypto callbacks (#4706)
1 parent 354a899 commit 00cf2cd

File tree

6 files changed

+1
-154
lines changed

6 files changed

+1
-154
lines changed

.evergreen/install-mongodb-client-encryption.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if [ -z ${PROJECT_DIRECTORY+omitted} ]; then echo "PROJECT_DIRECTORY is unset" &
99
source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
1010

1111
rm -rf mongodb-client-encryption
12-
git clone https://github.com/baileympearson/mongodb-client-encryption.git -b NODE-7043
12+
git clone https://github.com/mongodb-js/mongodb-client-encryption.git -b NODE-6297
1313
pushd mongodb-client-encryption
1414

1515
node --version

src/client-side-encryption/auto_encrypter.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { MongoClient, type MongoClientOptions } from '../mongo_client';
1010
import { type Abortable } from '../mongo_types';
1111
import { MongoDBCollectionNamespace } from '../utils';
1212
import { autoSelectSocketOptions } from './client_encryption';
13-
import * as cryptoCallbacks from './crypto_callbacks';
1413
import { defaultErrorWrapper, MongoCryptInvalidArgumentError } from './errors';
1514
import { MongocryptdManager } from './mongocryptd_manager';
1615
import {
@@ -254,7 +253,6 @@ export class AutoEncrypter {
254253
}
255254

256255
const mongoCryptOptions: MongoCryptOptions = {
257-
cryptoCallbacks,
258256
errorWrapper: defaultErrorWrapper
259257
};
260258
if (options.schemaMap) {

src/client-side-encryption/client_encryption.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { type CreateCollectionOptions } from '../operations/create_collection';
2525
import { type DeleteResult } from '../operations/delete';
2626
import { type CSOTTimeoutContext, TimeoutContext } from '../timeout';
2727
import { MongoDBCollectionNamespace, resolveTimeoutOptions } from '../utils';
28-
import * as cryptoCallbacks from './crypto_callbacks';
2928
import {
3029
defaultErrorWrapper,
3130
MongoCryptCreateDataKeyError,
@@ -144,7 +143,6 @@ export class ClientEncryption {
144143

145144
const mongoCryptOptions: MongoCryptOptions = {
146145
...options,
147-
cryptoCallbacks,
148146
kmsProviders: !Buffer.isBuffer(this._kmsProviders)
149147
? (serialize(this._kmsProviders) as Buffer)
150148
: this._kmsProviders,

src/client-side-encryption/crypto_callbacks.ts

Lines changed: 0 additions & 87 deletions
This file was deleted.

test/mongodb.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ export * from '../src/bulk/unordered';
104104
export * from '../src/change_stream';
105105
export * from '../src/client-side-encryption/auto_encrypter';
106106
export * from '../src/client-side-encryption/client_encryption';
107-
export * from '../src/client-side-encryption/crypto_callbacks';
108107
export * from '../src/client-side-encryption/errors';
109108
export * from '../src/client-side-encryption/mongocryptd_manager';
110109
export * from '../src/client-side-encryption/providers/aws';

test/unit/client-side-encryption/client_encryption.test.ts

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { resolve } from 'path';
55
import * as sinon from 'sinon';
66

77
import { ClientEncryption } from '../../../src/client-side-encryption/client_encryption';
8-
import * as cryptoCallbacks from '../../../src/client-side-encryption/crypto_callbacks';
98
import {
109
MongoCryptCreateDataKeyError,
1110
MongoCryptCreateEncryptedCollectionError
@@ -35,66 +34,6 @@ class MockClient {
3534
describe('ClientEncryption', function () {
3635
this.timeout(12000);
3736

38-
context('with stubbed key material and fixed random source', function () {
39-
const sandbox = sinon.createSandbox();
40-
41-
afterEach(() => {
42-
sandbox.restore();
43-
});
44-
beforeEach(() => {
45-
const rndData = Buffer.from(
46-
'\x4d\x06\x95\x64\xf5\xa0\x5e\x9e\x35\x23\xb9\x8f\x57\x5a\xcb\x15',
47-
'latin1'
48-
);
49-
let rndPos = 0;
50-
sandbox.stub(cryptoCallbacks, 'randomHook').callsFake((buffer, count) => {
51-
if (rndPos + count > rndData.length) {
52-
return new Error('Out of fake random data');
53-
}
54-
buffer.set(rndData.subarray(rndPos, rndPos + count));
55-
rndPos += count;
56-
return count;
57-
});
58-
59-
// stubbed out for AWS unit testing below
60-
sandbox.stub(StateMachine.prototype, 'fetchKeys').callsFake((client, ns, filter) => {
61-
filter = deserialize(filter);
62-
const keyIds = filter.$or[0]._id.$in.map(key => key.toString('hex'));
63-
const fileNames = keyIds.map(keyId =>
64-
resolve(`${__dirname}/data/keys/${keyId.toUpperCase()}-local-document.json`)
65-
);
66-
const contents = fileNames.map(filename =>
67-
EJSON.parse(fs.readFileSync(filename, { encoding: 'utf-8' }))
68-
);
69-
return Promise.resolve(contents);
70-
});
71-
});
72-
73-
// This exactly matches _test_encrypt_fle2_explicit from the C tests
74-
it('should explicitly encrypt and decrypt with the "local" KMS provider (FLE2, exact result)', function () {
75-
const encryption = new ClientEncryption(new MockClient(), {
76-
keyVaultNamespace: 'client.encryption',
77-
kmsProviders: { local: { key: Buffer.alloc(96) } }
78-
});
79-
80-
const encryptOptions = {
81-
keyId: new Binary(Buffer.from('ABCDEFAB123498761234123456789012', 'hex'), 4),
82-
algorithm: 'Unindexed'
83-
};
84-
85-
return encryption
86-
.encrypt('value123', encryptOptions)
87-
.then(encrypted => {
88-
expect(encrypted._bsontype).to.equal('Binary');
89-
expect(encrypted.sub_type).to.equal(6);
90-
return encryption.decrypt(encrypted);
91-
})
92-
.then(decrypted => {
93-
expect(decrypted).to.equal('value123');
94-
});
95-
});
96-
});
97-
9837
it('should provide the libmongocrypt version', function () {
9938
expect(ClientEncryption.libmongocryptVersion).to.be.a('string');
10039
});

0 commit comments

Comments
 (0)