0.1.38 • Published 9 months ago

soul-quickstore-client v0.1.38

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

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 to startSession is larger than 100000 characters.
  • data too large: Thrown when the data provided to updateSession 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.

0.1.38

9 months ago

0.1.37

9 months ago

0.1.36

9 months ago

0.1.35

11 months ago

0.1.3

11 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago