@waku/message-encryption 0.0.24 → 0.0.25
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-CL5AR7HZ.js} +2 -2
- package/bundle/ecies.js +3 -3
- package/bundle/{encryption-zFGfcjHZ.js → encryption-Cjy0BsYx.js} +1176 -2460
- package/bundle/{index-alzPvot7.js → index-CltQJQo2.js} +1 -1
- package/bundle/index.js +5 -5
- package/bundle/{symmetric-CXVjdTdV.js → symmetric-Cd3XbaRu.js} +450 -607
- package/bundle/{symmetric-7aAyizy_.js → symmetric-DLwHvHs7.js} +2 -2
- 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/package.json +10 -10
- package/src/index.ts +1 -1
@@ -1047,503 +1047,396 @@ function asUint8Array(buf) {
|
|
1047
1047
|
return buf;
|
1048
1048
|
}
|
1049
1049
|
|
1050
|
+
function coerce(o) {
|
1051
|
+
if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array')
|
1052
|
+
return o;
|
1053
|
+
if (o instanceof ArrayBuffer)
|
1054
|
+
return new Uint8Array(o);
|
1055
|
+
if (ArrayBuffer.isView(o)) {
|
1056
|
+
return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
|
1057
|
+
}
|
1058
|
+
throw new Error('Unknown type, must be binary type');
|
1059
|
+
}
|
1060
|
+
function fromString$1(str) {
|
1061
|
+
return new TextEncoder().encode(str);
|
1062
|
+
}
|
1063
|
+
function toString(b) {
|
1064
|
+
return new TextDecoder().decode(b);
|
1065
|
+
}
|
1066
|
+
|
1067
|
+
/* eslint-disable */
|
1050
1068
|
// base-x encoding / decoding
|
1051
1069
|
// Copyright (c) 2018 base-x contributors
|
1052
1070
|
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
1053
1071
|
// Distributed under the MIT software license, see the accompanying
|
1054
1072
|
// 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++;
|
1073
|
+
/**
|
1074
|
+
* @param {string} ALPHABET
|
1075
|
+
* @param {any} name
|
1076
|
+
*/
|
1077
|
+
function base(ALPHABET, name) {
|
1078
|
+
if (ALPHABET.length >= 255) {
|
1079
|
+
throw new TypeError('Alphabet too long');
|
1080
|
+
}
|
1081
|
+
var BASE_MAP = new Uint8Array(256);
|
1082
|
+
for (var j = 0; j < BASE_MAP.length; j++) {
|
1083
|
+
BASE_MAP[j] = 255;
|
1084
|
+
}
|
1085
|
+
for (var i = 0; i < ALPHABET.length; i++) {
|
1086
|
+
var x = ALPHABET.charAt(i);
|
1087
|
+
var xc = x.charCodeAt(0);
|
1088
|
+
if (BASE_MAP[xc] !== 255) {
|
1089
|
+
throw new TypeError(x + ' is ambiguous');
|
1090
|
+
}
|
1091
|
+
BASE_MAP[xc] = i;
|
1087
1092
|
}
|
1093
|
+
var BASE = ALPHABET.length;
|
1094
|
+
var LEADER = ALPHABET.charAt(0);
|
1095
|
+
var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
1096
|
+
var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
1097
|
+
/**
|
1098
|
+
* @param {any[] | Iterable<number>} source
|
1099
|
+
*/
|
1100
|
+
function encode(source) {
|
1101
|
+
// @ts-ignore
|
1102
|
+
if (source instanceof Uint8Array)
|
1103
|
+
;
|
1104
|
+
else if (ArrayBuffer.isView(source)) {
|
1105
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
1106
|
+
}
|
1107
|
+
else if (Array.isArray(source)) {
|
1108
|
+
source = Uint8Array.from(source);
|
1109
|
+
}
|
1110
|
+
if (!(source instanceof Uint8Array)) {
|
1111
|
+
throw new TypeError('Expected Uint8Array');
|
1112
|
+
}
|
1113
|
+
if (source.length === 0) {
|
1114
|
+
return '';
|
1115
|
+
}
|
1116
|
+
// Skip & count leading zeroes.
|
1117
|
+
var zeroes = 0;
|
1118
|
+
var length = 0;
|
1119
|
+
var pbegin = 0;
|
1120
|
+
var pend = source.length;
|
1121
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
1122
|
+
pbegin++;
|
1123
|
+
zeroes++;
|
1124
|
+
}
|
1088
1125
|
// Allocate enough space in big-endian base58 representation.
|
1089
|
-
|
1090
|
-
|
1126
|
+
var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
1127
|
+
var b58 = new Uint8Array(size);
|
1091
1128
|
// Process the bytes.
|
1092
|
-
|
1093
|
-
|
1129
|
+
while (pbegin !== pend) {
|
1130
|
+
var carry = source[pbegin];
|
1094
1131
|
// Apply "b58 = b58 * 256 + ch".
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1132
|
+
var i = 0;
|
1133
|
+
for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
1134
|
+
carry += (256 * b58[it1]) >>> 0;
|
1135
|
+
b58[it1] = (carry % BASE) >>> 0;
|
1136
|
+
carry = (carry / BASE) >>> 0;
|
1137
|
+
}
|
1138
|
+
if (carry !== 0) {
|
1139
|
+
throw new Error('Non-zero carry');
|
1140
|
+
}
|
1141
|
+
length = i;
|
1142
|
+
pbegin++;
|
1143
|
+
}
|
1105
1144
|
// Skip leading zeroes in base58 result.
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1145
|
+
var it2 = size - length;
|
1146
|
+
while (it2 !== size && b58[it2] === 0) {
|
1147
|
+
it2++;
|
1148
|
+
}
|
1110
1149
|
// Translate the result into a string.
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1150
|
+
var str = LEADER.repeat(zeroes);
|
1151
|
+
for (; it2 < size; ++it2) {
|
1152
|
+
str += ALPHABET.charAt(b58[it2]);
|
1153
|
+
}
|
1154
|
+
return str;
|
1155
|
+
}
|
1156
|
+
/**
|
1157
|
+
* @param {string | string[]} source
|
1158
|
+
*/
|
1159
|
+
function decodeUnsafe(source) {
|
1160
|
+
if (typeof source !== 'string') {
|
1161
|
+
throw new TypeError('Expected String');
|
1162
|
+
}
|
1163
|
+
if (source.length === 0) {
|
1164
|
+
return new Uint8Array();
|
1165
|
+
}
|
1166
|
+
var psz = 0;
|
1119
1167
|
// Skip leading spaces.
|
1120
|
-
|
1168
|
+
if (source[psz] === ' ') {
|
1169
|
+
return;
|
1170
|
+
}
|
1121
1171
|
// Skip and count leading '1's.
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1172
|
+
var zeroes = 0;
|
1173
|
+
var length = 0;
|
1174
|
+
while (source[psz] === LEADER) {
|
1175
|
+
zeroes++;
|
1176
|
+
psz++;
|
1177
|
+
}
|
1128
1178
|
// Allocate enough space in big-endian base256 representation.
|
1129
|
-
|
1130
|
-
|
1179
|
+
var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
1180
|
+
var b256 = new Uint8Array(size);
|
1131
1181
|
// Process the characters.
|
1132
|
-
|
1182
|
+
while (source[psz]) {
|
1133
1183
|
// Decode character
|
1134
|
-
|
1184
|
+
var carry = BASE_MAP[source.charCodeAt(psz)];
|
1135
1185
|
// Invalid character
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1186
|
+
if (carry === 255) {
|
1187
|
+
return;
|
1188
|
+
}
|
1189
|
+
var i = 0;
|
1190
|
+
for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
1191
|
+
carry += (BASE * b256[it3]) >>> 0;
|
1192
|
+
b256[it3] = (carry % 256) >>> 0;
|
1193
|
+
carry = (carry / 256) >>> 0;
|
1194
|
+
}
|
1195
|
+
if (carry !== 0) {
|
1196
|
+
throw new Error('Non-zero carry');
|
1197
|
+
}
|
1198
|
+
length = i;
|
1199
|
+
psz++;
|
1200
|
+
}
|
1147
1201
|
// Skip trailing spaces.
|
1148
|
-
|
1202
|
+
if (source[psz] === ' ') {
|
1203
|
+
return;
|
1204
|
+
}
|
1149
1205
|
// 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
|
-
|
1206
|
+
var it4 = size - length;
|
1207
|
+
while (it4 !== size && b256[it4] === 0) {
|
1208
|
+
it4++;
|
1209
|
+
}
|
1210
|
+
var vch = new Uint8Array(zeroes + (size - it4));
|
1211
|
+
var j = zeroes;
|
1212
|
+
while (it4 !== size) {
|
1213
|
+
vch[j++] = b256[it4++];
|
1214
|
+
}
|
1215
|
+
return vch;
|
1216
|
+
}
|
1217
|
+
/**
|
1218
|
+
* @param {string | string[]} string
|
1219
|
+
*/
|
1220
|
+
function decode(string) {
|
1221
|
+
var buffer = decodeUnsafe(string);
|
1222
|
+
if (buffer) {
|
1223
|
+
return buffer;
|
1224
|
+
}
|
1225
|
+
throw new Error(`Non-${name} character`);
|
1226
|
+
}
|
1227
|
+
return {
|
1228
|
+
encode: encode,
|
1229
|
+
decodeUnsafe: decodeUnsafe,
|
1230
|
+
decode: decode
|
1231
|
+
};
|
1171
1232
|
}
|
1172
1233
|
var src = base;
|
1173
|
-
|
1174
1234
|
var _brrp__multiformats_scope_baseX = src;
|
1175
1235
|
|
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
1236
|
/**
|
1202
1237
|
* Class represents both BaseEncoder and MultibaseEncoder meaning it
|
1203
1238
|
* can be used to encode to multibase or base encode without multibase
|
1204
1239
|
* prefix.
|
1205
|
-
*
|
1206
|
-
* @class
|
1207
|
-
* @template {string} Base
|
1208
|
-
* @template {string} Prefix
|
1209
|
-
* @implements {API.MultibaseEncoder<Prefix>}
|
1210
|
-
* @implements {API.BaseEncoder}
|
1211
1240
|
*/
|
1212
1241
|
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
|
-
}
|
1242
|
+
name;
|
1243
|
+
prefix;
|
1244
|
+
baseEncode;
|
1245
|
+
constructor(name, prefix, baseEncode) {
|
1246
|
+
this.name = name;
|
1247
|
+
this.prefix = prefix;
|
1248
|
+
this.baseEncode = baseEncode;
|
1249
|
+
}
|
1250
|
+
encode(bytes) {
|
1251
|
+
if (bytes instanceof Uint8Array) {
|
1252
|
+
return `${this.prefix}${this.baseEncode(bytes)}`;
|
1253
|
+
}
|
1254
|
+
else {
|
1255
|
+
throw Error('Unknown type, must be binary type');
|
1256
|
+
}
|
1257
|
+
}
|
1235
1258
|
}
|
1236
|
-
|
1237
|
-
/**
|
1238
|
-
* @template {string} Prefix
|
1239
|
-
*/
|
1240
1259
|
/**
|
1241
1260
|
* Class represents both BaseDecoder and MultibaseDecoder so it could be used
|
1242
1261
|
* to decode multibases (with matching prefix) or just base decode strings
|
1243
1262
|
* 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
1263
|
*/
|
1252
1264
|
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
|
-
}
|
1265
|
+
name;
|
1266
|
+
prefix;
|
1267
|
+
baseDecode;
|
1268
|
+
prefixCodePoint;
|
1269
|
+
constructor(name, prefix, baseDecode) {
|
1270
|
+
this.name = name;
|
1271
|
+
this.prefix = prefix;
|
1272
|
+
/* c8 ignore next 3 */
|
1273
|
+
if (prefix.codePointAt(0) === undefined) {
|
1274
|
+
throw new Error('Invalid prefix character');
|
1275
|
+
}
|
1276
|
+
this.prefixCodePoint = prefix.codePointAt(0);
|
1277
|
+
this.baseDecode = baseDecode;
|
1278
|
+
}
|
1279
|
+
decode(text) {
|
1280
|
+
if (typeof text === 'string') {
|
1281
|
+
if (text.codePointAt(0) !== this.prefixCodePoint) {
|
1282
|
+
throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
|
1283
|
+
}
|
1284
|
+
return this.baseDecode(text.slice(this.prefix.length));
|
1285
|
+
}
|
1286
|
+
else {
|
1287
|
+
throw Error('Can only multibase decode strings');
|
1288
|
+
}
|
1289
|
+
}
|
1290
|
+
or(decoder) {
|
1291
|
+
return or(this, decoder);
|
1292
|
+
}
|
1292
1293
|
}
|
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
1294
|
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
|
-
}
|
1295
|
+
decoders;
|
1296
|
+
constructor(decoders) {
|
1297
|
+
this.decoders = decoders;
|
1298
|
+
}
|
1299
|
+
or(decoder) {
|
1300
|
+
return or(this, decoder);
|
1301
|
+
}
|
1302
|
+
decode(input) {
|
1303
|
+
const prefix = input[0];
|
1304
|
+
const decoder = this.decoders[prefix];
|
1305
|
+
if (decoder != null) {
|
1306
|
+
return decoder.decode(input);
|
1307
|
+
}
|
1308
|
+
else {
|
1309
|
+
throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
|
1310
|
+
}
|
1311
|
+
}
|
1312
|
+
}
|
1313
|
+
function or(left, right) {
|
1314
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
1315
|
+
return new ComposedDecoder({
|
1316
|
+
...(left.decoders ?? { [left.prefix]: left }),
|
1317
|
+
...(right.decoders ?? { [right.prefix]: right })
|
1318
|
+
});
|
1334
1319
|
}
|
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
1320
|
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
|
-
|
1321
|
+
name;
|
1322
|
+
prefix;
|
1323
|
+
baseEncode;
|
1324
|
+
baseDecode;
|
1325
|
+
encoder;
|
1326
|
+
decoder;
|
1327
|
+
constructor(name, prefix, baseEncode, baseDecode) {
|
1328
|
+
this.name = name;
|
1329
|
+
this.prefix = prefix;
|
1330
|
+
this.baseEncode = baseEncode;
|
1331
|
+
this.baseDecode = baseDecode;
|
1332
|
+
this.encoder = new Encoder(name, prefix, baseEncode);
|
1333
|
+
this.decoder = new Decoder(name, prefix, baseDecode);
|
1334
|
+
}
|
1335
|
+
encode(input) {
|
1336
|
+
return this.encoder.encode(input);
|
1337
|
+
}
|
1338
|
+
decode(input) {
|
1339
|
+
return this.decoder.decode(input);
|
1340
|
+
}
|
1341
|
+
}
|
1342
|
+
function from({ name, prefix, encode, decode }) {
|
1343
|
+
return new Codec(name, prefix, encode, decode);
|
1344
|
+
}
|
1345
|
+
function baseX({ name, prefix, alphabet }) {
|
1346
|
+
const { encode, decode } = _brrp__multiformats_scope_baseX(alphabet, name);
|
1347
|
+
return from({
|
1348
|
+
prefix,
|
1349
|
+
name,
|
1350
|
+
encode,
|
1351
|
+
decode: (text) => coerce(decode(text))
|
1352
|
+
});
|
1353
|
+
}
|
1354
|
+
function decode$1(string, alphabet, bitsPerChar, name) {
|
1355
|
+
// Build the character lookup table:
|
1356
|
+
const codes = {};
|
1357
|
+
for (let i = 0; i < alphabet.length; ++i) {
|
1358
|
+
codes[alphabet[i]] = i;
|
1359
|
+
}
|
1360
|
+
// Count the padding bytes:
|
1361
|
+
let end = string.length;
|
1362
|
+
while (string[end - 1] === '=') {
|
1363
|
+
--end;
|
1364
|
+
}
|
1365
|
+
// Allocate the output:
|
1366
|
+
const out = new Uint8Array((end * bitsPerChar / 8) | 0);
|
1367
|
+
// Parse the data:
|
1368
|
+
let bits = 0; // Number of bits currently in the buffer
|
1369
|
+
let buffer = 0; // Bits waiting to be written out, MSB first
|
1370
|
+
let written = 0; // Next byte to write
|
1371
|
+
for (let i = 0; i < end; ++i) {
|
1372
|
+
// Read one character from the string:
|
1373
|
+
const value = codes[string[i]];
|
1374
|
+
if (value === undefined) {
|
1375
|
+
throw new SyntaxError(`Non-${name} character`);
|
1376
|
+
}
|
1377
|
+
// Append the bits to the buffer:
|
1378
|
+
buffer = (buffer << bitsPerChar) | value;
|
1379
|
+
bits += bitsPerChar;
|
1380
|
+
// Write out some bits if the buffer has a byte's worth:
|
1381
|
+
if (bits >= 8) {
|
1382
|
+
bits -= 8;
|
1383
|
+
out[written++] = 0xff & (buffer >> bits);
|
1384
|
+
}
|
1385
|
+
}
|
1386
|
+
// Verify that we have received just enough bits:
|
1387
|
+
if (bits >= bitsPerChar || (0xff & (buffer << (8 - bits))) !== 0) {
|
1388
|
+
throw new SyntaxError('Unexpected end of data');
|
1389
|
+
}
|
1390
|
+
return out;
|
1391
|
+
}
|
1392
|
+
function encode$1(data, alphabet, bitsPerChar) {
|
1393
|
+
const pad = alphabet[alphabet.length - 1] === '=';
|
1394
|
+
const mask = (1 << bitsPerChar) - 1;
|
1395
|
+
let out = '';
|
1396
|
+
let bits = 0; // Number of bits currently in the buffer
|
1397
|
+
let buffer = 0; // Bits waiting to be written out, MSB first
|
1398
|
+
for (let i = 0; i < data.length; ++i) {
|
1399
|
+
// Slurp data into the buffer:
|
1400
|
+
buffer = (buffer << 8) | data[i];
|
1401
|
+
bits += 8;
|
1402
|
+
// Write out as much as we can:
|
1403
|
+
while (bits > bitsPerChar) {
|
1404
|
+
bits -= bitsPerChar;
|
1405
|
+
out += alphabet[mask & (buffer >> bits)];
|
1406
|
+
}
|
1407
|
+
}
|
1408
|
+
// Partial character:
|
1409
|
+
if (bits !== 0) {
|
1410
|
+
out += alphabet[mask & (buffer << (bitsPerChar - bits))];
|
1411
|
+
}
|
1412
|
+
// Add padding characters until we hit a byte boundary:
|
1413
|
+
if (pad) {
|
1414
|
+
while (((out.length * bitsPerChar) & 7) !== 0) {
|
1415
|
+
out += '=';
|
1416
|
+
}
|
1417
|
+
}
|
1418
|
+
return out;
|
1388
1419
|
}
|
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
1420
|
/**
|
1520
1421
|
* 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
1422
|
*/
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
}
|
1423
|
+
function rfc4648({ name, prefix, bitsPerChar, alphabet }) {
|
1424
|
+
return from({
|
1425
|
+
prefix,
|
1426
|
+
name,
|
1427
|
+
encode(input) {
|
1428
|
+
return encode$1(input, alphabet, bitsPerChar);
|
1429
|
+
},
|
1430
|
+
decode(input) {
|
1431
|
+
return decode$1(input, alphabet, bitsPerChar, name);
|
1432
|
+
}
|
1433
|
+
});
|
1434
|
+
}
|
1542
1435
|
|
1543
1436
|
const base10 = baseX({
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1437
|
+
prefix: '9',
|
1438
|
+
name: 'base10',
|
1439
|
+
alphabet: '0123456789'
|
1547
1440
|
});
|
1548
1441
|
|
1549
1442
|
var base10$1 = /*#__PURE__*/Object.freeze({
|
@@ -1551,21 +1444,17 @@ var base10$1 = /*#__PURE__*/Object.freeze({
|
|
1551
1444
|
base10: base10
|
1552
1445
|
});
|
1553
1446
|
|
1554
|
-
// @ts-check
|
1555
|
-
|
1556
|
-
|
1557
1447
|
const base16 = rfc4648({
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1448
|
+
prefix: 'f',
|
1449
|
+
name: 'base16',
|
1450
|
+
alphabet: '0123456789abcdef',
|
1451
|
+
bitsPerChar: 4
|
1562
1452
|
});
|
1563
|
-
|
1564
1453
|
const base16upper = rfc4648({
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1454
|
+
prefix: 'F',
|
1455
|
+
name: 'base16upper',
|
1456
|
+
alphabet: '0123456789ABCDEF',
|
1457
|
+
bitsPerChar: 4
|
1569
1458
|
});
|
1570
1459
|
|
1571
1460
|
var base16$1 = /*#__PURE__*/Object.freeze({
|
@@ -1574,14 +1463,11 @@ var base16$1 = /*#__PURE__*/Object.freeze({
|
|
1574
1463
|
base16upper: base16upper
|
1575
1464
|
});
|
1576
1465
|
|
1577
|
-
// @ts-check
|
1578
|
-
|
1579
|
-
|
1580
1466
|
const base2 = rfc4648({
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1467
|
+
prefix: '0',
|
1468
|
+
name: 'base2',
|
1469
|
+
alphabet: '01',
|
1470
|
+
bitsPerChar: 1
|
1585
1471
|
});
|
1586
1472
|
|
1587
1473
|
var base2$1 = /*#__PURE__*/Object.freeze({
|
@@ -1590,41 +1476,30 @@ var base2$1 = /*#__PURE__*/Object.freeze({
|
|
1590
1476
|
});
|
1591
1477
|
|
1592
1478
|
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}`)
|
1479
|
+
const alphabetBytesToChars = (alphabet.reduce((p, c, i) => { p[i] = c; return p; }, ([])));
|
1480
|
+
const alphabetCharsToBytes = (alphabet.reduce((p, c, i) => { p[c.codePointAt(0)] = i; return p; }, ([])));
|
1481
|
+
function encode(data) {
|
1482
|
+
return data.reduce((p, c) => {
|
1483
|
+
p += alphabetBytesToChars[c];
|
1484
|
+
return p;
|
1485
|
+
}, '');
|
1486
|
+
}
|
1487
|
+
function decode(str) {
|
1488
|
+
const byts = [];
|
1489
|
+
for (const char of str) {
|
1490
|
+
const byt = alphabetCharsToBytes[char.codePointAt(0)];
|
1491
|
+
if (byt === undefined) {
|
1492
|
+
throw new Error(`Non-base256emoji character: ${char}`);
|
1493
|
+
}
|
1494
|
+
byts.push(byt);
|
1617
1495
|
}
|
1618
|
-
byts
|
1619
|
-
}
|
1620
|
-
return new Uint8Array(byts)
|
1496
|
+
return new Uint8Array(byts);
|
1621
1497
|
}
|
1622
|
-
|
1623
1498
|
const base256emoji = from({
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1499
|
+
prefix: '🚀',
|
1500
|
+
name: 'base256emoji',
|
1501
|
+
encode,
|
1502
|
+
decode
|
1628
1503
|
});
|
1629
1504
|
|
1630
1505
|
var base256emoji$1 = /*#__PURE__*/Object.freeze({
|
@@ -1633,66 +1508,58 @@ var base256emoji$1 = /*#__PURE__*/Object.freeze({
|
|
1633
1508
|
});
|
1634
1509
|
|
1635
1510
|
const base32 = rfc4648({
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1511
|
+
prefix: 'b',
|
1512
|
+
name: 'base32',
|
1513
|
+
alphabet: 'abcdefghijklmnopqrstuvwxyz234567',
|
1514
|
+
bitsPerChar: 5
|
1640
1515
|
});
|
1641
|
-
|
1642
1516
|
const base32upper = rfc4648({
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1517
|
+
prefix: 'B',
|
1518
|
+
name: 'base32upper',
|
1519
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',
|
1520
|
+
bitsPerChar: 5
|
1647
1521
|
});
|
1648
|
-
|
1649
1522
|
const base32pad = rfc4648({
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1523
|
+
prefix: 'c',
|
1524
|
+
name: 'base32pad',
|
1525
|
+
alphabet: 'abcdefghijklmnopqrstuvwxyz234567=',
|
1526
|
+
bitsPerChar: 5
|
1654
1527
|
});
|
1655
|
-
|
1656
1528
|
const base32padupper = rfc4648({
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1529
|
+
prefix: 'C',
|
1530
|
+
name: 'base32padupper',
|
1531
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=',
|
1532
|
+
bitsPerChar: 5
|
1661
1533
|
});
|
1662
|
-
|
1663
1534
|
const base32hex = rfc4648({
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1535
|
+
prefix: 'v',
|
1536
|
+
name: 'base32hex',
|
1537
|
+
alphabet: '0123456789abcdefghijklmnopqrstuv',
|
1538
|
+
bitsPerChar: 5
|
1668
1539
|
});
|
1669
|
-
|
1670
1540
|
const base32hexupper = rfc4648({
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1541
|
+
prefix: 'V',
|
1542
|
+
name: 'base32hexupper',
|
1543
|
+
alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV',
|
1544
|
+
bitsPerChar: 5
|
1675
1545
|
});
|
1676
|
-
|
1677
1546
|
const base32hexpad = rfc4648({
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1547
|
+
prefix: 't',
|
1548
|
+
name: 'base32hexpad',
|
1549
|
+
alphabet: '0123456789abcdefghijklmnopqrstuv=',
|
1550
|
+
bitsPerChar: 5
|
1682
1551
|
});
|
1683
|
-
|
1684
1552
|
const base32hexpadupper = rfc4648({
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1553
|
+
prefix: 'T',
|
1554
|
+
name: 'base32hexpadupper',
|
1555
|
+
alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=',
|
1556
|
+
bitsPerChar: 5
|
1689
1557
|
});
|
1690
|
-
|
1691
1558
|
const base32z = rfc4648({
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1559
|
+
prefix: 'h',
|
1560
|
+
name: 'base32z',
|
1561
|
+
alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769',
|
1562
|
+
bitsPerChar: 5
|
1696
1563
|
});
|
1697
1564
|
|
1698
1565
|
var base32$1 = /*#__PURE__*/Object.freeze({
|
@@ -1709,15 +1576,14 @@ var base32$1 = /*#__PURE__*/Object.freeze({
|
|
1709
1576
|
});
|
1710
1577
|
|
1711
1578
|
const base36 = baseX({
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1579
|
+
prefix: 'k',
|
1580
|
+
name: 'base36',
|
1581
|
+
alphabet: '0123456789abcdefghijklmnopqrstuvwxyz'
|
1715
1582
|
});
|
1716
|
-
|
1717
1583
|
const base36upper = baseX({
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1584
|
+
prefix: 'K',
|
1585
|
+
name: 'base36upper',
|
1586
|
+
alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
1721
1587
|
});
|
1722
1588
|
|
1723
1589
|
var base36$1 = /*#__PURE__*/Object.freeze({
|
@@ -1727,15 +1593,14 @@ var base36$1 = /*#__PURE__*/Object.freeze({
|
|
1727
1593
|
});
|
1728
1594
|
|
1729
1595
|
const base58btc = baseX({
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1596
|
+
name: 'base58btc',
|
1597
|
+
prefix: 'z',
|
1598
|
+
alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
1733
1599
|
});
|
1734
|
-
|
1735
1600
|
const base58flickr = baseX({
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1601
|
+
name: 'base58flickr',
|
1602
|
+
prefix: 'Z',
|
1603
|
+
alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
|
1739
1604
|
});
|
1740
1605
|
|
1741
1606
|
var base58 = /*#__PURE__*/Object.freeze({
|
@@ -1744,35 +1609,29 @@ var base58 = /*#__PURE__*/Object.freeze({
|
|
1744
1609
|
base58flickr: base58flickr
|
1745
1610
|
});
|
1746
1611
|
|
1747
|
-
// @ts-check
|
1748
|
-
|
1749
|
-
|
1750
1612
|
const base64 = rfc4648({
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1613
|
+
prefix: 'm',
|
1614
|
+
name: 'base64',
|
1615
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
|
1616
|
+
bitsPerChar: 6
|
1755
1617
|
});
|
1756
|
-
|
1757
1618
|
const base64pad = rfc4648({
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1619
|
+
prefix: 'M',
|
1620
|
+
name: 'base64pad',
|
1621
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
1622
|
+
bitsPerChar: 6
|
1762
1623
|
});
|
1763
|
-
|
1764
1624
|
const base64url = rfc4648({
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1625
|
+
prefix: 'u',
|
1626
|
+
name: 'base64url',
|
1627
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
|
1628
|
+
bitsPerChar: 6
|
1769
1629
|
});
|
1770
|
-
|
1771
1630
|
const base64urlpad = rfc4648({
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1631
|
+
prefix: 'U',
|
1632
|
+
name: 'base64urlpad',
|
1633
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=',
|
1634
|
+
bitsPerChar: 6
|
1776
1635
|
});
|
1777
1636
|
|
1778
1637
|
var base64$1 = /*#__PURE__*/Object.freeze({
|
@@ -1783,14 +1642,11 @@ var base64$1 = /*#__PURE__*/Object.freeze({
|
|
1783
1642
|
base64urlpad: base64urlpad
|
1784
1643
|
});
|
1785
1644
|
|
1786
|
-
// @ts-check
|
1787
|
-
|
1788
|
-
|
1789
1645
|
const base8 = rfc4648({
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1646
|
+
prefix: '7',
|
1647
|
+
name: 'base8',
|
1648
|
+
alphabet: '01234567',
|
1649
|
+
bitsPerChar: 3
|
1794
1650
|
});
|
1795
1651
|
|
1796
1652
|
var base8$1 = /*#__PURE__*/Object.freeze({
|
@@ -1798,14 +1654,11 @@ var base8$1 = /*#__PURE__*/Object.freeze({
|
|
1798
1654
|
base8: base8
|
1799
1655
|
});
|
1800
1656
|
|
1801
|
-
// @ts-check
|
1802
|
-
|
1803
|
-
|
1804
1657
|
const identity = from({
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1658
|
+
prefix: '\x00',
|
1659
|
+
name: 'identity',
|
1660
|
+
encode: (buf) => toString(buf),
|
1661
|
+
decode: (str) => fromString$1(str)
|
1809
1662
|
});
|
1810
1663
|
|
1811
1664
|
var identityBase = /*#__PURE__*/Object.freeze({
|
@@ -1813,19 +1666,9 @@ var identityBase = /*#__PURE__*/Object.freeze({
|
|
1813
1666
|
identity: identity
|
1814
1667
|
});
|
1815
1668
|
|
1816
|
-
// @ts-check
|
1817
|
-
|
1818
|
-
/**
|
1819
|
-
* @template T
|
1820
|
-
* @typedef {import('./interface.js').ByteView<T>} ByteView
|
1821
|
-
*/
|
1822
|
-
|
1823
1669
|
new TextEncoder();
|
1824
1670
|
new TextDecoder();
|
1825
1671
|
|
1826
|
-
// @ts-check
|
1827
|
-
|
1828
|
-
|
1829
1672
|
const bases = { ...identityBase, ...base2$1, ...base8$1, ...base10$1, ...base16$1, ...base32$1, ...base36$1, ...base58, ...base64$1, ...base256emoji$1 };
|
1830
1673
|
|
1831
1674
|
/**
|
@@ -2812,4 +2655,4 @@ var symmetric = /*#__PURE__*/Object.freeze({
|
|
2812
2655
|
generateIv: generateIv
|
2813
2656
|
});
|
2814
2657
|
|
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,
|
2658
|
+
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, concat as j, keccak256 as k, getDefaultExportFromCjs as l, encrypt$1 as m, hexToBytes as n, decrypt$1 as o, generateIv as p, encrypt as q, randomBytes as r, sha256 as s, decrypt as t, utf8ToBytes as u, Signature as v, recoverPublicKey as w };
|