Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#59965 [@types/react-native-auth0] Add cust…
Browse files Browse the repository at this point in the history
…om URL parameters to AuthorizeParams by @bombillazo

* Add optional user defined query parameter to AuthorizeParams interface

* Add test for user defiend custom params

* Fix styling issue

* Update react-native-auth0 version number

* Typo fixes

* Add generic type parameter to AuthorizeParams

* Update generic types and update test

* Remove unused ports

* Update AuthorizeParams type

* Make AuthorizeParams interface cleaner

* Add boolean to custom param value type

Co-authored-by: Bombillazo <[email protected]>
  • Loading branch information
bombillazo and bombillazo authored Apr 27, 2022
1 parent b528814 commit 82c30c3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
7 changes: 4 additions & 3 deletions types/react-native-auth0/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for react-native-auth0 2.10
// Type definitions for react-native-auth0 2.13
// Project: https://github.com/auth0/react-native-auth0
// Definitions by: Andrea Ascari <https://github.com/ascariandrea>
// Mark Nelissen <https://github.com/marknelissen>
Expand Down Expand Up @@ -200,16 +200,17 @@ export const users: Users;
* Web Auth
*/
export interface AuthorizeParams {
state?: string; // Random string to prevent CSRF attacks and used to discard unexepcted results. By default its a cryptographically secure random.
state?: string; // Random string to prevent CSRF attacks and used to discard unexpected results. By default it is a cryptographically secure random.
nonce?: string; // Random string to prevent replay attacks of id_tokens.
audience?: string; // Identifier of Resource Server (RS) to be included as audience (aud claim) of the issued access token
audience?: string; // Identifier of Resource Server (RS) to be included as the audience (aud claim) of the issued access token
scope?: string; // Scopes requested for the issued tokens. e.g. `openid profile`
connection?: string; // The name of the identity provider to use, e.g. "google-oauth2" or "facebook". When not set, it will display Auth0's Universal Login Page.
language?: string;
prompt?: string;
max_age?: number; // The allowable elapsed time in seconds since the last time the user was authenticated (optional).
organization?: string; // The ID of the organization to join
invitationUrl?: string; // The invitation URL to join an organization. Takes precedence over the "organization" parameter.
[key: string]: string | number | boolean | undefined; // Optional user-defined values appended to the auth page URL query parameters.
}

export interface AuthorizeOptions {
Expand Down
13 changes: 12 additions & 1 deletion types/react-native-auth0/react-native-auth0-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Auth0, { UserInfo } from 'react-native-auth0';
import Auth0 from 'react-native-auth0';

const auth0 = new Auth0({
domain: 'definitely-typed',
Expand Down Expand Up @@ -131,6 +131,17 @@ auth0.webAuth
})
.then(credentials => credentials.doesNotExist); // $ExpectError

auth0.webAuth
.authorize({
state: 'state',
nonce: 'nonce',
scope: 'openid',
language: 'en',
prompt: 'login',
customParam1: 'MyValue', // User defined custom string parameter
customParam2: 9001, // User defined custom number parameter
});

auth0.webAuth.clearSession({ federated: false });
auth0.webAuth.clearSession({ federated: true, customScheme: 'customUrlScheme' });
auth0.webAuth.clearSession();
Expand Down

0 comments on commit 82c30c3

Please sign in to comment.