Installation

SelfGuard can either be instantiated in the browser or server.
There are also react components to automatically integrate SelfGuard’s Modules (i.e - Enable/Disabling User Notifications)

Browser

Terminal
npm install selfguard-client

Server

Terminal
npm install selfguard-node

React Components

Terminal
npm install selfguard-react-components

Import

Depending on the environment, SelfGuard can be imported in the following ways.

Browser

import SelfGuard from "selfguard-client";

Server

import SelfGuard from "selfguard-node";

React Components

import {NotificationsButton} from "selfguard-react-components";

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);
If SelfGuard is instantiated with an ecdsa key pair, it will automatically store the encryption keys with Lit Protocol such that only the owner of the metamask account will be able to access them.

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.

key_pair_type
string
required

The key pair type that can either be ecdsa or rsa

public_key
string
required

The public key of the user, which can be generated using sg.createKeyPair('rsa' || 'ecdsa');

private_key
string
required

The private key of the user, which can be generated using sg.createKeyPair('rsa' || 'ecdsa');

let sg = new SelfGuard(API_KEY, key_pair_type, public_key, private_key);
If SelfGuard is instantiated with metamask, it will automatically store the encryption keys with Lit Protocol such that only the owner of the metamask account will be able to access them.

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.


Only Available in a Metamask Compatible Browser
let sg = new SelfGuard(API_KEY, 'metamask');