trac-peer 0.0.45 → 0.0.47
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 +3 -3
- package/src/functions.js +3 -3
- package/src/index.js +7 -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.47",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"autobase": "7.1.1",
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
"hyperdht": "6.19.0",
|
|
18
18
|
"hyperswarm": "4.8.4",
|
|
19
19
|
"is-options": "1.0.2",
|
|
20
|
-
"minimist-string": "^1.0.2",
|
|
21
20
|
"pear-interface": "1.0.0",
|
|
22
21
|
"protomux-wakeup": "^2.2.1",
|
|
23
22
|
"ready-resource": "^1.0.0",
|
|
24
23
|
"safety-catch": "1.0.2",
|
|
25
24
|
"sodium-native": "^4.3.3",
|
|
26
25
|
"trac-wallet": "^0.0.4",
|
|
27
|
-
"xache": "1.2.0"
|
|
26
|
+
"xache": "1.2.0",
|
|
27
|
+
"yargs": "^17.7.2"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"registry": "https://registry.npmjs.org",
|
package/src/functions.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import yargs from 'yargs/yargs';
|
|
2
2
|
|
|
3
3
|
export function resolveNumberString(number, decimals){
|
|
4
4
|
number = number + '';
|
|
@@ -104,7 +104,7 @@ export function jsonStringify(value){
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
export async function setNick(input, peer){
|
|
107
|
-
const splitted =
|
|
107
|
+
const splitted = yargs(input).parse();
|
|
108
108
|
const value = splitted.nick;
|
|
109
109
|
const nonce = Math.random() + '-' + Date.now();
|
|
110
110
|
const signature = { dispatch : {
|
|
@@ -117,7 +117,7 @@ export async function setNick(input, peer){
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
export async function postMessage(input, peer){
|
|
120
|
-
const splitted =
|
|
120
|
+
const splitted = yargs(input).parse();
|
|
121
121
|
const value = splitted.message;
|
|
122
122
|
const nonce = Math.random() + '-' + Date.now();
|
|
123
123
|
const signature = { dispatch : {
|
package/src/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import {createHash} from "node:crypto";
|
|
|
10
10
|
import w from 'protomux-wakeup';
|
|
11
11
|
const wakeup = new w();
|
|
12
12
|
import {addWriter, addAdmin, setAutoAddWriters, setChatStatus,
|
|
13
|
-
postMessage, jsonStringify, visibleLength} from "./functions.js";
|
|
13
|
+
postMessage, jsonStringify, visibleLength, setNick} from "./functions.js";
|
|
14
14
|
export {default as Protocol} from "./protocol.js";
|
|
15
15
|
export {default as Contract} from "./contract.js";
|
|
16
16
|
export {default as Feature} from "./feature.js";
|
|
@@ -457,6 +457,7 @@ export class Peer extends ReadyResource {
|
|
|
457
457
|
console.log('- /set_auto_add_writers: Only admin. Use "on" or "off" as 2nd parameter to allow/disallow peers automatically being added as writers.');
|
|
458
458
|
console.log('- /set_chat_status: Only admin. Use "on" or "off" as 2nd parameter to enable/disable the built-in chat system.');
|
|
459
459
|
console.log('- /post: Post a message like \'/post --message "Hello"\'. Chat must be enabled.');
|
|
460
|
+
console.log('- /set_nick: Change your nickname like this \'/set_nick --nick "Peter"\'. Chat must be enabled.');
|
|
460
461
|
console.log('- /dag: check system properties such as writer key, DAG, etc.');
|
|
461
462
|
console.log('- /get_keys: prints your key pair. Be careful and never share!');
|
|
462
463
|
console.log('- /exit: Exit the program');
|
|
@@ -483,11 +484,13 @@ export class Peer extends ReadyResource {
|
|
|
483
484
|
await addAdmin(input, this);
|
|
484
485
|
} else if (input.startsWith('/set_auto_add_writers')) {
|
|
485
486
|
await setAutoAddWriters(input, this);
|
|
486
|
-
}
|
|
487
|
+
} else if (input.startsWith('/set_chat_status')) {
|
|
487
488
|
await setChatStatus(input, this);
|
|
488
|
-
}
|
|
489
|
+
} else if (input.startsWith('/post')) {
|
|
489
490
|
await postMessage(input, this);
|
|
490
|
-
}
|
|
491
|
+
} else if (input.startsWith('/set_nick')) {
|
|
492
|
+
await setNick(input, this);
|
|
493
|
+
} else {
|
|
491
494
|
this.protocol_instance.execute(input);
|
|
492
495
|
}
|
|
493
496
|
}
|