Secure Local Storage

This guide describes the Sencha Web Application Client secure local storage API and how to code your application to use this storage.

Secure local storage encrypts data before storing in a mobile device’s local memory. This feature lets applications store organizational data securely. Sencha Web Application Client uses the Ext.space.Promise API to asynchronously process reads, writes, and deletes through its quick encryption and decryption mechanism.

Data in the local storage is represented as a collection of JSON key-value pairs.

Sencha Web Application Client secure local storage improves on the localstorage feature of HTML5:

  • All data is encrypted before being persisted to local storage
  • Much higher storage limits than the 2-3 MB allocated for localstorage
  • Multiple key collections per application
  • Asynchronous using Ext.space.Promise

Secure local storage uses these APIs:

Ext.space.Promise

A promise registers callbacks to receive after the operation completes. This provides the eventual result of an asynchronlus operation.

For more information, see Promises/A+.

Ext.space.SecureLocalStorage

Encrypted key-value store modeled on HTML5 localstorage.

Ext.space.SecureSQL

Provides the backend storage mechanism for Sencha Web Application Client.

Using Secure Local Storage

The following storage function points to a storage area using a key value. If the caller provides data, the function stores the data. If no data is present, the function reads data from the key location.

store: function (key, data) {                         
    var mystore = Ext.space.SecureLocalStorage.get(key);
    if(data){
            return mystore.set('items', data);
    } else {
            return mystore.get('items');
    }
}

Deleting Secure Local Storage

You can delete a key-value pair from memory using:

delete: function (key) {
    var mystore = Ext.space.SecureLocalStorage.get(key);
    return mystore.delete('items');
}

You can call this function with:

mystore.delete('items').then(function(isDeleted){ ... })

Searching for Stored Data

The following API lets you find data:

find: function (key) {
    var mystore = Ext.space.SecureLocalStorage.get(key);
    return mystore.get('items', data);
}

You could then search using:

find('key').then(function(WhatToDoWhenFound){
    // Code for when key is found
});
Last updated