forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Auth0 definitions for JS API and widget
- Loading branch information
AdvancedREI
committed
May 13, 2014
1 parent
68fd50f
commit a52dade
Showing
5 changed files
with
199 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// <reference path="../auth0/auth0.d.ts" /> | ||
/// <reference path="auth0.widget.d.ts" /> | ||
|
||
var widget: Auth0WidgetStatic = new Auth0Widget({ | ||
domain: 'mine.auth0.com', | ||
clientID: 'dsa7d77dsa7d7', | ||
callbackURL: 'http://my-app.com/callback', | ||
callbackOnLocationHash: true | ||
}); | ||
|
||
widget.signin({ | ||
connections: ['facebook', 'google-oauth2', 'twitter', 'Username-Password-Authentication'], | ||
icon: 'https://contoso.com/logo-32.png', | ||
showIcon: true | ||
}, | ||
() => { | ||
// The Auth0 Widget is now loaded. | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Type definitions for Auth0Widget.js | ||
// Project: Auth0.com | ||
// Definitions by: Robert McLaws <https://github.com/advancedrei> | ||
// Definitions: https://github.com/borisyankov/DefinitelyTyped | ||
|
||
/// <reference path="../auth0/auth0.d.ts" /> | ||
|
||
|
||
interface Auth0WidgetStatic { | ||
new(params: Auth0Constructor): Auth0WidgetStatic; | ||
|
||
getClient(): Auth0Static; | ||
getProfile(token: string, callback: Function): Auth0UserProfile; | ||
parseHash(hash: string): Auth0DecodedHash; | ||
reset(options: Auth0Options, callback?: Function): Auth0WidgetStatic; | ||
signin(options: Auth0Options, widgetLoadedCallback?: Function, popupCallback?: Function): Auth0WidgetStatic; | ||
signup(options: Auth0Options, callback: (error?: Auth0Error, profile?, id_token?, access_token?, state?) => any): Auth0WidgetStatic; | ||
} | ||
|
||
interface Auth0Constructor extends Auth0ClientOptions { | ||
assetsUrl?: string; | ||
cdn?: string; | ||
dict?: any; | ||
} | ||
|
||
interface Auth0Options { | ||
access_token?: string; | ||
connections?: string[]; | ||
container?: string; | ||
enableReturnUserExperience?: boolean; | ||
extraParameters?: any; | ||
icon?: string; | ||
protocol?: string; | ||
request_id?: string; | ||
scope?: string; | ||
showIcon?: boolean; | ||
showForgot?: boolean; | ||
showSignup?: boolean; | ||
state?: any; | ||
userPwdConnectionName?: string; | ||
username_style?: string; | ||
} | ||
|
||
declare var Auth0Widget: Auth0WidgetStatic; | ||
|
||
declare module "Auth0Widget" { | ||
export = Auth0Widget | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/// <reference path="../auth0/auth0.d.ts" /> | ||
|
||
var auth0 = new Auth0({ | ||
domain: 'mine.auth0.com', | ||
clientID: 'dsa7d77dsa7d7', | ||
callbackURL: 'http://my-app.com/callback', | ||
callbackOnLocationHash: true | ||
}); | ||
|
||
auth0.login({ | ||
connection: 'google-oauth2', | ||
popup: true, | ||
popupOptions: { | ||
width: 450, | ||
height: 800 | ||
} | ||
}, (err, profile, idToken, accessToken, state) => { | ||
if (err) { | ||
alert("something went wrong: " + err.message); | ||
return; | ||
} | ||
alert('hello ' + profile.name); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// Type definitions for Auth0.js | ||
// Project: Auth0.com | ||
// Definitions by: Robert McLaws <https://github.com/advancedrei> | ||
// Definitions: https://github.com/borisyankov/DefinitelyTyped | ||
|
||
/** This is the interface for the main Auth0 client. */ | ||
interface Auth0Static { | ||
|
||
new(options: Auth0ClientOptions): Auth0Static; | ||
changePassword(options: any, callback?: Function); | ||
decodeJwt(jwt: string): any; | ||
login(options: any, callback: (error, profile?, id_token?, access_token?, state?) => any); | ||
loginWithPopup(options: Auth0LoginOptions, callback: (error, profile?, id_token?, access_token?, state?) => any); | ||
loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?, id_token?, access_token?, state?) => any); | ||
loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?, id_token?, access_token?, state?) => any); | ||
logout(query: string): void; | ||
getConnections(callback?: Function) | ||
getDelegationToken(targetClientId, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void; | ||
getProfile(id_token: string, callback?: Function): Auth0UserProfile; | ||
getSSOData(withActiveDirectories: any, callback?: Function); | ||
parseHash(hash: string): Auth0DecodedHash; | ||
signup(options: Auth0SignupOptions, callback: Function); | ||
validateUser(options: any, callback: (error?: Auth0Error, valid?) => any); | ||
} | ||
|
||
/** Represents constructor options for the Auth0 client. */ | ||
interface Auth0ClientOptions { | ||
clientID: string; | ||
callbackURL: string; | ||
callbackOnLoactionHash?: boolean; | ||
domain: string; | ||
forceJSONP?: boolean; | ||
} | ||
|
||
/** Represents a normalized UserProfile. */ | ||
interface Auth0UserProfile { | ||
email: string; | ||
family_name: string; | ||
gender: string; | ||
given_name: string; | ||
locale: string; | ||
name: string; | ||
nickname: string; | ||
picture: string; | ||
user_id: string; | ||
/** Represents one or more Identities that may be associated with the User. */ | ||
identities: Auth0Identity[]; | ||
} | ||
|
||
/** Represents */ | ||
interface Auth0Identity { | ||
access_token: string; | ||
connection: string; | ||
isSocial: boolean; | ||
provider: string; | ||
user_id: string; | ||
} | ||
|
||
interface Auth0DecodedHash { | ||
access_token: string; | ||
id_token: string; | ||
profile: Auth0UserProfile; | ||
state: any; | ||
} | ||
|
||
interface Auth0PopupOptions { | ||
width: number; | ||
height: number; | ||
} | ||
|
||
interface Auth0LoginOptions { | ||
auto_login?: boolean; | ||
connection?: string; | ||
email?: string; | ||
username?: string; | ||
password?: string; | ||
popup?: boolean; | ||
popupOptions?: Auth0PopupOptions; | ||
} | ||
|
||
interface Auth0SignupOptions extends Auth0LoginOptions { | ||
auto_login: boolean; | ||
} | ||
|
||
interface Auth0Error { | ||
code: any; | ||
details: any; | ||
name: string; | ||
message: string; | ||
status: any; | ||
} | ||
|
||
/** Represents the response from an API Token Delegation request. */ | ||
interface Auth0DelegationToken { | ||
/** The length of time in seconds the token is valid for. */ | ||
expires_in: string; | ||
/** The JWT for delegated access. */ | ||
id_token: string; | ||
/** The type of token being returned. Possible values: "Bearer" */ | ||
token_type: string; | ||
} | ||
|
||
declare var Auth0: Auth0Static; | ||
|
||
declare module "Auth0" { | ||
export = Auth0 | ||
} |