werift 0.25.0 → 0.25.1

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.
Files changed (80) hide show
  1. package/lib/common/src/binaryData.d.ts +116 -0
  2. package/lib/common/src/binaryData.js +421 -0
  3. package/lib/common/src/binaryData.js.map +1 -0
  4. package/lib/common/src/index.d.ts +1 -0
  5. package/lib/common/src/index.js +24 -0
  6. package/lib/common/src/index.js.map +1 -1
  7. package/lib/dtls/src/cipher/prf.d.ts +2 -2
  8. package/lib/dtls/src/cipher/prf.js +2 -2
  9. package/lib/dtls/src/cipher/prf.js.map +1 -1
  10. package/lib/dtls/src/context/cipher.js +4 -3
  11. package/lib/dtls/src/context/cipher.js.map +1 -1
  12. package/lib/dtls/src/handshake/binary.d.ts +12 -8
  13. package/lib/dtls/src/handshake/binary.js +3 -2
  14. package/lib/dtls/src/handshake/binary.js.map +1 -1
  15. package/lib/dtls/src/handshake/extensions/ellipticCurves.d.ts +4 -3
  16. package/lib/dtls/src/handshake/extensions/ellipticCurves.js +7 -6
  17. package/lib/dtls/src/handshake/extensions/ellipticCurves.js.map +1 -1
  18. package/lib/dtls/src/handshake/extensions/renegotiationIndication.d.ts +4 -3
  19. package/lib/dtls/src/handshake/extensions/renegotiationIndication.js +6 -6
  20. package/lib/dtls/src/handshake/extensions/renegotiationIndication.js.map +1 -1
  21. package/lib/dtls/src/handshake/extensions/signature.d.ts +7 -3
  22. package/lib/dtls/src/handshake/extensions/signature.js +6 -6
  23. package/lib/dtls/src/handshake/extensions/signature.js.map +1 -1
  24. package/lib/dtls/src/handshake/extensions/useSrtp.d.ts +4 -3
  25. package/lib/dtls/src/handshake/extensions/useSrtp.js +6 -6
  26. package/lib/dtls/src/handshake/extensions/useSrtp.js.map +1 -1
  27. package/lib/dtls/src/handshake/message/alert.d.ts +4 -3
  28. package/lib/dtls/src/handshake/message/alert.js +6 -6
  29. package/lib/dtls/src/handshake/message/alert.js.map +1 -1
  30. package/lib/dtls/src/handshake/message/certificate.d.ts +3 -2
  31. package/lib/dtls/src/handshake/message/certificate.js +5 -5
  32. package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
  33. package/lib/dtls/src/handshake/message/changeCipherSpec.d.ts +3 -2
  34. package/lib/dtls/src/handshake/message/changeCipherSpec.js +5 -5
  35. package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
  36. package/lib/dtls/src/handshake/message/client/certificateVerify.d.ts +4 -3
  37. package/lib/dtls/src/handshake/message/client/certificateVerify.js +6 -6
  38. package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
  39. package/lib/dtls/src/handshake/message/client/hello.d.ts +14 -10
  40. package/lib/dtls/src/handshake/message/client/hello.js +9 -9
  41. package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
  42. package/lib/dtls/src/handshake/message/client/keyExchange.d.ts +3 -2
  43. package/lib/dtls/src/handshake/message/client/keyExchange.js +5 -5
  44. package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
  45. package/lib/dtls/src/handshake/message/server/certificateRequest.d.ts +8 -4
  46. package/lib/dtls/src/handshake/message/server/certificateRequest.js +7 -7
  47. package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
  48. package/lib/dtls/src/handshake/message/server/hello.d.ts +9 -8
  49. package/lib/dtls/src/handshake/message/server/hello.js +11 -11
  50. package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
  51. package/lib/dtls/src/handshake/message/server/helloDone.d.ts +1 -1
  52. package/lib/dtls/src/handshake/message/server/helloDone.js +4 -4
  53. package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
  54. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.d.ts +5 -4
  55. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +5 -5
  56. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
  57. package/lib/dtls/src/handshake/message/server/keyExchange.d.ts +10 -9
  58. package/lib/dtls/src/handshake/message/server/keyExchange.js +11 -10
  59. package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
  60. package/lib/dtls/src/handshake/random.d.ts +5 -4
  61. package/lib/dtls/src/handshake/random.js +6 -6
  62. package/lib/dtls/src/handshake/random.js.map +1 -1
  63. package/lib/dtls/src/record/message/fragment.d.ts +8 -7
  64. package/lib/dtls/src/record/message/fragment.js +10 -10
  65. package/lib/dtls/src/record/message/fragment.js.map +1 -1
  66. package/lib/dtls/src/record/message/header.d.ts +8 -7
  67. package/lib/dtls/src/record/message/header.js +8 -8
  68. package/lib/dtls/src/record/message/header.js.map +1 -1
  69. package/lib/dtls/src/record/message/plaintext.d.ts +1 -1
  70. package/lib/dtls/src/socket.d.ts +4 -4
  71. package/lib/dtls/src/socket.js +6 -6
  72. package/lib/dtls/src/socket.js.map +1 -1
  73. package/lib/dtls/src/util/binary.d.ts +2 -1
  74. package/lib/dtls/src/util/binary.js +3 -2
  75. package/lib/dtls/src/util/binary.js.map +1 -1
  76. package/lib/index.mjs +517 -210
  77. package/lib/nonstandard/index.mjs +500 -194
  78. package/lib/polyfill/dom.mjs +538 -232
  79. package/lib/polyfill/index.mjs +538 -232
  80. package/package.json +1 -2
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Declarative binary data encoder / decoder.
3
+ *
4
+ * TypeScript port of the subset of `binary-data` used by werift.
5
+ * https://github.com/reklatsmasters/binary-data
6
+ * https://github.com/shinyoshiaki/binary-data
7
+ *
8
+ * MIT License
9
+ *
10
+ * Copyright (c) 2017 Dmitry Tsvettsikh
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+ /** Thrown when the input does not contain enough bytes to decode. */
31
+ export declare class NotEnoughDataError extends Error {
32
+ constructor(expected: number, received: number);
33
+ }
34
+ /** Sequential reader over a single Buffer. Returned buffers share memory with the input. */
35
+ export declare class BinaryReader {
36
+ private readonly buf;
37
+ private offset;
38
+ constructor(buf: Buffer);
39
+ /** The number of unread bytes. */
40
+ get length(): number;
41
+ /** The number of bytes consumed so far. */
42
+ get bytes(): number;
43
+ readBuffer(size: number): Buffer;
44
+ readUIntBE(size: number): number;
45
+ private assertSize;
46
+ }
47
+ /** Collects written chunks and concatenates them once at the end. */
48
+ export declare class BinaryWriter {
49
+ private readonly chunks;
50
+ private written;
51
+ /** The number of bytes written so far. */
52
+ get bytes(): number;
53
+ writeBuffer(buf: Buffer): void;
54
+ writeUIntBE(value: number, size: number): void;
55
+ toBuffer(): Buffer;
56
+ }
57
+ /**
58
+ * Encode / decode context.
59
+ * `node` is the root object, `current` is the object currently being processed.
60
+ */
61
+ export interface BinaryContext {
62
+ node: any;
63
+ current: any;
64
+ }
65
+ export interface DataType<T> {
66
+ encode(value: T, writer: BinaryWriter, context: BinaryContext): void;
67
+ decode(reader: BinaryReader, context: BinaryContext): T;
68
+ }
69
+ export type NumberType = DataType<number>;
70
+ export interface Schema {
71
+ [key: string]: DataType<any> | Schema;
72
+ }
73
+ export type TypeOrSchema = DataType<any> | Schema;
74
+ /** Infer the decoded value from a type or schema. */
75
+ export type Decoded<S> = S extends DataType<infer T> ? T : S extends Schema ? {
76
+ -readonly [K in keyof S]: Decoded<S[K]>;
77
+ } : never;
78
+ export type LengthCallback = (context: BinaryContext) => number;
79
+ /** Encode `obj` using a type or schema. */
80
+ export declare function encode(obj: any, typeOrSchema: TypeOrSchema): Buffer;
81
+ /**
82
+ * Decode `buf` using a type or schema.
83
+ * Trailing bytes are ignored. Throws NotEnoughDataError when `buf` is too short.
84
+ */
85
+ export declare function decode<S extends TypeOrSchema>(buf: Buffer, typeOrSchema: S): Decoded<S>;
86
+ type LengthSpec = number | NumberType | LengthCallback;
87
+ /**
88
+ * Buffer type.
89
+ * @param length fixed number of bytes, number type for size-prefixed buffers,
90
+ * or callback returning the number of bytes.
91
+ */
92
+ declare function buffer(length: LengthSpec): DataType<Buffer>;
93
+ /**
94
+ * Array type.
95
+ * @param type type or schema of each item.
96
+ * @param length fixed length, number type for length-prefixed arrays, or callback.
97
+ * @param lengthType `count` (number of items) or `bytes` (number of bytes).
98
+ */
99
+ declare function array<S extends TypeOrSchema>(type: S, length: LengthSpec, lengthType?: "count" | "bytes"): DataType<Decoded<S>[]>;
100
+ /**
101
+ * String type.
102
+ * @param length fixed number of bytes, number type for size-prefixed strings,
103
+ * or callback returning the number of bytes.
104
+ */
105
+ declare function string(length: LengthSpec, encoding?: BufferEncoding): DataType<string>;
106
+ export declare const types: {
107
+ uint8: NumberType;
108
+ uint16be: NumberType;
109
+ uint24be: NumberType;
110
+ uint32be: NumberType;
111
+ uint48be: NumberType;
112
+ buffer: typeof buffer;
113
+ array: typeof array;
114
+ string: typeof string;
115
+ };
116
+ export {};
@@ -0,0 +1,421 @@
1
+ "use strict";
2
+ /**
3
+ * Declarative binary data encoder / decoder.
4
+ *
5
+ * TypeScript port of the subset of `binary-data` used by werift.
6
+ * https://github.com/reklatsmasters/binary-data
7
+ * https://github.com/shinyoshiaki/binary-data
8
+ *
9
+ * MIT License
10
+ *
11
+ * Copyright (c) 2017 Dmitry Tsvettsikh
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.types = exports.BinaryWriter = exports.BinaryReader = exports.NotEnoughDataError = void 0;
33
+ exports.encode = encode;
34
+ exports.decode = decode;
35
+ /** Thrown when the input does not contain enough bytes to decode. */
36
+ class NotEnoughDataError extends Error {
37
+ constructor(expected, received) {
38
+ super(`requested ${expected} bytes but only ${received} available`);
39
+ this.name = "NotEnoughDataError";
40
+ }
41
+ }
42
+ exports.NotEnoughDataError = NotEnoughDataError;
43
+ /** Sequential reader over a single Buffer. Returned buffers share memory with the input. */
44
+ class BinaryReader {
45
+ constructor(buf) {
46
+ Object.defineProperty(this, "buf", {
47
+ enumerable: true,
48
+ configurable: true,
49
+ writable: true,
50
+ value: buf
51
+ });
52
+ Object.defineProperty(this, "offset", {
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true,
56
+ value: 0
57
+ });
58
+ }
59
+ /** The number of unread bytes. */
60
+ get length() {
61
+ return this.buf.length - this.offset;
62
+ }
63
+ /** The number of bytes consumed so far. */
64
+ get bytes() {
65
+ return this.offset;
66
+ }
67
+ readBuffer(size) {
68
+ this.assertSize(size);
69
+ const res = this.buf.subarray(this.offset, this.offset + size);
70
+ this.offset += size;
71
+ return res;
72
+ }
73
+ readUIntBE(size) {
74
+ this.assertSize(size);
75
+ const res = this.buf.readUIntBE(this.offset, size);
76
+ this.offset += size;
77
+ return res;
78
+ }
79
+ assertSize(size) {
80
+ if (size > this.length) {
81
+ throw new NotEnoughDataError(size, this.length);
82
+ }
83
+ }
84
+ }
85
+ exports.BinaryReader = BinaryReader;
86
+ /** Collects written chunks and concatenates them once at the end. */
87
+ class BinaryWriter {
88
+ constructor() {
89
+ Object.defineProperty(this, "chunks", {
90
+ enumerable: true,
91
+ configurable: true,
92
+ writable: true,
93
+ value: []
94
+ });
95
+ Object.defineProperty(this, "written", {
96
+ enumerable: true,
97
+ configurable: true,
98
+ writable: true,
99
+ value: 0
100
+ });
101
+ }
102
+ /** The number of bytes written so far. */
103
+ get bytes() {
104
+ return this.written;
105
+ }
106
+ writeBuffer(buf) {
107
+ this.chunks.push(buf);
108
+ this.written += buf.length;
109
+ }
110
+ writeUIntBE(value, size) {
111
+ const buf = Buffer.allocUnsafe(size);
112
+ switch (size) {
113
+ case 1:
114
+ buf.writeUInt8(value, 0);
115
+ break;
116
+ case 2:
117
+ buf.writeUInt16BE(value, 0);
118
+ break;
119
+ case 4:
120
+ buf.writeUInt32BE(value, 0);
121
+ break;
122
+ default:
123
+ buf.writeUIntBE(value, 0, size);
124
+ }
125
+ this.writeBuffer(buf);
126
+ }
127
+ toBuffer() {
128
+ return Buffer.concat(this.chunks, this.written);
129
+ }
130
+ }
131
+ exports.BinaryWriter = BinaryWriter;
132
+ const isObject = (value) => typeof value === "object" && value !== null;
133
+ const isType = (value) => isObject(value) &&
134
+ typeof value.encode === "function" &&
135
+ typeof value.decode === "function";
136
+ const isPlainObject = (value) => {
137
+ if (!isObject(value))
138
+ return false;
139
+ const proto = Object.getPrototypeOf(value);
140
+ return proto === Object.prototype || proto === null;
141
+ };
142
+ const createContext = () => ({
143
+ node: undefined,
144
+ current: undefined,
145
+ });
146
+ const cloneContext = (context) => ({
147
+ node: context.node,
148
+ current: context.current,
149
+ });
150
+ const assertSchema = (schema, message) => {
151
+ if (!isPlainObject(schema)) {
152
+ throw new TypeError(message);
153
+ }
154
+ };
155
+ const encodeCommon = (value, typeOrSchema, writer, context) => {
156
+ if (isType(typeOrSchema)) {
157
+ typeOrSchema.encode(value, writer, context);
158
+ }
159
+ else {
160
+ encodeSchema(value, typeOrSchema, writer, context);
161
+ }
162
+ };
163
+ const encodeSchema = (obj, schema, writer, context) => {
164
+ assertSchema(schema, "Argument `schema` should be a plain object.");
165
+ if (context.node === undefined) {
166
+ context.node = obj;
167
+ }
168
+ context.current = obj;
169
+ for (const key of Object.keys(schema)) {
170
+ const type = schema[key];
171
+ const value = obj[key];
172
+ if (isType(type)) {
173
+ type.encode(value, writer, context);
174
+ }
175
+ else {
176
+ encodeSchema(value, type, writer, context);
177
+ context.current = obj;
178
+ }
179
+ }
180
+ };
181
+ const decodeCommon = (reader, typeOrSchema, context) => {
182
+ if (isType(typeOrSchema)) {
183
+ return typeOrSchema.decode(reader, context);
184
+ }
185
+ return decodeSchema(reader, typeOrSchema, context);
186
+ };
187
+ const decodeSchema = (reader, schema, context) => {
188
+ assertSchema(schema, "Argument #2 should be a plain object.");
189
+ const node = Object.create(null);
190
+ if (context.node === undefined) {
191
+ context.node = node;
192
+ }
193
+ context.current = node;
194
+ for (const key of Object.keys(schema)) {
195
+ const type = schema[key];
196
+ if (isType(type)) {
197
+ node[key] = type.decode(reader, context);
198
+ }
199
+ else {
200
+ node[key] = decodeSchema(reader, type, context);
201
+ context.current = node;
202
+ }
203
+ }
204
+ return node;
205
+ };
206
+ /** Encode `obj` using a type or schema. */
207
+ function encode(obj, typeOrSchema) {
208
+ const writer = new BinaryWriter();
209
+ encodeCommon(obj, typeOrSchema, writer, createContext());
210
+ return writer.toBuffer();
211
+ }
212
+ /**
213
+ * Decode `buf` using a type or schema.
214
+ * Trailing bytes are ignored. Throws NotEnoughDataError when `buf` is too short.
215
+ */
216
+ function decode(buf, typeOrSchema) {
217
+ return decodeCommon(new BinaryReader(buf), typeOrSchema, createContext());
218
+ }
219
+ const createUIntBE = (size) => ({
220
+ encode: (value, writer) => writer.writeUIntBE(value, size),
221
+ decode: (reader) => reader.readUIntBE(size),
222
+ });
223
+ const assertLengthSpec = (length) => {
224
+ if (typeof length !== "number" &&
225
+ !isType(length) &&
226
+ typeof length !== "function") {
227
+ throw new TypeError("Unknown type of argument #1.");
228
+ }
229
+ };
230
+ const checkLength = (required, having, name) => {
231
+ if (required !== having) {
232
+ throw new Error(`${name} required length ${required} instead of ${having}`);
233
+ }
234
+ };
235
+ const checkLengthType = (length, message) => {
236
+ if (typeof length !== "number") {
237
+ throw new TypeError(message);
238
+ }
239
+ };
240
+ /**
241
+ * Buffer type.
242
+ * @param length fixed number of bytes, number type for size-prefixed buffers,
243
+ * or callback returning the number of bytes.
244
+ */
245
+ function buffer(length) {
246
+ assertLengthSpec(length);
247
+ const lengthTypeError = "Length of a buffer should be a number.";
248
+ return {
249
+ encode(buf, writer, context) {
250
+ if (!Buffer.isBuffer(buf)) {
251
+ throw new TypeError("Argument 1 should be a Buffer or a BinaryStream.");
252
+ }
253
+ if (typeof length === "number") {
254
+ checkLength(length, buf.length, "Buffer");
255
+ }
256
+ else if (isType(length)) {
257
+ length.encode(buf.length, writer, context);
258
+ }
259
+ else {
260
+ const expected = length(context);
261
+ checkLengthType(expected, lengthTypeError);
262
+ checkLength(expected, buf.length, "Buffer");
263
+ }
264
+ writer.writeBuffer(buf);
265
+ },
266
+ decode(reader, context) {
267
+ let size;
268
+ if (typeof length === "number") {
269
+ size = length;
270
+ }
271
+ else if (isType(length)) {
272
+ size = length.decode(reader, context);
273
+ }
274
+ else {
275
+ size = length(context);
276
+ }
277
+ checkLengthType(size, lengthTypeError);
278
+ return reader.readBuffer(size);
279
+ },
280
+ };
281
+ }
282
+ /**
283
+ * Array type.
284
+ * @param type type or schema of each item.
285
+ * @param length fixed length, number type for length-prefixed arrays, or callback.
286
+ * @param lengthType `count` (number of items) or `bytes` (number of bytes).
287
+ */
288
+ function array(type, length, lengthType = "count") {
289
+ if (!isType(type) && !isPlainObject(type)) {
290
+ throw new TypeError("Argument #1 should be a valid type.");
291
+ }
292
+ assertLengthSpec(length);
293
+ const isLengthInBytes = lengthType === "bytes";
294
+ const sizeTypeError = "Length of an array should be a number.";
295
+ return {
296
+ encode(items, writer, parent) {
297
+ if (!Array.isArray(items)) {
298
+ throw new TypeError("Argument #1 should be an Array.");
299
+ }
300
+ const context = cloneContext(parent);
301
+ let expectedSize = 0;
302
+ if (typeof length === "number") {
303
+ expectedSize = length;
304
+ }
305
+ else if (isType(length)) {
306
+ expectedSize = items.length;
307
+ }
308
+ else {
309
+ expectedSize = length(context);
310
+ checkLengthType(expectedSize, sizeTypeError);
311
+ }
312
+ // Encode items first so that the byte length is known for the prefix.
313
+ const body = new BinaryWriter();
314
+ for (const item of items) {
315
+ encodeCommon(item, type, body, context);
316
+ }
317
+ if (isLengthInBytes) {
318
+ if (isType(length)) {
319
+ expectedSize = body.bytes;
320
+ }
321
+ checkLength(body.bytes, expectedSize, "Argument #1");
322
+ }
323
+ else {
324
+ checkLength(expectedSize, items.length, "Argument #1");
325
+ }
326
+ if (isType(length)) {
327
+ length.encode(expectedSize, writer, context);
328
+ }
329
+ writer.writeBuffer(body.toBuffer());
330
+ },
331
+ decode(reader, parent) {
332
+ const context = cloneContext(parent);
333
+ let expectedSize;
334
+ if (typeof length === "number") {
335
+ expectedSize = length;
336
+ }
337
+ else if (isType(length)) {
338
+ expectedSize = length.decode(reader, context);
339
+ }
340
+ else {
341
+ expectedSize = length(context);
342
+ }
343
+ checkLengthType(expectedSize, sizeTypeError);
344
+ const items = [];
345
+ if (isLengthInBytes) {
346
+ const before = reader.bytes;
347
+ let bytes = 0;
348
+ while (bytes < expectedSize) {
349
+ items.push(decodeCommon(reader, type, context));
350
+ bytes = reader.bytes - before;
351
+ }
352
+ if (bytes > expectedSize) {
353
+ throw new Error("Incorrect length of an array.");
354
+ }
355
+ }
356
+ else {
357
+ for (let i = 0; i < expectedSize; i++) {
358
+ items.push(decodeCommon(reader, type, context));
359
+ }
360
+ }
361
+ return items;
362
+ },
363
+ };
364
+ }
365
+ /**
366
+ * String type.
367
+ * @param length fixed number of bytes, number type for size-prefixed strings,
368
+ * or callback returning the number of bytes.
369
+ */
370
+ function string(length, encoding = "ascii") {
371
+ if (!Buffer.isEncoding(encoding)) {
372
+ throw new Error("Argument #2 should be an encoding name.");
373
+ }
374
+ assertLengthSpec(length);
375
+ const lengthTypeError = "Length of a buffer should be a number.";
376
+ return {
377
+ encode(value, writer, context) {
378
+ const buf = Buffer.from(value.toString(), encoding);
379
+ if (typeof length === "number") {
380
+ if (buf.length !== length) {
381
+ throw new Error(`Size of string should be ${length} in bytes.`);
382
+ }
383
+ }
384
+ else if (isType(length)) {
385
+ length.encode(buf.length, writer, context);
386
+ }
387
+ else {
388
+ const expected = length(context);
389
+ checkLengthType(expected, lengthTypeError);
390
+ checkLength(expected, buf.length, "Buffer");
391
+ }
392
+ writer.writeBuffer(buf);
393
+ },
394
+ decode(reader, context) {
395
+ let size;
396
+ if (typeof length === "number") {
397
+ size = length;
398
+ }
399
+ else if (isType(length)) {
400
+ size = length.decode(reader, context);
401
+ checkLengthType(size, "Size of a string should be a number.");
402
+ }
403
+ else {
404
+ size = length(context);
405
+ checkLengthType(size, lengthTypeError);
406
+ }
407
+ return reader.readBuffer(size).toString(encoding);
408
+ },
409
+ };
410
+ }
411
+ exports.types = {
412
+ uint8: createUIntBE(1),
413
+ uint16be: createUIntBE(2),
414
+ uint24be: createUIntBE(3),
415
+ uint32be: createUIntBE(4),
416
+ uint48be: createUIntBE(6),
417
+ buffer,
418
+ array,
419
+ string,
420
+ };
421
+ //# sourceMappingURL=binaryData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binaryData.js","sourceRoot":"","sources":["../../../../common/src/binaryData.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAiOH,wBAIC;AAMD,wBAKC;AA9OD,qEAAqE;AACrE,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,QAAgB,EAAE,QAAgB;QAC5C,KAAK,CAAC,aAAa,QAAQ,mBAAmB,QAAQ,YAAY,CAAC,CAAC;QACpE,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC;AAED,4FAA4F;AAC5F,MAAa,YAAY;IAGvB,YAA6B,GAAW;QAA5B;;;;mBAAiB,GAAG;WAAQ;QAFhC;;;;mBAAS,CAAC;WAAC;IAEwB,CAAC;IAE5C,kCAAkC;IAClC,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACvC,CAAC;IAED,2CAA2C;IAC3C,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QAC/D,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC;QACpB,OAAO,GAAG,CAAC;IACb,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACtB,MAAM,G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AAG,MAAM,CAAC,OAAO,CAAC,CAAC;gBACjC,eAAe,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;gBAC3C,WAAW,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YAC9C,CAAC;YAED,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;QACD,MAAM,CAAC,MAAM,EAAE,OAAO;YACpB,IAAI,IAAY,CAAC;YACjB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC/B,IAAI,GAAG,MAAM,CAAC;YAChB,CAAC;iBAAM,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC1B,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACtC,eAAe,CAAC,IAAI,EAAE,sCAAsC,CAAC,CAAC;YAChE,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;gBACvB,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;YACzC,CAAC;YAED,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,CAAC;AAEY,QAAA,KAAK,GAAG;IACnB,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;IACtB,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IACzB,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IACzB,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IACzB,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IACzB,MAAM;IACN,KAAK;IACL,MAAM;CACP,CAAC","sourcesContent":["/**\n * Declarative binary data encoder / decoder.\n *\n * TypeScript port of the subset of `binary-data` used by werift.\n * https://github.com/reklatsmasters/binary-data\n * https://github.com/shinyoshiaki/binary-data\n *\n * MIT License\n *\n * Copyright (c) 2017 Dmitry Tsvettsikh\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/** Thrown when the input does not contain enough bytes to decode. */\nexport class NotEnoughDataError extends Error {\n constructor(expected: number, received: number) {\n super(`requested ${expected} bytes but only ${received} available`);\n this.name = \"NotEnoughDataError\";\n }\n}\n\n/** Sequential reader over a single Buffer. Returned buffers share memory with the input. */\nexport class BinaryReader {\n private offset = 0;\n\n constructor(private readonly buf: Buffer) {}\n\n /** The number of unread bytes. */\n get length() {\n return this.buf.length - this.offset;\n }\n\n /** The number of bytes consumed so far. */\n get bytes() {\n return this.offset;\n }\n\n readBuffer(size: number): Buffer {\n this.assertSize(size);\n const res = this.buf.subarray(this.offset, this.offset + size);\n this.offset += size;\n return res;\n }\n\n readUIntBE(size: number): number {\n this.assertSize(size);\n const res = this.buf.readUIntBE(this.offset, size);\n this.offset += size;\n return res;\n }\n\n private assertSize(size: number) {\n if (size > this.length) {\n throw new NotEnoughDataError(size, this.length);\n }\n }\n}\n\n/** Collects written chunks and concatenates them once at the end. */\nexport class BinaryWriter {\n private readonly chunks: Buffer[] = [];\n private written = 0;\n\n /** The number of bytes written so far. */\n get bytes() {\n return this.written;\n }\n\n writeBuffer(buf: Buffer) {\n this.chunks.push(buf);\n this.written += buf.length;\n }\n\n writeUIntBE(value: number, size: number) {\n const buf = Buffer.allocUnsafe(size);\n switch (size) {\n case 1:\n buf.writeUInt8(value, 0);\n break;\n case 2:\n buf.writeUInt16BE(value, 0);\n break;\n case 4:\n buf.writeUInt32BE(value, 0);\n break;\n default:\n buf.writeUIntBE(value, 0, size);\n }\n this.writeBuffer(buf);\n }\n\n toBuffer(): Buffer {\n return Buffer.concat(this.chunks, this.written);\n }\n}\n\n/**\n * Encode / decode context.\n * `node` is the root object, `current` is the object currently being processed.\n */\nexport interface BinaryContext {\n node: any;\n current: any;\n}\n\nexport interface DataType<T> {\n encode(value: T, writer: BinaryWriter, context: BinaryContext): void;\n decode(reader: BinaryReader, context: BinaryContext): T;\n}\n\nexport type NumberType = DataType<number>;\n\nexport interface Schema {\n [key: string]: DataType<any> | Schema;\n}\n\nexport type TypeOrSchema = DataType<any> | Schema;\n\n/** Infer the decoded value from a type or schema. */\nexport type Decoded<S> = S extends DataType<infer T>\n ? T\n : S extends Schema\n ? { -readonly [K in keyof S]: Decoded<S[K]> }\n : never;\n\nexport type LengthCallback = (context: BinaryContext) => number;\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isType = (value: unknown): value is DataType<any> =>\n isObject(value) &&\n typeof value.encode === \"function\" &&\n typeof value.decode === \"function\";\n\nconst isPlainObject = (value: unknown): value is Schema => {\n if (!isObject(value)) return false;\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n};\n\nconst createContext = (): BinaryContext => ({\n node: undefined,\n current: undefined,\n});\n\nconst cloneContext = (context: BinaryContext): BinaryContext => ({\n node: context.node,\n current: context.current,\n});\n\nconst assertSchema = (schema: unknown, message: string) => {\n if (!isPlainObject(schema)) {\n throw new TypeError(message);\n }\n};\n\nconst encodeCommon = (\n value: any,\n typeOrSchema: TypeOrSchema,\n writer: BinaryWriter,\n context: BinaryContext,\n) => {\n if (isType(typeOrSchema)) {\n typeOrSchema.encode(value, writer, context);\n } else {\n encodeSchema(value, typeOrSchema, writer, context);\n }\n};\n\nconst encodeSchema = (\n obj: any,\n schema: Schema,\n writer: BinaryWriter,\n context: BinaryContext,\n) => {\n assertSchema(schema, \"Argument `schema` should be a plain object.\");\n\n if (context.node === undefined) {\n context.node = obj;\n }\n context.current = obj;\n\n for (const key of Object.keys(schema)) {\n const type = schema[key];\n const value = obj[key];\n\n if (isType(type)) {\n type.encode(value, writer, context);\n } else {\n encodeSchema(value, type, writer, context);\n context.current = obj;\n }\n }\n};\n\nconst decodeCommon = (\n reader: BinaryReader,\n typeOrSchema: TypeOrSchema,\n context: BinaryContext,\n): any => {\n if (isType(typeOrSchema)) {\n return typeOrSchema.decode(reader, context);\n }\n return decodeSchema(reader, typeOrSchema, context);\n};\n\nconst decodeSchema = (\n reader: BinaryReader,\n schema: Schema,\n context: BinaryContext,\n) => {\n assertSchema(schema, \"Argument #2 should be a plain object.\");\n\n const node: Record<string, unknown> = Object.create(null);\n\n if (context.node === undefined) {\n context.node = node;\n }\n context.current = node;\n\n for (const key of Object.keys(schema)) {\n const type = schema[key];\n\n if (isType(type)) {\n node[key] = type.decode(reader, context);\n } else {\n node[key] = decodeSchema(reader, type, context);\n context.current = node;\n }\n }\n\n return node;\n};\n\n/** Encode `obj` using a type or schema. */\nexport function encode(obj: any, typeOrSchema: TypeOrSchema): Buffer {\n const writer = new BinaryWriter();\n encodeCommon(obj, typeOrSchema, writer, createContext());\n return writer.toBuffer();\n}\n\n/**\n * Decode `buf` using a type or schema.\n * Trailing bytes are ignored. Throws NotEnoughDataError when `buf` is too short.\n */\nexport function decode<S extends TypeOrSchema>(\n buf: Buffer,\n typeOrSchema: S,\n): Decoded<S> {\n return decodeCommon(new BinaryReader(buf), typeOrSchema, createContext());\n}\n\nconst createUIntBE = (size: number): NumberType => ({\n encode: (value, writer) => writer.writeUIntBE(value, size),\n decode: (reader) => reader.readUIntBE(size),\n});\n\ntype LengthSpec = number | NumberType | LengthCallback;\n\nconst assertLengthSpec = (length: unknown) => {\n if (\n typeof length !== \"number\" &&\n !isType(length) &&\n typeof length !== \"function\"\n ) {\n throw new TypeError(\"Unknown type of argument #1.\");\n }\n};\n\nconst checkLength = (required: number, having: number, name: string) => {\n if (required !== having) {\n throw new Error(`${name} required length ${required} instead of ${having}`);\n }\n};\n\nconst checkLengthType = (length: unknown, message: string) => {\n if (typeof length !== \"number\") {\n throw new TypeError(message);\n }\n};\n\n/**\n * Buffer type.\n * @param length fixed number of bytes, number type for size-prefixed buffers,\n * or callback returning the number of bytes.\n */\nfunction buffer(length: LengthSpec): DataType<Buffer> {\n assertLengthSpec(length);\n const lengthTypeError = \"Length of a buffer should be a number.\";\n\n return {\n encode(buf, writer, context) {\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError(\"Argument 1 should be a Buffer or a BinaryStream.\");\n }\n\n if (typeof length === \"number\") {\n checkLength(length, buf.length, \"Buffer\");\n } else if (isType(length)) {\n length.encode(buf.length, writer, context);\n } else {\n const expected = length(context);\n checkLengthType(expected, lengthTypeError);\n checkLength(expected, buf.length, \"Buffer\");\n }\n\n writer.writeBuffer(buf);\n },\n decode(reader, context) {\n let size: number;\n if (typeof length === \"number\") {\n size = length;\n } else if (isType(length)) {\n size = length.decode(reader, context);\n } else {\n size = length(context);\n }\n checkLengthType(size, lengthTypeError);\n\n return reader.readBuffer(size);\n },\n };\n}\n\n/**\n * Array type.\n * @param type type or schema of each item.\n * @param length fixed length, number type for length-prefixed arrays, or callback.\n * @param lengthType `count` (number of items) or `bytes` (number of bytes).\n */\nfunction array<S extends TypeOrSchema>(\n type: S,\n length: LengthSpec,\n lengthType: \"count\" | \"bytes\" = \"count\",\n): DataType<Decoded<S>[]> {\n if (!isType(type) && !isPlainObject(type)) {\n throw new TypeError(\"Argument #1 should be a valid type.\");\n }\n assertLengthSpec(length);\n\n const isLengthInBytes = lengthType === \"bytes\";\n const sizeTypeError = \"Length of an array should be a number.\";\n\n return {\n encode(items, writer, parent) {\n if (!Array.isArray(items)) {\n throw new TypeError(\"Argument #1 should be an Array.\");\n }\n\n const context = cloneContext(parent);\n\n let expectedSize = 0;\n if (typeof length === \"number\") {\n expectedSize = length;\n } else if (isType(length)) {\n expectedSize = items.length;\n } else {\n expectedSize = length(context);\n checkLengthType(expectedSize, sizeTypeError);\n }\n\n // Encode items first so that the byte length is known for the prefix.\n const body = new BinaryWriter();\n for (const item of items) {\n encodeCommon(item, type, body, context);\n }\n\n if (isLengthInBytes) {\n if (isType(length)) {\n expectedSize = body.bytes;\n }\n checkLength(body.bytes, expectedSize, \"Argument #1\");\n } else {\n checkLength(expectedSize, items.length, \"Argument #1\");\n }\n\n if (isType(length)) {\n length.encode(expectedSize, writer, context);\n }\n writer.writeBuffer(body.toBuffer());\n },\n decode(reader, parent) {\n const context = cloneContext(parent);\n\n let expectedSize: number;\n if (typeof length === \"number\") {\n expectedSize = length;\n } else if (isType(length)) {\n expectedSize = length.decode(reader, context);\n } else {\n expectedSize = length(context);\n }\n checkLengthType(expectedSize, sizeTypeError);\n\n const items: Decoded<S>[] = [];\n\n if (isLengthInBytes) {\n const before = reader.bytes;\n let bytes = 0;\n while (bytes < expectedSize) {\n items.push(decodeCommon(reader, type, context));\n bytes = reader.bytes - before;\n }\n if (bytes > expectedSize) {\n throw new Error(\"Incorrect length of an array.\");\n }\n } else {\n for (let i = 0; i < expectedSize; i++) {\n items.push(decodeCommon(reader, type, context));\n }\n }\n\n return items;\n },\n };\n}\n\n/**\n * String type.\n * @param length fixed number of bytes, number type for size-prefixed strings,\n * or callback returning the number of bytes.\n */\nfunction string(\n length: LengthSpec,\n encoding: BufferEncoding = \"ascii\",\n): DataType<string> {\n if (!Buffer.isEncoding(encoding)) {\n throw new Error(\"Argument #2 should be an encoding name.\");\n }\n assertLengthSpec(length);\n const lengthTypeError = \"Length of a buffer should be a number.\";\n\n return {\n encode(value, writer, context) {\n const buf = Buffer.from(value.toString(), encoding);\n\n if (typeof length === \"number\") {\n if (buf.length !== length) {\n throw new Error(`Size of string should be ${length} in bytes.`);\n }\n } else if (isType(length)) {\n length.encode(buf.length, writer, context);\n } else {\n const expected = length(context);\n checkLengthType(expected, lengthTypeError);\n checkLength(expected, buf.length, \"Buffer\");\n }\n\n writer.writeBuffer(buf);\n },\n decode(reader, context) {\n let size: number;\n if (typeof length === \"number\") {\n size = length;\n } else if (isType(length)) {\n size = length.decode(reader, context);\n checkLengthType(size, \"Size of a string should be a number.\");\n } else {\n size = length(context);\n checkLengthType(size, lengthTypeError);\n }\n\n return reader.readBuffer(size).toString(encoding);\n },\n };\n}\n\nexport const types = {\n uint8: createUIntBE(1),\n uint16be: createUIntBE(2),\n uint24be: createUIntBE(3),\n uint32be: createUIntBE(4),\n uint48be: createUIntBE(6),\n buffer,\n array,\n string,\n};\n"]}
@@ -7,3 +7,4 @@ export * from "./type";
7
7
  export * from "./log";
8
8
  export * from "./event";
9
9
  export * from "./transport";
10
+ export * as binaryData from "./binaryData";
@@ -10,10 +10,33 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
13
18
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
19
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
20
  };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
16
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.binaryData = void 0;
17
40
  __exportStar(require("./binary"), exports);
18
41
  __exportStar(require("./crc"), exports);
19
42
  __exportStar(require("./number"), exports);
@@ -23,4 +46,5 @@ __exportStar(require("./type"), exports);
23
46
  __exportStar(require("./log"), exports);
24
47
  __exportStar(require("./event"), exports);
25
48
  __exportStar(require("./transport"), exports);
49
+ exports.binaryData = __importStar(require("./binaryData"));
26
50
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../common/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,wCAAsB;AACtB,2CAAyB;AACzB,4CAA0B;AAC1B,4CAA0B;AAC1B,yCAAuB;AACvB,wCAAsB;AACtB,0CAAwB;AACxB,8CAA4B","sourcesContent":["export * from \"./binary\";\nexport * from \"./crc\";\nexport * from \"./number\";\nexport * from \"./promise\";\nexport * from \"./network\";\nexport * from \"./type\";\nexport * from \"./log\";\nexport * from \"./event\";\nexport * from \"./transport\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../common/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,wCAAsB;AACtB,2CAAyB;AACzB,4CAA0B;AAC1B,4CAA0B;AAC1B,yCAAuB;AACvB,wCAAsB;AACtB,0CAAwB;AACxB,8CAA4B;AAC5B,2DAA2C","sourcesContent":["export * from \"./binary\";\nexport * from \"./crc\";\nexport * from \"./number\";\nexport * from \"./promise\";\nexport * from \"./network\";\nexport * from \"./type\";\nexport * from \"./log\";\nexport * from \"./event\";\nexport * from \"./transport\";\nexport * as binaryData from \"./binaryData\";\n"]}
@@ -10,8 +10,8 @@ export declare function prfVerifyData(masterSecret: Buffer, handshakes: Buffer,
10
10
  export declare function prfVerifyDataClient(masterSecret: Buffer, handshakes: Buffer): Buffer<ArrayBuffer>;
11
11
  export declare function prfVerifyDataServer(masterSecret: Buffer, handshakes: Buffer): Buffer<ArrayBuffer>;
12
12
  export declare function prfEncryptionKeys(masterSecret: Buffer, clientRandom: Buffer, serverRandom: Buffer, prfKeyLen: number, prfIvLen: number, prfNonceLen: number, algorithm?: string): {
13
- clientWriteKey: any;
14
- serverWriteKey: any;
13
+ clientWriteKey: Buffer<ArrayBufferLike>;
14
+ serverWriteKey: Buffer<ArrayBufferLike>;
15
15
  clientNonce: Buffer<ArrayBuffer>;
16
16
  serverNonce: Buffer<ArrayBuffer>;
17
17
  };
@@ -15,8 +15,8 @@ exports.prfVerifyDataClient = prfVerifyDataClient;
15
15
  exports.prfVerifyDataServer = prfVerifyDataServer;
16
16
  exports.prfEncryptionKeys = prfEncryptionKeys;
17
17
  const crypto_1 = require("crypto");
18
- const binary_data_1 = require("@shinyoshiaki/binary-data");
19
18
  const tweetnacl_1 = __importDefault(require("tweetnacl"));
19
+ const common_1 = require("../imports/common");
20
20
  const const_1 = require("./const");
21
21
  const ec_1 = require("./ec");
22
22
  function prfPreMasterSecret(publicKey, privateKey, curve) {
@@ -83,7 +83,7 @@ function prfEncryptionKeys(masterSecret, clientRandom, serverRandom, prfKeyLen,
83
83
  const secret = masterSecret;
84
84
  const seed = Buffer.concat([serverRandom, clientRandom]);
85
85
  const keyBlock = prfPHash(secret, Buffer.concat([Buffer.from("key expansion"), seed]), size, algorithm);
86
- const stream = (0, binary_data_1.createDecode)(keyBlock);
86
+ const stream = new common_1.binaryData.BinaryReader(keyBlock);
87
87
  const clientWriteKey = stream.readBuffer(prfKeyLen);
88
88
  const serverWriteKey = stream.readBuffer(prfKeyLen);
89
89
  const clientNonceImplicit = stream.readBuffer(prfIvLen);