disarm 0.14.1 → 0.16.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
@@ -27,6 +27,17 @@ export declare class Lexicon {
27
27
  export declare class Pipeline {
28
28
  /** Run the named pipeline over `text`, returning the cleaned string. */
29
29
  process(text: string): string
30
+ /**
31
+ * What the named profile this was built from is for, in one sentence (#860).
32
+ * `null` for a pipeline not built from a profile.
33
+ */
34
+ get purpose(): string | null
35
+ /**
36
+ * A copy of this pipeline whose confusable passes fold under `digitPolicy` (#646).
37
+ * Throws when the profile has no confusables step and the policy is not the default:
38
+ * a setting that would never run is refused rather than kept.
39
+ */
40
+ withDigitPolicy(digitPolicy: string): Pipeline
30
41
  }
31
42
 
32
43
  /**
@@ -60,23 +71,64 @@ export interface AutoLangInspection {
60
71
  discriminatorsHit: Array<string>
61
72
  }
62
73
 
63
- export declare function canonicalize(text: string): string
74
+ /**
75
+ * Canonicalize text for security-sensitive comparison. Not an output sanitizer —
76
+ * encode at the sink.
77
+ *
78
+ * Two steps introduce ASCII, not one (#719): the leading NFKC, and the confusable fold,
79
+ * which reaches characters NFKC leaves alone. `U+2236 RATIO` becomes `:`, `U+2044
80
+ * FRACTION SLASH` becomes `/`, `U+2216 SET MINUS` becomes `\`. A string that carried no
81
+ * delimiter can leave here carrying one. `inspectAnomalies` reports it as `confusable`
82
+ * WHEN the word also carries an ASCII letter, which is the gate that keeps ordinary
83
+ * non-Latin text from firing; a delimiter-only string is not reported.
84
+ */
85
+ export declare function canonicalize(text: string, digitPolicy: string): string
86
+
87
+ /**
88
+ * Strip the non-interchange and invisible classes while KEEPING the script (#698).
89
+ *
90
+ * The seven universal `strip*` primitives cannot be composed into this, and the
91
+ * difference runs in both directions. `strip_format` is *less* destructive where
92
+ * rendering matters — it preserves the Private Use Area for icon fonts and keeps the
93
+ * VS15/VS16 presentation selectors after a base (`RENDERING_STRIP`), both of which the
94
+ * naive chain deletes — and *more* destructive with whitespace, because it ends in
95
+ * `CollapseWs` and folds TAB/LF to a space where the primitives leave them. The policy
96
+ * itself is a private constant, so a caller on this binding could not express it at all.
97
+ *
98
+ * Unlike `canonicalize` it does NOT fold confusables, so non-Latin text keeps its script
99
+ * — the point of the preset.
100
+ * Canonicalize, but fail rather than silently normalize a structural difference away.
101
+ */
102
+ export declare function canonicalizeStrict(text: string, digitPolicy: string): string
64
103
 
65
104
  /**
66
105
  * Library catalog deduplication key (like `searchKey` plus confusable folding).
67
106
  * `lang` selects the transliteration table; `strict_iso9` picks the ISO 9:1995
68
107
  * Cyrillic scheme.
69
108
  */
70
- export declare function catalogKey(text: string, lang: string | undefined | null, strictIso9: boolean): string
109
+ export declare function catalogKey(text: string, lang: string | undefined | null, strictIso9: boolean, digitPolicy: string): string
71
110
 
72
111
  export declare function collapseWhitespace(text: string): string
73
112
 
74
113
  /**
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?
114
+ * TR39 sources whose prototype is in `script`, and how many the bundled tables fold
115
+ * (#963). The denominator `unmappedConfusables` does not have: it measures one table
116
+ * against the whole source population, so a script disarm ships no table for reports a
117
+ * number determined by that absence. An unknown name raises a
118
+ * `DisarmInvalidArgument`-tagged error.
79
119
  */
120
+ export declare function confusableCoverage(script: string): ConfusableCoverage
121
+
122
+ /** Per-script confusable coverage — the fair denominator (#963). */
123
+ export interface ConfusableCoverage {
124
+ /** The script the figures are about, in disarm's spelling. */
125
+ script: string
126
+ /** TR39 sources whose prototype is in this script. */
127
+ sources: number
128
+ /** How many of those `sources` a bundled fold table reaches. */
129
+ folded: number
130
+ }
131
+
80
132
  export declare function confusablesVersion(): string
81
133
 
82
134
  /** Replace emoji with their plain names; `strip_modifiers` drops skin-tone marks. */
@@ -88,6 +140,9 @@ export declare function demojize(text: string, stripModifiers: boolean): string
88
140
  */
89
141
  export declare function detectScripts(text: string): Array<string>
90
142
 
143
+ /** Levenshtein edit distance between `a` and `b`, in characters (#894). */
144
+ export declare function editDistance(a: string, b: string): number
145
+
91
146
  /** One reason a token is anomalous (a single finding). */
92
147
  export interface Finding {
93
148
  /** Which branch fired: `"invisible"` | `"bidi"` | `"zalgo"` | `"mixed_script"` | `"bidi_mixed"` | `"leet"` | `"segmentation"`. */
@@ -150,6 +205,15 @@ export declare function hasAnomalies(text: string, lexicon: Array<string> | Lexi
150
205
  */
151
206
  export declare function hasBidiConflict(text: string): boolean
152
207
 
208
+ /**
209
+ * All twelve UAX #9 explicit formatting characters, uncontexted (#778).
210
+ * The counterpart to `has_bidi_conflict`, which reads strong-direction letters and is
211
+ * blind to these; the two are disjoint. The anomaly detector's `bidi` kind reports nine
212
+ * of the twelve, holding back LRM, RLM and ALM because a lone directional mark is
213
+ * ordinary in right-to-left text.
214
+ */
215
+ export declare function hasBidiControl(text: string): boolean
216
+
153
217
  /**
154
218
  * Findings from a hostname homoglyph analysis (#549). Factual signals only — a
155
219
  * `suspicious == false` result is not a safety guarantee.
@@ -186,6 +250,17 @@ export interface HostnameAnalysis {
186
250
  * so they never reach `scripts`, `mixedScript` or `canonical`.
187
251
  */
188
252
  hasInvisible: boolean
253
+ /**
254
+ * Whether any label carried a Unicode compatibility form before normalization
255
+ * (#709) — fullwidth (`google`), ligature (`file`), Roman numeral (`Ⅰ`BM),
256
+ * mathematical alphanumeric (`𝗀𝗈𝗈𝗀𝗅𝖾`). The predicate is RFC 5892 §2.1's, applied
257
+ * per code point: `toNFKC(c) != c` is DISALLOWED in an IDN label, so IDNA2008
258
+ * disallows the whole set and this folds into `suspicious`. The threat is a
259
+ * blocklist bypass, not a lookalike: `evil.com` screens clean and resolves to
260
+ * `evil.com`. The one field read from the RAW input — the normalization every
261
+ * other field needs is what erases this evidence.
262
+ */
263
+ compatFold: boolean
189
264
  /**
190
265
  * Whether the labels span more than one script. Broader/noisier than
191
266
  * `bidiConflict`; NOT folded into `suspicious`.
@@ -214,6 +289,9 @@ export declare function inspectAnomalies(text: string, lexicon: Array<string> |
214
289
  /** Explain how auto-language detection resolves `text`. */
215
290
  export declare function inspectAutoLang(text: string): AutoLangInspection
216
291
 
292
+ /** Whether `text` is already its own canonical form under `preset` (#730). */
293
+ export declare function isCanonical(text: string, preset: string): boolean
294
+
217
295
  /**
218
296
  * Whether case folding and simple lowercasing agree, so the value is a stable
219
297
  * identity key (#619).
@@ -253,6 +331,13 @@ export interface KeyCollision {
253
331
  indices: Array<number>
254
332
  }
255
333
 
334
+ /**
335
+ * Whether a key stored under an earlier release still compares equal (#645). A
336
+ * monotonic counter, not a version: two artifacts reporting the same value produce the
337
+ * same key for the same input. Meaningless in isolation, by design.
338
+ */
339
+ export declare function keySchemaVersion(): number
340
+
256
341
  /**
257
342
  * Look up static facts about a language `code`. An unknown code raises a
258
343
  * `DisarmInvalidArgument`-tagged error.
@@ -287,18 +372,46 @@ export declare function listScripts(): Array<string>
287
372
  */
288
373
  export declare function mlNormalize(text: string, lang: string | undefined | null, emojiStyle: string, foldCase: boolean): string
289
374
 
375
+ /**
376
+ * The candidate closest to `value`, with its distance, or `null` beyond `max_distance`
377
+ * (#894). An exact match is reported with distance 0; ties go to the first candidate at
378
+ * the lowest distance.
379
+ */
380
+ export declare function nearestMatch(value: string, candidates: Array<string>, maxDistance: number): NearestMatch | null
381
+
382
+ /** A candidate and how far `nearestMatch` found it from the value asked about (#894). */
383
+ export interface NearestMatch {
384
+ /** The candidate, in the spelling the caller supplied. */
385
+ value: string
386
+ /** Its edit distance from the value asked about; `0` means the value *is* this candidate. */
387
+ distance: number
388
+ }
389
+
290
390
  /** Apply a normalization form: `"NFC"` | `"NFD"` | `"NFKC"` | `"NFKD"`. */
291
391
  export declare function normalize(text: string, form: string): string
292
392
 
293
- /** Fold cross-script confusables toward `target` (`"latin"` | `"cyrillic"`). */
393
+ /** Fold cross-script confusables toward `target` (`"latin"` | `"cyrillic"` | `"arabic"` | `"hebrew"`). */
294
394
  export declare function normalizeConfusables(text: string, target: string, digitPolicy: string): string
295
395
 
396
+ /**
397
+ * Replace every emoji with `replacement`, verbatim (#972). The counterpart to
398
+ * `demojize`: that names an emoji from the CLDR table, which is wider than the emoji
399
+ * set, and this replaces what the UCD calls an emoji and nothing else.
400
+ */
401
+ export declare function replaceEmoji(text: string, replacement: string): string
402
+
296
403
  /** Reverse-transliterate Latin → native script. `lang` is `"el"` | `"ru"` | `"uk"`. */
297
404
  export declare function reverseTransliterate(text: string, lang: string): string
298
405
 
299
406
  /**
300
407
  * Turn arbitrary text into a safe filename. `platform` is `"universal"` |
301
408
  * `"windows"` | `"posix"`.
409
+ *
410
+ * A safe **filename**, not a safe URL path segment. `%` is legal in a filename, so one
411
+ * the caller typed is kept — `sanitizeFilename("..%2Fetc")` returns `"%2Fetc"` — and a
412
+ * consumer that percent-decodes the result must validate *after* decoding. What this
413
+ * will not do is manufacture one: `%` never appears in the output unless it appeared in
414
+ * the input (#721).
302
415
  */
303
416
  export declare function sanitizeFilename(text: string, separator: string, maxLength: number, platform: string, lang: string | undefined | null, preserveExtension: boolean): string
304
417
 
@@ -324,7 +437,15 @@ export interface ScriptMeta {
324
437
  * Case/accent/script-insensitive search lookup key. `lang` selects the
325
438
  * transliteration table (omit for none).
326
439
  */
327
- export declare function searchKey(text: string, lang?: string | undefined | null): string
440
+ export declare function searchKey(text: string, lang: string | undefined | null, digitPolicy: string): string
441
+
442
+ /**
443
+ * The TR39 identifier skeleton plus the two prototype classes disarm's table keeps apart
444
+ * (#650). A spoof key: its only job is to make confusable identifiers collide, and its
445
+ * output is never for display. `digit_policy` is `"numeric"` (the letter half only),
446
+ * `"tr39"` (adds `1 ≡ l` and `0 ≡ O`) or `"preserve"`.
447
+ */
448
+ export declare function skeletonKey(text: string, digitPolicy: string): string
328
449
 
329
450
  /** Generate a URL-safe slug. */
330
451
  export declare function slugify(text: string, opts: SlugOptions): string
@@ -349,7 +470,7 @@ export interface SlugOptions {
349
470
  * Collation sort key (like `searchKey` but preserves base accented characters
350
471
  * for correct ordering). `lang` selects the transliteration table.
351
472
  */
352
- export declare function sortKey(text: string, lang?: string | undefined | null): string
473
+ export declare function sortKey(text: string, lang: string | undefined | null, digitPolicy: string): string
353
474
 
354
475
  export declare function stripAccents(text: string): string
355
476
 
@@ -357,10 +478,12 @@ export declare function stripBidi(text: string): string
357
478
 
358
479
  export declare function stripControlChars(text: string): string
359
480
 
481
+ export declare function stripFormat(text: string): string
482
+
360
483
  /** Strip every Unicode noncharacter (#413). */
361
484
  export declare function stripNoncharacters(text: string): string
362
485
 
363
- export declare function stripObfuscation(text: string): string
486
+ export declare function stripObfuscation(text: string, digitPolicy: string): string
364
487
 
365
488
  /** Strip every Private Use Area code point (#413). */
366
489
  export declare function stripPua(text: string): string
@@ -386,6 +509,18 @@ export declare function transliterate(text: string): string
386
509
  */
387
510
  export declare function transliterateOpts(text: string, scheme: string, lang?: string | undefined | null): string
388
511
 
512
+ /**
513
+ * The Unicode `confusables.txt` release the bundled confusable tables were folded
514
+ * from (#560). Deliberately not called a "Unicode version": disarm's other tables
515
+ * track different releases (see docs/provenance.md), so this answers one question —
516
+ * how current is the confusables fold?
517
+ * The UCD release disarm's normalizer implements (#645). Not a library-wide Unicode
518
+ * version — the bundled tables track different releases; this is the one integrators ask
519
+ * about, because it decides whether disarm's normalization agrees with the host
520
+ * platform's.
521
+ */
522
+ export declare function unicodeVersion(): string
523
+
389
524
  /**
390
525
  * An upstream confusable source the bundled table does not fold, located in the
391
526
  * 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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.16.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.16.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.1' && 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.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.16.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.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -591,11 +591,14 @@ 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
597
+ module.exports.confusableCoverage = nativeBinding.confusableCoverage
596
598
  module.exports.confusablesVersion = nativeBinding.confusablesVersion
597
599
  module.exports.demojize = nativeBinding.demojize
598
600
  module.exports.detectScripts = nativeBinding.detectScripts
601
+ module.exports.editDistance = nativeBinding.editDistance
599
602
  module.exports.findKeyCollisions = nativeBinding.findKeyCollisions
600
603
  module.exports.findUnmappedConfusables = nativeBinding.findUnmappedConfusables
601
604
  module.exports.findUntranslatable = nativeBinding.findUntranslatable
@@ -607,29 +610,36 @@ module.exports.graphemeTruncate = nativeBinding.graphemeTruncate
607
610
  module.exports.graphemeWidth = nativeBinding.graphemeWidth
608
611
  module.exports.hasAnomalies = nativeBinding.hasAnomalies
609
612
  module.exports.hasBidiConflict = nativeBinding.hasBidiConflict
613
+ module.exports.hasBidiControl = nativeBinding.hasBidiControl
610
614
  module.exports.inspectAnomalies = nativeBinding.inspectAnomalies
611
615
  module.exports.inspectAutoLang = nativeBinding.inspectAutoLang
616
+ module.exports.isCanonical = nativeBinding.isCanonical
612
617
  module.exports.isCaseFoldStable = nativeBinding.isCaseFoldStable
613
618
  module.exports.isConfusable = nativeBinding.isConfusable
614
619
  module.exports.isMixedScript = nativeBinding.isMixedScript
615
620
  module.exports.isNormalized = nativeBinding.isNormalized
616
621
  module.exports.isSuspiciousHostname = nativeBinding.isSuspiciousHostname
617
622
  module.exports.isZalgo = nativeBinding.isZalgo
623
+ module.exports.keySchemaVersion = nativeBinding.keySchemaVersion
618
624
  module.exports.langInfo = nativeBinding.langInfo
619
625
  module.exports.listContextLangs = nativeBinding.listContextLangs
620
626
  module.exports.listScripts = nativeBinding.listScripts
621
627
  module.exports.mlNormalize = nativeBinding.mlNormalize
628
+ module.exports.nearestMatch = nativeBinding.nearestMatch
622
629
  module.exports.normalize = nativeBinding.normalize
623
630
  module.exports.normalizeConfusables = nativeBinding.normalizeConfusables
631
+ module.exports.replaceEmoji = nativeBinding.replaceEmoji
624
632
  module.exports.reverseTransliterate = nativeBinding.reverseTransliterate
625
633
  module.exports.sanitizeFilename = nativeBinding.sanitizeFilename
626
634
  module.exports.scriptInfo = nativeBinding.scriptInfo
627
635
  module.exports.searchKey = nativeBinding.searchKey
636
+ module.exports.skeletonKey = nativeBinding.skeletonKey
628
637
  module.exports.slugify = nativeBinding.slugify
629
638
  module.exports.sortKey = nativeBinding.sortKey
630
639
  module.exports.stripAccents = nativeBinding.stripAccents
631
640
  module.exports.stripBidi = nativeBinding.stripBidi
632
641
  module.exports.stripControlChars = nativeBinding.stripControlChars
642
+ module.exports.stripFormat = nativeBinding.stripFormat
633
643
  module.exports.stripNoncharacters = nativeBinding.stripNoncharacters
634
644
  module.exports.stripObfuscation = nativeBinding.stripObfuscation
635
645
  module.exports.stripPua = nativeBinding.stripPua
@@ -640,4 +650,5 @@ module.exports.stripZeroWidthChars = nativeBinding.stripZeroWidthChars
640
650
  module.exports.terminalWidth = nativeBinding.terminalWidth
641
651
  module.exports.transliterate = nativeBinding.transliterate
642
652
  module.exports.transliterateOpts = nativeBinding.transliterateOpts
653
+ module.exports.unicodeVersion = nativeBinding.unicodeVersion
643
654
  module.exports.unmappedConfusables = nativeBinding.unmappedConfusables
Binary file
Binary file
Binary file
Binary file
Binary file
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Lexicon, Pipeline } from './binding';
2
- import type { Untranslatable, UnmappedConfusable, AutoLangInspection, KeyCollision, LangMeta, ScriptMeta, Finding as NativeFinding, AnomalyReport as NativeAnomalyReport, HostnameAnalysis as NativeHostnameAnalysis } from './binding';
3
- export type { Untranslatable, UnmappedConfusable, AutoLangInspection, KeyCollision, LangMeta, ScriptMeta, };
2
+ import type { Untranslatable, UnmappedConfusable, AutoLangInspection, KeyCollision, LangMeta, ScriptMeta, ConfusableCoverage, Finding as NativeFinding, AnomalyReport as NativeAnomalyReport, HostnameAnalysis as NativeHostnameAnalysis } from './binding';
3
+ export type { Untranslatable, UnmappedConfusable, AutoLangInspection, KeyCollision, LangMeta, ScriptMeta, ConfusableCoverage, };
4
4
  /** Findings from {@link analyzeHostname}. `suspicious` is a maximally
5
5
  * conservative screen, not a precise verdict (#549). */
6
6
  export type HostnameAnalysis = NativeHostnameAnalysis;
@@ -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' | 'deletion' | 'smuggled';
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. */
@@ -89,6 +93,20 @@ export declare function normalizeConfusables(text: string, options?: {
89
93
  target?: TargetScript;
90
94
  digitPolicy?: DigitPolicy;
91
95
  }): string;
96
+ /**
97
+ * Whether `text` is already its own canonical form under `preset` (#730).
98
+ *
99
+ * The verification-path counterpart to the presets: text in, normalized text out is the
100
+ * generation path, and this is the question a caller asks about bytes that arrive already
101
+ * bound. `hasAnomalies` is not this predicate — 142,760 assigned code points are reported
102
+ * clean by the detector and are not their own canonical form.
103
+ *
104
+ * `preset` is any name in the preset registry or any profile, defaulting to
105
+ * `'canonicalize'`. An unknown one throws {@link DisarmInvalidArgument}.
106
+ */
107
+ export declare function isCanonical(text: string, options?: {
108
+ preset?: string;
109
+ }): boolean;
92
110
  /** Whether `text` contains a character confusable with `target` (default `'latin'`). */
93
111
  export declare function isConfusable(text: string, options?: {
94
112
  target?: TargetScript;
@@ -169,6 +187,19 @@ export declare function findKeyCollisions(values: string[], key: CollisionKey, o
169
187
  export declare function demojize(text: string, options?: {
170
188
  stripModifiers?: boolean;
171
189
  }): string;
190
+ /** Replace every emoji with `replacement`, verbatim (#972).
191
+ *
192
+ * The counterpart to {@link demojize}, and a different question of a different table.
193
+ * `demojize` asks *what does CLDR call this?*, so its domain is the CLDR name table,
194
+ * which is wider than the emoji: `demojize('x™y')` is `'x trade mark y'`. This asks *is
195
+ * this an emoji by the UCD's properties?* — `Emoji_Presentation=Yes`, an `Emoji=Yes` base
196
+ * carrying `U+FE0F`, and the ZWJ, modifier, keycap and flag sequences on those. Nothing
197
+ * else moves.
198
+ *
199
+ * `replacement` is inserted exactly as given, with no padding and no whitespace collapse:
200
+ * `''` closes an intra-word split (`aa🔥bb` → `aabb`) and `' '` keeps two words apart
201
+ * (`stop🛑now` → `stop now`), and no rule serves both. */
202
+ export declare function replaceEmoji(text: string, replacement?: string): string;
172
203
  /** Apply a Unicode normalization `form` (default `'NFC'`). */
173
204
  export declare function normalize(text: string, options?: {
174
205
  form?: NormalizationForm;
@@ -210,8 +241,28 @@ export declare function stripZalgo(text: string, options?: {
210
241
  export declare function isZalgo(text: string, options?: {
211
242
  threshold?: number;
212
243
  }): boolean;
244
+ /**
245
+ * Canonicalize, but throw rather than silently normalize a structural difference away —
246
+ * the half of the pair that lets a caller reject input instead of comparing a value the
247
+ * sender never wrote.
248
+ */
249
+ export declare function canonicalizeStrict(text: string, options?: {
250
+ digitPolicy?: DigitPolicy;
251
+ }): string;
252
+ /**
253
+ * Strip the non-interchange and invisible classes while KEEPING the script.
254
+ *
255
+ * Unlike {@link canonicalize} it folds no confusables, so non-Latin text survives as
256
+ * itself. It cannot be rebuilt from the seven universal `strip*` functions, and the
257
+ * difference runs both ways: this preserves the Private Use Area (icon fonts) and keeps
258
+ * the VS15/VS16 presentation selectors after a base, which the naive chain deletes, and
259
+ * it collapses TAB/LF to a space, which the primitives leave alone. Infallible.
260
+ */
261
+ export declare function stripFormat(text: string): string;
213
262
  /** Remove obfuscation (zero-width, bidi, combining-mark abuse, homoglyphs) while keeping legible content. */
214
- export declare function stripObfuscation(text: string): string;
263
+ export declare function stripObfuscation(text: string, options?: {
264
+ digitPolicy?: DigitPolicy;
265
+ }): string;
215
266
  /**
216
267
  * Canonicalize text for security-sensitive comparison: NFKC → strip bidi/format
217
268
  * → strip invisible classes (#413) → strip control → strip zero-width → collapse
@@ -221,7 +272,9 @@ export declare function stripObfuscation(text: string): string;
221
272
  * The name describes the mechanism (Unicode canonicalization for matching), not
222
273
  * a safety guarantee — this is not an output sanitizer; encode at the sink.
223
274
  */
224
- export declare function canonicalize(text: string): string;
275
+ export declare function canonicalize(text: string, options?: {
276
+ digitPolicy?: DigitPolicy;
277
+ }): string;
225
278
  /**
226
279
  * @deprecated Renamed to {@link canonicalize} in 0.11 (the `*Clean` name
227
280
  * overpromised safety); removed in 1.0.
@@ -252,6 +305,7 @@ export declare function sanitizeFilename(text: string, options?: SanitizeFilenam
252
305
  */
253
306
  export declare function searchKey(text: string, options?: {
254
307
  lang?: string;
308
+ digitPolicy?: DigitPolicy;
255
309
  }): string;
256
310
  /**
257
311
  * Collation sort key — like {@link searchKey} but preserves base accented
@@ -259,6 +313,7 @@ export declare function searchKey(text: string, options?: {
259
313
  */
260
314
  export declare function sortKey(text: string, options?: {
261
315
  lang?: string;
316
+ digitPolicy?: DigitPolicy;
262
317
  }): string;
263
318
  /**
264
319
  * Library catalog deduplication key — like {@link searchKey} plus confusable
@@ -268,7 +323,38 @@ export declare function sortKey(text: string, options?: {
268
323
  export declare function catalogKey(text: string, options?: {
269
324
  lang?: string;
270
325
  strictIso9?: boolean;
326
+ digitPolicy?: DigitPolicy;
327
+ }): string;
328
+ /**
329
+ * The TR39 identifier skeleton plus the two prototype classes disarm's table keeps
330
+ * apart (#650). A spoof key: its only job is to make confusable identifiers collide,
331
+ * and its output is never for display. `digitPolicy` `'numeric'` (default) applies the
332
+ * letter half only; `'tr39'` adds `1 ≡ l` and `0 ≡ O`; `'preserve'` keeps a non-Latin
333
+ * numeral in its script.
334
+ */
335
+ export declare function skeletonKey(text: string, options?: {
336
+ digitPolicy?: DigitPolicy;
271
337
  }): string;
338
+ /**
339
+ * Levenshtein edit distance between `a` and `b`, in characters (#894) — the one class of
340
+ * registry spoofing the confusable tables deliberately do not model (`paypa1`, `adm1n`).
341
+ * Canonicalize both sides first when composed and decomposed spellings should compare
342
+ * equal.
343
+ */
344
+ export declare function editDistance(a: string, b: string): number;
345
+ /** A candidate and how far {@link nearestMatch} found it from the value asked about. */
346
+ export interface NearestMatch {
347
+ value: string;
348
+ distance: number;
349
+ }
350
+ /**
351
+ * The candidate closest to `value`, with its distance, or `null` beyond `maxDistance`
352
+ * (default 1). Reports; it does not decide. An exact match is reported with distance 0,
353
+ * and ties go to the first candidate at the lowest distance (#894).
354
+ */
355
+ export declare function nearestMatch(value: string, candidates: string[], options?: {
356
+ maxDistance?: number;
357
+ }): NearestMatch | null;
272
358
  /** Options for {@link mlNormalize}. */
273
359
  export interface MlNormalizeOptions {
274
360
  /** Language code selecting the transliteration table; omit for none. */
@@ -320,6 +406,15 @@ export declare function analyzeHostname(host: string, options?: {
320
406
  export declare function detectScripts(text: string): string[];
321
407
  /** Whether `text` mixes characters from more than one script. */
322
408
  export declare function isMixedScript(text: string): boolean;
409
+ /**
410
+ * All twelve UAX #9 explicit formatting characters, uncontexted.
411
+ *
412
+ * The counterpart to {@link hasBidiConflict}, which reads strong-direction letters and is
413
+ * blind to these; the two are disjoint. The anomaly detector's `bidi` kind reports nine of
414
+ * the twelve, holding back LRM, RLM and ALM because a lone directional mark is ordinary in
415
+ * right-to-left text.
416
+ */
417
+ export declare function hasBidiControl(text: string): boolean;
323
418
  /**
324
419
  * Whether `text` mixes strong left-to-right and strong right-to-left characters
325
420
  * — the precondition for Bidi display-reordering ("BiDi Swap", #412). Fires on
@@ -341,6 +436,33 @@ export declare function langInfo(code: string): LangMeta;
341
436
  * unknown name throws {@link DisarmInvalidArgument}.
342
437
  */
343
438
  export declare function scriptInfo(name: string): ScriptMeta;
439
+ /** TR39 sources whose prototype is in `script`, and how many of those disarm's bundled
440
+ * tables fold (#963).
441
+ *
442
+ * The denominator {@link unmappedConfusables} does not have. That function measures one
443
+ * bundled table against the whole 6,565-source population, which is the right question
444
+ * for a target disarm ships and a misleading one for a script it does not: Greek reports
445
+ * almost the entire population unmapped, and the number means only "there is no Greek
446
+ * table".
447
+ *
448
+ * `folded` counts sources any bundled table reaches, not sources folded *toward* this
449
+ * script — Greek is 71 of 159 because the Latin table folds Greek letters that look
450
+ * Latin. The grouping uses the UCD's script property, so `"Yi"` and 18 other scripts
451
+ * disarm's own enum does not name are addressable here. A script disarm knows that TR39
452
+ * never uses as a prototype returns 0 of 0. */
453
+ export declare function confusableCoverage(script: string): ConfusableCoverage;
454
+ /**
455
+ * The UCD release disarm's normalizer implements. Not a library-wide Unicode version —
456
+ * the bundled tables track different releases. This is the one integrators ask about,
457
+ * because it decides whether disarm's normalization agrees with the host platform's.
458
+ */
459
+ export declare function unicodeVersion(): string;
460
+ /**
461
+ * Whether a key stored under an earlier release still compares equal. A monotonic
462
+ * counter, not a version — two artifacts reporting the same value produce the same key
463
+ * for the same input. Meaningless in isolation, by design.
464
+ */
465
+ export declare function keySchemaVersion(): number;
344
466
  /**
345
467
  * The Unicode `confusables.txt` release the bundled confusable tables were folded
346
468
  * from, e.g. `"17.0.0"`.
package/index.js CHANGED
@@ -38,6 +38,7 @@ exports.transliterate = transliterate;
38
38
  exports.reverseTransliterate = reverseTransliterate;
39
39
  exports.findUntranslatable = findUntranslatable;
40
40
  exports.normalizeConfusables = normalizeConfusables;
41
+ exports.isCanonical = isCanonical;
41
42
  exports.isConfusable = isConfusable;
42
43
  exports.unmappedConfusables = unmappedConfusables;
43
44
  exports.findUnmappedConfusables = findUnmappedConfusables;
@@ -47,6 +48,7 @@ exports.foldCase = foldCase;
47
48
  exports.isCaseFoldStable = isCaseFoldStable;
48
49
  exports.findKeyCollisions = findKeyCollisions;
49
50
  exports.demojize = demojize;
51
+ exports.replaceEmoji = replaceEmoji;
50
52
  exports.normalize = normalize;
51
53
  exports.isNormalized = isNormalized;
52
54
  exports.collapseWhitespace = collapseWhitespace;
@@ -59,6 +61,8 @@ exports.stripNoncharacters = stripNoncharacters;
59
61
  exports.stripPua = stripPua;
60
62
  exports.stripZalgo = stripZalgo;
61
63
  exports.isZalgo = isZalgo;
64
+ exports.canonicalizeStrict = canonicalizeStrict;
65
+ exports.stripFormat = stripFormat;
62
66
  exports.stripObfuscation = stripObfuscation;
63
67
  exports.canonicalize = canonicalize;
64
68
  exports.securityClean = securityClean;
@@ -67,6 +71,9 @@ exports.sanitizeFilename = sanitizeFilename;
67
71
  exports.searchKey = searchKey;
68
72
  exports.sortKey = sortKey;
69
73
  exports.catalogKey = catalogKey;
74
+ exports.skeletonKey = skeletonKey;
75
+ exports.editDistance = editDistance;
76
+ exports.nearestMatch = nearestMatch;
70
77
  exports.mlNormalize = mlNormalize;
71
78
  exports.graphemeLen = graphemeLen;
72
79
  exports.graphemeSplit = graphemeSplit;
@@ -77,10 +84,14 @@ exports.isSuspiciousHostname = isSuspiciousHostname;
77
84
  exports.analyzeHostname = analyzeHostname;
78
85
  exports.detectScripts = detectScripts;
79
86
  exports.isMixedScript = isMixedScript;
87
+ exports.hasBidiControl = hasBidiControl;
80
88
  exports.hasBidiConflict = hasBidiConflict;
81
89
  exports.inspectAutoLang = inspectAutoLang;
82
90
  exports.langInfo = langInfo;
83
91
  exports.scriptInfo = scriptInfo;
92
+ exports.confusableCoverage = confusableCoverage;
93
+ exports.unicodeVersion = unicodeVersion;
94
+ exports.keySchemaVersion = keySchemaVersion;
84
95
  exports.confusablesVersion = confusablesVersion;
85
96
  exports.listScripts = listScripts;
86
97
  exports.listContextLangs = listContextLangs;
@@ -162,6 +173,20 @@ function findUntranslatable(text, options = {}) {
162
173
  function normalizeConfusables(text, options = {}) {
163
174
  return call(() => native.normalizeConfusables(text, options.target ?? 'latin', options.digitPolicy ?? 'numeric'));
164
175
  }
176
+ /**
177
+ * Whether `text` is already its own canonical form under `preset` (#730).
178
+ *
179
+ * The verification-path counterpart to the presets: text in, normalized text out is the
180
+ * generation path, and this is the question a caller asks about bytes that arrive already
181
+ * bound. `hasAnomalies` is not this predicate — 142,760 assigned code points are reported
182
+ * clean by the detector and are not their own canonical form.
183
+ *
184
+ * `preset` is any name in the preset registry or any profile, defaulting to
185
+ * `'canonicalize'`. An unknown one throws {@link DisarmInvalidArgument}.
186
+ */
187
+ function isCanonical(text, options = {}) {
188
+ return call(() => native.isCanonical(text, options.preset ?? 'canonicalize'));
189
+ }
165
190
  /** Whether `text` contains a character confusable with `target` (default `'latin'`). */
166
191
  function isConfusable(text, options = {}) {
167
192
  return call(() => native.isConfusable(text, options.target ?? 'latin'));
@@ -247,6 +272,21 @@ function findKeyCollisions(values, key, options = {}) {
247
272
  function demojize(text, options = {}) {
248
273
  return native.demojize(text, options.stripModifiers ?? false);
249
274
  }
275
+ /** Replace every emoji with `replacement`, verbatim (#972).
276
+ *
277
+ * The counterpart to {@link demojize}, and a different question of a different table.
278
+ * `demojize` asks *what does CLDR call this?*, so its domain is the CLDR name table,
279
+ * which is wider than the emoji: `demojize('x™y')` is `'x trade mark y'`. This asks *is
280
+ * this an emoji by the UCD's properties?* — `Emoji_Presentation=Yes`, an `Emoji=Yes` base
281
+ * carrying `U+FE0F`, and the ZWJ, modifier, keycap and flag sequences on those. Nothing
282
+ * else moves.
283
+ *
284
+ * `replacement` is inserted exactly as given, with no padding and no whitespace collapse:
285
+ * `''` closes an intra-word split (`aa🔥bb` → `aabb`) and `' '` keeps two words apart
286
+ * (`stop🛑now` → `stop now`), and no rule serves both. */
287
+ function replaceEmoji(text, replacement = '') {
288
+ return native.replaceEmoji(text, replacement);
289
+ }
250
290
  // ── Normalization ───────────────────────────────────────────────────────────
251
291
  /** Apply a Unicode normalization `form` (default `'NFC'`). */
252
292
  function normalize(text, options = {}) {
@@ -307,9 +347,29 @@ function isZalgo(text, options = {}) {
307
347
  return call(() => native.isZalgo(text, options.threshold ?? 3));
308
348
  }
309
349
  // ── Deobfuscation & security presets ────────────────────────────────────────
350
+ /**
351
+ * Canonicalize, but throw rather than silently normalize a structural difference away —
352
+ * the half of the pair that lets a caller reject input instead of comparing a value the
353
+ * sender never wrote.
354
+ */
355
+ function canonicalizeStrict(text, options = {}) {
356
+ return call(() => native.canonicalizeStrict(text, options.digitPolicy ?? 'numeric'));
357
+ }
358
+ /**
359
+ * Strip the non-interchange and invisible classes while KEEPING the script.
360
+ *
361
+ * Unlike {@link canonicalize} it folds no confusables, so non-Latin text survives as
362
+ * itself. It cannot be rebuilt from the seven universal `strip*` functions, and the
363
+ * difference runs both ways: this preserves the Private Use Area (icon fonts) and keeps
364
+ * the VS15/VS16 presentation selectors after a base, which the naive chain deletes, and
365
+ * it collapses TAB/LF to a space, which the primitives leave alone. Infallible.
366
+ */
367
+ function stripFormat(text) {
368
+ return native.stripFormat(text);
369
+ }
310
370
  /** Remove obfuscation (zero-width, bidi, combining-mark abuse, homoglyphs) while keeping legible content. */
311
- function stripObfuscation(text) {
312
- return call(() => native.stripObfuscation(text));
371
+ function stripObfuscation(text, options = {}) {
372
+ return call(() => native.stripObfuscation(text, options.digitPolicy ?? 'numeric'));
313
373
  }
314
374
  /**
315
375
  * Canonicalize text for security-sensitive comparison: NFKC → strip bidi/format
@@ -320,8 +380,8 @@ function stripObfuscation(text) {
320
380
  * The name describes the mechanism (Unicode canonicalization for matching), not
321
381
  * a safety guarantee — this is not an output sanitizer; encode at the sink.
322
382
  */
323
- function canonicalize(text) {
324
- return call(() => native.canonicalize(text));
383
+ function canonicalize(text, options = {}) {
384
+ return call(() => native.canonicalize(text, options.digitPolicy ?? 'numeric'));
325
385
  }
326
386
  /**
327
387
  * @deprecated Renamed to {@link canonicalize} in 0.11 (the `*Clean` name
@@ -352,14 +412,14 @@ function sanitizeFilename(text, options = {}) {
352
412
  * without confusable folding). `lang` selects the transliteration table.
353
413
  */
354
414
  function searchKey(text, options = {}) {
355
- return call(() => native.searchKey(text, options.lang ?? undefined));
415
+ return call(() => native.searchKey(text, options.lang ?? undefined, options.digitPolicy ?? 'numeric'));
356
416
  }
357
417
  /**
358
418
  * Collation sort key — like {@link searchKey} but preserves base accented
359
419
  * characters for correct ordering. `lang` selects the transliteration table.
360
420
  */
361
421
  function sortKey(text, options = {}) {
362
- return call(() => native.sortKey(text, options.lang ?? undefined));
422
+ return call(() => native.sortKey(text, options.lang ?? undefined, options.digitPolicy ?? 'numeric'));
363
423
  }
364
424
  /**
365
425
  * Library catalog deduplication key — like {@link searchKey} plus confusable
@@ -367,7 +427,34 @@ function sortKey(text, options = {}) {
367
427
  * `false`) picks the ISO 9:1995 Cyrillic scheme.
368
428
  */
369
429
  function catalogKey(text, options = {}) {
370
- return call(() => native.catalogKey(text, options.lang ?? undefined, options.strictIso9 ?? false));
430
+ return call(() => native.catalogKey(text, options.lang ?? undefined, options.strictIso9 ?? false, options.digitPolicy ?? 'numeric'));
431
+ }
432
+ /**
433
+ * The TR39 identifier skeleton plus the two prototype classes disarm's table keeps
434
+ * apart (#650). A spoof key: its only job is to make confusable identifiers collide,
435
+ * and its output is never for display. `digitPolicy` `'numeric'` (default) applies the
436
+ * letter half only; `'tr39'` adds `1 ≡ l` and `0 ≡ O`; `'preserve'` keeps a non-Latin
437
+ * numeral in its script.
438
+ */
439
+ function skeletonKey(text, options = {}) {
440
+ return call(() => native.skeletonKey(text, options.digitPolicy ?? 'numeric'));
441
+ }
442
+ /**
443
+ * Levenshtein edit distance between `a` and `b`, in characters (#894) — the one class of
444
+ * registry spoofing the confusable tables deliberately do not model (`paypa1`, `adm1n`).
445
+ * Canonicalize both sides first when composed and decomposed spellings should compare
446
+ * equal.
447
+ */
448
+ function editDistance(a, b) {
449
+ return native.editDistance(a, b);
450
+ }
451
+ /**
452
+ * The candidate closest to `value`, with its distance, or `null` beyond `maxDistance`
453
+ * (default 1). Reports; it does not decide. An exact match is reported with distance 0,
454
+ * and ties go to the first candidate at the lowest distance (#894).
455
+ */
456
+ function nearestMatch(value, candidates, options = {}) {
457
+ return call(() => native.nearestMatch(value, candidates, options.maxDistance ?? 1)) ?? null;
371
458
  }
372
459
  /**
373
460
  * ML/NLP normalization: NFKC → emoji→text → transliterate → strip accents →
@@ -421,6 +508,17 @@ function detectScripts(text) {
421
508
  function isMixedScript(text) {
422
509
  return native.isMixedScript(text);
423
510
  }
511
+ /**
512
+ * All twelve UAX #9 explicit formatting characters, uncontexted.
513
+ *
514
+ * The counterpart to {@link hasBidiConflict}, which reads strong-direction letters and is
515
+ * blind to these; the two are disjoint. The anomaly detector's `bidi` kind reports nine of
516
+ * the twelve, holding back LRM, RLM and ALM because a lone directional mark is ordinary in
517
+ * right-to-left text.
518
+ */
519
+ function hasBidiControl(text) {
520
+ return native.hasBidiControl(text);
521
+ }
424
522
  /**
425
523
  * Whether `text` mixes strong left-to-right and strong right-to-left characters
426
524
  * — the precondition for Bidi display-reordering ("BiDi Swap", #412). Fires on
@@ -451,6 +549,39 @@ function langInfo(code) {
451
549
  function scriptInfo(name) {
452
550
  return call(() => native.scriptInfo(name));
453
551
  }
552
+ /** TR39 sources whose prototype is in `script`, and how many of those disarm's bundled
553
+ * tables fold (#963).
554
+ *
555
+ * The denominator {@link unmappedConfusables} does not have. That function measures one
556
+ * bundled table against the whole 6,565-source population, which is the right question
557
+ * for a target disarm ships and a misleading one for a script it does not: Greek reports
558
+ * almost the entire population unmapped, and the number means only "there is no Greek
559
+ * table".
560
+ *
561
+ * `folded` counts sources any bundled table reaches, not sources folded *toward* this
562
+ * script — Greek is 71 of 159 because the Latin table folds Greek letters that look
563
+ * Latin. The grouping uses the UCD's script property, so `"Yi"` and 18 other scripts
564
+ * disarm's own enum does not name are addressable here. A script disarm knows that TR39
565
+ * never uses as a prototype returns 0 of 0. */
566
+ function confusableCoverage(script) {
567
+ return call(() => native.confusableCoverage(script));
568
+ }
569
+ /**
570
+ * The UCD release disarm's normalizer implements. Not a library-wide Unicode version —
571
+ * the bundled tables track different releases. This is the one integrators ask about,
572
+ * because it decides whether disarm's normalization agrees with the host platform's.
573
+ */
574
+ function unicodeVersion() {
575
+ return native.unicodeVersion();
576
+ }
577
+ /**
578
+ * Whether a key stored under an earlier release still compares equal. A monotonic
579
+ * counter, not a version — two artifacts reporting the same value produce the same key
580
+ * for the same input. Meaningless in isolation, by design.
581
+ */
582
+ function keySchemaVersion() {
583
+ return native.keySchemaVersion();
584
+ }
454
585
  /**
455
586
  * The Unicode `confusables.txt` release the bundled confusable tables were folded
456
587
  * from, e.g. `"17.0.0"`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "disarm",
3
- "version": "0.14.1",
3
+ "version": "0.16.0",
4
4
  "description": "Unicode confusable/text-security building blocks, powered by Rust",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",