From eb04a7c5cc88943dc912607ba2be32ebcf89494a Mon Sep 17 00:00:00 2001 From: Adrian Chia Date: Tue, 5 Dec 2017 16:33:15 -0600 Subject: [PATCH 1/3] Add checkSession method to acquire new token from Auth0 --- types/auth0-js/auth0-js-tests.ts | 10 ++++++++++ types/auth0-js/index.d.ts | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/types/auth0-js/auth0-js-tests.ts b/types/auth0-js/auth0-js-tests.ts index d425cca21a..a4650c6154 100644 --- a/types/auth0-js/auth0-js-tests.ts +++ b/types/auth0-js/auth0-js-tests.ts @@ -174,6 +174,16 @@ webAuth.login({username: 'bar', password: 'foo'}, (err, data) => {}); webAuth.crossOriginAuthenticationCallback(); +webAuth.checkSession({ + audience: 'https://mystore.com/api/v2', + scope: 'read:order write:order', + redirectUri: 'https://example.com/auth/silent-callback' + }, (err, authResult) => { + // Authentication tokens or error +}); + + + const authentication = new auth0.Authentication({ domain: 'me.auth0.com', clientID: '...', diff --git a/types/auth0-js/index.d.ts b/types/auth0-js/index.d.ts index 340f14e15b..443ba7674b 100644 --- a/types/auth0-js/index.d.ts +++ b/types/auth0-js/index.d.ts @@ -268,6 +268,14 @@ export class WebAuth { * @param options: */ passwordlessVerify(options: PasswordlessVerifyOptions, callback: Auth0Callback): void; + + /** + * Renews an existing session on Auth0's servers using `response_mode=web_message` (i.e. Auth0's hosted login page) + * + * @param options options used in {@link authorize} call + * @param callback + */ + checkSession(options: AuthorizeOptions, callback: Auth0Callback): void; } export class Redirect { From 2a41d4fb397d99f8a7a1f91e413f684bfba7017c Mon Sep 17 00:00:00 2001 From: Adrian Chia Date: Tue, 5 Dec 2017 16:51:38 -0600 Subject: [PATCH 2/3] Fix travis build error --- types/auth0-js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/auth0-js/index.d.ts b/types/auth0-js/index.d.ts index 443ba7674b..7bce828ac1 100644 --- a/types/auth0-js/index.d.ts +++ b/types/auth0-js/index.d.ts @@ -273,7 +273,7 @@ export class WebAuth { * Renews an existing session on Auth0's servers using `response_mode=web_message` (i.e. Auth0's hosted login page) * * @param options options used in {@link authorize} call - * @param callback + * @param callback: any(err, token_payload) */ checkSession(options: AuthorizeOptions, callback: Auth0Callback): void; } From 1de5359aea3ff24e5b9826e7a0bd8e45029c8a2b Mon Sep 17 00:00:00 2001 From: Adrian Chia Date: Tue, 5 Dec 2017 17:03:16 -0600 Subject: [PATCH 3/3] [auth0-js] Add optional usePostMessage for checkSession, fix travis-ci build error --- types/auth0-js/auth0-js-tests.ts | 9 ++++++++- types/auth0-js/index.d.ts | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/types/auth0-js/auth0-js-tests.ts b/types/auth0-js/auth0-js-tests.ts index a4650c6154..d05ee2251e 100644 --- a/types/auth0-js/auth0-js-tests.ts +++ b/types/auth0-js/auth0-js-tests.ts @@ -182,7 +182,14 @@ webAuth.checkSession({ // Authentication tokens or error }); - +webAuth.checkSession({ + audience: 'https://mystore.com/api/v2', + scope: 'read:order write:order', + redirectUri: 'https://example.com/auth/silent-callback', + usePostMessage: true + }, (err, authResult) => { + // Renewed tokens or error +}); const authentication = new auth0.Authentication({ domain: 'me.auth0.com', diff --git a/types/auth0-js/index.d.ts b/types/auth0-js/index.d.ts index 7bce828ac1..6110f2fe52 100644 --- a/types/auth0-js/index.d.ts +++ b/types/auth0-js/index.d.ts @@ -275,7 +275,7 @@ export class WebAuth { * @param options options used in {@link authorize} call * @param callback: any(err, token_payload) */ - checkSession(options: AuthorizeOptions, callback: Auth0Callback): void; + checkSession(options: CheckSessionOptions, callback: Auth0Callback): void; } export class Redirect { @@ -761,3 +761,10 @@ export interface AuthorizeOptions { scope?: string; audience?: string; } + +export interface CheckSessionOptions extends AuthorizeOptions { + /** + * optional parameter for auth0 to use postMessage to communicate between the silent callback and the SPA. + */ + usePostMessage?: boolean; +}