@capybara-hq/kernel 0.1.0-rc.146 → 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 +2 -0
- package/dist/catalog/provenance.js +5 -1
- 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/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/extensions.module.js +9 -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 +5 -0
- package/dist/extensions/grant-epoch.js +9 -0
- package/dist/extensions/host.d.ts +71 -2
- package/dist/extensions/host.js +293 -27
- package/dist/extensions/installs.d.ts +18 -0
- package/dist/extensions/installs.js +28 -0
- package/dist/extensions/isolated/admission.d.ts +17 -2
- package/dist/extensions/isolated/admission.js +15 -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/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/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/revision-approvals.d.ts +58 -3
- package/dist/extensions/revision-approvals.js +135 -14
- package/dist/extensions/revision-review.d.ts +144 -0
- package/dist/extensions/revision-review.js +297 -0
- package/dist/extensions/revocation.js +3 -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 +4 -0
- package/dist/index.js +4 -0
- 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 +25 -1
- package/dist/lifecycle/kernel-lifecycle.js +73 -18
- 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 +4 -0
- package/dist/overrides.js +2 -0
- package/dist/packages/official-publisher.d.ts +26 -1
- package/dist/packages/official-publisher.js +48 -1
- 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
|
@@ -18,6 +18,30 @@ export function pluginSwitchOff(itemId) {
|
|
|
18
18
|
updated_at: sql `now()`,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Locks connector rows in id order, before any of them is written. Every writer that changes
|
|
23
|
+
* several connectors of a plugin in one transaction takes them this way (the delete's switch-off,
|
|
24
|
+
* an org's uninstall, the re-import's relink), so two of them never wait for each other's rows in
|
|
25
|
+
* opposite orders (issue #1428: a re-import racing the delete's owed uninstall deadlocked, 40P01).
|
|
26
|
+
*/
|
|
27
|
+
export async function lockConnectorRows(db, which) {
|
|
28
|
+
if ("ids" in which ? which.ids.length === 0 : which.templateIds.length === 0)
|
|
29
|
+
return [];
|
|
30
|
+
// org-filter: runs in the caller's scope on exactly the rows it is about to write: an org's
|
|
31
|
+
// uninstall passes its own connectors, the platform's delete or re-import of a plugin the
|
|
32
|
+
// connectors of the plugin's templates in every org by design (spec §5 rule 8)
|
|
33
|
+
const rows = await db
|
|
34
|
+
.selectFrom("connectors")
|
|
35
|
+
.select("id")
|
|
36
|
+
.where("deleted_at", "is", null)
|
|
37
|
+
.$call((q) => "ids" in which
|
|
38
|
+
? q.where("id", "in", [...which.ids])
|
|
39
|
+
: q.where("platform_template_id", "in", [...which.templateIds]))
|
|
40
|
+
.orderBy("id")
|
|
41
|
+
.forUpdate()
|
|
42
|
+
.execute();
|
|
43
|
+
return rows.map((r) => r.id);
|
|
44
|
+
}
|
|
21
45
|
/**
|
|
22
46
|
* Switches off, in the caller's transaction, every live connector in any org made from one of the
|
|
23
47
|
* item's connector templates ({@link pluginSwitchOff}): the super admin's delete of the item
|
|
@@ -26,6 +50,12 @@ export function pluginSwitchOff(itemId) {
|
|
|
26
50
|
* the commit (the orgs the update returns). Returns how many connectors it touched.
|
|
27
51
|
*/
|
|
28
52
|
export async function switchOffItemConnectors(db, hints, itemId) {
|
|
53
|
+
const templateIds = (await db
|
|
54
|
+
.selectFrom("platform_connector_templates")
|
|
55
|
+
.select("id")
|
|
56
|
+
.where("catalog_item_id", "=", itemId)
|
|
57
|
+
.execute()).map((r) => r.id);
|
|
58
|
+
await lockConnectorRows(db, { templateIds });
|
|
29
59
|
// org-filter: the delete of a catalog item switches off its template connectors in every org
|
|
30
60
|
// by design (spec §5 rule 8), keyed by the item's own template ids
|
|
31
61
|
const rows = await db
|
|
@@ -67,6 +97,9 @@ export async function relinkDeletedItemConnectors(db, hints, to) {
|
|
|
67
97
|
if (old.length === 0)
|
|
68
98
|
return 0;
|
|
69
99
|
const oldItems = [...new Set(old.map((r) => r.item_id))];
|
|
100
|
+
// In id order before writing: the delete's owed uninstall may be switching the same connectors
|
|
101
|
+
// off right now (issue #1428)
|
|
102
|
+
await lockConnectorRows(db, { templateIds: old.map((r) => r.id) });
|
|
70
103
|
// org-filter: an import relinks the deleted plugin's template connectors in every org by
|
|
71
104
|
// design, keyed by the deleted items' own template ids
|
|
72
105
|
const rows = await db
|
|
@@ -6,10 +6,11 @@ import { ExtensionAdmin } from "../extensions/admin-view.js";
|
|
|
6
6
|
import { ExtensionBlobs } from "../extensions/blobs.js";
|
|
7
7
|
import { ExtensionInstalls } from "../extensions/installs.js";
|
|
8
8
|
import { PluginApproveLock, PluginInstallLock } from "../extensions/locks.js";
|
|
9
|
-
import { ExtensionPackageError } from "../extensions/package.js";
|
|
9
|
+
import { ExtensionPackageError, type PackageClientReview } from "../extensions/package.js";
|
|
10
10
|
import { type PermissionSet } from "../extensions/permission-set.js";
|
|
11
11
|
import { type PackageWarning, type PermissionGroup, type PermissionItem } from "../extensions/permission-view.js";
|
|
12
12
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
13
|
+
import { type FullAccessAcknowledgement, type RevisionGrantOutcome, type RevisionReview, RevisionReviews } from "../extensions/revision-review.js";
|
|
13
14
|
import type { SingleProviderBlock } from "../extensions/single-provider.js";
|
|
14
15
|
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
15
16
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
@@ -28,6 +29,7 @@ import { type TranslationReport } from "./claude/report.js";
|
|
|
28
29
|
import { CatalogItemLock } from "./locks.js";
|
|
29
30
|
import { PlatformComponents } from "./platform-components.js";
|
|
30
31
|
import { PluginPackageError } from "./plugin-package.js";
|
|
32
|
+
import type { PublisherEvidence } from "./provenance.js";
|
|
31
33
|
import type { PluginScope } from "./scope.js";
|
|
32
34
|
/**
|
|
33
35
|
* Platform import of a plugin (package ecosystem spec §4.3): one review for every plugin, whatever
|
|
@@ -106,24 +108,18 @@ export interface PluginReviewExtension {
|
|
|
106
108
|
reviewHash: string;
|
|
107
109
|
/** Sensitive permissions or migration warnings. */
|
|
108
110
|
sensitive: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* The permission review of this exact revision (plan task 1.3a): the 1.2e display and its
|
|
113
|
+
* `review:v1:` hash, the consent it needs and the realms to acknowledge (1.3d). Absent for a
|
|
114
|
+
* bootstrap import (its grants are the bootstrap approval's, plan task 1.3c).
|
|
115
|
+
*/
|
|
116
|
+
revision?: RevisionReview;
|
|
109
117
|
/**
|
|
110
118
|
* The extension's client code (client extensions spec §5.4, §9.1), for the 客户端代码 group of
|
|
111
119
|
* the review: every file of `extension.client` by its manifest key with its size, checked
|
|
112
120
|
* against its integrity when the import was prepared. Absent without client code.
|
|
113
121
|
*/
|
|
114
|
-
client?:
|
|
115
|
-
}
|
|
116
|
-
/** The client code of an extension in a review. */
|
|
117
|
-
export interface PluginReviewClient {
|
|
118
|
-
/** Entry, styles and assets in that order; `path` is the manifest key (`./dist/client/...`). */
|
|
119
|
-
files: {
|
|
120
|
-
path: string;
|
|
121
|
-
size: number;
|
|
122
|
-
}[];
|
|
123
|
-
/** Total bytes. */
|
|
124
|
-
totalBytes: number;
|
|
125
|
-
/** The client API version the bundle was built against. */
|
|
126
|
-
apiVersion: number;
|
|
122
|
+
client?: PackageClientReview;
|
|
127
123
|
}
|
|
128
124
|
/** One connector template in a review. */
|
|
129
125
|
export interface PluginReviewTemplate {
|
|
@@ -331,6 +327,11 @@ export interface PluginConfirmResult {
|
|
|
331
327
|
created: boolean;
|
|
332
328
|
/** null when there is nothing to deploy (no extension, or keep). */
|
|
333
329
|
deploy: ExtensionDeployResult | null;
|
|
330
|
+
/**
|
|
331
|
+
* What the confirmation did with the revision grant (shadow mode until plan task 1.5a: the
|
|
332
|
+
* import completes either way); absent without an extension permission review.
|
|
333
|
+
*/
|
|
334
|
+
grant?: RevisionGrantOutcome;
|
|
334
335
|
/**
|
|
335
336
|
* A confirm with `deploy: false` that approved the extension's permissions (its snapshot
|
|
336
337
|
* written): what {@link PluginImport.restoreApproval} needs to put the previous approval back
|
|
@@ -364,6 +365,11 @@ export interface ReviewProvenance {
|
|
|
364
365
|
provenance: ProvenanceResult;
|
|
365
366
|
warning?: "repository_mismatch";
|
|
366
367
|
}
|
|
368
|
+
/** The classified publisher evidence of a revision (`classifyPublisherEvidence`) and its digest. */
|
|
369
|
+
export interface ReviewPublisher {
|
|
370
|
+
evidence: PublisherEvidence;
|
|
371
|
+
digest?: string | undefined;
|
|
372
|
+
}
|
|
367
373
|
/** The snapshot overwritten at confirm (restored when deploying an upgrade fails). */
|
|
368
374
|
export interface PreviousSnapshot {
|
|
369
375
|
version: string;
|
|
@@ -429,6 +435,8 @@ export declare class PluginImport {
|
|
|
429
435
|
/** The item's scope sync, owed by the confirm's commit when it deploys no extension. */
|
|
430
436
|
private readonly outbox;
|
|
431
437
|
private readonly hints;
|
|
438
|
+
/** The permission review of the extension revision and its grant (plan task 1.3a). */
|
|
439
|
+
private readonly revisionReviews;
|
|
432
440
|
/** Where plugin files go (the kernel's object storage; the CLI's own, see {@link useCliStorage}). */
|
|
433
441
|
private files;
|
|
434
442
|
/**
|
|
@@ -449,7 +457,9 @@ export declare class PluginImport {
|
|
|
449
457
|
/** The platform rows of a new item's components, written in the confirm's transaction. */
|
|
450
458
|
platform: PlatformComponents,
|
|
451
459
|
/** The item's scope sync, owed by the confirm's commit when it deploys no extension. */
|
|
452
|
-
outbox: Pick<OutboxService, "add" | "addMany">, hints: HintPublisher
|
|
460
|
+
outbox: Pick<OutboxService, "add" | "addMany">, hints: HintPublisher,
|
|
461
|
+
/** The permission review of the extension revision and its grant (plan task 1.3a). */
|
|
462
|
+
revisionReviews: RevisionReviews);
|
|
453
463
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
454
464
|
private get db();
|
|
455
465
|
/**
|
|
@@ -484,6 +494,8 @@ export declare class PluginImport {
|
|
|
484
494
|
claudeManifestIgnored?: true;
|
|
485
495
|
/** An org upload (a `file` source only, ruling P3-7). */
|
|
486
496
|
owner?: ImportOwner;
|
|
497
|
+
/** The revision's classified publisher evidence (npm sources). */
|
|
498
|
+
publisher?: ReviewPublisher;
|
|
487
499
|
}): Promise<{
|
|
488
500
|
stagingId: string;
|
|
489
501
|
review: PluginReview;
|
|
@@ -582,6 +594,8 @@ export declare class PluginImport {
|
|
|
582
594
|
orgs?: string[];
|
|
583
595
|
/** An org upload's new item: shared with other orgs by its owner (default false, P3-16). */
|
|
584
596
|
shareable?: boolean;
|
|
597
|
+
/** The per-realm full-access acknowledgement of the extension's review (plan task 1.3d). */
|
|
598
|
+
fullAccessAcknowledgement?: FullAccessAcknowledgement | undefined;
|
|
585
599
|
/**
|
|
586
600
|
* Deploy the extension after the commit (default true). false (the platform's import and
|
|
587
601
|
* update, `PlatformImportUpdate`) leaves the deployment to the platform update that follows,
|
|
@@ -600,6 +614,12 @@ export declare class PluginImport {
|
|
|
600
614
|
}, opts?: ActorOpts & {
|
|
601
615
|
owner?: ImportOwner;
|
|
602
616
|
}): Promise<PluginConfirmResult>;
|
|
617
|
+
/**
|
|
618
|
+
* The org scope a revision's review is prepared with: the live item's (a new version keeps it),
|
|
619
|
+
* else `optional`, the confirm's default. A new item's scope chosen at confirm is what the grant
|
|
620
|
+
* binds; confirm rechecks the review with this one.
|
|
621
|
+
*/
|
|
622
|
+
private itemApprovalScope;
|
|
603
623
|
/**
|
|
604
624
|
* The platform components of the staged version when its confirm will most likely make it the
|
|
605
625
|
* item's first usable version ({@link commit} decides under its locks): no live item of the name
|
|
@@ -22,10 +22,11 @@ import { ExtensionBlobs } from "../extensions/blobs.js";
|
|
|
22
22
|
import { ExtensionInstalls } from "../extensions/installs.js";
|
|
23
23
|
import { PluginApproveLock, PluginInstallLock } from "../extensions/locks.js";
|
|
24
24
|
import { unrunMigrations } from "../extensions/migrate-lock.js";
|
|
25
|
-
import { ExtensionPackageError, permissionSetOfPackage, readExtensionPackage, } from "../extensions/package.js";
|
|
25
|
+
import { ExtensionPackageError, permissionSetOfPackage, readExtensionPackage, reviewPackageClient, } from "../extensions/package.js";
|
|
26
26
|
import { diffPermissions, permissionKeys, WARNINGS_KEY_PREFIX, } from "../extensions/permission-set.js";
|
|
27
27
|
import { reviewHash as extensionReviewHash, migrationWarnings, permissionGroups, permissionKeyItems, } from "../extensions/permission-view.js";
|
|
28
28
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
29
|
+
import { checkAcknowledgement, RevisionReviews, } from "../extensions/revision-review.js";
|
|
29
30
|
import { audit } from "../identity/audit.js";
|
|
30
31
|
import { assertCustomAllowed } from "../identity/settings.js";
|
|
31
32
|
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
@@ -170,6 +171,7 @@ let PluginImport = class PluginImport {
|
|
|
170
171
|
platform;
|
|
171
172
|
outbox;
|
|
172
173
|
hints;
|
|
174
|
+
revisionReviews;
|
|
173
175
|
/** Where plugin files go (the kernel's object storage; the CLI's own, see {@link useCliStorage}). */
|
|
174
176
|
files;
|
|
175
177
|
/**
|
|
@@ -190,7 +192,9 @@ let PluginImport = class PluginImport {
|
|
|
190
192
|
/** The platform rows of a new item's components, written in the confirm's transaction. */
|
|
191
193
|
platform,
|
|
192
194
|
/** The item's scope sync, owed by the confirm's commit when it deploys no extension. */
|
|
193
|
-
outbox, hints
|
|
195
|
+
outbox, hints,
|
|
196
|
+
/** The permission review of the extension revision and its grant (plan task 1.3a). */
|
|
197
|
+
revisionReviews) {
|
|
194
198
|
this.kdb = kdb;
|
|
195
199
|
this.adminLock = adminLock;
|
|
196
200
|
this.orgLock = orgLock;
|
|
@@ -210,6 +214,7 @@ let PluginImport = class PluginImport {
|
|
|
210
214
|
this.platform = platform;
|
|
211
215
|
this.outbox = outbox;
|
|
212
216
|
this.hints = hints;
|
|
217
|
+
this.revisionReviews = revisionReviews;
|
|
213
218
|
this.files = storage;
|
|
214
219
|
}
|
|
215
220
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
@@ -408,6 +413,22 @@ let PluginImport = class PluginImport {
|
|
|
408
413
|
if (ext) {
|
|
409
414
|
extension = await this.reviewExtension(ext, await this.extensionState(m.name, packageName));
|
|
410
415
|
await assertDowngradable(this.db, extension, ext.migrationSql, this.extensionDbIdentity, this.config.get().db.connectTimeoutMs);
|
|
416
|
+
if (source.kind !== "bootstrap") {
|
|
417
|
+
extension.revision = await this.revisionReviews.prepare({
|
|
418
|
+
revision: {
|
|
419
|
+
plugin: ext.section.name,
|
|
420
|
+
version: ext.section.version,
|
|
421
|
+
sha512: createHash("sha512")
|
|
422
|
+
.update(bytes)
|
|
423
|
+
.digest("hex"),
|
|
424
|
+
},
|
|
425
|
+
pkg: ext,
|
|
426
|
+
set: permissionSetOfPackage(ext),
|
|
427
|
+
approvalScope: await this.itemApprovalScope(existing?.id),
|
|
428
|
+
publisher: opts.publisher?.evidence ?? { evidence: "none" },
|
|
429
|
+
evidenceDigest: opts.publisher?.digest,
|
|
430
|
+
});
|
|
431
|
+
}
|
|
411
432
|
}
|
|
412
433
|
// Display files go to PG with the staging row; skills and templates need object storage, which a
|
|
413
434
|
// bootstrap import never has (the object store may be a bootstrap plugin itself). A file that is
|
|
@@ -571,17 +592,14 @@ let PluginImport = class PluginImport {
|
|
|
571
592
|
/** Fetches a plugin from the configured npm registry (verified by `dist.integrity`), then prepares it. */
|
|
572
593
|
async prepareNpm(actor, input, opts = {}) {
|
|
573
594
|
const got = await this.installs.fetchNpm(input);
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
version: got.version,
|
|
577
|
-
integrity: got.integrity,
|
|
578
|
-
});
|
|
595
|
+
const revision = { package: input.package, version: got.version, integrity: got.integrity };
|
|
596
|
+
const { provenance, publisher } = await this.installs.npmEvidence(revision);
|
|
579
597
|
const r = await this.prepare(actor, got.bytes, {
|
|
580
598
|
kind: "npm",
|
|
581
599
|
ref: `${input.package}@${got.version}`,
|
|
582
600
|
integrity: got.integrity,
|
|
583
601
|
detail: { registry: new URL(this.config.get().packages.npmRegistry).origin },
|
|
584
|
-
}, { ...opts, expect: { packageName: input.package }, provenance: { provenance } });
|
|
602
|
+
}, { ...opts, expect: { packageName: input.package }, provenance: { provenance }, publisher });
|
|
585
603
|
return { stagingId: r.stagingId, review: r.review };
|
|
586
604
|
}
|
|
587
605
|
/**
|
|
@@ -730,6 +748,13 @@ let PluginImport = class PluginImport {
|
|
|
730
748
|
const src = row.source;
|
|
731
749
|
if (input.reviewHash !== review.reviewHash)
|
|
732
750
|
throw reviewStale(review);
|
|
751
|
+
const permissionReview = review.extension?.revision;
|
|
752
|
+
if (permissionReview !== undefined) {
|
|
753
|
+
checkAcknowledgement(permissionReview, input.fullAccessAcknowledgement);
|
|
754
|
+
}
|
|
755
|
+
else if (input.fullAccessAcknowledgement !== undefined) {
|
|
756
|
+
throw new ApiError("plugin.full_access_ack_invalid", "The full-access acknowledgement does not match this review: it has no extension permission review; review it again", [{ reason: "no permission review" }]);
|
|
757
|
+
}
|
|
733
758
|
const official = src.kind === "marketplace" && src.marketplaceId === OFFICIAL_MARKETPLACE_ID;
|
|
734
759
|
const requireProof = official && (await officialPublisherProofMode(this.db)) === "require";
|
|
735
760
|
if (official) {
|
|
@@ -759,7 +784,13 @@ let PluginImport = class PluginImport {
|
|
|
759
784
|
assertDeclarativeUpload(manifest);
|
|
760
785
|
const reviewed = review.extension;
|
|
761
786
|
// Read the stored package outside the transaction unless it was already installed as is
|
|
762
|
-
|
|
787
|
+
// A keep reads the package only for the revision grant: unreadable, the confirm still records
|
|
788
|
+
// the version (the grant is skipped and the result says why)
|
|
789
|
+
const stored = reviewed && reviewed.action !== "keep"
|
|
790
|
+
? await this.readStored(reviewed.sha256)
|
|
791
|
+
: reviewed?.revision !== undefined
|
|
792
|
+
? await this.readStored(reviewed.sha256).catch(() => undefined)
|
|
793
|
+
: undefined;
|
|
763
794
|
// The platform components of the item's first usable version: planned and their files copied
|
|
764
795
|
// (keyed by content) before the transaction, their rows written in it
|
|
765
796
|
const prepared = staged.retry === true ? undefined : await this.prepareFirstVersion(staged, row.object_prefix);
|
|
@@ -775,13 +806,15 @@ let PluginImport = class PluginImport {
|
|
|
775
806
|
scope,
|
|
776
807
|
orgs: [...new Set(orgs ?? [])].sort(),
|
|
777
808
|
...(owner !== undefined && { owner, shareable: input.shareable ?? false }),
|
|
778
|
-
}, stored, opts, prepared, input.updateFollows === true);
|
|
809
|
+
}, stored, opts, prepared, input.updateFollows === true, input.fullAccessAcknowledgement);
|
|
779
810
|
const { now } = committed;
|
|
811
|
+
const grant = committed.grant !== undefined ? { grant: committed.grant } : {};
|
|
780
812
|
if (input.deploy === false) {
|
|
781
813
|
return {
|
|
782
814
|
item: await this.itemView(committed.itemId),
|
|
783
815
|
created: committed.created,
|
|
784
816
|
deploy: null,
|
|
817
|
+
...grant,
|
|
785
818
|
...(now &&
|
|
786
819
|
committed.previous !== undefined && {
|
|
787
820
|
approval: { review, extension: now, previous: committed.previous },
|
|
@@ -795,8 +828,35 @@ let PluginImport = class PluginImport {
|
|
|
795
828
|
item: await this.itemView(committed.itemId),
|
|
796
829
|
created: committed.created,
|
|
797
830
|
deploy,
|
|
831
|
+
...grant,
|
|
798
832
|
};
|
|
799
833
|
}
|
|
834
|
+
/**
|
|
835
|
+
* The org scope a revision's review is prepared with: the live item's (a new version keeps it),
|
|
836
|
+
* else `optional`, the confirm's default. A new item's scope chosen at confirm is what the grant
|
|
837
|
+
* binds; confirm rechecks the review with this one.
|
|
838
|
+
*/
|
|
839
|
+
async itemApprovalScope(itemId) {
|
|
840
|
+
if (itemId === undefined)
|
|
841
|
+
return { mode: "optional" };
|
|
842
|
+
const item = await this.db
|
|
843
|
+
.selectFrom("catalog_items")
|
|
844
|
+
.select("scope")
|
|
845
|
+
.where("id", "=", itemId)
|
|
846
|
+
.executeTakeFirst();
|
|
847
|
+
if (item === undefined)
|
|
848
|
+
return { mode: "optional" };
|
|
849
|
+
if (item.scope !== "named")
|
|
850
|
+
return { mode: item.scope };
|
|
851
|
+
// org-filter: deployment-wide: the item's whole named list (spans orgs), keyed by its item id
|
|
852
|
+
const orgs = await asPlatform("read the named scope a revision review is prepared with", () => this.db
|
|
853
|
+
.selectFrom("catalog_item_scope_orgs")
|
|
854
|
+
.select("org_id")
|
|
855
|
+
.where("item_id", "=", itemId)
|
|
856
|
+
.orderBy("org_id")
|
|
857
|
+
.execute());
|
|
858
|
+
return { mode: "named", orgs: orgs.map((r) => r.org_id) };
|
|
859
|
+
}
|
|
800
860
|
/**
|
|
801
861
|
* The platform components of the staged version when its confirm will most likely make it the
|
|
802
862
|
* item's first usable version ({@link commit} decides under its locks): no live item of the name
|
|
@@ -835,7 +895,7 @@ let PluginImport = class PluginImport {
|
|
|
835
895
|
*/
|
|
836
896
|
async commit(actor, c, scope, stored, opts, prepared,
|
|
837
897
|
/** A platform update follows and owes the scope sync (see `confirm`'s `updateFollows`). */
|
|
838
|
-
updateFollows) {
|
|
898
|
+
updateFollows, ack) {
|
|
839
899
|
const { stagingId, review, staged, src, manifest } = c;
|
|
840
900
|
const reviewed = review.extension;
|
|
841
901
|
const stale = () => reviewStale(review);
|
|
@@ -1034,6 +1094,29 @@ let PluginImport = class PluginImport {
|
|
|
1034
1094
|
for (const org of requestOrgs)
|
|
1035
1095
|
await addScopeOrg(t, this.hints, actor, item, org, opts);
|
|
1036
1096
|
}
|
|
1097
|
+
// The revision grant, under the extension's install lock, for the scope the item has after this
|
|
1098
|
+
// confirm, the orgs of the import requests it answers included (shadow mode: recorded beside
|
|
1099
|
+
// the legacy snapshot, which keeps governing admission)
|
|
1100
|
+
let grant;
|
|
1101
|
+
if (now?.revision !== undefined) {
|
|
1102
|
+
if (stored === undefined) {
|
|
1103
|
+
grant = { status: "skipped", reason: "the stored package cannot be read" };
|
|
1104
|
+
}
|
|
1105
|
+
else {
|
|
1106
|
+
const outcome = await this.revisionReviews.confirm({
|
|
1107
|
+
actor,
|
|
1108
|
+
actorTokenId: opts.actorTokenId,
|
|
1109
|
+
prepared: now.revision,
|
|
1110
|
+
pkg: stored,
|
|
1111
|
+
set: permissionSetOfPackage(stored),
|
|
1112
|
+
approvalScope: await this.itemApprovalScope(itemId),
|
|
1113
|
+
ack,
|
|
1114
|
+
});
|
|
1115
|
+
if (outcome === "stale")
|
|
1116
|
+
throw stale();
|
|
1117
|
+
grant = outcome;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1037
1120
|
if (owner !== undefined && created)
|
|
1038
1121
|
await markVersionApplied(t, itemId, staged.version);
|
|
1039
1122
|
if (created) {
|
|
@@ -1071,6 +1154,7 @@ let PluginImport = class PluginImport {
|
|
|
1071
1154
|
created,
|
|
1072
1155
|
now,
|
|
1073
1156
|
previous,
|
|
1157
|
+
...(grant !== undefined && { grant }),
|
|
1074
1158
|
};
|
|
1075
1159
|
}
|
|
1076
1160
|
/**
|
|
@@ -1577,6 +1661,7 @@ let PluginImport = class PluginImport {
|
|
|
1577
1661
|
const warnings = migrationWarnings(pkg.migrationSql, name);
|
|
1578
1662
|
const { added, removed } = diffPermissions(snap?.permissions, set);
|
|
1579
1663
|
const permissions = permissionGroups(set);
|
|
1664
|
+
const client = reviewPackageClient(pkg);
|
|
1580
1665
|
return {
|
|
1581
1666
|
name,
|
|
1582
1667
|
version: pkg.section.version,
|
|
@@ -1589,7 +1674,7 @@ let PluginImport = class PluginImport {
|
|
|
1589
1674
|
warnings,
|
|
1590
1675
|
reviewHash: extensionReviewHash(set, warnings),
|
|
1591
1676
|
sensitive: permissions.some((g) => g.sensitive) || warnings.length > 0,
|
|
1592
|
-
...(
|
|
1677
|
+
...(client !== undefined && { client }),
|
|
1593
1678
|
};
|
|
1594
1679
|
}
|
|
1595
1680
|
async readStored(sha256) {
|
|
@@ -1656,7 +1741,8 @@ PluginImport = __decorate([
|
|
|
1656
1741
|
__param(16, Inject(XactLock)),
|
|
1657
1742
|
__param(17, Inject(PlatformComponents)),
|
|
1658
1743
|
__param(18, Inject(OutboxService)),
|
|
1659
|
-
__param(19, Inject(InvalidationHints))
|
|
1744
|
+
__param(19, Inject(InvalidationHints)),
|
|
1745
|
+
__param(20, Inject(RevisionReviews))
|
|
1660
1746
|
], PluginImport);
|
|
1661
1747
|
export { PluginImport };
|
|
1662
1748
|
/**
|
|
@@ -1722,7 +1808,17 @@ export function pluginReviewHash(r, files) {
|
|
|
1722
1808
|
r.name,
|
|
1723
1809
|
r.version,
|
|
1724
1810
|
r.contentDigest,
|
|
1725
|
-
e
|
|
1811
|
+
e
|
|
1812
|
+
? [
|
|
1813
|
+
e.name,
|
|
1814
|
+
e.sha256,
|
|
1815
|
+
e.action,
|
|
1816
|
+
e.currentVersion,
|
|
1817
|
+
e.currentSha256,
|
|
1818
|
+
e.reviewHash,
|
|
1819
|
+
e.revision?.hash ?? null,
|
|
1820
|
+
]
|
|
1821
|
+
: null,
|
|
1726
1822
|
r.connectorTemplates.map((t) => [
|
|
1727
1823
|
t.id,
|
|
1728
1824
|
t.plugin,
|
|
@@ -1765,27 +1861,6 @@ function reviewIcon(icon, files) {
|
|
|
1765
1861
|
const type = /\.png$/i.test(icon) ? "image/png" : "image/svg+xml";
|
|
1766
1862
|
return `data:${type};base64,${Buffer.from(data).toString("base64")}`;
|
|
1767
1863
|
}
|
|
1768
|
-
/** The client code of a read extension package for its review (sizes from the package's files). */
|
|
1769
|
-
function reviewClient(pkg) {
|
|
1770
|
-
const c = pkg.section.client;
|
|
1771
|
-
const sizes = new Map(pkg.files.map((f) => [f.path, f.size]));
|
|
1772
|
-
const files = [
|
|
1773
|
-
...(c.entry !== undefined ? [c.entry] : []),
|
|
1774
|
-
...(c.styles ?? []),
|
|
1775
|
-
...(c.assets ?? []),
|
|
1776
|
-
].map((path) => {
|
|
1777
|
-
// checkClientFiles ran first: every listed file is in the package
|
|
1778
|
-
const size = sizes.get(path.slice(2));
|
|
1779
|
-
if (size === undefined)
|
|
1780
|
-
throw new Error(`client file ${path} is not in the package`);
|
|
1781
|
-
return { path, size };
|
|
1782
|
-
});
|
|
1783
|
-
return {
|
|
1784
|
-
files,
|
|
1785
|
-
totalBytes: files.reduce((n, f) => n + f.size, 0),
|
|
1786
|
-
apiVersion: c.apiVersion,
|
|
1787
|
-
};
|
|
1788
|
-
}
|
|
1789
1864
|
/**
|
|
1790
1865
|
* A version change that is a downgrade (the imported version below the installed one) whose
|
|
1791
1866
|
* version has migrations not run on this deployment -> `extension.downgrade_unsupported` (the same
|
|
@@ -35,6 +35,7 @@ import { findConnectorIn, lockOrgForActions, readCatalogAgentTemplates, readCata
|
|
|
35
35
|
import { versionUsable } from "./catalog-items.js";
|
|
36
36
|
import { agentDefinitionRefs, componentOn, connectorTemplateChoice, connectorTemplateState, connectorTemplatesOn, listedIn, loadComponents, loadScopeState, pluginFactsOf, referenceIds, switchOf, themeIdClashes, } from "./component-state.js";
|
|
37
37
|
import { contentLostWhenOff, DEPENDENCY_DEPTH_LIMIT } from "./org-intent.js";
|
|
38
|
+
import { lockConnectorRows } from "./plugin-connectors.js";
|
|
38
39
|
import { assertItemInstallable, disabledPluginItems, pluginItemDisabled, resolveRequestsByInstall, } from "./request-rules.js";
|
|
39
40
|
import { visibleTo } from "./scope.js";
|
|
40
41
|
import { pluginEffectsWanted, ScopeNoLongerWanted, ScopeStillWanted, wantedByScope, } from "./scope-state.js";
|
|
@@ -1283,6 +1284,11 @@ let PluginInstaller = class PluginInstaller {
|
|
|
1283
1284
|
? 2 + extensionOrder.indexOf(c.ref)
|
|
1284
1285
|
: 1000 + (c.created ? 0 : 1);
|
|
1285
1286
|
comps.sort((a, b) => rank(a) - rank(b));
|
|
1287
|
+
// The connectors this uninstall switches off, locked in id order before the first is written:
|
|
1288
|
+
// a re-import of the deleted plugin relinks the same rows (issue #1428)
|
|
1289
|
+
await lockConnectorRows(t, {
|
|
1290
|
+
ids: comps.filter((c) => c.kind === "connector").map((c) => c.ref),
|
|
1291
|
+
});
|
|
1286
1292
|
const agentRefs = await this.agentRefs(orgId);
|
|
1287
1293
|
for (const c of comps) {
|
|
1288
1294
|
const keep = (reason) => addKept({ kind: c.kind, ref: c.ref, reason });
|
|
@@ -46,6 +46,8 @@ export type PublisherEvidenceOutcome = {
|
|
|
46
46
|
outcome: "refused";
|
|
47
47
|
reason: string;
|
|
48
48
|
};
|
|
49
|
+
/** The normalized identity an official publisher proof establishes. */
|
|
50
|
+
export declare function officialPublisherIdentity(): PublisherIdentity;
|
|
49
51
|
/**
|
|
50
52
|
* The publisher evidence of one revision:
|
|
51
53
|
* - `integrity`: whether the bytes matched the recorded digest; a mismatch always refuses;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { officialPublisherProblem, } from "../packages/official-publisher.js";
|
|
1
|
+
import { OFFICIAL_PUBLISHER_CERTIFICATE, officialPublisherProblem, } from "../packages/official-publisher.js";
|
|
2
2
|
import { canonicalJson } from "../tools/canonical-json.js";
|
|
3
3
|
/** `https://Host/Path/` → `https://host/Path` without a trailing slash; other strings trimmed. */
|
|
4
4
|
function normalizeUrl(value) {
|
|
@@ -55,6 +55,10 @@ export function normalizePublisherIdentity(certificate) {
|
|
|
55
55
|
export function samePublisher(a, b) {
|
|
56
56
|
return canonicalJson(a) === canonicalJson(b);
|
|
57
57
|
}
|
|
58
|
+
/** The normalized identity an official publisher proof establishes. */
|
|
59
|
+
export function officialPublisherIdentity() {
|
|
60
|
+
return normalizePublisherIdentity({ ...OFFICIAL_PUBLISHER_CERTIFICATE, commit: "" });
|
|
61
|
+
}
|
|
58
62
|
/**
|
|
59
63
|
* The publisher evidence of one revision:
|
|
60
64
|
* - `integrity`: whether the bytes matched the recorded digest; a mismatch always refuses;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where `extensionPermissions.autoApprove` may be used (extension permission model spec, "Review,
|
|
3
|
+
* updates and provenance"; plan task 1.3c): outside production only. It is refused in the official
|
|
4
|
+
* images, identified by the build-time marker file the kernel image writes (`docker/kernel.Dockerfile`),
|
|
5
|
+
* and with `NODE_ENV=production`. The marker is a root-owned file at a fixed path, so changing the
|
|
6
|
+
* environment cannot remove an official image's restriction.
|
|
7
|
+
*/
|
|
8
|
+
/** The build marker of the official kernel image. */
|
|
9
|
+
export declare const OFFICIAL_IMAGE_MARKER = "/app/.capybara-official-image";
|
|
10
|
+
/** Whether this process runs in an official kernel image (the build marker exists). */
|
|
11
|
+
export declare function isOfficialImage(marker?: string): boolean;
|
|
12
|
+
/** Why `autoApprove` is refused here, or undefined when it may be used. */
|
|
13
|
+
export declare function autoApproveRefusal(where: {
|
|
14
|
+
nodeEnv: string | undefined;
|
|
15
|
+
officialImage: boolean;
|
|
16
|
+
}): string | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
/**
|
|
3
|
+
* Where `extensionPermissions.autoApprove` may be used (extension permission model spec, "Review,
|
|
4
|
+
* updates and provenance"; plan task 1.3c): outside production only. It is refused in the official
|
|
5
|
+
* images, identified by the build-time marker file the kernel image writes (`docker/kernel.Dockerfile`),
|
|
6
|
+
* and with `NODE_ENV=production`. The marker is a root-owned file at a fixed path, so changing the
|
|
7
|
+
* environment cannot remove an official image's restriction.
|
|
8
|
+
*/
|
|
9
|
+
/** The build marker of the official kernel image. */
|
|
10
|
+
export const OFFICIAL_IMAGE_MARKER = "/app/.capybara-official-image";
|
|
11
|
+
/** Whether this process runs in an official kernel image (the build marker exists). */
|
|
12
|
+
export function isOfficialImage(marker = OFFICIAL_IMAGE_MARKER) {
|
|
13
|
+
return existsSync(marker);
|
|
14
|
+
}
|
|
15
|
+
/** Why `autoApprove` is refused here, or undefined when it may be used. */
|
|
16
|
+
export function autoApproveRefusal(where) {
|
|
17
|
+
if (where.officialImage) {
|
|
18
|
+
return "extensionPermissions.autoApprove is refused in the official images; approve extensions with `capybara bootstrap approve` and in the admin console";
|
|
19
|
+
}
|
|
20
|
+
if (where.nodeEnv === "production") {
|
|
21
|
+
return "extensionPermissions.autoApprove is refused with NODE_ENV=production; approve extensions with `capybara bootstrap approve` and in the admin console";
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|