Skip to content

Commit

Permalink
Fix missing Auth0Error and Auth0UserProfile after upgrade auth0-js to…
Browse files Browse the repository at this point in the history
… v8, add resumeAuth
  • Loading branch information
adrianchia committed Mar 1, 2017
1 parent 8f4f374 commit 2b81d56
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 142 deletions.
11 changes: 8 additions & 3 deletions auth0-lock/auth0-lock-tests.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import 'auth0-js/v7';
import Auth0Lock from 'auth0-lock';
import auth0 from 'auth0-js';
import Auth0Lock, {
Auth0LockStatic,
Auth0LockConstructorOptions,
Auth0LockShowOptions,
Auth0LockAvatarUrlCallback,
Auth0LockAvatarDisplayNameCallback} from 'auth0-lock';

const CLIENT_ID = "YOUR_AUTH0_APP_CLIENTID";
const DOMAIN = "YOUR_DOMAIN_AT.auth0.com";
Expand Down Expand Up @@ -38,7 +43,7 @@ lock.show(showOptions);
// "on" event-driven example

lock.on("authenticated", function(authResult : any) {
lock.getProfile(authResult.idToken, function(error, profile) {
lock.getProfile(authResult.idToken, function(error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) {
if (error) {
// Handle error
return;
Expand Down
271 changes: 137 additions & 134 deletions auth0-lock/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,141 +3,144 @@
// Definitions by: Brian Caruso <https://github.com/carusology>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference types="auth0-js/v7" />
import auth0 from "auth0-js";
import Auth0Error = auth0.Auth0Error;
import Auth0UserProfile = auth0.Auth0UserProfile;

interface Auth0LockAdditionalSignUpFieldOption {
value: string;
label: string;
}

type Auth0LockAdditionalSignUpFieldOptionsCallback =
(error: Auth0Error, options: Auth0LockAdditionalSignUpFieldOption[]) => void;

type Auth0LockAdditionalSignUpFieldOptionsFunction =
(callback: Auth0LockAdditionalSignUpFieldOptionsCallback) => void;

type Auth0LockAdditionalSignUpFieldPrefillCallback =
(error: Auth0Error, prefill: string) => void;

type Auth0LockAdditionalSignUpFieldPrefillFunction =
(callback: Auth0LockAdditionalSignUpFieldPrefillCallback) => void;

interface Auth0LockAdditionalSignUpField {
icon?: string;
name: string;
options?: Auth0LockAdditionalSignUpFieldOption[] | Auth0LockAdditionalSignUpFieldOptionsFunction;
placeholder: string;
prefill?: string | Auth0LockAdditionalSignUpFieldPrefillFunction;
type?: "select" | "text";
validator?: (input: string) => { valid: boolean; hint?: string };
}

type Auth0LockAvatarUrlCallback = (error: Auth0Error, url: string) => void;
type Auth0LockAvatarDisplayNameCallback = (error: Auth0Error, displayName: string) => void;

interface Auth0LockAvatarOptions {
url: (email: string, callback: Auth0LockAvatarUrlCallback) => void;
displayName: (email: string, callback: Auth0LockAvatarDisplayNameCallback) => void;
}

interface Auth0LockThemeOptions {
logo?: string;
primaryColor?: string;
}

// https://auth0.com/docs/libraries/lock/v10/sending-authentication-parameters
interface Auth0LockAuthParamsOptions {
access_token?: any;
connection_scopes?: any;
device?: any;
nonce?: any;
protocol?: any;
request_id?: any;
scope?: string;
state?: string;
}

interface Auth0LockAuthOptions {
params?: Auth0LockAuthParamsOptions;
redirect?: boolean;
redirectUrl?: string;
responseType?: string;
sso?: boolean;
}

interface Auth0LockPopupOptions {
width: number;
height: number;
left: number;
top: number;
}

interface Auth0LockConstructorOptions {
additionalSignUpFields?: Auth0LockAdditionalSignUpField[];
allowedConnections?: string[];
allowForgotPassword?: boolean;
allowLogin?: boolean;
allowSignUp?: boolean;
assetsUrl?: string;
auth?: Auth0LockAuthOptions;
autoclose?: boolean;
autofocus?: boolean;
avatar?: Auth0LockAvatarOptions;
closable?: boolean;
container?: string;
defaultADUsernameFromEmailPrefix?: string;
defaultDatabaseConnection?: string;
defaultEnterpriseConnection?: string;
forgotPasswordLink?: string;
initialScreen?: "login" | "signUp" | "forgotPassword";
language?: string;
languageDictionary?: any;
loginAfterSignUp?: boolean;
mustAcceptTerms?: boolean;
popupOptions?: Auth0LockPopupOptions;
prefill?: { email?: string, username?: string};
rememberLastLogin?: boolean;
signupLink?: string;
socialButtonStyle?: "big" | "small";
theme?: Auth0LockThemeOptions;
usernameStyle?: string;
}

interface Auth0LockFlashMessageOptions {
type: "success" | "error";
text: string;
}

interface Auth0LockShowOptions {
allowedConnections?: string[];
allowForgotPassword?: boolean;
allowLogin?: boolean;
allowSignUp?: boolean;
auth?: Auth0LockAuthOptions;
initialScreen?: "login" | "signUp" | "forgotPassword";
flashMessage?: Auth0LockFlashMessageOptions;
rememberLastLogin?: boolean;
}

interface Auth0LockStatic {
new (clientId: string, domain: string, options?: Auth0LockConstructorOptions): Auth0LockStatic;

// deprecated
getProfile(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void): void;
getUserInfo(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => 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: Auth0Error) => void): void;
on(event: "authenticated", callback: (authResult: any) => void): void;
on(event: string, callback: (...args: any[]) => void): void;
declare module "auth0-lock" {
interface Auth0LockAdditionalSignUpFieldOption {
value: string;
label: string;
}

type Auth0LockAdditionalSignUpFieldOptionsCallback =
(error: Auth0Error, options: Auth0LockAdditionalSignUpFieldOption[]) => void;

type Auth0LockAdditionalSignUpFieldOptionsFunction =
(callback: Auth0LockAdditionalSignUpFieldOptionsCallback) => void;

type Auth0LockAdditionalSignUpFieldPrefillCallback =
(error: Auth0Error, prefill: string) => void;

type Auth0LockAdditionalSignUpFieldPrefillFunction =
(callback: Auth0LockAdditionalSignUpFieldPrefillCallback) => void;

interface Auth0LockAdditionalSignUpField {
icon?: string;
name: string;
options?: Auth0LockAdditionalSignUpFieldOption[] | Auth0LockAdditionalSignUpFieldOptionsFunction;
placeholder: string;
prefill?: string | Auth0LockAdditionalSignUpFieldPrefillFunction;
type?: "select" | "text";
validator?: (input: string) => { valid: boolean; hint?: string };
}

type Auth0LockAvatarUrlCallback = (error: Auth0Error, url: string) => void;
type Auth0LockAvatarDisplayNameCallback = (error: Auth0Error, displayName: string) => void;

interface Auth0LockAvatarOptions {
url: (email: string, callback: Auth0LockAvatarUrlCallback) => void;
displayName: (email: string, callback: Auth0LockAvatarDisplayNameCallback) => void;
}

interface Auth0LockThemeOptions {
logo?: string;
primaryColor?: string;
}

// https://auth0.com/docs/libraries/lock/v10/sending-authentication-parameters
interface Auth0LockAuthParamsOptions {
access_token?: any;
connection_scopes?: any;
device?: any;
nonce?: any;
protocol?: any;
request_id?: any;
scope?: string;
state?: string;
}

interface Auth0LockAuthOptions {
params?: Auth0LockAuthParamsOptions;
redirect?: boolean;
redirectUrl?: string;
responseType?: string;
sso?: boolean;
}

interface Auth0LockPopupOptions {
width: number;
height: number;
left: number;
top: number;
}

interface Auth0LockConstructorOptions {
additionalSignUpFields?: Auth0LockAdditionalSignUpField[];
allowedConnections?: string[];
allowForgotPassword?: boolean;
allowLogin?: boolean;
allowSignUp?: boolean;
assetsUrl?: string;
auth?: Auth0LockAuthOptions;
autoclose?: boolean;
autofocus?: boolean;
avatar?: Auth0LockAvatarOptions;
closable?: boolean;
container?: string;
defaultADUsernameFromEmailPrefix?: string;
defaultDatabaseConnection?: string;
defaultEnterpriseConnection?: string;
forgotPasswordLink?: string;
initialScreen?: "login" | "signUp" | "forgotPassword";
language?: string;
languageDictionary?: any;
loginAfterSignUp?: boolean;
mustAcceptTerms?: boolean;
popupOptions?: Auth0LockPopupOptions;
prefill?: { email?: string, username?: string};
rememberLastLogin?: boolean;
signupLink?: string;
socialButtonStyle?: "big" | "small";
theme?: Auth0LockThemeOptions;
usernameStyle?: string;
}

interface Auth0LockFlashMessageOptions {
type: "success" | "error";
text: string;
}

interface Auth0LockShowOptions {
allowedConnections?: string[];
allowForgotPassword?: boolean;
allowLogin?: boolean;
allowSignUp?: boolean;
auth?: Auth0LockAuthOptions;
initialScreen?: "login" | "signUp" | "forgotPassword";
flashMessage?: Auth0LockFlashMessageOptions;
rememberLastLogin?: boolean;
}

interface Auth0LockStatic {
new (clientId: string, domain: string, options?: Auth0LockConstructorOptions): Auth0LockStatic;

// deprecated
getProfile(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void): void;
getUserInfo(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void): void;

// https://github.com/auth0/lock#resumeauthhash-callback
resumeAuth( hash: string, callback: (error: Auth0Error, authResult: Auth0UserProfile) => 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: Auth0Error) => void): void;
on(event: "authenticated", callback: (authResult: any) => void): void;
on(event: string, callback: (...args: any[]) => void): void;
}
}

declare var Auth0Lock: Auth0LockStatic;

declare module "auth0-lock" {
export default Auth0Lock;
}
export default Auth0Lock;
5 changes: 0 additions & 5 deletions auth0-lock/package.json

This file was deleted.

0 comments on commit 2b81d56

Please sign in to comment.