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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@transcend-io/secret-value

v2.0.0

Published

Type-safe wrapper for secret values

Readme

Why does this libary exist

FOSSA Status

This module contains a type-safe secret wrapper for Typescript Project with the aim to greatly reduce the possibility of logging sensitive data, while also explicitly marking which values in Typescript ought to be protected.

Let's jump into an example of when this might be useful: say you have a class that doesn't currently have any sensitive data that represents the results from a customer filling out a survey:

class SurveyResults {
  constructor(
    public favoriteColor: string,
    public leastFavoritePokemon: string,
  ) {}
}

Some time later, you pick up a bug ticket to ask the customer for their social security number as well. Well a person's SSN is sensitive information, so it would be a good idea to keep the information out of logs if you could. How can you mark that the SSN is sensitive in such a way where you can have confidence that it will never appear in a log message, error message, or stack trace? Seeing as this class did not previously have sensitive information in it, maybe it's contents were logged somewhere. Or maybe in the future someone would log them out assuming that the class didn't have any sensitive information.

Well you could add a big 'ole comment saying This class has sensitive information, plz don't log it ever, but you can't always guarantee that your developers will honor that comment, if they read it at all.

Instead, you could wrap the SSN in a Secret<T> type that explicitly states that its value should never see the light:

import { Secret } from '@transcend-io/secret-value';

class SurveyResults {
  constructor(
    public favoriteColor: string,
    public leastFavoritePokemon: string,
    public ssn: Secret<string>,
  ) {}
}

Now running any variation of:

const results = new SurveyResults('blue', 'zubat', new Secret('123-45-6789'));

console.log(results);
console.log(JSON.stringify(results, null, 2));
console.log(results.valueOf());
console.log(JSON.parse(JSON.stringify(results)));
console.log(results.ssn);
console.log(results.ssn.valueOf());
console.log(results.ssn.toString());
console.log(results.ssn.toLocaleString());
console.log(JSON.stringify(results.ssn));

will result in [redacted] being displayed to STDOUT instead of the actual value 123-45-6789

When you do actually want to use the value of the SSN in your code, you can call .release() to get the wrapped value back out.

doSomethingWith(results.ssn.release());

Installation

With yarn:

yarn add @transcend-io/secret-value

With npm:

npm install @transcend-io/secret-value

API

Wrapping a secret:

import { Secret } from '@transcend-io/secret-value';

const secret = new Secret('some secret value');

Unwrapping a secret:

secret.release();

Updating a Secret value while keeping the result a secret:

const secretLength = secret.map((rawValue) => rawValue.length);

Wrapping multiple values of an existing object:

import { wrapSecrets } from '@transcend-io/secret-value';

const rawObject = { foo: 'bar', bazz: 'buzz', bippity: 'boppity' };
const secretified = wrapSecrets(rawObject, ['bazz', 'bippity']);
console.log(secretified); // prints { foo: 'bar', bazz: [redacted], bippity: [redacted] }

License

FOSSA Status