From 2e531425dc21bb3a19e54232d3c7d8b5f150762d Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 26 Feb 2018 10:25:49 -0500 Subject: [PATCH] HelloJs: added display type, typed promise value return for login, typed return value GetAuthReponse (#23614) * - added display type - typed promise value return for login - typed return value GetAuthReponse * bumping version number for hellojs * fixed module declaration for unit tests * reverted last module declaration fixes * removed namespace declaration to pass linting * hellojs :put namespace declaration back and improved global var declaration * hellojs: removed the global definition as per recomendation of Andy --- types/hellojs/hellojs-tests.ts | 4 ---- types/hellojs/index.d.ts | 38 +++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 11 deletions(-) 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;