@waku/message-encryption 0.0.24 → 0.0.26-070b625.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/bundle/crypto.js +1 -1
- package/bundle/{ecies-R65pUoo3.js → ecies-pobP8Dyx.js} +2 -2
- package/bundle/ecies.js +3 -3
- package/bundle/{encryption-zFGfcjHZ.js → encryption-D5jL4iz1.js} +1786 -2826
- package/bundle/{index-alzPvot7.js → index-DxtaUQnt.js} +1 -1
- package/bundle/index.js +5 -5
- package/bundle/{symmetric-7aAyizy_.js → symmetric-HwbDJphw.js} +2 -2
- package/bundle/{symmetric-CXVjdTdV.js → symmetric-qyNI8P98.js} +468 -624
- package/bundle/symmetric.js +3 -3
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/misc.js +1 -1
- package/dist/misc.js.map +1 -1
- package/package.json +1 -112
- package/src/index.ts +1 -1
@@ -1036,514 +1036,396 @@ Object.defineProperties(utils, {
|
|
1036
1036
|
},
|
1037
1037
|
});
|
1038
1038
|
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
if (
|
1045
|
-
return new Uint8Array(
|
1039
|
+
function coerce(o) {
|
1040
|
+
if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array')
|
1041
|
+
return o;
|
1042
|
+
if (o instanceof ArrayBuffer)
|
1043
|
+
return new Uint8Array(o);
|
1044
|
+
if (ArrayBuffer.isView(o)) {
|
1045
|
+
return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
|
1046
1046
|
}
|
1047
|
-
|
1047
|
+
throw new Error('Unknown type, must be binary type');
|
1048
|
+
}
|
1049
|
+
function fromString$1(str) {
|
1050
|
+
return new TextEncoder().encode(str);
|
1051
|
+
}
|
1052
|
+
function toString(b) {
|
1053
|
+
return new TextDecoder().decode(b);
|
1048
1054
|
}
|
1049
1055
|
|
1056
|
+
/* eslint-disable */
|
1050
1057
|
// base-x encoding / decoding
|
1051
1058
|
// Copyright (c) 2018 base-x contributors
|
1052
1059
|
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
1053
1060
|
// Distributed under the MIT software license, see the accompanying
|
1054
1061
|
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
var
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
} else if (Array.isArray(source)) {
|
1075
|
-
source = Uint8Array.from(source);
|
1076
|
-
}
|
1077
|
-
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
1078
|
-
if (source.length === 0) { return '' }
|
1079
|
-
// Skip & count leading zeroes.
|
1080
|
-
var zeroes = 0;
|
1081
|
-
var length = 0;
|
1082
|
-
var pbegin = 0;
|
1083
|
-
var pend = source.length;
|
1084
|
-
while (pbegin !== pend && source[pbegin] === 0) {
|
1085
|
-
pbegin++;
|
1086
|
-
zeroes++;
|
1062
|
+
/**
|
1063
|
+
* @param {string} ALPHABET
|
1064
|
+
* @param {any} name
|
1065
|
+
*/
|
1066
|
+
function base(ALPHABET, name) {
|
1067
|
+
if (ALPHABET.length >= 255) {
|
1068
|
+
throw new TypeError('Alphabet too long');
|
1069
|
+
}
|
1070
|
+
var BASE_MAP = new Uint8Array(256);
|
1071
|
+
for (var j = 0; j < BASE_MAP.length; j++) {
|
1072
|
+
BASE_MAP[j] = 255;
|
1073
|
+
}
|
1074
|
+
for (var i = 0; i < ALPHABET.length; i++) {
|
1075
|
+
var x = ALPHABET.charAt(i);
|
1076
|
+
var xc = x.charCodeAt(0);
|
1077
|
+
if (BASE_MAP[xc] !== 255) {
|
1078
|
+
throw new TypeError(x + ' is ambiguous');
|
1079
|
+
}
|
1080
|
+
BASE_MAP[xc] = i;
|
1087
1081
|
}
|
1082
|
+
var BASE = ALPHABET.length;
|
1083
|
+
var LEADER = ALPHABET.charAt(0);
|
1084
|
+
var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
1085
|
+
var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
1086
|
+
/**
|
1087
|
+
* @param {any[] | Iterable<number>} source
|
1088
|
+
*/
|
1089
|
+
function encode(source) {
|
1090
|
+
// @ts-ignore
|
1091
|
+
if (source instanceof Uint8Array)
|
1092
|
+
;
|
1093
|
+
else if (ArrayBuffer.isView(source)) {
|
1094
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
1095
|
+
}
|
1096
|
+
else if (Array.isArray(source)) {
|
1097
|
+
source = Uint8Array.from(source);
|
1098
|
+
}
|
1099
|
+
if (!(source instanceof Uint8Array)) {
|
1100
|
+
throw new TypeError('Expected Uint8Array');
|
1101
|
+
}
|
1102
|
+
if (source.length === 0) {
|
1103
|
+
return '';
|
1104
|
+
}
|
1105
|
+
// Skip & count leading zeroes.
|
1106
|
+
var zeroes = 0;
|
1107
|
+
var length = 0;
|
1108
|
+
var pbegin = 0;
|
1109
|
+
var pend = source.length;
|
1110
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
1111
|
+
pbegin++;
|
1112
|
+
zeroes++;
|
1113
|
+
}
|
1088
1114
|
// Allocate enough space in big-endian base58 representation.
|
1089
|
-
|
1090
|
-
|
1115
|
+
var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
1116
|
+
var b58 = new Uint8Array(size);
|
1091
1117
|
// Process the bytes.
|
1092
|
-
|
1093
|
-
|
1118
|
+
while (pbegin !== pend) {
|
1119
|
+
var carry = source[pbegin];
|
1094
1120
|
// Apply "b58 = b58 * 256 + ch".
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1121
|
+
var i = 0;
|
1122
|
+
for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
1123
|
+
carry += (256 * b58[it1]) >>> 0;
|
1124
|
+
b58[it1] = (carry % BASE) >>> 0;
|
1125
|
+
carry = (carry / BASE) >>> 0;
|
1126
|
+
}
|
1127
|
+
if (carry !== 0) {
|
1128
|
+
throw new Error('Non-zero carry');
|
1129
|
+
}
|
1130
|
+
length = i;
|
1131
|
+
pbegin++;
|
1132
|
+
}
|
1105
1133
|
// Skip leading zeroes in base58 result.
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1134
|
+
var it2 = size - length;
|
1135
|
+
while (it2 !== size && b58[it2] === 0) {
|
1136
|
+
it2++;
|
1137
|
+
}
|
1110
1138
|
// Translate the result into a string.
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1139
|
+
var str = LEADER.repeat(zeroes);
|
1140
|
+
for (; it2 < size; ++it2) {
|
1141
|
+
str += ALPHABET.charAt(b58[it2]);
|
1142
|
+
}
|
1143
|
+
return str;
|
1144
|
+
}
|
1145
|
+
/**
|
1146
|
+
* @param {string | string[]} source
|
1147
|
+
*/
|
1148
|
+
function decodeUnsafe(source) {
|
1149
|
+
if (typeof source !== 'string') {
|
1150
|
+
throw new TypeError('Expected String');
|
1151
|
+
}
|
1152
|
+
if (source.length === 0) {
|
1153
|
+
return new Uint8Array();
|
1154
|
+
}
|
1155
|
+
var psz = 0;
|
1119
1156
|
// Skip leading spaces.
|
1120
|
-
|
1157
|
+
if (source[psz] === ' ') {
|
1158
|
+
return;
|
1159
|
+
}
|
1121
1160
|
// Skip and count leading '1's.
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1161
|
+
var zeroes = 0;
|
1162
|
+
var length = 0;
|
1163
|
+
while (source[psz] === LEADER) {
|
1164
|
+
zeroes++;
|
1165
|
+
psz++;
|
1166
|
+
}
|
1128
1167
|
// Allocate enough space in big-endian base256 representation.
|
1129
|
-
|
1130
|
-
|
1168
|
+
var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
1169
|
+
var b256 = new Uint8Array(size);
|
1131
1170
|
// Process the characters.
|
1132
|
-
|
1171
|
+
while (source[psz]) {
|
1133
1172
|
// Decode character
|
1134
|
-
|
1173
|
+
var carry = BASE_MAP[source.charCodeAt(psz)];
|
1135
1174
|
// Invalid character
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1175
|
+
if (carry === 255) {
|
1176
|
+
return;
|
1177
|
+
}
|
1178
|
+
var i = 0;
|
1179
|
+
for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
1180
|
+
carry += (BASE * b256[it3]) >>> 0;
|
1181
|
+
b256[it3] = (carry % 256) >>> 0;
|
1182
|
+
carry = (carry / 256) >>> 0;
|
1183
|
+
}
|
1184
|
+
if (carry !== 0) {
|
1185
|
+
throw new Error('Non-zero carry');
|
1186
|
+
}
|
1187
|
+
length = i;
|
1188
|
+
psz++;
|
1189
|
+
}
|
1147
1190
|
// Skip trailing spaces.
|
1148
|
-
|
1191
|
+
if (source[psz] === ' ') {
|
1192
|
+
return;
|
1193
|
+
}
|
1149
1194
|
// Skip leading zeroes in b256.
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1195
|
+
var it4 = size - length;
|
1196
|
+
while (it4 !== size && b256[it4] === 0) {
|
1197
|
+
it4++;
|
1198
|
+
}
|
1199
|
+
var vch = new Uint8Array(zeroes + (size - it4));
|
1200
|
+
var j = zeroes;
|
1201
|
+
while (it4 !== size) {
|
1202
|
+
vch[j++] = b256[it4++];
|
1203
|
+
}
|
1204
|
+
return vch;
|
1205
|
+
}
|
1206
|
+
/**
|
1207
|
+
* @param {string | string[]} string
|
1208
|
+
*/
|
1209
|
+
function decode(string) {
|
1210
|
+
var buffer = decodeUnsafe(string);
|
1211
|
+
if (buffer) {
|
1212
|
+
return buffer;
|
1213
|
+
}
|
1214
|
+
throw new Error(`Non-${name} character`);
|
1215
|
+
}
|
1216
|
+
return {
|
1217
|
+
encode: encode,
|
1218
|
+
decodeUnsafe: decodeUnsafe,
|
1219
|
+
decode: decode
|
1220
|
+
};
|
1171
1221
|
}
|
1172
1222
|
var src = base;
|
1173
|
-
|
1174
1223
|
var _brrp__multiformats_scope_baseX = src;
|
1175
1224
|
|
1176
|
-
/**
|
1177
|
-
* @param {ArrayBufferView|ArrayBuffer|Uint8Array} o
|
1178
|
-
* @returns {Uint8Array}
|
1179
|
-
*/
|
1180
|
-
const coerce = o => {
|
1181
|
-
if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array') return o
|
1182
|
-
if (o instanceof ArrayBuffer) return new Uint8Array(o)
|
1183
|
-
if (ArrayBuffer.isView(o)) {
|
1184
|
-
return new Uint8Array(o.buffer, o.byteOffset, o.byteLength)
|
1185
|
-
}
|
1186
|
-
throw new Error('Unknown type, must be binary type')
|
1187
|
-
};
|
1188
|
-
|
1189
|
-
/**
|
1190
|
-
* @param {string} str
|
1191
|
-
* @returns {Uint8Array}
|
1192
|
-
*/
|
1193
|
-
const fromString$1 = str => (new TextEncoder()).encode(str);
|
1194
|
-
|
1195
|
-
/**
|
1196
|
-
* @param {Uint8Array} b
|
1197
|
-
* @returns {string}
|
1198
|
-
*/
|
1199
|
-
const toString = b => (new TextDecoder()).decode(b);
|
1200
|
-
|
1201
1225
|
/**
|
1202
1226
|
* Class represents both BaseEncoder and MultibaseEncoder meaning it
|
1203
1227
|
* can be used to encode to multibase or base encode without multibase
|
1204
1228
|
* prefix.
|
1205
|
-
*
|
1206
|
-
* @class
|
1207
|
-
* @template {string} Base
|
1208
|
-
* @template {string} Prefix
|
1209
|
-
* @implements {API.MultibaseEncoder<Prefix>}
|
1210
|
-
* @implements {API.BaseEncoder}
|
1211
1229
|
*/
|
1212
1230
|
class Encoder {
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
if (bytes instanceof Uint8Array) {
|
1230
|
-
return `${this.prefix}${this.baseEncode(bytes)}`
|
1231
|
-
} else {
|
1232
|
-
throw Error('Unknown type, must be binary type')
|
1233
|
-
}
|
1234
|
-
}
|
1231
|
+
name;
|
1232
|
+
prefix;
|
1233
|
+
baseEncode;
|
1234
|
+
constructor(name, prefix, baseEncode) {
|
1235
|
+
this.name = name;
|
1236
|
+
this.prefix = prefix;
|
1237
|
+
this.baseEncode = baseEncode;
|
1238
|
+
}
|
1239
|
+
encode(bytes) {
|
1240
|
+
if (bytes instanceof Uint8Array) {
|
1241
|
+
return `${this.prefix}${this.baseEncode(bytes)}`;
|
1242
|
+
}
|
1243
|
+
else {
|
1244
|
+
throw Error('Unknown type, must be binary type');
|
1245
|
+
}
|
1246
|
+
}
|
1235
1247
|
}
|
1236
|
-
|
1237
|
-
/**
|
1238
|
-
* @template {string} Prefix
|
1239
|
-
*/
|
1240
1248
|
/**
|
1241
1249
|
* Class represents both BaseDecoder and MultibaseDecoder so it could be used
|
1242
1250
|
* to decode multibases (with matching prefix) or just base decode strings
|
1243
1251
|
* with corresponding base encoding.
|
1244
|
-
*
|
1245
|
-
* @class
|
1246
|
-
* @template {string} Base
|
1247
|
-
* @template {string} Prefix
|
1248
|
-
* @implements {API.MultibaseDecoder<Prefix>}
|
1249
|
-
* @implements {API.UnibaseDecoder<Prefix>}
|
1250
|
-
* @implements {API.BaseDecoder}
|
1251
1252
|
*/
|
1252
1253
|
class Decoder {
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
}
|
1282
|
-
}
|
1283
|
-
|
1284
|
-
/**
|
1285
|
-
* @template {string} OtherPrefix
|
1286
|
-
* @param {API.UnibaseDecoder<OtherPrefix>|ComposedDecoder<OtherPrefix>} decoder
|
1287
|
-
* @returns {ComposedDecoder<Prefix|OtherPrefix>}
|
1288
|
-
*/
|
1289
|
-
or (decoder) {
|
1290
|
-
return or(this, decoder)
|
1291
|
-
}
|
1254
|
+
name;
|
1255
|
+
prefix;
|
1256
|
+
baseDecode;
|
1257
|
+
prefixCodePoint;
|
1258
|
+
constructor(name, prefix, baseDecode) {
|
1259
|
+
this.name = name;
|
1260
|
+
this.prefix = prefix;
|
1261
|
+
/* c8 ignore next 3 */
|
1262
|
+
if (prefix.codePointAt(0) === undefined) {
|
1263
|
+
throw new Error('Invalid prefix character');
|
1264
|
+
}
|
1265
|
+
this.prefixCodePoint = prefix.codePointAt(0);
|
1266
|
+
this.baseDecode = baseDecode;
|
1267
|
+
}
|
1268
|
+
decode(text) {
|
1269
|
+
if (typeof text === 'string') {
|
1270
|
+
if (text.codePointAt(0) !== this.prefixCodePoint) {
|
1271
|
+
throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
|
1272
|
+
}
|
1273
|
+
return this.baseDecode(text.slice(this.prefix.length));
|
1274
|
+
}
|
1275
|
+
else {
|
1276
|
+
throw Error('Can only multibase decode strings');
|
1277
|
+
}
|
1278
|
+
}
|
1279
|
+
or(decoder) {
|
1280
|
+
return or(this, decoder);
|
1281
|
+
}
|
1292
1282
|
}
|
1293
|
-
|
1294
|
-
/**
|
1295
|
-
* @template {string} Prefix
|
1296
|
-
* @typedef {Record<Prefix, API.UnibaseDecoder<Prefix>>} Decoders
|
1297
|
-
*/
|
1298
|
-
|
1299
|
-
/**
|
1300
|
-
* @template {string} Prefix
|
1301
|
-
* @implements {API.MultibaseDecoder<Prefix>}
|
1302
|
-
* @implements {API.CombobaseDecoder<Prefix>}
|
1303
|
-
*/
|
1304
1283
|
class ComposedDecoder {
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
return decoder.decode(input)
|
1330
|
-
} else {
|
1331
|
-
throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)
|
1332
|
-
}
|
1333
|
-
}
|
1284
|
+
decoders;
|
1285
|
+
constructor(decoders) {
|
1286
|
+
this.decoders = decoders;
|
1287
|
+
}
|
1288
|
+
or(decoder) {
|
1289
|
+
return or(this, decoder);
|
1290
|
+
}
|
1291
|
+
decode(input) {
|
1292
|
+
const prefix = input[0];
|
1293
|
+
const decoder = this.decoders[prefix];
|
1294
|
+
if (decoder != null) {
|
1295
|
+
return decoder.decode(input);
|
1296
|
+
}
|
1297
|
+
else {
|
1298
|
+
throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
|
1299
|
+
}
|
1300
|
+
}
|
1301
|
+
}
|
1302
|
+
function or(left, right) {
|
1303
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
1304
|
+
return new ComposedDecoder({
|
1305
|
+
...(left.decoders ?? { [left.prefix]: left }),
|
1306
|
+
...(right.decoders ?? { [right.prefix]: right })
|
1307
|
+
});
|
1334
1308
|
}
|
1335
|
-
|
1336
|
-
/**
|
1337
|
-
* @template {string} L
|
1338
|
-
* @template {string} R
|
1339
|
-
* @param {API.UnibaseDecoder<L>|API.CombobaseDecoder<L>} left
|
1340
|
-
* @param {API.UnibaseDecoder<R>|API.CombobaseDecoder<R>} right
|
1341
|
-
* @returns {ComposedDecoder<L|R>}
|
1342
|
-
*/
|
1343
|
-
const or = (left, right) => new ComposedDecoder(/** @type {Decoders<L|R>} */({
|
1344
|
-
...(left.decoders || { [/** @type API.UnibaseDecoder<L> */(left).prefix]: left }),
|
1345
|
-
...(right.decoders || { [/** @type API.UnibaseDecoder<R> */(right).prefix]: right })
|
1346
|
-
}));
|
1347
|
-
|
1348
|
-
/**
|
1349
|
-
* @class
|
1350
|
-
* @template {string} Base
|
1351
|
-
* @template {string} Prefix
|
1352
|
-
* @implements {API.MultibaseCodec<Prefix>}
|
1353
|
-
* @implements {API.MultibaseEncoder<Prefix>}
|
1354
|
-
* @implements {API.MultibaseDecoder<Prefix>}
|
1355
|
-
* @implements {API.BaseCodec}
|
1356
|
-
* @implements {API.BaseEncoder}
|
1357
|
-
* @implements {API.BaseDecoder}
|
1358
|
-
*/
|
1359
1309
|
class Codec {
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
return
|
1387
|
-
|
1310
|
+
name;
|
1311
|
+
prefix;
|
1312
|
+
baseEncode;
|
1313
|
+
baseDecode;
|
1314
|
+
encoder;
|
1315
|
+
decoder;
|
1316
|
+
constructor(name, prefix, baseEncode, baseDecode) {
|
1317
|
+
this.name = name;
|
1318
|
+
this.prefix = prefix;
|
1319
|
+
this.baseEncode = baseEncode;
|
1320
|
+
this.baseDecode = baseDecode;
|
1321
|
+
this.encoder = new Encoder(name, prefix, baseEncode);
|
1322
|
+
this.decoder = new Decoder(name, prefix, baseDecode);
|
1323
|
+
}
|
1324
|
+
encode(input) {
|
1325
|
+
return this.encoder.encode(input);
|
1326
|
+
}
|
1327
|
+
decode(input) {
|
1328
|
+
return this.decoder.decode(input);
|
1329
|
+
}
|
1330
|
+
}
|
1331
|
+
function from({ name, prefix, encode, decode }) {
|
1332
|
+
return new Codec(name, prefix, encode, decode);
|
1333
|
+
}
|
1334
|
+
function baseX({ name, prefix, alphabet }) {
|
1335
|
+
const { encode, decode } = _brrp__multiformats_scope_baseX(alphabet, name);
|
1336
|
+
return from({
|
1337
|
+
prefix,
|
1338
|
+
name,
|
1339
|
+
encode,
|
1340
|
+
decode: (text) => coerce(decode(text))
|
1341
|
+
});
|
1342
|
+
}
|
1343
|
+
function decode$1(string, alphabet, bitsPerChar, name) {
|
1344
|
+
// Build the character lookup table:
|
1345
|
+
const codes = {};
|
1346
|
+
for (let i = 0; i < alphabet.length; ++i) {
|
1347
|
+
codes[alphabet[i]] = i;
|
1348
|
+
}
|
1349
|
+
// Count the padding bytes:
|
1350
|
+
let end = string.length;
|
1351
|
+
while (string[end - 1] === '=') {
|
1352
|
+
--end;
|
1353
|
+
}
|
1354
|
+
// Allocate the output:
|
1355
|
+
const out = new Uint8Array((end * bitsPerChar / 8) | 0);
|
1356
|
+
// Parse the data:
|
1357
|
+
let bits = 0; // Number of bits currently in the buffer
|
1358
|
+
let buffer = 0; // Bits waiting to be written out, MSB first
|
1359
|
+
let written = 0; // Next byte to write
|
1360
|
+
for (let i = 0; i < end; ++i) {
|
1361
|
+
// Read one character from the string:
|
1362
|
+
const value = codes[string[i]];
|
1363
|
+
if (value === undefined) {
|
1364
|
+
throw new SyntaxError(`Non-${name} character`);
|
1365
|
+
}
|
1366
|
+
// Append the bits to the buffer:
|
1367
|
+
buffer = (buffer << bitsPerChar) | value;
|
1368
|
+
bits += bitsPerChar;
|
1369
|
+
// Write out some bits if the buffer has a byte's worth:
|
1370
|
+
if (bits >= 8) {
|
1371
|
+
bits -= 8;
|
1372
|
+
out[written++] = 0xff & (buffer >> bits);
|
1373
|
+
}
|
1374
|
+
}
|
1375
|
+
// Verify that we have received just enough bits:
|
1376
|
+
if (bits >= bitsPerChar || (0xff & (buffer << (8 - bits))) !== 0) {
|
1377
|
+
throw new SyntaxError('Unexpected end of data');
|
1378
|
+
}
|
1379
|
+
return out;
|
1380
|
+
}
|
1381
|
+
function encode$1(data, alphabet, bitsPerChar) {
|
1382
|
+
const pad = alphabet[alphabet.length - 1] === '=';
|
1383
|
+
const mask = (1 << bitsPerChar) - 1;
|
1384
|
+
let out = '';
|
1385
|
+
let bits = 0; // Number of bits currently in the buffer
|
1386
|
+
let buffer = 0; // Bits waiting to be written out, MSB first
|
1387
|
+
for (let i = 0; i < data.length; ++i) {
|
1388
|
+
// Slurp data into the buffer:
|
1389
|
+
buffer = (buffer << 8) | data[i];
|
1390
|
+
bits += 8;
|
1391
|
+
// Write out as much as we can:
|
1392
|
+
while (bits > bitsPerChar) {
|
1393
|
+
bits -= bitsPerChar;
|
1394
|
+
out += alphabet[mask & (buffer >> bits)];
|
1395
|
+
}
|
1396
|
+
}
|
1397
|
+
// Partial character:
|
1398
|
+
if (bits !== 0) {
|
1399
|
+
out += alphabet[mask & (buffer << (bitsPerChar - bits))];
|
1400
|
+
}
|
1401
|
+
// Add padding characters until we hit a byte boundary:
|
1402
|
+
if (pad) {
|
1403
|
+
while (((out.length * bitsPerChar) & 7) !== 0) {
|
1404
|
+
out += '=';
|
1405
|
+
}
|
1406
|
+
}
|
1407
|
+
return out;
|
1388
1408
|
}
|
1389
|
-
|
1390
|
-
/**
|
1391
|
-
* @template {string} Base
|
1392
|
-
* @template {string} Prefix
|
1393
|
-
* @param {object} options
|
1394
|
-
* @param {Base} options.name
|
1395
|
-
* @param {Prefix} options.prefix
|
1396
|
-
* @param {(bytes:Uint8Array) => string} options.encode
|
1397
|
-
* @param {(input:string) => Uint8Array} options.decode
|
1398
|
-
* @returns {Codec<Base, Prefix>}
|
1399
|
-
*/
|
1400
|
-
const from = ({ name, prefix, encode, decode }) =>
|
1401
|
-
new Codec(name, prefix, encode, decode);
|
1402
|
-
|
1403
|
-
/**
|
1404
|
-
* @template {string} Base
|
1405
|
-
* @template {string} Prefix
|
1406
|
-
* @param {object} options
|
1407
|
-
* @param {Base} options.name
|
1408
|
-
* @param {Prefix} options.prefix
|
1409
|
-
* @param {string} options.alphabet
|
1410
|
-
* @returns {Codec<Base, Prefix>}
|
1411
|
-
*/
|
1412
|
-
const baseX = ({ prefix, name, alphabet }) => {
|
1413
|
-
const { encode, decode } = _brrp__multiformats_scope_baseX(alphabet, name);
|
1414
|
-
return from({
|
1415
|
-
prefix,
|
1416
|
-
name,
|
1417
|
-
encode,
|
1418
|
-
/**
|
1419
|
-
* @param {string} text
|
1420
|
-
*/
|
1421
|
-
decode: text => coerce(decode(text))
|
1422
|
-
})
|
1423
|
-
};
|
1424
|
-
|
1425
|
-
/**
|
1426
|
-
* @param {string} string
|
1427
|
-
* @param {string} alphabet
|
1428
|
-
* @param {number} bitsPerChar
|
1429
|
-
* @param {string} name
|
1430
|
-
* @returns {Uint8Array}
|
1431
|
-
*/
|
1432
|
-
const decode$1 = (string, alphabet, bitsPerChar, name) => {
|
1433
|
-
// Build the character lookup table:
|
1434
|
-
/** @type {Record<string, number>} */
|
1435
|
-
const codes = {};
|
1436
|
-
for (let i = 0; i < alphabet.length; ++i) {
|
1437
|
-
codes[alphabet[i]] = i;
|
1438
|
-
}
|
1439
|
-
|
1440
|
-
// Count the padding bytes:
|
1441
|
-
let end = string.length;
|
1442
|
-
while (string[end - 1] === '=') {
|
1443
|
-
--end;
|
1444
|
-
}
|
1445
|
-
|
1446
|
-
// Allocate the output:
|
1447
|
-
const out = new Uint8Array((end * bitsPerChar / 8) | 0);
|
1448
|
-
|
1449
|
-
// Parse the data:
|
1450
|
-
let bits = 0; // Number of bits currently in the buffer
|
1451
|
-
let buffer = 0; // Bits waiting to be written out, MSB first
|
1452
|
-
let written = 0; // Next byte to write
|
1453
|
-
for (let i = 0; i < end; ++i) {
|
1454
|
-
// Read one character from the string:
|
1455
|
-
const value = codes[string[i]];
|
1456
|
-
if (value === undefined) {
|
1457
|
-
throw new SyntaxError(`Non-${name} character`)
|
1458
|
-
}
|
1459
|
-
|
1460
|
-
// Append the bits to the buffer:
|
1461
|
-
buffer = (buffer << bitsPerChar) | value;
|
1462
|
-
bits += bitsPerChar;
|
1463
|
-
|
1464
|
-
// Write out some bits if the buffer has a byte's worth:
|
1465
|
-
if (bits >= 8) {
|
1466
|
-
bits -= 8;
|
1467
|
-
out[written++] = 0xff & (buffer >> bits);
|
1468
|
-
}
|
1469
|
-
}
|
1470
|
-
|
1471
|
-
// Verify that we have received just enough bits:
|
1472
|
-
if (bits >= bitsPerChar || 0xff & (buffer << (8 - bits))) {
|
1473
|
-
throw new SyntaxError('Unexpected end of data')
|
1474
|
-
}
|
1475
|
-
|
1476
|
-
return out
|
1477
|
-
};
|
1478
|
-
|
1479
|
-
/**
|
1480
|
-
* @param {Uint8Array} data
|
1481
|
-
* @param {string} alphabet
|
1482
|
-
* @param {number} bitsPerChar
|
1483
|
-
* @returns {string}
|
1484
|
-
*/
|
1485
|
-
const encode$1 = (data, alphabet, bitsPerChar) => {
|
1486
|
-
const pad = alphabet[alphabet.length - 1] === '=';
|
1487
|
-
const mask = (1 << bitsPerChar) - 1;
|
1488
|
-
let out = '';
|
1489
|
-
|
1490
|
-
let bits = 0; // Number of bits currently in the buffer
|
1491
|
-
let buffer = 0; // Bits waiting to be written out, MSB first
|
1492
|
-
for (let i = 0; i < data.length; ++i) {
|
1493
|
-
// Slurp data into the buffer:
|
1494
|
-
buffer = (buffer << 8) | data[i];
|
1495
|
-
bits += 8;
|
1496
|
-
|
1497
|
-
// Write out as much as we can:
|
1498
|
-
while (bits > bitsPerChar) {
|
1499
|
-
bits -= bitsPerChar;
|
1500
|
-
out += alphabet[mask & (buffer >> bits)];
|
1501
|
-
}
|
1502
|
-
}
|
1503
|
-
|
1504
|
-
// Partial character:
|
1505
|
-
if (bits) {
|
1506
|
-
out += alphabet[mask & (buffer << (bitsPerChar - bits))];
|
1507
|
-
}
|
1508
|
-
|
1509
|
-
// Add padding characters until we hit a byte boundary:
|
1510
|
-
if (pad) {
|
1511
|
-
while ((out.length * bitsPerChar) & 7) {
|
1512
|
-
out += '=';
|
1513
|
-
}
|
1514
|
-
}
|
1515
|
-
|
1516
|
-
return out
|
1517
|
-
};
|
1518
|
-
|
1519
1409
|
/**
|
1520
1410
|
* RFC4648 Factory
|
1521
|
-
*
|
1522
|
-
* @template {string} Base
|
1523
|
-
* @template {string} Prefix
|
1524
|
-
* @param {object} options
|
1525
|
-
* @param {Base} options.name
|
1526
|
-
* @param {Prefix} options.prefix
|
1527
|
-
* @param {string} options.alphabet
|
1528
|
-
* @param {number} options.bitsPerChar
|
1529
1411
|
*/
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
}
|
1412
|
+
function rfc4648({ name, prefix, bitsPerChar, alphabet }) {
|
1413
|
+
return from({
|
1414
|
+
prefix,
|
1415
|
+
name,
|
1416
|
+
encode(input) {
|
1417
|
+
return encode$1(input, alphabet, bitsPerChar);
|
1418
|
+
},
|
1419
|
+
decode(input) {
|
1420
|
+
return decode$1(input, alphabet, bitsPerChar, name);
|
1421
|
+
}
|
1422
|
+
});
|
1423
|
+
}
|
1542
1424
|
|
1543
1425
|
const base10 = baseX({
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1426
|
+
prefix: '9',
|
1427
|
+
name: 'base10',
|
1428
|
+
alphabet: '0123456789'
|
1547
1429
|
});
|
1548
1430
|
|
1549
1431
|
var base10$1 = /*#__PURE__*/Object.freeze({
|
@@ -1551,21 +1433,17 @@ var base10$1 = /*#__PURE__*/Object.freeze({
|
|
1551
1433
|
base10: base10
|
1552
1434
|
});
|
1553
1435
|
|
1554
|
-
// @ts-check
|
1555
|
-
|
1556
|
-
|
1557
1436
|
const base16 = rfc4648({
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1437
|
+
prefix: 'f',
|
1438
|
+
name: 'base16',
|
1439
|
+
alphabet: '0123456789abcdef',
|
1440
|
+
bitsPerChar: 4
|
1562
1441
|
});
|
1563
|
-
|
1564
1442
|
const base16upper = rfc4648({
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1443
|
+
prefix: 'F',
|
1444
|
+
name: 'base16upper',
|
1445
|
+
alphabet: '0123456789ABCDEF',
|
1446
|
+
bitsPerChar: 4
|
1569
1447
|
});
|
1570
1448
|
|
1571
1449
|
var base16$1 = /*#__PURE__*/Object.freeze({
|
@@ -1574,14 +1452,11 @@ var base16$1 = /*#__PURE__*/Object.freeze({
|
|
1574
1452
|
base16upper: base16upper
|
1575
1453
|
});
|
1576
1454
|
|
1577
|
-
// @ts-check
|
1578
|
-
|
1579
|
-
|
1580
1455
|
const base2 = rfc4648({
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1456
|
+
prefix: '0',
|
1457
|
+
name: 'base2',
|
1458
|
+
alphabet: '01',
|
1459
|
+
bitsPerChar: 1
|
1585
1460
|
});
|
1586
1461
|
|
1587
1462
|
var base2$1 = /*#__PURE__*/Object.freeze({
|
@@ -1590,41 +1465,30 @@ var base2$1 = /*#__PURE__*/Object.freeze({
|
|
1590
1465
|
});
|
1591
1466
|
|
1592
1467
|
const alphabet = Array.from('🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂');
|
1593
|
-
const alphabetBytesToChars =
|
1594
|
-
const alphabetCharsToBytes =
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
* @returns {Uint8Array}
|
1610
|
-
*/
|
1611
|
-
function decode (str) {
|
1612
|
-
const byts = [];
|
1613
|
-
for (const char of str) {
|
1614
|
-
const byt = alphabetCharsToBytes[/** @type {number} */ (char.codePointAt(0))];
|
1615
|
-
if (byt === undefined) {
|
1616
|
-
throw new Error(`Non-base256emoji character: ${char}`)
|
1468
|
+
const alphabetBytesToChars = (alphabet.reduce((p, c, i) => { p[i] = c; return p; }, ([])));
|
1469
|
+
const alphabetCharsToBytes = (alphabet.reduce((p, c, i) => { p[c.codePointAt(0)] = i; return p; }, ([])));
|
1470
|
+
function encode(data) {
|
1471
|
+
return data.reduce((p, c) => {
|
1472
|
+
p += alphabetBytesToChars[c];
|
1473
|
+
return p;
|
1474
|
+
}, '');
|
1475
|
+
}
|
1476
|
+
function decode(str) {
|
1477
|
+
const byts = [];
|
1478
|
+
for (const char of str) {
|
1479
|
+
const byt = alphabetCharsToBytes[char.codePointAt(0)];
|
1480
|
+
if (byt === undefined) {
|
1481
|
+
throw new Error(`Non-base256emoji character: ${char}`);
|
1482
|
+
}
|
1483
|
+
byts.push(byt);
|
1617
1484
|
}
|
1618
|
-
byts
|
1619
|
-
}
|
1620
|
-
return new Uint8Array(byts)
|
1485
|
+
return new Uint8Array(byts);
|
1621
1486
|
}
|
1622
|
-
|
1623
1487
|
const base256emoji = from({
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1488
|
+
prefix: '🚀',
|
1489
|
+
name: 'base256emoji',
|
1490
|
+
encode,
|
1491
|
+
decode
|
1628
1492
|
});
|
1629
1493
|
|
1630
1494
|
var base256emoji$1 = /*#__PURE__*/Object.freeze({
|
@@ -1633,66 +1497,58 @@ var base256emoji$1 = /*#__PURE__*/Object.freeze({
|
|
1633
1497
|
});
|
1634
1498
|
|
1635
1499
|
const base32 = rfc4648({
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1500
|
+
prefix: 'b',
|
1501
|
+
name: 'base32',
|
1502
|
+
alphabet: 'abcdefghijklmnopqrstuvwxyz234567',
|
1503
|
+
bitsPerChar: 5
|
1640
1504
|
});
|
1641
|
-
|
1642
1505
|
const base32upper = rfc4648({
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1506
|
+
prefix: 'B',
|
1507
|
+
name: 'base32upper',
|
1508
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',
|
1509
|
+
bitsPerChar: 5
|
1647
1510
|
});
|
1648
|
-
|
1649
1511
|
const base32pad = rfc4648({
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1512
|
+
prefix: 'c',
|
1513
|
+
name: 'base32pad',
|
1514
|
+
alphabet: 'abcdefghijklmnopqrstuvwxyz234567=',
|
1515
|
+
bitsPerChar: 5
|
1654
1516
|
});
|
1655
|
-
|
1656
1517
|
const base32padupper = rfc4648({
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1518
|
+
prefix: 'C',
|
1519
|
+
name: 'base32padupper',
|
1520
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=',
|
1521
|
+
bitsPerChar: 5
|
1661
1522
|
});
|
1662
|
-
|
1663
1523
|
const base32hex = rfc4648({
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1524
|
+
prefix: 'v',
|
1525
|
+
name: 'base32hex',
|
1526
|
+
alphabet: '0123456789abcdefghijklmnopqrstuv',
|
1527
|
+
bitsPerChar: 5
|
1668
1528
|
});
|
1669
|
-
|
1670
1529
|
const base32hexupper = rfc4648({
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1530
|
+
prefix: 'V',
|
1531
|
+
name: 'base32hexupper',
|
1532
|
+
alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV',
|
1533
|
+
bitsPerChar: 5
|
1675
1534
|
});
|
1676
|
-
|
1677
1535
|
const base32hexpad = rfc4648({
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1536
|
+
prefix: 't',
|
1537
|
+
name: 'base32hexpad',
|
1538
|
+
alphabet: '0123456789abcdefghijklmnopqrstuv=',
|
1539
|
+
bitsPerChar: 5
|
1682
1540
|
});
|
1683
|
-
|
1684
1541
|
const base32hexpadupper = rfc4648({
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1542
|
+
prefix: 'T',
|
1543
|
+
name: 'base32hexpadupper',
|
1544
|
+
alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=',
|
1545
|
+
bitsPerChar: 5
|
1689
1546
|
});
|
1690
|
-
|
1691
1547
|
const base32z = rfc4648({
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1548
|
+
prefix: 'h',
|
1549
|
+
name: 'base32z',
|
1550
|
+
alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769',
|
1551
|
+
bitsPerChar: 5
|
1696
1552
|
});
|
1697
1553
|
|
1698
1554
|
var base32$1 = /*#__PURE__*/Object.freeze({
|
@@ -1709,15 +1565,14 @@ var base32$1 = /*#__PURE__*/Object.freeze({
|
|
1709
1565
|
});
|
1710
1566
|
|
1711
1567
|
const base36 = baseX({
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1568
|
+
prefix: 'k',
|
1569
|
+
name: 'base36',
|
1570
|
+
alphabet: '0123456789abcdefghijklmnopqrstuvwxyz'
|
1715
1571
|
});
|
1716
|
-
|
1717
1572
|
const base36upper = baseX({
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1573
|
+
prefix: 'K',
|
1574
|
+
name: 'base36upper',
|
1575
|
+
alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
1721
1576
|
});
|
1722
1577
|
|
1723
1578
|
var base36$1 = /*#__PURE__*/Object.freeze({
|
@@ -1727,15 +1582,14 @@ var base36$1 = /*#__PURE__*/Object.freeze({
|
|
1727
1582
|
});
|
1728
1583
|
|
1729
1584
|
const base58btc = baseX({
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1585
|
+
name: 'base58btc',
|
1586
|
+
prefix: 'z',
|
1587
|
+
alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
1733
1588
|
});
|
1734
|
-
|
1735
1589
|
const base58flickr = baseX({
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1590
|
+
name: 'base58flickr',
|
1591
|
+
prefix: 'Z',
|
1592
|
+
alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
|
1739
1593
|
});
|
1740
1594
|
|
1741
1595
|
var base58 = /*#__PURE__*/Object.freeze({
|
@@ -1744,35 +1598,29 @@ var base58 = /*#__PURE__*/Object.freeze({
|
|
1744
1598
|
base58flickr: base58flickr
|
1745
1599
|
});
|
1746
1600
|
|
1747
|
-
// @ts-check
|
1748
|
-
|
1749
|
-
|
1750
1601
|
const base64 = rfc4648({
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1602
|
+
prefix: 'm',
|
1603
|
+
name: 'base64',
|
1604
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
|
1605
|
+
bitsPerChar: 6
|
1755
1606
|
});
|
1756
|
-
|
1757
1607
|
const base64pad = rfc4648({
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1608
|
+
prefix: 'M',
|
1609
|
+
name: 'base64pad',
|
1610
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
1611
|
+
bitsPerChar: 6
|
1762
1612
|
});
|
1763
|
-
|
1764
1613
|
const base64url = rfc4648({
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1614
|
+
prefix: 'u',
|
1615
|
+
name: 'base64url',
|
1616
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
|
1617
|
+
bitsPerChar: 6
|
1769
1618
|
});
|
1770
|
-
|
1771
1619
|
const base64urlpad = rfc4648({
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1620
|
+
prefix: 'U',
|
1621
|
+
name: 'base64urlpad',
|
1622
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=',
|
1623
|
+
bitsPerChar: 6
|
1776
1624
|
});
|
1777
1625
|
|
1778
1626
|
var base64$1 = /*#__PURE__*/Object.freeze({
|
@@ -1783,14 +1631,11 @@ var base64$1 = /*#__PURE__*/Object.freeze({
|
|
1783
1631
|
base64urlpad: base64urlpad
|
1784
1632
|
});
|
1785
1633
|
|
1786
|
-
// @ts-check
|
1787
|
-
|
1788
|
-
|
1789
1634
|
const base8 = rfc4648({
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1635
|
+
prefix: '7',
|
1636
|
+
name: 'base8',
|
1637
|
+
alphabet: '01234567',
|
1638
|
+
bitsPerChar: 3
|
1794
1639
|
});
|
1795
1640
|
|
1796
1641
|
var base8$1 = /*#__PURE__*/Object.freeze({
|
@@ -1798,14 +1643,11 @@ var base8$1 = /*#__PURE__*/Object.freeze({
|
|
1798
1643
|
base8: base8
|
1799
1644
|
});
|
1800
1645
|
|
1801
|
-
// @ts-check
|
1802
|
-
|
1803
|
-
|
1804
1646
|
const identity = from({
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1647
|
+
prefix: '\x00',
|
1648
|
+
name: 'identity',
|
1649
|
+
encode: (buf) => toString(buf),
|
1650
|
+
decode: (str) => fromString$1(str)
|
1809
1651
|
});
|
1810
1652
|
|
1811
1653
|
var identityBase = /*#__PURE__*/Object.freeze({
|
@@ -1813,30 +1655,24 @@ var identityBase = /*#__PURE__*/Object.freeze({
|
|
1813
1655
|
identity: identity
|
1814
1656
|
});
|
1815
1657
|
|
1816
|
-
// @ts-check
|
1817
|
-
|
1818
|
-
/**
|
1819
|
-
* @template T
|
1820
|
-
* @typedef {import('./interface.js').ByteView<T>} ByteView
|
1821
|
-
*/
|
1822
|
-
|
1823
1658
|
new TextEncoder();
|
1824
1659
|
new TextDecoder();
|
1825
1660
|
|
1826
|
-
// @ts-check
|
1827
|
-
|
1828
|
-
|
1829
1661
|
const bases = { ...identityBase, ...base2$1, ...base8$1, ...base10$1, ...base16$1, ...base32$1, ...base36$1, ...base58, ...base64$1, ...base256emoji$1 };
|
1830
1662
|
|
1663
|
+
/**
|
1664
|
+
* Returns a `Uint8Array` of the requested size. Referenced memory will
|
1665
|
+
* be initialized to 0.
|
1666
|
+
*/
|
1667
|
+
function alloc(size = 0) {
|
1668
|
+
return new Uint8Array(size);
|
1669
|
+
}
|
1831
1670
|
/**
|
1832
1671
|
* Where possible returns a Uint8Array of the requested size that references
|
1833
1672
|
* uninitialized memory. Only use if you are certain you will immediately
|
1834
1673
|
* overwrite every value in the returned `Uint8Array`.
|
1835
1674
|
*/
|
1836
1675
|
function allocUnsafe(size = 0) {
|
1837
|
-
if (globalThis.Buffer?.allocUnsafe != null) {
|
1838
|
-
return asUint8Array(globalThis.Buffer.allocUnsafe(size));
|
1839
|
-
}
|
1840
1676
|
return new Uint8Array(size);
|
1841
1677
|
}
|
1842
1678
|
|
@@ -1897,9 +1733,6 @@ function fromString(string, encoding = 'utf8') {
|
|
1897
1733
|
if (base == null) {
|
1898
1734
|
throw new Error(`Unsupported encoding "${encoding}"`);
|
1899
1735
|
}
|
1900
|
-
if ((encoding === 'utf8' || encoding === 'utf-8') && globalThis.Buffer != null && globalThis.Buffer.from != null) {
|
1901
|
-
return asUint8Array(globalThis.Buffer.from(string, 'utf-8'));
|
1902
|
-
}
|
1903
1736
|
// add multibase prefix
|
1904
1737
|
return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions
|
1905
1738
|
}
|
@@ -1945,7 +1778,7 @@ var sha3$1 = {exports: {}};
|
|
1945
1778
|
/**
|
1946
1779
|
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
1947
1780
|
*
|
1948
|
-
* @version 0.9.
|
1781
|
+
* @version 0.9.3
|
1949
1782
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
1950
1783
|
* @copyright Chen, Yi-Cyuan 2015-2023
|
1951
1784
|
* @license MIT
|
@@ -2025,6 +1858,14 @@ var sha3$1 = {exports: {}};
|
|
2025
1858
|
return formatMessage(message)[0].length === 0;
|
2026
1859
|
};
|
2027
1860
|
|
1861
|
+
var cloneArray = function (array) {
|
1862
|
+
var newArray = [];
|
1863
|
+
for (var i = 0; i < array.length; ++i) {
|
1864
|
+
newArray[i] = array[i];
|
1865
|
+
}
|
1866
|
+
return newArray;
|
1867
|
+
};
|
1868
|
+
|
2028
1869
|
var createOutputMethod = function (bits, padding, outputType) {
|
2029
1870
|
return function (message) {
|
2030
1871
|
return new Keccak(bits, padding, bits).update(message)[outputType]();
|
@@ -2304,6 +2145,7 @@ var sha3$1 = {exports: {}};
|
|
2304
2145
|
HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];
|
2305
2146
|
}
|
2306
2147
|
if (j % blockCount === 0) {
|
2148
|
+
s = cloneArray(s);
|
2307
2149
|
f(s);
|
2308
2150
|
i = 0;
|
2309
2151
|
}
|
@@ -2339,11 +2181,12 @@ var sha3$1 = {exports: {}};
|
|
2339
2181
|
array[j] = s[i];
|
2340
2182
|
}
|
2341
2183
|
if (j % blockCount === 0) {
|
2184
|
+
s = cloneArray(s);
|
2342
2185
|
f(s);
|
2343
2186
|
}
|
2344
2187
|
}
|
2345
2188
|
if (extraBytes) {
|
2346
|
-
array[
|
2189
|
+
array[j] = s[i];
|
2347
2190
|
buffer = buffer.slice(0, bytes);
|
2348
2191
|
}
|
2349
2192
|
return buffer;
|
@@ -2367,6 +2210,7 @@ var sha3$1 = {exports: {}};
|
|
2367
2210
|
array[offset + 3] = (block >> 24) & 0xFF;
|
2368
2211
|
}
|
2369
2212
|
if (j % blockCount === 0) {
|
2213
|
+
s = cloneArray(s);
|
2370
2214
|
f(s);
|
2371
2215
|
}
|
2372
2216
|
}
|
@@ -2602,7 +2446,7 @@ const Symmetric = {
|
|
2602
2446
|
const Asymmetric = {
|
2603
2447
|
keySize: 32
|
2604
2448
|
};
|
2605
|
-
const OneMillion = BigInt(
|
2449
|
+
const OneMillion = BigInt(1_000_000);
|
2606
2450
|
const Version = 1;
|
2607
2451
|
|
2608
2452
|
const crypto = {
|
@@ -2812,4 +2656,4 @@ var symmetric = /*#__PURE__*/Object.freeze({
|
|
2812
2656
|
generateIv: generateIv
|
2813
2657
|
});
|
2814
2658
|
|
2815
|
-
export { OneMillion as O, Symmetric as S, Version as V, generateSymmetricKey as a, getPublicKey as b, getSubtle as c, sign as d, ecies as e, symmetric as f, generatePrivateKey as g,
|
2659
|
+
export { OneMillion as O, Symmetric as S, Version as V, generateSymmetricKey as a, getPublicKey as b, getSubtle as c, sign as d, ecies as e, symmetric as f, generatePrivateKey as g, allocUnsafe as h, fromString as i, alloc as j, keccak256 as k, concat as l, getDefaultExportFromCjs as m, encrypt$1 as n, hexToBytes as o, decrypt$1 as p, generateIv as q, randomBytes as r, sha256 as s, encrypt as t, utf8ToBytes as u, decrypt as v, Signature as w, recoverPublicKey as x };
|