Created
June 9, 2016 12:50
-
-
Save macnibblet/e09de2334fe56884bfc6f88e607e4859 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generated by typings | |
// Source: https://raw.githubusercontent.com/interactive-solutions/ts-authentication/refactor/typings/authentication.d.ts | |
declare namespace interactivesolutions.authentication { | |
import EventManager = interactivesolutions.eventManager.EventManager; | |
function HttpAuthorizationInjector(authenticationStorage: AuthenticationStorage): { | |
request: (request: ng.IRequestConfig) => ng.IRequestConfig; | |
}; | |
function HttpRefreshTokenInjector(loginStateName: string, $q: ng.IQService, $injector: any): { | |
responseError: (response: ng.IHttpPromiseCallbackArg<any>) => ng.IPromise<void>; | |
}; | |
/** | |
* Simple data container for the access token | |
*/ | |
class AccessToken { | |
constructor(accessToken: string, ownerId: any, expiresAt: number, refreshToken: string, tokenType: string); | |
getAccessToken(): string; | |
getOwnerId(): any; | |
getExpiresAt(): number; | |
getRefreshToken(): string; | |
getTokenType(): string; | |
} | |
/** | |
* Storage class, handles reading and writing to local storage. | |
*/ | |
class AuthenticationStorage { | |
private accessToken; | |
constructor(); | |
write(accessToken: AccessToken): void; | |
read(): AccessToken; | |
clear(): void; | |
hasAccessToken(): boolean; | |
private fromLocalStorage(); | |
} | |
class AuthenticationService extends EventManager { | |
/** | |
* @param $http | |
* @param $rootScope | |
* @param authenticationStorage | |
*/ | |
constructor($http: ng.IHttpService, $rootScope: ng.IRootScopeService, authenticationStorage: AuthenticationStorage); | |
/** | |
* Authenticate | |
* | |
* @param parameters | |
* | |
* @returns {IPromise<void>} | |
*/ | |
login(parameters: any): ng.IPromise<void>; | |
/** | |
* Use the refresh token to generate a new access token | |
* | |
* @returns {IPromise<void>} | |
*/ | |
refresh(): ng.IPromise<void>; | |
/** | |
* Check if the current user is authenticated, does not test if it's still valid tho. | |
* | |
* @returns {boolean} | |
*/ | |
isAuthenticated(): boolean; | |
/** | |
* Remove the oauth token and trigger a auth event | |
*/ | |
logout(): void; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment