1.1.81 • Published 1 year ago

selfguard-client v1.1.81

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

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});
1.1.70

1 year ago

1.1.74

1 year ago

1.1.73

1 year ago

1.1.72

1 year ago

1.1.71

1 year ago

1.1.78

1 year ago

1.1.77

1 year ago

1.1.76

1 year ago

1.1.75

1 year ago

1.1.79

1 year ago

1.1.81

1 year ago

1.1.80

1 year ago

1.1.49

2 years ago

1.1.48

2 years ago

1.1.47

2 years ago

1.1.52

2 years ago

1.1.51

2 years ago

1.1.50

2 years ago

1.1.56

2 years ago

1.1.55

2 years ago

1.1.54

2 years ago

1.1.53

2 years ago

1.1.59

2 years ago

1.1.58

2 years ago

1.1.57

2 years ago

1.1.63

2 years ago

1.1.62

2 years ago

1.1.61

2 years ago

1.1.60

2 years ago

1.1.67

1 year ago

1.1.66

1 year ago

1.1.65

1 year ago

1.1.64

1 year ago

1.1.69

1 year ago

1.1.68

1 year ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.29

2 years ago

1.1.28

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.1.6

2 years ago

1.0.7

2 years ago

1.1.5

2 years ago

1.0.6

2 years ago

1.1.4

2 years ago

1.0.5

2 years ago

1.1.3

2 years ago

1.0.4

2 years ago

1.1.2

2 years ago

1.1.30

2 years ago

1.1.34

2 years ago

1.1.33

2 years ago

1.1.32

2 years ago

1.1.31

2 years ago

1.1.38

2 years ago

1.1.37

2 years ago

1.1.36

2 years ago

1.1.35

2 years ago

1.1.39

2 years ago

1.1.41

2 years ago

1.1.40

2 years ago

1.1.45

2 years ago

1.1.23

2 years ago

1.1.44

2 years ago

1.1.22

2 years ago

1.1.43

2 years ago

1.1.21

2 years ago

1.1.42

2 years ago

1.1.20

2 years ago

1.1.26

2 years ago

1.1.25

2 years ago

1.1.46

2 years ago

1.1.24

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago