Skip to content
Merged
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: 5 additions & 2 deletions packages/frontend/src/app/connectors/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import { WebhookCard } from '@/components/webhook-card';
import { FilesPanel } from '@/components/file-search/files-panel';
import Link from 'next/link';
import { sessionStore } from '@/lib/storage';
import {
EMPTY_EMAIL_FORM,
EmailSettingsFields,
Expand Down Expand Up @@ -597,9 +598,11 @@
// The new-connector form moved a secret typed into the URL or a header
// into a variable; say so the first time the connector is opened.
const noticeKey = `amcp:secretsNotice:${id}`;
const notice = typeof window !== 'undefined' ? window.sessionStorage.getItem(noticeKey) : null;
// sessionStore, not window.sessionStorage: Safari throws SecurityError
// when storage is blocked, and that broke the whole page.
const notice = sessionStore.get(noticeKey);
if (notice) {
window.sessionStorage.removeItem(noticeKey);
sessionStore.remove(noticeKey);
setMsg(notice);
}
}, [id]);
Expand Down Expand Up @@ -628,7 +631,7 @@
}

fetchConnector();
}, [token, id]);

Check warning on line 634 in packages/frontend/src/app/connectors/[id]/page.tsx

View workflow job for this annotation

GitHub Actions / Frontend (lint, typecheck, build)

React Hook useEffect has missing dependencies: 'fetchConnector', 'searchParams', and 't'. Either include them or remove the dependency array

/** Fill the Login → Token fields from a snapshot and remember it. */
const applyLoginTokenSnapshot = (snap: LoginTokenFormSnapshot) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/app/connectors/new/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { HeadersEditor, headerRowsToObject, type HeaderRow } from '@/components/
import { isTrialLimitMessage, TrialLimitNotice } from '@/lib/trial-limit';
import { cn } from '@/lib/utils';
import { missingLoginCredential, tokenPathFromInput } from '@/lib/login-token-form';
import { sessionStore } from '@/lib/storage';
import {
EMPTY_EMAIL_FORM,
EmailSettingsFields,
Expand Down Expand Up @@ -294,7 +295,7 @@ export default function NewConnectorPage() {
const created = await connectors.create(data, token);
// Shown on the connector's page: this form navigates away right after.
if (created.secretsNotice) {
window.sessionStorage.setItem(`amcp:secretsNotice:${created.id}`, created.secretsNotice);
sessionStore.set(`amcp:secretsNotice:${created.id}`, created.secretsNotice);
}

if (specUrl && (selectedType === 'REST' || selectedType === 'SOAP' || selectedType === 'GRAPHQL')) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { expect, test } from '@playwright/test';

/**
* Safari throws `SecurityError: The operation is insecure` on any access to
* `window.sessionStorage` when the browser blocks site storage. The connector
* page read a one-time notice from sessionStorage on mount, so the error took
* the whole page down (Sentry CLOUD-FRONTEND-12). It must render anyway.
*/

const USER = {
id: 'u1',
email: 'test@example.com',
name: 'Test User',
role: 'ADMIN',
organizationId: 'o1',
emailVerified: true,
};

const CONNECTOR = {
id: 'c1',
name: 'Storage Blocked Connector',
type: 'REST',
baseUrl: 'https://api.example.com',
authType: 'NONE',
authConfig: null,
isActive: true,
headers: {},
envVars: { API_REGION: 'eu' },
maskedEnvVars: [],
config: {},
tools: [],
createdAt: '2026-09-01T00:00:00Z',
userId: 'u1',
organizationId: 'o1',
};

test('connector page renders when sessionStorage throws SecurityError', async ({ page, baseURL }) => {
const pageErrors: string[] = [];
page.on('pageerror', (err) => pageErrors.push(err.message));

await page.context().addCookies([{ name: 'amcp_token', value: 'test-token', url: baseURL! }]);
await page.addInitScript((user) => {
localStorage.setItem('amcp_token', 'test-token');
localStorage.setItem('amcp_user', JSON.stringify(user));
Object.defineProperty(window, 'sessionStorage', {
configurable: true,
get() {
throw new DOMException('The operation is insecure.', 'SecurityError');
},
});
}, USER);

await page.route(/\/api\//, async (route) => {
const url = route.request().url();
const json = (body: unknown) =>
route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(body) });
if (url.includes('/api/connectors/proxy-availability')) return json({ available: false });
if (url.includes('/api/connectors/c1/catalog-diff')) return json({ catalogManaged: false });
if (url.includes('/api/connectors/c1')) return json(CONNECTOR);
if (url.includes('/api/users/me/onboarding-state')) return json({ onboardingCompletedAt: '2026-01-01T00:00:00Z' });
if (url.includes('/api/users/me')) return json(USER);
if (url.includes('/api/organizations/current')) return json({ id: 'o1', name: 'Acme', createdAt: '2026-01-01' });
if (url.includes('/api/organizations/mine')) return json([{ id: 'o1', name: 'Acme', role: 'ADMIN', joinedAt: '2026-01-01' }]);
if (url.includes('/api/license/status')) return json({ plan: 'community', status: 'active' });
if (url.includes('/api/connectors')) return json([CONNECTOR]);
return json({});
});

await page.goto('/connectors/c1');

await expect(page.getByRole('button', { name: 'Edit (1)' })).toBeVisible();
expect(pageErrors.filter((m) => m.includes('insecure'))).toEqual([]);
});
Loading