fix(auth0-lock): adds additional theme options (#16426)

* fix(auth0-lock): adds additional theme options

* fix(auth0lock): adds AuthResult object
This commit is contained in:
Dan Caddigan
2017-06-01 12:00:10 -04:00
committed by Andy
parent 825c8bea94
commit c2cef9fd8b
3 changed files with 77 additions and 5 deletions

View File

@@ -61,11 +61,22 @@ lock.on("authenticated", function(authResult : any) {
});
});
// test theme
var themeOptions : Auth0LockConstructorOptions = {
theme: {
authButtons: {
fooProvider: {
displayName: 'foo'
},
barProvider: {
displayName: 'foo',
primaryColor: '#FF0000',
foregroundColor: '#00FF00',
icon: 'http://baz.com/icon.png'
}
},
labeledSubmitButton: false,
logo: "https://example.com/assets/logo.png",
primaryColor: "green"
}
@@ -73,6 +84,14 @@ var themeOptions : Auth0LockConstructorOptions = {
new Auth0Lock(CLIENT_ID, DOMAIN, themeOptions);
// test empty theme
var themeOptionsEmpty : Auth0LockConstructorOptions = {
theme: { }
};
new Auth0Lock(CLIENT_ID, DOMAIN, themeOptions);
// test authentication
var authOptions : Auth0LockConstructorOptions = {
@@ -170,7 +189,7 @@ var selectFieldOptionsWithCallbacks : Auth0LockConstructorOptions = {
cb(null, prefill);
}
}]
}
};
new Auth0Lock(CLIENT_ID, DOMAIN, selectFieldOptionsWithCallbacks);
@@ -198,3 +217,17 @@ var avatarOptions : Auth0LockConstructorOptions = {
};
new Auth0Lock(CLIENT_ID, DOMAIN, avatarOptions);
var authResult : AuthResult = {
accessToken: 'fake_access_token',
idToken: 'fake_id_token',
idTokenPayload: {
aud: "EaQzyHt1Dy57l-r5iHcMeT-lh1fFZntg",
exp: 1494393724,
iat: 1494357724,
iss: "https://www.foo.com",
sub: "auth0|aksjfkladsf"
},
refreshToken: undefined,
state: "923jf092j3.FFSDJFDSKLDF"
};

View File

@@ -1,6 +1,7 @@
// Type definitions for auth0-lock 10.10
// Type definitions for auth0-lock 10.16
// Project: http://auth0.com
// Definitions by: Brian Caruso <https://github.com/carusology>
// Dan Caddigan <https://github.com/goldcaddy77>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="auth0-js" />
@@ -40,7 +41,19 @@ interface Auth0LockAvatarOptions {
displayName: (email: string, callback: Auth0LockAvatarDisplayNameCallback) => void;
}
interface Auth0LockThemeButton {
displayName: string;
primaryColor?: string;
foregroundColor?: string;
icon?: string;
}
interface Auth0LockThemeButtonOptions {
[provider: string]: Auth0LockThemeButton;
}
interface Auth0LockThemeOptions {
authButtons?: Auth0LockThemeButtonOptions;
labeledSubmitButton?: boolean;
logo?: string;
primaryColor?: string;
}
@@ -121,6 +134,20 @@ interface Auth0LockShowOptions {
rememberLastLogin?: boolean;
}
interface AuthResult {
accessToken: string;
idToken: string;
idTokenPayload: {
aud: string;
exp: number;
iat: number;
iss: string;
sub: string;
};
refreshToken?: string;
state: string;
}
interface Auth0LockStatic {
new (clientId: string, domain: string, options?: Auth0LockConstructorOptions): Auth0LockStatic;
@@ -128,14 +155,14 @@ interface Auth0LockStatic {
getProfile(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void;
getUserInfo(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void;
// https://github.com/auth0/lock#resumeauthhash-callback
resumeAuth( hash: string, callback: (error: auth0.Auth0Error, authResult: any) => void): void;
resumeAuth( hash: string, callback: (error: auth0.Auth0Error, authResult: AuthResult) => void): void;
show(options?: Auth0LockShowOptions): void;
hide(): void;
logout(query: any): void;
on(event: "show" | "hide", callback: () => void): void;
on(event: "unrecoverable_error" | "authorization_error", callback: (error: auth0.Auth0Error) => void): void;
on(event: "authenticated", callback: (authResult: any) => void): void;
on(event: "authenticated", callback: (authResult: AuthResult) => void): void;
on(event: string, callback: (...args: any[]) => void): void;
}

View File

@@ -0,0 +1,12 @@
{
"extends": "dtslint/dt.json",
"rules": {
"only-arrow-functions": false,
"no-misused-new": false,
"no-single-declare-module": false,
"prefer-method-signature": false,
"object-literal-shorthand": false,
"typedef-whitespace": false,
"no-var": false
}
}