🔐 NativeScript plugin for secure local storage of fi. passwords
TypeScript JavaScript CSS Ruby
Latest commit 3a29c8d Jan 10, 2017 @EddyVerbruggen committed on GitHub Delete postclone.js

README.md

NativeScript Secure Storage plugin

Installation

From the command prompt go to your app's root folder and execute:

tns plugin add nativescript-secure-storage

Demo app

Want to dive in quickly? Check out the demo! Otherwise, continue reading.

You can run the demo app from the root of the project by typing npm run demo.ios.device.

API

set

"In order to GET something you first need to SET it."

-- Eddy Verbruggen

JavaScript
// require the plugin
var SecureStorage = require("nativescript-secure-storage").SecureStorage;

// instantiate the plugin
var secureStorage = new SecureStorage();

secureStorage.set({
  key: "foo",
  value: "I was set at " + new Date()
}).then(
  function(success) {
    console.log("Successfully set a value? " + success);
  }
);
TypeScript
// require the plugin
import {SecureStorage} from "nativescript-secure-storage";

// instantiate the plugin
let secureStorage = new SecureStorage();

secureStorage.set({
  key: "foo",
  value: "I was set at " + new Date()
}).then(success => console.log("Successfully set a value? " + success));

get

Will return null if not found.

JavaScript
secureStorage.get({
  key: "foo"
}).then(
  function(value) {
    console.log("Got value: " + value);
  }
);
TypeScript
secureStorage.get({
  key: "foo"
}).then(value => console.log("Got value: " + value));

remove

JavaScript
secureStorage.remove({
  key: "foo"
}).then(
  function(success) {
    console.log("Removed value? " + success);
  }
);
TypeScript
secureStorage.remove({
  key: "foo"
}).then(success => console.log("Successfully removed a value? " + success));

Usage with Angular

In your view:

<Button text="set secure value" (tap)="setSecureValue()"></Button>

In your @Component:

import { SecureStorage } from "nativescript-secure-storage";

export class MyComponent {
  secureStorage = new SecureStorage();

  // a method that can be called from your view
  setSecureValue() {
    this.secureStorage.set({
      key: 'myKey',
      value: 'my value'
    }).then(success => { console.log(success)});
  }
}