Skip to content

Instantly share code, notes, and snippets.

@cmonacaps
Last active July 31, 2020 14:23
Show Gist options
  • Save cmonacaps/302a2b5d5f7125cfc6c453511238f998 to your computer and use it in GitHub Desktop.
Save cmonacaps/302a2b5d5f7125cfc6c453511238f998 to your computer and use it in GitHub Desktop.
declare namespace lafs_gui_signon {
interface UserIdent {
id: number;
}
/** checkUserCredentials
*
* Resolve with a `UserIdent` value if the supplied `username` and `password` are valid
* according to an external authority, and throw a diagnostic otherwise or if it could not
* be determined. When returning the `UserIdent` it is asynchronously stored along with
* related access token in user local storage.
*/
declare function checkUserCredentials(username: string, password: string): Promise<UserIdent>;
/** confirmUserSignOn
*
* Verify with the external authority the validity of the token held in user local storage,
* storage, obtained during a previous successful call to `checkUserCredentials` documented
* above, and return true if the token is valid, and false otherwise, or if the token is not
* found in local storage. When returning false, the token held in user local storage, if
* applicable, is asynchronously deleted. If an answer could not be obtained from the
* authority, an exception having a useful diagnostic will be thrown.
*/
declare function confirmUserSignOn() : Promise<boolean>
/** getUserIdent
*
* Read and parse the user identification structure held in local storage along with
* the access token obtained from the sign-on authority.
*
* If the content in the user local storage is missing or could not be parsed, and
* exception having a useful diagnostic is thrown.
*
* Note that this function makes no external request.
*/
declare function getUserIdent() : Promise<UserIdent>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment