@leofcoin/peernet 1.0.3 → 1.0.6
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-471408b6.js → client-cbaadd55.js} +1 -1
- package/exports/browser/{index-601960df.js → index-88c7fc2e.js} +1 -22
- package/exports/browser/{messages-cf68bfb3.js → messages-ba0fcf7e.js} +1 -1
- package/exports/browser/{peernet-e1e0a046.js → peernet-6a78293a.js} +446 -435
- package/exports/browser/peernet.js +1 -1
- package/exports/peernet.js +9 -0
- package/package.json +1 -1
- package/src/identity.ts +10 -1
|
@@ -1,27 +1,6 @@
|
|
|
1
|
-
import { M as MultiWallet,
|
|
1
|
+
import { M as MultiWallet, e as encrypt, b as base58$1 } from './peernet-6a78293a.js';
|
|
2
2
|
import './value-157ab062.js';
|
|
3
3
|
|
|
4
|
-
const passwordToKey = (password) => globalThis.crypto.subtle.importKey('raw', password, 'PBKDF2', false, ['deriveKey']);
|
|
5
|
-
const deriveKey = (key, salt, iterations = 250000, hashAlgorithm = 'SHA-512') => globalThis.crypto.subtle.deriveKey({
|
|
6
|
-
name: 'PBKDF2',
|
|
7
|
-
salt,
|
|
8
|
-
iterations,
|
|
9
|
-
hash: hashAlgorithm
|
|
10
|
-
}, key, {
|
|
11
|
-
name: 'AES-GCM',
|
|
12
|
-
length: 256
|
|
13
|
-
}, false, ['encrypt', 'decrypt']);
|
|
14
|
-
const encrypt = async (password, data, version = new TextEncoder().encode('1')) => {
|
|
15
|
-
const passwordKey = await passwordToKey(new TextEncoder().encode(password));
|
|
16
|
-
const salt = randombytes(16);
|
|
17
|
-
const iv = randombytes(16);
|
|
18
|
-
const key = await deriveKey(passwordKey, salt);
|
|
19
|
-
const encrypted = await globalThis.crypto.subtle.encrypt({
|
|
20
|
-
name: 'AES-GCM',
|
|
21
|
-
iv
|
|
22
|
-
}, key, new TextEncoder().encode(data));
|
|
23
|
-
return index$1([version, salt, iv, new Uint8Array(encrypted)]);
|
|
24
|
-
};
|
|
25
4
|
/**
|
|
26
5
|
* @params {String} network
|
|
27
6
|
* @return {object} { identity, accounts, config }
|
|
@@ -1467,444 +1467,446 @@ var utils$p = {
|
|
|
1467
1467
|
*/
|
|
1468
1468
|
var isHex = (function (string) { return /^[A-F0-9]+$/i.test(string); });
|
|
1469
1469
|
|
|
1470
|
-
let BasicInterface$1 = class BasicInterface {
|
|
1471
|
-
encoded;
|
|
1472
|
-
decoded;
|
|
1473
|
-
keys;
|
|
1474
|
-
name;
|
|
1475
|
-
#proto;
|
|
1476
|
-
set proto(value) {
|
|
1477
|
-
this.#proto = value;
|
|
1478
|
-
this.keys = Object.keys(value);
|
|
1479
|
-
}
|
|
1480
|
-
get proto() {
|
|
1481
|
-
return this.#proto;
|
|
1482
|
-
}
|
|
1483
|
-
decode(encoded) {
|
|
1484
|
-
encoded = encoded || this.encoded;
|
|
1485
|
-
return new Object();
|
|
1486
|
-
}
|
|
1487
|
-
encode(decoded) {
|
|
1488
|
-
decoded = decoded || this.decoded;
|
|
1489
|
-
return new Uint8Array();
|
|
1490
|
-
}
|
|
1491
|
-
// get Codec(): Codec {}
|
|
1492
|
-
protoEncode(data) {
|
|
1493
|
-
// check schema
|
|
1494
|
-
return index$1.encode(this.proto, data);
|
|
1495
|
-
}
|
|
1496
|
-
protoDecode(data) {
|
|
1497
|
-
// check schema
|
|
1498
|
-
return index$1.decode(this.proto, data);
|
|
1499
|
-
}
|
|
1500
|
-
isHex(string) {
|
|
1501
|
-
return isHex(string);
|
|
1502
|
-
}
|
|
1503
|
-
isBase32(string) {
|
|
1504
|
-
return index$8.isBase32(string);
|
|
1505
|
-
}
|
|
1506
|
-
isBase58(string) {
|
|
1507
|
-
return base58$1.isBase58(string);
|
|
1508
|
-
}
|
|
1509
|
-
fromBs32(encoded) {
|
|
1510
|
-
return this.decode(index$8.decode(encoded));
|
|
1511
|
-
}
|
|
1512
|
-
fromBs58(encoded) {
|
|
1513
|
-
return this.decode(fromBase58(encoded));
|
|
1514
|
-
}
|
|
1515
|
-
async toArray() {
|
|
1516
|
-
const array = [];
|
|
1517
|
-
for await (const value of this.encoded.values()) {
|
|
1518
|
-
array.push(value);
|
|
1519
|
-
}
|
|
1520
|
-
return array;
|
|
1521
|
-
}
|
|
1522
|
-
fromString(string) {
|
|
1523
|
-
const array = string.split(',');
|
|
1524
|
-
const arrayLike = array.map(string => Number(string));
|
|
1525
|
-
return this.decode(Uint8Array.from(arrayLike));
|
|
1526
|
-
}
|
|
1527
|
-
fromHex(string) {
|
|
1528
|
-
return this.decode(fromHex(string));
|
|
1529
|
-
}
|
|
1530
|
-
fromArray(array) {
|
|
1531
|
-
return this.decode(Uint8Array.from([...array]));
|
|
1532
|
-
}
|
|
1533
|
-
fromEncoded(encoded) {
|
|
1534
|
-
return this.decode(encoded);
|
|
1535
|
-
}
|
|
1536
|
-
toString() {
|
|
1537
|
-
if (!this.encoded)
|
|
1538
|
-
this.encode();
|
|
1539
|
-
return this.encoded.toString();
|
|
1540
|
-
}
|
|
1541
|
-
toHex() {
|
|
1542
|
-
if (!this.encoded)
|
|
1543
|
-
this.encode();
|
|
1544
|
-
return toHex$1(this.encoded.toString().split(',').map(number => Number(number)));
|
|
1545
|
-
}
|
|
1546
|
-
/**
|
|
1547
|
-
* @return {String} encoded
|
|
1548
|
-
*/
|
|
1549
|
-
toBs32() {
|
|
1550
|
-
if (!this.encoded)
|
|
1551
|
-
this.encode();
|
|
1552
|
-
return toBase32(this.encoded);
|
|
1553
|
-
}
|
|
1554
|
-
/**
|
|
1555
|
-
* @return {String} encoded
|
|
1556
|
-
*/
|
|
1557
|
-
toBs58() {
|
|
1558
|
-
if (!this.encoded)
|
|
1559
|
-
this.encode();
|
|
1560
|
-
return toBase58(this.encoded);
|
|
1561
|
-
}
|
|
1470
|
+
let BasicInterface$1 = class BasicInterface {
|
|
1471
|
+
encoded;
|
|
1472
|
+
decoded;
|
|
1473
|
+
keys;
|
|
1474
|
+
name;
|
|
1475
|
+
#proto;
|
|
1476
|
+
set proto(value) {
|
|
1477
|
+
this.#proto = value;
|
|
1478
|
+
this.keys = Object.keys(value);
|
|
1479
|
+
}
|
|
1480
|
+
get proto() {
|
|
1481
|
+
return this.#proto;
|
|
1482
|
+
}
|
|
1483
|
+
decode(encoded) {
|
|
1484
|
+
encoded = encoded || this.encoded;
|
|
1485
|
+
return new Object();
|
|
1486
|
+
}
|
|
1487
|
+
encode(decoded) {
|
|
1488
|
+
decoded = decoded || this.decoded;
|
|
1489
|
+
return new Uint8Array();
|
|
1490
|
+
}
|
|
1491
|
+
// get Codec(): Codec {}
|
|
1492
|
+
protoEncode(data) {
|
|
1493
|
+
// check schema
|
|
1494
|
+
return index$1.encode(this.proto, data);
|
|
1495
|
+
}
|
|
1496
|
+
protoDecode(data) {
|
|
1497
|
+
// check schema
|
|
1498
|
+
return index$1.decode(this.proto, data);
|
|
1499
|
+
}
|
|
1500
|
+
isHex(string) {
|
|
1501
|
+
return isHex(string);
|
|
1502
|
+
}
|
|
1503
|
+
isBase32(string) {
|
|
1504
|
+
return index$8.isBase32(string);
|
|
1505
|
+
}
|
|
1506
|
+
isBase58(string) {
|
|
1507
|
+
return base58$1.isBase58(string);
|
|
1508
|
+
}
|
|
1509
|
+
fromBs32(encoded) {
|
|
1510
|
+
return this.decode(index$8.decode(encoded));
|
|
1511
|
+
}
|
|
1512
|
+
fromBs58(encoded) {
|
|
1513
|
+
return this.decode(fromBase58(encoded));
|
|
1514
|
+
}
|
|
1515
|
+
async toArray() {
|
|
1516
|
+
const array = [];
|
|
1517
|
+
for await (const value of this.encoded.values()) {
|
|
1518
|
+
array.push(value);
|
|
1519
|
+
}
|
|
1520
|
+
return array;
|
|
1521
|
+
}
|
|
1522
|
+
fromString(string) {
|
|
1523
|
+
const array = string.split(',');
|
|
1524
|
+
const arrayLike = array.map(string => Number(string));
|
|
1525
|
+
return this.decode(Uint8Array.from(arrayLike));
|
|
1526
|
+
}
|
|
1527
|
+
fromHex(string) {
|
|
1528
|
+
return this.decode(fromHex(string));
|
|
1529
|
+
}
|
|
1530
|
+
fromArray(array) {
|
|
1531
|
+
return this.decode(Uint8Array.from([...array]));
|
|
1532
|
+
}
|
|
1533
|
+
fromEncoded(encoded) {
|
|
1534
|
+
return this.decode(encoded);
|
|
1535
|
+
}
|
|
1536
|
+
toString() {
|
|
1537
|
+
if (!this.encoded)
|
|
1538
|
+
this.encode();
|
|
1539
|
+
return this.encoded.toString();
|
|
1540
|
+
}
|
|
1541
|
+
toHex() {
|
|
1542
|
+
if (!this.encoded)
|
|
1543
|
+
this.encode();
|
|
1544
|
+
return toHex$1(this.encoded.toString().split(',').map(number => Number(number)));
|
|
1545
|
+
}
|
|
1546
|
+
/**
|
|
1547
|
+
* @return {String} encoded
|
|
1548
|
+
*/
|
|
1549
|
+
toBs32() {
|
|
1550
|
+
if (!this.encoded)
|
|
1551
|
+
this.encode();
|
|
1552
|
+
return toBase32(this.encoded);
|
|
1553
|
+
}
|
|
1554
|
+
/**
|
|
1555
|
+
* @return {String} encoded
|
|
1556
|
+
*/
|
|
1557
|
+
toBs58() {
|
|
1558
|
+
if (!this.encoded)
|
|
1559
|
+
this.encode();
|
|
1560
|
+
return toBase58(this.encoded);
|
|
1561
|
+
}
|
|
1562
1562
|
};
|
|
1563
1563
|
|
|
1564
|
-
let Codec$1 = class Codec extends BasicInterface$1 {
|
|
1565
|
-
codecBuffer;
|
|
1566
|
-
codec;
|
|
1567
|
-
hashAlg;
|
|
1568
|
-
constructor(buffer) {
|
|
1569
|
-
super();
|
|
1570
|
-
if (buffer) {
|
|
1571
|
-
if (buffer instanceof Uint8Array) {
|
|
1572
|
-
const codec = index$7.decode(buffer);
|
|
1573
|
-
const name = this.getCodecName(codec);
|
|
1574
|
-
if (name) {
|
|
1575
|
-
this.name = name;
|
|
1576
|
-
this.encoded = buffer;
|
|
1577
|
-
this.decode(buffer);
|
|
1578
|
-
}
|
|
1579
|
-
else {
|
|
1580
|
-
this.encode(Number(new TextDecoder().decode(buffer)));
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
else if (buffer instanceof ArrayBuffer) {
|
|
1584
|
-
const codec = index$7.decode(buffer);
|
|
1585
|
-
const name = this.getCodecName(codec);
|
|
1586
|
-
if (name) {
|
|
1587
|
-
this.name = name;
|
|
1588
|
-
this.decode(buffer);
|
|
1589
|
-
}
|
|
1590
|
-
else {
|
|
1591
|
-
this.encode(Number(new TextDecoder().decode(new Uint8Array(buffer))));
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
else if (typeof buffer === 'string') {
|
|
1595
|
-
if (utils$p.getCodec(buffer))
|
|
1596
|
-
this.fromName(buffer);
|
|
1597
|
-
else if (this.isHex(buffer))
|
|
1598
|
-
this.fromHex(buffer);
|
|
1599
|
-
else if (this.isBase32(buffer))
|
|
1600
|
-
this.fromBs32(buffer);
|
|
1601
|
-
else if (this.isBase58(buffer))
|
|
1602
|
-
this.fromBs58(buffer);
|
|
1603
|
-
else
|
|
1604
|
-
this.fromString(buffer);
|
|
1605
|
-
}
|
|
1606
|
-
if (!isNaN(buffer))
|
|
1607
|
-
if (utils$p.getCodec(buffer))
|
|
1608
|
-
this.fromCodec(buffer);
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1611
|
-
fromEncoded(encoded) {
|
|
1612
|
-
const codec = index$7.decode(encoded);
|
|
1613
|
-
const name = this.getCodecName(codec);
|
|
1614
|
-
this.name = name;
|
|
1615
|
-
this.encoded = encoded;
|
|
1616
|
-
return this.decode(encoded);
|
|
1617
|
-
}
|
|
1618
|
-
getCodec(name) {
|
|
1619
|
-
return utils$p.getCodec(name);
|
|
1620
|
-
}
|
|
1621
|
-
getCodecName(codec) {
|
|
1622
|
-
return utils$p.getCodecName(codec);
|
|
1623
|
-
}
|
|
1624
|
-
getHashAlg(name) {
|
|
1625
|
-
return utils$p.getHashAlg(name);
|
|
1626
|
-
}
|
|
1627
|
-
fromCodec(codec) {
|
|
1628
|
-
this.name = this.getCodecName(codec);
|
|
1629
|
-
this.hashAlg = this.getHashAlg(this.name);
|
|
1630
|
-
this.codec = this.getCodec(this.name);
|
|
1631
|
-
this.codecBuffer = index$7.encode(this.codec);
|
|
1632
|
-
}
|
|
1633
|
-
fromName(name) {
|
|
1634
|
-
const codec = this.getCodec(name);
|
|
1635
|
-
this.name = name;
|
|
1636
|
-
this.codec = codec;
|
|
1637
|
-
this.hashAlg = this.getHashAlg(name);
|
|
1638
|
-
this.codecBuffer = index$7.encode(this.codec);
|
|
1639
|
-
}
|
|
1640
|
-
decode(encoded) {
|
|
1641
|
-
encoded = encoded || this.encoded;
|
|
1642
|
-
const codec = index$7.decode(encoded);
|
|
1643
|
-
this.fromCodec(codec);
|
|
1644
|
-
return this.decoded;
|
|
1645
|
-
}
|
|
1646
|
-
encode(codec) {
|
|
1647
|
-
codec = codec || this.codec;
|
|
1648
|
-
this.encoded = index$7.encode(codec);
|
|
1649
|
-
return this.encoded;
|
|
1650
|
-
}
|
|
1564
|
+
let Codec$1 = class Codec extends BasicInterface$1 {
|
|
1565
|
+
codecBuffer;
|
|
1566
|
+
codec;
|
|
1567
|
+
hashAlg;
|
|
1568
|
+
constructor(buffer) {
|
|
1569
|
+
super();
|
|
1570
|
+
if (buffer) {
|
|
1571
|
+
if (buffer instanceof Uint8Array) {
|
|
1572
|
+
const codec = index$7.decode(buffer);
|
|
1573
|
+
const name = this.getCodecName(codec);
|
|
1574
|
+
if (name) {
|
|
1575
|
+
this.name = name;
|
|
1576
|
+
this.encoded = buffer;
|
|
1577
|
+
this.decode(buffer);
|
|
1578
|
+
}
|
|
1579
|
+
else {
|
|
1580
|
+
this.encode(Number(new TextDecoder().decode(buffer)));
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
else if (buffer instanceof ArrayBuffer) {
|
|
1584
|
+
const codec = index$7.decode(new Uint8Array(buffer));
|
|
1585
|
+
const name = this.getCodecName(codec);
|
|
1586
|
+
if (name) {
|
|
1587
|
+
this.name = name;
|
|
1588
|
+
this.decode(buffer);
|
|
1589
|
+
}
|
|
1590
|
+
else {
|
|
1591
|
+
this.encode(Number(new TextDecoder().decode(new Uint8Array(buffer))));
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
else if (typeof buffer === 'string') {
|
|
1595
|
+
if (utils$p.getCodec(buffer))
|
|
1596
|
+
this.fromName(buffer);
|
|
1597
|
+
else if (this.isHex(buffer))
|
|
1598
|
+
this.fromHex(buffer);
|
|
1599
|
+
else if (this.isBase32(buffer))
|
|
1600
|
+
this.fromBs32(buffer);
|
|
1601
|
+
else if (this.isBase58(buffer))
|
|
1602
|
+
this.fromBs58(buffer);
|
|
1603
|
+
else
|
|
1604
|
+
this.fromString(buffer);
|
|
1605
|
+
}
|
|
1606
|
+
if (!isNaN(buffer))
|
|
1607
|
+
if (utils$p.getCodec(buffer))
|
|
1608
|
+
this.fromCodec(buffer);
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
fromEncoded(encoded) {
|
|
1612
|
+
const codec = index$7.decode(encoded);
|
|
1613
|
+
const name = this.getCodecName(codec);
|
|
1614
|
+
this.name = name;
|
|
1615
|
+
this.encoded = encoded;
|
|
1616
|
+
return this.decode(encoded);
|
|
1617
|
+
}
|
|
1618
|
+
getCodec(name) {
|
|
1619
|
+
return utils$p.getCodec(name);
|
|
1620
|
+
}
|
|
1621
|
+
getCodecName(codec) {
|
|
1622
|
+
return utils$p.getCodecName(codec);
|
|
1623
|
+
}
|
|
1624
|
+
getHashAlg(name) {
|
|
1625
|
+
return utils$p.getHashAlg(name);
|
|
1626
|
+
}
|
|
1627
|
+
fromCodec(codec) {
|
|
1628
|
+
this.name = this.getCodecName(codec);
|
|
1629
|
+
this.hashAlg = this.getHashAlg(this.name);
|
|
1630
|
+
this.codec = this.getCodec(this.name);
|
|
1631
|
+
this.codecBuffer = index$7.encode(this.codec);
|
|
1632
|
+
}
|
|
1633
|
+
fromName(name) {
|
|
1634
|
+
const codec = this.getCodec(name);
|
|
1635
|
+
this.name = name;
|
|
1636
|
+
this.codec = codec;
|
|
1637
|
+
this.hashAlg = this.getHashAlg(name);
|
|
1638
|
+
this.codecBuffer = index$7.encode(this.codec);
|
|
1639
|
+
}
|
|
1640
|
+
decode(encoded) {
|
|
1641
|
+
encoded = encoded || this.encoded;
|
|
1642
|
+
const codec = index$7.decode(encoded);
|
|
1643
|
+
this.fromCodec(codec);
|
|
1644
|
+
return this.decoded;
|
|
1645
|
+
}
|
|
1646
|
+
encode(codec) {
|
|
1647
|
+
codec = codec || this.codec;
|
|
1648
|
+
this.encoded = index$7.encode(codec);
|
|
1649
|
+
return this.encoded;
|
|
1650
|
+
}
|
|
1651
1651
|
};
|
|
1652
1652
|
|
|
1653
|
-
let CodecHash$1 = class CodecHash extends BasicInterface$1 {
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
if (options.
|
|
1661
|
-
this.
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
await this.
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
uint8Array
|
|
1737
|
-
this.
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
if (this.
|
|
1754
|
-
this.
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
this.
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1653
|
+
let CodecHash$1 = class CodecHash extends BasicInterface$1 {
|
|
1654
|
+
codec;
|
|
1655
|
+
codecs;
|
|
1656
|
+
digest;
|
|
1657
|
+
size;
|
|
1658
|
+
constructor(buffer, options) {
|
|
1659
|
+
super();
|
|
1660
|
+
if (options.name)
|
|
1661
|
+
this.name = options.name;
|
|
1662
|
+
else
|
|
1663
|
+
this.name = 'disco-hash';
|
|
1664
|
+
if (options.codecs)
|
|
1665
|
+
this.codecs = options.codecs;
|
|
1666
|
+
return this.init(buffer);
|
|
1667
|
+
}
|
|
1668
|
+
async init(uint8Array) {
|
|
1669
|
+
if (uint8Array) {
|
|
1670
|
+
if (uint8Array instanceof Uint8Array) {
|
|
1671
|
+
this.codec = new Codec$1(uint8Array);
|
|
1672
|
+
const name = this.codec.name;
|
|
1673
|
+
if (name) {
|
|
1674
|
+
this.name = name;
|
|
1675
|
+
this.decode(uint8Array);
|
|
1676
|
+
}
|
|
1677
|
+
else {
|
|
1678
|
+
await this.encode(uint8Array);
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
if (typeof uint8Array === 'string') {
|
|
1682
|
+
if (this.isHex(uint8Array))
|
|
1683
|
+
await this.fromHex(uint8Array);
|
|
1684
|
+
if (this.isBase32(uint8Array))
|
|
1685
|
+
await this.fromBs32(uint8Array);
|
|
1686
|
+
else if (this.isBase58(uint8Array))
|
|
1687
|
+
await this.fromBs58(uint8Array);
|
|
1688
|
+
else
|
|
1689
|
+
throw new Error(`unsupported string ${uint8Array}`);
|
|
1690
|
+
}
|
|
1691
|
+
else if (typeof uint8Array === 'object')
|
|
1692
|
+
await this.fromJSON(uint8Array);
|
|
1693
|
+
}
|
|
1694
|
+
return this;
|
|
1695
|
+
}
|
|
1696
|
+
get prefix() {
|
|
1697
|
+
const length = this.length;
|
|
1698
|
+
const uint8Array = new Uint8Array(length.length + this.codec.codecBuffer.length);
|
|
1699
|
+
uint8Array.set(length);
|
|
1700
|
+
uint8Array.set(this.codec.codecBuffer, length.length);
|
|
1701
|
+
return uint8Array;
|
|
1702
|
+
}
|
|
1703
|
+
get length() {
|
|
1704
|
+
return index$7.encode(this.size);
|
|
1705
|
+
}
|
|
1706
|
+
get buffer() {
|
|
1707
|
+
return this.encoded;
|
|
1708
|
+
}
|
|
1709
|
+
get hash() {
|
|
1710
|
+
return this.encoded;
|
|
1711
|
+
}
|
|
1712
|
+
fromJSON(json) {
|
|
1713
|
+
return this.encode(new TextEncoder().encode(JSON.stringify(json)));
|
|
1714
|
+
}
|
|
1715
|
+
async encode(buffer, name) {
|
|
1716
|
+
if (!this.name && name)
|
|
1717
|
+
this.name = name;
|
|
1718
|
+
if (!buffer)
|
|
1719
|
+
buffer = this.buffer;
|
|
1720
|
+
this.codec = new Codec$1(this.name);
|
|
1721
|
+
this.codec.fromName(this.name);
|
|
1722
|
+
let hashAlg = this.codec.hashAlg;
|
|
1723
|
+
const hashVariant = Number(hashAlg.split('-')[hashAlg.split('-').length - 1]);
|
|
1724
|
+
if (hashAlg.includes('dbl')) {
|
|
1725
|
+
hashAlg = hashAlg.replace('dbl-', '');
|
|
1726
|
+
const hasher = await createKeccak(hashVariant);
|
|
1727
|
+
await hasher.init();
|
|
1728
|
+
hasher.update(buffer);
|
|
1729
|
+
buffer = hasher.digest('binary');
|
|
1730
|
+
}
|
|
1731
|
+
const hasher = await createKeccak(hashVariant);
|
|
1732
|
+
await hasher.init();
|
|
1733
|
+
hasher.update(buffer);
|
|
1734
|
+
this.digest = hasher.digest('binary');
|
|
1735
|
+
this.size = this.digest.length;
|
|
1736
|
+
const uint8Array = new Uint8Array(this.digest.length + this.prefix.length);
|
|
1737
|
+
uint8Array.set(this.prefix);
|
|
1738
|
+
uint8Array.set(this.digest, this.prefix.length);
|
|
1739
|
+
this.encoded = uint8Array;
|
|
1740
|
+
return this.encoded;
|
|
1741
|
+
}
|
|
1742
|
+
async validate(buffer) {
|
|
1743
|
+
if (Buffer.isBuffer(buffer)) {
|
|
1744
|
+
const codec = index$7.decode(buffer);
|
|
1745
|
+
if (this.codecs[codec]) {
|
|
1746
|
+
this.decode(buffer);
|
|
1747
|
+
}
|
|
1748
|
+
else {
|
|
1749
|
+
await this.encode(buffer);
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
if (typeof buffer === 'string') {
|
|
1753
|
+
if (this.isHex(buffer))
|
|
1754
|
+
this.fromHex(buffer);
|
|
1755
|
+
if (this.isBase32(buffer))
|
|
1756
|
+
this.fromBs32(buffer);
|
|
1757
|
+
}
|
|
1758
|
+
if (typeof buffer === 'object')
|
|
1759
|
+
this.fromJSON(buffer);
|
|
1760
|
+
}
|
|
1761
|
+
decode(buffer) {
|
|
1762
|
+
this.encoded = buffer;
|
|
1763
|
+
const codec = index$7.decode(buffer);
|
|
1764
|
+
this.codec = new Codec$1(codec);
|
|
1765
|
+
// TODO: validate codec
|
|
1766
|
+
buffer = buffer.slice(index$7.decode.bytes);
|
|
1767
|
+
this.size = index$7.decode(buffer);
|
|
1768
|
+
this.digest = buffer.slice(index$7.decode.bytes);
|
|
1769
|
+
if (this.digest.length !== this.size) {
|
|
1770
|
+
throw new Error(`hash length inconsistent: ${this.encoded.toString()}`);
|
|
1771
|
+
}
|
|
1772
|
+
// const codec = new Codec(codec, this.codecs)
|
|
1773
|
+
this.name = this.codec.name;
|
|
1774
|
+
this.size = this.digest.length;
|
|
1775
|
+
return {
|
|
1776
|
+
codec: this.codec,
|
|
1777
|
+
name: this.name,
|
|
1778
|
+
size: this.size,
|
|
1779
|
+
length: this.length,
|
|
1780
|
+
digest: this.digest,
|
|
1781
|
+
};
|
|
1782
|
+
}
|
|
1781
1783
|
};
|
|
1782
1784
|
|
|
1783
|
-
let FormatInterface$1 = class FormatInterface extends BasicInterface$1 {
|
|
1784
|
-
hashFormat;
|
|
1785
|
-
init(buffer) {
|
|
1786
|
-
if (buffer instanceof Uint8Array)
|
|
1787
|
-
this.fromUint8Array(buffer);
|
|
1788
|
-
else if (buffer instanceof ArrayBuffer)
|
|
1789
|
-
this.fromArrayBuffer(buffer);
|
|
1790
|
-
else if (buffer instanceof FormatInterface$1 && buffer?.name === this.name)
|
|
1791
|
-
return buffer;
|
|
1792
|
-
else if (typeof buffer === 'string') {
|
|
1793
|
-
if (this.isHex(buffer))
|
|
1794
|
-
this.fromHex(buffer);
|
|
1795
|
-
else if (this.isBase58(buffer))
|
|
1796
|
-
this.fromBs58(buffer);
|
|
1797
|
-
else if (this.isBase32(buffer))
|
|
1798
|
-
this.fromBs32(buffer);
|
|
1799
|
-
else
|
|
1800
|
-
this.fromString(buffer);
|
|
1801
|
-
}
|
|
1802
|
-
else {
|
|
1803
|
-
this.create(buffer);
|
|
1804
|
-
}
|
|
1805
|
-
return this;
|
|
1806
|
-
}
|
|
1807
|
-
hasCodec() {
|
|
1808
|
-
if (!this.encoded)
|
|
1809
|
-
return false;
|
|
1810
|
-
const codec = new Codec$1(this.encoded);
|
|
1811
|
-
if (codec.name)
|
|
1812
|
-
return true;
|
|
1813
|
-
}
|
|
1814
|
-
decode(encoded) {
|
|
1815
|
-
encoded = encoded || this.encoded;
|
|
1816
|
-
const codec = new Codec$1(this.encoded);
|
|
1817
|
-
if (codec.codecBuffer) {
|
|
1818
|
-
encoded = encoded.slice(codec.codecBuffer.length);
|
|
1819
|
-
this.name = codec.name;
|
|
1820
|
-
this.decoded = this.protoDecode(encoded);
|
|
1821
|
-
// try {
|
|
1822
|
-
// this.decoded = JSON.parse(this.decoded)
|
|
1823
|
-
// } catch {
|
|
1824
|
-
// }
|
|
1825
|
-
}
|
|
1826
|
-
else {
|
|
1827
|
-
throw new Error(`no codec found`);
|
|
1828
|
-
}
|
|
1829
|
-
return this.decoded;
|
|
1830
|
-
}
|
|
1831
|
-
encode(decoded) {
|
|
1832
|
-
let encoded;
|
|
1833
|
-
if (!decoded)
|
|
1834
|
-
decoded = this.decoded;
|
|
1835
|
-
const codec = new Codec$1(this.name);
|
|
1836
|
-
if (decoded instanceof Uint8Array)
|
|
1837
|
-
encoded = decoded;
|
|
1838
|
-
else
|
|
1839
|
-
encoded = this.protoEncode(decoded);
|
|
1840
|
-
if (codec.codecBuffer) {
|
|
1841
|
-
const uint8Array = new Uint8Array(encoded.length + codec.codecBuffer.length);
|
|
1842
|
-
uint8Array.set(codec.codecBuffer);
|
|
1843
|
-
uint8Array.set(encoded, codec.codecBuffer.length);
|
|
1844
|
-
this.encoded = uint8Array;
|
|
1845
|
-
}
|
|
1846
|
-
else {
|
|
1847
|
-
throw new Error(`invalid codec`);
|
|
1848
|
-
}
|
|
1849
|
-
return this.encoded;
|
|
1850
|
-
}
|
|
1851
|
-
/**
|
|
1852
|
-
* @param {Buffer|String|Object} buffer - data - The data needed to create the desired message
|
|
1853
|
-
* @param {Object} proto - {protoObject}
|
|
1854
|
-
* @param {Object} options - {hashFormat, name}
|
|
1855
|
-
*/
|
|
1856
|
-
constructor(buffer, proto, options) {
|
|
1857
|
-
super();
|
|
1858
|
-
this.proto = proto;
|
|
1859
|
-
this.hashFormat = options?.hashFormat ? options.hashFormat : 'bs32';
|
|
1860
|
-
if (options?.name)
|
|
1861
|
-
this.name = options.name;
|
|
1862
|
-
this.init(buffer);
|
|
1863
|
-
}
|
|
1864
|
-
/**
|
|
1865
|
-
* @return {PeernetHash}
|
|
1866
|
-
*/
|
|
1867
|
-
get peernetHash() {
|
|
1868
|
-
return new CodecHash$1(this.decoded, { name: this.name });
|
|
1869
|
-
}
|
|
1870
|
-
/**
|
|
1871
|
-
* @return {peernetHash}
|
|
1872
|
-
*/
|
|
1873
|
-
async hash() {
|
|
1874
|
-
const upper = this.hashFormat.charAt(0).toUpperCase();
|
|
1875
|
-
const format = `${upper}${this.hashFormat.substring(1, this.hashFormat.length)}`;
|
|
1876
|
-
return (await this.peernetHash)[`to${format}`]();
|
|
1877
|
-
}
|
|
1878
|
-
fromUint8Array(buffer) {
|
|
1879
|
-
this.encoded = buffer;
|
|
1880
|
-
return this.hasCodec() ? this.decode() : this.create(JSON.parse(new TextDecoder().decode(this.encoded)));
|
|
1881
|
-
}
|
|
1882
|
-
fromArrayBuffer(buffer) {
|
|
1883
|
-
this.encoded = new Uint8Array(buffer, buffer.byteOffset, buffer.byteLength);
|
|
1884
|
-
return this.hasCodec() ? this.decode() : this.create(JSON.parse(new TextDecoder().decode(this.encoded)));
|
|
1885
|
-
}
|
|
1886
|
-
/**
|
|
1887
|
-
* @param {Object} data
|
|
1888
|
-
*/
|
|
1889
|
-
create(data) {
|
|
1890
|
-
const decoded = {};
|
|
1891
|
-
if (this.keys?.length > 0) {
|
|
1892
|
-
for (const key of this.keys) {
|
|
1893
|
-
Object.defineProperties(decoded, {
|
|
1894
|
-
[key]: {
|
|
1895
|
-
enumerable: true,
|
|
1896
|
-
configurable: true,
|
|
1897
|
-
set: (value) => data[key],
|
|
1898
|
-
get: () => data[key]
|
|
1899
|
-
}
|
|
1900
|
-
});
|
|
1901
|
-
}
|
|
1902
|
-
this.decoded = decoded;
|
|
1903
|
-
return this.encode(decoded);
|
|
1904
|
-
}
|
|
1905
|
-
}
|
|
1785
|
+
let FormatInterface$1 = class FormatInterface extends BasicInterface$1 {
|
|
1786
|
+
hashFormat;
|
|
1787
|
+
init(buffer) {
|
|
1788
|
+
if (buffer instanceof Uint8Array)
|
|
1789
|
+
this.fromUint8Array(buffer);
|
|
1790
|
+
else if (buffer instanceof ArrayBuffer)
|
|
1791
|
+
this.fromArrayBuffer(buffer);
|
|
1792
|
+
else if (buffer instanceof FormatInterface$1 && buffer?.name === this.name)
|
|
1793
|
+
return buffer;
|
|
1794
|
+
else if (typeof buffer === 'string') {
|
|
1795
|
+
if (this.isHex(buffer))
|
|
1796
|
+
this.fromHex(buffer);
|
|
1797
|
+
else if (this.isBase58(buffer))
|
|
1798
|
+
this.fromBs58(buffer);
|
|
1799
|
+
else if (this.isBase32(buffer))
|
|
1800
|
+
this.fromBs32(buffer);
|
|
1801
|
+
else
|
|
1802
|
+
this.fromString(buffer);
|
|
1803
|
+
}
|
|
1804
|
+
else {
|
|
1805
|
+
this.create(buffer);
|
|
1806
|
+
}
|
|
1807
|
+
return this;
|
|
1808
|
+
}
|
|
1809
|
+
hasCodec() {
|
|
1810
|
+
if (!this.encoded)
|
|
1811
|
+
return false;
|
|
1812
|
+
const codec = new Codec$1(this.encoded);
|
|
1813
|
+
if (codec.name)
|
|
1814
|
+
return true;
|
|
1815
|
+
}
|
|
1816
|
+
decode(encoded) {
|
|
1817
|
+
encoded = encoded || this.encoded;
|
|
1818
|
+
const codec = new Codec$1(this.encoded);
|
|
1819
|
+
if (codec.codecBuffer) {
|
|
1820
|
+
encoded = encoded.slice(codec.codecBuffer.length);
|
|
1821
|
+
this.name = codec.name;
|
|
1822
|
+
this.decoded = this.protoDecode(encoded);
|
|
1823
|
+
// try {
|
|
1824
|
+
// this.decoded = JSON.parse(this.decoded)
|
|
1825
|
+
// } catch {
|
|
1826
|
+
// }
|
|
1827
|
+
}
|
|
1828
|
+
else {
|
|
1829
|
+
throw new Error(`no codec found`);
|
|
1830
|
+
}
|
|
1831
|
+
return this.decoded;
|
|
1832
|
+
}
|
|
1833
|
+
encode(decoded) {
|
|
1834
|
+
let encoded;
|
|
1835
|
+
if (!decoded)
|
|
1836
|
+
decoded = this.decoded;
|
|
1837
|
+
const codec = new Codec$1(this.name);
|
|
1838
|
+
if (decoded instanceof Uint8Array)
|
|
1839
|
+
encoded = decoded;
|
|
1840
|
+
else
|
|
1841
|
+
encoded = this.protoEncode(decoded);
|
|
1842
|
+
if (codec.codecBuffer) {
|
|
1843
|
+
const uint8Array = new Uint8Array(encoded.length + codec.codecBuffer.length);
|
|
1844
|
+
uint8Array.set(codec.codecBuffer);
|
|
1845
|
+
uint8Array.set(encoded, codec.codecBuffer.length);
|
|
1846
|
+
this.encoded = uint8Array;
|
|
1847
|
+
}
|
|
1848
|
+
else {
|
|
1849
|
+
throw new Error(`invalid codec`);
|
|
1850
|
+
}
|
|
1851
|
+
return this.encoded;
|
|
1852
|
+
}
|
|
1853
|
+
/**
|
|
1854
|
+
* @param {Buffer|String|Object} buffer - data - The data needed to create the desired message
|
|
1855
|
+
* @param {Object} proto - {protoObject}
|
|
1856
|
+
* @param {Object} options - {hashFormat, name}
|
|
1857
|
+
*/
|
|
1858
|
+
constructor(buffer, proto, options) {
|
|
1859
|
+
super();
|
|
1860
|
+
this.proto = proto;
|
|
1861
|
+
this.hashFormat = options?.hashFormat ? options.hashFormat : 'bs32';
|
|
1862
|
+
if (options?.name)
|
|
1863
|
+
this.name = options.name;
|
|
1864
|
+
this.init(buffer);
|
|
1865
|
+
}
|
|
1866
|
+
/**
|
|
1867
|
+
* @return {PeernetHash}
|
|
1868
|
+
*/
|
|
1869
|
+
get peernetHash() {
|
|
1870
|
+
return new CodecHash$1(this.decoded, { name: this.name });
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* @return {peernetHash}
|
|
1874
|
+
*/
|
|
1875
|
+
async hash() {
|
|
1876
|
+
const upper = this.hashFormat.charAt(0).toUpperCase();
|
|
1877
|
+
const format = `${upper}${this.hashFormat.substring(1, this.hashFormat.length)}`;
|
|
1878
|
+
return (await this.peernetHash)[`to${format}`]();
|
|
1879
|
+
}
|
|
1880
|
+
fromUint8Array(buffer) {
|
|
1881
|
+
this.encoded = buffer;
|
|
1882
|
+
return this.hasCodec() ? this.decode() : this.create(JSON.parse(new TextDecoder().decode(this.encoded)));
|
|
1883
|
+
}
|
|
1884
|
+
fromArrayBuffer(buffer) {
|
|
1885
|
+
this.encoded = new Uint8Array(buffer, buffer.byteOffset, buffer.byteLength);
|
|
1886
|
+
return this.hasCodec() ? this.decode() : this.create(JSON.parse(new TextDecoder().decode(this.encoded)));
|
|
1887
|
+
}
|
|
1888
|
+
/**
|
|
1889
|
+
* @param {Object} data
|
|
1890
|
+
*/
|
|
1891
|
+
create(data) {
|
|
1892
|
+
const decoded = {};
|
|
1893
|
+
if (this.keys?.length > 0) {
|
|
1894
|
+
for (const key of this.keys) {
|
|
1895
|
+
Object.defineProperties(decoded, {
|
|
1896
|
+
[key]: {
|
|
1897
|
+
enumerable: true,
|
|
1898
|
+
configurable: true,
|
|
1899
|
+
set: (value) => data[key],
|
|
1900
|
+
get: () => data[key]
|
|
1901
|
+
}
|
|
1902
|
+
});
|
|
1903
|
+
}
|
|
1904
|
+
this.decoded = decoded;
|
|
1905
|
+
return this.encode(decoded);
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1906
1908
|
};
|
|
1907
|
-
const FormatInterface = FormatInterface$1;
|
|
1909
|
+
const FormatInterface = FormatInterface$1;
|
|
1908
1910
|
const Codec = Codec$1;
|
|
1909
1911
|
|
|
1910
1912
|
const BufferToUint8Array = data => {
|
|
@@ -16059,6 +16061,15 @@ class Identity {
|
|
|
16059
16061
|
return JSON.parse(accounts);
|
|
16060
16062
|
}
|
|
16061
16063
|
async load(password) {
|
|
16064
|
+
if (password && password.includes('.txt')) {
|
|
16065
|
+
const { readFile } = await import('fs/promises');
|
|
16066
|
+
try {
|
|
16067
|
+
password = (await readFile(password)).toString();
|
|
16068
|
+
}
|
|
16069
|
+
catch (error) {
|
|
16070
|
+
console.error(error);
|
|
16071
|
+
}
|
|
16072
|
+
}
|
|
16062
16073
|
if (!password) {
|
|
16063
16074
|
const importee = await import('./src/prompts/password.js');
|
|
16064
16075
|
password = await importee.default();
|
|
@@ -16071,7 +16082,7 @@ class Identity {
|
|
|
16071
16082
|
globalThis.peernet.selectedAccount = new TextDecoder().decode(selected);
|
|
16072
16083
|
}
|
|
16073
16084
|
else {
|
|
16074
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-
|
|
16085
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-88c7fc2e.js');
|
|
16075
16086
|
const { identity, accounts } = await importee.default(password, this.network);
|
|
16076
16087
|
await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
|
|
16077
16088
|
await globalThis.walletStore.put('version', String(1));
|
|
@@ -16237,7 +16248,7 @@ class Peernet {
|
|
|
16237
16248
|
this.root = options.root;
|
|
16238
16249
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
16239
16250
|
// FolderMessageResponse
|
|
16240
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-
|
|
16251
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-ba0fcf7e.js');
|
|
16241
16252
|
/**
|
|
16242
16253
|
* proto Object containing protos
|
|
16243
16254
|
* @type {Object}
|
|
@@ -16286,7 +16297,7 @@ class Peernet {
|
|
|
16286
16297
|
* @see DataHandler
|
|
16287
16298
|
*/
|
|
16288
16299
|
pubsub.subscribe('peer:data', dataHandler);
|
|
16289
|
-
const importee = await import('./client-
|
|
16300
|
+
const importee = await import('./client-cbaadd55.js');
|
|
16290
16301
|
/**
|
|
16291
16302
|
* @access public
|
|
16292
16303
|
* @type {PeernetClient}
|
|
@@ -16730,4 +16741,4 @@ class Peernet {
|
|
|
16730
16741
|
}
|
|
16731
16742
|
globalThis.Peernet = Peernet;
|
|
16732
16743
|
|
|
16733
|
-
export { FormatInterface as F, LittlePubSub as L, MultiWallet as M, Peernet as P, base58$1 as b,
|
|
16744
|
+
export { FormatInterface as F, LittlePubSub as L, MultiWallet as M, Peernet as P, base58$1 as b, encrypt as e };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { P as default } from './peernet-
|
|
1
|
+
export { P as default } from './peernet-6a78293a.js';
|
|
2
2
|
import './value-157ab062.js';
|
package/exports/peernet.js
CHANGED
|
@@ -319,6 +319,15 @@ class Identity {
|
|
|
319
319
|
return JSON.parse(accounts);
|
|
320
320
|
}
|
|
321
321
|
async load(password) {
|
|
322
|
+
if (password && password.includes('.txt')) {
|
|
323
|
+
const { readFile } = await import('fs/promises');
|
|
324
|
+
try {
|
|
325
|
+
password = (await readFile(password)).toString();
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
console.error(error);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
322
331
|
if (!password) {
|
|
323
332
|
const importee = await import('./src/prompts/password.js');
|
|
324
333
|
password = await importee.default();
|
package/package.json
CHANGED
package/src/identity.ts
CHANGED
|
@@ -23,7 +23,16 @@ export default class Identity {
|
|
|
23
23
|
return JSON.parse(accounts)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
async load(password?: string): Promise<void> {
|
|
26
|
+
async load(password?: string): Promise<void> {
|
|
27
|
+
if (password && password.includes('.txt')) {
|
|
28
|
+
|
|
29
|
+
const { readFile } = await import('fs/promises')
|
|
30
|
+
try {
|
|
31
|
+
password = (await readFile(password)).toString()
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error(error)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
27
36
|
if (!password) {
|
|
28
37
|
const importee: { default: () => Promise<string> } = await import('./prompts/password.js')
|
|
29
38
|
password = await importee.default()
|