import { computed, handler, NAME, pattern, Stream, UI, Writable, } from "commonfabric"; import { TrustedRecipientConfirmSurface, TrustedRedactedReleaseSurface, } from "../cfc/trusted-surfaces/mod.ts"; export type ConfirmationReleaseExampleOutput = { [NAME]: string; [UI]: unknown; decoyStatus: string; recipientLabel?: string; payloadPreview?: string; confirmedRecipientRelease?: string; redactionLabel?: string; sourceText?: string; releasedRedactedContent?: string; confirmRecipientRelease?: Stream; releaseRedactedContent?: Stream; triggerDecoy: Stream; }; const setDecoyStatus = handler< void, { decoyStatus: Writable; message: string } >((_, { decoyStatus, message }) => { decoyStatus.set(message); }); export const FinanceRecipientConfirmExample = pattern< Record, ConfirmationReleaseExampleOutput >(() => { const recipientLabel = new Writable("finance@example.com"); const payloadPreview = new Writable("Quarterly budget packet"); const confirmedRecipientRelease = new Writable(""); const decoyStatus = new Writable("Host finance shortcut is idle."); const triggerDecoy = setDecoyStatus({ decoyStatus, message: "Host finance send shortcut is untrusted.", }); const trusted = TrustedRecipientConfirmSurface({ recipientLabel, payloadPreview, confirmedRecipientRelease, }); return { [NAME]: computed(() => "Finance Recipient Confirmation"), [UI]: ( Untrusted finance host The host can suggest a send action, but the trusted recipient surface is the only authority to release it. Send packet without confirmation
{decoyStatus}
{trusted}
), recipientLabel, payloadPreview, confirmedRecipientRelease, decoyStatus, confirmRecipientRelease: trusted.confirmRecipientRelease, triggerDecoy, }; }); export const CustomerSupportRecipientConfirmExample = pattern< Record, ConfirmationReleaseExampleOutput >(() => { const recipientLabel = new Writable("support lead"); const payloadPreview = new Writable("case transcript excerpt"); const confirmedRecipientRelease = new Writable(""); const decoyStatus = new Writable("Host support shortcut is idle."); const triggerDecoy = setDecoyStatus({ decoyStatus, message: "Host support reply shortcut is untrusted.", }); const trusted = TrustedRecipientConfirmSurface({ recipientLabel, payloadPreview, confirmedRecipientRelease, }); return { [NAME]: computed(() => "Customer Support Recipient Confirmation"), [UI]: ( Untrusted support host The support console embeds a reviewed confirmation surface for the actual recipient and transcript excerpt. Send reply without confirmation
{decoyStatus}
{trusted}
), recipientLabel, payloadPreview, confirmedRecipientRelease, decoyStatus, confirmRecipientRelease: trusted.confirmRecipientRelease, triggerDecoy, }; }); export const PatientCaseRedactedReleaseExample = pattern< Record, ConfirmationReleaseExampleOutput >(() => { const redactionLabel = new Writable("patient case"); const sourceText = new Writable( "Patient secret code 123-45-6789 can be released only after redaction.", ); const releasedRedactedContent = new Writable(""); const decoyStatus = new Writable("Host patient export is idle."); const triggerDecoy = setDecoyStatus({ decoyStatus, message: "Host patient export did not release content.", }); const trusted = TrustedRedactedReleaseSurface({ redactionLabel, sourceText, releasedRedactedContent, }); return { [NAME]: computed(() => "Patient Case Redacted Release"), [UI]: ( Untrusted case host The host offers a one-click export, while the trusted surface shows the source and commits only a redacted derivative. Export original case text
{decoyStatus}
{trusted}
), redactionLabel, sourceText, releasedRedactedContent, decoyStatus, releaseRedactedContent: trusted.releaseRedactedContent, triggerDecoy, }; }); export const SecurityIncidentRedactedReleaseExample = pattern< Record, ConfirmationReleaseExampleOutput >(() => { const redactionLabel = new Writable("incident"); const sourceText = new Writable( "Incident note contains secret escalation details for responders.", ); const releasedRedactedContent = new Writable(""); const decoyStatus = new Writable("Host incident export is idle."); const triggerDecoy = setDecoyStatus({ decoyStatus, message: "Host incident export did not release content.", }); const trusted = TrustedRedactedReleaseSurface({ redactionLabel, sourceText, releasedRedactedContent, }); return { [NAME]: computed(() => "Security Incident Redacted Release"), [UI]: ( Untrusted incident host The incident console embeds the trusted redaction surface so the protected release is not an ambient host-side export. Export incident note directly
{decoyStatus}
{trusted}
), redactionLabel, sourceText, releasedRedactedContent, decoyStatus, releaseRedactedContent: trusted.releaseRedactedContent, triggerDecoy, }; }); const EXAMPLE_TITLES = [ "Finance Recipient Confirmation", "Customer Support Recipient Confirmation", "Patient Case Redacted Release", "Security Incident Redacted Release", ] as const; export default pattern>(() => ({ [NAME]: computed(() => "Confirmation and Redacted Release Examples"), [UI]: ( Recipient confirmation and redacted release These untrusted host wrappers embed trusted surfaces for recipient confirmation and source-visible redacted release. The gallery currently exposes {EXAMPLE_TITLES.length}{" "} example patterns. Catalog {EXAMPLE_TITLES.map((title, index) => (
{index + 1}. {title}
))}
{FinanceRecipientConfirmExample}
{CustomerSupportRecipientConfirmExample}
{PatientCaseRedactedReleaseExample}
{SecurityIncidentRedactedReleaseExample}
), exampleCount: EXAMPLE_TITLES.length, }));