BrowserApp.js
Provides support for webdaemon apps in browsers.
Usage
import { BrowserApp } from 'webdaemon'
Patterns
Instantiate in your app code to extract and validate security token passed in URL:
const app = await BrowserApp.getInstance('MyApp')
Once instantiated in a page, no need to repeat the app name. For example, in a separate module:
const app = await BrowserApp.getInstance()
const appName = app.getAppName() // e.g. 'MyApp'
Use to find the party daemon name (i.e. who is using your app right now):
const user = app.getParty() // e.g. some.daemon.id
Get the token that secures communication back to that party:
const tokenBase64 = app.getTokenBase64()
const headers = {
'X-Tabserver-Token': tokenBase64
}
Get the token that secures communication back to a different system:
const tokenBase64 = app.getTokenBase64('api.acme.com')
Note that the only tokens available are those provided to the app upon launch. These tokens are not generated by your app.