wireweave 0.3.9 → 0.3.11
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/bans.js +5 -2
- package/src/debug.js +4 -4
- package/src/pages.js +12 -2
package/package.json
CHANGED
package/src/bans.js
CHANGED
|
@@ -55,13 +55,16 @@ export class Bans extends EventTarget {
|
|
|
55
55
|
if (!creator) return;
|
|
56
56
|
this.sub = 'bans-' + serverId;
|
|
57
57
|
this.pool.subscribe(this.sub,
|
|
58
|
-
[{ kinds: [30078], authors: [creator], '#
|
|
58
|
+
[{ kinds: [30078], authors: [creator], '#server': [serverId] }],
|
|
59
59
|
(event) => {
|
|
60
60
|
if (event.pubkey !== creator) return;
|
|
61
61
|
try {
|
|
62
62
|
const dTag = event.tags.find(t => t[0] === 'd');
|
|
63
63
|
if (!dTag?.[1]) return;
|
|
64
|
-
const
|
|
64
|
+
const parts = dTag[1].split(':');
|
|
65
|
+
const prefix = parts[0];
|
|
66
|
+
const pubkey = parts[parts.length - 1];
|
|
67
|
+
if (prefix !== 'zellous-ban' && prefix !== 'zellous-timeout') return;
|
|
65
68
|
const data = this.store.get(serverId) || { banned: [], timeouts: {} };
|
|
66
69
|
if (prefix === 'zellous-ban' && pubkey && !data.banned.includes(pubkey)) data.banned.push(pubkey);
|
|
67
70
|
else if (prefix === 'zellous-timeout' && pubkey) {
|
package/src/debug.js
CHANGED
|
@@ -3,15 +3,15 @@ const registry = new Map();
|
|
|
3
3
|
export const register = (key, obj) => {
|
|
4
4
|
registry.set(key, obj);
|
|
5
5
|
if (typeof window !== 'undefined') {
|
|
6
|
-
window.
|
|
7
|
-
window.
|
|
6
|
+
window.__wireweave = window.__wireweave || {};
|
|
7
|
+
window.__wireweave[key] = obj;
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export const deregister = (key) => {
|
|
12
12
|
registry.delete(key);
|
|
13
|
-
if (typeof window !== 'undefined' && window.
|
|
14
|
-
delete window.
|
|
13
|
+
if (typeof window !== 'undefined' && window.__wireweave) {
|
|
14
|
+
delete window.__wireweave[key];
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
|
package/src/pages.js
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
const stripTags = (html) => html
|
|
2
|
+
.replace(/<\s*(script|iframe|object|embed|form|input|button)\b[^>]*>[\s\S]*?<\s*\/\s*\1\s*>/gi, '')
|
|
3
|
+
.replace(/<\s*(script|iframe|object|embed|form|input|button)\b[^>]*\/?\s*>/gi, '')
|
|
4
|
+
.replace(/\son[a-z]+\s*=\s*"[^"]*"/gi, '')
|
|
5
|
+
.replace(/\son[a-z]+\s*=\s*'[^']*'/gi, '')
|
|
6
|
+
.replace(/\son[a-z]+\s*=\s*[^\s>]+/gi, '')
|
|
7
|
+
.replace(/(href|src)\s*=\s*"\s*javascript:[^"]*"/gi, '$1="#"')
|
|
8
|
+
.replace(/(href|src)\s*=\s*'\s*javascript:[^']*'/gi, "$1='#'");
|
|
9
|
+
|
|
1
10
|
const sanitize = (html) => {
|
|
2
|
-
|
|
11
|
+
const stripped = stripTags(html);
|
|
12
|
+
if (typeof document === 'undefined') return stripped;
|
|
3
13
|
const el = document.createElement('div');
|
|
4
|
-
el.innerHTML =
|
|
14
|
+
el.innerHTML = stripped;
|
|
5
15
|
el.querySelectorAll('script,iframe,object,embed,form,input,button').forEach(n => n.remove());
|
|
6
16
|
el.querySelectorAll('*').forEach(n => {
|
|
7
17
|
[...n.attributes].forEach(a => {
|