@akveo/nga-auth
Version:
@akveo/nga-auth
104 lines (103 loc) • 3.31 kB
TypeScript
import { Observable } from 'rxjs/Rx';
import 'rxjs/add/operator/do';
import { NgaAbstractAuthProvider } from '../providers/abstract-auth.provider';
import { NgaTokenService } from './token.service';
export declare class NgaAuthResult {
protected success: boolean;
protected response: any;
protected redirect: any;
protected token: any;
protected errors: string[];
protected messages: string[];
constructor(success: boolean, response?: any, redirect?: any, errors?: any, messages?: any, token?: any);
getResponse(): any;
getTokenValue(): any;
getRedirect(): any;
getErrors(): string[];
getMessages(): string[];
isSuccess(): boolean;
isFailure(): boolean;
}
export declare class NgaAuthService {
protected tokenService: NgaTokenService;
protected providers: {};
constructor(tokenService: NgaTokenService, providers?: {});
/**
* Retrieves current authenticated token stored
* @returns {Observable<any>}
*/
getToken(): Observable<any>;
/**
* Returns true if auth token is presented in the token storage
* @returns {Observable<any>}
*/
isAuthenticated(): Observable<any>;
/**
* Returns tokens stream
* @returns {Observable<any>}
*/
onTokenChange(): Observable<any>;
/**
* Returns authentication status stream
* @returns {Observable<any>}
*/
onAuthenticationChange(): Observable<any>;
/**
* Authenticates with the selected provider
* Stores received token in the token storage
*
* Example:
* authenticate('email', {email: 'email@example.com', password: 'test'})
*
* @param provider
* @param data
* @returns {Observable<NgaAuthResult>}
*/
authenticate(provider: string, data?: any): Observable<NgaAuthResult>;
/**
* Registers with the selected provider
* Stores received token in the token storage
*
* Example:
* register('email', {email: 'email@example.com', name: 'Some Name', password: 'test'})
*
* @param provider
* @param data
* @returns {Observable<NgaAuthResult>}
*/
register(provider: string, data?: any): Observable<NgaAuthResult>;
/**
* Sign outs with the selected provider
* Removes token from the token storage
*
* Example:
* logout('email')
*
* @param provider
* @returns {Observable<NgaAuthResult>}
*/
logout(provider: string): Observable<NgaAuthResult>;
/**
* Sends forgot password request to the selected provider
*
* Example:
* requestPassword('email', {email: 'email@example.com'})
*
* @param provider
* @param data
* @returns {Observable<NgaAuthResult>}
*/
requestPassword(provider: string, data?: any): Observable<NgaAuthResult>;
/**
* Tries to reset password with the selected provider
*
* Example:
* resetPassword('email', {newPassword: 'test'})
*
* @param provider
* @param data
* @returns {Observable<NgaAuthResult>}
*/
resetPassword(provider: string, data?: any): Observable<NgaAuthResult>;
getProvider(provider: string): NgaAbstractAuthProvider;
}