Public Sharing Links
Relevant source files
The following files were used as context for generating this wiki page:
Public Sharing Links allow users to generate unique, secure tokens that provide anonymous access to specific resources, such as a "Source," within the Briefy platform. This feature enables knowledge sharing with external stakeholders or the public without requiring the recipient to have an account or be authenticated.
These links are designed with security and control in mind, offering configurable expiration periods and the ability to revoke access at any time. When a resource is shared, the recipient can view the content, metadata, and even listen to generated narrations through a dedicated public interface.
Sources: apps/web/src/features/sources/components/ShareDialog.tsx, apps/web/src/routes/share/$token.tsx
Architecture and Data Flow
The sharing system is split into a management layer (creation and revocation) and a consumption layer (public viewing). Users interact with a ShareDialog within the authenticated application to manage links, while external users access the $token.tsx route to view shared content.
Sharing Lifecycle
The following diagram illustrates the lifecycle of a public sharing link, from creation to consumption and eventual revocation or expiration.
Management Interface
Users manage sharing through the ShareDialog component, which is accessible from the Source header.
Configuration Options
Users can choose the validity period for a new link. The frontend calculates the expiresAt timestamp based on the selection:
| Validity Option | Duration (ms) | Description |
|---|---|---|
7d | 604,800,000 | Expires in 7 days |
30d | 2,592,000,000 | Expires in 30 days |
90d | 7,776,000,000 | Expires in 90 days |
never | N/A | Link never expires automatically |
Sources: apps/web/src/features/sources/components/ShareDialog.tsx:16-28
Key Management Functions
createShareLink: Generates a new token for a specific target type (e.g.,SOURCE) and ID.listShareLinks: Retrieves all active links created for a specific resource.revokeShareLink: Immediately invalidates a specific link ID, removing public access.copyToClipboard: Formats the share URL as${window.location.origin}/share/${token}and copies it to the system clipboard.
Sources: apps/web/src/features/sources/components/ShareDialog.tsx:55-102
Public Viewing and Resolution
The public route /share/$token is responsible for resolving the token and rendering the content.
Token Resolution Logic
The resolution process includes several validation checks performed by the backend and handled by the frontend:
- 404 Not Found: The link does not exist or has been manually revoked.
- 410 Gone: The link has passed its
expiresAttimestamp. - 500 Error: General server failure during resolution.
Sources: apps/web/src/routes/share/$token.tsx:25-39
Shared Content Rendering
The public page displays a subset of the resource data, specifically curated for external viewing:
- Metadata: Source type, author, published date, reading time, and original URL (with domain extraction).
- Audio Narration: If a narration exists, a
PublicNarrationPlayeris rendered. - Markdown Content: The main body of the source is rendered as formatted article content.
- Expiration Notice: If the link has an expiration date, it is displayed at the bottom of the page.
Sources: apps/web/src/routes/share/$token.tsx:82-140
Technical Implementation Details
Data Model: ShareLinkDto
The sharing system uses a Data Transfer Object (DTO) to communicate link status:
| Field | Type | Description |
|---|---|---|
id | string | Internal unique identifier for the link record. |
token | string | The unique secure token used in the URL. |
targetId | string | The ID of the resource being shared (e.g., sourceId). |
expiresAt | string (ISO) | Optional timestamp when the link becomes invalid. |
Sources: apps/web/src/features/sources/components/ShareDialog.tsx:11-14
Implementation Findings
- Security: The global web audio player used in the authenticated app relies on
/api/sources/{id}/audio, which requires authentication. Public share pages require thePublicNarrationPlayerto handle narration refresh or playback without requiring a user session. - State Management: The
resolveShareLinkfunction is the primary entry point for fetching shared data. If successful, the document title is updated to match the shared source's title.
Sources: AGENT_NOTES.md:204-208, apps/web/src/routes/share/$token.tsx:49-55
Conclusion
The Public Sharing Links feature provides a controlled gateway to Briefy's knowledge graph. By decoupling resource access from user authentication via secure, time-limited tokens, the system enables collaboration while maintaining strict ownership controls through the management and revocation interface.
Sources: apps/web/src/features/sources/components/ShareDialog.tsx, apps/web/src/routes/share/$token.tsx