@onboardbase/store
v1.0.0
Published
Secure Store for Objects
Downloads
256
Readme
Onboardbase Store
Install
npm install @onboardbase/store
#or
yarn add @onboardbase/store
Example
import Store from '@onboardbase/store';
const store = new Store('YOUR_STORE_KEY');
(async () => {
console.log('set data', await store.set({ key: 'hey', value: 'hello' }));
console.log('get data', await store.get({ key: 'hey' }));
console.log(
'get data from locker',
await store.set({ key: 'hey2', value: 'hello-some-locker', lockerKey: 'some-locker' }),
);
console.log('get data from locker', await store.get({ key: 'hey2', lockerKey: 'some-locker' }));
const fs = require('fs');
const { Blob } = require('buffer');
let buffer = fs.readFileSync('./.gitignore');
let blob = new Blob([buffer]);
console.log(
'upload file',
await store.setFile({ key: 'hey-file', fileName: 'gitignore', lockerKey: 'some-locker', file: blob }),
);
console.log('download file', await store.getFile({ key: 'hey-file', lockerKey: 'some-locker' }));
})();
Usage
Set encrypted Key-Value
import Store from '@onboardbase/store';
const store = new Store('SK_M@!ODASMC@_#CSADM'); // your STORE_KEY;
// setObject
store.set({key: 'key', value: 'value'});
// Object
const object = store.setFile({ key: 'key', file: Blob })
Get Key-Value from Default Locker
store.get({ key: 'key' });
Get Value of a Key from a Locker
const value = store.get({ key: 'key', lockerKey: 'lockey_key' });
Files
Set Files or Blobs
await store.setFile({ key: 'hey-file', fileName: 'gitignore', file: blob });
// within a locker
await store.setFile({ key: 'hey-file', fileName: 'gitignore', lockerKey: 'some-locker', file: blob })
Get Files or Blobs from Default Locker
const object = await store.getFile({ key: 'hey-file' })
Get Files or Blobs from a Locker
const object = await store.getFile({ key: 'hey-file', lockerKey: 'some-locker' })