Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

feat(vault): open the sandbox authorization window from the approval click (#2284)

Call Whitebd800d03a0f9
diff --git a/docs/plans/vault-sandbox-protocol-v2.md b/docs/plans/vault-sandbox-protocol-v2.md
index bf31a6862..b25669e3f 100644
--- a/docs/plans/vault-sandbox-protocol-v2.md
+++ b/docs/plans/vault-sandbox-protocol-v2.md
@@ -135,7 +135,8 @@ root of the "unlocked but still prompted every time" experience.
approval inside a freshly authorized session is one intent already paid for.
- **G2 — The top-level sandbox is *the* authorization surface.** It renders
daemon-endorsed context, in human language, for every consent it collects;
- an embedded card only launches that surface.
+ the parent's approval click opens that surface directly, and an embedded
+ card only launches it when the parent could not.
- **G3 — One clock.** The sandbox owns time; the parent renders events.
- **G4 — Explicit risk tiers.** Silent / confirm / passkey-always are product
decisions per operation class, configurable where it matters.
@@ -332,16 +333,44 @@ display-only).
### 6.6 Confirm-surface hardening (prerequisite for R2)
R2/R3 authorization is performed in a dedicated top-level sandbox window. The
-embedded sandbox only renders a visible launcher and cannot authorize an
-operation from its iframe-local hit tests or from a parent-supplied visibility
-claim. Each request opens a unique popup window whose URL contains only the
-random request id and appearance settings. After the popup signals readiness,
-the opener transfers the signed prompt and encrypted wrap metadata through a
-same-origin, id-gated `postMessage` handshake; approval metadata is never put
-in the URL. The popup validates the opener origin and window source, renders
-the confirmation, performs any WebAuthn ceremony, and returns a typed result
-through the same channel. The opener applies a five-minute timeout and a
-short close grace period for queued mobile-browser messages.
+embedded sandbox cannot authorize an operation from its iframe-local hit tests
+or from a parent-supplied visibility claim. Each authorization uses a unique
+popup window whose URL contains only a random id and appearance settings.
+After the popup signals readiness, the requesting sandbox frame transfers the
+signed prompt and encrypted wrap metadata through a same-origin, id-gated
+`postMessage` handshake; approval metadata is never put in the URL. The popup
+validates the requester origin and window source, renders the confirmation,
+performs any WebAuthn ceremony, and returns a typed result through the same
+channel. The requester applies a five-minute timeout and a short close grace
+period for queued mobile-browser messages.
+
+The parent's approval click is the user gesture that opens this window, so the
+user reviews and approves the operation in one sandbox surface:
+
+1. The parent opens `…/index.html?mode=authorize&id=<id>&locale&theme`
+ synchronously in the click, before any await, and sends the id as the
+ top-level `authorizationWindow` field of the interactive RPC envelope
+ (`[A-Za-z0-9_-]{16,128}`; any other value fails the request with
+ `invalid_payload`). The parent keeps the frame collapsed for that request.
+2. The first authorization inside the request claims the id once; a second
+ authorization in the same request (the lock-race retry) finds no id and
+ falls back to the launcher below.
+3. The popup has no requester reference of its own, so it announces
+ `authorization-ready` every 500 ms to each same-origin frame of its opener,
+ with its own origin as the target origin. The requesting frame pairs with
+ the window whose ready message carries its id and ignores every other
+ source. The popup accepts `authorization-request` only from a frame of its
+ opener and replies only to that frame, so PRF output never leaves the
+ sandbox origin.
+4. A window that does not announce itself within 30 seconds, or closes, fails
+ the operation with the retryable `authorization_window_closed`. The parent
+ closes its handle when the operation settles.
+
+Without an id (the browser blocked the parent's window, or an older parent),
+the embedded sandbox renders a visible launcher card whose click opens the
+window itself. The parent holds a handle to the window it opened and can
+navigate or close it, but it cannot read the cross-origin document or its
+result, so it gains nothing beyond what it can already show in its own page.
The old iframe visibility and parent-attestation checks remain telemetry-only
compatibility signals while the top-level window is open. The security boundary
@@ -351,8 +380,8 @@ is the browser-rendered top-level sandbox page, not the embedder's DOM.
### 7.1 Approvals (access)
-Parent: one click (Approve) on the request card launches a top-level sandbox
-authorization window. Parent fetches **one** batch
+Parent: one click (Approve) on the request card opens the top-level sandbox
+authorization window (§6.6). Parent fetches **one** batch
of signed contexts (`POST /vault/agent-bindings:batch` with the request id;
daemon returns per-secret bindings sharing one display block), sends one
`approveRelease`. Sandbox: one card — title, session label, command, egress,
@@ -418,8 +447,8 @@ triggered from the create form (`setup` immediately continues into the pending
### 7.4 Reveal
Secret detail (protected static) gains "Show value / Copy value" actions
-calling `reveal`. R2: confirm in the top-level sandbox authorization window;
-after approval, plaintext is rendered inside the sandbox iframe only. This
+calling `reveal`. R2: the action click opens the top-level sandbox
+authorization window, where the user confirms; after approval, plaintext is rendered inside the sandbox iframe only. This
closes the orphaned-`unseal` gap without moving plaintext into the parent.
**Copy-mode caveat**: the system clipboard is a shared resource — once the
diff --git a/ui/src/components/ui/vault-approval-card.tsx b/ui/src/components/ui/vault-approval-card.tsx
index 66c7a7d16..17f2ba3e8 100644
--- a/ui/src/components/ui/vault-approval-card.tsx
+++ b/ui/src/components/ui/vault-approval-card.tsx
@@ -13,8 +13,9 @@ import {
import { useInstanceAuthorization } from '@/context/InstanceAuthorizationContext';
import { partitionTags } from '@/lib/vaultTags';
import { useProtectedVault, type ProtectedUnlockMaterial } from '@/lib/useProtectedVault';
+import { openVaultAuthorizationWindow } from '@/lib/vaultSandboxClient';
import { SigningAddressList } from './signing-address-list';
-import { type BlindBox, type SignatureScheme } from '@/lib/vaultCrypto';
+import { type BlindBox, type SignatureResult, type SignatureScheme } from '@/lib/vaultCrypto';
import { cn, copyTextToClipboard } from '@/lib/utils';
import { Badge } from './badge';
import { Button } from './button';
@@ -274,31 +275,38 @@ export const VaultApprovalCard: React.FC<{
}),
);
} else {
- // Protected members — ONE batch call returns signed, value-free agent-delivery contexts
- // for the whole selector; the sandbox then releases every DEK behind ONE confirm (protocol
- // v2 §7.1) as opaque HPKE blind boxes for the pinned resident agent.
- const issued = await api.createVaultAgentBindingsBatch({ request_id: request.id, grant_duration: durationValue });
- failIfNotOk(issued);
- const materialByName = new Map(materials.map((m) => [m.name, m]));
- const approveItems = issued.items.map((item) => {
- const material = materialByName.get(item.name);
- if (!material) throw new Error(t('vaults.approval.errors.missingMaterial'));
- return { material, context: item.context };
- });
- // One confirm card lists every member; the blind boxes come back in item order.
- const blindBoxes = await vault.approveProtectedRelease(approveItems);
- if (blindBoxes.length !== issued.items.length) throw new Error(t('vaults.approval.errors.failed'));
- const deks: Array<{ name: string; dek_blindbox: BlindBox; approval: { nonce: string; expires_at_unix: number } }> =
- issued.items.map((item, index) => ({ name: item.name, dek_blindbox: blindBoxes[index], approval: item.approval }));
- failIfNotOk(
- await api.fulfillVaultAccessRequest(request.id, {
- grant_id: grantId,
- grant_duration: durationValue,
- this_session_only: sessionBound,
- agent_pubkey: issued.agent_pubkey,
- deks,
- }),
- );
+ // This click is the approval gesture, so it opens the sandbox authorization window before
+ // any await; the sandbox then confirms in that window without a second launcher card.
+ const authorizationWindow = openVaultAuthorizationWindow();
+ try {
+ // Protected members — ONE batch call returns signed, value-free agent-delivery contexts
+ // for the whole selector; the sandbox then releases every DEK behind ONE confirm (protocol
+ // v2 §7.1) as opaque HPKE blind boxes for the pinned resident agent.
+ const issued = await api.createVaultAgentBindingsBatch({ request_id: request.id, grant_duration: durationValue });
+ failIfNotOk(issued);
+ const materialByName = new Map(materials.map((m) => [m.name, m]));
+ const approveItems = issued.items.map((item) => {
+ const material = materialByName.get(item.name);
+ if (!material) throw new Error(t('vaults.approval.errors.missingMaterial'));
+ return { material, context: item.context };
+ });
+ // One confirm card lists every member; the blind boxes come back in item order.
+ const blindBoxes = await vault.approveProtectedRelease(approveItems, authorizationWindow?.id);
+ if (blindBoxes.length !== issued.items.length) throw new Error(t('vaults.approval.errors.failed'));
+ const deks: Array<{ name: string; dek_blindbox: BlindBox; approval: { nonce: string; expires_at_unix: number } }> =
+ issued.items.map((item, index) => ({ name: item.name, dek_blindbox: blindBoxes[index], approval: item.approval }));
+ failIfNotOk(
+ await api.fulfillVaultAccessRequest(request.id, {
+ grant_id: grantId,
+ grant_duration: durationValue,
+ this_session_only: sessionBound,
+ agent_pubkey: issued.agent_pubkey,
+ deks,
+ }),
+ );
+ } finally {
+ authorizationWindow?.close();
+ }
}
// Remember the approver's choice as next time's default — but not for one-shot, where the
// duration was forced to one-time (not chosen), so persisting it would wrongly bias the next
@@ -324,7 +332,14 @@ export const VaultApprovalCard: React.FC<{
const operationContext =
delivery.operation_context ?? (card as { operation_context?: VaultSignedOperationContext } | null)?.operation_context;
if (!operationContext) throw new Error(t('vaults.approval.errors.missingMaterial'));
- const sig = await vault.signProtectedRequest(material, signingContext, scheme as SignatureScheme, operationContext);
+ // Open the sandbox authorization window from this click, before any await (see approveAccess).
+ const authorizationWindow = openVaultAuthorizationWindow();
+ let sig: SignatureResult;
+ try {
+ sig = await vault.signProtectedRequest(material, signingContext, scheme as SignatureScheme, operationContext, authorizationWindow?.id);
+ } finally {
+ authorizationWindow?.close();
+ }
const signature: Record<string, unknown> = { signature: sig.signature };
if (sig.recovery_id != null) signature.recovery_id = sig.recovery_id;
failIfNotOk(await api.signVaultDigest({ name, request_id: request.id, digest, scheme, signature }));
diff --git a/ui/src/components/workbench/VaultsPage.test.tsx b/ui/src/components/workbench/VaultsPage.test.tsx
index 8d0da8920..1ac5f1422 100644
--- a/ui/src/components/workbench/VaultsPage.test.tsx
+++ b/ui/src/components/workbench/VaultsPage.test.tsx
@@ -2,7 +2,7 @@
import type { ReactNode } from 'react';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
-import { act, cleanup, render, screen, waitFor } from '@testing-library/react';
+import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { MemoryRouter } from 'react-router-dom';
@@ -15,6 +15,7 @@ type WorkbenchEventHandlers = { onVaultsUpdated?: (data: unknown) => void };
const eventHandlers = vi.hoisted(() => [] as WorkbenchEventHandlers[]);
const api = vi.hoisted(() => ({
connectWorkbenchEvents: vi.fn(() => () => undefined),
+ createVaultRevealContext: vi.fn(),
getVaultAudit: vi.fn(),
getVaultGrants: vi.fn(),
getVaultRequests: vi.fn(),
@@ -103,6 +104,7 @@ beforeEach(() => {
afterEach(() => {
cleanup();
vi.clearAllMocks();
+ vi.restoreAllMocks();
});
describe('VaultsPage remote audit history', () => {
@@ -152,3 +154,48 @@ describe('PERMISSIONS-016 VaultsPage wakes an Editor on the bare vaults.updated
expect(query).toMatchObject({ status: 'pending' });
});
});
+
+// A popup opened after an await has lost the click's user activation and is blocked, which would
+// silently bring back the sandbox's own launcher card and its second approval click.
+describe('VaultsPage protected reveal', () => {
+ it('opens the sandbox authorization window inside the click and hands it to the reveal', async () => {
+ const user = userEvent.setup();
+ api.listVaultSecrets.mockResolvedValue({
+ secrets: [
+ {
+ name: 'alpha',
+ tags: [],
+ kind: 'static',
+ protection: 'protected',
+ signer_kind: null,
+ source: 'user',
+ policy: {},
+ last_used_at: null,
+ use_count: 0,
+ created_at: '2026-08-11T00:00:00Z',
+ updated_at: '2026-08-11T00:00:00Z',
+ },
+ ],
+ });
+ api.createVaultRevealContext.mockResolvedValue({
+ ok: true,
+ context: { secret_name: 'alpha' },
+ envelope: { ciphertext: 'c', nonce: 'n', wrap_meta: 'w' },
+ });
+ revealProtectedValue.mockResolvedValue(undefined);
+ const popup = { closed: false, close: vi.fn() };
+ const open = vi.spyOn(window, 'open').mockReturnValue(popup as unknown as Window);
+
+ renderPage();
+ await user.click(await screen.findByRole('button', { name: 'vaults.rowActions' }));
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'vaults.reveal.show' }));
+
+ // Asserted synchronously after the click dispatch, before any awaited work can run.
+ expect(open).toHaveBeenCalledOnce();
+ const opened = new URL(String(open.mock.calls[0][0]));
+ expect(opened.searchParams.get('mode')).toBe('authorize');
+ await waitFor(() => expect(revealProtectedValue).toHaveBeenCalledOnce());
+ expect(revealProtectedValue.mock.calls[0][2]).toBe(opened.searchParams.get('id'));
+ await waitFor(() => expect(popup.close).toHaveBeenCalledOnce());
+ });
+});
diff --git a/ui/src/components/workbench/VaultsPage.tsx b/ui/src/components/workbench/VaultsPage.tsx
index 296fd29cb..b536b61f7 100644
--- a/ui/src/components/workbench/VaultsPage.tsx
+++ b/ui/src/components/workbench/VaultsPage.tsx
@@ -23,6 +23,7 @@ import { VaultRequestSessionLink } from '../ui/vault-request-session-link';
import { VaultSecretDialog } from '../ui/vault-secret-dialog';
import { VaultSettingsDialog } from '../ui/vault-settings-dialog';
import { useProtectedVault } from '../../lib/useProtectedVault';
+import { openVaultAuthorizationWindow } from '../../lib/vaultSandboxClient';
import { useVaultRequestRefresh } from '../../lib/useVaultRequestRefresh';
import {
useInstanceAuthorization,
@@ -670,9 +671,11 @@ export const VaultsPage: React.FC = () => {
// Reveal a protected static value inside the sandbox frame (protocol v2 §7.4): fetch a signed
// reveal context + the sealed envelope, then let the sandbox open + display it. Plaintext never
- // returns to Avibe; the sandbox performs the in-frame confirm (and passkey when locked/Strict).
+ // returns to Avibe; the sandbox confirms in its top-level authorization window (and passkey when
+ // locked/Strict), which this click opens before any await.
const revealSecret = useCallback(
async (secret: VaultSecret) => {
+ const authorizationWindow = openVaultAuthorizationWindow();
try {
const res = await api.createVaultRevealContext(secret.name, { session_label: t('vaults.title') });
if (!res?.ok || !res.context) throw new Error(res?.message || t('vaults.reveal.errors.contextFailed'));
@@ -684,9 +687,12 @@ export const VaultsPage: React.FC = () => {
await vault.revealProtectedValue(
{ name: secret.name, kind: 'static', envelope: { ciphertext: res.envelope.ciphertext, nonce: res.envelope.nonce, wrap_meta: wrapMeta } },
res.context,
+ authorizationWindow?.id,
);
} catch (err: unknown) {
showToast(messageFromError(err), 'warning');
+ } finally {
+ authorizationWindow?.close();
}
},
[api, vault, showToast, t],
diff --git a/ui/src/lib/useProtectedVault.ts b/ui/src/lib/useProtectedVault.ts
index de8a71a34..50a88d800 100644
--- a/ui/src/lib/useProtectedVault.ts
+++ b/ui/src/lib/useProtectedVault.ts
@@ -381,10 +381,11 @@ export function useProtectedVault() {
signingContext: VaultSandboxSigningContext,
scheme: SignatureScheme,
context: VaultSignedOperationContext,
+ authorizationWindow?: string,
): Promise<SignatureResult> => {
const sandbox = await getVaultSandboxClient();
try {
- return await sandbox.sign({ material, scheme, signingContext, context });
+ return await sandbox.sign({ material, scheme, signingContext, context }, authorizationWindow);
} finally {
void syncProtectedOperationStatus(material.envelope.wrap_meta).catch(() => undefined);
}
@@ -398,11 +399,11 @@ export function useProtectedVault() {
* per-secret `releaseProtectedDelivery` loop.
*/
const approveProtectedRelease = useCallback(
- async (items: ApproveReleaseItem[]): Promise<BlindBox[]> => {
+ async (items: ApproveReleaseItem[], authorizationWindow?: string): Promise<BlindBox[]> => {
if (items.length === 0) return [];
const sandbox = await getVaultSandboxClient();
try {
- const result = await sandbox.approveRelease({ items });
+ const result = await sandbox.approveRelease({ items }, authorizationWindow);
return result.blindBoxes;
} finally {
const wrapMeta = items[0]?.material.envelope.wrap_meta;
@@ -418,10 +419,14 @@ export function useProtectedVault() {
* the parent. R2: an in-sandbox confirm while unlocked, a passkey while locked or under Strict.
*/
const revealProtectedValue = useCallback(
- async (material: ProtectedUnlockMaterial, context: VaultSignedOperationContext): Promise<{ completed: boolean }> => {
+ async (
+ material: ProtectedUnlockMaterial,
+ context: VaultSignedOperationContext,
+ authorizationWindow?: string,
+ ): Promise<{ completed: boolean }> => {
const sandbox = await getVaultSandboxClient();
try {
- return await sandbox.reveal({ material, context });
+ return await sandbox.reveal({ material, context }, authorizationWindow);
} finally {
void syncProtectedOperationStatus(material.envelope.wrap_meta).catch(() => undefined);
}
diff --git a/ui/src/lib/vaultSandboxClient.test.ts b/ui/src/lib/vaultSandboxClient.test.ts
index b0b587805..627508a8f 100644
--- a/ui/src/lib/vaultSandboxClient.test.ts
+++ b/ui/src/lib/vaultSandboxClient.test.ts
@@ -37,7 +37,7 @@ type TestVaultSandboxClient = {
request: <T>(
op: string,
payload: unknown,
- options: { timeoutMs?: number; interactive?: boolean },
+ options: { timeoutMs?: number; interactive?: boolean; authorizationWindow?: string },
) => Promise<T>;
};
@@ -137,6 +137,49 @@ describe('VaultSandboxClient interactive request surface', () => {
await expect(result).resolves.toEqual({ blindBoxes: [] });
});
+ // The approval click already opened the sandbox authorization window, so the sandbox skips its
+ // launcher card. Expanding the frame here would bring back the duplicate review surface this
+ // path removes, and dropping the window id would make the sandbox show that card again.
+ it('keeps the frame collapsed and names the authorization window the parent opened', async () => {
+ const iframe = document.createElement('iframe');
+ document.body.appendChild(iframe);
+
+ const client = Object.create(VaultSandboxClient.prototype) as TestVaultSandboxClient;
+ Object.assign(client, {
+ iframe,
+ backdrop: null,
+ pending: new Map(),
+ readyPromise: Promise.resolve({}),
+ handshaken: true,
+ modalVisible: false,
+ interactiveRequests: new Set(),
+ surfaceRefreshTimer: null,
+ });
+ const setModalVisible = vi.spyOn(client, 'setModalVisible');
+ const postMessage = vi.spyOn(iframe.contentWindow!, 'postMessage').mockImplementation(() => undefined);
+
+ const result = client.request<{ blindBoxes: unknown[] }>(
+ 'approveRelease',
+ { items: [] },
+ { interactive: true, authorizationWindow: 'window-0123456789abcdef' },
+ );
+ await vi.waitFor(() => expect(postMessage).toHaveBeenCalledTimes(1));
+
+ const [wire] = postMessage.mock.calls[0];
+ expect(wire).toMatchObject({ op: 'approveRelease', authorizationWindow: 'window-0123456789abcdef' });
+ expect(wire).not.toHaveProperty('surface');
+ expect(setModalVisible).not.toHaveBeenCalled();
+ expect(iframe.style.visibility).not.toBe('visible');
+ // A fallback launcher still gets a surface attestation once the sandbox asks for its slot.
+ const requestId = (wire as { id: string }).id;
+ expect(client.interactiveRequests.has(requestId)).toBe(true);
+ const pending = client.pending.get(requestId);
+ if (!pending) throw new Error('interactive request was not registered');
+ window.clearTimeout(pending.timer);
+ pending.resolve({ blindBoxes: [] });
+ await expect(result).resolves.toEqual({ blindBoxes: [] });
+ });
+
it('collapses the modal when interactive surface measurement fails before send', async () => {
const iframe = document.createElement('iframe');
document.body.appendChild(iframe);
diff --git a/ui/src/lib/vaultSandboxClient.ts b/ui/src/lib/vaultSandboxClient.ts
index 9b6698d1e..7849c1eb7 100644
--- a/ui/src/lib/vaultSandboxClient.ts
+++ b/ui/src/lib/vaultSandboxClient.ts
@@ -14,6 +14,7 @@ import {
VAULT_SANDBOX_PINNED_MANIFEST,
VAULT_SANDBOX_REQUIRED_RESOURCE_PATHS,
} from './vaultSandboxManifest';
+import { openLinkInNewContext } from './pwaNavigation';
import { getVaultSandboxAppearance, type VaultSandboxAppearance } from './vaultSandboxAppearance';
import { getVaultSandboxPolicy, refreshVaultSandboxPolicy, type VaultSessionPolicy } from './vaultSandboxPolicy';
import { buildVaultConfirmSurface, type VaultConfirmSurface } from './vaultConfirmSurface';
@@ -161,6 +162,41 @@ function randomId(): string {
return [...bytes].map((byte) => byte.toString(16).padStart(2, '0')).join('');
}
+export type VaultAuthorizationWindow = {
+ id: string;
+ close: () => void;
+};
+
+/**
+ * Open the top-level sandbox authorization window for one protected operation (protocol v2
+ * §6.6). Call it synchronously from the user's approval click, before any await: the window needs
+ * that gesture, and opening it here lets the sandbox skip the in-frame launcher card. Pass the id
+ * to the operation and close the handle when the operation settles. Returns null when the browser
+ * blocks the window; the sandbox then falls back to its own launcher.
+ */
+export function openVaultAuthorizationWindow(): VaultAuthorizationWindow | null {
+ const id = randomId();
+ const url = new URL(VAULT_SANDBOX_IFRAME_URL);
+ const appearance = getVaultSandboxAppearance();
+ url.searchParams.set('mode', 'authorize');
+ url.searchParams.set('id', id);
+ url.searchParams.set('locale', appearance.locale);
+ url.searchParams.set('theme', appearance.theme);
+ // No noopener: the sandbox window reaches the requesting sandbox frame through its opener.
+ const popup = openLinkInNewContext(url.toString(), 'popup,width=520,height=760');
+ if (!popup) return null;
+ return {
+ id,
+ close: () => {
+ try {
+ if (!popup.closed) popup.close();
+ } catch {
+ // The sandbox may already have closed its window.
+ }
+ },
+ };
+}
+
function base64(bytes: ArrayBuffer): string {
const raw = String.fromCharCode(...new Uint8Array(bytes));
return btoa(raw);
@@ -587,19 +623,23 @@ export class VaultSandboxClient {
private async request<T>(
op: VaultSandboxOp,
payload?: unknown,
- options: { timeoutMs?: number; interactive?: boolean } = {},
+ options: { timeoutMs?: number; interactive?: boolean; authorizationWindow?: string } = {},
): Promise<T> {
await this.readyPromise;
const id = randomId();
// Interactive ops expand the iframe before sending so the launcher card is visible before the
// request reaches the sandbox. The final authorization is completed in a top-level window;
// the optional surface evidence remains a compatibility field, never a security decision.
+ // When the caller already opened that window, the sandbox needs no launcher card, so the
+ // iframe stays collapsed until the sandbox asks for its slot with `ui.show`.
let surface: VaultConfirmSurface | null = null;
try {
if (options.interactive) {
this.interactiveRequests.add(id);
- this.setModalVisible(true);
- surface = await this.measureSurface();
+ if (!options.authorizationWindow) {
+ this.setModalVisible(true);
+ surface = await this.measureSurface();
+ }
}
} catch (error) {
this.interactiveRequests.delete(id);
@@ -620,7 +660,15 @@ export class VaultSandboxClient {
});
});
this.target.postMessage(
- { channel: CHANNEL, version: VERSION, id, op, payload: payload ?? {}, ...(surface ? { surface } : {}) },
+ {
+ channel: CHANNEL,
+ version: VERSION,
+ id,
+ op,
+ payload: payload ?? {},
+ ...(surface ? { surface } : {}),
+ ...(options.authorizationWindow ? { authorizationWindow: options.authorizationWindow } : {}),
+ },
VAULT_SANDBOX_ORIGIN,
);
return promise;
@@ -682,8 +730,15 @@ export class VaultSandboxClient {
return this.request<VaultSandboxSealResult>('seal', wire, { timeoutMs: INTERACTIVE_TIMEOUT_MS });
}
- reveal(payload: { material: ProtectedUnlockMaterialLike; context: VaultSignedOperationContext }): Promise<{ completed: boolean }> {
- return this.request<{ completed: boolean }>('reveal', payload, { timeoutMs: INTERACTIVE_TIMEOUT_MS, interactive: true });
+ reveal(
+ payload: { material: ProtectedUnlockMaterialLike; context: VaultSignedOperationContext },
+ authorizationWindow?: string,
+ ): Promise<{ completed: boolean }> {
+ return this.request<{ completed: boolean }>('reveal', payload, {
+ timeoutMs: INTERACTIVE_TIMEOUT_MS,
+ interactive: true,
+ authorizationWindow,
+ });
}
sign(payload: {
@@ -691,18 +746,19 @@ export class VaultSandboxClient {
scheme: SignatureScheme;
signingContext: VaultSandboxSigningContext;
context: VaultSignedOperationContext;
- }): Promise<SignatureResult> {
- return this.request<SignatureResult>('sign', payload, { timeoutMs: INTERACTIVE_TIMEOUT_MS, interactive: true });
+ }, authorizationWindow?: string): Promise<SignatureResult> {
+ return this.request<SignatureResult>('sign', payload, { timeoutMs: INTERACTIVE_TIMEOUT_MS, interactive: true, authorizationWindow });
}
/**
* Batch DEK release: one confirm card lists every member, then the sandbox emits one HPKE blind
* box per item (order matches `items`). Replaces v1 `releaseDEK`'s per-secret ceremony.
*/
- approveRelease(payload: { items: ApproveReleaseItem[] }): Promise<{ blindBoxes: BlindBox[] }> {
+ approveRelease(payload: { items: ApproveReleaseItem[] }, authorizationWindow?: string): Promise<{ blindBoxes: BlindBox[] }> {
return this.request<{ blindBoxes: BlindBox[] }>('approveRelease', payload, {
timeoutMs: INTERACTIVE_TIMEOUT_MS,
interactive: true,
+ authorizationWindow,
});
}