Skip to main content
Version: 0.6.0-alpha.2

SecureStorage Module


Version 0.6.0

OpenRPC

This document was generated from an OpenRPC JSON-Schema, and is intended to provide a human readable overview and examples of the methods contained in the module.

For the full schema, see the link below.

Schema
securestorage.json

Table of Contents

Usage

To use the SecureStorage module, you can import it into your project from the Firebolt SDK:

import { SecureStorage } from '@firebolt-js/sdk'

Overview

A module for storing and retrieving secure data owned by the app.

Events

Methods

get

Get stored value by key.

function get(scope: StorageScope, key: string): Promise<string>

Parameters

ParamTypeRequiredSummary
scopeStorageScopetrueThe scope of the key/value.
keystringtrueKey to get.

Promise Resolution

TypeDescription
stringThe retrieved value, if found.

Examples

Successfully retrieve a refresh token with key 'authRefreshToken'
JavaScript
import { SecureStorage } from '@firebolt-js/sdk'

SecureStorage.get("household", "authRefreshToken")
.then(value => {
console.log(value)
})

Value of value

"VGhpcyBub3QgYSByZWFsIHRva2VuLgo="
JSON-RPC
Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "securestorage.get",
"params": {
"scope": "household",
"key": "authRefreshToken"
}
}
Response
{
"jsonrpc": "2.0",
"id": 1,
"result": "VGhpcyBub3QgYSByZWFsIHRva2VuLgo="
}
Attempt to retrieve a a key with no value set.
JavaScript
import { SecureStorage } from '@firebolt-js/sdk'

SecureStorage.get("household", "authRefreshToken")
.then(value => {
console.log(value)
})

Value of value

null
JSON-RPC
Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "securestorage.get",
"params": {
"scope": "household",
"key": "authRefreshToken"
}
}
Response
{
"jsonrpc": "2.0",
"id": 1,
"result": null
}

set

Set or update a secure data value.

function set(scope: StorageScope, key: string, value: string): Promise<boolean>

Parameters

ParamTypeRequiredSummary
scopeStorageScopetrueThe scope of the data key.
keystringtrueKey to set.
valuestringtrueValue to set.

Promise Resolution

TypeDescription
booleanwhether the call was successful or not

Examples

Set a refresh token with name 'authRefreshToken'
JavaScript
import { SecureStorage } from '@firebolt-js/sdk'

SecureStorage.set("household", "authRefreshToken", "VGhpcyBub3QgYSByZWFsIHRva2VuLgo=")
.then(success => {
console.log(success)
})

Value of success

true
JSON-RPC
Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "securestorage.set",
"params": {
"scope": "household",
"key": "authRefreshToken",
"value": "VGhpcyBub3QgYSByZWFsIHRva2VuLgo="
}
}
Response
{
"jsonrpc": "2.0",
"id": 1,
"result": true
}

remove

Remove a secure data value.

function remove(scope: StorageScope, key: string): Promise<boolean>

Parameters

ParamTypeRequiredSummary
scopeStorageScopetrueThe scope of the data key.
keystringtrueKey to remove.

Promise Resolution

TypeDescription
booleanwhether the call was successful or not

Examples

Remove the value with key 'authRefreshToken'
JavaScript
import { SecureStorage } from '@firebolt-js/sdk'

SecureStorage.remove("household", "authRefreshToken")
.then(success => {
console.log(success)
})

Value of success

true
JSON-RPC
Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "securestorage.remove",
"params": {
"scope": "household",
"key": "authRefreshToken"
}
}
Response
{
"jsonrpc": "2.0",
"id": 1,
"result": true
}

Schemas

StorageScope

type StorageScope = 'household'

Details

The scope of the data.