Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

astro-mail-obfuscation

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astro-mail-obfuscation

An Astro integration that obfuscates email addresses in the source code by encrypting them. The email addresses are only decrypted and displayed on the client side using JavaScript, helping to protect against email scraping bots.

  • 1.0.0
  • unpublished
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
0
Weekly downloads
 
Created
Source

Astro-Mail-Obfuscation

Protect your email addresses!

Malicious bots scour the internet for email addresses, which often leads to spam and phishing attacks. Encrypting email addresses in the source code helps prevent most bots from scraping them, as they cannot interpret JavaScript or advanced obfuscation techniques.

This is an integration for Astro.

Installation:

Alternative installation with Astro CLI: npx astro add astro-mail-obfuscator

1. Recommended installation with npm:

npm install astro-mail-obfuscation

2. Add the following configuration to your astro.config.mjs file:

import { defineConfig } from "astro/config";

import astroMailObfuscation from "astro-mail-obfuscation";

export default defineConfig({
  integrations: [
    astroMailObfuscation({
      fallbackText: "...", // Default: "Enable JS!"
      loadingText: "...", // Default: "Loading..."
      // userKey: "A1B3C2..." (Optional, not recommended!)
    }),
  ],
});

The userKey is used for XOR encryption and is generated automatically during the build process. You can set the userKey manually if you want, but it is not required.

3. Add the following css globally to your project:

.astroMailObfuscationHidden {
  display: initial;
}

.astroMailObfuscationScript .astroMailObfuscationHidden {
  display: none;
}

Usage:

In your .astro files:

<a href="mailto:mail1@..." data-obfuscation>mail1@...</a>

<a href="mailto:mail2@..." data-obfuscation>Contact us!</a>

// ...

Add data-obfuscation to all <a> tags that you want to encrypt in the source code.

Examples:

Source code without this integration:

<a href="mailto:mail@...">mail@...</a>

An easy game for bots to read and scrape the email addresses here.

Source code with this integration:

<a data-obfuscation="">
  <noscript>Enable JS!</noscript>
  <span data-...="5b000..."> Loading... </span>
</a>

Bots cannot read the email address directly and cannot do anything with the data-... either, as they do not know where the userKey is stored (or even that it is needed for decryption).

Disclaimer: This integration helps prevent email scraping but cannot guarantee complete protection.

Planned Features:

Support for encrypting phone numbers in the source code.

Keywords

FAQs

Package last updated on 21 Oct 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc