Env variables and configuration
You can add a number of key-value
pairs into the Applet in a form of config.
Config values are unique per device and typically is used for passing:
- custom variables
- tokens and credentials
- any dynamic value that differs per-device
Accessing configuration
Configuration is available within JS SDK under the sos
object.
Accessing applet configuration
// Parsed JSON object passed for current applet & current device together
console.log(sos.config);
console.log(sos.config.identification);
console.log(sos.config.yourKey);
Defining configuration in code
Any configuration can be defined as code in package.json
.
You can define multiple configuration in a config array. Each configuration item has the following definition:
Key | Value type | Description |
---|---|---|
name | string | name of the configuration |
valueType | string/URL/enum/number/secret | expected value type |
list | array of strings | numbers | only for valueType enum, list of predefined options |
mandatory | boolean | required to be filled before building applet or assigning applet |
description | string | description shown in the UI to guide user |
placeholder | string | field placeholder in the UI to guide user; placeholder is never used as default value |
min | number | minimum number value user can fill in to the field |
max | number | maximum number value user can fill in to the field |
Secret
type in configuration
Applet/Timing configuration is often used for passing sensitive data - e.g.: tokens, credentials, and passwords. To keep these values protected, use Applet configuration with valueType: secret.
Any values with valueType: secret will be protected from being seen in the Box.
Full example
package.json
"sos": {
"config": [
{
"name": "authToken",
"valueType": "secret",
"mandatory": true,
"description": "A token generated by My Control used for authentication against My cloud."
},
{
"name": "myBaseUrl",
"valueType": "URL",
"description": "A base URL to My cloud. No slash at the end required.",
"placeholder": "https://api.signageos.io"
},
{
"name": "playerDuration",
"valueType": "string",
"description": "A length of generated playlist in '##s' format (seconds).",
"placeholder": "172800s"
},
{
"name": "refreshIntervalMs",
"valueType": "number",
"description": "Frequency of trying to generate new playlist from My cloud in milliseconds.",
"placeholder": "65000",
"min": 60000,
"max": 70000
},
{
"name": "playerId",
"valueType": "string",
"description": "An identifier for the device used to identifying against cloud. E.g. platform: SSSP, WEBOS, BRIGHTSIGN, ANDROID, WINDOWS, LINUX",
"placeholder": "{PLATFORM}_{SERIAL_NUMBER}"
},
{
"name": "proxyUrl",
"valueType": "URL",
"description": "A prefix for all HTTP(s) requests done by My player to My cloud. Default is no proxy.",
"placeholder": "https://cors-anywhere.herokuapp.com/"
}
],
"appletUid": "967daxxxxxxx58e27376a5596028"
},
Setting configuration values
Learn how to assing the configuration values using Box or REST API