Skip to content

Instantly share code, notes, and snippets.

@AndreSteenveld
Created August 7, 2016 12:38
Show Gist options
  • Save AndreSteenveld/19940860d897b5767c6fb3689832ac51 to your computer and use it in GitHub Desktop.
Save AndreSteenveld/19940860d897b5767c6fb3689832ac51 to your computer and use it in GitHub Desktop.
Stubbed out the OAuth2-server model
/**
* @typedef Client
* @type Object
* @property {String} id
* @property {String[]} grants
* @property {String[]} redirectUris
*/
/**
* @typedef User
* @type Object
*/
/**
* @typedef Scope
* @type Object
*/
/**
* @typedef Token
* @type Object
* @property {AccessToken} accessTokne
* @property {AuthorizationCode} authorizationCode
* @property {RefreshToken} refreshToken
* @property {Scope} scope
*/
/**
* @typedef AccessToken
* @extends Token
* @type Object
* @property {Client} client
* @property {User} user
* @property {Date} expiresAt
*/
/**
* @typedef RefreshToken
* @extends Token
* @type Object
* @property {Client} client
* @property {User} user
* @property {Date} expiresAt
*/
/**
* @typedef AuthorizationCode
* @type Object
* @property {String} authorizationCode
* @property {Client} client
* @property {User} user
* @property {Date} expiresAt
* @property {String} redirectUri
*/
/**
* @param {Token} token
* @return {Promise.<AccessToken>}
*/
export function getAccessToken( token ){ }
/**
* @param {String} id
* @param {String} secret
* @return {Promise.<Client>}
*/
export function getClient( id, secret ){ }
/**
* @param {Token} token
* @param {Client} client
* @param {User} user
* @return {Promise.<Token>}
*/
export function saveToken( token, client, user ){ }
/**
* @param {User} user
* @param {Client} client
* @param {Scope} scope
* @return {Promise.<bool>}
*/
export function validateScope( user, client, scope ){ }
/**
* @return {Promise.<AccessToken>}
*/
export function generateAccessToken( ){ }
/**
* @return {Promise.<AuthorizationCode>}
*/
export function generateAuthorizationCode( ){ }
/**
* @return {Promise.<RefreshToken>}
*/
export function generateRefreshToken( ){ }
/**
* @param {String} authorizationCode
* @return {Promise.<AuthorizationCode>}
*/
export function getAuthorizationCode( authorizationCode ){
}
/**
* @param {String} authorizationCode
* @return {Promise.<bool>}
*/
export function revokeAuthorizationCode( authorizationCode ){
}
/**
* @param {token} token
* @param {Client} client
* @param {user} user
* @return {Promise.<>}
*/
export function saveAuthorizationCode( token, client, user ){ }
/**
* @param {Client} client
* @return {Promise.<User>}
*/
export function getUserFromClient( client ){ }
/**
* @param {String} username
* @param {String} password
* @return {User}
*/
export function getUser( username, password ){ }
/**
* @param {Token} token
* @return {RefreshToken}
*/
export function getRefreshToken( token ){ }
/**
* @param {Token} token
* @return {Promise.<bool>}
*/
export function revokeToken( token ){ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment