Skip to content

Commit 52cfe9c

Browse files
authored
fix(NODE-3534): add subtype 0x6 and 0x7 constants on Binary class (#461)
1 parent dea5e13 commit 52cfe9c

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/binary.ts

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ export class Binary {
4848
static readonly SUBTYPE_UUID = 4;
4949
/** MD5 BSON type */
5050
static readonly SUBTYPE_MD5 = 5;
51+
/** Encrypted BSON type */
52+
static readonly SUBTYPE_ENCRYPTED = 6;
53+
/** Column BSON type */
54+
static readonly SUBTYPE_COLUMN = 7;
5155
/** User BSON type */
5256
static readonly SUBTYPE_USER_DEFINED = 128;
5357

src/bson.ts

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export {
3030
BSON_BINARY_SUBTYPE_USER_DEFINED,
3131
BSON_BINARY_SUBTYPE_UUID,
3232
BSON_BINARY_SUBTYPE_UUID_NEW,
33+
BSON_BINARY_SUBTYPE_ENCRYPTED,
34+
BSON_BINARY_SUBTYPE_COLUMN,
3335
BSON_DATA_ARRAY,
3436
BSON_DATA_BINARY,
3537
BSON_DATA_BOOLEAN,

src/constants.ts

+6
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,11 @@ export const BSON_BINARY_SUBTYPE_UUID_NEW = 4;
100100
/** Binary MD5 Type @internal */
101101
export const BSON_BINARY_SUBTYPE_MD5 = 5;
102102

103+
/** Encrypted BSON type @internal */
104+
export const BSON_BINARY_SUBTYPE_ENCRYPTED = 6;
105+
106+
/** Column BSON type @internal */
107+
export const BSON_BINARY_SUBTYPE_COLUMN = 7;
108+
103109
/** Binary User Defined Type @internal */
104110
export const BSON_BINARY_SUBTYPE_USER_DEFINED = 128;

test/node/check_constants.js

+10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ describe('BSON Constants', () => {
3939
expect(BSON.BSON_BINARY_SUBTYPE_MD5).to.equal(5);
4040
expect(BSON.Binary.SUBTYPE_MD5).to.equal(5);
4141
});
42+
43+
it('Encrypted should be 6', () => {
44+
expect(BSON.BSON_BINARY_SUBTYPE_ENCRYPTED).to.equal(6);
45+
expect(BSON.Binary.SUBTYPE_ENCRYPTED).to.equal(6);
46+
});
47+
48+
it('Column should be 7', () => {
49+
expect(BSON.BSON_BINARY_SUBTYPE_COLUMN).to.equal(7);
50+
expect(BSON.Binary.SUBTYPE_COLUMN).to.equal(7);
51+
});
4252
});
4353
context('BSON Type indicators', () => {
4454
/*

test/node/specs/bson-corpus/binary.json

+5
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
"canonical_bson": "1D000000057800100000000573FFD26444B34C6990E8E7D1DFC035D400",
5151
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"05\"}}}"
5252
},
53+
{
54+
"description": "subtype 0x07",
55+
"canonical_bson": "1D000000057800100000000773FFD26444B34C6990E8E7D1DFC035D400",
56+
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"07\"}}}"
57+
},
5358
{
5459
"description": "subtype 0x80",
5560
"canonical_bson": "0F0000000578000200000080FFFF00",

0 commit comments

Comments
 (0)