From 5a50c254b84a25472b5a1697164e8b51a3d8195f Mon Sep 17 00:00:00 2001 From: Mark Nelissen Date: Tue, 18 Dec 2018 00:46:08 +0100 Subject: [PATCH 1/5] add type definition for custom claims in id token --- types/react-native-auth0/index.d.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/types/react-native-auth0/index.d.ts b/types/react-native-auth0/index.d.ts index 7508386166..c2003e8f34 100644 --- a/types/react-native-auth0/index.d.ts +++ b/types/react-native-auth0/index.d.ts @@ -1,8 +1,9 @@ -// Type definitions for react-native-auth0 1.2 +// Type definitions for react-native-auth0 1.3 // Project: https://github.com/auth0/react-native-auth0 // Definitions by: Andrea Ascari +// Mark Nelissen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 3.2 /** * Auth @@ -75,7 +76,7 @@ export interface ResetPasswordParams { connection: string; } -export interface UserInfo { +export type UserInfo = { email: string; emailVerified: boolean; name: string; @@ -83,7 +84,10 @@ export interface UserInfo { picture: string; sub: string; updatedAt: string; -} +} & { + [key: string]: string; +}; + export class Auth { authorizationUrl(params: AuthorizationUrlParams): string; /* tslint:disable-next-line no-unnecessary-generics */ From 30ad7989c34ba6494a0a4e35c36d60dc8da76b00 Mon Sep 17 00:00:00 2001 From: Mark Nelissen Date: Tue, 18 Dec 2018 10:00:28 +0100 Subject: [PATCH 2/5] revert typescript version bump --- types/react-native-auth0/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-auth0/index.d.ts b/types/react-native-auth0/index.d.ts index c2003e8f34..2e589932fa 100644 --- a/types/react-native-auth0/index.d.ts +++ b/types/react-native-auth0/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Andrea Ascari // Mark Nelissen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.2 +// TypeScript Version: 2.6 /** * Auth From cda2acc5017b40072a08a55faac95ff1e2e98133 Mon Sep 17 00:00:00 2001 From: Mark Nelissen Date: Wed, 19 Dec 2018 21:20:16 +0100 Subject: [PATCH 3/5] generify custom claims --- types/react-native-auth0/index.d.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/types/react-native-auth0/index.d.ts b/types/react-native-auth0/index.d.ts index 2e589932fa..e0273b76dc 100644 --- a/types/react-native-auth0/index.d.ts +++ b/types/react-native-auth0/index.d.ts @@ -76,7 +76,7 @@ export interface ResetPasswordParams { connection: string; } -export type UserInfo = { +export type UserInfo = { email: string; emailVerified: boolean; name: string; @@ -84,9 +84,7 @@ export type UserInfo = { picture: string; sub: string; updatedAt: string; -} & { - [key: string]: string; -}; +} & CustomClaims export class Auth { authorizationUrl(params: AuthorizationUrlParams): string; @@ -99,7 +97,7 @@ export class Auth { refreshToken(params: RefreshTokenParams): Promise; resetPassword(params: ResetPasswordParams): Promise; revoke(params: RevokeParams): Promise; - userInfo(params: UserInfoParams): Promise; + userInfo(params: UserInfoParams): Promise>; } /** From f5c3a17d815348cd98712b34928b93ebc98cc395 Mon Sep 17 00:00:00 2001 From: Mark Nelissen Date: Wed, 19 Dec 2018 21:36:05 +0100 Subject: [PATCH 4/5] fix linting errors --- types/react-native-auth0/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-native-auth0/index.d.ts b/types/react-native-auth0/index.d.ts index e0273b76dc..1c0dc6ede3 100644 --- a/types/react-native-auth0/index.d.ts +++ b/types/react-native-auth0/index.d.ts @@ -84,7 +84,7 @@ export type UserInfo = { picture: string; sub: string; updatedAt: string; -} & CustomClaims +} & CustomClaims; export class Auth { authorizationUrl(params: AuthorizationUrlParams): string; @@ -93,10 +93,10 @@ export class Auth { exchange(params: ExchangeParams): Promise; logoutUrl(params: LogoutParams): string; passwordRealm(params: PasswordRealmParams): Promise; - refreshToken(params: RefreshTokenParams): Promise; resetPassword(params: ResetPasswordParams): Promise; revoke(params: RevokeParams): Promise; + /* tslint:disable-next-line no-unnecessary-generics */ userInfo(params: UserInfoParams): Promise>; } From 7778bc7c8222312aecef7cdca892f7ffd541161e Mon Sep 17 00:00:00 2001 From: Mark Nelissen Date: Wed, 19 Dec 2018 22:55:42 +0100 Subject: [PATCH 5/5] add default value for CustomClaims --- types/react-native-auth0/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-auth0/index.d.ts b/types/react-native-auth0/index.d.ts index 1c0dc6ede3..e738cf69b3 100644 --- a/types/react-native-auth0/index.d.ts +++ b/types/react-native-auth0/index.d.ts @@ -97,7 +97,7 @@ export class Auth { resetPassword(params: ResetPasswordParams): Promise; revoke(params: RevokeParams): Promise; /* tslint:disable-next-line no-unnecessary-generics */ - userInfo(params: UserInfoParams): Promise>; + userInfo(params: UserInfoParams): Promise>; } /**