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

import NevisMobileAuthentication

struct PinEnrollMethodHandler: UserInteractionMethodHandler {
	func execute(using _: MobileAuthenticationClient, method: ReactMethod, with message: ChannelInMessage, operation: any UserInteractionOperation) async {
		let message: PinEnrollMessage = validate(message: message)
		let state: PinEnrollState = await validate(state: operation.state)
		await state.enrollPin(pin: message.pin.joined())
		MethodChannelHandler.shared.resolve(method: method)
	}
}
