@fixthisplz/schema 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 the FixThisPlz contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,77 @@
1
- # Temporary Holding Version
1
+ # @fixthisplz/schema
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ What a [FixThisPlz](https://github.com/fixthisplz/fixthisplz) report is and how it is sent: the **submission protocol v1**.
4
+
5
+ - [`report.schema.json`](report.schema.json) (JSON Schema 2020-12) is the single source of truth for the report context and the protocol bodies.
6
+ - TypeScript types generated from it at build time, so they cannot drift.
7
+ - `limits` and `errorCodes`, shared by the widget and by any backend.
8
+ - The masking rules (`maskText`, `maskUrl`, `maskContext`), applied by the widget before sending and by a server again on reception.
9
+
10
+ There is no runtime validator: pick the one your backend already uses (for example [Ajv](https://ajv.js.org) with its 2020-12 build).
11
+
12
+ ## Install
13
+
14
+ ```sh
15
+ npm install @fixthisplz/schema
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```ts
21
+ import { errorCodes, limits, type SubmissionError } from "@fixthisplz/schema";
22
+ import schema from "@fixthisplz/schema/report.schema.json" with { type: "json" };
23
+
24
+ // Validate contexts with the validator of your choice, for example: new Ajv2020().compile(schema).
25
+
26
+ // On a server: refuse a description over the limit (limits count characters, not UTF-16 units).
27
+ if ([...description.trim()].length > limits.descriptionLength) {
28
+ const body: SubmissionError = { code: errorCodes.invalid.code, message: "The description is too long." };
29
+ return Response.json(body, { status: errorCodes.invalid.status });
30
+ }
31
+ ```
32
+
33
+ ## Submission protocol v1
34
+
35
+ **Request:** `POST <endpoint>` as `multipart/form-data`:
36
+
37
+ | Field | Required | Content |
38
+ |---|---|---|
39
+ | `description` | yes | What the reporter wrote, 1 to 5,000 characters (blank is refused) |
40
+ | `context` | yes | JSON of the report context (`ReportContext`), at most 64 KiB |
41
+ | `reporter_email` | no | Contact e-mail of an anonymous reporter, at most 254 characters |
42
+ | `website` | no | Honeypot: must be empty |
43
+ | `captcha_token` | no | Captcha token, when a captcha is configured |
44
+ | `screenshot` | no | JPEG file, at most 5 MiB and 40 megapixels |
45
+
46
+ **Success:** `201` with `{ "id": 42, "number": "#42" }` (`SubmissionSuccess`). `number` is what the reporter sees. A filled honeypot gets the same status with `{ "id": 0, "number": "" }`, and the report is dropped.
47
+
48
+ **Failure:** an HTTP status with `{ "code": "…", "message": "…" }` (`SubmissionError`; backends may add keys). Clients rely on the status first, and on the code only where the table says so:
49
+
50
+ | Status | Code (`errorCodes`) | Meaning |
51
+ |---|---|---|
52
+ | 403 | `fixthisplz_not_allowed` (`notAllowed`) | The reporter may not report |
53
+ | 403 | `fixthisplz_captcha_failed` (`captchaFailed`) | The captcha check failed |
54
+ | 404 | `fixthisplz_disabled` (`disabled`) | Reporting is switched off |
55
+ | 413 | `fixthisplz_too_large` (`tooLarge`) | The payload is too large |
56
+ | 422 | `fixthisplz_invalid`, `fixthisplz_invalid_context`, `fixthisplz_bad_type`, `fixthisplz_upload_failed` | Invalid field. **`message` is shown to the reporter**, so it must be human-readable and translated |
57
+ | 429 | `fixthisplz_rate_limited` (`rateLimited`) | Rate limited |
58
+ | 500 | `fixthisplz_store_failed`, `fixthisplz_save_failed` | The server could not store the report |
59
+ | 503 | `fixthisplz_captcha_unavailable` (`captchaUnavailable`) | The captcha provider is unavailable |
60
+
61
+ ### Widget settings (optional)
62
+
63
+ A backend may tell the widget how to mask before a report: the widget's `settingsUrl` option points at a URL whose `GET` answers `200` with a `WidgetSettings` body (`{ "masking": { "enabled": true, "keys": ["token", "key"] } }`). The widget reads it when a report starts, without credentials; on any failure (an error status, a 3-second timeout, an invalid body) it uses its own `masking` option. The FixThisPlz hub serves it at `/api/v1/projects/<public key>/widget-settings`.
64
+
65
+ ### Masking
66
+
67
+ When masking is enabled, in every URL of the context the values of the query parameters whose percent-decoded, lowercased name **contains** one of the `keys` become `…` (`access_token` is masked by `token`); other values stay readable, except that a value carrying its own query or fragment (a return URL in `next=`, `redirect_uri=`, `state=`) has its listed values masked the same way, up to 4 levels deep (deeper, the whole value is masked). Credentials and fragments are dropped from every URL, those inside texts included, and Bearer tokens, JWTs, e-mail addresses and runs of 32 or more token characters are masked in every text. Disabled, nothing is masked. A server applies the same rule again on reception with `maskContext()`; on a context the widget masked with the same setting it changes nothing.
68
+
69
+ ## Report context v1
70
+
71
+ Snake_case JSON with a closed list of keys; see the descriptions in [`report.schema.json`](report.schema.json). Unless the site switched masking off, every text is masked in the browser before sending (see [Masking](#masking)), and again on the server.
72
+
73
+ `schema_version` (always `1`), `widget_version`, `url`, `title`, `locale`, `timezone`, `user_agent`, `viewport`, `element` (or `null` for the whole page), `console`, `network`, and the optional `capture` and `metadata` (a flat map of host strings: at most 20 keys, 64 characters per key, 500 per value).
74
+
75
+ ## Licence
76
+
77
+ [MIT](LICENSE)
@@ -0,0 +1,58 @@
1
+ export type { ConsoleEntry, ElementRect, MaskingSettings, NetworkEntry, ReportCapture, ReportContext, ReportElement, ReportMetadata, SubmissionError, SubmissionFields, SubmissionSuccess, WidgetSettings, } from "./report.generated.js";
2
+ /** Version of the report context format (`context.schema_version`). */
3
+ export declare const SCHEMA_VERSION = 1;
4
+ export { limits } from "./limits.js";
5
+ export * from "./masking.js";
6
+ /** Error codes of the submission protocol v1, with the HTTP status that carries each. */
7
+ export declare const errorCodes: {
8
+ readonly notAllowed: {
9
+ readonly code: "fixthisplz_not_allowed";
10
+ readonly status: 403;
11
+ };
12
+ readonly captchaFailed: {
13
+ readonly code: "fixthisplz_captcha_failed";
14
+ readonly status: 403;
15
+ };
16
+ readonly disabled: {
17
+ readonly code: "fixthisplz_disabled";
18
+ readonly status: 404;
19
+ };
20
+ readonly tooLarge: {
21
+ readonly code: "fixthisplz_too_large";
22
+ readonly status: 413;
23
+ };
24
+ readonly invalid: {
25
+ readonly code: "fixthisplz_invalid";
26
+ readonly status: 422;
27
+ };
28
+ readonly invalidContext: {
29
+ readonly code: "fixthisplz_invalid_context";
30
+ readonly status: 422;
31
+ };
32
+ readonly badType: {
33
+ readonly code: "fixthisplz_bad_type";
34
+ readonly status: 422;
35
+ };
36
+ readonly uploadFailed: {
37
+ readonly code: "fixthisplz_upload_failed";
38
+ readonly status: 422;
39
+ };
40
+ readonly rateLimited: {
41
+ readonly code: "fixthisplz_rate_limited";
42
+ readonly status: 429;
43
+ };
44
+ readonly storeFailed: {
45
+ readonly code: "fixthisplz_store_failed";
46
+ readonly status: 500;
47
+ };
48
+ readonly saveFailed: {
49
+ readonly code: "fixthisplz_save_failed";
50
+ readonly status: 500;
51
+ };
52
+ readonly captchaUnavailable: {
53
+ readonly code: "fixthisplz_captcha_unavailable";
54
+ readonly status: 503;
55
+ };
56
+ };
57
+ /** One of the protocol v1 error codes. */
58
+ export type ErrorCode = (typeof errorCodes)[keyof typeof errorCodes]["code"];
package/dist/index.js ADDED
@@ -0,0 +1,280 @@
1
+ // src/limits.ts
2
+ var limits = {
3
+ descriptionLength: 5e3,
4
+ reporterEmailLength: 254,
5
+ /** Raw JSON of the `context` field. */
6
+ contextBytes: 65536,
7
+ screenshotBytes: 5242880,
8
+ /** Width × height of the screenshot: decompression-bomb guard for backends. */
9
+ screenshotPixels: 4e7,
10
+ urlLength: 2048,
11
+ titleLength: 255,
12
+ localeLength: 16,
13
+ timezoneLength: 64,
14
+ userAgentLength: 512,
15
+ viewportLength: 32,
16
+ widgetVersionLength: 32,
17
+ selectorLength: 512,
18
+ tagLength: 32,
19
+ roleLength: 64,
20
+ nameLength: 200,
21
+ textLength: 300,
22
+ /** Absolute bound of each `element.rect` value. */
23
+ coordinate: 1e6,
24
+ consoleEntries: 20,
25
+ consoleMessageLength: 500,
26
+ networkEntries: 20,
27
+ networkUrlLength: 512,
28
+ methodLength: 10,
29
+ /** `at` of console and network entries. */
30
+ timestampLength: 32,
31
+ metadataKeys: 20,
32
+ metadataKeyLength: 64,
33
+ metadataValueLength: 500,
34
+ /** Names in a masking setting's `keys`. */
35
+ maskedParams: 50,
36
+ maskedParamLength: 64
37
+ };
38
+
39
+ // src/masking.ts
40
+ var DEFAULT_MASKED_PARAMS = [
41
+ "token",
42
+ "key",
43
+ "secret",
44
+ "password",
45
+ "session",
46
+ "auth",
47
+ "code",
48
+ "email"
49
+ ];
50
+ var DEFAULT_MASKING = { enabled: true, keys: [...DEFAULT_MASKED_PARAMS] };
51
+ var VALUE_MASK = "\u2026";
52
+ var WS = "\\t\\n\\v\\f\\r ";
53
+ var STEPS = [
54
+ [/* @__PURE__ */ new RegExp(`\\bBearer[${WS}]+[^${WS}]+`, "gi"), "Bearer [token]"],
55
+ [/\beyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*/g, "[token]"],
56
+ // Every repetition bounded on purpose (see Redactor.php). PHP \w under /u (UCP) is letters, numbers, "_",
57
+ // combining marks (Mn, Mc) and connector punctuation (Pc): same set here. Node's Unicode tables can be newer
58
+ // than PCRE's, so JS may mask very slightly more than PHP (safe direction).
59
+ [
60
+ /[\p{L}\p{N}\p{Mn}\p{Mc}\p{Pc}.+%-]{1,64}@[\p{L}\p{N}\p{Mn}\p{Mc}\p{Pc}-]{1,63}(?:\.[\p{L}\p{N}\p{Mn}\p{Mc}\p{Pc}-]{1,63}){1,20}/gu,
61
+ "[email]"
62
+ ],
63
+ [/[A-Za-z0-9_-]{32,}/g, "[token]"]
64
+ ];
65
+ var EMBEDDED_URL = /\b[a-z][a-z0-9+.-]*:\/\/[^\s"'<>]+/gi;
66
+ var CONTROL_AND_SPACE = /[\x00-\x20\x7f]+/g;
67
+ var VALUE_RESERVED = /[\x00-\x20\x7f%&#]/g;
68
+ var NAME_RESERVED = /[%&=#]/g;
69
+ var PATH_RESERVED = /[%?#]/g;
70
+ var LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
71
+ var ESCAPES = /(?:%[0-9A-Fa-f]{2})+/g;
72
+ function scrub(s) {
73
+ return String(s ?? "").replace(LONE_SURROGATE, "?");
74
+ }
75
+ function truncate(s, max) {
76
+ return Array.from(s).slice(0, Math.max(0, max)).join("");
77
+ }
78
+ function normalizeMaskedParam(name) {
79
+ const normalized = name.trim().toLowerCase();
80
+ const length = Array.from(normalized).length;
81
+ return length === 0 || length > limits.maskedParamLength || /[\s&=#?]/.test(normalized) ? null : normalized;
82
+ }
83
+ var STRICT_UTF8 = /* @__PURE__ */ new TextDecoder("utf-8", { fatal: true });
84
+ var LENIENT_UTF8 = /* @__PURE__ */ new TextDecoder("utf-8", { fatal: false });
85
+ function decodeRun(run, reserved) {
86
+ const bytes = Uint8Array.from(run.match(/%([0-9A-Fa-f]{2})/g) ?? [], (h) => parseInt(h.slice(1), 16));
87
+ const keep = (decoded) => reserved ? encodeReserved(decoded, reserved) : decoded;
88
+ try {
89
+ return keep(STRICT_UTF8.decode(bytes));
90
+ } catch {
91
+ return keep(LENIENT_UTF8.decode(bytes)).replace(/�/g, "?");
92
+ }
93
+ }
94
+ function decode(part, reserved) {
95
+ return part.replace(ESCAPES, (run) => decodeRun(run, reserved)).replace(CONTROL_AND_SPACE, "");
96
+ }
97
+ function isMaskedParam(name, keys) {
98
+ const decoded = decode(name).toLowerCase();
99
+ return keys.some((key) => decoded.includes(key.toLowerCase()));
100
+ }
101
+ function encodeReserved(part, reserved) {
102
+ return part.replace(reserved, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0")}`);
103
+ }
104
+ var MAX_NESTING = 4;
105
+ function maskPairs(pairs, keys, depth) {
106
+ return pairs.split("&").map((pair) => {
107
+ const equals = pair.indexOf("=");
108
+ const rawName = equals === -1 ? pair : pair.slice(0, equals);
109
+ const name = encodeReserved(decode(rawName), NAME_RESERVED);
110
+ if (isMaskedParam(name, keys)) {
111
+ return `${name}=${VALUE_MASK}`;
112
+ }
113
+ return equals === -1 ? name : `${name}=${maskValue(pair.slice(equals + 1), keys, depth)}`;
114
+ }).filter((pair) => pair !== "").join("&");
115
+ }
116
+ function maskValue(raw, keys, depth) {
117
+ const value = raw.replace(ESCAPES, (run) => decodeRun(run));
118
+ if (!value.includes("=")) {
119
+ return encodeReserved(value, VALUE_RESERVED);
120
+ }
121
+ if (depth >= MAX_NESTING) {
122
+ return VALUE_MASK;
123
+ }
124
+ const hash = value.indexOf("#");
125
+ const body = hash === -1 ? value : value.slice(0, hash);
126
+ const query = body.indexOf("?");
127
+ const head = query === -1 || body.slice(0, query).includes("=") ? "" : body.slice(0, query + 1);
128
+ const pairs = body.slice(head.length);
129
+ const after = hash === -1 ? "" : value.slice(hash + 1);
130
+ const fragment = hash === -1 ? "" : `#${after.includes("=") ? maskPairs(after, keys, depth + 1) : after}`;
131
+ return encodeReserved(`${head}${maskPairs(pairs, keys, depth + 1)}${fragment}`, VALUE_RESERVED);
132
+ }
133
+ function splitUrl(url) {
134
+ const match = URL_PATTERN.exec(url);
135
+ if (!match) {
136
+ return null;
137
+ }
138
+ const [, scheme = "", authority = "", path = "", query = ""] = match;
139
+ return { scheme, host: authority.slice(authority.lastIndexOf("@") + 1), path, query };
140
+ }
141
+ function joinUrl(scheme, host, path, query, keys) {
142
+ const pairs = maskPairs(query, keys, 0);
143
+ return `${scheme.toLowerCase()}://${host}${decode(path, PATH_RESERVED)}${pairs ? `?${pairs}` : ""}`;
144
+ }
145
+ function maskEmbedded(url, keys) {
146
+ const parts = splitUrl(url.replace(CONTROL_AND_SPACE, ""));
147
+ return parts ? joinUrl(parts.scheme, parts.host, parts.path, parts.query, keys) : "";
148
+ }
149
+ function applyPatterns(text) {
150
+ let out = text;
151
+ for (const [pattern, replacement] of STEPS) {
152
+ out = out.replace(pattern, replacement);
153
+ }
154
+ return out;
155
+ }
156
+ function maskText(value, max, masking) {
157
+ try {
158
+ const out = scrub(value);
159
+ if (!masking.enabled) {
160
+ return truncate(out, max);
161
+ }
162
+ return truncate(applyPatterns(out.replace(EMBEDDED_URL, (url) => maskEmbedded(url, masking.keys))), max);
163
+ } catch {
164
+ return "";
165
+ }
166
+ }
167
+ function splitHostPort(hostPort) {
168
+ const close = hostPort.startsWith("[") ? hostPort.indexOf("]") : -1;
169
+ const colon = hostPort.indexOf(":", close === -1 ? 0 : close);
170
+ if (colon === -1) {
171
+ return hostPort;
172
+ }
173
+ const host = hostPort.slice(0, colon);
174
+ const port = hostPort.slice(colon + 1);
175
+ if (host === "" || !/^\d*$/.test(port) || Number(port) > 65535) {
176
+ return null;
177
+ }
178
+ return port === "" ? host : `${host}:${port}`;
179
+ }
180
+ var URL_PATTERN = /^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)([^?#]*)(?:\?([^#]*))?(?:#.*)?$/;
181
+ function maskUrl(value, max, masking) {
182
+ try {
183
+ const cleaned = scrub(value).replace(CONTROL_AND_SPACE, "");
184
+ if (!masking.enabled) {
185
+ return truncate(cleaned, max);
186
+ }
187
+ const parts = splitUrl(cleaned);
188
+ const host = parts && parts.host !== "" ? splitHostPort(parts.host) : null;
189
+ if (!parts || host === null) {
190
+ return "";
191
+ }
192
+ return truncate(applyPatterns(joinUrl(parts.scheme, host, parts.path, parts.query, masking.keys)), max);
193
+ } catch {
194
+ return "";
195
+ }
196
+ }
197
+ function maskContext(context, masking) {
198
+ if (!masking.enabled) {
199
+ return context;
200
+ }
201
+ const text = (v, max) => maskText(v, max, masking);
202
+ const { element } = context;
203
+ return {
204
+ ...context,
205
+ url: maskUrl(context.url, limits.urlLength, masking),
206
+ title: text(context.title, limits.titleLength),
207
+ locale: text(context.locale, limits.localeLength),
208
+ timezone: text(context.timezone, limits.timezoneLength),
209
+ user_agent: text(context.user_agent, limits.userAgentLength),
210
+ viewport: text(context.viewport, limits.viewportLength),
211
+ element: element && {
212
+ ...element,
213
+ selector: text(element.selector, limits.selectorLength),
214
+ tag: text(element.tag, limits.tagLength),
215
+ role: text(element.role, limits.roleLength),
216
+ name: text(element.name, limits.nameLength),
217
+ text: text(element.text, limits.textLength)
218
+ },
219
+ console: context.console.map((entry) => ({
220
+ ...entry,
221
+ message: text(entry.message, limits.consoleMessageLength),
222
+ at: text(entry.at, limits.timestampLength)
223
+ })),
224
+ network: context.network.map((entry) => ({
225
+ ...entry,
226
+ url: maskUrl(entry.url, limits.networkUrlLength, masking),
227
+ at: text(entry.at, limits.timestampLength)
228
+ }))
229
+ };
230
+ }
231
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
232
+ function parseWidgetSettings(value) {
233
+ const masking = isRecord(value) ? value.masking : void 0;
234
+ if (!isRecord(masking) || typeof masking.enabled !== "boolean" || !Array.isArray(masking.keys)) {
235
+ return null;
236
+ }
237
+ if (masking.keys.length > limits.maskedParams) {
238
+ return null;
239
+ }
240
+ const keys = [];
241
+ for (const key of masking.keys) {
242
+ const normalized = typeof key === "string" ? normalizeMaskedParam(key) : null;
243
+ if (normalized === null) {
244
+ return null;
245
+ }
246
+ keys.push(normalized);
247
+ }
248
+ return { masking: { enabled: masking.enabled, keys } };
249
+ }
250
+
251
+ // src/index.ts
252
+ var SCHEMA_VERSION = 1;
253
+ var errorCodes = {
254
+ notAllowed: { code: "fixthisplz_not_allowed", status: 403 },
255
+ captchaFailed: { code: "fixthisplz_captcha_failed", status: 403 },
256
+ disabled: { code: "fixthisplz_disabled", status: 404 },
257
+ tooLarge: { code: "fixthisplz_too_large", status: 413 },
258
+ invalid: { code: "fixthisplz_invalid", status: 422 },
259
+ invalidContext: { code: "fixthisplz_invalid_context", status: 422 },
260
+ badType: { code: "fixthisplz_bad_type", status: 422 },
261
+ uploadFailed: { code: "fixthisplz_upload_failed", status: 422 },
262
+ rateLimited: { code: "fixthisplz_rate_limited", status: 429 },
263
+ storeFailed: { code: "fixthisplz_store_failed", status: 500 },
264
+ saveFailed: { code: "fixthisplz_save_failed", status: 500 },
265
+ captchaUnavailable: { code: "fixthisplz_captcha_unavailable", status: 503 }
266
+ };
267
+ export {
268
+ DEFAULT_MASKED_PARAMS,
269
+ DEFAULT_MASKING,
270
+ SCHEMA_VERSION,
271
+ errorCodes,
272
+ isMaskedParam,
273
+ limits,
274
+ maskContext,
275
+ maskText,
276
+ maskUrl,
277
+ normalizeMaskedParam,
278
+ parseWidgetSettings,
279
+ truncate
280
+ };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Size limits of a report. String lengths count characters (code points), as JSON Schema `maxLength` does;
3
+ * `*Bytes` limits count bytes. Tests keep each value equal to report.schema.json.
4
+ */
5
+ export declare const limits: {
6
+ readonly descriptionLength: 5000;
7
+ readonly reporterEmailLength: 254;
8
+ /** Raw JSON of the `context` field. */
9
+ readonly contextBytes: 65536;
10
+ readonly screenshotBytes: 5242880;
11
+ /** Width × height of the screenshot: decompression-bomb guard for backends. */
12
+ readonly screenshotPixels: 40000000;
13
+ readonly urlLength: 2048;
14
+ readonly titleLength: 255;
15
+ readonly localeLength: 16;
16
+ readonly timezoneLength: 64;
17
+ readonly userAgentLength: 512;
18
+ readonly viewportLength: 32;
19
+ readonly widgetVersionLength: 32;
20
+ readonly selectorLength: 512;
21
+ readonly tagLength: 32;
22
+ readonly roleLength: 64;
23
+ readonly nameLength: 200;
24
+ readonly textLength: 300;
25
+ /** Absolute bound of each `element.rect` value. */
26
+ readonly coordinate: 1000000;
27
+ readonly consoleEntries: 20;
28
+ readonly consoleMessageLength: 500;
29
+ readonly networkEntries: 20;
30
+ readonly networkUrlLength: 512;
31
+ readonly methodLength: 10;
32
+ /** `at` of console and network entries. */
33
+ readonly timestampLength: 32;
34
+ readonly metadataKeys: 20;
35
+ readonly metadataKeyLength: 64;
36
+ readonly metadataValueLength: 500;
37
+ /** Names in a masking setting's `keys`. */
38
+ readonly maskedParams: 50;
39
+ readonly maskedParamLength: 64;
40
+ };
@@ -0,0 +1,44 @@
1
+ import type { MaskingSettings, ReportContext, WidgetSettings } from "./report.generated.js";
2
+ /** The suggested words: a query parameter whose name contains one of them is masked. */
3
+ export declare const DEFAULT_MASKED_PARAMS: readonly string[];
4
+ /** What applies when nothing else is known: masking on, with the suggested words. */
5
+ export declare const DEFAULT_MASKING: MaskingSettings;
6
+ /** First max code points of s (never splits a surrogate pair). */
7
+ export declare function truncate(s: string, max: number): string;
8
+ /**
9
+ * A parameter name as a setting stores it: trimmed and lowercased. Null when it is empty, longer than
10
+ * `limits.maskedParamLength`, or holds whitespace or one of `& = # ?` (it could never match a name).
11
+ */
12
+ export declare function normalizeMaskedParam(name: string): string | null;
13
+ /**
14
+ * Whether a query parameter is sensitive: its name, decoded as it is written out, lowercased, contains one of the
15
+ * words. Matching by "contains" catches access_token, api_key or X-Auth-Token; it also catches author or zipcode (safe
16
+ * direction): remove the word from the list to keep those readable.
17
+ */
18
+ export declare function isMaskedParam(name: string, keys: readonly string[]): boolean;
19
+ /**
20
+ * A free text, masked then truncated (a token can never be cut into a visible fragment). Enabled: each embedded
21
+ * absolute URL is rewritten like maskUrl() (credentials and fragment dropped, listed values "…", nested ones too),
22
+ * then Bearer tokens, JWTs, e-mail addresses and runs of 32 or more token characters are masked. Disabled: only lone
23
+ * surrogates are replaced. Fails closed ('' on error).
24
+ */
25
+ export declare function maskText(value: unknown, max: number, masking: MaskingSettings): string;
26
+ /**
27
+ * A URL, masked then truncated. Enabled: scheme and host required (else ''); credentials and fragment dropped; path
28
+ * and parameter names decoded; the values of the listed parameters become "…", the others are decoded and kept, and
29
+ * looked into when they hold pairs of their own (a return URL); then the text patterns of maskText(). Disabled: the
30
+ * URL as given, without control characters. Fails closed ('' on error).
31
+ */
32
+ export declare function maskUrl(value: unknown, max: number, masking: MaskingSettings): string;
33
+ /**
34
+ * A report context with the rules applied again to every field the widget masks (the page URL, the page facts, the
35
+ * element description, the console and network entries), each bounded by its `limits` entry. metadata (host strings)
36
+ * and capture are left alone. Idempotent: a context the widget masked with the same setting comes back unchanged.
37
+ * Disabled: the context itself.
38
+ */
39
+ export declare function maskContext(context: ReportContext, masking: MaskingSettings): ReportContext;
40
+ /**
41
+ * A widget settings answer (`WidgetSettings`) after a shape and bounds check, its words normalized; null when it is
42
+ * not one. Unknown keys are ignored.
43
+ */
44
+ export declare function parseWidgetSettings(value: unknown): WidgetSettings | null;
@@ -0,0 +1,267 @@
1
+ /**
2
+ * This file was automatically generated by json-schema-to-typescript.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and run json-schema-to-typescript to regenerate this file.
5
+ */
6
+ /**
7
+ * When the entry was recorded, as an ISO 8601 UTC string from `Date.prototype.toISOString()`; empty when unknown.
8
+ *
9
+ * This interface was referenced by `ReportContext`'s JSON-Schema
10
+ * via the `definition` "Timestamp".
11
+ */
12
+ export type Timestamp = string;
13
+ /**
14
+ * Context of a FixThisPlz report, version 1: what the widget knows about the page when the reporter sends it. Sent as the JSON `context` field of a submission (protocol v1). The wire format is snake_case. Unless the site switched masking off, every text is masked in the browser before sending (Bearer tokens, JWTs, e-mail addresses and long token-like runs are masked; in URLs, the values of sensitive query parameters, per the site's masking setting, become "…") and the server masks again. Keys are a closed list.
15
+ */
16
+ export interface ReportContext {
17
+ /**
18
+ * Version of this context format. Lets a backend support several versions.
19
+ */
20
+ schema_version: 1;
21
+ /**
22
+ * Version of the widget that produced the report (replaces the 1.2.0 `plugin_version`).
23
+ */
24
+ widget_version: string;
25
+ /**
26
+ * Page URL. When masking is on: no credentials, no fragment, and the values of sensitive query parameters (per the site's masking setting) become "…"; the server masks again.
27
+ */
28
+ url: string;
29
+ /**
30
+ * Document title.
31
+ */
32
+ title: string;
33
+ /**
34
+ * Browser language (`navigator.language`), for example `fr-FR`.
35
+ */
36
+ locale: string;
37
+ /**
38
+ * IANA time zone of the browser, for example `Europe/Paris`; empty when unknown.
39
+ */
40
+ timezone: string;
41
+ /**
42
+ * Browser user agent string.
43
+ */
44
+ user_agent: string;
45
+ /**
46
+ * Viewport size as `<width>x<height>` in CSS pixels, for example `1280x720`.
47
+ */
48
+ viewport: string;
49
+ /**
50
+ * The element the reporter picked, or null for the whole page.
51
+ */
52
+ element: ReportElement | null;
53
+ /**
54
+ * Last console errors and warnings, oldest first.
55
+ *
56
+ * @maxItems 20
57
+ */
58
+ console: ConsoleEntry[];
59
+ /**
60
+ * Last failed network requests (status 400 or more, or 0 for a network failure), oldest first.
61
+ *
62
+ * @maxItems 20
63
+ */
64
+ network: NetworkEntry[];
65
+ capture?: ReportCapture;
66
+ metadata?: ReportMetadata;
67
+ }
68
+ /**
69
+ * The picked element, described without any field value.
70
+ *
71
+ * This interface was referenced by `ReportContext`'s JSON-Schema
72
+ * via the `definition` "ReportElement".
73
+ */
74
+ export interface ReportElement {
75
+ /**
76
+ * CSS selector: a stable id or test attribute when there is one, else a `tag:nth-of-type` path of at most 5 segments.
77
+ */
78
+ selector: string;
79
+ /**
80
+ * Lowercase tag name.
81
+ */
82
+ tag: string;
83
+ /**
84
+ * ARIA role, explicit or implicit; empty when none.
85
+ */
86
+ role: string;
87
+ /**
88
+ * Accessible name; empty when none.
89
+ */
90
+ name: string;
91
+ /**
92
+ * Visible text. Always empty for form fields: a field value is never sent.
93
+ */
94
+ text: string;
95
+ rect: ElementRect;
96
+ }
97
+ /**
98
+ * Bounding box of the element in viewport CSS pixels, truncated to integers.
99
+ *
100
+ * This interface was referenced by `ReportContext`'s JSON-Schema
101
+ * via the `definition` "ElementRect".
102
+ */
103
+ export interface ElementRect {
104
+ /**
105
+ * This interface was referenced by `ElementRect`'s JSON-Schema
106
+ * via the `definition` "coordinate".
107
+ */
108
+ x: number;
109
+ /**
110
+ * This interface was referenced by `ElementRect`'s JSON-Schema
111
+ * via the `definition` "coordinate".
112
+ */
113
+ y: number;
114
+ /**
115
+ * This interface was referenced by `ElementRect`'s JSON-Schema
116
+ * via the `definition` "coordinate".
117
+ */
118
+ width: number;
119
+ /**
120
+ * This interface was referenced by `ElementRect`'s JSON-Schema
121
+ * via the `definition` "coordinate".
122
+ */
123
+ height: number;
124
+ }
125
+ /**
126
+ * This interface was referenced by `ReportContext`'s JSON-Schema
127
+ * via the `definition` "ConsoleEntry".
128
+ */
129
+ export interface ConsoleEntry {
130
+ level: "error" | "warn";
131
+ /**
132
+ * Message, masked when masking is on.
133
+ */
134
+ message: string;
135
+ at: Timestamp;
136
+ }
137
+ /**
138
+ * This interface was referenced by `ReportContext`'s JSON-Schema
139
+ * via the `definition` "NetworkEntry".
140
+ */
141
+ export interface NetworkEntry {
142
+ /**
143
+ * HTTP method, uppercase letters only.
144
+ */
145
+ method: string;
146
+ /**
147
+ * Request URL, masked like `url` (sensitive query parameter values become "…"; the server masks again).
148
+ */
149
+ url: string;
150
+ /**
151
+ * HTTP status; 0 for a network failure.
152
+ */
153
+ status: number;
154
+ at: Timestamp;
155
+ }
156
+ /**
157
+ * How the attached screenshot was made. Present only when a screenshot is sent.
158
+ *
159
+ * This interface was referenced by `ReportContext`'s JSON-Schema
160
+ * via the `definition` "ReportCapture".
161
+ */
162
+ export interface ReportCapture {
163
+ /**
164
+ * `tab`: real capture of the tab; `dom`: reconstruction of the page from the DOM.
165
+ */
166
+ method: "tab" | "dom";
167
+ /**
168
+ * Whether sensitive areas were masked.
169
+ */
170
+ masked: boolean;
171
+ }
172
+ /**
173
+ * Flat map of host-supplied strings, such as an app version or a tenant. The WordPress plugin sends its page reference as `wp_page`.
174
+ *
175
+ * This interface was referenced by `ReportContext`'s JSON-Schema
176
+ * via the `definition` "ReportMetadata".
177
+ */
178
+ export interface ReportMetadata {
179
+ [k: string]: string;
180
+ }
181
+ /**
182
+ * How a site masks what the widget collects. `enabled: false`: nothing is masked, by the widget or the server. Enabled: in URLs, the values of query parameters whose name contains one of `keys` (case-insensitive) become "…", and Bearer tokens, JWTs, e-mail addresses and long token-like runs are masked in every text.
183
+ *
184
+ * This interface was referenced by `ReportContext`'s JSON-Schema
185
+ * via the `definition` "MaskingSettings".
186
+ */
187
+ export interface MaskingSettings {
188
+ enabled: boolean;
189
+ /**
190
+ * Lowercase words matched against query parameter names, at most 50.
191
+ *
192
+ * @maxItems 50
193
+ */
194
+ keys: string[];
195
+ }
196
+ /**
197
+ * Body of the optional widget settings answer (`GET <settingsUrl>`): what the site's server tells the widget before a report.
198
+ *
199
+ * This interface was referenced by `ReportContext`'s JSON-Schema
200
+ * via the `definition` "WidgetSettings".
201
+ */
202
+ export interface WidgetSettings {
203
+ masking: MaskingSettings;
204
+ [k: string]: unknown;
205
+ }
206
+ /**
207
+ * Text fields of a submission: `POST <endpoint>` as `multipart/form-data`. An optional `screenshot` file part goes with them: a JPEG of at most 5,242,880 bytes (5 MiB) and 40,000,000 pixels.
208
+ *
209
+ * This interface was referenced by `ReportContext`'s JSON-Schema
210
+ * via the `definition` "SubmissionFields".
211
+ */
212
+ export interface SubmissionFields {
213
+ /**
214
+ * What the reporter wrote, as typed. Required: blank text is refused.
215
+ */
216
+ description: string;
217
+ /**
218
+ * JSON of the report context, at most 65,536 bytes.
219
+ */
220
+ context: string;
221
+ /**
222
+ * Contact e-mail of an anonymous reporter. Ignored for a signed-in reporter.
223
+ */
224
+ reporter_email?: string;
225
+ /**
226
+ * Honeypot: must be empty. A backend answers a filled one with a fake success and drops the report.
227
+ */
228
+ website?: string;
229
+ /**
230
+ * Captcha token, when a captcha is configured.
231
+ */
232
+ captcha_token?: string;
233
+ }
234
+ /**
235
+ * Body of the `201` answer to a submission.
236
+ *
237
+ * This interface was referenced by `ReportContext`'s JSON-Schema
238
+ * via the `definition` "SubmissionSuccess".
239
+ */
240
+ export interface SubmissionSuccess {
241
+ /**
242
+ * Report id. 0 for a dropped (honeypot) submission.
243
+ */
244
+ id: number;
245
+ /**
246
+ * What the reporter sees, for example `#42`. Empty for a dropped (honeypot) submission.
247
+ */
248
+ number: string;
249
+ [k: string]: unknown;
250
+ }
251
+ /**
252
+ * Body of a refused submission, sent with an HTTP error status. Backends may add keys (WordPress adds `data.status`).
253
+ *
254
+ * This interface was referenced by `ReportContext`'s JSON-Schema
255
+ * via the `definition` "SubmissionError".
256
+ */
257
+ export interface SubmissionError {
258
+ /**
259
+ * Machine-readable code, for example `fixthisplz_rate_limited`.
260
+ */
261
+ code: string;
262
+ /**
263
+ * Human-readable, translated message. Shown to the reporter for a 422.
264
+ */
265
+ message: string;
266
+ [k: string]: unknown;
267
+ }
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@fixthisplz/schema",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "FixThisPlz report schema and submission protocol: JSON Schema, TypeScript types, limits and error codes.",
5
+ "keywords": [
6
+ "fixthisplz",
7
+ "bug-report",
8
+ "feedback",
9
+ "json-schema"
10
+ ],
11
+ "license": "MIT",
12
+ "homepage": "https://github.com/fixthisplz/fixthisplz/tree/main/packages/schema#readme",
13
+ "bugs": "https://github.com/fixthisplz/fixthisplz/issues",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/fixthisplz/fixthisplz.git",
17
+ "directory": "packages/schema"
18
+ },
19
+ "type": "module",
20
+ "sideEffects": false,
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js"
25
+ },
26
+ "./report.schema.json": "./report.schema.json",
27
+ "./package.json": "./package.json"
28
+ },
29
+ "types": "./dist/index.d.ts",
30
+ "files": [
31
+ "dist",
32
+ "report.schema.json"
33
+ ],
34
+ "engines": {
35
+ "node": ">=22.12"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "devDependencies": {
41
+ "ajv": "8.20.0",
42
+ "ajv-formats": "3.0.1",
43
+ "json-schema-to-typescript": "16.0.0",
44
+ "tsup": "9.0.0"
45
+ },
46
+ "scripts": {
47
+ "generate": "json2ts --input report.schema.json --output src/report.generated.ts --unreachableDefinitions --maxItems -1",
48
+ "build": "pnpm generate && tsup && tsc --project tsconfig.build.json",
49
+ "typecheck": "pnpm generate && tsc",
50
+ "test": "vitest run"
51
+ }
6
52
  }
@@ -0,0 +1,276 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/fixthisplz/fixthisplz/main/packages/schema/report.schema.json",
4
+ "title": "ReportContext",
5
+ "description": "Context of a FixThisPlz report, version 1: what the widget knows about the page when the reporter sends it. Sent as the JSON `context` field of a submission (protocol v1). The wire format is snake_case. Unless the site switched masking off, every text is masked in the browser before sending (Bearer tokens, JWTs, e-mail addresses and long token-like runs are masked; in URLs, the values of sensitive query parameters, per the site's masking setting, become \"…\") and the server masks again. Keys are a closed list.",
6
+ "type": "object",
7
+ "properties": {
8
+ "schema_version": {
9
+ "description": "Version of this context format. Lets a backend support several versions.",
10
+ "const": 1
11
+ },
12
+ "widget_version": {
13
+ "description": "Version of the widget that produced the report (replaces the 1.2.0 `plugin_version`).",
14
+ "type": "string",
15
+ "maxLength": 32
16
+ },
17
+ "url": {
18
+ "description": "Page URL. When masking is on: no credentials, no fragment, and the values of sensitive query parameters (per the site's masking setting) become \"…\"; the server masks again.",
19
+ "type": "string",
20
+ "pattern": "^https?://",
21
+ "maxLength": 2048
22
+ },
23
+ "title": {
24
+ "description": "Document title.",
25
+ "type": "string",
26
+ "maxLength": 255
27
+ },
28
+ "locale": {
29
+ "description": "Browser language (`navigator.language`), for example `fr-FR`.",
30
+ "type": "string",
31
+ "maxLength": 16
32
+ },
33
+ "timezone": {
34
+ "description": "IANA time zone of the browser, for example `Europe/Paris`; empty when unknown.",
35
+ "type": "string",
36
+ "maxLength": 64
37
+ },
38
+ "user_agent": {
39
+ "description": "Browser user agent string.",
40
+ "type": "string",
41
+ "maxLength": 512
42
+ },
43
+ "viewport": {
44
+ "description": "Viewport size as `<width>x<height>` in CSS pixels, for example `1280x720`.",
45
+ "type": "string",
46
+ "maxLength": 32
47
+ },
48
+ "element": {
49
+ "description": "The element the reporter picked, or null for the whole page.",
50
+ "anyOf": [{ "$ref": "#/$defs/ReportElement" }, { "type": "null" }]
51
+ },
52
+ "console": {
53
+ "description": "Last console errors and warnings, oldest first.",
54
+ "type": "array",
55
+ "maxItems": 20,
56
+ "items": { "$ref": "#/$defs/ConsoleEntry" }
57
+ },
58
+ "network": {
59
+ "description": "Last failed network requests (status 400 or more, or 0 for a network failure), oldest first.",
60
+ "type": "array",
61
+ "maxItems": 20,
62
+ "items": { "$ref": "#/$defs/NetworkEntry" }
63
+ },
64
+ "capture": { "$ref": "#/$defs/ReportCapture" },
65
+ "metadata": { "$ref": "#/$defs/ReportMetadata" }
66
+ },
67
+ "required": [
68
+ "schema_version",
69
+ "widget_version",
70
+ "url",
71
+ "title",
72
+ "locale",
73
+ "timezone",
74
+ "user_agent",
75
+ "viewport",
76
+ "element",
77
+ "console",
78
+ "network"
79
+ ],
80
+ "additionalProperties": false,
81
+ "$defs": {
82
+ "ReportElement": {
83
+ "title": "ReportElement",
84
+ "description": "The picked element, described without any field value.",
85
+ "type": "object",
86
+ "properties": {
87
+ "selector": {
88
+ "description": "CSS selector: a stable id or test attribute when there is one, else a `tag:nth-of-type` path of at most 5 segments.",
89
+ "type": "string",
90
+ "maxLength": 512
91
+ },
92
+ "tag": { "description": "Lowercase tag name.", "type": "string", "maxLength": 32 },
93
+ "role": {
94
+ "description": "ARIA role, explicit or implicit; empty when none.",
95
+ "type": "string",
96
+ "maxLength": 64
97
+ },
98
+ "name": { "description": "Accessible name; empty when none.", "type": "string", "maxLength": 200 },
99
+ "text": {
100
+ "description": "Visible text. Always empty for form fields: a field value is never sent.",
101
+ "type": "string",
102
+ "maxLength": 300
103
+ },
104
+ "rect": { "$ref": "#/$defs/ElementRect" }
105
+ },
106
+ "required": ["selector", "tag", "role", "name", "text", "rect"],
107
+ "additionalProperties": false
108
+ },
109
+ "ElementRect": {
110
+ "title": "ElementRect",
111
+ "description": "Bounding box of the element in viewport CSS pixels, truncated to integers.",
112
+ "type": "object",
113
+ "properties": {
114
+ "x": { "$ref": "#/$defs/ElementRect/$defs/coordinate" },
115
+ "y": { "$ref": "#/$defs/ElementRect/$defs/coordinate" },
116
+ "width": { "$ref": "#/$defs/ElementRect/$defs/coordinate" },
117
+ "height": { "$ref": "#/$defs/ElementRect/$defs/coordinate" }
118
+ },
119
+ "required": ["x", "y", "width", "height"],
120
+ "additionalProperties": false,
121
+ "$defs": {
122
+ "coordinate": { "type": "integer", "minimum": -1000000, "maximum": 1000000 }
123
+ }
124
+ },
125
+ "ConsoleEntry": {
126
+ "title": "ConsoleEntry",
127
+ "type": "object",
128
+ "properties": {
129
+ "level": { "enum": ["error", "warn"] },
130
+ "message": { "description": "Message, masked when masking is on.", "type": "string", "maxLength": 500 },
131
+ "at": { "$ref": "#/$defs/Timestamp" }
132
+ },
133
+ "required": ["level", "message", "at"],
134
+ "additionalProperties": false
135
+ },
136
+ "NetworkEntry": {
137
+ "title": "NetworkEntry",
138
+ "type": "object",
139
+ "properties": {
140
+ "method": {
141
+ "description": "HTTP method, uppercase letters only.",
142
+ "type": "string",
143
+ "pattern": "^[A-Z]*$",
144
+ "maxLength": 10
145
+ },
146
+ "url": {
147
+ "description": "Request URL, masked like `url` (sensitive query parameter values become \"…\"; the server masks again).",
148
+ "type": "string",
149
+ "maxLength": 512
150
+ },
151
+ "status": {
152
+ "description": "HTTP status; 0 for a network failure.",
153
+ "type": "integer",
154
+ "minimum": 0,
155
+ "maximum": 599
156
+ },
157
+ "at": { "$ref": "#/$defs/Timestamp" }
158
+ },
159
+ "required": ["method", "url", "status", "at"],
160
+ "additionalProperties": false
161
+ },
162
+ "Timestamp": {
163
+ "description": "When the entry was recorded, as an ISO 8601 UTC string from `Date.prototype.toISOString()`; empty when unknown.",
164
+ "type": "string",
165
+ "maxLength": 32
166
+ },
167
+ "ReportCapture": {
168
+ "title": "ReportCapture",
169
+ "description": "How the attached screenshot was made. Present only when a screenshot is sent.",
170
+ "type": "object",
171
+ "properties": {
172
+ "method": {
173
+ "description": "`tab`: real capture of the tab; `dom`: reconstruction of the page from the DOM.",
174
+ "enum": ["tab", "dom"]
175
+ },
176
+ "masked": { "description": "Whether sensitive areas were masked.", "type": "boolean" }
177
+ },
178
+ "required": ["method", "masked"],
179
+ "additionalProperties": false
180
+ },
181
+ "ReportMetadata": {
182
+ "title": "ReportMetadata",
183
+ "description": "Flat map of host-supplied strings, such as an app version or a tenant. The WordPress plugin sends its page reference as `wp_page`.",
184
+ "type": "object",
185
+ "maxProperties": 20,
186
+ "propertyNames": { "type": "string", "minLength": 1, "maxLength": 64 },
187
+ "additionalProperties": { "type": "string", "maxLength": 500 }
188
+ },
189
+ "MaskingSettings": {
190
+ "title": "MaskingSettings",
191
+ "description": "How a site masks what the widget collects. `enabled: false`: nothing is masked, by the widget or the server. Enabled: in URLs, the values of query parameters whose name contains one of `keys` (case-insensitive) become \"…\", and Bearer tokens, JWTs, e-mail addresses and long token-like runs are masked in every text.",
192
+ "type": "object",
193
+ "properties": {
194
+ "enabled": { "type": "boolean" },
195
+ "keys": {
196
+ "description": "Lowercase words matched against query parameter names, at most 50.",
197
+ "type": "array",
198
+ "maxItems": 50,
199
+ "items": { "type": "string", "minLength": 1, "maxLength": 64, "pattern": "^[^\\s&=#?]+$" }
200
+ }
201
+ },
202
+ "required": ["enabled", "keys"],
203
+ "additionalProperties": false
204
+ },
205
+ "WidgetSettings": {
206
+ "title": "WidgetSettings",
207
+ "description": "Body of the optional widget settings answer (`GET <settingsUrl>`): what the site's server tells the widget before a report.",
208
+ "type": "object",
209
+ "properties": { "masking": { "$ref": "#/$defs/MaskingSettings" } },
210
+ "required": ["masking"]
211
+ },
212
+ "SubmissionFields": {
213
+ "title": "SubmissionFields",
214
+ "description": "Text fields of a submission: `POST <endpoint>` as `multipart/form-data`. An optional `screenshot` file part goes with them: a JPEG of at most 5,242,880 bytes (5 MiB) and 40,000,000 pixels.",
215
+ "type": "object",
216
+ "properties": {
217
+ "description": {
218
+ "description": "What the reporter wrote, as typed. Required: blank text is refused.",
219
+ "type": "string",
220
+ "pattern": "\\S",
221
+ "maxLength": 5000
222
+ },
223
+ "context": {
224
+ "description": "JSON of the report context, at most 65,536 bytes.",
225
+ "type": "string",
226
+ "contentMediaType": "application/json",
227
+ "contentSchema": { "$ref": "#" }
228
+ },
229
+ "reporter_email": {
230
+ "description": "Contact e-mail of an anonymous reporter. Ignored for a signed-in reporter.",
231
+ "type": "string",
232
+ "format": "email",
233
+ "maxLength": 254
234
+ },
235
+ "website": {
236
+ "description": "Honeypot: must be empty. A backend answers a filled one with a fake success and drops the report.",
237
+ "type": "string",
238
+ "maxLength": 0
239
+ },
240
+ "captcha_token": { "description": "Captcha token, when a captcha is configured.", "type": "string" }
241
+ },
242
+ "required": ["description", "context"],
243
+ "additionalProperties": false
244
+ },
245
+ "SubmissionSuccess": {
246
+ "title": "SubmissionSuccess",
247
+ "description": "Body of the `201` answer to a submission.",
248
+ "type": "object",
249
+ "properties": {
250
+ "id": { "description": "Report id. 0 for a dropped (honeypot) submission.", "type": "integer", "minimum": 0 },
251
+ "number": {
252
+ "description": "What the reporter sees, for example `#42`. Empty for a dropped (honeypot) submission.",
253
+ "type": "string"
254
+ }
255
+ },
256
+ "required": ["id", "number"]
257
+ },
258
+ "SubmissionError": {
259
+ "title": "SubmissionError",
260
+ "description": "Body of a refused submission, sent with an HTTP error status. Backends may add keys (WordPress adds `data.status`).",
261
+ "type": "object",
262
+ "properties": {
263
+ "code": {
264
+ "description": "Machine-readable code, for example `fixthisplz_rate_limited`.",
265
+ "type": "string",
266
+ "minLength": 1
267
+ },
268
+ "message": {
269
+ "description": "Human-readable, translated message. Shown to the reporter for a 422.",
270
+ "type": "string"
271
+ }
272
+ },
273
+ "required": ["code", "message"]
274
+ }
275
+ }
276
+ }