Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
astro-mail-obfuscation
Advanced tools
Protect email addresses and phone numbers in the source code of your Astro app by disguising them.
🔥 v2.2.0 is here! Introducing two new methods and an automatic mode.
Protect email addresses and phone numbers in your Astro app's source code from bots using XOR-based obfuscation. This ensures that contact information remains accessible to real users but hidden from most bots.
Astro Mail Obfuscation is simple and developer-friendly, making it easy to implement without complex setup. It provides effective obfuscation with three methods or an automatic mode, adding variability and making it even harder for bots to scrape data. The integration seamlessly supports Astro ViewTransition
and is built for stable, robust deployment.
Note: Server-Side Rendering (SSR) is currently not supported.
Recommended installation using the Astro CLI:
npx astro add astro-mail-obfuscation
Add the data-obfuscation
attribute to your links:
<a href="mailto:mail@..." data-obfuscation="1">mail@...</a>
<a href="tel:0123..." data-obfuscation="2">0123...</a>
<!-- <a href="tel:0123..." data-obfuscation="3">0123...</a> -->
Set data-obfuscation
to 1
, 2
, or 3
to select a specific method (see below).
Note: Links without the
data-obfuscation
attribute will not be obfuscated, which may be relevant for compliance considerations (e.g., GDPR).
Alternatively, set it to 0
to let the integration randomly assign a method during the build process, increasing variability and making it harder for bots to decode the obfuscation:
<a href="mailto:mail@..." data-obfuscation="0">mail@...</a> <a href="tel:0123..." data-obfuscation="0">0123...</a>
Configuration is optional, as the integration works out of the box. During the build, userKey
and userSalt
are generated automatically, so manual configuration of these values is typically unnecessary.
However, you may set fallbackText
in your astro.config.mjs
file to customize the message shown to users who have JavaScript disabled:
// astro.config.mjs
export default defineConfig({
integrations: [
mailObfuscation({
fallbackText: "...", // Default: "[PROTECTED!]"
// userKey: "...", // Not recommended to change
// userSalt: "...", // Not recommended to change
}),
],
});
Note: The
userSalt
must be exactly five characters long if you choose to set it manually.
The integration provides three XOR-based methods for obfuscation:
userKey
, hexadecimal encoding.userKey
, Base64 encoding (dynamically reversed).userKey
and userSalt
, Base62 encoding.Each method offers a similar level of security. For added variability, it’s recommended to use the automatic mode (data-obfuscation="0"
), which randomly assigns a method during the build, making it even harder for bots to detect and decode obfuscated contact information.
While this integration provides protection against simple bots, it’s important to note that bots capable of executing JavaScript can still extract obfuscated data. However, most bots do not execute JavaScript due to performance and cost constraints. The integration raises the barrier for data scraping but does not guarantee complete security against all bots.
FAQs
Protect email addresses, phone numbers and other sensitive data from bots scraping the source code of your Astro app.
The npm package astro-mail-obfuscation receives a total of 3 weekly downloads. As such, astro-mail-obfuscation popularity was classified as not popular.
We found that astro-mail-obfuscation 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.