UNPKG

3.63 kBJavaScriptView Raw
1"use strict";
2var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6 return c > 3 && r && Object.defineProperty(target, key, r), r;
7};
8var plugin_1 = require('./plugin');
9/**
10 * @name Secure Storage
11 * @description
12 * This plugin gets, sets and removes key,value pairs from a device's secure storage.
13 *
14 * 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).
15 *
16 * @usage
17 *
18 * ```typescript
19 * import { SecureStorage } from 'ionic-native';
20 *
21 * let secureStorage: SecureStorage = new SecureStorage();
22 * secureStorage.create('my_store_name')
23 * .then(
24 * () => console.log('Storage is ready!'),
25 * error => console.log(error)
26 * );
27 *
28 * secureStorage.get('myitem')
29 * .then(
30 * data => console.log(data),
31 * error => console.log(error)
32 * );
33 *
34 * secureStorage.set('myitem', 'myvalue')
35 * .then(
36 * data => console.log(data),
37 * error => console.log(error)
38 * );
39 *
40 * secureStorage.remove('myitem')
41 * .then(
42 * data => console.log(data),
43 * error => console.log(error)
44 * );
45 * ```
46 */
47var SecureStorage = (function () {
48 function SecureStorage() {
49 }
50 /**
51 * Creates a namespaced storage.
52 * @param store {string}
53 * @returns {Promise<any>}
54 */
55 SecureStorage.prototype.create = function (store) {
56 var _this = this;
57 return new Promise(function (res, rej) {
58 _this._objectInstance = new cordova.plugins.SecureStorage(res, rej, store);
59 });
60 };
61 /**
62 * Gets a stored item
63 * @param reference {string}
64 * @returns {Promise<any>}
65 */
66 SecureStorage.prototype.get = function (reference) { return; };
67 /**
68 * Stores a value
69 * @param reference {string}
70 * @param value {string}
71 * @returns {Promise<any>}
72 */
73 SecureStorage.prototype.set = function (reference, value) { return; };
74 /**
75 * Removes a single stored item
76 * @param reference {string}
77 * @returns {Promise<any>}
78 */
79 SecureStorage.prototype.remove = function (reference) { return; };
80 __decorate([
81 plugin_1.CordovaInstance({
82 callbackOrder: 'reverse'
83 })
84 ], SecureStorage.prototype, "get", null);
85 __decorate([
86 plugin_1.CordovaInstance({
87 callbackOrder: 'reverse'
88 })
89 ], SecureStorage.prototype, "set", null);
90 __decorate([
91 plugin_1.CordovaInstance({
92 callbackOrder: 'reverse'
93 })
94 ], SecureStorage.prototype, "remove", null);
95 SecureStorage = __decorate([
96 plugin_1.Plugin({
97 pluginName: 'SecureStorage',
98 plugin: 'cordova-plugin-secure-storage',
99 pluginRef: 'plugins.securestorage',
100 repo: 'https://github.com/Crypho/cordova-plugin-secure-storage',
101 platforms: ['Android', 'iOS', 'Windows Phone', 'Browser']
102 })
103 ], SecureStorage);
104 return SecureStorage;
105}());
106exports.SecureStorage = SecureStorage;
107//# sourceMappingURL=securestorage.js.map
\No newline at end of file