diff --git a/types/auth0-lock/auth0-lock-tests.ts b/types/auth0-lock/auth0-lock-tests.ts index a241eb6d0c..3abe93a7c2 100644 --- a/types/auth0-lock/auth0-lock-tests.ts +++ b/types/auth0-lock/auth0-lock-tests.ts @@ -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" +}; diff --git a/types/auth0-lock/index.d.ts b/types/auth0-lock/index.d.ts index 285ad25288..e49c23a308 100644 --- a/types/auth0-lock/index.d.ts +++ b/types/auth0-lock/index.d.ts @@ -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 +// Dan Caddigan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -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; } diff --git a/types/auth0-lock/tslint.json b/types/auth0-lock/tslint.json new file mode 100644 index 0000000000..51b68d9fc6 --- /dev/null +++ b/types/auth0-lock/tslint.json @@ -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 + } +}