diff --git a/README.md b/README.md index 8f5708c20..0e8ca78c5 100755 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ List of Definitions * [Handlebars](http://handlebarsjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [HashSet](http://www.timdown.co.uk/jshashtable/jshashset.html) (by [Sergey Gerasimov](https://github.com/gerich-home)) * [Hashtable](http://www.timdown.co.uk/jshashtable/) (by [Sergey Gerasimov](https://github.com/gerich-home)) +* [HelloJS](http://adodson.com/hello.js) (by [Pavel Zika](https://github.com/PavelPZ)) * [Highcharts](http://www.highcharts.com/) (by [damianog](https://github.com/damianog)) * [Highland](http://highlandjs.org/) (by [Bart van der Schoor](https://github.com/Bartvds/)) * [highlight.js](https://github.com/isagalaev/highlight.js) (by [Niklas Mollenhauer](https://github.com/nikeee)) diff --git a/hellojs/hellojs-test.ts b/hellojs/hellojs-test.ts new file mode 100644 index 000000000..ef0508867 --- /dev/null +++ b/hellojs/hellojs-test.ts @@ -0,0 +1,32 @@ +/// + +hello.init( + { + 'facebook': '', + }, + { + redirect_uri: 'hello.html', + display: 'page', + } + ); + +hello('facebook').login(); + +hello('facebook').logout(); + +hello.on('auth.login', auth => { + alert('log to ' + auth.network) +}).on('auth.logout', auth => { + alert('unlog from ' + auth.network) + }); + +hello.getAuthResponse('facebook'); + +hello.login('facebook', null, () => { + var req = hello.getAuthResponse('facebook'); +}); + +hello.logout('facebook'); + +var serviceInfo = hello.service('facebook'); + diff --git a/hellojs/hellojs.d.ts b/hellojs/hellojs.d.ts new file mode 100644 index 000000000..a95b80a93 --- /dev/null +++ b/hellojs/hellojs.d.ts @@ -0,0 +1,67 @@ +// Type definitions for hello.js 0.2.1 +// Project: http://adodson.com/hello.js/ +// Definitions by: Pavel Zika +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface HelloJSLoginOptions { + redirect_uri?: string; + display?: string; + scope?: string; + response_type?: string; + force?: boolean; + oauth_proxy?: string; + timeout?: number; + default_service?: string; +} + +interface HelloJSEventArgument { + network: string; + authResponse?: any; +} + +interface HelloJSStatic { + init(serviceAppIds: { [id: string]: string; }, defaultOptions?: HelloJSLoginOptions):void; + login(network: string, option?: HelloJSLoginOptions, callback?: () => void): void; + logout(network: string, callback?: () => void): void; + on(eventName: string, event: (auth: HelloJSEventArgument) => void): HelloJSStatic; + off(eventName: string, event: (auth: HelloJSEventArgument) => void): HelloJSStatic; + getAuthResponse(network: string): any; + service(network: string): HelloJSServiceDef; + settings: HelloJSLoginOptions; + (network: string): HelloJSStaticNamed; + init(servicesDef: { [id: string]: HelloJSServiceDef; }): void; +} + +interface HelloJSStaticNamed { + login(option?: HelloJSLoginOptions, callback?: () => void): void; + logout(callback?: () => void): void; + getAuthResponse(): any; +} + +interface HelloJSOAuthDef { + version: number; + auth: string; + request: string; + token: string; +} + +interface HelloJSServiceDef { + name: string; + oauth: HelloJSOAuthDef; + scope?: { [id: string]: string; }; + scope_delim?: string; + autorefresh?: boolean; + base?: string; + root?: string; + get?: { [id: string]: any; } + post?: { [id: string]: any; } + del?: { [id: string]: string; } + put?: { [id: string]: any; } + wrap?: { [id: string]: (par: any) => void; } + xhr?: (par: any) => void; + jsonp?: (par: any) => void; + form?: (par: any) => void; + api?: (...par: any[]) => void; +} + +declare var hello: HelloJSStatic;