@leofcoin/peernet 0.18.1 → 0.18.2
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/exports/browser/{client-1c52a169.js → client-ed00c639.js} +1 -1
- package/exports/browser/{index-4a0fc4ea.js → index-7018cab6.js} +1 -1
- package/exports/browser/{index-639f2260.js → index-ddd5774f.js} +2 -2
- package/exports/browser/{messages-6db1f01d.js → messages-452642e3.js} +1 -1
- package/exports/browser/{peernet-3b3933a5.js → peernet-2796cdb2.js} +190 -288
- package/exports/browser/peernet.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as base58$1, i as index$1, a as index$2, c as index$3, d as index$4, e as createRIPEMD160, f as createHMAC, g as createSHA512, h as createKeccak } from './peernet-
|
|
1
|
+
import { b as base58$1, i as index$1, a as index$2, c as index$3, d as index$4, e as createRIPEMD160, f as createHMAC, g as createSHA512, h as createKeccak } from './peernet-2796cdb2.js';
|
|
2
2
|
import './value-40634404.js';
|
|
3
3
|
|
|
4
4
|
const randombytes = strength => crypto.getRandomValues(new Uint8Array(strength));
|
|
@@ -1258,6 +1258,187 @@ new Mutex();
|
|
|
1258
1258
|
|
|
1259
1259
|
new Mutex();
|
|
1260
1260
|
|
|
1261
|
+
const blockchainCodecs = [
|
|
1262
|
+
{
|
|
1263
|
+
name: 'leofcoin-block',
|
|
1264
|
+
codec: '0x6c62',
|
|
1265
|
+
hashAlg: 'dbl-keccak-512',
|
|
1266
|
+
},
|
|
1267
|
+
{
|
|
1268
|
+
name: 'leofcoin-tx',
|
|
1269
|
+
codec: '0x6c74',
|
|
1270
|
+
hashAlg: 'dbl-keccak-512',
|
|
1271
|
+
},
|
|
1272
|
+
{
|
|
1273
|
+
name: 'leofcoin-itx',
|
|
1274
|
+
codec: '0x6c69',
|
|
1275
|
+
hashAlg: 'keccak-512',
|
|
1276
|
+
},
|
|
1277
|
+
{
|
|
1278
|
+
name: 'leofcoin-pr',
|
|
1279
|
+
codec: '0x6c70',
|
|
1280
|
+
hashAlg: 'keccak-256',
|
|
1281
|
+
},
|
|
1282
|
+
{
|
|
1283
|
+
name: 'contract-message',
|
|
1284
|
+
codec: '0x63636d',
|
|
1285
|
+
hashAlg: 'keccak-256'
|
|
1286
|
+
},
|
|
1287
|
+
{
|
|
1288
|
+
name: 'transaction-message',
|
|
1289
|
+
codec: '0x746d',
|
|
1290
|
+
hashAlg: 'keccak-256'
|
|
1291
|
+
},
|
|
1292
|
+
{
|
|
1293
|
+
name: 'block-message',
|
|
1294
|
+
codec: '0x626d',
|
|
1295
|
+
hashAlg: 'keccak-256'
|
|
1296
|
+
},
|
|
1297
|
+
{
|
|
1298
|
+
name: 'bw-message',
|
|
1299
|
+
codec: '0x62776d',
|
|
1300
|
+
hashAlg: 'keccak-256'
|
|
1301
|
+
},
|
|
1302
|
+
{
|
|
1303
|
+
name: 'bw-request-message',
|
|
1304
|
+
codec: '0x6277726d',
|
|
1305
|
+
hashAlg: 'keccak-256'
|
|
1306
|
+
},
|
|
1307
|
+
{
|
|
1308
|
+
name: 'validator-message',
|
|
1309
|
+
codec: '0x766d',
|
|
1310
|
+
hashAlg: 'keccak-256'
|
|
1311
|
+
}
|
|
1312
|
+
];
|
|
1313
|
+
|
|
1314
|
+
const internalCodecs = [
|
|
1315
|
+
{
|
|
1316
|
+
name: 'disco-hash',
|
|
1317
|
+
codec: '0x30',
|
|
1318
|
+
hashAlg: 'dbl-keccak-256',
|
|
1319
|
+
},
|
|
1320
|
+
{
|
|
1321
|
+
name: 'peernet-peer-response',
|
|
1322
|
+
codec: '0x707072',
|
|
1323
|
+
hashAlg: 'keccak-256',
|
|
1324
|
+
},
|
|
1325
|
+
{
|
|
1326
|
+
name: 'peernet-peer',
|
|
1327
|
+
codec: '0x7070',
|
|
1328
|
+
hashAlg: 'keccak-256',
|
|
1329
|
+
},
|
|
1330
|
+
{
|
|
1331
|
+
name: 'peernet-dht',
|
|
1332
|
+
codec: '0x706468',
|
|
1333
|
+
hashAlg: 'keccak-256',
|
|
1334
|
+
},
|
|
1335
|
+
{
|
|
1336
|
+
name: 'peernet-dht-response',
|
|
1337
|
+
codec: '0x706472',
|
|
1338
|
+
hashAlg: 'keccak-256',
|
|
1339
|
+
},
|
|
1340
|
+
{
|
|
1341
|
+
name: 'peernet-data',
|
|
1342
|
+
codec: '0x706461',
|
|
1343
|
+
hashAlg: 'keccak-256',
|
|
1344
|
+
},
|
|
1345
|
+
{
|
|
1346
|
+
name: 'peernet-data-response',
|
|
1347
|
+
codec: '0x70646172',
|
|
1348
|
+
hashAlg: 'keccak-256',
|
|
1349
|
+
},
|
|
1350
|
+
{
|
|
1351
|
+
name: 'peernet-message',
|
|
1352
|
+
codec: '0x706d65',
|
|
1353
|
+
hashAlg: 'keccak-256',
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
name: 'peernet-ps',
|
|
1357
|
+
codec: '707073',
|
|
1358
|
+
hashAlg: 'keccak-256',
|
|
1359
|
+
},
|
|
1360
|
+
{
|
|
1361
|
+
name: 'peernet-response',
|
|
1362
|
+
codec: '0x7072',
|
|
1363
|
+
hashAlg: 'keccak-256',
|
|
1364
|
+
},
|
|
1365
|
+
{
|
|
1366
|
+
name: 'peernet-request',
|
|
1367
|
+
codec: '0x707271',
|
|
1368
|
+
hashAlg: 'keccak-256',
|
|
1369
|
+
},
|
|
1370
|
+
{
|
|
1371
|
+
name: 'peernet-file',
|
|
1372
|
+
codec: '0x7066',
|
|
1373
|
+
hashAlg: 'keccak-256',
|
|
1374
|
+
},
|
|
1375
|
+
{
|
|
1376
|
+
name: 'peernet-file-response',
|
|
1377
|
+
codec: '0x706672',
|
|
1378
|
+
hashAlg: 'keccak-256',
|
|
1379
|
+
}
|
|
1380
|
+
];
|
|
1381
|
+
|
|
1382
|
+
const codecs = [
|
|
1383
|
+
...internalCodecs,
|
|
1384
|
+
...blockchainCodecs,
|
|
1385
|
+
{
|
|
1386
|
+
name: 'chat-message',
|
|
1387
|
+
codec: '0x70636d',
|
|
1388
|
+
hashAlg: 'dbl-keccak-256',
|
|
1389
|
+
}
|
|
1390
|
+
];
|
|
1391
|
+
|
|
1392
|
+
globalThis.peernet = globalThis.peernet || {};
|
|
1393
|
+
globalThis.peernet.codecs = globalThis.peernet.codecs || {};
|
|
1394
|
+
const addCodec = (codecInput) => {
|
|
1395
|
+
let { hashAlg, codec, name } = codecInput;
|
|
1396
|
+
if (!globalThis.peernet.codecs[name])
|
|
1397
|
+
globalThis.peernet.codecs[name] = {
|
|
1398
|
+
hashAlg,
|
|
1399
|
+
codec: parseInt(codec, 16)
|
|
1400
|
+
};
|
|
1401
|
+
};
|
|
1402
|
+
const getCodec = (name) => globalThis.peernet.codecs[name];
|
|
1403
|
+
const getCodecName = (codec) => {
|
|
1404
|
+
return Object.keys(globalThis.peernet.codecs).reduce((p, c) => {
|
|
1405
|
+
const item = globalThis.peernet.codecs[c];
|
|
1406
|
+
if (item.codec === codec)
|
|
1407
|
+
return c;
|
|
1408
|
+
else
|
|
1409
|
+
return p;
|
|
1410
|
+
}, undefined);
|
|
1411
|
+
};
|
|
1412
|
+
const getCodecByName = (name) => globalThis.peernet.codecs[name];
|
|
1413
|
+
const getHashAlg = (name) => {
|
|
1414
|
+
if (typeof name === 'number')
|
|
1415
|
+
return getCodecByName(getCodecName(name)).hashAlg;
|
|
1416
|
+
return getCodecByName(name).hashAlg;
|
|
1417
|
+
};
|
|
1418
|
+
const isCodec = (codec) => {
|
|
1419
|
+
if (codec.codec !== undefined && codec.hashAlg)
|
|
1420
|
+
return true;
|
|
1421
|
+
return false;
|
|
1422
|
+
};
|
|
1423
|
+
const validateCodec = (codec) => {
|
|
1424
|
+
if (codec.codec === undefined ||
|
|
1425
|
+
codec.hashAlg === undefined ||
|
|
1426
|
+
codec.name === undefined)
|
|
1427
|
+
throw new Error(`invalid codecInput: ${codec}`);
|
|
1428
|
+
};
|
|
1429
|
+
for (const codec of codecs) {
|
|
1430
|
+
addCodec(codec);
|
|
1431
|
+
}
|
|
1432
|
+
var utils = {
|
|
1433
|
+
isCodec,
|
|
1434
|
+
addCodec,
|
|
1435
|
+
getCodec,
|
|
1436
|
+
getHashAlg,
|
|
1437
|
+
getCodecName,
|
|
1438
|
+
validateCodec,
|
|
1439
|
+
codecs: globalThis.peernet.codecs
|
|
1440
|
+
};
|
|
1441
|
+
|
|
1261
1442
|
/**
|
|
1262
1443
|
* @param {string}
|
|
1263
1444
|
*/
|
|
@@ -1377,102 +1558,10 @@ let BasicInterface$1 = class BasicInterface {
|
|
|
1377
1558
|
}
|
|
1378
1559
|
};
|
|
1379
1560
|
|
|
1380
|
-
var codecs$1 = {
|
|
1381
|
-
// just a hash
|
|
1382
|
-
'disco-hash': {
|
|
1383
|
-
codec: parseInt('0x30', 16),
|
|
1384
|
-
hashAlg: 'dbl-keccak-256', // ,
|
|
1385
|
-
// testnet: 'olivia'
|
|
1386
|
-
},
|
|
1387
|
-
'peernet-peer-response': {
|
|
1388
|
-
codec: parseInt('0x707072', 16),
|
|
1389
|
-
hashAlg: 'keccak-256',
|
|
1390
|
-
},
|
|
1391
|
-
'peernet-peer': {
|
|
1392
|
-
codec: parseInt('0x7070', 16),
|
|
1393
|
-
hashAlg: 'keccak-256',
|
|
1394
|
-
},
|
|
1395
|
-
'peernet-dht': {
|
|
1396
|
-
codec: parseInt('0x706468', 16),
|
|
1397
|
-
hashAlg: 'keccak-256',
|
|
1398
|
-
},
|
|
1399
|
-
'peernet-dht-response': {
|
|
1400
|
-
codec: parseInt('0x706472', 16),
|
|
1401
|
-
hashAlg: 'keccak-256',
|
|
1402
|
-
},
|
|
1403
|
-
// data
|
|
1404
|
-
'peernet-data': {
|
|
1405
|
-
codec: parseInt('0x706461', 16),
|
|
1406
|
-
hashAlg: 'keccak-256',
|
|
1407
|
-
},
|
|
1408
|
-
'peernet-data-response': {
|
|
1409
|
-
codec: parseInt('0x70646172', 16),
|
|
1410
|
-
hashAlg: 'keccak-256',
|
|
1411
|
-
},
|
|
1412
|
-
// message
|
|
1413
|
-
'peernet-message': {
|
|
1414
|
-
codec: parseInt('0x706d65', 16),
|
|
1415
|
-
hashAlg: 'keccak-256',
|
|
1416
|
-
},
|
|
1417
|
-
// pubsub
|
|
1418
|
-
'peernet-ps': {
|
|
1419
|
-
codec: parseInt('0x707073', 16),
|
|
1420
|
-
hashAlg: 'keccak-256',
|
|
1421
|
-
},
|
|
1422
|
-
'peernet-response': {
|
|
1423
|
-
codec: parseInt('0x7072', 16),
|
|
1424
|
-
hashAlg: 'keccak-256',
|
|
1425
|
-
},
|
|
1426
|
-
'peernet-request': {
|
|
1427
|
-
codec: parseInt('0x707271', 16),
|
|
1428
|
-
hashAlg: 'keccak-256',
|
|
1429
|
-
},
|
|
1430
|
-
// normal block
|
|
1431
|
-
'leofcoin-block': {
|
|
1432
|
-
codec: parseInt('0x6c62', 16),
|
|
1433
|
-
hashAlg: 'dbl-keccak-512', // ,
|
|
1434
|
-
// testnet: 'olivia'
|
|
1435
|
-
},
|
|
1436
|
-
'leofcoin-tx': {
|
|
1437
|
-
codec: parseInt('0x6c74', 16),
|
|
1438
|
-
hashAlg: 'dbl-keccak-512', // ,
|
|
1439
|
-
// testnet: 'olivia'
|
|
1440
|
-
},
|
|
1441
|
-
// itx
|
|
1442
|
-
'leofcoin-itx': {
|
|
1443
|
-
codec: parseInt('0x6c69', 16),
|
|
1444
|
-
hashAlg: 'keccak-512', // ,
|
|
1445
|
-
// testnet: 'olivia'
|
|
1446
|
-
},
|
|
1447
|
-
// peer reputation
|
|
1448
|
-
'leofcoin-pr': {
|
|
1449
|
-
codec: parseInt('0x6c70', 16),
|
|
1450
|
-
hashAlg: 'keccak-256', // ,
|
|
1451
|
-
// testnet: 'olivia'
|
|
1452
|
-
},
|
|
1453
|
-
// chat message
|
|
1454
|
-
'chat-message': {
|
|
1455
|
-
codec: parseInt('0x70636d', 16),
|
|
1456
|
-
hashAlg: 'dbl-keccak-256',
|
|
1457
|
-
},
|
|
1458
|
-
'peernet-file': {
|
|
1459
|
-
codec: parseInt('0x7066', 16),
|
|
1460
|
-
hashAlg: 'keccak-256',
|
|
1461
|
-
},
|
|
1462
|
-
'peernet-file-response': {
|
|
1463
|
-
codec: parseInt('0x706672', 16),
|
|
1464
|
-
hashAlg: 'keccak-256',
|
|
1465
|
-
}
|
|
1466
|
-
};
|
|
1467
|
-
|
|
1468
1561
|
let Codec$1 = class Codec extends BasicInterface$1 {
|
|
1469
1562
|
codecBuffer;
|
|
1470
1563
|
codec;
|
|
1471
1564
|
hashAlg;
|
|
1472
|
-
get codecs() {
|
|
1473
|
-
const globalCodecs = globalThis.peernet?.codecs || {};
|
|
1474
|
-
return { ...globalCodecs, ...codecs$1 };
|
|
1475
|
-
}
|
|
1476
1565
|
constructor(buffer) {
|
|
1477
1566
|
super();
|
|
1478
1567
|
if (buffer) {
|
|
@@ -1500,7 +1589,7 @@ let Codec$1 = class Codec extends BasicInterface$1 {
|
|
|
1500
1589
|
}
|
|
1501
1590
|
}
|
|
1502
1591
|
else if (typeof buffer === 'string') {
|
|
1503
|
-
if (
|
|
1592
|
+
if (utils.getCodec(buffer))
|
|
1504
1593
|
this.fromName(buffer);
|
|
1505
1594
|
else if (this.isHex(buffer))
|
|
1506
1595
|
this.fromHex(buffer);
|
|
@@ -1512,7 +1601,7 @@ let Codec$1 = class Codec extends BasicInterface$1 {
|
|
|
1512
1601
|
throw new Error(`unsupported string ${buffer}`);
|
|
1513
1602
|
}
|
|
1514
1603
|
if (!isNaN(buffer))
|
|
1515
|
-
if (
|
|
1604
|
+
if (utils.getCodec(buffer))
|
|
1516
1605
|
this.fromCodec(buffer);
|
|
1517
1606
|
}
|
|
1518
1607
|
}
|
|
@@ -1524,19 +1613,13 @@ let Codec$1 = class Codec extends BasicInterface$1 {
|
|
|
1524
1613
|
return this.decode(encoded);
|
|
1525
1614
|
}
|
|
1526
1615
|
getCodec(name) {
|
|
1527
|
-
return
|
|
1616
|
+
return utils.getCodec(name);
|
|
1528
1617
|
}
|
|
1529
1618
|
getCodecName(codec) {
|
|
1530
|
-
return
|
|
1531
|
-
const item = this.codecs[c];
|
|
1532
|
-
if (item.codec === codec)
|
|
1533
|
-
return c;
|
|
1534
|
-
else
|
|
1535
|
-
return p;
|
|
1536
|
-
}, undefined);
|
|
1619
|
+
return utils.getCodecName(codec);
|
|
1537
1620
|
}
|
|
1538
1621
|
getHashAlg(name) {
|
|
1539
|
-
return
|
|
1622
|
+
return utils.getHashAlg(name);
|
|
1540
1623
|
}
|
|
1541
1624
|
fromCodec(codec) {
|
|
1542
1625
|
this.name = this.getCodecName(codec);
|
|
@@ -2064,7 +2147,7 @@ class MessageHandler {
|
|
|
2064
2147
|
let identity = await walletStore.get('identity');
|
|
2065
2148
|
identity = JSON.parse(identity);
|
|
2066
2149
|
if (!globalThis.MultiWallet) {
|
|
2067
|
-
const importee = await import(/* webpackChunkName: "multi-wallet" */ './index-
|
|
2150
|
+
const importee = await import(/* webpackChunkName: "multi-wallet" */ './index-7018cab6.js');
|
|
2068
2151
|
globalThis.MultiWallet = importee.default;
|
|
2069
2152
|
}
|
|
2070
2153
|
const wallet = new MultiWallet(this.network);
|
|
@@ -2269,187 +2352,6 @@ class LeofcoinStorage {
|
|
|
2269
2352
|
|
|
2270
2353
|
}
|
|
2271
2354
|
|
|
2272
|
-
const blockchainCodecs = [
|
|
2273
|
-
{
|
|
2274
|
-
name: 'leofcoin-block',
|
|
2275
|
-
codec: '0x6c62',
|
|
2276
|
-
hashAlg: 'dbl-keccak-512',
|
|
2277
|
-
},
|
|
2278
|
-
{
|
|
2279
|
-
name: 'leofcoin-tx',
|
|
2280
|
-
codec: '0x6c74',
|
|
2281
|
-
hashAlg: 'dbl-keccak-512',
|
|
2282
|
-
},
|
|
2283
|
-
{
|
|
2284
|
-
name: 'leofcoin-itx',
|
|
2285
|
-
codec: '0x6c69',
|
|
2286
|
-
hashAlg: 'keccak-512',
|
|
2287
|
-
},
|
|
2288
|
-
{
|
|
2289
|
-
name: 'leofcoin-pr',
|
|
2290
|
-
codec: '0x6c70',
|
|
2291
|
-
hashAlg: 'keccak-256',
|
|
2292
|
-
},
|
|
2293
|
-
{
|
|
2294
|
-
name: 'contract-message',
|
|
2295
|
-
codec: '0x63636d',
|
|
2296
|
-
hashAlg: 'keccak-256'
|
|
2297
|
-
},
|
|
2298
|
-
{
|
|
2299
|
-
name: 'transaction-message',
|
|
2300
|
-
codec: '0x746d',
|
|
2301
|
-
hashAlg: 'keccak-256'
|
|
2302
|
-
},
|
|
2303
|
-
{
|
|
2304
|
-
name: 'block-message',
|
|
2305
|
-
codec: '0x626d',
|
|
2306
|
-
hashAlg: 'keccak-256'
|
|
2307
|
-
},
|
|
2308
|
-
{
|
|
2309
|
-
name: 'bw-message',
|
|
2310
|
-
codec: '0x62776d',
|
|
2311
|
-
hashAlg: 'keccak-256'
|
|
2312
|
-
},
|
|
2313
|
-
{
|
|
2314
|
-
name: 'bw-request-message',
|
|
2315
|
-
codec: '0x6277726d',
|
|
2316
|
-
hashAlg: 'keccak-256'
|
|
2317
|
-
},
|
|
2318
|
-
{
|
|
2319
|
-
name: 'validator-message',
|
|
2320
|
-
codec: '0x766d',
|
|
2321
|
-
hashAlg: 'keccak-256'
|
|
2322
|
-
}
|
|
2323
|
-
];
|
|
2324
|
-
|
|
2325
|
-
const internalCodecs = [
|
|
2326
|
-
{
|
|
2327
|
-
name: 'disco-hash',
|
|
2328
|
-
codec: '0x30',
|
|
2329
|
-
hashAlg: 'dbl-keccak-256',
|
|
2330
|
-
},
|
|
2331
|
-
{
|
|
2332
|
-
name: 'peernet-peer-response',
|
|
2333
|
-
codec: '0x707072',
|
|
2334
|
-
hashAlg: 'keccak-256',
|
|
2335
|
-
},
|
|
2336
|
-
{
|
|
2337
|
-
name: 'peernet-peer',
|
|
2338
|
-
codec: '0x7070',
|
|
2339
|
-
hashAlg: 'keccak-256',
|
|
2340
|
-
},
|
|
2341
|
-
{
|
|
2342
|
-
name: 'peernet-dht',
|
|
2343
|
-
codec: '0x706468',
|
|
2344
|
-
hashAlg: 'keccak-256',
|
|
2345
|
-
},
|
|
2346
|
-
{
|
|
2347
|
-
name: 'peernet-dht-response',
|
|
2348
|
-
codec: '0x706472',
|
|
2349
|
-
hashAlg: 'keccak-256',
|
|
2350
|
-
},
|
|
2351
|
-
{
|
|
2352
|
-
name: 'peernet-data',
|
|
2353
|
-
codec: '0x706461',
|
|
2354
|
-
hashAlg: 'keccak-256',
|
|
2355
|
-
},
|
|
2356
|
-
{
|
|
2357
|
-
name: 'peernet-data-response',
|
|
2358
|
-
codec: '0x70646172',
|
|
2359
|
-
hashAlg: 'keccak-256',
|
|
2360
|
-
},
|
|
2361
|
-
{
|
|
2362
|
-
name: 'peernet-message',
|
|
2363
|
-
codec: '0x706d65',
|
|
2364
|
-
hashAlg: 'keccak-256',
|
|
2365
|
-
},
|
|
2366
|
-
{
|
|
2367
|
-
name: 'peernet-ps',
|
|
2368
|
-
codec: '707073',
|
|
2369
|
-
hashAlg: 'keccak-256',
|
|
2370
|
-
},
|
|
2371
|
-
{
|
|
2372
|
-
name: 'peernet-response',
|
|
2373
|
-
codec: '0x7072',
|
|
2374
|
-
hashAlg: 'keccak-256',
|
|
2375
|
-
},
|
|
2376
|
-
{
|
|
2377
|
-
name: 'peernet-request',
|
|
2378
|
-
codec: '0x707271',
|
|
2379
|
-
hashAlg: 'keccak-256',
|
|
2380
|
-
},
|
|
2381
|
-
{
|
|
2382
|
-
name: 'peernet-file',
|
|
2383
|
-
codec: '0x7066',
|
|
2384
|
-
hashAlg: 'keccak-256',
|
|
2385
|
-
},
|
|
2386
|
-
{
|
|
2387
|
-
name: 'peernet-file-response',
|
|
2388
|
-
codec: '0x706672',
|
|
2389
|
-
hashAlg: 'keccak-256',
|
|
2390
|
-
}
|
|
2391
|
-
];
|
|
2392
|
-
|
|
2393
|
-
const codecs = [
|
|
2394
|
-
...internalCodecs,
|
|
2395
|
-
...blockchainCodecs,
|
|
2396
|
-
{
|
|
2397
|
-
name: 'chat-message',
|
|
2398
|
-
codec: '0x70636d',
|
|
2399
|
-
hashAlg: 'dbl-keccak-256',
|
|
2400
|
-
}
|
|
2401
|
-
];
|
|
2402
|
-
|
|
2403
|
-
globalThis.peernet = globalThis.peernet || {};
|
|
2404
|
-
globalThis.peernet.codecs = globalThis.peernet.codecs || {};
|
|
2405
|
-
const addCodec = (codecInput) => {
|
|
2406
|
-
let { hashAlg, codec, name } = codecInput;
|
|
2407
|
-
if (!globalThis.peernet.codecs[name])
|
|
2408
|
-
globalThis.peernet.codecs[name] = {
|
|
2409
|
-
hashAlg,
|
|
2410
|
-
codec: parseInt(codec, 16)
|
|
2411
|
-
};
|
|
2412
|
-
};
|
|
2413
|
-
const getCodec = (name) => globalThis.peernet.codecs[name];
|
|
2414
|
-
const getCodecName = (codec) => {
|
|
2415
|
-
return Object.keys(globalThis.peernet.codecs).reduce((p, c) => {
|
|
2416
|
-
const item = globalThis.peernet.codecs[c];
|
|
2417
|
-
if (item.codec === codec)
|
|
2418
|
-
return c;
|
|
2419
|
-
else
|
|
2420
|
-
return p;
|
|
2421
|
-
}, undefined);
|
|
2422
|
-
};
|
|
2423
|
-
const getCodecByName = (name) => globalThis.peernet.codecs[name];
|
|
2424
|
-
const getHashAlg = (name) => {
|
|
2425
|
-
if (typeof name === 'number')
|
|
2426
|
-
return getCodecByName(getCodecName(name)).hashAlg;
|
|
2427
|
-
return getCodecByName(name).hashAlg;
|
|
2428
|
-
};
|
|
2429
|
-
const isCodec = (codec) => {
|
|
2430
|
-
if (codec.codec !== undefined && codec.hashAlg)
|
|
2431
|
-
return true;
|
|
2432
|
-
return false;
|
|
2433
|
-
};
|
|
2434
|
-
const validateCodec = (codec) => {
|
|
2435
|
-
if (codec.codec === undefined ||
|
|
2436
|
-
codec.hashAlg === undefined ||
|
|
2437
|
-
codec.name === undefined)
|
|
2438
|
-
throw new Error(`invalid codecInput: ${codec}`);
|
|
2439
|
-
};
|
|
2440
|
-
for (const codec of codecs) {
|
|
2441
|
-
addCodec(codec);
|
|
2442
|
-
}
|
|
2443
|
-
var utils = {
|
|
2444
|
-
isCodec,
|
|
2445
|
-
addCodec,
|
|
2446
|
-
getCodec,
|
|
2447
|
-
getHashAlg,
|
|
2448
|
-
getCodecName,
|
|
2449
|
-
validateCodec,
|
|
2450
|
-
codecs: globalThis.peernet.codecs
|
|
2451
|
-
};
|
|
2452
|
-
|
|
2453
2355
|
globalThis.LeofcoinStorage = LeofcoinStorage;
|
|
2454
2356
|
globalThis.leofcoin = globalThis.leofcoin || {};
|
|
2455
2357
|
globalThis.pubsub = globalThis.pubsub || new LittlePubSub();
|
|
@@ -2571,7 +2473,7 @@ class Peernet {
|
|
|
2571
2473
|
this.root = options.root;
|
|
2572
2474
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
2573
2475
|
// FolderMessageResponse
|
|
2574
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-
|
|
2476
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-452642e3.js');
|
|
2575
2477
|
/**
|
|
2576
2478
|
* proto Object containing protos
|
|
2577
2479
|
* @type {Object}
|
|
@@ -2619,7 +2521,7 @@ class Peernet {
|
|
|
2619
2521
|
}
|
|
2620
2522
|
}
|
|
2621
2523
|
else {
|
|
2622
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-
|
|
2524
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-ddd5774f.js');
|
|
2623
2525
|
const generateAccount = importee.default;
|
|
2624
2526
|
const { identity, accounts, config } = await generateAccount(this.network);
|
|
2625
2527
|
// await accountStore.put('config', JSON.stringify(config));
|
|
@@ -2648,7 +2550,7 @@ class Peernet {
|
|
|
2648
2550
|
* @see DataHandler
|
|
2649
2551
|
*/
|
|
2650
2552
|
pubsub.subscribe('peer:data', dataHandler);
|
|
2651
|
-
const importee = await import('./client-
|
|
2553
|
+
const importee = await import('./client-ed00c639.js');
|
|
2652
2554
|
/**
|
|
2653
2555
|
* @access public
|
|
2654
2556
|
* @type {PeernetClient}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { P as default } from './peernet-
|
|
1
|
+
export { P as default } from './peernet-2796cdb2.js';
|
|
2
2
|
import './value-40634404.js';
|