Create polished demo videos without editing skills. Mac/Windows/Linux
Validate cloud responses and reset account-specific sharing state
webadderall3c7a5fea547b
diff --git a/electron/ipc/cloudShareContract.ts b/electron/ipc/cloudShareContract.tsindex f85a28a2..00b44bd0 100644--- a/electron/ipc/cloudShareContract.ts+++ b/electron/ipc/cloudShareContract.ts@@ -98,3 +98,29 @@ export function parseCloudShareTicket(value: unknown): CloudShareTicket {finalizeUrl,};}++/** Validates untrusted library JSON before presenting recording metadata to the renderer. */+export function parseCloudRecordingList(data: unknown, endpoint: string) {+ if (!data || typeof data !== "object" || !("videos" in data) || !Array.isArray(data.videos))+ throw new Error("Invalid recordings response.");+ return data.videos.slice(0, 100).map((raw: unknown) => {+ if (!raw || typeof raw !== "object" || Array.isArray(raw))+ throw new Error("Invalid recording response.");+ const video = raw as Record<string, unknown>;+ if (+ typeof video.share_code !== "string" ||+ !/^[a-z0-9]{1,128}$/.test(video.share_code) ||+ typeof video.title !== "string"+ )+ throw new Error("Invalid recording response.");+ const size = Number(video.file_size);+ return {+ code: video.share_code,+ title: video.title,+ size: Number.isFinite(size) && size >= 0 ? size : 0,+ createdAt: typeof video.created_at === "string" ? video.created_at : undefined,+ ready: video.upload_completed === 1,+ url: new URL(`/s/${video.share_code}`, endpoint).href,+ };+ });+}diff --git a/electron/ipc/register/cloudShare.test.ts b/electron/ipc/register/cloudShare.test.tsindex a874b151..394e6685 100644--- a/electron/ipc/register/cloudShare.test.ts+++ b/electron/ipc/register/cloudShare.test.ts@@ -1,5 +1,9 @@import { describe, expect, it } from "vitest";-import { normalizeCloudEndpoint, parseCloudShareTicket } from "../cloudShareContract";+import {+ normalizeCloudEndpoint,+ parseCloudShareTicket,+ parseCloudRecordingList,+} from "../cloudShareContract";describe("cloud share contract", () => {it("accepts only Recordly production and local development endpoints", () => {@@ -29,13 +33,11 @@ describe("cloud share contract", () => {});it("rejects insecure and untrusted remote endpoints", () => {+ expect(() => normalizeCloudEndpoint("https://untrusted.example.test/api/upload")).toThrow(+ "only allowed through the Recordly service",+ );expect(() =>- normalizeCloudEndpoint("https://untrusted.example.test/api/upload"),- ).toThrow("only allowed through the Recordly service");- expect(() =>- normalizeCloudEndpoint(- "https://videos.recordly.dev.attacker.example/api/upload",- ),+ normalizeCloudEndpoint("https://videos.recordly.dev.attacker.example/api/upload"),).toThrow("only allowed through the Recordly service");expect(() => normalizeCloudEndpoint("http://share.example.com/api/shares")).toThrow("only allowed through the Recordly service",@@ -98,3 +100,57 @@ describe("cloud share contract", () => {).toThrow("uploadUrl must use HTTPS");});});++describe("cloud recording library responses", () => {+ it.each([+ null,+ false,+ "invalid",+ [],+ {},+ { videos: null },+ ])("rejects malformed lists (%j)", (data) => {+ expect(() =>+ parseCloudRecordingList(data, "https://videos.recordly.dev/api/upload"),+ ).toThrow("Invalid recordings response.");+ });+ it.each([+ null,+ false,+ "invalid",+ [],+ {},+ { share_code: "abc", title: 1 },+ ])("rejects malformed rows (%j)", (row) => {+ expect(() =>+ parseCloudRecordingList({ videos: [row] }, "https://videos.recordly.dev/api/upload"),+ ).toThrow("Invalid recording response.");+ });+ it("uses the validated endpoint for links and normalizes readiness and size", () => {+ expect(+ parseCloudRecordingList(+ {+ videos: [+ {+ share_code: "abc123",+ title: "Fixture",+ file_size: 8,+ upload_completed: 1,+ created_at: "2026-01-01",+ },+ ],+ },+ "https://videos.recordly.dev/api/upload",+ ),+ ).toEqual([+ {+ code: "abc123",+ title: "Fixture",+ size: 8,+ ready: true,+ createdAt: "2026-01-01",+ url: "https://videos.recordly.dev/s/abc123",+ },+ ]);+ });+});diff --git a/electron/ipc/register/cloudShare.ts b/electron/ipc/register/cloudShare.tsindex 32c13471..cb9ed7ea 100644--- a/electron/ipc/register/cloudShare.ts+++ b/electron/ipc/register/cloudShare.ts@@ -4,7 +4,11 @@ import fs from "node:fs/promises";import path from "node:path";import { Transform } from "node:stream";import { ipcMain } from "electron";-import { normalizeCloudEndpoint, parseCloudShareTicket } from "../cloudShareContract";+import {+ normalizeCloudEndpoint,+ parseCloudRecordingList,+ parseCloudShareTicket,+} from "../cloudShareContract";import { isOwnedExportPath } from "../export/exportStream";import { isAllowedLocalReadPath } from "../project/manager";@@ -289,27 +293,9 @@ export function registerCloudShareHandlers() {await responseError(response, "Could not manage shared recordings"),);if (input.action === "delete") return { success: true };- const data = (await readJsonResponse(response)) as { videos?: unknown };- if (!Array.isArray(data.videos)) throw new Error("Invalid recordings response.");return {success: true,- videos: data.videos.slice(0, 100).map((video: Record<string, unknown>) => {- if (- typeof video.share_code !== "string" ||- !/^[a-z0-9]{1,128}$/.test(video.share_code) ||- typeof video.title !== "string"- )- throw new Error("Invalid recording response.");- return {- code: video.share_code,- title: video.title,- size: Number(video.file_size) || 0,- createdAt:- typeof video.created_at === "string" ? video.created_at : undefined,- ready: video.upload_completed === 1,- url: new URL(`/s/${video.share_code}`, endpoint).href,- };- }),+ videos: parseCloudRecordingList(await readJsonResponse(response), endpoint),};} catch (error) {return {diff --git a/src/components/video-editor/cloud/CloudShareButton.tsx b/src/components/video-editor/cloud/CloudShareButton.tsxindex c44f1d1b..cfc3fb4c 100644--- a/src/components/video-editor/cloud/CloudShareButton.tsx+++ b/src/components/video-editor/cloud/CloudShareButton.tsx@@ -65,6 +65,11 @@ export function CloudShareButton({const [capacityAvailable, setCapacityAvailable] = useState<boolean | null>(null);const [checkingCapacity, setCheckingCapacity] = useState(false);useEffect(() => {+ setCapacityAvailable(null);+ setCheckingCapacity(false);+ setError(undefined);+ setShareUrl(undefined);+ setCopied(false);if (!authToken || !DEFAULT_CLOUD_ENDPOINT) return;let active = true;setCheckingCapacity(true);diff --git a/src/components/video-editor/cloud/SharedRecordings.tsx b/src/components/video-editor/cloud/SharedRecordings.tsxindex 27d1e1e8..b72ee76d 100644--- a/src/components/video-editor/cloud/SharedRecordings.tsx+++ b/src/components/video-editor/cloud/SharedRecordings.tsx@@ -1,3 +1,4 @@+import { FREE_RECORDING_LIMIT } from "./shareCapacity";import { LibrarySkeleton } from "../dashboard/LibrarySkeleton";import { ProjectCard } from "../dashboard/ProjectCard";import { DashboardToolbar } from "../dashboard/DashboardToolbar";@@ -65,9 +66,12 @@ export function SharedRecordings({// biome-ignore lint/correctness/useExhaustiveDependencies: A new share URL must refresh this library.useEffect(() => {if (expanded) void load();- return () => { loadGeneration.current += 1; };+ return () => {+ loadGeneration.current += 1;+ };}, [expanded, load, refreshKey]);const remove = async (code: string) => {+ if (!window.confirm("Delete this shared recording? This cannot be undone.")) return;setDeleting(code);setError(undefined);try {@@ -131,6 +135,7 @@ export function SharedRecordings({run={run}busy={loading || Boolean(deleting)}actionLabel="Refresh"+ action="refresh"/><DashboardFiltershideSelection@@ -214,18 +219,14 @@ export function SharedRecordings({return (<section className="space-y-3 border-b border-foreground/10 pb-4"><div className="flex items-center justify-between gap-2">- {standalone ? (- <h2 className="text-lg font-semibold">Shared recordings</h2>- ) : (- <Button- variant="ghost"- size="sm"- onPress={() => setExpanded((value) => !value)}- aria-expanded={expanded}- >- {expanded ? "Hide shared recordings" : "Manage shared recordings"}- </Button>- )}+ <Button+ variant="ghost"+ size="sm"+ onPress={() => setExpanded((value) => !value)}+ aria-expanded={expanded}+ >+ {expanded ? "Hide shared recordings" : "Manage shared recordings"}+ </Button>{expanded && (<Buttonvariant="ghost"@@ -244,16 +245,12 @@ export function SharedRecordings({<p className="text-xs text-muted">{loading? "Loading recordings…"- : `${recordings.length} of 5 recordings · 1 GB each · Free links expire after 14 days`}+ : `${recordings.length} of ${FREE_RECORDING_LIMIT} recordings · 1 GB each · Free links expire after 14 days`}</p>{loading ? (<LibrarySkeleton />) : (- <ul- className={- standalone ? "space-y-2" : "max-h-64 space-y-2 overflow-y-auto"- }- >+ <ul className="max-h-64 space-y-2 overflow-y-auto">{recordings.map((recording) => (<likey={recording.code}diff --git a/src/components/video-editor/dashboard/DashboardToolbar.tsx b/src/components/video-editor/dashboard/DashboardToolbar.tsxindex d7d13c2a..78e4e8d6 100644--- a/src/components/video-editor/dashboard/DashboardToolbar.tsx+++ b/src/components/video-editor/dashboard/DashboardToolbar.tsx@@ -16,10 +16,11 @@ export function DashboardToolbar({run,busy,actionLabel = "Import",+ action = "import",}: Pick<DashboardProps & DashboardModel,"onImportFile" | "query" | "setQuery" | "run" | "busy" | "isRaw"-> & { actionLabel?: string }) {+> & { actionLabel?: string; action?: "import" | "refresh" }) {return (<><header@@ -46,7 +47,7 @@ export function DashboardToolbar({onClick={() => void run(onImportFile)}className="h-10 shrink-0 gap-2 text-[13px]">- {actionLabel === "Refresh" ? (+ {action === "refresh" ? (<ArrowClockwise className="size-4" />) : (<UploadSimple className="size-4" />diff --git a/tests/ui/publish-cloud.spec.ts b/tests/ui/publish-cloud.spec.tsindex 8883e42c..1cf7dea3 100644--- a/tests/ui/publish-cloud.spec.ts+++ b/tests/ui/publish-cloud.spec.ts@@ -7,20 +7,32 @@ test("publish preserves local destination and stays open throughout sharing", asawait expect(page.getByRole("button", { name: "Export Video", exact: true })).toBeVisible();await page.reload();await page.getByRole("button", { name: "Publish", exact: true }).click();- await expect(page.getByRole("row", { name: "Local", exact: true })).toHaveAttribute("aria-selected", "true");+ await expect(page.getByRole("row", { name: "Local", exact: true })).toHaveAttribute(+ "aria-selected",+ "true",+ );await page.getByRole("row", { name: "Link", exact: true }).click();await page.getByRole("button", { name: "Share", exact: true }).click();await expect(page.getByText(/Uploading ·/)).toBeVisible();await page.keyboard.press("Escape");await expect(page.getByText(/Uploading ·/)).toBeVisible();- await expect(page.getByRole("row", { name: "Local", exact: true })).toHaveAttribute("aria-disabled", "true");- await expect(page.getByRole("button", { name: "Copy link", exact: true })).toBeVisible({ timeout: 20000 });+ await expect(page.getByRole("row", { name: "Local", exact: true })).toHaveAttribute(+ "aria-disabled",+ "true",+ );+ await expect(page.getByRole("button", { name: "Copy link", exact: true })).toBeVisible({+ timeout: 20000,+ });});test("a full cloud quota prevents starting preparation", async ({ page }) => {await page.goto("/tests/ui/publish.html?full");await page.getByRole("button", { name: "Publish", exact: true }).click();- await expect(page.getByText("You have 5 cloud recordings. Delete one from Shared before sharing another.")).toBeVisible();+ await expect(+ page.getByText(+ "You have 5 cloud recordings. Delete one from Shared before sharing another.",+ ),+ ).toBeVisible();await expect(page.getByRole("button", { name: "Share", exact: true })).toBeDisabled();});@@ -28,10 +40,47 @@ test("shared cards open ready links and delete incomplete uploads", async ({ pagawait page.goto("/tests/ui/shared-recordings.html");await page.getByRole("button", { name: "Product walkthrough", exact: true }).click();await expect(page.getByRole("status")).toHaveText("Opened https://example.test/s/demo1");- await expect(page.getByRole("button", { name: "An interrupted upload", exact: true })).toBeDisabled();- await page.getByRole("button", { name: "Options for An interrupted upload", exact: true }).click();+ await expect(+ page.getByRole("button", { name: "An interrupted upload", exact: true }),+ ).toBeDisabled();+ await page+ .getByRole("button", { name: "Options for An interrupted upload", exact: true })+ .click();+ page.once("dialog", (dialog) => dialog.dismiss());await page.getByRole("menuitem", { name: "Delete recording", exact: true }).click();- await expect(page.getByRole("button", { name: "An interrupted upload", exact: true })).toHaveCount(0);+ await expect(+ page.getByRole("button", { name: "An interrupted upload", exact: true }),+ ).toHaveCount(1);+ await page+ .getByRole("button", { name: "Options for An interrupted upload", exact: true })+ .click();+ page.once("dialog", (dialog) => dialog.accept());+ await page.getByRole("menuitem", { name: "Delete recording", exact: true }).click();+ await expect(+ page.getByRole("button", { name: "An interrupted upload", exact: true }),+ ).toHaveCount(0);await page.getByRole("textbox", { name: "Search projects" }).fill("missing");await expect(page.getByText("No matching projects", { exact: true })).toBeVisible();});++test("switching accounts clears the previous account's cloud quota", async ({ page }) => {+ await page.goto("/tests/ui/publish.html?full&switch");+ await page.getByRole("button", { name: "Publish", exact: true }).click();+ await expect(+ page.getByText(+ "You have 5 cloud recordings. Delete one from Shared before sharing another.",+ ),+ ).toBeVisible();+ await page+ .getByRole("button", { name: "Fixture sign out", exact: true })+ .evaluate((button: HTMLButtonElement) => button.click());+ await expect(+ page.getByText(+ "You have 5 cloud recordings. Delete one from Shared before sharing another.",+ ),+ ).toHaveCount(0);+ await page+ .getByRole("button", { name: "Fixture switch account", exact: true })+ .evaluate((button: HTMLButtonElement) => button.click());+ await expect(page.getByRole("button", { name: "Share", exact: true })).toBeEnabled();+});diff --git a/tests/ui/publish.tsx b/tests/ui/publish.tsxindex 35d34c2e..b11a843d 100644--- a/tests/ui/publish.tsx+++ b/tests/ui/publish.tsx@@ -10,11 +10,12 @@ let reportUpload:| ((event: { uploadId: string; uploadedBytes: number; totalBytes: number }) => void)| undefined;window.electronAPI = {- cloudShareManage: async () => ({+ cloudShareManage: async ({ token }: { token: string }) => ({success: true,- videos: new URLSearchParams(location.search).has("full")- ? Array(5).fill({ ready: true })- : [],+ videos:+ token === "fixture" && new URLSearchParams(location.search).has("full")+ ? Array(5).fill({ ready: true })+ : [],}),onCloudShareProgress: (callback: typeof reportUpload) => {reportUpload = callback;@@ -33,6 +34,7 @@ window.electronAPI = {} as unknown as typeof window.electronAPI;function Preview() {const [open, setOpen] = useState(false);+ const [authToken, setAuthToken] = useState<string | undefined>("fixture");const [percentage, setPercentage] = useState(0);const { t } = useI18n();const [preferences] = useState(loadEditorPreferences);@@ -40,7 +42,7 @@ function Preview() {const props = {t,projectTitle: "Preview",- authToken: "fixture",+ authToken,shareRequestNonce: 0,exportSettings,exportSession: {@@ -66,6 +68,16 @@ function Preview() {} as unknown as ComponentProps<typeof EditorExportMenu>;return (<div className="flex justify-end p-12">+ {new URLSearchParams(location.search).has("switch") && (+ <div>+ <button type="button" onClick={() => setAuthToken(undefined)}>+ Fixture sign out+ </button>+ <button type="button" onClick={() => setAuthToken("other")}>+ Fixture switch account+ </button>+ </div>+ )}<EditorExportMenu {...props} /></div>);