Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@adraffy/ens-normalize
Advanced tools
@adraffy/ens-normalize is an npm package designed to normalize Ethereum Name Service (ENS) names. It ensures that ENS names are in a consistent format, which is crucial for avoiding ambiguities and ensuring compatibility across different systems.
Normalization
This feature allows you to normalize an ENS name to ensure it is in a consistent format. The code sample demonstrates how to normalize the ENS name 'example.eth'.
const { normalize } = require('@adraffy/ens-normalize');
const normalized = normalize('example.eth');
console.log(normalized);
Validation
This feature allows you to validate an ENS name to check if it conforms to the expected format. The code sample demonstrates how to validate the ENS name 'example.eth'.
const { validate } = require('@adraffy/ens-normalize');
const isValid = validate('example.eth');
console.log(isValid);
Unicode Handling
This feature allows you to convert Punycode-encoded ENS names to their Unicode equivalents. The code sample demonstrates how to convert the Punycode-encoded ENS name 'xn--exmple-cua.eth' to its Unicode equivalent.
const { toUnicode } = require('@adraffy/ens-normalize');
const unicodeName = toUnicode('xn--exmple-cua.eth');
console.log(unicodeName);
The eth-ens-namehash package is another tool for generating ENS namehashes. It includes some basic normalization features but is primarily focused on the namehashing process. It is less comprehensive in normalization compared to @adraffy/ens-normalize.
The punycode package provides utilities for converting between Unicode and Punycode, which is useful for handling internationalized domain names (IDNs). While it does not specifically target ENS names, it can be used in conjunction with other packages to handle Unicode normalization.
1-file, 0-dependancy Compact ES6 Ethereum Name Service (ENS) Name Normalizer.
This library is 5-10x smaller than existing implementations.
Reference: UTS-46 v14.0.0
import {ens_normalize} from '@adraffy/ens-normalize';
// browser:
// import {ens_normalize} from 'https://unpkg.com/@adraffy/ens-normalize@latest/ens-normalize.js';
// simple api:
let normalized = ens_normalize('🚴♂️.eth'); // throws if error
// errors:
// - contains disallowed character
// - puny decode failure
// - label not idna after puny decode
// - label has double-hyphen at [3:4]
// - label starts/ends with hyphen
// - label starts with combining mark
// note: does not enforce .eth TLD 3-byte minimum
Adapted Puny Decode from mathiasbynens/punycode.js.
FAQs
Ethereum Name Service (ENS) Name Normalizer
The npm package @adraffy/ens-normalize receives a total of 808,493 weekly downloads. As such, @adraffy/ens-normalize popularity was classified as popular.
We found that @adraffy/ens-normalize demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.