grpc-libp2p-client 0.0.33 → 0.0.35
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/dc-http2/frame.cjs.js +1 -717
- package/dist/dc-http2/frame.cjs.js.map +1 -1
- package/dist/dc-http2/frame.esm.js +1 -717
- package/dist/dc-http2/frame.esm.js.map +1 -1
- package/dist/dc-http2/hpack.cjs.js +1 -717
- package/dist/dc-http2/hpack.cjs.js.map +1 -1
- package/dist/dc-http2/hpack.esm.js +1 -717
- package/dist/dc-http2/hpack.esm.js.map +1 -1
- package/dist/dc-http2/parser.cjs.js +1 -717
- package/dist/dc-http2/parser.cjs.js.map +1 -1
- package/dist/dc-http2/parser.esm.js +1 -717
- package/dist/dc-http2/parser.esm.js.map +1 -1
- package/dist/dc-http2/stream.cjs.js +18 -3
- package/dist/dc-http2/stream.cjs.js.map +1 -1
- package/dist/dc-http2/stream.esm.js +18 -3
- package/dist/dc-http2/stream.esm.js.map +1 -1
- package/dist/grpc.js +20 -721
- package/dist/grpc.js.map +1 -1
- package/dist/grpc.min.js +1 -1
- package/dist/grpc.min.js.map +1 -1
- package/dist/index.cjs.js +19 -720
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +19 -720
- package/dist/index.esm.js.map +1 -1
- package/dist/stats.html +1 -1
- package/package.json +1 -1
- package/src/dc-http2/hpack.ts +1 -3
- package/src/dc-http2/stream.ts +20 -4
|
@@ -1,720 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function coerce(o) {
|
|
4
|
-
if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array') {
|
|
5
|
-
return o;
|
|
6
|
-
}
|
|
7
|
-
if (o instanceof ArrayBuffer) {
|
|
8
|
-
return new Uint8Array(o);
|
|
9
|
-
}
|
|
10
|
-
if (ArrayBuffer.isView(o)) {
|
|
11
|
-
return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
|
|
12
|
-
}
|
|
13
|
-
throw new Error('Unknown type, must be binary type');
|
|
14
|
-
}
|
|
15
|
-
function fromString(str) {
|
|
16
|
-
return new TextEncoder().encode(str);
|
|
17
|
-
}
|
|
18
|
-
function toString$1(b) {
|
|
19
|
-
return new TextDecoder().decode(b);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/* eslint-disable */
|
|
23
|
-
// base-x encoding / decoding
|
|
24
|
-
// Copyright (c) 2018 base-x contributors
|
|
25
|
-
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
26
|
-
// Distributed under the MIT software license, see the accompanying
|
|
27
|
-
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
28
|
-
/**
|
|
29
|
-
* @param {string} ALPHABET
|
|
30
|
-
* @param {any} name
|
|
31
|
-
*/
|
|
32
|
-
function base(ALPHABET, name) {
|
|
33
|
-
if (ALPHABET.length >= 255) {
|
|
34
|
-
throw new TypeError('Alphabet too long');
|
|
35
|
-
}
|
|
36
|
-
var BASE_MAP = new Uint8Array(256);
|
|
37
|
-
for (var j = 0; j < BASE_MAP.length; j++) {
|
|
38
|
-
BASE_MAP[j] = 255;
|
|
39
|
-
}
|
|
40
|
-
for (var i = 0; i < ALPHABET.length; i++) {
|
|
41
|
-
var x = ALPHABET.charAt(i);
|
|
42
|
-
var xc = x.charCodeAt(0);
|
|
43
|
-
if (BASE_MAP[xc] !== 255) {
|
|
44
|
-
throw new TypeError(x + ' is ambiguous');
|
|
45
|
-
}
|
|
46
|
-
BASE_MAP[xc] = i;
|
|
47
|
-
}
|
|
48
|
-
var BASE = ALPHABET.length;
|
|
49
|
-
var LEADER = ALPHABET.charAt(0);
|
|
50
|
-
var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
51
|
-
var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
52
|
-
/**
|
|
53
|
-
* @param {any[] | Iterable<number>} source
|
|
54
|
-
*/
|
|
55
|
-
function encode(source) {
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
if (source instanceof Uint8Array)
|
|
58
|
-
;
|
|
59
|
-
else if (ArrayBuffer.isView(source)) {
|
|
60
|
-
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
61
|
-
}
|
|
62
|
-
else if (Array.isArray(source)) {
|
|
63
|
-
source = Uint8Array.from(source);
|
|
64
|
-
}
|
|
65
|
-
if (!(source instanceof Uint8Array)) {
|
|
66
|
-
throw new TypeError('Expected Uint8Array');
|
|
67
|
-
}
|
|
68
|
-
if (source.length === 0) {
|
|
69
|
-
return '';
|
|
70
|
-
}
|
|
71
|
-
// Skip & count leading zeroes.
|
|
72
|
-
var zeroes = 0;
|
|
73
|
-
var length = 0;
|
|
74
|
-
var pbegin = 0;
|
|
75
|
-
var pend = source.length;
|
|
76
|
-
while (pbegin !== pend && source[pbegin] === 0) {
|
|
77
|
-
pbegin++;
|
|
78
|
-
zeroes++;
|
|
79
|
-
}
|
|
80
|
-
// Allocate enough space in big-endian base58 representation.
|
|
81
|
-
var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
82
|
-
var b58 = new Uint8Array(size);
|
|
83
|
-
// Process the bytes.
|
|
84
|
-
while (pbegin !== pend) {
|
|
85
|
-
var carry = source[pbegin];
|
|
86
|
-
// Apply "b58 = b58 * 256 + ch".
|
|
87
|
-
var i = 0;
|
|
88
|
-
for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
89
|
-
carry += (256 * b58[it1]) >>> 0;
|
|
90
|
-
b58[it1] = (carry % BASE) >>> 0;
|
|
91
|
-
carry = (carry / BASE) >>> 0;
|
|
92
|
-
}
|
|
93
|
-
if (carry !== 0) {
|
|
94
|
-
throw new Error('Non-zero carry');
|
|
95
|
-
}
|
|
96
|
-
length = i;
|
|
97
|
-
pbegin++;
|
|
98
|
-
}
|
|
99
|
-
// Skip leading zeroes in base58 result.
|
|
100
|
-
var it2 = size - length;
|
|
101
|
-
while (it2 !== size && b58[it2] === 0) {
|
|
102
|
-
it2++;
|
|
103
|
-
}
|
|
104
|
-
// Translate the result into a string.
|
|
105
|
-
var str = LEADER.repeat(zeroes);
|
|
106
|
-
for (; it2 < size; ++it2) {
|
|
107
|
-
str += ALPHABET.charAt(b58[it2]);
|
|
108
|
-
}
|
|
109
|
-
return str;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* @param {string | string[]} source
|
|
113
|
-
*/
|
|
114
|
-
function decodeUnsafe(source) {
|
|
115
|
-
if (typeof source !== 'string') {
|
|
116
|
-
throw new TypeError('Expected String');
|
|
117
|
-
}
|
|
118
|
-
if (source.length === 0) {
|
|
119
|
-
return new Uint8Array();
|
|
120
|
-
}
|
|
121
|
-
var psz = 0;
|
|
122
|
-
// Skip leading spaces.
|
|
123
|
-
if (source[psz] === ' ') {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
// Skip and count leading '1's.
|
|
127
|
-
var zeroes = 0;
|
|
128
|
-
var length = 0;
|
|
129
|
-
while (source[psz] === LEADER) {
|
|
130
|
-
zeroes++;
|
|
131
|
-
psz++;
|
|
132
|
-
}
|
|
133
|
-
// Allocate enough space in big-endian base256 representation.
|
|
134
|
-
var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
135
|
-
var b256 = new Uint8Array(size);
|
|
136
|
-
// Process the characters.
|
|
137
|
-
while (source[psz]) {
|
|
138
|
-
// Decode character
|
|
139
|
-
var carry = BASE_MAP[source.charCodeAt(psz)];
|
|
140
|
-
// Invalid character
|
|
141
|
-
if (carry === 255) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
var i = 0;
|
|
145
|
-
for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
146
|
-
carry += (BASE * b256[it3]) >>> 0;
|
|
147
|
-
b256[it3] = (carry % 256) >>> 0;
|
|
148
|
-
carry = (carry / 256) >>> 0;
|
|
149
|
-
}
|
|
150
|
-
if (carry !== 0) {
|
|
151
|
-
throw new Error('Non-zero carry');
|
|
152
|
-
}
|
|
153
|
-
length = i;
|
|
154
|
-
psz++;
|
|
155
|
-
}
|
|
156
|
-
// Skip trailing spaces.
|
|
157
|
-
if (source[psz] === ' ') {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
// Skip leading zeroes in b256.
|
|
161
|
-
var it4 = size - length;
|
|
162
|
-
while (it4 !== size && b256[it4] === 0) {
|
|
163
|
-
it4++;
|
|
164
|
-
}
|
|
165
|
-
var vch = new Uint8Array(zeroes + (size - it4));
|
|
166
|
-
var j = zeroes;
|
|
167
|
-
while (it4 !== size) {
|
|
168
|
-
vch[j++] = b256[it4++];
|
|
169
|
-
}
|
|
170
|
-
return vch;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* @param {string | string[]} string
|
|
174
|
-
*/
|
|
175
|
-
function decode(string) {
|
|
176
|
-
var buffer = decodeUnsafe(string);
|
|
177
|
-
if (buffer) {
|
|
178
|
-
return buffer;
|
|
179
|
-
}
|
|
180
|
-
throw new Error(`Non-${name} character`);
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
encode: encode,
|
|
184
|
-
decodeUnsafe: decodeUnsafe,
|
|
185
|
-
decode: decode
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
var src = base;
|
|
189
|
-
var _brrp__multiformats_scope_baseX = src;
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Class represents both BaseEncoder and MultibaseEncoder meaning it
|
|
193
|
-
* can be used to encode to multibase or base encode without multibase
|
|
194
|
-
* prefix.
|
|
195
|
-
*/
|
|
196
|
-
class Encoder {
|
|
197
|
-
name;
|
|
198
|
-
prefix;
|
|
199
|
-
baseEncode;
|
|
200
|
-
constructor(name, prefix, baseEncode) {
|
|
201
|
-
this.name = name;
|
|
202
|
-
this.prefix = prefix;
|
|
203
|
-
this.baseEncode = baseEncode;
|
|
204
|
-
}
|
|
205
|
-
encode(bytes) {
|
|
206
|
-
if (bytes instanceof Uint8Array) {
|
|
207
|
-
return `${this.prefix}${this.baseEncode(bytes)}`;
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
throw Error('Unknown type, must be binary type');
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Class represents both BaseDecoder and MultibaseDecoder so it could be used
|
|
216
|
-
* to decode multibases (with matching prefix) or just base decode strings
|
|
217
|
-
* with corresponding base encoding.
|
|
218
|
-
*/
|
|
219
|
-
class Decoder {
|
|
220
|
-
name;
|
|
221
|
-
prefix;
|
|
222
|
-
baseDecode;
|
|
223
|
-
prefixCodePoint;
|
|
224
|
-
constructor(name, prefix, baseDecode) {
|
|
225
|
-
this.name = name;
|
|
226
|
-
this.prefix = prefix;
|
|
227
|
-
const prefixCodePoint = prefix.codePointAt(0);
|
|
228
|
-
/* c8 ignore next 3 */
|
|
229
|
-
if (prefixCodePoint === undefined) {
|
|
230
|
-
throw new Error('Invalid prefix character');
|
|
231
|
-
}
|
|
232
|
-
this.prefixCodePoint = prefixCodePoint;
|
|
233
|
-
this.baseDecode = baseDecode;
|
|
234
|
-
}
|
|
235
|
-
decode(text) {
|
|
236
|
-
if (typeof text === 'string') {
|
|
237
|
-
if (text.codePointAt(0) !== this.prefixCodePoint) {
|
|
238
|
-
throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
|
|
239
|
-
}
|
|
240
|
-
return this.baseDecode(text.slice(this.prefix.length));
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
throw Error('Can only multibase decode strings');
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
or(decoder) {
|
|
247
|
-
return or(this, decoder);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
class ComposedDecoder {
|
|
251
|
-
decoders;
|
|
252
|
-
constructor(decoders) {
|
|
253
|
-
this.decoders = decoders;
|
|
254
|
-
}
|
|
255
|
-
or(decoder) {
|
|
256
|
-
return or(this, decoder);
|
|
257
|
-
}
|
|
258
|
-
decode(input) {
|
|
259
|
-
const prefix = input[0];
|
|
260
|
-
const decoder = this.decoders[prefix];
|
|
261
|
-
if (decoder != null) {
|
|
262
|
-
return decoder.decode(input);
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
function or(left, right) {
|
|
270
|
-
return new ComposedDecoder({
|
|
271
|
-
...(left.decoders ?? { [left.prefix]: left }),
|
|
272
|
-
...(right.decoders ?? { [right.prefix]: right })
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
class Codec {
|
|
276
|
-
name;
|
|
277
|
-
prefix;
|
|
278
|
-
baseEncode;
|
|
279
|
-
baseDecode;
|
|
280
|
-
encoder;
|
|
281
|
-
decoder;
|
|
282
|
-
constructor(name, prefix, baseEncode, baseDecode) {
|
|
283
|
-
this.name = name;
|
|
284
|
-
this.prefix = prefix;
|
|
285
|
-
this.baseEncode = baseEncode;
|
|
286
|
-
this.baseDecode = baseDecode;
|
|
287
|
-
this.encoder = new Encoder(name, prefix, baseEncode);
|
|
288
|
-
this.decoder = new Decoder(name, prefix, baseDecode);
|
|
289
|
-
}
|
|
290
|
-
encode(input) {
|
|
291
|
-
return this.encoder.encode(input);
|
|
292
|
-
}
|
|
293
|
-
decode(input) {
|
|
294
|
-
return this.decoder.decode(input);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
function from({ name, prefix, encode, decode }) {
|
|
298
|
-
return new Codec(name, prefix, encode, decode);
|
|
299
|
-
}
|
|
300
|
-
function baseX({ name, prefix, alphabet }) {
|
|
301
|
-
const { encode, decode } = _brrp__multiformats_scope_baseX(alphabet, name);
|
|
302
|
-
return from({
|
|
303
|
-
prefix,
|
|
304
|
-
name,
|
|
305
|
-
encode,
|
|
306
|
-
decode: (text) => coerce(decode(text))
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
function decode$1(string, alphabetIdx, bitsPerChar, name) {
|
|
310
|
-
// Count the padding bytes:
|
|
311
|
-
let end = string.length;
|
|
312
|
-
while (string[end - 1] === '=') {
|
|
313
|
-
--end;
|
|
314
|
-
}
|
|
315
|
-
// Allocate the output:
|
|
316
|
-
const out = new Uint8Array((end * bitsPerChar / 8) | 0);
|
|
317
|
-
// Parse the data:
|
|
318
|
-
let bits = 0; // Number of bits currently in the buffer
|
|
319
|
-
let buffer = 0; // Bits waiting to be written out, MSB first
|
|
320
|
-
let written = 0; // Next byte to write
|
|
321
|
-
for (let i = 0; i < end; ++i) {
|
|
322
|
-
// Read one character from the string:
|
|
323
|
-
const value = alphabetIdx[string[i]];
|
|
324
|
-
if (value === undefined) {
|
|
325
|
-
throw new SyntaxError(`Non-${name} character`);
|
|
326
|
-
}
|
|
327
|
-
// Append the bits to the buffer:
|
|
328
|
-
buffer = (buffer << bitsPerChar) | value;
|
|
329
|
-
bits += bitsPerChar;
|
|
330
|
-
// Write out some bits if the buffer has a byte's worth:
|
|
331
|
-
if (bits >= 8) {
|
|
332
|
-
bits -= 8;
|
|
333
|
-
out[written++] = 0xff & (buffer >> bits);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
// Verify that we have received just enough bits:
|
|
337
|
-
if (bits >= bitsPerChar || (0xff & (buffer << (8 - bits))) !== 0) {
|
|
338
|
-
throw new SyntaxError('Unexpected end of data');
|
|
339
|
-
}
|
|
340
|
-
return out;
|
|
341
|
-
}
|
|
342
|
-
function encode$1(data, alphabet, bitsPerChar) {
|
|
343
|
-
const pad = alphabet[alphabet.length - 1] === '=';
|
|
344
|
-
const mask = (1 << bitsPerChar) - 1;
|
|
345
|
-
let out = '';
|
|
346
|
-
let bits = 0; // Number of bits currently in the buffer
|
|
347
|
-
let buffer = 0; // Bits waiting to be written out, MSB first
|
|
348
|
-
for (let i = 0; i < data.length; ++i) {
|
|
349
|
-
// Slurp data into the buffer:
|
|
350
|
-
buffer = (buffer << 8) | data[i];
|
|
351
|
-
bits += 8;
|
|
352
|
-
// Write out as much as we can:
|
|
353
|
-
while (bits > bitsPerChar) {
|
|
354
|
-
bits -= bitsPerChar;
|
|
355
|
-
out += alphabet[mask & (buffer >> bits)];
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
// Partial character:
|
|
359
|
-
if (bits !== 0) {
|
|
360
|
-
out += alphabet[mask & (buffer << (bitsPerChar - bits))];
|
|
361
|
-
}
|
|
362
|
-
// Add padding characters until we hit a byte boundary:
|
|
363
|
-
if (pad) {
|
|
364
|
-
while (((out.length * bitsPerChar) & 7) !== 0) {
|
|
365
|
-
out += '=';
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
return out;
|
|
369
|
-
}
|
|
370
|
-
function createAlphabetIdx(alphabet) {
|
|
371
|
-
// Build the character lookup table:
|
|
372
|
-
const alphabetIdx = {};
|
|
373
|
-
for (let i = 0; i < alphabet.length; ++i) {
|
|
374
|
-
alphabetIdx[alphabet[i]] = i;
|
|
375
|
-
}
|
|
376
|
-
return alphabetIdx;
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* RFC4648 Factory
|
|
380
|
-
*/
|
|
381
|
-
function rfc4648({ name, prefix, bitsPerChar, alphabet }) {
|
|
382
|
-
const alphabetIdx = createAlphabetIdx(alphabet);
|
|
383
|
-
return from({
|
|
384
|
-
prefix,
|
|
385
|
-
name,
|
|
386
|
-
encode(input) {
|
|
387
|
-
return encode$1(input, alphabet, bitsPerChar);
|
|
388
|
-
},
|
|
389
|
-
decode(input) {
|
|
390
|
-
return decode$1(input, alphabetIdx, bitsPerChar, name);
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
const base10 = baseX({
|
|
396
|
-
prefix: '9',
|
|
397
|
-
name: 'base10',
|
|
398
|
-
alphabet: '0123456789'
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
var base10$1 = /*#__PURE__*/Object.freeze({
|
|
402
|
-
__proto__: null,
|
|
403
|
-
base10: base10
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
const base16 = rfc4648({
|
|
407
|
-
prefix: 'f',
|
|
408
|
-
name: 'base16',
|
|
409
|
-
alphabet: '0123456789abcdef',
|
|
410
|
-
bitsPerChar: 4
|
|
411
|
-
});
|
|
412
|
-
const base16upper = rfc4648({
|
|
413
|
-
prefix: 'F',
|
|
414
|
-
name: 'base16upper',
|
|
415
|
-
alphabet: '0123456789ABCDEF',
|
|
416
|
-
bitsPerChar: 4
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
var base16$1 = /*#__PURE__*/Object.freeze({
|
|
420
|
-
__proto__: null,
|
|
421
|
-
base16: base16,
|
|
422
|
-
base16upper: base16upper
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
const base2 = rfc4648({
|
|
426
|
-
prefix: '0',
|
|
427
|
-
name: 'base2',
|
|
428
|
-
alphabet: '01',
|
|
429
|
-
bitsPerChar: 1
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
var base2$1 = /*#__PURE__*/Object.freeze({
|
|
433
|
-
__proto__: null,
|
|
434
|
-
base2: base2
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
const alphabet = Array.from('🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂');
|
|
438
|
-
const alphabetBytesToChars = (alphabet.reduce((p, c, i) => { p[i] = c; return p; }, ([])));
|
|
439
|
-
const alphabetCharsToBytes = (alphabet.reduce((p, c, i) => {
|
|
440
|
-
const codePoint = c.codePointAt(0);
|
|
441
|
-
if (codePoint == null) {
|
|
442
|
-
throw new Error(`Invalid character: ${c}`);
|
|
443
|
-
}
|
|
444
|
-
p[codePoint] = i;
|
|
445
|
-
return p;
|
|
446
|
-
}, ([])));
|
|
447
|
-
function encode(data) {
|
|
448
|
-
return data.reduce((p, c) => {
|
|
449
|
-
p += alphabetBytesToChars[c];
|
|
450
|
-
return p;
|
|
451
|
-
}, '');
|
|
452
|
-
}
|
|
453
|
-
function decode(str) {
|
|
454
|
-
const byts = [];
|
|
455
|
-
for (const char of str) {
|
|
456
|
-
const codePoint = char.codePointAt(0);
|
|
457
|
-
if (codePoint == null) {
|
|
458
|
-
throw new Error(`Invalid character: ${char}`);
|
|
459
|
-
}
|
|
460
|
-
const byt = alphabetCharsToBytes[codePoint];
|
|
461
|
-
if (byt == null) {
|
|
462
|
-
throw new Error(`Non-base256emoji character: ${char}`);
|
|
463
|
-
}
|
|
464
|
-
byts.push(byt);
|
|
465
|
-
}
|
|
466
|
-
return new Uint8Array(byts);
|
|
467
|
-
}
|
|
468
|
-
const base256emoji = from({
|
|
469
|
-
prefix: '🚀',
|
|
470
|
-
name: 'base256emoji',
|
|
471
|
-
encode,
|
|
472
|
-
decode
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
var base256emoji$1 = /*#__PURE__*/Object.freeze({
|
|
476
|
-
__proto__: null,
|
|
477
|
-
base256emoji: base256emoji
|
|
478
|
-
});
|
|
479
|
-
|
|
480
|
-
const base32 = rfc4648({
|
|
481
|
-
prefix: 'b',
|
|
482
|
-
name: 'base32',
|
|
483
|
-
alphabet: 'abcdefghijklmnopqrstuvwxyz234567',
|
|
484
|
-
bitsPerChar: 5
|
|
485
|
-
});
|
|
486
|
-
const base32upper = rfc4648({
|
|
487
|
-
prefix: 'B',
|
|
488
|
-
name: 'base32upper',
|
|
489
|
-
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',
|
|
490
|
-
bitsPerChar: 5
|
|
491
|
-
});
|
|
492
|
-
const base32pad = rfc4648({
|
|
493
|
-
prefix: 'c',
|
|
494
|
-
name: 'base32pad',
|
|
495
|
-
alphabet: 'abcdefghijklmnopqrstuvwxyz234567=',
|
|
496
|
-
bitsPerChar: 5
|
|
497
|
-
});
|
|
498
|
-
const base32padupper = rfc4648({
|
|
499
|
-
prefix: 'C',
|
|
500
|
-
name: 'base32padupper',
|
|
501
|
-
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=',
|
|
502
|
-
bitsPerChar: 5
|
|
503
|
-
});
|
|
504
|
-
const base32hex = rfc4648({
|
|
505
|
-
prefix: 'v',
|
|
506
|
-
name: 'base32hex',
|
|
507
|
-
alphabet: '0123456789abcdefghijklmnopqrstuv',
|
|
508
|
-
bitsPerChar: 5
|
|
509
|
-
});
|
|
510
|
-
const base32hexupper = rfc4648({
|
|
511
|
-
prefix: 'V',
|
|
512
|
-
name: 'base32hexupper',
|
|
513
|
-
alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV',
|
|
514
|
-
bitsPerChar: 5
|
|
515
|
-
});
|
|
516
|
-
const base32hexpad = rfc4648({
|
|
517
|
-
prefix: 't',
|
|
518
|
-
name: 'base32hexpad',
|
|
519
|
-
alphabet: '0123456789abcdefghijklmnopqrstuv=',
|
|
520
|
-
bitsPerChar: 5
|
|
521
|
-
});
|
|
522
|
-
const base32hexpadupper = rfc4648({
|
|
523
|
-
prefix: 'T',
|
|
524
|
-
name: 'base32hexpadupper',
|
|
525
|
-
alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=',
|
|
526
|
-
bitsPerChar: 5
|
|
527
|
-
});
|
|
528
|
-
const base32z = rfc4648({
|
|
529
|
-
prefix: 'h',
|
|
530
|
-
name: 'base32z',
|
|
531
|
-
alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769',
|
|
532
|
-
bitsPerChar: 5
|
|
533
|
-
});
|
|
534
|
-
|
|
535
|
-
var base32$1 = /*#__PURE__*/Object.freeze({
|
|
536
|
-
__proto__: null,
|
|
537
|
-
base32: base32,
|
|
538
|
-
base32hex: base32hex,
|
|
539
|
-
base32hexpad: base32hexpad,
|
|
540
|
-
base32hexpadupper: base32hexpadupper,
|
|
541
|
-
base32hexupper: base32hexupper,
|
|
542
|
-
base32pad: base32pad,
|
|
543
|
-
base32padupper: base32padupper,
|
|
544
|
-
base32upper: base32upper,
|
|
545
|
-
base32z: base32z
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
const base36 = baseX({
|
|
549
|
-
prefix: 'k',
|
|
550
|
-
name: 'base36',
|
|
551
|
-
alphabet: '0123456789abcdefghijklmnopqrstuvwxyz'
|
|
552
|
-
});
|
|
553
|
-
const base36upper = baseX({
|
|
554
|
-
prefix: 'K',
|
|
555
|
-
name: 'base36upper',
|
|
556
|
-
alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
var base36$1 = /*#__PURE__*/Object.freeze({
|
|
560
|
-
__proto__: null,
|
|
561
|
-
base36: base36,
|
|
562
|
-
base36upper: base36upper
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
const base58btc = baseX({
|
|
566
|
-
name: 'base58btc',
|
|
567
|
-
prefix: 'z',
|
|
568
|
-
alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
|
569
|
-
});
|
|
570
|
-
const base58flickr = baseX({
|
|
571
|
-
name: 'base58flickr',
|
|
572
|
-
prefix: 'Z',
|
|
573
|
-
alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
|
|
574
|
-
});
|
|
575
|
-
|
|
576
|
-
var base58 = /*#__PURE__*/Object.freeze({
|
|
577
|
-
__proto__: null,
|
|
578
|
-
base58btc: base58btc,
|
|
579
|
-
base58flickr: base58flickr
|
|
580
|
-
});
|
|
581
|
-
|
|
582
|
-
const base64 = rfc4648({
|
|
583
|
-
prefix: 'm',
|
|
584
|
-
name: 'base64',
|
|
585
|
-
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
|
|
586
|
-
bitsPerChar: 6
|
|
587
|
-
});
|
|
588
|
-
const base64pad = rfc4648({
|
|
589
|
-
prefix: 'M',
|
|
590
|
-
name: 'base64pad',
|
|
591
|
-
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
|
592
|
-
bitsPerChar: 6
|
|
593
|
-
});
|
|
594
|
-
const base64url = rfc4648({
|
|
595
|
-
prefix: 'u',
|
|
596
|
-
name: 'base64url',
|
|
597
|
-
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
|
|
598
|
-
bitsPerChar: 6
|
|
599
|
-
});
|
|
600
|
-
const base64urlpad = rfc4648({
|
|
601
|
-
prefix: 'U',
|
|
602
|
-
name: 'base64urlpad',
|
|
603
|
-
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=',
|
|
604
|
-
bitsPerChar: 6
|
|
605
|
-
});
|
|
606
|
-
|
|
607
|
-
var base64$1 = /*#__PURE__*/Object.freeze({
|
|
608
|
-
__proto__: null,
|
|
609
|
-
base64: base64,
|
|
610
|
-
base64pad: base64pad,
|
|
611
|
-
base64url: base64url,
|
|
612
|
-
base64urlpad: base64urlpad
|
|
613
|
-
});
|
|
614
|
-
|
|
615
|
-
const base8 = rfc4648({
|
|
616
|
-
prefix: '7',
|
|
617
|
-
name: 'base8',
|
|
618
|
-
alphabet: '01234567',
|
|
619
|
-
bitsPerChar: 3
|
|
620
|
-
});
|
|
621
|
-
|
|
622
|
-
var base8$1 = /*#__PURE__*/Object.freeze({
|
|
623
|
-
__proto__: null,
|
|
624
|
-
base8: base8
|
|
625
|
-
});
|
|
626
|
-
|
|
627
|
-
const identity = from({
|
|
628
|
-
prefix: '\x00',
|
|
629
|
-
name: 'identity',
|
|
630
|
-
encode: (buf) => toString$1(buf),
|
|
631
|
-
decode: (str) => fromString(str)
|
|
632
|
-
});
|
|
633
|
-
|
|
634
|
-
var identityBase = /*#__PURE__*/Object.freeze({
|
|
635
|
-
__proto__: null,
|
|
636
|
-
identity: identity
|
|
637
|
-
});
|
|
638
|
-
|
|
639
|
-
new TextEncoder();
|
|
640
|
-
new TextDecoder();
|
|
641
|
-
|
|
642
|
-
const bases = { ...identityBase, ...base2$1, ...base8$1, ...base10$1, ...base16$1, ...base32$1, ...base36$1, ...base58, ...base64$1, ...base256emoji$1 };
|
|
643
|
-
|
|
644
|
-
/**
|
|
645
|
-
* Returns a `Uint8Array` of the requested size. Referenced memory will
|
|
646
|
-
* be initialized to 0.
|
|
647
|
-
*/
|
|
648
|
-
/**
|
|
649
|
-
* Where possible returns a Uint8Array of the requested size that references
|
|
650
|
-
* uninitialized memory. Only use if you are certain you will immediately
|
|
651
|
-
* overwrite every value in the returned `Uint8Array`.
|
|
652
|
-
*/
|
|
653
|
-
function allocUnsafe(size = 0) {
|
|
654
|
-
return new Uint8Array(size);
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
function createCodec(name, prefix, encode, decode) {
|
|
658
|
-
return {
|
|
659
|
-
name,
|
|
660
|
-
prefix,
|
|
661
|
-
encoder: {
|
|
662
|
-
name,
|
|
663
|
-
prefix,
|
|
664
|
-
encode
|
|
665
|
-
},
|
|
666
|
-
decoder: {
|
|
667
|
-
decode
|
|
668
|
-
}
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
|
-
const string = createCodec('utf8', 'u', (buf) => {
|
|
672
|
-
const decoder = new TextDecoder('utf8');
|
|
673
|
-
return 'u' + decoder.decode(buf);
|
|
674
|
-
}, (str) => {
|
|
675
|
-
const encoder = new TextEncoder();
|
|
676
|
-
return encoder.encode(str.substring(1));
|
|
677
|
-
});
|
|
678
|
-
const ascii = createCodec('ascii', 'a', (buf) => {
|
|
679
|
-
let string = 'a';
|
|
680
|
-
for (let i = 0; i < buf.length; i++) {
|
|
681
|
-
string += String.fromCharCode(buf[i]);
|
|
682
|
-
}
|
|
683
|
-
return string;
|
|
684
|
-
}, (str) => {
|
|
685
|
-
str = str.substring(1);
|
|
686
|
-
const buf = allocUnsafe(str.length);
|
|
687
|
-
for (let i = 0; i < str.length; i++) {
|
|
688
|
-
buf[i] = str.charCodeAt(i);
|
|
689
|
-
}
|
|
690
|
-
return buf;
|
|
691
|
-
});
|
|
692
|
-
const BASES = {
|
|
693
|
-
utf8: string,
|
|
694
|
-
'utf-8': string,
|
|
695
|
-
hex: bases.base16,
|
|
696
|
-
latin1: ascii,
|
|
697
|
-
ascii,
|
|
698
|
-
binary: ascii,
|
|
699
|
-
...bases
|
|
700
|
-
};
|
|
701
|
-
|
|
702
|
-
/**
|
|
703
|
-
* Turns a `Uint8Array` into a string.
|
|
704
|
-
*
|
|
705
|
-
* Supports `utf8`, `utf-8` and any encoding supported by the multibase module.
|
|
706
|
-
*
|
|
707
|
-
* Also `ascii` which is similar to node's 'binary' encoding.
|
|
708
|
-
*/
|
|
709
|
-
function toString(array, encoding = 'utf8') {
|
|
710
|
-
const base = BASES[encoding];
|
|
711
|
-
if (base == null) {
|
|
712
|
-
throw new Error(`Unsupported encoding "${encoding}"`);
|
|
713
|
-
}
|
|
714
|
-
// strip multibase prefix
|
|
715
|
-
return base.encoder.encode(array).substring(1);
|
|
716
|
-
}
|
|
717
|
-
|
|
718
3
|
// HPACK Implementation
|
|
719
4
|
class HPACK {
|
|
720
5
|
constructor(maxDynamicTableSize = 4096) {
|
|
@@ -1157,8 +442,7 @@ class HPACK {
|
|
|
1157
442
|
}
|
|
1158
443
|
else {
|
|
1159
444
|
try {
|
|
1160
|
-
|
|
1161
|
-
result = toString(bytes);
|
|
445
|
+
result = new TextDecoder().decode(bytes);
|
|
1162
446
|
}
|
|
1163
447
|
catch (e) {
|
|
1164
448
|
result = '';
|