wireweave 0.1.3 → 0.1.5
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/README.md +3 -0
- package/package.json +5 -3
- package/src/bans.js +36 -2
- package/src/servers.js +9 -0
- package/src/wireweave.js +1 -1
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wireweave",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "nostr + webrtc voice SDK. networking layer for 247420 projects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"LICENSE"
|
|
30
30
|
],
|
|
31
31
|
"scripts": {
|
|
32
|
-
"test": "node test.js"
|
|
32
|
+
"test": "node test.js",
|
|
33
|
+
"site:build": "node site/build.js"
|
|
33
34
|
},
|
|
34
35
|
"repository": {
|
|
35
36
|
"type": "git",
|
|
@@ -48,11 +49,12 @@
|
|
|
48
49
|
"bugs": {
|
|
49
50
|
"url": "https://github.com/AnEntrypoint/wireweave/issues"
|
|
50
51
|
},
|
|
51
|
-
"homepage": "https://github.
|
|
52
|
+
"homepage": "https://anentrypoint.github.io/wireweave/",
|
|
52
53
|
"peerDependencies": {
|
|
53
54
|
"nostr-tools": "^2.7.0"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
57
|
+
"flatspace": "^1.0.13",
|
|
56
58
|
"nostr-tools": "^2.7.0",
|
|
57
59
|
"ws": "^8.18.0"
|
|
58
60
|
},
|
package/src/bans.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export class Bans extends EventTarget {
|
|
2
|
-
constructor({ relayPool }) {
|
|
2
|
+
constructor({ relayPool, auth = null, roles = null }) {
|
|
3
3
|
super();
|
|
4
4
|
if (!relayPool) throw new Error('Bans: relayPool required');
|
|
5
|
-
this.pool = relayPool;
|
|
5
|
+
this.pool = relayPool; this.auth = auth; this.roles = roles;
|
|
6
6
|
this.store = new Map();
|
|
7
7
|
this.sub = null;
|
|
8
8
|
}
|
|
@@ -14,6 +14,40 @@ export class Bans extends EventTarget {
|
|
|
14
14
|
return !!t && t.expiry > Math.floor(Date.now() / 1000);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
async ban(serverId, pubkey) {
|
|
18
|
+
if (!this.auth?.isLoggedIn()) throw new Error('Not logged in');
|
|
19
|
+
if (this.roles && !this.roles.isAdmin(serverId)) throw new Error('Insufficient permissions');
|
|
20
|
+
const dTag = 'zellous-ban:' + serverId + ':' + pubkey;
|
|
21
|
+
const signed = await this.auth.sign({
|
|
22
|
+
kind: 30078, created_at: Math.floor(Date.now() / 1000),
|
|
23
|
+
tags: [['d', dTag], ['server', serverId]],
|
|
24
|
+
content: JSON.stringify({ action: 'ban', pubkey, timestamp: Math.floor(Date.now() / 1000) })
|
|
25
|
+
});
|
|
26
|
+
this.pool.publish(signed);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async timeout(serverId, pubkey, minutes) {
|
|
30
|
+
if (!this.auth?.isLoggedIn()) throw new Error('Not logged in');
|
|
31
|
+
if (this.roles && !this.roles.isAdmin(serverId)) throw new Error('Insufficient permissions');
|
|
32
|
+
const expiry = Math.floor(Date.now() / 1000) + (minutes * 60);
|
|
33
|
+
const dTag = 'zellous-timeout:' + serverId + ':' + pubkey;
|
|
34
|
+
const signed = await this.auth.sign({
|
|
35
|
+
kind: 30078, created_at: Math.floor(Date.now() / 1000),
|
|
36
|
+
tags: [['d', dTag], ['server', serverId]],
|
|
37
|
+
content: JSON.stringify({ action: 'timeout', pubkey, expiry })
|
|
38
|
+
});
|
|
39
|
+
this.pool.publish(signed);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async kickFromVoice(pubkey) {
|
|
43
|
+
if (!this.auth?.isLoggedIn()) throw new Error('Not logged in');
|
|
44
|
+
const signed = await this.auth.sign({
|
|
45
|
+
kind: 30078, created_at: Math.floor(Date.now() / 1000),
|
|
46
|
+
tags: [['d', 'zellous-kick:' + pubkey]], content: ''
|
|
47
|
+
});
|
|
48
|
+
this.pool.publish(signed);
|
|
49
|
+
}
|
|
50
|
+
|
|
17
51
|
subscribe(serverId) {
|
|
18
52
|
if (this.sub) { this.pool.unsubscribe(this.sub); this.sub = null; }
|
|
19
53
|
if (!serverId) return;
|
package/src/servers.js
CHANGED
|
@@ -41,6 +41,15 @@ export class Servers extends EventTarget {
|
|
|
41
41
|
this._emit('updated', { servers: this.servers });
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
async rename(serverId, name, iconColor = '#5865F2') {
|
|
45
|
+
if (!serverId?.startsWith(this.auth.pubkey + ':')) throw new Error('Only owner can rename');
|
|
46
|
+
const dTag = serverId.split(':')[1];
|
|
47
|
+
const signed = await this.auth.sign({ kind: 34550, created_at: Math.floor(Date.now() / 1000), tags: [['d', dTag], ['name', name], ['color', iconColor]], content: '' });
|
|
48
|
+
this.pool.publish(signed);
|
|
49
|
+
const s = this.servers.find(x => x.id === serverId);
|
|
50
|
+
if (s) { s.name = name; s.iconColor = iconColor; this.servers = [...this.servers]; this._persist(); this._emit('updated', { servers: this.servers }); }
|
|
51
|
+
}
|
|
52
|
+
|
|
44
53
|
async create(name, iconColor = '#5865F2') {
|
|
45
54
|
const dTag = Math.random().toString(36).slice(2, 10);
|
|
46
55
|
const serverId = this.auth.pubkey + ':' + dTag;
|
package/src/wireweave.js
CHANGED
|
@@ -29,8 +29,8 @@ export const createWireweave = ({
|
|
|
29
29
|
const pool = createRelayPool({ relays, verifyEvent: nostrTools.verifyEvent, WebSocketImpl });
|
|
30
30
|
const auth = createAuth({ nostrTools, storage, extension });
|
|
31
31
|
const message = createMessageBus();
|
|
32
|
-
const bans = createBans({ relayPool: pool });
|
|
33
32
|
const roles = createRoles({ relayPool: pool, auth });
|
|
33
|
+
const bans = createBans({ relayPool: pool, auth, roles });
|
|
34
34
|
const settings = createSettings({ relayPool: pool, auth, roles });
|
|
35
35
|
const pages = createPages({ relayPool: pool, auth, roles });
|
|
36
36
|
const media = createMedia({ relayPool: pool, auth });
|