Skip to content

fix(NODE-3534): add subtype 0x6 and 0x7 constants on Binary class #461

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 2 commits into from
Sep 17, 2021
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
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/bson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
10 changes: 10 additions & 0 deletions test/node/check_constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
/*
Expand Down
5 changes: 5 additions & 0 deletions test/node/specs/bson-corpus/binary.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down