sonic-ws 1.1.1-patch → 1.2.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.
@@ -7,7 +7,6 @@ type ImpactType<T extends (PacketType | readonly PacketType[]), K> = T extends P
7
7
  export declare class Packet<T extends (PacketType | readonly PacketType[])> {
8
8
  defaultEnabled: boolean;
9
9
  readonly tag: string;
10
- readonly async: boolean;
11
10
  readonly maxSize: number;
12
11
  readonly minSize: number;
13
12
  readonly type: T;
@@ -19,17 +18,20 @@ export declare class Packet<T extends (PacketType | readonly PacketType[])> {
19
18
  readonly dontSpread: boolean;
20
19
  readonly autoFlatten: boolean;
21
20
  readonly rateLimit: number;
21
+ readonly async: boolean;
22
+ readonly rereference: boolean;
23
+ readonly gzipCompression: boolean;
22
24
  readonly object: boolean;
23
25
  readonly client: boolean;
24
26
  private receiveProcessor;
25
27
  private sendProcessor;
26
28
  private validator;
27
29
  processReceive: (data: Uint8Array, validationResult: any) => any;
28
- processSend: (data: any[]) => Uint8Array;
29
- validate: (data: Uint8Array) => boolean;
30
+ processSend: (data: any[]) => Promise<Uint8Array>;
31
+ validate: (data: Uint8Array) => Promise<[Uint8Array, boolean]>;
30
32
  customValidator: ((socket: SonicWSConnection, ...values: any[]) => boolean) | null;
31
33
  constructor(tag: string, schema: PacketSchema<T>, customValidator: ValidatorFunction, enabled: boolean, client: boolean);
32
- listen(value: Uint8Array, socket: SonicWSConnection | null): [processed: any, flatten: boolean] | string;
34
+ listen(value: Uint8Array, socket: SonicWSConnection | null): Promise<[processed: any, flatten: boolean] | string>;
33
35
  serialize(): number[];
34
36
  private static readVarInts;
35
37
  static deserialize(data: Uint8Array, offset: number, client: boolean): [packet: Packet<any>, offset: number];
@@ -46,10 +48,12 @@ export declare class PacketSchema<T extends (PacketType | readonly PacketType[])
46
48
  dontSpread: boolean;
47
49
  autoFlatten: boolean;
48
50
  async: boolean;
51
+ rereference: boolean;
52
+ gzipCompression: boolean;
49
53
  object: boolean;
50
54
  constructor(object: boolean);
51
55
  testObject(): this is PacketSchema<PacketType[]>;
52
- static single<T extends PacketType | EnumPackage>(type: T, dataMax: number, dataMin: number, dontSpread: boolean, dataBatching: number, maxBatchSize: number, rateLimit: number, async: boolean): PacketSchema<ConvertType<T>>;
53
- static object<T extends readonly (PacketType | EnumPackage)[]>(types: T, dataMaxes: number[], dataMins: number[], dontSpread: boolean, autoFlatten: boolean, dataBatching: number, maxBatchSize: number, rateLimit: number, async: boolean): PacketSchema<ConvertType<T[number]>[]>;
56
+ static single<T extends PacketType | EnumPackage>(type: T, dataMax: number, dataMin: number, dontSpread: boolean, dataBatching: number, maxBatchSize: number, rateLimit: number, async: boolean, gzipCompression: boolean, rereference: boolean): PacketSchema<ConvertType<T>>;
57
+ static object<T extends readonly (PacketType | EnumPackage)[]>(types: T, dataMaxes: number[], dataMins: number[], dontSpread: boolean, autoFlatten: boolean, dataBatching: number, maxBatchSize: number, rateLimit: number, async: boolean, gzipCompression: boolean): PacketSchema<ConvertType<T[number]>[]>;
54
58
  }
55
59
  export {};
@@ -27,7 +27,6 @@ const StringUtil_1 = require("../util/StringUtil");
27
27
  class Packet {
28
28
  defaultEnabled;
29
29
  tag;
30
- async;
31
30
  maxSize;
32
31
  minSize;
33
32
  type;
@@ -39,6 +38,9 @@ class Packet {
39
38
  dontSpread;
40
39
  autoFlatten;
41
40
  rateLimit;
41
+ async;
42
+ rereference;
43
+ gzipCompression;
42
44
  object;
43
45
  client;
44
46
  receiveProcessor;
@@ -57,8 +59,10 @@ class Packet {
57
59
  this.rateLimit = schema.rateLimit;
58
60
  this.dontSpread = schema.dontSpread;
59
61
  this.autoFlatten = schema.autoFlatten;
62
+ this.rereference = schema.rereference;
60
63
  this.dataBatching = schema.dataBatching;
61
64
  this.maxBatchSize = client ? Infinity : schema.maxBatchSize;
65
+ this.gzipCompression = schema.gzipCompression;
62
66
  this.object = schema.object;
63
67
  if (schema.testObject()) {
64
68
  this.type = schema.type;
@@ -70,8 +74,8 @@ class Packet {
70
74
  this.minSize = this.type.length;
71
75
  // trst me bro..
72
76
  this.receiveProcessor = (0, PacketProcessors_1.createObjReceiveProcessor)(this);
73
- this.validator = (0, PacketProcessors_1.createObjValidator)(this);
74
77
  this.sendProcessor = (0, PacketProcessors_1.createObjSendProcessor)(this);
78
+ this.validator = (0, PacketProcessors_1.createObjValidator)(this);
75
79
  }
76
80
  else {
77
81
  this.type = schema.type;
@@ -82,22 +86,22 @@ class Packet {
82
86
  // @ts-expect-error
83
87
  this.receiveProcessor = (0, PacketProcessors_1.createReceiveProcessor)(this.type, this.enumData, this.dataMax);
84
88
  // @ts-expect-error
85
- this.validator = (0, PacketProcessors_1.createValidator)(this.type, this.dataMax, this.dataMin, this);
89
+ this.sendProcessor = (0, PacketProcessors_1.createSendProcessor)(this.type, this.gzipCompression, this.rereference);
86
90
  // @ts-expect-error
87
- this.sendProcessor = (0, PacketProcessors_1.createSendProcessor)(this.type);
91
+ this.validator = (0, PacketProcessors_1.createValidator)(this.type, this.dataMax, this.dataMin, this, this.gzipCompression, this.rereference);
88
92
  }
89
93
  this.processReceive = (data, validationResult) => this.receiveProcessor(data, validationResult, 0);
90
- this.processSend = (data) => new Uint8Array(this.sendProcessor(data));
94
+ this.processSend = async (data) => new Uint8Array(await this.sendProcessor(tag, data));
91
95
  this.validate = (data) => this.validator(data, 0);
92
96
  this.customValidator = customValidator;
93
97
  }
94
- listen(value, socket) {
98
+ async listen(value, socket) {
95
99
  try {
96
- const validationResult = this.validate(value);
100
+ const [dcData, validationResult] = await this.validate(value);
97
101
  // holy shit i used === to fix another bug
98
102
  if (!this.client && validationResult === false)
99
103
  return "Invalid packet";
100
- const processed = this.processReceive(value, validationResult);
104
+ const processed = this.processReceive(dcData, validationResult);
101
105
  const useableData = this.autoFlatten ? (0, PacketUtils_1.UnFlattenData)(processed) : processed;
102
106
  if (this.customValidator != null) {
103
107
  if (!this.dontSpread) {
@@ -120,8 +124,7 @@ class Packet {
120
124
  // shared values for both
121
125
  const sharedData = [
122
126
  this.tag.length, ...(0, StringUtil_1.processCharCodes)(this.tag),
123
- this.dontSpread ? 1 : 0,
124
- this.async ? 1 : 0,
127
+ (0, CompressionUtil_1.compressBools)([this.dontSpread, this.async, this.object, this.autoFlatten, this.gzipCompression, this.rereference]),
125
128
  this.dataBatching,
126
129
  this.enumData.length, ...this.enumData.map(x => x.serialize()).flat(),
127
130
  ];
@@ -129,7 +132,6 @@ class Packet {
129
132
  if (!this.object) {
130
133
  return [
131
134
  ...sharedData, // shared
132
- 0, // dummy byte flag for consistent deserialization; becomes -1 to indicate single
133
135
  ...(0, CompressionUtil_1.convertVarInt)(this.dataMax), // the data max
134
136
  ...(0, CompressionUtil_1.convertVarInt)(this.dataMin), // the data min
135
137
  this.type,
@@ -138,12 +140,10 @@ class Packet {
138
140
  // object packet
139
141
  return [
140
142
  ...sharedData,
141
- this.maxSize + 1, // size, and +1 because of 0 for single
142
- this.autoFlatten ? 1 : 0, // auto flatten flag
143
+ this.maxSize, // size
143
144
  ...this.dataMax.map(CompressionUtil_1.convertVarInt).flat(), // all data maxes, serialized
144
145
  ...this.dataMin.map(CompressionUtil_1.convertVarInt).flat(), // all data mins, serialized
145
- ...this.type, // all types, offset by 1 for NULL
146
- this.tag.length, // tag length, offset by 1 for NULL
146
+ ...this.type, // all types
147
147
  ];
148
148
  }
149
149
  static readVarInts(data, offset, size) {
@@ -161,10 +161,8 @@ class Packet {
161
161
  const tagLength = data[offset++];
162
162
  // read tag as it's up 1, and add offset
163
163
  const tag = (0, BufferUtil_1.as8String)(data.slice(offset, offset += tagLength));
164
- // then read dont spread, go up 1
165
- const dontSpread = data[offset++] == 1;
166
- // read async
167
- const async = data[offset++] == 1;
164
+ // then read dontSpread and async
165
+ const [dontSpread, async, isObject, autoFlatten, gzipCompression, rereference] = (0, CompressionUtil_1.decompressBools)(data[offset++]);
168
166
  // read batching, up 1
169
167
  const dataBatching = data[offset++];
170
168
  // read enum length, up 1
@@ -191,13 +189,10 @@ class Packet {
191
189
  // define the enum with the values
192
190
  enums.push((0, EnumHandler_1.DefineEnum)(enumTag, values));
193
191
  }
194
- // read type count; prob should change sometime
195
- const size = data[offset++] - 1;
196
192
  // objects
197
- // single packet is 0, 0 - 1 = -1
198
- if (size != -1) {
199
- // 1 for true, 0 for false
200
- const autoFlatten = data[offset++] == 1;
193
+ if (isObject) {
194
+ // read size
195
+ const size = data[offset++];
201
196
  // read var ints for the datamaxes
202
197
  const [dataMaxes, o1] = this.readVarInts(data, offset, size);
203
198
  offset = o1;
@@ -210,11 +205,11 @@ class Packet {
210
205
  let index = 0;
211
206
  const finalTypes = types.map(x => x == PacketType_1.PacketType.ENUMS ? enums[index++] : x); // convert enums to their enum packages
212
207
  // make schema
213
- const schema = PacketSchema.object(finalTypes, dataMaxes, dataMins, dontSpread, autoFlatten, dataBatching, -1, -1, async);
208
+ const schema = PacketSchema.object(finalTypes, dataMaxes, dataMins, dontSpread, autoFlatten, dataBatching, -1, -1, async, gzipCompression);
214
209
  return [
215
210
  new Packet(tag, schema, null, false, client),
216
211
  // +1 to go next
217
- (offset - beginningOffset) + 1,
212
+ (offset - beginningOffset),
218
213
  ];
219
214
  }
220
215
  // single packet
@@ -224,16 +219,15 @@ class Packet {
224
219
  // read varint for datamin
225
220
  const [o2, dataMin] = (0, CompressionUtil_1.readVarInt)(data, offset);
226
221
  offset = o2;
227
- // read type, no more so no +1
228
- const type = data[offset];
222
+ // read type
223
+ const type = data[offset++];
229
224
  // do enum stuff
230
225
  const finalType = type == PacketType_1.PacketType.ENUMS ? enums[0] : type; // convert enum to enum package
231
226
  // make schema
232
- const schema = PacketSchema.single(finalType, dataMax, dataMin, dontSpread, dataBatching, -1, -1, async);
227
+ const schema = PacketSchema.single(finalType, dataMax, dataMin, dontSpread, dataBatching, -1, -1, async, gzipCompression, rereference);
233
228
  return [
234
229
  new Packet(tag, schema, null, false, client),
235
- // +1 to go next
236
- (offset - beginningOffset) + 1,
230
+ (offset - beginningOffset),
237
231
  ];
238
232
  }
239
233
  static deserializeAll(data, client) {
@@ -259,6 +253,8 @@ class PacketSchema {
259
253
  dontSpread = false;
260
254
  autoFlatten = false;
261
255
  async = false;
256
+ rereference = false;
257
+ gzipCompression = false;
262
258
  object;
263
259
  constructor(object) {
264
260
  this.object = object;
@@ -266,7 +262,7 @@ class PacketSchema {
266
262
  testObject() {
267
263
  return this.object;
268
264
  }
269
- static single(type, dataMax, dataMin, dontSpread, dataBatching, maxBatchSize, rateLimit, async) {
265
+ static single(type, dataMax, dataMin, dontSpread, dataBatching, maxBatchSize, rateLimit, async, gzipCompression, rereference) {
270
266
  const schema = new PacketSchema(false);
271
267
  if (typeof type == 'number') {
272
268
  schema.type = type;
@@ -277,16 +273,18 @@ class PacketSchema {
277
273
  schema.type = PacketType_1.PacketType.ENUMS;
278
274
  schema.enumData = [type];
279
275
  }
280
- schema.dataMax = dataMax;
276
+ schema.async = async;
281
277
  schema.dataMin = dataMin;
278
+ schema.dataMax = dataMax;
279
+ schema.rateLimit = rateLimit;
282
280
  schema.dontSpread = dontSpread;
281
+ schema.rereference = rereference;
283
282
  schema.dataBatching = dataBatching;
284
283
  schema.maxBatchSize = maxBatchSize;
285
- schema.rateLimit = rateLimit;
286
- schema.async = async;
284
+ schema.gzipCompression = gzipCompression;
287
285
  return schema;
288
286
  }
289
- static object(types, dataMaxes, dataMins, dontSpread, autoFlatten, dataBatching, maxBatchSize, rateLimit, async) {
287
+ static object(types, dataMaxes, dataMins, dontSpread, autoFlatten, dataBatching, maxBatchSize, rateLimit, async, gzipCompression) {
290
288
  if (types.length != dataMaxes.length || types.length != dataMins.length)
291
289
  throw new Error("There is an inbalance between the amount of types, data maxes, and data mins!");
292
290
  const schema = new PacketSchema(true);
@@ -300,14 +298,15 @@ class PacketSchema {
300
298
  schema.enumData.push(type);
301
299
  }
302
300
  });
303
- schema.dataMax = dataMaxes;
301
+ schema.async = async;
304
302
  schema.dataMin = dataMins;
303
+ schema.dataMax = dataMaxes;
304
+ schema.rateLimit = rateLimit;
305
305
  schema.dontSpread = dontSpread;
306
306
  schema.autoFlatten = autoFlatten;
307
307
  schema.dataBatching = dataBatching;
308
308
  schema.maxBatchSize = maxBatchSize;
309
- schema.rateLimit = rateLimit;
310
- schema.async = async;
309
+ schema.gzipCompression = gzipCompression;
311
310
  return schema;
312
311
  }
313
312
  }
@@ -67,7 +67,7 @@ export declare class SonicWSConnection implements Connection {
67
67
  * @param tag The tag to send
68
68
  * @param values The values to send
69
69
  */
70
- send(tag: string, ...values: any[]): void;
70
+ send(tag: string, ...values: any[]): Promise<void>;
71
71
  /**
72
72
  * Broadcasts a packet to all other users connected
73
73
  * @param tag The tag to send
@@ -209,17 +209,17 @@ class SonicWSConnection {
209
209
  else
210
210
  this.listenLock = false;
211
211
  }
212
- messageHandler(data) {
212
+ async messageHandler(data) {
213
213
  if (data == null)
214
214
  return;
215
215
  const [tag, value] = data;
216
216
  const packet = this.host.clientPackets.getPacket(tag);
217
217
  if (packet.dataBatching == 0) {
218
- const res = packet.listen(value, this);
218
+ const res = await packet.listen(value, this);
219
219
  this.listenPacket(res, tag);
220
220
  return;
221
221
  }
222
- const batchData = BatchHelper_1.BatchHelper.unravelBatch(packet, value, this);
222
+ const batchData = await BatchHelper_1.BatchHelper.unravelBatch(packet, value, this);
223
223
  if (typeof batchData == 'string')
224
224
  return this.invalidPacket(batchData);
225
225
  for (const data of batchData) {
@@ -281,8 +281,8 @@ class SonicWSConnection {
281
281
  * @param tag The tag to send
282
282
  * @param values The values to send
283
283
  */
284
- send(tag, ...values) {
285
- this.send_processed(...(0, PacketUtils_1.processPacket)(this.host.serverPackets, tag, values));
284
+ async send(tag, ...values) {
285
+ this.send_processed(...await (0, PacketUtils_1.processPacket)(this.host.serverPackets, tag, values));
286
286
  }
287
287
  /**
288
288
  * Broadcasts a packet to all other users connected
@@ -13,6 +13,8 @@ export type SonicServerOptions = {
13
13
  readonly serverPackets?: PacketTypings;
14
14
  /** Default WS Options */
15
15
  readonly websocketOptions?: WS.ServerOptions;
16
+ /** If it should check for updates; defaults to true. */
17
+ readonly checkForUpdates?: boolean;
16
18
  };
17
19
  export type PacketTypings = readonly Packet<PacketType | readonly PacketType[]>[];
18
20
  export declare class SonicWSServer {
@@ -98,14 +100,14 @@ export declare class SonicWSServer {
98
100
  * @param packetTag Packet tag to send
99
101
  * @param values Values to send
100
102
  */
101
- broadcastTagged(tag: string, packetTag: string, ...values: any): void;
103
+ broadcastTagged(tag: string, packetTag: string, ...values: any): Promise<void>;
102
104
  /**
103
105
  * Broadcasts a packet to all users connected, but with a filter
104
106
  * @param tag The tag to send
105
107
  * @param filter The filter for who to send to
106
108
  * @param values The values to send
107
109
  */
108
- broadcastFiltered(tag: string, filter: (socket: SonicWSConnection) => boolean, ...values: any): void;
110
+ broadcastFiltered(tag: string, filter: (socket: SonicWSConnection) => boolean, ...values: any): Promise<void>;
109
111
  /**
110
112
  * Broadcasts a packet to all users connected
111
113
  * @param tag The tag to send
@@ -83,10 +83,11 @@ class SonicWSServer {
83
83
  const s_serverPackets = this.serverPackets.serialize();
84
84
  const serverData = [...version_1.SERVER_SUFFIX_NUMS, version_1.VERSION];
85
85
  const keyData = [...(0, CompressionUtil_1.convertVarInt)(s_clientPackets.length), ...s_clientPackets, ...s_serverPackets];
86
- this.wss.on('connection', (socket) => {
86
+ this.wss.on('connection', async (socket) => {
87
87
  const sonicConnection = new SonicWSConnection_1.SonicWSConnection(socket, this, this.generateSocketID(), this.handshakePacket, this.clientRateLimit, this.serverRateLimit);
88
88
  // send tags to the client so it doesn't have to hard code them in
89
- socket.send(new Uint8Array([...serverData, ...(0, CompressionUtil_1.convertVarInt)(sonicConnection.id), ...keyData]));
89
+ const data = new Uint8Array([...(0, CompressionUtil_1.convertVarInt)(sonicConnection.id), ...keyData]);
90
+ socket.send([...serverData, ...await (0, CompressionUtil_1.compressGzip)(data)]);
90
91
  this.connections.push(sonicConnection);
91
92
  this.connectionMap[sonicConnection.id] = sonicConnection;
92
93
  this.connectListeners.forEach(l => l(sonicConnection));
@@ -101,17 +102,19 @@ class SonicWSServer {
101
102
  }
102
103
  });
103
104
  });
104
- fetch('https://raw.githubusercontent.com/liwybloc/sonic-ws/refs/heads/main/release/version')
105
- .then((res) => res.text())
106
- .then((ver) => {
107
- if (parseInt(ver) != version_1.VERSION) {
108
- console.warn(`SonicWS is currently running outdated! (current: ${version_1.VERSION}, latest: ${ver}) Update with "npm update sonic-ws"`);
109
- }
110
- })
111
- .catch((err) => {
112
- console.error(err);
113
- console.warn(`Could not check SonicWS version.`);
114
- });
105
+ if (settings.checkForUpdates ?? true) {
106
+ fetch('https://raw.githubusercontent.com/liwybloc/sonic-ws/refs/heads/main/release/version')
107
+ .then((res) => res.text())
108
+ .then((ver) => {
109
+ if (parseInt(ver) > version_1.VERSION) {
110
+ console.warn(`SonicWS is currently running outdated! (current: ${version_1.VERSION}, latest: ${ver}) Update with "npm update sonic-ws"`);
111
+ }
112
+ })
113
+ .catch((err) => {
114
+ console.error(err);
115
+ console.warn(`Could not check SonicWS version.`);
116
+ });
117
+ }
115
118
  }
116
119
  generateSocketID() {
117
120
  if (this.availableIds.length == 0)
@@ -213,10 +216,10 @@ class SonicWSServer {
213
216
  * @param packetTag Packet tag to send
214
217
  * @param values Values to send
215
218
  */
216
- broadcastTagged(tag, packetTag, ...values) {
219
+ async broadcastTagged(tag, packetTag, ...values) {
217
220
  if (!this.tagsInv.has(tag))
218
221
  return;
219
- const data = (0, PacketUtils_1.processPacket)(this.serverPackets, packetTag, values);
222
+ const data = await (0, PacketUtils_1.processPacket)(this.serverPackets, packetTag, values);
220
223
  this.tagsInv.get(tag).forEach(conn => conn.send_processed(...data));
221
224
  }
222
225
  /**
@@ -225,8 +228,8 @@ class SonicWSServer {
225
228
  * @param filter The filter for who to send to
226
229
  * @param values The values to send
227
230
  */
228
- broadcastFiltered(tag, filter, ...values) {
229
- const data = (0, PacketUtils_1.processPacket)(this.serverPackets, tag, values);
231
+ async broadcastFiltered(tag, filter, ...values) {
232
+ const data = await (0, PacketUtils_1.processPacket)(this.serverPackets, tag, values);
230
233
  this.connections.filter(filter).forEach(conn => conn.send_processed(...data));
231
234
  }
232
235
  /**
@@ -11,5 +11,5 @@ export declare class BatchHelper {
11
11
  private initiateBatch;
12
12
  private startBatch;
13
13
  batchPacket(code: number, data: Uint8Array): void;
14
- static unravelBatch(packet: Packet<any>, data: Uint8Array, socket: SonicWSConnection | null): any[] | string;
14
+ static unravelBatch(packet: Packet<any>, data: Uint8Array, socket: SonicWSConnection | null): Promise<any[] | string>;
15
15
  }
@@ -51,7 +51,7 @@ class BatchHelper {
51
51
  if (!this.batchTimeouts[code])
52
52
  this.startBatch(code);
53
53
  }
54
- static unravelBatch(packet, data, socket) {
54
+ static async unravelBatch(packet, data, socket) {
55
55
  const result = [];
56
56
  for (let i = 0; i < data.length;) {
57
57
  // must be >0 for it to apply
@@ -66,7 +66,7 @@ class BatchHelper {
66
66
  // read sector
67
67
  const sect = data.slice(i, i += varint);
68
68
  // call the packets listeners
69
- const listen = packet.listen(sect, socket);
69
+ const listen = await packet.listen(sect, socket);
70
70
  // if invalid, return that
71
71
  if (typeof listen == 'string')
72
72
  return "Batched packet: " + listen;
@@ -15,6 +15,7 @@ export declare const MAX_UVARINT: number;
15
15
  export declare const MAX_VARINT: number;
16
16
  export declare const ONE_EIGHT: number;
17
17
  export declare const ONE_FOURTH: number;
18
+ export declare const EMPTY_UINT8: Uint8Array<ArrayBuffer>;
18
19
  export declare const varIntOverflowPow: (num: number) => number;
19
20
  export type SHORT_BITS = [high: number, low: number];
20
21
  export declare function fromShort(short: SHORT_BITS): number;
@@ -39,3 +40,9 @@ export declare function bytesToBits(bytes: ArrayLike<number>): string;
39
40
  export declare function bitsToBytes(bitString: string): Uint8Array;
40
41
  export declare function encodeHuffman(text: string): Uint8Array;
41
42
  export declare function decodeHuffman(bits: string): string;
43
+ export declare function compressGzip(data: Uint8Array<ArrayBuffer>, ident?: string): Promise<Uint8Array>;
44
+ export declare function decompressGzip(data: Uint8Array): Promise<Uint8Array>;
45
+ export declare const compressJSON: (value: any) => Uint8Array<ArrayBuffer>;
46
+ export declare const decompressJSON: (bytes: Uint8Array) => any;
47
+ export declare function bytesToHex(bytes: Uint8Array): string;
48
+ export declare function hexToBytes(hex: string): Uint8Array<ArrayBuffer>;