Create a NonLocalStorage instance.
API credentials.
Optional
id: stringOptional ID.
Create a NonLocalStorage instance.
API credentials.
Optional
options: InstanceOptionsOptional instance options.
Unique instance identifier
Indicates if the WebSocket connection is currently established. True if connected, false otherwise.
Static
retrieveRetrieves an access token for a given project using API credentials.
The unique identifier of the project.
The API key associated with the project.
The API secret associated with the project.
A promise that resolves to the access token as a string.
Sets the access token to be used for authentication.
The access token string to set.
token expiration in milliseconds from now
Registers a handler function to be called when the access token is about to expire.
A callback function that will be invoked before the access token expires.
Removes a previously registered handler for the access token expiring event.
The callback function to remove from the access token expiring handlers list.
Retrieve or initialize encryption settings for end-to-end encryption.
Optional
saltLength: numberOptional salt length in bytes (default: 16).
Promise resolving to encryption settings information.
Rotate encryption keys to enhance security.
Optional
saltLength: numberOptional salt length in bytes (default: 16).
Promise resolving to new encryption settings information.
Store a value by key.
The key name.
The value to store.
Optional
options: { ttl?: number; ifAbsent?: boolean }Optional overrides.
Optional
ttl?: numberTime-to-live in milliseconds for this item.
Optional
ifAbsent?: booleanIf true only set if item absent.
Metadata about the stored item.
Store multiple values at once.
Object of key/value pairs. Example:
{
key1: { value: 'foo' },
key2: { value: 'bar', ttl: 3600000 },
key2: { value: 'zip', ifAbsent: true }
}
ttl
is time-to-live in milliseconds for each item.
Metadata for each stored item.
Retrieve multiple values by key.
Array of key names.
Object of items found.
Retrieve all items, optionally filtered by prefix.
Optional
options: { prefix?: string }Optional prefix filter.
Object of all items.
Get all keys, optionally filtered by prefix.
Optional
options: { prefix?: string }Optional prefix filter.
Array of key names.
Remove a value by key.
The key name.
Remove multiple values by key.
Array of key names.
Atomically increment a numeric value.
The key name.
Amount to increment by (default 1).
Optional
options: { ttl?: number }Optional TTL override.
The updated item.
Atomically decrement a numeric value.
The key name.
Amount to decrement by (default 1).
Optional
options: { ttl?: number }Optional TTL override.
The updated item.
Remove all items for this instance.
Send a message to the server or other clients.
The message object to send.
Transport options (WebSocket or HTTP).
Register an event handler for WebSocket connection events.
The 'connect' event name.
Function to call when connected.
Register an event handler for WebSocket disconnection events.
The 'disconnect' event name.
Function to call when disconnected.
Register an event handler for presence join events.
The 'presence:join' event name.
Function to call when a connection joins.
Register an event handler for presence leave events.
The 'presence:leave' event name.
Function to call when a connection leaves.
Register an event handler for incoming messages.
The 'message' event name.
Function to call when a message is received.
Register an event handler for WebSocket errors.
The 'error' event name.
Function to call when an error occurs.
Register an event handler for all setItem events.
The 'setItem' event name.
Function to call when any item is set.
Register an event handler for specific setItem events.
The 'setItem' event name.
The specific item name to listen for.
Function to call when the named item is set.
Register an event handler for all removeItem events.
The 'removeItem' event name.
Function to call when any item is removed.
Register an event handler for specific removeItem events.
The 'removeItem' event name.
The specific item name to listen for.
Function to call when the named item is removed.
Remove an event handler for WebSocket connection events.
The 'connect' event name.
Function to remove.
Remove an event handler for WebSocket disconnection events.
The 'disconnect' event name.
Function to remove.
Remove an event handler for presence join events.
The 'presence:join' event name.
Function to remove.
Remove an event handler for presence leave events.
The 'presence:leave' event name.
Function to remove.
Remove an event handler for incoming messages.
The 'message' event name.
Function to remove.
Remove an event handler for WebSocket errors.
The 'error' event name.
Function to remove.
Remove an event handler for all setItem events.
The 'setItem' event name.
Function to remove.
Remove an event handler for specific setItem events.
The 'setItem' event name.
The specific item name.
Function to remove.
Remove an event handler for all removeItem events.
The 'removeItem' event name.
Function to remove.
Remove an event handler for specific removeItem events.
The 'removeItem' event name.
The specific item name.
Function to remove.
Join the presence channel to announce this connection to others.
Optional data to associate with this connection.
Get a list of all currently connected clients in the presence channel.
Promise resolving to an array of connected clients with their data.
Provides a persistent, optionally encrypted, remote key-value store. Supports atomic operations, TTL, and presence via websockets.
Remarks
Use this class to interact with the Vaultrice API for storing and retrieving data.