The `unicode-confusables` utility provides functions to detect and resolve visually confusing Unicode characters in strings, adhering to the security guidelines outlined in Unicode Technical Standard #39 (UTS39). It leverages the `confusables.txt` data file to identify characters that can be easily mistaken for others, including homoglyphs and zero-width characters. Currently at version 0.1.1, the library's release cadence is tied to updates in the UTS39 standard and `confusables.txt` data. Its primary differentiators include direct adherence to the official Unicode standard, the ability to not only detect but also rectify confused characters, and support for a wide range of scripts, including non-Latin languages. It also provides a mechanism to update its underlying data set, making it crucial for applications requiring robust input validation and security against 'homograph attacks' or similar visual spoofing.
npm install unicode-confusablesVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to check if a string contains confusing Unicode characters, identify the specific confusables, and rectify them. It also shows detection of zero-width characters and homoglyphs.
Pin the exact version in `package.json` (e.g., `"unicode-confusables": "0.1.1"`) and review updates manually.
Integrate `npm run update` into your CI/CD pipeline or a regular maintenance script to ensure the data is current.
Supplement this library with other security measures appropriate for your application's threat model, and educate users about potential risks beyond UTS39.
For performance-sensitive applications, consider caching results for common strings or rate-limiting checks. Profile your application to identify bottlenecks.
Ensure you are using named imports: `import { isConfusing } from 'unicode-confusables';`Use object destructuring for CommonJS `require`: `const { isConfusing } = require('unicode-confusables');`Run `npm install unicode-confusables` or `yarn add unicode-confusables` to install the package. Verify the import path is exactly `'unicode-confusables'`.
No dependency data recorded yet.