@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.
Files changed (185) hide show
  1. package/dist/admin/extensions.controller.d.ts +0 -11
  2. package/dist/admin/extensions.controller.js +0 -28
  3. package/dist/admin/health.service.d.ts +25 -1
  4. package/dist/admin/health.service.js +50 -18
  5. package/dist/audit/full-access.d.ts +78 -0
  6. package/dist/audit/full-access.js +283 -0
  7. package/dist/automations/automations.service.d.ts +1 -0
  8. package/dist/automations/automations.service.js +3 -1
  9. package/dist/automations/calendar.js +3 -1
  10. package/dist/automations/grant-rules.d.ts +2 -1
  11. package/dist/automations/grant-rules.js +8 -1
  12. package/dist/automations/unattended.d.ts +13 -1
  13. package/dist/automations/unattended.js +13 -1
  14. package/dist/catalog/admin-catalog.controller.d.ts +8 -0
  15. package/dist/catalog/admin-catalog.controller.js +8 -2
  16. package/dist/catalog/admin-catalog.schemas.d.ts +10 -0
  17. package/dist/catalog/admin-catalog.schemas.js +8 -1
  18. package/dist/catalog/catalog-content.d.ts +6 -0
  19. package/dist/catalog/catalog-scope.service.d.ts +22 -2
  20. package/dist/catalog/catalog-scope.service.js +27 -3
  21. package/dist/catalog/catalog.service.js +19 -2
  22. package/dist/catalog/marketplaces.service.d.ts +1 -1
  23. package/dist/catalog/org-catalog.service.d.ts +8 -1
  24. package/dist/catalog/org-catalog.service.js +36 -3
  25. package/dist/catalog/platform-components.js +3 -2
  26. package/dist/catalog/platform-import-update.d.ts +2 -0
  27. package/dist/catalog/platform-import-update.js +8 -1
  28. package/dist/catalog/plugin-connectors.d.ts +11 -0
  29. package/dist/catalog/plugin-connectors.js +33 -0
  30. package/dist/catalog/plugin-import.d.ts +35 -15
  31. package/dist/catalog/plugin-import.js +110 -35
  32. package/dist/catalog/plugin-install.js +6 -0
  33. package/dist/catalog/provenance.d.ts +71 -0
  34. package/dist/catalog/provenance.js +112 -0
  35. package/dist/config/auto-approve.d.ts +16 -0
  36. package/dist/config/auto-approve.js +24 -0
  37. package/dist/config/capacity-presets.d.ts +243 -0
  38. package/dist/config/capacity-presets.js +195 -0
  39. package/dist/config/env.d.ts +2 -1
  40. package/dist/config/env.js +6 -1
  41. package/dist/config/load.js +15 -0
  42. package/dist/config/schema.d.ts +46 -9
  43. package/dist/config/schema.js +154 -30
  44. package/dist/ctx/create-ctx.d.ts +16 -0
  45. package/dist/ctx/create-ctx.js +269 -34
  46. package/dist/ctx/net.d.ts +5 -1
  47. package/dist/ctx/net.js +62 -12
  48. package/dist/db/kernel-schema.d.ts +31 -0
  49. package/dist/db/migrator.js +0 -36
  50. package/dist/dial-in/routes.js +1 -1
  51. package/dist/erasure/org-batches.js +1 -6
  52. package/dist/erasure/org-catalog.js +6 -2
  53. package/dist/erasure/org-rules.js +1 -0
  54. package/dist/erasure/org-worker.js +0 -13
  55. package/dist/errors.d.ts +6 -0
  56. package/dist/errors.js +6 -0
  57. package/dist/extensions/admin-ops.d.ts +14 -1
  58. package/dist/extensions/admin-ops.js +30 -3
  59. package/dist/extensions/admin-view.d.ts +21 -1
  60. package/dist/extensions/admin-view.js +43 -0
  61. package/dist/extensions/bootstrap-packages.d.ts +5 -0
  62. package/dist/extensions/bootstrap-packages.js +1 -1
  63. package/dist/extensions/bootstrap-review.d.ts +251 -0
  64. package/dist/extensions/bootstrap-review.js +676 -0
  65. package/dist/extensions/bootstrap.d.ts +21 -1
  66. package/dist/extensions/bootstrap.js +72 -2
  67. package/dist/extensions/cli.d.ts +6 -0
  68. package/dist/extensions/cli.js +4 -0
  69. package/dist/extensions/enabled.d.ts +3 -0
  70. package/dist/extensions/execution-realm.d.ts +96 -0
  71. package/dist/extensions/execution-realm.js +141 -0
  72. package/dist/extensions/extensions.module.js +12 -0
  73. package/dist/extensions/full-access-disclosure.d.ts +15 -0
  74. package/dist/extensions/full-access-disclosure.js +57 -0
  75. package/dist/extensions/grant-epoch.d.ts +9 -2
  76. package/dist/extensions/grant-epoch.js +13 -2
  77. package/dist/extensions/host.d.ts +96 -4
  78. package/dist/extensions/host.js +411 -33
  79. package/dist/extensions/installs.d.ts +18 -0
  80. package/dist/extensions/installs.js +28 -0
  81. package/dist/extensions/instance.d.ts +2 -0
  82. package/dist/extensions/instance.js +1 -0
  83. package/dist/extensions/isolated/admission.d.ts +23 -2
  84. package/dist/extensions/isolated/admission.js +32 -7
  85. package/dist/extensions/isolated/authorization.d.ts +8 -2
  86. package/dist/extensions/isolated/authorization.js +11 -3
  87. package/dist/extensions/isolated/broker.d.ts +3 -0
  88. package/dist/extensions/isolated/broker.js +50 -14
  89. package/dist/extensions/isolated/configured-package.d.ts +5 -0
  90. package/dist/extensions/isolated/configured-package.js +2 -0
  91. package/dist/extensions/isolated/lanes.d.ts +44 -3
  92. package/dist/extensions/isolated/lanes.js +263 -80
  93. package/dist/extensions/isolated/metrics.d.ts +146 -0
  94. package/dist/extensions/isolated/metrics.js +304 -0
  95. package/dist/extensions/isolated/revision.d.ts +7 -1
  96. package/dist/extensions/isolated/revision.js +26 -5
  97. package/dist/extensions/isolated/rpc.d.ts +5 -0
  98. package/dist/extensions/isolated/rpc.js +7 -2
  99. package/dist/extensions/isolated/sandbox.d.ts +23 -0
  100. package/dist/extensions/isolated/sandbox.js +50 -0
  101. package/dist/extensions/isolated/status.d.ts +79 -0
  102. package/dist/extensions/isolated/status.js +216 -0
  103. package/dist/extensions/isolated/tier.d.ts +127 -2
  104. package/dist/extensions/isolated/tier.js +266 -7
  105. package/dist/extensions/isolated/usage.d.ts +134 -0
  106. package/dist/extensions/isolated/usage.js +322 -0
  107. package/dist/extensions/ledger.d.ts +5 -0
  108. package/dist/extensions/ledger.js +16 -0
  109. package/dist/extensions/lifecycle.d.ts +42 -2
  110. package/dist/extensions/lifecycle.js +100 -4
  111. package/dist/extensions/org-config.js +11 -0
  112. package/dist/extensions/package.d.ts +14 -0
  113. package/dist/extensions/package.js +23 -0
  114. package/dist/extensions/permission-view.d.ts +2 -2
  115. package/dist/extensions/permissions.controller.d.ts +35 -0
  116. package/dist/extensions/permissions.controller.js +98 -0
  117. package/dist/extensions/permissions.schemas.d.ts +288 -0
  118. package/dist/extensions/permissions.schemas.js +96 -0
  119. package/dist/extensions/permissions.service.d.ts +116 -0
  120. package/dist/extensions/permissions.service.js +428 -0
  121. package/dist/extensions/realm-retirement.d.ts +65 -0
  122. package/dist/extensions/realm-retirement.js +150 -0
  123. package/dist/extensions/registry.d.ts +6 -0
  124. package/dist/extensions/registry.js +8 -0
  125. package/dist/extensions/review-hash.d.ts +114 -0
  126. package/dist/extensions/review-hash.js +145 -0
  127. package/dist/extensions/revision-approvals.d.ts +58 -3
  128. package/dist/extensions/revision-approvals.js +135 -14
  129. package/dist/extensions/revision-grants.d.ts +10 -0
  130. package/dist/extensions/revision-review.d.ts +144 -0
  131. package/dist/extensions/revision-review.js +297 -0
  132. package/dist/extensions/revocation-leases.d.ts +273 -0
  133. package/dist/extensions/revocation-leases.js +533 -0
  134. package/dist/extensions/revocation.d.ts +78 -0
  135. package/dist/extensions/revocation.js +205 -0
  136. package/dist/extensions/state.module.js +12 -0
  137. package/dist/git/run-end.d.ts +35 -7
  138. package/dist/git/run-end.js +87 -38
  139. package/dist/http/api.module.js +2 -0
  140. package/dist/identity/audit.d.ts +2 -1
  141. package/dist/identity/audit.js +4 -17
  142. package/dist/index.d.ts +10 -2
  143. package/dist/index.js +10 -2
  144. package/dist/infra/config/kernel-config.service.d.ts +6 -0
  145. package/dist/infra/config/kernel-config.service.js +21 -0
  146. package/dist/infra/outbox/registry.d.ts +13 -0
  147. package/dist/infra/outbox/registry.js +8 -0
  148. package/dist/lifecycle/kernel-lifecycle.d.ts +27 -1
  149. package/dist/lifecycle/kernel-lifecycle.js +83 -22
  150. package/dist/net/private-endpoint-preflight.d.ts +159 -0
  151. package/dist/net/private-endpoint-preflight.js +417 -0
  152. package/dist/net/private-endpoints.d.ts +68 -0
  153. package/dist/net/private-endpoints.js +164 -0
  154. package/dist/net/public-address.d.ts +14 -0
  155. package/dist/net/public-address.js +15 -1
  156. package/dist/net/safe-fetch.d.ts +2 -1
  157. package/dist/net/safe-fetch.js +10 -3
  158. package/dist/overrides.d.ts +9 -1
  159. package/dist/overrides.js +4 -0
  160. package/dist/packages/official-publisher.d.ts +65 -1
  161. package/dist/packages/official-publisher.js +171 -46
  162. package/dist/packages/provenance.d.ts +11 -0
  163. package/dist/packages/provenance.js +24 -0
  164. package/dist/platform/exclusions.js +4 -4
  165. package/dist/platform/ops/automations.ops.js +1 -1
  166. package/dist/platform/ops/catalog-admin.ops.js +25 -4
  167. package/dist/platform/ops/extension-permissions.ops.d.ts +11 -0
  168. package/dist/platform/ops/extension-permissions.ops.js +159 -0
  169. package/dist/platform/platform-ops.module.d.ts +2 -1
  170. package/dist/platform/platform-ops.module.js +2 -0
  171. package/dist/platform/route-schemas.js +2 -0
  172. package/dist/retention/purge-batch.js +10 -14
  173. package/dist/runtime/maintenance.d.ts +4 -2
  174. package/dist/runtime/maintenance.js +16 -3
  175. package/dist/runtime/run-finish.d.ts +3 -3
  176. package/dist/runtime/run-finish.js +7 -3
  177. package/dist/sandbox/permission-availability.d.ts +17 -2
  178. package/dist/sandbox/permission-availability.js +22 -1
  179. package/dist/sandbox/permission-facts.js +7 -1
  180. package/dist/tools/builtins/sandbox/common.js +2 -0
  181. package/dist/tools/pipeline.d.ts +2 -1
  182. package/dist/tools/pipeline.js +7 -2
  183. package/package.json +4 -3
  184. package/src/migrations/0238_extension_usage.sql +40 -0
  185. package/src/migrations/0239_extension_replica_isolation.sql +28 -0
@@ -46,6 +46,29 @@ export class ExtensionPackageError extends Error {
46
46
  export function extensionPackageApiError(e) {
47
47
  return new ApiError(e.code, e.message, e.issues);
48
48
  }
49
+ /** The client code of a read extension package for its review (sizes from the package's files). */
50
+ export function reviewPackageClient(pkg) {
51
+ const c = pkg.section.client;
52
+ if (c === undefined)
53
+ return undefined;
54
+ const sizes = new Map(pkg.files.map((f) => [f.path, f.size]));
55
+ const files = [
56
+ ...(c.entry !== undefined ? [c.entry] : []),
57
+ ...(c.styles ?? []),
58
+ ...(c.assets ?? []),
59
+ ].map((path) => {
60
+ // checkClientFiles ran first: every listed file is in the package
61
+ const size = sizes.get(path.slice(2));
62
+ if (size === undefined)
63
+ throw new Error(`client file ${path} is not in the package`);
64
+ return { path, size };
65
+ });
66
+ return {
67
+ files,
68
+ totalBytes: files.reduce((n, f) => n + f.size, 0),
69
+ apiVersion: c.apiVersion,
70
+ };
71
+ }
49
72
  const fail = (issue) => {
50
73
  throw new ExtensionPackageError([issue]);
51
74
  };
@@ -7,9 +7,9 @@ import type { ExtensionSource } from "./sources.js";
7
7
  export declare function reviewPermissionRows(set: PermissionSet): {
8
8
  rows: {
9
9
  key: string;
10
- family: "config.deployment" | "config.deployment.secret" | "execution.full-access" | "execution.provider.unsupported" | "host.no-isolation" | "migration.warnings" | "optional" | "optional.custodian" | "permissions.agents" | "permissions.bus" | "permissions.client" | "permissions.conversations" | "permissions.deviceaccess" | "permissions.deviceaccess.host" | "permissions.deviceaccess.loopbackports" | "permissions.deviceaccess.siteaccess" | "permissions.dialin" | "permissions.fullaccess.rawegress" | "permissions.hooks.observe" | "permissions.hooks.policy" | "permissions.hooks.sensitive" | "permissions.http" | "permissions.inbox" | "permissions.kv" | "permissions.lock" | "permissions.models" | "permissions.network" | "permissions.outbox" | "permissions.people" | "permissions.queue" | "permissions.secrets" | "permissions.storage" | "permissions.tools" | "permissions.triggers" | "provides" | "provides.standard" | "requires" | "requires.custodian" | "setup.check" | "table" | "ui.action" | "ui.component" | "ui.embed" | "ui.query" | "ui.view";
10
+ family: "config.deployment" | "config.deployment.secret" | "execution.config.unsupported" | "execution.full-access" | "execution.provider.unsupported" | "host.no-isolation" | "migration.warnings" | "optional" | "optional.custodian" | "permissions.agents" | "permissions.bus" | "permissions.client" | "permissions.conversations" | "permissions.deviceaccess" | "permissions.deviceaccess.host" | "permissions.deviceaccess.loopbackports" | "permissions.deviceaccess.siteaccess" | "permissions.dialin" | "permissions.fullaccess.rawegress" | "permissions.hooks.observe" | "permissions.hooks.policy" | "permissions.hooks.sensitive" | "permissions.http" | "permissions.inbox" | "permissions.kv" | "permissions.lock" | "permissions.models" | "permissions.network" | "permissions.outbox" | "permissions.people" | "permissions.queue" | "permissions.secrets" | "permissions.storage" | "permissions.tools" | "permissions.triggers" | "provides" | "provides.standard" | "requires" | "requires.custodian" | "setup.check" | "table" | "ui.action" | "ui.component" | "ui.embed" | "ui.query" | "ui.view";
11
11
  risk: "custodian" | "fullAccess" | "informational" | "sensitive" | "standard";
12
- reason: "Accepts connections from devices that use this protocol." | "Calls the model mapped to this declared purpose." | "Can deny the protected action at this mount." | "Can request a grant for a device loopback port." | "Can request approved actions on websites from the person's device." | "Contains migration statements that require review." | "Coordinates work using locks in the extension namespace." | "Creates a table in the extension database schema." | "Depends on a provider that handles a protected resource." | "Emits durable events of this type." | "Handles this named action for its extension UI." | "Handles this named query for its extension UI." | "Implements a kernel capability and sees the resource it serves." | "Implements this kernel capability." | "Makes network requests outside the kernel egress broker." | "Observes bounded metadata at this mount." | "Observes model or tool data at this mount." | "Orders startup after this extension point when present." | "Posts to the inbox of members of enabled orgs." | "Publishes and receives events in the extension namespace." | "Reads and writes keys in the extension namespace." | "Reads metadata for conversations about its own subjects." | "Reads or stores secrets in its approved namespace." | "Reads or writes objects in its scoped storage prefix." | "Reads the names and avatars of org members." | "Reads which agents a member can use." | "Receives requests and data for this route and audience." | "Receives this field from effective configuration." | "Renders this named component in the app." | "Renders this named view through the kernel." | "Requires this extension point at startup." | "Runs this named tool with its input and scoped call context." | "Runs this read-only setup check." | "Runs this service outside the device sandbox." | "Runs with the privileges of the approved execution realm." | "Runs without a host isolation supervisor." | "Schedules work in the extension namespace." | "Sends requests and data to this destination." | "Serves an embedded page for this view." | "Stages durable effects in the extension namespace." | "Supplies client code for the app." | "This provider contract does not yet have an isolated execution form." | "Uses this confidential configuration field." | "Uses this service on a person's device.";
12
+ reason: "Accepts connections from devices that use this protocol." | "Calls the model mapped to this declared purpose." | "Can deny the protected action at this mount." | "Can request a grant for a device loopback port." | "Can request approved actions on websites from the person's device." | "Contains migration statements that require review." | "Coordinates work using locks in the extension namespace." | "Creates a table in the extension database schema." | "Depends on a provider that handles a protected resource." | "Emits durable events of this type." | "Handles this named action for its extension UI." | "Handles this named query for its extension UI." | "Implements a kernel capability and sees the resource it serves." | "Implements this kernel capability." | "Makes network requests outside the kernel egress broker." | "Observes bounded metadata at this mount." | "Observes model or tool data at this mount." | "Orders startup after this extension point when present." | "Posts to the inbox of members of enabled orgs." | "Publishes and receives events in the extension namespace." | "Reads and writes keys in the extension namespace." | "Reads metadata for conversations about its own subjects." | "Reads or stores secrets in its approved namespace." | "Reads or writes objects in its scoped storage prefix." | "Reads the names and avatars of org members." | "Reads which agents a member can use." | "Receives requests and data for this route and audience." | "Receives this field from effective configuration." | "Renders this named component in the app." | "Renders this named view through the kernel." | "Requires this extension point at startup." | "Runs this named tool with its input and scoped call context." | "Runs this read-only setup check." | "Runs this service outside the device sandbox." | "Runs with the privileges of the approved execution realm." | "Runs without a host isolation supervisor." | "Schedules work in the extension namespace." | "Sends requests and data to this destination." | "Serves an embedded page for this view." | "Stages durable effects in the extension namespace." | "Supplies client code for the app." | "The deployment config schema is outside the isolated tier's declarative subset." | "This provider contract does not yet have an isolated execution form." | "Uses this confidential configuration field." | "Uses this service on a person's device.";
13
13
  purpose: import("@capybara-hq/plugin-sdk").PermissionPurpose | undefined;
14
14
  }[];
15
15
  errors: string[];
@@ -0,0 +1,35 @@
1
+ import type { z } from "zod";
2
+ import { type Principal } from "../identity/principal.js";
3
+ import { type IsolationStatus, PermissionApproveBody, type PermissionApproveResult, type PermissionInventory, type PermissionReviewView, PermissionRevokeBody, type PermissionRevokeResult } from "./permissions.schemas.js";
4
+ import { ExtensionPermissions } from "./permissions.service.js";
5
+ /**
6
+ * The extension permission routes (plan task 1.4a; `permissions.schemas.ts` has the contract)
7
+ * and the isolation status (1.4j). Super admins only.
8
+ */
9
+ export declare class ExtensionPermissionsController {
10
+ private readonly permissions;
11
+ constructor(permissions: ExtensionPermissions);
12
+ /** Every install record with its shadow decision, grants and shadow placements. */
13
+ inventory(): Promise<PermissionInventory>;
14
+ /**
15
+ * The permission review of the install's current revision. Not installed -> 404
16
+ * `extension.not_found`; digest not recorded yet or package unreadable -> 409
17
+ * `extension.permission_review_unavailable`.
18
+ */
19
+ review(name: string): Promise<PermissionReviewView>;
20
+ /**
21
+ * A person approves that review (a human security consent: no Platform operation): the revision
22
+ * grant and the legacy approval in one transaction. Another revision or review -> 409
23
+ * `extension.permission_review_stale`; a wrong full-access acknowledgement -> 409
24
+ * `plugin.full_access_ack_invalid`; a missing one -> 200 with the grant skipped (until 1.5a).
25
+ */
26
+ approve(principal: Principal, name: string, body: z.infer<typeof PermissionApproveBody>): Promise<PermissionApproveResult>;
27
+ /**
28
+ * Revokes keys of a revision's live grant, or the whole grant. Unknown or unrevocable keys -> 409
29
+ * `extension.permission_keys_unknown`; no live grant -> 404
30
+ * `extension.permission_grant_not_found`.
31
+ */
32
+ revoke(principal: Principal, name: string, body: z.infer<typeof PermissionRevokeBody>): Promise<PermissionRevokeResult>;
33
+ /** The isolation status: `not_configured`, or each live replica's supervisor checks. */
34
+ isolation(): Promise<IsolationStatus>;
35
+ }
@@ -0,0 +1,98 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
+ return function (target, key) { decorator(target, key, paramIndex); }
9
+ };
10
+ import { Controller, Get, HttpCode, Inject, Param, Post } from "@nestjs/common";
11
+ import { CurrentPrincipal, patTokenId, requireUser, SuperAdmin, } from "../identity/principal.js";
12
+ import { createZodDto } from "../infra/validation/create-zod-dto.js";
13
+ import { ZBody } from "../infra/validation/zod-params.js";
14
+ import { PermissionApproveBody, PermissionRevokeBody, } from "./permissions.schemas.js";
15
+ import { ExtensionPermissions } from "./permissions.service.js";
16
+ class PermissionApproveBodyDto extends createZodDto(PermissionApproveBody, "ExtensionPermissionApproveBody") {
17
+ }
18
+ class PermissionRevokeBodyDto extends createZodDto(PermissionRevokeBody, "ExtensionPermissionRevokeBody") {
19
+ }
20
+ const actorOpts = (actor) => {
21
+ const tokenId = patTokenId(actor);
22
+ return tokenId !== undefined ? { actorTokenId: tokenId } : {};
23
+ };
24
+ /**
25
+ * The extension permission routes (plan task 1.4a; `permissions.schemas.ts` has the contract)
26
+ * and the isolation status (1.4j). Super admins only.
27
+ */
28
+ let ExtensionPermissionsController = class ExtensionPermissionsController {
29
+ permissions;
30
+ constructor(permissions) {
31
+ this.permissions = permissions;
32
+ }
33
+ /** Every install record with its shadow decision, grants and shadow placements. */
34
+ inventory() {
35
+ return this.permissions.inventory();
36
+ }
37
+ /**
38
+ * The permission review of the install's current revision. Not installed -> 404
39
+ * `extension.not_found`; digest not recorded yet or package unreadable -> 409
40
+ * `extension.permission_review_unavailable`.
41
+ */
42
+ review(name) {
43
+ return this.permissions.review(name);
44
+ }
45
+ /**
46
+ * A person approves that review (a human security consent: no Platform operation): the revision
47
+ * grant and the legacy approval in one transaction. Another revision or review -> 409
48
+ * `extension.permission_review_stale`; a wrong full-access acknowledgement -> 409
49
+ * `plugin.full_access_ack_invalid`; a missing one -> 200 with the grant skipped (until 1.5a).
50
+ */
51
+ approve(principal, name, body) {
52
+ const actor = requireUser(principal);
53
+ return this.permissions.approve(actor.account.id, name, body, actorOpts(actor));
54
+ }
55
+ /**
56
+ * Revokes keys of a revision's live grant, or the whole grant. Unknown or unrevocable keys -> 409
57
+ * `extension.permission_keys_unknown`; no live grant -> 404
58
+ * `extension.permission_grant_not_found`.
59
+ */
60
+ revoke(principal, name, body) {
61
+ const actor = requireUser(principal);
62
+ return this.permissions.revoke(actor.account.id, name, body, actorOpts(actor));
63
+ }
64
+ /** The isolation status: `not_configured`, or each live replica's supervisor checks. */
65
+ isolation() {
66
+ return this.permissions.isolationStatus();
67
+ }
68
+ };
69
+ __decorate([
70
+ Get("extension-permissions")
71
+ ], ExtensionPermissionsController.prototype, "inventory", null);
72
+ __decorate([
73
+ Get("extension-permissions/:name/review"),
74
+ __param(0, Param("name"))
75
+ ], ExtensionPermissionsController.prototype, "review", null);
76
+ __decorate([
77
+ Post("extension-permissions/:name/approve"),
78
+ HttpCode(200),
79
+ __param(0, CurrentPrincipal()),
80
+ __param(1, Param("name")),
81
+ __param(2, ZBody(PermissionApproveBodyDto))
82
+ ], ExtensionPermissionsController.prototype, "approve", null);
83
+ __decorate([
84
+ Post("extension-permissions/:name/revoke"),
85
+ HttpCode(200),
86
+ __param(0, CurrentPrincipal()),
87
+ __param(1, Param("name")),
88
+ __param(2, ZBody(PermissionRevokeBodyDto))
89
+ ], ExtensionPermissionsController.prototype, "revoke", null);
90
+ __decorate([
91
+ Get("extension-isolation")
92
+ ], ExtensionPermissionsController.prototype, "isolation", null);
93
+ ExtensionPermissionsController = __decorate([
94
+ Controller("api/v1/admin"),
95
+ SuperAdmin(),
96
+ __param(0, Inject(ExtensionPermissions))
97
+ ], ExtensionPermissionsController);
98
+ export { ExtensionPermissionsController };
@@ -0,0 +1,288 @@
1
+ import { z } from "zod";
2
+ import type { PrivateEndpointGap } from "../net/private-endpoint-preflight.js";
3
+ import type { RouteSchemas } from "../platform/route-schemas.js";
4
+ import type { ExecutionDecision } from "./execution-realm.js";
5
+ import type { ShadowPlacement } from "./isolated/tier.js";
6
+ import type { ReviewDisplay } from "./review-hash.js";
7
+ import type { ShadowGrantStatus, ShadowRevisionDecision } from "./revision-approvals.js";
8
+ import type { ApprovalScope, ExecutionRealm, GrantAuthority, GrantSource, PublisherEvidence, RevisionGrantState } from "./revision-grants.js";
9
+ import type { RevisionReview } from "./revision-review.js";
10
+ /**
11
+ * The shared schemas of the extension permission routes (extension permission model spec,
12
+ * "Review, updates and provenance", "Revocation, audit and people"; plan tasks 1.4a and 1.4j).
13
+ * Requests are zod schemas, used by the controller and by the Platform operations (the parity
14
+ * test compares them); responses are the exported view types. The web (1.4d / 1.4e / 1.4k) and
15
+ * the CLI (1.4f) build against both.
16
+ *
17
+ * Routes (all super admin):
18
+ * - `GET /api/v1/admin/extension-permissions`: the inventory, one {@link PermissionInventoryEntry}
19
+ * per install record ({@link PermissionInventory}).
20
+ * - `GET /api/v1/admin/extension-permissions/:name/review`: the permission review of the
21
+ * install's current revision ({@link PermissionReviewView}). Its Platform operation returns a
22
+ * handoff link card to the web confirm page.
23
+ * - `POST /api/v1/admin/extension-permissions/:name/approve`: a person confirms that review
24
+ * ({@link PermissionApproveBody}), full access included with one acknowledgement per realm. It
25
+ * is a `human security consent` exclusion of the Platform tool and is refused unattended. Returns
26
+ * {@link PermissionApproveResult}.
27
+ * - `POST /api/v1/admin/extension-permissions/:name/revoke`: revokes keys of a revision's grant,
28
+ * or the whole grant ({@link PermissionRevokeBody}); revocation only narrows, so the Platform
29
+ * tool may do it. Returns {@link PermissionRevokeResult}.
30
+ * - `GET /api/v1/admin/extension-isolation`: the isolation status ({@link IsolationStatus}).
31
+ *
32
+ * The catalog import and import-and-update confirms take the same
33
+ * {@link FullAccessAcknowledgementBody} (`catalog/admin-catalog.schemas.ts`).
34
+ */
35
+ /** An extension name as the routes take it (`@Param`). */
36
+ export declare const PermissionNamePathParams: z.ZodObject<{
37
+ name: z.ZodString;
38
+ }, z.core.$strip>;
39
+ /** One exact revision of the named extension: its version and the archive's lowercase sha512. */
40
+ export declare const PermissionRevisionBody: z.ZodObject<{
41
+ version: z.ZodString;
42
+ sha512: z.ZodString;
43
+ }, z.core.$strict>;
44
+ /**
45
+ * One explicit acknowledgement per realm whose full access a permission review confers, bound to
46
+ * that review's hash (plan task 1.3d): `reviewHash` is the review's `hash`, `realms` exactly its
47
+ * `acknowledge`. A wrong one is refused (409 `plugin.full_access_ack_invalid`).
48
+ */
49
+ export declare const FullAccessAcknowledgementBody: z.ZodObject<{
50
+ reviewHash: z.ZodString;
51
+ realms: z.ZodArray<z.ZodEnum<{
52
+ browser: "browser";
53
+ device: "device";
54
+ server: "server";
55
+ }>>;
56
+ }, z.core.$strict>;
57
+ /**
58
+ * `POST …/:name/approve`: confirms the review `GET …/:name/review` returned for `revision`. The
59
+ * install must still run that revision and the review must still hash to `reviewHash` (else 409
60
+ * `extension.permission_review_stale`). A review that confers full access records its revision
61
+ * grant only with `fullAccessAcknowledgement` naming exactly its realms: a wrong one is refused
62
+ * (409 `plugin.full_access_ack_invalid`), a missing one returns 200 with the grant `skipped`
63
+ * (shadow mode; refused from plan task 1.5a). The legacy approval is written either way until 1.5a.
64
+ */
65
+ export declare const PermissionApproveBody: z.ZodObject<{
66
+ revision: z.ZodObject<{
67
+ version: z.ZodString;
68
+ sha512: z.ZodString;
69
+ }, z.core.$strict>;
70
+ reviewHash: z.ZodString;
71
+ fullAccessAcknowledgement: z.ZodOptional<z.ZodObject<{
72
+ reviewHash: z.ZodString;
73
+ realms: z.ZodArray<z.ZodEnum<{
74
+ browser: "browser";
75
+ device: "device";
76
+ server: "server";
77
+ }>>;
78
+ }, z.core.$strict>>;
79
+ }, z.core.$strict>;
80
+ /**
81
+ * `POST …/:name/revoke`: revokes `keys` of the revision's live grant (a realm's full access is its
82
+ * `execution.full-access:<realm>` key), or the whole grant without `keys`. Unknown or unrevocable
83
+ * keys -> 409 `extension.permission_keys_unknown`; no live grant -> 404
84
+ * `extension.permission_grant_not_found`.
85
+ */
86
+ export declare const PermissionRevokeBody: z.ZodObject<{
87
+ revision: z.ZodObject<{
88
+ version: z.ZodString;
89
+ sha512: z.ZodString;
90
+ }, z.core.$strict>;
91
+ keys: z.ZodOptional<z.ZodArray<z.ZodString>>;
92
+ reason: z.ZodOptional<z.ZodString>;
93
+ }, z.core.$strict>;
94
+ export declare const PERMISSION_ROUTES: readonly RouteSchemas[];
95
+ /** One exact revision. */
96
+ export interface PermissionRevision {
97
+ version: string;
98
+ /** Lowercase hex sha512 of the archive; null while the package backfill has not recorded it. */
99
+ sha512: string | null;
100
+ }
101
+ /** A revision grant as the inventory shows it (no purposes: the review shows those). */
102
+ export interface PermissionGrantSummary {
103
+ generation: number;
104
+ state: RevisionGrantState;
105
+ source: GrantSource;
106
+ authority: GrantAuthority;
107
+ publisherEvidence: PublisherEvidence;
108
+ approvalScope: {
109
+ mode: ApprovalScope["mode"];
110
+ orgs: string[];
111
+ };
112
+ /** Full-access realms and their forcing keys, net of revocation and retirement. */
113
+ realms: Partial<Record<ExecutionRealm, string[]>>;
114
+ /** Keys still serving. */
115
+ serving: string[];
116
+ /** Keys revoked or retired (every key once the grant is revoked): the Partially revoked rows. */
117
+ withdrawn: string[];
118
+ reviewHash: string;
119
+ approvedBy: string | null;
120
+ approvedAt: string;
121
+ }
122
+ /** Where one replica would place the revision on its last convergence (1.3b, shadow). */
123
+ export interface PermissionShadowExecution {
124
+ replicaId: string;
125
+ /** The revision that replica placed (it may still be converging to the installed one). */
126
+ version: string;
127
+ host: "available" | "not_configured" | "failing";
128
+ decision: Pick<ExecutionDecision, "kind" | "fullAccess" | "unknownKeys" | "confirmable">;
129
+ uncovered: Partial<Record<ExecutionRealm, string[]>>;
130
+ would: ShadowPlacement;
131
+ diverges: boolean;
132
+ hostReasonRetired: boolean;
133
+ }
134
+ /** One install record in the inventory. */
135
+ export interface PermissionInventoryEntry {
136
+ plugin: string;
137
+ /** The installed revision. */
138
+ revision: PermissionRevision;
139
+ /**
140
+ * `catalog`, `npm`, `file` or `bootstrap` (install records only: a config-declared extension's
141
+ * revision is reviewed by the bootstrap review, plan task 1.3c).
142
+ */
143
+ source: string;
144
+ catalogItemId: string | null;
145
+ required: boolean;
146
+ /** The shadow decision of the installed revision (status, keys, would serve). */
147
+ status: ShadowGrantStatus;
148
+ decision: ShadowRevisionDecision;
149
+ /** The installed revision's own grant (any state), if it ever had one. */
150
+ grant: PermissionGrantSummary | null;
151
+ /** The install's approved revision when it is another one (an upgrade waiting for review). */
152
+ approved: (PermissionRevision & {
153
+ generation: number;
154
+ }) | null;
155
+ /** The install's candidate revision, waiting for review. */
156
+ candidate: PermissionRevision | null;
157
+ /** Per live replica, the shadow placement of its last convergence (empty until it ran). */
158
+ executions: PermissionShadowExecution[];
159
+ }
160
+ export interface PermissionInventory {
161
+ entries: PermissionInventoryEntry[];
162
+ /** Required installs the enforcing start gate (1.5a) would refuse. */
163
+ missingRequired: string[];
164
+ }
165
+ /** `GET …/:name/review`. */
166
+ export interface PermissionReviewView {
167
+ plugin: string;
168
+ revision: {
169
+ version: string;
170
+ sha512: string;
171
+ };
172
+ /** The review of that revision: display, hash, consent, realms to acknowledge, block. */
173
+ review: Pick<RevisionReview, "hash" | "consent" | "acknowledge" | "blocked"> & {
174
+ display: ReviewDisplay;
175
+ };
176
+ /** The web confirm page for this review (what the Platform operation's handoff opens). */
177
+ confirmUrl: string;
178
+ /** Manifest paths and sizes of the client files in the exact revision being reviewed. */
179
+ clientFiles?: {
180
+ path: string;
181
+ size: number;
182
+ }[];
183
+ /**
184
+ * The deployment's isolation state now (`GET /api/v1/admin/extension-isolation`'s `state`): the
185
+ * review binds only whether the supervisor is configured, so show this beside it (a revision
186
+ * that runs isolated is unavailable while the supervisor fails).
187
+ */
188
+ isolation: "not_configured" | "available" | "failing" | "unknown";
189
+ }
190
+ /** `POST …/:name/approve`. */
191
+ export interface PermissionApproveResult {
192
+ plugin: string;
193
+ revision: {
194
+ version: string;
195
+ sha512: string;
196
+ };
197
+ /** What happened to the revision grant (the legacy approval is written either way until 1.5a). */
198
+ grant: {
199
+ status: "granted" | "kept";
200
+ generation: number;
201
+ } | {
202
+ status: "continued";
203
+ generation: number;
204
+ fullAccess: ExecutionRealm[];
205
+ } | {
206
+ status: "skipped";
207
+ reason: string;
208
+ };
209
+ }
210
+ /** `POST …/:name/revoke`. */
211
+ export interface PermissionRevokeResult {
212
+ plugin: string;
213
+ revision: {
214
+ version: string;
215
+ sha512: string;
216
+ };
217
+ grant: PermissionGrantSummary;
218
+ /** Keys this revocation withdrew. */
219
+ withdrawn: string[];
220
+ /** Per full-access realm revoked, where the revision goes next once revocation is enforced. */
221
+ fullAccess: {
222
+ realm: ExecutionRealm;
223
+ next: "isolated" | "pending_approval";
224
+ }[];
225
+ /**
226
+ * Whether revocation already changes what runs: false in shadow mode until the enforcing
227
+ * cutover (plan task 1.5a), when the legacy approval still governs admission and the extension
228
+ * keeps running as before; disable it to stop it now.
229
+ */
230
+ enforced: boolean;
231
+ }
232
+ /** A supervisor check that can fail, in the order the kernel runs them. */
233
+ export type IsolationCheck = "guard_reachability" | "engine_runtime" | "image" | "postgres_socket";
234
+ /** One live replica's supervisor readiness, as its last probe saw it. */
235
+ export interface ReplicaIsolation {
236
+ replicaId: string;
237
+ /** `not_configured`: this replica runs without the supervisor (a mixed configuration). */
238
+ state: "available" | "failing" | "not_configured";
239
+ /** The first check that failed (`failing` only); `message` is the kernel's English text. */
240
+ failedCheck: IsolationCheck | null;
241
+ message: string | null;
242
+ /** When its last probe ran; null when not configured. */
243
+ probedAt: string | null;
244
+ }
245
+ /** A plugin a failing supervisor keeps from running (it would run isolated). */
246
+ export interface IsolationPausedPlugin {
247
+ plugin: string;
248
+ version: string;
249
+ /** The replicas where it is paused. */
250
+ replicas: string[];
251
+ }
252
+ /**
253
+ * `GET /api/v1/admin/extension-isolation`. Not configured: only the state, the kernel probes
254
+ * nothing. Configured: `available` when every live replica's supervisor passed its checks,
255
+ * `failing` when any did not (`replicas` says which check), `unknown` before any replica probed.
256
+ */
257
+ export type IsolationStatus = {
258
+ state: "not_configured";
259
+ } | {
260
+ state: "available" | "failing" | "unknown";
261
+ replicas: ReplicaIsolation[];
262
+ paused: IsolationPausedPlugin[];
263
+ /** Platform endpoints `ctx.net` would not admit for isolated plugins (#1459). */
264
+ privateEndpointGaps: PrivateEndpointGap[];
265
+ };
266
+ /**
267
+ * The org-facing disclosure of an optional full-access plugin (spec "Review, updates and
268
+ * provenance" step 3; the 1.4f org page), on the org catalog item read: shown to the org's admins
269
+ * when the plugin's approved revision runs with full access, null otherwise (and always null for
270
+ * other members). No secrets, no other org's data, no deployment internals beyond the realms and
271
+ * why they need full access.
272
+ */
273
+ export interface FullAccessDisclosure {
274
+ approvedRevision: {
275
+ version: string;
276
+ };
277
+ realms: ExecutionRealm[];
278
+ /**
279
+ * Why full access is needed, by class: `host_no_isolation` (the deployment runs without the
280
+ * isolation supervisor), `provider_contract` (an extension point without an isolated form yet),
281
+ * `client_code` (code in the app page), `device_host` (a service outside the device sandbox),
282
+ * `declared` (a declared capability that only runs with the kernel's privileges).
283
+ */
284
+ reasons: FullAccessReason[];
285
+ approverAuthority: GrantAuthority;
286
+ approvedAt: string;
287
+ }
288
+ export type FullAccessReason = "host_no_isolation" | "provider_contract" | "client_code" | "device_host" | "declared";
@@ -0,0 +1,96 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The shared schemas of the extension permission routes (extension permission model spec,
4
+ * "Review, updates and provenance", "Revocation, audit and people"; plan tasks 1.4a and 1.4j).
5
+ * Requests are zod schemas, used by the controller and by the Platform operations (the parity
6
+ * test compares them); responses are the exported view types. The web (1.4d / 1.4e / 1.4k) and
7
+ * the CLI (1.4f) build against both.
8
+ *
9
+ * Routes (all super admin):
10
+ * - `GET /api/v1/admin/extension-permissions`: the inventory, one {@link PermissionInventoryEntry}
11
+ * per install record ({@link PermissionInventory}).
12
+ * - `GET /api/v1/admin/extension-permissions/:name/review`: the permission review of the
13
+ * install's current revision ({@link PermissionReviewView}). Its Platform operation returns a
14
+ * handoff link card to the web confirm page.
15
+ * - `POST /api/v1/admin/extension-permissions/:name/approve`: a person confirms that review
16
+ * ({@link PermissionApproveBody}), full access included with one acknowledgement per realm. It
17
+ * is a `human security consent` exclusion of the Platform tool and is refused unattended. Returns
18
+ * {@link PermissionApproveResult}.
19
+ * - `POST /api/v1/admin/extension-permissions/:name/revoke`: revokes keys of a revision's grant,
20
+ * or the whole grant ({@link PermissionRevokeBody}); revocation only narrows, so the Platform
21
+ * tool may do it. Returns {@link PermissionRevokeResult}.
22
+ * - `GET /api/v1/admin/extension-isolation`: the isolation status ({@link IsolationStatus}).
23
+ *
24
+ * The catalog import and import-and-update confirms take the same
25
+ * {@link FullAccessAcknowledgementBody} (`catalog/admin-catalog.schemas.ts`).
26
+ */
27
+ /** An extension name as the routes take it (`@Param`). */
28
+ export const PermissionNamePathParams = z.object({ name: z.string().min(1).max(64) });
29
+ const Realm = z.enum(["server", "browser", "device"]);
30
+ /** `review:v1:<sha256 hex>`, the hash of a revision's permission review (1.2e). */
31
+ const ReviewHash = z.string().regex(/^review:v1:[0-9a-f]{64}$/);
32
+ /** One exact revision of the named extension: its version and the archive's lowercase sha512. */
33
+ export const PermissionRevisionBody = z
34
+ .object({
35
+ version: z.string().min(1).max(256),
36
+ sha512: z.string().regex(/^[0-9a-f]{128}$/),
37
+ })
38
+ .strict();
39
+ /**
40
+ * One explicit acknowledgement per realm whose full access a permission review confers, bound to
41
+ * that review's hash (plan task 1.3d): `reviewHash` is the review's `hash`, `realms` exactly its
42
+ * `acknowledge`. A wrong one is refused (409 `plugin.full_access_ack_invalid`).
43
+ */
44
+ export const FullAccessAcknowledgementBody = z
45
+ .object({
46
+ reviewHash: z.string().min(1).max(128),
47
+ realms: z.array(Realm).max(3),
48
+ })
49
+ .strict();
50
+ /**
51
+ * `POST …/:name/approve`: confirms the review `GET …/:name/review` returned for `revision`. The
52
+ * install must still run that revision and the review must still hash to `reviewHash` (else 409
53
+ * `extension.permission_review_stale`). A review that confers full access records its revision
54
+ * grant only with `fullAccessAcknowledgement` naming exactly its realms: a wrong one is refused
55
+ * (409 `plugin.full_access_ack_invalid`), a missing one returns 200 with the grant `skipped`
56
+ * (shadow mode; refused from plan task 1.5a). The legacy approval is written either way until 1.5a.
57
+ */
58
+ export const PermissionApproveBody = z
59
+ .object({
60
+ revision: PermissionRevisionBody,
61
+ reviewHash: ReviewHash,
62
+ fullAccessAcknowledgement: FullAccessAcknowledgementBody.optional(),
63
+ })
64
+ .strict();
65
+ /**
66
+ * `POST …/:name/revoke`: revokes `keys` of the revision's live grant (a realm's full access is its
67
+ * `execution.full-access:<realm>` key), or the whole grant without `keys`. Unknown or unrevocable
68
+ * keys -> 409 `extension.permission_keys_unknown`; no live grant -> 404
69
+ * `extension.permission_grant_not_found`.
70
+ */
71
+ export const PermissionRevokeBody = z
72
+ .object({
73
+ revision: PermissionRevisionBody,
74
+ keys: z.array(z.string().min(1).max(512)).min(1).max(200).optional(),
75
+ /** Shown in the audit. */
76
+ reason: z.string().min(1).max(500).optional(),
77
+ })
78
+ .strict();
79
+ export const PERMISSION_ROUTES = [
80
+ { route: "GET /api/v1/admin/extension-permissions" },
81
+ {
82
+ route: "GET /api/v1/admin/extension-permissions/:name/review",
83
+ params: PermissionNamePathParams,
84
+ },
85
+ {
86
+ route: "POST /api/v1/admin/extension-permissions/:name/approve",
87
+ params: PermissionNamePathParams,
88
+ body: PermissionApproveBody,
89
+ },
90
+ {
91
+ route: "POST /api/v1/admin/extension-permissions/:name/revoke",
92
+ params: PermissionNamePathParams,
93
+ body: PermissionRevokeBody,
94
+ },
95
+ { route: "GET /api/v1/admin/extension-isolation" },
96
+ ];