Blob messaging — implementation draft

The message content profile specifies format interpretation, HTML safety, recipient privacy, form-result semantics, and motion controls without prescribing rendering APIs or SDKs.

Status: core implemented with unit evidence; no claim of public deployment, archive format registration, malware scanning, or interoperable messaging clients.

Model and persistence interface

The product model is one stream of messages and conversations, with configurable Views that filter its metadata. A View does not own content: an item may appear in several Views, and deleting or changing a View never moves or deletes messages. Views are not authorization scopes; existing app grants remain independent of their mutable filters.

The current runtime provides saved owner View definitions through /api/views and paginated metadata projections through /api/incoming. Filters combine tags, read status, item type, classification and bounded received times. Conversation events project to a conversation card. See the implementation and compatibility boundary. The collection fields and operations below describe retained legacy transport/authorization partitions, not user-facing inboxes. They must not be silently replaced by a View identifier or mutable tag predicate.

Messages consist of immutable decoded bytes and owner-managed metadata: {id,owner,collection,mimeType,size,receivedAt,readAt,tags,classification,quarantined,grantId} plus separately stored untrusted senderMetadata:{subject,tags} when provided. Raw sender annotations remain untrusted. New contact grants separately authorize required delivery tags and a bounded optional selection; only that validated policy supplies initial owner tags and tag rule inputs. readAt:null means unread. Classifications are unclassified, personal, work, spam, and automation; they are organizational labels, not content safety judgments. The shared signed contact endpoint renders a composer on HTML GET, mints a distinct five-minute inbox JWT on the proposed token-MIME GET, and accepts an intentional multipart POST to that same URL. Neither GET sends a message. Authenticated owner routes call list/read/update/delete; owner identity must come from a verified session, never a request field.

packages/messaging/index.mjs exports ContactEndpointService, ContactTokenService, MessagingService, NotificationService, content utilities, and MemoryMessagingStore. The endpoint service receives the grant registry as tokens and an injected signer; MessagingService receives this endpoint service as its tokens verifier. Legacy ContactTokenService remains the internal parent/key registry and compatibility implementation, not the new published contact representation. Other services receive {store,crypto,clock}. Store contract is transaction(async tx => result), with tx.get(key), tx.set(key,value), tx.delete(key), and tx.list(prefix) returning {key,value}[]. Transactions must be serializable, atomic, and roll back on failure. Values include Uint8Array byte content. Plain eventually consistent KV or independently committed statements do not satisfy this contract.

The in-memory adapter serializes operations and is a test/reference implementation. A Durable Object adapter may persist metadata transactionally and externalize immutable bytes to R2. Object writes require bounded staging, unguessable keys scoped to owner/message, metadata commit after successful object storage, and orphan cleanup on failed metadata commits. Never accept arbitrary caller bucket keys. Downloads must verify current owner authorization before resolving an object. Byte accounting, quota reservation, deduplication receipts, metadata, and notification events must commit together; external blob failures must not acknowledge acceptance. Durable-object storage's value-size limit means production adapters must externalize large blobs rather than storing an entire message as one value.

Operations and rules

createCollection(owner,name) returns {id,owner,name,active}. At most 100 collections are accepted. disableCollection revokes associated invitations immediately. receive(token,{collection,mimeType,bytes,idempotencyKey}) binds a receipt to invitation + collection + MIME + SHA-256 of immutable copied bytes. Identical concurrent sends return one acceptance; changed payload under the same key is rejected. Signature, scope, and revocation still apply on replay. Quota consumption is cumulative per invitation and is not refunded when a recipient deletes a message. Account stored-byte/message quotas are refunded on deletion. Defaults cap stored account data at 1 GiB / 10,000 messages.

list(owner,{collection?,unread?,quarantined?,limit?}) returns metadata, newest first, up to 1,000 entries; cursor pagination is not implemented. read(owner,id) returns bytes and metadata without changing unread status. update(owner,id,{read?,collection?,tags?,classification?,quarantined?}) changes only those fields. delete removes message content and its notification event. Moving requires a live destination owned by the same account. Lists and message IDs cannot cross account namespaces.

Rules are an ordered array, at most 100: {id,enabled,match:{grantId?,mimeType?,collection?,tagsAll?},actions:{collection?,tags?,classification?,quarantined?}}. Empty match applies to all deliveries. All comparisons use original delivery metadata, including validated delivery tags, preventing accidental rule cascades. tagsAll requires every listed tag; raw sender annotations are not a substitute. Matching actions apply in order; tags replace the current tag array. Quarantine is sticky during ingestion: a later rule cannot undo it. Only explicit owner action releases quarantine. Rules cannot mark an incoming message read, execute code, fetch URLs, trigger remote requests, or expand sender grant scope. A rule targeting a disabled destination is skipped. A grant-wide quarantine rule supports pausing a contact without notifying about its messages. Revoking its invitation blocks acceptance entirely.

Tags are opaque identifiers; labels are presentation and are never part of tag identity. Renaming a label must not change stored tags, rules or contact tag configuration. A host may reserve a namespace prefix for host-defined tags whose meaning and localized labels it documents. A sender may introduce only tag IDs the recipient explicitly allowed for that contact; it cannot otherwise introduce host-reserved IDs. Automated suggestions SHOULD remain distinguishable from recipient-final tags. Tag provenance, host registries and default rules are recipient-private service behavior; the 3sln.me profile is described in tags.

Reference-service receipt limits

The 3sln.me runtime applies additional durable recipient-wide and contact-parent message admission limits. These are service policy, not mandatory Bindle-wide rates. Owner counters use the stable account ID across all aliases and contact links; minted child tokens share the recorded parent link counter. Conversation invitations use contact admission, while stored conversation events consume the same owner allowance. Existing request, lifetime grant, storage quota, combined activity and physical-write safeguards remain in force and may refuse earlier. The runtime's per-message ceiling is one MiB; library/archive format ceilings described here are not a promise that a deployed endpoint accepts that size. Storage allowances depend on the account plan, rather than the MessagingService library default.

Default owner ceilings use UTC fixed minute/hour/day windows:

Plan Messages: minute / hour / day Payload MiB: minute / hour / day
Free 30 / 300 / 1,000 16 / 128 / 512
Paid 120 / 1,000 / 5,000 64 / 512 / 2,048
Plus 240 / 2,000 / 10,000 128 / 1,024 / 4,096
Ultra 240 / 2,000 / 10,000 256 / 2,048 / 8,192

Each contact parent's default count and byte ceilings are half its owner's ceilings. Usage survives token refresh, restart, shelving and plan changes. A new parent still shares the owner cap. Fixed windows reset at their UTC boundary; existing rolling activity and write guards continue to bound bursts around that boundary. A provisional checkout upgrade does not increase receipt capacity before confirmation.

The charged unit is an admitted new message attempt, not a successful delivery. Validation, live authorization, established idempotency replay and storage-quota checks run before this debit. Downstream failure may consume an admission until the window resets. An established authorized identical replay returns its original result without another receipt debit or new message blob write; changed content under the same key conflicts, and expired/revoked credentials cannot retrieve a receipt. Deleting or offloading content does not refund admission usage.

Window exhaustion returns HTTP429 with message_receipt_limited and a bounded Retry-After in seconds. Signed contact URLs and bearer delivery expose that header through CORS. Senders should retain their operation ID and immutable payload for a retry, respect the delay and avoid tight retry loops. Disabled configured allowances have no promised retry time; content that can never fit a configured byte allowance returns413. Other grant/quota failures retain their existing semantics and do not imply that waiting renews a link. No response exposes another link's usage or the owner's classification results.

Self-host operators can configure MESSAGE_RECEIPT_LIMITS as JSON, with optional plan entries containing exactly owner and contact; each contains exactly minute, hour, day, each with integer messages and bytes. Omitted plans use defaults. Contact limits cannot exceed owner limits; zero disables that allowance. Malformed configuration fails closed. The current bounded record supports256 active-day contact parents per owner; new-parent capacity exhaustion refuses with a retry delay. Owner snapshots expose messageReceiptAdmission and its explicit unit. Independent user-editable per-link rates are not implemented.

Automated multi-label classification and rejection-summary push/email delivery are separate proposed features, not enabled by these receipt limits. Current classifications and owner rules retain the behavior described above.

Safe rendering and bounded archives

Treat sender bytes and MIME labels as hostile. Plain text requires strict UTF-8 and renders escaped in a pre element. HTML uses a deliberately small inert formatting-tag allowlist. Every tag is reconstructed; every attribute, URL, image, script, style, form, embedded document and custom element is removed. Text is escaped. Rich HTML entities may display literally; exact original styling is not preserved. This is a safe reduced-format viewer, not a general browser or high-fidelity sanitizer.

renderMessage returns either a document with sandbox:"", referrerPolicy:"no-referrer", and CSP, or an attachment descriptor. Document HTML belongs only in an empty-sandbox iframe's srcdoc; never assign sender content or rendered documents to the main application's HTML DOM. CSP blocks all network, scripts, styles, fonts, media, frames, objects, forms, and base URLs. Original bytes are available only as authenticated attachments with nosniff, attachment disposition, and an isolated download origin for production. Rendering unknown types does not execute handlers.

Implemented archive profile: application/vnd.3sln.web-archive+json (project-private, unregistered MIME) containing {version:1,entrypoint:"index.html",entries:[{path,mimeType,data}]}, where data is canonical unpadded base64url. At most 64 entries, 1 MiB per decoded entry, 4 MiB total decoded bytes, 10 MiB envelope; duplicate names, traversal, absolute paths, backslashes, URL syntax, percent escapes, compressed/nested archives and external fetching are rejected. Entry MIME types are text/plain, text/html, image/png, image/jpeg, image/webp; entrypoint must be text. Only the inert entrypoint is displayed; bundled images are not fetched or rendered. The archive is decoded in memory, never extracted into a filesystem. ZIP/WARC/MHTML support and faithful offline page rendering are not implemented.

Automation and realtime evolution

Future structured automation requests or WebRTC signaling can use explicitly authorized exact MIME types and ordinary blob transport. Today these remain opaque attachments. Parsing an offer must never auto-accept a connection or permission prompt: future contracts need schema/size limits, authenticated peer identity distinct from bearer possession, replay/expiry policy, user consent, TURN configuration, IP privacy, session cancellation and abuse controls. Future automation requires narrow independent execution grants. Classifying a blob as automation is not permission to execute it.