/**
 * Copyright © 2024 Nevis Security AG. All rights reserved.
 */

import type { PasswordChangeContext } from './PasswordChangeContext';
import type { PasswordChangeHandler } from './PasswordChangeHandler';
import { PasswordPolicyProvider } from './PasswordPolicyProvider';

/**
 * The object in charge of password change.
 *
 * The SDK does not provide implementations of this interface.
 * The implementation must be done by the user of the SDK.
 *
 * @see {@link PasswordChange.passwordChanger}
 */
export abstract class PasswordChanger extends PasswordPolicyProvider {
	/**
	 * The method that will be invoked till either the user provides the old password
	 * and a new password that conforms with the format specified by the {@link PasswordPolicy},
	 * or till the operation is cancelled (through the {@link PasswordChangeHandler.cancel}),
	 * or till the password authenticator is permanently locked because the user
	 * provided too many times an invalid password.
	 *
	 * @param context the context.
	 * @param handler the object that must be invoked with the new and old passwords.
	 */
	abstract changePassword(context: PasswordChangeContext, handler: PasswordChangeHandler): void;
}
