Skip to content

Commit

Permalink
Make authorize and clearSession parameters optional (#701)
Browse files Browse the repository at this point in the history
  • Loading branch information
poovamraj authored Aug 16, 2023
1 parent 3a5c686 commit 109549e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ const Home = () => {
const { authorize, clearSession, user, getCredentials, error } = useAuth0();

const onLogin = async () => {
await authorize({ scope: 'openid profile email' }, {});
await authorize();
const credentials = await getCredentials(undefined, 0, {});
Alert.alert('AccessToken: ' + credentials?.accessToken);
};

const loggedIn = user !== undefined && user !== null;

const onLogout = async () => {
await clearSession({ federated: true }, {});
await clearSession();
};

return (
Expand Down
24 changes: 16 additions & 8 deletions src/hooks/auth0-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export interface Auth0ContextInterface<TUser extends User = User>
* @param options Options for customizing the SDK's handling of the authorize call
*/
authorize: (
parameters: WebAuthorizeParameters,
options: WebAuthorizeOptions
parameters?: WebAuthorizeParameters,
options?: WebAuthorizeOptions
) => Promise<Credentials | undefined>;
/**
* Start the passwordless SMS login flow. See {@link Auth#passwordlessWithSMS}
Expand All @@ -35,15 +35,19 @@ export interface Auth0ContextInterface<TUser extends User = User>
/**
* Authorize the user using a SMS code. See {@link Auth#loginWithSMS}
*/
authorizeWithSMS: (parameters: LoginWithSMSOptions) => Promise<Credentials | undefined>;
authorizeWithSMS: (
parameters: LoginWithSMSOptions
) => Promise<Credentials | undefined>;
/**
* Start the passwordless email login flow. See {@link Auth#passwordlessWithEmail}
*/
sendEmailCode: (parameters: PasswordlessWithEmailOptions) => Promise<void>;
/**
* Authorize the user using an email code. See {@link Auth#loginWithEmail}
*/
authorizeWithEmail: (parameters: LoginWithEmailOptions) => Promise<Credentials | undefined>;
authorizeWithEmail: (
parameters: LoginWithEmailOptions
) => Promise<Credentials | undefined>;
/**
* Send a challenge for multi-factor authentication. See {@link Auth#multifactorChallenge}
*/
Expand All @@ -53,11 +57,15 @@ export interface Auth0ContextInterface<TUser extends User = User>
/**
* Authorize the user using an Out Of Band authentication code. See {@link Auth#loginWithOOB}
*/
authorizeWithOOB: (parameters: LoginWithOOBOptions) => Promise<Credentials | undefined>;
authorizeWithOOB: (
parameters: LoginWithOOBOptions
) => Promise<Credentials | undefined>;
/**
* Autohrize the user using a One Time Password code. See {@link Auth#loginWithOTP}.
*/
authorizeWithOTP: (parameters: LoginWithOTPOptions) => Promise<Credentials | undefined>;
authorizeWithOTP: (
parameters: LoginWithOTPOptions
) => Promise<Credentials | undefined>;
/**
* Authorize the user using a multi-factor authentication Recovery Code. See {@link Auth#loginWithRecoveryCode}
*/
Expand All @@ -76,8 +84,8 @@ export interface Auth0ContextInterface<TUser extends User = User>
* @param options Options for configuring the SDK's clear session behaviour.
*/
clearSession: (
parameters: ClearSessionParameters,
options: ClearSessionOptions
parameters?: ClearSessionParameters,
options?: ClearSessionOptions
) => Promise<void>;
/**
* Gets the user's credentials from the native credential store. If credentials have expired, they are automatically refreshed
Expand Down

0 comments on commit 109549e

Please sign in to comment.