@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/dist/typing.js CHANGED
@@ -1,85 +1,85 @@
1
- import { chatError as e } from "./errors.js";
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 { createTypingInvalidation as r } from "./typingInvalidation.js";
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 = (t) => {
10
- if (!t || typeof t != "object" || Array.isArray(t)) throw e("invalid_input");
11
- let n = Object.getOwnPropertyDescriptor(t, "channelId");
12
- if (!n || !("value" in n) || typeof n.value != "string" || !n.value.trim() || n.value.length > 256 || n.value.includes("\0") || n.value === "~") throw e("invalid_input");
13
- return n.value;
14
- }, u = (t) => a.try({
15
- try: t,
16
- catch: () => e("invalid_input")
17
- }), d = (n, r) => {
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(n), o = l(r);
21
- let t = Object.getOwnPropertyDescriptor(r, "active");
22
- if (!t || !("value" in t) || typeof t.value != "boolean") throw e("invalid_input");
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(e("invalid_input"));
25
+ return a.fail(r("invalid_input"));
26
26
  }
27
27
  return a.gen(function* () {
28
- let n = yield* c.readAccess(i, o), r = yield* u(c.now), l = yield* c.social;
29
- if (n.channel.kind === "dm" && !l) return yield* a.fail(e("forbidden"));
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 (n.channel.frozen) return yield* a.fail(e("frozen"));
32
- if (n.member.mutedUntil !== null && n.member.mutedUntil > r) return yield* a.fail(e("muted"));
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: n.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(e("unavailable"));
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
- n.member.subjectId,
43
+ e.member.subjectId,
44
44
  o
45
- ], f.perChannel], [[i.tenantId, n.member.subjectId], f.global]]) {
46
- let n = s("sha256").update(JSON.stringify(t)).digest("hex"), i = yield* c.limiter.consume("chat:typing:" + n, {
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
- }, r).pipe(a.mapError(() => e("unavailable")), a.catchDefect(() => a.fail(e("unavailable"))));
52
- if (i.failOpenReason !== void 0) return yield* a.fail(e("unavailable"));
53
- if (!i.allowed) return yield* a.fail(e("rate_limited"));
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 ? r + t : r;
56
- return !Number.isSafeInteger(p) || p > 864e13 ? yield* a.fail(e("unavailable")) : Object.freeze({
57
- subjectId: n.member.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(e("unavailable"))));
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 = (t) => a.gen(function* () {
67
- if (t.event !== i.name) return "deny";
68
- let r = yield* u(() => l(t.key)), s = yield* o.decodeUnknownEffect(n)(t.payload).pipe(a.mapError(() => e("invalid_input"))), d = yield* c.readAccess(t.subject, r, s.subjectId), f = yield* u(c.now);
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(t.subject, s.subjectId).pipe(a.mapError(() => e("unavailable")))) ? "drop" : "allow";
72
- }).pipe(a.catch(() => a.succeed("deny")), a.catchDefect(() => a.succeed("deny"))), m = r(c.store);
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: (t) => u(() => {
80
- if (t.event !== i.name) throw e("forbidden");
81
- return l(t.key);
82
- }).pipe(a.flatMap((e) => m(structuredClone(t.subject), e)))
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 { chatMessageSegments as t } from "./messageLinks.js";
3
- import { ChannelTabs as n, ChatPanel as r, Composer as i, MessageList as a, TypingIndicator as o, chatLabels as s, chatMentionLabels as c, chatTypingLabels as l } from "./components.js";
4
- import { useTyping as u } from "./useTyping.js";
5
- import { useChatTypingPublisher as d } from "./useChatTypingPublisher.js";
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 { n as ChannelTabs, r as ChatPanel, i as Composer, a as MessageList, o as TypingIndicator, s as chatLabels, c as chatMentionLabels, t as chatMessageSegments, l 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, d as useChatTypingPublisher, M as useChatVoiceJoin, u as useTyping, w as useUnread };
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.90.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.90.0",
77
- "@voltro/database": "0.90.0",
78
- "@voltro/client": "0.90.0",
79
- "@voltro/runtime": "0.90.0",
80
- "@voltro/plugin-ratelimit": "0.90.0",
81
- "@voltro/plugin-moderation": "0.90.0",
82
- "@voltro/plugin-social": "0.90.0",
83
- "@voltro/plugin-players": "0.90.0",
84
- "@voltro/plugin-notifications": "0.90.0",
85
- "@voltro/kv": "0.90.0",
86
- "@voltro/ui-shadcn": "0.90.0",
87
- "@voltro/plugin-sanctions": "0.90.0",
88
- "@voltro/plugin-licensing": "0.90.0",
89
- "@voltro/plugin-storage": "0.90.0",
90
- "@voltro/plugin-guilds": "0.90.0",
91
- "@voltro/plugin-matchmaking": "0.90.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.2",
94
+ "effect": "4.1.4",
95
95
  "react": "^19.0.0"
96
96
  },
97
97
  "publishConfig": {