Account client
How to use
Import module
import { Account, IdP as Provider } from 'account'
Initialize
const config = {
label: 'me'
}
const provider = new Provider({
endpoint: 'http://domain.name'
})
const account = new Account(config, provider, window.localStorage)
Modes
Account
supports two modes: id
& label
.
These modes are pretty the same. Main difference is that in id
mode Account
uses audience
suffix at any request.
"Me" mode
id
& label
modes require a label to be known. But you actually may not.
There is special fetchLabel
method which allows to request actual label
for the account.
It uses me
placeholer for the request's URL. For instance:
Account.fetchLabel(
{ access_token: '<token>' },
new IdP(),
).then(({ id: acc_label }) => {
})
Request access token
access_token
will be automatically refreshed if applicable.
account.tokenData()
.then((_: ) => { })
Revoke refresh token
account.revokeRefreshToken()
.then((_: ) => { })
Store token
const tokenData = {}
account
.store(tokenData)
.then((_ ) => { })
Load token
account
.load()
.then((_ ) => { })
Remove token
account
.remove()
.then((_ ) => { })