|
| 1 | +# AirGap Secure Storage - Cordova Plugin |
| 2 | + |
| 3 | +## Installation |
| 4 | +Install the plugin simply using npm: |
| 5 | + |
| 6 | +``` |
| 7 | +npm install git+ssh://git@github.com:airgap-it/cordova-plugin-airgap-secure-storage.git#master --save |
| 8 | +``` |
| 9 | + |
| 10 | +Make sure the plugin is added in your cordova `config.xml` as follows: |
| 11 | + |
| 12 | +``` |
| 13 | +<plugin name="cordova-plugin-airgap-secure-storage" spec="git+ssh://git@github.com:airgap-it/cordova-plugin-airgap-secure-storage.git#master" /> |
| 14 | +``` |
| 15 | + |
| 16 | +Instead of `#master` you can also pass a specific commit-hash to fix the version you would like to install. |
| 17 | + |
| 18 | +## Pre-Requisites Android / iOS |
| 19 | +To work, SecureStorage requires a secure lock-screen setup, either secured by a PIN / Pattern or Fingerprint. Otherwise, the keystore cannot be used to safely store data. |
| 20 | + |
| 21 | +## Usage |
| 22 | +The plugin provides a global variable as any cordova plugin does, to create a new instance call it as follows: |
| 23 | + |
| 24 | +``` |
| 25 | +let secureStorage = new window.SecureStorage("secure-storage-alias", false) |
| 26 | +``` |
| 27 | + |
| 28 | +You need to init() the SecureStorage instance in order to set it up properly if necessary. |
| 29 | + |
| 30 | +``` |
| 31 | +secureStorage.init(() => { |
| 32 | + // successful setup |
| 33 | +}), (error) => { |
| 34 | + // setup failed |
| 35 | +}) |
| 36 | +``` |
| 37 | + |
| 38 | +Then, the plugin provides the following functionalities: |
| 39 | + |
| 40 | +``` |
| 41 | +secureStorage.isDeviceSecure(key, value, () => {}, (error) => {}) |
| 42 | +secureStorage.secureDevice(key, value, () => {}, (error) => {}) |
| 43 | +
|
| 44 | +secureStorage.setItem(key, value, () => {}, (error) => {}) |
| 45 | +secureStorage.getItem(key, (value) => {}, (error) => {}) |
| 46 | +secureStorage.removeItem(key, () => {}, (error) => {}) |
| 47 | +secureStorage.removeAll(key, () => {}, (error) => {}) |
| 48 | +``` |
| 49 | + |
| 50 | +Everything else is handled by the device. |
0 commit comments