npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

astro-mail-obfuscation

v2.3.4

Published

Protect email addresses, phone numbers and other sensitive data from bots scraping the source code of your Astro app.

Downloads

599

Readme

Astro Mail Obfuscation

CodeFactor

Supported HTML tags: h1-h6, p, span, a, label, ul, ol, li, strong, b, em, i.

This Astro integration effectively prevents spam bots from extracting email addresses, phone numbers or other sensitive data from the source code of your website. You can manually select one of three methods or activate random mode to increase variation and make it harder for bots to extract data. The integration has been designed with a focus on stability, reliability, performance and seamless support for <ViewTransitions />.

Important: Server-side rendering is currently not supported.

Installation

Install (recommended via Astro CLI):

npx astro add astro-mail-obfuscation

Usage

Add the data-obfuscation attribute to any HTML tag containing sensitive content to obfuscate it during the build process. You can use the values "1", "2" or "3" to manually select the method for the respective tag. Alternatively, you can use "0" to specify that the integration automatically selects one of the three methods at random during the build, which increases variability and makes interpretation by simple bots even more difficult.

Examples:

<!-- Manually select obfuscation method: -->
<a href="mailto:info@..." data-obfuscation="1">info@...</a>
<a href="tel:0123..." data-obfuscation="2">0123...</a>
<p>...<span data-obfuscation="3">info@...</span>...</p>
<!-- Automatically select a random obfuscation method: -->
<ul data-obfuscation="0">
  <li>John Doe</li>
  <li>Jane Doe</li>
</ul>
<label data-obfuscation="0">info@...</label>
<!-- ... -->

Information: HTML tags that do not contain the data-obfuscation attribute are not obfuscated. This can be useful in certain situations (e.g. GDPR).

Methods

The integration provides three XOR-based methods for obfuscation:

  • Method "1": XOR with userKey, resulting in hexadecimal encoding.
  • Method "2": XOR with userKey, resulting in Base64 encoding (dynamically reversed).
  • Method "3": XOR with userKey and userSalt, resulting in Base62 encoding.

Each method uses XOR-based encoding with additional keys to vary how the content is represented, making it harder for simpler bots to detect patterns. For increased variability, data-obfuscation="0" enables automatic mode, which randomly selects a method during the build to further complicate bot interpretation.

Configuration

This integration works out of the box with no required setup.

Nevertheless, a few settings can be made to control the behavior of the integration:

// astro.config.mjs
import mailObfuscation from "astro-mail-obfuscation";
export default defineConfig({
  integrations: [
    mailObfuscation({
      fallbackText: "Please enable JavaScript!", // Default: "[PROTECTED!]"
      // userKey: "...", // Automatically generated
      // userSalt: "...", // Automatically generated (must be 8 characters if set manually)
      // concurrencyLimit: number, // Max concurrent tasks, default: 5 (p-limit)
      // allowedTags: ["button", "..."] // Add unsupported HTML tags to the whitelist
    }),
  ],
});

The fallbackText is displayed if the user has deactivated JavaScript in the browser. Whenever you run the build process, userKey and userSalt are automatically regenerated by default. If you still want to set static values within your Astro configuration, please note that the userSalt must be exactly 8 characters long. The length of the userKey, on the other hand, is not limited. The userKey and userSalt are set as a meta tag on all pages during the build process to make them accessible to the client-side JavaScript. Please change the concurrencyLimit with caution, as a value that is too high could affect stability. By default, 17 HTML tags are supported, but if you still need support for more tags, add them to the allowedTags array.

Recommendation: In most cases, only the fallbackText needs to be adjusted. The default settings are already optimized for stable use.

Limitations

While the majority of basic bots cannot execute JavaScript, this integration provides an effective and practical level of protection against simpler, more common bots. Astro Mail Obfuscation is a client-side solution that is particularly ideal for use on static sites.