Keychain
Encrypted per-script storage
Encrypted storage for API keys, scoped per script and readable from the widget. Put keys here rather than in a string literal: script source travels inside any exported .js file, so a key written into a script is shared with it.
Methods
Keychain.set(key, value)BooleanStores a value. Returns false if it could not be written.
- key String required
- value String required
Keychain.get(key)StringThe stored value, or null.
- key String required
Keychain.has(key)BooleanWhether a value is stored under this key.
- key String required
Keychain.delete(key)BooleanRemoves the value.
- key String required
Examples
Using a stored key
// once, from a script you run in the app:
// Keychain.set("apiKey", "…");
var key = Keychain.get("apiKey");
if (!key) {
Script.setWidget(new Widget({ child: Text("No API key set") }));
} else {
var res = Http.get(url + "?appid=" + key);
}