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

import { OutOfBandPayloadError } from './OutOfBandPayloadError';

/**
 * The encrypted contents of the out-of-band payload could not be decrypted.
 *
 * This occurs for instance when the keys that are used to decrypt the out-of-band payload are deleted.
 * The problem can also occur in the case where the user is trying to redeem a token that was generated
 * for another mobile device: a malicious user trying to authenticate using the QR code generated by another
 * user, or a user with multiple devices trying to scan the QR using the wrong device.
 */
export class OutOfBandPayloadDecryptionError extends OutOfBandPayloadError {
	/**
	 * Provides details about the error that occurred.
	 */
	description: string;

	/**
	 * The exception (if any) that caused this error.
	 */
	cause?: string;

	/**
	 * The default constructor.
	 *
	 * @param description provides details about the error that occurred.
	 * @param cause the exception (if any) that caused this error.
	 */
	constructor(description: string, cause?: string) {
		super();
		this.description = description;
		this.cause = cause;
	}
}
