@crombolo/server 0.60.0 → 0.61.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.
@@ -5,16 +5,21 @@
5
5
  * disable it.
6
6
  * docs/bundles.md, "Permissions".
7
7
  */
8
+
9
+ import { hasSection, type Principal } from '@crombolo/api-management/domain'
8
10
  import {
11
+ AREA_PERMISSIONS,
9
12
  askedPermissions,
10
13
  type BundlePackage,
11
14
  type BundlePermission,
12
15
  type DeclaredPermission,
13
16
  describePermissions,
14
17
  isSchema3Field,
18
+ USER_DELEGATE,
15
19
  } from '@crombolo/backoffice-host/registry'
16
- import { type BundleGrant, BundleGrantRepository, type Db } from '@crombolo/data'
17
- import { API_PERMISSIONS } from './bundle-api.ts'
20
+ import { type ActivityKind, type BundleGrant, BundleGrantRepository, type Db } from '@crombolo/data'
21
+ import { API_PERMISSIONS, sectionOfPermission } from './bundle-api.ts'
22
+ import { type ActivityPerson, type ActivityRecorder, timed } from './extension-activity.ts'
18
23
 
19
24
  /** The permissions each capability serves; `log` needs none. */
20
25
  export const CAPABILITY_PERMISSIONS: Record<string, readonly BundlePermission[]> = {
@@ -32,7 +37,8 @@ export const CAPABILITY_PERMISSIONS: Record<string, readonly BundlePermission[]>
32
37
  const DECLARATION_PERMISSIONS: ReadonlySet<string> = new Set([
33
38
  'events.content',
34
39
  'routes.public',
35
- 'actAs',
40
+ // Every area, as the person using it: checked per call, not by a capability (story 325).
41
+ USER_DELEGATE,
36
42
  'templates',
37
43
  'member.delegate',
38
44
  // What the screens need, not the server half (story 320).
@@ -108,7 +114,9 @@ export function permissionProblems(
108
114
  const serves = CAPABILITY_PERMISSIONS[capability]
109
115
  if (!serves || serves.length === 0) continue
110
116
  const writes = serves.filter((p) => p !== 'member.delegate')
111
- if (!writes.some((p) => has.has(p)))
117
+ // Acting for the person covers every area's capability, not a request out (story 325).
118
+ const delegated = has.has(USER_DELEGATE) && capability !== 'fetch'
119
+ if (!writes.some((p) => has.has(p)) && !delegated)
112
120
  problems.push(
113
121
  `Bundle "${label}" uses "${capability}" but declares none of its permissions (${writes.join(', ')}) in "crombolo.permissions".`,
114
122
  )
@@ -129,6 +137,28 @@ export function permissionProblems(
129
137
  return problems
130
138
  }
131
139
 
140
+ /**
141
+ * What a capability may use for this caller (story 325): its grant, and under
142
+ * `user.delegate` each area whose section the back-office person using it holds.
143
+ * A job, an event or a visitor adds nothing: they reach the site only through
144
+ * `api`, as whoever granted it. Pure.
145
+ */
146
+ export function delegatedPermissions(
147
+ granted: readonly string[],
148
+ person: Principal | undefined,
149
+ ): string[] {
150
+ if (!granted.includes(USER_DELEGATE) || !person) return [...granted]
151
+ const reached = AREA_PERMISSIONS.filter((permission) => {
152
+ if (person.isAdmin) return true
153
+ const section = sectionOfPermission(permission)
154
+ return section !== undefined && hasSection(person, section)
155
+ })
156
+ return [...new Set([...granted, ...reached])]
157
+ }
158
+
159
+ /** Why `user.delegate` cannot be granted without a person to act for (story 325). */
160
+ export const DELEGATE_NEEDS_PERSON = `${USER_DELEGATE} acts for whoever granted it when nobody is using it, and nobody is named: grant it signed in to the back office, or name the user with --delegate-to <user key>`
161
+
132
162
  /** A capability call the bundle was not given the permission for. */
133
163
  export class PermissionRefusedError extends Error {
134
164
  constructor(
@@ -148,6 +178,8 @@ export function gated<T extends object>(
148
178
  capability: string,
149
179
  host: T,
150
180
  declared: readonly string[],
181
+ /** Records each call for the activity view (story 327), for the person it is made for. */
182
+ activity?: { recorder: ActivityRecorder; person: ActivityPerson },
151
183
  ): T {
152
184
  const methods = METHOD_PERMISSIONS[capability]
153
185
  if (!methods) return host
@@ -155,13 +187,32 @@ export function gated<T extends object>(
155
187
  const out: Record<string, unknown> = {}
156
188
  for (const [name, value] of Object.entries(host)) {
157
189
  const needs = methods[name]
190
+ const event = {
191
+ extensionId: bundle,
192
+ ...(activity?.person ?? { personKey: null, personName: null }),
193
+ kind: (needs?.endsWith('.read') ? 'read' : 'write') as ActivityKind,
194
+ area: capability,
195
+ verb: name,
196
+ }
158
197
  out[name] =
159
198
  typeof value === 'function' && needs && !has.has(needs)
160
199
  ? () => {
200
+ activity?.recorder.record({
201
+ ...event,
202
+ kind: 'refused',
203
+ verb: `${name} (${needs})`,
204
+ outcome: 'refused',
205
+ })
161
206
  throw new PermissionRefusedError(bundle, needs)
162
207
  }
163
208
  : typeof value === 'function'
164
- ? (value as (...args: unknown[]) => unknown).bind(host)
209
+ ? // A request out is recorded where its origin is known, as a request (story 327).
210
+ activity && needs && capability !== 'fetch'
211
+ ? (...args: unknown[]) =>
212
+ timed(activity.recorder, event, () =>
213
+ (value as (...args: unknown[]) => unknown).apply(host, args),
214
+ )
215
+ : (value as (...args: unknown[]) => unknown).bind(host)
165
216
  : value
166
217
  }
167
218
  return Object.freeze(out) as T
@@ -189,7 +240,7 @@ export interface BundleGrantState {
189
240
 
190
241
  /**
191
242
  * What the installed version asks for that a grant does not cover (story 309):
192
- * permissions, `http.outbound` origins, and whom `actAs` acts for. Empty when it
243
+ * permissions, `http.outbound` origins, and who granted `user.delegate`. Empty when it
193
244
  * covers it all. Pure.
194
245
  */
195
246
  export function grantGaps(pkg: BundlePackage, grant: BundleGrant | undefined): string[] {
@@ -199,8 +250,12 @@ export function grantGaps(pkg: BundlePackage, grant: BundleGrant | undefined): s
199
250
  const gaps = declaredPermissions(pkg).filter((permission) => !has.has(permission))
200
251
  for (const origin of declaredOrigins(pkg))
201
252
  if (!grant.origins.includes(origin)) gaps.push(`http.outbound ${origin}`)
202
- if (declaredPermissions(pkg).includes('actAs') && !grant.actAs && !gaps.includes('actAs'))
203
- gaps.push('actAs: whom it acts for')
253
+ if (
254
+ declaredPermissions(pkg).includes(USER_DELEGATE) &&
255
+ !grant.delegateKey &&
256
+ !gaps.includes(USER_DELEGATE)
257
+ )
258
+ gaps.push(`${USER_DELEGATE}: who granted it, for when nobody is using it`)
204
259
  return gaps
205
260
  }
206
261
 
@@ -219,22 +274,24 @@ export interface BundleGrants {
219
274
  state(pkg: BundlePackage): BundleGrantState
220
275
  /**
221
276
  * Records what a bundle is approved for, and by whom; true when that changed.
222
- * `actAs` is whom it acts for, when it asks to act for a user (story 308).
277
+ * `delegateKey` is who granted `user.delegate`, whom a job or an event acts for (story 325).
223
278
  */
224
279
  grant(
225
280
  pkg: BundlePackage,
226
281
  by: string | null,
227
- options?: { actAs?: string | null },
282
+ options?: { delegateKey?: string | null },
228
283
  ): Promise<boolean>
229
284
  disable(pkg: BundlePackage, by: string | null): Promise<BundleGrantState>
230
285
  enable(pkg: BundlePackage): Promise<BundleGrantState>
286
+ /** Forgets its grant entirely, as removing it does (story 328). */
287
+ forget(bundleId: string): Promise<void>
231
288
  }
232
289
 
233
290
  /** Whether a recorded approval already holds this version and list. */
234
291
  export function approvalHolds(
235
292
  pkg: BundlePackage,
236
293
  grant: BundleGrant | undefined,
237
- actAs?: string | null,
294
+ delegateKey?: string | null,
238
295
  ): boolean {
239
296
  if (!grant || grant.version !== pkg.version) return false
240
297
  const same = (a: readonly string[], b: readonly string[]) =>
@@ -242,7 +299,7 @@ export function approvalHolds(
242
299
  return (
243
300
  same(grant.permissions, declaredPermissions(pkg)) &&
244
301
  same(grant.origins, declaredOrigins(pkg)) &&
245
- (actAs === undefined || grant.actAs === actAs)
302
+ (delegateKey === undefined || grant.delegateKey === delegateKey)
246
303
  )
247
304
  }
248
305
 
@@ -314,7 +371,7 @@ export function createBundleGrants(options: {
314
371
  version: pkg.version,
315
372
  permissions: declaredPermissions(pkg),
316
373
  origins: declaredOrigins(pkg),
317
- actAs: declaredPermissions(pkg).includes('actAs') ? grant.actAs : null,
374
+ delegateKey: declaredPermissions(pkg).includes(USER_DELEGATE) ? grant.delegateKey : null,
318
375
  grantedBy: grant.grantedBy,
319
376
  })
320
377
  await read()
@@ -325,7 +382,7 @@ export function createBundleGrants(options: {
325
382
  return stateOf(pkg)
326
383
  },
327
384
  async grant(pkg, by, options = {}) {
328
- if (approvalHolds(pkg, grants.get(pkg.id), options.actAs)) return false
385
+ if (approvalHolds(pkg, grants.get(pkg.id), options.delegateKey)) return false
329
386
  const asks = declaredPermissions(pkg)
330
387
  await repository.grant({
331
388
  bundleId: pkg.id,
@@ -333,12 +390,18 @@ export function createBundleGrants(options: {
333
390
  version: pkg.version,
334
391
  permissions: asks,
335
392
  origins: declaredOrigins(pkg),
336
- actAs: asks.includes('actAs') ? (options.actAs ?? grants.get(pkg.id)?.actAs ?? null) : null,
393
+ delegateKey: asks.includes(USER_DELEGATE)
394
+ ? (options.delegateKey ?? grants.get(pkg.id)?.delegateKey ?? null)
395
+ : null,
337
396
  grantedBy: by,
338
397
  })
339
398
  await read()
340
399
  return true
341
400
  },
401
+ async forget(bundleId) {
402
+ await repository.forget(bundleId)
403
+ await read()
404
+ },
342
405
  async disable(pkg, by) {
343
406
  await repository.disable(
344
407
  { bundleId: pkg.id, packageName: pkg.packageName, version: pkg.version },
package/src/bundles.ts CHANGED
@@ -74,6 +74,7 @@ import {
74
74
  SITE_OWNER,
75
75
  type TablesDatabase,
76
76
  } from '@crombolo/data'
77
+ import type { ScreenAnswer } from '@crombolo/extension/screens'
77
78
  import {
78
79
  normaliseRedirectPath,
79
80
  type PublishedCache,
@@ -85,6 +86,7 @@ import { anonymiseProblems } from './anonymise-rules.ts'
85
86
  import type { BundleApi } from './bundle-api.ts'
86
87
  import {
87
88
  declaredPermissions,
89
+ delegatedPermissions,
88
90
  disabledResponse,
89
91
  gated,
90
92
  isSchema3,
@@ -92,6 +94,8 @@ import {
92
94
  permissionProblems,
93
95
  } from './bundle-grants.ts'
94
96
  import type { BundleMedia, BundleMediaDeclaration } from './bundle-media.ts'
97
+ import { type ActivityRecorder, personOf } from './extension-activity.ts'
98
+ import { normaliseScreenResult } from './extension-screens.ts'
95
99
  import type { BundleForms } from './form-types.ts'
96
100
  import type { BundleIdentityProviders } from './identity-provider-overrides.ts'
97
101
  import { type JobInfo, type JobSchedule, jobProblems, type OwnerJobs } from './owner-jobs.ts'
@@ -344,6 +348,37 @@ export interface ServerBundle<
344
348
  jobs?: Record<string, BundleJob<C, T>>
345
349
  /** When its jobs run by themselves: cron expressions in a timezone. */
346
350
  schedules?: readonly JobSchedule[]
351
+ /**
352
+ * Screens the back office draws from what they return (story 323), by id:
353
+ * each a `view` and the `actions` its buttons name. docs/extensions.md, "Screens".
354
+ */
355
+ screens?: Readonly<Record<string, BundleScreen<C, T>>>
356
+ }
357
+
358
+ /** What a screen's view or action is given: a back-office route's context, and the screen's state. */
359
+ export interface BundleScreenContext<
360
+ C extends BundleCapability = BundleCapability,
361
+ T extends BundleTables = BundleTables,
362
+ > extends BundleRouteContext<C, T> {
363
+ principal: Principal
364
+ /** What the last answer asked the back office to keep, sent back as it was. */
365
+ state: Record<string, unknown>
366
+ /** What the button sent, and a form's values under `values` when it submits. */
367
+ input: Record<string, unknown>
368
+ signal?: AbortSignal
369
+ }
370
+
371
+ export type BundleScreenHandler<
372
+ C extends BundleCapability = BundleCapability,
373
+ T extends BundleTables = BundleTables,
374
+ > = (context: BundleScreenContext<C, T>) => ScreenAnswer | Promise<ScreenAnswer>
375
+
376
+ export interface BundleScreen<
377
+ C extends BundleCapability = BundleCapability,
378
+ T extends BundleTables = BundleTables,
379
+ > {
380
+ view: BundleScreenHandler<C, T>
381
+ actions?: Readonly<Record<string, BundleScreenHandler<C, T>>>
347
382
  }
348
383
 
349
384
  /** A bundle's background job (story 187). */
@@ -423,6 +458,8 @@ export function validateServerBundles(
423
458
  problems.push(
424
459
  `Bundle "${label}" declares tables under the id "${SITE_OWNER}", which names the site's own tables.`,
425
460
  )
461
+ for (const problem of screenProblems(bundle.screens))
462
+ problems.push(`Bundle "${label}" screens: ${problem}.`)
426
463
  if (bundle.tables) {
427
464
  if (bundle.tables.id !== bundle.id)
428
465
  problems.push(
@@ -735,6 +772,8 @@ export type CallerCapabilities = {
735
772
 
736
773
  export interface ServerBundlesOptions {
737
774
  bundles: readonly ServerBundle[]
775
+ /** Where each capability call is recorded for the activity view (story 327). */
776
+ activity?: ActivityRecorder
738
777
  /** The bundle packages the site depends on, from discovery. */
739
778
  packages: readonly BundlePackage[]
740
779
  /** The running release, which every bundle's peer range must admit. */
@@ -863,9 +902,10 @@ export function createServerBundles(options: ServerBundlesOptions): ServerBundle
863
902
  ): Pick<BundleHost, BundleCapability> => {
864
903
  const host: Record<string, unknown> = {}
865
904
  // What it was granted, not what it declares (story 309).
866
- const declared = options.granted
867
- ? options.granted(bundle.id)
868
- : declaredPermissions(owners.get(bundle.id))
905
+ const declared = delegatedPermissions(
906
+ options.granted ? options.granted(bundle.id) : declaredPermissions(owners.get(bundle.id)),
907
+ caller.kind === 'backoffice' ? caller.principal : undefined,
908
+ )
869
909
  for (const capability of bundle.capabilities) {
870
910
  // Acting for a member needs `member.delegate`, on every call (story 309).
871
911
  if (
@@ -883,7 +923,15 @@ export function createServerBundles(options: ServerBundlesOptions): ServerBundle
883
923
  ? (logs.get(bundle.id) as BundleLog)
884
924
  : (options.host as Partial<BundleHost>)[capability]
885
925
  // Only what its declared permissions allow (story 222).
886
- host[capability] = given ? gated(bundle.id, capability, given, declared) : given
926
+ host[capability] = given
927
+ ? gated(
928
+ bundle.id,
929
+ capability,
930
+ given,
931
+ declared,
932
+ options.activity ? { recorder: options.activity, person: personOf(caller) } : undefined,
933
+ )
934
+ : given
887
935
  }
888
936
  const database = databaseOf(bundle)
889
937
  if (database) host.database = database
@@ -907,6 +955,64 @@ export function createServerBundles(options: ServerBundlesOptions): ServerBundle
907
955
  ),
908
956
  )
909
957
 
958
+ /**
959
+ * A screen's view, or one of its actions (story 323): `POST _screen/<id>` with
960
+ * `{ action?, input?, state? }`, answered with the screen held to the
961
+ * catalogue. A handler that throws, a refused capability included, answers
962
+ * `{ problem }`, so the back office keeps the last screen and says why.
963
+ */
964
+ const screenCall = async (
965
+ bundle: ServerBundle,
966
+ id: string,
967
+ request: Request,
968
+ principal: Principal,
969
+ ): Promise<Response> => {
970
+ if (request.method !== 'POST')
971
+ return new Response('Method Not Allowed', { status: 405, headers: { allow: 'POST' } })
972
+ const screen = Object.hasOwn(bundle.screens ?? {}, id) ? bundle.screens?.[id] : undefined
973
+ if (!screen) return new Response('Not Found', { status: 404 })
974
+ if (options.isOn && !options.isOn(bundle.id)) return disabledResponse(bundle.id)
975
+ let body: Record<string, unknown>
976
+ try {
977
+ const parsed = await request.json()
978
+ body = parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {}
979
+ } catch {
980
+ body = {}
981
+ }
982
+ const action = typeof body.action === 'string' ? body.action : undefined
983
+ const handler = action
984
+ ? Object.hasOwn(screen.actions ?? {}, action)
985
+ ? screen.actions?.[action]
986
+ : undefined
987
+ : screen.view
988
+ if (!handler) return new Response('Not Found', { status: 404 })
989
+ const caller: BundleCaller = Object.freeze({ kind: 'backoffice', principal })
990
+ const log = logs.get(bundle.id)
991
+ try {
992
+ const answer = await handler({
993
+ bundle: contextFor(bundle, caller) as BundleScreenContext['bundle'],
994
+ caller,
995
+ principal,
996
+ state: plainObject(body.state),
997
+ input: plainObject(body.input),
998
+ signal: request.signal,
999
+ })
1000
+ const { result, dropped } = normaliseScreenResult(answer)
1001
+ if (dropped.length > 0)
1002
+ log?.warn('Its screen {screen} answered what the back office does not draw: {dropped}', {
1003
+ screen: id,
1004
+ dropped: dropped.join(', '),
1005
+ })
1006
+ return Response.json(result)
1007
+ } catch (error) {
1008
+ // A refusal may cross the channel as an outcome rather than an Error: its message is what to say.
1009
+ const said = (error as { message?: unknown } | null)?.message
1010
+ const message = typeof said === 'string' && said.length > 0 ? said : 'It could not answer.'
1011
+ log?.error('Its screen {screen} failed: {error}', { screen: id, error: message })
1012
+ return Response.json({ problem: message })
1013
+ }
1014
+ }
1015
+
910
1016
  /** A site route that answers as waiting while its bundle is off. */
911
1017
  const whileOn = (bundleId: string, route: SiteRoute): SiteRoute => {
912
1018
  const isOn = options.isOn
@@ -958,6 +1064,9 @@ export function createServerBundles(options: ServerBundlesOptions): ServerBundle
958
1064
  // the declared section, and a bundle has no way to opt a route out.
959
1065
  if (!hasSection(principal, bundle.section)) return new Response('Forbidden', { status: 403 })
960
1066
 
1067
+ if (requested.startsWith(SCREEN_SEGMENT))
1068
+ return screenCall(bundle, requested.slice(SCREEN_SEGMENT.length), request, principal)
1069
+
961
1070
  for (const route of (bundle.routes ?? []).filter((candidate) => !onSite(candidate))) {
962
1071
  const params = matchRoute(route.path, requested)
963
1072
  if (!params) continue
@@ -981,6 +1090,36 @@ export function createServerBundles(options: ServerBundlesOptions): ServerBundle
981
1090
 
982
1091
  const PUBLIC_CALLER: BundleCaller = Object.freeze({ kind: 'public' })
983
1092
 
1093
+ const SCREEN_ID = /^[a-z][a-z0-9-]{0,39}$/
1094
+
1095
+ /** Why a bundle's `screens` cannot be mounted: a bad id, or a view or action that is not a function. */
1096
+ export function screenProblems(screens: ServerBundle['screens']): string[] {
1097
+ if (screens === undefined) return []
1098
+ if (!screens || typeof screens !== 'object') return ['"screens" is an object of screens by id']
1099
+ const problems: string[] = []
1100
+ for (const [id, screen] of Object.entries(screens)) {
1101
+ if (!SCREEN_ID.test(id))
1102
+ problems.push(`"${id}" is not a screen id: lower case letters, digits and dashes`)
1103
+ if (typeof screen?.view !== 'function') problems.push(`"${id}" has no view function`)
1104
+ for (const [name, action] of Object.entries(screen?.actions ?? {}))
1105
+ if (typeof action !== 'function')
1106
+ problems.push(`"${id}"'s action "${name}" is not a function`)
1107
+ }
1108
+ return problems
1109
+ }
1110
+
1111
+ /** Below a bundle's back-office namespace, where its screens answer (story 323). */
1112
+ const SCREEN_SEGMENT = '_screen/'
1113
+
1114
+ const plainObject = (value: unknown): Record<string, unknown> => {
1115
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return {}
1116
+ try {
1117
+ return JSON.parse(JSON.stringify(value)) as Record<string, unknown>
1118
+ } catch {
1119
+ return {}
1120
+ }
1121
+ }
1122
+
984
1123
  /** `BundleMedia`'s methods, refused one by one without `member.delegate`. */
985
1124
  const MEDIA_METHODS: readonly (keyof BundleMedia)[] = [
986
1125
  'create',
@@ -58,8 +58,8 @@ export async function handleComponentTemplates(
58
58
  return Response.json({ items: componentTemplates(onDisk, await repo.all(), extensions) })
59
59
 
60
60
  if (request.method === 'POST') {
61
- // As changing which templates a type allows: Structure, which Settings brings.
62
- if (!hasSection(principal, 'structure') && !hasSection(principal, 'settings'))
61
+ // As changing which templates a type allows: Settings.
62
+ if (!hasSection(principal, 'settings'))
63
63
  return Response.json(
64
64
  { message: 'Making a component a template needs access to Structure.' },
65
65
  { status: 403 },
package/src/config.ts CHANGED
@@ -23,6 +23,7 @@ import {
23
23
  import type { ServerBundle } from './bundles.ts'
24
24
  import type { EmailPort } from './email.ts'
25
25
  import type { GitConfig } from './git-routes.ts'
26
+ import { type UnrestrictedFrom, unrestrictedFrom } from './grant-policy.ts'
26
27
  import { checkHost, type HostConfig } from './host-token.ts'
27
28
  import { checkIdentityProviders, type IdentityProvider } from './identity-providers.ts'
28
29
  import type { MediaStore } from './media-store.ts'
@@ -343,6 +344,11 @@ export interface CromboloConfig {
343
344
  }
344
345
  /** How many days the audit log keeps an entry; 0 keeps them forever. docs/audit-log.md. */
345
346
  auditRetentionDays: number
347
+ /**
348
+ * How many days what each extension did is kept for its Activity view (story
349
+ * 327); 0 keeps none. `CROMBOLO_EXTENSION_ACTIVITY_DAYS`.
350
+ */
351
+ extensionActivityDays: number
346
352
  /**
347
353
  * How many days delivered webhooks, their log and dispatched content events
348
354
  * are kept; 0 keeps them forever. Failed work stays until retried. docs/webhooks.md.
@@ -593,6 +599,13 @@ export interface CromboloConfig {
593
599
  * `CROMBOLO_BUNDLE_SIGNATURES` and `CROMBOLO_BUNDLE_SOURCES`.
594
600
  */
595
601
  bundlePolicy: ProvenancePolicy
602
+ /**
603
+ * Where an Unrestricted extension may be granted from (story 324): the back
604
+ * office, by an administrator, or only the site's config, so a commit someone
605
+ * reviews is the only way. `CROMBOLO_UNRESTRICTED_EXTENSIONS`, `backoffice`
606
+ * unless it says `config`.
607
+ */
608
+ unrestrictedExtensions: UnrestrictedFrom
596
609
  /**
597
610
  * Where the Packages section's Marketplace sends someone browsing for
598
611
  * extensions. Never framed — npm refuses to be framed — so the native view
@@ -623,8 +636,6 @@ export interface ExtensionEntry {
623
636
  grant?: readonly string[]
624
637
  /** The origins its `http.outbound` may reach, when it asks for any. */
625
638
  origins?: readonly string[]
626
- /** Whom `actAs` acts for: `caller`, or `user:<key>`. */
627
- actAs?: string
628
639
  /** Its settings' values, locked in the back office. */
629
640
  settings?: Readonly<Record<string, unknown>>
630
641
  /**
@@ -679,6 +690,7 @@ export const DEFAULTS = {
679
690
  keepAllVersionsNewerThanDays: 7,
680
691
  keepLatestVersionPerDayForDays: 90,
681
692
  auditRetentionDays: 365,
693
+ extensionActivityDays: 14,
682
694
  eventRetentionDays: 30,
683
695
  memberRegistrationType: 'Member',
684
696
  memberSessionMinutes: 60 * 24 * 14,
@@ -893,6 +905,10 @@ export function loadConfig(
893
905
  setting('CROMBOLO_AUDIT_RETENTION_DAYS'),
894
906
  DEFAULTS.auditRetentionDays,
895
907
  ),
908
+ extensionActivityDays: nonNegative(
909
+ setting('CROMBOLO_EXTENSION_ACTIVITY_DAYS'),
910
+ DEFAULTS.extensionActivityDays,
911
+ ),
896
912
  eventRetentionDays: nonNegative(
897
913
  setting('CROMBOLO_EVENT_RETENTION_DAYS'),
898
914
  DEFAULTS.eventRetentionDays,
@@ -951,6 +967,7 @@ export function loadConfig(
951
967
  applyBundleContentOnInstall: setting('CROMBOLO_APPLY_BUNDLE_CONTENT') !== 'false',
952
968
  // Resolved again below, once it is known whether a store was configured.
953
969
  runtimeInstalls: setting('CROMBOLO_RUNTIME_INSTALLS') !== 'false',
970
+ unrestrictedExtensions: unrestrictedFrom(setting('CROMBOLO_UNRESTRICTED_EXTENSIONS')),
954
971
  bundlePolicy: {
955
972
  signatures: bundleSignatures(setting('CROMBOLO_BUNDLE_SIGNATURES')),
956
973
  sources: (setting('CROMBOLO_BUNDLE_SOURCES') ?? '')
@@ -1144,7 +1161,7 @@ export function describeDatabase(
1144
1161
  }
1145
1162
  }
1146
1163
 
1147
- export const VERSION = '0.60.0'
1164
+ export const VERSION = '0.61.0'
1148
1165
 
1149
1166
  /** A whole number of seconds from the environment; undefined when unset or not one. */
1150
1167
  /** A positive number from a setting, else the default. */