@chatwarden/core 0.1.1 → 0.1.3
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 +128 -4
- package/dist/src/audit.d.ts +27 -5
- package/dist/src/audit.d.ts.map +1 -1
- package/dist/src/audit.js +57 -6
- package/dist/src/audit.js.map +1 -1
- package/dist/src/chatwarden.d.ts +183 -11
- package/dist/src/chatwarden.d.ts.map +1 -1
- package/dist/src/chatwarden.js +65 -10
- package/dist/src/chatwarden.js.map +1 -1
- package/dist/src/documents.d.ts +12 -2
- package/dist/src/documents.d.ts.map +1 -1
- package/dist/src/documents.js +56 -34
- package/dist/src/documents.js.map +1 -1
- package/dist/src/events.d.ts +3 -0
- package/dist/src/events.d.ts.map +1 -1
- package/dist/src/events.js.map +1 -1
- package/dist/src/index.d.ts +20 -11
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +11 -6
- package/dist/src/index.js.map +1 -1
- package/dist/src/ladder.d.ts +2 -0
- package/dist/src/ladder.d.ts.map +1 -1
- package/dist/src/ladder.js +1 -1
- package/dist/src/ladder.js.map +1 -1
- package/dist/src/policy.d.ts +129 -0
- package/dist/src/policy.d.ts.map +1 -0
- package/dist/src/policy.js +242 -0
- package/dist/src/policy.js.map +1 -0
- package/dist/src/profile.d.ts +120 -7
- package/dist/src/profile.d.ts.map +1 -1
- package/dist/src/profile.js +295 -7
- package/dist/src/profile.js.map +1 -1
- package/dist/src/reporting.d.ts +127 -0
- package/dist/src/reporting.d.ts.map +1 -0
- package/dist/src/reporting.js +172 -0
- package/dist/src/reporting.js.map +1 -0
- package/dist/src/reports.d.ts +80 -4
- package/dist/src/reports.d.ts.map +1 -1
- package/dist/src/reports.js +120 -6
- package/dist/src/reports.js.map +1 -1
- package/dist/src/staffReports.d.ts +17 -5
- package/dist/src/staffReports.d.ts.map +1 -1
- package/dist/src/staffReports.js +22 -5
- package/dist/src/staffReports.js.map +1 -1
- package/dist/src/staffViews.d.ts +138 -0
- package/dist/src/staffViews.d.ts.map +1 -0
- package/dist/src/staffViews.js +205 -0
- package/dist/src/staffViews.js.map +1 -0
- package/dist/src/team.d.ts +149 -0
- package/dist/src/team.d.ts.map +1 -0
- package/dist/src/team.js +385 -0
- package/dist/src/team.js.map +1 -0
- package/dist/src/types.d.ts +245 -4
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +5 -0
- package/dist/src/types.js.map +1 -1
- package/package.json +2 -2
- package/src/audit.ts +71 -7
- package/src/chatwarden.ts +245 -20
- package/src/documents.ts +70 -43
- package/src/events.ts +10 -1
- package/src/index.ts +109 -4
- package/src/ladder.ts +1 -1
- package/src/policy.ts +288 -0
- package/src/profile.ts +369 -14
- package/src/reporting.ts +251 -0
- package/src/reports.ts +163 -10
- package/src/staffReports.ts +33 -7
- package/src/staffViews.ts +325 -0
- package/src/team.ts +422 -0
- package/src/types.ts +257 -4
package/README.md
CHANGED
|
@@ -93,7 +93,7 @@ const filed = await cw.reports.submit({
|
|
|
93
93
|
roomId: 'lobby',
|
|
94
94
|
reporterSeat: 'seat-1',
|
|
95
95
|
targetSeat: 'seat-2',
|
|
96
|
-
|
|
96
|
+
reason: 'harassment', // optional: a one-tap report with no reason is fine (see "Reporting settings")
|
|
97
97
|
note: 'kept at it after I asked them to stop',
|
|
98
98
|
});
|
|
99
99
|
console.log(filed.ok ? `report ${filed.reportId} filed` : `not filed: ${filed.refused}`);
|
|
@@ -113,14 +113,19 @@ For the moderators' screens and the player's notices, mount the routes in
|
|
|
113
113
|
| `cw.rooms` | `seat`, `seatConnection`, `unseat`, `close`: who is in which seat of which room. |
|
|
114
114
|
| `cw.chat.accept(room, seat, text)` | The answer for one line: `{ deliver }` or `{ refuse: { reason } }`. `visibleTo` applies a viewer's mutes. `restricted(who)` says whether a person is chat-restricted, for typing indicators. |
|
|
115
115
|
| `cw.mutes` | A player mutes another player for themselves only. |
|
|
116
|
-
| `cw.reports` | `submit` (players), `list` and `
|
|
116
|
+
| `cw.reports` | `submit` and `addDetail` (players; see "Reporting settings"), `list`, `get` and `reporterRecord` (staff). `reporterRecord(person)` is how the reports a person filed stand: `{ reports, open, actioned, dismissed, badFaith, suspendedUntil, reasonMatched, reasonDecided }`. |
|
|
117
117
|
| `cw.decide(input)` | A moderator closes a report and writes the sanctions and notices in one transaction. Safe to send twice. |
|
|
118
|
-
| `cw.sanctions` | `apply` and `revoke`, for a moderator who acts without a report. |
|
|
118
|
+
| `cw.sanctions` | `apply` and `revoke`, for a moderator who acts without a report. `forPerson(subject)` and `list({ cursor?, limit?, source? })` (staff) read sanctions as `SanctionGroupView`s: one per group, built from the person's own row, so no IP, hash or stored value is in them. |
|
|
119
|
+
| `cw.blocked` | `list({ days })` and `countsByTerm({ days })` (staff), with `days` 1, 7 or 30: the lines the slur filter blocked, with the raw text, and the strikes per term. |
|
|
120
|
+
| `cw.cases` | The team workbench (staff): `claim(person, actor, { takeOver? })` and `release` a soft claim on a person's case (`releaseWhenDone` is what a decision does: it ends the claim only when the person has no other open report, so one case per person is held until its last report is decided), `next(actor, { category? })` to claim the oldest open case nobody holds, `holder` / `holders` to read claims, and `view` / `viewers` for who has a case open. A claim lasts 10 minutes from the last beat on your clock, lives in the store (so several server processes on one database agree, and two moderators racing for one case never both win), and is a courtesy: the core never refuses a decision because of one (the HTTP routes do). Viewing is a 30 second hint kept in this process's memory and never stored; it tracks only people with an open report, and one actor keeps at most 20 cases open. A claimer that loses a database lock race to another process is retried (3 attempts) and gets the normal "claimed" answer. |
|
|
121
|
+
| `cw.changes.token()` | A cheap, opaque change token for the queue. It differs after any report filed or decided, sanction applied or revoked, rule gap closed, claim taken, taken over or released, or saved reason changed, and is the same otherwise (a claim heartbeat does not move it). It is kept in the store, so a restart does not rewind it (the in-memory store is the exception: it starts again at "0"). |
|
|
122
|
+
| `cw.reasons` | Saved decision reasons (staff): `list`, `add({ label, text })`, `update(id, patch)` and `setActive(id, active)`. A label is up to 40 characters, a text up to 500 (counted as characters, an emoji is one), at most 200 reasons; a label holds no control character, a text none but a newline. |
|
|
119
123
|
| `cw.notices` | A player's pending notices, acknowledgements and "My record". Built so no identifier can leak. |
|
|
120
124
|
| `cw.doors` | `check` a person at the door (login, join) against bans. |
|
|
121
125
|
| `cw.names.check` | May a player use this as a name? |
|
|
122
126
|
| `cw.history`, `cw.suggest` | A person's recent record, and what the preset suggests as the next step. |
|
|
123
|
-
| `cw.rules`, `cw.profile`, `cw.limits`, `cw.summary`, `cw.documents` | The rules, standard and numbers in force, and the written code of conduct and guides. |
|
|
127
|
+
| `cw.rules`, `cw.profile`, `cw.limits`, `cw.summary`, `cw.documents` | The rules, standard and numbers in force, and the written code of conduct and guides. `cw.profile` and `cw.summary` are read live: the profile in force is your code's profile with the owner's stored edits on top (see "The editable profile"), so read it when you need it and never keep it. |
|
|
128
|
+
| `cw.policy` | The editable profile: `get`, `save`, `preview`, `reset` and `refresh`. The lengths a moderator is offered, the ladder, the first offences, the repeat rule, the area and severe rules and the guideline outcome texts can be edited at runtime and are stored in your store. |
|
|
124
129
|
| `cw.gaps`, `cw.audit` | Rule gaps for the periodic review, and the staff audit trail. |
|
|
125
130
|
| `cw.on(type, listener)` | Events: `report.created`, `report.closed`, `sanction.applied`, `sanction.revoked`, `gap.created`, `auto.restricted`. |
|
|
126
131
|
| `cw.purge`, `cw.ready`, `cw.flush`, `cw.close` | Housekeeping. |
|
|
@@ -150,6 +155,125 @@ Rule, or `'uncovered'` with a `gapNote`. `lineIds` picks up to five of that play
|
|
|
150
155
|
with blocked words starred out. A timeout is `kind: 'chat'` with `durationMs`. `cw.suggest(subject, level, rule)` says what the preset
|
|
151
156
|
would do next, for a moderator who wants a starting point. A failing store rejects the call, so catch it.
|
|
152
157
|
|
|
158
|
+
## The editable profile
|
|
159
|
+
|
|
160
|
+
The profile you give `createChatwarden` (a preset and `overrides`) is the **base**. An owner can change part of it while the game
|
|
161
|
+
runs: the lengths a moderator is offered (`durations`, and whether `customDuration` is allowed), the escalation `ladder`, the
|
|
162
|
+
`firstOffense` per conduct level, the `repeat` rule, `areaRules` and `severeRules`, and the outcome text of each written guideline
|
|
163
|
+
tier, and the reporting settings (see "Reporting settings"). The edits are a validated, versioned **layer** kept in your store, and `cw.profile` is the base with that layer on top.
|
|
164
|
+
Profanity handling is not editable: it stays in your code. Sanctions already given are not touched.
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
import { createChatwarden, type Platform } from '@chatwarden/core';
|
|
168
|
+
import { createMemoryStore } from '@chatwarden/store-memory';
|
|
169
|
+
|
|
170
|
+
const platform: Platform = { identify: (ctx) => ctx as { clientKey: string } };
|
|
171
|
+
const cw = await createChatwarden({ store: createMemoryStore(), secret: 'a-long-random-secret', platform, retention: false });
|
|
172
|
+
|
|
173
|
+
const HOUR = 3_600_000;
|
|
174
|
+
const { version } = cw.policy.get(); // 0 until something is saved
|
|
175
|
+
|
|
176
|
+
// What would this suggest for a clean record, a warning, a 24 hour restriction and a 7 day ban? Nothing is saved.
|
|
177
|
+
const layer = { durations: [HOUR, 6 * HOUR, 12 * HOUR, 24 * HOUR], firstOffense: { rude: { kind: 'chat' as const, durationMs: 6 * HOUR } } };
|
|
178
|
+
const preview = cw.policy.preview(layer);
|
|
179
|
+
if (preview.ok) console.log(preview.samples.clean.rude); // { label: 'Restrict chat 6 hours', kind: 'chat', durationMs: 21600000 }
|
|
180
|
+
|
|
181
|
+
// Save it. `version` is the one you loaded: if someone saved since, the answer is { ok: false, error: 'conflict' }.
|
|
182
|
+
const saved = cw.policy.save(layer, { version, actor: 'owner@example.com', reason: 'offer shorter timeouts' });
|
|
183
|
+
if (saved.ok) console.log(cw.profile.durations, saved.changed); // in force at once, here
|
|
184
|
+
|
|
185
|
+
cw.policy.reset('durations'); // put one section back to the base; reset() puts everything back
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
- **`cw.policy.get()`** returns `{ effective, base, layer, version, canSave }`. `layerError` (`{ path, kind }`) is also there when the stored layer
|
|
189
|
+
cannot be used: it is then ignored, the base stays in force, and one `chatwarden.policy_layer_invalid` line is logged. `kind` is `'unreadable'`
|
|
190
|
+
when the stored text could not be read at all (corrupted, not JSON, not an object), so the owner's edits are gone until they save again, and
|
|
191
|
+
`'invalid'` when it was read but a setting is not valid (a field from a newer kit, say). A save or a full `reset()` repairs either.
|
|
192
|
+
- **`save(layer, { version, actor, reason })`** stores the whole layer: a section you leave out goes back to the base. It answers
|
|
193
|
+
`{ ok: true, version, changed }`, `{ ok: false, error: 'conflict' }` for a stale `version` (nothing is written),
|
|
194
|
+
`{ ok: false, error: 'invalid', path }` for a layer that touches a setting that is not editable or would make the profile invalid
|
|
195
|
+
(`path` names the field, such as `layer.profanity` or `layer.ladder[2].high.durationMs`; no value), and
|
|
196
|
+
`{ ok: false, error: 'unsupported' }` when the store has no `loadPolicyLayer` and `savePolicyLayer`. `actor` and `reason` are
|
|
197
|
+
checked here; `@chatwarden/http` writes them to the audit trail.
|
|
198
|
+
- **`guidelines` is positional.** Entry `i` of the layer's `guidelines` list is the new `outcome` text for tier `i` of the profile's
|
|
199
|
+
own `guidelines` (`null` leaves a tier alone). If you reorder or add tiers in the profile in your code, stored texts keep their
|
|
200
|
+
positions, so they land on the wrong tiers: reset `guidelines` (or save it again) after such a change. A stored list longer than the
|
|
201
|
+
profile's tiers is unusable and reported as `layerError`.
|
|
202
|
+
- **Whole outcomes.** An outcome written as an object in a layer (`firstOffense`, `repeat.outcome`) needs both `kind` and `durationMs`, so a
|
|
203
|
+
stored layer never changes meaning when your base profile does. `areaRules` and `severeRules` list at most 100 rule numbers each.
|
|
204
|
+
- **Types.** `ModerationProfile` is what you write; `durations` and `customDuration` are optional in it, so a profile written for 0.1.1 still
|
|
205
|
+
compiles and works everywhere (`validateProfile`, the document functions, `defineProfile`, `createChatwarden`). What the kit hands back
|
|
206
|
+
(`cw.profile`, `cw.policy.get()`, `defineProfile`, `resolveProfile`) is a `ResolvedProfile` with both filled in, and `cw.documents.policyJson()`'s
|
|
207
|
+
`profile` therefore has the two keys even for a profile that had none.
|
|
208
|
+
- **Audit.** A save and a reset are recorded by `@chatwarden/http` as `policy.update` and `policy.reset` rows whose `detail` is
|
|
209
|
+
`{ sections, reason? }`. If you write your own `Store`, keep and return that `detail` from `insertAudit` and `listAudit`.
|
|
210
|
+
- **A ladder cell without a `label`** gets one from its kind and length: "Restrict chat 6 hours", "Ban from public rooms 12 hours",
|
|
211
|
+
"Full ban 3 days", "Full ban permanent".
|
|
212
|
+
- **`durations`** is a sorted list of lengths, each from 1 millisecond to 365 days, at most 50. It is only the list a moderator is offered:
|
|
213
|
+
`cw.decide` and `cw.sanctions.apply` still accept any valid length. The staff routes in `@chatwarden/http` refuse a length outside
|
|
214
|
+
the list (400 `duration_not_offered`) when `customDuration` is false.
|
|
215
|
+
- **Other processes** see a save within 10 seconds: a read of the profile looks at the stored version at most that often, on your
|
|
216
|
+
`clock`. `cw.policy.refresh()` looks now.
|
|
217
|
+
- **Your own store.** `loadPolicyLayer()` and `savePolicyLayer(layer, expectedVersion)` are optional on `Store`. The second must be
|
|
218
|
+
one atomic conditional write that returns the new version, or `null` when the stored version is not `expectedVersion`. A store
|
|
219
|
+
without them still works; `save` and `reset` answer `unsupported` and the profile stays code-only.
|
|
220
|
+
|
|
221
|
+
## Reporting settings
|
|
222
|
+
|
|
223
|
+
How players report is part of the profile, so it has defaults and an owner can edit it with the rest (`cw.policy`, section `reporting`). Nothing
|
|
224
|
+
is required: a profile that says nothing about reporting gets the defaults.
|
|
225
|
+
|
|
226
|
+
- **`flow`**: `'one_tap'` (the default: one step, where the player may pick a reason and add a note in the same dialog and neither is needed), `'reason_first'`
|
|
227
|
+
(the screen asks for a reason first; the kit takes a report with no reason all the same, only the screen differs) or `'reason_required'`
|
|
228
|
+
(a report with no reason is refused `reason_required`).
|
|
229
|
+
- **`reasons`**: the ordered list a player picks from, 1 to 20 of them. Each is `{ id, label, hint, group, rules, asksNote, enabled }`; only
|
|
230
|
+
`id` (a unique lowercase slug) and `label` are needed when you write one. `rules` are the Community Rule numbers the reason usually
|
|
231
|
+
means: the first citable one is the rule a moderator is suggested, and a decision under any of them counts as "matched" for the reporter's
|
|
232
|
+
accuracy. At least one reason must be on, and `other` can be relabelled and re-mapped but not removed or switched off. The defaults, in
|
|
233
|
+
order: **Chat**: `harassment` (Insults or harassment, CR 2), `hate` (Hate, CR 1), `sexual` (Sexual content, CR 3), `threat` (Threats, CR 2),
|
|
234
|
+
`spam` (Spam or ads, CR 4), `personal_info` (Sharing personal info, CR 2); **Gameplay**: `cheating` (Cheating, CR 5), `griefing` (Throwing or
|
|
235
|
+
griefing, CR 6), `afk` (Leaving or AFK, CR 6); then `other` (Something else, asks for a note).
|
|
236
|
+
- **`thanks`**: what the reporter is told afterwards. Default "Thanks for the report. We'll look into it."
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
// One tap, no reason: accepted. (This is the default flow.)
|
|
240
|
+
await cw.reports.submit({ roomId: 'lobby', reporterSeat: 'seat-1', targetSeat: 'seat-2' });
|
|
241
|
+
|
|
242
|
+
// A reason the studio did not list, or switched off, is refused in every flow.
|
|
243
|
+
await cw.reports.submit({ roomId: 'lobby', reporterSeat: 'seat-1', targetSeat: 'seat-3', reason: 'not_a_reason' }); // { ok: false, refused: 'reason_unknown' }
|
|
244
|
+
|
|
245
|
+
// A follow-up of your own (the kit's dialog sends the reason and note with the report): add them to an existing report.
|
|
246
|
+
const res = await cw.reports.addDetail(reportId, 'seat-1', { reason: 'cheating', note: 'speed hacking in the last round' });
|
|
247
|
+
// { ok: true }, or { ok: false, refused: 'not_found' | 'not_reporter' | 'too_late' | 'already_added' | 'reason_unknown' | 'off' }
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
- **The reason is a hint, never the truth.** It is stored as `reportedReason` (a reason id, or null). What settles a case is the moderator's decision,
|
|
251
|
+
or later the AI read. The staff views show it as "Reported as ..." or "No reason given", and a report with no reason shows the lines and asks the
|
|
252
|
+
moderator which rule applies.
|
|
253
|
+
- **`submit` refusals**, in order: `off`, `reason_required`, `reason_unknown`, `not_player`, `self`, `suspended`, `rate`, `duplicate`. A refused reason
|
|
254
|
+
counts against nothing. The reason is read from the profile at that moment, so an edit applies to the next report.
|
|
255
|
+
- **`addDetail(reportId, reporterSeat, { reason?, note? })`** attaches the follow-up to the report. Only the reporter can add it: `reporterSeat` must be
|
|
256
|
+
the seat the report was filed from and must still hold the reporter in that room. It works once, within ten minutes of the report (exactly ten is
|
|
257
|
+
in time), and only while the report is open. It never changes the target or the excerpt. A reason given replaces the reported reason; a note replaces the
|
|
258
|
+
note; one left out keeps what was there. Refusals: `off` (the kit is off, your store does not support follow-ups because it has no `addReportDetail`, or the store failed), `not_found`, `not_reporter`,
|
|
259
|
+
`too_late`, `already_added`, `reason_unknown`. A call that gives neither a reason nor a note answers `ok: true` and does not use up the one allowed.
|
|
260
|
+
- **The kit has no player report route.** You call `cw.reports.submit` from your own route, and you do the same for `addDetail`: take the reporter's
|
|
261
|
+
seat from your own session (never from the request body) and the report id from what `submit` answered, and pass the player's choice through. The
|
|
262
|
+
player route `GET /rules` in `@chatwarden/http` hands the report screen its flow, enabled reasons and thank-you.
|
|
263
|
+
- **Reporter accuracy.** `cw.reports.reporterRecord(person)` adds `reasonDecided` (decided reports they filed that named a reason) and `reasonMatched` (those
|
|
264
|
+
where the decision cited, against the reported person, a rule in the reason's `rules`). A dismissal never matches. A reason that is no longer in the
|
|
265
|
+
list, and one that maps to no rule (`other` by default, so an honest "Something else" is never counted as inaccurate), cannot be judged and are left out; a
|
|
266
|
+
switched-off one still counts. It reads the newest 200 decided reports. It is read against the reasons in force now. It is a signal for moderators
|
|
267
|
+
and is never used to refuse a report.
|
|
268
|
+
- **From 0.1.1.** `ReportInput.category` is still accepted as an alias of `reason` (the six old ids are valid reasons, `disruption` reads as `griefing`),
|
|
269
|
+
and `reason` wins when both are given; a blank `reason` falls back to `category`. A report's stored `category` is still one of the six old ids, derived from its reason (`'other'` when none), so
|
|
270
|
+
code that reads it keeps working; `ReportCategory` is unchanged. The alias keeps its 0.1.1 leniency: a `category` that is not an enabled reason (unknown, not text, or switched off) is taken and stored as
|
|
271
|
+
`'other'`, as before. Only the new `reason` field is refused (`reason_unknown`). Reports stored before 0.1.2 read their old category as their `reportedReason`.
|
|
272
|
+
**Upgrading:** `ReportRefusal` has two new members (`reason_required`, `reason_unknown`), `addDetail` has its own result type, and `layerError` gains a required
|
|
273
|
+
`kind`; an exhaustive `Record<ReportRefusal, ...>` or a `switch` with a `never` check over them needs the new cases to compile.
|
|
274
|
+
- **Your own store.** `addReportDetail` and `loadReporterDecisions` are optional on `Store`. Without the first, `addDetail` answers `off`; without the
|
|
275
|
+
second, the accuracy counts are 0. `insertReport` must keep `reportedReason`, and `listReports` must apply the `reason` filter (`null` means none).
|
|
276
|
+
|
|
153
277
|
## Typing indicators
|
|
154
278
|
|
|
155
279
|
Do not show a "typing..." indicator for a player who cannot chat. `cw.chat.restricted(who, { roomId, seatId })` runs the
|
package/dist/src/audit.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PolicySection } from './profile.js';
|
|
1
2
|
import type { Clock, Logger, Store } from './types.js';
|
|
2
3
|
/** What a staff member may do. Ordered from least to most. */
|
|
3
4
|
export declare const ROLES: readonly ["moderator", "senior", "owner"];
|
|
@@ -6,10 +7,21 @@ export type Role = (typeof ROLES)[number];
|
|
|
6
7
|
* The closed list of things the audit trail records. The `term.*` and `exception.*` names also cover the rows the
|
|
7
8
|
* term editor (`LiveTerms`) wrote before the trail existed.
|
|
8
9
|
*/
|
|
9
|
-
export declare const AUDIT_ACTIONS: readonly ["report.view", "report.decide", "sanction.apply", "sanction.revoke", "gap.close", "term.add", "term.update", "term.toggle", "exception.add", "exception.update", "exception.toggle", "history.view", "suggest", "policy.view"];
|
|
10
|
+
export declare const AUDIT_ACTIONS: readonly ["report.view", "report.decide", "sanction.apply", "sanction.revoke", "gap.close", "term.add", "term.update", "term.toggle", "exception.add", "exception.update", "exception.toggle", "history.view", "suggest", "policy.view", "blocked.view", "case.takeover", "reason.add", "reason.update", "reason.toggle", "policy.update", "policy.reset"];
|
|
10
11
|
export type AuditAction = (typeof AUDIT_ACTIONS)[number];
|
|
11
|
-
/**
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* What a `policy.update` or `policy.reset` row says it did: the editable sections it changed, and the reason the owner gave.
|
|
14
|
+
* The reason is the one free text an audit row may carry (1 to {@link AUDIT_REASON_MAX} characters, trimmed); the sections are
|
|
15
|
+
* names from a closed list. No layer value is ever recorded.
|
|
16
|
+
*/
|
|
17
|
+
export interface AuditDetail {
|
|
18
|
+
sections: PolicySection[];
|
|
19
|
+
reason?: string;
|
|
20
|
+
}
|
|
21
|
+
/** The longest reason a policy audit row keeps. */
|
|
22
|
+
export declare const AUDIT_REASON_MAX = 2000;
|
|
23
|
+
/** What an entry points at: a report id, a sanction group id, a person (a staff ref), a term id, an exception id or a saved reason id. */
|
|
24
|
+
export declare const AUDIT_TARGET_TYPES: readonly ["report", "sanction", "person", "term", "exception", "reason"];
|
|
13
25
|
export type AuditTargetType = (typeof AUDIT_TARGET_TYPES)[number];
|
|
14
26
|
export interface AuditTarget {
|
|
15
27
|
type: AuditTargetType;
|
|
@@ -30,8 +42,13 @@ export interface AuditRecordInput {
|
|
|
30
42
|
role: Role;
|
|
31
43
|
action: AuditAction;
|
|
32
44
|
target?: AuditTarget;
|
|
45
|
+
/** Required for `policy.update` and `policy.reset` (and refused for every other action). */
|
|
46
|
+
detail?: AuditDetail;
|
|
33
47
|
}
|
|
34
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* One entry as the store keeps and returns it. There is no field for chat text or a note. The one free text is the `reason` inside
|
|
50
|
+
* the `detail` of a `policy.update` or `policy.reset` row (the owner's own reason for changing the settings).
|
|
51
|
+
*/
|
|
35
52
|
export interface AuditRow {
|
|
36
53
|
id: string;
|
|
37
54
|
/** Epoch ms. */
|
|
@@ -41,6 +58,8 @@ export interface AuditRow {
|
|
|
41
58
|
role: Role | null;
|
|
42
59
|
action: AuditAction;
|
|
43
60
|
target: AuditTarget | null;
|
|
61
|
+
/** Only on a `policy.update` or `policy.reset` row. */
|
|
62
|
+
detail?: AuditDetail;
|
|
44
63
|
}
|
|
45
64
|
/** What {@link Store.listAudit} takes. */
|
|
46
65
|
export interface AuditListQuery {
|
|
@@ -60,6 +79,8 @@ export interface AuditItem {
|
|
|
60
79
|
role: Role | null;
|
|
61
80
|
action: AuditAction;
|
|
62
81
|
target?: AuditTarget;
|
|
82
|
+
/** Only on a `policy.update` or `policy.reset` row. */
|
|
83
|
+
detail?: AuditDetail;
|
|
63
84
|
}
|
|
64
85
|
/** What `cw.audit.list` takes. `limit` is required. */
|
|
65
86
|
export interface AuditQuery {
|
|
@@ -93,7 +114,8 @@ export declare function decodeAuditCursor(cursor: unknown): {
|
|
|
93
114
|
};
|
|
94
115
|
/**
|
|
95
116
|
* The staff audit trail: who (actor and role) did what (a name from {@link AUDIT_ACTIONS}) to which id, and when.
|
|
96
|
-
* It stores no chat text,
|
|
117
|
+
* It stores no chat text, note or evidence: there is no field for any, and a target must look like an id. The one free text it
|
|
118
|
+
* keeps is the owner's `reason` in the `detail` of a `policy.update` or `policy.reset` row, next to the section names.
|
|
97
119
|
*/
|
|
98
120
|
export declare class AuditService {
|
|
99
121
|
private readonly store;
|
package/dist/src/audit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/audit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/audit.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEvD,8DAA8D;AAC9D,eAAO,MAAM,KAAK,2CAA4C,CAAC;AAC/D,MAAM,MAAM,IAAI,G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E;AAED,yGAAyG;AACzG,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAQ7E;AA0CD;;;;GAIG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;gBAEhC,IAAI,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,KAAK,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE;IAM7E;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO;IAuBxC;;;;OAIG;IACH,IAAI,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS;CAiC/B"}
|
package/dist/src/audit.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { randomId } from './crypto.js';
|
|
2
|
+
import { POLICY_SECTIONS } from './profile.js';
|
|
2
3
|
import { safeWarn } from './log.js';
|
|
3
4
|
import { b64urlDecode, b64urlEncode } from './staffReports.js';
|
|
4
5
|
/** What a staff member may do. Ordered from least to most. */
|
|
@@ -22,9 +23,20 @@ export const AUDIT_ACTIONS = [
|
|
|
22
23
|
'history.view',
|
|
23
24
|
'suggest',
|
|
24
25
|
'policy.view',
|
|
26
|
+
'blocked.view',
|
|
27
|
+
'case.takeover',
|
|
28
|
+
'reason.add',
|
|
29
|
+
'reason.update',
|
|
30
|
+
'reason.toggle',
|
|
31
|
+
'policy.update',
|
|
32
|
+
'policy.reset',
|
|
25
33
|
];
|
|
26
|
-
/**
|
|
27
|
-
export const
|
|
34
|
+
/** The longest reason a policy audit row keeps. */
|
|
35
|
+
export const AUDIT_REASON_MAX = 2000;
|
|
36
|
+
/** The actions whose row carries an {@link AuditDetail}, and the only ones that may. */
|
|
37
|
+
const DETAIL_ACTIONS = ['policy.update', 'policy.reset'];
|
|
38
|
+
/** What an entry points at: a report id, a sanction group id, a person (a staff ref), a term id, an exception id or a saved reason id. */
|
|
39
|
+
export const AUDIT_TARGET_TYPES = ['report', 'sanction', 'person', 'term', 'exception', 'reason'];
|
|
28
40
|
/** The largest page. */
|
|
29
41
|
export const AUDIT_PAGE_MAX = 200;
|
|
30
42
|
/** A list query that cannot be answered: a `before` cursor we did not issue, or an unknown `action` / bad `actor`. */
|
|
@@ -60,27 +72,64 @@ export function decodeAuditCursor(cursor) {
|
|
|
60
72
|
throw new AuditQueryError('before');
|
|
61
73
|
return { at, id: text.slice(sep + 1) };
|
|
62
74
|
}
|
|
75
|
+
/** The detail of a policy row, or null when it is not valid: sections from the closed list, an optional reason, nothing else. */
|
|
76
|
+
function parseDetail(detail) {
|
|
77
|
+
if (typeof detail !== 'object' || detail === null || Array.isArray(detail))
|
|
78
|
+
return null;
|
|
79
|
+
const d = detail;
|
|
80
|
+
for (const k of Object.keys(d))
|
|
81
|
+
if (k !== 'sections' && k !== 'reason')
|
|
82
|
+
return null;
|
|
83
|
+
const sections = d.sections;
|
|
84
|
+
if (!Array.isArray(sections))
|
|
85
|
+
return null;
|
|
86
|
+
const known = POLICY_SECTIONS;
|
|
87
|
+
if (!sections.every((x) => typeof x === 'string' && known.includes(x)))
|
|
88
|
+
return null;
|
|
89
|
+
const unique = [...new Set(sections)];
|
|
90
|
+
if (d.reason === undefined)
|
|
91
|
+
return { sections: unique };
|
|
92
|
+
if (typeof d.reason !== 'string')
|
|
93
|
+
return null;
|
|
94
|
+
const reason = d.reason.trim();
|
|
95
|
+
if (reason === '' || reason.length > AUDIT_REASON_MAX)
|
|
96
|
+
return null;
|
|
97
|
+
return { sections: unique, reason };
|
|
98
|
+
}
|
|
63
99
|
/** Parse the input of `record`; null when anything is off. Copies only the known fields. */
|
|
64
100
|
function parse(input) {
|
|
65
101
|
if (typeof input !== 'object' || input === null)
|
|
66
102
|
return null;
|
|
67
|
-
const { actor, role, action, target } = input;
|
|
103
|
+
const { actor, role, action, target, detail } = input;
|
|
68
104
|
if (typeof actor !== 'string' || !ACTOR_RE.test(actor))
|
|
69
105
|
return null;
|
|
70
106
|
if (!isRole(role) || !isAction(action))
|
|
71
107
|
return null;
|
|
108
|
+
// A policy row must say what it changed; no other row may carry anything but ids.
|
|
109
|
+
let parsedDetail;
|
|
110
|
+
if (DETAIL_ACTIONS.includes(action)) {
|
|
111
|
+
const d = parseDetail(detail);
|
|
112
|
+
if (d === null)
|
|
113
|
+
return null;
|
|
114
|
+
parsedDetail = d;
|
|
115
|
+
}
|
|
116
|
+
else if (detail !== undefined) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const extra = parsedDetail === undefined ? {} : { detail: parsedDetail };
|
|
72
120
|
if (target === undefined)
|
|
73
|
-
return { actor, role, action };
|
|
121
|
+
return { actor, role, action, ...extra };
|
|
74
122
|
if (typeof target !== 'object' || target === null)
|
|
75
123
|
return null;
|
|
76
124
|
const { type, ref } = target;
|
|
77
125
|
if (!isTargetType(type) || typeof ref !== 'string' || !REF_RE.test(ref))
|
|
78
126
|
return null;
|
|
79
|
-
return { actor, role, action, target: { type, ref } };
|
|
127
|
+
return { actor, role, action, target: { type, ref }, ...extra };
|
|
80
128
|
}
|
|
81
129
|
/**
|
|
82
130
|
* The staff audit trail: who (actor and role) did what (a name from {@link AUDIT_ACTIONS}) to which id, and when.
|
|
83
|
-
* It stores no chat text,
|
|
131
|
+
* It stores no chat text, note or evidence: there is no field for any, and a target must look like an id. The one free text it
|
|
132
|
+
* keeps is the owner's `reason` in the `detail` of a `policy.update` or `policy.reset` row, next to the section names.
|
|
84
133
|
*/
|
|
85
134
|
export class AuditService {
|
|
86
135
|
store;
|
|
@@ -109,6 +158,7 @@ export class AuditService {
|
|
|
109
158
|
role: parsed.role,
|
|
110
159
|
action: parsed.action,
|
|
111
160
|
target: parsed.target ?? null,
|
|
161
|
+
...(parsed.detail === undefined ? {} : { detail: parsed.detail }),
|
|
112
162
|
});
|
|
113
163
|
return true;
|
|
114
164
|
}
|
|
@@ -149,6 +199,7 @@ export class AuditService {
|
|
|
149
199
|
role: r.role,
|
|
150
200
|
action: r.action,
|
|
151
201
|
...(r.target === null ? {} : { target: { type: r.target.type, ref: r.target.ref } }),
|
|
202
|
+
...(r.detail === undefined ? {} : { detail: { sections: [...r.detail.sections], ...(r.detail.reason === undefined ? {} : { reason: r.detail.reason }) } }),
|
|
152
203
|
})),
|
|
153
204
|
next: rows.length === limit && last !== undefined ? encodeAuditCursor(last.at, last.id) : null,
|
|
154
205
|
};
|
package/dist/src/audit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG/D,8DAA8D;AAC9D,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAU,CAAC;AAG/D;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,aAAa;IACb,eAAe;IACf,gBAAgB;IAChB,iBAAiB;IACjB,WAAW;IACX,UAAU;IACV,aAAa;IACb,aAAa;IACb,eAAe;IACf,kBAAkB;IAClB,kBAAkB;IAClB,cAAc;IACd,SAAS;IACT,aAAa;
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,O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