Skip to content

Commit

Permalink
fix(clerk-js): Refactor types for resetPassword
Browse files Browse the repository at this point in the history
fix(clerk-js): Refactor types for resetPassword
  • Loading branch information
raptisj committed Apr 13, 2023
1 parent fa70749 commit fd53901
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/clerk-js/src/core/resources/SignIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class SignIn extends BaseResource implements SignInResource {
resetPassword = (params: ResetPasswordParams): Promise<SignInResource> => {
return this._basePost({
body: params,
path: `${this.pathRoot}/${this.id}/reset_password`,
action: 'reset_password',
});
};

Expand Down
14 changes: 11 additions & 3 deletions packages/types/src/factors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
OAuthStrategy,
PasswordStrategy,
PhoneCodeStrategy,
ResetPasswordCode,
ResetPasswordCodeStrategy,
TOTPStrategy,
Web3Strategy,
} from './strategies';
Expand Down Expand Up @@ -54,12 +54,15 @@ export type BackupCodeFactor = {
strategy: BackupCodeStrategy;
};

export type ResetPasswordCodeFactorConfig = {
strategy: ResetPasswordCode;
export type ResetPasswordCodeFactor = {
strategy: ResetPasswordCodeStrategy;
emailAddressId?: string;
safeIdentifier: string;
phoneNumberId?: string;
};

export type ResetPasswordCodeFactorConfig = Omit<ResetPasswordCodeFactor, 'safeIdentifier'>;

export type EmailCodeConfig = Omit<EmailCodeFactor, 'safeIdentifier'>;
export type EmailLinkConfig = Omit<EmailLinkFactor, 'safeIdentifier'> & {
redirectUrl: string;
Expand Down Expand Up @@ -105,3 +108,8 @@ export type BackupCodeAttempt = {
strategy: BackupCodeStrategy;
code: string;
};

export type ResetPasswordCodeAttempt = {
strategy: ResetPasswordCodeStrategy;
code: string;
};
9 changes: 7 additions & 2 deletions packages/types/src/signIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ export interface SignInResource extends ClerkResource {
createMagicLinkFlow: () => CreateMagicLinkFlowReturn<SignInStartMagicLinkFlowParams, SignInResource>;
}

export type SignInStatus = 'needs_identifier' | 'needs_first_factor' | 'needs_second_factor' | 'complete';
export type SignInStatus =
| 'needs_identifier'
| 'needs_first_factor'
| 'needs_second_factor'
| 'needs_new_password'
| 'complete';

export type SignInIdentifier =
| UsernameIdentifier
Expand Down Expand Up @@ -153,7 +158,7 @@ export type SignInCreateParams = (
) & { transfer?: boolean };

export type ResetPasswordParams = {
new_password: string;
password: string;
};

export interface SignInStartMagicLinkFlowParams extends StartMagicLinkFlowParams {
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/strategies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type EmailLinkStrategy = 'email_link';
export type TicketStrategy = 'ticket';
export type TOTPStrategy = 'totp';
export type BackupCodeStrategy = 'backup_code';
export type ResetPasswordCode = 'reset_password_code';
export type ResetPasswordCodeStrategy = 'reset_password_code';

export type OAuthStrategy = `oauth_${OAuthProvider}`;
export type Web3Strategy = `web3_${Web3Provider}_signature`;

0 comments on commit fd53901

Please sign in to comment.