@leofcoin/peernet 0.18.4 → 0.18.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-bcc5fcc2.js → client-185cbc7f.js} +1 -1
- package/exports/browser/{index-b1a03d93.js → index-53a6455f.js} +1 -1
- package/exports/browser/{index-d7584e0e.js → index-9bf6b3b4.js} +2 -2
- package/exports/browser/{messages-bc8f619c.js → messages-9ae8a6d0.js} +1 -1
- package/exports/browser/{peernet-0418c064.js → peernet-b0cce194.js} +37 -34
- package/exports/browser/peernet.js +1 -1
- package/exports/store.js +6 -2
- 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-b0cce194.js';
|
|
2
2
|
import './value-40634404.js';
|
|
3
3
|
|
|
4
4
|
const randombytes = strength => crypto.getRandomValues(new Uint8Array(strength));
|
|
@@ -1395,10 +1395,14 @@ const addCodec = (codecInput) => {
|
|
|
1395
1395
|
if (!globalThis.peernetCodecs[name])
|
|
1396
1396
|
globalThis.peernetCodecs[name] = {
|
|
1397
1397
|
hashAlg,
|
|
1398
|
-
codec: parseInt(codec, 16)
|
|
1398
|
+
codec: typeof codec === 'string' ? parseInt(codec, 16) : codec
|
|
1399
1399
|
};
|
|
1400
1400
|
};
|
|
1401
|
-
const getCodec = (name) =>
|
|
1401
|
+
const getCodec = (name) => {
|
|
1402
|
+
if (typeof name === 'number')
|
|
1403
|
+
return name;
|
|
1404
|
+
return getCodecByName(name).codec;
|
|
1405
|
+
};
|
|
1402
1406
|
const getCodecName = (codec) => {
|
|
1403
1407
|
return Object.keys(globalThis.peernetCodecs).reduce((p, c) => {
|
|
1404
1408
|
const item = globalThis.peernetCodecs[c];
|
|
@@ -1535,26 +1539,6 @@ let BasicInterface$1 = class BasicInterface {
|
|
|
1535
1539
|
this.encode();
|
|
1536
1540
|
return toBase58(this.encoded);
|
|
1537
1541
|
}
|
|
1538
|
-
/**
|
|
1539
|
-
* @param {Object} data
|
|
1540
|
-
*/
|
|
1541
|
-
create(data) {
|
|
1542
|
-
const decoded = {};
|
|
1543
|
-
if (this.keys?.length > 0) {
|
|
1544
|
-
for (const key of this.keys) {
|
|
1545
|
-
Object.defineProperties(decoded, {
|
|
1546
|
-
[key]: {
|
|
1547
|
-
enumerable: true,
|
|
1548
|
-
configurable: true,
|
|
1549
|
-
set: (value) => data[key],
|
|
1550
|
-
get: () => data[key]
|
|
1551
|
-
}
|
|
1552
|
-
});
|
|
1553
|
-
}
|
|
1554
|
-
this.decoded = decoded;
|
|
1555
|
-
return this.encode(decoded);
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
1542
|
};
|
|
1559
1543
|
|
|
1560
1544
|
let Codec$1 = class Codec extends BasicInterface$1 {
|
|
@@ -1573,7 +1557,7 @@ let Codec$1 = class Codec extends BasicInterface$1 {
|
|
|
1573
1557
|
this.decode(buffer);
|
|
1574
1558
|
}
|
|
1575
1559
|
else {
|
|
1576
|
-
this.encode(buffer);
|
|
1560
|
+
this.encode(Number(new TextDecoder().decode(buffer)));
|
|
1577
1561
|
}
|
|
1578
1562
|
}
|
|
1579
1563
|
else if (buffer instanceof ArrayBuffer) {
|
|
@@ -1584,7 +1568,7 @@ let Codec$1 = class Codec extends BasicInterface$1 {
|
|
|
1584
1568
|
this.decode(buffer);
|
|
1585
1569
|
}
|
|
1586
1570
|
else {
|
|
1587
|
-
this.encode(buffer);
|
|
1571
|
+
this.encode(Number(new TextDecoder().decode(new Uint8Array(buffer))));
|
|
1588
1572
|
}
|
|
1589
1573
|
}
|
|
1590
1574
|
else if (typeof buffer === 'string') {
|
|
@@ -1597,7 +1581,7 @@ let Codec$1 = class Codec extends BasicInterface$1 {
|
|
|
1597
1581
|
else if (this.isBase58(buffer))
|
|
1598
1582
|
this.fromBs58(buffer);
|
|
1599
1583
|
else
|
|
1600
|
-
|
|
1584
|
+
this.fromString(buffer);
|
|
1601
1585
|
}
|
|
1602
1586
|
if (!isNaN(buffer))
|
|
1603
1587
|
if (utils.getCodec(buffer))
|
|
@@ -1624,14 +1608,14 @@ let Codec$1 = class Codec extends BasicInterface$1 {
|
|
|
1624
1608
|
this.name = this.getCodecName(codec);
|
|
1625
1609
|
this.hashAlg = this.getHashAlg(this.name);
|
|
1626
1610
|
this.codec = this.getCodec(this.name);
|
|
1627
|
-
this.codecBuffer = index$6.encode(codec);
|
|
1611
|
+
this.codecBuffer = index$6.encode(this.codec);
|
|
1628
1612
|
}
|
|
1629
1613
|
fromName(name) {
|
|
1630
1614
|
const codec = this.getCodec(name);
|
|
1631
1615
|
this.name = name;
|
|
1632
1616
|
this.codec = codec;
|
|
1633
1617
|
this.hashAlg = this.getHashAlg(name);
|
|
1634
|
-
this.codecBuffer = index$6.encode(codec);
|
|
1618
|
+
this.codecBuffer = index$6.encode(this.codec);
|
|
1635
1619
|
}
|
|
1636
1620
|
decode(encoded) {
|
|
1637
1621
|
encoded = encoded || this.encoded;
|
|
@@ -1785,7 +1769,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface$1 {
|
|
|
1785
1769
|
this.fromArrayBuffer(buffer);
|
|
1786
1770
|
else if (buffer instanceof FormatInterface$1 && buffer?.name === this.name)
|
|
1787
1771
|
return buffer;
|
|
1788
|
-
else if (buffer
|
|
1772
|
+
else if (typeof buffer === 'string') {
|
|
1789
1773
|
if (this.isHex(buffer))
|
|
1790
1774
|
this.fromHex(buffer);
|
|
1791
1775
|
else if (this.isBase58(buffer))
|
|
@@ -1793,7 +1777,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface$1 {
|
|
|
1793
1777
|
else if (this.isBase32(buffer))
|
|
1794
1778
|
this.fromBs32(buffer);
|
|
1795
1779
|
else
|
|
1796
|
-
|
|
1780
|
+
this.fromString(buffer);
|
|
1797
1781
|
}
|
|
1798
1782
|
else {
|
|
1799
1783
|
this.create(buffer);
|
|
@@ -1879,6 +1863,26 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface$1 {
|
|
|
1879
1863
|
this.encoded = new Uint8Array(buffer, buffer.byteOffset, buffer.byteLength);
|
|
1880
1864
|
return this.hasCodec() ? this.decode() : this.create(JSON.parse(new TextDecoder().decode(this.encoded)));
|
|
1881
1865
|
}
|
|
1866
|
+
/**
|
|
1867
|
+
* @param {Object} data
|
|
1868
|
+
*/
|
|
1869
|
+
create(data) {
|
|
1870
|
+
const decoded = {};
|
|
1871
|
+
if (this.keys?.length > 0) {
|
|
1872
|
+
for (const key of this.keys) {
|
|
1873
|
+
Object.defineProperties(decoded, {
|
|
1874
|
+
[key]: {
|
|
1875
|
+
enumerable: true,
|
|
1876
|
+
configurable: true,
|
|
1877
|
+
set: (value) => data[key],
|
|
1878
|
+
get: () => data[key]
|
|
1879
|
+
}
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1882
|
+
this.decoded = decoded;
|
|
1883
|
+
return this.encode(decoded);
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1882
1886
|
};
|
|
1883
1887
|
const FormatInterface = FormatInterface$1;
|
|
1884
1888
|
const Codec = Codec$1;
|
|
@@ -2146,7 +2150,7 @@ class MessageHandler {
|
|
|
2146
2150
|
let identity = await walletStore.get('identity');
|
|
2147
2151
|
identity = JSON.parse(identity);
|
|
2148
2152
|
if (!globalThis.MultiWallet) {
|
|
2149
|
-
const importee = await import(/* webpackChunkName: "multi-wallet" */ './index-
|
|
2153
|
+
const importee = await import(/* webpackChunkName: "multi-wallet" */ './index-53a6455f.js');
|
|
2150
2154
|
globalThis.MultiWallet = importee.default;
|
|
2151
2155
|
}
|
|
2152
2156
|
const wallet = new MultiWallet(this.network);
|
|
@@ -2334,7 +2338,6 @@ class LeofcoinStorage {
|
|
|
2334
2338
|
async size() {
|
|
2335
2339
|
let size = 0;
|
|
2336
2340
|
const query = await this.db.iterate();
|
|
2337
|
-
console.log(query);
|
|
2338
2341
|
for await (const item of query) {
|
|
2339
2342
|
size += item.value ? item.value.length : item[1].length;
|
|
2340
2343
|
}
|
|
@@ -2472,7 +2475,7 @@ class Peernet {
|
|
|
2472
2475
|
this.root = options.root;
|
|
2473
2476
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
2474
2477
|
// FolderMessageResponse
|
|
2475
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-
|
|
2478
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-9ae8a6d0.js');
|
|
2476
2479
|
/**
|
|
2477
2480
|
* proto Object containing protos
|
|
2478
2481
|
* @type {Object}
|
|
@@ -2520,7 +2523,7 @@ class Peernet {
|
|
|
2520
2523
|
}
|
|
2521
2524
|
}
|
|
2522
2525
|
else {
|
|
2523
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-
|
|
2526
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-9bf6b3b4.js');
|
|
2524
2527
|
const generateAccount = importee.default;
|
|
2525
2528
|
const { identity, accounts, config } = await generateAccount(this.network);
|
|
2526
2529
|
// await accountStore.put('config', JSON.stringify(config));
|
|
@@ -2549,7 +2552,7 @@ class Peernet {
|
|
|
2549
2552
|
* @see DataHandler
|
|
2550
2553
|
*/
|
|
2551
2554
|
pubsub.subscribe('peer:data', dataHandler);
|
|
2552
|
-
const importee = await import('./client-
|
|
2555
|
+
const importee = await import('./client-185cbc7f.js');
|
|
2553
2556
|
/**
|
|
2554
2557
|
* @access public
|
|
2555
2558
|
* @type {PeernetClient}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { P as default } from './peernet-
|
|
1
|
+
export { P as default } from './peernet-b0cce194.js';
|
|
2
2
|
import './value-40634404.js';
|
package/exports/store.js
CHANGED
|
@@ -179,8 +179,12 @@ class Store {
|
|
|
179
179
|
return value.uint8Array
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
toUint8Array(buffer) {
|
|
183
|
+
return Buffer.isBuffer(buffer) ? new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength / Uint8Array.BYTES_PER_ELEMENT) : buffer
|
|
184
|
+
}
|
|
185
|
+
|
|
182
186
|
async get(key) {
|
|
183
|
-
return this.db.get(this.toKeyPath(key))
|
|
187
|
+
return this.toUint8Array(await this.db.get(this.toKeyPath(key)))
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
async put(key, value) {
|
|
@@ -198,7 +202,7 @@ class Store {
|
|
|
198
202
|
async values(limit = -1) {
|
|
199
203
|
const values = [];
|
|
200
204
|
for await (const value of this.db.values({limit})) {
|
|
201
|
-
values.push(value);
|
|
205
|
+
values.push(this.toUint8Array(value));
|
|
202
206
|
}
|
|
203
207
|
return values
|
|
204
208
|
}
|