validate([ 'client_run_id' => ['required', 'string', 'regex:/^[A-Za-z0-9-]{8,64}$/'], ]); return response()->json( $service->create((string) $data['client_run_id']), 201, ['Cache-Control' => 'private, no-store'], ); } public function consume( Request $request, string $clientRunId, HxbOtpRelayService $service, ): JsonResponse { $bearer = trim((string) $request->bearerToken()); $result = $service->consume($clientRunId, $bearer); $status = (string) ($result['status'] ?? 'not_found'); if ($status === HxbOtpRelayService::STATUS_CONSUMED && isset($result['code'])) { return response()->json($result, 200, ['Cache-Control' => 'private, no-store']); } if ($status === HxbOtpRelayService::STATUS_PENDING) { return response()->json($result, 202, ['Cache-Control' => 'private, no-store']); } if ($status === HxbOtpRelayService::STATUS_EXPIRED) { return response()->json($result, 410, ['Cache-Control' => 'private, no-store']); } return response()->json(['status' => $status], $status === 'not_found' ? 404 : 410, [ 'Cache-Control' => 'private, no-store', ]); } }