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
This commit is contained in:
Vincent Biret
2018-02-26 07:25:49 -08:00
committed by Andy
parent cc4dd22133
commit 2e531425dc
2 changed files with 31 additions and 11 deletions
-4
View File
@@ -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',
+31 -7
View File
@@ -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 <https://github.com/PavelPZ>
// Mikko Vuorinen <https://github.com/vuorinem>
// Vincent Biret <https://github.com/baywet>
// 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<any>;
login(options?: HelloJSLoginOptions, callback?: () => void): PromiseLike<any>;
login(network?: string, options?: HelloJSLoginOptions, callback?: () => void): PromiseLike<any>;
login(callback: () => void): PromiseLike<HelloJSLoginEventArguement>;
login(options?: HelloJSLoginOptions, callback?: () => void): PromiseLike<HelloJSLoginEventArguement>;
login(network?: string, options?: HelloJSLoginOptions, callback?: () => void): PromiseLike<HelloJSLoginEventArguement>;
logout(callback?: () => void): PromiseLike<any>;
logout(options?: HelloJSLogoutOptions, callback?: () => void): PromiseLike<any>;
logout(network?: string, options?: HelloJSLogoutOptions, callback?: () => void): PromiseLike<any>;
getAuthResponse(network?: string): any;
getAuthResponse(network?: string): HelloJSAuthResponse;
settings: HelloJSLoginOptions;
(network: string): HelloJSStatic;
utils: HelloJSUtils;