From 548a7925ed894613942f649222f095eddcff2aee Mon Sep 17 00:00:00 2001 From: Christian Svensson Date: Wed, 8 Mar 2017 18:19:35 +0100 Subject: [PATCH 1/8] sync deprecated markers with auth0-js --- auth0-js/index.d.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/auth0-js/index.d.ts b/auth0-js/index.d.ts index f51e3979d3..a3ac8331ae 100644 --- a/auth0-js/index.d.ts +++ b/auth0-js/index.d.ts @@ -63,9 +63,7 @@ export class Authentication { * Makes a call to the `/ssodata` endpoint * * @method getSSOData - * @param {Boolean} withActiveDirectories * @param {Function} callback - * @deprecated `getSSOData` will be soon deprecated. */ getSSOData(callback?: (error?: Auth0Error, authResult?: any) => any): void; @@ -75,7 +73,6 @@ export class Authentication { * @method getSSOData * @param {Boolean} withActiveDirectories * @param {Function} callback - * @deprecated `getSSOData` will be soon deprecated. */ getSSOData(withActiveDirectories: boolean, callback?: (error?: Auth0Error, authResult?: any) => any): void; @@ -94,7 +91,6 @@ export class Authentication { * @method delegation * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--delegation * @param {Function} callback - * @deprecated `delegation` will be soon deprecated. */ delegation(options: any, callback: (error?: Auth0Error, authResult?: Auth0DelegationToken) => any): any; From d9edf84e9cc0a8d47b0dcd2c57883d25f07a33a0 Mon Sep 17 00:00:00 2001 From: Christian Svensson Date: Wed, 8 Mar 2017 18:20:31 +0100 Subject: [PATCH 2/8] callbacks return value to void (from any) --- auth0-js/index.d.ts | 88 ++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/auth0-js/index.d.ts b/auth0-js/index.d.ts index a3ac8331ae..35c47cc8a1 100644 --- a/auth0-js/index.d.ts +++ b/auth0-js/index.d.ts @@ -35,7 +35,7 @@ export class Authentication { * @param {Object} options: https://auth0.com/docs/api-auth/grant/password * @param {Function} callback */ - loginWithDefaultDirectory(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + loginWithDefaultDirectory(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; /** * Makes a call to the `/ro` endpoint @@ -43,21 +43,21 @@ export class Authentication { * @param {Function} callback * @deprecated `loginWithResourceOwner` will be soon deprecated, user `login` instead. */ - loginWithResourceOwner(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + loginWithResourceOwner(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; /** * Makes a call to the `oauth/token` endpoint with `password-realm` grant type * @param {any} options * @param {Function} callback */ - login(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + login(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; /** * Makes a call to the `oauth/token` endpoint * @param {any} options * @param {Function} callback */ - oauthToken(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + oauthToken(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; /** * Makes a call to the `/ssodata` endpoint @@ -65,7 +65,7 @@ export class Authentication { * @method getSSOData * @param {Function} callback */ - getSSOData(callback?: (error?: Auth0Error, authResult?: any) => any): void; + getSSOData(callback?: (error?: Auth0Error, authResult?: any) => void): void; /** * Makes a call to the `/ssodata` endpoint @@ -74,7 +74,7 @@ export class Authentication { * @param {Boolean} withActiveDirectories * @param {Function} callback */ - getSSOData(withActiveDirectories: boolean, callback?: (error?: Auth0Error, authResult?: any) => any): void; + getSSOData(withActiveDirectories: boolean, callback?: (error?: Auth0Error, authResult?: any) => void): void; /** * Makes a call to the `/userinfo` endpoint and returns the user profile @@ -83,7 +83,7 @@ export class Authentication { * @param {String} accessToken * @param {Function} callback */ - userInfo(token: string, callback: (error?: Auth0Error, user?: any) => any): void; + userInfo(token: string, callback: (error?: Auth0Error, user?: any) => void): void; /** * Makes a call to the `/delegation` endpoint @@ -92,7 +92,7 @@ export class Authentication { * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--delegation * @param {Function} callback */ - delegation(options: any, callback: (error?: Auth0Error, authResult?: Auth0DelegationToken) => any): any; + delegation(options: any, callback: (error?: Auth0Error, authResult?: Auth0DelegationToken) => void): any; /** * Fetches the user country based on the ip. @@ -100,7 +100,7 @@ export class Authentication { * @method getUserCountry * @param {Function} callback */ - getUserCountry(callback: (error?: Auth0Error, result?: any) => any): void; + getUserCountry(callback: (error?: Auth0Error, result?: any) => void): void; } export class PasswordlessAuthentication { @@ -166,7 +166,7 @@ export class Management { * @param {String} userId * @param {Function} callback */ - getUser(userId: string, callback: (error?: Auth0Error, user?: any) => any): void; + getUser(userId: string, callback: (error?: Auth0Error, user?: any) => void): void; /** * Updates the user metdata. It will patch the user metdata with the attributes sent. @@ -177,7 +177,7 @@ export class Management { * @param {Object} userMetadata * @param {Function} callback */ - patchUserMetadata(userId: string, userMetadata: any, callback: (error?: Auth0Error, user?: any) => any): void; + patchUserMetadata(userId: string, userMetadata: any, callback: (error?: Auth0Error, user?: any) => void): void; /** * Link two users. https://auth0.com/docs/api/management/v2#!/Users/post_identities @@ -187,7 +187,7 @@ export class Management { * @param {String} secondaryUserToken * @param {Function} callback */ - linkUser(userId: string, secondaryUserToken: string, callback: (error?: Auth0Error, user?: any) => any): void; + linkUser(userId: string, secondaryUserToken: string, callback: (error?: Auth0Error, user?: any) => void): void; } export class WebAuth { @@ -218,7 +218,7 @@ export class WebAuth { * @param {String} options.hash [OPTIONAL] the url hash. If not provided it will extract from window.location.hash * @param {Function} callback: any(err, token_payload) */ - parseHash(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + parseHash(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; /** * Decodes the id_token and verifies the nonce. @@ -238,7 +238,7 @@ export class WebAuth { * @param {Object} options: any valid oauth2 parameter to be sent to the `/authorize` endpoint * @param {Function} callback */ - renewAuth(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + renewAuth(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; /** * Initialices a change password transaction @@ -247,7 +247,7 @@ export class WebAuth { * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password * @param {Function} callback */ - changePassword(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + changePassword(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; /** * Signs up a new user @@ -266,7 +266,7 @@ export class WebAuth { * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup * @param {Function} callback */ - signupAndAuthorize(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + signupAndAuthorize(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; /** * Redirects to the auth0 logout page @@ -276,7 +276,7 @@ export class WebAuth { */ logout(options: any): void; - passwordlessStart(options: PasswordlessStartOptions, callback: (error?: Auth0Error, data?: any) => any): void; + passwordlessStart(options: PasswordlessStartOptions, callback: (error?: Auth0Error, data?: any) => void): void; /** * Verifies the passwordless TOTP and redirects to finish the passwordless transaction @@ -380,7 +380,7 @@ export class Popup { * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup * @param {Function} callback */ - signupAndLogin(options: any, callback: any): void; + signupAndLogin(options: any, callback: any): void; } interface ManagementOptions { @@ -466,42 +466,42 @@ interface PasswordlessVerifyOptions { } interface Auth0UserProfile { - name: string; - nickname: string; - picture: string; - user_id: string; - username?: string; - given_name?: string; - family_name?: string; - email?: string; - email_verified?: string; - clientID: string; - gender?: string; - locale?: string; - identities: Auth0Identity[]; - created_at: string; - updated_at: string; - sub: string; - user_metadata?: any; - app_metadata?: any; + name: string; + nickname: string; + picture: string; + user_id: string; + username?: string; + given_name?: string; + family_name?: string; + email?: string; + email_verified?: string; + clientID: string; + gender?: string; + locale?: string; + identities: Auth0Identity[]; + created_at: string; + updated_at: string; + sub: string; + user_metadata?: any; + app_metadata?: any; } interface MicrosoftUserProfile extends Auth0UserProfile { - emails?: string[]; //optional depending on whether email addresses permission is granted + emails?: string[]; //optional depending on whether email addresses permission is granted } interface Office365UserProfile extends Auth0UserProfile { - tenantid: string; - upn: string; + tenantid: string; + upn: string; } interface AdfsUserProfile extends Auth0UserProfile { - issuer?: string; + issuer?: string; } interface Auth0Identity { - connection: string; - isSocial: boolean; - provider: string; - user_id: string; + connection: string; + isSocial: boolean; + provider: string; + user_id: string; } From d6a395cb587c61266680d048a510a77ae677d78c Mon Sep 17 00:00:00 2001 From: Christian Svensson Date: Wed, 8 Mar 2017 18:21:23 +0100 Subject: [PATCH 3/8] fixed invalid delegtion return value --- auth0-js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth0-js/index.d.ts b/auth0-js/index.d.ts index 35c47cc8a1..28e5137840 100644 --- a/auth0-js/index.d.ts +++ b/auth0-js/index.d.ts @@ -437,7 +437,7 @@ interface Auth0DecodedHash { /** Represents the response from an API Token Delegation request. */ interface Auth0DelegationToken { /** The length of time in seconds the token is valid for. */ - ExpiresIn: number; + expiresIn: number; /** The JWT for delegated access. */ idToken: string; /** The type of token being returned. Possible values: "Bearer" */ From ae7eb8638ac707e18aa307c57d306bc28adbe324 Mon Sep 17 00:00:00 2001 From: Christian Svensson Date: Wed, 8 Mar 2017 18:34:29 +0100 Subject: [PATCH 4/8] added callback type for improved consistency --- auth0-js/index.d.ts | 62 +++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/auth0-js/index.d.ts b/auth0-js/index.d.ts index 28e5137840..9a84cc75f1 100644 --- a/auth0-js/index.d.ts +++ b/auth0-js/index.d.ts @@ -35,7 +35,7 @@ export class Authentication { * @param {Object} options: https://auth0.com/docs/api-auth/grant/password * @param {Function} callback */ - loginWithDefaultDirectory(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; + loginWithDefaultDirectory(options: any, callback: Auth0Callback): void; /** * Makes a call to the `/ro` endpoint @@ -43,21 +43,21 @@ export class Authentication { * @param {Function} callback * @deprecated `loginWithResourceOwner` will be soon deprecated, user `login` instead. */ - loginWithResourceOwner(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; + loginWithResourceOwner(options: any, callback: Auth0Callback): void; /** * Makes a call to the `oauth/token` endpoint with `password-realm` grant type * @param {any} options * @param {Function} callback */ - login(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; + login(options: any, callback: Auth0Callback): void; /** * Makes a call to the `oauth/token` endpoint * @param {any} options * @param {Function} callback */ - oauthToken(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; + oauthToken(options: any, callback: Auth0Callback): void; /** * Makes a call to the `/ssodata` endpoint @@ -65,7 +65,7 @@ export class Authentication { * @method getSSOData * @param {Function} callback */ - getSSOData(callback?: (error?: Auth0Error, authResult?: any) => void): void; + getSSOData(callback?: Auth0Callback): void; /** * Makes a call to the `/ssodata` endpoint @@ -74,7 +74,7 @@ export class Authentication { * @param {Boolean} withActiveDirectories * @param {Function} callback */ - getSSOData(withActiveDirectories: boolean, callback?: (error?: Auth0Error, authResult?: any) => void): void; + getSSOData(withActiveDirectories: boolean, callback?: Auth0Callback): void; /** * Makes a call to the `/userinfo` endpoint and returns the user profile @@ -83,7 +83,7 @@ export class Authentication { * @param {String} accessToken * @param {Function} callback */ - userInfo(token: string, callback: (error?: Auth0Error, user?: any) => void): void; + userInfo(token: string, callback: Auth0Callback): void; /** * Makes a call to the `/delegation` endpoint @@ -92,7 +92,7 @@ export class Authentication { * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--delegation * @param {Function} callback */ - delegation(options: any, callback: (error?: Auth0Error, authResult?: Auth0DelegationToken) => void): any; + delegation(options: any, callback: Auth0Callback): any; /** * Fetches the user country based on the ip. @@ -100,7 +100,7 @@ export class Authentication { * @method getUserCountry * @param {Function} callback */ - getUserCountry(callback: (error?: Auth0Error, result?: any) => void): void; + getUserCountry(callback: Auth0Callback): void; } export class PasswordlessAuthentication { @@ -122,7 +122,7 @@ export class PasswordlessAuthentication { * @param {Object} options: https://auth0.com/docs/api/authentication#passwordless * @param {Function} callback */ - start(options: PasswordlessStartOptions, callback: any): void; + start(options: PasswordlessStartOptions, callback: Auth0Callback): void; /** * Verifies the passwordless TOTP and returns an error if any. @@ -131,7 +131,7 @@ export class PasswordlessAuthentication { * @param {Object} options * @param {Function} callback */ - verify(options: any, callback: any): void; + verify(options: any, callback: Auth0Callback): void; } export class DBConnection { @@ -144,7 +144,7 @@ export class DBConnection { * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup * @param {Function} calback */ - signup(options: any, callback: any): void; + signup(options: any, callback: Auth0Callback): void; /** * Initializes the change password flow @@ -153,7 +153,7 @@ export class DBConnection { * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password * @param {Function} callback */ - changePassword(options: ChangePasswordOptions, callback: any): void; + changePassword(options: ChangePasswordOptions, callback: Auth0Callback): void; } export class Management { @@ -166,7 +166,7 @@ export class Management { * @param {String} userId * @param {Function} callback */ - getUser(userId: string, callback: (error?: Auth0Error, user?: any) => void): void; + getUser(userId: string, callback: Auth0Callback): void; /** * Updates the user metdata. It will patch the user metdata with the attributes sent. @@ -177,7 +177,7 @@ export class Management { * @param {Object} userMetadata * @param {Function} callback */ - patchUserMetadata(userId: string, userMetadata: any, callback: (error?: Auth0Error, user?: any) => void): void; + patchUserMetadata(userId: string, userMetadata: any, callback: Auth0Callback): void; /** * Link two users. https://auth0.com/docs/api/management/v2#!/Users/post_identities @@ -187,7 +187,7 @@ export class Management { * @param {String} secondaryUserToken * @param {Function} callback */ - linkUser(userId: string, secondaryUserToken: string, callback: (error?: Auth0Error, user?: any) => void): void; + linkUser(userId: string, secondaryUserToken: string, callback: Auth0Callback): void; } export class WebAuth { @@ -218,7 +218,7 @@ export class WebAuth { * @param {String} options.hash [OPTIONAL] the url hash. If not provided it will extract from window.location.hash * @param {Function} callback: any(err, token_payload) */ - parseHash(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; + parseHash(options: any, callback: Auth0Callback): void; /** * Decodes the id_token and verifies the nonce. @@ -229,7 +229,7 @@ export class WebAuth { * @param {String} nonce * @param {Function} callback: function(err, {payload, transaction}) */ - validateToken(token: string, state: string, nonce: string, callback: any): void; + validateToken(token: string, state: string, nonce: string, callback: Auth0Callback): void; /** * Executes a silent authentication transaction under the hood in order to fetch a new token. @@ -238,7 +238,7 @@ export class WebAuth { * @param {Object} options: any valid oauth2 parameter to be sent to the `/authorize` endpoint * @param {Function} callback */ - renewAuth(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; + renewAuth(options: any, callback: Auth0Callback): void; /** * Initialices a change password transaction @@ -247,7 +247,7 @@ export class WebAuth { * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password * @param {Function} callback */ - changePassword(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; + changePassword(options: any, callback: Auth0Callback): void; /** * Signs up a new user @@ -256,7 +256,7 @@ export class WebAuth { * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup * @param {Function} callback */ - signup(options: any, callback: any): void; + signup(options: any, callback: Auth0Callback): void; /** * Signs up a new user, automatically logs the user in after the signup and returns the user token. @@ -266,7 +266,7 @@ export class WebAuth { * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup * @param {Function} callback */ - signupAndAuthorize(options: any, callback: (error?: Auth0Error, authResult?: any) => void): void; + signupAndAuthorize(options: any, callback: Auth0Callback): void; /** * Redirects to the auth0 logout page @@ -276,7 +276,7 @@ export class WebAuth { */ logout(options: any): void; - passwordlessStart(options: PasswordlessStartOptions, callback: (error?: Auth0Error, data?: any) => void): void; + passwordlessStart(options: PasswordlessStartOptions, callback: Auth0Callback): void; /** * Verifies the passwordless TOTP and redirects to finish the passwordless transaction @@ -290,7 +290,7 @@ export class WebAuth { * @param {Object} options.verificationCode: the TOTP code * @param {Function} callback */ - passwordlessVerify(options: any, callback: any): void; + passwordlessVerify(options: any, callback: Auth0Callback): void; } export class Redirect { @@ -304,7 +304,7 @@ export class Redirect { * @param {Function} callback * @deprecated `webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead. */ - loginWithCredentials(options: any, callback: any): void; + loginWithCredentials(options: any, callback: Auth0Callback): void; /** * Signs up a new user and automatically logs the user in after the signup. @@ -313,7 +313,7 @@ export class Redirect { * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup * @param {Function} callback */ - signupAndLogin(options: any, callback: any): void; + signupAndLogin(options: any, callback: Auth0Callback): void; } export class Popup { @@ -347,7 +347,7 @@ export class Popup { * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db * @param {Function} callback */ - authorize(options: any, callback: any): void; + authorize(options: any, callback: Auth0Callback): void; /** * Initializes the legacy Lock login flow in a popup @@ -357,7 +357,7 @@ export class Popup { * @param {Function} callback * @deprecated `webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead. */ - loginWithCredentials(options: any, callback: any): void; + loginWithCredentials(options: any, callback: Auth0Callback): void; /** * Verifies the passwordless TOTP and returns the requested token @@ -371,7 +371,7 @@ export class Popup { * @param {Object} options.verificationCode: the TOTP code * @param {Function} callback */ - passwordlessVerify(options: any, callback: any): void; + passwordlessVerify(options: any, callback: Auth0Callback): void; /** * Signs up a new user and automatically logs the user in after the signup. @@ -380,9 +380,11 @@ export class Popup { * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup * @param {Function} callback */ - signupAndLogin(options: any, callback: any): void; + signupAndLogin(options: any, callback: Auth0Callback): void; } +type Auth0Callback = (error: null | Auth0Error, result: T) => void; + interface ManagementOptions { domain: string; token: string; From 736f2e1c4f79694ad547d56620fc7b1c148728c1 Mon Sep 17 00:00:00 2001 From: Christian Svensson Date: Wed, 8 Mar 2017 18:54:47 +0100 Subject: [PATCH 5/8] made many types less general --- auth0-js/index.d.ts | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/auth0-js/index.d.ts b/auth0-js/index.d.ts index 9a84cc75f1..b4e2b5f599 100644 --- a/auth0-js/index.d.ts +++ b/auth0-js/index.d.ts @@ -83,7 +83,7 @@ export class Authentication { * @param {String} accessToken * @param {Function} callback */ - userInfo(token: string, callback: Auth0Callback): void; + userInfo(token: string, callback: Auth0Callback): void; /** * Makes a call to the `/delegation` endpoint @@ -100,7 +100,7 @@ export class Authentication { * @method getUserCountry * @param {Function} callback */ - getUserCountry(callback: Auth0Callback): void; + getUserCountry(callback: Auth0Callback<{ countryCode: string }>): void; } export class PasswordlessAuthentication { @@ -166,7 +166,7 @@ export class Management { * @param {String} userId * @param {Function} callback */ - getUser(userId: string, callback: Auth0Callback): void; + getUser(userId: string, callback: Auth0Callback): void; /** * Updates the user metdata. It will patch the user metdata with the attributes sent. @@ -177,7 +177,7 @@ export class Management { * @param {Object} userMetadata * @param {Function} callback */ - patchUserMetadata(userId: string, userMetadata: any, callback: Auth0Callback): void; + patchUserMetadata(userId: string, userMetadata: any, callback: Auth0Callback): void; /** * Link two users. https://auth0.com/docs/api/management/v2#!/Users/post_identities @@ -213,12 +213,13 @@ export class WebAuth { * * @method parseHash * @param {Object} options: + * @param {String} options._idTokenVerification [OPTIONAL] Default: true * @param {String} options.state [OPTIONAL] to verify the response * @param {String} options.nonce [OPTIONAL] to verify the id_token * @param {String} options.hash [OPTIONAL] the url hash. If not provided it will extract from window.location.hash * @param {Function} callback: any(err, token_payload) */ - parseHash(options: any, callback: Auth0Callback): void; + parseHash(options: any, callback: Auth0Callback): void; /** * Decodes the id_token and verifies the nonce. @@ -276,6 +277,18 @@ export class WebAuth { */ logout(options: any): void; + /** + * Initialices a passwordless authentication transaction + * + * @method passwordlessStart + * @param {Object} options: https://auth0.com/docs/api/authentication#passwordless + * @param {Object} options.send: `link` or `code` + * @param {Object} options.phoneNumber: send should be code and email not set + * @param {Object} options.email: phoneNumber should be ignored + * @param {Object} options.connection + * @param {Object} options.authParams + * @param {Function} callback + */ passwordlessStart(options: PasswordlessStartOptions, callback: Auth0Callback): void; /** From ad56ca57ea195cb0e7f2ceea590f614dd90a20f7 Mon Sep 17 00:00:00 2001 From: Christian Svensson Date: Wed, 8 Mar 2017 18:56:13 +0100 Subject: [PATCH 6/8] removed internal method --- auth0-js/index.d.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/auth0-js/index.d.ts b/auth0-js/index.d.ts index b4e2b5f599..d1df4d52ae 100644 --- a/auth0-js/index.d.ts +++ b/auth0-js/index.d.ts @@ -347,12 +347,6 @@ export class Popup { */ preload(options: any): any; - /** - * Internal use. - * - * @method getPopupHandler - */ - getPopupHandler(options: any, preload: boolean): any; /** * Opens in a popup the hosted login page (`/authorize`) in order to initialize a new authN/authZ transaction * From 3a6cc84ded1ab7906f2980e41129f7b8041802fb Mon Sep 17 00:00:00 2001 From: Christian Svensson Date: Wed, 8 Mar 2017 19:01:49 +0100 Subject: [PATCH 7/8] added a little more testing code --- auth0-js/auth0-js-tests.ts | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/auth0-js/auth0-js-tests.ts b/auth0-js/auth0-js-tests.ts index cbd791030b..cd7789c62d 100644 --- a/auth0-js/auth0-js-tests.ts +++ b/auth0-js/auth0-js-tests.ts @@ -61,8 +61,6 @@ webAuth.signupAndAuthorize({ }); - - webAuth.client.login({ realm: 'Username-Password-Authentication', //connection name or HRD domain username: 'info@auth0.com', @@ -73,6 +71,26 @@ webAuth.client.login({ // Auth tokens in the result or an error }); +webAuth.popup.buildPopupHandler(); +webAuth.popup.preload({}); +webAuth.popup.authorize({}, (err, data) => { + if (err) /* handle error */ return; + // do something with data +}); +webAuth.popup.loginWithCredentials({}, (err, data) => { + if (err) /* handle error */ return; + // do something with data +}); +webAuth.popup.passwordlessVerify({}, (err, data) => { + if (err) /* handle error */ return; + // do something with data +}); +webAuth.popup.signupAndLogin({}, (err, data) => { + if (err) /* handle error */ return; + // do something with data +}); + + let authentication = new auth0.Authentication({ domain: 'me.auth0.com', clientID: '...', @@ -101,7 +119,9 @@ authentication.delegation({ refresh_token: 'your_refresh_token', api_type: 'app' }, (err, data) => { - + if (!err) { + localStorage.setItem('token', data.idToken) + } }); authentication.loginWithDefaultDirectory({ @@ -146,6 +166,8 @@ let management = new auth0.Management({ management.getUser('asd', (err, user) => {}); -management.patchUserMetadata('asd', {role: 'admin'}, (err, user) => {}); +management.patchUserMetadata('asd', {role: 'admin'}, (err, user) => { + if (!err && user.email_verified) return; // do something +}); management.linkUser('asd', 'eqwe', (err, user) => {}); From 8328aea9c315f495b0a1b82dd97d649fba9a07a1 Mon Sep 17 00:00:00 2001 From: Christian Svensson Date: Wed, 8 Mar 2017 19:10:15 +0100 Subject: [PATCH 8/8] typings updated for auth0-js@8.3 --- auth0-js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth0-js/index.d.ts b/auth0-js/index.d.ts index d1df4d52ae..d8d1e6f392 100644 --- a/auth0-js/index.d.ts +++ b/auth0-js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Auth0.js 8.2 +// Type definitions for Auth0.js 8.3 // Project: https://github.com/auth0/auth0.js // Definitions by: Adrian Chia // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped