hypercore-signing-request 2.0.0 → 3.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/index.js +12 -14
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -6,31 +6,29 @@ const c = require('compact-encoding')
|
|
|
6
6
|
|
|
7
7
|
const VERSION = 1
|
|
8
8
|
|
|
9
|
-
const FramedManifest = c.frame(m.manifest)
|
|
10
|
-
|
|
11
9
|
const Request = {
|
|
12
10
|
preencode (state, req) {
|
|
13
11
|
c.uint.preencode(state, req.version)
|
|
14
|
-
FramedManifest.preencode(state, req.manifest)
|
|
15
|
-
c.fixed32.preencode(state, req.treeHash)
|
|
16
12
|
c.uint.preencode(state, req.length)
|
|
17
13
|
c.uint.preencode(state, req.fork)
|
|
14
|
+
c.fixed32.preencode(state, req.treeHash)
|
|
15
|
+
m.manifest.preencode(state, req.manifest)
|
|
18
16
|
},
|
|
19
17
|
encode (state, req) {
|
|
20
18
|
c.uint.encode(state, req.version)
|
|
21
|
-
FramedManifest.encode(state, req.manifest)
|
|
22
|
-
c.fixed32.encode(state, req.treeHash)
|
|
23
19
|
c.uint.encode(state, req.length)
|
|
24
20
|
c.uint.encode(state, req.fork)
|
|
21
|
+
c.fixed32.encode(state, req.treeHash)
|
|
22
|
+
m.manifest.encode(state, req.manifest)
|
|
25
23
|
},
|
|
26
24
|
decode (state) {
|
|
27
25
|
const version = c.uint.decode(state)
|
|
28
26
|
if (version !== VERSION) throw new Error('Unknown signing request version: ' + version)
|
|
29
27
|
|
|
30
|
-
const manifest = FramedManifest.decode(state)
|
|
31
|
-
const treeHash = c.fixed32.decode(state)
|
|
32
28
|
const length = c.uint.decode(state)
|
|
33
29
|
const fork = c.uint.decode(state)
|
|
30
|
+
const treeHash = c.fixed32.decode(state)
|
|
31
|
+
const manifest = m.manifest.decode(state)
|
|
34
32
|
|
|
35
33
|
const key = Verifier.manifestHash(manifest)
|
|
36
34
|
const id = HypercoreID.normalize(key)
|
|
@@ -39,10 +37,10 @@ const Request = {
|
|
|
39
37
|
version,
|
|
40
38
|
id,
|
|
41
39
|
key,
|
|
42
|
-
manifest,
|
|
43
|
-
treeHash,
|
|
44
40
|
length,
|
|
45
|
-
fork
|
|
41
|
+
fork,
|
|
42
|
+
treeHash,
|
|
43
|
+
manifest
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
}
|
|
@@ -53,10 +51,10 @@ module.exports = {
|
|
|
53
51
|
|
|
54
52
|
return c.encode(Request, {
|
|
55
53
|
version: VERSION,
|
|
56
|
-
manifest: core.manifest,
|
|
57
|
-
treeHash: await core.treeHash(length),
|
|
58
54
|
length,
|
|
59
|
-
fork
|
|
55
|
+
fork,
|
|
56
|
+
treeHash: await core.treeHash(length),
|
|
57
|
+
manifest: core.manifest
|
|
60
58
|
})
|
|
61
59
|
},
|
|
62
60
|
decode (buffer) {
|