@voltro/plugin-chat 0.90.0 → 0.91.1
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/CHANGELOG.md +131 -0
- package/THIRD-PARTY-NOTICES.md +247 -1418
- package/dist/index.js +53 -53
- package/dist/inspect.js +4 -4
- package/dist/mentionNotifications.js +12 -12
- package/dist/server.js +4 -4
- package/dist/service.js +745 -745
- package/dist/typing.js +40 -40
- package/dist/typingInvalidation.js +1 -1
- package/dist/web.js +5 -5
- package/package.json +18 -18
package/dist/typing.js
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createTypingInvalidation as e } from "./typingInvalidation.js";
|
|
2
2
|
import { CHAT_TYPING_TTL_MS as t, ChatTypingSchema as n } from "./contract.js";
|
|
3
|
-
import {
|
|
3
|
+
import { chatError as r } from "./errors.js";
|
|
4
4
|
import { typing as i } from "./events.js";
|
|
5
5
|
import { Effect as a, Schema as o } from "effect";
|
|
6
6
|
import { createHash as s } from "node:crypto";
|
|
7
7
|
// src/typing.ts
|
|
8
8
|
var c = (c) => {
|
|
9
|
-
let l = (
|
|
10
|
-
if (!
|
|
11
|
-
let
|
|
12
|
-
if (!
|
|
13
|
-
return
|
|
14
|
-
}, u = (
|
|
15
|
-
try:
|
|
16
|
-
catch: () =>
|
|
17
|
-
}), d = (
|
|
9
|
+
let l = (e) => {
|
|
10
|
+
if (!e || typeof e != "object" || Array.isArray(e)) throw r("invalid_input");
|
|
11
|
+
let t = Object.getOwnPropertyDescriptor(e, "channelId");
|
|
12
|
+
if (!t || !("value" in t) || typeof t.value != "string" || !t.value.trim() || t.value.length > 256 || t.value.includes("\0") || t.value === "~") throw r("invalid_input");
|
|
13
|
+
return t.value;
|
|
14
|
+
}, u = (e) => a.try({
|
|
15
|
+
try: e,
|
|
16
|
+
catch: () => r("invalid_input")
|
|
17
|
+
}), d = (e, n) => {
|
|
18
18
|
let i, o, d;
|
|
19
19
|
try {
|
|
20
|
-
i = structuredClone(
|
|
21
|
-
let t = Object.getOwnPropertyDescriptor(
|
|
22
|
-
if (!t || !("value" in t) || typeof t.value != "boolean") throw
|
|
20
|
+
i = structuredClone(e), o = l(n);
|
|
21
|
+
let t = Object.getOwnPropertyDescriptor(n, "active");
|
|
22
|
+
if (!t || !("value" in t) || typeof t.value != "boolean") throw r("invalid_input");
|
|
23
23
|
d = t.value;
|
|
24
24
|
} catch {
|
|
25
|
-
return a.fail(
|
|
25
|
+
return a.fail(r("invalid_input"));
|
|
26
26
|
}
|
|
27
27
|
return a.gen(function* () {
|
|
28
|
-
let
|
|
29
|
-
if (
|
|
28
|
+
let e = yield* c.readAccess(i, o), n = yield* u(c.now), l = yield* c.social;
|
|
29
|
+
if (e.channel.kind === "dm" && !l) return yield* a.fail(r("forbidden"));
|
|
30
30
|
if (d) {
|
|
31
|
-
if (
|
|
32
|
-
if (
|
|
31
|
+
if (e.channel.frozen) return yield* a.fail(r("frozen"));
|
|
32
|
+
if (e.member.mutedUntil !== null && e.member.mutedUntil > n) return yield* a.fail(r("muted"));
|
|
33
33
|
yield* c.sanctioned(i, o);
|
|
34
34
|
}
|
|
35
35
|
let f = c.options.strategies.rateLimit({
|
|
36
|
-
channel:
|
|
36
|
+
channel: e.channel,
|
|
37
37
|
perChannel: c.options.perChannelRate,
|
|
38
38
|
global: c.options.globalRate
|
|
39
39
|
});
|
|
40
|
-
if (![f.perChannel, f.global].every((e) => Number.isSafeInteger(e) && e > 0 && e <= 1e4)) return yield* a.fail(
|
|
40
|
+
if (![f.perChannel, f.global].every((e) => Number.isSafeInteger(e) && e > 0 && e <= 1e4)) return yield* a.fail(r("unavailable"));
|
|
41
41
|
for (let [t, l] of [[[
|
|
42
42
|
i.tenantId,
|
|
43
|
-
|
|
43
|
+
e.member.subjectId,
|
|
44
44
|
o
|
|
45
|
-
], f.perChannel], [[i.tenantId,
|
|
46
|
-
let
|
|
45
|
+
], f.perChannel], [[i.tenantId, e.member.subjectId], f.global]]) {
|
|
46
|
+
let e = s("sha256").update(JSON.stringify(t)).digest("hex"), i = yield* c.limiter.consume("chat:typing:" + e, {
|
|
47
47
|
limit: l,
|
|
48
48
|
windowMs: 1e3,
|
|
49
49
|
algorithm: "fixed-window",
|
|
50
50
|
burst: l
|
|
51
|
-
},
|
|
52
|
-
if (i.failOpenReason !== void 0) return yield* a.fail(
|
|
53
|
-
if (!i.allowed) return yield* a.fail(
|
|
51
|
+
}, n).pipe(a.mapError(() => r("unavailable")), a.catchDefect(() => a.fail(r("unavailable"))));
|
|
52
|
+
if (i.failOpenReason !== void 0) return yield* a.fail(r("unavailable"));
|
|
53
|
+
if (!i.allowed) return yield* a.fail(r("rate_limited"));
|
|
54
54
|
}
|
|
55
|
-
let p = d ?
|
|
56
|
-
return !Number.isSafeInteger(p) || p > 864e13 ? yield* a.fail(
|
|
57
|
-
subjectId:
|
|
55
|
+
let p = d ? n + t : n;
|
|
56
|
+
return !Number.isSafeInteger(p) || p > 864e13 ? yield* a.fail(r("unavailable")) : Object.freeze({
|
|
57
|
+
subjectId: e.member.subjectId,
|
|
58
58
|
active: d,
|
|
59
59
|
expiresAt: p
|
|
60
60
|
});
|
|
61
|
-
}).pipe(a.catchDefect(() => a.fail(
|
|
61
|
+
}).pipe(a.catchDefect(() => a.fail(r("unavailable"))));
|
|
62
62
|
}, f = (e) => a.gen(function* () {
|
|
63
63
|
if (e.event !== i.name) return !1;
|
|
64
64
|
let t = yield* u(() => l(e.key));
|
|
65
65
|
return yield* c.readAccess(e.subject, t), !0;
|
|
66
|
-
}).pipe(a.catch(() => a.succeed(!1)), a.catchDefect(() => a.succeed(!1))), p = (
|
|
67
|
-
if (
|
|
68
|
-
let
|
|
66
|
+
}).pipe(a.catch(() => a.succeed(!1)), a.catchDefect(() => a.succeed(!1))), p = (e) => a.gen(function* () {
|
|
67
|
+
if (e.event !== i.name) return "deny";
|
|
68
|
+
let t = yield* u(() => l(e.key)), s = yield* o.decodeUnknownEffect(n)(e.payload).pipe(a.mapError(() => r("invalid_input"))), d = yield* c.readAccess(e.subject, t, s.subjectId), f = yield* u(c.now);
|
|
69
69
|
if (s.subjectId === d.member.subjectId || d.peer === null || !Number.isSafeInteger(s.expiresAt) || s.expiresAt > f + 5e3 || s.expiresAt < f - 5e3 || s.active && s.expiresAt <= f || s.active && (d.channel.frozen || d.peer.mutedUntil !== null && d.peer.mutedUntil > f)) return "drop";
|
|
70
70
|
let p = yield* c.social;
|
|
71
|
-
return d.channel.kind === "dm" && !p ? "deny" : p && (yield* p.isBlocked(
|
|
72
|
-
}).pipe(a.catch(() => a.succeed("deny")), a.catchDefect(() => a.succeed("deny"))), m =
|
|
71
|
+
return d.channel.kind === "dm" && !p ? "deny" : p && (yield* p.isBlocked(e.subject, s.subjectId).pipe(a.mapError(() => r("unavailable")))) ? "drop" : "allow";
|
|
72
|
+
}).pipe(a.catch(() => a.succeed("deny")), a.catchDefect(() => a.succeed("deny"))), m = e(c.store);
|
|
73
73
|
return {
|
|
74
74
|
prepare: d,
|
|
75
75
|
policy: {
|
|
76
76
|
id: i.clientPolicy,
|
|
77
77
|
admit: f,
|
|
78
78
|
deliver: p,
|
|
79
|
-
monitor: (
|
|
80
|
-
if (
|
|
81
|
-
return l(
|
|
82
|
-
}).pipe(a.flatMap((
|
|
79
|
+
monitor: (e) => u(() => {
|
|
80
|
+
if (e.event !== i.name) throw r("forbidden");
|
|
81
|
+
return l(e.key);
|
|
82
|
+
}).pipe(a.flatMap((t) => m(structuredClone(e.subject), t)))
|
|
83
83
|
},
|
|
84
84
|
close: m.close
|
|
85
85
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { chatError as e } from "./errors.js";
|
|
2
1
|
import "./contract.js";
|
|
2
|
+
import { chatError as e } from "./errors.js";
|
|
3
3
|
import { Deferred as t, Effect as n } from "effect";
|
|
4
4
|
import { socialRelationsTable as r } from "@voltro/plugin-social";
|
|
5
5
|
// src/typingInvalidation.ts
|
package/dist/web.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BASE_NAME as e } from "./rpc.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { ChannelTabs as t, ChatPanel as n, Composer as r, MessageList as i, TypingIndicator as a, chatLabels as o, chatMentionLabels as s, chatTypingLabels as c } from "./components.js";
|
|
3
|
+
import { useTyping as l } from "./useTyping.js";
|
|
4
|
+
import { useChatTypingPublisher as u } from "./useChatTypingPublisher.js";
|
|
5
|
+
import { chatMessageSegments as d } from "./messageLinks.js";
|
|
6
6
|
import { pluginTag as f } from "@voltro/protocol";
|
|
7
7
|
import { useAction as p, useSubscription as m } from "@voltro/client";
|
|
8
8
|
// src/web.ts
|
|
@@ -16,4 +16,4 @@ var h = (t, n, r = "app") => m(r, f(e, "mentionCandidates"), {
|
|
|
16
16
|
channelId: t,
|
|
17
17
|
...n === void 0 ? {} : { before: n }
|
|
18
18
|
}), x = (t = "app") => p(t, f(e, "send")), S = (t = "app") => p(t, f(e, "edit")), C = (t = "app") => p(t, f(e, "remove")), w = (t = "app") => m(t, f(e, "unread"), {}), T = (t = "app") => p(t, f(e, "markRead")), E = (t = "app") => p(t, f(e, "original")), D = (t = "app") => p(t, f(e, "join")), O = (t = "app") => p(t, f(e, "dm")), k = (t = "app") => p(t, f(e, "leave")), A = (t = "app") => p(t, f(e, "transferOwnership")), j = (t = "app") => p(t, f(e, "setTyping")), M = (t = "app") => p(t, f(e, "voice.join"));
|
|
19
|
-
export {
|
|
19
|
+
export { t as ChannelTabs, n as ChatPanel, r as Composer, i as MessageList, a as TypingIndicator, o as chatLabels, s as chatMentionLabels, d as chatMessageSegments, c as chatTypingLabels, _ as useChannel, y as useChannelList, g as useChatAuthors, O as useChatDm, S as useChatEdit, D as useChatJoin, k as useChatLeave, T as useChatMarkRead, v as useChatMembership, h as useChatMentionCandidates, b as useChatMessages, E as useChatOriginal, C as useChatRemove, x as useChatSend, j as useChatSetTyping, A as useChatTransferOwnership, u as useChatTypingPublisher, M as useChatVoiceJoin, l as useTyping, w as useUnread };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/plugin-chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.91.1",
|
|
4
4
|
"description": "Membership-filtered durable chat with configurable moderation, rate and retention strategies",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voltro",
|
|
@@ -73,25 +73,25 @@
|
|
|
73
73
|
"node": ">=24.0.0"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@voltro/protocol": "0.
|
|
77
|
-
"@voltro/database": "0.
|
|
78
|
-
"@voltro/client": "0.
|
|
79
|
-
"@voltro/runtime": "0.
|
|
80
|
-
"@voltro/plugin-ratelimit": "0.
|
|
81
|
-
"@voltro/plugin-moderation": "0.
|
|
82
|
-
"@voltro/plugin-social": "0.
|
|
83
|
-
"@voltro/plugin-players": "0.
|
|
84
|
-
"@voltro/plugin-notifications": "0.
|
|
85
|
-
"@voltro/kv": "0.
|
|
86
|
-
"@voltro/ui-shadcn": "0.
|
|
87
|
-
"@voltro/plugin-sanctions": "0.
|
|
88
|
-
"@voltro/plugin-licensing": "0.
|
|
89
|
-
"@voltro/plugin-storage": "0.
|
|
90
|
-
"@voltro/plugin-guilds": "0.
|
|
91
|
-
"@voltro/plugin-matchmaking": "0.
|
|
76
|
+
"@voltro/protocol": "0.91.1",
|
|
77
|
+
"@voltro/database": "0.91.1",
|
|
78
|
+
"@voltro/client": "0.91.1",
|
|
79
|
+
"@voltro/runtime": "0.91.1",
|
|
80
|
+
"@voltro/plugin-ratelimit": "0.91.1",
|
|
81
|
+
"@voltro/plugin-moderation": "0.91.1",
|
|
82
|
+
"@voltro/plugin-social": "0.91.1",
|
|
83
|
+
"@voltro/plugin-players": "0.91.1",
|
|
84
|
+
"@voltro/plugin-notifications": "0.91.1",
|
|
85
|
+
"@voltro/kv": "0.91.1",
|
|
86
|
+
"@voltro/ui-shadcn": "0.91.1",
|
|
87
|
+
"@voltro/plugin-sanctions": "0.91.1",
|
|
88
|
+
"@voltro/plugin-licensing": "0.91.1",
|
|
89
|
+
"@voltro/plugin-storage": "0.91.1",
|
|
90
|
+
"@voltro/plugin-guilds": "0.91.1",
|
|
91
|
+
"@voltro/plugin-matchmaking": "0.91.1"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
|
-
"effect": "4.1.
|
|
94
|
+
"effect": "4.1.4",
|
|
95
95
|
"react": "^19.0.0"
|
|
96
96
|
},
|
|
97
97
|
"publishConfig": {
|