hypercore-signing-request 3.0.2 → 3.1.1

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.
Files changed (2) hide show
  1. package/index.js +6 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -46,18 +46,19 @@ const Request = {
46
46
  }
47
47
 
48
48
  module.exports = {
49
- async generate (core, { length = core.length, fork = core.fork } = {}) {
49
+ async generate (core, { length = core.length, fork = core.fork, manifest = null } = {}) {
50
50
  if (!core.opened) await core.ready()
51
51
 
52
- if (core.core.compat) throw new Error('Cannot generate signing requests for compat cores')
52
+ if (core.core.compat && !manifest) throw new Error('Cannot generate signing requests for compat cores')
53
53
  if (core.fork !== fork) throw new Error('Core should have the same fork')
54
+ if (!manifest) manifest = core.manifest
54
55
 
55
56
  return c.encode(Request, {
56
57
  version: VERSION,
57
58
  length,
58
59
  fork,
59
60
  treeHash: await core.treeHash(length),
60
- manifest: core.manifest
61
+ manifest
61
62
  })
62
63
  },
63
64
  decode (buffer) {
@@ -70,9 +71,10 @@ module.exports = {
70
71
  return req
71
72
  },
72
73
  signable (pub, req) {
74
+ const v = req.manifest.version
73
75
  for (const s of req.manifest.signers) {
74
76
  if (s.publicKey.equals(pub)) {
75
- return caps.treeSignable(s.namespace, req.treeHash, req.length, req.fork)
77
+ return caps.treeSignable(v === 0 ? s.namespace : req.key, req.treeHash, req.length, req.fork)
76
78
  }
77
79
  }
78
80
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-signing-request",
3
- "version": "3.0.2",
3
+ "version": "3.1.1",
4
4
  "description": "Generate shareable signing requests for Hypercore",
5
5
  "main": "index.js",
6
6
  "scripts": {