disarm 0.14.0 → 0.15.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/binding.d.ts CHANGED
@@ -60,8 +60,36 @@ export interface AutoLangInspection {
60
60
  discriminatorsHit: Array<string>
61
61
  }
62
62
 
63
+ /**
64
+ * Canonicalize text for security-sensitive comparison. Not an output sanitizer —
65
+ * encode at the sink.
66
+ *
67
+ * Two steps introduce ASCII, not one (#719): the leading NFKC, and the confusable fold,
68
+ * which reaches characters NFKC leaves alone. `U+2236 RATIO` becomes `:`, `U+2044
69
+ * FRACTION SLASH` becomes `/`, `U+2216 SET MINUS` becomes `\`. A string that carried no
70
+ * delimiter can leave here carrying one. `inspectAnomalies` reports it as `confusable`
71
+ * WHEN the word also carries an ASCII letter, which is the gate that keeps ordinary
72
+ * non-Latin text from firing; a delimiter-only string is not reported.
73
+ */
63
74
  export declare function canonicalize(text: string): string
64
75
 
76
+ /**
77
+ * Strip the non-interchange and invisible classes while KEEPING the script (#698).
78
+ *
79
+ * The seven universal `strip*` primitives cannot be composed into this, and the
80
+ * difference runs in both directions. `strip_format` is *less* destructive where
81
+ * rendering matters — it preserves the Private Use Area for icon fonts and keeps the
82
+ * VS15/VS16 presentation selectors after a base (`RENDERING_STRIP`), both of which the
83
+ * naive chain deletes — and *more* destructive with whitespace, because it ends in
84
+ * `CollapseWs` and folds TAB/LF to a space where the primitives leave them. The policy
85
+ * itself is a private constant, so a caller on this binding could not express it at all.
86
+ *
87
+ * Unlike `canonicalize` it does NOT fold confusables, so non-Latin text keeps its script
88
+ * — the point of the preset.
89
+ * Canonicalize, but fail rather than silently normalize a structural difference away.
90
+ */
91
+ export declare function canonicalizeStrict(text: string): string
92
+
65
93
  /**
66
94
  * Library catalog deduplication key (like `searchKey` plus confusable folding).
67
95
  * `lang` selects the transliteration table; `strict_iso9` picks the ISO 9:1995
@@ -71,12 +99,6 @@ export declare function catalogKey(text: string, lang: string | undefined | null
71
99
 
72
100
  export declare function collapseWhitespace(text: string): string
73
101
 
74
- /**
75
- * The Unicode `confusables.txt` release the bundled confusable tables were folded
76
- * from (#560). Deliberately not called a "Unicode version": disarm's other tables
77
- * track different releases (see docs/provenance.md), so this answers one question —
78
- * how current is the confusables fold?
79
- */
80
102
  export declare function confusablesVersion(): string
81
103
 
82
104
  /** Replace emoji with their plain names; `strip_modifiers` drops skin-tone marks. */
@@ -150,6 +172,15 @@ export declare function hasAnomalies(text: string, lexicon: Array<string> | Lexi
150
172
  */
151
173
  export declare function hasBidiConflict(text: string): boolean
152
174
 
175
+ /**
176
+ * All twelve UAX #9 explicit formatting characters, uncontexted (#778).
177
+ * The counterpart to `has_bidi_conflict`, which reads strong-direction letters and is
178
+ * blind to these; the two are disjoint. The anomaly detector's `bidi` kind reports nine
179
+ * of the twelve, holding back LRM, RLM and ALM because a lone directional mark is
180
+ * ordinary in right-to-left text.
181
+ */
182
+ export declare function hasBidiControl(text: string): boolean
183
+
153
184
  /**
154
185
  * Findings from a hostname homoglyph analysis (#549). Factual signals only — a
155
186
  * `suspicious == false` result is not a safety guarantee.
@@ -186,6 +217,17 @@ export interface HostnameAnalysis {
186
217
  * so they never reach `scripts`, `mixedScript` or `canonical`.
187
218
  */
188
219
  hasInvisible: boolean
220
+ /**
221
+ * Whether any label carried a Unicode compatibility form before normalization
222
+ * (#709) — fullwidth (`google`), ligature (`file`), Roman numeral (`Ⅰ`BM),
223
+ * mathematical alphanumeric (`𝗀𝗈𝗈𝗀𝗅𝖾`). The predicate is RFC 5892 §2.1's, applied
224
+ * per code point: `toNFKC(c) != c` is DISALLOWED in an IDN label, so IDNA2008
225
+ * disallows the whole set and this folds into `suspicious`. The threat is a
226
+ * blocklist bypass, not a lookalike: `evil.com` screens clean and resolves to
227
+ * `evil.com`. The one field read from the RAW input — the normalization every
228
+ * other field needs is what erases this evidence.
229
+ */
230
+ compatFold: boolean
189
231
  /**
190
232
  * Whether the labels span more than one script. Broader/noisier than
191
233
  * `bidiConflict`; NOT folded into `suspicious`.
@@ -253,6 +295,13 @@ export interface KeyCollision {
253
295
  indices: Array<number>
254
296
  }
255
297
 
298
+ /**
299
+ * Whether a key stored under an earlier release still compares equal (#645). A
300
+ * monotonic counter, not a version: two artifacts reporting the same value produce the
301
+ * same key for the same input. Meaningless in isolation, by design.
302
+ */
303
+ export declare function keySchemaVersion(): number
304
+
256
305
  /**
257
306
  * Look up static facts about a language `code`. An unknown code raises a
258
307
  * `DisarmInvalidArgument`-tagged error.
@@ -290,7 +339,7 @@ export declare function mlNormalize(text: string, lang: string | undefined | nul
290
339
  /** Apply a normalization form: `"NFC"` | `"NFD"` | `"NFKC"` | `"NFKD"`. */
291
340
  export declare function normalize(text: string, form: string): string
292
341
 
293
- /** Fold cross-script confusables toward `target` (`"latin"` | `"cyrillic"`). */
342
+ /** Fold cross-script confusables toward `target` (`"latin"` | `"cyrillic"` | `"arabic"` | `"hebrew"`). */
294
343
  export declare function normalizeConfusables(text: string, target: string, digitPolicy: string): string
295
344
 
296
345
  /** Reverse-transliterate Latin → native script. `lang` is `"el"` | `"ru"` | `"uk"`. */
@@ -299,6 +348,12 @@ export declare function reverseTransliterate(text: string, lang: string): string
299
348
  /**
300
349
  * Turn arbitrary text into a safe filename. `platform` is `"universal"` |
301
350
  * `"windows"` | `"posix"`.
351
+ *
352
+ * A safe **filename**, not a safe URL path segment. `%` is legal in a filename, so one
353
+ * the caller typed is kept — `sanitizeFilename("..%2Fetc")` returns `"%2Fetc"` — and a
354
+ * consumer that percent-decodes the result must validate *after* decoding. What this
355
+ * will not do is manufacture one: `%` never appears in the output unless it appeared in
356
+ * the input (#721).
302
357
  */
303
358
  export declare function sanitizeFilename(text: string, separator: string, maxLength: number, platform: string, lang: string | undefined | null, preserveExtension: boolean): string
304
359
 
@@ -357,6 +412,8 @@ export declare function stripBidi(text: string): string
357
412
 
358
413
  export declare function stripControlChars(text: string): string
359
414
 
415
+ export declare function stripFormat(text: string): string
416
+
360
417
  /** Strip every Unicode noncharacter (#413). */
361
418
  export declare function stripNoncharacters(text: string): string
362
419
 
@@ -386,6 +443,18 @@ export declare function transliterate(text: string): string
386
443
  */
387
444
  export declare function transliterateOpts(text: string, scheme: string, lang?: string | undefined | null): string
388
445
 
446
+ /**
447
+ * The Unicode `confusables.txt` release the bundled confusable tables were folded
448
+ * from (#560). Deliberately not called a "Unicode version": disarm's other tables
449
+ * track different releases (see docs/provenance.md), so this answers one question —
450
+ * how current is the confusables fold?
451
+ * The UCD release disarm's normalizer implements (#645). Not a library-wide Unicode
452
+ * version — the bundled tables track different releases; this is the one integrators ask
453
+ * about, because it decides whether disarm's normalization agrees with the host
454
+ * platform's.
455
+ */
456
+ export declare function unicodeVersion(): string
457
+
389
458
  /**
390
459
  * An upstream confusable source the bundled table does not fold, located in the
391
460
  * input (#563). Mirrors `Untranslatable`, its transliteration analogue.
package/binding.js CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('disarm-android-arm64')
79
79
  const bindingPackageVersion = require('disarm-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('disarm-android-arm-eabi')
95
95
  const bindingPackageVersion = require('disarm-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('disarm-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('disarm-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('disarm-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('disarm-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('disarm-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('disarm-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('disarm-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('disarm-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('disarm-darwin-universal')
184
184
  const bindingPackageVersion = require('disarm-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('disarm-darwin-x64')
200
200
  const bindingPackageVersion = require('disarm-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('disarm-darwin-arm64')
216
216
  const bindingPackageVersion = require('disarm-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('disarm-freebsd-x64')
236
236
  const bindingPackageVersion = require('disarm-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('disarm-freebsd-arm64')
252
252
  const bindingPackageVersion = require('disarm-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('disarm-linux-x64-musl')
273
273
  const bindingPackageVersion = require('disarm-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('disarm-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('disarm-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('disarm-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('disarm-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('disarm-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('disarm-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('disarm-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('disarm-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('disarm-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('disarm-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('disarm-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('disarm-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('disarm-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('disarm-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('disarm-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('disarm-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('disarm-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('disarm-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('disarm-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('disarm-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('disarm-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('disarm-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('disarm-openharmony-arm64')
478
478
  const bindingPackageVersion = require('disarm-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('disarm-openharmony-x64')
494
494
  const bindingPackageVersion = require('disarm-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('disarm-openharmony-arm')
510
510
  const bindingPackageVersion = require('disarm-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.15.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.15.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -591,6 +591,7 @@ module.exports.Lexicon = nativeBinding.Lexicon
591
591
  module.exports.Pipeline = nativeBinding.Pipeline
592
592
  module.exports.analyzeHostname = nativeBinding.analyzeHostname
593
593
  module.exports.canonicalize = nativeBinding.canonicalize
594
+ module.exports.canonicalizeStrict = nativeBinding.canonicalizeStrict
594
595
  module.exports.catalogKey = nativeBinding.catalogKey
595
596
  module.exports.collapseWhitespace = nativeBinding.collapseWhitespace
596
597
  module.exports.confusablesVersion = nativeBinding.confusablesVersion
@@ -607,6 +608,7 @@ module.exports.graphemeTruncate = nativeBinding.graphemeTruncate
607
608
  module.exports.graphemeWidth = nativeBinding.graphemeWidth
608
609
  module.exports.hasAnomalies = nativeBinding.hasAnomalies
609
610
  module.exports.hasBidiConflict = nativeBinding.hasBidiConflict
611
+ module.exports.hasBidiControl = nativeBinding.hasBidiControl
610
612
  module.exports.inspectAnomalies = nativeBinding.inspectAnomalies
611
613
  module.exports.inspectAutoLang = nativeBinding.inspectAutoLang
612
614
  module.exports.isCaseFoldStable = nativeBinding.isCaseFoldStable
@@ -615,6 +617,7 @@ module.exports.isMixedScript = nativeBinding.isMixedScript
615
617
  module.exports.isNormalized = nativeBinding.isNormalized
616
618
  module.exports.isSuspiciousHostname = nativeBinding.isSuspiciousHostname
617
619
  module.exports.isZalgo = nativeBinding.isZalgo
620
+ module.exports.keySchemaVersion = nativeBinding.keySchemaVersion
618
621
  module.exports.langInfo = nativeBinding.langInfo
619
622
  module.exports.listContextLangs = nativeBinding.listContextLangs
620
623
  module.exports.listScripts = nativeBinding.listScripts
@@ -630,6 +633,7 @@ module.exports.sortKey = nativeBinding.sortKey
630
633
  module.exports.stripAccents = nativeBinding.stripAccents
631
634
  module.exports.stripBidi = nativeBinding.stripBidi
632
635
  module.exports.stripControlChars = nativeBinding.stripControlChars
636
+ module.exports.stripFormat = nativeBinding.stripFormat
633
637
  module.exports.stripNoncharacters = nativeBinding.stripNoncharacters
634
638
  module.exports.stripObfuscation = nativeBinding.stripObfuscation
635
639
  module.exports.stripPua = nativeBinding.stripPua
@@ -640,4 +644,5 @@ module.exports.stripZeroWidthChars = nativeBinding.stripZeroWidthChars
640
644
  module.exports.terminalWidth = nativeBinding.terminalWidth
641
645
  module.exports.transliterate = nativeBinding.transliterate
642
646
  module.exports.transliterateOpts = nativeBinding.transliterateOpts
647
+ module.exports.unicodeVersion = nativeBinding.unicodeVersion
643
648
  module.exports.unmappedConfusables = nativeBinding.unmappedConfusables
Binary file
Binary file
Binary file
Binary file
Binary file
package/index.d.ts CHANGED
@@ -25,7 +25,7 @@ export { Lexicon };
25
25
  */
26
26
  export { Pipeline };
27
27
  /** The anomaly branch that fired for a finding. */
28
- export type AnomalyKind = 'invisible' | 'bidi' | 'bidi_mixed' | 'zalgo' | 'mixed_script' | 'leet' | 'segmentation' | 'control' | 'compat_fold';
28
+ export type AnomalyKind = 'invisible' | 'bidi' | 'bidi_mixed' | 'zalgo' | 'mixed_script' | 'leet' | 'segmentation' | 'control' | 'compat_fold' | 'confusable' | 'enclosing_mark' | 'mixed_numbers' | 'duplicate_mark';
29
29
  /**
30
30
  * One reason a token is anomalous. Re-typed over the generated {@link NativeFinding}
31
31
  * so `kind` is the {@link AnomalyKind} string-union rather than a bare `string`.
@@ -62,8 +62,12 @@ export type TargetScript = 'latin' | 'cyrillic';
62
62
  *
63
63
  * Scoped to `target: 'latin'`: the override rows are generated from the Latin table and
64
64
  * carry TR39's Latin-script targets, so with `target: 'cyrillic'` the option is a no-op.
65
+ *
66
+ * `'preserve'` leaves the digit alone (#648). The other two both rewrite a non-Latin
67
+ * numeral and neither keeps the script — `२०२४` becomes `२0२४` or `२o२४`, both
68
+ * mixed-script. This one applies under every target script.
65
69
  */
66
- export type DigitPolicy = 'numeric' | 'tr39';
70
+ export type DigitPolicy = 'numeric' | 'tr39' | 'preserve';
67
71
  /** Unicode normalization form. */
68
72
  export type NormalizationForm = 'NFC' | 'NFD' | 'NFKC' | 'NFKD';
69
73
  /** Filename-safety platform ruleset. */
@@ -210,6 +214,22 @@ export declare function stripZalgo(text: string, options?: {
210
214
  export declare function isZalgo(text: string, options?: {
211
215
  threshold?: number;
212
216
  }): boolean;
217
+ /**
218
+ * Canonicalize, but throw rather than silently normalize a structural difference away —
219
+ * the half of the pair that lets a caller reject input instead of comparing a value the
220
+ * sender never wrote.
221
+ */
222
+ export declare function canonicalizeStrict(text: string): string;
223
+ /**
224
+ * Strip the non-interchange and invisible classes while KEEPING the script.
225
+ *
226
+ * Unlike {@link canonicalize} it folds no confusables, so non-Latin text survives as
227
+ * itself. It cannot be rebuilt from the seven universal `strip*` functions, and the
228
+ * difference runs both ways: this preserves the Private Use Area (icon fonts) and keeps
229
+ * the VS15/VS16 presentation selectors after a base, which the naive chain deletes, and
230
+ * it collapses TAB/LF to a space, which the primitives leave alone. Infallible.
231
+ */
232
+ export declare function stripFormat(text: string): string;
213
233
  /** Remove obfuscation (zero-width, bidi, combining-mark abuse, homoglyphs) while keeping legible content. */
214
234
  export declare function stripObfuscation(text: string): string;
215
235
  /**
@@ -320,6 +340,15 @@ export declare function analyzeHostname(host: string, options?: {
320
340
  export declare function detectScripts(text: string): string[];
321
341
  /** Whether `text` mixes characters from more than one script. */
322
342
  export declare function isMixedScript(text: string): boolean;
343
+ /**
344
+ * All twelve UAX #9 explicit formatting characters, uncontexted.
345
+ *
346
+ * The counterpart to {@link hasBidiConflict}, which reads strong-direction letters and is
347
+ * blind to these; the two are disjoint. The anomaly detector's `bidi` kind reports nine of
348
+ * the twelve, holding back LRM, RLM and ALM because a lone directional mark is ordinary in
349
+ * right-to-left text.
350
+ */
351
+ export declare function hasBidiControl(text: string): boolean;
323
352
  /**
324
353
  * Whether `text` mixes strong left-to-right and strong right-to-left characters
325
354
  * — the precondition for Bidi display-reordering ("BiDi Swap", #412). Fires on
@@ -341,6 +370,18 @@ export declare function langInfo(code: string): LangMeta;
341
370
  * unknown name throws {@link DisarmInvalidArgument}.
342
371
  */
343
372
  export declare function scriptInfo(name: string): ScriptMeta;
373
+ /**
374
+ * The UCD release disarm's normalizer implements. Not a library-wide Unicode version —
375
+ * the bundled tables track different releases. This is the one integrators ask about,
376
+ * because it decides whether disarm's normalization agrees with the host platform's.
377
+ */
378
+ export declare function unicodeVersion(): string;
379
+ /**
380
+ * Whether a key stored under an earlier release still compares equal. A monotonic
381
+ * counter, not a version — two artifacts reporting the same value produce the same key
382
+ * for the same input. Meaningless in isolation, by design.
383
+ */
384
+ export declare function keySchemaVersion(): number;
344
385
  /**
345
386
  * The Unicode `confusables.txt` release the bundled confusable tables were folded
346
387
  * from, e.g. `"17.0.0"`.
package/index.js CHANGED
@@ -59,6 +59,8 @@ exports.stripNoncharacters = stripNoncharacters;
59
59
  exports.stripPua = stripPua;
60
60
  exports.stripZalgo = stripZalgo;
61
61
  exports.isZalgo = isZalgo;
62
+ exports.canonicalizeStrict = canonicalizeStrict;
63
+ exports.stripFormat = stripFormat;
62
64
  exports.stripObfuscation = stripObfuscation;
63
65
  exports.canonicalize = canonicalize;
64
66
  exports.securityClean = securityClean;
@@ -77,10 +79,13 @@ exports.isSuspiciousHostname = isSuspiciousHostname;
77
79
  exports.analyzeHostname = analyzeHostname;
78
80
  exports.detectScripts = detectScripts;
79
81
  exports.isMixedScript = isMixedScript;
82
+ exports.hasBidiControl = hasBidiControl;
80
83
  exports.hasBidiConflict = hasBidiConflict;
81
84
  exports.inspectAutoLang = inspectAutoLang;
82
85
  exports.langInfo = langInfo;
83
86
  exports.scriptInfo = scriptInfo;
87
+ exports.unicodeVersion = unicodeVersion;
88
+ exports.keySchemaVersion = keySchemaVersion;
84
89
  exports.confusablesVersion = confusablesVersion;
85
90
  exports.listScripts = listScripts;
86
91
  exports.listContextLangs = listContextLangs;
@@ -307,6 +312,26 @@ function isZalgo(text, options = {}) {
307
312
  return call(() => native.isZalgo(text, options.threshold ?? 3));
308
313
  }
309
314
  // ── Deobfuscation & security presets ────────────────────────────────────────
315
+ /**
316
+ * Canonicalize, but throw rather than silently normalize a structural difference away —
317
+ * the half of the pair that lets a caller reject input instead of comparing a value the
318
+ * sender never wrote.
319
+ */
320
+ function canonicalizeStrict(text) {
321
+ return call(() => native.canonicalizeStrict(text));
322
+ }
323
+ /**
324
+ * Strip the non-interchange and invisible classes while KEEPING the script.
325
+ *
326
+ * Unlike {@link canonicalize} it folds no confusables, so non-Latin text survives as
327
+ * itself. It cannot be rebuilt from the seven universal `strip*` functions, and the
328
+ * difference runs both ways: this preserves the Private Use Area (icon fonts) and keeps
329
+ * the VS15/VS16 presentation selectors after a base, which the naive chain deletes, and
330
+ * it collapses TAB/LF to a space, which the primitives leave alone. Infallible.
331
+ */
332
+ function stripFormat(text) {
333
+ return native.stripFormat(text);
334
+ }
310
335
  /** Remove obfuscation (zero-width, bidi, combining-mark abuse, homoglyphs) while keeping legible content. */
311
336
  function stripObfuscation(text) {
312
337
  return call(() => native.stripObfuscation(text));
@@ -421,6 +446,17 @@ function detectScripts(text) {
421
446
  function isMixedScript(text) {
422
447
  return native.isMixedScript(text);
423
448
  }
449
+ /**
450
+ * All twelve UAX #9 explicit formatting characters, uncontexted.
451
+ *
452
+ * The counterpart to {@link hasBidiConflict}, which reads strong-direction letters and is
453
+ * blind to these; the two are disjoint. The anomaly detector's `bidi` kind reports nine of
454
+ * the twelve, holding back LRM, RLM and ALM because a lone directional mark is ordinary in
455
+ * right-to-left text.
456
+ */
457
+ function hasBidiControl(text) {
458
+ return native.hasBidiControl(text);
459
+ }
424
460
  /**
425
461
  * Whether `text` mixes strong left-to-right and strong right-to-left characters
426
462
  * — the precondition for Bidi display-reordering ("BiDi Swap", #412). Fires on
@@ -451,6 +487,22 @@ function langInfo(code) {
451
487
  function scriptInfo(name) {
452
488
  return call(() => native.scriptInfo(name));
453
489
  }
490
+ /**
491
+ * The UCD release disarm's normalizer implements. Not a library-wide Unicode version —
492
+ * the bundled tables track different releases. This is the one integrators ask about,
493
+ * because it decides whether disarm's normalization agrees with the host platform's.
494
+ */
495
+ function unicodeVersion() {
496
+ return native.unicodeVersion();
497
+ }
498
+ /**
499
+ * Whether a key stored under an earlier release still compares equal. A monotonic
500
+ * counter, not a version — two artifacts reporting the same value produce the same key
501
+ * for the same input. Meaningless in isolation, by design.
502
+ */
503
+ function keySchemaVersion() {
504
+ return native.keySchemaVersion();
505
+ }
454
506
  /**
455
507
  * The Unicode `confusables.txt` release the bundled confusable tables were folded
456
508
  * from, e.g. `"17.0.0"`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "disarm",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Unicode confusable/text-security building blocks, powered by Rust",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",