@peerbit/server 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/lib/esm/cli.js +67 -20
- package/lib/esm/cli.js.map +1 -1
- package/lib/esm/client.d.ts +7 -1
- package/lib/esm/client.js +48 -31
- package/lib/esm/client.js.map +1 -1
- package/lib/esm/config.d.ts +3 -3
- package/lib/esm/config.js +18 -16
- package/lib/esm/config.js.map +1 -1
- package/lib/esm/peerbit.d.ts +2 -0
- package/lib/esm/peerbit.js +1 -0
- package/lib/esm/peerbit.js.map +1 -1
- package/lib/esm/remotes.d.ts +1 -2
- package/lib/esm/remotes.js +1 -2
- package/lib/esm/remotes.js.map +1 -1
- package/lib/esm/routes.d.ts +1 -0
- package/lib/esm/routes.js +1 -0
- package/lib/esm/routes.js.map +1 -1
- package/lib/esm/server.d.ts +2 -6
- package/lib/esm/server.js +161 -176
- package/lib/esm/server.js.map +1 -1
- package/lib/esm/signes-request.d.ts +5 -0
- package/lib/esm/signes-request.js +54 -0
- package/lib/esm/signes-request.js.map +1 -0
- package/lib/esm/trust.browser.d.ts +0 -0
- package/lib/esm/trust.browser.js +3 -0
- package/lib/esm/trust.browser.js.map +1 -0
- package/lib/esm/trust.d.ts +9 -0
- package/lib/esm/trust.js +36 -0
- package/lib/esm/trust.js.map +1 -0
- package/lib/ui/assets/index-cac7195d.js +77 -0
- package/lib/ui/index.html +1 -1
- package/package.json +4 -4
- package/src/cli.ts +81 -25
- package/src/client.ts +77 -35
- package/src/config.ts +21 -23
- package/src/peerbit.ts +3 -0
- package/src/remotes.ts +1 -3
- package/src/routes.ts +1 -1
- package/src/server.ts +205 -241
- package/src/signes-request.ts +84 -0
- package/src/trust.browser.ts +1 -0
- package/src/trust.ts +39 -0
- package/lib/ui/assets/index-73eaa3bc.js +0 -53
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// Not supported
|
package/src/trust.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
export class Trust {
|
|
4
|
+
private trusted: string[];
|
|
5
|
+
constructor(readonly path: string) {
|
|
6
|
+
if (fs.existsSync(path)) {
|
|
7
|
+
this.trusted = JSON.parse(
|
|
8
|
+
fs.readFileSync(path).toString("utf-8")
|
|
9
|
+
) as string[];
|
|
10
|
+
} else {
|
|
11
|
+
this.trusted = [];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
save() {
|
|
16
|
+
fs.writeFileSync(this.path, JSON.stringify(this.trusted));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
isTrusted(hashcode: string) {
|
|
20
|
+
return this.trusted.includes(hashcode);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
add(key: string) {
|
|
24
|
+
if (this.isTrusted(key)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this.trusted.push(key);
|
|
28
|
+
this.save();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
remove(hashcode: string) {
|
|
32
|
+
const existing = this.trusted.findIndex((x) => (x = hashcode));
|
|
33
|
+
if (existing >= 0) {
|
|
34
|
+
this.trusted.splice(existing, 1);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|