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

import NevisMobileAuthentication

struct OutOfBandAuthenticationMethodHandler: MethodHandler {
	func execute(using _: MobileAuthenticationClient, with message: ChannelInMessage) {
		let message: OutOfBandAuthenticationMessage = validate(message: message)
		let operation: OutOfBandAuthenticationOperation = OperationCache.shared.read(by: message.operationId)

		let authentication = operation.authentication.configure(by: message, operation: operation)
		OperationCache.shared.update(by: message.operationId, operation: operation)
		authentication.execute()
	}
}
