From b7bc24c3e6e0719d9b80f892f4c4c5c633f7bafb Mon Sep 17 00:00:00 2001 From: Jan-Pieter Zoutewelle Date: Mon, 19 Feb 2018 13:18:05 +0100 Subject: [PATCH 1/5] Add typescript definition --- index.d.ts | 28 ++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 29 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 00000000..db963d95 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,28 @@ +export interface AppAuthInput { + scopes: string[]; + issuer: string; + clientId: string; + redirectUrl: string; + aditionalParameters?: object; + } + + export interface AuthorizeResult { + accessToken: string; + accessTokenExpirationDate: string; + additionalParameters: object; + idToken: string; + refreshToken: string; + tokenType: string; + } + + export function authorize(properties: AppAuthInput): Promise; + + export function refresh( + properties: AppAuthInput, + { refreshToken: string } + ): Promise; + + export function revoke( + properties: AppAuthInput, + { tokenToRevoke: string, sendClientId: boolean } +): Promise; \ No newline at end of file diff --git a/package.json b/package.json index b97954e2..e3ff9415 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "2.0.0", "description": "React Native bridge for AppAuth for supporting any OAuth 2 provider", "main": "index.js", + "types": "index.d.ts", "scripts": { "test": "jest", "lint": "eslint .", From a283a69612f460794a5c20336819ce51e7995b5c Mon Sep 17 00:00:00 2001 From: Jan-Pieter Zoutewelle Date: Mon, 19 Feb 2018 21:02:11 +0100 Subject: [PATCH 2/5] Improve typescript definition --- index.d.ts | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/index.d.ts b/index.d.ts index db963d95..4b6cd9ea 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,11 +1,19 @@ -export interface AppAuthInput { +export interface AuthConfiguration extends BaseAuthConfiguration { scopes: string[]; - issuer: string; - clientId: string; redirectUrl: string; aditionalParameters?: object; } + export interface BaseAuthConfiguration{ + issuer: string; + clientId: string; + } + + export interface RevokeConfiguration{ + clientId: string; + issuer: string; + } + export interface AuthorizeResult { accessToken: string; accessTokenExpirationDate: string; @@ -15,14 +23,19 @@ export interface AppAuthInput { tokenType: string; } - export function authorize(properties: AppAuthInput): Promise; + export interface RevokeOptions { + tokenToRevoke: string; + sendClientId?: boolean; + } + + export function authorize(properties: AuthConfiguration): Promise; export function refresh( - properties: AppAuthInput, + properties: AuthConfiguration, { refreshToken: string } ): Promise; export function revoke( - properties: AppAuthInput, - { tokenToRevoke: string, sendClientId: boolean } + properties: BaseAuthConfiguration, + options: RevokeOptions ): Promise; \ No newline at end of file From 0828ebcd0677b3ba389e7e6298aca10202bb8b6a Mon Sep 17 00:00:00 2001 From: Jan-Pieter Zoutewelle Date: Tue, 20 Feb 2018 08:18:24 +0100 Subject: [PATCH 3/5] Rename & improve typescript definitions --- index.d.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/index.d.ts b/index.d.ts index 4b6cd9ea..879aeee8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,7 +1,7 @@ export interface AuthConfiguration extends BaseAuthConfiguration { scopes: string[]; redirectUrl: string; - aditionalParameters?: object; + aditionalParameters?: {[name: string]: any}; } export interface BaseAuthConfiguration{ @@ -17,25 +17,23 @@ export interface AuthConfiguration extends BaseAuthConfiguration { export interface AuthorizeResult { accessToken: string; accessTokenExpirationDate: string; - additionalParameters: object; + aditionalParameters?: {[name: string]: any}; idToken: string; refreshToken: string; tokenType: string; } - export interface RevokeOptions { + export interface RevokeConfiguration { tokenToRevoke: string; sendClientId?: boolean; } - export function authorize(properties: AuthConfiguration): Promise; + export interface RefreshConfiguration { + refreshToken: string; + } + + export function authorize(config: AuthConfiguration): Promise; - export function refresh( - properties: AuthConfiguration, - { refreshToken: string } - ): Promise; + export function refresh(config: AuthConfiguration, refreshConfig: RefreshConfiguration): Promise; - export function revoke( - properties: BaseAuthConfiguration, - options: RevokeOptions -): Promise; \ No newline at end of file + export function revoke(config: BaseAuthConfiguration, refreshConfig: RevokeConfiguration): Promise; \ No newline at end of file From 41db15e3db7734575af1b1ecae812d87140c309a Mon Sep 17 00:00:00 2001 From: Jan-Pieter Zoutewelle Date: Tue, 20 Feb 2018 11:53:40 +0100 Subject: [PATCH 4/5] Fix typescript definitions (copy paste typo & additional properties typed as string) --- index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 879aeee8..b84ec0b7 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,7 +1,7 @@ export interface AuthConfiguration extends BaseAuthConfiguration { scopes: string[]; redirectUrl: string; - aditionalParameters?: {[name: string]: any}; + aditionalParameters?: {[name: string]: string}; } export interface BaseAuthConfiguration{ @@ -17,7 +17,7 @@ export interface AuthConfiguration extends BaseAuthConfiguration { export interface AuthorizeResult { accessToken: string; accessTokenExpirationDate: string; - aditionalParameters?: {[name: string]: any}; + aditionalParameters?: {[name: string]: string}; idToken: string; refreshToken: string; tokenType: string; @@ -36,4 +36,4 @@ export interface AuthConfiguration extends BaseAuthConfiguration { export function refresh(config: AuthConfiguration, refreshConfig: RefreshConfiguration): Promise; - export function revoke(config: BaseAuthConfiguration, refreshConfig: RevokeConfiguration): Promise; \ No newline at end of file + export function revoke(config: BaseAuthConfiguration, revokeConfig: RevokeConfiguration): Promise; \ No newline at end of file From 1ffebb7ce91bfbcc33deb697bc0dbc233c02fd4f Mon Sep 17 00:00:00 2001 From: Jan-Pieter Zoutewelle Date: Tue, 20 Feb 2018 13:10:44 +0100 Subject: [PATCH 5/5] Fix typos and add prettier --- index.d.ts | 81 ++++++++++++++++++++++++++++------------------------ package.json | 4 +++ 2 files changed, 47 insertions(+), 38 deletions(-) diff --git a/index.d.ts b/index.d.ts index b84ec0b7..196708f9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,39 +1,44 @@ +export interface BaseAuthConfiguration { + issuer: string; + clientId: string; +} export interface AuthConfiguration extends BaseAuthConfiguration { - scopes: string[]; - redirectUrl: string; - aditionalParameters?: {[name: string]: string}; - } - - export interface BaseAuthConfiguration{ - issuer: string; - clientId: string; - } - - export interface RevokeConfiguration{ - clientId: string; - issuer: string; - } - - export interface AuthorizeResult { - accessToken: string; - accessTokenExpirationDate: string; - aditionalParameters?: {[name: string]: string}; - idToken: string; - refreshToken: string; - tokenType: string; - } - - export interface RevokeConfiguration { - tokenToRevoke: string; - sendClientId?: boolean; - } - - export interface RefreshConfiguration { - refreshToken: string; - } - - export function authorize(config: AuthConfiguration): Promise; - - export function refresh(config: AuthConfiguration, refreshConfig: RefreshConfiguration): Promise; - - export function revoke(config: BaseAuthConfiguration, revokeConfig: RevokeConfiguration): Promise; \ No newline at end of file + scopes: string[]; + redirectUrl: string; + additionalParameters?: { [name: string]: string }; +} + +export interface RevokeConfiguration { + clientId: string; + issuer: string; +} + +export interface AuthorizeResult { + accessToken: string; + accessTokenExpirationDate: string; + additionalParameters?: { [name: string]: string }; + idToken: string; + refreshToken: string; + tokenType: string; +} + +export interface RevokeConfiguration { + tokenToRevoke: string; + sendClientId?: boolean; +} + +export interface RefreshConfiguration { + refreshToken: string; +} + +export function authorize(config: AuthConfiguration): Promise; + +export function refresh( + config: AuthConfiguration, + refreshConfig: RefreshConfiguration +): Promise; + +export function revoke( + config: BaseAuthConfiguration, + revokeConfig: RevokeConfiguration +): Promise; diff --git a/package.json b/package.json index e3ff9415..7b5115c8 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,10 @@ "*.js": [ "eslint --fix", "git add" + ], + "*.ts": [ + "prettier --write", + "git add" ] }, "files": [