Skip to content

Public Forms (/v/form/:slug) ​

Public forms allow external partners, customers, and unauthenticated field reporters to submit requests, orders, incident reports, or service tickets at /v/form/:slug through the dxosForms resource (public-forms.js and public-form-html.js) in @latticedx/plugin-lattice-foundation. The intake pipeline enforces Zero-PII isolation: anonymous clients never receive organizationId, internal defaults, or target collection names, and direct CRUD access to form metadata or submission tables is blocked.

Every valid submission runs inside a tenant-scoped PostgreSQL RLS transaction (withTenantRlsContext), inserts the target business record, stores an audit receipt in latticePublicFormSubmissions, and emits a public_form.submitted CloudEvent to the Event Bus.

latticePublicFormsGuard and Routing Boundary ​

The registerPublicFormsGuard middleware (tagged latticePublicFormsGuard, mounted after: 'acl') blocks direct non-root CRUD or charts:queryData requests against:

  • latticePublicForms
  • latticePublicFormSubmissions

Blocked requests fail with HTTP 403 (PUBLIC_FORM_DIRECT_ACCESS_FORBIDDEN), forcing all interactions through dxosForms. At the Nginx edge (10-lattice-public-routes.sh), /v/form proxies directly to the application upstream and /form issues a 302 redirect to /v/form.

dxosForms API Reference ​

dxosForms exposes 3 public actions and 7 loggedIn administrative actions guarded by resolveAdminContext. Two inspection actions (listSubmissions and downloadAttachment) also permit business managers (ldx_manager, ldx_admin, admin).

Public Actions (public ACL) ​

GET/api/dxosForms:meta?slug=partner-intake
Public
Returns public field metadata via serializePublicMeta, stripping organizationId, targetCollection, and token hashes.
POST/api/dxosForms:submit?slug=partner-intake
Public | Optional x-form-token (ldx_ftok_*)
Validates payload, honeypot, and rate limits; creates target record and submission receipt; returns submissionCode and statusToken (ldx_frm_*).
GET/api/dxosForms:status?slug=partner-intake&submissionCode=LDX-FRM-...&token=ldx_frm_...
Public + statusToken (ldx_frm_*)
Queries live target record status using constant-time SHA-256 verification via timingSafeEqualHex.

Administrative Actions (loggedIn ACL) ​

GET/api/dxosForms:list?limit=50
Bearer JWT | ldx_pat_*Admin
Lists public form definitions scoped to the caller's tenant (or all tenants for root).
GET/api/dxosForms:get?id=1
Bearer JWT | ldx_pat_*Admin
Fetches a single form definition by numeric id or slug.
POST/api/dxosForms:save
Bearer JWT | ldx_pat_*Admin + write
Creates or updates a form definition, validating SLUG_RE, PUBLIC_FORM_ALLOWLIST_COLLECTIONS, and BLOCKED_TARGET_FIELDS.
POST/api/dxosForms:delete
Bearer JWT | ldx_pat_*Admin + write
Deletes a tenant-owned form definition by id (supports POST and DELETE).
POST/api/dxosForms:rotateToken
Bearer JWT | ldx_pat_*Admin + write
Generates a fresh ldx_ftok_<48 hex> access token, stores its SHA-256 accessTokenHash, and enables requireAccessToken.
GET/api/dxosForms:listSubmissions?slug=partner-intake&page=1&pageSize=20
Bearer JWT | ldx_pat_*Admin | Manager
Lists sanitized submission receipts alongside attachment metadata.
GET/api/dxosForms:downloadAttachment?submissionCode=LDX-FRM-...&fieldName=attachment
Bearer JWT | ldx_pat_*Admin | Manager
Streams a stored attachment with Content-Disposition: attachment and X-Content-Type-Options: nosniff.

Slug Rules, Allowlisted Collections, and Field Schema ​

Every form definition passes validatePublicFormDefinition before persistence:

Form Definition Schema (dxosForms:save)
ParameterTypeDefaultDescription
slugrequired
string—Matches /^[a-z0-9](?:[a-z0-9-]{1,61}[a-z0-9])$/ (3 to 63 chars) and is excluded from the 15 RESERVED_FORM_SLUGS.
titlerequired
string—Public form title (1 to 180 characters).
targetCollectionrequired
string—Must be in PUBLIC_FORM_ALLOWLIST_COLLECTIONS or match ^latticeCustom[A-Z][A-Za-z0-9]{1,40}$.
allowedFieldsJsonrequired
FieldSpec[]—1 to 50 input field descriptors restricted to the 9 ALLOWED_FIELD_TYPES.
defaultValuesJson
object—Primitive default values applied server-side on target creation; rejects BLOCKED_TARGET_FIELDS.
honeypotField
string_hp_websiteHidden bot-trap field name matching /^[a-zA-Z_][a-zA-Z0-9_]{1,63}$/.
rateLimitPerMinute
integer20Per-IP per-slug submission cap per minute (1..300).
requireAccessToken
booleanfalseEnforces ldx_ftok_* bearer or header token verification on submit.
workflowRuleKey
string—Optional workflow key attached to the emitted public_form.submitted CloudEvent.
active
booleantrueEnables or disables public metadata and submissions.

Target Collection Allowlist (PUBLIC_FORM_ALLOWLIST_COLLECTIONS) ​

Forms may only write to 8 built-in collections or custom collections matching ^latticeCustom[A-Z][A-Za-z0-9]{1,40}$:

Target CollectionTypical Intake Use CaseInitialized Fields
latticeRequestsPurchase or partner intake requestsstatus: 'submitted', version: 1, amendmentNo: 0
latticeOrdersExternal order or shipment requestsstatus: 'submitted', version: 1, amendmentNo: 0
latticeServiceTicketsCustomer support and service ticketsstatus: 'submitted', version: 1, amendmentNo: 0
latticeIncidentCasesField cold-chain incident reportsstatus: 'submitted'
latticeParaDocumentsExternal knowledge vault submissionsstatus: 'submitted'
latticeAgentProposalsQueued operational proposalsstatus: 'submitted'
latticeLocationsPartner site or drop-off registrationactive: true
latticeAssetsAsset and equipment onboardingactive: true

Reserved Slugs and Supported Field Types ​

RuleValues
RESERVED_FORM_SLUGS (15)admin, api, signin, signup, mobile, track, form, v, p, static, storage, files, lattice, health, settings
ALLOWED_FIELD_TYPES (9)string, text, number, integer, boolean, date, email, select, file
Field length & regex boundsDEFAULT_MAX_FIELD_LENGTH = 2000 (MAX_FIELD_LENGTH_CAP = 10000), regex pattern <= 120 chars with nested quantifier rejection to prevent ReDoS.

Security Controls, Anti-Spam, and Rate Limiting ​

Zero-PII, Prototype Guards, and BLOCKED_TARGET_FIELDS ​

serializePublicMeta ​

Public metadata responses return only slug, title, description, fields, honeypotField, requireAccessToken, and active, omitting organizationId, targetCollection, accessTokenHash, createdByUserId, and defaultValuesJson.

Prototype & depth guard (assertNoPrototypePollution) ​

Rejects payloads nested deeper than 20 levels (maxDepth = 20) or containing __proto__, constructor, or prototype. Supplying organizationId in submit requests fails immediately with 400 FORM_ORG_OVERRIDE_FORBIDDEN.

BLOCKED_TARGET_FIELDS ​

Blocks exposure or client override of 29 system, lifecycle, and security keys:

text
id, organizationId, createdAt, updatedAt, createdById, updatedById,
status, version, amendedFromId, amendmentNo, requesterId, assigneeId,
submittedBy, cancelledBy, cancelReason, cancelledAt, submittedAt,
userId, identitySubject, password, secret, token, apiKey, privateKey,
accessTokenHash, statusTokenHash, __proto__, constructor, prototype

Any field name matching SENSITIVE_FIELD_NAME_RE (password|secret|token|apikey|api_key|privatekey|private_key|hash|salt) is also rejected across form schemas, defaults, and hydrated submission listings.

_hp_website Honeypot and 20 / 60 / 300 Rate Limits ​

  • Bot honeypot (_hp_website): If any request bag (body, params, values) supplies a non-empty value for the configured honeypotField or _hp_website, the submission is rejected with 400 FORM_BOT_DETECTED.
  • 60-second sliding-window rate limiter (createSlidingWindowRateLimiter):
ScopeConstantDefault Limit / MinCounter Key
Pre-lookup IP flood protectionPRE_LOOKUP_IP_FLOOD_LIMIT300${clientIp}:__flood__
Form submission (dxosForms:submit)DEFAULT_RATE_LIMIT_PER_MIN20 (configurable 1..300)${clientIp}:${slug}
Status lookup (dxosForms:status)STATUS_RATE_LIMIT_PER_MIN60${clientIp}:status:${slug}

Exceeded windows return HTTP 429 RATE_LIMIT_EXCEEDED with a Retry-After header.

Token Model: ldx_ftok_ and ldx_frm_ ​

  • Form access token (ldx_ftok_<48 hex>): When requireAccessToken is enabled, dxosForms:rotateToken generates a 24-byte random token prefixed with ldx_ftok_ and persists only its SHA-256 digest (accessTokenHash). Clients supply the token via body (token / accessToken), query, or x-form-token header; validation executes constant-time timingSafeEqualHex (using DUMMY_HASH_HEX when the form does not exist to prevent timing side-channels).
  • Submission status token (ldx_frm_<48 hex>): Every accepted submission generates a unique submissionCode (LDX-FRM-<8 hex>) and a one-time statusToken (ldx_frm_...), storing only its SHA-256 statusTokenHash for subsequent dxosForms:status checks.

File Upload Magic-Byte Verification and public_form.submitted CloudEvent ​

The sanitizeFileFieldValue handler caps uploads at MAX_FILE_UPLOAD_BYTES = 2MB (2,097,152 bytes), blocks path-traversal characters (.., /, \, control bytes), hashes content with SHA-256, and verifies binary file signatures across the 5 ALLOWED_FILE_MIME_TYPES:

MIME TypeMagic-Byte / Content Verification
application/pdfLeading 5 bytes match %PDF-
image/pngLeading 8 bytes match 89 50 4E 47 0D 0A 1A 0A
image/jpegLeading 3 bytes match FF D8 FF
image/webpBytes 0..3 equal RIFF and bytes 8..11 equal WEBP
text/plainZero 0x00 null bytes and does not start with <script, <svg, <html, <?xml, <!doctype, <!--, <iframe, <object, or <embed

After committing both the target record and the latticePublicFormSubmissions receipt, dxosForms:submit emits the public_form.submitted CloudEvent (source: 'dxosForms', subject: submissionCode) carrying { slug, submissionCode, targetCollection, targetRecordId, workflowRuleKey } to trigger downstream LatticeFlow v2 rules or Event Bus webhooks.

bash
curl -X POST https://localhost:8443/api/dxosForms:save \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "slug": "coldchain-incident",
    "title": "Cold-Chain Incident Intake",
    "targetCollection": "latticeIncidentCases",
    "rateLimitPerMinute": 20,
    "allowedFieldsJson": [
      { "name": "name", "label": "Incident Summary", "type": "string", "required": true, "maxLength": 160 },
      { "name": "severity", "label": "Severity", "type": "select", "required": true, "options": ["low", "medium", "high", "critical"] },
      { "name": "evidence", "label": "Site Photo", "type": "file", "required": false }
    ]
  }'

Apache-2.0 · LatticeDX v0.4.2 · Powered by NocoBase · v2.2.50 · Apache-2.0 (Clause 5.2)