File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 11import zlib from 'zlib' ;
22import { promisify , TextDecoder } from 'util' ;
3- import { deserialize } from 'bson' ;
3+ import { type Binary , deserialize } from 'bson' ;
44
55class MessageHeader {
66 messageLength : number ;
@@ -54,9 +54,24 @@ type OpContents = OpMsg | OpReply | OpUpdate | OpInsert | OpQuery | OpGetMore |
5454
5555class BSONBuffer {
5656 data : any ;
57+ decodedPayload ?: any ;
5758
5859 constructor ( buf : Uint8Array ) {
5960 this . data = deserialize ( buf ) ;
61+ let payload : undefined | Binary ;
62+ if ( ( this . data . saslStart || this . data . saslContinue || this . data . conversationId ) &&
63+ this . data . payload ?. _bsontype === 'Binary' ) {
64+ payload = this . data . payload ;
65+ }
66+ if ( this . data . speculativeAuthenticate ?. payload ?. _bsontype === 'Binary' ) {
67+ payload = this . data . speculativeAuthenticate . payload ;
68+ }
69+ try {
70+ if ( payload ) {
71+ this . decodedPayload = deserialize ( payload . value ( ) ) ;
72+ }
73+ } catch ( err ) {
74+ }
6075 }
6176}
6277
You can’t perform that action at this time.
0 commit comments