soul-quickstore-client
v0.1.38
Published
QuickStore is an NPM package meant for quick storing and retrieving of data for Soul Identity SDK applications. It should not be used for long term data storage as it is consistently purged.
Downloads
5
Readme
soul-quickstore-client
QuickStore is an NPM package meant for quick storing and retrieving of data for Soul Identity SDK applications. It should not be used for long term data storage as it is consistently purged.
Installation
You can install the QuickStore using NPM:
npm install soul-quickstore-client --save
Usage
Here's how to use the QuickStore class in your JavaScript or TypeScript project:
import { QuickStore } from 'soul-quickstore-client';
// Initialize QuickStore with a key
const store = new QuickStore('your_key_here');
// Start a session with initial data
store
.startSession('your_initial_data_here')
.then(success => {
if (success) console.log('Session started successfully');
})
.catch(error => {
console.error('Failed to start session:', error);
});
// Update session with data
store
.updateSession('your_data_here')
.then(success => {
if (success) console.log('Session updated successfully');
})
.catch(error => {
console.error('Failed to update session:', error);
});
// Retrieve session
store
.retrieveSession()
.then(data => {
console.log('Session data:', data);
})
.catch(error => {
console.error('Failed to retrieve session:', error);
});
// Delete session
store
.deleteSession()
.then(success => {
if (success) console.log('Session deleted successfully');
})
.catch(error => {
console.error('Failed to delete session:', error);
});
API
constructor(inputKey?: Uint8Array | string)
: Initializes the QuickStore object with an optional key. If no key is provided, a new key is generated.startSession(initialData?: string): Promise<boolean>
: Starts a session with optional initial data.updateSession(data: string): Promise<boolean>
: Updates the session with the provided data.retrieveSession(): Promise<string>
: Retrieves the current session's data.deleteSession(): Promise<boolean>
: Deletes the current session.getID(): string
: Returns the id of the current session.setBackendUrl(url: string)
: Sets the backend URL for the session management.getUpdateKey(): string
: Returns the update key for the current session.getRetrievalKey(): string
: Returns the retrieval key for the current session.
Errors
The QuickStore class throws errors when it encounters issues with data size or when there's a problem with session management:
initialData too large
: Thrown when the initial data provided tostartSession
is larger than 100000 characters.data too large
: Thrown when the data provided toupdateSession
is larger than 100000 characters.no data
: Thrown when trying to retrieve a session's data but no data is found.decryption failed
: Thrown when decryption of the session's data fails.
Contributing
Please feel free to fork this repository, make changes, and submit pull requests. If you find any bugs, please report them by creating new issues in the repository.
License
This project is licensed under the MIT License.
Visit Soul Stamps
For more information and to explore our other offerings, check out Soul Identity.