trac-peer 0.0.2 → 0.0.4
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/package.json +1 -1
- package/src/index.js +4 -4
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -20,7 +20,7 @@ export class Peer extends ReadyResource {
|
|
|
20
20
|
constructor(options = {}) {
|
|
21
21
|
super();
|
|
22
22
|
this.STORES_DIRECTORY = options.stores_directory;
|
|
23
|
-
this.KEY_PAIR_PATH = `${this.STORES_DIRECTORY}${options.store_name}/keypair.json`;
|
|
23
|
+
this.KEY_PAIR_PATH = `${this.STORES_DIRECTORY}${options.store_name}/db/keypair.json`;
|
|
24
24
|
this.keyPair = null;
|
|
25
25
|
this.store = new Corestore(this.STORES_DIRECTORY + options.store_name);
|
|
26
26
|
this.msb = options.msb || null;
|
|
@@ -91,7 +91,7 @@ export class Peer extends ReadyResource {
|
|
|
91
91
|
} else if (op.type === 'addIndexer') {
|
|
92
92
|
const admin = await view.get('admin');
|
|
93
93
|
if(null !== admin && op.value.msg.key === op.key && op.value.msg.type === 'addIndexer') {
|
|
94
|
-
const verified = _this.wallet.verify(JSON.stringify(op.value.msg),
|
|
94
|
+
const verified = _this.wallet.verify(op.value.hash, JSON.stringify(op.value.msg), admin.value);
|
|
95
95
|
if(verified){
|
|
96
96
|
const writerKey = b4a.from(op.key, 'hex');
|
|
97
97
|
await base.addWriter(writerKey);
|
|
@@ -101,7 +101,7 @@ export class Peer extends ReadyResource {
|
|
|
101
101
|
} else if (op.type === 'addWriter') {
|
|
102
102
|
const admin = await view.get('admin');
|
|
103
103
|
if(null !== admin && op.value.msg.key === op.key && op.value.msg.type === 'addWriter') {
|
|
104
|
-
const verified = _this.wallet.verify(JSON.stringify(op.value.msg),
|
|
104
|
+
const verified = _this.wallet.verify(op.value.hash, JSON.stringify(op.value.msg), admin.value);
|
|
105
105
|
if(verified){
|
|
106
106
|
const writerKey = b4a.from(op.key, 'hex');
|
|
107
107
|
await base.addWriter(writerKey, { isIndexer : false });
|
|
@@ -113,7 +113,7 @@ export class Peer extends ReadyResource {
|
|
|
113
113
|
if(null !== admin && op.value.msg.key === op.key &&
|
|
114
114
|
op.value.msg.type === 'setAutoAddWriters' &&
|
|
115
115
|
(op.key === 'on' || op.key === 'off')) {
|
|
116
|
-
const verified = _this.wallet.verify(JSON.stringify(op.value.msg),
|
|
116
|
+
const verified = _this.wallet.verify(op.value.hash, JSON.stringify(op.value.msg), admin.value);
|
|
117
117
|
if(verified){
|
|
118
118
|
await view.put('auto_add_writers', op.key);
|
|
119
119
|
console.log(`Set auto_add_writers: ${op.key}`);
|