From a44ae6df3fd333d66400b8184863eaa2340f79bc Mon Sep 17 00:00:00 2001 From: repairman2003 Date: Fri, 29 Jan 2016 01:52:04 -0500 Subject: [PATCH] Adding auth0-angular.d.ts --- auth0-angular/auth0-angular-tests.ts | 24 ++++ auth0-angular/auth0-angular.d.ts | 167 +++++++++++++++++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 auth0-angular/auth0-angular-tests.ts create mode 100644 auth0-angular/auth0-angular.d.ts diff --git a/auth0-angular/auth0-angular-tests.ts b/auth0-angular/auth0-angular-tests.ts new file mode 100644 index 0000000000..1abd9fdc3d --- /dev/null +++ b/auth0-angular/auth0-angular-tests.ts @@ -0,0 +1,24 @@ +/// + +var authProvider: auth0.angular.IAuth0ServiceProvider; + +// Initialize Auth0 +authProvider.init({ + clientID: 'myClientID', + domain: 'mydomain.auth0.com' +}); + +// Listen for authenticated event +authProvider.on('authenticated', ($location: any) => { +}); + + +var authService: auth0.angular.IAuth0Service; + +// Sign in to Auth0 +authService.signin({}, (profile: string, idToken: string, acccessToken: string, state: string, refreshToken: string) => { +}, (err) => { +}); + +// Sign out of Auth0 +authService.signout(); \ No newline at end of file diff --git a/auth0-angular/auth0-angular.d.ts b/auth0-angular/auth0-angular.d.ts new file mode 100644 index 0000000000..1aa633c8e6 --- /dev/null +++ b/auth0-angular/auth0-angular.d.ts @@ -0,0 +1,167 @@ +// Type definitions for auth0-angular +// Project: https://github.com/auth0/auth0-angular +// Definitions by: Matt Emory https://github.com/homesar +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module auth0.angular { + + interface IAuth0ClientOptions { + /** + * Login url if you're using ngRoute + */ + loginUrl?: string; + + /** + * Login state if you're using ui-router + */ + loginState?: string; + + /** + * Client identifier of your Auth0 application + */ + clientID: string; + + /** + * Domain of your Auth0 account + */ + domain: string; + + /** + * Use single signon + */ + sso?: boolean; + } + + interface ITokenOptions { + + targetClientId?: string; + api?: string; + } + + interface IAuth0Options { + /** + * Connection name + */ + connection?: string; + + /** + * Username + */ + username?: string; + + /** + * Email address + */ + email?: string; + } + + interface ISuccessCallback { + (profile?: string, idToken?: string, accessToken?: string, state?: string, refreshToken?: string): void; + } + + interface IErrorCallback { + (error: any): void; + } + + interface IAuth0Service { + /** + * Hooks to internal Angular events so that a user will be redirected to the login page if trying to visit a restricted resource + */ + hookEvents(): void; + + /** + * Performs a token delegation request exchanging th ecurrent token for another one. + * @param options Token options + */ + getToken(options?: ITokenOptions): ng.IPromise; + + /** + * Refreshes the Id token + * @param refreshToken Refresh token to use when renewing + */ + refreshIdToken(refreshToken: string): ng.IPromise; + + /** + * Renews the Id Token with the same scopes as the original token + * @param id_token Id Token + */ + renewIdToken(id_token: string): ng.IPromise; + + /** + * Logs in a user, returning tokens and profile information + * @param options Options to bypass displaying the Lock UI + * @param successCallback Callback on successful login + * @param errorCallback Callback on failed login + */ + signin(options?: IAuth0Options, successCallback?: ISuccessCallback, errorCallback?: IErrorCallback): void; + + /** + * Displays Lock in signup mode, and logs the user in immediately after a successful signup. + * @param options Options to bypass displaying the Lock UI + * @param successCallback Callback on successful signup + * @param errorCallback Callback on failed signup + */ + signup(options?: IAuth0Options, successCallback?: ISuccessCallback, errorCallback?: IErrorCallback): void; + + /** + * Performs the "forgot your password" flow. + * @param options Options to bypass displaying the Lock UI + * @param successCallback Callback on successful reset + * @param errorCallback Callback on failed reset + */ + reset(options?: IAuth0Options, successCallback?: ISuccessCallback, errorCallback?: IErrorCallback): void; + + /** + * Validates the user + * @param options Options to bypass displaying the Lock UI + * @param successCallback Callback on successful validation + * @param errorCallback Callback on failed validation + */ + validateUser(options: IAuth0Options, successCallback?: ISuccessCallback, errorCallback?: IErrorCallback): void; + + /** + * Logs the user out locally by deleting their token from local storage. + */ + signout(): void; + + /** + * Reauthenticates the user by using a stored profile and token without going through the login flow. + * @param profile Profile of the user + * @param idToken Id token + * @param accessToken Access token + * @param state State + * @param refreshToken Flag to indicate refreshing the token + */ + authenticate(profile?: any, idToken?: string, accessToken?: string, state?: any, refreshToken?: boolean): ng.IPromise; + + /** + * Gets the user's profile + * @param idToken Id token + */ + getProfile(idToken?: string): ng.IPromise; + + // Properties + + accessToken: string; + idToken: string; + profile: any; + isAuthenticated: boolean; + config: any; + } + + interface IAuth0ServiceProvider { + /** + * Configures the auth service + * @param options Client options passed into Auth0 + */ + init(options: IAuth0ClientOptions): void; + + /** + * @param event Name of the event to handle. + * @param handler Event handler + */ + on(event: string, handler: (...args: any[]) => any): void; + } +} \ No newline at end of file