Introduction
SelfGuard provides encryption APIs and tooling to allow web2/3 developers to build enhanced and secure UI/UX.
Get Started
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
npm install selfguard-client
Server
npm install selfguard-node
React Components
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);
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.
The key pair type that can either be ecdsa
or rsa
The public key of the user, which can be generated using sg.createKeyPair('rsa' || 'ecdsa')
;
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);
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');