diff --git a/types/hellojs/hellojs-tests.ts b/types/hellojs/hellojs-tests.ts index e5b76d3ceb..4a4e068379 100644 --- a/types/hellojs/hellojs-tests.ts +++ b/types/hellojs/hellojs-tests.ts @@ -1,7 +1,3 @@ -import * as hello from 'hellojs'; - -// Test code copied from Azure AD B2C sample app at -// https://github.com/Azure-Samples/active-directory-b2c-javascript-hellojs-singlepageapp/tree/cd5982f09a7bff0a72b7b4e44c4b5190b09e20fa hello.init({ serviceName: { name: 'Test', diff --git a/types/hellojs/index.d.ts b/types/hellojs/index.d.ts index 16b19afb4a..e8efdaf19c 100644 --- a/types/hellojs/index.d.ts +++ b/types/hellojs/index.d.ts @@ -1,11 +1,13 @@ -// Type definitions for hello.js 1.15 +// Type definitions for hello.js 1.16 // Project: http://adodson.com/hello.js/ // Definitions by: Pavel Zika // Mikko Vuorinen +// Vincent Biret // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 export = hello; +export as namespace hello; declare const hello: hello.HelloJSStatic; @@ -53,9 +55,11 @@ declare namespace hello { type HelloJSTokenResponseType = "token" | "code"; + type HelloJSDisplayType = "popup" | "page" | "none"; + interface HelloJSLoginOptions { redirect_uri?: string; - display?: string; + display?: HelloJSDisplayType; scope?: string; response_type?: HelloJSTokenResponseType; force?: boolean | null; @@ -87,19 +91,39 @@ declare namespace hello { interface HelloJSEventArgument { network: string; - authResponse?: any; + authResponse?: HelloJSAuthResponse; + } + + interface HelloJSLoginEventArguement { + network: string; + authResponse?: HelloJSAuthResponse; + error?: Error; + } + + interface HelloJSAuthResponse { + access_token?: string; + token_type?: string; + expires_in?: number; + id_token?: string; + state?: string; + session_state?: string; + network?: string; + display?: HelloJSDisplayType; + redirect_uri?: string; + scope?: string; + expires?: number; } interface HelloJSStatic extends HelloJSEvent { init(serviceAppIds: { [id: string]: string; }, options?: HelloJSLoginOptions): void; init(servicesDef: { [id: string]: HelloJSServiceDef; }): void; - login(callback: () => void): PromiseLike; - login(options?: HelloJSLoginOptions, callback?: () => void): PromiseLike; - login(network?: string, options?: HelloJSLoginOptions, callback?: () => void): PromiseLike; + login(callback: () => void): PromiseLike; + login(options?: HelloJSLoginOptions, callback?: () => void): PromiseLike; + login(network?: string, options?: HelloJSLoginOptions, callback?: () => void): PromiseLike; logout(callback?: () => void): PromiseLike; logout(options?: HelloJSLogoutOptions, callback?: () => void): PromiseLike; logout(network?: string, options?: HelloJSLogoutOptions, callback?: () => void): PromiseLike; - getAuthResponse(network?: string): any; + getAuthResponse(network?: string): HelloJSAuthResponse; settings: HelloJSLoginOptions; (network: string): HelloJSStatic; utils: HelloJSUtils;