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

als-hidden-data-link

v1.0.0

Published

**als-hidden-data-link** is a Node.js library designed for embedding hidden numeric IDs or other data into messages using invisible characters. These hidden IDs can be used to retrieve associated data later, making it useful for scenarios where you need t

Downloads

3

Readme

als-hidden-data-link

als-hidden-data-link is a Node.js library designed for embedding hidden numeric IDs or other data into messages using invisible characters. These hidden IDs can be used to retrieve associated data later, making it useful for scenarios where you need to embed identifiers into text that will be transmitted via messaging platforms, such as WhatsApp or email.

Installation

To install the library, run the following command in your Node.js project:

npm install als-hidden-data-link

Usage

1. Import the Library

First, import the DataLinkManager class from the library:

const DataLinkManager = require('als-hidden-data-link');

2. Initialize the DataLinkManager

You can initialize the DataLinkManager with a maximum number of entries it can store. The default is 300, but you can set a custom value as needed.

const manager = new DataLinkManager(300);

3. Encrypting a Message

To embed a hidden numeric ID into a message, use the getMsg method. This method takes a message and an associated ID, and it will return the message with the embedded ID.

const message = 'This is a secret message';
const userId = 'user123'; // This can be any data you want to associate
const encryptedMessage = manager.getMsg(message, userId);

console.log(encryptedMessage);

The encrypted message will contain invisible characters representing the numeric ID associated with the message.

4. Decrypting a Message

To retrieve the ID associated with an encrypted message, use the getData method. This will extract the embedded ID from the message.

const decryptedId = manager.getData(encryptedMessage);

if (decryptedId) {
    console.log(`The decrypted ID is: ${decryptedId}`);
} else {
    console.log('No ID found in the message.');
}

5. Handling Maximum Entries

If the number of stored entries exceeds the maxN limit, the class will automatically overwrite the oldest entry. For example, if you set maxN to 2 and attempt to store three entries, the first entry will be replaced.

const manager = new DataLinkManager(2);

manager.getMsg('First message', 'id1');
manager.getMsg('Second message', 'id2');
const encryptedThird = manager.getMsg('Third message', 'id3'); // This will overwrite 'id1'

const retrievedId = manager.getData(encryptedThird);
console.log(`The decrypted ID is: ${retrievedId}`); // Should return 'id3'

6. Invalid Message Handling

If you attempt to decrypt a message that does not contain any embedded ID, the getData method will return null.

const invalidMessage = 'This message has no hidden ID';
const result = manager.getData(invalidMessage);

console.log(result); // Output: null

API Reference

new DataLinkManager(maxN)

  • maxN: The maximum number of entries that the DataLinkManager can store. Default is 300.
  • Returns: A new instance of DataLinkManager.

getMsg(message, data)

  • message: The message in which to embed the ID.
  • data: The data to associate with the message.
  • Returns: The message with the hidden ID embedded in it.

getData(encryptedMessage)

  • encryptedMessage: The message from which to extract the hidden ID.
  • Returns: The associated ID if found, or null if no ID is embedded.

Example

const DataLinkManager = require('als-hidden-data-link');

// Initialize the manager
const manager = new DataLinkManager();

// Encrypt a message with an ID
const message = 'Hello world!';
const encryptedMessage = manager.getMsg(message, 'myCustomId');

// Later, decrypt the message to retrieve the ID
const retrievedId = manager.getData(encryptedMessage);

console.log(`The retrieved ID is: ${retrievedId}`);