awesome-cordova-plugins/src/plugins/securestorage.ts
Ramon Henrique Ornelas 54460e2362 style(): fix angular styles (#512)
* style(canva-camera): fix angular style

* style(crop): fix angular style

* style(file-chooser): fix angular style

* style(file-opener): fix angular style

* style(file): fix angular style

* style(inappbrowser): fix angular style

* style(instagram): fix angular style

* style(is-debug): fix angular style

* style(native-page-transitions): fix angular style

* style(market): fix angular style

* style(music-controls): fix angular style

* style(nfc): fix angular style

* style(pay-pal): fix angular style

* style(power-management): fix angular style

* style(securestorage): fix angular style

* style(streaming-media): fix angular style

* style(video-editor): fix angular style

* style(youtube-video-player): fix angular style
2016-08-31 17:02:15 -04:00

92 lines
2.1 KiB
TypeScript

import { CordovaInstance, Plugin } from './plugin';
declare var cordova: any;
/**
* @name Secure Storage
* @description
* This plugin gets, sets and removes key,value pairs from a device's secure storage.
*
* Requires Cordova plugin: `cordova-plugin-secure-storage`. For more info, please see the [Cordova Secure Storage docs](https://github.com/Crypho/cordova-plugin-secure-storage).
*
* @usage
*
* ```typescript
* import { SecureStorage } from 'ionic-native';
*
* let secureStorage: SecureStorage = new SecureStorage();
* secureStorage.create('my_store_name')
* .then(
* () => console.log('Storage is ready!'),
* error => console.log(error)
* );
*
* secureStorage.get('myitem')
* .then(
* data => console.log(data),
* error => console.log(error)
* );
*
* secureStorage.set('myitem', 'myvalue')
* .then(
* data => console.log(data),
* error => console.log(error)
* );
*
* secureStorage.remove('myitem')
* .then(
* data => console.log(data),
* error => console.log(error)
* );
* ```
*/
@Plugin({
plugin: 'cordova-plugin-secure-storage',
pluginRef: 'plugins.securestorage',
repo: 'https://github.com/Crypho/cordova-plugin-secure-storage',
platforms: ['Android', 'iOS', 'Windows Phone', 'Browser']
})
export class SecureStorage {
private _objectInstance: any;
constructor() {}
/**
* Creates a namespaced storage.
* @param store {string}
*/
create(store: string): Promise<any> {
return new Promise((res, rej) => {
this._objectInstance = new cordova.plugins.SecureStorage(res, rej, store);
});
}
/**
* Gets a stored item
* @param reference {string}
*/
@CordovaInstance({
callbackOrder: 'reverse'
})
get(reference: string): Promise<any> { return; }
/**
* Stores a value
* @param reference {string}
* @param value {string}
*/
@CordovaInstance({
callbackOrder: 'reverse'
})
set(reference: string, value: string): Promise<any> { return; }
/**
* Removes a single stored item
* @param reference {string}
*/
@CordovaInstance({
callbackOrder: 'reverse'
})
remove(reference: string): Promise<any> { return; }
}