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

@cross-solution/strapi-plugin-anonymize

v1.0.2

Published

anonymizes data in a collection

Downloads

1,032

Readme

Strapi plugin anonymize

the plugin filters data from collections and anonymizes all fields that do not appear in a whitelist. It expects a boolean field “anonymized” in the collection that is to be anonymized.

Rules can be defined for the anonymization of individual fields.

Status

WIP - Work in Progress/Planning

Install

yarn add @cross-solution/strapi-plugin-anonymize

Configuration:

The default configuration is as follows (you must add it to ./config/plugin.js):

module.exports = {
  // ...
  "anonymize": {
    cron: "*/10 * * * * *",
    enabled: true,
    config: {
      anonymize: [
        {
          collection: "Strapi UID, eg. plugin::bfa.bfa-beruf",
          filters: {
            foo: {
              $contains: "bar",
            },
          },
          limit: 4,
          keepData: ['field1', 'field2'],
           rules: {
            // Truncate string to first 3 characters
            field1: { type: "truncate", length: 3 }, // e.g., "ABCDEFG" → "ABC"

            // Replace value with a fixed string
            field3: { type: "replace", value: "REDACTED" }, // e.g., "Original Value" → "REDACTED"
            field4: { type: "replace", value: "t" }, // e.g., "Original Value" → "t"

            // Prefix string with specified text
            field5: { type: "prefix", prefix: "anon-" }, // e.g., "Name" → "anon-Name"

            // Set fixed date values (can use one or all of year, month, day)
            //** won't be applied as createdAt field can't be changed. but you can use this rule to any date field like this **//
            field6: { type: "date", year: 2000, month: 1, day: 1 }, // e.g., "2023-08-10" → "2000-01-01"

            // Mask with * for the first 4 characters
            field7: { type: "mask", length: 4 }, // e.g., "Visible" → "****ible"

            // Hash the string value
            field8: { type: "hash" }, // e.g., "SensitiveInfo" → "6b1b36cbb04b41490bfc0ab2bfa26f86" (SHA-256)

            // Randomize a numeric field within a specified range
            field9: { type: "randomize", dataType: "number", min: 1, max: 100 }, // e.g., 23 → (random number between 1 and 100)

            // Randomize a string field to a specific length
            field9: {
              type: "randomize",
              dataType: "string",
              length: 5,
            }, // e.g., "ABCDEF" → "x3a5z" (random 5 characters)   *** bkz is unique, if you want to test this rule remove unique from bkz in schema ***
          },
        },
      ]
    }
  }
  // ...
}

Anonymization Rules

Truncate: Limits the length of a string to a specified number of characters. { type: "truncate", length: 2 }, // "60486" -> "60"

Replace: Replaces the entire value with a predefined value. { type: "replace", value: "REDACTED" }, // "John Doe" -> "REDACTED"

Prefix: Adds a prefix to the beginning of a string. { type: "prefix", prefix: "ANON-" }, // "12345" -> "ANON-12345"

Date: Modifies only parts of a date while preserving the rest. { type: "date", year: 2000, month: 1, day: 1 }, // "2023-08-20" -> "2000-01-01"

Mask: Hides part of the string with asterisks, leaving a specific number of characters visible. { type: "mask", length: 3 }, // "12345678" -> "***45678"

Hash: Hashes a string for anonymization. { type: "hash" }, // "secret" -> "2bb80d... (hashed)"

Randomize: Generates a random value within a defined range.

{ type: "randomize", dataType: "number", min: 1000, max: 9999 }, // e.g., 1234
{ type: "randomize", dataType: "string", length: 6 }, // e.g., "abc123"