BaseInternetAccountModel
Auto-generated from the @jbrowse/mobx-state-tree model in the source. See the developer guide for concepts. Built into JBrowse core. View source.
Adds a token header to each request for a file on one of the account's
domains, keeping the token in sessionStorage. Every internet account type
builds on this model.
Properties
| Member | Description |
|---|---|
idstring · default createElementId() |
The identifier references to this node resolve through. A snapshot that leaves it out gets a generated one. |
typestring |
The registered name of the concrete type, which a snapshot selects it by. |
configurationBaseInternetAccountConfig |
The config node this model reads its settings from, through getConf. |
Getters
| Member | Description |
|---|---|
namestring |
|
descriptionstring |
|
internetAccountIdstring |
|
authHeaderstring |
|
tokenTypestring |
|
domainsstring[] |
|
toggleContentsReactNode |
Can use this to customize what is displayed in fileSelector's toggle box |
selectorLabelstring | undefined |
Can use this to add a label to the UrlChooser |
showInFileSelectorboolean |
Whether the fileSelector offers this account as a source to pick. Turn it off for an account that only ever matches by domain and has nothing for the user to enter — HTTP Basic, whose ephemeral per-origin accounts would otherwise pile up as toggles nobody asked for. |
browseLabelstring | undefined |
The fileSelector's label for a button that opens the provider's own file picker, for an account that has one; see chooseLocation |
tokenKeystring |
The sessionStorage key that holds this internetAccount's token |
credentialBindingstring |
The account's config minus its name and description, as JSON with sorted keys. A stored credential is read back only by an account whose binding is identical to the one that stored it. |
Methods
| Member | Description |
|---|---|
handlesLocation(location: UriLocation) => boolean |
Determine whether this internetAccount provides credentials for a URL |
bindCredential(token: string) => string |
The value to put in storage for token, tied to this account's config |
unbindCredential(stored: string | undefined) => string | undefined |
The token in a stored value, if this account's config is the one that stored it |
Actions
| Member | Description |
|---|---|
chooseLocation() => Promise<UriLocation | undefined> |
Open the provider's file picker and resolve to the chosen file's location, or undefined if the user cancels |
| getTokenFromUser |
Must be implemented by a model extending or composing this one. Pass the user's token to resolve. |
storeToken(token: string) => void |
|
retrieveToken() => string | undefined |
|
validateToken(token: string, _loc: UriLocation) => Promise<string> |
This can be used by an internetAccount to validate a token works before it is used. This runs when preAuthorizationInformation is requested, so it can check that a token is valid before sending it to a worker thread. It expects the token to be returned, so this action can also generate a new token (e.g. with a refresh token) if the original one was invalid. Should throw an error if a token is invalid, and call removeToken first when the failure condemns the token itself (a 401), so the next getToken asks again; a failure for any other reason, such as a missing file, should keep it. |
removeToken() => void |
Clears the stored token. Also drops the in-memory cached promise so a subsequent getToken re-prompts / re-derives rather than handing back the token that was just invalidated. |
getToken(location?: UriLocation) => Promise<string> |
Try to get the token from a previously cached promise, then in a worker from the location's pre-authorization, or on the main thread from session storage. If token is not available, uses getTokenFromUser. |
| addAuthHeaderToInit |
|
| fetchWithToken |
Run a request with the current token and, only if it comes back 401, put the token through validateToken and run it exactly once more. This is how every account's fetcher reaches a resource. |
| Gets the token and returns it along with the information needed to create a new internetAccount. | |
| getFetcher |
Get a fetch method that will add any needed authentication headers to the request before sending it. If location is provided, it will be checked to see if it includes a token in it pre-auth information. |
openLocation(location: UriLocation) => RemoteFileWithRangeCache |
Gets a filehandle that uses a fetch that adds auth headers |