@resq-systems/security 2.1.0 → 2.1.2
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 +1 -1
- package/lib/controls/address.d.mts +8 -8
- package/lib/controls/address.d.mts.map +1 -1
- package/lib/controls/address.mjs.map +1 -1
- package/lib/controls/csrf.d.mts +7 -7
- package/lib/controls/csrf.d.mts.map +1 -1
- package/lib/controls/csrf.mjs +5 -2
- package/lib/controls/csrf.mjs.map +1 -1
- package/lib/controls/origin.d.mts +6 -6
- package/lib/controls/origin.d.mts.map +1 -1
- package/lib/controls/origin.mjs +1 -0
- package/lib/controls/origin.mjs.map +1 -1
- package/lib/controls/payload.d.mts +4 -4
- package/lib/controls/payload.d.mts.map +1 -1
- package/lib/controls/payload.mjs.map +1 -1
- package/lib/controls/query.d.mts +8 -8
- package/lib/controls/query.d.mts.map +1 -1
- package/lib/controls/query.mjs +1 -0
- package/lib/controls/query.mjs.map +1 -1
- package/lib/controls/redirect.d.mts +5 -5
- package/lib/controls/redirect.d.mts.map +1 -1
- package/lib/controls/redirect.mjs.map +1 -1
- package/lib/controls/upload.d.mts +7 -7
- package/lib/controls/upload.d.mts.map +1 -1
- package/lib/controls/upload.mjs.map +1 -1
- package/lib/crypto.d.mts +20 -21
- package/lib/crypto.d.mts.map +1 -1
- package/lib/crypto.mjs +3 -1
- package/lib/crypto.mjs.map +1 -1
- package/lib/hash.d.mts +5 -5
- package/lib/hash.d.mts.map +1 -1
- package/lib/hash.mjs +1 -0
- package/lib/hash.mjs.map +1 -1
- package/lib/paths.d.mts +5 -5
- package/lib/paths.d.mts.map +1 -1
- package/lib/paths.mjs +1 -0
- package/lib/paths.mjs.map +1 -1
- package/lib/sanitize.d.mts +36 -37
- package/lib/sanitize.d.mts.map +1 -1
- package/lib/sanitize.mjs.map +1 -1
- package/lib/threats/capec.generated.d.mts +4 -4
- package/lib/threats/capec.generated.d.mts.map +1 -1
- package/lib/threats/capec.generated.mjs.map +1 -1
- package/lib/threats/engine.d.mts +4 -5
- package/lib/threats/engine.d.mts.map +1 -1
- package/lib/threats/engine.mjs +1 -0
- package/lib/threats/engine.mjs.map +1 -1
- package/lib/threats/rules/datastore.d.mts +4 -5
- package/lib/threats/rules/datastore.d.mts.map +1 -1
- package/lib/threats/rules/datastore.mjs.map +1 -1
- package/lib/threats/rules/index.d.mts +5 -5
- package/lib/threats/rules/index.d.mts.map +1 -1
- package/lib/threats/rules/index.mjs.map +1 -1
- package/lib/threats/rules/markup.d.mts +4 -5
- package/lib/threats/rules/markup.d.mts.map +1 -1
- package/lib/threats/rules/markup.mjs +2 -1
- package/lib/threats/rules/markup.mjs.map +1 -1
- package/lib/threats/rules/protocol.d.mts +4 -5
- package/lib/threats/rules/protocol.d.mts.map +1 -1
- package/lib/threats/rules/protocol.mjs.map +1 -1
- package/lib/threats/rules/system.d.mts +4 -5
- package/lib/threats/rules/system.d.mts.map +1 -1
- package/lib/threats/rules/system.mjs +4 -4
- package/lib/threats/rules/system.mjs.map +1 -1
- package/lib/threats/rules/web.d.mts +5 -6
- package/lib/threats/rules/web.d.mts.map +1 -1
- package/lib/threats/rules/web.mjs +1 -1
- package/lib/threats/rules/web.mjs.map +1 -1
- package/lib/threats/scoring.d.mts +5 -6
- package/lib/threats/scoring.d.mts.map +1 -1
- package/lib/threats/scoring.mjs +1 -0
- package/lib/threats/scoring.mjs.map +1 -1
- package/lib/threats/types.d.mts +18 -18
- package/lib/threats/types.d.mts.map +1 -1
- package/lib/threats/types.mjs.map +1 -1
- package/lib/threats/variants.d.mts +3 -4
- package/lib/threats/variants.d.mts.map +1 -1
- package/lib/threats/variants.mjs.map +1 -1
- package/lib/unicode/confusables.d.mts +5 -5
- package/lib/unicode/confusables.d.mts.map +1 -1
- package/lib/unicode/confusables.mjs +1 -0
- package/lib/unicode/confusables.mjs.map +1 -1
- package/lib/unicode/index.d.mts +11 -11
- package/lib/unicode/index.d.mts.map +1 -1
- package/lib/unicode/index.mjs +1 -0
- package/lib/unicode/index.mjs.map +1 -1
- package/lib/validators.d.mts +89 -39
- package/lib/validators.d.mts.map +1 -1
- package/lib/validators.mjs +285 -21
- package/lib/validators.mjs.map +1 -1
- package/package.json +7 -7
package/lib/validators.d.mts
CHANGED
|
@@ -7,7 +7,7 @@ import { ThreatFinding, ThreatType } from "./threats/types.mjs";
|
|
|
7
7
|
* {@link scanForThreats}, whose result adds a numeric score and an allow/review/block
|
|
8
8
|
* verdict instead of collapsing everything into one boolean.
|
|
9
9
|
*/
|
|
10
|
-
interface ThreatDetectionResult {
|
|
10
|
+
export interface ThreatDetectionResult {
|
|
11
11
|
/** `true` when no detector fired. Equivalent to `threats.length === 0`. */
|
|
12
12
|
isSafe: boolean;
|
|
13
13
|
/** Findings from the enabled detectors, at most one per weakness category. */
|
|
@@ -20,7 +20,7 @@ interface ThreatDetectionResult {
|
|
|
20
20
|
* summary — or a finding from an older version of this package — without having to
|
|
21
21
|
* populate the full record.
|
|
22
22
|
*/
|
|
23
|
-
interface ThreatSummary {
|
|
23
|
+
export interface ThreatSummary {
|
|
24
24
|
/** Weakness category. The only field the message depends on. */
|
|
25
25
|
readonly type: ThreatType;
|
|
26
26
|
/** Operator-facing description, if available. */
|
|
@@ -39,7 +39,7 @@ interface ThreatSummary {
|
|
|
39
39
|
* `checkCommandInjection` → `shell`, `checkPathTraversal` → `filesystem`;
|
|
40
40
|
* `checkHomoglyphs` runs UTS #39 identifier analysis.
|
|
41
41
|
*/
|
|
42
|
-
interface ThreatDetectionConfig {
|
|
42
|
+
export interface ThreatDetectionConfig {
|
|
43
43
|
/** Default `true`. Maps to the `html` context. */
|
|
44
44
|
checkXSS?: boolean;
|
|
45
45
|
/** Default `true`. Maps to the `sql` context. */
|
|
@@ -71,7 +71,7 @@ interface ThreatDetectionConfig {
|
|
|
71
71
|
* // → [{ ruleId: "XSS-EVENT-HANDLER-001", type: "xss", severity: "high", … }]
|
|
72
72
|
* ```
|
|
73
73
|
*/
|
|
74
|
-
declare function containsXSSPatterns(input: string): ThreatFinding[];
|
|
74
|
+
export declare function containsXSSPatterns(input: string): ThreatFinding[];
|
|
75
75
|
/**
|
|
76
76
|
* Detect prototype-pollution payloads — `__proto__`, `constructor.prototype`, and the
|
|
77
77
|
* nested-object forms that arrive through a JSON body or query-string expansion.
|
|
@@ -83,7 +83,7 @@ declare function containsXSSPatterns(input: string): ThreatFinding[];
|
|
|
83
83
|
* @param input - String to scan.
|
|
84
84
|
* @returns Empty array, or a single finding of type `"prototype_pollution"`.
|
|
85
85
|
*/
|
|
86
|
-
declare function containsPrototypePollution(input: string): ThreatFinding[];
|
|
86
|
+
export declare function containsPrototypePollution(input: string): ThreatFinding[];
|
|
87
87
|
/**
|
|
88
88
|
* Detect SQL-injection patterns in a value bound for a query.
|
|
89
89
|
*
|
|
@@ -94,7 +94,7 @@ declare function containsPrototypePollution(input: string): ThreatFinding[];
|
|
|
94
94
|
* @param input - String to scan. Truncated at 100 000 characters.
|
|
95
95
|
* @returns Empty array, or one finding of type `"sql_injection"`.
|
|
96
96
|
*/
|
|
97
|
-
declare function containsSQLInjection(input: string): ThreatFinding[];
|
|
97
|
+
export declare function containsSQLInjection(input: string): ThreatFinding[];
|
|
98
98
|
/**
|
|
99
99
|
* Detect NoSQL operator injection — `$where`, `$ne`, `$regex`, and the object and
|
|
100
100
|
* array forms that bypass authentication filters in document stores.
|
|
@@ -102,7 +102,7 @@ declare function containsSQLInjection(input: string): ThreatFinding[];
|
|
|
102
102
|
* @param input - String to scan.
|
|
103
103
|
* @returns Empty array, or one finding of type `"nosql_injection"`.
|
|
104
104
|
*/
|
|
105
|
-
declare function containsNoSQLInjection(input: string): ThreatFinding[];
|
|
105
|
+
export declare function containsNoSQLInjection(input: string): ThreatFinding[];
|
|
106
106
|
/**
|
|
107
107
|
* Detect shell command-injection patterns — command substitution, chained commands,
|
|
108
108
|
* pipes into an interpreter.
|
|
@@ -114,7 +114,7 @@ declare function containsNoSQLInjection(input: string): ThreatFinding[];
|
|
|
114
114
|
* @param input - String to scan. Truncated at 100 000 characters.
|
|
115
115
|
* @returns Empty array, or one finding of type `"command_injection"`.
|
|
116
116
|
*/
|
|
117
|
-
declare function containsCommandInjection(input: string): ThreatFinding[];
|
|
117
|
+
export declare function containsCommandInjection(input: string): ThreatFinding[];
|
|
118
118
|
/**
|
|
119
119
|
* Detect path-traversal payloads — `../`, its percent-encoded and double-encoded
|
|
120
120
|
* forms, NUL truncation, and references to sensitive system paths.
|
|
@@ -127,7 +127,7 @@ declare function containsCommandInjection(input: string): ThreatFinding[];
|
|
|
127
127
|
* @param input - String to scan.
|
|
128
128
|
* @returns Empty array, or one finding of type `"path_traversal"`.
|
|
129
129
|
*/
|
|
130
|
-
declare function containsPathTraversal(input: string): ThreatFinding[];
|
|
130
|
+
export declare function containsPathTraversal(input: string): ThreatFinding[];
|
|
131
131
|
/**
|
|
132
132
|
* Detect visually confusable characters in a **protected identifier**.
|
|
133
133
|
*
|
|
@@ -142,7 +142,7 @@ declare function containsPathTraversal(input: string): ThreatFinding[];
|
|
|
142
142
|
* @param input - Identifier to scan.
|
|
143
143
|
* @returns Empty array, or a single finding of type `"homoglyph"`.
|
|
144
144
|
*/
|
|
145
|
-
declare function containsHomoglyphs(input: string): ThreatFinding[];
|
|
145
|
+
export declare function containsHomoglyphs(input: string): ThreatFinding[];
|
|
146
146
|
/**
|
|
147
147
|
* Run the enabled detectors against `input` and aggregate findings.
|
|
148
148
|
*
|
|
@@ -157,7 +157,7 @@ declare function containsHomoglyphs(input: string): ThreatFinding[];
|
|
|
157
157
|
* @param config - Detector toggles. Everything except command injection defaults on.
|
|
158
158
|
* @returns `{ isSafe, threats }`.
|
|
159
159
|
*/
|
|
160
|
-
declare function detectThreatPatterns(input: string, config?: ThreatDetectionConfig): ThreatDetectionResult;
|
|
160
|
+
export declare function detectThreatPatterns(input: string, config?: ThreatDetectionConfig): ThreatDetectionResult;
|
|
161
161
|
/**
|
|
162
162
|
* Boolean shortcut over {@link detectThreatPatterns}.
|
|
163
163
|
*
|
|
@@ -165,7 +165,7 @@ declare function detectThreatPatterns(input: string, config?: ThreatDetectionCon
|
|
|
165
165
|
* @param config - Optional detector toggles.
|
|
166
166
|
* @returns `true` when no detector fires.
|
|
167
167
|
*/
|
|
168
|
-
declare function isSafeInput(input: string, config?: ThreatDetectionConfig): boolean;
|
|
168
|
+
export declare function isSafeInput(input: string, config?: ThreatDetectionConfig): boolean;
|
|
169
169
|
/**
|
|
170
170
|
* HTML-entity-escape a value being inserted as **element text**.
|
|
171
171
|
*
|
|
@@ -193,7 +193,7 @@ declare function isSafeInput(input: string, config?: ThreatDetectionConfig): boo
|
|
|
193
193
|
* // "<script>alert("xss")</script>"
|
|
194
194
|
* ```
|
|
195
195
|
*/
|
|
196
|
-
declare function escapeHtmlText(input: string): string;
|
|
196
|
+
export declare function escapeHtmlText(input: string): string;
|
|
197
197
|
/**
|
|
198
198
|
* HTML-entity-escape a value being inserted as an **attribute value**.
|
|
199
199
|
*
|
|
@@ -212,7 +212,7 @@ declare function escapeHtmlText(input: string): string;
|
|
|
212
212
|
* @param input - Untrusted string. Non-string or empty input yields `""`.
|
|
213
213
|
* @returns Output safe to interpolate into a quoted or unquoted attribute value.
|
|
214
214
|
*/
|
|
215
|
-
declare function escapeHtmlAttribute(input: string): string;
|
|
215
|
+
export declare function escapeHtmlAttribute(input: string): string;
|
|
216
216
|
/**
|
|
217
217
|
* HTML-entity-escape a value for display.
|
|
218
218
|
*
|
|
@@ -224,7 +224,7 @@ declare function escapeHtmlAttribute(input: string): string;
|
|
|
224
224
|
* @param input - Untrusted string.
|
|
225
225
|
* @returns Entity-escaped output.
|
|
226
226
|
*/
|
|
227
|
-
declare function sanitizeForDisplay(input: string): string;
|
|
227
|
+
export declare function sanitizeForDisplay(input: string): string;
|
|
228
228
|
/**
|
|
229
229
|
* Escape a value for inclusion in a log record.
|
|
230
230
|
*
|
|
@@ -251,7 +251,7 @@ declare function sanitizeForDisplay(input: string): string;
|
|
|
251
251
|
* // "alice\\nINFO user promoted to admin" — one line, no forged entry
|
|
252
252
|
* ```
|
|
253
253
|
*/
|
|
254
|
-
declare function encodeLogValue(value: string, options?: {
|
|
254
|
+
export declare function encodeLogValue(value: string, options?: {
|
|
255
255
|
readonly maxLength?: number;
|
|
256
256
|
}): string;
|
|
257
257
|
/**
|
|
@@ -260,19 +260,67 @@ declare function encodeLogValue(value: string, options?: {
|
|
|
260
260
|
* This is the control named by the formula-injection rules. A CSV file is not inert: a
|
|
261
261
|
* cell beginning `=`, `+`, `-`, `@`, tab or CR is evaluated as a formula by Excel,
|
|
262
262
|
* Sheets and LibreOffice when the recipient opens it, so the payload executes on *their*
|
|
263
|
-
* machine, outside the exporting application entirely (CWE-1236).
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
263
|
+
* machine, outside the exporting application entirely (CWE-1236). LF and the full-width
|
|
264
|
+
* `=` `+` `-` `@` are treated as triggers too, following the OWASP CSV Injection list,
|
|
265
|
+
* and so is any character whose NFKC form is a trigger or part of the leading run.
|
|
266
|
+
*
|
|
267
|
+
* Two separate jobs, in order: neutralise formula triggers with apostrophes, then apply
|
|
268
|
+
* RFC 4180 quoting so the field cannot break the row for a reader that splits on the same
|
|
269
|
+
* delimiter.
|
|
270
|
+
*
|
|
271
|
+
* A trigger is neutralised wherever a reader may start a field in text: at the start of
|
|
272
|
+
* the value, and right after each boundary inside it. The boundaries are comma,
|
|
273
|
+
* semicolon, TAB, CR and LF; the other line separators of Python's `str.splitlines()`
|
|
274
|
+
* (VT, FF, U+001C to U+001E, U+0085, U+2028 and U+2029); U+037E, which NFC folds onto
|
|
275
|
+
* `;`; and each character of the delimiter. The apostrophe goes in front of the leading
|
|
276
|
+
* run there, as it does at the start. A reader that splits on any boundary, or that
|
|
277
|
+
* ignores quotes, therefore finds every field that starts inside the value neutralised,
|
|
278
|
+
* in every column, even after an earlier cell has thrown it out of step. A field that
|
|
279
|
+
* starts at a boundary at the very end of the value runs on into the file's closing quote,
|
|
280
|
+
* delimiter or line break and then the next cell, which is neutralised in its own right.
|
|
281
|
+
* The work is linear in the value's length.
|
|
282
|
+
*
|
|
283
|
+
* At the start of the value, TAB, CR and LF are triggers, as OWASP lists them. After a
|
|
284
|
+
* boundary they are leading-run characters only: a run of them in front of `=` `+` `-`
|
|
285
|
+
* `@` or a full-width or small form is seen through and neutralised, but on their own
|
|
286
|
+
* they lead no formula there. So `"x,\t=1"` becomes `"x,'\t'=1"`, while plain multi-line
|
|
287
|
+
* or tab-separated text such as `"line1\r\nline2"` keeps its value.
|
|
288
|
+
*
|
|
289
|
+
* **Numbers, booleans and bigints are never prefixed.** They came from the application's
|
|
290
|
+
* own types and cannot carry a formula, so `-1234` exports as a negative number while
|
|
270
291
|
* `"-1234"` exports as text. Pass numeric columns as numbers, or every negative value in
|
|
271
|
-
* the sheet becomes a string.
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
292
|
+
* the sheet becomes a string. Every other value is treated as text, including an array or
|
|
293
|
+
* object, whose string form repeats contents the caller may not control.
|
|
294
|
+
*
|
|
295
|
+
* Worth knowing before relying on it:
|
|
296
|
+
* - **Values can change after a boundary, by design.** A reader that uses the delimiter
|
|
297
|
+
* the file was written with shows an apostrophe inserted after a boundary as part of the
|
|
298
|
+
* value: `"a\n=b"` reads back as `"a\n'=b"`. Only a formula lead gets one, so text such
|
|
299
|
+
* as `"line1\r\nline2"`, `"a\n\nb"` or `"x,\ty"` reads back unchanged. Without it, a
|
|
300
|
+
* reader that splits on that boundary would start a cell there whose leading characters
|
|
301
|
+
* were never checked.
|
|
302
|
+
* - The apostrophe is an Excel convention, **not** an RFC 4180 construct. Readers that do
|
|
303
|
+
* not implement it surface it as a literal character in the data.
|
|
304
|
+
* - **A reader that splits on any other character is not protected.** That includes `|`,
|
|
305
|
+
* a space, and a character that only NFKC folds onto a boundary, such as the full-width
|
|
306
|
+
* comma U+FF0C. A value holding one of them followed by a trigger gets no apostrophe
|
|
307
|
+
* there, and is quoted only if it holds a character that requires quoting. Quoting
|
|
308
|
+
* protects that reader at most in the first column; in any later column, or wherever the
|
|
309
|
+
* value is not quoted, it starts a live cell there. Read the file with the delimiter it
|
|
310
|
+
* was written with.
|
|
311
|
+
* - A field containing a comma, semicolon or TAB is quoted whatever the delimiter, and so
|
|
312
|
+
* is a field containing any character of a multi-character delimiter. Quoting changes no
|
|
313
|
+
* value, and protects only a reader in step with the writer.
|
|
314
|
+
* - **The delimiter must play no other part in the file.** It is written between cells,
|
|
315
|
+
* where no apostrophe can go, and `escapeCsvField` accepts any delimiter. One containing
|
|
316
|
+
* `=`, `+`, `-`, `@` or a character whose NFKC form is one of them, such as their
|
|
317
|
+
* full-width or small forms, puts a trigger at the start of a field for a reader that
|
|
318
|
+
* splits on anything else: `toCsvRow(["", "1+1"], { delimiter: "=" })` is `=1+1`. One
|
|
319
|
+
* containing `'` lets a reader that splits on it cut the apostrophe off a neutralised
|
|
320
|
+
* cell. One containing `"`, CR or LF leaves the apostrophes working but breaks RFC 4180
|
|
321
|
+
* framing: a `"` there opens a quoted field where the writer meant a delimiter, and CR
|
|
322
|
+
* or LF ends the record for every RFC 4180 reader. No reader can then count on staying
|
|
323
|
+
* in step with the writer, which is all that quoting protects.
|
|
276
324
|
* - NUL is removed rather than escaped, so it does not round-trip.
|
|
277
325
|
* - Scanning the output with `scanForThreats` still reports a finding, by design:
|
|
278
326
|
* `CSV-FORMULA-LEAD-001` sees through the apostrophe and `CSV-DDE-001` is
|
|
@@ -288,10 +336,12 @@ declare function encodeLogValue(value: string, options?: {
|
|
|
288
336
|
* ```ts
|
|
289
337
|
* escapeCsvField("=WEBSERVICE(\"https://evil.example\")");
|
|
290
338
|
* // quoted, and inert on open
|
|
339
|
+
* escapeCsvField("a\n=1+1"); // "\"a\n'=1+1\"" — inert after the line break too
|
|
340
|
+
* escapeCsvField("a\r\nb"); // "\"a\r\nb\"" — quoted, value unchanged
|
|
291
341
|
* escapeCsvField(-1234); // "-1234" — a number, not a formula
|
|
292
342
|
* ```
|
|
293
343
|
*/
|
|
294
|
-
declare function escapeCsvField(value: unknown, options?: {
|
|
344
|
+
export declare function escapeCsvField(value: unknown, options?: {
|
|
295
345
|
readonly delimiter?: string;
|
|
296
346
|
}): string;
|
|
297
347
|
/**
|
|
@@ -307,7 +357,7 @@ declare function escapeCsvField(value: unknown, options?: {
|
|
|
307
357
|
* toCsvRow(["Ada Lovelace", "=1+1", 42]);
|
|
308
358
|
* ```
|
|
309
359
|
*/
|
|
310
|
-
declare function toCsvRow(values: readonly unknown[], options?: {
|
|
360
|
+
export declare function toCsvRow(values: readonly unknown[], options?: {
|
|
311
361
|
readonly delimiter?: string;
|
|
312
362
|
}): string;
|
|
313
363
|
/**
|
|
@@ -338,7 +388,7 @@ declare function toCsvRow(values: readonly unknown[], options?: {
|
|
|
338
388
|
* const html = "<script>window.__DATA__ = " + json + ";</script>";
|
|
339
389
|
* ```
|
|
340
390
|
*/
|
|
341
|
-
declare function encodeJsonForScript(value: unknown): string;
|
|
391
|
+
export declare function encodeJsonForScript(value: unknown): string;
|
|
342
392
|
/**
|
|
343
393
|
* Fold non-ASCII lookalike characters onto ASCII and compose to NFC.
|
|
344
394
|
*
|
|
@@ -354,12 +404,12 @@ declare function encodeJsonForScript(value: unknown): string;
|
|
|
354
404
|
* @param input - Raw string from an untrusted source. Non-string input yields `""`.
|
|
355
405
|
* @returns NFC-composed string with non-ASCII confusables folded to ASCII.
|
|
356
406
|
*/
|
|
357
|
-
declare function normalizeUnicode(input: string): string;
|
|
407
|
+
export declare function normalizeUnicode(input: string): string;
|
|
358
408
|
/**
|
|
359
409
|
* Generic user-facing fallback message. Render verbatim when a detector fires and you
|
|
360
410
|
* do not want to reveal which one.
|
|
361
411
|
*/
|
|
362
|
-
declare const THREAT_DETECTED_MESSAGE = "Input contains potentially unsafe content";
|
|
412
|
+
export declare const THREAT_DETECTED_MESSAGE = "Input contains potentially unsafe content";
|
|
363
413
|
/**
|
|
364
414
|
* Refinement helper for `zod.string().refine(...)`, `effect/Schema.filter(...)`, or
|
|
365
415
|
* any predicate-based validator. Equivalent to {@link isSafeInput} with defaults.
|
|
@@ -367,7 +417,7 @@ declare const THREAT_DETECTED_MESSAGE = "Input contains potentially unsafe conte
|
|
|
367
417
|
* @param input - String to test.
|
|
368
418
|
* @returns `true` when no detector fires.
|
|
369
419
|
*/
|
|
370
|
-
declare function validateSafeText(input: string): boolean;
|
|
420
|
+
export declare function validateSafeText(input: string): boolean;
|
|
371
421
|
/**
|
|
372
422
|
* Validate a human name field.
|
|
373
423
|
*
|
|
@@ -397,7 +447,7 @@ declare function validateSafeText(input: string): boolean;
|
|
|
397
447
|
* validatePersonName("<script>x</script>"); // false
|
|
398
448
|
* ```
|
|
399
449
|
*/
|
|
400
|
-
declare function validatePersonName(input: string): boolean;
|
|
450
|
+
export declare function validatePersonName(input: string): boolean;
|
|
401
451
|
/**
|
|
402
452
|
* Validate a human name field.
|
|
403
453
|
*
|
|
@@ -409,7 +459,7 @@ declare function validatePersonName(input: string): boolean;
|
|
|
409
459
|
* @param input - Candidate name.
|
|
410
460
|
* @returns `true` when the value is a plausible name.
|
|
411
461
|
*/
|
|
412
|
-
declare function validateSafeName(input: string): boolean;
|
|
462
|
+
export declare function validateSafeName(input: string): boolean;
|
|
413
463
|
/**
|
|
414
464
|
* Validate an email address.
|
|
415
465
|
*
|
|
@@ -424,7 +474,7 @@ declare function validateSafeName(input: string): boolean;
|
|
|
424
474
|
* @param input - Candidate address.
|
|
425
475
|
* @returns `true` when the format is valid and the domain is not a script mix.
|
|
426
476
|
*/
|
|
427
|
-
declare function validateSafeEmail(input: string): boolean;
|
|
477
|
+
export declare function validateSafeEmail(input: string): boolean;
|
|
428
478
|
/**
|
|
429
479
|
* Render a user-facing error message for a detection result.
|
|
430
480
|
*
|
|
@@ -437,10 +487,10 @@ declare function validateSafeEmail(input: string): boolean;
|
|
|
437
487
|
* @returns A message, or `""` when the result is safe — so `message || undefined`
|
|
438
488
|
* works at a call site.
|
|
439
489
|
*/
|
|
440
|
-
declare function getThreatErrorMessage(result: {
|
|
490
|
+
export declare function getThreatErrorMessage(result: {
|
|
441
491
|
readonly isSafe: boolean;
|
|
442
492
|
readonly threats: readonly ThreatSummary[];
|
|
443
493
|
}): string;
|
|
444
494
|
//#endregion
|
|
445
|
-
export {
|
|
495
|
+
export type { ThreatFinding, ThreatType };
|
|
446
496
|
//# sourceMappingURL=validators.d.mts.map
|
package/lib/validators.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.mts","names":[],"sources":["../src/validators.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"validators.d.mts","names":[],"sources":["../src/validators.ts"],"mappings":";;;;;;;;;iBAiDiB;;EAEhB;;EAEA,SAAS;;;;;;;;;iBAUO;;WAEP,MAAM;;WAEN;;WAEA;;;;;;;;;;;;;iBAkBO;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;;;;;;;;;;;;;;wBAkDe,oBAAoB,gBAAgB;;;;;;;;;;;;wBAepC,2BAA2B,gBAAgB;;;;;;;;;;;wBAc3C,qBAAqB,gBAAgB;;;;;;;;wBAWrC,uBAAuB,gBAAgB;;;;;;;;;;;;wBAevC,yBAAyB,gBAAgB;;;;;;;;;;;;;wBAgBzC,sBAAsB,gBAAgB;;;;;;;;;;;;;;;wBA2CtC,mBAAmB,gBAAgB;;;;;;;;;;;;;;;wBA0CnC,qBACf,eACA,SAAQ,wBACN;;;;;;;;wBA8Ba,YAAY,eAAe,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmCpC,eAAe;;;;;;;;;;;;;;;;;;;wBA4Cf,oBAAoB;;;;;;;;;;;;wBAwBpB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwDnB,eACf,eACA;WAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAiXL,eACf,gBACA;WAAoB;;;;;;;;;;;;;;;wBA8CL,SACf,4BACA;WAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAyDL,oBAAoB;;;;;;;;;;;;;;;;wBAuCpB,iBAAiB;;;;;qBAYpB;;;;;;;;wBASG,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAoDjB,mBAAmB;;;;;;;;;;;;wBAyBnB,iBAAiB;;;;;;;;;;;;;;;wBAyBjB,kBAAkB;;;;;;;;;;;;;wBA2BlB,sBAAsB;WAC5B;WACA,kBAAkB"}
|