diff --git a/types/auth0-lock/auth0-lock-tests.ts b/types/auth0-lock/auth0-lock-tests.ts index 0642453a13..c2107b11e4 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: 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) { + console.log(error, profile); + }); + } +}); + // Show supports UI arguments const showOptions : Auth0LockShowOptions = { @@ -37,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 @@ -49,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 diff --git a/types/auth0-lock/index.d.ts b/types/auth0-lock/index.d.ts index 0a57d988ce..8ed6b50c87 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: 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;