SelfGuard provides encryption APIs and tooling to allow web2/3 developers to build enhanced and secure UI/UX. These include Encrypted Notifications, File Storage, Custodianship, and Payments.
Contact [email protected] with any questions.
Get your API-Key at https://selfguard.xyz
npm install selfguard-client
import SelfGuard from 'selfguard-client';
There are three main ways to instantiate SelfGuard.
This instantiates SelfGuard such that data with SelfGuard can be decrypted with this API-KEY.
let sg = new SelfGuard(API_KEY);
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);
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');
Allows you to create an RSA or ECSDA key pair.
let key_pair = sg.createKeyPair('rsa' || 'ecdsa');
Allows you to save this key pair with SelfGuard, encrypted with a password
await sg.uploadKeyPair(key_pair,'password');
Allows you to retrieve all encrypted key pairs stored with this account
await sg.getKeyPairs();
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!')
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)
Allows you to encrypt any piece of data with a password.
sg.encryptWithPassword( 'This is some super top secret text!','password')
Allows you to decrypt encrypted data with the respective password.
sg.decryptWithPassword(ciphertext, 'password')
Used for storing encrypted files onto decentralized storage protocols like IPFS.
await sg.encryptFile(file,(err,progress) => {
console.log(progress);
});
await sg.decryptFile(id,(err,progress) => {
console.log(progress);
});
await sg.getFiles();
Allows you to encrypt data and store the encrypted data with SelfGuard itself.
await sg.tokenize( 'This is some super top secret text!');
Allows you to retrieve the previously tokenized data by providing the respective token id.
let data = await sg.detokenize(token_id)
Allows you to store any key value data where the value is encrypted.
await sg.put('key','value');
Allows you to retrieve key value data where the value is decrypted upon retrieval
await sg.get('key');
Allows you to get all the keys (amongst all the key-value objects) stored with this account
await sg.getKeys();
Used to send texts or emails to addresses who's email and phone number are stored using the encrypted key/value storage.
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}
/>
)
await sg.updateProfile({user_address, value, notification_group});
await sg.sendSMS({user_address,notification_group,text});
await sg.sendEmail({user_address,notification_group, subject, body});