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

import { OperationError } from './OperationError';

/**
 * The device supports StrongBox and the key was created and stored in StrongBox during registration,
 * but the created key cannot be used for signing. In this case the registration fails and the created
 * key material is deleted.
 *
 * This error has been introduced because we have observed that some devices are not able to sign
 * the FIDO UAF assertions when the key is stored in StrongBox. In this case we suggest to execute
 * the registration providing `false` to the {@link Registration.allowStrongBox} method.
 *
 * @remarks
 * This is an Android specific error.
 *
 * @group Errors
 * @category Operation
 *
 * @see
 *  - {@link Registration.allowStrongBox}
 *  - {@link OutOfBandRegistration.allowStrongBox}
 *  - {@link AuthCloudApiRegistration.allowStrongBox}
 */
export class OperationSigningFailedWithStrongBox extends OperationError {
	/**
	 * 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;
	}
}
