@leofcoin/peernet 1.2.30 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/exports/browser/browser-CCfR9KOM.js +147 -0
- package/exports/browser/client-CAC7RVMf.js +2224 -0
- package/exports/browser/identity-Cf8KKnho.js +8522 -0
- package/exports/browser/identity.js +1 -1
- package/exports/browser/index-dTQVgkpf.js +37 -0
- package/exports/browser/messages-Dw86z0zq.js +212 -0
- package/exports/browser/peernet-B2jRhqGI.js +9684 -0
- package/exports/browser/peernet.js +2 -2
- package/package.json +3 -3
- package/test/peernet.test.js +37 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/peernet",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -105,11 +105,11 @@
|
|
|
105
105
|
"license": "MIT",
|
|
106
106
|
"packageManager": "npm@11.17.0",
|
|
107
107
|
"dependencies": {
|
|
108
|
-
"@leofcoin/codec-format-interface": "^
|
|
108
|
+
"@leofcoin/codec-format-interface": "^2.0.0",
|
|
109
109
|
"@leofcoin/codecs": "^1.1.2",
|
|
110
110
|
"@leofcoin/generate-account": "^2.0.3",
|
|
111
111
|
"@leofcoin/identity-utils": "^1.0.2",
|
|
112
|
-
"@leofcoin/multi-wallet": "^3.1.
|
|
112
|
+
"@leofcoin/multi-wallet": "^3.1.11",
|
|
113
113
|
"@leofcoin/storage": "^3.5.38",
|
|
114
114
|
"@mapbox/node-pre-gyp": "^2.0.3",
|
|
115
115
|
"@netpeer/swarm": "^0.9.12",
|
package/test/peernet.test.js
CHANGED
|
@@ -10,6 +10,7 @@ import { promisify } from 'node:util'
|
|
|
10
10
|
import Peernet from '../exports/peernet.js'
|
|
11
11
|
import Identity, { resolveAccountWallets } from '../exports/identity.js'
|
|
12
12
|
import MultiWallet from '@leofcoin/multi-wallet'
|
|
13
|
+
import { Codec, CodecHash } from '@leofcoin/codec-format-interface'
|
|
13
14
|
import { fromBase58, toBase58 } from '@vandeurenglenn/typed-array-utils'
|
|
14
15
|
|
|
15
16
|
const options = {
|
|
@@ -54,6 +55,42 @@ test('exposes identity instance', () => {
|
|
|
54
55
|
assert.ok(peernet.identity instanceof Identity)
|
|
55
56
|
})
|
|
56
57
|
|
|
58
|
+
test('built peernet messages use canonical codec-first hashes', async () => {
|
|
59
|
+
const message = new peernet.protos['peernet-ps']({ data: new Uint8Array([1, 2, 3]), topic: new Uint8Array([4]) })
|
|
60
|
+
const hash = new CodecHash()
|
|
61
|
+
hash.fromBs32(await message.hash())
|
|
62
|
+
assert.equal(hash.name, 'peernet-ps')
|
|
63
|
+
assert.equal(hash.size, hash.digest.length)
|
|
64
|
+
const codec = new Codec('peernet-ps').encode()
|
|
65
|
+
assert.deepEqual(hash.encoded.subarray(0, codec.length), codec)
|
|
66
|
+
assert.deepEqual(hash.encoded, new Uint8Array([...codec, ...hash.length, ...hash.digest]))
|
|
67
|
+
const roundTrip = new peernet.protos['peernet-ps'](message.encoded)
|
|
68
|
+
assert.equal(await roundTrip.hash(), hash.toBs32())
|
|
69
|
+
assert.deepEqual(roundTrip.decoded.data, message.decoded.data)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
test('hash parser rejects old length-first peernet content addresses', async () => {
|
|
73
|
+
const message = new peernet.protos['peernet-ps']({ data: new Uint8Array([1, 2, 3]), topic: new Uint8Array([4]) })
|
|
74
|
+
const hash = new CodecHash()
|
|
75
|
+
hash.fromBs32(await message.hash())
|
|
76
|
+
const previousFormat = new Uint8Array([...hash.length, ...hash.codec, ...hash.digest])
|
|
77
|
+
assert.throws(() => new CodecHash().decode(previousFormat))
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
test('release dependency graph contains only codec 2.x and no Git varint fallback', async () => {
|
|
81
|
+
const manifest = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'))
|
|
82
|
+
const lock = JSON.parse(await readFile(new URL('../package-lock.json', import.meta.url), 'utf8'))
|
|
83
|
+
assert.equal(manifest.dependencies['@leofcoin/codec-format-interface'], '^2.0.0')
|
|
84
|
+
assert.equal(lock.packages[''].version, manifest.version)
|
|
85
|
+
const codecs = Object.entries(lock.packages).filter(([name]) => name.endsWith('/@leofcoin/codec-format-interface'))
|
|
86
|
+
assert.equal(codecs.length, 1)
|
|
87
|
+
assert.equal(codecs[0][1].version, '2.0.0')
|
|
88
|
+
for (const [name, entry] of Object.entries(lock.packages)) {
|
|
89
|
+
assert.ok(!name.endsWith('/varint'), name)
|
|
90
|
+
assert.ok(!/^(git\+|git:|github:|file:)/.test(entry.resolved ?? ''), name)
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
|
|
57
94
|
test('freshIdentity replaces a persisted identity and signer', async () => {
|
|
58
95
|
const originalId = peernet.id
|
|
59
96
|
const originalAccount = peernet.selectedAccount
|