core¶
Source | core |
---|
The core is a function catalog to handle users accountId, login provider and users utility functions.
logout¶
core.logout(disabledReload);
Logout the current user. Removes the active account, provider and terms of use acceptance.
Parameters¶
disabledReload
-boolean
: The options used for calling
getCurrentProvider¶
core.getCurrentProvider();
Get the current, in local storage, configured provider.
Returns¶
string
: The current provider (external, internal, agent-executor)
isInternalProvider¶
core.isInternalProvider();
Check if we should use internal provider.
Returns¶
boolean
: Check if we should use internal provider.
getExternalProvider¶
core.getExternalProvider();
Checks if a injected web3 provider exists an returns it’s name
Returns¶
boolean
: check if the current provider is external
setCurrentProvider¶
core.setCurrentProvider(provider);
Sets the current provider that should be used.
Parameters¶
string
: provider to switch to
activeAccount¶
core.activeAccount();
Get the current selected account included the check of the current provider.
Returns¶
string
: account id of the current user (0x0…)
getAccountId¶
core.getAccountId();
Returns the current (in the localStorage) saved account id
Returns¶
string
: account id of the user (0x0…)
setAccountId¶
core.setAccountId(accountId);
Sets an account id as active one to the local storage.
Parameters¶
accountId
-string
: account id to set to the localStorage
getExternalAccount¶
core.getExternalAccount();
Checks if an external provider is activated and returns it’s active account id
Returns¶
string
: The external account.
getAgentExecutor¶
core.getAgentExecutor();
Checks the current url parameters if agent executor login parameters are given.
Returns¶
any
: all agent-exeutor parameters for requesting smart-agents and decrypting the profile
Example¶
- URL : hhtps://dashboard.test.evan.network/index.html?agent-executor=1234…#/dashboard.evan
core.getAgentExecutor()
// {
// token: '', // token to request the smart-agent and to load accountId and key for decrypting profile
// accountId: '', // accountId of the smart-agent account
// key: '' // data-key of the profile
// }
watchAccountChange¶
core.watchAccountChange();
Watches for account changes and reload the page if nessecary
currentBrowser¶
core.currentBrowser();
Return the name of the current used browser => https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
Returns¶
string
: opera / firefox / safari / ie / edge / chrome