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