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 1
1
import zlib from 'zlib' ;
2
2
import { promisify , TextDecoder } from 'util' ;
3
- import { deserialize } from 'bson' ;
3
+ import { type Binary , deserialize } from 'bson' ;
4
4
5
5
class MessageHeader {
6
6
messageLength : number ;
@@ -54,9 +54,24 @@ type OpContents = OpMsg | OpReply | OpUpdate | OpInsert | OpQuery | OpGetMore |
54
54
55
55
class BSONBuffer {
56
56
data : any ;
57
+ decodedPayload ?: any ;
57
58
58
59
constructor ( buf : Uint8Array ) {
59
60
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
+ }
60
75
}
61
76
}
62
77
You can’t perform that action at this time.
0 commit comments