@crombolo/server 0.60.0 → 0.62.0

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.
@@ -282,7 +282,11 @@ export function createMemberAuth(
282
282
  applicationUrl: config.applicationUrl,
283
283
  secureCookies: config.secureCookies,
284
284
  resolve: (provider) =>
285
- new IdentityProviderOverrides(db, config.secretKey).apply('member', provider),
285
+ new IdentityProviderOverrides(
286
+ db,
287
+ config.secretKey,
288
+ config.lockedIdentityProviders,
289
+ ).apply('member', provider),
286
290
  },
287
291
  )
288
292
 
@@ -122,7 +122,7 @@ export async function checkedAddress(
122
122
  const reason = refusedAddress(address)
123
123
  if (reason)
124
124
  throw new OutboundRefused(
125
- `${host === address ? host : `${host} (${address})`} is ${reason}, which this site does not send to. The config's webhooks.allowPrivateAddresses allows it.`,
125
+ `${host === address ? host : `${host} (${address})`} is ${reason}, which this site does not send to. CROMBOLO_ALLOW_PRIVATE_ADDRESSES allows it.`,
126
126
  )
127
127
  }
128
128
  return addresses[0]
package/src/ports.ts CHANGED
@@ -28,7 +28,6 @@ import {
28
28
  import type { EventSink } from '@crombolo/content'
29
29
  import {
30
30
  CORE_SECTION_ALIASES,
31
- clientSections,
32
31
  DEFAULT_UPLOAD_SETTINGS,
33
32
  hasAccessToSensitiveData,
34
33
  isUploadAllowed,
@@ -257,7 +256,7 @@ function createCurrentUserPort(
257
256
  hasAccessToSensitiveData: hasAccessToSensitiveData(principal.groups),
258
257
  fallbackPermissions: principal.permissions,
259
258
  permissions,
260
- allowedSections: clientSections(principal),
259
+ allowedSections: [...principal.allowedSections],
261
260
  userGroupIds: principal.groupKeys.map((id) => ({ id })),
262
261
  }
263
262
  },
package/src/remote.ts CHANGED
@@ -45,7 +45,7 @@ import {
45
45
  } from '@crombolo/transfer'
46
46
  import { readAuditPageQuery, recordAudit } from './adapters/audit.ts'
47
47
  import { type BundleAdmin, settingsIn } from './bundle-admin.ts'
48
- import { actAsChoice } from './bundle-api.ts'
48
+ import { userKeyOf } from './bundle-api.ts'
49
49
  import { codeChanges, installedCode, planCode } from './bundle-code-install.ts'
50
50
  import {
51
51
  checkBundleContent,
@@ -878,6 +878,9 @@ export function createRemote(options: RemoteOptions): Remote {
878
878
  id: principal.ci ? null : principal.id,
879
879
  name: `${principal.name}${ciRun(principal)}`,
880
880
  email: principal.ci ? null : principal.email,
881
+ // A remote reaches extensions only with "Install code on this site", which is the
882
+ // grant itself: it counts as the administrator the back office asks for (story 324).
883
+ isAdmin: true,
881
884
  source: 'request' as const,
882
885
  ipAddress: null,
883
886
  forwardedFor: request.headers.get('x-forwarded-for'),
@@ -907,7 +910,8 @@ export function createRemote(options: RemoteOptions): Remote {
907
910
  grant: Array.isArray(body.grant)
908
911
  ? body.grant.filter((p): p is string => typeof p === 'string')
909
912
  : [],
910
- actAs: actAsChoice(body.actAs),
913
+ // A CI job has no key of its own: it names whom a job or an event acts for (story 325).
914
+ delegateTo: userKeyOf(body.delegateTo),
911
915
  },
912
916
  )
913
917
  return status === 200
@@ -957,7 +961,11 @@ export function createRemote(options: RemoteOptions): Remote {
957
961
  if (removing) {
958
962
  const name = decodeURIComponent(what.slice('installed/'.length))
959
963
  const outcome = await bundles.uninstall(actor, name, {
960
- revertContent: new URL(request.url).searchParams.get('revertContent') === 'true',
964
+ // Story 328: `dropContent`, `revertContent` before 0.61, still read for one release.
965
+ dropContent: ['dropContent', 'revertContent'].some(
966
+ (key) => new URL(request.url).searchParams.get(key) === 'true',
967
+ ),
968
+ dropData: new URL(request.url).searchParams.get('dropData') === 'true',
961
969
  })
962
970
  return outcome.ok
963
971
  ? Response.json(outcome)
@@ -974,7 +982,7 @@ export function createRemote(options: RemoteOptions): Remote {
974
982
  applyContent: body.applyContent === true,
975
983
  // Naming the grant is the consent: a script that names what it grants has said yes.
976
984
  grant,
977
- actAs: typeof body.actAs === 'string' ? body.actAs : null,
985
+ delegateTo: userKeyOf(body.delegateTo),
978
986
  settings: settingsIn(body.settings),
979
987
  })
980
988
  if (outcome.ok) return Response.json(outcome)
package/src/server.ts CHANGED
@@ -85,10 +85,12 @@ import {
85
85
  import {
86
86
  appendCacheInstruction,
87
87
  type Db,
88
+ ExtensionActivityLog,
88
89
  ensureFormLibraryTypes,
89
90
  ensureKeyValue,
90
91
  FormEntryRepository,
91
92
  FormWorkflowRepository,
93
+ FormWorkflowSecretRepository,
92
94
  JobRepository,
93
95
  type JobState,
94
96
  latestContentVersionId,
@@ -168,7 +170,7 @@ import { createPublishedContentSource, loadDraftNode } from './adapters/document
168
170
  import type { Approvals } from './approvals.ts'
169
171
  import { handleApprovalsApi } from './approvals-api.ts'
170
172
  import { type BundleActor, createBundleAdmin, settingsIn } from './bundle-admin.ts'
171
- import { actAsChoice, actingPrincipalOf } from './bundle-api.ts'
173
+ import { actingPrincipalOf } from './bundle-api.ts'
172
174
  import { type BundleGrants, declaredOrigins } from './bundle-grants.ts'
173
175
  import { CommandError, installBundleContent } from './bundle-install.ts'
174
176
  import { BUNDLES_CHANGED_EVENT, type BundleReload, createBundleReloader } from './bundle-reload.ts'
@@ -194,6 +196,7 @@ import { syncDomainsFile } from './domains.ts'
194
196
  import { editorTypeLibs, siteJsxImportSource } from './editor-types.ts'
195
197
  import { emailAvailability } from './email.ts'
196
198
  import { noticeAboutEmail } from './email-notice.ts'
199
+ import { activityCsv, readActivityQuery } from './extension-activity.ts'
197
200
  import { createBackOfficeBuilds } from './extension-backoffice.ts'
198
201
  import { warnAboutAppPlugins } from './extensions-notice.ts'
199
202
  import { coerceForm, deleteForm, saveForm } from './form-files.ts'
@@ -206,6 +209,7 @@ import {
206
209
  writeFlash,
207
210
  } from './form-submit.ts'
208
211
  import { describeFormTypes, formTypesFor } from './form-types.ts'
212
+ import { isSecretHeader, refusedSendAddresses } from './form-workflows.ts'
209
213
  import {
210
214
  entriesCsv,
211
215
  formDetail,
@@ -214,6 +218,7 @@ import {
214
218
  parseEntryState,
215
219
  redactSensitive,
216
220
  } from './forms.ts'
221
+ import { mayGrant } from './grant-policy.ts'
217
222
  import { HOST_TOKEN_SECONDS, issueHostToken } from './host-token.ts'
218
223
  import { canEncodeAvif, ImageProcessor, parseImagingQuery } from './imaging.ts'
219
224
  import type { BackgroundJobs } from './jobs.ts'
@@ -283,6 +288,7 @@ import { syncConfiguredRedirects } from './redirects.ts'
283
288
  import { createRoutes, type DeclaredRoute, SITE_ROUTE_OWNER, siteRouteProblems } from './routes.ts'
284
289
  import { componentAliasesIn, importSchema, type SchemaBoot, watchSchema } from './schema.ts'
285
290
  import { publishSchema, type SchemaStore } from './schema-store.ts'
291
+ import { SECRET_KEY_VARIABLE, sealSecret, usableSecretKey } from './secrets.ts'
286
292
  import { createSeoHost, originOf, publicOrigin } from './seo.ts'
287
293
  import {
288
294
  combineHubs,
@@ -459,7 +465,13 @@ export async function createServer(
459
465
  } = core
460
466
  /** The extensions that are on: granted, and not turned off (story 309). */
461
467
  const onExtensions = () =>
462
- extensions.list().filter((extension) => bundleGrants.isOn(extension.bundle.id))
468
+ extensions.list().filter(
469
+ (extension) =>
470
+ bundleGrants.isOn(extension.bundle.id) &&
471
+ // Story 326: one installed as a dependency shows only when the site's code wires it.
472
+ (!extension.bundle.dependency ||
473
+ config.bundles.some((bundle) => bundle.id === extension.bundle.id)),
474
+ )
463
475
  // Their back-office code, built when first asked for (story 320).
464
476
  const backOfficeBuilds = createBackOfficeBuilds(config.siteDir, (id) => {
465
477
  const named = logger('bundle', id)
@@ -495,6 +507,7 @@ export async function createServer(
495
507
  contentApplied: async (packageName) =>
496
508
  (await new TransferRunRepository(db).appliedForPackage(packageName))?.packageVersion ?? null,
497
509
  applyContentOnInstall: config.applyBundleContentOnInstall,
510
+ unrestrictedFrom: config.unrestrictedExtensions,
498
511
  installs: config.runtimeInstalls,
499
512
  installsElsewhere: config.installsElsewhere,
500
513
  policy: config.bundlePolicy,
@@ -624,7 +637,11 @@ export async function createServer(
624
637
  secureCookies: config.secureCookies,
625
638
  log: (message) => log.warning('Backoffice sign-in: {message}', { message }),
626
639
  resolve: (provider) =>
627
- new IdentityProviderOverrides(db, config.secretKey).apply('user', provider),
640
+ new IdentityProviderOverrides(
641
+ db,
642
+ config.secretKey,
643
+ config.lockedIdentityProviders,
644
+ ).apply('user', provider),
628
645
  },
629
646
  )
630
647
 
@@ -846,11 +863,13 @@ export async function createServer(
846
863
  extensions,
847
864
  bundleGrants,
848
865
  failed: () => [...core.failedExtensions, ...backOfficeBuilds.failed()],
866
+ stopExtension: (id) => core.stopExtension(id),
849
867
  })
850
868
  const actorOf = (principal: Principal, request: Request): BundleActor => ({
851
869
  id: principal.id,
852
870
  name: principal.name,
853
871
  email: principal.email,
872
+ isAdmin: principal.isAdmin,
854
873
  source: 'request',
855
874
  ...clientAddress(request),
856
875
  })
@@ -2142,6 +2161,7 @@ export async function createServer(
2142
2161
  url: marketplace.url(),
2143
2162
  keyword: config.packageKeyword,
2144
2163
  appliesContent: config.applyBundleContentOnInstall,
2164
+ mayGrant: mayGrant(principal.isAdmin, config.unrestrictedExtensions),
2145
2165
  installs: config.runtimeInstalls,
2146
2166
  installsElsewhere: config.runtimeInstalls ? null : (config.installsElsewhere ?? null),
2147
2167
  items: await marketplace.search(url.searchParams.get('q') ?? undefined),
@@ -2203,8 +2223,56 @@ export async function createServer(
2203
2223
  }
2204
2224
  }
2205
2225
 
2226
+ // Story 328: the data a removed extension left, deleted on its own, an administrator's.
2227
+ if (action === 'drop-left-data' && request.method === 'POST') {
2228
+ if (!principal.isAdmin)
2229
+ return Response.json(
2230
+ { ok: false, message: 'An administrator deletes what an extension left.' },
2231
+ { status: 403 },
2232
+ )
2233
+ const body = (await request.json().catch(() => ({}))) as { id?: unknown }
2234
+ const { status, ...outcome } = await bundleAdmin.dropLeftData(
2235
+ actorOf(principal, request),
2236
+ typeof body.id === 'string' ? body.id : '',
2237
+ )
2238
+ return Response.json(outcome, { status })
2239
+ }
2240
+
2241
+ // Story 327: what one extension did, newest first, its counts, and the same as a file.
2242
+ const watching = /^installed\/([a-z0-9][a-z0-9-]*)\/activity(\/summary|\.csv)?$/.exec(action)
2243
+ if (watching && request.method === 'GET') {
2244
+ const [, id, part] = watching as unknown as [string, string, string | undefined]
2245
+ const read = readActivityQuery(url.searchParams)
2246
+ if (typeof read === 'string')
2247
+ return Response.json(
2248
+ { title: 'Invalid request', status: 400, detail: read },
2249
+ { status: 400 },
2250
+ )
2251
+ await core.activity.flush()
2252
+ const store = new ExtensionActivityLog(db)
2253
+ if (part === '/summary')
2254
+ return Response.json({
2255
+ counts: await store.counts(
2256
+ id,
2257
+ new Date(Date.now() - config.extensionActivityDays * 86_400_000),
2258
+ ),
2259
+ people: await store.people(id),
2260
+ days: config.extensionActivityDays,
2261
+ })
2262
+ if (part === '.csv')
2263
+ return new Response(await activityCsv(store, id, read.filter), {
2264
+ headers: {
2265
+ 'content-type': 'text/csv; charset=utf-8',
2266
+ 'content-disposition': `attachment; filename="${id}-activity.csv"`,
2267
+ },
2268
+ })
2269
+ return Response.json(await store.page(id, read.filter, read.cursor))
2270
+ }
2271
+
2272
+ // What this person may grant at each level here (story 324): the panel shows the button, the sentence or the snippet.
2273
+ const granting = mayGrant(principal.isAdmin, config.unrestrictedExtensions)
2206
2274
  if (action === 'installed' && request.method === 'GET')
2207
- return Response.json(await bundleAdmin.installed())
2275
+ return Response.json({ ...(await bundleAdmin.installed()), mayGrant: granting })
2208
2276
 
2209
2277
  // Where a version was built, for the Install panel before anything is
2210
2278
  // installed (story 060), and whether this site would take it.
@@ -2223,13 +2291,20 @@ export async function createServer(
2223
2291
  }
2224
2292
 
2225
2293
  if ((action === 'install' || action === 'uninstall') && request.method === 'POST') {
2294
+ // Installing or removing code is an administrator's, as granting it is (story 324).
2295
+ if (!principal.isAdmin)
2296
+ return Response.json(
2297
+ { ok: false, message: 'An administrator installs and removes extensions.' },
2298
+ { status: 403 },
2299
+ )
2226
2300
  const body = (await request.json().catch(() => ({}))) as {
2227
2301
  name?: unknown
2228
2302
  version?: unknown
2229
2303
  applyContent?: unknown
2230
2304
  grant?: unknown
2231
- actAs?: unknown
2232
2305
  settings?: unknown
2306
+ dropData?: unknown
2307
+ dropContent?: unknown
2233
2308
  }
2234
2309
  const name = typeof body.name === 'string' ? body.name : ''
2235
2310
  const actor = actorOf(principal, request)
@@ -2239,13 +2314,16 @@ export async function createServer(
2239
2314
  name,
2240
2315
  version: typeof body.version === 'string' ? body.version : undefined,
2241
2316
  applyContent: body.applyContent !== false,
2242
- actAs: actAsChoice(body.actAs, principal.id),
2243
2317
  grant: Array.isArray(body.grant)
2244
2318
  ? body.grant.filter((p): p is string => typeof p === 'string')
2245
2319
  : [],
2246
2320
  settings: settingsIn(body.settings),
2247
2321
  })
2248
- : await bundleAdmin.uninstall(actor, name)
2322
+ : // Story 328: its data and the content it added are kept unless asked.
2323
+ await bundleAdmin.uninstall(actor, name, {
2324
+ dropData: body.dropData === true,
2325
+ dropContent: body.dropContent === true,
2326
+ })
2249
2327
  log.info('{user} {action} the package {name}: {outcome}', {
2250
2328
  user: principal.email,
2251
2329
  action: action === 'install' ? 'installed' : 'removed',
@@ -2314,17 +2392,12 @@ export async function createServer(
2314
2392
  : Response.json({ ok: false, message: outcome.message }, { status: outcome.status })
2315
2393
  }
2316
2394
 
2317
- // Story 309: granting an installed extension what it asks for, administrators only.
2395
+ // Story 309: granting an installed extension what it asks for, administrators only: the
2396
+ // admin's one refusal says so, for every level and every way in (story 324).
2318
2397
  if (action === 'grant' && request.method === 'POST') {
2319
- if (!principal.isAdmin)
2320
- return Response.json(
2321
- { ok: false, message: 'Only an administrator grants an extension.' },
2322
- { status: 403 },
2323
- )
2324
2398
  const body = (await request.json().catch(() => ({}))) as {
2325
2399
  id?: unknown
2326
2400
  grant?: unknown
2327
- actAs?: unknown
2328
2401
  }
2329
2402
  const { status, ...outcome } = await bundleAdmin.grant(
2330
2403
  actorOf(principal, request),
@@ -2333,7 +2406,6 @@ export async function createServer(
2333
2406
  grant: Array.isArray(body.grant)
2334
2407
  ? body.grant.filter((p): p is string => typeof p === 'string')
2335
2408
  : [],
2336
- actAs: actAsChoice(body.actAs, principal.id),
2337
2409
  },
2338
2410
  )
2339
2411
  return Response.json(outcome, { status })
@@ -2661,11 +2733,74 @@ export async function createServer(
2661
2733
  })
2662
2734
  }
2663
2735
 
2736
+ // A send-to-URL workflow's secret header (story 304): sealed here, never
2737
+ // in the form's file, and never shown back. Set on any site, schema
2738
+ // writable or not, since it is the site's own and not the form's.
2739
+ const secretMatch = /^([^/]+)\/workflows\/([^/]+)\/secrets\/([^/]+)$/.exec(action)
2740
+ if (secretMatch && (request.method === 'PUT' || request.method === 'DELETE')) {
2741
+ if (!may(FormPermissions.Manage)) return new Response('Forbidden', { status: 403 })
2742
+ const [, formKey, workflowKey, header] = secretMatch.map((part) =>
2743
+ decodeURIComponent(part),
2744
+ ) as [string, string, string, string]
2745
+ const form = byKey.get(formKey)
2746
+ const workflow = form?.workflows.find((candidate) => candidate.key === workflowKey)
2747
+ const headers = workflow?.settings.headers as Record<string, unknown> | undefined
2748
+ if (!form?.key || !workflow || !isSecretHeader(headers?.[header]))
2749
+ return Response.json(
2750
+ { message: 'The form names no such secret header; save the form first.' },
2751
+ { status: 404 },
2752
+ )
2753
+ const secrets = new FormWorkflowSecretRepository(db)
2754
+ let set: { sealed: string; url: string } | undefined
2755
+ if (request.method === 'PUT') {
2756
+ const body = (await request.json().catch(() => ({}))) as { value?: unknown }
2757
+ if (typeof body.value !== 'string' || body.value === '')
2758
+ return Response.json({ message: 'Give the header a value.' }, { status: 400 })
2759
+ const key = usableSecretKey(config.secretKey)
2760
+ if (!key)
2761
+ return Response.json(
2762
+ {
2763
+ message: `Keeping a secret header needs ${SECRET_KEY_VARIABLE} set on the server.`,
2764
+ },
2765
+ { status: 409 },
2766
+ )
2767
+ set = { sealed: sealSecret(body.value, key), url: String(workflow.settings.url ?? '') }
2768
+ }
2769
+ await secrets.set(form.key, workflowKey, header, set, principal.name ?? null)
2770
+ await recordAudit(db, {
2771
+ category: 'settings',
2772
+ action: set ? 'secret header set' : 'secret header removed',
2773
+ source: 'request',
2774
+ userKey: principal.id,
2775
+ userName: principal.name,
2776
+ entityType: 'form',
2777
+ entityKey: form.key,
2778
+ entityName: form.name,
2779
+ detail: `${workflow.name}: ${header}`,
2780
+ ...clientAddress(request),
2781
+ })
2782
+ return Response.json({ ok: true })
2783
+ }
2784
+
2664
2785
  if (action && request.method === 'GET') {
2665
2786
  const form = byKey.get(decodeURIComponent(action))
2666
2787
  if (!form) return new Response('Not Found', { status: 404 })
2788
+ // Which secret headers are set for the address each workflow sends to, never their values.
2789
+ const secrets: { workflow: string; header: string; set: boolean }[] = []
2790
+ for (const workflow of form.workflows) {
2791
+ const headers = workflow.settings.headers as Record<string, unknown> | undefined
2792
+ const named = Object.keys(headers ?? {}).filter((name) => isSecretHeader(headers?.[name]))
2793
+ if (named.length === 0 || !workflow.key || !form.key) continue
2794
+ const kept = await new FormWorkflowSecretRepository(db).of(form.key, workflow.key)
2795
+ for (const header of named)
2796
+ secrets.push({
2797
+ workflow: workflow.key,
2798
+ header,
2799
+ set: kept.get(header)?.url === workflow.settings.url,
2800
+ })
2801
+ }
2667
2802
  // The whole definition, which is what the designer edits.
2668
- return Response.json({ ...formDetail(form), definition: form })
2803
+ return Response.json({ ...formDetail(form), definition: form, secrets })
2669
2804
  }
2670
2805
 
2671
2806
  // What a choice source offers now, in the default language, for the
@@ -2704,6 +2839,9 @@ export async function createServer(
2704
2839
  if (!may(FormPermissions.Manage)) return new Response('Forbidden', { status: 403 })
2705
2840
  const body = await request.json().catch(() => ({}))
2706
2841
  const folder = url.searchParams.get('folder') ?? undefined
2842
+ const refused = await refusedSendAddresses(coerceForm(body), config.allowPrivateAddresses)
2843
+ if (refused.length > 0)
2844
+ return Response.json({ status: 'invalid', problems: refused }, { status: 400 })
2707
2845
  const written = await saveForm(coerceForm(body), { ...formFiles, folder })
2708
2846
  if (!written.ok) {
2709
2847
  log.warning('{user} could not save a form: {detail}', {
@@ -2720,6 +2858,12 @@ export async function createServer(
2720
2858
  forms.invalidate()
2721
2859
  await ensureFormLibraryTypes(db, forms.all())
2722
2860
  cache.invalidate()
2861
+ const saved = coerceForm(body)
2862
+ if (saved.key)
2863
+ await new FormWorkflowSecretRepository(db).forget(
2864
+ saved.key,
2865
+ saved.workflows.flatMap((workflow) => (workflow.key ? [workflow.key] : [])),
2866
+ )
2723
2867
  log.info('{user} saved the form {form}', {
2724
2868
  user: principal.email,
2725
2869
  form: coerceForm(body).alias,
@@ -2740,6 +2884,7 @@ export async function createServer(
2740
2884
  forms.invalidate()
2741
2885
  await ensureFormLibraryTypes(db, forms.all())
2742
2886
  cache.invalidate()
2887
+ if (form.key) await new FormWorkflowSecretRepository(db).forget(form.key)
2743
2888
  log.info('{user} deleted the form {form}; its entries are kept', {
2744
2889
  user: principal.email,
2745
2890
  form: form.alias,
package/src/settings.ts CHANGED
@@ -204,6 +204,14 @@ const DECLARED = [
204
204
  section: 'Database',
205
205
  description: 'How many days the audit log keeps an entry. `0` keeps them all.',
206
206
  },
207
+ {
208
+ env: 'CROMBOLO_EXTENSION_ACTIVITY_DAYS',
209
+ kind: 'number',
210
+ default: '14',
211
+ section: 'Database',
212
+ description:
213
+ 'How many days what each extension did is kept for its Activity view in Settings, under Extensions. `0` keeps nothing.',
214
+ },
207
215
  {
208
216
  env: 'CROMBOLO_EVENT_RETENTION_DAYS',
209
217
  kind: 'number',
@@ -214,6 +222,13 @@ const DECLARED = [
214
222
  },
215
223
 
216
224
  // Sign-in and secrets
225
+ {
226
+ env: 'CROMBOLO_ALLOW_PRIVATE_ADDRESSES',
227
+ kind: 'boolean',
228
+ section: 'Sign-in and secrets',
229
+ description:
230
+ "Lets webhooks, a form's send-to-URL workflow and an identity provider's test reach loopback, private and link-local addresses, for an intranet. On in development, off otherwise.",
231
+ },
217
232
  {
218
233
  env: 'CROMBOLO_ADMIN_LOGIN',
219
234
  kind: 'string',
@@ -262,6 +277,13 @@ const DECLARED = [
262
277
  description:
263
278
  'Creates the password administrator even when an API client is set. Honoured only on localhost.',
264
279
  },
280
+ {
281
+ env: 'CROMBOLO_LOCKED_IDENTITY_PROVIDERS',
282
+ kind: 'list',
283
+ section: 'Sign-in and secrets',
284
+ description:
285
+ "Identity providers nobody can change in the back office, by id, separated by commas, or `all`: they sign in by the site's configuration alone. A provider declared `locked: true` is locked too.",
286
+ },
265
287
  {
266
288
  env: 'CROMBOLO_SECRET_KEY',
267
289
  kind: 'string',
@@ -347,6 +369,15 @@ const DECLARED = [
347
369
  description:
348
370
  'Where a signed bundle has to come from, separated by commas: `org/*`, `org/repo`, or `org/repo@v*` for its tags. Empty takes signed extensions from anywhere. Each is also a trusted CI build for site bundles, locked on Settings → Trusted signers.',
349
371
  },
372
+ {
373
+ env: 'CROMBOLO_UNRESTRICTED_EXTENSIONS',
374
+ kind: 'enum',
375
+ values: ['backoffice', 'config'],
376
+ default: 'backoffice',
377
+ section: 'Back office and bundles',
378
+ description:
379
+ "Where an Unrestricted extension, one whose own code runs in the back office, may be turned on: by an administrator in Settings, or only in the site's configuration, so a commit someone reviews is the only way.",
380
+ },
350
381
  {
351
382
  env: 'CROMBOLO_INSTALLS_ELSEWHERE_MESSAGE',
352
383
  kind: 'string',
package/src/site-file.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  * failed export never leaves a file that looks whole.
11
11
  */
12
12
  import { rename, rm } from 'node:fs/promises'
13
- import { discoverBundles } from '@crombolo/backoffice-host/registry'
13
+ import { discoverBundles, readRecord } from '@crombolo/backoffice-host/registry'
14
14
  import { type Db, NodeRepository, type NodeRow, ObjectTypes } from '@crombolo/data'
15
15
  import {
16
16
  BUNDLE_SECTIONS,
@@ -125,11 +125,14 @@ export function unknownHostProvided(
125
125
  }
126
126
 
127
127
  function requiredPackages(config: CromboloConfig): Record<string, string> {
128
- if (config.bundles.length === 0) return {}
129
128
  const wired = new Set(config.bundles.map((bundle) => bundle.id))
130
129
  // The installation's own packages are not the site's to need (story 177).
131
130
  const hosts = new Set(config.hostProvided)
132
131
  const required: Record<string, string> = {}
132
+ // Story 326: what the record says is installed, each in a root of its own.
133
+ for (const line of Object.values(readRecord(config.siteDir)))
134
+ if (!hosts.has(line.name)) required[line.name] = line.version
135
+ if (config.bundles.length === 0) return required
133
136
  for (const found of discoverBundles(config.siteDir).bundles)
134
137
  if (wired.has(found.id) && !hosts.has(found.packageName))
135
138
  required[found.packageName] = found.version