import * as wn from 'webnative'
const state = await wn.initialise({
// Will ask the user permission to store
// your apps data in `private/Apps/Nullsoft/Winamp`
// Ask the user permission to additional filesystem paths
private: [ wn.path.directory("Audio", "Music") ],
public: [ wn.path.directory("Audio", "Mixtapes") ]
case wn.InitialisationError.InsecureContext:
// We need a secure context to do cryptography
// Usually this means we need HTTPS or localhost
case wn.InitialisationError.UnsupportedBrowser:
// Browser not supported.
// Example: Firefox private mode can't use indexedDB.
switch (state.scenario) {
case wn.Scenario.AuthCancelled:
// User was redirected to lobby,
// but cancelled the authorisation
case wn.Scenario.AuthSucceeded:
case wn.Scenario.Continuation:
// state.authenticated - Will always be `true` in these scenarios
// state.newUser - If the user is new to Fission
// state.throughLobby - If the user authenticated through the lobby, or just came back.
// state.username - The user's username.
// β We can now interact with our file system (more on that later)
case wn.Scenario.NotAuthorised:
wn.redirectToLobby(state.permissions)