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

import { ChannelMessage } from '../ChannelMessage';

/**
 * Holds the parameters of the validate password call.
 */
export class PasswordValidationMessage extends ChannelMessage {
	/**
	 * The identifier of the operation.
	 */
	operationId: string;

	/**
	 * The password to be validated.
	 */
	password: string;

	/**
	 * Default constructor for {@link PasswordValidationMessage}.
	 *
	 * @param operationId the identifier of the operation.
	 * @param password the password to be validated.
	 */
	private constructor(operationId: string, password: string) {
		super();
		this.operationId = operationId;
		this.password = password;
	}

	/**
	 * Alternate constructor that creates an {@link PasswordValidationMessage} from a json.
	 *
	 * @param json contains the source for instance creation.
	 * @returns the created instance.
	 */
	static fromJson(json: any): PasswordValidationMessage {
		return new PasswordValidationMessage(json.operationId, json.password.join(''));
	}
}
