From 7f6508562138dacfd1e12478b7c2bdf69d83d67f Mon Sep 17 00:00:00 2001 From: Sterling Camden Date: Tue, 28 Nov 2017 15:46:38 -0800 Subject: [PATCH 1/5] add types for checkSession method --- types/auth0-lock/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/auth0-lock/index.d.ts b/types/auth0-lock/index.d.ts index 0a57d988ce..c1a393409a 100644 --- a/types/auth0-lock/index.d.ts +++ b/types/auth0-lock/index.d.ts @@ -154,6 +154,7 @@ interface Auth0LockStatic { // deprecated getProfile(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void; getUserInfo(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void; + checkSession(options: object, callback: (error: auth0.Auth0Error, authResult: AuthResult | undefined) => void): void; // https://github.com/auth0/lock#resumeauthhash-callback resumeAuth(hash: string, callback: (error: auth0.Auth0Error, authResult: AuthResult) => void): void; show(options?: Auth0LockShowOptions): void; From 9890a3710c594347c55c924842c902dd3ce9220d Mon Sep 17 00:00:00 2001 From: Sterling Camden Date: Tue, 28 Nov 2017 15:52:44 -0800 Subject: [PATCH 2/5] Update index.d.ts --- types/auth0-lock/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/auth0-lock/index.d.ts b/types/auth0-lock/index.d.ts index c1a393409a..8ed6b50c87 100644 --- a/types/auth0-lock/index.d.ts +++ b/types/auth0-lock/index.d.ts @@ -154,7 +154,7 @@ interface Auth0LockStatic { // deprecated getProfile(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void; getUserInfo(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void; - checkSession(options: object, callback: (error: auth0.Auth0Error, authResult: AuthResult | undefined) => void): void; + checkSession(options: any, callback: (error: auth0.Auth0Error, authResult: AuthResult | undefined) => void): void; // https://github.com/auth0/lock#resumeauthhash-callback resumeAuth(hash: string, callback: (error: auth0.Auth0Error, authResult: AuthResult) => void): void; show(options?: Auth0LockShowOptions): void; From 4ef390ef6e1cda3c2b5e1276b361bd39d0bee390 Mon Sep 17 00:00:00 2001 From: Sterling Camden Date: Fri, 8 Dec 2017 10:13:34 -0800 Subject: [PATCH 3/5] Update auth0-lock-tests.ts --- types/auth0-lock/auth0-lock-tests.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/types/auth0-lock/auth0-lock-tests.ts b/types/auth0-lock/auth0-lock-tests.ts index 0642453a13..c67afcb0c7 100644 --- a/types/auth0-lock/auth0-lock-tests.ts +++ b/types/auth0-lock/auth0-lock-tests.ts @@ -10,6 +10,17 @@ lock.show(); lock.hide(); lock.logout(() => {}); +lock.checkSession({}, function (error, authResult) { + if (error || !authResult) { + lock.show(); + } else { + // user has an active session, so we can use the accessToken directly. + lock.getUserInfo(authResult.accessToken, function (error, profile) { + console.log(error, profile); + }); + } +}); + // Show supports UI arguments const showOptions : Auth0LockShowOptions = { From 633fd064a6dcae07f426019fdcacb0188155cca6 Mon Sep 17 00:00:00 2001 From: Sterling Camden Date: Fri, 8 Dec 2017 10:44:39 -0800 Subject: [PATCH 4/5] fix whitespace and be explicit about callback types --- types/auth0-lock/auth0-lock-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/auth0-lock/auth0-lock-tests.ts b/types/auth0-lock/auth0-lock-tests.ts index c67afcb0c7..cff3fb4db0 100644 --- a/types/auth0-lock/auth0-lock-tests.ts +++ b/types/auth0-lock/auth0-lock-tests.ts @@ -10,12 +10,12 @@ lock.show(); lock.hide(); lock.logout(() => {}); -lock.checkSession({}, function (error, authResult) { +lock.checkSession({}, function(error: auth0.Auth0Error, authResult: AuthResult): void { if (error || !authResult) { lock.show(); } else { // user has an active session, so we can use the accessToken directly. - lock.getUserInfo(authResult.accessToken, function (error, profile) { + lock.getUserInfo(authResult.accessToken, function(error, profile) { console.log(error, profile); }); } From fc6c685112a36e2d3997f8651c9739605c7752bc Mon Sep 17 00:00:00 2001 From: Sterling Camden Date: Fri, 8 Dec 2017 10:54:41 -0800 Subject: [PATCH 5/5] add auth result type to callbacks instead of any --- types/auth0-lock/auth0-lock-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/auth0-lock/auth0-lock-tests.ts b/types/auth0-lock/auth0-lock-tests.ts index cff3fb4db0..c2107b11e4 100644 --- a/types/auth0-lock/auth0-lock-tests.ts +++ b/types/auth0-lock/auth0-lock-tests.ts @@ -48,7 +48,7 @@ lock.show(showOptions); // "on" event-driven example -lock.on("authenticated", function(authResult : any) { +lock.on("authenticated", function(authResult: AuthResult) { lock.getProfile(authResult.idToken, function(error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) { if (error) { // Handle error @@ -60,7 +60,7 @@ lock.on("authenticated", function(authResult : any) { }); }); -lock.on("authenticated", function(authResult : any) { +lock.on("authenticated", function(authResult: AuthResult) { lock.getUserInfo(authResult.accessToken, function(error, profile) { if (error) { // Handle error