graphdb
Version:
Javascript client library supporting GraphDB and RDF4J REST API.
77 lines (76 loc) • 2.94 kB
TypeScript
export = AuthenticationService;
/**
* Service dealing with user authentication in a secured server.
*
* @author Mihail Radkov
* @author Svilen Velikov
* @author Teodossi Dossev
*/
declare class AuthenticationService {
/**
* Instantiates the service with the provided HTTP request executor.
*
* @param {HttpClient} [httpClient] used to execute HTTP requests
*/
constructor(httpClient?: HttpClient);
httpClient: HttpClient;
authenticationFactory: any;
/**
* Performs a login request against secured server with provided username and
* password. Upon successful authentication a {@link User} instance is created
* with the user data and the auth token and returned to the client.
*
* @param {ClientConfig} clientConfig concrete client configuration
* @param {User} user logged in user
*
* @return {Promise<User>} a promise resolving to an authenticated
* {@link User} instance.
*/
login(clientConfig: ClientConfig, user: User): Promise<User>;
/**
* Performs a logout of logged in user. This effectively removes the stored in
* the client user. Every consecutive call against secured server will result
* in <code>Unauthorized</code> error with status code <code>401</code>.
*
* @param {User} user logged in user
*
* @return {Promise} returns a promise which resolves with undefined.
*/
logout(user: User): Promise<any>;
/**
* Return an effective valid token as string which is going to be send as a
* request header <code>Authorization: token</code>. If there is no logged in
* user, then this method returns <code>undefined</code>.
*
* @param {User} user logged in user
* @return {string|undefined} authentication token
*/
getAuthenticationToken(user: User): string | undefined;
/**
* Checks if user credentials are provided and there isn't authenticated user
* yet. If that's the case, authentication should be made.
*
* @private
* @param {ClientConfig} clientConfig concrete client config
* @param {User} user logged in user
*
* @return {boolean} true if authentication should be made
*/
private isAlreadyAuthenticated;
/**
* Returns authentication type related {@link HttpRequestBuilder}
* login request builder
*
* @param {ClientConfig} clientConfig concrete client configuration
* @return {HttpRequestBuilder} request builder
*/
getLoginRequest(clientConfig: ClientConfig): HttpRequestBuilder;
/**
* Authentication type getter
* @param {ClientConfig} clientConfig concrete client configuration
* @return {BasicAuthentication|GdbTokenAuthentication} concrete
* authentication type
*/
getAuthentication(clientConfig: ClientConfig): BasicAuthentication | GdbTokenAuthentication;
}
import User = require("../auth/user");