Skip to content

Commit b01c6fd

Browse files
committed
Add support for security token sections
1 parent 9b486c9 commit b01c6fd

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/parse.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/parse.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ class OpMsgBodySection {
6969
}
7070
}
7171

72+
class OpMsgSecurityTokenSection {
73+
kind = 'SecurityToken' as const;
74+
body: BSONBuffer;
75+
76+
constructor(body: BSONBuffer) {
77+
this.body = body;
78+
}
79+
}
80+
7281
class OpMsgDocumentSequenceSection {
7382
kind = 'DocumentSequence' as const;
7483
docSequenceId: string;
@@ -92,7 +101,7 @@ class OpMsgUnknownSection {
92101
class OpMsg {
93102
opCode = 'OP_MSG' as const;
94103
flagBits: number;
95-
sections: (OpMsgBodySection | OpMsgDocumentSequenceSection | OpMsgUnknownSection)[];
104+
sections: (OpMsgBodySection | OpMsgDocumentSequenceSection | OpMsgSecurityTokenSection | OpMsgUnknownSection)[];
96105
checksum: number | null;
97106

98107
constructor(values: Pick<OpMsg, 'flagBits' | 'sections' | 'checksum'>) {
@@ -134,6 +143,13 @@ class OpMsg {
134143
sections.push(new OpMsgDocumentSequenceSection(docSequenceId, objects));
135144
}
136145
break;
146+
case 2: {
147+
const bsonSize = dv.getUint32(i + 1, true);
148+
sections.push(new OpMsgSecurityTokenSection(
149+
new BSONBuffer(new Uint8Array(dv.buffer, dv.byteOffset + i + 1, bsonSize))));
150+
i += 1 + bsonSize;
151+
}
152+
break;
137153
default: {
138154
sections.push(new OpMsgUnknownSection(kind));
139155
i = length;

0 commit comments

Comments
 (0)