domma-cms 1.66.5 → 1.66.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.66.7] - 2026-11-14
4
+
5
+ - **Security: Tools' collections are no longer readable through the public API.** A collection made with no API settings was readable by anyone at `/api/collections/<slug>/public`, and several Tools (Campaigns Pro, Surveys, Onboard Pro, eCards, Invoice, Site Builder, Blog and Blog Pro) made theirs that way - so invitations, contacts, deliveries and unsubscribes could be read without signing in. A Tool's collection is now closed unless its own schema opens it, and on the first start after this update every Tool collection still on the old setting is closed once (the log lists them). A site that wants one open can switch Read back on in Collections, under API & Export, and that choice is kept. The Tools' own screens and pages are not affected.
6
+ - **Security: the `[collection]` tag asks the collection first.** The tag showed any collection's entries to whoever could write the text - a page, a blog post, a survey's intro, a product description, the page preview. Each collection now has **Show on pages** (Collections, API & Export). It starts on for a collection you made yourself, and off for a Tool's collection, a built-in one and one that holds a form's submissions; a tag for one that is off shows nothing (a preview says why). `scope="mine"` is unchanged. Switch it off for any collection of your own that holds private entries.
7
+
8
+ ## [1.66.6] - 2026-11-14
9
+
10
+ - Pictures in Media now show in emails read in webmail. They are sent with `Cross-Origin-Resource-Policy: cross-origin`, so a campaign's or survey's banner and footer no longer arrive as alt text only. Every other response keeps `same-origin`.
11
+
3
12
  ## [1.66.5] - 2026-11-13
4
13
 
5
14
  - Contacts related records and the shared Tool styles come from Domma Mail 0.92.0 (shared mail core 0.29.0). Nothing changes on a site.
@@ -1,3 +1,3 @@
1
- export const FIELD_TYPES=[{value:"string",label:"Text (single line)"},{value:"email",label:"Email"},{value:"tel",label:"Phone"},{value:"number",label:"Number"},{value:"textarea",label:"Textarea (multi-line)"},{value:"select",label:"Dropdown (select)"},{value:"radio",label:"Radio buttons"},{value:"checkbox",label:"Single checkbox"},{value:"checkbox-group",label:"Checkbox group"},{value:"date",label:"Date"},{value:"time",label:"Time"},{value:"url",label:"URL"},{value:"hidden",label:"Hidden field"},{value:"file",label:"Files (uploaded with a form)"}],OPTION_TYPES=new Set(["select","radio","checkbox-group"]),ADDON_TYPES=new Set(["string","email","tel","number","textarea","select","date","time","url"]);const f=/^[a-z0-9-]+$/i;export const EXTRA_TYPES={clear:new Set(["string","email","tel","url","textarea"]),stepper:new Set(["number"]),counter:new Set(["string","textarea"])};const m=24;function p(e){return e?typeof e=="string"?{icon:"",text:e}:{icon:e.icon||"",text:e.icon?"":String(e.text??"")}:{icon:"",text:""}}export function addonFromBoxes(e,r){const n=String(e??"").trim(),t=String(r??"").trim();return n&&f.test(n)?{icon:n}:t?{text:t.slice(0,m)}:null}export const OPERATIONS=["create","read","update","delete"],EXPORT_FORMATS=["csv","json"],FIELD_NAME_RE=/^[A-Za-z_][A-Za-z0-9_-]*$/;export function slugify(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}export const nameFromLabel=e=>slugify(e).replace(/-/g,"_"),typeLabel=e=>FIELD_TYPES.find(r=>r.value===e)?.label||e||"";export function optionsText(e){return(Array.isArray(e)?e:[]).map(r=>typeof r=="string"?`${r}: ${r}`:`${r?.value??""}: ${r?.label??r?.value??""}`).join(`
1
+ const f=["outreach-contacts","outreach-groups","outreach-unsubscribes"];export const FIELD_TYPES=[{value:"string",label:"Text (single line)"},{value:"email",label:"Email"},{value:"tel",label:"Phone"},{value:"number",label:"Number"},{value:"textarea",label:"Textarea (multi-line)"},{value:"select",label:"Dropdown (select)"},{value:"radio",label:"Radio buttons"},{value:"checkbox",label:"Single checkbox"},{value:"checkbox-group",label:"Checkbox group"},{value:"date",label:"Date"},{value:"time",label:"Time"},{value:"url",label:"URL"},{value:"hidden",label:"Hidden field"},{value:"file",label:"Files (uploaded with a form)"}],OPTION_TYPES=new Set(["select","radio","checkbox-group"]),ADDON_TYPES=new Set(["string","email","tel","number","textarea","select","date","time","url"]);const m=/^[a-z0-9-]+$/i;export const EXTRA_TYPES={clear:new Set(["string","email","tel","url","textarea"]),stepper:new Set(["number"]),counter:new Set(["string","textarea"])};const g=24;function p(e){return e?typeof e=="string"?{icon:"",text:e}:{icon:e.icon||"",text:e.icon?"":String(e.text??"")}:{icon:"",text:""}}export function addonFromBoxes(e,r){const n=String(e??"").trim(),t=String(r??"").trim();return n&&m.test(n)?{icon:n}:t?{text:t.slice(0,g)}:null}export const OPERATIONS=["create","read","update","delete"],EXPORT_FORMATS=["csv","json"],FIELD_NAME_RE=/^[A-Za-z_][A-Za-z0-9_-]*$/;export function slugify(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}export const nameFromLabel=e=>slugify(e).replace(/-/g,"_"),typeLabel=e=>FIELD_TYPES.find(r=>r.value===e)?.label||e||"";export function optionsText(e){return(Array.isArray(e)?e:[]).map(r=>typeof r=="string"?`${r}: ${r}`:`${r?.value??""}: ${r?.label??r?.value??""}`).join(`
2
2
  `)}export function parseOptions(e){return String(e??"").split(`
3
- `).filter(r=>r.trim()).map(r=>{const[n,...t]=r.split(":");return{value:n.trim(),label:t.join(":").trim()||n.trim()}})}const g=()=>({create:{enabled:!1,access:"admin"},read:{enabled:!0,access:"public"},update:{enabled:!1,access:"admin"},delete:{enabled:!1,access:"admin"}}),b=e=>({enabled:!0,access:e||"",formats:["csv","json"]});export function roleLadder(e){return(Array.isArray(e)?e:e?.entries||[]).map(n=>({name:n?.data?.name,label:n?.data?.label||n?.data?.name,level:Number(n?.data?.level)})).filter(n=>typeof n.name=="string"&&n.name&&Number.isFinite(n.level)).sort((n,t)=>n.level-t.level||n.name.localeCompare(t.name))}export function accessOptions(e,r,{token:n=!0}={}){const t=[{value:"public",label:"Public - anyone"}];n&&t.push({value:"token",label:"API token"});for(const i of[...e||[]].reverse())t.push({value:i.name,label:i.level===0?`${i.label} only`:`${i.label} and above`});return typeof r=="string"&&r&&!t.some(i=>i.value===r)&&t.push(e?.length?{value:r,label:`${r} (role not found)`,missing:!0}:{value:r,label:r}),t}let x=0;export const fieldKey=()=>`f${Date.now().toString(36)}${(x++).toString(36)}`;export function formFromCollection(e=null,{project:r="",defaultRole:n=""}={}){const t=e||{},i={...g(),...t.api||{}},l={...b(n),...t.export||{}},s={title:String(t.title??""),slug:String(t.slug??""),description:String(t.description??""),layout:t.layout==="grid"?"grid":"stacked",columns:String(Number.parseInt(t.columns,10)||2),project:String(t.meta?.project??r??""),bundled:t.bundled===!0,storageAdapter:t.storage?.adapter==="mongodb"?"mongodb":"file",storageConnection:String(t.storage?.connection||"default"),fields:(Array.isArray(t.fields)?t.fields:[]).map(o=>({...o,_key:fieldKey()})),readFields:Array.isArray(i.read?.fields)?i.read.fields.join(", "):"",mineEnabled:i.mine===void 0||i.mine===!0,mineLocked:!!t.plugin&&!(i.mine===void 0||i.mine===!0),exportEnabled:l.enabled!==!1,exportAccess:typeof l.access=="string"&&l.access?l.access:String(n||""),exportCsv:(Array.isArray(l.formats)?l.formats:EXPORT_FORMATS).includes("csv"),exportJson:(Array.isArray(l.formats)?l.formats:EXPORT_FORMATS).includes("json")};for(const o of OPERATIONS){s[`${o}Enabled`]=i[o]?.enabled===!0;const a=i[o]?.access;s[`${o}Access`]=typeof a=="string"&&a?a:"admin"}return s}export function cleanField(e){const{_key:r,...n}=e||{};return n}export function payloadFromForm(e,{isNew:r=!1,meta:n={}}={}){const t=e||{},i={};for(const o of OPERATIONS)i[o]={enabled:t[`${o}Enabled`]===!0,access:t[`${o}Access`]||"admin"};const l=String(t.readFields??"").split(",").map(o=>o.trim()).filter(Boolean);l.length&&(i.read.fields=l),i.mine=t.mineLocked?!1:t.mineEnabled!==!1;const s=Math.min(6,Math.max(1,Number.parseInt(t.columns,10)||2));return{title:String(t.title??"").trim(),...r&&{slug:slugify(t.slug||t.title)},description:String(t.description??"").trim(),layout:t.layout==="grid"?"grid":"stacked",columns:s,fields:(t.fields||[]).map(cleanField),api:i,export:{enabled:t.exportEnabled!==!1,...t.exportAccess&&{access:t.exportAccess},formats:EXPORT_FORMATS.filter(o=>o==="csv"?t.exportCsv:t.exportJson)},storage:t.storageAdapter==="mongodb"?{adapter:"mongodb",connection:t.storageConnection||"default"}:{adapter:"file"},meta:{...n||{},project:String(t.project??"")||null},bundled:t.bundled===!0}}export function snapshot(e){const{fields:r=[],...n}=e||{};return JSON.stringify({...n,fields:r.map(cleanField)})}export function checkForm(e,{isNew:r=!1,taken:n=[],original:t={}}={}){const i=e||{},l={};if(String(i.title??"").trim()||(l.title="A collection needs a title."),r){const c=slugify(i.slug||i.title);c?n.includes(c)&&(l.slug=`"${c}" is already a collection.`):l.slug="The slug needs a letter or a number."}const s=Number.parseInt(i.columns,10);i.layout==="grid"&&!(s>=1&&s<=6)&&(l.columns="Between 1 and 6 columns.");const o={},a=new Map;return(i.fields||[]).forEach(c=>{const d=fieldProblem(c,t[c._key]);d&&(o[c._key]=d);const u=String(c.name??"").trim();u&&(a.has(u)?o[c._key]=o[c._key]||`"${u}" is used by another field.`:a.set(u,c._key))}),Object.keys(o).length&&(l.fields=o),i.exportEnabled&&!i.exportCsv&&!i.exportJson&&(l.export="Pick at least one export format, or turn export off."),l}export function fieldProblem(e,r){const n=String(e?.name??"").trim();return n?n!==r&&!FIELD_NAME_RE.test(n)?"Names start with a letter or _, then letters, digits, _ or -.":OPTION_TYPES.has(e.type)&&!(Array.isArray(e.options)&&e.options.length)?`A ${typeLabel(e.type).toLowerCase()} needs at least one option.`:"":"A field needs a name - it is what each entry is keyed by."}export const errorCount=e=>Object.keys(e||{}).filter(r=>r!=="fields").length+Object.keys(e?.fields||{}).length;export function fieldRow(e,r={},{grid:n=!1}={}){const t=[e.name||"(no name)",typeLabel(e.type)];return OPTION_TYPES.has(e.type)&&t.push(`${(e.options||[]).length} options`),n&&t.push(e.fullWidth?"full width":`span ${e.span>1?e.span:1}`),{key:e._key,label:e.label||"(Untitled field)",meta:t.join(" \xB7 "),required:e.required===!0,hidden:e.type==="hidden",notInLists:e.listHidden===!0&&e.type!=="hidden",problem:r[e._key]||"",rowCls:r[e._key]?"is-bad":""}}export function moveField(e,r,n){const t=[...e];if(r<0||r>=t.length||n<0||n>=t.length||r===n)return t;const[i]=t.splice(r,1);return t.splice(n,0,i),t}export function duplicateField(e,r){const n=e[r];if(!n)return[...e];const t=new Set(e.map(a=>a.name)),i=`${n.name||"field"}_copy`;let l=i;for(let a=2;t.has(l);a++)l=`${i}_${a}`;const s={...JSON.parse(JSON.stringify(cleanField(n))),name:l,label:`${n.label||"Field"} (copy)`,_key:fieldKey()};delete s.id;const o=[...e];return o.splice(r+1,0,s),o}export const newField=()=>({id:`field-${Date.now()}`,name:"",label:"",type:"string",required:!1,placeholder:"",helper:"",options:[],validation:[],logic:null,_key:fieldKey()});export function panelForm(e){return{label:String(e.label??""),name:String(e.name??""),type:e.type||"string",required:e.required===!0,placeholder:String(e.placeholder??""),helper:String(e.helper??""),options:optionsText(e.options),span:String(e.span>1?e.span:1),fullWidth:e.fullWidth===!0,prefixIcon:p(e.prefix).icon,prefixText:p(e.prefix).text,suffixIcon:p(e.suffix).icon,suffixText:p(e.suffix).text,clear:e.clear===!0,stepper:e.stepper===!0,counter:e.counter===!0,inLists:e.listHidden!==!0}}export function fieldFromPanel(e,r){const n={...e,label:String(r.label??"").trim(),name:String(r.name??"").trim(),type:r.type||"string",required:r.required===!0,placeholder:String(r.placeholder??"").trim(),helper:String(r.helper??"").trim()};OPTION_TYPES.has(n.type)&&(n.options=parseOptions(r.options)),"inLists"in r&&(r.inLists===!1?n.listHidden=!0:delete n.listHidden);for(const[t,i]of Object.entries(EXTRA_TYPES)){if(!i.has(n.type)){delete n[t];continue}t in r&&(r[t]===!0?n[t]=!0:delete n[t])}for(const t of["prefix","suffix"]){const i=`${t}Icon`in r||`${t}Text`in r;if(!ADDON_TYPES.has(n.type)){delete n[t];continue}if(!i)continue;const l=addonFromBoxes(r[`${t}Icon`],r[`${t}Text`]);l?n[t]=l:delete n[t]}if(r.fullWidth)n.fullWidth=!0,delete n.span;else{delete n.fullWidth;const t=Number.parseInt(r.span,10);t>1?n.span=Math.min(6,t):delete n.span}return n}export function storageChange(e,r){const n=e||"file",t=r||"file";return n===t?"":`${n} \u2192 ${t}`}export function draftOf(e){const{fields:r=[],...n}=e||{};return{...n,fields:r.map(cleanField)}}export function formFromDraft(e,r){const n=e||{};return{...r,...n,fields:(Array.isArray(n.fields)?n.fields:r.fields).map(t=>({...cleanField(t),_key:fieldKey()}))}}
3
+ `).filter(r=>r.trim()).map(r=>{const[n,...t]=r.split(":");return{value:n.trim(),label:t.join(":").trim()||n.trim()}})}const b=()=>({create:{enabled:!1,access:"admin"},read:{enabled:!0,access:"public"},update:{enabled:!1,access:"admin"},delete:{enabled:!1,access:"admin"}}),x=e=>({enabled:!0,access:e||"",formats:["csv","json"]});export function roleLadder(e){return(Array.isArray(e)?e:e?.entries||[]).map(n=>({name:n?.data?.name,label:n?.data?.label||n?.data?.name,level:Number(n?.data?.level)})).filter(n=>typeof n.name=="string"&&n.name&&Number.isFinite(n.level)).sort((n,t)=>n.level-t.level||n.name.localeCompare(t.name))}export function accessOptions(e,r,{token:n=!0}={}){const t=[{value:"public",label:"Public - anyone"}];n&&t.push({value:"token",label:"API token"});for(const i of[...e||[]].reverse())t.push({value:i.name,label:i.level===0?`${i.label} only`:`${i.label} and above`});return typeof r=="string"&&r&&!t.some(i=>i.value===r)&&t.push(e?.length?{value:r,label:`${r} (role not found)`,missing:!0}:{value:r,label:r}),t}let y=0;export const fieldKey=()=>`f${Date.now().toString(36)}${(y++).toString(36)}`;export function formFromCollection(e=null,{project:r="",defaultRole:n=""}={}){const t=e||{},i={...b(),...t.api||{}},l={...x(n),...t.export||{}},s={title:String(t.title??""),slug:String(t.slug??""),description:String(t.description??""),layout:t.layout==="grid"?"grid":"stacked",columns:String(Number.parseInt(t.columns,10)||2),project:String(t.meta?.project??r??""),bundled:t.bundled===!0,storageAdapter:t.storage?.adapter==="mongodb"?"mongodb":"file",storageConnection:String(t.storage?.connection||"default"),fields:(Array.isArray(t.fields)?t.fields:[]).map(o=>({...o,_key:fieldKey()})),readFields:Array.isArray(i.read?.fields)?i.read.fields.join(", "):"",mineEnabled:i.mine===void 0||i.mine===!0,pagesEnabled:i.pages!==void 0?i.pages===!0:!(t.plugin||t.builtIn||t.systemManaged||t.meta?.generatedFromForm||f.includes(t.slug)),mineLocked:!!t.plugin&&!(i.mine===void 0||i.mine===!0),exportEnabled:l.enabled!==!1,exportAccess:typeof l.access=="string"&&l.access?l.access:String(n||""),exportCsv:(Array.isArray(l.formats)?l.formats:EXPORT_FORMATS).includes("csv"),exportJson:(Array.isArray(l.formats)?l.formats:EXPORT_FORMATS).includes("json")};for(const o of OPERATIONS){s[`${o}Enabled`]=i[o]?.enabled===!0;const a=i[o]?.access;s[`${o}Access`]=typeof a=="string"&&a?a:"admin"}return s}export function cleanField(e){const{_key:r,...n}=e||{};return n}export function payloadFromForm(e,{isNew:r=!1,meta:n={}}={}){const t=e||{},i={};for(const o of OPERATIONS)i[o]={enabled:t[`${o}Enabled`]===!0,access:t[`${o}Access`]||"admin"};const l=String(t.readFields??"").split(",").map(o=>o.trim()).filter(Boolean);l.length&&(i.read.fields=l),i.mine=t.mineLocked?!1:t.mineEnabled!==!1,i.pages=t.pagesEnabled===!0;const s=Math.min(6,Math.max(1,Number.parseInt(t.columns,10)||2));return{title:String(t.title??"").trim(),...r&&{slug:slugify(t.slug||t.title)},description:String(t.description??"").trim(),layout:t.layout==="grid"?"grid":"stacked",columns:s,fields:(t.fields||[]).map(cleanField),api:i,export:{enabled:t.exportEnabled!==!1,...t.exportAccess&&{access:t.exportAccess},formats:EXPORT_FORMATS.filter(o=>o==="csv"?t.exportCsv:t.exportJson)},storage:t.storageAdapter==="mongodb"?{adapter:"mongodb",connection:t.storageConnection||"default"}:{adapter:"file"},meta:{...n||{},project:String(t.project??"")||null},bundled:t.bundled===!0}}export function snapshot(e){const{fields:r=[],...n}=e||{};return JSON.stringify({...n,fields:r.map(cleanField)})}export function checkForm(e,{isNew:r=!1,taken:n=[],original:t={}}={}){const i=e||{},l={};if(String(i.title??"").trim()||(l.title="A collection needs a title."),r){const c=slugify(i.slug||i.title);c?n.includes(c)&&(l.slug=`"${c}" is already a collection.`):l.slug="The slug needs a letter or a number."}const s=Number.parseInt(i.columns,10);i.layout==="grid"&&!(s>=1&&s<=6)&&(l.columns="Between 1 and 6 columns.");const o={},a=new Map;return(i.fields||[]).forEach(c=>{const d=fieldProblem(c,t[c._key]);d&&(o[c._key]=d);const u=String(c.name??"").trim();u&&(a.has(u)?o[c._key]=o[c._key]||`"${u}" is used by another field.`:a.set(u,c._key))}),Object.keys(o).length&&(l.fields=o),i.exportEnabled&&!i.exportCsv&&!i.exportJson&&(l.export="Pick at least one export format, or turn export off."),l}export function fieldProblem(e,r){const n=String(e?.name??"").trim();return n?n!==r&&!FIELD_NAME_RE.test(n)?"Names start with a letter or _, then letters, digits, _ or -.":OPTION_TYPES.has(e.type)&&!(Array.isArray(e.options)&&e.options.length)?`A ${typeLabel(e.type).toLowerCase()} needs at least one option.`:"":"A field needs a name - it is what each entry is keyed by."}export const errorCount=e=>Object.keys(e||{}).filter(r=>r!=="fields").length+Object.keys(e?.fields||{}).length;export function fieldRow(e,r={},{grid:n=!1}={}){const t=[e.name||"(no name)",typeLabel(e.type)];return OPTION_TYPES.has(e.type)&&t.push(`${(e.options||[]).length} options`),n&&t.push(e.fullWidth?"full width":`span ${e.span>1?e.span:1}`),{key:e._key,label:e.label||"(Untitled field)",meta:t.join(" \xB7 "),required:e.required===!0,hidden:e.type==="hidden",notInLists:e.listHidden===!0&&e.type!=="hidden",problem:r[e._key]||"",rowCls:r[e._key]?"is-bad":""}}export function moveField(e,r,n){const t=[...e];if(r<0||r>=t.length||n<0||n>=t.length||r===n)return t;const[i]=t.splice(r,1);return t.splice(n,0,i),t}export function duplicateField(e,r){const n=e[r];if(!n)return[...e];const t=new Set(e.map(a=>a.name)),i=`${n.name||"field"}_copy`;let l=i;for(let a=2;t.has(l);a++)l=`${i}_${a}`;const s={...JSON.parse(JSON.stringify(cleanField(n))),name:l,label:`${n.label||"Field"} (copy)`,_key:fieldKey()};delete s.id;const o=[...e];return o.splice(r+1,0,s),o}export const newField=()=>({id:`field-${Date.now()}`,name:"",label:"",type:"string",required:!1,placeholder:"",helper:"",options:[],validation:[],logic:null,_key:fieldKey()});export function panelForm(e){return{label:String(e.label??""),name:String(e.name??""),type:e.type||"string",required:e.required===!0,placeholder:String(e.placeholder??""),helper:String(e.helper??""),options:optionsText(e.options),span:String(e.span>1?e.span:1),fullWidth:e.fullWidth===!0,prefixIcon:p(e.prefix).icon,prefixText:p(e.prefix).text,suffixIcon:p(e.suffix).icon,suffixText:p(e.suffix).text,clear:e.clear===!0,stepper:e.stepper===!0,counter:e.counter===!0,inLists:e.listHidden!==!0}}export function fieldFromPanel(e,r){const n={...e,label:String(r.label??"").trim(),name:String(r.name??"").trim(),type:r.type||"string",required:r.required===!0,placeholder:String(r.placeholder??"").trim(),helper:String(r.helper??"").trim()};OPTION_TYPES.has(n.type)&&(n.options=parseOptions(r.options)),"inLists"in r&&(r.inLists===!1?n.listHidden=!0:delete n.listHidden);for(const[t,i]of Object.entries(EXTRA_TYPES)){if(!i.has(n.type)){delete n[t];continue}t in r&&(r[t]===!0?n[t]=!0:delete n[t])}for(const t of["prefix","suffix"]){const i=`${t}Icon`in r||`${t}Text`in r;if(!ADDON_TYPES.has(n.type)){delete n[t];continue}if(!i)continue;const l=addonFromBoxes(r[`${t}Icon`],r[`${t}Text`]);l?n[t]=l:delete n[t]}if(r.fullWidth)n.fullWidth=!0,delete n.span;else{delete n.fullWidth;const t=Number.parseInt(r.span,10);t>1?n.span=Math.min(6,t):delete n.span}return n}export function storageChange(e,r){const n=e||"file",t=r||"file";return n===t?"":`${n} \u2192 ${t}`}export function draftOf(e){const{fields:r=[],...n}=e||{};return{...n,fields:r.map(cleanField)}}export function formFromDraft(e,r){const n=e||{};return{...r,...n,fields:(Array.isArray(n.fields)?n.fields:r.fields).map(t=>({...cleanField(t),_key:fieldKey()}))}}
@@ -114,6 +114,10 @@
114
114
  <label class="cex-check"><input type="checkbox" data-model="mineEnabled.value" data-bind-disabled="mineLocked.value"> Users can read their own entries (scope=mine)
115
115
  <span data-help-title="Their own entries" data-help="A signed-in user may read the entries they created - [collection scope=&quot;mine&quot;] and ?scope=mine - even when Read is off. Turn this off when entries hold something their creator must not see."></span></label>
116
116
  </div>
117
+ <div class="cex-op cex-op-sub">
118
+ <label class="cex-check"><input type="checkbox" data-model="pagesEnabled.value"> Show on pages ([collection] tag)
119
+ <span data-help-title="Show on pages" data-help="Lets the [collection] tag show these entries on a page, a blog post or any other text that takes tags. Anyone who can write that text decides what visitors see, so leave this off for entries that are private - enquiries, orders, people's details. It is off to begin with for a Tool's collection, a built-in one and one that holds a form's submissions. Read (above) is separate: it is for the API."></span></label>
120
+ </div>
117
121
  <div class="cex-op"><strong>Update</strong>
118
122
  <label class="cex-check"><input type="checkbox" data-model="updateEnabled.value"> Allowed</label>
119
123
  <select class="form-input" aria-label="Who may update" data-model="updateAccess.value" data-bind-disabled="!updateEnabled.value"></select></div>
@@ -84,6 +84,11 @@
84
84
  delete entries.</li>
85
85
  <li>On pages, a <code>[collection]</code> shows its entries to anyone who can open the page -
86
86
  gate the page, or use <code>scope="mine"</code> or a View with a row-level rule.</li>
87
+ <li><strong>Show on pages</strong> (API &amp; Export) decides whether <code>[collection]</code> may
88
+ show a collection at all. It is on for a collection you made, and off for a Tool's collection,
89
+ a built-in one and one that holds a form's submissions. Anyone who can write a page, a blog
90
+ post or other text that takes tags could otherwise put those entries on the site - so switch
91
+ it off for any collection of your own that holds private entries.</li>
87
92
  <li>Through the API, the API &amp; Export tab decides: Public, Token (an API token), or signed-in
88
93
  users with a role and above. A role the site does not have admits only the level-0
89
94
  role.</li>
@@ -666,6 +666,8 @@ Where: `server/services/presetCollections.js` (`PRESETS`, `seedAll()`), `server/
666
666
  - **Eight display types**: `table` (the default, a Domma Table with search, sort, paging and column chooser), `cards`, `list`, `accordion`, `timeline`, `carousel`, `listgroup`, `block` (each entry rendered through a reusable block template).
667
667
  Since: 0.14.3 (`timeline`), 0.38.0 (`carousel`, `listgroup`); see [Feature history](#feature-history).
668
668
  Where: server-side rendering in `server/services/markdown.js`; browser behaviour in `public/js/site.js`, `collection-context.js` and `collection-browser.js`.
669
+ - **Show on pages** (`api.pages`, unreleased): `[collection]` reads entries with no viewer check, so the collection decides whether it may be shown. Absent, it is on for a content collection and off for a Tool's (`plugin`), a built-in (known by name: `BUILT_IN_SLUGS`; or `systemManaged`), a form's submissions (`meta.generatedFromForm`) and the outreach lists; `true`/`false` is the site's choice (Collections, API & Export). A refused tag renders nothing, or a note in a preview. `scope="mine"` is governed by `api.mine`, not this.
670
+ Where: `pagesAllowed()` in `server/services/collectionAccess.js`, applied in `processCollectionBlocks()`; the editor mirrors the rule in `admin/js/lib/collection-editor-arrange.js`.
669
671
  - **Common attributes**:
670
672
  - `slug` (required)
671
673
  - `display`
@@ -980,7 +982,7 @@ Where: `server/services/presetCollections.js` (`PRESETS`, `seedAll()`), `server/
980
982
  - a role name (a signed-in user at that level or above)
981
983
  - `token` (a project API token)
982
984
 
983
- A default collection allows public read and nothing else. `api.read.fields` limits which fields reads return. Admin screens are never governed by these settings.
985
+ A default collection allows public read and nothing else; a collection a Tool makes (`plugin` set) allows nothing unless its schema says so (unreleased - before that, Tools' collections made with no `api` block were readable by anyone; `closeToolCollections()` closes those once at boot and marks them `apiDefault: 'closed'`, after which the site's own choice is kept). `api.read.fields` limits which fields reads return. Admin screens are never governed by these settings.
984
986
  - **A role the site does not have admits only the level-0 role** (0.92.1), on `/api/v1`, the public collection route and API Builder endpoints alike; the same for a collection's export access. Before 0.92.1 an unknown role came out as the lowest level, which every signed-in user met. The editor lists the site's real roles ("User and above") and marks a stale one "manager (role not found)" with a note instead of quietly swapping it.
985
987
  Where: collection editor **API & Export** tab; `schema.api`.
986
988
  - **`/api/v1` external REST**. A stable, versioned alias of the public collection endpoints.
@@ -2537,6 +2539,8 @@ Measurement and automation: a Performance screen per campaign - reached, opened
2537
2539
 
2538
2540
  **Pictures and files from Media and the File Store (unreleased, 2026-11-13).** Insert picture in the campaign editor takes a picture from Media or the File Store as well as an upload, and Link a file (body, header, footer) links to a document in either - a link, never an attachment, so the email stays small and the click is counted. A File Store file goes into an email only as its public link (`/_f/<code>`, `?inline=1` for a picture): a private one is made public when chosen, after a confirm, and needs to be the person's own file plus the File Store's "Public links" permission. Making it private again or trashing it stops the link in emails already sent. The File Store is optional - without it only Media is offered. Every field of the editor now carries a full help popover.
2539
2541
 
2542
+ **Blocks and tags in campaign emails (unreleased, 2026-11-13).** Insert block or tag in the campaign editor (body, header, footer) writes a page tag into the message: a site block, or one of the static tags (button, link, card, box, banner, badge, grid, row, spacer, center, text, hero, table, listgroup). At send time, in Preview email and in a test send, each tag is rendered by the engine's own renderer and then turned into email HTML: styles inlined from a small email stylesheet plus the block's own CSS, theme tokens resolved against the site's light theme, grids and flex rows made into tables, icons, scripts and forms removed. Interactive tags (tabs, carousels, forms, collections, embeds, effects) are never rendered - typed by hand they stay as text. Merge fields work inside tags (`[button href="{{link}}" … /]`). The email sanitiser still runs per recipient. Also: right-click or double-click a picture in the message to edit or remove it.
2543
+
2540
2544
  **Where:** Admin sidebar "Campaigns Pro" (`#/plugins/campaigns-pro`); Performance per campaign at `#/plugins/campaigns-pro/performance/:slug`; the audience screen is shared with Surveys.
2541
2545
 
2542
2546
  ### Onboard Pro (`onboard-pro`)
@@ -1049,6 +1049,12 @@ The form's own CSS classes (set in the form builder: Settings, Submit Button and
1049
1049
  Self-closing. Renders a CMS collection inline on a public page. Supports table, cards, list, accordion, timeline, and
1050
1050
  block display modes, with structured filtering and per-user scoping.
1051
1051
 
1052
+ The collection must be set to **Show on pages** (Collections, API & Export - `api.pages` in its schema). That is on for a
1053
+ collection made to hold content, and off until switched on for a Tool's collection, a built-in one and one that holds a
1054
+ form's submissions: the tag reads entries for whoever wrote the text, so the collection decides whether it may be shown at
1055
+ all. A tag for a collection that is off renders nothing (a preview shows a note saying why). `scope="mine"` is not
1056
+ affected - it shows a signed-in visitor their own entries, and `api.mine` governs it.
1057
+
1052
1058
  ```
1053
1059
  [collection slug="enquiries" display="table" /]
1054
1060
  [collection slug="team" display="cards" columns="3" title-field="name" /]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "1.66.5",
3
+ "version": "1.66.7",
4
4
  "description": "File-based CMS powered by Domma and Fastify. Run npx domma-cms my-site to create a new project.",
5
5
  "type": "module",
6
6
  "main": "server/server.js",
@@ -59,7 +59,7 @@ import {getRoleLevel, invalidate as invalidateRoles, isBaseRole} from '../../ser
59
59
  import {getEffectiveLevel} from '../../services/userRoles.js';
60
60
  import {getConfig, saveConfig} from '../../config.js';
61
61
  import {riskyConnectionOptions, signedOnly} from '../../services/codePolicy.js';
62
- import {PRESET_COLLECTION_SLUGS, USER_DATA_PRESET_SLUGS} from '../../services/presetCollections.js';
62
+ import {BUILT_IN_SLUGS, USER_DATA_PRESET_SLUGS} from '../../services/presetCollections.js';
63
63
  import {ensureFormForCollection} from '../../services/forms.js';
64
64
  import {hooks} from '../../services/hooks.js';
65
65
  import {DRAFT_STATUS, authenticateApiToken, draftsOnlyDecision, scopeAllows} from '../../services/apiTokens.js';
@@ -136,7 +136,7 @@ import {
136
136
  pluginDenial
137
137
  } from '../../services/collectionAccess.js';
138
138
 
139
- const ALL_PRESET_SLUGS = new Set(['roles', 'user-profiles', ...PRESET_COLLECTION_SLUGS]);
139
+ const ALL_PRESET_SLUGS = BUILT_IN_SLUGS;
140
140
 
141
141
  /** Built-in collections the public surface never writes: every preset bar the user-data ones, and anything systemManaged. */
142
142
  function isSystemCollection(schema) {
@@ -532,7 +532,8 @@ export async function collectionsRoutes(fastify) {
532
532
  if (!canSeeArtefact(request.user, schema)) {
533
533
  return reply.status(403).send({ error: 'Access denied for this project' });
534
534
  }
535
- return schema;
535
+ // builtIn: the editor's "Show on pages" starts off for a built-in (pagesAllowed).
536
+ return {...schema, ...(ALL_PRESET_SLUGS.has(schema.slug) && {builtIn: true})};
536
537
  });
537
538
 
538
539
  fastify.put('/collections/:slug', canUpdate, async (request, reply) => {
@@ -114,7 +114,8 @@ export async function pagesRoutes(fastify) {
114
114
  fastify.post('/pages/preview', {...canRead, config: {keepsCache: true}}, async (request, reply) => {
115
115
  const {markdown} = request.body;
116
116
  if (typeof markdown !== 'string') return reply.status(400).send({error: 'markdown must be a string'});
117
- const {html} = await parseMarkdown(`---\ntitle: preview\n---\n${markdown}`, {user: request.user || null});
117
+ // writerNotes: a tag that draws nothing for a visitor says why here (a [collection] not set to show on pages).
118
+ const {html} = await parseMarkdown(`---\ntitle: preview\n---\n${markdown}`, {user: request.user || null, writerNotes: true});
118
119
  return {html};
119
120
  });
120
121
 
@@ -57,7 +57,9 @@ async function ensureList() {
57
57
  {name: 'email', label: 'Email', type: 'text', required: true},
58
58
  {name: 'at', label: 'At', type: 'text', required: false},
59
59
  {name: 'source', label: 'Source', type: 'text', required: false}
60
- ]
60
+ ],
61
+ // People's addresses: never through the public collections API.
62
+ api: {read: {enabled: false, access: 'admin'}}
61
63
  }).catch(() => {});
62
64
  }
63
65
  }
package/server/server.js CHANGED
@@ -25,6 +25,7 @@ import {notifierFor} from './services/notify.js';
25
25
  import {grantAdminToolDefaults, grantPermissionOnce, load as loadRoles, seed as seedRoles} from './services/roles.js';
26
26
  import {ensureAllProfiles, seed as seedUserProfiles} from './services/userProfiles.js';
27
27
  import {seedAll as seedPresetCollections} from './services/presetCollections.js';
28
+ import {closeToolCollections} from './services/collections.js';
28
29
  import {seedCoreProject, seedDocsProject} from './services/projects.js';
29
30
  import {seedDefaultBlocks} from './services/blocks.js';
30
31
  import {seedDefaultComponents} from './services/components.js';
@@ -35,7 +36,7 @@ import {requestSerializer} from './services/request-log.js';
35
36
  import {rateLimitOptions} from './services/rate-limit.js';
36
37
  import {registerAdminAssets} from './services/adminAssets.js';
37
38
  import {registerPublicAssets} from './services/publicAssets.js';
38
- import {isActiveType, servedType} from './services/mediaTypes.js';
39
+ import {mediaHeaders} from './services/mediaTypes.js';
39
40
  import {connectSources, frameSources, imageSources} from './services/embedCsp.js';
40
41
  import {cspSources as gaSources} from './services/googleAnalytics.js';
41
42
 
@@ -263,6 +264,10 @@ await grantAdminToolDefaults().catch(() => {});
263
264
  await seedUserProfiles();
264
265
  await ensureAllProfiles();
265
266
  await seedPresetCollections();
267
+ // Tools' collections created under the old default were readable by anyone: closed once, here.
268
+ await closeToolCollections()
269
+ .then(closed => { if (closed.length) console.warn(`[collections] public read closed on ${closed.length} Tool collection(s): ${closed.join(', ')}`); })
270
+ .catch(() => {});
266
271
  await seedCoreProject();
267
272
  await seedDocsProject(); // built-in Domma Docs project - seeded disabled by default
268
273
  await seedDefaultBlocks();
@@ -433,14 +438,8 @@ await app.register(staticPlugin, {
433
438
  root: mediaDir,
434
439
  prefix: '/media/',
435
440
  decorateReply: false,
436
- setHeaders: (reply, filePath) => {
437
- reply.header('X-Content-Type-Options', 'nosniff');
438
- // A file a browser would run as a document (HTML, any XML, SVG, script) is
439
- // served sandboxed: shown, never able to script this site's address.
440
- if (isActiveType(servedType(filePath))) {
441
- reply.header('Content-Security-Policy', "sandbox; default-src 'none'; img-src 'self' data:; style-src 'unsafe-inline'");
442
- }
443
- }
441
+ // nosniff, sandboxed documents, and pictures other sites' pages (webmail) may show - services/mediaTypes.js.
442
+ setHeaders: (reply, filePath) => reply.headers(mediaHeaders(filePath))
444
443
  });
445
444
 
446
445
  // Fingerprinted public assets are cached for good, and the site's custom CSS is
@@ -30,7 +30,7 @@
30
30
  *
31
31
  * A level-0 user keeps everything - the same bypass rowAccess.js gives them.
32
32
  */
33
- import {USER_DATA_PRESET_SLUGS} from './presetCollections.js';
33
+ import {BUILT_IN_SLUGS, SHARED_TOOL_SLUGS, USER_DATA_PRESET_SLUGS} from './presetCollections.js';
34
34
  import {getPermissionsFor} from './roles.js';
35
35
  import {getEffectiveLevel, getEffectiveRoles} from './userRoles.js';
36
36
  import fs from 'node:fs';
@@ -243,6 +243,34 @@ export function mineAllowed(schema) {
243
243
  return mine === undefined || mine === true;
244
244
  }
245
245
 
246
+ /**
247
+ * May `[collection slug="…"]` show this collection's rows on a page?
248
+ *
249
+ * The tag reads rows with no viewer check: whoever can write page text (a
250
+ * page, a blog post, a survey's intro, a product description, a preview)
251
+ * decides what the public sees. So the collection says whether it may be
252
+ * shown at all - `api.pages`:
253
+ *
254
+ * - `true` / `false`: the site's choice (Collections > API & Export).
255
+ * - absent: yes for a collection somebody made to hold content; no for one
256
+ * that belongs to a Tool (`plugin`), is a built-in (BUILT_IN_SLUGS,
257
+ * `systemManaged`) or holds a form's submissions
258
+ * (`meta.generatedFromForm`) - those hold other people's data.
259
+ *
260
+ * Anything but `true` or absent refuses: a typo narrows rather than opens.
261
+ * `scope="mine"` is not judged here (a viewer's own rows; see mineAllowed).
262
+ *
263
+ * @param {object|null} schema
264
+ * @returns {boolean}
265
+ */
266
+ export function pagesAllowed(schema) {
267
+ if (!schema) return false;
268
+ const pages = schema.api?.pages;
269
+ if (pages !== undefined) return pages === true;
270
+ if (SHARED_TOOL_SLUGS.has(schema.slug) || BUILT_IN_SLUGS.has(schema.slug)) return false;
271
+ return !(schema.plugin || schema.preset || schema.systemManaged || schema.meta?.generatedFromForm);
272
+ }
273
+
246
274
  /**
247
275
  * The list filter that keeps a user-data preset to the caller's own rows, or
248
276
  * null when no filter applies (not a user-data preset, root, or a preset whose
@@ -15,6 +15,7 @@ import * as cache from './cache/index.js';
15
15
  import {typedEntryData} from './entryValues.js';
16
16
  import {toCsv} from '../../public/js/collection-export.mjs';
17
17
  import {fileIn} from './safePath.js';
18
+ import {SHARED_TOOL_SLUGS} from './presetCollections.js';
18
19
 
19
20
  const COLLECTIONS_DIR = path.resolve(config.content.collectionsDir);
20
21
  const TOOL_TRASH_SLUGS = new Set(['notes-notes', 'todo-items', 'contacts-contacts']);
@@ -58,15 +59,62 @@ async function writeSchema(schema) {
58
59
  *
59
60
  * @returns {object}
60
61
  */
61
- function defaultApiAccess() {
62
+ function defaultApiAccess({owned = false} = {}) {
62
63
  return {
63
64
  create: { enabled: false, access: 'admin' },
64
- read: { enabled: true, access: 'public' },
65
+ // A Tool's collection holds the Tool's data (invitations, orders,
66
+ // contacts): nobody reads it through the public API unless the Tool's
67
+ // own schema says so. Open-by-default leaked exactly those rows.
68
+ read: owned ? { enabled: false, access: 'admin' } : { enabled: true, access: 'public' },
65
69
  update: { enabled: false, access: 'admin' },
66
70
  delete: { enabled: false, access: 'admin' }
67
71
  };
68
72
  }
69
73
 
74
+ /** The mark on a Tool's collection whose public read has been through closeToolCollections(). */
75
+ const API_DEFAULT_CLOSED = 'closed';
76
+
77
+ /**
78
+ * Close the public read of every Tool-owned collection that still has the old
79
+ * default (read on, for anyone) - once per collection.
80
+ *
81
+ * Until this rule a collection created with no `api` block was readable by
82
+ * anyone at /api/collections/:slug/public, and several Tools shipped schemas
83
+ * without one. Whether an existing collection is open on purpose or by that
84
+ * default cannot be told from the file, and no Tool relies on it, so it is
85
+ * closed; `apiDefault: 'closed'` records that it was looked at, and a site
86
+ * that then opens it in Collections > API & Export keeps its choice.
87
+ *
88
+ * @returns {Promise<string[]>} the slugs that were closed
89
+ */
90
+ export async function closeToolCollections() {
91
+ await ensureDir();
92
+ let names;
93
+ try {
94
+ names = (await fs.readdir(COLLECTIONS_DIR, {withFileTypes: true})).filter(e => e.isDirectory()).map(e => e.name);
95
+ } catch {
96
+ return [];
97
+ }
98
+ const closed = [];
99
+ for (const name of names) {
100
+ let schema;
101
+ try { schema = await readSchema(name); } catch { continue; }
102
+ if (!(schema?.plugin || SHARED_TOOL_SLUGS.has(schema?.slug)) || schema.apiDefault === API_DEFAULT_CLOSED) continue;
103
+ const read = schema.api?.read;
104
+ const open = read?.enabled === true && read?.access === 'public';
105
+ const next = {...schema, apiDefault: API_DEFAULT_CLOSED};
106
+ if (open) next.api = {...schema.api, read: {...read, enabled: false, access: 'admin'}};
107
+ try {
108
+ await writeSchema(next);
109
+ if (open) {
110
+ closed.push(schema.slug);
111
+ await cache.invalidateTags([`collection:${schema.slug}`]);
112
+ }
113
+ } catch { /* a read-only content directory: the next boot tries again */ }
114
+ }
115
+ return closed;
116
+ }
117
+
70
118
  // ---------------------------------------------------------------------------
71
119
  // Schema (collection) operations - always file-based
72
120
  // ---------------------------------------------------------------------------
@@ -157,10 +205,10 @@ export async function createCollection({title, slug, description = '', fields =
157
205
  title: title.trim(),
158
206
  description: description.trim(),
159
207
  fields,
160
- api: { ...defaultApiAccess(), ...api },
208
+ api: { ...defaultApiAccess({owned: Boolean(plugin)}), ...api },
161
209
  storage: storage || {adapter: 'file'},
162
210
  ...(bundled ? {bundled: true} : {}),
163
- ...(plugin ? {plugin} : {}),
211
+ ...(plugin ? {plugin, apiDefault: API_DEFAULT_CLOSED} : {}),
164
212
  ...(meta != null && {meta}),
165
213
  createdAt: now,
166
214
  updatedAt: now
@@ -196,8 +244,12 @@ export async function updateCollection(slug, updates) {
196
244
  // `api.mine` (see mineAllowed in collectionAccess.js) is kept when an
197
245
  // update's api block does not mention it: clients that rebuild `api` from
198
246
  // the four verbs would otherwise switch a collection's opt-out back on.
199
- if (rest.api && typeof rest.api === 'object' && !('mine' in rest.api) && schema.api && 'mine' in schema.api) {
200
- updated.api = {...rest.api, mine: schema.api.mine};
247
+ // `api.pages` (pagesAllowed, same file) likewise: a choice about showing
248
+ // the rows on pages must not be lost to a client that never heard of it.
249
+ if (rest.api && typeof rest.api === 'object' && schema.api) {
250
+ for (const kept of ['mine', 'pages']) {
251
+ if (!(kept in rest.api) && kept in schema.api) updated.api = {...updated.api, [kept]: schema.api[kept]};
252
+ }
201
253
  }
202
254
 
203
255
  // Preserve the original plugin field (never overwrite)
@@ -17,6 +17,7 @@ import {fileURLToPath} from 'url';
17
17
  import {applyTransforms, getSanitizeExtensions, getShortcodeProcessors} from './hooks.js';
18
18
  import {getConfig} from '../config.js';
19
19
  import {getCollection, listEntries} from './collections.js';
20
+ import {pagesAllowed} from './collectionAccess.js';
20
21
  import {getMenu, navbarOverrideFromAttrs, resolveLocation, resolveMenuDecorations} from './menus.js';
21
22
  import {contentsOverrideFromAttrs} from './pageContents.js';
22
23
  import {buildMenuNav} from './menuRender.js';
@@ -1338,7 +1339,7 @@ async function processViewBlocks(markdown, tagSet, user = null, flags = {}) {
1338
1339
  * @param {string} markdown
1339
1340
  * @returns {Promise<string>}
1340
1341
  */
1341
- async function processCollectionBlocks(markdown, tagSet) {
1342
+ async function processCollectionBlocks(markdown, tagSet, opts = {}) {
1342
1343
  const {scrubbed, restore} = scrubCodeRegions(markdown);
1343
1344
  // Find all [collection ...] shortcodes
1344
1345
  const pattern = /\[collection([^\]]*?)\/\]/gi;
@@ -1357,6 +1358,21 @@ async function processCollectionBlocks(markdown, tagSet) {
1357
1358
  }
1358
1359
  tagSet?.add(`collection:${slug}`);
1359
1360
 
1361
+ // The tag reads rows for whoever wrote the text, with no viewer check,
1362
+ // so the collection itself says whether it may be shown on a page
1363
+ // (pagesAllowed: a Tool's, a built-in's or a form's rows are not,
1364
+ // unless the site switched that on). scope="mine" is a viewer's own
1365
+ // rows, decided later by api.mine.
1366
+ const asked = attrs.scope === 'mine' ? null : await getCollection(slug).catch(() => null);
1367
+ if (asked && !pagesAllowed(asked)) {
1368
+ // The writer is told why, in a preview; a visitor gets nothing.
1369
+ const note = (opts.expiry?.preview || opts.writerNotes)
1370
+ ? `<div class="dm-collection-display dm-collection-empty"><p>${escapeHtmlText(`The collection "${slug}" is not set to be shown on pages. Switch on "Show on pages" in Collections, under API & Export.`)}</p></div>`
1371
+ : '';
1372
+ result = result.replace(fullMatch, () => inertShortcodes(note));
1373
+ continue;
1374
+ }
1375
+
1360
1376
  // scope="mine" can't share the per-role page cache (data is per-user),
1361
1377
  // so emit a hydration placeholder. The public site JS POSTs the raw
1362
1378
  // attrs to /api/collections/render-scope, which re-runs renderCollectionFragment
@@ -5505,7 +5521,7 @@ export async function parseMarkdown(raw, opts = {}) {
5505
5521
  const slots = await processSlottedBlocks(preprocessed, opts, tagSet, flags, slotComponents);
5506
5522
  const {output: withComponents, used: usedComponents} = collectAndRewriteComponents(slots.output);
5507
5523
  for (const component of slotComponents) usedComponents.add(component);
5508
- const withCollection = await processCollectionBlocks(withComponents, tagSet);
5524
+ const withCollection = await processCollectionBlocks(withComponents, tagSet, opts);
5509
5525
  const withView = await processViewBlocks(withCollection, tagSet, opts.user || null, flags);
5510
5526
  const withStaticBlock = await processStaticBlocks(withView, tagSet);
5511
5527
  const menuCtx = opts.urlPath
@@ -42,3 +42,18 @@ export function formMayCollect(type) {
42
42
  export function refusedExtensions() {
43
43
  return Object.entries(mime._types).filter(([, type]) => !formMayCollect(type)).map(([ext]) => ext).sort();
44
44
  }
45
+
46
+ /**
47
+ * The headers /media/ adds to a file it serves. nosniff always; a file a browser would run as a document (HTML, any
48
+ * XML, SVG, script) is sandboxed - shown, never able to script this site's address. A picture may be shown from
49
+ * another site's page: Media is public, and an email is read on someone else's page (webmail), where helmet's
50
+ * same-origin left a campaign's banner and footer as alt text. Everything else keeps helmet's same-origin.
51
+ */
52
+ export function mediaHeaders(filePath) {
53
+ const type = servedType(filePath);
54
+ return {
55
+ 'X-Content-Type-Options': 'nosniff',
56
+ ...(isActiveType(type) ? {'Content-Security-Policy': "sandbox; default-src 'none'; img-src 'self' data:; style-src 'unsafe-inline'"} : {}),
57
+ ...(/^image\//.test(type) ? {'Cross-Origin-Resource-Policy': 'cross-origin'} : {})
58
+ };
59
+ }
@@ -12,6 +12,14 @@ const COLLECTIONS_DIR = path.resolve(config.content.collectionsDir);
12
12
  // contacts, enquiries, feedback, notes, categories, posts, comments, to-do
13
13
  // have been removed - they belong to plugins and are seeded on plugin enable.
14
14
 
15
+ /**
16
+ * The outreach Tools' shared lists (people's addresses). Whichever Tool is
17
+ * enabled first makes them, and the unsubscribe page makes the suppression
18
+ * list with no Tool at all - so one of these can exist with no `plugin` mark.
19
+ * They are a Tool's collections all the same.
20
+ */
21
+ export const SHARED_TOOL_SLUGS = new Set(['outreach-contacts', 'outreach-groups', 'outreach-unsubscribes']);
22
+
15
23
  /** A chat preset: system-managed, no public API, MongoDB where the site can have it. */
16
24
  function chatPreset(slug, title, description, fields) {
17
25
  const closed = {enabled: false, access: 'admin'};
@@ -552,6 +560,13 @@ const PRESETS = [
552
560
  /** Slugs exported for use in adapterRegistry and the delete guard. */
553
561
  export const PRESET_COLLECTION_SLUGS = PRESETS.map(p => p.slug);
554
562
 
563
+ /**
564
+ * Every built-in collection, by name. A stored schema cannot be asked: reading
565
+ * one turns `preset` into `bundled` (collections.js readSchema), and `bundled`
566
+ * is also a switch a site can set on a collection of its own.
567
+ */
568
+ export const BUILT_IN_SLUGS = new Set(['roles', 'user-profiles', ...PRESET_COLLECTION_SLUGS]);
569
+
555
570
  /**
556
571
  * The presets that hold people's own data - the Notes, Todo and Contacts
557
572
  * Tools - rather than the site's workings. These, and only these, may live in
@@ -584,12 +599,13 @@ async function keptStorage(schemaPath) {
584
599
  return null;
585
600
  }
586
601
 
587
- /** Whether an existing schema.json switches scope=mine off (`api.mine: false`). */
588
- async function keptMineOff(schemaPath) {
602
+ /** A site's own api choices in an existing schema.json: scope=mine off, and Show on pages on. */
603
+ async function keptChoices(schemaPath) {
589
604
  try {
590
- return JSON.parse(await fs.readFile(schemaPath, 'utf8'))?.api?.mine === false;
605
+ const api = JSON.parse(await fs.readFile(schemaPath, 'utf8'))?.api;
606
+ return {mineOff: api?.mine === false, pagesOn: api?.pages === true};
591
607
  } catch {
592
- return false;
608
+ return {mineOff: false, pagesOn: false};
593
609
  }
594
610
  }
595
611
 
@@ -612,9 +628,14 @@ export async function seedAll() {
612
628
  let written = kept ? {...schema, storage: kept} : schema;
613
629
  // A site's `api.mine: false` (own rows not readable through scope=mine)
614
630
  // survives the rewrite; it only ever narrows access.
615
- if (schema.api?.mine !== false && await keptMineOff(schemaPath)) {
631
+ const choices = await keptChoices(schemaPath);
632
+ if (schema.api?.mine !== false && choices.mineOff) {
616
633
  written = {...written, api: {...(written.api || {}), mine: false}};
617
634
  }
635
+ // So does "Show on pages" switched on for a built-in (pagesAllowed in
636
+ // collectionAccess.js): the site said so, and without this the switch
637
+ // would go back off at every start.
638
+ if (choices.pagesOn) written = {...written, api: {...(written.api || {}), pages: true}};
618
639
  await fs.writeFile(schemaPath, JSON.stringify(written, null, 2) + '\n', 'utf8');
619
640
 
620
641
  try {