UNPKG

baasic-sdk-javascript

Version:

JavaScript SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).

89 lines (88 loc) 4.34 kB
/** * @module loginClient * @description Login Client provides an easy way to consume Application Registration REST API end-points. In order to obtain needed routes `loginClient` uses `loginRoute`. */ import { ITokenHandler } from '../../../core/contracts'; import { ApiClient, IHttpResponse } from '../../../httpApi'; import { LoginRoute } from '.'; import { IPlatformUserInfo, ILoginData } from './contracts'; export declare class LoginClient { protected loginRoute: LoginRoute; protected tokenHandler: ITokenHandler; protected apiClient: ApiClient; readonly routeDefinition: LoginRoute; private utility; constructor(loginRoute: LoginRoute, tokenHandler: ITokenHandler, apiClient: ApiClient); /** * Returns a promise that is resolved once the login action has been performed. This action logs user into the application and success response returns the token resource. * @method * @example loginClient.login({ username : '<username>', password : '<password>', options : ['session', 'sliding'] }) .then(function (data) { // perform success actions here }, function (data, status) { // perform error handling here }) .finally (function () {}); **/ login(data: ILoginData): PromiseLike<any>; /** * Returns a promise that is resolved once the loadUserData action has been performed. This action retrieves the account information of the currently logged in user. Retrieved account information will contain permission collection which identifies access policies assigned to the user and application sections. * @method * @example loginClient.loadUserData() .then(function (data) { // perform success actions here }, function (data) { // perform error handling here }) .finally (function () {}); */ loadUserData(data: any): PromiseLike<IHttpResponse<IPlatformUserInfo>>; /** * Returns a promise that is resolved once the logout action has been performed. This action invalidates user token logging the user out of the system. * @method * @param token Authentication token which uniquely identifies user that needs to be logged out from the system. * @param type Token type. * @returns A promise that is resolved once the logout action has been performed. * @example let token = baasicAuthorizationService.getAccessToken(); loginClient.logout(token.access_token, token.token_type) .then(function (data) { // perform success handling here }, function() { // perform error handling here }) .finally (function () {}); */ logout(token: string, type: string): PromiseLike<any>; /** * Returns a promise that is resolved once the refresh token action has been performed. This action refreshes user token. * @method * @param token Authentication token which uniquely identifies user that needs to be logged out from the system. * @param type Token type. * @returns A promise that is resolved once the refresh token action has been performed. * @example let token = baasicAuthorizationService.getAccessToken(); loginClient.refresh(token.access_token, token.token_type) .then(function (data) { // perform success handling here }, function() { // perform error handling here }) .finally (function () {}); */ refresh(token: string, type: string): PromiseLike<any>; /** * Returns url encoded form data. */ private transformData; } /** * @overview ***Notes:** - Refer to the [Baasic REST API](http://dev.baasic.com/api/reference/home) for detailed information about available Baasic REST API end-points. - All end-point objects are transformed by the associated route definition. */