Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Merge pull request #291 from nexbit/fix/dts
Browse files Browse the repository at this point in the history
chore(project): fix d.ts
  • Loading branch information
doktordirk authored Oct 14, 2016
2 parents cf8b1f1 + 920134a commit 447003f
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 55 deletions.
6 changes: 3 additions & 3 deletions src/authFilterValueConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ export class AuthFilterValueConverter {
/**
* route toView predictator on route.config.auth === isAuthenticated
* @param {RouteConfig} routes the routes array to convert
* @param {Boolean} isAuthenticated authentication status
* @return {Boolean} show/hide element
* @param {boolean} isAuthenticated authentication status
* @return {boolean} show/hide element
*/
toView(routes: RouteConfig, isAuthenticated: Boolean): Boolean {
toView(routes: RouteConfig, isAuthenticated: boolean): boolean {
return routes.filter(route => typeof route.config.auth !== 'boolean' || route.config.auth === isAuthenticated);
}
}
88 changes: 44 additions & 44 deletions src/authService.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ export class AuthService {
/**
* The current login status
*
* @param {Boolean}
* @param {boolean}
*/
authenticated: Boolean = false;
authenticated: boolean = false;

/**
* The currently set timeoutID
*
* @param {Number}
* @param {number}
*/
timeoutID: Number = 0;
timeoutID: number = 0;

/**
* Create an AuthService instance
Expand Down Expand Up @@ -137,9 +137,9 @@ export class AuthService {
/**
* Sets the login timeout
*
* @param {Number} ttl Timeout time in ms
* @param {number} ttl Timeout time in ms
*/
setTimeout(ttl: Number) {
setTimeout(ttl: number) {
this.clearTimeout();

this.timeoutID = PLATFORM.global.setTimeout(() => {
Expand Down Expand Up @@ -205,12 +205,12 @@ export class AuthService {
/**
* Get current user profile from server
*
* @param {({}|Number|String)} [criteriaOrId] (optional) An object or a Number|String converted to {id: criteriaOrId}
* @param {({}|number|string)} [criteriaOrId] (optional) An object or a number|string converted to {id: criteriaOrId}
* @returns {Promise<any>} The server response
*
* @memberOf AuthService
*/
getMe(criteriaOrId?: {}|Number|String): Promise<any> {
getMe(criteriaOrId?: {}|number|string): Promise<any> {
if (typeof criteriaOrId === 'string' || typeof criteriaOrId === 'number') {
criteriaOrId = {id: criteriaOrId};
}
Expand All @@ -222,11 +222,11 @@ export class AuthService {
* Send current user profile update to server
*
* @param {{}} body Request body with data.
* @param {{}|Number|String} [criteriaOrId] (optional) An object or a Number|String converted to {id: criteriaOrId}
* @param {{}|number|string} [criteriaOrId] (optional) An object or a number|string converted to {id: criteriaOrId}
*
* @return {Promise<any>} The server response
*/
updateMe(body: {}, criteriaOrId?: {}|Number|String): Promise<any> {
updateMe(body: {}, criteriaOrId?: {}|number|string): Promise<any> {
if (typeof criteriaOrId === 'string' || typeof criteriaOrId === 'number') {
criteriaOrId = {id: criteriaOrId};
}
Expand All @@ -240,41 +240,41 @@ export class AuthService {
/**
* Get accessToken from storage
*
* @returns {String} Current accessToken
* @returns {string} Current accessToken
*/
getAccessToken(): String {
getAccessToken(): string {
return this.authentication.getAccessToken();
}

@deprecated({message: 'Use .getAccessToken() instead.'})
getCurrentToken(): String {
getCurrentToken(): string {
return this.getAccessToken();
}

/**
* Get refreshToken from storage
*
* @returns {String} Current refreshToken
* @returns {string} Current refreshToken
*/
getRefreshToken(): String {
getRefreshToken(): string {
return this.authentication.getRefreshToken();
}

/**
* Get idToken from storage
*
* @returns {String} Current idToken
* @returns {string} Current idToken
*/
getIdToken(): String {
getIdToken(): string {
return this.authentication.getIdToken();
}

/**
* Gets authentication status from storage
*
* @returns {Boolean} For Non-JWT and unexpired JWT: true, else: false
* @returns {boolean} For Non-JWT and unexpired JWT: true, else: false
*/
isAuthenticated(): Boolean {
isAuthenticated(): boolean {
this.authentication.responseAnalyzed = false;

let authenticated = this.authentication.isAuthenticated();
Expand All @@ -295,27 +295,27 @@ export class AuthService {
/**
* Gets exp in milliseconds
*
* @returns {Number} Exp for JWT tokens, NaN for all other tokens
* @returns {number} Exp for JWT tokens, NaN for all other tokens
*/
getExp(): Number {
getExp(): number {
return this.authentication.getExp();
}

/**
* Gets ttl in seconds
*
* @returns {Number} Ttl for JWT tokens, NaN for all other tokens
* @returns {number} Ttl for JWT tokens, NaN for all other tokens
*/
getTtl(): Number {
getTtl(): number {
return this.authentication.getTtl();
}

/**
* Gets exp from token payload and compares to current time
*
* @returns {Boolean} Returns (ttl > 0)? for JWT, undefined other tokens
* @returns {boolean} Returns (ttl > 0)? for JWT, undefined other tokens
*/
isTokenExpired(): Boolean {
isTokenExpired(): boolean {
return this.authentication.isTokenExpired();
}

Expand Down Expand Up @@ -365,15 +365,15 @@ export class AuthService {
/**
* Signup locally. Login and redirect depending on config
*
* @param {String|{}} displayNameOrCredentials displayName | object with signup data.
* @param {[String]|{}} emailOrOptions [email | options for post request]
* @param {[String]} passwordOrRedirectUri [password | optional redirectUri overwrite]
* @param {string|{}} displayNameOrCredentials displayName | object with signup data.
* @param {[string]|{}} emailOrOptions [email | options for post request]
* @param {[string]} passwordOrRedirectUri [password | optional redirectUri overwrite]
* @param {[{}]} options [options]
* @param {[String]} redirectUri [optional redirectUri overwrite]
* @param {[string]} redirectUri [optional redirectUri overwrite]
*
* @return {Promise<any>} Server response as Object
*/
signup(displayNameOrCredentials: String|{}, emailOrOptions?: String|{}, passwordOrRedirectUri?: String, options?: {}, redirectUri?: String): Promise<any> {
signup(displayNameOrCredentials: string|{}, emailOrOptions?: string|{}, passwordOrRedirectUri?: string, options?: {}, redirectUri?: string): Promise<any> {
let normalized = {};

if (typeof displayNameOrCredentials === 'object') {
Expand Down Expand Up @@ -404,14 +404,14 @@ export class AuthService {
/**
* Login locally. Redirect depending on config
*
* @param {[String]|{}} emailOrCredentials email | object with signup data.
* @param {[String]} [passwordOrOptions] [password | options for post request]
* @param {[string]|{}} emailOrCredentials email | object with signup data.
* @param {[string]} [passwordOrOptions] [password | options for post request]
* @param {[{}]} [optionsOrRedirectUri] [options | redirectUri overwrite]]
* @param {[String]} [redirectUri] [optional redirectUri overwrite]
* @param {[string]} [redirectUri] [optional redirectUri overwrite]
*
* @return {Promise<Object>|Promise<Error>} Server response as Object
*/
login(emailOrCredentials: String|{}, passwordOrOptions?: String, optionsOrRedirectUri?: {}, redirectUri?: String): Promise<any> {
login(emailOrCredentials: string|{}, passwordOrOptions?: string, optionsOrRedirectUri?: {}, redirectUri?: string): Promise<any> {
let normalized = {};

if (typeof emailOrCredentials === 'object') {
Expand Down Expand Up @@ -444,13 +444,13 @@ export class AuthService {
/**
* Logout locally and redirect to redirectUri (if set) or redirectUri of config. Sends logout request first, if set in config
*
* @param {[String]} [redirectUri] [optional redirectUri overwrite]
* @param {[String]} [query] [optional query]
* @param {[String]} [name] [optional name Name of the provider]
* @param {[string]} [redirectUri] [optional redirectUri overwrite]
* @param {[string]} [query] [optional query]
* @param {[string]} [name] [optional name Name of the provider]
*
* @return {Promise<any>} Server response as Object
*/
logout(redirectUri?: String, query?: String, name?: String): Promise<any> {
logout(redirectUri?: string, query?: string, name?: string): Promise<any> {
let localLogout = response => new Promise(resolve => {
this.setResponseObject(null);

Expand Down Expand Up @@ -485,13 +485,13 @@ export class AuthService {
/**
* Authenticate with third-party and redirect to redirectUri (if set) or redirectUri of config
*
* @param {String} name Name of the provider
* @param {[String]} [redirectUri] [optional redirectUri overwrite]
* @param {string} name Name of the provider
* @param {[string]} [redirectUri] [optional redirectUri overwrite]
* @param {[{}]} [userData] [optional userData for the local authentication server]
*
* @return {Promise<any>} Server response as Object
*/
authenticate(name: String, redirectUri?: String, userData?: {}): Promise<any> {
authenticate(name: string, redirectUri?: string, userData?: {}): Promise<any> {
return this.authentication.authenticate(name, userData)
.then(response => {
this.setResponseObject(response);
Expand All @@ -505,12 +505,12 @@ export class AuthService {
/**
* Unlink third-party
*
* @param {String} name Name of the provider
* @param {[String]} [redirectUri] [optional redirectUri overwrite]
* @param {string} name Name of the provider
* @param {[string]} [redirectUri] [optional redirectUri overwrite]
*
* @return {Promise<any>} Server response as Object
*/
unlink(name: String, redirectUri?: String): Promise<any> {
unlink(name: string, redirectUri?: string): Promise<any> {
const unlinkUrl = this.config.joinBase(this.config.unlinkUrl) + name;

return this.client.request(this.config.unlinkMethod, unlinkUrl)
Expand Down
6 changes: 3 additions & 3 deletions src/authenticatedFilterValueConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export class AuthenticatedFilterValueConverter {
/**
* route toView predictator on route.config.auth === (parameter || authService.isAuthenticated())
* @param {RouteConfig} routes the routes array to convert
* @param {[Boolean]} [isAuthenticated] optional isAuthenticated value. default: this.authService.authenticated
* @return {Boolean} show/hide element
* @param {[boolean]} [isAuthenticated] optional isAuthenticated value. default: this.authService.authenticated
* @return {boolean} show/hide element
*/
toView(routes: RouteConfig, isAuthenticated: Boolean = this.authService.authenticated): Boolean {
toView(routes: RouteConfig, isAuthenticated: boolean = this.authService.authenticated): boolean {
return routes.filter(route => typeof route.config.auth !== 'boolean' || route.config.auth === isAuthenticated);
}
}
2 changes: 1 addition & 1 deletion src/authenticatedValueConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class AuthenticatedValueConverter {

/**
* element toView predictator on authService.isAuthenticated()
* @return {Boolean} show/hide element
* @return {boolean} show/hide element
*/
toView() {
return this.authService.authenticated;
Expand Down
6 changes: 3 additions & 3 deletions src/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ export class Authentication {
return this.payload;
}

getExp(): Number {
getExp(): number {
if (!this.responseAnalyzed) this.getDataFromResponse(this.getResponseObject());

return this.exp;
}

/* get status from data */
getTtl(): Number {
getTtl(): number {
const exp = this.getExp();

return Number.isNaN(exp) ? NaN : exp - Math.round(new Date().getTime() / 1000);
Expand Down Expand Up @@ -245,7 +245,7 @@ export class Authentication {
/**
* Authenticate with third-party
*
* @param {String} name Name of the provider
* @param {string} name Name of the provider
* @param {[{}]} [userData] Additional data send to the authentication server
*
* @return {Promise<any>} The authentication server response
Expand Down
2 changes: 1 addition & 1 deletion src/baseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ export class BaseConfig {
/**
* RandomState
*
* @returns {Number}
* @returns {number}
*/
function randomState() {
let rand = Math.random()
Expand Down

0 comments on commit 447003f

Please sign in to comment.