Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/managed-auth-react/src/KernelManagedAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { StepError } from "./components/StepError";
import { StepExpired } from "./components/StepExpired";
import { LoadingState } from "./components/LoadingState";
import { ExternalActionWaiting } from "./components/ExternalActionWaiting";
import { HumanInterventionStep } from "./components/HumanInterventionStep";
import { useLocalization } from "./localization/context";
import type { Appearance } from "./appearance/types";
import type { Localization } from "./localization/types";
Expand Down Expand Up @@ -120,6 +121,12 @@ function KernelManagedAuthInner({
);
}

if (uiState === "awaiting_human_intervention") {
return (
<HumanInterventionStep liveViewUrl={state?.live_view_url ?? undefined} />
);
}

if (uiState === "success") {
return <StepSuccess targetDomain={targetDomain} />;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { useSlot } from "../appearance/context";
import { useLocalization } from "../localization/context";

interface HumanInterventionStepProps {
liveViewUrl?: string | null;
}

export function HumanInterventionStep({
liveViewUrl,
}: HumanInterventionStepProps) {
const slot = useSlot();
const l = useLocalization();

return (
<div className="kma-step kma-step--center kma-human-intervention">
<div className="kma-step__header">
<h2 className="kma-loading-title">{l.humanInterventionTitle}</h2>
<p {...slot("humanInterventionMessage", "kma-subtitle")}>
{l.humanInterventionMessage}
</p>
</div>

{liveViewUrl ? (
<div className="kma-human-intervention__iframe-wrap">
<iframe
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The iframe element in HumanInterventionStep.tsx is missing the sandbox attribute, which lacks protection against potential XSS and script injection attacks

Fix on Vercel

src={liveViewUrl}
title={l.humanInterventionIframeTitle}
className="kma-human-intervention__iframe"
allow="clipboard-write"
/>
<span
className="kma-human-intervention__live-badge"
aria-hidden="true"
>
<span className="kma-human-intervention__live-dot" />
Live
</span>
</div>
) : (
<div className="kma-bouncing-dots" aria-hidden="true">
<span
className="kma-bouncing-dot"
style={{ animationDelay: "0ms" }}
/>
<span
className="kma-bouncing-dot"
style={{ animationDelay: "150ms" }}
/>
<span
className="kma-bouncing-dot"
style={{ animationDelay: "300ms" }}
/>
</div>
)}

<p className="kma-loading-hint">{l.humanInterventionWaiting}</p>
</div>
);
}
2 changes: 2 additions & 0 deletions packages/managed-auth-react/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type FlowStep =
| "DISCOVERING"
| "AWAITING_INPUT"
| "AWAITING_EXTERNAL_ACTION"
| "AWAITING_HUMAN_INTERVENTION"
| "SUBMITTING"
| "COMPLETED";

Expand Down Expand Up @@ -101,6 +102,7 @@ export type UIState =
| "discovering"
| "awaiting_input"
| "awaiting_external_action"
| "awaiting_human_intervention"
| "submitting"
| "success"
| "expired"
Expand Down
5 changes: 5 additions & 0 deletions packages/managed-auth-react/src/localization/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@ export const DEFAULT_LOCALIZATION: Localizer = {
externalActionTitle: "Action Required",
externalActionFallbackMessage: "Complete the verification on your device",
externalActionWaiting: "Waiting for your confirmation...",
humanInterventionTitle: "Your Help Needed",
humanInterventionMessage:
"Please solve the captcha in the browser below to continue",
humanInterventionIframeTitle: "Browser live view",
humanInterventionWaiting: "Waiting for you to complete the challenge...",
};
5 changes: 5 additions & 0 deletions packages/managed-auth-react/src/localization/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export interface Localization {
externalActionTitle?: string;
externalActionFallbackMessage?: string;
externalActionWaiting?: string;
/** Human intervention (HITL). */
humanInterventionTitle?: string;
humanInterventionMessage?: string;
humanInterventionIframeTitle?: string;
humanInterventionWaiting?: string;
}

export type Localizer = Required<Localization>;
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ function deriveUIState(state: ManagedAuthResponse): UIState {
return "awaiting_input";
case "AWAITING_EXTERNAL_ACTION":
return "awaiting_external_action";
case "AWAITING_HUMAN_INTERVENTION":
return "awaiting_human_intervention";
case "SUBMITTING":
return "submitting";
default:
Expand Down
86 changes: 86 additions & 0 deletions packages/managed-auth-react/src/styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,92 @@
}
}

/* ---------- Human intervention (HITL) ---------- */

/* Animate the shell + card growing when HITL is active so the transition isn't
abrupt. Uses :has() to detect HITL state. */
.kma-shell {
transition: max-width 0.25s ease;
}

.kma-card {
transition: max-width 0.25s ease;
}

.kma-shell:has(.kma-human-intervention),
.kma-card:has(.kma-human-intervention) {
max-width: min(90vw, 960px);
}

.kma-human-intervention {
display: flex;
flex-direction: column;
align-items: stretch;
gap: 1.25rem;
padding: 0.5rem 0;
text-align: center;
}

.kma-human-intervention .kma-step__header {
display: flex;
flex-direction: column;
gap: 0.5rem;
align-items: center;
}

.kma-human-intervention__iframe-wrap {
position: relative;
width: 100%;
aspect-ratio: 4 / 3;
border-radius: var(--kma-radius, 0.75rem);
overflow: hidden;
border: 1px solid var(--kma-color-border, rgba(0, 0, 0, 0.08));
background: var(--kma-color-muted, rgba(0, 0, 0, 0.03));
}

.kma-human-intervention__iframe {
width: 100%;
height: 100%;
border: none;
display: block;
}

/* Subtle "live" indicator pinned to the iframe corner for context. */
.kma-human-intervention__live-badge {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: inline-flex;
align-items: center;
gap: 0.375rem;
padding: 0.25rem 0.625rem;
font-size: 0.75rem;
font-weight: 600;
letter-spacing: 0.02em;
background: rgba(0, 0, 0, 0.65);
color: #fff;
border-radius: 9999px;
pointer-events: none;
}

.kma-human-intervention__live-dot {
width: 0.5rem;
height: 0.5rem;
border-radius: 9999px;
background: oklch(0.704 0.191 22.216);
animation: kma-live-pulse 2s ease-in-out infinite;
}

@keyframes kma-live-pulse {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.4;
}
}

/* ---------- Expired step ---------- */

/* Matches the previous hosted-ui `space-y-6 text-center py-8`. */
Expand Down
Loading