diff --git a/dembrane/frontend/src/lib/api.ts b/dembrane/frontend/src/lib/api.ts index d30e574a5..84841cb25 100644 --- a/dembrane/frontend/src/lib/api.ts +++ b/dembrane/frontend/src/lib/api.ts @@ -2,12 +2,26 @@ import { i18n } from "@lingui/core"; import { t } from "@lingui/core/macro"; -import axios, { type AxiosError, type CreateAxiosDefaults } from "axios"; +import axios, { + type AxiosError, + type CreateAxiosDefaults, + type InternalAxiosRequestConfig, +} from "axios"; import { toast } from "@/components/common/Toaster"; import { VOICE_TRANSCRIBE_TIMEOUT_MS } from "@/components/voice/voiceInput"; import { API_BASE_URL } from "@/config"; import { bff } from "./bff"; import { loadErrorMessages } from "./errors/present"; +import { + clearParticipantToken, + clearParticipantTokenValue, + isParticipantTokenRejection, + PARTICIPANT_TOKEN_HEADER, + participantTokenConfig, + participantTokenHeaders, + readResponseHeader, + setParticipantToken, +} from "./participantToken"; export const apiCommonConfig: CreateAxiosDefaults = { baseURL: API_BASE_URL, @@ -17,8 +31,44 @@ export const apiCommonConfig: CreateAxiosDefaults = { export const apiNoAuth = axios.create(apiCommonConfig); apiNoAuth.interceptors.response.use( - (response) => response.data, + (response) => { + const token = readResponseHeader( + response.headers, + PARTICIPANT_TOKEN_HEADER, + ); + const conversationId = + response.data && + typeof response.data === "object" && + "id" in response.data && + typeof (response.data as { id?: unknown }).id === "string" + ? (response.data as { id: string }).id + : null; + if (token && conversationId) { + setParticipantToken(conversationId, token); + } + return response.data; + }, (error) => { + const config = (error as AxiosError)?.config as + | (InternalAxiosRequestConfig & { tokenRetried?: boolean }) + | undefined; + const sentToken = readResponseHeader( + config?.headers, + PARTICIPANT_TOKEN_HEADER, + ); + if (sentToken && isParticipantTokenRejection(error)) { + clearParticipantTokenValue(sentToken); + // The server checks the token before it does anything, so the rejected call did + // nothing: once more without it keeps a recording's chunk instead of losing it. + if (config && !config.tokenRetried) { + console.warn( + `[participant token] rejected on ${config.method?.toUpperCase()} ${config.url}; retrying without it`, + ); + config.headers.delete(PARTICIPANT_TOKEN_HEADER); + const retry: typeof config = { ...config, tokenRetried: true }; + return apiNoAuth.request(retry); + } + } // Start loading the error messages now, so the screen that shows this error has // them by the time it renders (see lib/errors/present.ts). void loadErrorMessages(i18n); @@ -40,6 +90,7 @@ export const getParticipantConversationById = async ( ) => { return apiNoAuth.get( `/participant/projects/${projectId}/conversations/${conversationId}`, + participantTokenConfig(conversationId), ); }; @@ -49,6 +100,7 @@ export const getParticipantConversationChunks = async ( ) => { return apiNoAuth.get( `participant/projects/${projectId}/conversations/${conversationId}/chunks`, + participantTokenConfig(conversationId), ); }; @@ -63,6 +115,7 @@ export const getParticipantConversationReplies = async ( ) => { return apiNoAuth.get( `/participant/projects/${projectId}/conversations/${conversationId}/replies`, + participantTokenConfig(conversationId), ); }; @@ -73,6 +126,7 @@ export const deleteParticipantConversationChunk = async ( ) => { return apiNoAuth.delete( `/participant/projects/${projectId}/conversations/${conversationId}/chunks/${chunkId}`, + participantTokenConfig(conversationId), ); }; @@ -278,6 +332,8 @@ export const checkS3Connectivity = async ( try { const { probe_url } = await apiNoAuth.post( `/participant/conversations/${conversationId}/check-s3`, + undefined, + participantTokenConfig(conversationId), ); await fetch(probe_url, { @@ -379,7 +435,7 @@ export const pingConversation = async ( await apiNoAuth.post( `/participant/conversations/${conversationId}/ping`, telemetry ?? undefined, - { timeout: PING_TIMEOUT_MS }, + { timeout: PING_TIMEOUT_MS, ...participantTokenConfig(conversationId) }, ); return true; } catch { @@ -412,7 +468,10 @@ export const pingConversationLeft = ( state: "left", }), credentials: "include", - headers: { "Content-Type": "application/json" }, + headers: { + "Content-Type": "application/json", + ...participantTokenHeaders(conversationId), + }, keepalive: true, method: "POST", }, @@ -469,11 +528,15 @@ export const uploadConversationChunkWithPresignedUrl = async (payload: { fields: Record; file_url: string; } - >(`/participant/conversations/${payload.conversationId}/get-upload-url`, { - content_type: payload.chunk.type, - conversation_id: payload.conversationId, - filename: fileName, - }); + >( + `/participant/conversations/${payload.conversationId}/get-upload-url`, + { + content_type: payload.chunk.type, + conversation_id: payload.conversationId, + filename: fileName, + }, + participantTokenConfig(payload.conversationId), + ); } catch (error) { console.error("[Upload] Failed to get presigned URL:", error); if (axios.isAxiosError(error)) { @@ -584,6 +647,7 @@ export const confirmConversationChunkUpload = async (payload: { source: payload.source, timestamp: payload.timestamp, }, + participantTokenConfig(payload.conversationId), ); // Report 100% after successful confirmation @@ -608,6 +672,7 @@ export const uploadConversationText = async (payload: { source: payload.source, timestamp: payload.timestamp.toISOString(), }, + participantTokenConfig(payload.conversationId), ); }; @@ -782,6 +847,8 @@ export const initiateAndUploadConversationChunk = async (payload: { `[Upload] Failed to finish conversation ${conversationId}:`, error, ); + } finally { + clearParticipantToken(conversationId); } }), ); @@ -1530,6 +1597,8 @@ export const getProjectParticipantCount = async (projectId: string) => { export const finishConversation = async (conversationId: string) => { return apiNoAuth.post( `/participant/conversations/${conversationId}/finish`, + undefined, + participantTokenConfig(conversationId), ); }; @@ -1537,7 +1606,11 @@ export const generateConversationSummary = async (conversationId: string) => { return apiNoAuth.post< unknown, { status: string; summary: string } | { status: string; message: string } - >(`/conversations/${conversationId}/summarize`); + >( + `/conversations/${conversationId}/summarize`, + undefined, + participantTokenConfig(conversationId), + ); }; export const generateConversationTitle = async (conversationId: string) => { @@ -1652,6 +1725,7 @@ export const generateVerificationArtefact = async (payload: { topic_list: payload.topicList, }, { + ...participantTokenConfig(payload.conversationId), signal: payload.signal, }, ); @@ -1661,6 +1735,7 @@ export const generateVerificationArtefact = async (payload: { export type UpdateVerificationArtefactPayload = { artifactId: string; + conversationId: string; useConversation?: { conversationId: string; timestamp: string; @@ -1671,6 +1746,7 @@ export type UpdateVerificationArtefactPayload = { export const updateVerificationArtefact = async ({ artifactId, + conversationId, useConversation, content, approvedAt, @@ -1687,6 +1763,7 @@ export const updateVerificationArtefact = async ({ } : undefined, }, + participantTokenConfig(conversationId), ); return response; }; @@ -1694,12 +1771,17 @@ export const updateVerificationArtefact = async ({ export const getVerificationArtefacts = async (conversationId: string) => { return apiNoAuth.get( `/verify/artifacts/${conversationId}`, + participantTokenConfig(conversationId), ); }; -export const getVerificationArtefactById = async (artifactId: string) => { +export const getVerificationArtefactById = async ( + artifactId: string, + conversationId: string, +) => { return apiNoAuth.get( `/verify/artifact/${artifactId}`, + participantTokenConfig(conversationId), ); }; @@ -1721,11 +1803,15 @@ export const submitNotificationParticipant = async ( conversationId: string, ) => { try { - const response = await apiNoAuth.post("/participant/report/subscribe", { - conversation_id: conversationId, - emails, - project_id: projectId, - }); + const response = await apiNoAuth.post( + "/participant/report/subscribe", + { + conversation_id: conversationId, + emails, + project_id: projectId, + }, + participantTokenConfig(conversationId), + ); return response; } catch (_error) { throw new Error("Failed to subscribe to notifications"); diff --git a/dembrane/frontend/src/lib/participantToken.test.ts b/dembrane/frontend/src/lib/participantToken.test.ts new file mode 100644 index 000000000..58402b494 --- /dev/null +++ b/dembrane/frontend/src/lib/participantToken.test.ts @@ -0,0 +1,423 @@ +// @vitest-environment jsdom +import axios, { type AxiosAdapter, AxiosError } from "axios"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { + apiNoAuth, + checkS3Connectivity, + confirmConversationChunkUpload, + deleteParticipantConversationChunk, + finishConversation, + generateConversationSummary, + generateVerificationArtefact, + getParticipantConversationById, + getParticipantConversationChunks, + getParticipantConversationReplies, + getParticipantProjectById, + getVerificationArtefactById, + getVerificationArtefacts, + initiateConversation, + pingConversation, + pingConversationLeft, + submitNotificationParticipant, + updateVerificationArtefact, + uploadConversationChunkWithPresignedUrl, + uploadConversationText, +} from "./api"; +import { + clearAllParticipantTokens, + clearParticipantToken, + getParticipantToken, + PARTICIPANT_TOKEN_HEADER, + participantTokenKey, + setParticipantToken, +} from "./participantToken"; + +vi.mock("@/components/common/Toaster", () => ({ + toast: Object.assign(vi.fn(), { error: vi.fn(), success: vi.fn() }), +})); + +const originalAdapter = apiNoAuth.defaults.adapter; + +beforeEach(() => { + sessionStorage.clear(); + localStorage.clear(); + clearAllParticipantTokens(); +}); + +afterEach(() => { + apiNoAuth.defaults.adapter = originalAdapter; + sessionStorage.clear(); + localStorage.clear(); + clearAllParticipantTokens(); + vi.restoreAllMocks(); +}); + +describe("participantToken storage", () => { + it("stores and reads tokens in sessionStorage under portal:token:", () => { + setParticipantToken("conv-1", "p1.body.sig"); + expect(sessionStorage.getItem("portal:token:conv-1")).toBe("p1.body.sig"); + expect(localStorage.getItem("portal:token:conv-1")).toBeNull(); + expect(getParticipantToken("conv-1")).toBe("p1.body.sig"); + + clearParticipantToken("conv-1"); + expect(sessionStorage.getItem("portal:token:conv-1")).toBeNull(); + expect(getParticipantToken("conv-1")).toBeNull(); + }); + + it("clears only participant token keys on clearAllParticipantTokens", () => { + sessionStorage.setItem("unrelated-key", "keep"); + setParticipantToken("conv-1", "p1.one.sig"); + setParticipantToken("conv-2", "p1.two.sig"); + + clearAllParticipantTokens(); + + expect(getParticipantToken("conv-1")).toBeNull(); + expect(getParticipantToken("conv-2")).toBeNull(); + expect(sessionStorage.getItem("unrelated-key")).toBe("keep"); + }); + + it("falls back to in-memory storage when sessionStorage throws in private browsing", () => { + vi.spyOn(Storage.prototype, "setItem").mockImplementation(() => { + throw new DOMException("QuotaExceededError"); + }); + vi.spyOn(Storage.prototype, "getItem").mockImplementation(() => { + throw new DOMException("SecurityError"); + }); + + setParticipantToken("conv-private", "p1.private.sig"); + expect(getParticipantToken("conv-private")).toBe("p1.private.sig"); + expect(getParticipantToken("conv-other")).toBeNull(); + }); +}); + +describe("apiNoAuth participant token plumbing", () => { + it("stores X-Participant-Token from initiate and attaches it to subsequent participant requests", async () => { + const seenHeaders = new Map(); + + const adapter = vi.fn(async (config) => { + const method = (config.method ?? "get").toUpperCase(); + const key = `${method} ${config.url}`; + seenHeaders.set( + key, + config.headers.get(PARTICIPANT_TOKEN_HEADER)?.toString(), + ); + + if (config.url === "/participant/projects/p-1/conversations/initiate") { + return { + config, + data: { id: "c-1", project_id: "p-1" }, + headers: { "x-participant-token": "p1.c1.sig" }, + status: 200, + statusText: "OK", + }; + } + if (config.url === "/participant/conversations/c-1/get-upload-url") { + return { + config, + data: { + chunk_id: "chunk-1", + fields: {}, + file_url: "https://storage.example/chunk-1.webm", + upload_url: "https://storage.example/upload", + }, + headers: {}, + status: 200, + statusText: "OK", + }; + } + if (config.url === "/participant/conversations/c-1/check-s3") { + return { + config, + data: { probe_url: "https://storage.example/probe" }, + headers: {}, + status: 200, + statusText: "OK", + }; + } + if (config.url === "/verify/generate") { + return { + config, + data: { artifact_list: [] }, + headers: {}, + status: 200, + statusText: "OK", + }; + } + return { + config, + data: {}, + headers: {}, + status: 200, + statusText: "OK", + }; + }); + apiNoAuth.defaults.adapter = adapter; + + vi.spyOn(axios, "post").mockResolvedValue({}); + const fetchSpy = vi + .spyOn(globalThis, "fetch") + .mockResolvedValue(new Response(null, { status: 200 })); + vi.spyOn(console, "log").mockImplementation(() => {}); + + const conversation = await initiateConversation({ + name: "Alex", + pin: "1234", + projectId: "p-1", + source: "PORTAL_AUDIO", + tagIdList: [], + }); + expect(conversation.id).toBe("c-1"); + expect(sessionStorage.getItem(participantTokenKey("c-1"))).toBe( + "p1.c1.sig", + ); + expect(localStorage.getItem(participantTokenKey("c-1"))).toBeNull(); + expect( + seenHeaders.get("POST /participant/projects/p-1/conversations/initiate"), + ).toBeUndefined(); + + const upload = await uploadConversationChunkWithPresignedUrl({ + chunk: new File(["audio"], "part1.webm", { type: "audio/webm" }), + conversationId: "c-1", + source: "PORTAL_AUDIO", + timestamp: new Date("2026-11-30T10:00:00Z"), + }); + await confirmConversationChunkUpload(upload); + await uploadConversationText({ + content: "Typed note", + conversationId: "c-1", + source: "PORTAL_TEXT", + timestamp: new Date("2026-11-30T10:01:00Z"), + }); + await finishConversation("c-1"); + await generateConversationSummary("c-1"); + await getParticipantConversationById("p-1", "c-1"); + await getParticipantConversationChunks("p-1", "c-1"); + await getParticipantConversationReplies("p-1", "c-1"); + await deleteParticipantConversationChunk("p-1", "c-1", "chunk-1"); + await checkS3Connectivity("c-1"); + await pingConversation("c-1", { state: "recording" }); + pingConversationLeft("c-1", "p-1"); + await submitNotificationParticipant(["a@example.com"], "p-1", "c-1"); + await generateVerificationArtefact({ + conversationId: "c-1", + topicList: ["summary"], + }); + await getVerificationArtefacts("c-1"); + await getVerificationArtefactById("art-1", "c-1"); + await updateVerificationArtefact({ + approvedAt: "2026-11-30T10:05:00Z", + artifactId: "art-1", + content: "Approved summary", + conversationId: "c-1", + }); + await getParticipantProjectById("p-1"); + await finishConversation("c-other"); + + const expectedWithToken = [ + "POST /participant/conversations/c-1/get-upload-url", + "POST /participant/conversations/c-1/confirm-upload", + "POST /participant/conversations/c-1/upload-text", + "POST /participant/conversations/c-1/finish", + "POST /conversations/c-1/summarize", + "GET /participant/projects/p-1/conversations/c-1", + "GET participant/projects/p-1/conversations/c-1/chunks", + "GET /participant/projects/p-1/conversations/c-1/replies", + "DELETE /participant/projects/p-1/conversations/c-1/chunks/chunk-1", + "POST /participant/conversations/c-1/check-s3", + "POST /participant/conversations/c-1/ping", + "POST /participant/report/subscribe", + "POST /verify/generate", + "GET /verify/artifacts/c-1", + "GET /verify/artifact/art-1", + "PUT /verify/artifact/art-1", + ]; + + for (const key of expectedWithToken) { + expect(seenHeaders.get(key), key).toBe("p1.c1.sig"); + } + + // Project-level call and another conversation without a stored token send no token. + expect(seenHeaders.get("GET /participant/projects/p-1")).toBeUndefined(); + expect( + seenHeaders.get("POST /participant/conversations/c-other/finish"), + ).toBeUndefined(); + + // Keepalive beacon sent the token too. + const pingLeftCall = fetchSpy.mock.calls.find( + ([url]) => + typeof url === "string" && + url.endsWith("/participant/conversations/c-1/ping"), + ); + expect(pingLeftCall).toBeTruthy(); + expect( + (pingLeftCall?.[1]?.headers as Record)?.[ + PARTICIPANT_TOKEN_HEADER + ], + ).toBe("p1.c1.sig"); + }); + + it("on participant.token_invalid clears the token and sends the call once more without it", async () => { + setParticipantToken("c-stale", "p1.stale.sig"); + setParticipantToken("c-fresh", "p1.fresh.sig"); + + const sentOnRetry: Array = []; + let attempt = 0; + const adapter = vi.fn(async (config) => { + attempt++; + sentOnRetry.push( + config.headers.get(PARTICIPANT_TOKEN_HEADER)?.toString(), + ); + if (attempt === 1) { + throw new AxiosError( + "Forbidden", + "ERR_BAD_REQUEST", + config, + {}, + { + config, + data: { code: "participant.token_invalid" }, + headers: {}, + status: 403, + statusText: "Forbidden", + }, + ); + } + return { + config, + data: { id: "c-stale" }, + headers: {}, + status: 200, + statusText: "OK", + }; + }); + apiNoAuth.defaults.adapter = adapter; + + // The caller gets the answer of the retry, not the rejection. + await expect( + getParticipantConversationById("p-1", "c-stale"), + ).resolves.toEqual({ id: "c-stale" }); + expect(sentOnRetry).toEqual(["p1.stale.sig", undefined]); + + // Stale token was cleared; other conversations' tokens remain untouched. + expect(getParticipantToken("c-stale")).toBeNull(); + expect(getParticipantToken("c-fresh")).toBe("p1.fresh.sig"); + }); + + it("a chunk upload rejected for its token is not lost", async () => { + setParticipantToken("c-1", "p1.rotated.sig"); + const calls: Array = []; + apiNoAuth.defaults.adapter = vi.fn(async (config) => { + const token = config.headers.get(PARTICIPANT_TOKEN_HEADER)?.toString(); + calls.push(token); + if (token) { + throw new AxiosError( + "Forbidden", + "ERR_BAD_REQUEST", + config, + {}, + { + config, + data: { code: "participant.token_invalid" }, + headers: {}, + status: 403, + statusText: "Forbidden", + }, + ); + } + return { + config, + data: { chunk_id: "chunk-1" }, + headers: {}, + status: 200, + statusText: "OK", + }; + }); + + await expect( + confirmConversationChunkUpload({ + chunk_id: "chunk-1", + conversationId: "c-1", + file_url: "https://s3/x", + source: "PORTAL_AUDIO", + timestamp: "2026-11-30T10:00:00Z", + }), + ).resolves.toBeDefined(); + expect(calls).toEqual(["p1.rotated.sig", undefined]); + }); + + it("retries a token rejection only once", async () => { + setParticipantToken("c-1", "p1.bad.sig"); + const adapter = vi.fn(async (config) => { + throw new AxiosError( + "Forbidden", + "ERR_BAD_REQUEST", + config, + {}, + { + config, + data: { code: "participant.token_invalid" }, + headers: {}, + status: 403, + statusText: "Forbidden", + }, + ); + }); + apiNoAuth.defaults.adapter = adapter; + + await expect( + getParticipantConversationById("p-1", "c-1"), + ).rejects.toThrow(); + expect(adapter).toHaveBeenCalledTimes(2); + }); + + it("keeps the token and does not retry on a 403 without a code", async () => { + setParticipantToken("c-1", "p1.valid.sig"); + const adapter = vi.fn(async (config) => { + throw new AxiosError( + "Forbidden", + "ERR_BAD_REQUEST", + config, + {}, + { + config, + data: "Forbidden", + headers: {}, + status: 403, + statusText: "Forbidden", + }, + ); + }); + apiNoAuth.defaults.adapter = adapter; + + await expect( + getParticipantConversationById("p-1", "c-1"), + ).rejects.toThrow(); + expect(adapter).toHaveBeenCalledTimes(1); + expect(getParticipantToken("c-1")).toBe("p1.valid.sig"); + }); + + it("keeps the stored token on unrelated 403 errors", async () => { + setParticipantToken("c-1", "p1.valid.sig"); + + apiNoAuth.defaults.adapter = vi.fn(async (config) => { + throw new AxiosError( + "Forbidden", + "ERR_BAD_REQUEST", + config, + {}, + { + config, + data: { code: "billing.tier_required" }, + headers: {}, + status: 403, + statusText: "Forbidden", + }, + ); + }); + + await expect( + getParticipantConversationById("p-1", "c-1"), + ).rejects.toThrow(); + expect(getParticipantToken("c-1")).toBe("p1.valid.sig"); + }); +}); diff --git a/dembrane/frontend/src/lib/participantToken.ts b/dembrane/frontend/src/lib/participantToken.ts new file mode 100644 index 000000000..d7b4935b5 --- /dev/null +++ b/dembrane/frontend/src/lib/participantToken.ts @@ -0,0 +1,159 @@ +import { readApiError } from "./errors/read"; + +export const PARTICIPANT_TOKEN_HEADER = "X-Participant-Token"; + +const STORAGE_PREFIX = "portal:token:"; +const memoryStore = new Map(); + +export const participantTokenKey = (conversationId: string): string => + `${STORAGE_PREFIX}${conversationId}`; + +export const setParticipantToken = ( + conversationId: string, + token: string, +): void => { + if (!conversationId || !token) return; + const key = participantTokenKey(conversationId); + try { + globalThis.sessionStorage.setItem(key, token); + memoryStore.delete(key); + } catch { + // Private browsing or storage quota: keep the token for this page session. + memoryStore.set(key, token); + } +}; + +export const getParticipantToken = ( + conversationId: string | null | undefined, +): string | null => { + if (!conversationId) return null; + const key = participantTokenKey(conversationId); + try { + const stored = globalThis.sessionStorage.getItem(key); + if (stored) return stored; + } catch { + // Private browsing: fall back to the in-memory store. + } + return memoryStore.get(key) ?? null; +}; + +export const clearParticipantToken = ( + conversationId: string | null | undefined, +): void => { + if (!conversationId) return; + const key = participantTokenKey(conversationId); + memoryStore.delete(key); + try { + globalThis.sessionStorage.removeItem(key); + } catch { + // Ignore storage access failures. + } +}; + +/** + * Remove any stored participant token whose value matches a rejected token + * (for example after a server secret rotation returns 403). + */ +export const clearParticipantTokenValue = (token: string): void => { + if (!token) return; + for (const [key, value] of memoryStore.entries()) { + if (value === token) { + memoryStore.delete(key); + } + } + try { + const storage = globalThis.sessionStorage; + const keysToRemove: string[] = []; + for (let i = 0; i < storage.length; i++) { + const key = storage.key(i); + if (key?.startsWith(STORAGE_PREFIX) && storage.getItem(key) === token) { + keysToRemove.push(key); + } + } + for (const key of keysToRemove) { + storage.removeItem(key); + } + } catch { + // Ignore storage access failures. + } +}; + +export const clearAllParticipantTokens = (): void => { + memoryStore.clear(); + try { + const storage = globalThis.sessionStorage; + const keysToRemove: string[] = []; + for (let i = 0; i < storage.length; i++) { + const key = storage.key(i); + if (key?.startsWith(STORAGE_PREFIX)) { + keysToRemove.push(key); + } + } + for (const key of keysToRemove) { + storage.removeItem(key); + } + } catch { + // Ignore storage access failures. + } +}; + +export const participantTokenHeaders = ( + conversationId: string | null | undefined, +): Record => { + const token = getParticipantToken(conversationId); + return token ? { [PARTICIPANT_TOKEN_HEADER]: token } : {}; +}; + +export const participantTokenConfig = ( + conversationId: string | null | undefined, +): { headers: Record } | undefined => { + const headers = participantTokenHeaders(conversationId); + return Object.keys(headers).length > 0 ? { headers } : undefined; +}; + +export const readResponseHeader = ( + headers: unknown, + name: string, +): string | null => { + if (!headers || typeof headers !== "object") return null; + if ( + "get" in headers && + typeof (headers as { get: unknown }).get === "function" + ) { + const value = (headers as { get: (headerName: string) => unknown }).get( + name, + ); + if (typeof value === "string" && value.length > 0) return value; + } + const target = name.toLowerCase(); + for (const [key, value] of Object.entries(headers)) { + if (key.toLowerCase() === target) { + if (typeof value === "string" && value.length > 0) return value; + if ( + Array.isArray(value) && + typeof value[0] === "string" && + value[0].length > 0 + ) { + return value[0]; + } + } + } + return null; +}; + +/** + * Matches the server's participant.token_invalid from either axios or a useChat stream. + * Other 403s (a closed project, a Verify switched off) say nothing about the token. + */ +export const isParticipantTokenRejection = (err: unknown): boolean => { + const parsed = readApiError(err); + if (parsed.code === "participant.token_invalid") return true; + if (err instanceof Error) { + try { + return JSON.parse(err.message)?.code === "participant.token_invalid"; + } catch { + return false; + } + } + return false; +}; diff --git a/dembrane/frontend/src/locales/cs-CZ.po b/dembrane/frontend/src/locales/cs-CZ.po index 6361f49bc..a705bbd25 100644 --- a/dembrane/frontend/src/locales/cs-CZ.po +++ b/dembrane/frontend/src/locales/cs-CZ.po @@ -409,7 +409,7 @@ msgid "{0} deleted" msgstr "{0} deleted" #. placeholder {0}: failed.length -#: src/lib/api.ts:622 +#: src/lib/api.ts:687 msgid "{0} file(s) failed to upload. Try those again." msgstr "{0} souborů se nepodařilo nahrát. Zkuste to znovu." @@ -1502,7 +1502,7 @@ msgstr "Aktivita" #: src/routes/organisation/OrganisationRoute.tsx:2106 #: src/routes/organisation/OrganisationRoute.tsx:2119 #: src/routes/organisation/OrganisationRoute.tsx:2142 -#: src/portal/routes/ParticipantPostConversation.tsx:199 +#: src/portal/routes/ParticipantPostConversation.tsx:220 #: src/components/chat/TagsUpdateSuggestionCard.tsx:185 #: src/components/billing/BillingManager.tsx:1392 msgid "Add" @@ -1698,7 +1698,7 @@ msgstr "Přidáno lidí: {granted}" msgid "Added by a host" msgstr "Přidal hostitel" -#: src/portal/routes/ParticipantPostConversation.tsx:208 +#: src/portal/routes/ParticipantPostConversation.tsx:229 msgid "Added emails" msgstr "Added emails" @@ -1905,7 +1905,7 @@ msgid "All" msgstr "All" #. placeholder {0}: payload.chunks.length -#: src/lib/api.ts:752 +#: src/lib/api.ts:817 msgid "All {0} file(s) uploaded successfully" msgstr "Všech {0} souborů bylo úspěšně nahráno" @@ -2112,7 +2112,7 @@ msgstr "E-mailové upozornění bude odesláno {participantCount, plural, one {# msgid "An email notification will be sent to participants. Do you want to proceed?" msgstr "Účastníkům bude odesláno e-mailové upozornění. Chcete pokračovat?" -#: src/portal/routes/ParticipantStart.tsx:85 +#: src/portal/routes/ParticipantStart.tsx:90 msgid "An error occurred while loading the portal. Please contact the support team." msgstr "Při načítání portálu došlo k chybě. Kontaktujte prosím tým podpory." @@ -5071,7 +5071,7 @@ msgstr "Do I need this?" msgid "Do you plan to use dembrane in health, education, recruitment, critical infrastructure management, law enforcement or justice contexts?" msgstr "Plánujete dembrane používat ve zdravotnictví, školství, náboru, správě kritické infrastruktury, vymáhání práva nebo justici?" -#: src/portal/routes/ParticipantPostConversation.tsx:174 +#: src/portal/routes/ParticipantPostConversation.tsx:195 msgid "Do you want to stay in the loop?" msgstr "Do you want to stay in the loop?" @@ -5444,7 +5444,7 @@ msgstr "Email verification | dembrane" msgid "error.action.contact_admin" msgstr "Napište svému správci" -#: src/portal/routes/ParticipantPostConversation.tsx:183 +#: src/portal/routes/ParticipantPostConversation.tsx:204 msgid "email@work.com" msgstr "email@work.com" @@ -10726,7 +10726,7 @@ msgstr "Please check your inputs for errors." msgid "Please enable participation to enable sharing" msgstr "Please enable participation to enable sharing" -#: src/portal/routes/ParticipantPostConversation.tsx:92 +#: src/portal/routes/ParticipantPostConversation.tsx:113 msgid "Please enter a valid email." msgstr "Please enter a valid email." @@ -11561,7 +11561,7 @@ msgstr "Record" msgid "Record a voice message" msgstr "Nahrát hlasovou zprávu" -#: src/portal/routes/ParticipantPostConversation.tsx:161 +#: src/portal/routes/ParticipantPostConversation.tsx:182 msgid "Record another conversation" msgstr "Record another conversation" @@ -11825,7 +11825,7 @@ msgstr "Odebrat přístup" msgid "Remove avatar" msgstr "Remove avatar" -#: src/portal/routes/ParticipantPostConversation.tsx:214 +#: src/portal/routes/ParticipantPostConversation.tsx:235 msgid "Remove email" msgstr "Odebrat e-mail" @@ -13315,7 +13315,7 @@ msgstr "Sdílet s celým pracovním prostorem" msgid "Share with workspace" msgstr "Sdílet s pracovním prostorem" -#: src/portal/routes/ParticipantPostConversation.tsx:177 +#: src/portal/routes/ParticipantPostConversation.tsx:198 msgid "Share your details here" msgstr "Share your details here" @@ -13497,7 +13497,7 @@ msgstr "Zobrazte popcorn až ve třech dalších jazycích najednou." msgid "Show projects" msgstr "Show projects" -#: src/portal/routes/ParticipantPostConversation.tsx:152 +#: src/portal/routes/ParticipantPostConversation.tsx:173 msgid "Show QR code" msgstr "Zobrazit QR kód" @@ -14151,7 +14151,7 @@ msgstr "Silné heslo" msgid "Subject" msgstr "Předmět" -#: src/portal/routes/ParticipantPostConversation.tsx:247 +#: src/portal/routes/ParticipantPostConversation.tsx:268 msgid "Submit" msgstr "Submit" @@ -14569,11 +14569,11 @@ msgstr "Text" msgid "Text contributions and follow-up forms." msgstr "Textové příspěvky a navazující formuláře." -#: src/portal/routes/ParticipantPostConversation.tsx:133 +#: src/portal/routes/ParticipantPostConversation.tsx:154 msgid "Thank you for participating!" msgstr "Thank you for participating!" -#: src/portal/routes/ParticipantPostConversation.tsx:256 +#: src/portal/routes/ParticipantPostConversation.tsx:277 msgid "Thank you!" msgstr "Thank you!" @@ -15262,7 +15262,7 @@ msgstr "Toto nasazení zobrazuje až {applied} hran." msgid "This deployment shows up to {applied} nodes." msgstr "Toto nasazení zobrazuje až {applied} uzlů." -#: src/portal/routes/ParticipantPostConversation.tsx:88 +#: src/portal/routes/ParticipantPostConversation.tsx:109 msgid "This email is already in the list." msgstr "This email is already in the list." @@ -16823,7 +16823,7 @@ msgid "Verification prompts allow 10,000 characters, and verified outcomes have msgstr "Výzvy k ověření umožňují až 10 000 znaků a ověřené výstupy mají tlačítko pro kopírování." #. js-lingui-explicit-id -#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:167 +#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:176 msgid "participant.banner.verification_required" msgstr "Verification required" @@ -17184,7 +17184,7 @@ msgstr "Nastavíme projekt, budeme vám v den akce po boku a pomůžeme s násle msgid "We still couldn't charge your method. Update it and try again." msgstr "Platbu se stále nepodařilo strhnout. Aktualizujte platební metodu a zkuste to znovu." -#: src/portal/routes/ParticipantPostConversation.tsx:267 +#: src/portal/routes/ParticipantPostConversation.tsx:288 msgid "We will only send you a message if your host generates a report, we never share your details with anyone. You can opt out at any time." msgstr "We will only send you a message if your host generates a report, we never share your details with anyone. You can opt out at any time." @@ -18421,7 +18421,7 @@ msgstr "Zde se objeví vaše projekty. Projekt obsahuje vše k jednomu tématu: msgid "Your recording, {0}" msgstr "Vaše nahrávka, {0}" -#: src/portal/routes/ParticipantPostConversation.tsx:137 +#: src/portal/routes/ParticipantPostConversation.tsx:158 msgid "Your response has been recorded. You may now close this tab. You may also share the QR code so others can contribute, or record another conversation." msgstr "Vaše odpověď byla zaznamenána. Tuto kartu můžete zavřít. Můžete také sdílet QR kód, aby mohli přispět i ostatní, nebo nahrát další rozhovor." diff --git a/dembrane/frontend/src/locales/de-DE.po b/dembrane/frontend/src/locales/de-DE.po index c289db28b..463fc8e00 100644 --- a/dembrane/frontend/src/locales/de-DE.po +++ b/dembrane/frontend/src/locales/de-DE.po @@ -409,7 +409,7 @@ msgid "{0} deleted" msgstr "{0} gelöscht" #. placeholder {0}: failed.length -#: src/lib/api.ts:622 +#: src/lib/api.ts:687 msgid "{0} file(s) failed to upload. Try those again." msgstr "{0} Datei(en) konnten nicht hochgeladen werden. Versuche es erneut." @@ -1502,7 +1502,7 @@ msgstr "Aktivität" #: src/routes/organisation/OrganisationRoute.tsx:2106 #: src/routes/organisation/OrganisationRoute.tsx:2119 #: src/routes/organisation/OrganisationRoute.tsx:2142 -#: src/portal/routes/ParticipantPostConversation.tsx:199 +#: src/portal/routes/ParticipantPostConversation.tsx:220 #: src/components/chat/TagsUpdateSuggestionCard.tsx:185 #: src/components/billing/BillingManager.tsx:1392 msgid "Add" @@ -1698,7 +1698,7 @@ msgstr "{granted} Personen hinzugefügt" msgid "Added by a host" msgstr "Von einem Host hinzugefügt" -#: src/portal/routes/ParticipantPostConversation.tsx:208 +#: src/portal/routes/ParticipantPostConversation.tsx:229 msgid "Added emails" msgstr "Hinzugefügte E-Mails" @@ -1905,7 +1905,7 @@ msgid "All" msgstr "Alle" #. placeholder {0}: payload.chunks.length -#: src/lib/api.ts:752 +#: src/lib/api.ts:817 msgid "All {0} file(s) uploaded successfully" msgstr "Alle {0} Datei(en) erfolgreich hochgeladen" @@ -2112,7 +2112,7 @@ msgstr "Eine E-Mail-Benachrichtigung wird an {participantCount, plural, one {# T msgid "An email notification will be sent to participants. Do you want to proceed?" msgstr "Eine E-Mail-Benachrichtigung wird an die Teilnehmer gesendet. Möchtest du fortfahren?" -#: src/portal/routes/ParticipantStart.tsx:85 +#: src/portal/routes/ParticipantStart.tsx:90 msgid "An error occurred while loading the portal. Please contact the support team." msgstr "Beim Laden des Portals ist ein Fehler aufgetreten. Bitte kontaktiere das Support-Team." @@ -5071,7 +5071,7 @@ msgstr "Benötige ich dies?" msgid "Do you plan to use dembrane in health, education, recruitment, critical infrastructure management, law enforcement or justice contexts?" msgstr "Planst du, dembrane im Gesundheitswesen, in der Bildung, Personalbeschaffung, bei kritischen Infrastrukturen, bei Strafverfolgung oder Justiz einzusetzen?" -#: src/portal/routes/ParticipantPostConversation.tsx:174 +#: src/portal/routes/ParticipantPostConversation.tsx:195 msgid "Do you want to stay in the loop?" msgstr "Möchtest du auf dem Laufenden bleiben?" @@ -5444,7 +5444,7 @@ msgstr "E-Mail-Bestätigung | dembrane" msgid "error.action.contact_admin" msgstr "E-Mail an deinen Administrator" -#: src/portal/routes/ParticipantPostConversation.tsx:183 +#: src/portal/routes/ParticipantPostConversation.tsx:204 msgid "email@work.com" msgstr "email@work.com" @@ -10726,7 +10726,7 @@ msgstr "Bitte überprüfe deine Eingaben auf Fehler." msgid "Please enable participation to enable sharing" msgstr "Bitte aktiviere die Teilnahme, um das Teilen zu ermöglichen" -#: src/portal/routes/ParticipantPostConversation.tsx:92 +#: src/portal/routes/ParticipantPostConversation.tsx:113 msgid "Please enter a valid email." msgstr "Bitte gib eine gültige E-Mail-Adresse ein." @@ -11561,7 +11561,7 @@ msgstr "Aufnehmen" msgid "Record a voice message" msgstr "Sprachnachricht aufnehmen" -#: src/portal/routes/ParticipantPostConversation.tsx:161 +#: src/portal/routes/ParticipantPostConversation.tsx:182 msgid "Record another conversation" msgstr "Ein weiteres Gespräch aufnehmen" @@ -11825,7 +11825,7 @@ msgstr "Zugriff entfernen" msgid "Remove avatar" msgstr "Profilbild entfernen" -#: src/portal/routes/ParticipantPostConversation.tsx:214 +#: src/portal/routes/ParticipantPostConversation.tsx:235 msgid "Remove email" msgstr "E-Mail entfernen" @@ -13315,7 +13315,7 @@ msgstr "Mit gesamtem Workspace teilen" msgid "Share with workspace" msgstr "Für Arbeitsbereich freigeben" -#: src/portal/routes/ParticipantPostConversation.tsx:177 +#: src/portal/routes/ParticipantPostConversation.tsx:198 msgid "Share your details here" msgstr "Teile hier deine Daten" @@ -13497,7 +13497,7 @@ msgstr "Zeige Popcorn in bis zu drei zusätzlichen Sprachen gleichzeitig." msgid "Show projects" msgstr "Projekte anzeigen" -#: src/portal/routes/ParticipantPostConversation.tsx:152 +#: src/portal/routes/ParticipantPostConversation.tsx:173 msgid "Show QR code" msgstr "QR-Code anzeigen" @@ -14151,7 +14151,7 @@ msgstr "Sicheres Passwort" msgid "Subject" msgstr "Betreff" -#: src/portal/routes/ParticipantPostConversation.tsx:247 +#: src/portal/routes/ParticipantPostConversation.tsx:268 msgid "Submit" msgstr "Absenden" @@ -14569,11 +14569,11 @@ msgstr "Text" msgid "Text contributions and follow-up forms." msgstr "Textbeiträge und Formulare zur Nachbereitung." -#: src/portal/routes/ParticipantPostConversation.tsx:133 +#: src/portal/routes/ParticipantPostConversation.tsx:154 msgid "Thank you for participating!" msgstr "Vielen Dank für deine Teilnahme!" -#: src/portal/routes/ParticipantPostConversation.tsx:256 +#: src/portal/routes/ParticipantPostConversation.tsx:277 msgid "Thank you!" msgstr "Vielen Dank!" @@ -15262,7 +15262,7 @@ msgstr "Diese Bereitstellung zeigt bis zu {applied} Kanten." msgid "This deployment shows up to {applied} nodes." msgstr "Diese Bereitstellung zeigt bis zu {applied} Knoten." -#: src/portal/routes/ParticipantPostConversation.tsx:88 +#: src/portal/routes/ParticipantPostConversation.tsx:109 msgid "This email is already in the list." msgstr "Diese E-Mail ist bereits in der Liste." @@ -16821,7 +16821,7 @@ msgid "Verification prompts allow 10,000 characters, and verified outcomes have msgstr "Verifizierungs-Prompts erlauben 10.000 Zeichen, und verifizierte Ergebnisse haben einen Kopier-Button." #. js-lingui-explicit-id -#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:167 +#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:176 msgid "participant.banner.verification_required" msgstr "Verifizierung erforderlich" @@ -17182,7 +17182,7 @@ msgstr "Wir richten das Projekt ein, stehen dir am Tag der Veranstaltung zur Sei msgid "We still couldn't charge your method. Update it and try again." msgstr "Deine Zahlungsmethode konnte noch immer nicht belastet werden. Bitte aktualisiere sie und versuche es erneut." -#: src/portal/routes/ParticipantPostConversation.tsx:267 +#: src/portal/routes/ParticipantPostConversation.tsx:288 msgid "We will only send you a message if your host generates a report, we never share your details with anyone. You can opt out at any time." msgstr "Wir werden dir nur eine Nachricht senden, wenn dein Gastgeber einen Bericht erstellt. Wir geben deine Daten niemals an Dritte weiter. Du kannst dich jederzeit abmelden." @@ -18419,7 +18419,7 @@ msgstr "Hier erscheinen deine Projekte. Ein Projekt enthält alles zu einem Them msgid "Your recording, {0}" msgstr "Deine Aufnahme, {0}" -#: src/portal/routes/ParticipantPostConversation.tsx:137 +#: src/portal/routes/ParticipantPostConversation.tsx:158 msgid "Your response has been recorded. You may now close this tab. You may also share the QR code so others can contribute, or record another conversation." msgstr "Deine Antwort wurde aufgezeichnet. Du kannst diesen Tab jetzt schließen. Du kannst auch den QR-Code teilen, damit andere beitragen können, oder ein weiteres Gespräch aufnehmen." diff --git a/dembrane/frontend/src/locales/en-US.po b/dembrane/frontend/src/locales/en-US.po index 039520b9c..b0f64d2cf 100644 --- a/dembrane/frontend/src/locales/en-US.po +++ b/dembrane/frontend/src/locales/en-US.po @@ -409,7 +409,7 @@ msgid "{0} deleted" msgstr "{0} deleted" #. placeholder {0}: failed.length -#: src/lib/api.ts:622 +#: src/lib/api.ts:687 msgid "{0} file(s) failed to upload. Try those again." msgstr "{0} file(s) failed to upload. Try those again." @@ -1502,7 +1502,7 @@ msgstr "Activity" #: src/routes/organisation/OrganisationRoute.tsx:2106 #: src/routes/organisation/OrganisationRoute.tsx:2119 #: src/routes/organisation/OrganisationRoute.tsx:2142 -#: src/portal/routes/ParticipantPostConversation.tsx:199 +#: src/portal/routes/ParticipantPostConversation.tsx:220 #: src/components/chat/TagsUpdateSuggestionCard.tsx:185 #: src/components/billing/BillingManager.tsx:1392 msgid "Add" @@ -1698,7 +1698,7 @@ msgstr "Added {granted} people" msgid "Added by a host" msgstr "Added by a host" -#: src/portal/routes/ParticipantPostConversation.tsx:208 +#: src/portal/routes/ParticipantPostConversation.tsx:229 msgid "Added emails" msgstr "Added emails" @@ -1905,7 +1905,7 @@ msgid "All" msgstr "All" #. placeholder {0}: payload.chunks.length -#: src/lib/api.ts:752 +#: src/lib/api.ts:817 msgid "All {0} file(s) uploaded successfully" msgstr "All {0} file(s) uploaded successfully" @@ -2112,7 +2112,7 @@ msgstr "An email notification will be sent to {participantCount, plural, one {# msgid "An email notification will be sent to participants. Do you want to proceed?" msgstr "An email notification will be sent to participants. Do you want to proceed?" -#: src/portal/routes/ParticipantStart.tsx:85 +#: src/portal/routes/ParticipantStart.tsx:90 msgid "An error occurred while loading the portal. Please contact the support team." msgstr "An error occurred while loading the portal. Please contact the support team." @@ -5071,7 +5071,7 @@ msgstr "Do I need this?" msgid "Do you plan to use dembrane in health, education, recruitment, critical infrastructure management, law enforcement or justice contexts?" msgstr "Do you plan to use dembrane in health, education, recruitment, critical infrastructure management, law enforcement or justice contexts?" -#: src/portal/routes/ParticipantPostConversation.tsx:174 +#: src/portal/routes/ParticipantPostConversation.tsx:195 msgid "Do you want to stay in the loop?" msgstr "Do you want to stay in the loop?" @@ -5444,7 +5444,7 @@ msgstr "Email verification | dembrane" msgid "error.action.contact_admin" msgstr "Email your admin" -#: src/portal/routes/ParticipantPostConversation.tsx:183 +#: src/portal/routes/ParticipantPostConversation.tsx:204 msgid "email@work.com" msgstr "email@work.com" @@ -10726,7 +10726,7 @@ msgstr "Please check your inputs for errors." msgid "Please enable participation to enable sharing" msgstr "Please enable participation to enable sharing" -#: src/portal/routes/ParticipantPostConversation.tsx:92 +#: src/portal/routes/ParticipantPostConversation.tsx:113 msgid "Please enter a valid email." msgstr "Please enter a valid email." @@ -11561,7 +11561,7 @@ msgstr "Record" msgid "Record a voice message" msgstr "Record a voice message" -#: src/portal/routes/ParticipantPostConversation.tsx:161 +#: src/portal/routes/ParticipantPostConversation.tsx:182 msgid "Record another conversation" msgstr "Record another conversation" @@ -11825,7 +11825,7 @@ msgstr "Remove access" msgid "Remove avatar" msgstr "Remove avatar" -#: src/portal/routes/ParticipantPostConversation.tsx:214 +#: src/portal/routes/ParticipantPostConversation.tsx:235 msgid "Remove email" msgstr "Remove email" @@ -13315,7 +13315,7 @@ msgstr "Share with whole workspace" msgid "Share with workspace" msgstr "Share with workspace" -#: src/portal/routes/ParticipantPostConversation.tsx:177 +#: src/portal/routes/ParticipantPostConversation.tsx:198 msgid "Share your details here" msgstr "Share your details here" @@ -13497,7 +13497,7 @@ msgstr "Show popcorn in up to three extra languages at once." msgid "Show projects" msgstr "Show projects" -#: src/portal/routes/ParticipantPostConversation.tsx:152 +#: src/portal/routes/ParticipantPostConversation.tsx:173 msgid "Show QR code" msgstr "Show QR code" @@ -14151,7 +14151,7 @@ msgstr "Strong password" msgid "Subject" msgstr "Subject" -#: src/portal/routes/ParticipantPostConversation.tsx:247 +#: src/portal/routes/ParticipantPostConversation.tsx:268 msgid "Submit" msgstr "Submit" @@ -14569,11 +14569,11 @@ msgstr "Text" msgid "Text contributions and follow-up forms." msgstr "Text contributions and follow-up forms." -#: src/portal/routes/ParticipantPostConversation.tsx:133 +#: src/portal/routes/ParticipantPostConversation.tsx:154 msgid "Thank you for participating!" msgstr "Thank you for participating!" -#: src/portal/routes/ParticipantPostConversation.tsx:256 +#: src/portal/routes/ParticipantPostConversation.tsx:277 msgid "Thank you!" msgstr "Thank you!" @@ -15262,7 +15262,7 @@ msgstr "This deployment shows up to {applied} edges." msgid "This deployment shows up to {applied} nodes." msgstr "This deployment shows up to {applied} nodes." -#: src/portal/routes/ParticipantPostConversation.tsx:88 +#: src/portal/routes/ParticipantPostConversation.tsx:109 msgid "This email is already in the list." msgstr "This email is already in the list." @@ -16823,7 +16823,7 @@ msgid "Verification prompts allow 10,000 characters, and verified outcomes have msgstr "Verification prompts allow 10,000 characters, and verified outcomes have a copy button." #. js-lingui-explicit-id -#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:167 +#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:176 msgid "participant.banner.verification_required" msgstr "Verification required" @@ -17184,7 +17184,7 @@ msgstr "We set up the project, stand beside you on the day, and help write the r msgid "We still couldn't charge your method. Update it and try again." msgstr "We still couldn't charge your method. Update it and try again." -#: src/portal/routes/ParticipantPostConversation.tsx:267 +#: src/portal/routes/ParticipantPostConversation.tsx:288 msgid "We will only send you a message if your host generates a report, we never share your details with anyone. You can opt out at any time." msgstr "We will only send you a message if your host generates a report, we never share your details with anyone. You can opt out at any time." @@ -18421,7 +18421,7 @@ msgstr "Your projects will appear here. A project holds everything for one topic msgid "Your recording, {0}" msgstr "Your recording, {0}" -#: src/portal/routes/ParticipantPostConversation.tsx:137 +#: src/portal/routes/ParticipantPostConversation.tsx:158 msgid "Your response has been recorded. You may now close this tab. You may also share the QR code so others can contribute, or record another conversation." msgstr "Your response has been recorded. You may now close this tab. You may also share the QR code so others can contribute, or record another conversation." diff --git a/dembrane/frontend/src/locales/es-ES.po b/dembrane/frontend/src/locales/es-ES.po index ba2d993fd..491fcd813 100644 --- a/dembrane/frontend/src/locales/es-ES.po +++ b/dembrane/frontend/src/locales/es-ES.po @@ -409,7 +409,7 @@ msgid "{0} deleted" msgstr "{0} eliminadas" #. placeholder {0}: failed.length -#: src/lib/api.ts:622 +#: src/lib/api.ts:687 msgid "{0} file(s) failed to upload. Try those again." msgstr "Error al subir {0} archivo(s). Vuelve a intentarlo." @@ -1502,7 +1502,7 @@ msgstr "Actividad" #: src/routes/organisation/OrganisationRoute.tsx:2106 #: src/routes/organisation/OrganisationRoute.tsx:2119 #: src/routes/organisation/OrganisationRoute.tsx:2142 -#: src/portal/routes/ParticipantPostConversation.tsx:199 +#: src/portal/routes/ParticipantPostConversation.tsx:220 #: src/components/chat/TagsUpdateSuggestionCard.tsx:185 #: src/components/billing/BillingManager.tsx:1392 msgid "Add" @@ -1698,7 +1698,7 @@ msgstr "{granted} personas añadidas" msgid "Added by a host" msgstr "Añadido por un host" -#: src/portal/routes/ParticipantPostConversation.tsx:208 +#: src/portal/routes/ParticipantPostConversation.tsx:229 msgid "Added emails" msgstr "E-mails añadidos" @@ -1905,7 +1905,7 @@ msgid "All" msgstr "Todo" #. placeholder {0}: payload.chunks.length -#: src/lib/api.ts:752 +#: src/lib/api.ts:817 msgid "All {0} file(s) uploaded successfully" msgstr "Los {0} archivo(s) se subieron correctamente" @@ -2112,7 +2112,7 @@ msgstr "Se enviará una notificación por correo electrónico a {participantCoun msgid "An email notification will be sent to participants. Do you want to proceed?" msgstr "Se enviará una notificación por correo electrónico a los participantes. ¿Quieres continuar?" -#: src/portal/routes/ParticipantStart.tsx:85 +#: src/portal/routes/ParticipantStart.tsx:90 msgid "An error occurred while loading the portal. Please contact the support team." msgstr "Ocurrió un error al cargar el portal. Ponte en contacto con el equipo de soporte." @@ -5071,7 +5071,7 @@ msgstr "¿Necesito esto?" msgid "Do you plan to use dembrane in health, education, recruitment, critical infrastructure management, law enforcement or justice contexts?" msgstr "¿Planeas usar dembrane en contextos de salud, educación, selección de personal, gestión de infraestructuras críticas, orden público o justicia?" -#: src/portal/routes/ParticipantPostConversation.tsx:174 +#: src/portal/routes/ParticipantPostConversation.tsx:195 msgid "Do you want to stay in the loop?" msgstr "¿Quieres estar en el bucle?" @@ -5444,7 +5444,7 @@ msgstr "Verificación de correo | dembrane" msgid "error.action.contact_admin" msgstr "Escribe a tu administrador" -#: src/portal/routes/ParticipantPostConversation.tsx:183 +#: src/portal/routes/ParticipantPostConversation.tsx:204 msgid "email@work.com" msgstr "email@trabajo.com" @@ -10726,7 +10726,7 @@ msgstr "Por favor, revisa tus entradas para errores." msgid "Please enable participation to enable sharing" msgstr "Por favor, habilite la participación para habilitar el uso compartido" -#: src/portal/routes/ParticipantPostConversation.tsx:92 +#: src/portal/routes/ParticipantPostConversation.tsx:113 msgid "Please enter a valid email." msgstr "Por favor, ingrese un correo electrónico válido." @@ -11561,7 +11561,7 @@ msgstr "Grabar" msgid "Record a voice message" msgstr "Grabar un mensaje de voz" -#: src/portal/routes/ParticipantPostConversation.tsx:161 +#: src/portal/routes/ParticipantPostConversation.tsx:182 msgid "Record another conversation" msgstr "Registrar otra conversación" @@ -11825,7 +11825,7 @@ msgstr "Quitar acceso" msgid "Remove avatar" msgstr "Eliminar avatar" -#: src/portal/routes/ParticipantPostConversation.tsx:214 +#: src/portal/routes/ParticipantPostConversation.tsx:235 msgid "Remove email" msgstr "Eliminar correo electrónico" @@ -13315,7 +13315,7 @@ msgstr "Compartir con todo el espacio de trabajo" msgid "Share with workspace" msgstr "Compartir con el espacio de trabajo" -#: src/portal/routes/ParticipantPostConversation.tsx:177 +#: src/portal/routes/ParticipantPostConversation.tsx:198 msgid "Share your details here" msgstr "Comparte tus detalles aquí" @@ -13497,7 +13497,7 @@ msgstr "Muestra popcorn en hasta tres idiomas adicionales a la vez." msgid "Show projects" msgstr "Mostrar proyectos" -#: src/portal/routes/ParticipantPostConversation.tsx:152 +#: src/portal/routes/ParticipantPostConversation.tsx:173 msgid "Show QR code" msgstr "Mostrar código QR" @@ -14151,7 +14151,7 @@ msgstr "Contraseña segura" msgid "Subject" msgstr "Asunto" -#: src/portal/routes/ParticipantPostConversation.tsx:247 +#: src/portal/routes/ParticipantPostConversation.tsx:268 msgid "Submit" msgstr "Enviar" @@ -14569,11 +14569,11 @@ msgstr "Texto" msgid "Text contributions and follow-up forms." msgstr "Aportaciones de texto y formularios de seguimiento." -#: src/portal/routes/ParticipantPostConversation.tsx:133 +#: src/portal/routes/ParticipantPostConversation.tsx:154 msgid "Thank you for participating!" msgstr "¡Gracias por participar!" -#: src/portal/routes/ParticipantPostConversation.tsx:256 +#: src/portal/routes/ParticipantPostConversation.tsx:277 msgid "Thank you!" msgstr "¡Gracias!" @@ -15262,7 +15262,7 @@ msgstr "Este despliegue muestra hasta {applied} conexiones." msgid "This deployment shows up to {applied} nodes." msgstr "Este despliegue muestra hasta {applied} nodos." -#: src/portal/routes/ParticipantPostConversation.tsx:88 +#: src/portal/routes/ParticipantPostConversation.tsx:109 msgid "This email is already in the list." msgstr "Este correo electrónico ya está en la lista." @@ -16823,7 +16823,7 @@ msgid "Verification prompts allow 10,000 characters, and verified outcomes have msgstr "Las instrucciones de verificación admiten hasta 10.000 caracteres, y los resultados verificados tienen un botón para copiar." #. js-lingui-explicit-id -#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:167 +#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:176 msgid "participant.banner.verification_required" msgstr "Verificación requerida" @@ -17184,7 +17184,7 @@ msgstr "Configuramos el proyecto, te acompañamos el día del evento y te ayudam msgid "We still couldn't charge your method. Update it and try again." msgstr "Seguimos sin poder cobrar a tu método de pago. Actualízalo e inténtalo de nuevo." -#: src/portal/routes/ParticipantPostConversation.tsx:267 +#: src/portal/routes/ParticipantPostConversation.tsx:288 msgid "We will only send you a message if your host generates a report, we never share your details with anyone. You can opt out at any time." msgstr "Solo te enviaremos un mensaje si tu host genera un informe, nunca compartimos tus detalles con nadie. Puedes optar por no recibir más mensajes en cualquier momento." @@ -18421,7 +18421,7 @@ msgstr "Aquí aparecerán tus proyectos. Un proyecto reúne todo sobre un tema: msgid "Your recording, {0}" msgstr "Tu grabación, {0}" -#: src/portal/routes/ParticipantPostConversation.tsx:137 +#: src/portal/routes/ParticipantPostConversation.tsx:158 msgid "Your response has been recorded. You may now close this tab. You may also share the QR code so others can contribute, or record another conversation." msgstr "Tu respuesta ha sido registrada. Puedes cerrar esta pestaña ahora. También puedes compartir el código QR para que otras personas puedan contribuir, o registrar otra conversación." diff --git a/dembrane/frontend/src/locales/fr-FR.po b/dembrane/frontend/src/locales/fr-FR.po index c6e419299..fbeee8a2b 100644 --- a/dembrane/frontend/src/locales/fr-FR.po +++ b/dembrane/frontend/src/locales/fr-FR.po @@ -409,7 +409,7 @@ msgid "{0} deleted" msgstr "{0} supprimé(s)" #. placeholder {0}: failed.length -#: src/lib/api.ts:622 +#: src/lib/api.ts:687 msgid "{0} file(s) failed to upload. Try those again." msgstr "Échec de l'importation de {0} fichier(s). Veuillez réessayer." @@ -1502,7 +1502,7 @@ msgstr "Activité" #: src/routes/organisation/OrganisationRoute.tsx:2106 #: src/routes/organisation/OrganisationRoute.tsx:2119 #: src/routes/organisation/OrganisationRoute.tsx:2142 -#: src/portal/routes/ParticipantPostConversation.tsx:199 +#: src/portal/routes/ParticipantPostConversation.tsx:220 #: src/components/chat/TagsUpdateSuggestionCard.tsx:185 #: src/components/billing/BillingManager.tsx:1392 msgid "Add" @@ -1698,7 +1698,7 @@ msgstr "{granted} personnes ajoutées" msgid "Added by a host" msgstr "Ajouté par un hôte" -#: src/portal/routes/ParticipantPostConversation.tsx:208 +#: src/portal/routes/ParticipantPostConversation.tsx:229 msgid "Added emails" msgstr "E-mails ajoutés" @@ -1905,7 +1905,7 @@ msgid "All" msgstr "Tout" #. placeholder {0}: payload.chunks.length -#: src/lib/api.ts:752 +#: src/lib/api.ts:817 msgid "All {0} file(s) uploaded successfully" msgstr "Les {0} fichier(s) ont bien été importés" @@ -2112,7 +2112,7 @@ msgstr "Une notification par e-mail sera envoyée à {participantCount, plural, msgid "An email notification will be sent to participants. Do you want to proceed?" msgstr "Une notification par e-mail sera envoyée aux participants. Voulez-vous continuer ?" -#: src/portal/routes/ParticipantStart.tsx:85 +#: src/portal/routes/ParticipantStart.tsx:90 msgid "An error occurred while loading the portal. Please contact the support team." msgstr "Une erreur s'est produite lors du chargement du portail. Veuillez contacter l'équipe de support." @@ -5071,7 +5071,7 @@ msgstr "Dois-je avoir cela ?" msgid "Do you plan to use dembrane in health, education, recruitment, critical infrastructure management, law enforcement or justice contexts?" msgstr "Prévoyez-vous d'utiliser dembrane dans les domaines de la santé, de l'éducation, du recrutement, de la gestion d'infrastructures critiques, du maintien de l'ordre ou de la justice ?" -#: src/portal/routes/ParticipantPostConversation.tsx:174 +#: src/portal/routes/ParticipantPostConversation.tsx:195 msgid "Do you want to stay in the loop?" msgstr "Voulez-vous rester dans la boucle ?" @@ -5444,7 +5444,7 @@ msgstr "Vérification de l'adresse e-mail | dembrane" msgid "error.action.contact_admin" msgstr "Envoyer un e-mail à votre administrateur" -#: src/portal/routes/ParticipantPostConversation.tsx:183 +#: src/portal/routes/ParticipantPostConversation.tsx:204 msgid "email@work.com" msgstr "email@travail.com" @@ -10726,7 +10726,7 @@ msgstr "Veuillez vérifier vos entrées pour les erreurs." msgid "Please enable participation to enable sharing" msgstr "Veuillez activer la participation pour activer le partage" -#: src/portal/routes/ParticipantPostConversation.tsx:92 +#: src/portal/routes/ParticipantPostConversation.tsx:113 msgid "Please enter a valid email." msgstr "Veuillez entrer une adresse e-mail valide." @@ -11561,7 +11561,7 @@ msgstr "Enregistrer" msgid "Record a voice message" msgstr "Enregistrer un message vocal" -#: src/portal/routes/ParticipantPostConversation.tsx:161 +#: src/portal/routes/ParticipantPostConversation.tsx:182 msgid "Record another conversation" msgstr "Enregistrer une autre conversation" @@ -11825,7 +11825,7 @@ msgstr "Retirer l'accès" msgid "Remove avatar" msgstr "Supprimer l'avatar" -#: src/portal/routes/ParticipantPostConversation.tsx:214 +#: src/portal/routes/ParticipantPostConversation.tsx:235 msgid "Remove email" msgstr "Supprimer l'e-mail" @@ -13315,7 +13315,7 @@ msgstr "Partager avec tout l'espace de travail" msgid "Share with workspace" msgstr "Partager avec l'espace de travail" -#: src/portal/routes/ParticipantPostConversation.tsx:177 +#: src/portal/routes/ParticipantPostConversation.tsx:198 msgid "Share your details here" msgstr "Partager vos informations ici" @@ -13497,7 +13497,7 @@ msgstr "Affichez le popcorn dans jusqu'à trois langues supplémentaires à la f msgid "Show projects" msgstr "Afficher les projets" -#: src/portal/routes/ParticipantPostConversation.tsx:152 +#: src/portal/routes/ParticipantPostConversation.tsx:173 msgid "Show QR code" msgstr "Afficher le QR code" @@ -14151,7 +14151,7 @@ msgstr "Mot de passe robuste" msgid "Subject" msgstr "Objet" -#: src/portal/routes/ParticipantPostConversation.tsx:247 +#: src/portal/routes/ParticipantPostConversation.tsx:268 msgid "Submit" msgstr "Soumettre" @@ -14569,11 +14569,11 @@ msgstr "Texte" msgid "Text contributions and follow-up forms." msgstr "Des contributions écrites et des formulaires de suivi." -#: src/portal/routes/ParticipantPostConversation.tsx:133 +#: src/portal/routes/ParticipantPostConversation.tsx:154 msgid "Thank you for participating!" msgstr "Merci pour votre participation !" -#: src/portal/routes/ParticipantPostConversation.tsx:256 +#: src/portal/routes/ParticipantPostConversation.tsx:277 msgid "Thank you!" msgstr "Merci !" @@ -15262,7 +15262,7 @@ msgstr "Ce déploiement affiche jusqu'à {applied} liens." msgid "This deployment shows up to {applied} nodes." msgstr "Ce déploiement affiche jusqu'à {applied} nœuds." -#: src/portal/routes/ParticipantPostConversation.tsx:88 +#: src/portal/routes/ParticipantPostConversation.tsx:109 msgid "This email is already in the list." msgstr "Cette e-mail est déjà dans la liste." @@ -16820,7 +16820,7 @@ msgid "Verification prompts allow 10,000 characters, and verified outcomes have msgstr "Les invites de vérification autorisent 10 000 caractères, et les résultats vérifiés ont un bouton de copie." #. js-lingui-explicit-id -#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:167 +#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:176 msgid "participant.banner.verification_required" msgstr "Vérification requise" @@ -17181,7 +17181,7 @@ msgstr "Nous configurons le projet, vous accompagnons le jour J et vous aidons e msgid "We still couldn't charge your method. Update it and try again." msgstr "Impossible de débiter votre moyen de paiement. Mettez-le à jour et réessayez." -#: src/portal/routes/ParticipantPostConversation.tsx:267 +#: src/portal/routes/ParticipantPostConversation.tsx:288 msgid "We will only send you a message if your host generates a report, we never share your details with anyone. You can opt out at any time." msgstr "Nous vous envoyerons un message uniquement si votre hôte génère un rapport, nous ne partageons jamais vos informations avec personne. Vous pouvez vous désinscrire à tout moment." @@ -18418,7 +18418,7 @@ msgstr "Vos projets apparaîtront ici. Un projet réunit tout ce qui concerne un msgid "Your recording, {0}" msgstr "Votre enregistrement, {0}" -#: src/portal/routes/ParticipantPostConversation.tsx:137 +#: src/portal/routes/ParticipantPostConversation.tsx:158 msgid "Your response has been recorded. You may now close this tab. You may also share the QR code so others can contribute, or record another conversation." msgstr "Votre réponse a été enregistrée. Vous pouvez maintenant fermer cette page. Vous pouvez également partager le code QR pour que d'autres puissent contribuer, ou enregistrer une autre conversation." diff --git a/dembrane/frontend/src/locales/it-IT.po b/dembrane/frontend/src/locales/it-IT.po index 723521b8f..4f71569f2 100644 --- a/dembrane/frontend/src/locales/it-IT.po +++ b/dembrane/frontend/src/locales/it-IT.po @@ -409,7 +409,7 @@ msgid "{0} deleted" msgstr "{0} eliminati" #. placeholder {0}: failed.length -#: src/lib/api.ts:622 +#: src/lib/api.ts:687 msgid "{0} file(s) failed to upload. Try those again." msgstr "Impossibile caricare {0} file. Riprova." @@ -1502,7 +1502,7 @@ msgstr "Attività" #: src/routes/organisation/OrganisationRoute.tsx:2106 #: src/routes/organisation/OrganisationRoute.tsx:2119 #: src/routes/organisation/OrganisationRoute.tsx:2142 -#: src/portal/routes/ParticipantPostConversation.tsx:199 +#: src/portal/routes/ParticipantPostConversation.tsx:220 #: src/components/chat/TagsUpdateSuggestionCard.tsx:185 #: src/components/billing/BillingManager.tsx:1392 msgid "Add" @@ -1698,7 +1698,7 @@ msgstr "{granted} persone aggiunte" msgid "Added by a host" msgstr "Aggiunto da un host" -#: src/portal/routes/ParticipantPostConversation.tsx:208 +#: src/portal/routes/ParticipantPostConversation.tsx:229 msgid "Added emails" msgstr "Added emails" @@ -1905,7 +1905,7 @@ msgid "All" msgstr "All" #. placeholder {0}: payload.chunks.length -#: src/lib/api.ts:752 +#: src/lib/api.ts:817 msgid "All {0} file(s) uploaded successfully" msgstr "Tutti i {0} file caricati con successo" @@ -2112,7 +2112,7 @@ msgstr "Verrà inviata una notifica via email a {participantCount, plural, one { msgid "An email notification will be sent to participants. Do you want to proceed?" msgstr "Verrà inviata una notifica via email ai partecipanti. Vuoi procedere?" -#: src/portal/routes/ParticipantStart.tsx:85 +#: src/portal/routes/ParticipantStart.tsx:90 msgid "An error occurred while loading the portal. Please contact the support team." msgstr "Si è verificato un errore durante il caricamento del portale. Contatta il team di supporto." @@ -5071,7 +5071,7 @@ msgstr "Do I need this?" msgid "Do you plan to use dembrane in health, education, recruitment, critical infrastructure management, law enforcement or justice contexts?" msgstr "Hai intenzione di usare dembrane in contesti sanitari, educativi, di selezione del personale, gestione di infrastrutture critiche, ordine pubblico o giustizia?" -#: src/portal/routes/ParticipantPostConversation.tsx:174 +#: src/portal/routes/ParticipantPostConversation.tsx:195 msgid "Do you want to stay in the loop?" msgstr "Do you want to stay in the loop?" @@ -5444,7 +5444,7 @@ msgstr "Verifica email | dembrane" msgid "error.action.contact_admin" msgstr "Invia un'email al tuo amministratore" -#: src/portal/routes/ParticipantPostConversation.tsx:183 +#: src/portal/routes/ParticipantPostConversation.tsx:204 msgid "email@work.com" msgstr "email@work.com" @@ -10726,7 +10726,7 @@ msgstr "Please check your inputs for errors." msgid "Please enable participation to enable sharing" msgstr "Please enable participation to enable sharing" -#: src/portal/routes/ParticipantPostConversation.tsx:92 +#: src/portal/routes/ParticipantPostConversation.tsx:113 msgid "Please enter a valid email." msgstr "Please enter a valid email." @@ -11561,7 +11561,7 @@ msgstr "Record" msgid "Record a voice message" msgstr "Registra un messaggio vocale" -#: src/portal/routes/ParticipantPostConversation.tsx:161 +#: src/portal/routes/ParticipantPostConversation.tsx:182 msgid "Record another conversation" msgstr "Record another conversation" @@ -11825,7 +11825,7 @@ msgstr "Rimuovi accesso" msgid "Remove avatar" msgstr "Remove avatar" -#: src/portal/routes/ParticipantPostConversation.tsx:214 +#: src/portal/routes/ParticipantPostConversation.tsx:235 msgid "Remove email" msgstr "Rimuovi email" @@ -13315,7 +13315,7 @@ msgstr "Condividi con tutto il workspace" msgid "Share with workspace" msgstr "Condividi con lo spazio di lavoro" -#: src/portal/routes/ParticipantPostConversation.tsx:177 +#: src/portal/routes/ParticipantPostConversation.tsx:198 msgid "Share your details here" msgstr "Share your details here" @@ -13497,7 +13497,7 @@ msgstr "Mostra il popcorn in un massimo di tre lingue aggiuntive contemporaneame msgid "Show projects" msgstr "Mostra progetti" -#: src/portal/routes/ParticipantPostConversation.tsx:152 +#: src/portal/routes/ParticipantPostConversation.tsx:173 msgid "Show QR code" msgstr "Mostra il codice QR" @@ -14151,7 +14151,7 @@ msgstr "Password efficace" msgid "Subject" msgstr "Oggetto" -#: src/portal/routes/ParticipantPostConversation.tsx:247 +#: src/portal/routes/ParticipantPostConversation.tsx:268 msgid "Submit" msgstr "Submit" @@ -14569,11 +14569,11 @@ msgstr "Text" msgid "Text contributions and follow-up forms." msgstr "Contributi scritti e moduli dopo la conversazione." -#: src/portal/routes/ParticipantPostConversation.tsx:133 +#: src/portal/routes/ParticipantPostConversation.tsx:154 msgid "Thank you for participating!" msgstr "Thank you for participating!" -#: src/portal/routes/ParticipantPostConversation.tsx:256 +#: src/portal/routes/ParticipantPostConversation.tsx:277 msgid "Thank you!" msgstr "Thank you!" @@ -15262,7 +15262,7 @@ msgstr "Questa distribuzione mostra fino a {applied} collegamenti." msgid "This deployment shows up to {applied} nodes." msgstr "Questa distribuzione mostra fino a {applied} nodi." -#: src/portal/routes/ParticipantPostConversation.tsx:88 +#: src/portal/routes/ParticipantPostConversation.tsx:109 msgid "This email is already in the list." msgstr "This email is already in the list." @@ -16823,7 +16823,7 @@ msgid "Verification prompts allow 10,000 characters, and verified outcomes have msgstr "I prompt di verifica consentono 10.000 caratteri e i risultati verificati hanno un pulsante Copia." #. js-lingui-explicit-id -#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:167 +#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:176 msgid "participant.banner.verification_required" msgstr "Verification required" @@ -17184,7 +17184,7 @@ msgstr "Configuriamo il progetto, siamo al tuo fianco il giorno dell'evento e ti msgid "We still couldn't charge your method. Update it and try again." msgstr "Non siamo ancora riusciti ad addebitare il tuo metodo. Aggiornalo e riprova." -#: src/portal/routes/ParticipantPostConversation.tsx:267 +#: src/portal/routes/ParticipantPostConversation.tsx:288 msgid "We will only send you a message if your host generates a report, we never share your details with anyone. You can opt out at any time." msgstr "We will only send you a message if your host generates a report, we never share your details with anyone. You can opt out at any time." @@ -18421,7 +18421,7 @@ msgstr "Qui compariranno i tuoi progetti. Un progetto raccoglie tutto su un argo msgid "Your recording, {0}" msgstr "La tua registrazione, {0}" -#: src/portal/routes/ParticipantPostConversation.tsx:137 +#: src/portal/routes/ParticipantPostConversation.tsx:158 msgid "Your response has been recorded. You may now close this tab. You may also share the QR code so others can contribute, or record another conversation." msgstr "La tua risposta è stata registrata. Ora puoi chiudere questa scheda. Puoi anche condividere il codice QR così che altri possano contribuire, o registrare un'altra conversazione." diff --git a/dembrane/frontend/src/locales/nl-NL.po b/dembrane/frontend/src/locales/nl-NL.po index 34ea89583..da3843741 100644 --- a/dembrane/frontend/src/locales/nl-NL.po +++ b/dembrane/frontend/src/locales/nl-NL.po @@ -409,7 +409,7 @@ msgid "{0} deleted" msgstr "{0} verwijderd" #. placeholder {0}: failed.length -#: src/lib/api.ts:622 +#: src/lib/api.ts:687 msgid "{0} file(s) failed to upload. Try those again." msgstr "{0} bestand(en) uploaden mislukt. Probeer die opnieuw." @@ -1502,7 +1502,7 @@ msgstr "Activiteit" #: src/routes/organisation/OrganisationRoute.tsx:2106 #: src/routes/organisation/OrganisationRoute.tsx:2119 #: src/routes/organisation/OrganisationRoute.tsx:2142 -#: src/portal/routes/ParticipantPostConversation.tsx:199 +#: src/portal/routes/ParticipantPostConversation.tsx:220 #: src/components/chat/TagsUpdateSuggestionCard.tsx:185 #: src/components/billing/BillingManager.tsx:1392 msgid "Add" @@ -1698,7 +1698,7 @@ msgstr "{granted} mensen toegevoegd" msgid "Added by a host" msgstr "Toegevoegd door een host" -#: src/portal/routes/ParticipantPostConversation.tsx:208 +#: src/portal/routes/ParticipantPostConversation.tsx:229 msgid "Added emails" msgstr "Toegevoegde e-mails" @@ -1905,7 +1905,7 @@ msgid "All" msgstr "Alles" #. placeholder {0}: payload.chunks.length -#: src/lib/api.ts:752 +#: src/lib/api.ts:817 msgid "All {0} file(s) uploaded successfully" msgstr "Alle {0} bestand(en) succesvol geüpload" @@ -2112,7 +2112,7 @@ msgstr "Er wordt een e-mailmelding verstuurd naar {participantCount, plural, one msgid "An email notification will be sent to participants. Do you want to proceed?" msgstr "Er wordt een e-mailmelding naar de deelnemers verstuurd. Wil je doorgaan?" -#: src/portal/routes/ParticipantStart.tsx:85 +#: src/portal/routes/ParticipantStart.tsx:90 msgid "An error occurred while loading the portal. Please contact the support team." msgstr "Er is een fout opgetreden bij het laden van het portaal. Neem contact op met het supportteam." @@ -5068,7 +5068,7 @@ msgstr "Ben ik dit nodig?" msgid "Do you plan to use dembrane in health, education, recruitment, critical infrastructure management, law enforcement or justice contexts?" msgstr "Ben je van plan dembrane te gebruiken in de zorg, het onderwijs, werving, het beheer van kritieke infrastructuur, rechtshandhaving of de rechtspraak?" -#: src/portal/routes/ParticipantPostConversation.tsx:174 +#: src/portal/routes/ParticipantPostConversation.tsx:195 msgid "Do you want to stay in the loop?" msgstr "Wil je op de hoogte blijven?" @@ -5441,7 +5441,7 @@ msgstr "E-mailverificatie | dembrane" msgid "error.action.contact_admin" msgstr "E-mail je beheerder" -#: src/portal/routes/ParticipantPostConversation.tsx:183 +#: src/portal/routes/ParticipantPostConversation.tsx:204 msgid "email@work.com" msgstr "email@werk.com" @@ -10723,7 +10723,7 @@ msgstr "Controleer uw invoer voor fouten." msgid "Please enable participation to enable sharing" msgstr "Schakel deelneming in om delen mogelijk te maken" -#: src/portal/routes/ParticipantPostConversation.tsx:92 +#: src/portal/routes/ParticipantPostConversation.tsx:113 msgid "Please enter a valid email." msgstr "Voer een geldig e-mailadres in." @@ -11558,7 +11558,7 @@ msgstr "Opname starten" msgid "Record a voice message" msgstr "Spraakbericht opnemen" -#: src/portal/routes/ParticipantPostConversation.tsx:161 +#: src/portal/routes/ParticipantPostConversation.tsx:182 msgid "Record another conversation" msgstr "Neem nog een gesprek op" @@ -11822,7 +11822,7 @@ msgstr "Toegang intrekken" msgid "Remove avatar" msgstr "Avatar verwijderen" -#: src/portal/routes/ParticipantPostConversation.tsx:214 +#: src/portal/routes/ParticipantPostConversation.tsx:235 msgid "Remove email" msgstr "E-mail verwijderen" @@ -13312,7 +13312,7 @@ msgstr "Delen met hele werkruimte" msgid "Share with workspace" msgstr "Deel met werkruimte" -#: src/portal/routes/ParticipantPostConversation.tsx:177 +#: src/portal/routes/ParticipantPostConversation.tsx:198 msgid "Share your details here" msgstr "Deel je gegevens hier" @@ -13494,7 +13494,7 @@ msgstr "Toon popcorn in maximaal drie extra talen tegelijk." msgid "Show projects" msgstr "Toon projecten" -#: src/portal/routes/ParticipantPostConversation.tsx:152 +#: src/portal/routes/ParticipantPostConversation.tsx:173 msgid "Show QR code" msgstr "QR-code tonen" @@ -14148,7 +14148,7 @@ msgstr "Sterk wachtwoord" msgid "Subject" msgstr "Onderwerp" -#: src/portal/routes/ParticipantPostConversation.tsx:247 +#: src/portal/routes/ParticipantPostConversation.tsx:268 msgid "Submit" msgstr "Stuur in" @@ -14566,11 +14566,11 @@ msgstr "Tekst" msgid "Text contributions and follow-up forms." msgstr "Tekstbijdragen en vervolgformulieren." -#: src/portal/routes/ParticipantPostConversation.tsx:133 +#: src/portal/routes/ParticipantPostConversation.tsx:154 msgid "Thank you for participating!" msgstr "Dank je wel voor je deelname!" -#: src/portal/routes/ParticipantPostConversation.tsx:256 +#: src/portal/routes/ParticipantPostConversation.tsx:277 msgid "Thank you!" msgstr "Bedankt!" @@ -15259,7 +15259,7 @@ msgstr "Deze implementatie toont maximaal {applied} randen." msgid "This deployment shows up to {applied} nodes." msgstr "Deze implementatie toont maximaal {applied} knooppunten." -#: src/portal/routes/ParticipantPostConversation.tsx:88 +#: src/portal/routes/ParticipantPostConversation.tsx:109 msgid "This email is already in the list." msgstr "Deze e-mail is al in de lijst." @@ -16818,7 +16818,7 @@ msgid "Verification prompts allow 10,000 characters, and verified outcomes have msgstr "Verificatieprompts mogen 10.000 tekens bevatten en geverifieerde uitkomsten hebben een kopieerknop." #. js-lingui-explicit-id -#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:167 +#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:176 msgid "participant.banner.verification_required" msgstr "Verificatie vereist" @@ -17179,7 +17179,7 @@ msgstr "We zetten samen het project op, draaien op de dag zelf met je mee en hel msgid "We still couldn't charge your method. Update it and try again." msgstr "We konden je methode nog steeds niet belasten. Werk deze bij en probeer het opnieuw." -#: src/portal/routes/ParticipantPostConversation.tsx:267 +#: src/portal/routes/ParticipantPostConversation.tsx:288 msgid "We will only send you a message if your host generates a report, we never share your details with anyone. You can opt out at any time." msgstr "We sturen u alleen een bericht als uw gastgever een rapport genereert, we delen uw gegevens niet met iemand. U kunt op elk moment afmelden." @@ -18416,7 +18416,7 @@ msgstr "Hier komen je projecten. Een project bevat alles voor één onderwerp: d msgid "Your recording, {0}" msgstr "Je opname, {0}" -#: src/portal/routes/ParticipantPostConversation.tsx:137 +#: src/portal/routes/ParticipantPostConversation.tsx:158 msgid "Your response has been recorded. You may now close this tab. You may also share the QR code so others can contribute, or record another conversation." msgstr "Je antwoord is opgeslagen. Je kunt dit tabblad sluiten. Je kunt ook de QR-code delen zodat anderen kunnen bijdragen, of nog een gesprek opnemen." diff --git a/dembrane/frontend/src/locales/uk-UA.po b/dembrane/frontend/src/locales/uk-UA.po index 2a3e765dd..b229dfda1 100644 --- a/dembrane/frontend/src/locales/uk-UA.po +++ b/dembrane/frontend/src/locales/uk-UA.po @@ -409,7 +409,7 @@ msgid "{0} deleted" msgstr "Видалено: {0}" #. placeholder {0}: failed.length -#: src/lib/api.ts:622 +#: src/lib/api.ts:687 msgid "{0} file(s) failed to upload. Try those again." msgstr "Не вдалося завантажити {0} файл(ів). Спробуйте ще раз." @@ -1502,7 +1502,7 @@ msgstr "Активність" #: src/routes/organisation/OrganisationRoute.tsx:2106 #: src/routes/organisation/OrganisationRoute.tsx:2119 #: src/routes/organisation/OrganisationRoute.tsx:2142 -#: src/portal/routes/ParticipantPostConversation.tsx:199 +#: src/portal/routes/ParticipantPostConversation.tsx:220 #: src/components/chat/TagsUpdateSuggestionCard.tsx:185 #: src/components/billing/BillingManager.tsx:1392 msgid "Add" @@ -1698,7 +1698,7 @@ msgstr "Додано {granted} користувачів" msgid "Added by a host" msgstr "Додано ведучим" -#: src/portal/routes/ParticipantPostConversation.tsx:208 +#: src/portal/routes/ParticipantPostConversation.tsx:229 msgid "Added emails" msgstr "Added emails" @@ -1905,7 +1905,7 @@ msgid "All" msgstr "All" #. placeholder {0}: payload.chunks.length -#: src/lib/api.ts:752 +#: src/lib/api.ts:817 msgid "All {0} file(s) uploaded successfully" msgstr "Усі файли ({0}) успішно завантажено" @@ -2112,7 +2112,7 @@ msgstr "Сповіщення електронною поштою буде над msgid "An email notification will be sent to participants. Do you want to proceed?" msgstr "Учасникам буде надіслано сповіщення електронною поштою. Продовжити?" -#: src/portal/routes/ParticipantStart.tsx:85 +#: src/portal/routes/ParticipantStart.tsx:90 msgid "An error occurred while loading the portal. Please contact the support team." msgstr "Під час завантаження порталу сталася помилка. Зверніться до служби підтримки." @@ -5071,7 +5071,7 @@ msgstr "Do I need this?" msgid "Do you plan to use dembrane in health, education, recruitment, critical infrastructure management, law enforcement or justice contexts?" msgstr "Чи плануєте ви використовувати dembrane у сфері охорони здоров’я, освіти, найму персоналу, управління критичною інфраструктурою, правоохоронної діяльності чи правосуддя?" -#: src/portal/routes/ParticipantPostConversation.tsx:174 +#: src/portal/routes/ParticipantPostConversation.tsx:195 msgid "Do you want to stay in the loop?" msgstr "Do you want to stay in the loop?" @@ -5444,7 +5444,7 @@ msgstr "Підтвердження електронної пошти | dembrane" msgid "error.action.contact_admin" msgstr "Написати адміністратору" -#: src/portal/routes/ParticipantPostConversation.tsx:183 +#: src/portal/routes/ParticipantPostConversation.tsx:204 msgid "email@work.com" msgstr "email@work.com" @@ -10726,7 +10726,7 @@ msgstr "Please check your inputs for errors." msgid "Please enable participation to enable sharing" msgstr "Please enable participation to enable sharing" -#: src/portal/routes/ParticipantPostConversation.tsx:92 +#: src/portal/routes/ParticipantPostConversation.tsx:113 msgid "Please enter a valid email." msgstr "Please enter a valid email." @@ -11561,7 +11561,7 @@ msgstr "Record" msgid "Record a voice message" msgstr "Записати голосове повідомлення" -#: src/portal/routes/ParticipantPostConversation.tsx:161 +#: src/portal/routes/ParticipantPostConversation.tsx:182 msgid "Record another conversation" msgstr "Record another conversation" @@ -11825,7 +11825,7 @@ msgstr "Скасувати доступ" msgid "Remove avatar" msgstr "Remove avatar" -#: src/portal/routes/ParticipantPostConversation.tsx:214 +#: src/portal/routes/ParticipantPostConversation.tsx:235 msgid "Remove email" msgstr "Видалити адресу" @@ -13315,7 +13315,7 @@ msgstr "Поділитися з усім робочим простором" msgid "Share with workspace" msgstr "Поділитися з робочим простором" -#: src/portal/routes/ParticipantPostConversation.tsx:177 +#: src/portal/routes/ParticipantPostConversation.tsx:198 msgid "Share your details here" msgstr "Share your details here" @@ -13497,7 +13497,7 @@ msgstr "Показуйте popcorn одночасно ще до трьох мо msgid "Show projects" msgstr "Показати проєкти" -#: src/portal/routes/ParticipantPostConversation.tsx:152 +#: src/portal/routes/ParticipantPostConversation.tsx:173 msgid "Show QR code" msgstr "Показати QR-код" @@ -14151,7 +14151,7 @@ msgstr "Надійний пароль" msgid "Subject" msgstr "Тема" -#: src/portal/routes/ParticipantPostConversation.tsx:247 +#: src/portal/routes/ParticipantPostConversation.tsx:268 msgid "Submit" msgstr "Submit" @@ -14569,11 +14569,11 @@ msgstr "Text" msgid "Text contributions and follow-up forms." msgstr "Текстові внески та форми для подальшого зв’язку." -#: src/portal/routes/ParticipantPostConversation.tsx:133 +#: src/portal/routes/ParticipantPostConversation.tsx:154 msgid "Thank you for participating!" msgstr "Thank you for participating!" -#: src/portal/routes/ParticipantPostConversation.tsx:256 +#: src/portal/routes/ParticipantPostConversation.tsx:277 msgid "Thank you!" msgstr "Thank you!" @@ -15262,7 +15262,7 @@ msgstr "У цьому розгортанні показується до {applie msgid "This deployment shows up to {applied} nodes." msgstr "У цьому розгортанні показується до {applied} вузлів." -#: src/portal/routes/ParticipantPostConversation.tsx:88 +#: src/portal/routes/ParticipantPostConversation.tsx:109 msgid "This email is already in the list." msgstr "This email is already in the list." @@ -16823,7 +16823,7 @@ msgid "Verification prompts allow 10,000 characters, and verified outcomes have msgstr "Підказки для перевірки можуть містити до 10 000 символів, а перевірені результати мають кнопку копіювання." #. js-lingui-explicit-id -#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:167 +#: src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx:176 msgid "participant.banner.verification_required" msgstr "Verification required" @@ -17184,7 +17184,7 @@ msgstr "Ми налаштовуємо проєкт, підтримуємо ва msgid "We still couldn't charge your method. Update it and try again." msgstr "Усе ще не вдалося списати кошти. Оновіть спосіб оплати та спробуйте знову." -#: src/portal/routes/ParticipantPostConversation.tsx:267 +#: src/portal/routes/ParticipantPostConversation.tsx:288 msgid "We will only send you a message if your host generates a report, we never share your details with anyone. You can opt out at any time." msgstr "We will only send you a message if your host generates a report, we never share your details with anyone. You can opt out at any time." @@ -18421,7 +18421,7 @@ msgstr "Тут з’являться ваші проєкти. Проєкт мі msgid "Your recording, {0}" msgstr "Ваш запис, {0}" -#: src/portal/routes/ParticipantPostConversation.tsx:137 +#: src/portal/routes/ParticipantPostConversation.tsx:158 msgid "Your response has been recorded. You may now close this tab. You may also share the QR code so others can contribute, or record another conversation." msgstr "Вашу відповідь записано. Тепер ви можете закрити цю вкладку. Ви також можете поділитися QR-кодом, щоб інші могли долучитися, або записати ще одну розмову." diff --git a/dembrane/frontend/src/portal/components/conversation/audio/ParticipantConversationAudioContent.test.tsx b/dembrane/frontend/src/portal/components/conversation/audio/ParticipantConversationAudioContent.test.tsx index a2eb8d999..b14e44fcf 100644 --- a/dembrane/frontend/src/portal/components/conversation/audio/ParticipantConversationAudioContent.test.tsx +++ b/dembrane/frontend/src/portal/components/conversation/audio/ParticipantConversationAudioContent.test.tsx @@ -5,22 +5,40 @@ import { MantineProvider } from "@mantine/core"; import { cleanup, render, screen } from "@testing-library/react"; import { MemoryRouter, Outlet, Route, Routes } from "react-router"; import { afterEach, beforeAll, expect, it, vi } from "vitest"; +import { + clearAllParticipantTokens, + getParticipantToken, + PARTICIPANT_TOKEN_HEADER, + setParticipantToken, +} from "@/lib/participantToken"; import { ParticipantConversationAudioContent } from "./ParticipantConversationAudioContent"; const state = vi.hoisted(() => ({ + chatOptions: undefined as + | { + headers?: Record; + onError?: (error: Error) => void; + } + | undefined, echoError: undefined as Error | undefined, project: {} as Record, })); vi.mock("@ai-sdk/react", () => ({ - useChat: () => ({ - data: undefined, - error: state.echoError, - handleSubmit: vi.fn(), - isLoading: false, - messages: [], - status: state.echoError ? "error" : "ready", - }), + useChat: (options: { + headers?: Record; + onError?: (error: Error) => void; + }) => { + state.chatOptions = options; + return { + data: undefined, + error: state.echoError, + handleSubmit: vi.fn(), + isLoading: false, + messages: [], + status: state.echoError ? "error" : "ready", + }; + }, })); vi.mock("@/portal/components/conversation/queries", () => ({ useConversationQuery: () => ({ data: undefined }), @@ -68,6 +86,9 @@ beforeAll(() => { afterEach(() => { cleanup(); + sessionStorage.clear(); + clearAllParticipantTokens(); + state.chatOptions = undefined; state.echoError = undefined; state.project = {}; }); @@ -125,3 +146,26 @@ it("keeps the generic error for other Explore failures", () => { expect(screen.getByText(/Something went wrong/)).toBeTruthy(); expect(screen.queryByText("Not available right now")).toBeNull(); }); + +it("attaches X-Participant-Token to Explore replies when stored for the conversation", () => { + setParticipantToken("c-1", "p1.explore.sig"); + renderPage(); + expect(state.chatOptions?.headers).toEqual({ + [PARTICIPANT_TOKEN_HEADER]: "p1.explore.sig", + }); +}); + +it("omits X-Participant-Token from Explore replies when no token is stored", () => { + renderPage(); + expect(state.chatOptions?.headers).toEqual({}); +}); + +it("clears the stored token when Explore fails with participant.token_invalid", () => { + vi.spyOn(console, "error").mockImplementation(() => {}); + setParticipantToken("c-1", "p1.rotated.sig"); + renderPage(); + state.chatOptions?.onError?.( + new Error(JSON.stringify({ code: "participant.token_invalid" })), + ); + expect(getParticipantToken("c-1")).toBeNull(); +}); diff --git a/dembrane/frontend/src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx b/dembrane/frontend/src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx index 0d4f42b2e..f952c10c7 100644 --- a/dembrane/frontend/src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx +++ b/dembrane/frontend/src/portal/components/conversation/audio/ParticipantConversationAudioContent.tsx @@ -13,6 +13,11 @@ import { import { API_BASE_URL } from "@/config"; import { useLanguage } from "@/hooks/useLanguage"; import { useLoadNotification } from "@/hooks/useLoadNotification"; +import { + clearParticipantToken, + isParticipantTokenRejection, + participantTokenHeaders, +} from "@/lib/participantToken"; import { useConversationQuery, useConversationRepliesQuery, @@ -78,6 +83,7 @@ export const ParticipantConversationAudioContent = () => { language: iso639_1, }; }, + headers: participantTokenHeaders(conversationId), initialMessages: repliesQuery.data?.map((msg) => ({ content: msg.content_text ?? "", @@ -85,6 +91,9 @@ export const ParticipantConversationAudioContent = () => { role: msg.type === "assistant_reply" ? "assistant" : "user", })) ?? [], onError: (error) => { + if (isParticipantTokenRejection(error)) { + clearParticipantToken(conversationId); + } console.error("onError", error); removeValue(); }, diff --git a/dembrane/frontend/src/portal/components/verify/hooks/index.ts b/dembrane/frontend/src/portal/components/verify/hooks/index.ts index 00aeddc31..b23c34a40 100644 --- a/dembrane/frontend/src/portal/components/verify/hooks/index.ts +++ b/dembrane/frontend/src/portal/components/verify/hooks/index.ts @@ -75,6 +75,7 @@ export const useUpdateVerificationArtefact = () => { return useMutation({ mutationFn: async ({ artifactId, + conversationId, useConversation, content, approvedAt, @@ -83,6 +84,7 @@ export const useUpdateVerificationArtefact = () => { approvedAt, artifactId, content, + conversationId, useConversation, }; return updateVerificationArtefact(payload); @@ -113,7 +115,10 @@ export const useVerificationArtefactById = ( return cachedArtifact; } - const artefact = await getVerificationArtefactById(artifactId); + const artefact = await getVerificationArtefactById( + artifactId, + conversationId, + ); queryClient.setQueryData( ["verify", "artifact_by_id", artifactId], diff --git a/dembrane/frontend/src/portal/routes/ParticipantPostConversation.test.tsx b/dembrane/frontend/src/portal/routes/ParticipantPostConversation.test.tsx new file mode 100644 index 000000000..47b0a3f0e --- /dev/null +++ b/dembrane/frontend/src/portal/routes/ParticipantPostConversation.test.tsx @@ -0,0 +1,126 @@ +// @vitest-environment jsdom +import { i18n } from "@lingui/core"; +import { I18nProvider } from "@lingui/react"; +import { MantineProvider } from "@mantine/core"; +import { cleanup, render } from "@testing-library/react"; +import { StrictMode } from "react"; +import { MemoryRouter, Route, Routes } from "react-router"; +import { afterEach, beforeAll, expect, it, vi } from "vitest"; +import { + clearAllParticipantTokens, + getParticipantToken, + setParticipantToken, +} from "@/lib/participantToken"; +import { ParticipantPostConversation } from "./ParticipantPostConversation"; + +const projectState = vi.hoisted(() => ({ + data: { + default_conversation_ask_for_participant_email: false, + default_conversation_finish_text: null, + id: "p-1", + is_dembrane_event_cta_enabled: false, + is_project_notification_subscription_allowed: false, + }, +})); + +vi.mock("@/portal/hooks/useParticipantProjectById", () => ({ + useParticipantProjectById: () => ({ + data: projectState.data, + isLoading: false, + }), +})); + +vi.mock("@/portal/routes/useSubmitNotificationParticipant", () => ({ + useSubmitNotificationParticipant: () => ({ + isPending: false, + mutate: vi.fn(), + }), +})); + +vi.mock("@/portal/components/ParticipantShareModal", () => ({ + ParticipantShareModal: () => null, +})); + +vi.mock("@/portal/components/finish/DembraneEventCta", () => ({ + DembraneEventCta: () => null, +})); + +beforeAll(() => { + i18n.load("en", {}); + i18n.activate("en"); + window.matchMedia = + window.matchMedia || + ((query: string) => ({ + addEventListener: () => {}, + addListener: () => {}, + dispatchEvent: () => false, + matches: false, + media: query, + onchange: null, + removeEventListener: () => {}, + removeListener: () => {}, + })); +}); + +afterEach(() => { + cleanup(); + sessionStorage.clear(); + clearAllParticipantTokens(); + projectState.data = { + default_conversation_ask_for_participant_email: false, + default_conversation_finish_text: null, + id: "p-1", + is_dembrane_event_cta_enabled: false, + is_project_notification_subscription_allowed: false, + }; +}); + +const renderFinish = () => + render( + + + + + } + /> + + + + , + ); + +// The finish screen is where a participant still acts on their conversation (report +// sign-up, and the landscape choice that follows), so the token stays while it is open. +it("keeps the participant token on the finish screen and clears it on leaving", async () => { + setParticipantToken("c-1", "p1.done.sig"); + const view = renderFinish(); + expect(getParticipantToken("c-1")).toBe("p1.done.sig"); + + view.unmount(); + await new Promise((r) => setTimeout(r, 0)); + expect(getParticipantToken("c-1")).toBeNull(); +}); + +it("a remount, as StrictMode does in dev, keeps the token", async () => { + setParticipantToken("c-1", "p1.done.sig"); + render( + + + + + + } + /> + + + + + , + ); + await new Promise((r) => setTimeout(r, 0)); + expect(getParticipantToken("c-1")).toBe("p1.done.sig"); +}); diff --git a/dembrane/frontend/src/portal/routes/ParticipantPostConversation.tsx b/dembrane/frontend/src/portal/routes/ParticipantPostConversation.tsx index 15f62d210..5814e0389 100644 --- a/dembrane/frontend/src/portal/routes/ParticipantPostConversation.tsx +++ b/dembrane/frontend/src/portal/routes/ParticipantPostConversation.tsx @@ -20,16 +20,20 @@ import { QrCodeIcon, RepeatIcon, } from "@phosphor-icons/react"; -import { type KeyboardEvent, useRef, useState } from "react"; +import { type KeyboardEvent, useEffect, useRef, useState } from "react"; import { useParams } from "react-router"; import { I18nLink } from "@/components/common/i18nLink"; import { Markdown } from "@/components/common/Markdown"; +import { clearParticipantToken } from "@/lib/participantToken"; import { testId } from "@/lib/testUtils"; import { DembraneEventCta } from "@/portal/components/finish/DembraneEventCta"; import { ParticipantShareModal } from "@/portal/components/ParticipantShareModal"; import { useParticipantProjectById } from "@/portal/hooks/useParticipantProjectById"; import { useSubmitNotificationParticipant } from "@/portal/routes/useSubmitNotificationParticipant"; +// Pending token clears per conversation, so a remount of the same one cancels only its own. +const leaving = new Map>(); + export const ParticipantPostConversation = () => { const { projectId, conversationId } = useParams(); const project = useParticipantProjectById(projectId ?? ""); @@ -44,6 +48,23 @@ export const ParticipantPostConversation = () => { const initiateLink = `/${projectId}/start`; + // The token serves this screen (report sign-up, the landscape choice) and goes when the + // participant leaves it, so a shared tablet does not carry it on. Deferred, so + // StrictMode's dev remount does not count as leaving. + useEffect(() => { + if (!conversationId) return; + clearTimeout(leaving.get(conversationId)); + return () => { + leaving.set( + conversationId, + setTimeout(() => { + leaving.delete(conversationId); + clearParticipantToken(conversationId); + }, 0), + ); + }; + }, [conversationId]); + const variables = { "{{CONVERSATION_ID}}": conversationId ?? "null", "{{PROJECT_ID}}": projectId ?? "null", diff --git a/dembrane/frontend/src/portal/routes/ParticipantStart.test.tsx b/dembrane/frontend/src/portal/routes/ParticipantStart.test.tsx index c3ecbe8db..91369ead7 100644 --- a/dembrane/frontend/src/portal/routes/ParticipantStart.test.tsx +++ b/dembrane/frontend/src/portal/routes/ParticipantStart.test.tsx @@ -5,6 +5,11 @@ import { MantineProvider } from "@mantine/core"; import { cleanup, render, screen } from "@testing-library/react"; import { MemoryRouter, Route, Routes } from "react-router"; import { afterEach, beforeAll, expect, it, vi } from "vitest"; +import { + clearAllParticipantTokens, + getParticipantToken, + setParticipantToken, +} from "@/lib/participantToken"; import { ParticipantStartRoute } from "./ParticipantStart"; vi.mock("posthog-js", () => ({ default: { capture: vi.fn() } })); @@ -48,6 +53,8 @@ beforeAll(() => { afterEach(() => { cleanup(); + sessionStorage.clear(); + clearAllParticipantTokens(); project.current = { id: "p-1", is_ai_available: true, @@ -114,3 +121,9 @@ it("shows the not-taking-recordings page under the portal logo", () => { expect(header.contains(screen.getByTestId("logo"))).toBe(true); expect(screen.queryByTestId("onboarding")).toBeNull(); }); + +it("clears leftover participant tokens when starting a new session", () => { + setParticipantToken("c-previous", "p1.old.sig"); + renderStart("/p-1/start?mode=text"); + expect(getParticipantToken("c-previous")).toBeNull(); +}); diff --git a/dembrane/frontend/src/portal/routes/ParticipantStart.tsx b/dembrane/frontend/src/portal/routes/ParticipantStart.tsx index c3dcda6f6..2882ac92f 100644 --- a/dembrane/frontend/src/portal/routes/ParticipantStart.tsx +++ b/dembrane/frontend/src/portal/routes/ParticipantStart.tsx @@ -9,6 +9,7 @@ import DembraneLoadingSpinner from "@/components/common/DembraneLoadingSpinner"; import { Logo } from "@/components/common/Logo"; import { ENABLE_MONITOR } from "@/config"; import { useVisitorBeacon } from "@/hooks/useVisitorBeacon"; +import { clearAllParticipantTokens } from "@/lib/participantToken"; import { testId } from "@/lib/testUtils"; import { NotTakingRecordings } from "@/portal/components/NotTakingRecordings"; import { resolvePortalMode } from "@/portal/components/recordingCap"; @@ -26,6 +27,10 @@ export const ParticipantStartRoute = () => { const { projectId } = useParams<{ projectId: string }>(); const [searchParams] = useSearchParams(); + useEffect(() => { + clearAllParticipantTokens(); + }, []); + // One visitor beacon for the whole portal onboarding, owned here so it // fires "scanned" the moment the QR link opens — before the project even // loads and before the onboarding deck mounts. The deck reports its finer diff --git a/dembrane/platform/packages/conversations/src/participant-token.ts b/dembrane/platform/packages/conversations/src/participant-token.ts index d82b3be96..bf33693f3 100644 --- a/dembrane/platform/packages/conversations/src/participant-token.ts +++ b/dembrane/platform/packages/conversations/src/participant-token.ts @@ -53,6 +53,24 @@ export class ParticipantTokens { if (this.required) throw new UnauthenticatedError("participant.token_required"); return false; } + this.verify(header, conversationId, projectId); + return true; + } + + /** + * Strict check for routes that always require a valid participant token regardless + * of PARTICIPANT_TOKEN_REQUIRED (landscape, handoff, public-intake). + */ + require( + header: string | undefined, + conversationId: string, + projectId?: string, + ): ParticipantClaims { + if (!header) throw new UnauthenticatedError("participant.token_required"); + return this.verify(header, conversationId, projectId); + } + + private verify(header: string, conversationId: string, projectId?: string): ParticipantClaims { const claims = this.read(header); if ( !claims || @@ -60,7 +78,7 @@ export class ParticipantTokens { (projectId !== undefined && claims.projectId !== projectId) ) throw new ForbiddenError("participant.token_invalid"); - return true; + return claims; } private sign(body: string): string { diff --git a/dembrane/platform/packages/conversations/test/portal-units.test.ts b/dembrane/platform/packages/conversations/test/portal-units.test.ts index 0c0a4c749..f772973b4 100644 --- a/dembrane/platform/packages/conversations/test/portal-units.test.ts +++ b/dembrane/platform/packages/conversations/test/portal-units.test.ts @@ -24,6 +24,23 @@ test("without a token the conversation id still works, until tokens are required ); }); +test("require rejects missing, wrong, and forged tokens even when PARTICIPANT_TOKEN_REQUIRED is false", () => { + const t = new ParticipantTokens("s".repeat(48), false); + const token = t.issue({ conversationId: C, projectId: P }); + + expect(() => t.require(undefined, C, P)).toThrow(UnauthenticatedError); + expect(() => t.require("", C, P)).toThrow(UnauthenticatedError); + expect(() => t.require(token, "other", P)).toThrow(ForbiddenError); + expect(() => t.require(token, C, "other")).toThrow(ForbiddenError); + expect(() => t.require(`${token}x`, C, P)).toThrow(ForbiddenError); + expect(() => new ParticipantTokens("x".repeat(48), false).require(token, C, P)).toThrow( + ForbiddenError, + ); + + expect(t.require(token, C, P)).toEqual({ conversationId: C, projectId: P }); + expect(t.require(token, C)).toEqual({ conversationId: C, projectId: P }); +}); + test("stored audio paths round-trip to keys the way get_sanitized_s3_key parsed them", () => { const u = new AudioUrls("https://ams3.digitaloceanspaces.com", "dembrane"); const key = `conversation/${C}/chunks/x-a.webm`;