Secure Data (Keystore)

API Reference: UI.SecureData

Provides encrypt and securely store data locally on the device.

On iOS Key Services is being used to store securely small chunks of data on behalf of the user & on Android the Android Keystore system lets you store cryptographic keys in a container to make it more difficult to extract from the device.

JavaScript
JavaScript
service: "com.myapp.serviceparameter"
},
key: "keyparameter"
});
var isSaved = false;
var btnSave = new Button({
text: "Save",
onPress: function() {
secure.save({ value: "password" }).then((resolvedValue) => {
isSaved = true;
}, (error) => {
console.log(error);
});
}
});
var btnDel = new Button({
text: "Delete",
onPress: function() {
if (isSaved) { // for Android this must be checked
secure.delete({ value: "top secretpassword" }).then((resolvedValue) => {
console.log(resolvedValue);
}, (error) => {
console.log(error);
});
isSaved = false;
}
else {
alert("There is no data to delete.")
}
}
});
var btnRead = new Button({
text: "Read",
onPress: function() {
if (isSaved) { // for Android this must be checked
secure.read().then((resolvedValue) => {
console.log(resolvedValue);
}, (error) => {
console.log(error);
});
}
else {
alert("There is no data to read.")
}
}
});
this.layout.addChild(btnSave, "btnSave", ".sf-button", function(userProps) {
userProps.width = 250;
userProps.top = 100;
userProps.left = 80;
return userProps;
});
this.layout.addChild(btnDel, "btnDel", ".sf-button", function(userProps) {
userProps.width = 250;
userProps.top = 180;
userProps.left = 80;
return userProps;
});
this.layout.addChild(btnRead, "btnRead", ".sf-button", function(userProps) {
userProps.width = 250;
userProps.top = 250;
userProps.left = 80;
return userProps;
});
this.layout.applyLayout();
}
module.exports = SecureDataPage;