{"name":"@adraffy/ens-normalize","version":"1.11.1","description":"Ethereum Name Service (ENS) Name Normalizer","keywords":["ENS","ENSIP-1","ENSIP-15","Ethereum","UTS-46","UTS-51","IDNA","Name","Normalize","Normalization","NFC","NFD"],"exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs"},"./xnf":{"import":"./dist/index-xnf.mjs","require":"./dist/index-xnf.cjs"}},"main":"./dist/index.cjs","module":"./dist/index.mjs","repository":{"type":"git","url":"git+https://github.com/adraffy/ens-normalize.js.git"},"license":"MIT","bugs":{"url":"https://github.com/adraffy/ens-normalize.js/issues"},"homepage":"https://github.com/adraffy/ens-normalize.js#readme","author":{"name":"raffy.eth","url":"http://raffy.antistupid.com"},"scripts":{"unicode":"node derive/download.js","labels":"node validate/download-labels.js","derive":"node derive/make.js","make":"node src/make.js","validate":"node validate/make.js","test":"node test/all.js","types":"cp dist/index.d.mts dist/index.d.cts && cp dist/index.d.mts dist/index-xnf.d.mts && cp dist/index.d.mts dist/index-xnf.d.cts","build":"npm run types && npx rollup -c","rebuild":"npm run derive && npm run make && npm run validate && npm run test && npm run build","order":"node validate/dump-group-order.js save && npm run rebuild"},"devDependencies":{"@rollup/plugin-alias":"^5.1.1","@rollup/plugin-terser":"^0.4.4","rollup":"^4.46.2"},"type":"module","_id":"@adraffy/ens-normalize@1.11.1","gitHead":"19daa8507f95d9432fcf1e59c9ac76131630c6da","_nodeVersion":"24.5.0","_npmVersion":"11.5.2","dist":{"integrity":"sha512-nhCBV3quEgesuf7c7KYfperqSS14T8bYuvJ8PcLJp6znkZpFc0AuW4qBtr8eKVyPPe/8RSr7sglCWPU5eaxwKQ==","shasum":"6c2d657d4b2dfb37f8ea811dcb3e60843d4ac24a","tarball":"http://registry-npm.ywwl.com/@adraffy/ens-normalize/download/@adraffy/ens-normalize-1.11.1.tgz","fileCount":16,"unpackedSize":455684,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDYI1PtKPrb7tSU6mNqRPxqWNauH2FKOvzWZ94aJltTeQIhANr6OIhFGxasaQoWNzx37+iRRpV5mBIjIMmSTCKaxQHK"}],"size":228910,"noattachment":false,"key":"/@adraffy/ens-normalize/-/@adraffy/ens-normalize-1.11.1.tgz"},"_npmUser":{"name":"adraffy","email":"raffy@me.com"},"directories":{},"maintainers":[{"name":"adraffy","email":"raffy@me.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ens-normalize_1.11.1_1758224430999_0.9519538590697181"},"_hasShrinkwrap":false,"readme":"# ens-normalize.js\n0-dependency [Ethereum Name Service](https://ens.domains/) (ENS) Name Normalizer.\n\n`npm i @adraffy/ens-normalize` [&check;](https://www.npmjs.com/package/@adraffy/ens-normalize)\n\n* 🏛️ Follows [**ENSIP-15**: ENS Name Normalization Standard](https://docs.ens.domains/ensip/15)\n\t* Unicode: [`17.0.0`](./derive/data/17.0.0/) • CLDR: [`47`](./derive/data/CLDR-47/)\n\t* Other implementations:\n\t\t* Python — [namehash/**ens-normalize-python**](https://github.com/namehash/ens-normalize-python)\n\t\t* Rust — [sevenzing/**ens-normalize-rs**](https://github.com/sevenzing/ens-normalize-rs)\n\t\t* Zig — [evmts/**z-ens-normalize**](https://github.com/evmts/z-ens-normalize)\n\t\t* C# — [adraffy/**ENSNormalize.cs**](https://github.com/adraffy/ENSNormalize.cs)\n\t\t* Java — [adraffy/**ENSNormalize.java**](https://github.com/adraffy/ENSNormalize.java)\n\t\t* Swift – [adraffy/**ENSNormalize.swift**](https://github.com/adraffy/ENSNormalize.swift)\n\t\t* Go — [adraffy/**go-ens-normalize**](https://github.com/adraffy/go-ens-normalize)\n\t\t* Swift – [adraffy/**ENSNormalize.swift**](https://github.com/adraffy/ENSNormalize.swift)\n\t* Prior implementation:\n\t\t* Javascript — [ensdomains/**eth-ens-namehash**](https://github.com/ensdomains/eth-ens-namehash)\n\t* [Breakdown Reports from ENSIP-1](https://adraffy.github.io/ens-norm-tests/test-breakdown/output-20230226/)\t\n* ✅️ Passes **100%** [ENSIP-15 Validation Tests](https://adraffy.github.io/ens-normalize.js/test/validate.html)\n* ✅️ Passes **100%** [Unicode Normalization Tests](https://adraffy.github.io/ens-normalize.js/test/report-nf.html)\n* Minified File Sizes: \n\t* [`29KB`](./dist/index-xnf.min.js) — native NFC via [nf-native.js](./src/nf-native.js) using `String.normalize()` ⚠️\n\t* [`38KB` **Default**](./dist/index.min.js) — custom NFC via [nf.js](./src/nf.js)\n\t* [`44KB`](./dist/all.min.js) *Everything!* — custom NFC + sub-libraries: [parts.js](./src/parts.js), [utils.js](./src/utils.js)\n* Included Apps:\n\t* [**Resolver Demo**](https://adraffy.github.io/ens-normalize.js/test/resolver.html) ⭐\n\t* [Supported Emoji](https://adraffy.github.io/ens-normalize.js/test/emoji.html)\n\t* [Character Viewer](https://adraffy.github.io/ens-normalize.js/test/chars.html)\n\t* [Confused Explainer](https://adraffy.github.io/ens-normalize.js/test/confused.html)\n* Related Projects:\n\t* [Recent .eth Registrations](https://raffy.antistupid.com/eth/ens-regs.html) • [Renews](https://raffy.antistupid.com/eth/ens-renews.html) • [Expirations](https://raffy.antistupid.com/eth/ens-exp.html)\n\t* [Label Database](https://github.com/adraffy/ens-labels/) • [Labelhash⁻¹](https://adraffy.github.io/ens-labels/demo.html) • [Brute-force](https://raffy.antistupid.com/eth/ens-brute.html)\n\t* [Emoji Frequency Explorer](https://raffy.antistupid.com/eth/ens-emoji-freq.html)\n\t* [adraffy/**punycode.js**](https://github.com/adraffy/punycode.js/) • [Punycode Coder](https://adraffy.github.io/punycode.js/test/demo.html)\n\t* [adraffy/**keccak.js**](https://github.com/adraffy/keccak.js/) • [Keccak Hasher](https://adraffy.github.io/keccak.js/test/demo.html)\n\t* [adraffy/**emoji.js**](https://github.com/adraffy/emoji.js/) • [Emoji Parser](https://adraffy.github.io/emoji.js/test/demo.html)\n\t* More links at bottom of [Resolver Demo](https://adraffy.github.io/ens-normalize.js/test/resolver.html)\n\n```js\nimport {ens_normalize} from '@adraffy/ens-normalize'; // or require()\n// browser: https://cdn.jsdelivr.net/npm/@adraffy/ens-normalize@latest/dist/index.min.mjs (or .cjs)\n\n// *** ALL errors thrown by this library are safe to print ***\n// - characters are shown as {HEX} if should_escape()\n// - potentially different bidi directions inside \"quotes\"\n// - 200E is used near \"quotes\" to prevent spillover\n// - an \"error type\" can be extracted by slicing up to the first (:)\n// - labels are middle-truncated with ellipsis (…) at 63 cps\n\n// string -> string\n// throws on invalid names\n// output ready for namehash\nlet normalized = ens_normalize('RaFFY🚴‍♂️.eTh');\n// => \"raffy🚴‍♂.eth\"\n\n// note: does not enforce .eth registrar 3-character minimum\n```\n\nFormat names with fully-qualified emoji:\n```js\n// works like ens_normalize()\n// output ready for display\nlet pretty = ens_beautify('1⃣2⃣.eth'); \n// => \"1️⃣2️⃣.eth\"\n\n// note: normalization is unchanged:\n// ens_normalize(ens_beautify(x)) == ens_normalize(x)\n```\n\nNormalize name fragments for [substring search](./test/fragment.js):\n```js\n// these fragments fail ens_normalize() \n// but will normalize fine as fragments\nlet frag1 = ens_normalize_fragment('AB--');    // expected error: label ext\nlet frag2 = ens_normalize_fragment('\\u{303}'); // expected error: leading cm\nlet frag3 = ens_normalize_fragment('οо');      // expected error: mixture\n```\n\nInput-based tokenization:\n```js\n// string -> Token[]\n// never throws\nlet tokens = ens_tokenize('_R💩\\u{FE0F}a\\u{FE0F}\\u{304}\\u{AD}./');\n// [\n//     { type: 'valid', cps: [ 95 ] }, // valid (as-is)\n//     {\n//         type: 'mapped', \n//         cp: 82,         // input\n//         cps: [ 114 ]    // output\n//     }, \n//     { \n//         type: 'emoji',\n//         input: Emoji(2) [ 128169, 65039 ],  // input \n//         emoji: [ 128169, 65039 ],           // fully-qualified\n//         cps: Emoji(1) [ 128169 ]            // output (normalized)\n//     },\n//     {\n//         type: 'nfc',\n//         input: [ 97, 772 ],  // input (before nfc)\n//         cps: [ 257 ],        // output (after nfc)\n//         tokens0: [           // tokens (before nfc)\n//             { type: 'valid', cps: [ 97 ] },\n//             { type: 'ignored', cp: 65039 },\n//             { type: 'valid', cps: [ 772 ] }\n//         ],\n//         tokens: [            // tokens (after nfc)\n//             { type: 'valid', cps: [ 257 ] }\n//         ]\n//     },\n//     { type: 'ignored', cp: 173 },\n//     { type: 'stop', cp: 46 },\n//     { type: 'disallowed', cp: 47 }\n// ]\n\n// note: if name is normalizable, then:\n// ens_normalize(ens_tokenize(name).map(token => {\n//     ** convert valid/mapped/nfc/stop to string **\n// }).join('')) == ens_normalize(name)\n```\n\nOutput-based tokenization:\n```js\n// string -> Label[]\n// never throws\nlet labels = ens_split('💩Raffy.eth_');\n// [\n//   {\n//     input: [ 128169, 82, 97, 102, 102, 121 ],  \n//     offset: 0, // index of codepoint, not substring index!\n//                // (corresponding length can be inferred from input)\n//     tokens: [\n//       Emoji(2) [ 128169, 65039 ],   // emoji\n//       [ 114, 97, 102, 102, 121 ]    // nfc-text\n//     ],\n//     output: [ 128169, 114, 97, 102, 102, 121 ],\n//     emoji: true,\n//     type: 'Latin'\n//   },\n//   {\n//     input: [ 101, 116, 104, 95 ],\n//     offset: 7,\n//     tokens: [ [ 101, 116, 104, 95 ] ],\n//     output: [ 101, 116, 104, 95 ],\n//     error: Error('underscore allowed only at start')\n//   }\n// ]\n```\n\nGenerate a sorted array of (beautified) supported emoji codepoints:\n```js\n// () -> number[][]\nlet emojis = ens_emoji();\n// [\n//     [ 2764 ],\n//     [ 128169, 65039 ],\n//     [ 128105, 127997, 8205, 9877, 65039 ],\n//     ...\n// ]\n```\n\nDetermine if a character shouldn't be printed directly:\n```js\n// number -> bool\nshould_escape(0x202E); // eg. RIGHT-TO-LEFT OVERRIDE => true\n```\n\nDetermine if a character is a combining mark:\n```js\n// number -> bool\nis_combining_mark(0x20E3); // eg. COMBINING ENCLOSING KEYCAP => true\n```\n\nFormat codepoints as print-safe string:\n```js\n// number[] -> string\nsafe_str_from_cps([0x300, 0, 32, 97]); // \"◌̀{00} a\"\nsafe_str_from_cps(Array(100).fill(97), 4); // \"aa…aa\" => middle-truncated\n```\n\n## Build\n\n* `git clone` this repo, then `npm install` \n* Follow instructions in [/derive/](./derive/) to generate data files\n\t* `npm run derive` \n\t\t* [spec.json](./derive/output/spec.json)\n\t\t* [nf.json](./derive/output/nf.json)\n\t\t* [nf-tests.json](./derive/output/nf-tests.json)\n* `npm run make` — compress data files from [/derive/output/](./derive/output/)\n\t* [include-ens.js](./src/include-ens.js)\n\t* [include-nf.js](./src/include-nf.js)\n\t* [include-versions.js](./src/include-versions.js)\n* Follow instructions in [/validate/](./validate/) to generate validation tests\n\t* `npm run validate`\n\t\t* [tests.json](./validate/tests.json)\n* `npm run test` — perform validation tests\n* `npm run build` — create [/dist/](./dist/)\n* `npm run rebuild` — run all the commands above\n* `npm run order` — create optimal group ordering and rebuild again\n\n## Security\n\n* [Build](#build) and compare against [include-versions.js](./src/include-versions.js)\n\t* `spec_hash` — SHA-256 of [spec.json](./derive/output/spec.json) bytes\n\t* `ens_hash_base64` — SHA-256 of [include-ens.js](./src/include-ens.js) base64 literal\n\t* `nf_hash_base64` — SHA-256 of [include-nf.js](./src/include-nf.js) base64 literal\n","publish_time":1758224431258,"_cnpm_publish_time":1758224431258,"dist-tags":{"latest":"1.11.1"}}