trac-peer 0.0.82 → 0.0.83
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 +2 -2
- package/src/functions.js +0 -2
- package/src/index.js +1 -3
- package/src/protocol.js +3 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trac-peer",
|
|
3
3
|
"main": "src/index.js",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.83",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"autobase": "7.0.45",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"ready-resource": "^1.0.0",
|
|
24
24
|
"safety-catch": "1.0.2",
|
|
25
25
|
"sodium-native": "^4.3.3",
|
|
26
|
-
"trac-wallet": "^0.0.
|
|
26
|
+
"trac-wallet": "^0.0.30",
|
|
27
27
|
"xache": "1.2.0",
|
|
28
28
|
"bare-assert": "^1.0.2",
|
|
29
29
|
"bare-buffer": "^3.1.2",
|
package/src/functions.js
CHANGED
package/src/index.js
CHANGED
|
@@ -3,12 +3,10 @@ import Autobase from 'autobase';
|
|
|
3
3
|
import Hyperswarm from 'hyperswarm';
|
|
4
4
|
import ReadyResource from 'ready-resource';
|
|
5
5
|
import b4a from 'b4a';
|
|
6
|
-
import {Buffer} from "buffer"
|
|
7
6
|
import Hyperbee from 'hyperbee';
|
|
8
7
|
import readline from 'readline';
|
|
9
8
|
import tty from 'tty'
|
|
10
9
|
import Corestore from 'corestore';
|
|
11
|
-
import {createHash} from "crypto";
|
|
12
10
|
import w from 'protomux-wakeup';
|
|
13
11
|
const wakeup = new w();
|
|
14
12
|
import {addWriter, addAdmin, setAutoAddWriters, setChatStatus, setMod, deleteMessage,
|
|
@@ -90,7 +88,7 @@ export class Peer extends ReadyResource {
|
|
|
90
88
|
if (null !== str_dispatch &&
|
|
91
89
|
null === await batch.get('tx/'+op.key) &&
|
|
92
90
|
post_tx.value.tx === op.key &&
|
|
93
|
-
post_tx.value.ch === createHash('sha256').update(str_dispatch).digest('hex') &&
|
|
91
|
+
post_tx.value.ch === crypto.createHash('sha256').update(str_dispatch).digest('hex') &&
|
|
94
92
|
false !== await _this.contract_instance.execute(op, node, batch)) {
|
|
95
93
|
let len = await batch.get('txl');
|
|
96
94
|
if(null === len) {
|
package/src/protocol.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { formatNumberString, resolveNumberString } from "./functions.js";
|
|
2
|
-
import {createHash} from "crypto";
|
|
3
2
|
|
|
4
3
|
class Protocol{
|
|
5
4
|
constructor(options = {}) {
|
|
@@ -70,14 +69,14 @@ class Protocol{
|
|
|
70
69
|
{
|
|
71
70
|
this.nonce = Math.random() + '-' + Date.now();
|
|
72
71
|
const MSBwriter = writer;
|
|
73
|
-
const content_hash = createHash('sha256').update(JSON.stringify(obj)).digest('hex');
|
|
74
|
-
let tx = createHash('sha256').update(
|
|
72
|
+
const content_hash = crypto.createHash('sha256').update(JSON.stringify(obj)).digest('hex');
|
|
73
|
+
let tx = crypto.createHash('sha256').update(
|
|
75
74
|
MSBwriter + '-' +
|
|
76
75
|
this.peer.writerLocalKey + '-' +
|
|
77
76
|
this.peer.wallet.publicKey + '-' +
|
|
78
77
|
content_hash + '-' +
|
|
79
78
|
this.nonce).digest('hex');
|
|
80
|
-
tx = createHash('sha256').update(tx).digest('hex');
|
|
79
|
+
tx = crypto.createHash('sha256').update(tx).digest('hex');
|
|
81
80
|
const signature = this.peer.wallet.sign(tx + this.nonce);
|
|
82
81
|
this.peer.emit('tx', {
|
|
83
82
|
op: 'pre-tx',
|