From ff1bb915ee23b45c4532df5876b6689594b83b40 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Fri, 17 Sep 2021 15:52:16 -0400 Subject: [PATCH 1/2] fix(NODE-3534): add subtype 0x6 and 0x7 constants on Binary class --- src/binary.ts | 4 ++++ src/bson.ts | 2 ++ src/constants.ts | 6 ++++++ test/node/check_constants.js | 10 ++++++++++ test/node/specs/bson-corpus/binary.json | 5 +++++ 5 files changed, 27 insertions(+) diff --git a/src/binary.ts b/src/binary.ts index 20619dec..8e4e10af 100644 --- a/src/binary.ts +++ b/src/binary.ts @@ -48,6 +48,10 @@ export class Binary { static readonly SUBTYPE_UUID = 4; /** MD5 BSON type */ static readonly SUBTYPE_MD5 = 5; + /** Encrypted BSON type */ + static readonly SUBTYPE_ENCRYPTED = 6; + /** Column BSON type */ + static readonly SUBTYPE_COLUMN = 7; /** User BSON type */ static readonly SUBTYPE_USER_DEFINED = 128; diff --git a/src/bson.ts b/src/bson.ts index 550539d3..22acdb67 100644 --- a/src/bson.ts +++ b/src/bson.ts @@ -30,6 +30,8 @@ export { BSON_BINARY_SUBTYPE_USER_DEFINED, BSON_BINARY_SUBTYPE_UUID, BSON_BINARY_SUBTYPE_UUID_NEW, + BSON_BINARY_SUBTYPE_ENCRYPTED, + BSON_BINARY_SUBTYPE_COLUMN, BSON_DATA_ARRAY, BSON_DATA_BINARY, BSON_DATA_BOOLEAN, diff --git a/src/constants.ts b/src/constants.ts index 22b411eb..6af63e69 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -100,5 +100,11 @@ export const BSON_BINARY_SUBTYPE_UUID_NEW = 4; /** Binary MD5 Type @internal */ export const BSON_BINARY_SUBTYPE_MD5 = 5; +/** Encrypted BSON type @internal */ +export const BSON_BINARY_SUBTYPE_ENCRYPTED = 6; + +/** Column BSON type @internal */ +export const BSON_BINARY_SUBTYPE_COLUMN = 7; + /** Binary User Defined Type @internal */ export const BSON_BINARY_SUBTYPE_USER_DEFINED = 128; diff --git a/test/node/check_constants.js b/test/node/check_constants.js index f223e9c1..6a91d604 100644 --- a/test/node/check_constants.js +++ b/test/node/check_constants.js @@ -39,6 +39,16 @@ describe('BSON Constants', () => { expect(BSON.BSON_BINARY_SUBTYPE_MD5).to.equal(5); expect(BSON.Binary.SUBTYPE_MD5).to.equal(5); }); + + it('Encrypted should be 6', () => { + expect(BSON.BSON_BINARY_SUBTYPE_ENCRYPTED).to.equal(6); + expect(BSON.Binary.SUBTYPE_ENCRYPTED).to.equal(6); + }); + + it('Column should be 7', () => { + expect(BSON.BSON_BINARY_SUBTYPE_COLUMN).to.equal(7); + expect(BSON.Binary.SUBTYPE_COLUMN).to.equal(7); + }); }); context('BSON Type indicators', () => { /* diff --git a/test/node/specs/bson-corpus/binary.json b/test/node/specs/bson-corpus/binary.json index dd1ebfa1..beb2e07a 100644 --- a/test/node/specs/bson-corpus/binary.json +++ b/test/node/specs/bson-corpus/binary.json @@ -50,6 +50,11 @@ "canonical_bson": "1D000000057800100000000573FFD26444B34C6990E8E7D1DFC035D400", "canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"05\"}}}" }, + { + "description": "subtype 0x07", + "canonical_bson": "1D000000057800100000000773FFD26444B34C6990E8E7D1DFC035D400", + "canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"07\"}}}" + }, { "description": "subtype 0x80", "canonical_bson": "0F0000000578000200000080FFFF00", From 7aedc2ed2e4e79aded139ffedfc304c8408b392f Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Fri, 17 Sep 2021 16:00:41 -0400 Subject: [PATCH 2/2] fix: package-lock version number out of sync somehow --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index aed765f7..77cdbbc8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "bson", - "version": "4.5.1", + "version": "4.5.2", "license": "Apache-2.0", "dependencies": { "buffer": "^5.6.0"