@capybara-hq/kernel 0.1.0-rc.145 → 0.1.0-rc.147
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/dist/admin/extensions.controller.d.ts +0 -11
- package/dist/admin/extensions.controller.js +0 -28
- package/dist/admin/health.service.d.ts +25 -1
- package/dist/admin/health.service.js +50 -18
- package/dist/audit/full-access.d.ts +78 -0
- package/dist/audit/full-access.js +283 -0
- package/dist/automations/automations.service.d.ts +1 -0
- package/dist/automations/automations.service.js +3 -1
- package/dist/automations/calendar.js +3 -1
- package/dist/automations/grant-rules.d.ts +2 -1
- package/dist/automations/grant-rules.js +8 -1
- package/dist/automations/unattended.d.ts +13 -1
- package/dist/automations/unattended.js +13 -1
- package/dist/catalog/admin-catalog.controller.d.ts +8 -0
- package/dist/catalog/admin-catalog.controller.js +8 -2
- package/dist/catalog/admin-catalog.schemas.d.ts +10 -0
- package/dist/catalog/admin-catalog.schemas.js +8 -1
- package/dist/catalog/catalog-content.d.ts +6 -0
- package/dist/catalog/catalog-scope.service.d.ts +22 -2
- package/dist/catalog/catalog-scope.service.js +27 -3
- package/dist/catalog/catalog.service.js +19 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.service.d.ts +8 -1
- package/dist/catalog/org-catalog.service.js +36 -3
- package/dist/catalog/platform-components.js +3 -2
- package/dist/catalog/platform-import-update.d.ts +2 -0
- package/dist/catalog/platform-import-update.js +8 -1
- package/dist/catalog/plugin-connectors.d.ts +11 -0
- package/dist/catalog/plugin-connectors.js +33 -0
- package/dist/catalog/plugin-import.d.ts +35 -15
- package/dist/catalog/plugin-import.js +110 -35
- package/dist/catalog/plugin-install.js +6 -0
- package/dist/catalog/provenance.d.ts +71 -0
- package/dist/catalog/provenance.js +112 -0
- package/dist/config/auto-approve.d.ts +16 -0
- package/dist/config/auto-approve.js +24 -0
- package/dist/config/capacity-presets.d.ts +243 -0
- package/dist/config/capacity-presets.js +195 -0
- package/dist/config/env.d.ts +2 -1
- package/dist/config/env.js +6 -1
- package/dist/config/load.js +15 -0
- package/dist/config/schema.d.ts +46 -9
- package/dist/config/schema.js +154 -30
- package/dist/ctx/create-ctx.d.ts +16 -0
- package/dist/ctx/create-ctx.js +269 -34
- package/dist/ctx/net.d.ts +5 -1
- package/dist/ctx/net.js +62 -12
- package/dist/db/kernel-schema.d.ts +31 -0
- package/dist/db/migrator.js +0 -36
- package/dist/dial-in/routes.js +1 -1
- package/dist/erasure/org-batches.js +1 -6
- package/dist/erasure/org-catalog.js +6 -2
- package/dist/erasure/org-rules.js +1 -0
- package/dist/erasure/org-worker.js +0 -13
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/extensions/admin-ops.d.ts +14 -1
- package/dist/extensions/admin-ops.js +30 -3
- package/dist/extensions/admin-view.d.ts +21 -1
- package/dist/extensions/admin-view.js +43 -0
- package/dist/extensions/bootstrap-packages.d.ts +5 -0
- package/dist/extensions/bootstrap-packages.js +1 -1
- package/dist/extensions/bootstrap-review.d.ts +251 -0
- package/dist/extensions/bootstrap-review.js +676 -0
- package/dist/extensions/bootstrap.d.ts +21 -1
- package/dist/extensions/bootstrap.js +72 -2
- package/dist/extensions/cli.d.ts +6 -0
- package/dist/extensions/cli.js +4 -0
- package/dist/extensions/enabled.d.ts +3 -0
- package/dist/extensions/execution-realm.d.ts +96 -0
- package/dist/extensions/execution-realm.js +141 -0
- package/dist/extensions/extensions.module.js +12 -0
- package/dist/extensions/full-access-disclosure.d.ts +15 -0
- package/dist/extensions/full-access-disclosure.js +57 -0
- package/dist/extensions/grant-epoch.d.ts +9 -2
- package/dist/extensions/grant-epoch.js +13 -2
- package/dist/extensions/host.d.ts +96 -4
- package/dist/extensions/host.js +411 -33
- package/dist/extensions/installs.d.ts +18 -0
- package/dist/extensions/installs.js +28 -0
- package/dist/extensions/instance.d.ts +2 -0
- package/dist/extensions/instance.js +1 -0
- package/dist/extensions/isolated/admission.d.ts +23 -2
- package/dist/extensions/isolated/admission.js +32 -7
- package/dist/extensions/isolated/authorization.d.ts +8 -2
- package/dist/extensions/isolated/authorization.js +11 -3
- package/dist/extensions/isolated/broker.d.ts +3 -0
- package/dist/extensions/isolated/broker.js +50 -14
- package/dist/extensions/isolated/configured-package.d.ts +5 -0
- package/dist/extensions/isolated/configured-package.js +2 -0
- package/dist/extensions/isolated/lanes.d.ts +44 -3
- package/dist/extensions/isolated/lanes.js +263 -80
- package/dist/extensions/isolated/metrics.d.ts +146 -0
- package/dist/extensions/isolated/metrics.js +304 -0
- package/dist/extensions/isolated/revision.d.ts +7 -1
- package/dist/extensions/isolated/revision.js +26 -5
- package/dist/extensions/isolated/rpc.d.ts +5 -0
- package/dist/extensions/isolated/rpc.js +7 -2
- package/dist/extensions/isolated/sandbox.d.ts +23 -0
- package/dist/extensions/isolated/sandbox.js +50 -0
- package/dist/extensions/isolated/status.d.ts +79 -0
- package/dist/extensions/isolated/status.js +216 -0
- package/dist/extensions/isolated/tier.d.ts +127 -2
- package/dist/extensions/isolated/tier.js +266 -7
- package/dist/extensions/isolated/usage.d.ts +134 -0
- package/dist/extensions/isolated/usage.js +322 -0
- package/dist/extensions/ledger.d.ts +5 -0
- package/dist/extensions/ledger.js +16 -0
- package/dist/extensions/lifecycle.d.ts +42 -2
- package/dist/extensions/lifecycle.js +100 -4
- package/dist/extensions/org-config.js +11 -0
- package/dist/extensions/package.d.ts +14 -0
- package/dist/extensions/package.js +23 -0
- package/dist/extensions/permission-view.d.ts +2 -2
- package/dist/extensions/permissions.controller.d.ts +35 -0
- package/dist/extensions/permissions.controller.js +98 -0
- package/dist/extensions/permissions.schemas.d.ts +288 -0
- package/dist/extensions/permissions.schemas.js +96 -0
- package/dist/extensions/permissions.service.d.ts +116 -0
- package/dist/extensions/permissions.service.js +428 -0
- package/dist/extensions/realm-retirement.d.ts +65 -0
- package/dist/extensions/realm-retirement.js +150 -0
- package/dist/extensions/registry.d.ts +6 -0
- package/dist/extensions/registry.js +8 -0
- package/dist/extensions/review-hash.d.ts +114 -0
- package/dist/extensions/review-hash.js +145 -0
- package/dist/extensions/revision-approvals.d.ts +58 -3
- package/dist/extensions/revision-approvals.js +135 -14
- package/dist/extensions/revision-grants.d.ts +10 -0
- package/dist/extensions/revision-review.d.ts +144 -0
- package/dist/extensions/revision-review.js +297 -0
- package/dist/extensions/revocation-leases.d.ts +273 -0
- package/dist/extensions/revocation-leases.js +533 -0
- package/dist/extensions/revocation.d.ts +78 -0
- package/dist/extensions/revocation.js +205 -0
- package/dist/extensions/state.module.js +12 -0
- package/dist/git/run-end.d.ts +35 -7
- package/dist/git/run-end.js +87 -38
- package/dist/http/api.module.js +2 -0
- package/dist/identity/audit.d.ts +2 -1
- package/dist/identity/audit.js +4 -17
- package/dist/index.d.ts +10 -2
- package/dist/index.js +10 -2
- package/dist/infra/config/kernel-config.service.d.ts +6 -0
- package/dist/infra/config/kernel-config.service.js +21 -0
- package/dist/infra/outbox/registry.d.ts +13 -0
- package/dist/infra/outbox/registry.js +8 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +27 -1
- package/dist/lifecycle/kernel-lifecycle.js +83 -22
- package/dist/net/private-endpoint-preflight.d.ts +159 -0
- package/dist/net/private-endpoint-preflight.js +417 -0
- package/dist/net/private-endpoints.d.ts +68 -0
- package/dist/net/private-endpoints.js +164 -0
- package/dist/net/public-address.d.ts +14 -0
- package/dist/net/public-address.js +15 -1
- package/dist/net/safe-fetch.d.ts +2 -1
- package/dist/net/safe-fetch.js +10 -3
- package/dist/overrides.d.ts +9 -1
- package/dist/overrides.js +4 -0
- package/dist/packages/official-publisher.d.ts +65 -1
- package/dist/packages/official-publisher.js +171 -46
- package/dist/packages/provenance.d.ts +11 -0
- package/dist/packages/provenance.js +24 -0
- package/dist/platform/exclusions.js +4 -4
- package/dist/platform/ops/automations.ops.js +1 -1
- package/dist/platform/ops/catalog-admin.ops.js +25 -4
- package/dist/platform/ops/extension-permissions.ops.d.ts +11 -0
- package/dist/platform/ops/extension-permissions.ops.js +159 -0
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +2 -0
- package/dist/platform/route-schemas.js +2 -0
- package/dist/retention/purge-batch.js +10 -14
- package/dist/runtime/maintenance.d.ts +4 -2
- package/dist/runtime/maintenance.js +16 -3
- package/dist/runtime/run-finish.d.ts +3 -3
- package/dist/runtime/run-finish.js +7 -3
- package/dist/sandbox/permission-availability.d.ts +17 -2
- package/dist/sandbox/permission-availability.js +22 -1
- package/dist/sandbox/permission-facts.js +7 -1
- package/dist/tools/builtins/sandbox/common.js +2 -0
- package/dist/tools/pipeline.d.ts +2 -1
- package/dist/tools/pipeline.js +7 -2
- package/package.json +4 -3
- package/src/migrations/0238_extension_usage.sql +40 -0
- package/src/migrations/0239_extension_replica_isolation.sql +28 -0
|
@@ -6,6 +6,7 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
|
6
6
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
7
7
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
8
8
|
import type { KernelLogger } from "../log.js";
|
|
9
|
+
import { type BrokeredEndpointPin } from "../net/private-endpoint-preflight.js";
|
|
9
10
|
import { ExtensionAdminOps } from "./admin-ops.js";
|
|
10
11
|
import { type ExtraManifestTraces, type MergedBootstrapManifest } from "./bootstrap-extra.js";
|
|
11
12
|
import { ExtensionInstalls } from "./installs.js";
|
|
@@ -144,6 +145,8 @@ export declare class BootstrapFailedError extends Error {
|
|
|
144
145
|
}
|
|
145
146
|
/** The lock around a whole run (`lock:bootstrap`). */
|
|
146
147
|
export declare const BOOTSTRAP_LOCK_KEY = "bootstrap";
|
|
148
|
+
/** How long the start's platform URL check may take (DNS lookups) before it is skipped. */
|
|
149
|
+
export declare const PLATFORM_URL_CHECK_MS = 10000;
|
|
147
150
|
/** Its lifetime without renewal; a run keeps it by renewal, a crashed holder's expires. */
|
|
148
151
|
export declare const BOOTSTRAP_LOCK_TTL_MS = 120000;
|
|
149
152
|
/** Optional provider: the lock's lifetime (ms) instead of {@link BOOTSTRAP_LOCK_TTL_MS} (tests shorten it). */
|
|
@@ -173,6 +176,8 @@ export declare class BootstrapService {
|
|
|
173
176
|
private readonly log;
|
|
174
177
|
/** The lock's lifetime without renewal. */
|
|
175
178
|
private readonly lockTtlMs;
|
|
179
|
+
/** Tests only: the brokered pins the private endpoint preflight checks. */
|
|
180
|
+
private readonly brokeredPins;
|
|
176
181
|
constructor(kdb: KernelDb, txHost: TransactionHost, locks: LockService, approveLock: PluginApproveLock, installs: ExtensionInstalls, ops: ExtensionAdminOps, outbox: Pick<OutboxService, "add" | "addMany">,
|
|
177
182
|
/**
|
|
178
183
|
* Config-declared extension names (an entry of the same name is kept, config wins, and no
|
|
@@ -181,7 +186,9 @@ export declare class BootstrapService {
|
|
|
181
186
|
*/
|
|
182
187
|
registry: ExtensionRegistry, configService: KernelConfigService, log: KernelLogger,
|
|
183
188
|
/** The lock's lifetime without renewal. */
|
|
184
|
-
lockTtlMs?: number
|
|
189
|
+
lockTtlMs?: number,
|
|
190
|
+
/** Tests only: the brokered pins the private endpoint preflight checks. */
|
|
191
|
+
brokeredPins?: readonly BrokeredEndpointPin[]);
|
|
185
192
|
private get db();
|
|
186
193
|
private config;
|
|
187
194
|
/**
|
|
@@ -232,6 +239,19 @@ export declare class BootstrapService {
|
|
|
232
239
|
/** The platform update a raised pin goes through (after the extension step, if any). */
|
|
233
240
|
updater: BootstrapUpdater;
|
|
234
241
|
}): Promise<BootstrapResult>;
|
|
242
|
+
/**
|
|
243
|
+
* The generic platform URL check (`platformUrlGaps`): one warning per URL field of an enabled
|
|
244
|
+
* extension that `ctx.net` would refuse without an org, with the alias to add. Bounded by
|
|
245
|
+
* {@link PLATFORM_URL_CHECK_MS} (DNS may hang); a failure or timeout only warns.
|
|
246
|
+
*/
|
|
247
|
+
private warnPlatformUrls;
|
|
248
|
+
/**
|
|
249
|
+
* The private endpoint preflight (`net/private-endpoint-preflight.ts`): a pin moving to its
|
|
250
|
+
* `ctx.net` build while its private platform endpoint has no `net.privateEndpoints` alias throws
|
|
251
|
+
* {@link PrivateEndpointMissingError} before anything is written; a pin that is not yet that
|
|
252
|
+
* build only warns, naming the alias to add.
|
|
253
|
+
*/
|
|
254
|
+
private preflightPrivateEndpoints;
|
|
235
255
|
/**
|
|
236
256
|
* A pin whose plugin name an org holds (a live org-owned catalog item): the bootstrap takes no
|
|
237
257
|
* name over (ruling P3-28), so the entry fails; this warning tells the super admin why and
|
|
@@ -28,6 +28,7 @@ import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
|
28
28
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
29
29
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
30
30
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
31
|
+
import { BROKERED_ENDPOINT_PINS, BROKERED_ENDPOINT_PINS_SEAM, enabledExtensionsForScan, PrivateEndpointMissingError, platformUrlGaps, privateEndpointGaps, storedDeploymentConfig, } from "../net/private-endpoint-preflight.js";
|
|
31
32
|
import { PackageTgzError, unpackPackageTgz } from "../packages/tgz.js";
|
|
32
33
|
import { ExtensionAdminOps } from "./admin-ops.js";
|
|
33
34
|
import { writeSnapshot } from "./approvals.js";
|
|
@@ -74,6 +75,8 @@ export class BootstrapFailedError extends Error {
|
|
|
74
75
|
const managedMarketplaceId = (name) => `${CONFIG_MARKETPLACE_PREFIX}${name}`;
|
|
75
76
|
/** The lock around a whole run (`lock:bootstrap`). */
|
|
76
77
|
export const BOOTSTRAP_LOCK_KEY = "bootstrap";
|
|
78
|
+
/** How long the start's platform URL check may take (DNS lookups) before it is skipped. */
|
|
79
|
+
export const PLATFORM_URL_CHECK_MS = 10_000;
|
|
77
80
|
/** Its lifetime without renewal; a run keeps it by renewal, a crashed holder's expires. */
|
|
78
81
|
export const BOOTSTRAP_LOCK_TTL_MS = 120_000;
|
|
79
82
|
/** Optional provider: the lock's lifetime (ms) instead of {@link BOOTSTRAP_LOCK_TTL_MS} (tests shorten it). */
|
|
@@ -92,6 +95,7 @@ let BootstrapService = class BootstrapService {
|
|
|
92
95
|
configService;
|
|
93
96
|
log;
|
|
94
97
|
lockTtlMs;
|
|
98
|
+
brokeredPins;
|
|
95
99
|
constructor(kdb, txHost, locks, approveLock, installs, ops, outbox,
|
|
96
100
|
/**
|
|
97
101
|
* Config-declared extension names (an entry of the same name is kept, config wins, and no
|
|
@@ -100,7 +104,9 @@ let BootstrapService = class BootstrapService {
|
|
|
100
104
|
*/
|
|
101
105
|
registry, configService, log,
|
|
102
106
|
/** The lock's lifetime without renewal. */
|
|
103
|
-
lockTtlMs = BOOTSTRAP_LOCK_TTL_MS
|
|
107
|
+
lockTtlMs = BOOTSTRAP_LOCK_TTL_MS,
|
|
108
|
+
/** Tests only: the brokered pins the private endpoint preflight checks. */
|
|
109
|
+
brokeredPins = BROKERED_ENDPOINT_PINS) {
|
|
104
110
|
this.kdb = kdb;
|
|
105
111
|
this.txHost = txHost;
|
|
106
112
|
this.locks = locks;
|
|
@@ -112,6 +118,7 @@ let BootstrapService = class BootstrapService {
|
|
|
112
118
|
this.configService = configService;
|
|
113
119
|
this.log = log;
|
|
114
120
|
this.lockTtlMs = lockTtlMs;
|
|
121
|
+
this.brokeredPins = brokeredPins;
|
|
115
122
|
}
|
|
116
123
|
get db() {
|
|
117
124
|
return this.kdb.db;
|
|
@@ -186,6 +193,9 @@ let BootstrapService = class BootstrapService {
|
|
|
186
193
|
*/
|
|
187
194
|
async run(o) {
|
|
188
195
|
const manifestSha256 = bootstrapManifestSha256(o.manifest);
|
|
196
|
+
// Every run (init and each kernel start), done or not: warn about platform URLs ctx.net
|
|
197
|
+
// would refuse without an org (never refuses)
|
|
198
|
+
await this.warnPlatformUrls();
|
|
189
199
|
// Done: no lock, no directory, no network
|
|
190
200
|
const before = await this.recorded(o.manifest);
|
|
191
201
|
if (before)
|
|
@@ -200,6 +210,8 @@ let BootstrapService = class BootstrapService {
|
|
|
200
210
|
if (hasExtraManifestTraces(traces))
|
|
201
211
|
throw new BootstrapExtraMismatchError(traces);
|
|
202
212
|
}
|
|
213
|
+
// Before anything is obtained or written: a brokered pin's private endpoint needs its alias
|
|
214
|
+
await this.preflightPrivateEndpoints(o.manifest);
|
|
203
215
|
const fromExtra = new Set(o.manifest.extra?.plugins);
|
|
204
216
|
const deferBuiltin = o.deferBuiltin === true;
|
|
205
217
|
const isDeferred = (e) => deferBuiltin && e.builtin === true;
|
|
@@ -282,6 +294,62 @@ let BootstrapService = class BootstrapService {
|
|
|
282
294
|
return { manifestSha256, results };
|
|
283
295
|
});
|
|
284
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* The generic platform URL check (`platformUrlGaps`): one warning per URL field of an enabled
|
|
299
|
+
* extension that `ctx.net` would refuse without an org, with the alias to add. Bounded by
|
|
300
|
+
* {@link PLATFORM_URL_CHECK_MS} (DNS may hang); a failure or timeout only warns.
|
|
301
|
+
*/
|
|
302
|
+
async warnPlatformUrls() {
|
|
303
|
+
let timer;
|
|
304
|
+
try {
|
|
305
|
+
const gaps = await Promise.race([
|
|
306
|
+
(async () => platformUrlGaps({
|
|
307
|
+
config: this.config(),
|
|
308
|
+
extensions: await enabledExtensionsForScan(this.db),
|
|
309
|
+
}))(),
|
|
310
|
+
new Promise((_, reject) => {
|
|
311
|
+
timer = setTimeout(() => reject(new Error(`no answer within ${PLATFORM_URL_CHECK_MS} ms`)), PLATFORM_URL_CHECK_MS);
|
|
312
|
+
timer.unref?.();
|
|
313
|
+
}),
|
|
314
|
+
]);
|
|
315
|
+
for (const g of gaps) {
|
|
316
|
+
this.log.warn("a plugin's platform URL would be refused by ctx.net without a net.privateEndpoints alias", { plugin: g.plugin, field: g.field, origin: g.origin, kind: g.kind, hint: g.message });
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
catch (err) {
|
|
320
|
+
this.log.warn("platform URL check skipped", { err });
|
|
321
|
+
}
|
|
322
|
+
finally {
|
|
323
|
+
clearTimeout(timer);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* The private endpoint preflight (`net/private-endpoint-preflight.ts`): a pin moving to its
|
|
328
|
+
* `ctx.net` build while its private platform endpoint has no `net.privateEndpoints` alias throws
|
|
329
|
+
* {@link PrivateEndpointMissingError} before anything is written; a pin that is not yet that
|
|
330
|
+
* build only warns, naming the alias to add.
|
|
331
|
+
*/
|
|
332
|
+
async preflightPrivateEndpoints(manifest) {
|
|
333
|
+
const gaps = await privateEndpointGaps({
|
|
334
|
+
config: this.config(),
|
|
335
|
+
pins: manifest.plugins.map((e) => ({ name: e.name, version: e.version })),
|
|
336
|
+
storedConfig: (plugin) => storedDeploymentConfig(this.db, plugin),
|
|
337
|
+
brokered: this.brokeredPins,
|
|
338
|
+
});
|
|
339
|
+
for (const g of gaps) {
|
|
340
|
+
if (g.blocking)
|
|
341
|
+
continue;
|
|
342
|
+
this.log.warn("bootstrap: a plugin's private platform endpoint has no net.privateEndpoints alias", {
|
|
343
|
+
plugin: g.plugin,
|
|
344
|
+
origin: g.origin,
|
|
345
|
+
alias: g.alias,
|
|
346
|
+
hint: g.message,
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
const blocking = gaps.filter((g) => g.blocking);
|
|
350
|
+
if (blocking.length > 0)
|
|
351
|
+
throw new PrivateEndpointMissingError(blocking);
|
|
352
|
+
}
|
|
285
353
|
/**
|
|
286
354
|
* A pin whose plugin name an org holds (a live org-owned catalog item): the bootstrap takes no
|
|
287
355
|
* name over (ruling P3-28), so the entry fails; this warning tells the super admin why and
|
|
@@ -886,7 +954,9 @@ BootstrapService = __decorate([
|
|
|
886
954
|
__param(8, Inject(KernelConfigService)),
|
|
887
955
|
__param(9, Inject(KERNEL_LOGGER)),
|
|
888
956
|
__param(10, Optional()),
|
|
889
|
-
__param(10, Inject(BOOTSTRAP_LOCK_TTL))
|
|
957
|
+
__param(10, Inject(BOOTSTRAP_LOCK_TTL)),
|
|
958
|
+
__param(11, Optional()),
|
|
959
|
+
__param(11, Inject(BROKERED_ENDPOINT_PINS_SEAM))
|
|
890
960
|
], BootstrapService);
|
|
891
961
|
export { BootstrapService };
|
|
892
962
|
/** A `kept` result whose entry an earlier pass of the same start installed / upgraded / imported. */
|
package/dist/extensions/cli.d.ts
CHANGED
|
@@ -6,10 +6,12 @@ import { ExtensionAdminOps } from "./admin-ops.js";
|
|
|
6
6
|
import { ExtensionAdmin } from "./admin-view.js";
|
|
7
7
|
import { ExtensionApprovals } from "./approvals.js";
|
|
8
8
|
import { BootstrapService } from "./bootstrap.js";
|
|
9
|
+
import { BootstrapReviewService } from "./bootstrap-review.js";
|
|
9
10
|
import { type ConfigIssue } from "./config-issues.js";
|
|
10
11
|
import { type InspectedExtension } from "./host.js";
|
|
11
12
|
import { ExtensionInstalls } from "./installs.js";
|
|
12
13
|
import type { PermissionSet } from "./permission-set.js";
|
|
14
|
+
import { ExtensionPermissions } from "./permissions.service.js";
|
|
13
15
|
/** {@link openExtensionCli} 的结果:CLI 的 `capybara extensions *` 共用。 */
|
|
14
16
|
export interface ExtensionCli {
|
|
15
17
|
config: KernelConfig;
|
|
@@ -42,8 +44,12 @@ export interface ExtensionCli {
|
|
|
42
44
|
admin: ExtensionAdmin;
|
|
43
45
|
ops: ExtensionAdminOps;
|
|
44
46
|
approvals: ExtensionApprovals;
|
|
47
|
+
/** The revision review and operator approval of an install (plan task 1.4a). */
|
|
48
|
+
permissions: ExtensionPermissions;
|
|
45
49
|
/** The bootstrap step (`capybara bootstrap`), under the same `lock:bootstrap` as the kernel. */
|
|
46
50
|
bootstrap: BootstrapService;
|
|
51
|
+
/** The bootstrap review and its approval (`capybara bootstrap review | approve`). */
|
|
52
|
+
bootstrapReview: BootstrapReviewService;
|
|
47
53
|
/** CLI 本次刚导入的包字节(降级判断等读包时优先用它:包可能存在 CLI 读不到的对象存储里)。 */
|
|
48
54
|
remember(sha256: string, bytes: Uint8Array): void;
|
|
49
55
|
/** 安装记录包的权限集合(与后台审阅相同);包在对象存储里时 CLI 读不到,抛错。 */
|
package/dist/extensions/cli.js
CHANGED
|
@@ -7,6 +7,7 @@ import { ExtensionAdmin } from "./admin-view.js";
|
|
|
7
7
|
import { ExtensionApprovals } from "./approvals.js";
|
|
8
8
|
import { ExtensionBlobs } from "./blobs.js";
|
|
9
9
|
import { BootstrapService } from "./bootstrap.js";
|
|
10
|
+
import { BootstrapReviewService } from "./bootstrap-review.js";
|
|
10
11
|
import { toIssues } from "./config-issues.js";
|
|
11
12
|
import { mergeDeploymentConfig, readStoredDeploymentConfig, schemaFields, secretPathsOf, } from "./deployment-config-store.js";
|
|
12
13
|
import { ExtensionsModule } from "./extensions.module.js";
|
|
@@ -15,6 +16,7 @@ import { ExtensionInstalls } from "./installs.js";
|
|
|
15
16
|
import { PLUGINS_CHANGED_TOPIC } from "./lifecycle-topics.js";
|
|
16
17
|
import { parseLoadGate } from "./org-levels.js";
|
|
17
18
|
import { ExtensionPackageError, extensionPackageApiError, permissionSetOfPackage, readExtensionPackage, } from "./package.js";
|
|
19
|
+
import { ExtensionPermissions } from "./permissions.service.js";
|
|
18
20
|
/**
|
|
19
21
|
* The effective deployment config (the startup config `fileValue` completed by the `stored` PG
|
|
20
22
|
* fields) parsed as the host's load gate does: overridable fields may stay empty (spec A §5.4a),
|
|
@@ -92,7 +94,9 @@ export async function openExtensionCli(config, log, opts = {}) {
|
|
|
92
94
|
admin: app.get(ExtensionAdmin),
|
|
93
95
|
ops: app.get(ExtensionAdminOps),
|
|
94
96
|
approvals: app.get(ExtensionApprovals),
|
|
97
|
+
permissions: app.get(ExtensionPermissions),
|
|
95
98
|
bootstrap: app.get(BootstrapService),
|
|
99
|
+
bootstrapReview: app.get(BootstrapReviewService),
|
|
96
100
|
remember: (sha256, bytes) => blobs.remember(sha256, bytes),
|
|
97
101
|
readPackage: (sha256) => blobs.get(sha256),
|
|
98
102
|
async packageSet(sha256) {
|
|
@@ -122,9 +122,12 @@ export declare function extensionOrgCountsQuery(db: KernelSchemaDb, names: reado
|
|
|
122
122
|
extension_org_overrides: import("../db/kernel-schema.js").ExtensionOrgOverridesTable;
|
|
123
123
|
extension_packages: import("../db/kernel-schema.js").ExtensionPackagesTable;
|
|
124
124
|
extension_permission_snapshots: import("../db/kernel-schema.js").ExtensionPermissionSnapshotsTable;
|
|
125
|
+
extension_replica_isolation: import("../db/kernel-schema.js").ExtensionReplicaIsolationTable;
|
|
125
126
|
extension_replica_status: import("../db/kernel-schema.js").ExtensionReplicaStatusTable;
|
|
126
127
|
extension_revision_grant_orgs: import("../db/kernel-schema.js").ExtensionRevisionGrantOrgsTable;
|
|
127
128
|
extension_revision_grants: import("../db/kernel-schema.js").ExtensionRevisionGrantsTable;
|
|
129
|
+
extension_usage: import("../db/kernel-schema.js").ExtensionUsageTable;
|
|
130
|
+
extension_usage_batches: import("../db/kernel-schema.js").ExtensionUsageBatchesTable;
|
|
128
131
|
file_previewers: import("../db/kernel-schema.js").FilePreviewersTable;
|
|
129
132
|
file_shares: import("../db/kernel-schema.js").FileSharesTable;
|
|
130
133
|
files: import("../db/kernel-schema.js").FilesTable;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { type ExecutionRealm } from "./revision-grants.js";
|
|
2
|
+
/**
|
|
3
|
+
* The catalog-driven execution decision (extension permission model spec, "Purpose and boundary";
|
|
4
|
+
* plan task 1.2e). Pure: from a revision's canonical permission keys, whether it has server and
|
|
5
|
+
* client code, and the host's isolation state, it decides where each part runs and which
|
|
6
|
+
* declarations force full access in which realm. Review (1.3a), bootstrap review (1.3c), the
|
|
7
|
+
* tier selector (1.3b) and `capybara-plugin check` all read this one decision.
|
|
8
|
+
*
|
|
9
|
+
* - No server and no client code: declarative assets only, no extension process.
|
|
10
|
+
* - Every server declaration has an isolated contract and the supervisor is available: isolated.
|
|
11
|
+
* - A server declaration without an isolated contract: in-process server only under a full-access
|
|
12
|
+
* grant for the server realm; every such declaration is a forcing key (a provider contract's own
|
|
13
|
+
* `execution.provider.unsupported:<point>` key for a provided point).
|
|
14
|
+
* - A host configured without isolation: the kernel adds `host.no-isolation` to the server realm.
|
|
15
|
+
* - A supervisor configured but failing: a revision that would run isolated is unavailable (fail
|
|
16
|
+
* closed, never an in-process fallback); one already forced into the server realm is unaffected.
|
|
17
|
+
* - A client entry runs in the isolated client realm when it declares `isolated` and the kernel
|
|
18
|
+
* provides that realm (`ISOLATED_CLIENT_REALM_AVAILABLE`); otherwise it needs browser full
|
|
19
|
+
* access, forced by its client declarations.
|
|
20
|
+
* - A deployment config schema outside the isolated tier's declarative subset forces server full
|
|
21
|
+
* access through the kernel's `execution.config.unsupported` key, whether or not it declares a
|
|
22
|
+
* field.
|
|
23
|
+
* - A service declared to run outside the device sandbox forces device full access.
|
|
24
|
+
*
|
|
25
|
+
* A key no catalog row matches exactly once is unknown: it is reported, and treated as forcing
|
|
26
|
+
* server full access (fail closed) so it is never silently isolated.
|
|
27
|
+
*/
|
|
28
|
+
/** The host's isolation supervisor, as the kernel sees it. */
|
|
29
|
+
export type HostIsolation = "available" | "not_configured" | "failing";
|
|
30
|
+
/** The realm a client entry declares (`client.realm`); undeclared counts as `inPage`. */
|
|
31
|
+
export type ClientRealm = "isolated" | "inPage";
|
|
32
|
+
export declare const HOST_NO_ISOLATION_KEY = "host.no-isolation";
|
|
33
|
+
export interface ExecutionInput {
|
|
34
|
+
/** The canonical permission keys of the reviewed revision (`permissionKeys`). */
|
|
35
|
+
keys: readonly string[];
|
|
36
|
+
/** The revision carries server code (an extension entry). */
|
|
37
|
+
server: boolean;
|
|
38
|
+
/** The revision carries a client entry, with its declared realm. */
|
|
39
|
+
client?: {
|
|
40
|
+
realm?: ClientRealm;
|
|
41
|
+
} | undefined;
|
|
42
|
+
host: HostIsolation;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the deployment config schema fits the isolated tier's declarative subset
|
|
45
|
+
* (`deploymentConfigIsolatable`); a schema outside it forces server full access through
|
|
46
|
+
* {@link CONFIG_SCHEMA_UNSUPPORTED_KEY}. Defaults to true (no config, or a supported schema).
|
|
47
|
+
*/
|
|
48
|
+
configSchemaIsolatable?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export type RealmPlacement =
|
|
51
|
+
/** Nothing runs in this realm. */
|
|
52
|
+
{
|
|
53
|
+
mode: "none";
|
|
54
|
+
}
|
|
55
|
+
/** It runs in the realm's isolated form. */
|
|
56
|
+
| {
|
|
57
|
+
mode: "isolated";
|
|
58
|
+
}
|
|
59
|
+
/** It runs with the realm's privileges, only under a grant covering these forcing keys. */
|
|
60
|
+
| {
|
|
61
|
+
mode: "full-access";
|
|
62
|
+
forcingKeys: string[];
|
|
63
|
+
}
|
|
64
|
+
/** It would run isolated, but the isolation supervisor is failing: unavailable, fail closed. */
|
|
65
|
+
| {
|
|
66
|
+
mode: "unavailable";
|
|
67
|
+
reason: "isolation_unavailable";
|
|
68
|
+
};
|
|
69
|
+
export interface ExecutionDecision {
|
|
70
|
+
kind: "declarative" | "code";
|
|
71
|
+
server: RealmPlacement;
|
|
72
|
+
browser: RealmPlacement;
|
|
73
|
+
device: RealmPlacement;
|
|
74
|
+
/**
|
|
75
|
+
* The full-access realms a grant must cover, each with its forcing keys: the `realms` of a
|
|
76
|
+
* revision grant, whose `execution.full-access:<realm>` keys come from {@link fullAccessKeys}.
|
|
77
|
+
*/
|
|
78
|
+
fullAccess: Partial<Record<ExecutionRealm, string[]>>;
|
|
79
|
+
/** Keys no catalog row matches exactly once: the review shows and refuses them. */
|
|
80
|
+
unknownKeys: string[];
|
|
81
|
+
/**
|
|
82
|
+
* False when there is an unknown key, whatever the revision carries (a declarative-only or
|
|
83
|
+
* client-only revision included): such a decision can never be confirmed.
|
|
84
|
+
*/
|
|
85
|
+
confirmable: boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The kernel's forcing key of a deployment config schema outside the isolated subset. The config
|
|
89
|
+
* field keys stay what they are (each fits isolation); the schema itself is what forces.
|
|
90
|
+
*/
|
|
91
|
+
export declare const CONFIG_SCHEMA_UNSUPPORTED_KEY = "execution.config.unsupported";
|
|
92
|
+
export declare function executionDecision(input: ExecutionInput): ExecutionDecision;
|
|
93
|
+
/** The kernel-generated `execution.full-access:<realm>` keys a decision's grant must carry. */
|
|
94
|
+
export declare function fullAccessKeys(decision: Pick<ExecutionDecision, "fullAccess">): string[];
|
|
95
|
+
/** A one-line summary for review lists and `capybara-plugin check`. */
|
|
96
|
+
export declare function describeExecution(decision: ExecutionDecision): string;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { CLIENT_KEY, ISOLATED_CLIENT_REALM_AVAILABLE, ISOLATED_EXTENSION_POINTS, PERMISSION_REALM_FIT, PROVIDER_CONTRACTS, permissionCatalogMatches, } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { fullAccessKey } from "./revision-grants.js";
|
|
3
|
+
export const HOST_NO_ISOLATION_KEY = "host.no-isolation";
|
|
4
|
+
const sorted = (keys) => [...new Set(keys)].sort();
|
|
5
|
+
/** The realm a key forces, or `undefined` when it fits isolation (or is the kernel's own). */
|
|
6
|
+
function forcedRealm(key) {
|
|
7
|
+
const matches = permissionCatalogMatches(key);
|
|
8
|
+
const [match] = matches;
|
|
9
|
+
if (!match || matches.length !== 1)
|
|
10
|
+
return "unknown";
|
|
11
|
+
const fit = PERMISSION_REALM_FIT[match.family];
|
|
12
|
+
switch (fit) {
|
|
13
|
+
case "isolated":
|
|
14
|
+
case "kernel":
|
|
15
|
+
return undefined;
|
|
16
|
+
case "server":
|
|
17
|
+
case "browser":
|
|
18
|
+
case "device":
|
|
19
|
+
return { realm: fit, forcingKey: key };
|
|
20
|
+
case "point": {
|
|
21
|
+
const point = match.declaration;
|
|
22
|
+
if (ISOLATED_EXTENSION_POINTS.includes(point))
|
|
23
|
+
return undefined;
|
|
24
|
+
const provided = match.family === "provides" || match.family === "provides.standard";
|
|
25
|
+
const contract = PROVIDER_CONTRACTS[point];
|
|
26
|
+
return {
|
|
27
|
+
realm: "server",
|
|
28
|
+
forcingKey: provided && contract ? contract.forcingKey : key,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The kernel's forcing key of a deployment config schema outside the isolated subset. The config
|
|
35
|
+
* field keys stay what they are (each fits isolation); the schema itself is what forces.
|
|
36
|
+
*/
|
|
37
|
+
export const CONFIG_SCHEMA_UNSUPPORTED_KEY = "execution.config.unsupported";
|
|
38
|
+
export function executionDecision(input) {
|
|
39
|
+
const forcing = { server: [], browser: [], device: [] };
|
|
40
|
+
const unknownKeys = [];
|
|
41
|
+
// a schema outside the subset forces full access, whether or not it declares a field
|
|
42
|
+
if (input.configSchemaIsolatable === false)
|
|
43
|
+
forcing.server.push(CONFIG_SCHEMA_UNSUPPORTED_KEY);
|
|
44
|
+
for (const key of input.keys) {
|
|
45
|
+
const forced = forcedRealm(key);
|
|
46
|
+
if (forced === "unknown") {
|
|
47
|
+
unknownKeys.push(key);
|
|
48
|
+
forcing.server.push(key);
|
|
49
|
+
}
|
|
50
|
+
else if (forced) {
|
|
51
|
+
forcing[forced.realm].push(forced.forcingKey);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (!input.server && input.client === undefined) {
|
|
55
|
+
return {
|
|
56
|
+
kind: "declarative",
|
|
57
|
+
server: { mode: "none" },
|
|
58
|
+
browser: { mode: "none" },
|
|
59
|
+
device: { mode: "none" },
|
|
60
|
+
fullAccess: {},
|
|
61
|
+
unknownKeys: sorted(unknownKeys),
|
|
62
|
+
confirmable: unknownKeys.length === 0,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
let server = { mode: "none" };
|
|
66
|
+
if (input.server) {
|
|
67
|
+
const keys = sorted(forcing.server);
|
|
68
|
+
if (input.host === "not_configured") {
|
|
69
|
+
server = { mode: "full-access", forcingKeys: sorted([...keys, HOST_NO_ISOLATION_KEY]) };
|
|
70
|
+
}
|
|
71
|
+
else if (keys.length > 0) {
|
|
72
|
+
server = { mode: "full-access", forcingKeys: keys };
|
|
73
|
+
}
|
|
74
|
+
else if (input.host === "failing") {
|
|
75
|
+
server = { mode: "unavailable", reason: "isolation_unavailable" };
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
server = { mode: "isolated" };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
let browser = { mode: "none" };
|
|
82
|
+
if (input.client !== undefined) {
|
|
83
|
+
browser =
|
|
84
|
+
input.client.realm === "isolated" && ISOLATED_CLIENT_REALM_AVAILABLE
|
|
85
|
+
? { mode: "isolated" }
|
|
86
|
+
: {
|
|
87
|
+
mode: "full-access",
|
|
88
|
+
forcingKeys: sorted(forcing.browser.length > 0 ? forcing.browser : [CLIENT_KEY]),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
else if (forcing.browser.length > 0) {
|
|
92
|
+
// client declarations without a client entry still need the page's privileges to mean anything
|
|
93
|
+
browser = { mode: "full-access", forcingKeys: sorted(forcing.browser) };
|
|
94
|
+
}
|
|
95
|
+
const device = forcing.device.length > 0
|
|
96
|
+
? { mode: "full-access", forcingKeys: sorted(forcing.device) }
|
|
97
|
+
: { mode: "none" };
|
|
98
|
+
const fullAccess = {};
|
|
99
|
+
for (const [realm, placement] of [
|
|
100
|
+
["server", server],
|
|
101
|
+
["browser", browser],
|
|
102
|
+
["device", device],
|
|
103
|
+
]) {
|
|
104
|
+
if (placement.mode === "full-access")
|
|
105
|
+
fullAccess[realm] = placement.forcingKeys;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
kind: "code",
|
|
109
|
+
server,
|
|
110
|
+
browser,
|
|
111
|
+
device,
|
|
112
|
+
fullAccess,
|
|
113
|
+
unknownKeys: sorted(unknownKeys),
|
|
114
|
+
confirmable: unknownKeys.length === 0,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/** The kernel-generated `execution.full-access:<realm>` keys a decision's grant must carry. */
|
|
118
|
+
export function fullAccessKeys(decision) {
|
|
119
|
+
return Object.keys(decision.fullAccess).map(fullAccessKey).sort();
|
|
120
|
+
}
|
|
121
|
+
/** A one-line summary for review lists and `capybara-plugin check`. */
|
|
122
|
+
export function describeExecution(decision) {
|
|
123
|
+
const unknown = decision.confirmable
|
|
124
|
+
? ""
|
|
125
|
+
: `; unconfirmable: unknown ${decision.unknownKeys.join(", ")}`;
|
|
126
|
+
if (decision.kind === "declarative")
|
|
127
|
+
return `declarative only: no extension process${unknown}`;
|
|
128
|
+
const parts = [];
|
|
129
|
+
for (const realm of ["server", "browser", "device"]) {
|
|
130
|
+
const placement = decision[realm];
|
|
131
|
+
if (placement.mode === "none")
|
|
132
|
+
continue;
|
|
133
|
+
if (placement.mode === "isolated")
|
|
134
|
+
parts.push(`${realm}: isolated`);
|
|
135
|
+
else if (placement.mode === "unavailable")
|
|
136
|
+
parts.push(`${realm}: isolation unavailable`);
|
|
137
|
+
else
|
|
138
|
+
parts.push(`${realm}: full access (forced by ${placement.forcingKeys.join(", ")})`);
|
|
139
|
+
}
|
|
140
|
+
return `${parts.join("; ")}${unknown}`;
|
|
141
|
+
}
|
|
@@ -23,6 +23,7 @@ import { EmbedTokensModule } from "../ui/embed-token.js";
|
|
|
23
23
|
import { ExtensionAdminOps } from "./admin-ops.js";
|
|
24
24
|
import { ExtensionAdmin } from "./admin-view.js";
|
|
25
25
|
import { BootstrapService } from "./bootstrap.js";
|
|
26
|
+
import { BootstrapReviewService } from "./bootstrap-review.js";
|
|
26
27
|
import { ExtensionDeploymentConfigService } from "./deployment-config.js";
|
|
27
28
|
import { ExtensionDisplayNames } from "./display-name.js";
|
|
28
29
|
import { ExtensionHost } from "./host.js";
|
|
@@ -30,11 +31,14 @@ import { ExtensionLifecycle } from "./lifecycle.js";
|
|
|
30
31
|
import { PluginApproveLock, PluginDeploymentConfigLock, PluginInstallLock, SingleProviderLock, } from "./locks.js";
|
|
31
32
|
import { OrgExtensionConfigs } from "./org-config.js";
|
|
32
33
|
import { OrgOverrides } from "./org-overrides.js";
|
|
34
|
+
import { ExtensionPermissions } from "./permissions.service.js";
|
|
33
35
|
import { PluginGuides } from "./plugin-guides.js";
|
|
34
36
|
import { PluginIcons } from "./plugin-icons.js";
|
|
35
37
|
import { ExtensionPointDefaults } from "./point-defaults.js";
|
|
36
38
|
import { ExtensionPointServingModule } from "./point-serving.js";
|
|
39
|
+
import { HostReasonRetirement } from "./realm-retirement.js";
|
|
37
40
|
import { ExtensionRegistryModule } from "./registry.js";
|
|
41
|
+
import { ExtensionRevocations } from "./revocation.js";
|
|
38
42
|
import { SingleProviderGuard } from "./single-provider.js";
|
|
39
43
|
import { ReplicaStatusStore } from "./sources.js";
|
|
40
44
|
import { ExtensionStateModule } from "./state.module.js";
|
|
@@ -89,6 +93,9 @@ ExtensionsModule = __decorate([
|
|
|
89
93
|
ExtensionEffects,
|
|
90
94
|
ExtensionEffectKeys,
|
|
91
95
|
ExtensionLifecycle,
|
|
96
|
+
ExtensionRevocations,
|
|
97
|
+
ExtensionPermissions,
|
|
98
|
+
HostReasonRetirement,
|
|
92
99
|
ExtensionAdmin,
|
|
93
100
|
ExtensionAdminOps,
|
|
94
101
|
ExtensionDisplayNames,
|
|
@@ -99,6 +106,7 @@ ExtensionsModule = __decorate([
|
|
|
99
106
|
OrgOverrides,
|
|
100
107
|
ExtensionPointDefaults,
|
|
101
108
|
BootstrapService,
|
|
109
|
+
BootstrapReviewService,
|
|
102
110
|
ExtensionAvailability,
|
|
103
111
|
],
|
|
104
112
|
exports: [
|
|
@@ -112,6 +120,9 @@ ExtensionsModule = __decorate([
|
|
|
112
120
|
ExtensionEffects,
|
|
113
121
|
ExtensionEffectKeys,
|
|
114
122
|
ExtensionLifecycle,
|
|
123
|
+
ExtensionRevocations,
|
|
124
|
+
ExtensionPermissions,
|
|
125
|
+
HostReasonRetirement,
|
|
115
126
|
ExtensionAdmin,
|
|
116
127
|
ExtensionAdminOps,
|
|
117
128
|
ExtensionDisplayNames,
|
|
@@ -122,6 +133,7 @@ ExtensionsModule = __decorate([
|
|
|
122
133
|
OrgOverrides,
|
|
123
134
|
ExtensionPointDefaults,
|
|
124
135
|
BootstrapService,
|
|
136
|
+
BootstrapReviewService,
|
|
125
137
|
ExtensionAvailability,
|
|
126
138
|
SingleProviderGuard,
|
|
127
139
|
],
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
2
|
+
import type { FullAccessDisclosure, FullAccessReason } from "./permissions.schemas.js";
|
|
3
|
+
import { type ExecutionRealm, type ExtensionRevisionGrants, type RevisionGrant } from "./revision-grants.js";
|
|
4
|
+
/**
|
|
5
|
+
* The org-facing disclosure of a full-access plugin (spec "Review, updates and provenance" step 3;
|
|
6
|
+
* the 1.4f org page): the install's approved revision, the realms its live grant runs with full
|
|
7
|
+
* access, why (by class), who approved it and when. Nothing else of the grant: no other org's
|
|
8
|
+
* names, no forcing keys, no purposes. Null when the extension is not installed, has no approved
|
|
9
|
+
* revision, or its approved grant is not live or confers no full access.
|
|
10
|
+
*/
|
|
11
|
+
export declare function readFullAccessDisclosure(db: KernelSchemaDb, grants: Pick<ExtensionRevisionGrants, "live">, plugin: string): Promise<FullAccessDisclosure | null>;
|
|
12
|
+
/** The live grant of the install's approved revision, if any. */
|
|
13
|
+
export declare function approvedGrant(db: KernelSchemaDb, grants: Pick<ExtensionRevisionGrants, "live">, plugin: string): Promise<RevisionGrant | undefined>;
|
|
14
|
+
/** The class of one forcing key: what the org admin is told, never the key itself. */
|
|
15
|
+
export declare function reasonOf(realm: ExecutionRealm, key: string): FullAccessReason;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { EXECUTION_REALMS, effectiveRealms, isLive, } from "./revision-grants.js";
|
|
2
|
+
/**
|
|
3
|
+
* The org-facing disclosure of a full-access plugin (spec "Review, updates and provenance" step 3;
|
|
4
|
+
* the 1.4f org page): the install's approved revision, the realms its live grant runs with full
|
|
5
|
+
* access, why (by class), who approved it and when. Nothing else of the grant: no other org's
|
|
6
|
+
* names, no forcing keys, no purposes. Null when the extension is not installed, has no approved
|
|
7
|
+
* revision, or its approved grant is not live or confers no full access.
|
|
8
|
+
*/
|
|
9
|
+
export async function readFullAccessDisclosure(db, grants, plugin) {
|
|
10
|
+
const grant = await approvedGrant(db, grants, plugin);
|
|
11
|
+
if (!grant)
|
|
12
|
+
return null;
|
|
13
|
+
const realms = effectiveRealms(grant);
|
|
14
|
+
const present = EXECUTION_REALMS.filter((realm) => (realms[realm] ?? []).length > 0);
|
|
15
|
+
if (present.length === 0)
|
|
16
|
+
return null;
|
|
17
|
+
const reasons = new Set();
|
|
18
|
+
for (const realm of present) {
|
|
19
|
+
for (const key of realms[realm] ?? [])
|
|
20
|
+
reasons.add(reasonOf(realm, key));
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
approvedRevision: { version: grant.revision.version },
|
|
24
|
+
realms: present,
|
|
25
|
+
reasons: [...reasons].sort(),
|
|
26
|
+
approverAuthority: grant.authority,
|
|
27
|
+
approvedAt: grant.approvedAt.toISOString(),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** The live grant of the install's approved revision, if any. */
|
|
31
|
+
export async function approvedGrant(db, grants, plugin) {
|
|
32
|
+
const row = await db
|
|
33
|
+
.selectFrom("extension_installs")
|
|
34
|
+
.select(["approved_version", "approved_sha512"])
|
|
35
|
+
.where("name", "=", plugin)
|
|
36
|
+
.executeTakeFirst();
|
|
37
|
+
if (!row?.approved_version || !row.approved_sha512)
|
|
38
|
+
return undefined;
|
|
39
|
+
const grant = await grants.live({
|
|
40
|
+
plugin,
|
|
41
|
+
version: row.approved_version,
|
|
42
|
+
sha512: row.approved_sha512,
|
|
43
|
+
});
|
|
44
|
+
return grant && isLive(grant.state) ? grant : undefined;
|
|
45
|
+
}
|
|
46
|
+
/** The class of one forcing key: what the org admin is told, never the key itself. */
|
|
47
|
+
export function reasonOf(realm, key) {
|
|
48
|
+
if (key === "host.no-isolation")
|
|
49
|
+
return "host_no_isolation";
|
|
50
|
+
if (key.startsWith("execution.provider.unsupported:"))
|
|
51
|
+
return "provider_contract";
|
|
52
|
+
if (realm === "browser")
|
|
53
|
+
return "client_code";
|
|
54
|
+
if (realm === "device")
|
|
55
|
+
return "device_host";
|
|
56
|
+
return "declared";
|
|
57
|
+
}
|
|
@@ -22,8 +22,10 @@
|
|
|
22
22
|
* across all replicas, on a worker, but the epoch guards each replica's own in-memory cache, so
|
|
23
23
|
* every replica (api, worker and gateway alike) must read it itself. The read is a one-row
|
|
24
24
|
* primary-key lookup and writes nothing, so a timer per replica carries no cross-replica state;
|
|
25
|
-
* the source of truth stays in PostgreSQL. It runs
|
|
26
|
-
*
|
|
25
|
+
* the source of truth stays in PostgreSQL. It runs once an isolated grant was requested on this
|
|
26
|
+
* replica or an instance with a package opened its permission lease (revocation, plan task 1.3e),
|
|
27
|
+
* and stops when the extension host closes. Each change revalidates the cached isolated grants
|
|
28
|
+
* with calls in flight and every permission lease (one grant read for all leases).
|
|
27
29
|
*/
|
|
28
30
|
/** #1373: stale kernel admission or broker access ends at most 5 s after a revocation commits. */
|
|
29
31
|
export declare const REVOCATION_BOUND_MS = 5000;
|
|
@@ -92,6 +94,11 @@ export declare class GrantEpoch {
|
|
|
92
94
|
stop(): void;
|
|
93
95
|
/** The epoch when the last successful read is younger than `maxAgeMs`, otherwise undefined. */
|
|
94
96
|
fresh(): string | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* Seconds since the start of the last successful read, while polling; undefined before the
|
|
99
|
+
* first read or when stopped (the `grant_epoch_lag` gauge).
|
|
100
|
+
*/
|
|
101
|
+
lagSeconds(): number | undefined;
|
|
95
102
|
/** The fresh epoch, reading PostgreSQL first when needed; undefined when that read fails. */
|
|
96
103
|
ensureFresh(): Promise<string | undefined>;
|
|
97
104
|
/** One read at a time; concurrent callers share it. It settles within the read timeout. */
|