node-opcua-binary-stream 2.176.0 → 2.179.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/binaryStream.d.ts +50 -1
- package/dist/binaryStream.js +149 -11
- package/dist/binaryStream.js.map +1 -1
- package/dist/binaryStreamSizeCalculator.d.ts +15 -9
- package/dist/binaryStreamSizeCalculator.js +22 -11
- package/dist/binaryStreamSizeCalculator.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/package.json +6 -6
- package/source/binaryStream.ts +183 -29
- package/source/binaryStreamSizeCalculator.ts +26 -14
- package/source/index.ts +2 -2
package/dist/binaryStream.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-binary-stream
|
|
3
3
|
*/
|
|
4
|
-
import "util";
|
|
4
|
+
import "node:util";
|
|
5
|
+
/**
|
|
6
|
+
* raised when a growable BinaryStream would have to exceed its declared maximum size.
|
|
7
|
+
*
|
|
8
|
+
* Distinct from every other encoding failure on purpose: a caller that sized the stream
|
|
9
|
+
* from a negotiated limit needs to tell "the peer's message is too big" apart from
|
|
10
|
+
* "the encoder is broken".
|
|
11
|
+
*/
|
|
12
|
+
export declare class BinaryStreamMaxSizeExceededError extends Error {
|
|
13
|
+
constructor(message: string);
|
|
14
|
+
}
|
|
5
15
|
/**
|
|
6
16
|
* a BinaryStream can be use to perform sequential read or write
|
|
7
17
|
* inside a buffer.
|
|
@@ -26,6 +36,7 @@ import "util";
|
|
|
26
36
|
|
|
27
37
|
*/
|
|
28
38
|
export declare class BinaryStream {
|
|
39
|
+
#private;
|
|
29
40
|
static maxByteStringLength: number;
|
|
30
41
|
static maxStringLength: number;
|
|
31
42
|
/**
|
|
@@ -36,6 +47,18 @@ export declare class BinaryStream {
|
|
|
36
47
|
* @internal
|
|
37
48
|
*/
|
|
38
49
|
buffer: Buffer;
|
|
50
|
+
/**
|
|
51
|
+
* create a stream that reallocates its buffer as needed, up to maxLength bytes.
|
|
52
|
+
*
|
|
53
|
+
* Encoding a message whose size is not known up front otherwise means encoding it
|
|
54
|
+
* twice: once into a BinaryStreamSizeCalculator to learn the length, then again for
|
|
55
|
+
* real. Both passes walk the whole object graph, and measuring shows the sizing pass
|
|
56
|
+
* costs about as much as the real one.
|
|
57
|
+
*
|
|
58
|
+
* @param initialSize starting capacity; a good guess avoids reallocation entirely
|
|
59
|
+
* @param maxLength hard ceiling - exceeding it throws BinaryStreamMaxSizeExceededError
|
|
60
|
+
*/
|
|
61
|
+
static createGrowable(initialSize: number, maxLength: number): BinaryStream;
|
|
39
62
|
constructor(data: undefined | Buffer | number);
|
|
40
63
|
/**
|
|
41
64
|
* set the cursor to the begining of the stream
|
|
@@ -84,6 +107,21 @@ export declare class BinaryStream {
|
|
|
84
107
|
* @param value the value to write
|
|
85
108
|
*/
|
|
86
109
|
writeDouble(value: number): void;
|
|
110
|
+
/**
|
|
111
|
+
* reserve room for a 32 bit unsigned integer whose value is not known yet,
|
|
112
|
+
* and return the position at which it can later be written with patchUInt32.
|
|
113
|
+
*
|
|
114
|
+
* This lets a length-prefixed body be written in a single pass: reserve the slot,
|
|
115
|
+
* encode the body, then patch in the byte count. The alternative - computing the
|
|
116
|
+
* size up front - means encoding the body twice, which compounds for nested
|
|
117
|
+
* structures.
|
|
118
|
+
*/
|
|
119
|
+
reserveUInt32(): number;
|
|
120
|
+
/**
|
|
121
|
+
* write a 32 bit unsigned integer at an absolute position previously returned by
|
|
122
|
+
* reserveUInt32, without moving the cursor.
|
|
123
|
+
*/
|
|
124
|
+
patchUInt32(position: number, value: number): void;
|
|
87
125
|
/**
|
|
88
126
|
* @param arrayBuf a buffer or byte array write
|
|
89
127
|
* @param offset the offset position (default =0)
|
|
@@ -147,6 +185,17 @@ export declare class BinaryStream {
|
|
|
147
185
|
readByteStream(): Buffer | null;
|
|
148
186
|
readString(): string | null;
|
|
149
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* resolve the (offset, length) arguments of writeArrayBuffer into a byte count.
|
|
190
|
+
*
|
|
191
|
+
* Shared by BinaryStream and BinaryStreamSizeCalculator so the two can never
|
|
192
|
+
* disagree: MessageChunker sizes a message with the calculator, allocates
|
|
193
|
+
* exactly that many bytes, then encodes with the stream. Any divergence here
|
|
194
|
+
* shows up as malformed chunk framing, not as a wrong number.
|
|
195
|
+
*
|
|
196
|
+
* @internal
|
|
197
|
+
*/
|
|
198
|
+
export declare function clampArrayBufferLength(byteLength: number, offset: number, length?: number): number;
|
|
150
199
|
/**
|
|
151
200
|
* @function calculateByteLength
|
|
152
201
|
* calculate the size in bytes of a utf8 string
|
package/dist/binaryStream.js
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BinaryStream = void 0;
|
|
3
|
+
exports.BinaryStream = exports.BinaryStreamMaxSizeExceededError = void 0;
|
|
4
|
+
exports.clampArrayBufferLength = clampArrayBufferLength;
|
|
4
5
|
exports.calculateByteLength = calculateByteLength;
|
|
5
6
|
/**
|
|
6
7
|
* @module node-opcua-binary-stream
|
|
7
8
|
*/
|
|
8
|
-
require("util");
|
|
9
|
+
require("node:util");
|
|
9
10
|
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
10
|
-
const node_opcua_buffer_utils_1 = require("node-opcua-buffer-utils");
|
|
11
11
|
const MAXUINT32 = 4294967295; // 2**32 -1;
|
|
12
12
|
const performCheck = false;
|
|
13
|
+
/**
|
|
14
|
+
* raised when a growable BinaryStream would have to exceed its declared maximum size.
|
|
15
|
+
*
|
|
16
|
+
* Distinct from every other encoding failure on purpose: a caller that sized the stream
|
|
17
|
+
* from a negotiated limit needs to tell "the peer's message is too big" apart from
|
|
18
|
+
* "the encoder is broken".
|
|
19
|
+
*/
|
|
20
|
+
class BinaryStreamMaxSizeExceededError extends Error {
|
|
21
|
+
constructor(message) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = "BinaryStreamMaxSizeExceededError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.BinaryStreamMaxSizeExceededError = BinaryStreamMaxSizeExceededError;
|
|
13
27
|
/**
|
|
14
28
|
* a BinaryStream can be use to perform sequential read or write
|
|
15
29
|
* inside a buffer.
|
|
@@ -44,12 +58,56 @@ class BinaryStream {
|
|
|
44
58
|
* @internal
|
|
45
59
|
*/
|
|
46
60
|
buffer;
|
|
61
|
+
/**
|
|
62
|
+
* 0 means "fixed size": the buffer is never reallocated and an overflowing write
|
|
63
|
+
* fails the same way it always has. A non-zero value turns the stream growable and
|
|
64
|
+
* caps how far it may grow. Kept as a single field so a fixed stream - the
|
|
65
|
+
* overwhelming majority - pays exactly one compare per write.
|
|
66
|
+
*/
|
|
67
|
+
#maxLength = 0;
|
|
68
|
+
/**
|
|
69
|
+
* create a stream that reallocates its buffer as needed, up to maxLength bytes.
|
|
70
|
+
*
|
|
71
|
+
* Encoding a message whose size is not known up front otherwise means encoding it
|
|
72
|
+
* twice: once into a BinaryStreamSizeCalculator to learn the length, then again for
|
|
73
|
+
* real. Both passes walk the whole object graph, and measuring shows the sizing pass
|
|
74
|
+
* costs about as much as the real one.
|
|
75
|
+
*
|
|
76
|
+
* @param initialSize starting capacity; a good guess avoids reallocation entirely
|
|
77
|
+
* @param maxLength hard ceiling - exceeding it throws BinaryStreamMaxSizeExceededError
|
|
78
|
+
*/
|
|
79
|
+
static createGrowable(initialSize, maxLength) {
|
|
80
|
+
const stream = new BinaryStream(Math.max(1, initialSize));
|
|
81
|
+
stream.#maxLength = maxLength;
|
|
82
|
+
return stream;
|
|
83
|
+
}
|
|
84
|
+
#ensure(n) {
|
|
85
|
+
if (this.#maxLength !== 0 && this.length + n > this.buffer.length) {
|
|
86
|
+
this.#grow(n);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
#grow(n) {
|
|
90
|
+
const needed = this.length + n;
|
|
91
|
+
if (needed > this.#maxLength) {
|
|
92
|
+
throw new BinaryStreamMaxSizeExceededError(`BinaryStream: cannot grow to ${needed} bytes, the maximum allowed size is ${this.#maxLength}`);
|
|
93
|
+
}
|
|
94
|
+
let newSize = this.buffer.length * 2;
|
|
95
|
+
while (newSize < needed) {
|
|
96
|
+
newSize *= 2;
|
|
97
|
+
}
|
|
98
|
+
if (newSize > this.#maxLength) {
|
|
99
|
+
newSize = this.#maxLength;
|
|
100
|
+
}
|
|
101
|
+
const bigger = Buffer.allocUnsafe(newSize);
|
|
102
|
+
this.buffer.copy(bigger, 0, 0, this.length);
|
|
103
|
+
this.buffer = bigger;
|
|
104
|
+
}
|
|
47
105
|
constructor(data) {
|
|
48
106
|
if (data === undefined) {
|
|
49
|
-
this.buffer =
|
|
107
|
+
this.buffer = Buffer.allocUnsafe(1024);
|
|
50
108
|
}
|
|
51
109
|
else if (typeof data === "number") {
|
|
52
|
-
this.buffer =
|
|
110
|
+
this.buffer = Buffer.allocUnsafe(data);
|
|
53
111
|
}
|
|
54
112
|
else {
|
|
55
113
|
(0, node_opcua_assert_1.assert)(data instanceof Buffer);
|
|
@@ -70,6 +128,7 @@ class BinaryStream {
|
|
|
70
128
|
* @param value the value to write
|
|
71
129
|
*/
|
|
72
130
|
writeInt8(value) {
|
|
131
|
+
this.#ensure(1);
|
|
73
132
|
// c8 ignore next
|
|
74
133
|
if (performCheck) {
|
|
75
134
|
(0, node_opcua_assert_1.assert)(this.buffer.length >= this.length + 1, "not enough space in buffer");
|
|
@@ -83,6 +142,7 @@ class BinaryStream {
|
|
|
83
142
|
* @param value the value to write
|
|
84
143
|
*/
|
|
85
144
|
writeUInt8(value) {
|
|
145
|
+
this.#ensure(1);
|
|
86
146
|
// c8 ignore next
|
|
87
147
|
if (performCheck) {
|
|
88
148
|
(0, node_opcua_assert_1.assert)(this.buffer.length >= this.length + 1, "not enough space in buffer");
|
|
@@ -96,6 +156,7 @@ class BinaryStream {
|
|
|
96
156
|
* @param value the value to write
|
|
97
157
|
*/
|
|
98
158
|
writeInt16(value) {
|
|
159
|
+
this.#ensure(2);
|
|
99
160
|
// c8 ignore next
|
|
100
161
|
if (performCheck) {
|
|
101
162
|
(0, node_opcua_assert_1.assert)(this.buffer.length >= this.length + 2, "not enough space in buffer");
|
|
@@ -108,6 +169,7 @@ class BinaryStream {
|
|
|
108
169
|
* @param value the value to write
|
|
109
170
|
*/
|
|
110
171
|
writeUInt16(value) {
|
|
172
|
+
this.#ensure(2);
|
|
111
173
|
// c8 ignore next
|
|
112
174
|
if (performCheck) {
|
|
113
175
|
(0, node_opcua_assert_1.assert)(this.buffer.length >= this.length + 2, "not enough space in buffer");
|
|
@@ -120,6 +182,7 @@ class BinaryStream {
|
|
|
120
182
|
* @param value the value to write
|
|
121
183
|
*/
|
|
122
184
|
writeInteger(value) {
|
|
185
|
+
this.#ensure(4);
|
|
123
186
|
// c8 ignore next
|
|
124
187
|
if (performCheck) {
|
|
125
188
|
(0, node_opcua_assert_1.assert)(this.buffer.length >= this.length + 4, "not enough space in buffer");
|
|
@@ -133,10 +196,11 @@ class BinaryStream {
|
|
|
133
196
|
* @param value the value to write
|
|
134
197
|
*/
|
|
135
198
|
writeUInt32(value) {
|
|
199
|
+
this.#ensure(4);
|
|
136
200
|
// c8 ignore next
|
|
137
201
|
if (performCheck) {
|
|
138
202
|
(0, node_opcua_assert_1.assert)(this.buffer.length >= this.length + 4, "not enough space in buffer");
|
|
139
|
-
(0, node_opcua_assert_1.assert)(isFinite(value));
|
|
203
|
+
(0, node_opcua_assert_1.assert)(Number.isFinite(value));
|
|
140
204
|
(0, node_opcua_assert_1.assert)(value >= 0 && value <= MAXUINT32);
|
|
141
205
|
}
|
|
142
206
|
this.buffer.writeUInt32LE(value, this.length);
|
|
@@ -153,6 +217,7 @@ class BinaryStream {
|
|
|
153
217
|
* @param value the value to write
|
|
154
218
|
*/
|
|
155
219
|
writeFloat(value) {
|
|
220
|
+
this.#ensure(4);
|
|
156
221
|
// c8 ignore next
|
|
157
222
|
if (performCheck) {
|
|
158
223
|
(0, node_opcua_assert_1.assert)(this.buffer.length >= this.length + 4, "not enough space in buffer");
|
|
@@ -165,6 +230,7 @@ class BinaryStream {
|
|
|
165
230
|
* @param value the value to write
|
|
166
231
|
*/
|
|
167
232
|
writeDouble(value) {
|
|
233
|
+
this.#ensure(8);
|
|
168
234
|
// c8 ignore next
|
|
169
235
|
if (performCheck) {
|
|
170
236
|
(0, node_opcua_assert_1.assert)(this.buffer.length >= this.length + 8, "not enough space in buffer");
|
|
@@ -172,21 +238,62 @@ class BinaryStream {
|
|
|
172
238
|
this.buffer.writeDoubleLE(value, this.length);
|
|
173
239
|
this.length += 8;
|
|
174
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* reserve room for a 32 bit unsigned integer whose value is not known yet,
|
|
243
|
+
* and return the position at which it can later be written with patchUInt32.
|
|
244
|
+
*
|
|
245
|
+
* This lets a length-prefixed body be written in a single pass: reserve the slot,
|
|
246
|
+
* encode the body, then patch in the byte count. The alternative - computing the
|
|
247
|
+
* size up front - means encoding the body twice, which compounds for nested
|
|
248
|
+
* structures.
|
|
249
|
+
*/
|
|
250
|
+
reserveUInt32() {
|
|
251
|
+
this.#ensure(4);
|
|
252
|
+
const position = this.length;
|
|
253
|
+
this.length += 4;
|
|
254
|
+
return position;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* write a 32 bit unsigned integer at an absolute position previously returned by
|
|
258
|
+
* reserveUInt32, without moving the cursor.
|
|
259
|
+
*/
|
|
260
|
+
patchUInt32(position, value) {
|
|
261
|
+
this.buffer.writeUInt32LE(value, position);
|
|
262
|
+
}
|
|
175
263
|
/**
|
|
176
264
|
* @param arrayBuf a buffer or byte array write
|
|
177
265
|
* @param offset the offset position (default =0)
|
|
178
266
|
* @param length the number of byte to write
|
|
179
267
|
*/
|
|
180
|
-
writeArrayBuffer(arrayBuf, offset = 0, length
|
|
268
|
+
writeArrayBuffer(arrayBuf, offset = 0, length) {
|
|
181
269
|
// c8 ignore next
|
|
182
270
|
if (performCheck) {
|
|
183
271
|
(0, node_opcua_assert_1.assert)(arrayBuf instanceof ArrayBuffer);
|
|
184
272
|
}
|
|
273
|
+
// note: for a real ArrayBuffer this is a zero-copy view. It also preserves the
|
|
274
|
+
// legacy shape where a caller passes a TypedArray instead: that takes the
|
|
275
|
+
// array-like constructor path and truncates element-wise, which some tests rely on.
|
|
185
276
|
const byteArr = new Uint8Array(arrayBuf);
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
277
|
+
// `length` must default to "the rest of the buffer", not to the *whole* buffer:
|
|
278
|
+
// the old `length || byteArr.length` turned an explicit 0 into a full copy, and
|
|
279
|
+
// ignored `offset` when length was omitted.
|
|
280
|
+
const len = clampArrayBufferLength(byteArr.length, offset, length);
|
|
281
|
+
if (len === 0) {
|
|
282
|
+
return;
|
|
189
283
|
}
|
|
284
|
+
this.#ensure(len);
|
|
285
|
+
// make sure there is enough room in destination buffer
|
|
286
|
+
const remainingBytes = this.buffer.length - this.length;
|
|
287
|
+
/* c8 ignore next */
|
|
288
|
+
if (remainingBytes < len) {
|
|
289
|
+
throw new Error("BinaryStream.writeArrayBuffer error : not enough bytes left in buffer : requested is " +
|
|
290
|
+
len +
|
|
291
|
+
" but only " +
|
|
292
|
+
remainingBytes +
|
|
293
|
+
" left");
|
|
294
|
+
}
|
|
295
|
+
this.buffer.set(byteArr.subarray(offset, offset + len), this.length);
|
|
296
|
+
this.length += len;
|
|
190
297
|
}
|
|
191
298
|
// writeArrayBuffer(arrayBuf, offset, length) {
|
|
192
299
|
// offset = offset || 0;
|
|
@@ -284,6 +391,7 @@ class BinaryStream {
|
|
|
284
391
|
}
|
|
285
392
|
(0, node_opcua_assert_1.assert)(buf instanceof Buffer);
|
|
286
393
|
this.writeInteger(buf.length);
|
|
394
|
+
this.#ensure(buf.length);
|
|
287
395
|
// make sure there is enough room in destination buffer
|
|
288
396
|
const remainingBytes = this.buffer.length - this.length;
|
|
289
397
|
/* c8 ignore next */
|
|
@@ -307,6 +415,7 @@ class BinaryStream {
|
|
|
307
415
|
if (byteLength === 0) {
|
|
308
416
|
return;
|
|
309
417
|
}
|
|
418
|
+
this.#ensure(byteLength);
|
|
310
419
|
// make sure there is enough room in destination buffer
|
|
311
420
|
const remainingBytes = this.buffer.length - this.length;
|
|
312
421
|
/* c8 ignore next */
|
|
@@ -419,6 +528,35 @@ class BinaryStream {
|
|
|
419
528
|
}
|
|
420
529
|
}
|
|
421
530
|
exports.BinaryStream = BinaryStream;
|
|
531
|
+
/**
|
|
532
|
+
* resolve the (offset, length) arguments of writeArrayBuffer into a byte count.
|
|
533
|
+
*
|
|
534
|
+
* Shared by BinaryStream and BinaryStreamSizeCalculator so the two can never
|
|
535
|
+
* disagree: MessageChunker sizes a message with the calculator, allocates
|
|
536
|
+
* exactly that many bytes, then encodes with the stream. Any divergence here
|
|
537
|
+
* shows up as malformed chunk framing, not as a wrong number.
|
|
538
|
+
*
|
|
539
|
+
* @internal
|
|
540
|
+
*/
|
|
541
|
+
function clampArrayBufferLength(byteLength, offset, length) {
|
|
542
|
+
// A negative offset would make `available` larger than the source, and
|
|
543
|
+
// TypedArray#subarray reads a negative start as an offset from the *end* - so the
|
|
544
|
+
// caller would advance the cursor by more bytes than were actually copied, leaving
|
|
545
|
+
// a window of untouched destination memory inside the stream. Reject it here, in
|
|
546
|
+
// the one place both the stream and the size calculator agree on.
|
|
547
|
+
if (!(offset >= 0)) {
|
|
548
|
+
throw new Error(`BinaryStream.writeArrayBuffer: offset must be a non-negative number, got ${offset}`);
|
|
549
|
+
}
|
|
550
|
+
const available = byteLength - offset;
|
|
551
|
+
if (available <= 0) {
|
|
552
|
+
return 0;
|
|
553
|
+
}
|
|
554
|
+
const requested = length === undefined ? available : length;
|
|
555
|
+
if (requested <= 0) {
|
|
556
|
+
return 0;
|
|
557
|
+
}
|
|
558
|
+
return requested < available ? requested : available;
|
|
559
|
+
}
|
|
422
560
|
/**
|
|
423
561
|
* @function calculateByteLength
|
|
424
562
|
* calculate the size in bytes of a utf8 string
|
|
@@ -443,5 +581,5 @@ function calculateByteLength(str) {
|
|
|
443
581
|
}
|
|
444
582
|
return s;
|
|
445
583
|
}
|
|
446
|
-
const zeroLengthBuffer =
|
|
584
|
+
const zeroLengthBuffer = Buffer.allocUnsafe(0);
|
|
447
585
|
//# sourceMappingURL=binaryStream.js.map
|
package/dist/binaryStream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binaryStream.js","sourceRoot":"","sources":["../source/binaryStream.ts"],"names":[],"mappings":";;;AA6cA,kDAgBC;AA7dD;;GAEG;AACH,gBAAc;AAEd,yDAA2C;AAC3C,qEAAwE;AAExE,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,YAAY;AAC1C,MAAM,YAAY,GAAG,KAAK,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,YAAY;IACd,MAAM,CAAC,mBAAmB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;IAC9C,MAAM,CAAC,eAAe,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;IACjD;;OAEG;IACI,MAAM,CAAS;IAEtB;;OAEG;IACI,MAAM,CAAS;IAEtB,YAAY,IAAiC;QACzC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACrB,IAAI,CAAC,MAAM,GAAG,IAAA,uDAA6B,EAAC,IAAI,CAAC,CAAC;QACtD,CAAC;aAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAClC,IAAI,CAAC,MAAM,GAAG,IAAA,uDAA6B,EAAC,IAAI,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACJ,IAAA,0BAAM,EAAC,IAAI,YAAY,MAAM,CAAC,CAAC;YAC/B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,CAAC;IAED;;;OAGG;IACI,MAAM;QACT,IAAI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C,CAAC,CAAC;QAC/B,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;YAC/B,CAAC,EAAE,CAAC;QACR,CAAC;aAAM,IAAI,IAAI,GAAG,KAAK,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;YACxC,CAAC,IAAI,CAAC,CAAC;QACX,CAAC;QACD,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;YACnC,kBAAkB;YAClB,CAAC,EAAE,CAAC;QACR,CAAC;IACL,CAAC;IACD,OAAO,CAAC,CAAC;AACb,CAAC;AAED,MAAM,gBAAgB,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -14,15 +14,21 @@ export declare class BinaryStreamSizeCalculator {
|
|
|
14
14
|
length: number;
|
|
15
15
|
constructor();
|
|
16
16
|
rewind(): void;
|
|
17
|
-
writeInt8(
|
|
18
|
-
writeUInt8(
|
|
19
|
-
writeInt16(
|
|
20
|
-
writeInteger(
|
|
21
|
-
writeUInt32(
|
|
22
|
-
writeUInt16(
|
|
23
|
-
writeFloat(
|
|
24
|
-
writeDouble(
|
|
25
|
-
|
|
17
|
+
writeInt8(_value: number): void;
|
|
18
|
+
writeUInt8(_value: number): void;
|
|
19
|
+
writeInt16(_value: number): void;
|
|
20
|
+
writeInteger(_value: number): void;
|
|
21
|
+
writeUInt32(_value: number): void;
|
|
22
|
+
writeUInt16(_value: number): void;
|
|
23
|
+
writeFloat(_value: number): void;
|
|
24
|
+
writeDouble(_value: number): void;
|
|
25
|
+
/**
|
|
26
|
+
* counterpart of BinaryStream.reserveUInt32: only the 4 reserved bytes matter here.
|
|
27
|
+
* The returned position is meaningless for a calculator - patchUInt32 ignores it.
|
|
28
|
+
*/
|
|
29
|
+
reserveUInt32(): number;
|
|
30
|
+
patchUInt32(_position: number, _value: number): void;
|
|
31
|
+
writeArrayBuffer(arrayBuf: ArrayBuffer, offset?: number, byteLength?: number): void;
|
|
26
32
|
writeByteStream(buf: Buffer): void;
|
|
27
33
|
writeString(str: null | string): void;
|
|
28
34
|
}
|
|
@@ -26,34 +26,45 @@ class BinaryStreamSizeCalculator {
|
|
|
26
26
|
rewind() {
|
|
27
27
|
this.length = 0;
|
|
28
28
|
}
|
|
29
|
-
writeInt8(
|
|
29
|
+
writeInt8(_value) {
|
|
30
30
|
this.length += 1;
|
|
31
31
|
}
|
|
32
|
-
writeUInt8(
|
|
32
|
+
writeUInt8(_value) {
|
|
33
33
|
this.length += 1;
|
|
34
34
|
}
|
|
35
|
-
writeInt16(
|
|
35
|
+
writeInt16(_value) {
|
|
36
36
|
this.length += 2;
|
|
37
37
|
}
|
|
38
|
-
writeInteger(
|
|
38
|
+
writeInteger(_value) {
|
|
39
39
|
this.length += 4;
|
|
40
40
|
}
|
|
41
|
-
writeUInt32(
|
|
41
|
+
writeUInt32(_value) {
|
|
42
42
|
this.length += 4;
|
|
43
43
|
}
|
|
44
|
-
writeUInt16(
|
|
44
|
+
writeUInt16(_value) {
|
|
45
45
|
this.length += 2;
|
|
46
46
|
}
|
|
47
|
-
writeFloat(
|
|
47
|
+
writeFloat(_value) {
|
|
48
48
|
this.length += 4;
|
|
49
49
|
}
|
|
50
|
-
writeDouble(
|
|
50
|
+
writeDouble(_value) {
|
|
51
51
|
this.length += 8;
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
/**
|
|
54
|
+
* counterpart of BinaryStream.reserveUInt32: only the 4 reserved bytes matter here.
|
|
55
|
+
* The returned position is meaningless for a calculator - patchUInt32 ignores it.
|
|
56
|
+
*/
|
|
57
|
+
reserveUInt32() {
|
|
58
|
+
this.length += 4;
|
|
59
|
+
return -1;
|
|
60
|
+
}
|
|
61
|
+
patchUInt32(_position, _value) {
|
|
62
|
+
/* nothing to patch: a size calculator only accumulates a byte count */
|
|
63
|
+
}
|
|
64
|
+
writeArrayBuffer(arrayBuf, offset = 0, byteLength) {
|
|
55
65
|
(0, node_opcua_assert_1.assert)(arrayBuf instanceof ArrayBuffer);
|
|
56
|
-
|
|
66
|
+
// must resolve (offset, byteLength) exactly as BinaryStream.writeArrayBuffer does
|
|
67
|
+
this.length += (0, binaryStream_1.clampArrayBufferLength)(arrayBuf.byteLength, offset, byteLength);
|
|
57
68
|
}
|
|
58
69
|
writeByteStream(buf) {
|
|
59
70
|
if (!buf) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binaryStreamSizeCalculator.js","sourceRoot":"","sources":["../source/binaryStreamSizeCalculator.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yDAA2C;AAC3C,
|
|
1
|
+
{"version":3,"file":"binaryStreamSizeCalculator.js","sourceRoot":"","sources":["../source/binaryStreamSizeCalculator.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yDAA2C;AAC3C,iDAA6E;AAE7E;;;;;;;;;;;GAWG;AACH,MAAa,0BAA0B;IAC5B,MAAM,CAAS;IAEtB;QACI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,CAAC;IAEM,MAAM;QACT,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,CAAC;IAEM,SAAS,CAAC,MAAc;QAC3B,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;IACrB,CAAC;IAEM,UAAU,CAAC,MAAc;QAC5B,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;IACrB,CAAC;IAEM,UAAU,CAAC,MAAc;QAC5B,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;IACrB,CAAC;IAEM,YAAY,CAAC,MAAc;QAC9B,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;IACrB,CAAC;IAEM,WAAW,CAAC,MAAc;QAC7B,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;IACrB,CAAC;IAEM,WAAW,CAAC,MAAc;QAC7B,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;IACrB,CAAC;IAEM,UAAU,CAAC,MAAc;QA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 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-binary-stream
|
|
3
3
|
*/
|
|
4
|
-
import { BinaryStream } from "./binaryStream";
|
|
5
|
-
import { BinaryStreamSizeCalculator } from "./binaryStreamSizeCalculator";
|
|
4
|
+
import type { BinaryStream } from "./binaryStream";
|
|
5
|
+
import type { BinaryStreamSizeCalculator } from "./binaryStreamSizeCalculator";
|
|
6
6
|
export type OutputBinaryStream = BinaryStream | BinaryStreamSizeCalculator;
|
|
7
7
|
export * from "./binaryStream";
|
|
8
8
|
export * from "./binaryStreamSizeCalculator";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-binary-stream",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.179.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module binary-stream",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
"build": "tsc -b",
|
|
9
9
|
"test": "mocha",
|
|
10
10
|
"clean": "npx rimraf -g node_modules dist *.tsbuildinfo",
|
|
11
|
-
"lint": "
|
|
11
|
+
"lint": "biome check --no-errors-on-unmatched ."
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"node-opcua-assert": "2.
|
|
15
|
-
"node-opcua-buffer-utils": "2.
|
|
14
|
+
"node-opcua-assert": "2.179.0",
|
|
15
|
+
"node-opcua-buffer-utils": "2.179.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"node-opcua-benchmarker": "2.
|
|
18
|
+
"node-opcua-benchmarker": "2.179.0"
|
|
19
19
|
},
|
|
20
20
|
"author": "Etienne Rossignon",
|
|
21
21
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"internet of things"
|
|
33
33
|
],
|
|
34
34
|
"homepage": "http://node-opcua.github.io/",
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "c78c6ee424bae3c6e851fabd8e144390e2941f8a",
|
|
36
36
|
"files": [
|
|
37
37
|
"dist",
|
|
38
38
|
"source"
|
package/source/binaryStream.ts
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-binary-stream
|
|
3
3
|
*/
|
|
4
|
-
import "util";
|
|
4
|
+
import "node:util";
|
|
5
5
|
|
|
6
6
|
import { assert } from "node-opcua-assert";
|
|
7
|
-
import { createFastUninitializedBuffer } from "node-opcua-buffer-utils";
|
|
8
7
|
|
|
9
8
|
const MAXUINT32 = 4294967295; // 2**32 -1;
|
|
10
9
|
const performCheck = false;
|
|
11
10
|
|
|
11
|
+
/**
|
|
12
|
+
* raised when a growable BinaryStream would have to exceed its declared maximum size.
|
|
13
|
+
*
|
|
14
|
+
* Distinct from every other encoding failure on purpose: a caller that sized the stream
|
|
15
|
+
* from a negotiated limit needs to tell "the peer's message is too big" apart from
|
|
16
|
+
* "the encoder is broken".
|
|
17
|
+
*/
|
|
18
|
+
export class BinaryStreamMaxSizeExceededError extends Error {
|
|
19
|
+
constructor(message: string) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = "BinaryStreamMaxSizeExceededError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
12
25
|
/**
|
|
13
26
|
* a BinaryStream can be use to perform sequential read or write
|
|
14
27
|
* inside a buffer.
|
|
@@ -45,11 +58,61 @@ export class BinaryStream {
|
|
|
45
58
|
*/
|
|
46
59
|
public buffer: Buffer;
|
|
47
60
|
|
|
61
|
+
/**
|
|
62
|
+
* 0 means "fixed size": the buffer is never reallocated and an overflowing write
|
|
63
|
+
* fails the same way it always has. A non-zero value turns the stream growable and
|
|
64
|
+
* caps how far it may grow. Kept as a single field so a fixed stream - the
|
|
65
|
+
* overwhelming majority - pays exactly one compare per write.
|
|
66
|
+
*/
|
|
67
|
+
#maxLength = 0;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* create a stream that reallocates its buffer as needed, up to maxLength bytes.
|
|
71
|
+
*
|
|
72
|
+
* Encoding a message whose size is not known up front otherwise means encoding it
|
|
73
|
+
* twice: once into a BinaryStreamSizeCalculator to learn the length, then again for
|
|
74
|
+
* real. Both passes walk the whole object graph, and measuring shows the sizing pass
|
|
75
|
+
* costs about as much as the real one.
|
|
76
|
+
*
|
|
77
|
+
* @param initialSize starting capacity; a good guess avoids reallocation entirely
|
|
78
|
+
* @param maxLength hard ceiling - exceeding it throws BinaryStreamMaxSizeExceededError
|
|
79
|
+
*/
|
|
80
|
+
public static createGrowable(initialSize: number, maxLength: number): BinaryStream {
|
|
81
|
+
const stream = new BinaryStream(Math.max(1, initialSize));
|
|
82
|
+
stream.#maxLength = maxLength;
|
|
83
|
+
return stream;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#ensure(n: number): void {
|
|
87
|
+
if (this.#maxLength !== 0 && this.length + n > this.buffer.length) {
|
|
88
|
+
this.#grow(n);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
#grow(n: number): void {
|
|
93
|
+
const needed = this.length + n;
|
|
94
|
+
if (needed > this.#maxLength) {
|
|
95
|
+
throw new BinaryStreamMaxSizeExceededError(
|
|
96
|
+
`BinaryStream: cannot grow to ${needed} bytes, the maximum allowed size is ${this.#maxLength}`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
let newSize = this.buffer.length * 2;
|
|
100
|
+
while (newSize < needed) {
|
|
101
|
+
newSize *= 2;
|
|
102
|
+
}
|
|
103
|
+
if (newSize > this.#maxLength) {
|
|
104
|
+
newSize = this.#maxLength;
|
|
105
|
+
}
|
|
106
|
+
const bigger = Buffer.allocUnsafe(newSize);
|
|
107
|
+
this.buffer.copy(bigger, 0, 0, this.length);
|
|
108
|
+
this.buffer = bigger;
|
|
109
|
+
}
|
|
110
|
+
|
|
48
111
|
constructor(data: undefined | Buffer | number) {
|
|
49
112
|
if (data === undefined) {
|
|
50
|
-
this.buffer =
|
|
113
|
+
this.buffer = Buffer.allocUnsafe(1024);
|
|
51
114
|
} else if (typeof data === "number") {
|
|
52
|
-
this.buffer =
|
|
115
|
+
this.buffer = Buffer.allocUnsafe(data);
|
|
53
116
|
} else {
|
|
54
117
|
assert(data instanceof Buffer);
|
|
55
118
|
this.buffer = data;
|
|
@@ -71,6 +134,7 @@ export class BinaryStream {
|
|
|
71
134
|
* @param value the value to write
|
|
72
135
|
*/
|
|
73
136
|
public writeInt8(value: number): void {
|
|
137
|
+
this.#ensure(1);
|
|
74
138
|
// c8 ignore next
|
|
75
139
|
if (performCheck) {
|
|
76
140
|
assert(this.buffer.length >= this.length + 1, "not enough space in buffer");
|
|
@@ -85,6 +149,7 @@ export class BinaryStream {
|
|
|
85
149
|
* @param value the value to write
|
|
86
150
|
*/
|
|
87
151
|
public writeUInt8(value: number): void {
|
|
152
|
+
this.#ensure(1);
|
|
88
153
|
// c8 ignore next
|
|
89
154
|
if (performCheck) {
|
|
90
155
|
assert(this.buffer.length >= this.length + 1, "not enough space in buffer");
|
|
@@ -99,6 +164,7 @@ export class BinaryStream {
|
|
|
99
164
|
* @param value the value to write
|
|
100
165
|
*/
|
|
101
166
|
public writeInt16(value: number): void {
|
|
167
|
+
this.#ensure(2);
|
|
102
168
|
// c8 ignore next
|
|
103
169
|
if (performCheck) {
|
|
104
170
|
assert(this.buffer.length >= this.length + 2, "not enough space in buffer");
|
|
@@ -112,6 +178,7 @@ export class BinaryStream {
|
|
|
112
178
|
* @param value the value to write
|
|
113
179
|
*/
|
|
114
180
|
public writeUInt16(value: number): void {
|
|
181
|
+
this.#ensure(2);
|
|
115
182
|
// c8 ignore next
|
|
116
183
|
if (performCheck) {
|
|
117
184
|
assert(this.buffer.length >= this.length + 2, "not enough space in buffer");
|
|
@@ -125,6 +192,7 @@ export class BinaryStream {
|
|
|
125
192
|
* @param value the value to write
|
|
126
193
|
*/
|
|
127
194
|
public writeInteger(value: number): void {
|
|
195
|
+
this.#ensure(4);
|
|
128
196
|
// c8 ignore next
|
|
129
197
|
if (performCheck) {
|
|
130
198
|
assert(this.buffer.length >= this.length + 4, "not enough space in buffer");
|
|
@@ -139,10 +207,11 @@ export class BinaryStream {
|
|
|
139
207
|
* @param value the value to write
|
|
140
208
|
*/
|
|
141
209
|
public writeUInt32(value: number): void {
|
|
210
|
+
this.#ensure(4);
|
|
142
211
|
// c8 ignore next
|
|
143
212
|
if (performCheck) {
|
|
144
213
|
assert(this.buffer.length >= this.length + 4, "not enough space in buffer");
|
|
145
|
-
assert(isFinite(value));
|
|
214
|
+
assert(Number.isFinite(value));
|
|
146
215
|
assert(value >= 0 && value <= MAXUINT32);
|
|
147
216
|
}
|
|
148
217
|
this.buffer.writeUInt32LE(value, this.length);
|
|
@@ -160,6 +229,7 @@ export class BinaryStream {
|
|
|
160
229
|
* @param value the value to write
|
|
161
230
|
*/
|
|
162
231
|
public writeFloat(value: number): void {
|
|
232
|
+
this.#ensure(4);
|
|
163
233
|
// c8 ignore next
|
|
164
234
|
if (performCheck) {
|
|
165
235
|
assert(this.buffer.length >= this.length + 4, "not enough space in buffer");
|
|
@@ -173,6 +243,7 @@ export class BinaryStream {
|
|
|
173
243
|
* @param value the value to write
|
|
174
244
|
*/
|
|
175
245
|
public writeDouble(value: number): void {
|
|
246
|
+
this.#ensure(8);
|
|
176
247
|
// c8 ignore next
|
|
177
248
|
if (performCheck) {
|
|
178
249
|
assert(this.buffer.length >= this.length + 8, "not enough space in buffer");
|
|
@@ -181,21 +252,66 @@ export class BinaryStream {
|
|
|
181
252
|
this.length += 8;
|
|
182
253
|
}
|
|
183
254
|
|
|
255
|
+
/**
|
|
256
|
+
* reserve room for a 32 bit unsigned integer whose value is not known yet,
|
|
257
|
+
* and return the position at which it can later be written with patchUInt32.
|
|
258
|
+
*
|
|
259
|
+
* This lets a length-prefixed body be written in a single pass: reserve the slot,
|
|
260
|
+
* encode the body, then patch in the byte count. The alternative - computing the
|
|
261
|
+
* size up front - means encoding the body twice, which compounds for nested
|
|
262
|
+
* structures.
|
|
263
|
+
*/
|
|
264
|
+
public reserveUInt32(): number {
|
|
265
|
+
this.#ensure(4);
|
|
266
|
+
const position = this.length;
|
|
267
|
+
this.length += 4;
|
|
268
|
+
return position;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* write a 32 bit unsigned integer at an absolute position previously returned by
|
|
273
|
+
* reserveUInt32, without moving the cursor.
|
|
274
|
+
*/
|
|
275
|
+
public patchUInt32(position: number, value: number): void {
|
|
276
|
+
this.buffer.writeUInt32LE(value, position);
|
|
277
|
+
}
|
|
278
|
+
|
|
184
279
|
/**
|
|
185
280
|
* @param arrayBuf a buffer or byte array write
|
|
186
281
|
* @param offset the offset position (default =0)
|
|
187
282
|
* @param length the number of byte to write
|
|
188
283
|
*/
|
|
189
|
-
public writeArrayBuffer(arrayBuf: ArrayBuffer, offset = 0, length
|
|
284
|
+
public writeArrayBuffer(arrayBuf: ArrayBuffer, offset = 0, length?: number): void {
|
|
190
285
|
// c8 ignore next
|
|
191
286
|
if (performCheck) {
|
|
192
287
|
assert(arrayBuf instanceof ArrayBuffer);
|
|
193
288
|
}
|
|
289
|
+
// note: for a real ArrayBuffer this is a zero-copy view. It also preserves the
|
|
290
|
+
// legacy shape where a caller passes a TypedArray instead: that takes the
|
|
291
|
+
// array-like constructor path and truncates element-wise, which some tests rely on.
|
|
194
292
|
const byteArr = new Uint8Array(arrayBuf);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
293
|
+
// `length` must default to "the rest of the buffer", not to the *whole* buffer:
|
|
294
|
+
// the old `length || byteArr.length` turned an explicit 0 into a full copy, and
|
|
295
|
+
// ignored `offset` when length was omitted.
|
|
296
|
+
const len = clampArrayBufferLength(byteArr.length, offset, length);
|
|
297
|
+
if (len === 0) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
this.#ensure(len);
|
|
301
|
+
// make sure there is enough room in destination buffer
|
|
302
|
+
const remainingBytes = this.buffer.length - this.length;
|
|
303
|
+
/* c8 ignore next */
|
|
304
|
+
if (remainingBytes < len) {
|
|
305
|
+
throw new Error(
|
|
306
|
+
"BinaryStream.writeArrayBuffer error : not enough bytes left in buffer : requested is " +
|
|
307
|
+
len +
|
|
308
|
+
" but only " +
|
|
309
|
+
remainingBytes +
|
|
310
|
+
" left"
|
|
311
|
+
);
|
|
198
312
|
}
|
|
313
|
+
this.buffer.set(byteArr.subarray(offset, offset + len), this.length);
|
|
314
|
+
this.length += len;
|
|
199
315
|
}
|
|
200
316
|
|
|
201
317
|
// writeArrayBuffer(arrayBuf, offset, length) {
|
|
@@ -304,6 +420,7 @@ export class BinaryStream {
|
|
|
304
420
|
}
|
|
305
421
|
assert(buf instanceof Buffer);
|
|
306
422
|
this.writeInteger(buf.length);
|
|
423
|
+
this.#ensure(buf.length);
|
|
307
424
|
// make sure there is enough room in destination buffer
|
|
308
425
|
const remainingBytes = this.buffer.length - this.length;
|
|
309
426
|
|
|
@@ -311,10 +428,10 @@ export class BinaryStream {
|
|
|
311
428
|
if (remainingBytes < buf.length) {
|
|
312
429
|
throw new Error(
|
|
313
430
|
"BinaryStream.writeByteStream error : not enough bytes left in buffer : bufferLength is " +
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
431
|
+
buf.length +
|
|
432
|
+
" but only " +
|
|
433
|
+
remainingBytes +
|
|
434
|
+
" left"
|
|
318
435
|
);
|
|
319
436
|
}
|
|
320
437
|
buf.copy(this.buffer, this.length, 0, buf.length);
|
|
@@ -331,16 +448,17 @@ export class BinaryStream {
|
|
|
331
448
|
if (byteLength === 0) {
|
|
332
449
|
return;
|
|
333
450
|
}
|
|
451
|
+
this.#ensure(byteLength);
|
|
334
452
|
// make sure there is enough room in destination buffer
|
|
335
453
|
const remainingBytes = this.buffer.length - this.length;
|
|
336
454
|
/* c8 ignore next */
|
|
337
455
|
if (remainingBytes < byteLength) {
|
|
338
456
|
throw new Error(
|
|
339
457
|
"BinaryStream.writeByteStream error : not enough bytes left in buffer : bufferLength is " +
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
458
|
+
byteLength +
|
|
459
|
+
" but only " +
|
|
460
|
+
remainingBytes +
|
|
461
|
+
" left"
|
|
344
462
|
);
|
|
345
463
|
}
|
|
346
464
|
this.buffer.write(value, this.length);
|
|
@@ -369,7 +487,9 @@ export class BinaryStream {
|
|
|
369
487
|
|
|
370
488
|
public readArrayBuffer(length: number): Uint8Array {
|
|
371
489
|
if (length > BinaryStream.maxByteStringLength) {
|
|
372
|
-
throw new Error(
|
|
490
|
+
throw new Error(
|
|
491
|
+
`maxStringLength(${BinaryStream.maxByteStringLength}) has been exceeded in BinaryStream.readArrayBuffer len=${length}`
|
|
492
|
+
);
|
|
373
493
|
}
|
|
374
494
|
// c8 ignore next
|
|
375
495
|
if (performCheck) {
|
|
@@ -404,7 +524,9 @@ export class BinaryStream {
|
|
|
404
524
|
return zeroLengthBuffer;
|
|
405
525
|
}
|
|
406
526
|
if (bufLen > BinaryStream.maxByteStringLength) {
|
|
407
|
-
throw new Error(
|
|
527
|
+
throw new Error(
|
|
528
|
+
`maxStringLength(${BinaryStream.maxByteStringLength}) has been exceeded in BinaryStream.readArrayBuffer len=${bufLen}`
|
|
529
|
+
);
|
|
408
530
|
}
|
|
409
531
|
// check that there is enough space in the buffer
|
|
410
532
|
const remainingBytes = this.buffer.length - this.length;
|
|
@@ -412,10 +534,10 @@ export class BinaryStream {
|
|
|
412
534
|
if (remainingBytes < bufLen) {
|
|
413
535
|
throw new Error(
|
|
414
536
|
"BinaryStream.readByteStream error : not enough bytes left in buffer : bufferLength is " +
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
537
|
+
bufLen +
|
|
538
|
+
" but only " +
|
|
539
|
+
remainingBytes +
|
|
540
|
+
" left"
|
|
419
541
|
);
|
|
420
542
|
}
|
|
421
543
|
// create a shared memory buffer ! for speed
|
|
@@ -433,7 +555,9 @@ export class BinaryStream {
|
|
|
433
555
|
return "";
|
|
434
556
|
}
|
|
435
557
|
if (bufLen > BinaryStream.maxStringLength) {
|
|
436
|
-
throw new Error(
|
|
558
|
+
throw new Error(
|
|
559
|
+
`maxStringLength(${BinaryStream.maxStringLength}) has been exceeded in BinaryStream.readString len=${bufLen}`
|
|
560
|
+
);
|
|
437
561
|
}
|
|
438
562
|
// check that there is enough space in the buffer
|
|
439
563
|
const remainingBytes = this.buffer.length - this.length;
|
|
@@ -441,10 +565,10 @@ export class BinaryStream {
|
|
|
441
565
|
if (remainingBytes < bufLen) {
|
|
442
566
|
throw new Error(
|
|
443
567
|
"BinaryStream.readByteStream error : not enough bytes left in buffer : bufferLength is " +
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
568
|
+
bufLen +
|
|
569
|
+
" but only " +
|
|
570
|
+
remainingBytes +
|
|
571
|
+
" left"
|
|
448
572
|
);
|
|
449
573
|
}
|
|
450
574
|
const str = this.buffer.toString("utf-8", this.length, this.length + bufLen);
|
|
@@ -453,6 +577,36 @@ export class BinaryStream {
|
|
|
453
577
|
}
|
|
454
578
|
}
|
|
455
579
|
|
|
580
|
+
/**
|
|
581
|
+
* resolve the (offset, length) arguments of writeArrayBuffer into a byte count.
|
|
582
|
+
*
|
|
583
|
+
* Shared by BinaryStream and BinaryStreamSizeCalculator so the two can never
|
|
584
|
+
* disagree: MessageChunker sizes a message with the calculator, allocates
|
|
585
|
+
* exactly that many bytes, then encodes with the stream. Any divergence here
|
|
586
|
+
* shows up as malformed chunk framing, not as a wrong number.
|
|
587
|
+
*
|
|
588
|
+
* @internal
|
|
589
|
+
*/
|
|
590
|
+
export function clampArrayBufferLength(byteLength: number, offset: number, length?: number): number {
|
|
591
|
+
// A negative offset would make `available` larger than the source, and
|
|
592
|
+
// TypedArray#subarray reads a negative start as an offset from the *end* - so the
|
|
593
|
+
// caller would advance the cursor by more bytes than were actually copied, leaving
|
|
594
|
+
// a window of untouched destination memory inside the stream. Reject it here, in
|
|
595
|
+
// the one place both the stream and the size calculator agree on.
|
|
596
|
+
if (!(offset >= 0)) {
|
|
597
|
+
throw new Error(`BinaryStream.writeArrayBuffer: offset must be a non-negative number, got ${offset}`);
|
|
598
|
+
}
|
|
599
|
+
const available = byteLength - offset;
|
|
600
|
+
if (available <= 0) {
|
|
601
|
+
return 0;
|
|
602
|
+
}
|
|
603
|
+
const requested = length === undefined ? available : length;
|
|
604
|
+
if (requested <= 0) {
|
|
605
|
+
return 0;
|
|
606
|
+
}
|
|
607
|
+
return requested < available ? requested : available;
|
|
608
|
+
}
|
|
609
|
+
|
|
456
610
|
/**
|
|
457
611
|
* @function calculateByteLength
|
|
458
612
|
* calculate the size in bytes of a utf8 string
|
|
@@ -477,4 +631,4 @@ export function calculateByteLength(str: string): number {
|
|
|
477
631
|
return s;
|
|
478
632
|
}
|
|
479
633
|
|
|
480
|
-
const zeroLengthBuffer =
|
|
634
|
+
const zeroLengthBuffer = Buffer.allocUnsafe(0);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module node-opcua-binary-stream
|
|
3
3
|
*/
|
|
4
4
|
import { assert } from "node-opcua-assert";
|
|
5
|
-
import { calculateByteLength } from "./binaryStream";
|
|
5
|
+
import { calculateByteLength, clampArrayBufferLength } from "./binaryStream";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* a BinaryStreamSizeCalculator can be used to quickly evaluate the required size
|
|
@@ -17,7 +17,6 @@ import { calculateByteLength } from "./binaryStream";
|
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
19
|
export class BinaryStreamSizeCalculator {
|
|
20
|
-
|
|
21
20
|
public length: number;
|
|
22
21
|
|
|
23
22
|
constructor() {
|
|
@@ -28,42 +27,55 @@ export class BinaryStreamSizeCalculator {
|
|
|
28
27
|
this.length = 0;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
public writeInt8(
|
|
30
|
+
public writeInt8(_value: number): void {
|
|
32
31
|
this.length += 1;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
public writeUInt8(
|
|
34
|
+
public writeUInt8(_value: number): void {
|
|
36
35
|
this.length += 1;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
public writeInt16(
|
|
38
|
+
public writeInt16(_value: number): void {
|
|
40
39
|
this.length += 2;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
public writeInteger(
|
|
42
|
+
public writeInteger(_value: number): void {
|
|
44
43
|
this.length += 4;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
public writeUInt32(
|
|
46
|
+
public writeUInt32(_value: number): void {
|
|
48
47
|
this.length += 4;
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
public writeUInt16(
|
|
50
|
+
public writeUInt16(_value: number): void {
|
|
52
51
|
this.length += 2;
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
public
|
|
54
|
+
public writeFloat(_value: number): void {
|
|
56
55
|
this.length += 4;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
public writeDouble(
|
|
58
|
+
public writeDouble(_value: number): void {
|
|
60
59
|
this.length += 8;
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
/**
|
|
63
|
+
* counterpart of BinaryStream.reserveUInt32: only the 4 reserved bytes matter here.
|
|
64
|
+
* The returned position is meaningless for a calculator - patchUInt32 ignores it.
|
|
65
|
+
*/
|
|
66
|
+
public reserveUInt32(): number {
|
|
67
|
+
this.length += 4;
|
|
68
|
+
return -1;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public patchUInt32(_position: number, _value: number): void {
|
|
72
|
+
/* nothing to patch: a size calculator only accumulates a byte count */
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public writeArrayBuffer(arrayBuf: ArrayBuffer, offset = 0, byteLength?: number): void {
|
|
65
76
|
assert(arrayBuf instanceof ArrayBuffer);
|
|
66
|
-
|
|
77
|
+
// must resolve (offset, byteLength) exactly as BinaryStream.writeArrayBuffer does
|
|
78
|
+
this.length += clampArrayBufferLength(arrayBuf.byteLength, offset, byteLength);
|
|
67
79
|
}
|
|
68
80
|
|
|
69
81
|
public writeByteStream(buf: Buffer): void {
|
|
@@ -75,7 +87,7 @@ export class BinaryStreamSizeCalculator {
|
|
|
75
87
|
}
|
|
76
88
|
}
|
|
77
89
|
|
|
78
|
-
public writeString(str: null|string): void {
|
|
90
|
+
public writeString(str: null | string): void {
|
|
79
91
|
if (str === undefined || str === null) {
|
|
80
92
|
this.writeUInt32(-1);
|
|
81
93
|
return;
|
package/source/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-binary-stream
|
|
3
3
|
*/
|
|
4
|
-
import { BinaryStream } from "./binaryStream";
|
|
5
|
-
import { BinaryStreamSizeCalculator } from "./binaryStreamSizeCalculator";
|
|
4
|
+
import type { BinaryStream } from "./binaryStream";
|
|
5
|
+
import type { BinaryStreamSizeCalculator } from "./binaryStreamSizeCalculator";
|
|
6
6
|
export type OutputBinaryStream = BinaryStream | BinaryStreamSizeCalculator;
|
|
7
7
|
|
|
8
8
|
export * from "./binaryStream";
|