From 84518457f46227f54c919f4703008a4c4e97656e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Fri, 17 Jan 2020 17:54:57 +0100 Subject: [PATCH] feat(auth0-js): `buildAuthorizeUrl` documented and version bump (#41663) - documents public options for `buildAuthorizeUrl`: https://auth0.github.io/auth0.js/authentication_index.js.html#line108 - bump version up - drop TypeScript minimal version comment as not relevant for the types Thanks! --- types/auth0-js/auth0-js-tests.ts | 13 +++++++-- types/auth0-js/index.d.ts | 50 +++++++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/types/auth0-js/auth0-js-tests.ts b/types/auth0-js/auth0-js-tests.ts index 2a8b8f7dc9..ced4d557e7 100644 --- a/types/auth0-js/auth0-js-tests.ts +++ b/types/auth0-js/auth0-js-tests.ts @@ -211,13 +211,20 @@ const authentication = new auth0.Authentication({ _sendTelemetry: false }); +// $ExpectError authentication.buildAuthorizeUrl({state: '1234'}); +// $ExpectError +authentication.buildAuthorizeUrl(); +// $ExpectType string authentication.buildAuthorizeUrl({ - responseType: 'token', + audience: 'audience', + clientID: 'clientID', + nonce: '1234', redirectUri: 'http://anotherpage.com/callback2', - prompt: 'none', + responseMode: 'query', + responseType: 'code token', + scope: 'openid email', state: '1234', - connection_scope: 'scope1,scope2' }); authentication.buildLogoutUrl({ clientID: 'asdfasdfds' }); diff --git a/types/auth0-js/index.d.ts b/types/auth0-js/index.d.ts index c8c295d8a8..c6e1da9713 100644 --- a/types/auth0-js/index.d.ts +++ b/types/auth0-js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Auth0.js 9.10 +// Type definitions for Auth0.js 9.12 // Project: https://github.com/auth0/auth0.js // Definitions by: Adrian Chia // Matt Durrant @@ -6,7 +6,6 @@ // Bartosz Kotrys // Mark Nelissen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 export as namespace auth0; @@ -19,9 +18,11 @@ export class Authentication { /** * Builds and returns the `/authorize` url in order to initialize a new authN/authZ transaction * - * @param options: https://auth0.com/docs/api/authentication#!#get--authorize_db + * @param options: https://auth0.github.io/auth0.js/global.html#buildAuthorizeUrl + * @see {@link https://auth0.com/docs/api/authentication#authorize-client} + * @see {@link https://auth0.com/docs/api/authentication#social} */ - buildAuthorizeUrl(options: any): string; + buildAuthorizeUrl(options: AuthorizeUrlOptions): string; /** * Builds and returns the Logout url in order to initialize a new authN/authZ transaction @@ -697,6 +698,47 @@ export interface AdfsUserProfile extends Auth0UserProfile { issuer?: string; } +export interface AuthorizeUrlOptions { + /** + * your Auth0 client identifier obtained when creating the client in the Auth0 Dashboard + */ + clientID?: string; + /** + * url that the Auth0 will redirect after Auth with the Authorization Response + */ + redirectUri: string; + /** + * type of the response used by OAuth 2.0 flow. It can be any space separated + * list of the values `code`, `token`, `id_token`. + * {@link https://openid.net/specs/oauth-v2-multiple-response-types-1_0} + */ + responseType: string; + /** + * how the Auth response is encoded and redirected back to the client. + * Supported values are `query`, `fragment` and `form_post` + * {@link https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#ResponseModes} + */ + responseMode?: 'query' | 'fragment' | 'form_post'; + /** + * value used to mitigate XSRF attacks. + * {@link https://auth0.com/docs/protocols/oauth2/oauth-state} + */ + state?: string; + /** + * value used to mitigate replay attacks when using Implicit Grant. + * {@link https://auth0.com/docs/api-auth/tutorials/nonce} + */ + nonce?: string; + /** + * scopes to be requested during Auth. e.g. `openid email` + */ + scope?: string; + /** + * identifier of the resource server who will consume the access token issued after Auth + */ + audience?: string; +} + export interface Auth0Identity { connection: string; isSocial: boolean;