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 🙏

© 2025 – Pkg Stats / Ryan Hefner

selfguard-client

v1.1.81

Published

Universal API For Encryption

Downloads

108

Readme

Installation

npm install selfguard-client

Usage

Import SelfGuard-Client


import SelfGuard from 'selfguard-client';

Instantiation

There are three main ways to instantiate SelfGuard.

Without Asymmetric Encryption

This instantiates SelfGuard such that data with SelfGuard can be decrypted with this API-KEY.


let sg = new SelfGuard(API_KEY);

With Asymmetric Encryption (Key Pair)

This instantiates SelfGuard such that data encrypted with SelfGuard can only be decrypted by the user with the respective public/private key pair.


let sg = new SelfGuard(API_KEY, key_pair_type, public_key, private_key);

With Asymmetric Encryption (Metamask)

This instantiates SelfGuard such that data encrypted with SelfGuard can only be decrypted by the end user's metamask's account.


let sg = new SelfGuard(API_KEY, 'metamask');

Key Pair

Generate Public Private Key Pair

Allows you to create an RSA or ECSDA key pair.


let key_pair = sg.createKeyPair('rsa' || 'ecdsa');

Upload Key Pair

Allows you to save this key pair with SelfGuard, encrypted with a password


await sg.uploadKeyPair(key_pair,'password');

Get Key Pairs

Allows you to retrieve all encrypted key pairs stored with this account


await sg.getKeyPairs();

Encryption

Encrypt:

Allows you to encrypt any piece of data and receive the respective encryption key id (the encryption key is stored with SelfGuard) and the encrypted text.


await sg.encrypt( 'This is some super top secret text!')

Decrypt:

Allows you to decrypt previously encrypted data by providing the encrypted text and the encryption key id respective to the encrypted data.


await sg.decrypt(encrypted_text, encryption_key_id)

Encrypt With Password

Allows you to encrypt any piece of data with a password.


sg.encryptWithPassword( 'This is some super top secret text!','password')

Decrypt With Password:

Allows you to decrypt encrypted data with the respective password.


sg.decryptWithPassword(ciphertext, 'password')

File Storage

Used for storing encrypted files onto decentralized storage protocols like IPFS.

Upload/Encrypt File


await sg.encryptFile(file,(err,progress) => {
	console.log(progress);
});

Decrypt File


await sg.decryptFile(id,(err,progress) => {
	console.log(progress);
});

Get List of Files


await sg.getFiles();

Data Tokenization

Tokenize:

Allows you to encrypt data and store the encrypted data with SelfGuard itself.


await sg.tokenize( 'This is some super top secret text!');

Detokenize:

Allows you to retrieve the previously tokenized data by providing the respective token id.


let data = await sg.detokenize(token_id)

Encrypted Key/Value Storage

Put:

Allows you to store any key value data where the value is encrypted.


await sg.put('key','value');

Get:

Allows you to retrieve key value data where the value is decrypted upon retrieval


await sg.get('key');

Get Keys

Allows you to get all the keys (amongst all the key-value objects) stored with this account


await sg.getKeys();

Notifications

Used to send texts or emails to addresses who's email and phone number are stored using the encrypted key/value storage.

React Component For Notifications

Add Package

npm install selfguard-react-components

Implement Component

import { NotificationsButton } from  'selfguard-react-components';
return (
	<NotificationsButton
    api_key={api_key} 
    notification_group={notification_group} 
    user_address={user_address}
    background={background}
    size={size}
    color={color}
    onDisabled={onDisabled}
    onEnabled={onEnabled}
/>
)

Update Profile


await sg.updateProfile({user_address, value, notification_group});

Send SMS


await sg.sendSMS({user_address,notification_group,text});

Send Email


await sg.sendEmail({user_address,notification_group, subject, body});